From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: linux-nfs@vger.kernel.org
Cc: Jeff Layton <jlayton@redhat.com>,
Trond Myklebust <Trond.Myklebust@netapp.com>
Subject: [PATCH 24/37] NFS: implement option checking when remounting NFS filesystems (resend)
Date: Thu, 12 Jun 2008 15:22:01 -0400 [thread overview]
Message-ID: <20080612192201.24528.74417.stgit@localhost.localdomain> (raw)
In-Reply-To: <20080612192159.24528.43756.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
From: Jeff Layton <jlayton@redhat.com>
When remounting an NFS or NFS4 filesystem, the new NFS options are not
respected, yet the remount will still return success. This patch adds
a remount_fs sb op for NFS that checks any new nfs mount options against
the existing ones and fails the mount if any have changed.
This is only implemented for string-based mount options since doing
this with binary options isn't really feasible.
This is essentially the same as the original patch I sent out, but
adds a check to see if the addr= option has changed.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
fs/nfs/super.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 2a4a024..4461c00 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -207,6 +207,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
static void nfs_kill_super(struct super_block *);
static void nfs_put_super(struct super_block *);
+static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
static struct file_system_type nfs_fs_type = {
.owner = THIS_MODULE,
@@ -234,6 +235,7 @@ static const struct super_operations nfs_sops = {
.umount_begin = nfs_umount_begin,
.show_options = nfs_show_options,
.show_stats = nfs_show_stats,
+ .remount_fs = nfs_remount,
};
#ifdef CONFIG_NFS_V4
@@ -278,6 +280,7 @@ static const struct super_operations nfs4_sops = {
.umount_begin = nfs_umount_begin,
.show_options = nfs_show_options,
.show_stats = nfs_show_stats,
+ .remount_fs = nfs_remount,
};
#endif
@@ -1398,6 +1401,79 @@ out_invalid_fh:
return -EINVAL;
}
+static int
+nfs_compare_remount_data(struct nfs_server *nfss,
+ struct nfs_parsed_mount_data *data)
+{
+ if (data->flags != nfss->flags ||
+ data->rsize != nfss->rsize ||
+ data->wsize != nfss->wsize ||
+ data->retrans != nfss->client->cl_timeout->to_retries ||
+ data->auth_flavors[0] != nfss->client->cl_auth->au_flavor ||
+ data->acregmin != nfss->acregmin / HZ ||
+ data->acregmax != nfss->acregmax / HZ ||
+ data->acdirmin != nfss->acdirmin / HZ ||
+ data->acdirmax != nfss->acdirmax / HZ ||
+ data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
+ data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
+ memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
+ data->nfs_server.addrlen) != 0)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int
+nfs_remount(struct super_block *sb, int *flags, char *raw_data)
+{
+ int error;
+ struct nfs_server *nfss = sb->s_fs_info;
+ struct nfs_parsed_mount_data *data;
+ struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data;
+ struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
+
+ /*
+ * Userspace mount programs that send binary options generally send
+ * them populated with default values. We have no way to know which
+ * ones were explicitly specified. Fall back to legacy behavior and
+ * just return success.
+ */
+ if ((sb->s_type == &nfs4_fs_type && options4->version == 1) ||
+ (sb->s_type == &nfs_fs_type && options->version >= 1 &&
+ options->version <= 6))
+ return 0;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (data == NULL)
+ return -ENOMEM;
+
+ /* fill out struct with values from existing mount */
+ data->flags = nfss->flags;
+ data->rsize = nfss->rsize;
+ data->wsize = nfss->wsize;
+ data->retrans = nfss->client->cl_timeout->to_retries;
+ data->auth_flavors[0] = nfss->client->cl_auth->au_flavor;
+ data->acregmin = nfss->acregmin / HZ;
+ data->acregmax = nfss->acregmax / HZ;
+ data->acdirmin = nfss->acdirmin / HZ;
+ data->acdirmax = nfss->acdirmax / HZ;
+ data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
+ data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
+ memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
+ data->nfs_server.addrlen);
+
+ /* overwrite those values with any that were specified */
+ error = nfs_parse_mount_options((char *)options, data);
+ if (error < 0)
+ goto out;
+
+ /* compare new mount options with old ones */
+ error = nfs_compare_remount_data(nfss, data);
+out:
+ kfree(data);
+ return error;
+}
+
/*
* Initialise the common bits of the superblock
*/
next prev parent reply other threads:[~2008-06-12 19:34 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-12 19:22 [PATCH 00/37] Patches to be added to the 'devel' branch Trond Myklebust
[not found] ` <20080612192159.24528.43756.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-06-12 19:22 ` [PATCH 11/37] SUNRPC: Add a function to display the name of an RPC procedure Trond Myklebust
2008-06-12 19:22 ` [PATCH 04/37] SUNRPC: Ensure we exit early in case of an encode error Trond Myklebust
2008-06-12 19:22 ` [PATCH 07/37] NFS: Revert commit 44dd151d Trond Myklebust
2008-06-12 19:22 ` [PATCH 12/37] SUNRPC: Rename "call_" functions that are no longer FSM states Trond Myklebust
2008-06-12 19:22 ` [PATCH 16/37] NFS: Make nfs_fsync methods consistent Trond Myklebust
2008-06-12 19:22 ` [PATCH 14/37] SUNRPC: Refactor rpc_show_tasks Trond Myklebust
2008-06-12 19:22 ` [PATCH 03/37] NFS: Add correct bounds checking to NFSv2 locks Trond Myklebust
2008-06-12 19:22 ` [PATCH 06/37] NFS: Optimise append writes with holes Trond Myklebust
2008-06-12 19:22 ` [PATCH 05/37] SUNRPC: An ENOMEM error from call_encode is always fatal Trond Myklebust
[not found] ` <20080612192200.24528.71693.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-06-13 21:10 ` J. Bruce Fields
2008-06-12 19:22 ` [PATCH 10/37] NFS: Update help text for CONFIG_NFS_FS Trond Myklebust
2008-06-12 19:22 ` [PATCH 01/37] NFS: Fix a preemption count leak in nfs_update_request Trond Myklebust
2008-06-12 19:22 ` [PATCH 15/37] SUNRPC: Display some debugging information as text rather than numbers Trond Myklebust
2008-06-12 19:22 ` [PATCH 13/37] SUNRPC: Don't display the rpc_show_tasks header if there are no tasks Trond Myklebust
2008-06-12 19:22 ` [PATCH 02/37] NFS: nfs_updatepage(): don't mark page as dirty if an error occurred Trond Myklebust
2008-06-12 19:22 ` [PATCH 08/37] SUNRPC: Use GFP_NOFS when allocating credentials Trond Myklebust
[not found] ` <20080612192200.24528.65570.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-06-13 21:17 ` J. Bruce Fields
2008-06-13 21:26 ` Trond Myklebust
2008-06-13 21:31 ` J. Bruce Fields
2008-06-13 21:34 ` Trond Myklebust
2008-06-13 21:58 ` J. Bruce Fields
2008-06-13 22:07 ` Trond Myklebust
2008-06-12 19:22 ` [PATCH 09/37] NFS: do_setlk(): don't flush caches when we have a delegation Trond Myklebust
2008-06-12 19:22 ` [PATCH 17/37] NFS: Make nfs_llseek methods consistent Trond Myklebust
2008-06-12 19:22 ` [PATCH 23/37] fs/nfs/nfsroot.c: remove CVS keyword Trond Myklebust
2008-06-12 19:22 ` [PATCH 22/37] SUNRPC: Remove obsolete messages during transport connect Trond Myklebust
2008-06-12 19:22 ` [PATCH 26/37] rpc: eliminate unused variable in auth_gss upcall code Trond Myklebust
2008-06-12 19:22 ` [PATCH 32/37] NFS: Move fs/nfs/iostat.h to include/linux Trond Myklebust
2008-06-12 19:22 ` [PATCH 29/37] NFS: Fix the ftruncate() credential problem Trond Myklebust
2008-06-12 19:22 ` [PATCH 37/37] NFS: missing newline in NFS mount debugging message Trond Myklebust
2008-06-12 19:22 ` [PATCH 28/37] rpc: minor cleanup of scheduler callback code Trond Myklebust
2008-06-12 19:22 ` [PATCH 36/37] NFS: Treat "intr" and "nointr" options as deprecated Trond Myklebust
2008-06-12 19:22 ` [PATCH 35/37] NFS: Allow any value for the "retry" option Trond Myklebust
2008-06-12 19:22 ` [PATCH 20/37] NFS: Use NFSDBG_FILE for all fops Trond Myklebust
2008-06-12 19:22 ` [PATCH 33/37] NFS: Fix a warning in nfs4_async_handle_error Trond Myklebust
2008-06-12 19:22 ` [PATCH 18/37] NFS: Make nfs_open methods consistent Trond Myklebust
2008-06-12 19:22 ` [PATCH 31/37] NFS: Remove the redundant file_open entry from struct nfs_rpc_ops Trond Myklebust
2008-06-12 19:22 ` [PATCH 34/37] NFS: Ensure we zap only the access and acl caches when setting new acls Trond Myklebust
2008-06-12 19:22 ` [PATCH 19/37] NFS: Add debugging facility for NFS aops Trond Myklebust
2008-06-12 19:22 ` Trond Myklebust [this message]
2008-06-12 19:22 ` [PATCH 27/37] rpc: remove some unused macros Trond Myklebust
2008-06-12 19:22 ` [PATCH 25/37] rpc: bring back cl_chatty Trond Myklebust
2008-06-12 19:22 ` [PATCH 30/37] SUNRPC: Ensure all transports set rq_xtime consistently Trond Myklebust
2008-06-12 19:22 ` [PATCH 21/37] NFS: Fix trace debugging nits in write.c Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080612192201.24528.74417.stgit@localhost.localdomain \
--to=trond.myklebust@netapp.com \
--cc=jlayton@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox