Skip to content

btrfs: introduce btrfs specific bdev holder ops and implement mark_dead() call back

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 4 repliesIn review
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- Extra patches to properly handle fs mounting/unmounting races

- Harden freeze/thaw races
As they can be called on a per-fs and per-bdev basis, can cause extra races.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: use fs_info as the block device holderfs/btrfs/dev-replace.c fs/btrfs/fs.h fs/btrfs/super.c +1 more+4 -70 replies
2/4btrfs: replace fput() with bdev_fput() for block devicesfs/btrfs/dev-replace.c fs/btrfs/ioctl.c fs/btrfs/volumes.c+12 -120 replies
3/4btrfs: implement a basic per-block-device call backsfs/btrfs/dev-replace.c fs/btrfs/disk-io.c fs/btrfs/fs.h +4 more+130 -80 replies
4/4btrfs: add a simple dead device detection mechanismfs/btrfs/volumes.c fs/btrfs/volumes.h+53 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] btrfs: introduce btrfs specific bdev holder ops and implement mark_dead() call back

[CHANGELOG]
v2:
- Extra patches to properly handle fs mounting/unmounting races

- Harden freeze/thaw races
As they can be called on a per-fs and per-bdev basis, can cause extra races.

Btrfs doesn't implement any callbacks of blk_holder_ops, this means:

- No sync/freeze/thaw support for an opened btrfs device Not sure if this is the root cause of btrfs + hiberantion data loss, but it won't hurt if we have such support.

- No ability to detect dead device at runtime
Meaning we can have "living" dead device in btrfs, the worst case is generic/730, that the single device of a btrfs is removed, and btrfs just abort transaction when it fails to write the transaction.

This series improve the situation by:

- Use a per-fs holder for block device
This is a dependency to implement proper blk_holder_ops, as we need a way to grab the fs_info from a block device.

- Use bdev_fput() for btrfs devices
This ensures the bdev holder reclaim will not be delayed, thus ensure the fs_info's lifespan is always covering any opened block devices.

This is another dependency to implement blk_holder_ops, or we can grab an fs_info which is already released.

- Implement per-bdev sync/freeze/thaw callbacks
This has a special requirement for freeze/thaw, as freeze/thaw can be triggered from two different paths, by ioctl (aka, per-fs) and by block device (aka, per-bdev).

This means for the worst case, per-fs and per-dev freezing/thawing can race with each other, and this requires fs level serialization.

- Implement the mark_dead() call back
This will automatically mark the dead devices as missing, and degrade the fs.

Furthermore, if the remaining devices can no longer maintain RW operations, immediately mark the fs as error (thus also read-only) to prevent further data loss.

Qu Wenruo (4):
btrfs: use fs_info as the block device holder
btrfs: replace fput() with bdev_fput() for block devices
btrfs: implement a basic per-block-device call backs
btrfs: add a simple dead device detection mechanism

 fs/btrfs/dev-replace.c |   4 +-
 fs/btrfs/disk-io.c     |  11 +++
 fs/btrfs/fs.h          |  14 +++-
 fs/btrfs/ioctl.c       |   4 +-
 fs/btrfs/super.c       |  27 ++++++--
 fs/btrfs/super.h       |   2 +
 fs/btrfs/volumes.c     | 154 +++++++++++++++++++++++++++++++++++++----
 fs/btrfs/volumes.h     |   6 ++
 8 files changed, 197 insertions(+), 25 deletions(-)
Signature · 1 line
2.49.0