summaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_vfsops.c
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-08-17 23:28:17 +0200
committerBrian Behlendorf <[email protected]>2017-08-17 14:28:17 -0700
commit08de8c16f5d322fb594742ea78958385d8ee5b50 (patch)
tree17cc99f891d9cbd3130c24484b8209682ced9002 /module/zfs/zfs_vfsops.c
parenta1f3a1c05fa9cb06334189813d0e0d556d479620 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #6510 Closes #6515
Diffstat (limited to 'module/zfs/zfs_vfsops.c')
-rw-r--r--module/zfs/zfs_vfsops.c10
1 files changed, 9 insertions, 1 deletions
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);
}