* [PATCH 01/10] NFS: Create a single nfs_fill_super() function
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 20:06 ` Fred Isaman
2012-03-30 19:02 ` [PATCH 02/10] NFS: Create a single nfs_clone_super() function bjschuma
` (9 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
This can be shared by v2, v3 and v4 in their other common code.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 37412f7..c9bc86e 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2135,16 +2135,18 @@ static void nfs_fill_super(struct super_block *sb,
sb->s_blocksize_bits = 0;
sb->s_blocksize = 0;
- if (data->bsize)
+ if (data && data->bsize)
sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
- if (server->nfs_client->rpc_ops->version == 3) {
+ if (server->nfs_client->rpc_ops->version != 2) {
/* The VFS shouldn't apply the umask to mode bits. We will do
* so ourselves when necessary.
*/
sb->s_flags |= MS_POSIXACL;
sb->s_time_gran = 1;
}
+ if (server->nfs_client->rpc_ops->version == 4)
+ sb->s_xattr = nfs4_xattr_handlers;
sb->s_op = &nfs_sops;
nfs_initialise_sb(sb);
@@ -2520,22 +2522,6 @@ static void nfs4_clone_super(struct super_block *sb,
nfs_initialise_sb(sb);
}
-/*
- * Set up an NFS4 superblock
- */
-static void nfs4_fill_super(struct super_block *sb)
-{
- sb->s_time_gran = 1;
- sb->s_op = &nfs4_sops;
- /*
- * The VFS shouldn't apply the umask to mode bits. We will do
- * so ourselves when necessary.
- */
- sb->s_flags |= MS_POSIXACL;
- sb->s_xattr = nfs4_xattr_handlers;
- nfs_initialise_sb(sb);
-}
-
static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
{
args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3|
@@ -2723,7 +2709,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
if (!s->s_root) {
/* initial superblock/root creation */
- nfs4_fill_super(s);
+ nfs_fill_super(s, data);
nfs_fscache_get_super_cookie(s, data->fscache_uniq, NULL);
}
@@ -3074,7 +3060,7 @@ nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags,
if (!s->s_root) {
/* initial superblock/root creation */
- nfs4_fill_super(s);
+ nfs_fill_super(s, NULL);
nfs_fscache_get_super_cookie(s, NULL, data);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 01/10] NFS: Create a single nfs_fill_super() function
2012-03-30 19:02 ` [PATCH 01/10] NFS: Create a single nfs_fill_super() function bjschuma
@ 2012-03-30 20:06 ` Fred Isaman
2012-03-30 20:08 ` Bryan Schumaker
0 siblings, 1 reply; 15+ messages in thread
From: Fred Isaman @ 2012-03-30 20:06 UTC (permalink / raw)
To: bjschuma; +Cc: Trond.Myklebust, linux-nfs
On Fri, Mar 30, 2012 at 3:02 PM, <bjschuma@netapp.com> wrote:
> From: Bryan Schumaker <bjschuma@netapp.com>
>
> This can be shared by v2, v3 and v4 in their other common code.
>
> Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
> ---
> fs/nfs/super.c | 26 ++++++--------------------
> 1 file changed, 6 insertions(+), 20 deletions(-)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 37412f7..c9bc86e 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -2135,16 +2135,18 @@ static void nfs_fill_super(struct super_block *sb,
>
> sb->s_blocksize_bits = 0;
> sb->s_blocksize = 0;
> - if (data->bsize)
> + if (data && data->bsize)
> sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
>
> - if (server->nfs_client->rpc_ops->version == 3) {
> + if (server->nfs_client->rpc_ops->version != 2) {
> /* The VFS shouldn't apply the umask to mode bits. We will do
> * so ourselves when necessary.
> */
> sb->s_flags |= MS_POSIXACL;
> sb->s_time_gran = 1;
> }
> + if (server->nfs_client->rpc_ops->version == 4)
> + sb->s_xattr = nfs4_xattr_handlers;
>
> sb->s_op = &nfs_sops;
> nfs_initialise_sb(sb);
> @@ -2520,22 +2522,6 @@ static void nfs4_clone_super(struct super_block *sb,
> nfs_initialise_sb(sb);
> }
>
> -/*
> - * Set up an NFS4 superblock
> - */
> -static void nfs4_fill_super(struct super_block *sb)
> -{
> - sb->s_time_gran = 1;
> - sb->s_op = &nfs4_sops;
This seems to discard nfs4_sops (with the accompanying nfs4_evict_inode).
Fred
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 01/10] NFS: Create a single nfs_fill_super() function
2012-03-30 20:06 ` Fred Isaman
@ 2012-03-30 20:08 ` Bryan Schumaker
0 siblings, 0 replies; 15+ messages in thread
From: Bryan Schumaker @ 2012-03-30 20:08 UTC (permalink / raw)
To: Fred Isaman; +Cc: Trond.Myklebust, linux-nfs
On 03/30/12 16:06, Fred Isaman wrote:
> On Fri, Mar 30, 2012 at 3:02 PM, <bjschuma@netapp.com> wrote:
>> From: Bryan Schumaker <bjschuma@netapp.com>
>>
>> This can be shared by v2, v3 and v4 in their other common code.
>>
>> Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
>> ---
>> fs/nfs/super.c | 26 ++++++--------------------
>> 1 file changed, 6 insertions(+), 20 deletions(-)
>>
>> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
>> index 37412f7..c9bc86e 100644
>> --- a/fs/nfs/super.c
>> +++ b/fs/nfs/super.c
>> @@ -2135,16 +2135,18 @@ static void nfs_fill_super(struct super_block *sb,
>>
>> sb->s_blocksize_bits = 0;
>> sb->s_blocksize = 0;
>> - if (data->bsize)
>> + if (data && data->bsize)
>> sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
>>
>> - if (server->nfs_client->rpc_ops->version == 3) {
>> + if (server->nfs_client->rpc_ops->version != 2) {
>> /* The VFS shouldn't apply the umask to mode bits. We will do
>> * so ourselves when necessary.
>> */
>> sb->s_flags |= MS_POSIXACL;
>> sb->s_time_gran = 1;
>> }
>> + if (server->nfs_client->rpc_ops->version == 4)
>> + sb->s_xattr = nfs4_xattr_handlers;
>>
>> sb->s_op = &nfs_sops;
>> nfs_initialise_sb(sb);
>> @@ -2520,22 +2522,6 @@ static void nfs4_clone_super(struct super_block *sb,
>> nfs_initialise_sb(sb);
>> }
>>
>> -/*
>> - * Set up an NFS4 superblock
>> - */
>> -static void nfs4_fill_super(struct super_block *sb)
>> -{
>> - sb->s_time_gran = 1;
>> - sb->s_op = &nfs4_sops;
>
> This seems to discard nfs4_sops (with the accompanying nfs4_evict_inode).
Oops, I'll fix that... thanks for finding it!
- Bryan
>
> Fred
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 02/10] NFS: Create a single nfs_clone_super() function
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
2012-03-30 19:02 ` [PATCH 01/10] NFS: Create a single nfs_fill_super() function bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 03/10] NFS: Fix whitespace errors bjschuma
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
v2 and v3 shared a function for this, but v4 implemented something very
slightly different. Might as well share code whenever possible...
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
Please ignore the earlier version of this patch from last week. This one
should work better...
fs/nfs/super.c | 31 ++++++-------------------------
1 file changed, 6 insertions(+), 25 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c9bc86e..1358dc1 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2153,7 +2153,7 @@ static void nfs_fill_super(struct super_block *sb,
}
/*
- * Finish setting up a cloned NFS2/3 superblock
+ * Finish setting up a cloned NFS2/3/4 superblock
*/
static void nfs_clone_super(struct super_block *sb,
const struct super_block *old_sb)
@@ -2163,16 +2163,17 @@ static void nfs_clone_super(struct super_block *sb,
sb->s_blocksize_bits = old_sb->s_blocksize_bits;
sb->s_blocksize = old_sb->s_blocksize;
sb->s_maxbytes = old_sb->s_maxbytes;
+ sb->s_xattr = old_sb->s_xattr;
+ sb->s_op = old_sb->s_op;
+ sb->s_time_gran = 1;
- if (server->nfs_client->rpc_ops->version == 3) {
+ if (server->nfs_client->rpc_ops->version != 2) {
/* The VFS shouldn't apply the umask to mode bits. We will do
* so ourselves when necessary.
*/
sb->s_flags |= MS_POSIXACL;
- sb->s_time_gran = 1;
}
- sb->s_op = old_sb->s_op;
nfs_initialise_sb(sb);
}
@@ -2502,26 +2503,6 @@ error_splat_bdi:
#ifdef CONFIG_NFS_V4
-/*
- * Finish setting up a cloned NFS4 superblock
- */
-static void nfs4_clone_super(struct super_block *sb,
- const struct super_block *old_sb)
-{
- sb->s_blocksize_bits = old_sb->s_blocksize_bits;
- sb->s_blocksize = old_sb->s_blocksize;
- sb->s_maxbytes = old_sb->s_maxbytes;
- sb->s_time_gran = 1;
- sb->s_op = old_sb->s_op;
- /*
- * The VFS shouldn't apply the umask to mode bits. We will do
- * so ourselves when necessary.
- */
- sb->s_flags |= MS_POSIXACL;
- sb->s_xattr = old_sb->s_xattr;
- nfs_initialise_sb(sb);
-}
-
static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
{
args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3|
@@ -2969,7 +2950,7 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags,
if (!s->s_root) {
/* initial superblock/root creation */
- nfs4_clone_super(s, data->sb);
+ nfs_clone_super(s, data->sb);
nfs_fscache_get_super_cookie(s, NULL, data);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 03/10] NFS: Fix whitespace errors
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
2012-03-30 19:02 ` [PATCH 01/10] NFS: Create a single nfs_fill_super() function bjschuma
2012-03-30 19:02 ` [PATCH 02/10] NFS: Create a single nfs_clone_super() function bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 04/10] NFS: Consistent arguments to nfs_fscache_get_super_cookie() bjschuma
` (7 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
Remove the space from the beginning of both lines.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1358dc1..7a711e9 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2149,7 +2149,7 @@ static void nfs_fill_super(struct super_block *sb,
sb->s_xattr = nfs4_xattr_handlers;
sb->s_op = &nfs_sops;
- nfs_initialise_sb(sb);
+ nfs_initialise_sb(sb);
}
/*
@@ -2174,7 +2174,7 @@ static void nfs_clone_super(struct super_block *sb,
sb->s_flags |= MS_POSIXACL;
}
- nfs_initialise_sb(sb);
+ nfs_initialise_sb(sb);
}
static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 04/10] NFS: Consistent arguments to nfs_fscache_get_super_cookie()
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (2 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 03/10] NFS: Fix whitespace errors bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 05/10] NFS: Rename nfs4_proc_get_root() bjschuma
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
I intend on creating a single nfs_fs_mount() function used by all our
mount paths. To avoid checking between new mounts and clone mounts, I
instead pass both structures to the get_super_cookie() function and let
this function decide the best way to handle the situation.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/fscache.c | 13 +++++++++----
fs/nfs/fscache.h | 2 +-
fs/nfs/super.c | 4 ++--
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
index ae65c16..577b311 100644
--- a/fs/nfs/fscache.c
+++ b/fs/nfs/fscache.c
@@ -64,18 +64,23 @@ void nfs_fscache_release_client_cookie(struct nfs_client *clp)
* either by the 'fsc=xxx' option to mount, or by inheriting it from the parent
* superblock across an automount point of some nature.
*/
-void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq,
- struct nfs_clone_mount *mntdata)
+void nfs_fscache_get_super_cookie(struct super_block *sb,
+ struct nfs_parsed_mount_data *parsed,
+ struct nfs_clone_mount *cloned)
{
struct nfs_fscache_key *key, *xkey;
struct nfs_server *nfss = NFS_SB(sb);
struct rb_node **p, *parent;
+ char *uniq = NULL;
int diff, ulen;
+ if (parsed)
+ uniq = parsed->fscache_uniq;
+
if (uniq) {
ulen = strlen(uniq);
- } else if (mntdata) {
- struct nfs_server *mnt_s = NFS_SB(mntdata->sb);
+ } else if (cloned) {
+ struct nfs_server *mnt_s = NFS_SB(cloned->sb);
if (mnt_s->fscache_key) {
uniq = mnt_s->fscache_key->key.uniquifier;
ulen = mnt_s->fscache_key->key.uniq_len;
diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
index b9c572d..0264bd6 100644
--- a/fs/nfs/fscache.h
+++ b/fs/nfs/fscache.h
@@ -74,7 +74,7 @@ extern void nfs_fscache_get_client_cookie(struct nfs_client *);
extern void nfs_fscache_release_client_cookie(struct nfs_client *);
extern void nfs_fscache_get_super_cookie(struct super_block *,
- const char *,
+ struct nfs_parsed_mount_data *,
struct nfs_clone_mount *);
extern void nfs_fscache_release_super_cookie(struct super_block *);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 7a711e9..11e25f9 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2355,7 +2355,7 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
if (!s->s_root) {
/* initial superblock/root creation */
nfs_fill_super(s, data);
- nfs_fscache_get_super_cookie(s, data->fscache_uniq, NULL);
+ nfs_fscache_get_super_cookie(s, data, NULL);
}
mntroot = nfs_get_root(s, mntfh, dev_name);
@@ -2691,7 +2691,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
if (!s->s_root) {
/* initial superblock/root creation */
nfs_fill_super(s, data);
- nfs_fscache_get_super_cookie(s, data->fscache_uniq, NULL);
+ nfs_fscache_get_super_cookie(s, data, NULL);
}
mntroot = nfs4_get_root(s, mntfh, dev_name);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 05/10] NFS: Rename nfs4_proc_get_root()
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (3 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 04/10] NFS: Consistent arguments to nfs_fscache_get_super_cookie() bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 06/10] NFS: Create a single nfs_get_root() bjschuma
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
This function is really getting the root filehandle and not the root
dentry of the filesystem. I also removed the rpc_ops lookup from
nfs4_get_rootfh() under the assumption that if we reach this function
then we already know we are using NFS v4.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/getroot.c | 2 +-
fs/nfs/nfs4_fs.h | 1 +
fs/nfs/nfs4proc.c | 6 +++---
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 4ca6f5c..8a0f33e 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -150,7 +150,7 @@ int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh)
goto out;
/* Start by getting the root filehandle from the server */
- ret = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo);
+ ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo);
if (ret < 0) {
dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
goto out;
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 97ecc86..f2dc8d5 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -207,6 +207,7 @@ extern const struct inode_operations nfs4_dir_inode_operations;
/* nfs4proc.c */
extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
+extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f82bde0..bd00e10 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2345,8 +2345,8 @@ static int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle,
/*
* get the file handle for the "/" directory on the server
*/
-static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
- struct nfs_fsinfo *info)
+int nfs4_proc_get_rootfh(struct nfs_server *server, struct nfs_fh *fhandle,
+ struct nfs_fsinfo *info)
{
int minor_version = server->nfs_client->cl_minorversion;
int status = nfs4_lookup_root(server, fhandle, info);
@@ -6465,7 +6465,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.dir_inode_ops = &nfs4_dir_inode_operations,
.file_inode_ops = &nfs4_file_inode_operations,
.file_ops = &nfs4_file_operations,
- .getroot = nfs4_proc_get_root,
+ .getroot = nfs4_proc_get_rootfh,
.getattr = nfs4_proc_getattr,
.setattr = nfs4_proc_setattr,
.lookup = nfs4_proc_lookup,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 06/10] NFS: Create a single nfs_get_root()
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (4 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 05/10] NFS: Rename nfs4_proc_get_root() bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 07/10] NFS: Create a common fs_mount() function bjschuma
` (4 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
NFS v4 was doing something slightly different, so the difference can
become the new rpc_ops->getroot() function rather than existing on its
own.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/getroot.c | 83 -----------------------------------------------------
fs/nfs/nfs4proc.c | 28 +++++++++++++++++-
fs/nfs/super.c | 6 ++--
3 files changed, 30 insertions(+), 87 deletions(-)
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index 8a0f33e..8abfb19 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -178,87 +178,4 @@ out:
return ret;
}
-/*
- * get an NFS4 root dentry from the root filehandle
- */
-struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh,
- const char *devname)
-{
- struct nfs_server *server = NFS_SB(sb);
- struct nfs_fattr *fattr = NULL;
- struct dentry *ret;
- struct inode *inode;
- void *name = kstrdup(devname, GFP_KERNEL);
- int error;
-
- dprintk("--> nfs4_get_root()\n");
-
- if (!name)
- return ERR_PTR(-ENOMEM);
-
- /* get the info about the server and filesystem */
- error = nfs4_server_capabilities(server, mntfh);
- if (error < 0) {
- dprintk("nfs_get_root: getcaps error = %d\n",
- -error);
- kfree(name);
- return ERR_PTR(error);
- }
-
- fattr = nfs_alloc_fattr();
- if (fattr == NULL) {
- kfree(name);
- return ERR_PTR(-ENOMEM);
- }
-
- /* get the actual root for this mount */
- error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr);
- if (error < 0) {
- dprintk("nfs_get_root: getattr error = %d\n", -error);
- ret = ERR_PTR(error);
- goto out;
- }
-
- if (fattr->valid & NFS_ATTR_FATTR_FSID &&
- !nfs_fsid_equal(&server->fsid, &fattr->fsid))
- memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid));
-
- inode = nfs_fhget(sb, mntfh, fattr);
- if (IS_ERR(inode)) {
- dprintk("nfs_get_root: get root inode failed\n");
- ret = ERR_CAST(inode);
- goto out;
- }
-
- error = nfs_superblock_set_dummy_root(sb, inode);
- if (error != 0) {
- ret = ERR_PTR(error);
- goto out;
- }
-
- /* root dentries normally start off anonymous and get spliced in later
- * if the dentry tree reaches them; however if the dentry already
- * exists, we'll pick it up at this point and use it as the root
- */
- ret = d_obtain_alias(inode);
- if (IS_ERR(ret)) {
- dprintk("nfs_get_root: get root dentry failed\n");
- goto out;
- }
-
- security_d_instantiate(ret, inode);
- spin_lock(&ret->d_lock);
- if (IS_ROOT(ret) && !(ret->d_flags & DCACHE_NFSFS_RENAMED)) {
- ret->d_fsdata = name;
- name = NULL;
- }
- spin_unlock(&ret->d_lock);
-out:
- if (name)
- kfree(name);
- nfs_free_fattr(fattr);
- dprintk("<-- nfs4_get_root()\n");
- return ret;
-}
-
#endif /* CONFIG_NFS_V4 */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index bd00e10..e3ddebb 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -80,6 +80,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data);
static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *);
static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr);
+static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *);
static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr);
static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
struct nfs_fattr *fattr, struct iattr *sattr,
@@ -2363,6 +2364,31 @@ int nfs4_proc_get_rootfh(struct nfs_server *server, struct nfs_fh *fhandle,
return nfs4_map_errors(status);
}
+static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *mntfh,
+ struct nfs_fsinfo *info)
+{
+ int error;
+ struct nfs_fattr *fattr = info->fattr;
+
+ error = nfs4_server_capabilities(server, mntfh);
+ if (error < 0) {
+ dprintk("nfs4_get_root: getcaps error = %d\n", -error);
+ return error;
+ }
+
+ error = nfs4_proc_getattr(server, mntfh, fattr);
+ if (error < 0) {
+ dprintk("nfs4_get_root: getattr error = %d\n", -error);
+ return error;
+ }
+
+ if (fattr->valid & NFS_ATTR_FATTR_FSID &&
+ !nfs_fsid_equal(&server->fsid, &fattr->fsid))
+ memcpy(&server->fsid, &fattr->fsid, sizeof(server->fsid));
+
+ return error;
+}
+
/*
* Get locations and (maybe) other attributes of a referral.
* Note that we'll actually follow the referral later when
@@ -6465,7 +6491,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
.dir_inode_ops = &nfs4_dir_inode_operations,
.file_inode_ops = &nfs4_file_inode_operations,
.file_ops = &nfs4_file_operations,
- .getroot = nfs4_proc_get_rootfh,
+ .getroot = nfs4_proc_get_root,
.getattr = nfs4_proc_getattr,
.setattr = nfs4_proc_setattr,
.lookup = nfs4_proc_lookup,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 11e25f9..d636bd2 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2694,7 +2694,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
nfs_fscache_get_super_cookie(s, data, NULL);
}
- mntroot = nfs4_get_root(s, mntfh, dev_name);
+ mntroot = nfs_get_root(s, mntfh, dev_name);
if (IS_ERR(mntroot)) {
error = PTR_ERR(mntroot);
goto error_splat_super;
@@ -2954,7 +2954,7 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags,
nfs_fscache_get_super_cookie(s, NULL, data);
}
- mntroot = nfs4_get_root(s, data->fh, dev_name);
+ mntroot = nfs_get_root(s, data->fh, dev_name);
if (IS_ERR(mntroot)) {
error = PTR_ERR(mntroot);
goto error_splat_super;
@@ -3045,7 +3045,7 @@ nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags,
nfs_fscache_get_super_cookie(s, NULL, data);
}
- mntroot = nfs4_get_root(s, mntfh, dev_name);
+ mntroot = nfs_get_root(s, mntfh, dev_name);
if (IS_ERR(mntroot)) {
error = PTR_ERR(mntroot);
goto error_splat_super;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 07/10] NFS: Create a common fs_mount() function
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (5 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 06/10] NFS: Create a single nfs_get_root() bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 08/10] NFS: Create a common xdev_mount() function bjschuma
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
I created a new "struct nfs_mount_info" to use for passing mount data
and other information. This allows me to rip out the old v4 function
and instead use the common mount path.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 314 ++++++++++++++------------------------------------------
1 file changed, 76 insertions(+), 238 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index d636bd2..cf8a6b2 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -325,10 +325,8 @@ static const struct super_operations nfs_sops = {
#ifdef CONFIG_NFS_V4
static int nfs4_validate_text_mount_data(void *options,
struct nfs_parsed_mount_data *args, const char *dev_name);
-static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
+struct dentry *nfs4_try_mount(int flags, const char *dev_name,
struct nfs_parsed_mount_data *data);
-static struct dentry *nfs4_mount(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *raw_data);
static struct dentry *nfs4_remote_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *raw_data);
static struct dentry *nfs4_xdev_mount(struct file_system_type *fs_type,
@@ -342,7 +340,7 @@ static void nfs4_kill_super(struct super_block *sb);
static struct file_system_type nfs4_fs_type = {
.owner = THIS_MODULE,
.name = "nfs4",
- .mount = nfs4_mount,
+ .mount = nfs_fs_mount,
.kill_sb = nfs4_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
};
@@ -2125,6 +2123,11 @@ static inline void nfs_initialise_sb(struct super_block *sb)
nfs_super_set_maxbytes(sb, server->maxfilesize);
}
+struct nfs_mount_info {
+ struct nfs_parsed_mount_data *parsed;
+ unsigned int unshared;
+};
+
/*
* Finish setting up an NFS2/3 superblock
*/
@@ -2286,13 +2289,13 @@ static int nfs_bdi_register(struct nfs_server *server)
return bdi_register_dev(&server->backing_dev_info, server->s_dev);
}
-static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *raw_data)
+struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type,
+ struct nfs_server *server,
+ int flags, const char *dev_name,
+ struct nfs_fh *mntfh,
+ struct nfs_mount_info *mount_info)
{
- struct nfs_server *server = NULL;
struct super_block *s;
- struct nfs_parsed_mount_data *data;
- struct nfs_fh *mntfh;
struct dentry *mntroot = ERR_PTR(-ENOMEM);
int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
struct nfs_sb_mountdata sb_mntdata = {
@@ -2300,34 +2303,9 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
};
int error;
- data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION);
- mntfh = nfs_alloc_fhandle();
- if (data == NULL || mntfh == NULL)
- goto out;
-
- /* Validate the mount data */
- error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
- if (error < 0) {
- mntroot = ERR_PTR(error);
- goto out;
- }
-
-#ifdef CONFIG_NFS_V4
- if (data->version == 4) {
- mntroot = nfs4_try_mount(flags, dev_name, data);
- goto out;
- }
-#endif /* CONFIG_NFS_V4 */
-
- /* Get a volume representation */
- server = nfs_create_server(data, mntfh);
- if (IS_ERR(server)) {
- mntroot = ERR_CAST(server);
- goto out;
- }
sb_mntdata.server = server;
- if (server->flags & NFS_MOUNT_UNSHARED)
+ if (server->flags & mount_info->unshared)
compare_super = NULL;
/* -o noac implies -o sync */
@@ -2354,23 +2332,21 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
if (!s->s_root) {
/* initial superblock/root creation */
- nfs_fill_super(s, data);
- nfs_fscache_get_super_cookie(s, data, NULL);
+ nfs_fill_super(s, mount_info->parsed);
+ nfs_fscache_get_super_cookie(s, mount_info->parsed, NULL);
}
mntroot = nfs_get_root(s, mntfh, dev_name);
if (IS_ERR(mntroot))
goto error_splat_super;
- error = security_sb_set_mnt_opts(s, &data->lsm_opts);
+ error = security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts);
if (error)
goto error_splat_root;
s->s_flags |= MS_ACTIVE;
out:
- nfs_free_parsed_mount_data(data);
- nfs_free_fhandle(mntfh);
return mntroot;
out_err_nosb:
@@ -2388,6 +2364,55 @@ error_splat_bdi:
goto out;
}
+static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
+ int flags, const char *dev_name, void *raw_data)
+{
+ struct nfs_server *server;
+ struct nfs_parsed_mount_data *data;
+ struct nfs_mount_info mount_info = {
+ .unshared = NFS_MOUNT_UNSHARED,
+ };
+ struct nfs_fh *mntfh;
+ struct dentry *mntroot = ERR_PTR(-ENOMEM);
+ int error;
+
+ if (fs_type == &nfs4_fs_type)
+ data = nfs_alloc_parsed_mount_data(4);
+ else
+ data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION);
+ mntfh = nfs_alloc_fhandle();
+ if (data == NULL || mntfh == NULL)
+ goto out;
+
+ /* Validate the mount data */
+ error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
+ if (error < 0) {
+ mntroot = ERR_PTR(error);
+ goto out;
+ }
+ mount_info.parsed = data;
+
+#ifdef CONFIG_NFS_V4
+ if (data->version == 4) {
+ mntroot = nfs4_try_mount(flags, dev_name, data);
+ goto out;
+ }
+#endif /* CONFIG_NFS_V4 */
+
+ /* Get a volume representation */
+ server = nfs_create_server(data, mntfh);
+ if (IS_ERR(server)) {
+ mntroot = ERR_CAST(server);
+ goto out;
+ }
+
+ mntroot = nfs_fs_mount_common(fs_type, server, flags, dev_name, mntfh, &mount_info);
+out:
+ nfs_free_parsed_mount_data(data);
+ nfs_free_fhandle(mntfh);
+ return mntroot;
+}
+
/*
* Ensure that we unregister the bdi before kill_anon_super
* releases the device name
@@ -2541,190 +2566,35 @@ static int nfs4_validate_text_mount_data(void *options,
}
/*
- * Validate NFSv4 mount options
- */
-static int nfs4_validate_mount_data(void *options,
- struct nfs_parsed_mount_data *args,
- const char *dev_name)
-{
- struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
- struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
- char *c;
-
- if (data == NULL)
- goto out_no_data;
-
- switch (data->version) {
- case 1:
- if (data->host_addrlen > sizeof(args->nfs_server.address))
- goto out_no_address;
- if (data->host_addrlen == 0)
- goto out_no_address;
- args->nfs_server.addrlen = data->host_addrlen;
- if (copy_from_user(sap, data->host_addr, data->host_addrlen))
- return -EFAULT;
- if (!nfs_verify_server_address(sap))
- goto out_no_address;
-
- if (data->auth_flavourlen) {
- if (data->auth_flavourlen > 1)
- goto out_inval_auth;
- if (copy_from_user(&args->auth_flavors[0],
- data->auth_flavours,
- sizeof(args->auth_flavors[0])))
- return -EFAULT;
- }
-
- c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
- if (IS_ERR(c))
- return PTR_ERR(c);
- args->nfs_server.hostname = c;
-
- c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
- if (IS_ERR(c))
- return PTR_ERR(c);
- args->nfs_server.export_path = c;
- dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
-
- c = strndup_user(data->client_addr.data, 16);
- if (IS_ERR(c))
- return PTR_ERR(c);
- args->client_address = c;
-
- /*
- * Translate to nfs_parsed_mount_data, which nfs4_fill_super
- * can deal with.
- */
-
- args->flags = data->flags & NFS4_MOUNT_FLAGMASK;
- args->rsize = data->rsize;
- args->wsize = data->wsize;
- args->timeo = data->timeo;
- args->retrans = data->retrans;
- args->acregmin = data->acregmin;
- args->acregmax = data->acregmax;
- args->acdirmin = data->acdirmin;
- args->acdirmax = data->acdirmax;
- args->nfs_server.protocol = data->proto;
- nfs_validate_transport_protocol(args);
-
- break;
- default:
- if (nfs_parse_mount_options((char *)options, args) == 0)
- return -EINVAL;
-
- if (!nfs_verify_server_address(sap))
- return -EINVAL;
-
- return nfs4_validate_text_mount_data(options, args, dev_name);
- }
-
- return 0;
-
-out_no_data:
- dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
- return -EINVAL;
-
-out_inval_auth:
- dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
- data->auth_flavourlen);
- return -EINVAL;
-
-out_no_address:
- dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
- return -EINVAL;
-}
-
-/*
* Get the superblock for the NFS4 root partition
*/
static struct dentry *
nfs4_remote_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
{
- struct nfs_parsed_mount_data *data = raw_data;
- struct super_block *s;
+ struct nfs_mount_info mount_info = {
+ .parsed = raw_data,
+ .unshared = NFS4_MOUNT_UNSHARED,
+ };
struct nfs_server *server;
struct nfs_fh *mntfh;
- struct dentry *mntroot;
- int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
- struct nfs_sb_mountdata sb_mntdata = {
- .mntflags = flags,
- };
- int error = -ENOMEM;
+ struct dentry *mntroot = ERR_PTR(-ENOMEM);
mntfh = nfs_alloc_fhandle();
- if (data == NULL || mntfh == NULL)
+ if (mount_info.parsed == NULL || mntfh == NULL)
goto out;
/* Get a volume representation */
- server = nfs4_create_server(data, mntfh);
+ server = nfs4_create_server(mount_info.parsed, mntfh);
if (IS_ERR(server)) {
- error = PTR_ERR(server);
+ mntroot = ERR_CAST(server);
goto out;
}
- sb_mntdata.server = server;
-
- if (server->flags & NFS4_MOUNT_UNSHARED)
- compare_super = NULL;
-
- /* -o noac implies -o sync */
- if (server->flags & NFS_MOUNT_NOAC)
- sb_mntdata.mntflags |= MS_SYNCHRONOUS;
-
- /* Get a superblock - note that we may end up sharing one that already exists */
- s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
- if (IS_ERR(s)) {
- error = PTR_ERR(s);
- goto out_free;
- }
-
- if (s->s_fs_info != server) {
- nfs_free_server(server);
- server = NULL;
- } else {
- error = nfs_bdi_register(server);
- if (error)
- goto error_splat_bdi;
- }
-
- if (!s->s_root) {
- /* initial superblock/root creation */
- nfs_fill_super(s, data);
- nfs_fscache_get_super_cookie(s, data, NULL);
- }
-
- mntroot = nfs_get_root(s, mntfh, dev_name);
- if (IS_ERR(mntroot)) {
- error = PTR_ERR(mntroot);
- goto error_splat_super;
- }
-
- error = security_sb_set_mnt_opts(s, &data->lsm_opts);
- if (error)
- goto error_splat_root;
-
- s->s_flags |= MS_ACTIVE;
-
- nfs_free_fhandle(mntfh);
- return mntroot;
+ mntroot = nfs_fs_mount_common(&nfs4_fs_type, server, flags, dev_name, mntfh, &mount_info);
out:
nfs_free_fhandle(mntfh);
- return ERR_PTR(error);
-
-out_free:
- nfs_free_server(server);
- goto out;
-
-error_splat_root:
- dput(mntroot);
-error_splat_super:
- if (server && !s->s_root)
- bdi_unregister(&server->backing_dev_info);
-error_splat_bdi:
- deactivate_locked_super(s);
- goto out;
+ return mntroot;
}
static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
@@ -2831,7 +2701,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
return dentry;
}
-static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
+struct dentry *nfs4_try_mount(int flags, const char *dev_name,
struct nfs_parsed_mount_data *data)
{
char *export_path;
@@ -2854,38 +2724,6 @@ static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
return res;
}
-/*
- * Get the superblock for an NFS4 mountpoint
- */
-static struct dentry *nfs4_mount(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *raw_data)
-{
- struct nfs_parsed_mount_data *data;
- int error = -ENOMEM;
- struct dentry *res = ERR_PTR(-ENOMEM);
-
- data = nfs_alloc_parsed_mount_data(4);
- if (data == NULL)
- goto out;
-
- /* Validate the mount data */
- error = nfs4_validate_mount_data(raw_data, data, dev_name);
- if (error < 0) {
- res = ERR_PTR(error);
- goto out;
- }
-
- res = nfs4_try_mount(flags, dev_name, data);
- if (IS_ERR(res))
- error = PTR_ERR(res);
-
-out:
- nfs_free_parsed_mount_data(data);
- dprintk("<-- nfs4_mount() = %d%s\n", error,
- error != 0 ? " [error]" : "");
- return res;
-}
-
static void nfs4_kill_super(struct super_block *sb)
{
struct nfs_server *server = NFS_SB(sb);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 08/10] NFS: Create a common xdev_mount() function
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (6 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 07/10] NFS: Create a common fs_mount() function bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 09/10] NFS: Use nfs_fs_mount_common() for xdev mounts bjschuma
` (2 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
The only difference between nfs_xdev_mount() and nfs4_xdev_mount() is the
unshared flag, so I pass this as an nfs_mount_info parameter so we can
share more code.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 116 ++++++++++++++------------------------------------------
1 file changed, 28 insertions(+), 88 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index cf8a6b2..1247e7e 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2125,6 +2125,7 @@ static inline void nfs_initialise_sb(struct super_block *sb)
struct nfs_mount_info {
struct nfs_parsed_mount_data *parsed;
+ struct nfs_clone_mount *cloned;
unsigned int unshared;
};
@@ -2437,13 +2438,13 @@ static void nfs_kill_super(struct super_block *s)
}
/*
- * Clone an NFS2/3 server record on xdev traversal (FSID-change)
+ * Clone an NFS2/3/4 server record on xdev traversal (FSID-change)
*/
static struct dentry *
-nfs_xdev_mount(struct file_system_type *fs_type, int flags,
- const char *dev_name, void *raw_data)
+nfs_xdev_mount_common(struct file_system_type *fs_type, int flags,
+ const char *dev_name, struct nfs_mount_info *mount_info)
{
- struct nfs_clone_mount *data = raw_data;
+ struct nfs_clone_mount *data = mount_info->cloned;
struct super_block *s;
struct nfs_server *server;
struct dentry *mntroot;
@@ -2453,7 +2454,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
};
int error;
- dprintk("--> nfs_xdev_mount()\n");
+ dprintk("--> nfs_xdev_mount_common()\n");
/* create a new volume representation */
server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
@@ -2463,7 +2464,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
}
sb_mntdata.server = server;
- if (server->flags & NFS_MOUNT_UNSHARED)
+ if (server->flags & mount_info->unshared)
compare_super = NULL;
/* -o noac implies -o sync */
@@ -2508,13 +2509,13 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
/* clone any lsm security options from the parent to the new sb */
security_sb_clone_mnt_opts(data->sb, s);
- dprintk("<-- nfs_xdev_mount() = 0\n");
+ dprintk("<-- nfs_xdev_mount_common() = 0\n");
return mntroot;
out_err_nosb:
nfs_free_server(server);
out_err_noserver:
- dprintk("<-- nfs_xdev_mount() = %d [error]\n", error);
+ dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error);
return ERR_PTR(error);
error_splat_super:
@@ -2522,10 +2523,24 @@ error_splat_super:
bdi_unregister(&server->backing_dev_info);
error_splat_bdi:
deactivate_locked_super(s);
- dprintk("<-- nfs_xdev_mount() = %d [splat]\n", error);
+ dprintk("<-- nfs_xdev_mount_common() = %d [splat]\n", error);
return ERR_PTR(error);
}
+/*
+ * Clone an NFS2/3 server record on xdev traversal (FSID-change)
+ */
+static struct dentry *
+nfs_xdev_mount(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *raw_data)
+{
+ struct nfs_mount_info mount_info = {
+ .cloned = raw_data,
+ .unshared = NFS_MOUNT_UNSHARED,
+ };
+ return nfs_xdev_mount_common(&nfs_fs_type, flags, dev_name, &mount_info);
+}
+
#ifdef CONFIG_NFS_V4
static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
@@ -2743,86 +2758,11 @@ static struct dentry *
nfs4_xdev_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
{
- struct nfs_clone_mount *data = raw_data;
- struct super_block *s;
- struct nfs_server *server;
- struct dentry *mntroot;
- int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
- struct nfs_sb_mountdata sb_mntdata = {
- .mntflags = flags,
+ struct nfs_mount_info mount_info = {
+ .cloned = raw_data,
+ .unshared = NFS4_MOUNT_UNSHARED,
};
- int error;
-
- dprintk("--> nfs4_xdev_mount()\n");
-
- /* create a new volume representation */
- server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
- if (IS_ERR(server)) {
- error = PTR_ERR(server);
- goto out_err_noserver;
- }
- sb_mntdata.server = server;
-
- if (server->flags & NFS4_MOUNT_UNSHARED)
- compare_super = NULL;
-
- /* -o noac implies -o sync */
- if (server->flags & NFS_MOUNT_NOAC)
- sb_mntdata.mntflags |= MS_SYNCHRONOUS;
-
- /* Get a superblock - note that we may end up sharing one that already exists */
- s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
- if (IS_ERR(s)) {
- error = PTR_ERR(s);
- goto out_err_nosb;
- }
-
- if (s->s_fs_info != server) {
- nfs_free_server(server);
- server = NULL;
- } else {
- error = nfs_bdi_register(server);
- if (error)
- goto error_splat_bdi;
- }
-
- if (!s->s_root) {
- /* initial superblock/root creation */
- nfs_clone_super(s, data->sb);
- nfs_fscache_get_super_cookie(s, NULL, data);
- }
-
- mntroot = nfs_get_root(s, data->fh, dev_name);
- if (IS_ERR(mntroot)) {
- error = PTR_ERR(mntroot);
- goto error_splat_super;
- }
- if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
- dput(mntroot);
- error = -ESTALE;
- goto error_splat_super;
- }
-
- s->s_flags |= MS_ACTIVE;
-
- security_sb_clone_mnt_opts(data->sb, s);
-
- dprintk("<-- nfs4_xdev_mount() = 0\n");
- return mntroot;
-
-out_err_nosb:
- nfs_free_server(server);
-out_err_noserver:
- dprintk("<-- nfs4_xdev_mount() = %d [error]\n", error);
- return ERR_PTR(error);
-
-error_splat_super:
- if (server && !s->s_root)
- bdi_unregister(&server->backing_dev_info);
-error_splat_bdi:
- deactivate_locked_super(s);
- dprintk("<-- nfs4_xdev_mount() = %d [splat]\n", error);
- return ERR_PTR(error);
+ return nfs_xdev_mount_common(&nfs4_fs_type, flags, dev_name, &mount_info);
}
static struct dentry *
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 09/10] NFS: Use nfs_fs_mount_common() for xdev mounts
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (7 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 08/10] NFS: Create a common xdev_mount() function bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 19:02 ` [PATCH 10/10] NFS: Use nfs_fs_mount_common() for remote referral mounts bjschuma
2012-03-30 20:51 ` [PATCH 00/10] Clean up mount functions Boaz Harrosh
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
At this point, there are only a few small differences between these two
functions. I can set a few function pointers in the nfs_mount_info
struct to get around these differences.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 111 +++++++++++++++++++-------------------------------------
1 file changed, 38 insertions(+), 73 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1247e7e..73e0e4b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2124,6 +2124,8 @@ static inline void nfs_initialise_sb(struct super_block *sb)
}
struct nfs_mount_info {
+ void (*fill_super)(struct super_block *, struct nfs_mount_info *);
+ int (*set_security)(struct super_block *, struct dentry *, struct nfs_mount_info *);
struct nfs_parsed_mount_data *parsed;
struct nfs_clone_mount *cloned;
unsigned int unshared;
@@ -2133,10 +2135,14 @@ struct nfs_mount_info {
* Finish setting up an NFS2/3 superblock
*/
static void nfs_fill_super(struct super_block *sb,
- struct nfs_parsed_mount_data *data)
+ struct nfs_mount_info *mount_info)
{
+ struct nfs_parsed_mount_data *data = NULL;
struct nfs_server *server = NFS_SB(sb);
+ if (mount_info)
+ data = mount_info->parsed;
+
sb->s_blocksize_bits = 0;
sb->s_blocksize = 0;
if (data && data->bsize)
@@ -2160,8 +2166,9 @@ static void nfs_fill_super(struct super_block *sb,
* Finish setting up a cloned NFS2/3/4 superblock
*/
static void nfs_clone_super(struct super_block *sb,
- const struct super_block *old_sb)
+ struct nfs_mount_info *mount_info)
{
+ const struct super_block *old_sb = mount_info->cloned->sb;
struct nfs_server *server = NFS_SB(sb);
sb->s_blocksize_bits = old_sb->s_blocksize_bits;
@@ -2290,6 +2297,22 @@ static int nfs_bdi_register(struct nfs_server *server)
return bdi_register_dev(&server->backing_dev_info, server->s_dev);
}
+static int nfs_set_sb_security(struct super_block *s, struct dentry *mntroot,
+ struct nfs_mount_info *mount_info)
+{
+ return security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts);
+}
+
+static int nfs_clone_sb_security(struct super_block *s, struct dentry *mntroot,
+ struct nfs_mount_info *mount_info)
+{
+ /* clone any lsm security options from the parent to the new sb */
+ security_sb_clone_mnt_opts(mount_info->cloned->sb, s);
+ if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops)
+ return -ESTALE;
+ return 0;
+}
+
struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type,
struct nfs_server *server,
int flags, const char *dev_name,
@@ -2333,15 +2356,15 @@ struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type,
if (!s->s_root) {
/* initial superblock/root creation */
- nfs_fill_super(s, mount_info->parsed);
- nfs_fscache_get_super_cookie(s, mount_info->parsed, NULL);
+ mount_info->fill_super(s, mount_info);
+ nfs_fscache_get_super_cookie(s, mount_info->parsed, mount_info->cloned);
}
mntroot = nfs_get_root(s, mntfh, dev_name);
if (IS_ERR(mntroot))
goto error_splat_super;
- error = security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts);
+ error = mount_info->set_security(s, mntroot, mount_info);
if (error)
goto error_splat_root;
@@ -2371,6 +2394,8 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
struct nfs_server *server;
struct nfs_parsed_mount_data *data;
struct nfs_mount_info mount_info = {
+ .fill_super = nfs_fill_super,
+ .set_security = nfs_set_sb_security,
.unshared = NFS_MOUNT_UNSHARED,
};
struct nfs_fh *mntfh;
@@ -2445,13 +2470,8 @@ nfs_xdev_mount_common(struct file_system_type *fs_type, int flags,
const char *dev_name, struct nfs_mount_info *mount_info)
{
struct nfs_clone_mount *data = mount_info->cloned;
- struct super_block *s;
struct nfs_server *server;
- struct dentry *mntroot;
- int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
- struct nfs_sb_mountdata sb_mntdata = {
- .mntflags = flags,
- };
+ struct dentry *mntroot = ERR_PTR(-ENOMEM);
int error;
dprintk("--> nfs_xdev_mount_common()\n");
@@ -2460,71 +2480,14 @@ nfs_xdev_mount_common(struct file_system_type *fs_type, int flags,
server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
if (IS_ERR(server)) {
error = PTR_ERR(server);
- goto out_err_noserver;
- }
- sb_mntdata.server = server;
-
- if (server->flags & mount_info->unshared)
- compare_super = NULL;
-
- /* -o noac implies -o sync */
- if (server->flags & NFS_MOUNT_NOAC)
- sb_mntdata.mntflags |= MS_SYNCHRONOUS;
-
- /* Get a superblock - note that we may end up sharing one that already exists */
- s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
- if (IS_ERR(s)) {
- error = PTR_ERR(s);
- goto out_err_nosb;
- }
-
- if (s->s_fs_info != server) {
- nfs_free_server(server);
- server = NULL;
- } else {
- error = nfs_bdi_register(server);
- if (error)
- goto error_splat_bdi;
- }
-
- if (!s->s_root) {
- /* initial superblock/root creation */
- nfs_clone_super(s, data->sb);
- nfs_fscache_get_super_cookie(s, NULL, data);
- }
-
- mntroot = nfs_get_root(s, data->fh, dev_name);
- if (IS_ERR(mntroot)) {
- error = PTR_ERR(mntroot);
- goto error_splat_super;
- }
- if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
- dput(mntroot);
- error = -ESTALE;
- goto error_splat_super;
+ goto out;
}
- s->s_flags |= MS_ACTIVE;
-
- /* clone any lsm security options from the parent to the new sb */
- security_sb_clone_mnt_opts(data->sb, s);
-
- dprintk("<-- nfs_xdev_mount_common() = 0\n");
+ mount_info->fill_super = nfs_clone_super;
+ mount_info->set_security = nfs_clone_sb_security;
+ mntroot = nfs_fs_mount_common(fs_type, server, flags, dev_name, data->fh, mount_info);
+out:
return mntroot;
-
-out_err_nosb:
- nfs_free_server(server);
-out_err_noserver:
- dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error);
- return ERR_PTR(error);
-
-error_splat_super:
- if (server && !s->s_root)
- bdi_unregister(&server->backing_dev_info);
-error_splat_bdi:
- deactivate_locked_super(s);
- dprintk("<-- nfs_xdev_mount_common() = %d [splat]\n", error);
- return ERR_PTR(error);
}
/*
@@ -2588,6 +2551,8 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
{
struct nfs_mount_info mount_info = {
+ .fill_super = nfs_fill_super,
+ .set_security = nfs_set_sb_security,
.parsed = raw_data,
.unshared = NFS4_MOUNT_UNSHARED,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 10/10] NFS: Use nfs_fs_mount_common() for remote referral mounts
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (8 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 09/10] NFS: Use nfs_fs_mount_common() for xdev mounts bjschuma
@ 2012-03-30 19:02 ` bjschuma
2012-03-30 20:51 ` [PATCH 00/10] Clean up mount functions Boaz Harrosh
10 siblings, 0 replies; 15+ messages in thread
From: bjschuma @ 2012-03-30 19:02 UTC (permalink / raw)
To: Trond.Myklebust; +Cc: linux-nfs, Bryan Schumaker
From: Bryan Schumaker <bjschuma@netapp.com>
This should be the last function that needs to be switched over to the
common mount function.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
---
fs/nfs/super.c | 90 +++++++++-----------------------------------------------
1 file changed, 14 insertions(+), 76 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 73e0e4b..e0f6f4a 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2734,95 +2734,33 @@ static struct dentry *
nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *raw_data)
{
- struct nfs_clone_mount *data = raw_data;
- struct super_block *s;
+ struct nfs_mount_info mount_info = {
+ .fill_super = nfs_fill_super,
+ .set_security = nfs_clone_sb_security,
+ .cloned = raw_data,
+ .unshared = NFS4_MOUNT_UNSHARED,
+ };
struct nfs_server *server;
- struct dentry *mntroot;
+ struct dentry *mntroot = ERR_PTR(-ENOMEM);
struct nfs_fh *mntfh;
- int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
- struct nfs_sb_mountdata sb_mntdata = {
- .mntflags = flags,
- };
- int error = -ENOMEM;
dprintk("--> nfs4_referral_get_sb()\n");
mntfh = nfs_alloc_fhandle();
- if (mntfh == NULL)
- goto out_err_nofh;
+ if (mount_info.cloned == NULL || mntfh == NULL)
+ goto out;
/* create a new volume representation */
- server = nfs4_create_referral_server(data, mntfh);
+ server = nfs4_create_referral_server(mount_info.cloned, mntfh);
if (IS_ERR(server)) {
- error = PTR_ERR(server);
- goto out_err_noserver;
- }
- sb_mntdata.server = server;
-
- if (server->flags & NFS4_MOUNT_UNSHARED)
- compare_super = NULL;
-
- /* -o noac implies -o sync */
- if (server->flags & NFS_MOUNT_NOAC)
- sb_mntdata.mntflags |= MS_SYNCHRONOUS;
-
- /* Get a superblock - note that we may end up sharing one that already exists */
- s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
- if (IS_ERR(s)) {
- error = PTR_ERR(s);
- goto out_err_nosb;
- }
-
- if (s->s_fs_info != server) {
- nfs_free_server(server);
- server = NULL;
- } else {
- error = nfs_bdi_register(server);
- if (error)
- goto error_splat_bdi;
- }
-
- if (!s->s_root) {
- /* initial superblock/root creation */
- nfs_fill_super(s, NULL);
- nfs_fscache_get_super_cookie(s, NULL, data);
- }
-
- mntroot = nfs_get_root(s, mntfh, dev_name);
- if (IS_ERR(mntroot)) {
- error = PTR_ERR(mntroot);
- goto error_splat_super;
- }
- if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
- dput(mntroot);
- error = -ESTALE;
- goto error_splat_super;
+ mntroot = ERR_CAST(server);
+ goto out;
}
- s->s_flags |= MS_ACTIVE;
-
- security_sb_clone_mnt_opts(data->sb, s);
-
+ mntroot = nfs_fs_mount_common(&nfs4_fs_type, server, flags, dev_name, mntfh, &mount_info);
+out:
nfs_free_fhandle(mntfh);
- dprintk("<-- nfs4_referral_get_sb() = 0\n");
return mntroot;
-
-out_err_nosb:
- nfs_free_server(server);
-out_err_noserver:
- nfs_free_fhandle(mntfh);
-out_err_nofh:
- dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error);
- return ERR_PTR(error);
-
-error_splat_super:
- if (server && !s->s_root)
- bdi_unregister(&server->backing_dev_info);
-error_splat_bdi:
- deactivate_locked_super(s);
- nfs_free_fhandle(mntfh);
- dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
- return ERR_PTR(error);
}
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 00/10] Clean up mount functions
2012-03-30 19:02 [PATCH 00/10] Clean up mount functions bjschuma
` (9 preceding siblings ...)
2012-03-30 19:02 ` [PATCH 10/10] NFS: Use nfs_fs_mount_common() for remote referral mounts bjschuma
@ 2012-03-30 20:51 ` Boaz Harrosh
2012-03-30 20:57 ` Myklebust, Trond
10 siblings, 1 reply; 15+ messages in thread
From: Boaz Harrosh @ 2012-03-30 20:51 UTC (permalink / raw)
To: bjschuma; +Cc: Trond.Myklebust, linux-nfs
On 03/30/2012 12:02 PM, bjschuma@netapp.com wrote:
> 6 files changed, 196 insertions(+), 599 deletions(-)
>
Whahoo 403 lines removed. Is it spring already?
Boaz
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 00/10] Clean up mount functions
2012-03-30 20:51 ` [PATCH 00/10] Clean up mount functions Boaz Harrosh
@ 2012-03-30 20:57 ` Myklebust, Trond
0 siblings, 0 replies; 15+ messages in thread
From: Myklebust, Trond @ 2012-03-30 20:57 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: Schumaker, Bryan, linux-nfs@vger.kernel.org
T24gRnJpLCAyMDEyLTAzLTMwIGF0IDEzOjUxIC0wNzAwLCBCb2F6IEhhcnJvc2ggd3JvdGU6DQo+
IE9uIDAzLzMwLzIwMTIgMTI6MDIgUE0sIGJqc2NodW1hQG5ldGFwcC5jb20gd3JvdGU6DQo+IA0K
PiA+ICA2IGZpbGVzIGNoYW5nZWQsIDE5NiBpbnNlcnRpb25zKCspLCA1OTkgZGVsZXRpb25zKC0p
DQo+ID4gDQo+IA0KPiANCj4gV2hhaG9vIDQwMyBsaW5lcyByZW1vdmVkLiBJcyBpdCBzcHJpbmcg
YWxyZWFkeT8NCg0KU3ByaW5nIGNhbWUgdmVyeSBlYXJseSB0byBBbm4gQXJib3IgdGhpcyB5ZWFy
LCBzbyBpdCdzIGFscmVhZHkgY2xlYW5pbmcNCnRpbWUuLi4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1
c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lcg0KDQpOZXRBcHANClRyb25kLk15a2xlYnVz
dEBuZXRhcHAuY29tDQp3d3cubmV0YXBwLmNvbQ0KDQo=
^ permalink raw reply [flat|nested] 15+ messages in thread