netfs: Keep track of folios in a segmented bio_vec[] chain
Subsystems (13)
David Howells
maintainerv5 cover netfs: Keep track of folios in a segmented bio_vec[] chain
Hi Christian,
Could you add these patches to the VFS tree for next?
The patches get rid of folio_queue, rolling_buffer and ITER_FOLIOQ, replacing the folio queue construct used to manage buffers in netfslib with one based around a segmented chain of bio_vec arrays instead. There are three main aims here:
(1) The kernel file I/O subsystem seems to be moving towards consolidating on the use of bio_vec arrays, so embrace this by moving netfslib to keep track of its buffers for buffered I/O in bio_vec[] form.
(2) Netfslib already uses a bio_vec[] to handle unbuffered/DIO, so the number of different buffering schemes used can be reduced to just a single one.
(3) Always send an entire filesystem RPC request message to a TCP socket with single kernel_sendmsg() call as this is faster, more efficient and doesn't require the use of corking as it puts the entire transmission loop inside of a single tcp_sendmsg().
For the replacement of folio_queue, a segmented chain of bio_vec arrays rather than a single monolithic array is provided:
struct bvecq {
struct bvecq *next;
struct bvecq *prev;
unsigned long long fpos;
refcount_t ref;
u32 priv;
u16 nr_slots;
u16 max_slots;
enum bvecq_mem mem_type:2;
bool inline_bv:1;
bool discontig:1;
struct bio_vec *bv;
struct bio_vec __bv[];
};The fields are:
(1) next, prev - Link segments together in a list. I want this to be NULL-terminated linear rather than circular to make it possible to arbitrarily glue bits on the front.
(2) fpos, discontig - Note the current file position of the first byte of the segment and whether this bvecq is discontiguous with the previous. When accessing the pagecache to clear flags/locks, the fpos can be used to look up folios by file position rather than by finding those folios from the info stored in the bio_vecs.
When the file position is relevant, the model I'm working with is that all the segments pointed to by a single bvecq must represent contiguous data, but adjacent bvecqs within a chain need not be contiguous. This allows a bvecq chain to be used to provide bufferage for a sparse read or write RPC such as can be done with Ceph.
If a bvecq segment is not contiguous with the previous one, ->discontig should be set (this is technically redundant if one keeps track of the fpos as a bvecq chain is processed).
Note that the beginning and end file positions in a segment need not be aligned to any filesystem block size.
(3) ref - Refcount. Each bvecq keeps a ref on the next. I'm not sure this is entirely necessary, but it makes sharing slices easier.
(4) priv - Private data for the owner. Dispensible; currently only used for storing a debug ID for tracing in a patch not included here.
(5) max_slots, nr_slots. The size of bv[] and the number of slots used. I've assumed a maximum of 65535 bio_vecs in the array (which would represent a ~1MiB allocation).
(6) bv, __bv, inline_bv. bv points to the bio_vec[] array handled by this segment. This may begin at __bv and if it does inline_bv should be set (otherwise it's impossible to distinguish a separately allocated bio_vec[] that follows immediately by coincidence).
(7) mem_type. Indicates how the memory attached to the bio_vecs should be disposed of when the bvecq is destroyed. It can be one of:
BVECQ_MEM_EXTERNAL - Externally tracked ref; don't put
BVECQ_MEM_PAGECACHE - Pagecache; must be put
BVECQ_MEM_GUP - Pinned by from GUP; needs unpin
BVECQ_MEM_ALLOCED - Plain alloc'd pages; can be mempooled
[!] I'm not sure that this is a good name for this member or for the
enum values.
I've also defined an iov_iter iterator type ITER_BVECQ to walk this sort of construct so that it can be passed directly to sendmsg() or block-based DIO (as cachefiles does).
This series makes the following changes to netfslib:
(1) The folio_queue chain used to hold folios for buffered I/O is replaced with a bvecq chain. Each bio_vec then holds (a portion of) one folio. Each bvecq holds a contiguous sequence of folios, but adjacent bvecqs in a chain may be discontiguous.
(2) For unbuffered/DIO, the source iov_iter is extracted into a bvecq chain.
(3) An abstract position representation ('bvecq_pos') is created that can used to hold a position in a bvecq chain. For the moment, this takes a ref on the bvecq it points to, but that may be excessive.
(4) Buffer tracking is managed with three cursors: The load_cursor, at which new folios are added as we go; the dispatch_cursor, at which new subrequests' buffers start when they're created; and the collect_cursor, the point at which folios are being unlocked.
Not all cursors are necessarily needed in all situations and during buffered writeback, we need a dispatch cursor per stream (one for the network filesystem and one for the cache).
(5) ->prepare_read(), buffer setting up and ->issue_read() are merged, as are the write variants, with the filesystem calling back up to netfslib to prepare its buffer. This simplifies the process of setting up a subrequest. It may even make sense to have the filesystem allocate the subrequest.
(6) Retry dispatch tracking is added to netfs_io_request so that the buffer preparation functions can find it. Retry requires an additional buffer cursor.
(7) Netfslib dispatches I/O by accumulating enough bufferage to dispatch at least one subrequest, then looping to generate as many as the filesystem wants to (they may be limited by other constraints, e.g. max RDMA segment count or negotiated max size). This loop could be moved down into the filesystem. A new method is provided by which netfslib can ask the filesystem to provide an estimate of the data that should be accumulated before dispatch begins.
(8) Reading from the cache is now managed by querying the cache to provide a list of the next two data extents within the cache.
(9) AFS directories are switched to using a bvecq rather than a folio_queue to hold their contents.
(10) CIFS is switch to using a bvecq rather than a folio_queue for holding a temporary encryption buffer.
(11) CIFS RDMA is given the ability to extract ITER_BVECQ and support for extracting ITER_FOLIOQ is removed.
(12) All the folio_queue and rolling_buffer code is removed.
Cachefiles is also modified:
(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 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).
Two further things that I'm working on (but not in this branch) are:
(1) Make it so that a filesystem can be given a copy of a subchain which it can then tack header and trailer protocol elements upon to form a single message (I have this working for cifs) and even join copies together with intervening protocol elements to form compounds.
(2) Make it so that a filesystem can 'splice' out the contents of the TCP receive queue into a bvecq chain. This allows the socket lock to be dropped much more quickly and the copying of data read to the destination buffers to happen without the lock. I have this working for cifs too. Kernel recvmsg() doesn't then block kernel sendmsg() for anywhere near as long.
There are also some things I want to consider for the future:
(1) Create one or more batched iteration functions to 'unlock' all the folios in a bio_vec[], where 'unlock' is the appropriate action for ending a read or a write. Batching should hopefully also improve the efficiency of wrangling the marks on the xarray. Very often these marks are going to be represented by contiguous bits, so there may be a way to change them in bulk.
(2) Rather than walking the bvecq chain to get each individual folio out via bv_page, use the file position stored on the bvecq and the sum of bv_len to iterate over the appropriate range in i_pages.
(3) Change iov_iter to store the initial starting point and for iov_iter_revert() to reset to that and advance. This would (a) help prevent over-reversion and (b) dispense with the need for a prev pointer.
(4) Use bvecq to replace scatterlist. One problem with replacing scatterlist is that crypto drivers like to glue bits on the front of the scatterlists they're given (something trivial with that API) - and this is one way to achieve it.
The patches can also be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-next
Thanks,
David
Changes
=======
ver #5)
- Rebase on v7.2-rc2 as that has a bunch of outstanding netfs and afs bugfixes included.
ver #4)
- Fixed a number of bugs reported by Sashiko[3].
- Added a patch to fix an underflow in iov_iter_extract_xarray_pages().
- Added a patch to fix alloc failure in iov_iter_extract_bvec_pages().
- Added a patch to remove an unused var in kunit code.
- Added a patch to fix the folio offset in extract_xarray_to_sg().
- Added a patch to fix the exclusion over writeback to make it cover collection too.
- Fixed double fput() in cachefiles.
- Fixed the collection of cache writes to handle cancellation better.
- Fixed iterate_bvecq() to skip bvecq structs with nr_slots==0.
- Add a comment into iterate_bvecq() that a slot with bv_len>0 must have a valid bv_page.
- Fixed iov_iter_bvecq_advance(), iov_iter_bvecq_revert(), iter_count_bvecq_pages(), iov_iter_extract_bvecq_pages() and extract_bvecq_to_sg() to correctly handle empty bvecqs.
- Fixed extract_bvecq_to_sg() to be limited by iter->count.
- Fixed bvecq_expand_buffer() to take an unsigned size param.
- Fixed bvecq_expand_buffer() to not mix memory types in alloc'd bvecqs.
- Fixed bvecq_shorten_buffer() occasional retention of zero-length slots.
- Fixed slot validity check polarity in bvecq_pos_advance(); also don't use inner loop otherwise break then exits the wrong loop.
- Fixed bvecq_zero(), bvecq_slice() and bvecq_extract to use a barrier when
checking bq->nr_slots.
- Restructured bvecq_zero() to be similar to bvecq_pos_advance().
- Fixed an off-by-one error in bvecq_pos_step() and added a missing slot
reset.
- Fixed a break in netfs_extract_iter() that should have been a goto.
- Fixed netfs_extract_iter() to limit number of pages extracted to remnant
of max_pages.
- Fixed an uninit var in afs_do_read_symlink().
- Fixed netfs_read_gaps() to fill a multipart bvecq chain correctly.
- Fixed netfs_dispatch_unbuffered_reads() to initialise collect_cursor as
netfs_rreq_assess_dio() uses it to flush the data read.
- Fixed netfs_extract_iter() to init the slot counter outside the extract
loop to avoid overwriting already loaded slots.
- Fixed callers of bvecq_delete_spent() to update bvecq_pos::slot before
calling.
- Fixed netfs_reissue_write() to make sure subreq->content is unset before
setting.
- Altered netfs_extract_iter() to free any allocated bvecq chain if no pages
were extracted and an error occurred (and to initialise the return
pointer to NULL). Also, made it return an empty bvecq if nothing was
extracted, but no error occurred.
- Fixed ceph_netfs_issue_read() to just return if
ceph_netfs_issue_op_inline() returns anything other than 1 to avoid a
double termination.
- Fixed ceph_netfs_issue_read() to do the size calculation in the right
order to avoid the op expanding to larger than the buffer.
- Fixed netfs_issue_read(), in the NETFS_FILL_WITH_ZEROES case, to deduct
subreq->len from stream->buffered rather than just setting it to 0.
- Fixed netfs_perform_write() to put the folio if netfs_advance_writethrough()
fails.
- Restored the old ->prepare_write op specifically for
fscache_write_to_cache() which is still used by Ceph.
- Fixed undefined return in netfs_pgpriv2_issue_stream().
- Fixed netfs_collect_write_results() to try to make sure a request isn't
left paused if there are no further server-bound subreqs.
- Fixed netfs_queue_wb_folio() to redirty the folio before unlocking it if
it can't allocate a bvecq.
- Fixed netfs_writepages() to cancel the pagecache iteration after ENOMEM.
- Fixed netfs_advance/end_writethrough() to advance the dispatch cursor.
- Fixed netfs_retry_read_subrequests() to use barriers when walking
stream->subrequests as the app may add another subreq before pausing.
- Fixed netfs_prepare_write_retry_buffer() to use ->retry_start and
->retry_buffered rather than ->issue_from and ->buffered.
- Fixed netfs_retry_write_stream() to use barriers when walking
stream->subrequests as the app may add another subreq before pausing. - Fixed netfs_retry_write_stream() to check the correct length when adding additional subreqs.
- Fixed nfs_netfs_issue_read() to set -ENOMEM, not 0, on alloc failure.
- Fixed nfs_netfs_issue_read() to only terminate the subreq once.
- Fixed cifs_issue_read() to release the credits if cifs_reopen_file() fails.
- Rebased on v7.1.
ver #3)
- Rebased to -rc7 as the patches wouldn't apply for Christian.
- Prepended a fix for a warning from generic/464 (the problem also exists upstream, just not the warning).
- Renamed kmap_local_bvec() to bvec_kmap_partial() as requested by Christoph.
- Adjusted smbdirect patch descriptions as requested by Stefan Metzmacher.
ver #2)
- Fixed a number of bugs reported by Sashiko[1].
- Split a bunch of fixes out and posted them separately[2].
[1] https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com
[2] https://lore.kernel.org/linux-fsdevel/20260512-infozentrum-becher-7f86c47c96c8@brauner/T/#t
[3] https://sashiko.dev/#/patchset/20260608145432.681865-1-dhowells%40redhat.com
David Howells (21):
mm: Make readahead store folio count in readahead_control
netfs: Bulk load the readahead-provided folios up front Add a function to kmap one page of a multipage bio_vec
iov_iter: Make iov_iter_get_pages*() wrap iov_iter_extract_pages()
iov_iter: Add a segmented queue of bio_vec[]
netfs: Add some tools for managing bvecq chains
netfs: Add a function to extract from an iter into a bvecq
afs: Use a bvecq to hold dir content rather than folioq
cifs: Use a bvecq for buffering instead of a folioq
smbdirect: Support ITER_BVECQ in smbdirect_map_sges_from_iter()
cachefiles: Don't rely on backing fs storage map for most use cases
netfs: Add the cache object ID to netfs_read/write tracepoints
netfs: Switch to using bvecq rather than folio_queue and
rolling_buffer
smbdirect: Remove support for ITER_FOLIOQ from
smbdirect_map_sges_from_iter()
netfs: Remove netfs_alloc/free_folioq_buffer()
netfs: Remove netfs_extract_user_iter()
iov_iter: Remove ITER_FOLIOQ
netfs: Remove folio_queue and rolling_buffer
netfs: Check for too much data being read
netfs: Limit the minimum trigger for progress reporting
netfs: Combine prepare and issue ops and grab the buffers on request
Documentation/core-api/folio_queue.rst | 209 ---- Documentation/core-api/index.rst | 1 - Documentation/filesystems/netfs_library.rst | 2 +- fs/9p/vfs_addr.c | 59 +- fs/afs/dir.c | 40 +- fs/afs/dir_edit.c | 43 +- fs/afs/dir_search.c | 33 +- fs/afs/file.c | 28 +- fs/afs/fsclient.c | 8 +- fs/afs/inode.c | 2 +- fs/afs/internal.h | 12 +- fs/afs/symlink.c | 35 +- fs/afs/write.c | 32 +- fs/afs/yfsclient.c | 6 +- fs/cachefiles/interface.c | 82 +- fs/cachefiles/internal.h | 13 +- fs/cachefiles/io.c | 523 +++++++--- fs/cachefiles/namei.c | 19 +- fs/cachefiles/xattr.c | 24 +- fs/ceph/Kconfig | 1 + fs/ceph/addr.c | 125 ++- fs/netfs/Kconfig | 3 + fs/netfs/Makefile | 4 +- fs/netfs/buffered_read.c | 514 +++++---- fs/netfs/buffered_write.c | 31 +- fs/netfs/bvecq.c | 763 ++++++++++++++ fs/netfs/direct_read.c | 108 +- fs/netfs/direct_write.c | 157 +-- fs/netfs/fscache_io.c | 4 +- fs/netfs/internal.h | 112 +- fs/netfs/iterator.c | 391 +++---- fs/netfs/misc.c | 168 +-- fs/netfs/objects.c | 22 +- fs/netfs/read_collect.c | 160 +-- fs/netfs/read_pgpriv2.c | 187 ++-- fs/netfs/read_retry.c | 246 +++-- fs/netfs/read_single.c | 169 +-- fs/netfs/rolling_buffer.c | 222 ---- fs/netfs/stats.c | 6 +- fs/netfs/write_collect.c | 240 +++-- fs/netfs/write_issue.c | 1042 +++++++++++-------- fs/netfs/write_retry.c | 150 +-- fs/nfs/Kconfig | 1 + fs/nfs/fscache.c | 17 +- fs/smb/client/cifsglob.h | 2 +- fs/smb/client/cifssmb.c | 13 +- fs/smb/client/file.c | 139 +-- fs/smb/client/smb2ops.c | 82 +- fs/smb/client/smb2pdu.c | 28 +- fs/smb/client/transport.c | 15 +- fs/smb/smbdirect/connection.c | 134 ++- include/linux/bvec.h | 18 + include/linux/bvecq.h | 326 ++++++ include/linux/folio_queue.h | 282 ----- include/linux/fscache.h | 17 + include/linux/iov_iter.h | 87 +- include/linux/netfs.h | 165 +-- include/linux/pagemap.h | 10 + include/linux/rolling_buffer.h | 61 -- include/linux/uio.h | 17 +- include/trace/events/cachefiles.h | 17 +- include/trace/events/netfs.h | 155 ++- kernel/bpf/btf.c | 2 - lib/iov_iter.c | 547 +++++----- lib/scatterlist.c | 82 +- lib/tests/kunit_iov_iter.c | 135 ++- mm/readahead.c | 5 + net/9p/client.c | 8 +- 68 files changed, 4764 insertions(+), 3597 deletions(-) delete mode 100644 Documentation/core-api/folio_queue.rst create mode 100644 fs/netfs/bvecq.c delete mode 100644 fs/netfs/rolling_buffer.c create mode 100644 include/linux/bvecq.h delete mode 100644 include/linux/folio_queue.h delete mode 100644 include/linux/rolling_buffer.h
David Howells
maintainerPATCH v5 1/21 mm: Make readahead store folio count in readahead_control
Make readahead store folio count in readahead_control so that the filesystem can know in advance how many folios it needs to keep track of.
This is cleared by read_pages() in case it is called from a loop.
The count is accessed by the filesystem with readahead_folio_count().
--- include/linux/pagemap.h | 10 ++++++++++ mm/readahead.c | 5 +++++ 2 files changed, 15 insertions(+)
include/linux/pagemap.h +10 -0
@@ -1348,6 +1348,7 @@ struct readahead_control {struct file_ra_state *ra;/* private: use the readahead_* accessors instead */ pgoff_t _index; +unsigned int _nr_folios;unsigned int _nr_pages;unsigned int _batch_count;bool dropbehind;
@@ -1527,6 +1528,15 @@ static inline size_t readahead_batch_length(const struct readahead_control *rac)return rac->_batch_count *PAGE_SIZE ; } +/** +* readahead_folio_count - Get the number of folios in this readahead request. +* @rac: The readahead request. +*/ +static inline unsigned int readahead_folio_count (const struct readahead_control *rac) +{ +return rac->_nr_folios; +} +static inline unsigned long dir_pages (const struct inode *inode) { return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
mm/readahead.c +5 -0
@@ -188,6 +188,7 @@ static void read_pages(struct readahead_control *rac)if (unlikely (rac->_workingset))psi_memstall_leave (&rac->_pflags); rac->_workingset = false; + rac->_nr_folios =0 ;BUG_ON (readahead_count (rac)); }
@@ -303,6 +304,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,if (i == mark)folio_set_readahead (folio); ractl->_workingset |=folio_test_workingset (folio); + ractl->_nr_folios++; ractl->_nr_pages += min_nrpages; i += min_nrpages; }
@@ -473,6 +475,7 @@ static inline int ra_alloc_folio(struct readahead_control *ractl, pgoff_t index,return err; } + ractl->_nr_folios++; ractl->_nr_pages +=1UL << order; ractl->_workingset |=folio_test_workingset (folio);return 0 ;
@@ -822,6 +825,7 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset = true;psi_memstall_enter (&ractl->_pflags); } + ractl->_nr_folios++; ractl->_nr_pages += min_nrpages; ractl->_index = folio->index; }
@@ -851,6 +855,7 @@ void readahead_expand(struct readahead_control *ractl, ractl->_workingset = true;psi_memstall_enter (&ractl->_pflags); } + ractl->_nr_folios++; ractl->_nr_pages += min_nrpages;if (ra) { ra->size += min_nrpages;
David Howells
maintainerPATCH v5 2/21 netfs: Bulk load the readahead-provided folios up front
In reply to David HowellsLoad all the folios by the VM for readahead up front into the folio queue. With the number of folios provided by the VM, the folio queue can be fully allocated first and then the loading happen in one go inside the RCU read lock. The folio refs acquired from readahead are dropped in bulk once the first subrequest is dispatched as it's quite a slow operation. The collector waits for NETFS_RREQ_NEED_PUT_RA_REFS to be cleared so that it doesn't unlock folios before the xarray has been scanned for them.
This simplifies the buffer handling later and isn't noticeably slower as the xarray doesn't need to be modified and the folios are all already pre-locked.
--- fs/netfs/buffered_read.c | 97 +++++++++++++++++++++------------- fs/netfs/internal.h | 1 + fs/netfs/misc.c | 19 +++++++ fs/netfs/read_collect.c | 7 +++ fs/netfs/rolling_buffer.c | 75 ++++++++++++++++++++++++++ include/linux/netfs.h | 1 + include/linux/rolling_buffer.h | 3 ++ include/trace/events/netfs.h | 3 ++ 8 files changed, 169 insertions(+), 37 deletions(-)
fs/netfs/buffered_read.c +60 -37
@@ -54,6 +54,42 @@ static void netfs_rreq_expand(struct netfs_io_request *rreq, } } +/* +* Drop the folio refs acquired from the readahead API. +*/ +static void netfs_bulk_drop_ra_refs (struct netfs_io_request *rreq) +{ +struct folio_batch fbatch; +struct folio *folio; +pgoff_t nr_pages =DIV_ROUND_UP (rreq->len,PAGE_SIZE ); +pgoff_t first = rreq->start /PAGE_SIZE ; +XA_STATE (xas, &rreq->mapping->i_pages, first); + +folio_batch_init (&fbatch); + +rcu_read_lock (); + +xas_for_each (&xas, folio, first + nr_pages -1 ) { +if (xas_retry (&xas, folio)) +continue ; + +if (!folio_batch_add (&fbatch, folio)) +folio_batch_release (&fbatch); + } + +rcu_read_unlock (); +folio_batch_release (&fbatch); +trace_netfs_rreq (rreq, netfs_rreq_trace_ra_put_ref); +clear_bit_unlock (NETFS_RREQ_NEED_PUT_RA_REFS , &rreq->flags); +wake_up (&rreq->waitq); +} + +static void netfs_maybe_bulk_drop_ra_refs (struct netfs_io_request *rreq) +{ +if (test_bit (NETFS_RREQ_NEED_PUT_RA_REFS , &rreq->flags)) +netfs_bulk_drop_ra_refs (rreq); +} +/* * Begin an operation, and fetch the stored zero point value from the cookie if * available.
@@ -74,12 +110,8 @@ static int netfs_begin_cache_read(struct netfs_io_request *rreq, struct netfs_in* * Returns the limited size if successful and -ENOMEM if insufficient memory * available. -* -* [!] NOTE: This must be run in the same thread as ->issue_read() was called -* in as we access the readahead_control struct. */ -static ssize_t netfs_prepare_read_iterator (struct netfs_io_subrequest *subreq, -struct readahead_control *ractl) +static ssize_t netfs_prepare_read_iterator (struct netfs_io_subrequest *subreq) {struct netfs_io_request *rreq = subreq->rreq;size_t rsize = subreq->len;
@@ -87,28 +119,6 @@ static ssize_t netfs_prepare_read_iterator(struct netfs_io_subrequest *subreq,if (subreq->source ==NETFS_DOWNLOAD_FROM_SERVER ) rsize =umin (rsize, rreq->io_streams[0 ].sreq_max_len); -if (ractl) { -/* If we don't have sufficient folios in the rolling buffer, -* extract a folioq's worth from the readahead region at a time -* into the buffer. Note that this acquires a ref on each page -* that we will need to release later - but we don't want to do -* that until after we've started the I/O. -*/ -struct folio_batch put_batch; - -folio_batch_init (&put_batch); -while (rreq->submitted < subreq->start + rsize) { -ssize_t added; - - added =rolling_buffer_load_from_ra (&rreq->buffer, ractl, - &put_batch); -if (added <0 ) -return added; - rreq->submitted += added; - } -folio_batch_release (&put_batch); - } - subreq->len = rsize;if (unlikely (rreq->io_streams[0 ].sreq_max_segs)) { size_t limit = netfs_limit_iter(&rreq->buffer.iter, 0, rsize,
@@ -206,8 +216,7 @@ static void netfs_issue_read(struct netfs_io_request *rreq,* slicing up the region to be read according to available cache blocks and * network rsize. */ -static void netfs_read_to_pagecache (struct netfs_io_request *rreq, -struct readahead_control *ractl) +static void netfs_read_to_pagecache (struct netfs_io_request *rreq) {unsigned long long start = rreq->start;ssize_t size = rreq->len;
@@ -286,7 +295,7 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq,break ; issue: - slice =netfs_prepare_read_iterator (subreq, ractl); + slice =netfs_prepare_read_iterator (subreq);if (slice <0 ) { ret = slice;netfs_cancel_read (subreq, ret);
@@ -300,6 +309,7 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq, }netfs_issue_read (rreq, subreq); +netfs_maybe_bulk_drop_ra_refs (rreq);if (test_bit (NETFS_RREQ_PAUSE , &rreq->flags))netfs_wait_for_paused_read (rreq);
@@ -338,6 +348,7 @@ void netfs_readahead(struct readahead_control *ractl)struct netfs_io_request *rreq;struct netfs_inode *ictx =netfs_inode (ractl->mapping->host);unsigned long long start =readahead_pos (ractl); +ssize_t added;size_t size =readahead_length (ractl);int ret;
@@ -358,11 +369,23 @@ void netfs_readahead(struct readahead_control *ractl)netfs_rreq_expand (rreq, ractl); - rreq->submitted = rreq->start; -if (rolling_buffer_init (&rreq->buffer, rreq->debug_id,ITER_DEST ) <0 ) +/* Load the folios to be read into a bvecq chain. Note that this +* acquires a ref on each folio that we will need to release later - +* but we don't want to do that until after we've started the I/O. +*/ + added =rolling_buffer_bulk_load_from_ra (&rreq->buffer, ractl, rreq->debug_id); +if (added <0 ) { + ret = added; goto cleanup_free; -netfs_read_to_pagecache (rreq, ractl); + } +__set_bit (NETFS_RREQ_NEED_PUT_RA_REFS , &rreq->flags); + + rreq->submitted = rreq->start + added; + rreq->cleaned_to = rreq->start; + rreq->front_folio_order =folio_order (rreq->buffer.tail->vec.folios[0 ]); +netfs_read_to_pagecache (rreq); +netfs_maybe_bulk_drop_ra_refs (rreq);return netfs_put_request (rreq, netfs_rreq_trace_put_return); cleanup_free:
@@ -455,7 +478,7 @@ static int netfs_read_gaps(struct file *file, struct folio *folio)iov_iter_bvec (&rreq->buffer.iter,ITER_DEST , bvec, i, rreq->len); rreq->submitted = rreq->start + flen; -netfs_read_to_pagecache (rreq,NULL ); +netfs_read_to_pagecache (rreq); ret =netfs_wait_for_read (rreq);if (ret >=0 ) {
@@ -530,7 +553,7 @@ int netfs_read_folio(struct file *file, struct folio *folio)if (ret <0 ) goto discard; -netfs_read_to_pagecache (rreq,NULL ); +netfs_read_to_pagecache (rreq); ret =netfs_wait_for_read (rreq);netfs_put_request (rreq, netfs_rreq_trace_put_return);return ret <0 ? ret :0 ;
@@ -687,7 +710,7 @@ int netfs_write_begin(struct netfs_inode *ctx,if (ret <0 ) goto error_put; -netfs_read_to_pagecache (rreq,NULL ); +netfs_read_to_pagecache (rreq); ret =netfs_wait_for_read (rreq);netfs_put_request (rreq, netfs_rreq_trace_put_return);if (ret <0 )
@@ -752,7 +775,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,if (ret <0 ) goto error_put; -netfs_read_to_pagecache (rreq,NULL ); +netfs_read_to_pagecache (rreq); ret =netfs_wait_for_read (rreq);netfs_put_request (rreq, netfs_rreq_trace_put_return);return ret <0 ? ret :0 ;
fs/netfs/internal.h +1 -0
@@ -78,6 +78,7 @@ ssize_t netfs_wait_for_read(struct netfs_io_request *rreq);ssize_t netfs_wait_for_write (struct netfs_io_request *rreq);void netfs_wait_for_paused_read (struct netfs_io_request *rreq);void netfs_wait_for_paused_write (struct netfs_io_request *rreq); +void netfs_wait_for_put_ra_refs (struct netfs_io_request *rreq);/* * objects.c
fs/netfs/misc.c +19 -0
@@ -563,3 +563,22 @@ void netfs_wait_for_paused_write(struct netfs_io_request *rreq) {return netfs_wait_for_pause (rreq, netfs_write_collection); } + +/* +* Wait for the readahead-acquired refs to be put. +*/ +void netfs_wait_for_put_ra_refs (struct netfs_io_request *rreq) +{ +DEFINE_WAIT (myself); + +for (;;) { +trace_netfs_rreq (rreq, netfs_rreq_trace_wait_put_ra_refs); +prepare_to_wait (&rreq->waitq, &myself,TASK_UNINTERRUPTIBLE ); +if (!test_bit (NETFS_RREQ_NEED_PUT_RA_REFS , &rreq->flags)) +break ; +schedule (); + } + +trace_netfs_rreq (rreq, netfs_rreq_trace_waited_put_ra_refs); +finish_wait (&rreq->waitq, &myself); +}
fs/netfs/read_collect.c +7 -0
@@ -118,6 +118,13 @@ static void netfs_read_unlock_folios(struct netfs_io_request *rreq, slot =0 ; } +/* We have to wait for readahead refs to have been released before we +* can unlock any folios as the ref-dropper walks i_pages and the only +* thing preventing these folios from being removed is the folio lock. +*/ +if (test_bit (NETFS_RREQ_NEED_PUT_RA_REFS , &rreq->flags)) +netfs_wait_for_put_ra_refs (rreq); +for (;;) {struct folio *folio;unsigned long long fpos, fend;
fs/netfs/rolling_buffer.c +75 -0
81 lines not on this page · raw message
include/linux/netfs.h +1 -0
@@ -278,6 +278,7 @@ struct netfs_io_request {#define NETFS_RREQ_FOLIO_COPY_TO_CACHE 10/* Copy current folio to cache from read */ #define NETFS_RREQ_UPLOAD_TO_SERVER 11/* Need to write to the server */ #define NETFS_RREQ_USE_IO_ITER 12/* Use ->io_iter rather than ->i_pages */ +#define NETFS_RREQ_NEED_PUT_RA_REFS 17/* Need to put the folio refs RA gave us */ #define NETFS_RREQ_USE_PGPRIV2 31/* [DEPRECATED] Use PG_private_2 to mark * write to cache on read */ const struct netfs_request_ops *netfs_ops;
include/linux/rolling_buffer.h +3 -0
@@ -48,6 +48,9 @@ int rolling_buffer_make_space(struct rolling_buffer *roll);ssize_t rolling_buffer_load_from_ra (struct rolling_buffer *roll,struct readahead_control *ractl,struct folio_batch *put_batch); +ssize_t rolling_buffer_bulk_load_from_ra (struct rolling_buffer *roll, +struct readahead_control *ractl, +unsigned int rreq_id);ssize_t rolling_buffer_append (struct rolling_buffer *roll,struct folio *folio,unsigned int flags);struct folio_queue *rolling_buffer_delete_spent (struct rolling_buffer *roll);
include/trace/events/netfs.h +3 -0
@@ -59,6 +59,7 @@ EM(netfs_rreq_trace_free, "FREE ") \ EM(netfs_rreq_trace_intr, "INTR ") \ EM(netfs_rreq_trace_ki_complete, "KI-CMPL") \ + EM(netfs_rreq_trace_ra_put_ref, "RA-PUT ") \ EM(netfs_rreq_trace_recollect, "RECLLCT") \ EM(netfs_rreq_trace_redirty, "REDIRTY") \EM (netfs_rreq_trace_resubmit,"RESUBMT" ) \
@@ -70,9 +71,11 @@ EM(netfs_rreq_trace_unpause, "UNPAUSE") \ EM(netfs_rreq_trace_wait_ip, "WAIT-IP") \ EM(netfs_rreq_trace_wait_pause, "--PAUSED--") \ + EM(netfs_rreq_trace_wait_put_ra_refs, "WAIT-P-RA") \ EM(netfs_rreq_trace_wait_quiesce, "WAIT-QUIESCE") \ EM(netfs_rreq_trace_waited_ip, "DONE-IP") \ EM(netfs_rreq_trace_waited_pause, "--UNPAUSED--") \ + EM(netfs_rreq_trace_waited_put_ra_refs, "DONE-P-RA") \ EM(netfs_rreq_trace_waited_quiesce, "DONE-QUIESCE") \ EM(netfs_rreq_trace_wake_ip, "WAKE-IP") \EM (netfs_rreq_trace_wake_queue,"WAKE-Q " ) \
David Howells
maintainerPATCH v5 3/21 Add a function to kmap one page of a multipage bio_vec
In reply to David HowellsAdd a function to kmap one page of a multipage bio_vec by offset (which is added to the offset in the bio_vec internally). The caller is responsible for calculating how much of the page is then available.
--- include/linux/bvec.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/linux/bvec.h +18 -0
@@ -343,4 +343,22 @@ static inline phys_addr_t bvec_phys(const struct bio_vec *bvec) return page_to_phys(bvec->bv_page) + bvec->bv_offset; } +/** +* bvec_kmap_partial - Map part of a bvec into the kernel virtual address space +* @bvec: bvec to map +* @offset: Offset into bvec +* +* Map the page containing the byte at @offset into the kernel virtual address +* space. The caller is responsible for making sure this doesn't overrun. +* +* Call kunmap_local on the returned address to unmap. +*/ +static inline void *bvec_kmap_partial (struct bio_vec *bvec,size_t offset) +{ + offset += bvec->bv_offset; + +return kmap_local_page (bvec->bv_page + (offset >>PAGE_SHIFT )) + + (offset & ~PAGE_MASK ); +} +#endif /* __LINUX_BVEC_H */
David Howells
maintainerPATCH v5 4/21 iov_iter: Make iov_iter_get_pages*() wrap iov_iter_extract_pages()
In reply to David HowellsMake iov_iter_get_pages*() wrap iov_iter_extract_pages() for kernel iterator types (e.g. ITER_BVEC, ITER_FOLIOQ, ITER_XARRAY). The pages obtained have their refcounts incremented afterwards if they're not slab pages. ITER_KVEC is left returning -EFAULT.
--- lib/iov_iter.c | 164 ++++++------------------------------------------- 1 file changed, 19 insertions(+), 145 deletions(-)
lib/iov_iter.c +19 -145
@@ -910,118 +910,34 @@ static int want_pages_array(struct page ***res, size_t size,return count; } -static ssize_t iter_folioq_get_pages (struct iov_iter *iter, +/* +* Wrap iov_iter_extract_pages() and then pin the non-slab pages we got back. +* This only works for non-user iterator types as get_pages uses get_user_pages +* not pin_user_pages. +*/ +static ssize_t iter_get_kernel_pages (struct iov_iter *iter,struct page ***ppages,size_t maxsize,unsigned maxpages,size_t *_start_offset) { -const struct folio_queue *folioq = iter->folioq;struct page **pages; -unsigned int slot = iter->folioq_slot; -size_t extracted =0 , count = iter->count, iov_offset = iter->iov_offset; +ssize_t ret, done; -if (slot >=folioq_nr_slots (folioq)) { - folioq = folioq->next; - slot =0 ; -if (WARN_ON (iov_offset !=0 )) -return -EIO ; - } + ret =iov_iter_extract_pages (iter, ppages, maxsize, maxpages, +0 , _start_offset); +if (ret <=0 ) +return ret; - maxpages =want_pages_array (ppages, maxsize, iov_offset & ~PAGE_MASK , maxpages); -if (!maxpages) -return -ENOMEM ; - *_start_offset = iov_offset & ~PAGE_MASK ; pages = *ppages; +for (done = ret + *_start_offset; done >0 ; done -=PAGE_SIZE ) { +struct folio *folio =page_folio (*pages); -for (;;) { -struct folio *folio =folioq_folio (folioq, slot); -size_t offset = iov_offset, fsize =folioq_folio_size (folioq, slot); -size_t part =PAGE_SIZE - offset %PAGE_SIZE ; - -if (offset < fsize) { - part =umin (part,umin (maxsize - extracted, fsize - offset)); - count -= part; - iov_offset += part; - extracted += part; - - *pages =folio_page (folio, offset /PAGE_SIZE ); -get_page (*pages); - pages++; - maxpages--; - } - -if (maxpages ==0 || extracted >= maxsize) -break ; - -if (iov_offset >= fsize) { - iov_offset =0 ; - slot++; -if (slot ==folioq_nr_slots (folioq) && folioq->next) { - folioq = folioq->next; - slot =0 ; - } - } - } - - iter->count = count; - iter->iov_offset = iov_offset; - iter->folioq = folioq; - iter->folioq_slot = slot; -return extracted; -} - -static ssize_t iter_xarray_populate_pages (struct page **pages,struct xarray *xa, -pgoff_t index,unsigned int nr_pages) -{ -XA_STATE (xas, xa, index); -struct folio *folio; -unsigned int ret =0 ; - -rcu_read_lock (); -for (folio =xas_load (&xas); folio; folio =xas_next (&xas)) { -if (xas_retry (&xas, folio)) -continue ; - -/* Has the folio moved or been split? */ -if (unlikely (folio !=xas_reload (&xas))) { -xas_reset (&xas); -continue ; - } - - pages[ret] =folio_file_page (folio, xas.xa_index); -folio_get (folio); -if (++ret == nr_pages) -break ; +if (!folio_test_slab (folio)) +folio_get (folio); + pages++; } -rcu_read_unlock ();return ret; } -static ssize_t iter_xarray_get_pages (struct iov_iter *i, -struct page ***pages,size_t maxsize, -unsigned maxpages,size_t *_start_offset) -{ -unsigned nr, offset, count; -pgoff_t index; -loff_t pos; - - pos = i->xarray_start + i->iov_offset; - index = pos >>PAGE_SHIFT ; - offset = pos & ~PAGE_MASK ; - *_start_offset = offset; - - count =want_pages_array (pages, maxsize, offset, maxpages); -if (!count) -return -ENOMEM ; - nr =iter_xarray_populate_pages (*pages, i->xarray, index, count); -if (nr ==0 ) -return 0 ; - - maxsize =min_t (size_t, nr *PAGE_SIZE - offset, maxsize); - i->iov_offset += maxsize; - i->count -= maxsize; -return maxsize; -} -/* must be done on non-empty ITER_UBUF or ITER_IOVEC one */ static unsigned long first_iovec_segment (const struct iov_iter *i,size_t *size) {
@@ -1044,22 +960,6 @@ static unsigned long first_iovec_segment(const struct iov_iter *i, size_t *size)BUG ();// if it had been empty, we wouldn't get called } -/* must be done on non-empty ITER_BVEC one */ -static struct page *first_bvec_segment (const struct iov_iter *i, -size_t *size,size_t *start) -{ -struct page *page; -size_t skip = i->iov_offset, len; - - len = i->bvec->bv_len - skip; -if (*size > len) - *size = len; - skip += i->bvec->bv_offset; - page = i->bvec->bv_page + skip /PAGE_SIZE ; - *start = skip %PAGE_SIZE ; -return page; -} -static ssize_t __iov_iter_get_pages_alloc (struct iov_iter *i,struct page ***pages,size_t maxsize,unsigned int maxpages,size_t *start)
@@ -1095,36 +995,10 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i,iov_iter_advance (i, maxsize);return maxsize; } -if (iov_iter_is_bvec (i)) { -struct page **p; -struct page *page; - page =first_bvec_segment (i, &maxsize, start); - n =want_pages_array (pages, maxsize, *start, maxpages); -if (!n) -return -ENOMEM ; - p = *pages; -for (int k =0 ; k < n; k++) { -struct folio *folio =page_folio (page + k); - p[k] = page + k; -if (!folio_test_slab (folio)) -folio_get (folio); - } - maxsize =min_t (size_t, maxsize, n *PAGE_SIZE - *start); - i->count -= maxsize; - i->iov_offset += maxsize; -if (i->iov_offset == i->bvec->bv_len) { - i->iov_offset =0 ; - i->bvec++; - i->nr_segs--; - } -return maxsize; - } -if (iov_iter_is_folioq (i)) -return iter_folioq_get_pages (i, pages, maxsize, maxpages, start); -if (iov_iter_is_xarray (i)) -return iter_xarray_get_pages (i, pages, maxsize, maxpages, start); -return -EFAULT ; +if (iov_iter_is_kvec (i)) +return -EFAULT ; +return iter_get_kernel_pages (i, pages, maxsize, maxpages, start); } ssize_t iov_iter_get_pages2(struct iov_iter *i, struct page **pages,
David Howells
maintainerPATCH v5 5/21 iov_iter: Add a segmented queue of bio_vec[]
In reply to David HowellsAdd the concept of a segmented queue of bio_vec[] arrays. This allows an indefinite quantity of elements to be handled and allows things like network filesystems and crypto drivers to glue bits on the ends without having to reallocate the array.
The bvecq struct that defines each segment also carries capacity/usage information along with flags indicating whether the constituent memory regions need freeing or unpinning and the file position of the first element in a segment. The bvecq structs are refcounted to allow a queue to be extracted in batches and split between a number of subrequests.
The bvecq can have the bio_vec[] it manages allocated in with it, but this is not required. A flag is provided for if this is the case as comparing ->bv to ->__bv is not sufficient to detect this case.
Add an iterator type ITER_BVECQ for it. This is intended to replace ITER_FOLIOQ (and ITER_XARRAY).
Note that the prev pointer is only really needed for iov_iter_revert() and could be dispensed with if struct iov_iter contained the head information as well as the current point.
--- include/linux/bvecq.h | 56 +++++++ include/linux/iov_iter.h | 74 ++++++++- include/linux/uio.h | 11 ++ lib/iov_iter.c | 324 ++++++++++++++++++++++++++++++++++++- lib/scatterlist.c | 67 +++++++- lib/tests/kunit_iov_iter.c | 262 ++++++++++++++++++++++++++++++ 6 files changed, 788 insertions(+), 6 deletions(-) create mode 100644 include/linux/bvecq.h
include/linux/bvecq.h new file +56 -0
@@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Implementation of a segmented queue of bio_vec[]. +* +* Copyright (C) 2026 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +*/ + +#ifndef _LINUX_BVECQ_H +#define _LINUX_BVECQ_H + +#include <linux/bvec.h> + +/* +* The type of memory retention used by the elements in bvecq->bv[] and how to +* clean it up. +*/ +enum bvecq_mem { +BVECQ_MEM_EXTERNAL ,/* Externally retained memory - no freeing */ +BVECQ_MEM_PAGECACHE ,/* Ref'd pagecache pages - must put */ +BVECQ_MEM_GUP ,/* Pinned memory from get_user_pages() - unpin */ +BVECQ_MEM_ALLOCED ,/* Memory alloc'd by bvecq - can be freed/pooled */ +}__mode (byte ); + +/* +* Segmented bio_vec queue. +* +* These can be linked together to form messages of indefinite length and +* iterated over with an ITER_BVECQ iterator. The list is non-circular; next +* and prev are NULL at the ends. +* +* The bv pointer points to the bio_vec array; this may be __bv if allocated +* together. The caller is responsible for determining whether or not this is +* the case as the array pointed to by bv may be follow on directly from the +* bvecq by accident of allocation (ie. ->bv == ->__bv is *not* sufficient to +* determine this). +* +* The file position and discontiguity flag allow non-contiguous data sets to +* be chained together, but still teased apart without the need to convert the +* info in the bio_vec back into a folio pointer. +*/ +struct bvecq { +struct bvecq *next;/* Next bvec in the list or NULL */ +struct bvecq *prev;/* Prev bvec in the list or NULL */ +unsigned long long fpos;/* File position */ +refcount_t ref; +u32 priv;/* Private data */ +u16 nr_slots;/* Number of elements in bv[] used */ +u16 max_slots;/* Number of elements allocated in bv[] */ +enum bvecq_mem mem_type:3 ;/* What sort of memory and how to free it */ +bool inline_bv:1 ;/* T if __bv[] is being used */ +bool discontig:1 ;/* T if not contiguous with previous bvecq */ +struct bio_vec *bv;/* Pointer to array of page fragments */ +struct bio_vec __bv[];/* Default array (if ->inline_bv) */ +}; + +#endif /* _LINUX_BVECQ_H */
include/linux/iov_iter.h +72 -2
104 lines not on this page · raw message
include/linux/uio.h +11 -0
@@ -26,6 +26,7 @@ enum iter_type {ITER_IOVEC ,ITER_BVEC ,ITER_KVEC , +ITER_BVECQ ,ITER_FOLIOQ ,ITER_XARRAY , ITER_DISCARD,
@@ -68,6 +69,7 @@ struct iov_iter {const struct iovec *__iov;const struct kvec *kvec;const struct bio_vec *bvec; +const struct bvecq *bvecq;const struct folio_queue *folioq;struct xarray *xarray;void __user *ubuf;
@@ -77,6 +79,7 @@ struct iov_iter { };union {unsigned long nr_segs; +u16 bvecq_slot;u8 folioq_slot;loff_t xarray_start; };
@@ -145,6 +148,11 @@ static inline bool iov_iter_is_discard(const struct iov_iter *i)return iov_iter_type (i) ==ITER_DISCARD ; } +static inline bool iov_iter_is_bvecq (const struct iov_iter *i) +{ +return iov_iter_type (i) ==ITER_BVECQ ; +} +static inline bool iov_iter_is_folioq (const struct iov_iter *i) {return iov_iter_type (i) ==ITER_FOLIOQ ;
@@ -295,6 +303,9 @@ void iov_iter_kvec(struct iov_iter *i, unsigned int direction, const struct kvecvoid iov_iter_bvec (struct iov_iter *i,unsigned int direction,const struct bio_vec *bvec,unsigned long nr_segs,size_t count);void iov_iter_discard (struct iov_iter *i,unsigned int direction,size_t count); +void iov_iter_bvec_queue (struct iov_iter *i,unsigned int direction, +const struct bvecq *bvecq, +unsigned int first_slot,unsigned int offset,size_t count);void iov_iter_folio_queue (struct iov_iter *i,unsigned int direction,const struct folio_queue *folioq,unsigned int first_slot,unsigned int offset,size_t count);
lib/iov_iter.c +322 -2
397 lines not on this page · raw message
lib/scatterlist.c +65 -2
91 lines not on this page · raw message
lib/tests/kunit_iov_iter.c +262 -0
292 lines not on this page · raw message
David Howells
maintainerPATCH v5 6/21 netfs: Add some tools for managing bvecq chains
In reply to David HowellsProvide a selection of tools for managing bvec queue chains. This includes:
(1) Allocation, prepopulation, expansion, shortening and refcounting of bvecqs and bvecq chains.
This can be used to do things like creating an encryption buffer in cifs or a directory content buffer in afs. The memory segments will be appropriate disposed off according to the flags on the bvecq.
(2) Management of a bvecq chain as a rolling buffer and the management of positions within it.
(3) Loading folios, slicing chains and clearing content.
--- fs/netfs/Makefile | 1 + fs/netfs/bvecq.c | 763 +++++++++++++++++++++++++++++++++++ fs/netfs/internal.h | 1 + fs/netfs/stats.c | 4 +- include/linux/bvecq.h | 270 +++++++++++++ include/linux/netfs.h | 1 + include/trace/events/netfs.h | 24 ++ 7 files changed, 1063 insertions(+), 1 deletion(-) create mode 100644 fs/netfs/bvecq.c
fs/netfs/Makefile +1 -0
@@ -3,6 +3,7 @@ netfs-y := \ buffered_read.o \ buffered_write.o \ + bvecq.o \ direct_read.o \ direct_write.o \ iterator.o \
fs/netfs/bvecq.c new file +763 -0
763 lines not on this page · raw message
fs/netfs/internal.h +1 -0
@@ -170,6 +170,7 @@ extern atomic_t netfs_n_wh_retry_write_subreq;extern atomic_t netfs_n_wb_lock_skip;extern atomic_t netfs_n_wb_lock_wait;extern atomic_t netfs_n_folioq; +extern atomic_t netfs_n_bvecq;int netfs_stats_show (struct seq_file *m,void *v);
fs/netfs/stats.c +3 -1
@@ -48,6 +48,7 @@ atomic_t netfs_n_wh_retry_write_subreq;atomic_t netfs_n_wb_lock_skip;atomic_t netfs_n_wb_lock_wait;atomic_t netfs_n_folioq; +atomic_t netfs_n_bvecq;int netfs_stats_show (struct seq_file *m,void *v) {
@@ -90,9 +91,10 @@ int netfs_stats_show(struct seq_file *m, void *v)atomic_read (&netfs_n_rh_retry_read_subreq),atomic_read (&netfs_n_wh_retry_write_req), atomic_read(&netfs_n_wh_retry_write_subreq)); -seq_printf (m,"Objs : rr=%u sr=%u foq=%u wsc=%u\n" , +seq_printf (m,"Objs : rr=%u sr=%u bq=%u foq=%u wsc=%u\n" ,atomic_read (&netfs_n_rh_rreq),atomic_read (&netfs_n_rh_sreq), +atomic_read (&netfs_n_bvecq),atomic_read (&netfs_n_folioq),atomic_read (&netfs_n_wh_wstream_conflict)); seq_printf(m, "WbLock : skip=%u wait=%u\n",
include/linux/bvecq.h +270 -0
274 lines not on this page · raw message
include/linux/netfs.h +1 -0
@@ -17,6 +17,7 @@#include <linux/workqueue.h> #include <linux/fs.h> #include <linux/pagemap.h> +#include <linux/bvecq.h> #include <linux/uio.h> #include <linux/rolling_buffer.h>
include/trace/events/netfs.h +24 -0
@@ -789,6 +789,30 @@ TRACE_EVENT(netfs_folioq, __print_symbolic(__entry->trace, netfs_folioq_traces)) ); +TRACE_EVENT (netfs_bv_slot, + TP_PROTO(const struct bvecq *bq, int slot), + +TP_ARGS (bq, slot), + +TP_STRUCT__entry ( + __field(unsigned long, pfn) + __field(unsigned int, offset) + __field(unsigned int, len) + __field(unsigned int, slot) + ), + +TP_fast_assign ( + __entry->slot = slot; + __entry->pfn = page_to_pfn(bq->bv[slot].bv_page); + __entry->offset = bq->bv[slot].bv_offset; + __entry->len = bq->bv[slot].bv_len; + ), + +TP_printk ("bq[%x] p=%lx %x-%x" , + __entry->slot, + __entry->pfn, __entry->offset, __entry->offset + __entry->len) + ); +#undef EM#undef E_#endif /* _TRACE_NETFS_H */
David Howells
maintainerApologies... The outgoing MX decided to go offline in the middle of that:
error: git send-email: 4.7.1 Service unavailable - try again later
So I've re-sent it.
David