autofs and smb shares
Quoted 2 lines
Quoted 2 lines
If I do an ls it just give me a "ls: testdir: Invalid slot" until I
manually
Quoted 5 lines
Quoted 2 lines
umount the share. ( I'm able to umount the share manually without forcing and without any error )
Is the mount point busy or not?
If it's not then autofs should umount it after the timeout.
That's the point.
When the mount point is NOT busy, it wont umount it after timeout.
I've looked the source code ( I'm not a C expert ) and I think the problem is in the way it checks the mount point after the timeout.
Before umount the timed out mount point, it do a lstat, but it fails if the shared dir is unavailable.
That way it doesn't even to try to umount the directory.
Fast way to test it :
Create a shared dir somewhere
Configure autofs
Enter in the directory so that autofs will mount it
Exit from that directory
Before timeout expires, unshare the dir
When the timeout expires, it wont umount the directory, nor remount it when it became available again. You have to manually umount it, before be able to autofs-mount it again.
I've solved the problem ( I hope ) just forcing the umount when the fstat fails cause of errno like EBADSLT ( that's what I got when the share is not more available ).
Maybe it's safe to umount the dir without doing a fstat at all.
Amodiovalerio [Hypo] Verde
Ian Kent
maintainerQuoted 4 lines · Amodiovalerio [Hypo] Verde
I've solved the problem ( I hope ) just forcing the umount when the fstat fails cause of errno like EBADSLT ( that's what I got when the share is not more available ).
I don't see the EBADSLT here. I see an EIO.
Quoted 2 lines
Maybe it's safe to umount the dir without doing a fstat at all.
Don't like that much. The lstat probably causes smbfs to return EIO instead of EBADSLT.
If you are keen, please try this patch and let me know how you go.
Ian
daemon/automount.c +27 -10
@@ -135,21 +135,31 @@return 0 ; } -static int umount_ent (const char *root,const char *name) +static int umount_ent (const char *root,const char *name,const char *type) {char path_buf[PATH_MAX ];struct stat st; +int sav_errno; +int is_smbfs = (strcmp (type,"smbfs" ) ==0 ); +int status;int rv =0 ;sprintf (path_buf,"%s/%s" , root, name); -if (!lstat (path_buf, &st)) { -if (S_ISDIR (st.st_mode)) { -if (st.st_dev != ap.dev) { -wait_for_lock (); - rv =spawnl (LOG_DEBUG ,MOUNTED_LOCK ,PATH_UMOUNT , -PATH_UMOUNT , path_buf,NULL ); -unlink (AUTOFS_LOCK ); - } + status =lstat (path_buf, &st); + sav_errno = errno; + +/* EIO appears to correspond to an smb mount that has gone away */ +if (!status || (is_smbfs && sav_errno ==EIO )) { +int umount_ok =0 ; + +if (!status && (S_ISDIR (st.st_mode) && (st.st_dev != ap.dev))) + umount_ok =1 ; + +if (umount_ok || is_smbfs) { +wait_for_lock (); + rv =spawnl (LOG_DEBUG ,MOUNTED_LOCK , +PATH_UMOUNT ,PATH_UMOUNT , path_buf,NULL ); +unlink (AUTOFS_LOCK ); } }return rv;
@@ -234,6 +244,7 @@FILE *mtab;struct mntlist {const char *path; +const char *fs_type;struct mntlist *next; } *mntlist =NULL , *mptr;size_t pathlen =strlen (path);
@@ -268,9 +279,15 @@break ; m =alloca (sizeof (*m)); + p =alloca (len +1 );strcpy (p, mnt->mnt_dir); m->path = p; + + p =alloca (strlen (mnt->mnt_type) +1 ); +strcpy (p, mnt->mnt_type); + m->fs_type = p; + m->next = *prev; *prev = m; }
@@ -281,7 +298,7 @@ left =0 ;for (mptr = mntlist; mptr !=NULL ; mptr = mptr->next) {debug ("umount_multi: unmounting dir=%s\n" , mptr->path); -if (umount_ent ("" , mptr->path)) { +if (umount_ent ("" , mptr->path, mptr->fs_type)) { left++; } }
I applied the patch, but it doesn't work.
I confirm that there is a EBADSLT here. When I disable the share I got ( and I also check via errno )
"ls: .: Invalid slot"
Tried to change
if (!status || (is_smbfs && sav_errno == EIO )) {
with
if (!status || (is_smbfs && ( sav_errno == EIO || sav_errno == EBADSLT ) ))
{
and it works.
Amodiovalerio [Hypo] Verde
Quoted 1 line
Quoted 1 line
I've solved the problem ( I hope ) just forcing the umount when the
fstat
Quoted 1 line
Quoted 1 line
fails cause of errno like EBADSLT ( that's what I got when the share is
not
Quoted 13 lines
Quoted 1 line
more available ).
I don't see the EBADSLT here. I see an EIO.
Quoted 2 lines
Maybe it's safe to umount the dir without doing a fstat at all.
Don't like that much. The lstat probably causes smbfs to return EIO instead of EBADSLT.
If you are keen, please try this patch and let me know how you go.
Ian
Ian Kent
maintainerQuoted 9 lines · Amodiovalerio [Hypo] Verde
I applied the patch, but it doesn't work.
I confirm that there is a EBADSLT here. When I disable the share I got ( and I also check via errno )
"ls: .: Invalid slot"
Tried to change
Quoted 8 lines
if (!status || (
is_smbfs&&sav_errno== EIO )) {with
if (!status || (
is_smbfs&& (sav_errno== EIO ||sav_errno== EBADSLT ) ))
{and it works.
OK I'll add that. Must be related to the version of kernel or the smb mount.
I must say that my testing showed some problems when I tried to break it so lets keep an eye on it.
Ian