diff options
author | Seth Forshee <[email protected]> | 2018-04-12 15:24:38 -0400 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2018-05-07 17:19:57 -0700 |
commit | 3f729907c8cdbf928c0a0c69783641a573fb0208 (patch) | |
tree | 67dc67052953fc92358c9f6169ce4b2e7725d7a4 /config | |
parent | cca220d7c684dfd05887ae8434ad94edb2728240 (diff) |
Allow mounting datasets more than once
Currently mounting an already mounted zfs dataset results in an
error, whereas it is typically allowed with other filesystems.
This causes some bad interactions with mount namespaces. Take
this sequence for example:
- Create a dataset
- Create a snapshot of the dataset
- Create a clone of the snapshot
- Create a new mount namespace
- Rename the original dataset
The rename results in unmounting and remounting the clone in the
original mount namespace, however the remount fails because the
dataset is still mounted in the new mount namespace. (Note that
this means the mount in the new mount namespace is never being
unmounted, so perhaps the unmount/remount of the clone isn't
actually necessary.)
The problem here is a result of the way mounting is implemented
in the kernel module. Since it is not mounting block devices it
uses mount_nodev() instead of the usual mount_bdev(). However,
mount_nodev() is written for filesystems for which each mount is
a new instance (i.e. a new super block), and zfs should be able
to detect when a mount request can be satisfied using an existing
super block.
Change zpl_mount() to call sget() directly with it's own test
callback. Passing the objset_t object as the fs data allows
checking if a superblock already exists for the dataset, and in
that case we just need to return a new reference for the sb's
root dentry.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tom Caputi <[email protected]>
Signed-off-by: Alek Pinchuk <[email protected]>
Signed-off-by: Seth Forshee <[email protected]>
Closes #5796
Closes #7207
Diffstat (limited to 'config')
-rw-r--r-- | config/kernel-fst-mount.m4 | 28 | ||||
-rw-r--r-- | config/kernel-mount-nodev.m4 | 20 | ||||
-rw-r--r-- | config/kernel.m4 | 2 |
3 files changed, 29 insertions, 21 deletions
diff --git a/config/kernel-fst-mount.m4 b/config/kernel-fst-mount.m4 new file mode 100644 index 000000000..a8ac50bdd --- /dev/null +++ b/config/kernel-fst-mount.m4 @@ -0,0 +1,28 @@ +dnl # +dnl # 2.6.38 API change +dnl # The .get_sb callback has been replaced by a .mount callback +dnl # in the file_system_type structure. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_FST_MOUNT], [ + AC_MSG_CHECKING([whether fst->mount() exists]) + ZFS_LINUX_TRY_COMPILE([ + #include <linux/fs.h> + + static struct dentry * + mount(struct file_system_type *fs_type, int flags, + const char *osname, void *data) { + struct dentry *d = NULL; + return (d); + } + + static struct file_system_type fst __attribute__ ((unused)) = { + .mount = mount, + }; + ],[ + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FST_MOUNT, 1, [fst->mount() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel-mount-nodev.m4 b/config/kernel-mount-nodev.m4 deleted file mode 100644 index 28a45157e..000000000 --- a/config/kernel-mount-nodev.m4 +++ /dev/null @@ -1,20 +0,0 @@ -dnl # -dnl # 2.6.39 API change -dnl # The .get_sb callback has been replaced by a .mount callback -dnl # in the file_system_type structure. When using the new -dnl # interface the caller must now use the mount_nodev() helper. -dnl # This updated callback and helper no longer pass the vfsmount. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], - [AC_MSG_CHECKING([whether mount_nodev() is available]) - ZFS_LINUX_TRY_COMPILE_SYMBOL([ - #include <linux/fs.h> - ], [ - mount_nodev(NULL, 0, NULL, NULL); - ], [mount_nodev], [fs/super.c], [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_MOUNT_NODEV, 1, [mount_nodev() is available]) - ], [ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 93158f3d0..375e4b79a 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -102,7 +102,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_TRUNCATE_SETSIZE ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY - ZFS_AC_KERNEL_MOUNT_NODEV + ZFS_AC_KERNEL_FST_MOUNT ZFS_AC_KERNEL_SHRINK ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD |