diff options
author | Filipe Manana <fdmanana@suse.com> | 2018-06-26 19:43:15 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-06-28 05:30:57 -0400 |
commit | e4e7ede739f7fb468686dfffa2d1e35dca35bacd (patch) | |
tree | 8e7697a52d859cf09e5195ebbd8d59d7ef657071 | |
parent | 717beb96d969561cff53aad2f09547db20ee6ffd (diff) |
Btrfs: fix mount failure when qgroup rescan is in progress
If a power failure happens while the qgroup rescan kthread is running,
the next mount operation will always fail. This is because of a recent
regression that makes qgroup_rescan_init() incorrectly return -EINVAL
when we are mounting the filesystem (through btrfs_read_qgroup_config()).
This causes the -EINVAL error to be returned regardless of any qgroup
flags being set instead of returning the error only when neither of
the flags BTRFS_QGROUP_STATUS_FLAG_RESCAN nor BTRFS_QGROUP_STATUS_FLAG_ON
are set.
A test case for fstests follows up soon.
Fixes: 9593bf49675e ("btrfs: qgroup: show more meaningful qgroup_rescan_init error message")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/qgroup.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 99f2b9ce0f15..c25dc47210a3 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -2786,13 +2786,20 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, | |||
2786 | 2786 | ||
2787 | if (!init_flags) { | 2787 | if (!init_flags) { |
2788 | /* we're resuming qgroup rescan at mount time */ | 2788 | /* we're resuming qgroup rescan at mount time */ |
2789 | if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)) | 2789 | if (!(fs_info->qgroup_flags & |
2790 | BTRFS_QGROUP_STATUS_FLAG_RESCAN)) { | ||
2790 | btrfs_warn(fs_info, | 2791 | btrfs_warn(fs_info, |
2791 | "qgroup rescan init failed, qgroup is not enabled"); | 2792 | "qgroup rescan init failed, qgroup is not enabled"); |
2792 | else if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON)) | 2793 | ret = -EINVAL; |
2794 | } else if (!(fs_info->qgroup_flags & | ||
2795 | BTRFS_QGROUP_STATUS_FLAG_ON)) { | ||
2793 | btrfs_warn(fs_info, | 2796 | btrfs_warn(fs_info, |
2794 | "qgroup rescan init failed, qgroup rescan is not queued"); | 2797 | "qgroup rescan init failed, qgroup rescan is not queued"); |
2795 | return -EINVAL; | 2798 | ret = -EINVAL; |
2799 | } | ||
2800 | |||
2801 | if (ret) | ||
2802 | return ret; | ||
2796 | } | 2803 | } |
2797 | 2804 | ||
2798 | mutex_lock(&fs_info->qgroup_rescan_lock); | 2805 | mutex_lock(&fs_info->qgroup_rescan_lock); |