All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] dm-bufio: per-client retain target, sysfs and dm-verity cache control
@ 2026-11-17 13:19 Yongpeng Yang
  2026-11-17 13:19 ` [PATCH 1/4] dm-bufio: make the retain target per client Yongpeng Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Yongpeng Yang @ 2026-11-17 13:19 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski
  Cc: dm-devel, Yongpeng Yang

From: Yongpeng Yang <yangyongpeng@xiaomi.com>

Device-mapper's verity targets read their hash trees, and FEC parity
when FEC is enabled, through dm-bufio.  dm-bufio has a single
module-wide retain_bytes value shared by every client, no way to see
or change one client's memory use, and no way to warm the cache ahead
of the reads that need it.

That fits poorly systems with many verified devices of very different
sizes, such as Android, which mounts a dozen verity partitions plus
per-app verified images: a large partition's hash tree (tens of MB) is
evicted and re-read under memory pressure with the 256 KiB default,
while raising the global value would make every small, idle verity
device hold memory it does not need, and would still be the wrong size
for most of them.  The same system also wants to preload a device's
hash blocks at boot and to release the memory when the device is no
longer in use, which today requires dropping caches globally.

This series adds per-client granularity to dm-bufio and lets dm-verity
size and manage its caches:

 1. Move the retain target into struct dm_bufio_client, initialized
    from the module parameter at creation.  The parameter keeps its
    meaning as the default for new clients.

 2. Add dm_bufio_client_sysfs_add(), publishing a client in sysfs
    under a caller-chosen kobject and name, with a writable
    retain_bytes and the rest of the state read-only.  It is opt-in,
    so targets that do not want it pay nothing.

 3. dm-verity: size the hash client's retain target as
    hash_retain_percent (default 10) of the hash area, and register
    the hash, FEC parity and FEC data clients under
    /sys/block/dm-N/dm-bufio/<hash|fec|fec-data>/.

 4. dm-verity: add messages to report or set a client's retain target
    and to prefetch or drop hash blocks, for warming the cache ahead
    of use and releasing it afterwards.

Nothing changes for existing users: every client starts with the value
the module parameter holds, and only dm-verity opts into sysfs.

Tested on a VM running v7.4-rc1: message and sysfs write paths, the
shrinker retain floor under memory pressure, 500 suspend/resume
cycles, 100 create/destroy cycles watching slab counters for leaks,
and error-path injection.  No kernel warnings.

Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
Assisted-by: LLM

Yongpeng Yang (4):
  dm-bufio: make the retain target per client
  dm-bufio: allow exposing a client in sysfs under a caller-chosen
    kobject
  dm-verity: size the hash retain target from the hash area
  dm-verity: add messages to inspect, prefetch and drop hash blocks

 .../ABI/testing/sysfs-kernel-dm-bufio         |  76 +++++++
 .../admin-guide/device-mapper/dm-bufio.rst    |  54 +++++
 .../admin-guide/device-mapper/index.rst       |   1 +
 .../admin-guide/device-mapper/verity.rst      |  42 ++++
 drivers/md/dm-bufio.c                         | 178 ++++++++++++++-
 drivers/md/dm-verity-target.c                 | 209 ++++++++++++++++++
 drivers/md/dm-verity.h                        |   2 +
 include/linux/dm-bufio.h                      |  15 ++
 8 files changed, 576 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-kernel-dm-bufio
 create mode 100644 Documentation/admin-guide/device-mapper/dm-bufio.rst

-- 
2.43.0


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

end of thread, other threads:[~2026-11-18  0:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 13:19 [PATCH 0/4] dm-bufio: per-client retain target, sysfs and dm-verity cache control Yongpeng Yang
2026-11-17 13:19 ` [PATCH 1/4] dm-bufio: make the retain target per client Yongpeng Yang
2026-11-18  0:41   ` Benjamin Marzinski
2026-11-17 13:19 ` [PATCH 2/4] dm-bufio: allow exposing a client in sysfs under a caller-chosen kobject Yongpeng Yang
2026-11-17 13:40   ` sashiko-bot
2026-11-17 13:19 ` [PATCH 3/4] dm-verity: size the hash retain target from the hash area Yongpeng Yang
2026-11-17 13:44   ` sashiko-bot
2026-11-17 13:19 ` [PATCH 4/4] dm-verity: add messages to inspect, prefetch and drop hash blocks Yongpeng Yang
2026-11-17 13:49   ` sashiko-bot

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.