]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Skip ro check for snaps when multi-mount
authorChunwei Chen <tuxoko@gmail.com>
Mon, 19 Aug 2024 16:42:17 +0000 (09:42 -0700)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2024 16:42:17 +0000 (09:42 -0700)
Skip ro check for snapshots since they are always ro regardless if ro
flag is passed by mount or not. This allows multi-mounting snapshots
without requiring to specify ro flag.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #16299

module/os/linux/zfs/zpl_super.c

index d98d32c1f9fbd79240b43e4110cb6ca83aa9d150..0a82b8858eb8bedd3823e01b047aef88d837e3cb 100644 (file)
@@ -292,6 +292,7 @@ zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mnt_t *zm)
 {
        struct super_block *s;
        objset_t *os;
+       boolean_t issnap = B_FALSE;
        int err;
 
        err = dmu_objset_hold(zm->mnt_osname, FTAG, &os);
@@ -323,6 +324,7 @@ zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mnt_t *zm)
                if (zpl_enter(zfsvfs, FTAG) == 0) {
                        if (os != zfsvfs->z_os)
                                err = -SET_ERROR(EBUSY);
+                       issnap = zfsvfs->z_issnap;
                        zpl_exit(zfsvfs, FTAG);
                } else {
                        err = -SET_ERROR(EBUSY);
@@ -346,7 +348,11 @@ zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mnt_t *zm)
                        return (ERR_PTR(err));
                }
                s->s_flags |= SB_ACTIVE;
-       } else if ((flags ^ s->s_flags) & SB_RDONLY) {
+       } else if (!issnap && ((flags ^ s->s_flags) & SB_RDONLY)) {
+               /*
+                * Skip ro check for snap since snap is always ro regardless
+                * ro flag is passed by mount or not.
+                */
                deactivate_locked_super(s);
                return (ERR_PTR(-EBUSY));
        }