From 08de8c16f5d322fb594742ea78958385d8ee5b50 Mon Sep 17 00:00:00 2001 From: LOLi Date: Thu, 17 Aug 2017 23:28:17 +0200 Subject: Fix remounting snapshots read-write It's not enough to preserve/restore MS_RDONLY on the superblock flags to avoid remounting a snapshot read-write: be explicit about our intentions to the VFS layer so the readonly bit is updated correctly in do_remount_sb(). Reviewed-by: Chunwei Chen Reviewed-by: Brian Behlendorf Signed-off-by: loli10K Closes #6510 Closes #6515 --- module/zfs/zfs_vfsops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'module/zfs/zfs_vfsops.c') diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c index b60045a95..33557157b 100644 --- a/module/zfs/zfs_vfsops.c +++ b/module/zfs/zfs_vfsops.c @@ -1763,8 +1763,15 @@ zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm) { zfsvfs_t *zfsvfs = sb->s_fs_info; vfs_t *vfsp; + boolean_t issnap = dmu_objset_is_snapshot(zfsvfs->z_os); int error; + if ((issnap || !spa_writeable(dmu_objset_spa(zfsvfs->z_os))) && + !(*flags & MS_RDONLY)) { + *flags |= MS_RDONLY; + return (EROFS); + } + error = zfsvfs_parse_options(zm->mnt_data, &vfsp); if (error) return (error); @@ -1774,7 +1781,8 @@ zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm) vfsp->vfs_data = zfsvfs; zfsvfs->z_vfs = vfsp; - (void) zfs_register_callbacks(vfsp); + if (!issnap) + (void) zfs_register_callbacks(vfsp); return (error); } -- cgit v1.2.3