[PATCH v12 0/5] netfs, cachefiles: Changes for next, primarily occupancy tracking-related

David Howells dhowells at redhat.com
Thu Sep 10 15:02:35 PDT 2026


Hi Christian,

Could you pull these patches please into your vfs-7.4.netfs branch?  This
is the second of four batches, in this case dealing with cachefiles, and is
based upon the aforementioned branch.  This was split from v11 of a larger
netfslib series[1].

Cachefiles is modified to better implement caching for the class of files
that are opened new/truncated, written once sequentially with no seeking
and then closed (ie. the most common class):

 (1) The object type in the cachefiles file xattr is now correctly set to
     CACHEFILES_CONTENT_{SINGLE,ALL,BACKFS_MAP} rather than just being 0,
     to indicate whether we have one of: a single monolithic blob, all the
     data up to cache i_size with no holes or a sparse file with the data
     mapped by the backing file system (as currently upstream).

 (2) For "ALL" type files, the cache's i_size is used to track how much
     data is saved in the cache and no longer bears any relation to the
     netfs i_size.  The actual object size is stored in the xattr.

 (3) For most typical files which are contiguous and written progressively,
     the object type is now set to "ALL".  For anything else, cachefiles
     uses SEEK_DATA/HOLE to find extent outlines at before (this is the
     current behaviour and needs to be fixed, but in a separate set of
     patches as it's not trivial).

 (4) Reads of "ALL" type files can then skip the SEEK_DATA/HOLE step to
     determine the occupancy; backing file i_size and the object size field
     stored in the state xattr suffice.

Other changes are also made:

 (1) cachefile_do_prepare_read() is merged into cachefiles_prepare_read()
     now that the ondemand mode stuff got removed.

 (2) Some extra traces are added for write failure and insufficient space.

 (3) The state xattr on a cachefile is pre-set to try to avoid having to
     deal with ENOSPC from setxattr when committing the object.

The patches can also be found here:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-next-2

Thanks,
David

Changes
=======

ver #12)
- Split from v11 of "netfs: Keep track of folios in a segmented bio_vec[]
  chain"[1]

[1] https://lore.kernel.org/r/20260902173350.3468672-1-dhowells@redhat.com/

David Howells (5):
  cachefiles: Clean up cachefiles_do_prepare_read()
  netfs, cachefiles: Add a couple of traces for write failure
  cachefiles: Add a tracepoint to log insufficient space errors
  cachefiles: Don't rely on backing fs storage map for most use cases
  cachefiles: Preset the state xattr when creating a new file

 fs/afs/file.c                     |   1 -
 fs/cachefiles/interface.c         |  90 ++----
 fs/cachefiles/internal.h          |  14 +-
 fs/cachefiles/io.c                | 461 +++++++++++++++++++-----------
 fs/cachefiles/namei.c             |  34 +--
 fs/cachefiles/xattr.c             |  82 +++++-
 fs/netfs/buffered_read.c          | 188 +++++++-----
 fs/netfs/buffered_write.c         |   3 -
 fs/netfs/internal.h               |   2 +
 fs/netfs/objects.c                |   1 +
 fs/netfs/read_retry.c             |   2 +
 fs/netfs/read_single.c            |  40 +--
 fs/netfs/write_collect.c          | 132 +++++++--
 fs/netfs/write_issue.c            |  18 ++
 fs/netfs/write_retry.c            |   3 +
 include/linux/fscache.h           |  17 ++
 include/linux/netfs.h             |  38 ++-
 include/trace/events/cachefiles.h |  51 +++-
 include/trace/events/netfs.h      |  11 +-
 19 files changed, 785 insertions(+), 403 deletions(-)




More information about the linux-afs mailing list