mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
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 <behlendorf1@llnl.gov> Reviewed-by: Tom Caputi <tcaputi@datto.com> Signed-off-by: Alek Pinchuk <apinchuk@datto.com> Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Closes #5796 Closes #7207
This commit is contained in:
committed by
Tony Hutter
parent
cca220d7c6
commit
3f729907c8
@@ -182,6 +182,30 @@ zpl_bdi_destroy(struct super_block *sb)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 4.14 adds SB_* flag definitions, define them to MS_* equivalents
|
||||
* if not set.
|
||||
*/
|
||||
#ifndef SB_RDONLY
|
||||
#define SB_RDONLY MS_RDONLY
|
||||
#endif
|
||||
|
||||
#ifndef SB_SILENT
|
||||
#define SB_SILENT MS_SILENT
|
||||
#endif
|
||||
|
||||
#ifndef SB_ACTIVE
|
||||
#define SB_ACTIVE MS_ACTIVE
|
||||
#endif
|
||||
|
||||
#ifndef SB_POSIXACL
|
||||
#define SB_POSIXACL MS_POSIXACL
|
||||
#endif
|
||||
|
||||
#ifndef SB_MANDLOCK
|
||||
#define SB_MANDLOCK MS_MANDLOCK
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 2.6.38 API change,
|
||||
* LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases.
|
||||
|
||||
Reference in New Issue
Block a user