Skip to content

Commit e4e7ede

Browse files
fdmananakdave
authored andcommitted
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: 9593bf4 ("btrfs: qgroup: show more meaningful qgroup_rescan_init error message") Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 717beb9 commit e4e7ede

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/btrfs/qgroup.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,13 +2786,20 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
27862786

27872787
if (!init_flags) {
27882788
/* 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)) {
27902791
btrfs_warn(fs_info,
27912792
"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)) {
27932796
btrfs_warn(fs_info,
27942797
"qgroup rescan init failed, qgroup rescan is not queued");
2795-
return -EINVAL;
2798+
ret = -EINVAL;
2799+
}
2800+
2801+
if (ret)
2802+
return ret;
27962803
}
27972804

27982805
mutex_lock(&fs_info->qgroup_rescan_lock);

0 commit comments

Comments
 (0)