Patch "btrfs: improve the warning and error message for btrfs_remove_qgroup()" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    btrfs: improve the warning and error message for btrfs_remove_qgroup()

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     btrfs-improve-the-warning-and-error-message-for-btrf.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1ad5cb429fbc30f3cf290e6364e9d60343a6d435
Author: Qu Wenruo <wqu@xxxxxxxx>
Date:   Mon Nov 11 07:29:07 2024 +1030

    btrfs: improve the warning and error message for btrfs_remove_qgroup()
    
    [ Upstream commit c0def46dec9c547679a25fe7552c4bcbec0b0dd2 ]
    
    [WARNING]
    There are several warnings about the recently introduced qgroup
    auto-removal that it triggers WARN_ON() for the non-zero rfer/excl
    numbers, e.g:
    
     ------------[ cut here ]------------
     WARNING: CPU: 67 PID: 2882 at fs/btrfs/qgroup.c:1854 btrfs_remove_qgroup+0x3df/0x450
     CPU: 67 UID: 0 PID: 2882 Comm: btrfs-cleaner Kdump: loaded Not tainted 6.11.6-300.fc41.x86_64 #1
     RIP: 0010:btrfs_remove_qgroup+0x3df/0x450
     Call Trace:
      <TASK>
      btrfs_qgroup_cleanup_dropped_subvolume+0x97/0xc0
      btrfs_drop_snapshot+0x44e/0xa80
      btrfs_clean_one_deleted_snapshot+0xc3/0x110
      cleaner_kthread+0xd8/0x130
      kthread+0xd2/0x100
      ret_from_fork+0x34/0x50
      ret_from_fork_asm+0x1a/0x30
      </TASK>
     ---[ end trace 0000000000000000 ]---
     BTRFS warning (device sda): to be deleted qgroup 0/319 has non-zero numbers, rfer 258478080 rfer_cmpr 258478080 excl 0 excl_cmpr 0
    
    [CAUSE]
    Although the root cause is still unclear, as if qgroup is consistent a
    fully dropped subvolume (with extra transaction committed) should lead
    to all zero numbers for the qgroup.
    
    My current guess is the subvolume drop triggered the new subtree drop
    threshold thus marked qgroup inconsistent, then rescan cleared it but
    some corner case is not properly handled during subvolume dropping.
    
    But at least for this particular case, since it's only the rfer/excl not
    properly reset to 0, and qgroup is already marked inconsistent, there is
    nothing to be worried for the end users.
    
    The user space tool utilizing qgroup would queue a rescan to handle
    everything, so the kernel wanring is a little overkilled.
    
    [ENHANCEMENT]
    Enhance the warning inside btrfs_remove_qgroup() by:
    
    - Only do WARN() if CONFIG_BTRFS_DEBUG is enabled
      As explained the kernel can handle inconsistent qgroups by simply do a
      rescan, there is nothing to bother the end users.
    
    - Treat the reserved space leak the same as non-zero numbers
      By outputting the values and trigger a WARN() if it's a debug build.
      So far I haven't experienced any case related to reserved space so I
      hope we will never need to bother them.
    
    Fixes: 839d6ea4f86d ("btrfs: automatically remove the subvolume qgroup")
    Link: https://github.com/kdave/btrfs-progs/issues/922
    Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
    Reviewed-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index e70ed857fc743..4fcd6cd4c1c24 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1839,9 +1839,19 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
 	 * Thus its reserved space should all be zero, no matter if qgroup
 	 * is consistent or the mode.
 	 */
-	WARN_ON(qgroup->rsv.values[BTRFS_QGROUP_RSV_DATA] ||
-		qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC] ||
-		qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS]);
+	if (qgroup->rsv.values[BTRFS_QGROUP_RSV_DATA] ||
+	    qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC] ||
+	    qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS]) {
+		WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
+		btrfs_warn_rl(fs_info,
+"to be deleted qgroup %u/%llu has non-zero numbers, data %llu meta prealloc %llu meta pertrans %llu",
+			      btrfs_qgroup_level(qgroup->qgroupid),
+			      btrfs_qgroup_subvolid(qgroup->qgroupid),
+			      qgroup->rsv.values[BTRFS_QGROUP_RSV_DATA],
+			      qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PREALLOC],
+			      qgroup->rsv.values[BTRFS_QGROUP_RSV_META_PERTRANS]);
+
+	}
 	/*
 	 * The same for rfer/excl numbers, but that's only if our qgroup is
 	 * consistent and if it's in regular qgroup mode.
@@ -1850,8 +1860,9 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
 	 */
 	if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_FULL &&
 	    !(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)) {
-		if (WARN_ON(qgroup->rfer || qgroup->excl ||
-			    qgroup->rfer_cmpr || qgroup->excl_cmpr)) {
+		if (qgroup->rfer || qgroup->excl ||
+		    qgroup->rfer_cmpr || qgroup->excl_cmpr) {
+			WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
 			btrfs_warn_rl(fs_info,
 "to be deleted qgroup %u/%llu has non-zero numbers, rfer %llu rfer_cmpr %llu excl %llu excl_cmpr %llu",
 				      btrfs_qgroup_level(qgroup->qgroupid),




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux