Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Richard Weinberger <richard@nod.at>, linux-btrfs@vger.kernel.org
Cc: johannes.thumshirn@wdc.com
Subject: Re: qgroup rescan worker makes suspend fail
Date: Sun, 20 Sep 2026 09:08:33 +0930	[thread overview]
Message-ID: <72837ffa-61da-4ea1-9d98-ad2a350a955a@gmx.com> (raw)
In-Reply-To: <mu8fq8a8.b9a9a1ae-dd6b-45a4-a415-5db853d61536@nod.at>



在 2026/9/19 23:10, Richard Weinberger 写道:
> Once in a while, suspending my laptop just causes the screen to freeze.
> Initially, I thought Linux had crashed, but it usually recovers after 2 minutes,
> though the suspend doesn't actually happen. You can imagine this can be very
> unfortunate when you just close the laptop lid and pack the laptop into your
> bag...
> 
> After the problem started occurring more frequently, I investigated and found
> that the qgroup rescan worker is the problem. In dmesg, logs like these can
> usually be found:
> 
> [246013.777637] [ T278489] Freezing remaining freezable tasks
> [246033.780538] [ T278489] Freezing remaining freezable tasks failed after 20.003 seconds (0 tasks refusing to freeze, wq_busy=1):
> [246033.780576] [ T278489] Showing freezable workqueues that are still busy:
> [246033.780582] [ T278489] workqueue events_freezable: flags=0x104
> [246033.780590] [ T278489]   pwq 10: cpus=2 node=0 flags=0x0 nice=0 active=0 refcnt=2
> [246033.780609] [ T278489]     inactive: pci_pme_list_scan
> [246033.780642] [ T278489] workqueue btrfs-endio-meta: flags=0xe
> [246033.780649] [ T278489]   pwq 57: cpus=0-13 node=0 flags=0x4 nice=0 active=0 refcnt=2
> [246033.780660] [ T278489]     inactive: simple_end_io_work [btrfs]
> [246033.781183] [ T278489] workqueue btrfs-qgroup-rescan: flags=0x2000e
> [246033.781189] [ T278489]   pwq 56: cpus=0-13 flags=0x4 nice=0 active=1 refcnt=16
> [246033.781199] [ T278489]     in-flight: 205929:btrfs_work_helper [btrfs] for 111s
> [246033.781721] [ T278489] workqueue wg-kex-wginterproc: flags=0x6
> [246033.781726] [ T278489]   pwq 57: cpus=0-13 node=0 flags=0x4 nice=0 active=0 refcnt=2
> [246033.781736] [ T278489]     inactive: wg_packet_handshake_send_worker [wireguard]
> 
> My first thought was that the worker is likely not freezable, but it is.
> The problem is that the whole qgroup rescan is a single work item.
> In my case, such a scan can take up to 10 minutes, even though I have a
> fast NVMe SSD installed...
> 
> Wouldn't it make sense to have rescan_should_stop() return true when
> suspend starts? I think using a pm notifier could help here.
> What do you think?

Mind to try this diff? Although it requires certain pm freezing 
sequence, for now the kernel freezes the fs before processes, thus it 
should work:

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 05e35eb126dc..9ca81dfb9ee8 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3872,6 +3872,8 @@ static bool rescan_should_stop(struct 
btrfs_fs_info *fs_info)
                 return true;
         if (test_bit(BTRFS_QGROUP_RUNTIME_BIT_CANCEL_RESCAN, 
&fs_info->qgroup_flags))
                 return true;
+       if (fs_info->sb->s_writers.frozen > SB_UNFROZEN)
+               return true;
         return false;
  }

> 
> Thanks,
> //richard


  parent reply	other threads:[~2026-09-19 23:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 13:40 qgroup rescan worker makes suspend fail Richard Weinberger
2026-09-19 17:34 ` Johannes Thumshirn
2026-09-19 18:33   ` AW: " Richard Weinberger
2026-09-19 22:39   ` Qu Wenruo
2026-09-19 22:48     ` Qu Wenruo
2026-09-20  4:56     ` Andrei Borzenkov
2026-09-20  5:28       ` Qu Wenruo
2026-09-19 23:38 ` Qu Wenruo [this message]
2026-09-20 13:04   ` AW: " Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72837ffa-61da-4ea1-9d98-ad2a350a955a@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox