Skip to contentSkip to conversation

NFS: Propagate 'fsc' mount option through automounts

RFC PATCH In review David Howells 2 participants 5 messages Jul 9, 2009 – Jul 15, 2009 NFS client

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 NFS: Propagate 'fsc' mount option through automounts

Propagate the NFS 'fsc' mount option through NFS automounts of various types.

This is now required as commit:

	commit c02d7adf8c5429727a98bad1d039bccad4c61c50
	Author: Trond Myklebust <[email protected]>
	Date:   Mon Jun 22 15:09:14 2009 -0400

	NFSv4: Replace nfs4_path_walk() with VFS path lookup in a private namespace

now uses VFS-driven automounting to reach all submounts barring the root, thus preventing fscaching from being enabled on any submount other than the root.

This patch gets around that by propagating the NFS_OPTION_FSCACHE flag across automounts.

Note, however, that it doesn't propagate the uniquifier in the case of 'fsc=<xxx>' being passed to mount. This is probably wrong, and needs looking at.

---

 fs/nfs/client.c |    1 +
 fs/nfs/super.c  |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
fs/nfs/client.c +1 -0
index c2d0616..0949b46 100644
@@ -964,6 +964,7 @@ static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_serve
 	target->acdirmin = source->acdirmin;
 	target->acdirmax = source->acdirmax;
 	target->caps = source->caps;
+	target->options = source->options;
 }
 
 /*
fs/nfs/super.c +6 -0
index 0b4cbdc..bfab16f 100644
@@ -2214,6 +2214,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	struct nfs_server *server;
 	struct dentry *mntroot;
 	int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+	struct nfs_parsed_mount_data parsed_data = { .fscache_uniq = NULL, };
 	struct nfs_sb_mountdata sb_mntdata = {
 		.mntflags = flags,
 	};
@@ -2251,6 +2252,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	if (!s->s_root) {
 		/* initial superblock/root creation */
 		nfs_clone_super(s, data->sb);
+		nfs_fscache_get_super_cookie(s, &parsed_data);
 	}
 
 	mntroot = nfs_get_root(s, data->fh);
@@ -2687,6 +2689,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	struct nfs_server *server;
 	struct dentry *mntroot;
 	int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+	struct nfs_parsed_mount_data parsed_data = { .fscache_uniq = NULL, };
 	struct nfs_sb_mountdata sb_mntdata = {
 		.mntflags = flags,
 	};
@@ -2724,6 +2727,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	if (!s->s_root) {
 		/* initial superblock/root creation */
 		nfs4_clone_super(s, data->sb);
+		nfs_fscache_get_super_cookie(s, &parsed_data);
 	}
 
 	mntroot = nfs4_get_root(s, data->fh);
@@ -2768,6 +2772,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
 	struct dentry *mntroot;
 	struct nfs_fh mntfh;
 	int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+	struct nfs_parsed_mount_data parsed_data = { .fscache_uniq = NULL, };
 	struct nfs_sb_mountdata sb_mntdata = {
 		.mntflags = flags,
 	};
@@ -2805,6 +2810,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
 	if (!s->s_root) {
 		/* initial superblock/root creation */
 		nfs4_fill_super(s);
+		nfs_fscache_get_super_cookie(s, &parsed_data);
 	}
 
 	mntroot = nfs4_get_root(s, &mntfh);
#1 lore raw
Quoted 13 lines · David Howells

Propagate the NFS 'fsc' mount option through NFS automounts of various types.

This is now required as commit:

	commit c02d7adf8c5429727a98bad1d039bccad4c61c50
	Author: Trond Myklebust <[email protected]>
	Date:   Mon Jun 22 15:09:14 2009 -0400

	NFSv4: Replace nfs4_path_walk() with VFS path lookup in a private namespace

now uses VFS-driven automounting to reach all submounts barring the root, thus preventing fscaching from being enabled on any submount other than the root.

Quoted 6 lines

This patch gets around that by propagating the NFS_OPTION_FSCACHE flag across automounts.

Note, however, that it doesn't propagate the uniquifier in the case of 'fsc=<xxx>' being passed to mount. This is probably wrong, and needs looking at.

Why not just use the mount path as the default uniquifier?

Quoted 13 lines

---

 fs/nfs/client.c |    1 +
 fs/nfs/super.c  |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
fs/nfs/client.c +0 -0
index c2d0616..0949b46 100644

fs/nfs/client.c static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_serve · line 967

Quoted 4 lines
fs/nfs/client.c +1 -0
@@ -964,6 +964,7 @@ static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_serve
 	target->acdirmin = source->acdirmin;
 	target->acdirmax = source->acdirmax;
 	target->caps = source->caps;
+	target->options = source->options;

BTW: Why does fscache require a private flag field?

fs/nfs/super.c static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags, · line 2217

Quoted 12 lines
fs/nfs/client.c +0 -0
 }
 
 /*
fs/nfs/super.c +1 -0
index 0b4cbdc..bfab16f 100644
@@ -2214,6 +2214,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
 	struct nfs_server *server;
 	struct dentry *mntroot;
 	int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+	struct nfs_parsed_mount_data parsed_data = { .fscache_uniq = NULL, };

Rather than wasting all this space on the stack, how about just changing the second argument of nfs_fscache_get_super_cookie()? You only use the pointer to data->fscache_uniq.

Quoted 3 lines
fs/nfs/super.c +0 -0
 	struct nfs_sb_mountdata sb_mntdata = {
 		.mntflags = flags,
 	};
Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com
#2 lore raw
Quoted 1 line · Trond Myklebust

Why not just use the mount path as the default uniquifier?

Because:

(1) Which mount path? You're now constructing the mount tree in its own private namespace.

(2) Due to the new VFS-pathwalk-based mount, the uniquifier is applied to the root mount only, and if modified to inherit, would be applied to every automount subordinate to that, rather than just the actual subject of the mount.

(3) Due to the new VFS-pathwalk-based mount and the private namespace, the default uniquifier for all instances of any particular mount is always the same.

(4) If we work around some how the mounts now getting their mount path from the private namespace, there are still real namespaces, chroots and root-pivots to contend with.

Quoted 3 lines

fs/nfs/client.c static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_serve · line 967

Quoted 1 line
fs/nfs/client.c +1 -0
+	target->options = source->options;

BTW: Why does fscache require a private flag field?

I thought it best to avoid touching nfs_server::flags as that is at least partially visible to userspace.

Quoted 5 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	struct nfs_parsed_mount_data parsed_data = { .fscache_uniq = NULL, };

Rather than wasting all this space on the stack, how about just changing the second argument of nfs_fscache_get_super_cookie()? You only use the pointer to data->fscache_uniq.

Yeah, that's probably wise.

Actually, I don't really want to get this data via mount at all (as there are automounts to locally configure for caching).

David

#3 lore raw
Quoted 8 lines · David Howells
Quoted 1 line · Trond Myklebust

Why not just use the mount path as the default uniquifier?

Because:

(1) Which mount path? You're now constructing the mount tree in its own private namespace.

The natural thing would be to use the mount path that is required to locate the super block's root dentry on the server (i.e. the mount path for sb->s_root).
In the private namespace (since that reflects the namespace of the server, and hence mnt->mnt_root == sb->s_root) this mount path will always be the same as the contents of mnt->mnt_devname.

(In the local namespace, however, sb->s_root != mnt->mnt_root, and so mnt->mnt_devname is fixed up to reflect that difference. See nfs_fix_devname()...)

Quoted 8 lines

(2) Due to the new VFS-pathwalk-based mount, the uniquifier is applied to the root mount only, and if modified to inherit, would be applied to every automount subordinate to that, rather than just the actual subject of the mount.

(3) Due to the new VFS-pathwalk-based mount and the private namespace, the default uniquifier for all instances of any particular mount is always the same.

...and is that sufficient? If it is, then fine, let's leave it...

Quoted 3 lines

(4) If we work around some how the mounts now getting their mount path from the private namespace, there are still real namespaces, chroots and root-pivots to contend with.

Real namespaces, chroots and root-pivots are all changes to the client only. They do not change the server's namespace, and hence the mount path is invariant.

Trond

Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com
#4 lore raw
Quoted 1 line · Trond Myklebust
Quoted 1 line
Quoted 1 line

Why not just use the mount path as the default uniquifier?

In fact, why change it from being blank? If I do this:

The natural thing would be to use the mount path that is required to locate the super block's root dentry on the server (i.e. the mount path for sb->s_root).

then it may as well be blank, since the FSID is a sufficient uniquifier, and that's also included in the key.

Where a uniquifier is needed is when someone sets up two mounts of the same thing, but with different network parameters as these aren't recorded in the key. Under such a circumstance, manual intervention is required in the form of a supplied uniquifier on one of the mounts.

That uniquifier should also only apply to the superblock actually being mounted, I think; but it's probably okay to apply it to all the intervening transient superblocks from root that nfs_follow_remote_path() causes to exist, and just accept that you might get a little bit of rubbish in the cache once we start caching directories.

Also, the uniquifier would be applied to all superblocks that get created by automounts under a superblock that has a uniquifier.

David