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>
This commit is contained in:
Ilya Dryomov 2013-10-10 20:40:21 +03:00 коммит произвёл Chris Mason
Родитель adfa97cbdf
Коммит e649e587cb
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -650,6 +650,9 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
u64 result; u64 result;
int ret; int ret;
if (fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;
mutex_lock(&dev_replace->lock_finishing_cancel_unmount); mutex_lock(&dev_replace->lock_finishing_cancel_unmount);
btrfs_dev_replace_lock(dev_replace); btrfs_dev_replace_lock(dev_replace);
switch (dev_replace->replace_state) { switch (dev_replace->replace_state) {

Просмотреть файл

@ -3424,6 +3424,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info)
int btrfs_cancel_balance(struct btrfs_fs_info *fs_info) int btrfs_cancel_balance(struct btrfs_fs_info *fs_info)
{ {
if (fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;
mutex_lock(&fs_info->balance_mutex); mutex_lock(&fs_info->balance_mutex);
if (!fs_info->balance_ctl) { if (!fs_info->balance_ctl) {
mutex_unlock(&fs_info->balance_mutex); mutex_unlock(&fs_info->balance_mutex);