From 93b43af10df815d3ebfe136d03cd2d7f35350470 Mon Sep 17 00:00:00 2001 From: Seth Forshee Date: Thu, 12 Apr 2018 15:24:38 -0400 Subject: 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 Reviewed-by: Tom Caputi Signed-off-by: Alek Pinchuk Signed-off-by: Seth Forshee Closes #5796 Closes #7207 --- tests/runfiles/linux.run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/runfiles') diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index 9af97b81f..fb489d9fe 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -174,7 +174,7 @@ tests = ['zfs_mount_001_pos', 'zfs_mount_002_pos', 'zfs_mount_003_pos', 'zfs_mount_004_pos', 'zfs_mount_005_pos', 'zfs_mount_007_pos', 'zfs_mount_008_pos', 'zfs_mount_009_neg', 'zfs_mount_010_neg', 'zfs_mount_011_neg', 'zfs_mount_012_neg', 'zfs_mount_all_001_pos', - 'zfs_mount_encrypted', 'zfs_mount_remount'] + 'zfs_mount_encrypted', 'zfs_mount_remount', 'zfs_multi_mount'] tags = ['functional', 'cli_root', 'zfs_mount'] [tests/functional/cli_root/zfs_program] -- cgit v1.2.3