Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: "Dongjiang Zhu" <zhudongjiang@fygo.io>
To: <linux-btrfs@vger.kernel.org>
Cc: <johannes.thumshirn@wdc.com>, <naohiro.aota@wdc.com>
Subject: [PATCH 0/4] btrfs: zoned: fix active-zone accounting and transitions
Date: Mon, 24 Aug 2026 14:49:52 +0800	[thread overview]
Message-ID: <cover.1787551793.git.zhudongjiang@fygo.io> (raw)

After systems using HC620 host-managed zoned devices were upgraded to
Linux 6.18, multiple users reported transaction writeback failures with
-EAGAIN that forced filesystems read-only, as well as hung tasks.

Enforcing the device's max_active_zones=128 limit exposed existing
active-zone handling problems.  We reproduced representative cases
locally, including an -EAGAIN transaction abort that forced the filesystem
read-only and a balance self-deadlock that stalled transaction commit and
data writers.

Further investigation traced these failures to several related gaps in
Btrfs active-zone handling around mount recovery, non-data block group
activation and zone finishing:

- Conventional zones participate in runtime active-zone accounting, but
  that state cannot be reconstructed from device zone conditions at mount.
- Active metadata and system block groups are reconstructed at mount, but
  their runtime write roles are not.
- An obsolete allocation-time activation helper bypasses the write-time
  role pivot and can recursively enter zone finishing.
- do_zone_finish() clears the active state before the device operation has
  released the active-zone slot.

Together, these bugs can leave no active-zone slot available to metadata
or system writeback, or recursively enter zone finishing while holding
ro_block_group_mutex, resulting in the two failure modes described above.

Fix the active-zone model and its state transitions as follows:

1. Track only sequential zones as active.
2. Recover the normal metadata and system write roles on mount, and finish
   extra active block groups left by the old behavior.
3. Remove the obsolete allocation-time non-data activation helper so
   metadata and system activation goes through the write-time role pivot.
4. Serialize concurrent finish operations on the same block group and keep
   it active until the device operation and software cleanup complete.

The individual commits contain the corresponding reproduction conditions,
kernel stacks and state-transition traces.

Dongjiang Zhu (4):
  btrfs: zoned: track only sequential zones as active
  btrfs: zoned: recover active non-data block group roles on mount
  btrfs: zoned: remove obsolete non-data block group activation helper
  btrfs: zoned: serialize zone finishing per block group

 fs/btrfs/block-group.c |  38 +++-----
 fs/btrfs/block-group.h |   7 +-
 fs/btrfs/disk-io.c     |   7 +-
 fs/btrfs/fs.h          |   4 +
 fs/btrfs/zoned.c       | 193 ++++++++++++++++++++++++++++-------------
 fs/btrfs/zoned.h       |   9 +-
 6 files changed, 160 insertions(+), 98 deletions(-)

-- 
2.39.5

             reply	other threads:[~2026-08-24  6:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24  6:49 Dongjiang Zhu [this message]
2026-08-24  6:49 ` [PATCH 1/4] btrfs: zoned: track only sequential zones as active Dongjiang Zhu
2026-08-24 13:55   ` Johannes Thumshirn
2026-08-24 22:40     ` Qu Wenruo
2026-08-25  9:10       ` Johannes Thumshirn
2026-08-25  3:01     ` Dongjiang Zhu
2026-08-24  6:49 ` [PATCH 2/4] btrfs: zoned: recover active non-data block group roles on mount Dongjiang Zhu
2026-08-24 14:42   ` Johannes Thumshirn
2026-08-25  3:08     ` Dongjiang Zhu
2026-08-25 10:02       ` Johannes Thumshirn
2026-08-24  6:49 ` [PATCH 3/4] btrfs: zoned: remove obsolete non-data block group activation helper Dongjiang Zhu
2026-08-24 15:51   ` Johannes Thumshirn
2026-08-24  6:49 ` [PATCH 4/4] btrfs: zoned: serialize zone finishing per block group Dongjiang Zhu
2026-08-24 16:00   ` Johannes Thumshirn
2026-08-25  3:16     ` Dongjiang Zhu

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=cover.1787551793.git.zhudongjiang@fygo.io \
    --to=zhudongjiang@fygo.io \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /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