All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: implement blk_holder_ops call backs
@ 2025-06-06  5:47 Qu Wenruo
  2025-06-06  5:47 ` [PATCH 1/2] btrfs: use fs_info as the block device holder Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2025-06-06  5:47 UTC (permalink / raw)
  To: linux-btrfs

Although test case generic/730 is going to be skipped for btrfs due to
the missing shutdown support, it still exposed a problem that btrfs has
no implementation for blk_holder_ops, thus even if lower level driver
wants to notify btrfs there is a device that is going to be removed,
btrfs can do nothing but ignore such critical info.

This series will implement all 4 callbacks for blk_holder_ops, 3 of them
are straightforward, just call the full-fs version of
sync/freeze/unfreeze.

The trickier one is the mark_dead(), all other fses with shutdown
support will shutdown the fs, making all operations to return error,
even if there is a cached page.

For btrfs we do not yet have full shutdown support, but at least we can
notify such problem through dmesg, then check if the fs can still
maintain its RW operations.
If not then mark the fs error, so no more new writes will happen,
preventing further data loss.

Now btrfs will output something like this if the only device of a btrfs
is removed, instead of aborting transaction later due to IO error:

 BTRFS info (device sda): devid 1 device sda path /dev/sda is going to be removed
 BTRFS: error (device sda) in btrfs_dev_mark_dead:294: errno=-5 IO failure (btrfs can no longer maintain read-write due to missing device(s))
 BTRFS info (device sda state E): forced readonly

Future full-fs shutdown will depend on this feature to properly pass
generic/730.

Qu Wenruo (2):
  btrfs: use fs_info as the block device holder
  btrfs: add a simple dead device detection mechanism

 fs/btrfs/dev-replace.c |  2 +-
 fs/btrfs/fs.h          |  2 -
 fs/btrfs/super.c       |  7 ++--
 fs/btrfs/super.h       |  2 +
 fs/btrfs/volumes.c     | 90 ++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/volumes.h     |  6 +++
 6 files changed, 99 insertions(+), 10 deletions(-)

-- 
2.49.0


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

end of thread, other threads:[~2025-06-06  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06  5:47 [PATCH 0/2] btrfs: implement blk_holder_ops call backs Qu Wenruo
2025-06-06  5:47 ` [PATCH 1/2] btrfs: use fs_info as the block device holder Qu Wenruo
2025-06-06  5:47 ` [PATCH 2/2] btrfs: add a simple dead device detection mechanism Qu Wenruo
2025-06-06  8:18 ` [PATCH 0/2] btrfs: implement blk_holder_ops call backs 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.