All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] dm-bufio per-client retain and dm-verity cache control
@ 2026-11-21  8:41 Yongpeng Yang
  2026-11-21  8:41 ` [PATCH v4 1/4] dm-bufio: make the retain target per client Yongpeng Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yongpeng Yang @ 2026-11-21  8:41 UTC (permalink / raw)
  To: agk, bmarzins, mpatocka, snitzer, okozina, zkabelac, dm-devel
  Cc: yangyongpeng

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.  The hash areas we see range from a few MB to
tens of MB: with the 256 KiB default, a large partition's hash blocks
are evicted under memory pressure and re-read later, while a uniform
large value makes every cold, idle device hold memory it does not
need -- and most verity devices are cold most of the time.  What is
wanted is a lifecycle: prefetch when the device is about to be used,
drop when it goes cold again.

This series adds per-client granularity to dm-bufio and gives
dm-verity message-based control over its caches:

 1. Move the retain target into struct dm_bufio_client, initialized
    from the module parameter at creation, and export set/get plus a
    cached-buffer count.  The parameter keeps its meaning as the
    default for new clients.

 2. dm-verity: size the hash client's retain target as
    hash_retain_percent (default 10) of the hash area, so a small
    device keeps little and a large one keeps enough.

 3. dm-verity: add the retain_bytes message to report or set a
    client's retain target; the reply also reports current_bytes and
    buffers, so memory use can be watched through the message.

 4. dm-verity: add prefetch_hash and drop_hash messages to warm the
    cache ahead of use and release it afterwards.  Both are rejected
    with -EBUSY while the device is suspended.

Nothing changes for existing users: every client starts with the
value the module parameter holds.

The code, commit messages and documentation were drafted with
assistance from an AI coding assistant, from prompts describing the
desired behaviour and review feedback; the result was reviewed,
reworked and tested by hand.

Changes since v2:
 - The sysfs interface (per-client directories, ABI documentation and
   the suspend/reload handling around them) is dropped entirely, per
   Mikulas Patocka: state is better shown through the message
   interface.  The retain_bytes reply now carries current_bytes and
   buffers instead.

Changes since v3:
 - prefetch_hash and drop_hash now fail with -EBUSY while the device
   is suspended, so no new I/O is issued against the quiesced device
   and no message can race the bufio reset in postsuspend.  The check
   needs no further serialization: __dm_suspend() sets the suspended
   flag before the final synchronize_srcu() that precedes
   ->postsuspend, so a message that passed the check is drained by
   that barrier before the reset (sashiko).

Tested on a VM running v7.4-rc1: message write paths and the memory
reporting in the reply, the shrinker retain floor under memory
pressure, prefetch/drop lifecycles, suspend/resume cycles, a
prefetch-spam-during-suspend stress loop, and error-path injection.
No kernel warnings.

[1] v1: https://lore.kernel.org/all/20261117131918.2745193-1-yangyongpeng.storage@gmail.com/
[2] v2: https://lore.kernel.org/all/20261118172133.689163-1-yangyongpeng.storage@gmail.com/
[3] v3: https://lore.kernel.org/all/20261119163110.1630269-1-yangyongpeng.storage@gmail.com/

Comments welcome.

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

Yongpeng Yang (4):
  dm-bufio: make the retain target per client
  dm-verity: size the hash retain target from the hash area
  dm-verity: add retain_bytes message to inspect and tune the cache
    floor
  dm-verity: add messages to prefetch and drop the hash cache

 .../admin-guide/device-mapper/verity.rst      |  40 ++++
 .../admin-guide/kernel-parameters.txt         |   6 +
 drivers/md/dm-bufio.c                         |  41 +++-
 drivers/md/dm-verity-target.c                 | 209 +++++++++++++++++-
 include/linux/dm-bufio.h                      |   8 +
 5 files changed, 301 insertions(+), 3 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-11-21  8:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  8:41 [PATCH v4 0/4] dm-bufio per-client retain and dm-verity cache control Yongpeng Yang
2026-11-21  8:41 ` [PATCH v4 1/4] dm-bufio: make the retain target per client Yongpeng Yang
2026-11-21  8:41 ` [PATCH v4 2/4] dm-verity: size the hash retain target from the hash area Yongpeng Yang
2026-11-21  8:41 ` [PATCH v4 3/4] dm-verity: add retain_bytes message to inspect and tune the cache floor Yongpeng Yang
2026-11-21  8:41 ` [PATCH v4 4/4] dm-verity: add messages to prefetch and drop the hash cache Yongpeng Yang
2026-11-21  8:55   ` 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.