"nosharecache" option prevent "mount" from detecting when the mount is a duplicate.
Subsystems (2)
(I seem to have quite a pile of NFS issues lately.... some if it is tidying up issues from before Christmas, some of it just keeps on coming :-)
If you run "mount -a" it will attempt to mount all filesystems listed in /etc/fstab, but filesystems that are already mounted will not be mounted again. So it is normally safe to run "mount -a" multiple times.
However if an NFS mount in /etc/fstab has the "nosharecache" option set, mount doesn't notice that it is already mounted as so mounts it again. So repeated "mount -a" is no longer safe.
This happens because the prevention of multiple mounts happens in do_add_mount in fs/namespace.c:
err = -EBUSY; if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb && path->mnt->mnt_root == path->dentry) goto unlock;
i.e. if the exact same superblock is being mounted in the exact same place, return EBUSY.
With nosharecache, every mount attempt produces a new superblock so this test never fires.
One way to address this would be to have a different option, e.g.
sharecache=27
where the '27' is an arbitrary number meaning that if two mount attempts have different sharecache numbers they will have different superblocks. If they have the same sharecache number they can have the same superblock. This is not the most elegant interface ever and I would be very happy for suggestions to improve it. Maybe a string rather than a number ???
This probably isn't a very serious issue, but is a regression in terms of the usability of "mount -a" and I think it would be best to fix it if the cost is not too high.
Below is my patch to implement the "sharecache=%u" syntax.
Any ideas?
Thanks,
NeilBrown
fs/nfs/client.c +2 -0
@@ -779,6 +779,7 @@ static int nfs_init_server(struct nfs_server *server, server->acregmax = data->acregmax *HZ ; server->acdirmin = data->acdirmin *HZ ; server->acdirmax = data->acdirmax *HZ ; + server->cache_id = data->cache_id;/* Start lockd here, before we might error out */ error =nfs_start_lockd (server);
@@ -931,6 +932,7 @@ void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *sour target->caps = source->caps; target->options = source->options; target->auth_info = source->auth_info; + target->cache_id = source->cache_id; }EXPORT_SYMBOL_GPL (nfs_server_copy_userdata);
fs/nfs/internal.h +1 -0
@@ -95,6 +95,7 @@ struct nfs_parsed_mount_data {unsigned int minorversion;char *fscache_uniq;bool need_mount; +unsigned int cache_id;struct {struct sockaddr_storage address;
fs/nfs/nfs4client.c +1 -0
@@ -997,6 +997,7 @@ static int nfs4_init_server(struct nfs_server *server, server->acregmax = data->acregmax *HZ ; server->acdirmin = data->acdirmin *HZ ; server->acdirmax = data->acdirmax *HZ ; + server->cache_id = data->cache_id; server->port = data->nfs_server.port;
fs/nfs/super.c +15 -0
@@ -103,6 +103,7 @@ enum { Opt_mountport, Opt_mountvers, Opt_minorversion, + Opt_sharecacheid,/* Mount options that take string arguments */ Opt_nfsvers,
@@ -145,6 +146,7 @@ static const match_table_t nfs_mount_option_tokens = { { Opt_rdirplus, "rdirplus" }, { Opt_nordirplus, "nordirplus" }, { Opt_sharecache, "sharecache" }, + { Opt_sharecacheid, "sharecache=%s" }, { Opt_nosharecache, "nosharecache" }, { Opt_resvport, "resvport" }, { Opt_noresvport, "noresvport" },
@@ -665,6 +667,10 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,else seq_puts (m, nfs_infop->nostr); } +if (!(nfss->flags &NFS_MOUNT_UNSHARED ) && + nfss->cache_id) +seq_printf (m,",sharecache=%u" , nfss->cache_id); +rcu_read_lock ();seq_printf (m,",proto=%s" ,rpc_peeraddr2str (nfss->client,RPC_DISPLAY_NETID ));
@@ -1407,6 +1413,12 @@ static int nfs_parse_mount_options(char *raw, goto out_invalid_value; mnt->minorversion = option;break ; +case Opt_sharecacheid: +if (nfs_get_option_ul (args, &option) || + option <=0 ) + goto out_invalid_value; + mnt->cache_id = option; +break ;/* * options that take text values
@@ -2457,6 +2469,9 @@ static int nfs_compare_super(struct super_block *sb, void *data)/* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */ if (old->flags &NFS_MOUNT_UNSHARED )return 0 ; +if ((old->cache_id || server->cache_id) && + old->cache_id != server->cache_id) +return 0 ;if (memcmp (&old->fsid, &server->fsid,sizeof (old->fsid)) !=0 )return 0 ;return nfs_compare_mount_options (sb, server, mntflags);
include/linux/nfs_fs_sb.h +1 -0
@@ -145,6 +145,7 @@ struct nfs_server {#define NFS_OPTION_FSCACHE 0x00000001/* - local caching enabled */ #define NFS_OPTION_MIGRATION 0x00000002/* - NFSv4 migration enabled */ +unsigned int cache_id;/* For NFS_MOUNT_UNSHARED */ struct nfs_fsid fsid;__u64 maxfilesize;/* maximum file size */ struct timespec time_delta;/* smallest time granularity */
Quoted 35 lines · NeilBrown
(I seem to have quite a pile of NFS issues lately.... some if it is tidying up issues from before Christmas, some of it just keeps on coming :-)
If you run "mount -a" it will attempt to mount all filesystems listed in
/etc/fstab, but filesystems that are already mounted will not be mounted again. So it is normally safe to run "mount -a" multiple times.However if an NFS mount in
/etc/fstabhas the "nosharecache" option set, mount doesn't notice that it is already mounted as so mounts it again. So repeated "mount -a" is no longer safe.This happens because the prevention of multiple mounts happens in
do_add_mountinfs/namespace.c:err = -EBUSY; if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb && path->mnt->mnt_root == path->dentry) goto unlock;i.e. if the exact same superblock is being mounted in the exact same place, return EBUSY.
With nosharecache, every mount attempt produces a new superblock so this test never fires.One way to address this would be to have a different option, e.g.
sharecache=27where the '27' is an arbitrary number meaning that if two mount attempts have different sharecache numbers they will have different superblocks. If they have the same sharecache number they can have the same superblock. This is not the most elegant interface ever and I would be very happy for suggestions to improve it. Maybe a string rather than a number ???
Quoted 7 lines
This probably isn't a very serious issue, but is a regression in terms of the usability of "mount -a" and I think it would be best to fix it if the cost is not too high.
Below is my patch to implement the "sharecache=%u" syntax.
Any ideas?
What are people using nosharecache for these days, and why is this not another argument for just getting rid of it?
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 42 lines · On Mon, 10 Feb 2014 23:19:09 -0500 Trond Myklebust…
Quoted 39 lines · NeilBrown
(I seem to have quite a pile of NFS issues lately.... some if it is tidying up issues from before Christmas, some of it just keeps on coming :-)
If you run "mount -a" it will attempt to mount all filesystems listed in
/etc/fstab, but filesystems that are already mounted will not be mounted again. So it is normally safe to run "mount -a" multiple times.However if an NFS mount in
/etc/fstabhas the "nosharecache" option set, mount doesn't notice that it is already mounted as so mounts it again. So repeated "mount -a" is no longer safe.This happens because the prevention of multiple mounts happens in
do_add_mountinfs/namespace.c:err = -EBUSY; if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb && path->mnt->mnt_root == path->dentry) goto unlock;i.e. if the exact same superblock is being mounted in the exact same place, return EBUSY.
With nosharecache, every mount attempt produces a new superblock so this test never fires.One way to address this would be to have a different option, e.g.
sharecache=27where the '27' is an arbitrary number meaning that if two mount attempts have different sharecache numbers they will have different superblocks. If they have the same sharecache number they can have the same superblock. This is not the most elegant interface ever and I would be very happy for suggestions to improve it. Maybe a string rather than a number ???
This probably isn't a very serious issue, but is a regression in terms of the usability of "mount -a" and I think it would be best to fix it if the cost is not too high.
Quoted 5 lines
Quoted 3 lines
Below is my patch to implement the "sharecache=%u" syntax.
Any ideas?
What are people using nosharecache for these days, and why is this not another argument for just getting rid of it?
Baby or bath water?
In the particular case that brought this up for me they are actually using "nosharetransport" which is a similar option I provide in SLES because there are cases where sharing the transport reduces performance, and cases where sharing the transport interacts poorly with particular details (of particular versions) of the Netapp filer.
Seeing the root problem is the same for nosharecache and nosharetransport it seems reasonable to report it upstream as an issue with nosharecache.
If you don't think this is worth "fixing", I certainly don't feel strongly enough about it to argue.
Thanks,
NeilBrown