Commit 9593bf49 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: qgroup: show more meaningful qgroup_rescan_init error message

Error message from qgroup_rescan_init() mostly looks like:

  BTRFS info (device nvme0n1p1): qgroup_rescan_init failed with -115

Which is far from meaningful, and sometimes confusing as for above
-EINPROGRESS it's mostly (despite the init race) harmless, but sometimes
it can also indicate problem if the return value is -EINVAL.

Change it to some more meaningful messages like:

  BTRFS info (device nvme0n1p1): qgroup rescan is already in progress

And

  BTRFS err(device nvme0n1p1): qgroup rescan init failed, qgroup is not enabled
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
[ update the messages and level ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent fd4e994b
...@@ -2782,26 +2782,36 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, ...@@ -2782,26 +2782,36 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
{ {
int ret = 0; int ret = 0;
if (!init_flags && if (!init_flags) {
(!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) || /* we're resuming qgroup rescan at mount time */
!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON))) { if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN))
ret = -EINVAL; btrfs_warn(fs_info,
goto err; "qgroup rescan init failed, qgroup is not enabled");
else if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON))
btrfs_warn(fs_info,
"qgroup rescan init failed, qgroup rescan is not queued");
return -EINVAL;
} }
mutex_lock(&fs_info->qgroup_rescan_lock); mutex_lock(&fs_info->qgroup_rescan_lock);
spin_lock(&fs_info->qgroup_lock); spin_lock(&fs_info->qgroup_lock);
if (init_flags) { if (init_flags) {
if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) {
btrfs_warn(fs_info,
"qgroup rescan is already in progress");
ret = -EINPROGRESS; ret = -EINPROGRESS;
else if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON)) } else if (!(fs_info->qgroup_flags &
BTRFS_QGROUP_STATUS_FLAG_ON)) {
btrfs_warn(fs_info,
"qgroup rescan init failed, qgroup is not enabled");
ret = -EINVAL; ret = -EINVAL;
}
if (ret) { if (ret) {
spin_unlock(&fs_info->qgroup_lock); spin_unlock(&fs_info->qgroup_lock);
mutex_unlock(&fs_info->qgroup_rescan_lock); mutex_unlock(&fs_info->qgroup_rescan_lock);
goto err; return ret;
} }
fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_RESCAN; fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_RESCAN;
} }
...@@ -2820,13 +2830,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, ...@@ -2820,13 +2830,6 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
btrfs_init_work(&fs_info->qgroup_rescan_work, btrfs_init_work(&fs_info->qgroup_rescan_work,
btrfs_qgroup_rescan_helper, btrfs_qgroup_rescan_helper,
btrfs_qgroup_rescan_worker, NULL, NULL); btrfs_qgroup_rescan_worker, NULL, NULL);
if (ret) {
err:
btrfs_info(fs_info, "qgroup_rescan_init failed with %d", ret);
return ret;
}
return 0; return 0;
} }
......
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