Skip to contentSkip to conversation

Kernel patch to better support bind-mounts

PATCH Lukas Kolbe 3 participants 11 messages Jan 8, 2008 – Mar 5, 2008 Kernel automounter

lore
Share & tools
lore
#0 lore raw

Hi!

Ian, you made a patch for our problem here late laste year that didn't quite work for all of our cases. I don't really understand the code in the kernel module, but logic tells me that this patch should be safe. Plus, it's solving our problems and is straightforward. Your patch was:

fs/autofs4/root.c 2007-10-11 16:34:59.000000000 +0800 renamed from fs/autofs4/root.c.lookup_access-intent 2007-10-11 16:32:07.000000000 +0800 +3 -1
diff -up linux-2.6.21/fs/autofs4/root.c.lookup_access-intent linux-2.6.21/fs/autofs4/root.c
@@ -20,6 +20,8 @@
 #include <linux/smp_lock.h>
 #include "autofs_i.h"
 
+#define DIRECT_TRIGGER_FLAGS (LOOKUP_CONTINUE|LOOKUP_DIRECTORY|LOOKUP_ACCESS)
+
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -336,7 +338,7 @@ static void *autofs4_follow_link(struct 
                nd->flags);
 
        /* If it's our master or we shouldn't trigger a mount we're done */
-       lookup_type = nd->flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY);
+       lookup_type = nd->flags & DIRECT_TRIGGER_FLAGS;
        if (oz_mode || !lookup_type)
                goto done;
 

This helps for a map like this:

eclipse-3.1 \
/bin -rw,nosuid,grpid fileserver:/volumes/vol1/eclipse-3.1/bin.linx86
eclipse \
/bin -rw,nosuid,grpid :/vol/eclipse-3.1/bin

Accessing /vol/eclipse/bin now works flawlessly. But given this map:

jdk-1.5.13 -rw,nosuid,grpid fileserver:/export/stud/vol/jdk-1.5.13/linx86
jdk-1.5 -rw,nosuid,grpid :/vol/jdk-1.5.13

accessing /vol/jdk-1.5 doesn't work always (ie only when /vol/jdk-1.5.13 was accessed first). I changed the patch to the one below, and this problem is now also fixed.

Ian, can you comment on the sanity of this one? If it's OK, I'd like to see it pushed upstream. We're building our own kernel anyway now (had known large-scale linux was so damn difficult I bet I wouldn't have started in the first plate), but it would be nice to see upstream.

Signature · 33 lines
Lukas


diff -ru linux-2.6-2.6.23-a/fs/autofs4/root.c linux-2.6-2.6.23/fs/autofs4/root.c
--- linux-2.6-2.6.23-a/fs/autofs4/root.c        2007-11-30 16:20:33.000000000 +0100
+++ linux-2.6-2.6.23/fs/autofs4/root.c  2007-11-30 16:22:24.000000000 +0100
@@ -19,6 +19,9 @@
 #include <linux/time.h>
 #include "autofs_i.h"

+#define DIRECT_TRIGGER_FLAGS (LOOKUP_CONTINUE|LOOKUP_DIRECTORY|LOOKUP_ACCESS)
+
+
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -291,7 +294,7 @@
                        return status;
                }
        /* Trigger mount for path component or follow link */
-       } else if (flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY) ||
+       } else if (flags & DIRECT_TRIGGER_FLAGS ||
                        current->link_count) {
                DPRINTK("waiting for mount name=%.*s",
                        dentry->d_name.len, dentry->d_name.name);
@@ -335,7 +338,7 @@
                nd->flags);

        /* If it's our master or we shouldn't trigger a mount we're done */
-       lookup_type = nd->flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY);
+       lookup_type = nd->flags & DIRECT_TRIGGER_FLAGS;
        if (oz_mode || !lookup_type)
                goto done;
maintainer
#1 lore raw
Quoted 6 lines · Lukas Kolbe

Hi!

Ian, you made a patch for our problem here late laste year that didn't quite work for all of our cases. I don't really understand the code in the kernel module, but logic tells me that this patch should be safe. Plus, it's solving our problems and is straightforward. Your patch was:

Sure, but you'll need to give me a while to re-familiarize myself with the history and think about it for a while.

The only real issue here is the question of whether we will trigger mounts when they shouldn't be. Which can lead to mount storms in unexpected ways, but then I seem to remember that this change was needed due to changes in the way the kernel does it's lookups.

Quoted 23 lines

diff -up linux-2.6.21/fs/autofs4/root.c.lookup_access-intent linux-2.6.21/fs/autofs4/root.c

