public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] btrfs: DEV_STATS item related minor fixes
@ 2026-04-07  9:33 Qu Wenruo
  2026-04-07  9:33 ` [PATCH 1/4] btrfs: remove the dev stats item for replace target device Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Qu Wenruo @ 2026-04-07  9:33 UTC (permalink / raw)
  To: linux-btrfs

[BACKGROUND]
DEV_STATS (objectid, not type) items are storing the error counts for
each device. It's updated every time an error is hit, including
the following types:

- READ errors
- WRITE errors
- FLUSH errors
  Above alls are all errors directly returned from the device.

- CORRUPTION errors
  Aka, checksum mismatch.

- GENERATION errors
  Metadata generation mismatch.

[MINOR BUGS]
Recently when debugging an error reported about rejected dev-replace,
the device tree dump includes a DEV_STATS item for devid 0.

I'm wondering if that DEV_STATS item will ever be deleted, but
unfortunately it will never be deleted.

Normally it's not a big deal, as the DEV_STATS are normally all zeros.

But if it's not, and a new dev-replace is started and interrupted, at
the next mount the replace target device will suddenly inherit all the
error records, giving end users false alerts about a completely good
device.

[FIX]
The first 2 are manually removing the DEV_STATS items when dev-replace
and dev-removal finishes.

The 3rd patch is a more generic fix by forcing btrfs to update/create
DEV_STATS item after a new device is added.
This means for patched kernels, even there is some old DEV_STATS left,
the kernel will never re-use them during device add or dev-replace.

The last one is to reduce unnecessary DEV_STATS updates.

Qu Wenruo (4):
  btrfs: remove the dev stats item for replace target device
  btrfs: remove the dev stats item when removing a device
  btrfs: always update/create the dev stats item when adding a new
    device
  btrfs: avoid unnecessary dev stats updates

 fs/btrfs/dev-replace.c | 11 +++++++++-
 fs/btrfs/volumes.c     | 48 ++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/volumes.h     |  1 +
 3 files changed, 57 insertions(+), 3 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-13 22:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  9:33 [PATCH 0/4] btrfs: DEV_STATS item related minor fixes Qu Wenruo
2026-04-07  9:33 ` [PATCH 1/4] btrfs: remove the dev stats item for replace target device Qu Wenruo
2026-04-07  9:33 ` [PATCH 2/4] btrfs: remove the dev stats item when removing a device Qu Wenruo
2026-04-07  9:34 ` [PATCH 3/4] btrfs: always update/create the dev stats item when adding a new device Qu Wenruo
2026-04-07  9:34 ` [PATCH 4/4] btrfs: avoid unnecessary dev stats updates Qu Wenruo
2026-04-13 18:59 ` [PATCH 0/4] btrfs: DEV_STATS item related minor fixes David Sterba
2026-04-13 21:58   ` Qu Wenruo
2026-04-13 22:03     ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox