Skip to content

super: convert to a plain hashtable

Christian Brauner linux-btrfs linux-erofs linux-fsdevel 1 version In review

Get series with b4
b4 am [email protected] change-id 20261011-work-super-dev_hash-e30f79361408

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2selftests/filesystems: add a test for freezing a shared block devicetools/testing/selftests/filesystems/freeze/.gitignore tools/testing/selftests/filesystems/freeze/Makefile tools/testing/selftests/filesystems/freeze/config +1 more+482 -10 replies
2/2super: convert to plain hashtableblock/bdev.c fs/internal.h fs/namespace.c +2 more+145 -2031 reply

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/2] super: convert to a plain hashtable

This sits on top of the superblock fixes for v7.3.

Convert the rhltable to a plain hashtable under a spinlock. The walks keep their place with a cursor entry in the chain. A claim is unhashed the moment it's dropped and a walk that finds a superblock that isn't born yet waits for it to be born or to die and looks again. Since hashing can't fail anymore the entry for the superblock's own s_dev is embedded in struct super_block and the preallocation in alloc_super() goes away. This all simplifies things quite a lot.

It also fixes a btrfs bug where fs_bdev_freeze() ended up freezing a btrfs filesystem through a stale member that open_ctree() had already released while the freeze was waiting for SB_BORN. The resume doesn't find a holder for that device anymore so the filesystem stays frozen for good.

The selftest freezes a device that several erofs superblocks share. That's the one case where a device legitimately carries claims from more than one superblock and it checks that a suspend freezes each of them exactly once and that mounts coming and going under a suspended device leave nothing frozen behind.

I modeled the table in TLA+ and checked the real list code with CBMC. Both agree with the design.

---
Christian Brauner (2):
selftests/filesystems: add a test for freezing a shared block device
super: convert to plain hashtable

 block/bdev.c                                       |   2 +-
 fs/internal.h                                      |   1 -
 fs/namespace.c                                     |   2 -
 fs/super.c                                         | 332 ++++++--------
 include/linux/fs/super_types.h                     |  11 +-
 .../selftests/filesystems/freeze/.gitignore        |   1 +
 .../testing/selftests/filesystems/freeze/Makefile  |   2 +-
 tools/testing/selftests/filesystems/freeze/config  |   1 +
 .../filesystems/freeze/shared_bdev_test.c          | 479 +++++++++++++++++++++
 9 files changed, 627 insertions(+), 204 deletions(-)

---
base-commit: 16efce55f70b6093dbe53bffb8e79fb0e08a95b6
change-id: 20261011-work-super-dev_hash-e30f79361408