fs/autofs4/root.c 2007-10-11 16:34:59.000000000 +0800 renamed from fs/autofs4/root.c.lookup_access-intent 2007-10-11 16:32:07.000000000 +0800 +3 -1
@@ -20,6 +20,8 @@
 #include <linux/smp_lock.h>
 #include "autofs_i.h"
 
+#define DIRECT_TRIGGER_FLAGS (LOOKUP_CONTINUE|LOOKUP_DIRECTORY|LOOKUP_ACCESS)
+
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -336,7 +338,7 @@ static void *autofs4_follow_link(struct 
                nd->flags);
 
        /* If it's our master or we shouldn't trigger a mount we're done */
-       lookup_type = nd->flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY);
+       lookup_type = nd->flags & DIRECT_TRIGGER_FLAGS;
        if (oz_mode || !lookup_type)
                goto done;
 
Quoted 6 lines

This helps for a map like this:

eclipse-3.1 \
/bin -rw,nosuid,grpid fileserver:/volumes/vol1/eclipse-3.1/bin.linx86
eclipse \
/bin -rw,nosuid,grpid :/vol/eclipse-3.1/bin

Mounts for these multiple offsets are triggered in the same way as direct mounts, they are triggered when autofs4_follow_link is called by the VFS.

Quoted 5 lines

Accessing /vol/eclipse/bin now works flawlessly. But given this map:

jdk-1.5.13 -rw,nosuid,grpid fileserver:/export/stud/vol/jdk-1.5.13/linx86
jdk-1.5 -rw,nosuid,grpid :/vol/jdk-1.5.13

But these are indirect mounts and they are triggered by calling either autofs4_lookup or autofs4_revalidate and then indirectly try_to_fill_dentry, which is where you added the change I think.

What kernel version is this patch against?

Ian

#2 lore raw

Hi Ian!

Quoted 2 lines

Sure, but you'll need to give me a while to re-familiarize myself with the history and think about it for a while.

Of course. This patch was sitting here since before christmas and I only now came around actually talking about it, so no stress with that :)

Quoted 10 lines
Quoted 4 lines

eclipse-3.1 \
/bin -rw,nosuid,grpid fileserver:/volumes/vol1/eclipse-3.1/bin.linx86
eclipse \
/bin -rw,nosuid,grpid :/vol/eclipse-3.1/bin

Mounts for these multiple offsets are triggered in the same way as direct mounts, they are triggered when autofs4_follow_link is called by the VFS.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

Accessing /vol/eclipse/bin now works flawlessly. But given this map:

jdk-1.5.13 -rw,nosuid,grpid fileserver:/export/stud/vol/jdk-1.5.13/linx86
jdk-1.5 -rw,nosuid,grpid :/vol/jdk-1.5.13

But these are indirect mounts and they are triggered by calling either autofs4_lookup or autofs4_revalidate and then indirectly try_to_fill_dentry, which is where you added the change I think.

Ok, thanks, then I understand a bit better what's actually happening there.

Quoted 1 line

What kernel version is this patch against?

I tested it (IIRC) against 2.6.18 (from debian) and 2.6.23 (from kernel.org git) - autofs-code doesn't seem to have changed much.

Quoted 1 line

Ian

Signature · 1 line
Lukas
maintainer
#3 lore raw
Quoted 4 lines · Lukas Kolbe
Quoted 1 line

What kernel version is this patch against?

I tested it (IIRC) against 2.6.18 (from debian) and 2.6.23 (from kernel.org git) - autofs-code doesn't seem to have changed much.

True, just a couple of bug fixes, I'll look again at the kernel bits the patch relates to as well.

Ian

#4 lore raw
In reply to Lukas Kolbe

Hi Ian!

Ping? :)

We use this patch now for several servers and clients (debian etch with 2.6.18, ubuntu feisty with 2.6.20 and some test systems with 2.6.23), and have seen no regression so far, only working automounts :) I'd love to see this change upstream, so that I don't have to worry about constantly patching my own kernel anymore :)

Signature · 33 lines
Lukas


diff -ru linux-2.6-2.6.23-a/fs/autofs4/root.c linux-2.6-2.6.23/fs/autofs4/root.c
--- linux-2.6-2.6.23-a/fs/autofs4/root.c        2007-11-30 16:20:33.000000000 +0100
+++ linux-2.6-2.6.23/fs/autofs4/root.c  2007-11-30 16:22:24.000000000 +0100
@@ -19,6 +19,9 @@
 #include <linux/time.h>
 #include "autofs_i.h"

+#define DIRECT_TRIGGER_FLAGS (LOOKUP_CONTINUE|LOOKUP_DIRECTORY|LOOKUP_ACCESS)
+
+
 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
 static int autofs4_dir_unlink(struct inode *,struct dentry *);
 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
