* [PATCH 0/3] btrfs: qgroup: rescan related message minor fixes
@ 2026-11-20 9:08 Qu Wenruo
2026-11-20 9:08 ` [PATCH 1/3] btrfs: qgroup: handle the transaction commit error during rescan Qu Wenruo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-11-20 9:08 UTC (permalink / raw)
To: linux-btrfs
The first one is from Sashiko.
The second one is to make sure we output the rescan related message even
if we failed to start a transaction (e.g. transaction aborted).
The final one is to fix a bug that rescan cancelled message is never
shown.
Qu Wenruo (3):
btrfs: qgroup: handle the transaction commit error during rescan
btrfs: qgroup: ensure the qgroup rescan messages are always shown
btrfs: qgroup: show the "qgroup scan cancelled" message correctly
fs/btrfs/qgroup.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
--
2.56.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] btrfs: qgroup: handle the transaction commit error during rescan
2026-11-20 9:08 [PATCH 0/3] btrfs: qgroup: rescan related message minor fixes Qu Wenruo
@ 2026-11-20 9:08 ` Qu Wenruo
2026-11-20 9:08 ` [PATCH 2/3] btrfs: qgroup: ensure the qgroup rescan messages are always shown Qu Wenruo
2026-11-20 9:08 ` [PATCH 3/3] btrfs: qgroup: show the "qgroup scan cancelled" message correctly Qu Wenruo
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-11-20 9:08 UTC (permalink / raw)
To: linux-btrfs
After qgroup_rescan_leaf() return 1, meaning it has done the scanning,
btrfs_qgroup_rescan_worker() will call btrfs_commit_transaction() to
update the qgroup infos.
But if that btrfs_commit_transaction() failed, @ret is still 1, which
will treat the rescan as ended successfully, clearing the INCONSISTENT
flag.
Fix the error handling by also check the return value of
btrfs_commit_transaction(). If that failed, update @ret to the error
code so we treat the rescan as failed.
Link: https://sashiko.dev/#/bug/linux-b578ca93-4f5a-4a46-9dfc-71c1ac9af095
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/qgroup.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 3127d3fcab31..9f3886d128d3 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3928,10 +3928,15 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
ret = qgroup_rescan_leaf(trans, path);
did_leaf_rescans = true;
- if (ret > 0)
- btrfs_commit_transaction(trans);
- else
+ if (ret > 0) {
+ int commit_ret;
+
+ commit_ret = btrfs_commit_transaction(trans);
+ if (commit_ret < 0)
+ ret = commit_ret;
+ } else {
btrfs_end_transaction(trans);
+ }
}
out:
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] btrfs: qgroup: ensure the qgroup rescan messages are always shown
2026-11-20 9:08 [PATCH 0/3] btrfs: qgroup: rescan related message minor fixes Qu Wenruo
2026-11-20 9:08 ` [PATCH 1/3] btrfs: qgroup: handle the transaction commit error during rescan Qu Wenruo
@ 2026-11-20 9:08 ` Qu Wenruo
2026-11-20 9:08 ` [PATCH 3/3] btrfs: qgroup: show the "qgroup scan cancelled" message correctly Qu Wenruo
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-11-20 9:08 UTC (permalink / raw)
To: linux-btrfs
In btrfs_qgroup_rescan_worker(), if by somehow the transaction is
aborted halfway, later we can not start a new transaction.
This marks @trans variable always to be NULL, which later skips the
qgroup scan related messages, this can be a little confusing for end
users.
Fix it by only end the transaction if we have a valid trans handle,
other than returning from btrfs_qgroup_rescan_worker().
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/qgroup.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 9f3886d128d3..afac7402af36 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3986,10 +3986,8 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
complete_all(&fs_info->qgroup_rescan_completion);
mutex_unlock(&fs_info->qgroup_rescan_lock);
- if (!trans)
- return;
-
- btrfs_end_transaction(trans);
+ if (trans)
+ btrfs_end_transaction(trans);
if (stopped) {
btrfs_info(fs_info, "qgroup scan paused");
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] btrfs: qgroup: show the "qgroup scan cancelled" message correctly
2026-11-20 9:08 [PATCH 0/3] btrfs: qgroup: rescan related message minor fixes Qu Wenruo
2026-11-20 9:08 ` [PATCH 1/3] btrfs: qgroup: handle the transaction commit error during rescan Qu Wenruo
2026-11-20 9:08 ` [PATCH 2/3] btrfs: qgroup: ensure the qgroup rescan messages are always shown Qu Wenruo
@ 2026-11-20 9:08 ` Qu Wenruo
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2026-11-20 9:08 UTC (permalink / raw)
To: linux-btrfs
There are several reasons why we won't output the "qgroup scan cancelled"
message:
- We always clear BTRFS_QGROUP_RUNTIME_BIT_CANCEL_RESCAN before the
message check
So that test_bit() will never return true.
- @stopped has a higher priority
When a rescan is cancelled, it has a high chance to be caught by
rescan_should_stop(), so in that case @stopped is also true.
Then when checking which message to output, @stopped has a higher
priority, thus it shows the rescan as paused instead.
Fix the problem by:
- Save the previous CANCEL_RESCAN flag into @cancelled, and check that
variable instead
- Change the message priority so that cancelled has a higher priority
And for @stopped/@cancelled check, if they hit, output the message and
return. So we don't need the complex "if () {} else if () {}" logic
anymore.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/qgroup.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index afac7402af36..3be159541e4c 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3900,6 +3900,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
struct btrfs_path *path;
struct btrfs_trans_handle *trans = NULL;
int ret = 0;
+ bool cancelled = false;
bool stopped = false;
bool did_leaf_rescans = false;
@@ -3982,18 +3983,24 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
}
}
fs_info->qgroup_rescan_running = false;
- clear_bit(BTRFS_QGROUP_RUNTIME_BIT_CANCEL_RESCAN, &fs_info->qgroup_flags);
+ cancelled = test_and_clear_bit(BTRFS_QGROUP_RUNTIME_BIT_CANCEL_RESCAN,
+ &fs_info->qgroup_flags);
complete_all(&fs_info->qgroup_rescan_completion);
mutex_unlock(&fs_info->qgroup_rescan_lock);
if (trans)
btrfs_end_transaction(trans);
+ if (cancelled) {
+ btrfs_info(fs_info, "qgroup scan cancelled");
+ return;
+ }
if (stopped) {
btrfs_info(fs_info, "qgroup scan paused");
- } else if (test_bit(BTRFS_QGROUP_RUNTIME_BIT_CANCEL_RESCAN, &fs_info->qgroup_flags)) {
- btrfs_info(fs_info, "qgroup scan cancelled");
- } else if (ret >= 0) {
+ return;
+ }
+
+ if (ret >= 0) {
btrfs_info(fs_info, "qgroup scan completed%s",
ret > 0 ? " (inconsistency flag cleared)" : "");
} else {
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-20 9:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 9:08 [PATCH 0/3] btrfs: qgroup: rescan related message minor fixes Qu Wenruo
2026-11-20 9:08 ` [PATCH 1/3] btrfs: qgroup: handle the transaction commit error during rescan Qu Wenruo
2026-11-20 9:08 ` [PATCH 2/3] btrfs: qgroup: ensure the qgroup rescan messages are always shown Qu Wenruo
2026-11-20 9:08 ` [PATCH 3/3] btrfs: qgroup: show the "qgroup scan cancelled" message correctly Qu Wenruo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.