diff options
| author | Chao Shi <coshi036@gmail.com> | 2026-08-06 12:58:25 -0400 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-09-10 09:27:23 +0200 |
| commit | 781bf9c7e307910a843d019251f174d22796a005 (patch) | |
| tree | cdb5361060d0d1cda645ade115c7d7cb188e6e10 /tools/perf/scripts/python | |
| parent | 1aeacc2cbf86eb522c3add7626477a4439048f8c (diff) | |
buffer: allow a buffer_head to point at memory outside the page cache
jbd2 builds a temporary buffer_head to write out the frozen copy of a
metadata block, and that copy lives in slab memory. Today jbd2 points the
temporary buffer at the slab folio backing it. A slab folio's ->mapping is
not an address_space, so anything that follows bh->b_folio->mapping there
gets garbage rather than NULL; mark_buffer_write_io_error() does exactly
that, and we are about to start calling it on this buffer.
Rather than teach every such helper about slab folios, allow bh->b_folio to
be NULL and let b_data point straight at the memory. Code that needs the
folio has to check. There are two places in this file:
- __bh_submit() adds the data by virtual address using
bio_add_virt_nofail(), and skips the cgroup accounting: a buffer that is
not in the page cache has no owning folio to attribute writeback to.
- buffer_set_crypto_ctx() returns early. fscrypt has no interest in a
buffer that is not part of a file mapping, which is why it already
returns when the folio has no mapping.
Nothing sets b_folio to NULL yet, so this patch is a no-op on its own.
A buffer_head without a folio is a narrow thing, not a new general
capability. Most of the buffer_head API assumes a folio and will fault or
corrupt state without one - touch_buffer(), bh_offset(), the async read
completion path, and plenty more - so it is up to whoever builds such a
buffer to keep it away from all of that. What NULL buys us is that getting
it wrong fails loudly instead of quietly following a slab folio's
overloaded ->mapping. It is also only valid over memory that is always
mapped: buffers over highmem have no permanent kernel virtual address,
which is why folio_set_bh() records a folio and an offset instead.
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Weidong Zhu <weizhu@fiu.edu>
Signed-off-by: Chao Shi <coshi036@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/bb6fab2111a48d7ba61887fc1372362576fce6e6.1785951556.git.coshi036@gmail.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