@@ -291,7 +294,7 @@
                        return status;
                }
        /* Trigger mount for path component or follow link */
-       } else if (flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY) ||
+       } else if (flags & DIRECT_TRIGGER_FLAGS ||
                        current->link_count) {
                DPRINTK("waiting for mount name=%.*s",
                        dentry->d_name.len, dentry->d_name.name);
@@ -335,7 +338,7 @@
                nd->flags);

        /* If it's our master or we shouldn't trigger a mount we're done */
-       lookup_type = nd->flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY);
+       lookup_type = nd->flags & DIRECT_TRIGGER_FLAGS;
        if (oz_mode || !lookup_type)
                goto done;
#5 lore raw
Quoted 9 lines · Lukas Kolbe

Hi Ian!

Ping? :)

We use this patch now for several servers and clients (debian etch with 2.6.18, ubuntu feisty with 2.6.20 and some test systems with 2.6.23), and have seen no regression so far, only working automounts :) I'd love to see this change upstream, so that I don't have to worry about constantly patching my own kernel anymore :)

Why does adding mount on access(2) make things work better? What works better?

    Thanx...

       ps
maintainer
#6 lore raw
Quoted 5 lines · Peter Staubach
Quoted 4 lines · Lukas Kolbe

Hi Ian!

Ping? :)

Quoted 8 lines
Quoted 5 lines

We use this patch now for several servers and clients (debian etch with 2.6.18, ubuntu feisty with 2.6.20 and some test systems with 2.6.23), and have seen no regression so far, only working automounts :) I'd love to see this change upstream, so that I don't have to worry about constantly patching my own kernel anymore :)

Why does adding mount on access(2) make things work better? What works better?

Lucas has recursive maps.
For these mounts to work, we need to ensure that there aren't dependent mounts in the mount point path itself before proceeding. We've used the access system call, made just prior to performing the mount, to make this happen. In this case, however, the lookup flags in the kernel where not triggering the mount.

Ian

maintainer
#10 lore raw
In reply to Lukas Kolbe
Quoted 9 lines · Lukas Kolbe

Hi Ian!

Ping? :)

We use this patch now for several servers and clients (debian etch with 2.6.18, ubuntu feisty with 2.6.20 and some test systems with 2.6.23), and have seen no regression so far, only working automounts :) I'd love to see this change upstream, so that I don't have to worry about constantly patching my own kernel anymore :)

Sorry, I'll get to it.
Ian

#7 lore raw
In reply to Ian Kent
Quoted 18 lines · Ian Kent
Quoted 6 lines · Peter Staubach
Quoted 4 lines · Lukas Kolbe

Hi Ian!

Ping? :)

Quoted 9 lines
Quoted 6 lines

We use this patch now for several servers and clients (debian etch with 2.6.18, ubuntu feisty with 2.6.20 and some test systems with 2.6.23), and have seen no regression so far, only working automounts :) I'd love to see this change upstream, so that I don't have to worry about constantly patching my own kernel anymore :)

Why does adding mount on access(2) make things work better? What works better?

Quoted 6 lines

Lucas has recursive maps.
For these mounts to work, we need to ensure that there aren't dependent mounts in the mount point path itself before proceeding. We've used the access system call, made just prior to performing the mount, to make this happen. In this case, however, the lookup flags in the kernel where not triggering the mount.

And this does not trigger mounts by other applications, such as ls, too?

    Thanx...

       ps
#8 lore raw

Hi Peter!

Quoted 8 lines
Quoted 6 lines

Lucas has recursive maps.
For these mounts to work, we need to ensure that there aren't dependent mounts in the mount point path itself before proceeding. We've used the access system call, made just prior to performing the mount, to make this happen. In this case, however, the lookup flags in the kernel where not triggering the mount.

And this does not trigger mounts by other applications, such as ls, too?

Nope. If I only 'ls -la' my /vol/ or /homes, nothing gets mounted at all.

Quoted 3 lines
    Thanx...

       ps
Signature · 1 line
Lukas
#9 lore raw
Quoted 10 lines · Lukas Kolbe

Hi Peter!

Quoted 7 lines
Quoted 7 lines

Lucas has recursive maps.
For these mounts to work, we need to ensure that there aren't dependent mounts in the mount point path itself before proceeding. We've used the access system call, made just prior to performing the mount, to make this happen. In this case, however, the lookup flags in the kernel where not triggering the mount.

Quoted 7 lines
Quoted 2 lines

And this does not trigger mounts by other applications, such as ls, too?

Nope. If I only 'ls -la' my /vol/ or /homes, nothing gets mounted at all.

Cool. Thanx!

ps

Quoted 6 lines
Quoted 4 lines
    Thanx...

       ps