diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2013-10-10 13:40:21 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-11 22:00:50 -0500 |
commit | e649e587cbc66287b2a4bff8b2113ad679a2b8d8 (patch) | |
tree | bd5fde951a81a3c1804679e91a82b9b2c0e40de7 /fs | |
parent | adfa97cbdfe376b02bb3e1ea3166958fec35ca6f (diff) |
Btrfs: disallow 'btrfs {balance,replace} cancel' on ro mounts
For both balance and replace, cancelling involves changing the on-disk
state and committing a transaction, which is not a good thing to do on
read-only filesystems.
Cc: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/dev-replace.c | 3 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 9efb94e95858..98df26181349 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -650,6 +650,9 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) | |||
650 | u64 result; | 650 | u64 result; |
651 | int ret; | 651 | int ret; |
652 | 652 | ||
653 | if (fs_info->sb->s_flags & MS_RDONLY) | ||
654 | return -EROFS; | ||
655 | |||
653 | mutex_lock(&dev_replace->lock_finishing_cancel_unmount); | 656 | mutex_lock(&dev_replace->lock_finishing_cancel_unmount); |
654 | btrfs_dev_replace_lock(dev_replace); | 657 | btrfs_dev_replace_lock(dev_replace); |
655 | switch (dev_replace->replace_state) { | 658 | switch (dev_replace->replace_state) { |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9dfe038015f7..5d7ea267d8ff 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3424,6 +3424,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info) | |||
3424 | 3424 | ||
3425 | int btrfs_cancel_balance(struct btrfs_fs_info *fs_info) | 3425 | int btrfs_cancel_balance(struct btrfs_fs_info *fs_info) |
3426 | { | 3426 | { |
3427 | if (fs_info->sb->s_flags & MS_RDONLY) | ||
3428 | return -EROFS; | ||
3429 | |||
3427 | mutex_lock(&fs_info->balance_mutex); | 3430 | mutex_lock(&fs_info->balance_mutex); |
3428 | if (!fs_info->balance_ctl) { | 3431 | if (!fs_info->balance_ctl) { |
3429 | mutex_unlock(&fs_info->balance_mutex); | 3432 | mutex_unlock(&fs_info->balance_mutex); |