Commit 2c21b4d7 authored by Wang Shilong's avatar Wang Shilong Committed by Chris Mason

Btrfs: fix transaction abortion when remounting btrfs from RW to RO

Steps to reproduce:
 # mkfs.btrfs -f /dev/sda8
 # mount /dev/sda8 /mnt -o flushoncommit
 # dd if=/dev/zero of=/mnt/data bs=4k count=102400 &
 # mount /dev/sda8 /mnt -o remount, ro

When remounting RW to RO, the logic is to firstly set flag
to RO and then commit transaction, however with option
flushoncommit enabled,we will do RO check within committing
transaction, so we get a transaction abortion here.

Actually,here check is wrong, we should check if FS_STATE_ERROR
is set, fix it.
Reported-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Suggested-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarWang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent e4355f34
...@@ -8477,7 +8477,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) ...@@ -8477,7 +8477,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput)
{ {
int ret; int ret;
if (root->fs_info->sb->s_flags & MS_RDONLY) if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state))
return -EROFS; return -EROFS;
ret = __start_delalloc_inodes(root, delay_iput); ret = __start_delalloc_inodes(root, delay_iput);
...@@ -8503,7 +8503,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput) ...@@ -8503,7 +8503,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput)
struct list_head splice; struct list_head splice;
int ret; int ret;
if (fs_info->sb->s_flags & MS_RDONLY) if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
return -EROFS; return -EROFS;
INIT_LIST_HEAD(&splice); INIT_LIST_HEAD(&splice);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment