Patch for 2.1.122 super.c [was: autofs bug report]

Bill Hawes (whawes@transmeta.com)
Thu, 24 Sep 1998 18:21:59 -0700


This is a multi-part message in MIME format.
--------------FE545CADCB3CC84ADF4BC698
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Slava wrote:

> There is a bug in autofs 3.1.1 with linux 2.1.122. If you manually mount
> a
> filesystem onto it's mount point as specified in the automount map, it
> hangs.
> For example, if I have this in my /etc/auto.vol:
> floppy -fstype=vfat,user :/dev/fd0
> And do a mount /dev/fd0 /vol/floppy, I get this in my process list:
> 100 0 483 481 15 0 852 288 down_failed D ? 0:00
> mount
> -- this is the mount spawned by automount.
> 100 0 480 76 9 0 856 292 end S 1 0:00
> mount
> -- this is the manually spawned mount.
> What is probably happening is the first mount is locking /dev/fd0, and
> the
> second attempts to access it. It waits for the first one, which won't
> exit
> until the second one is done.

What happens here is that do_mount grabs the mount semaphore before doing a
lookup on the mount point directory. So when autofs sees the lookup and tells
the automounter to mount the directory, it can't get the semaphore and
everything stops.

We shouldn't need to get the semaphore before doing the lookup, as the lookup
will be valid in any case. I've made a minor change to reorder the
operations, and with this change the attempt to mount something
over the automount point fails cleanly. (The mount point becomes busy once
the automounter mounts it.)

Please give the attached patch a try and see if this takes care of the
problem for you. (The exact behavior may depend on the version of /bin/mount
as well, as mount attempts to lock the mtab file. I'm using 2.8a)

Regards,
Bill

--------------FE545CADCB3CC84ADF4BC698
Content-Type: text/plain; charset=us-ascii; name="super_122-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="super_122-patch"

--- linux-2.1.122/fs/super.c.old Wed Sep 23 11:42:44 1998
+++ linux-2.1.122/fs/super.c Thu Sep 24 14:06:52 1998
@@ -868,17 +907,20 @@
struct vfsmount *vfsmnt;
int error;

- down(&mount_sem);
error = -EACCES;
if (!(flags & MS_RDONLY) && dev && is_read_only(dev))
goto out;
- /*flags |= MS_RDONLY;*/

+ /*
+ * Do the lookup first to force automounting.
+ */
+printk("do_mount: pid %d looking up %s\n", current->pid, dir_name);
dir_d = namei(dir_name);
error = PTR_ERR(dir_d);
if (IS_ERR(dir_d))
goto out;

+ down(&mount_sem);
error = -ENOTDIR;
if (!S_ISDIR(dir_d->d_inode->i_mode))
goto dput_and_out;
@@ -911,13 +953,14 @@
d_mount(dir_d, sb->s_root);
error = 0; /* we don't dput(dir_d) - see umount */

-out:
+out_unlock:
up(&mount_sem);
+out:
return error;

dput_and_out:
dput(dir_d);
- goto out;
+ goto out_unlock;
}


--------------FE545CADCB3CC84ADF4BC698--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/