netfs: Miscellaneous preparatory changes
Subsystems (12)
David Howells
maintainerv12 cover netfs: Miscellaneous preparatory changes
Hi Christian,
Could you pull these patches please for -next? This is the first of four batches. This is based on your vfs.fixes as there are some prerequisite patches there. This was split from v11 of a larger series[1].
This a collection of miscellaneous modifications to netfslib that I want to make ahead of bigger changes, including:
(1) Convert "unsigned long long" to "uoff_t". This makes it a little more obvious as to the meaning of the value. Also convert some "loff_t" to "uoff_t" as most of the time it's used the value really should never be negative.
(2) Remove the writethrough code as the locking is really tricky to get right and it looks like it could deadlock with Ceph if snapshots are used.
(3) Adjust some tracepoints, including adding the cache object ID to certain tracepoinits.
(4) Make use of PG_private_2 opt-in. Use of PG_private_2 is deprecated and the MM people would like their page bit back, so we need to stop using it soon.
(5) Add some helper functions to handle the barriering needed for the NETFS_RREQ_ALL_QUEUED flag.
(6) Set the subrequest type at allocation time so that the allocation trace records the proposed type.
The patches can also be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-next-1
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/[email protected]/
David Howells (8):
netfs: Use uoff_t instead of unsigned long long and loff_t
netfs: Remove the writethrough code
netfs: trace: Change the "clear" folio traces to "endwb"
netfs: trace: Rejig a couple of the tracepoints
netfs: Add the cache object ID to netfs_read/write tracepoints
netfs: Make deprecated PG_private_2 support opt-in
netfs: Add some functions to wrap the all-queued handling
netfs: Set subrequest->source at alloc before trace emission
fs/9p/vfs_addr.c | 1 - fs/afs/file.c | 5 +- fs/cachefiles/interface.c | 10 +-- fs/cachefiles/internal.h | 4 +- fs/cachefiles/io.c | 25 +++--- fs/ceph/Kconfig | 1 + fs/ceph/addr.c | 4 +- fs/netfs/Kconfig | 3 + fs/netfs/Makefile | 2 +- fs/netfs/buffered_read.c | 35 ++++---- fs/netfs/buffered_write.c | 66 +++------------ fs/netfs/direct_read.c | 14 ++-- fs/netfs/direct_write.c | 8 +- fs/netfs/fscache_cookie.c | 8 +- fs/netfs/fscache_io.c | 10 +-- fs/netfs/internal.h | 67 ++++++++++++--- fs/netfs/iterator.c | 2 +- fs/netfs/main.c | 1 - fs/netfs/misc.c | 10 +-- fs/netfs/objects.c | 6 +- fs/netfs/read_collect.c | 14 ++-- fs/netfs/read_pgpriv2.c | 13 ++- fs/netfs/read_retry.c | 5 +- fs/netfs/read_single.c | 11 +-- fs/netfs/stats.c | 4 +- fs/netfs/write_collect.c | 25 +++--- fs/netfs/write_issue.c | 123 ++------------------------- fs/netfs/write_retry.c | 5 +- fs/nfs/Kconfig | 1 + include/linux/fscache-cache.h | 2 +- include/linux/fscache.h | 36 ++++---- include/linux/netfs.h | 80 +++++++++--------- include/trace/events/cachefiles.h | 30 +++---- include/trace/events/fscache.h | 10 +-- include/trace/events/netfs.h | 134 +++++++++++++++--------------- 35 files changed, 324 insertions(+), 451 deletions(-)
David Howells
maintainerPATCH v12 1/8 netfs: Use uoff_t instead of unsigned long long and loff_t
Use uoff_t instead of unsigned long long and loff_t for file positions that can't be negative.
--- fs/afs/file.c | 4 +- fs/cachefiles/interface.c | 10 ++-- fs/cachefiles/internal.h | 4 +- fs/cachefiles/io.c | 24 +++++----- fs/ceph/addr.c | 4 +- fs/netfs/buffered_read.c | 22 ++++----- fs/netfs/buffered_write.c | 10 ++-- fs/netfs/direct_read.c | 2 +- fs/netfs/direct_write.c | 8 ++-- fs/netfs/fscache_cookie.c | 8 ++-- fs/netfs/fscache_io.c | 8 ++-- fs/netfs/internal.h | 10 ++-- fs/netfs/iterator.c | 2 +- fs/netfs/misc.c | 8 ++-- fs/netfs/objects.c | 2 +- fs/netfs/read_collect.c | 4 +- fs/netfs/read_pgpriv2.c | 8 ++-- fs/netfs/read_retry.c | 2 +- fs/netfs/write_collect.c | 10 ++-- fs/netfs/write_issue.c | 10 ++-- fs/netfs/write_retry.c | 2 +- include/linux/fscache-cache.h | 2 +- include/linux/fscache.h | 36 +++++++-------- include/linux/netfs.h | 74 ++++++++++++++--------------- include/trace/events/cachefiles.h | 30 ++++++------ include/trace/events/fscache.h | 10 ++-- include/trace/events/netfs.h | 77 +++++++++++++++---------------- 27 files changed, 195 insertions(+), 196 deletions(-)
fs/afs/file.c +2 -2
@@ -413,7 +413,7 @@ static int afs_init_request(struct netfs_io_request *rreq, struct file *file)return 0 ; } -static int afs_check_write_begin (struct file *file,loff_t pos,unsigned len, +static int afs_check_write_begin (struct file *file,uoff_t pos,unsigned len,struct folio **foliop,void **_fsdata) {struct afs_vnode *vnode =AFS_FS_I (file_inode (file));
@@ -451,7 +451,7 @@ void afs_set_i_size(struct afs_vnode *vnode, loff_t new_i_size)fscache_update_cookie (afs_vnode_cache (vnode),NULL , &new_i_size); } -static void afs_update_i_size (struct inode *inode,loff_t new_i_size) +static void afs_update_i_size (struct inode *inode,uoff_t new_i_size) {afs_set_i_size (AFS_FS_I (inode), new_i_size); }
fs/cachefiles/interface.c +5 -5
@@ -111,7 +111,7 @@ static int cachefiles_adjust_size(struct cachefiles_object *object)struct iattr newattrs;struct file *file = object->file;uint64_t ni_size; -loff_t oi_size; +uoff_t oi_size;int ret; ni_size = object->cookie->object_size;
@@ -225,11 +225,11 @@ static bool cachefiles_lookup_cookie(struct fscache_cookie *cookie)* any unused granules. */ static bool cachefiles_shorten_object (struct cachefiles_object *object, -struct file *file,loff_t new_size) +struct file *file,uoff_t new_size) {struct cachefiles_cache *cache = object->volume->cache;struct inode *inode =file_inode (file); -loff_t i_size, dio_size; +uoff_t i_size, dio_size;int ret; dio_size =round_up (new_size,CACHEFILES_DIO_BLOCK_SIZE );
@@ -271,14 +271,14 @@ static bool cachefiles_shorten_object(struct cachefiles_object *object,* Resize the backing object. */ static void cachefiles_resize_cookie (struct netfs_cache_resources *cres, -loff_t new_size) +uoff_t new_size) {struct cachefiles_object *object =cachefiles_cres_object (cres);struct cachefiles_cache *cache = object->volume->cache;struct fscache_cookie *cookie = object->cookie;const struct cred *saved_cred;struct file *file =cachefiles_cres_file (cres); -loff_t old_size = cookie->object_size; +uoff_t old_size = cookie->object_size;_enter ("%llu->%llu" , old_size, new_size);
fs/cachefiles/internal.h +2 -2
@@ -203,11 +203,11 @@ extern bool cachefiles_begin_operation(struct netfs_cache_resources *cres, enum fscache_want_state want_state);extern int __cachefiles_prepare_write (struct cachefiles_object *object,struct file *file, -loff_t *_start,size_t *_len,size_t upper_len, +uoff_t *_start,size_t *_len,size_t upper_len,bool no_space_allocated_yet);extern int __cachefiles_write (struct cachefiles_object *object,struct file *file, -loff_t start_pos, +uoff_t start_pos,struct iov_iter *iter,netfs_io_terminated_t term_func,void *term_func_priv);
fs/cachefiles/io.c +12 -12
@@ -19,7 +19,7 @@struct cachefiles_kiocb {struct kiocb iocb;refcount_t ki_refcnt; -loff_t start; +uoff_t start;union {size_t skipped;size_t len;
@@ -73,7 +73,7 @@ static void cachefiles_read_complete(struct kiocb *iocb, long ret)* Initiate a read from the cache. */ static int cachefiles_read(struct netfs_cache_resources *cres, - loff_t start_pos, + uoff_t start_pos, struct iov_iter *iter, enum netfs_read_from_hole read_hole, netfs_io_terminated_t term_func,
@@ -197,8 +197,8 @@ static int cachefiles_read(struct netfs_cache_resources *cres,* of data starts and how long it is. */ static int cachefiles_query_occupancy (struct netfs_cache_resources *cres, -loff_t start,size_t len,size_t granularity, -loff_t *_data_start,size_t *_data_len) +uoff_t start,size_t len,size_t granularity, +uoff_t *_data_start,size_t *_data_len) {struct cachefiles_object *object;struct file *file;
@@ -280,7 +280,7 @@ static void cachefiles_write_complete(struct kiocb *iocb, long ret)*/ int __cachefiles_write (struct cachefiles_object *object,struct file *file, -loff_t start_pos, +uoff_t start_pos,struct iov_iter *iter,netfs_io_terminated_t term_func,void *term_func_priv)
@@ -357,7 +357,7 @@ int __cachefiles_write(struct cachefiles_object *object, }static int cachefiles_write (struct netfs_cache_resources *cres, -loff_t start_pos, +uoff_t start_pos,struct iov_iter *iter,netfs_io_terminated_t term_func,void *term_func_priv)
@@ -377,7 +377,7 @@ static int cachefiles_write(struct netfs_cache_resources *cres,static inline enum netfs_io_source cachefiles_do_prepare_read (struct netfs_cache_resources *cres, -loff_t start,size_t *_len,loff_t i_size, +uoff_t start,size_t *_len,loff_t i_size,unsigned long *_flags,ino_t netfs_ino) {enum cachefiles_prepare_read_trace why;
@@ -483,7 +483,7 @@ cachefiles_do_prepare_read(struct netfs_cache_resources *cres,* boundary as appropriate. */ static enum netfs_io_source cachefiles_prepare_read (struct netfs_io_subrequest *subreq, -unsigned long long i_size) +uoff_t i_size) { return cachefiles_do_prepare_read(&subreq->rreq->cache_resources, subreq->start, &subreq->len, i_size,
@@ -495,7 +495,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest **/ int __cachefiles_prepare_write (struct cachefiles_object *object,struct file *file, -loff_t *_start,size_t *_len,size_t upper_len, +uoff_t *_start,size_t *_len,size_t upper_len,bool no_space_allocated_yet) {struct cachefiles_cache *cache = object->volume->cache;
@@ -577,8 +577,8 @@ int __cachefiles_prepare_write(struct cachefiles_object *object, }static int cachefiles_prepare_write (struct netfs_cache_resources *cres, -loff_t *_start,size_t *_len,size_t upper_len, -loff_t i_size,bool no_space_allocated_yet) +uoff_t *_start,size_t *_len,size_t upper_len, +uoff_t i_size,bool no_space_allocated_yet) {struct cachefiles_object *object =cachefiles_cres_object (cres);struct cachefiles_cache *cache = object->volume->cache;
@@ -628,7 +628,7 @@ static void cachefiles_issue_write(struct netfs_io_subrequest *subreq)struct netfs_io_stream *stream = &wreq->io_streams[subreq->stream_nr];const struct cred *saved_cred;size_t off, pre, post, len = subreq->len; -loff_t start = subreq->start; +uoff_t start = subreq->start;int ret; _enter("W=%x[%x] %llx-%llx",
fs/ceph/addr.c +2 -2
@@ -65,7 +65,7 @@ (CONGESTION_ON_THRESH (congestion_kb) - \ (CONGESTION_ON_THRESH(congestion_kb) >> 2)) -static int ceph_netfs_check_write_begin (struct file *file,loff_t pos,unsigned int len, +static int ceph_netfs_check_write_begin (struct file *file,uoff_t pos,unsigned int len,struct folio **foliop,void **_fsdata);static inline struct ceph_snap_context *page_snap_context (struct page *page)
@@ -1854,7 +1854,7 @@ ceph_find_incompatible(struct folio *folio)return NULL ; } -static int ceph_netfs_check_write_begin (struct file *file,loff_t pos,unsigned int len, +static int ceph_netfs_check_write_begin (struct file *file,uoff_t pos,unsigned int len,struct folio **foliop,void **_fsdata) {struct inode *inode =file_inode (file);
fs/netfs/buffered_read.c +11 -11
@@ -10,9 +10,9 @@#include "internal.h" static void netfs_cache_expand_readahead (struct netfs_io_request *rreq, -unsigned long long *_start, -unsigned long long *_len, -unsigned long long i_size) +uoff_t *_start, +uoff_t *_len, +uoff_t i_size) {struct netfs_cache_resources *cres = &rreq->cache_resources;
@@ -139,7 +139,7 @@ static ssize_t netfs_prepare_read_iterator(struct netfs_io_subrequest *subreq)static enum netfs_io_source netfs_cache_prepare_read (struct netfs_io_request *rreq,struct netfs_io_subrequest *subreq, -loff_t i_size) +uoff_t i_size) {struct netfs_cache_resources *cres = &rreq->cache_resources;enum netfs_io_source source;
@@ -269,9 +269,9 @@ static void netfs_mark_copy_to_cache(struct netfs_io_request *rreq,static void netfs_read_to_pagecache (struct netfs_io_request *rreq) {struct folio_queue *fq = rreq->buffer.tail; -unsigned long long start = rreq->start;unsigned int offset =0 ;ssize_t size = rreq->len; +uoff_t start = rreq->start;int ret =0 , slot =0 ; do {
@@ -293,8 +293,8 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) source =netfs_cache_prepare_read (rreq, subreq, rreq->i_size); subreq->source = source;if (source ==NETFS_DOWNLOAD_FROM_SERVER ) { -unsigned long long zero_point =netfs_read_zero_point (rreq->inode); -unsigned long long zp =umin (zero_point, rreq->i_size); +uoff_t zero_point =netfs_read_zero_point (rreq->inode); +uoff_t zp =umin (zero_point, rreq->i_size);size_t len = subreq->len;if (unlikely (rreq->origin ==NETFS_READ_SINGLE ))
@@ -642,11 +642,11 @@ EXPORT_SYMBOL(netfs_read_folio);* If any of these criteria are met, then zero out the unwritten parts * of the folio and return true. Otherwise, return false. */ -static bool netfs_skip_folio_read (struct folio *folio,loff_t pos,size_t len, +static bool netfs_skip_folio_read (struct folio *folio,uoff_t pos,size_t len,bool always_fill) {struct inode *inode =folio_inode (folio); -loff_t i_size =i_size_read (inode); +uoff_t i_size =i_size_read (inode);size_t offset =offset_in_folio (folio, pos);size_t plen =folio_size (folio);
@@ -711,7 +711,7 @@ static bool netfs_skip_folio_read(struct folio *folio, loff_t pos, size_t len,*/ int netfs_write_begin (struct netfs_inode *ctx,struct file *file,struct address_space *mapping, -loff_t pos,unsigned int len,struct folio **_folio, +uoff_t pos,unsigned int len,struct folio **_folio,void **_fsdata) {struct netfs_io_request *rreq;
@@ -807,7 +807,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,struct netfs_io_request *rreq;struct address_space *mapping = folio->mapping;struct netfs_inode *ctx =netfs_inode (mapping->host); -unsigned long long start =folio_pos (folio); +uoff_t start =folio_pos (folio);size_t flen =folio_size (folio);int ret;
fs/netfs/buffered_write.c +5 -5
@@ -17,7 +17,7 @@* as possible to hold as much of the remaining length as possible in one go. */ static struct folio *netfs_grab_folio_for_write (struct address_space *mapping, -loff_t pos,size_t part) +uoff_t pos,size_t part) {pgoff_t index = pos /PAGE_SIZE ;fgf_t fgp_flags =FGP_WRITEBEGIN ;
@@ -35,9 +35,9 @@ static struct folio *netfs_grab_folio_for_write(struct address_space *mapping,* the values actually are. */ void netfs_update_i_size (struct netfs_inode *ctx,struct inode *inode, -loff_t pos,size_t copied) +uoff_t pos,size_t copied) { -loff_t i_size, end = pos + copied; +uoff_t i_size, end = pos + copied;blkcnt_t add;size_t gap;
@@ -102,7 +102,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,struct folio *folio =NULL , *writethrough =NULL ;unsigned int bdp_flags = (iocb->ki_flags &IOCB_NOWAIT ) ?BDP_ASYNC :0 ;ssize_t written =0 , ret, ret2; -loff_t pos = iocb->ki_pos; +uoff_t pos = iocb->ki_pos;size_t max_chunk =mapping_max_folio_size (mapping);bool maybe_trouble = false;
@@ -134,7 +134,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,enum netfs_folio_trace trace;struct netfs_folio *finfo;struct netfs_group *group; -unsigned long long fpos; +uoff_t fpos;size_t flen;size_t offset;/* Offset into pagecache folio */ size_t part;/* Bytes to write to folio */
fs/netfs/direct_read.c +1 -1
@@ -47,8 +47,8 @@ static void netfs_prepare_dio_read_iterator(struct netfs_io_subrequest *subreq)*/ static void netfs_dispatch_unbuffered_reads (struct netfs_io_request *rreq) { -unsigned long long start = rreq->start;ssize_t size = rreq->len; +uoff_t start = rreq->start;int ret; do {
fs/netfs/direct_write.c +4 -4
@@ -225,9 +225,9 @@ ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter * struct netfs_group *netfs_group) {struct netfs_io_request *wreq; -unsigned long long start = iocb->ki_pos; -unsigned long long end = start +iov_iter_count (iter);ssize_t ret, n; +uoff_t start = iocb->ki_pos; +uoff_t end = start +iov_iter_count (iter);size_t len =iov_iter_count (iter);bool async = !is_sync_kiocb (iocb);
@@ -336,8 +336,8 @@ ssize_t netfs_unbuffered_write_iter(struct kiocb *iocb, struct iov_iter *from)struct inode *inode = mapping->host;struct netfs_inode *ictx =netfs_inode (inode);ssize_t ret; -loff_t pos = iocb->ki_pos; -unsigned long long end = pos +iov_iter_count (from) -1 ; +uoff_t pos = iocb->ki_pos; +uoff_t end = pos +iov_iter_count (from) -1 ;_enter ("%llx,%zx,%llx" , pos,iov_iter_count (from),i_size_read (inode));
fs/netfs/fscache_cookie.c +4 -4
@@ -327,7 +327,7 @@ static struct fscache_cookie *fscache_alloc_cookie(u8 advice, const void *index_key, size_t index_key_len, const void *aux_data, size_t aux_data_len, - loff_t object_size) + uoff_t object_size) { struct fscache_cookie *cookie;
@@ -452,7 +452,7 @@ struct fscache_cookie *__fscache_acquire_cookie(u8 advice, const void *index_key, size_t index_key_len, const void *aux_data, size_t aux_data_len, - loff_t object_size) + uoff_t object_size) { struct fscache_cookie *cookie;
@@ -663,7 +663,7 @@ static void fscache_unuse_cookie_locked(struct fscache_cookie *cookie)* Stop using the cookie for I/O. */ void __fscache_unuse_cookie (struct fscache_cookie *cookie, -const void *aux_data,const loff_t *object_size) +const void *aux_data,const uoff_t *object_size) {unsigned int debug_id = cookie->debug_id;unsigned int r =refcount_read (&cookie->ref);
@@ -1049,7 +1049,7 @@ static void fscache_perform_invalidation(struct fscache_cookie *cookie)* Invalidate an object. */ void __fscache_invalidate (struct fscache_cookie *cookie, -const void *aux_data,loff_t new_size, +const void *aux_data,uoff_t new_size,unsigned int flags) {bool is_caching;
fs/netfs/fscache_io.c +4 -4
@@ -162,7 +162,7 @@ EXPORT_SYMBOL(__fscache_begin_write_operation);struct fscache_write_request {struct netfs_cache_resources cache_resources;struct address_space *mapping; -loff_t start; +uoff_t start;size_t len;bool set_bits;bool using_pgpriv2;
@@ -171,7 +171,7 @@ struct fscache_write_request { };void __fscache_clear_page_bits (struct address_space *mapping, -loff_t start,size_t len) +uoff_t start,size_t len) {pgoff_t first = start /PAGE_SIZE ;pgoff_t last = (start + len -1 ) /PAGE_SIZE ;
@@ -208,7 +208,7 @@ static void fscache_wreq_done(void *priv, ssize_t transferred_or_error)void __fscache_write_to_cache (struct fscache_cookie *cookie,struct address_space *mapping, -loff_t start,size_t len,loff_t i_size, +uoff_t start,size_t len,uoff_t i_size,netfs_io_terminated_t term_func,void *term_func_priv,bool using_pgpriv2,bool cond)
@@ -267,7 +267,7 @@ EXPORT_SYMBOL(__fscache_write_to_cache);/* * Change the size of a backing object. */ -void __fscache_resize_cookie (struct fscache_cookie *cookie,loff_t new_size) +void __fscache_resize_cookie (struct fscache_cookie *cookie,uoff_t new_size) {struct netfs_cache_resources cres;
fs/netfs/internal.h +5 -5
@@ -33,7 +33,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,* buffered_write.c */ void netfs_update_i_size (struct netfs_inode *ctx,struct inode *inode, -loff_t pos,size_t copied); +uoff_t pos,size_t copied);/* * main.c
@@ -86,7 +86,7 @@ void netfs_wait_for_put_ra_refs(struct netfs_io_request *rreq);*/ struct netfs_io_request *netfs_alloc_request (struct address_space *mapping,struct file *file, -loff_t start,size_t len, +uoff_t start,size_t len,enum netfs_io_origin origin);void netfs_get_request (struct netfs_io_request *rreq,enum netfs_rreq_ref_trace what);void netfs_clear_subrequests (struct netfs_io_request *rreq);
@@ -203,11 +203,11 @@ void netfs_write_collection_worker(struct work_struct *work);*/ struct netfs_io_request *netfs_create_write_req (struct address_space *mapping,struct file *file, -loff_t start, +uoff_t start,enum netfs_io_origin origin);void netfs_prepare_write (struct netfs_io_request *wreq,struct netfs_io_stream *stream, -loff_t start); +uoff_t start);void netfs_reissue_write (struct netfs_io_stream *stream,struct netfs_io_subrequest *subreq,struct iov_iter *source);
@@ -215,7 +215,7 @@ void netfs_issue_write(struct netfs_io_request *wreq, struct netfs_io_stream *stream);size_t netfs_advance_write (struct netfs_io_request *wreq,struct netfs_io_stream *stream, -loff_t start,size_t len,bool to_eof); +uoff_t start,size_t len,bool to_eof);struct netfs_io_request *netfs_begin_writethrough (struct kiocb *iocb,size_t len); int netfs_advance_writethrough(struct netfs_io_request *wreq, struct writeback_control *wbc, struct folio *folio, size_t copied, bool to_page_end,
fs/netfs/iterator.c +1 -1
@@ -209,7 +209,7 @@ static size_t netfs_limit_xarray(const struct iov_iter *iter, size_t start_offse {struct folio *folio;unsigned int nsegs =0 ; -loff_t pos = iter->xarray_start + iter->iov_offset; +uoff_t pos = iter->xarray_start + iter->iov_offset;pgoff_t index = pos /PAGE_SIZE ;size_t span =0 , n = iter->count;
fs/netfs/misc.c +4 -4
@@ -193,7 +193,7 @@ void netfs_clear_inode_writeback(struct inode *inode, const void *aux)struct fscache_cookie *cookie =netfs_i_cookie (netfs_inode (inode));if (inode_state_read_once (inode) &I_PINNING_NETFS_WB ) { -loff_t i_size =i_size_read (inode); +uoff_t i_size =i_size_read (inode);fscache_unuse_cookie (cookie, aux, &i_size); } }
@@ -218,8 +218,8 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)_enter ("{%lx},%zx,%zx" , folio->index, offset, length);if (offset ==0 && length == flen) { -unsigned long long i_size, remote_i_size, zero_point; -unsigned long long fpos =folio_pos (folio), end; +uoff_t i_size, remote_i_size, zero_point; +uoff_t fpos =folio_pos (folio), end;netfs_read_sizes (inode, &i_size, &remote_i_size, &zero_point); end =umin (fpos + flen, i_size);
@@ -305,7 +305,7 @@ bool netfs_release_folio(struct folio *folio, gfp_t gfp) {struct inode *inode =folio_inode (folio);struct netfs_inode *ctx =netfs_inode (inode); -unsigned long long i_size, remote_i_size, zero_point, end; +uoff_t i_size, remote_i_size, zero_point, end;if (folio_test_dirty (folio))return false;
fs/netfs/objects.c +1 -1
@@ -16,7 +16,7 @@ static void netfs_free_request(struct work_struct *work);*/ struct netfs_io_request *netfs_alloc_request (struct address_space *mapping,struct file *file, -loff_t start,size_t len, +uoff_t start,size_t len,enum netfs_io_origin origin) {static atomic_t debug_ids;
fs/netfs/read_collect.c +2 -2
@@ -153,8 +153,8 @@ static void netfs_read_unlock_folios(struct netfs_io_request *rreq, unsigned int *notes) {struct folio_queue *folioq = rreq->buffer.tail; -unsigned long long collected_to = rreq->collected_to;unsigned int slot = rreq->buffer.first_tail_slot; +uoff_t collected_to = rreq->collected_to;if (rreq->cleaned_to >= rreq->collected_to)return ;
@@ -179,7 +179,7 @@ static void netfs_read_unlock_folios(struct netfs_io_request *rreq,for (;;) {struct folio *folio; -unsigned long long fpos, fend; +uoff_t fpos, fend;size_t fsize; folio =folioq_folio (folioq, slot);
fs/netfs/read_pgpriv2.c +4 -4
@@ -20,7 +20,7 @@ static void netfs_pgpriv2_copy_folio(struct netfs_io_request *creq, struct folio {struct netfs_io_stream *cache = &creq->io_streams[1 ];size_t fsize =folio_size (folio), flen = fsize; -loff_t fpos =folio_pos (folio), i_size; +uoff_t fpos =folio_pos (folio), i_size;bool to_eof = false;_enter ("" );
@@ -175,8 +175,8 @@ void netfs_pgpriv2_end_copy_to_cache(struct netfs_io_request *rreq)bool netfs_pgpriv2_unlock_copied_folios (struct netfs_io_request *creq) {struct folio_queue *folioq = creq->buffer.tail; -unsigned long long collected_to = creq->collected_to;unsigned int slot = creq->buffer.first_tail_slot; +uoff_t collected_to = creq->collected_to;bool made_progress = false;if (slot >=folioq_nr_slots (folioq)) {
@@ -186,7 +186,7 @@ bool netfs_pgpriv2_unlock_copied_folios(struct netfs_io_request *creq)for (;;) {struct folio *folio; -unsigned long long fpos, fend; +uoff_t fpos, fend;size_t fsize, flen; folio =folioq_folio (folioq, slot);
@@ -199,7 +199,7 @@ bool netfs_pgpriv2_unlock_copied_folios(struct netfs_io_request *creq) fsize =folio_size (folio); flen = fsize; - fend = min_t(unsigned long long, fpos + flen, creq->i_size); + fend =min_t (uoff_t, fpos + flen, creq->i_size);trace_netfs_collect_folio (creq, folio, fend, collected_to);
fs/netfs/read_retry.c +1 -1
@@ -75,7 +75,7 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) do { struct netfs_io_subrequest *from, *to, *tmp; struct iov_iter source; - unsigned long long start, len; + uoff_t start, len; size_t part; bool boundary = false, subreq_superfluous = false;
fs/netfs/write_collect.c +5 -5
@@ -67,7 +67,7 @@ int netfs_folio_written_back(struct folio *folio)/* Streaming writes cannot be redirtied whilst under writeback, * so discard the streaming record. */ -unsigned long long fend; +uoff_t fend; fend =folio_pos (folio) + finfo->dirty_offset + finfo->dirty_len;spin_lock (&ictx->inode.i_lock);
@@ -115,8 +115,8 @@ static void netfs_writeback_unlock_folios(struct netfs_io_request *wreq, unsigned int *notes) {struct folio_queue *folioq = wreq->buffer.tail; -unsigned long long collected_to = wreq->collected_to;unsigned int slot = wreq->buffer.first_tail_slot; +uoff_t collected_to = wreq->collected_to;if (WARN_ON_ONCE (!folioq)) {pr_err ("[!] Writeback unlock found empty rolling buffer!\n" );
@@ -140,7 +140,7 @@ static void netfs_writeback_unlock_folios(struct netfs_io_request *wreq,for (;;) {struct folio *folio;struct netfs_folio *finfo; -unsigned long long fpos, fend; +uoff_t fpos, fend;size_t fsize, flen; folio =folioq_folio (folioq, slot);
@@ -154,7 +154,7 @@ static void netfs_writeback_unlock_folios(struct netfs_io_request *wreq, finfo =netfs_folio_info (folio); flen = finfo ? finfo->dirty_offset + finfo->dirty_len : fsize; - fend = min_t(unsigned long long, fpos + flen, wreq->i_size); + fend =min_t (uoff_t, fpos + flen, wreq->i_size);trace_netfs_collect_folio (wreq, folio, fend, collected_to);
@@ -201,8 +201,8 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq) {struct netfs_io_subrequest *front, *remove;struct netfs_io_stream *stream; -unsigned long long collected_to, issued_to;unsigned int notes; +uoff_t collected_to, issued_to;int s;_enter ("%llx-%llx" , wreq->start, wreq->start + wreq->len);
fs/netfs/write_issue.c +5 -5
@@ -89,7 +89,7 @@ static void netfs_kill_dirty_pages(struct address_space *mapping,*/ struct netfs_io_request *netfs_create_write_req (struct address_space *mapping,struct file *file, -loff_t start, +uoff_t start,enum netfs_io_origin origin) {struct netfs_io_request *wreq;
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(netfs_prepare_write_failed);*/ void netfs_prepare_write (struct netfs_io_request *wreq,struct netfs_io_stream *stream, -loff_t start) +uoff_t start) {struct netfs_io_subrequest *subreq;struct iov_iter *wreq_iter = &wreq->buffer.iter;
@@ -279,7 +279,7 @@ void netfs_issue_write(struct netfs_io_request *wreq,*/ size_t netfs_advance_write (struct netfs_io_request *wreq,struct netfs_io_stream *stream, -loff_t start,size_t len,bool to_eof) +uoff_t start,size_t len,bool to_eof) {struct netfs_io_subrequest *subreq = stream->construct;size_t part;
@@ -330,7 +330,7 @@ static int netfs_write_folio(struct netfs_io_request *wreq,struct netfs_folio *finfo;size_t iter_off =0 ;size_t fsize =folio_size (folio), flen = fsize, foff =0 ; -loff_t fpos =folio_pos (folio), i_size; +uoff_t fpos =folio_pos (folio), i_size;bool to_eof = false, streamw = false;bool debug = false;
@@ -721,7 +721,7 @@ static int netfs_write_folio_single(struct netfs_io_request *wreq,struct netfs_io_stream *stream;size_t iter_off =0 ;size_t fsize =folio_size (folio), flen; -loff_t fpos =folio_pos (folio); +uoff_t fpos =folio_pos (folio);ssize_t ret;bool to_eof = false;bool no_debug = false;
fs/netfs/write_retry.c +1 -1
@@ -55,7 +55,7 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, do { struct netfs_io_subrequest *subreq = NULL, *from, *to, *tmp; struct iov_iter source; - unsigned long long start, len; + uoff_t start, len; size_t part; bool boundary = false;
include/linux/fscache-cache.h +1 -1
@@ -67,7 +67,7 @@ struct fscache_cache_ops {/* Change the size of a data object */ void (*resize_cookie)(struct netfs_cache_resources *cres, -loff_t new_size); +uoff_t new_size);/* Invalidate an object */ bool (*invalidate_cookie)(struct fscache_cookie *cookie);
include/linux/fscache.h +18 -18
@@ -112,7 +112,7 @@ struct fscache_cookie {struct list_head proc_link;/* Link in proc list */ struct list_head commit_link;/* Link in commit queue */ struct work_struct work;/* Commit/relinq/withdraw work */ -loff_t object_size;/* Size of the netfs object */ +uoff_t object_size;/* Size of the netfs object */ unsigned long unused_at;/* Time at which unused (jiffies) */ unsigned long flags;#define FSCACHE_COOKIE_RELINQUISHED 0/* T if cookie has been relinquished */
@@ -163,22 +163,22 @@ extern struct fscache_cookie *__fscache_acquire_cookie( u8, const void *, size_t, const void *, size_t, - loff_t); + uoff_t);extern void __fscache_use_cookie (struct fscache_cookie *,bool ); -extern void __fscache_unuse_cookie (struct fscache_cookie *,const void *,const loff_t *); +extern void __fscache_unuse_cookie (struct fscache_cookie *,const void *,const uoff_t *);extern void __fscache_relinquish_cookie (struct fscache_cookie *,bool ); -extern void __fscache_resize_cookie (struct fscache_cookie *,loff_t ); -extern void __fscache_invalidate (struct fscache_cookie *,const void *,loff_t ,unsigned int ); +extern void __fscache_resize_cookie (struct fscache_cookie *,uoff_t ); +extern void __fscache_invalidate (struct fscache_cookie *,const void *,uoff_t ,unsigned int );extern int __fscache_begin_read_operation (struct netfs_cache_resources *,struct fscache_cookie *);extern int __fscache_begin_write_operation (struct netfs_cache_resources *,struct fscache_cookie *);void __fscache_write_to_cache (struct fscache_cookie *cookie,struct address_space *mapping, -loff_t start,size_t len,loff_t i_size, +uoff_t start,size_t len,uoff_t i_size,netfs_io_terminated_t term_func,void *term_func_priv,bool using_pgpriv2,bool cond); -extern void __fscache_clear_page_bits (struct address_space *,loff_t ,size_t ); +extern void __fscache_clear_page_bits (struct address_space *,uoff_t ,size_t );/** * fscache_acquire_volume - Register a volume as desiring caching services
@@ -249,7 +249,7 @@ struct fscache_cookie *fscache_acquire_cookie(struct fscache_volume *volume, size_t index_key_len, const void *aux_data, size_t aux_data_len, - loff_t object_size) + uoff_t object_size) { if (!fscache_volume_valid(volume)) return NULL;
@@ -286,7 +286,7 @@ static inline void fscache_use_cookie(struct fscache_cookie *cookie,*/ static inline void fscache_unuse_cookie (struct fscache_cookie *cookie,const void *aux_data, -const loff_t *object_size) +const uoff_t *object_size) {if (fscache_cookie_valid (cookie))__fscache_unuse_cookie (cookie, aux_data, object_size);
@@ -327,7 +327,7 @@ static inline void *fscache_get_aux(struct fscache_cookie *cookie)*/ static inline void fscache_update_aux (struct fscache_cookie *cookie, -const void *aux_data,const loff_t *object_size) +const void *aux_data,const uoff_t *object_size) {void *p =fscache_get_aux (cookie);
@@ -343,7 +343,7 @@ extern atomic_t fscache_n_updates;static inline void __fscache_update_cookie (struct fscache_cookie *cookie,const void *aux_data, -const loff_t *object_size) +const uoff_t *object_size) {#ifdef CONFIG_FSCACHE_STATS atomic_inc (&fscache_n_updates);
@@ -369,7 +369,7 @@ void __fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data*/ static inline void fscache_update_cookie (struct fscache_cookie *cookie,const void *aux_data, -const loff_t *object_size) +const uoff_t *object_size) {if (fscache_cookie_enabled (cookie))__fscache_update_cookie (cookie, aux_data, object_size);
@@ -386,7 +386,7 @@ void fscache_update_cookie(struct fscache_cookie *cookie, const void *aux_data,* description. */ static inline -void fscache_resize_cookie (struct fscache_cookie *cookie,loff_t new_size) +void fscache_resize_cookie (struct fscache_cookie *cookie,uoff_t new_size) {if (fscache_cookie_enabled (cookie))__fscache_resize_cookie (cookie, new_size);
@@ -413,7 +413,7 @@ void fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size)*/ static inline void fscache_invalidate (struct fscache_cookie *cookie, -const void *aux_data,loff_t size,unsigned int flags) +const void *aux_data,uoff_t size,unsigned int flags) {if (fscache_cookie_enabled (cookie))__fscache_invalidate (cookie, aux_data, size, flags);
@@ -502,7 +502,7 @@ static inline void fscache_end_operation(struct netfs_cache_resources *cres)*/ static inline int fscache_read(struct netfs_cache_resources *cres, - loff_t start_pos, + uoff_t start_pos, struct iov_iter *iter, enum netfs_read_from_hole read_hole, netfs_io_terminated_t term_func,
@@ -561,7 +561,7 @@ int fscache_begin_write_operation(struct netfs_cache_resources *cres,*/ static inline int fscache_write (struct netfs_cache_resources *cres, -loff_t start_pos, +uoff_t start_pos,struct iov_iter *iter,netfs_io_terminated_t term_func,void *term_func_priv)
@@ -581,7 +581,7 @@ int fscache_write(struct netfs_cache_resources *cres,* waiting. */ static inline void fscache_clear_page_bits (struct address_space *mapping, -loff_t start,size_t len, +uoff_t start,size_t len,bool caching) {if (caching)
@@ -615,7 +615,7 @@ static inline void fscache_clear_page_bits(struct address_space *mapping,*/ static inline void fscache_write_to_cache (struct fscache_cookie *cookie,struct address_space *mapping, -loff_t start,size_t len,loff_t i_size, +uoff_t start,size_t len,uoff_t i_size,netfs_io_terminated_t term_func,void *term_func_priv,bool using_pgpriv2,bool caching)
include/linux/netfs.h +37 -37
198 lines not on this page · raw message
include/trace/events/cachefiles.h +15 -15
@@ -449,7 +449,7 @@ TRACE_EVENT(cachefiles_vol_coherency, TRACE_EVENT(cachefiles_prep_read, TP_PROTO(struct cachefiles_object *obj, - loff_t start, + uoff_t start, size_t len, unsigned short flags, enum netfs_io_source source,
@@ -464,7 +464,7 @@ TRACE_EVENT(cachefiles_prep_read, __field(enum netfs_io_source, source) __field(enum cachefiles_prepare_read_trace, why) __field(size_t, len) - __field(loff_t, start) + __field(uoff_t, start) __field(unsigned int, netfs_inode) __field(unsigned int, cache_inode) ),
@@ -492,16 +492,16 @@ TRACE_EVENT(cachefiles_prep_read, TRACE_EVENT(cachefiles_read, TP_PROTO(struct cachefiles_object *obj, struct inode *backer, - loff_t start, + uoff_t start, size_t len), TP_ARGS(obj, backer, start, len), TP_STRUCT__entry( - __field(unsigned int, obj) - __field(unsigned int, backer) - __field(size_t, len) - __field(loff_t, start) + __field(unsigned int, obj) + __field(unsigned int, backer) + __field(size_t, len) + __field(uoff_t, start) ), TP_fast_assign(
@@ -521,16 +521,16 @@ TRACE_EVENT(cachefiles_read, TRACE_EVENT(cachefiles_write, TP_PROTO(struct cachefiles_object *obj, struct inode *backer, - loff_t start, + uoff_t start, size_t len), TP_ARGS(obj, backer, start, len), TP_STRUCT__entry( - __field(unsigned int, obj) - __field(unsigned int, backer) - __field(size_t, len) - __field(loff_t, start) + __field(unsigned int, obj) + __field(unsigned int, backer) + __field(size_t, len) + __field(uoff_t, start) ), TP_fast_assign(
@@ -549,7 +549,7 @@ TRACE_EVENT(cachefiles_write, TRACE_EVENT(cachefiles_trunc, TP_PROTO(struct cachefiles_object *obj, struct inode *backer, - loff_t from, loff_t to, enum cachefiles_trunc_trace why), + uoff_t from, uoff_t to, enum cachefiles_trunc_trace why), TP_ARGS(obj, backer, from, to, why),
@@ -557,8 +557,8 @@ TRACE_EVENT(cachefiles_trunc, __field(unsigned int, obj) __field(unsigned int, backer) __field(enum cachefiles_trunc_trace, why) - __field(loff_t, from) - __field(loff_t, to) + __field(uoff_t, from) + __field(uoff_t, to) ), TP_fast_assign(
include/trace/events/fscache.h +5 -5
@@ -460,13 +460,13 @@ TRACE_EVENT(fscache_relinquish, ); TRACE_EVENT(fscache_invalidate, - TP_PROTO(struct fscache_cookie *cookie, loff_t new_size), + TP_PROTO(struct fscache_cookie *cookie, uoff_t new_size), TP_ARGS(cookie, new_size), TP_STRUCT__entry( __field(unsigned int, cookie ) - __field(loff_t, new_size ) + __field(uoff_t, new_size ) ), TP_fast_assign(
@@ -479,14 +479,14 @@ TRACE_EVENT(fscache_invalidate, ); TRACE_EVENT(fscache_resize, - TP_PROTO(struct fscache_cookie *cookie, loff_t new_size), + TP_PROTO(struct fscache_cookie *cookie, uoff_t new_size), TP_ARGS(cookie, new_size), TP_STRUCT__entry( __field(unsigned int, cookie ) - __field(loff_t, old_size ) - __field(loff_t, new_size ) + __field(uoff_t, old_size ) + __field(uoff_t, new_size ) ), TP_fast_assign(
include/trace/events/netfs.h +38 -39
178 lines not on this page · raw message
David Howells
maintainerPATCH v12 2/8 netfs: Remove the writethrough code
In reply to David HowellsRemove the netfs writethrough code as it's very tricky to get the locking right and it will probably deadlock if used in conjunction with Ceph snapshots because it excludes writeback for the duration, but to flush out old snapshots, it does a synchronous flush that invokes writeback.
Instead, O_SYNC writes do a flush after performing the write - which is already there as the callers of netfs_perform_write() all call generic_write_sync().
--- fs/9p/vfs_addr.c | 1 - fs/afs/file.c | 1 - fs/netfs/buffered_write.c | 56 ++----------------- fs/netfs/internal.h | 7 --- fs/netfs/main.c | 1 - fs/netfs/stats.c | 4 +- fs/netfs/write_collect.c | 2 - fs/netfs/write_issue.c | 104 +---------------------------------- include/linux/netfs.h | 1 - include/trace/events/netfs.h | 8 +-- 10 files changed, 9 insertions(+), 176 deletions(-)
fs/9p/vfs_addr.c +0 -1
@@ -124,7 +124,6 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)struct p9_fid *fid;struct dentry *dentry;bool writing = (rreq->origin ==NETFS_READ_FOR_WRITE || - rreq->origin ==NETFS_WRITETHROUGH || rreq->origin ==NETFS_UNBUFFERED_WRITE || rreq->origin ==NETFS_DIO_WRITE );
fs/afs/file.c +0 -1
@@ -400,7 +400,6 @@ static int afs_init_request(struct netfs_io_request *rreq, struct file *file) }break ;case NETFS_WRITEBACK : -case NETFS_WRITETHROUGH :case NETFS_UNBUFFERED_WRITE :case NETFS_DIO_WRITE :if (S_ISREG (rreq->inode->i_mode))
fs/netfs/buffered_write.c +5 -51
79 lines not on this page · raw message
fs/netfs/internal.h +0 -7
@@ -157,7 +157,6 @@ extern atomic_t netfs_n_rh_write_zskip;extern atomic_t netfs_n_rh_retry_read_req;extern atomic_t netfs_n_rh_retry_read_subreq;extern atomic_t netfs_n_wh_buffered_write; -extern atomic_t netfs_n_wh_writethrough;extern atomic_t netfs_n_wh_dio_write;extern atomic_t netfs_n_wh_writepages;extern atomic_t netfs_n_wh_copy_to_cache;
@@ -216,12 +215,6 @@ void netfs_issue_write(struct netfs_io_request *wreq,size_t netfs_advance_write (struct netfs_io_request *wreq,struct netfs_io_stream *stream,uoff_t start,size_t len,bool to_eof); -struct netfs_io_request *netfs_begin_writethrough (struct kiocb *iocb,size_t len); -int netfs_advance_writethrough (struct netfs_io_request *wreq,struct writeback_control *wbc, -struct folio *folio,size_t copied,bool to_page_end, -struct folio **writethrough_cache); -ssize_t netfs_end_writethrough (struct netfs_io_request *wreq,struct writeback_control *wbc, -struct folio *writethrough_cache);/* * write_retry.c
fs/netfs/main.c +0 -1
@@ -44,7 +44,6 @@ static const char *netfs_origins[nr__netfs_io_origin] = { [NETFS_DIO_READ] = "DR", [NETFS_WRITEBACK] = "WB", [NETFS_WRITEBACK_SINGLE] = "W1", - [NETFS_WRITETHROUGH] = "WT", [NETFS_UNBUFFERED_WRITE] = "UW", [NETFS_DIO_WRITE] = "DW", [NETFS_PGPRIV2_COPY_TO_CACHE] = "2C",
fs/netfs/stats.c +1 -3
@@ -32,7 +32,6 @@ atomic_t netfs_n_rh_write_zskip;atomic_t netfs_n_rh_retry_read_req;atomic_t netfs_n_rh_retry_read_subreq;atomic_t netfs_n_wh_buffered_write; -atomic_t netfs_n_wh_writethrough;atomic_t netfs_n_wh_dio_write;atomic_t netfs_n_wh_writepages;atomic_t netfs_n_wh_copy_to_cache;
@@ -58,9 +57,8 @@ int netfs_stats_show(struct seq_file *m, void *v)atomic_read (&netfs_n_rh_read_single),atomic_read (&netfs_n_rh_write_begin), atomic_read(&netfs_n_rh_write_zskip)); -seq_printf (m,"Writes : BW=%u WT=%u DW=%u WP=%u 2C=%u\n" , +seq_printf (m,"Writes : BW=%u DW=%u WP=%u 2C=%u\n" ,atomic_read (&netfs_n_wh_buffered_write), -atomic_read (&netfs_n_wh_writethrough),atomic_read (&netfs_n_wh_dio_write),atomic_read (&netfs_n_wh_writepages),atomic_read (&netfs_n_wh_copy_to_cache));
fs/netfs/write_collect.c +0 -2
@@ -214,7 +214,6 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq)smp_rmb (); collected_to =ULLONG_MAX ;if (wreq->origin ==NETFS_WRITEBACK || - wreq->origin ==NETFS_WRITETHROUGH || wreq->origin ==NETFS_PGPRIV2_COPY_TO_CACHE ) notes =NEED_UNLOCK ;else
@@ -411,7 +410,6 @@ bool netfs_write_collection(struct netfs_io_request *wreq)switch (wreq->origin) {case NETFS_WRITEBACK :case NETFS_WRITEBACK_SINGLE : -case NETFS_WRITETHROUGH :netfs_wb_end (ictx);break ;default :
fs/netfs/write_issue.c +1 -103
122 lines not on this page · raw message
include/linux/netfs.h +0 -1
@@ -208,7 +208,6 @@ enum netfs_io_origin {NETFS_DIO_READ ,/* This is a direct I/O read */ NETFS_WRITEBACK ,/* This write was triggered by writepages */ NETFS_WRITEBACK_SINGLE ,/* This monolithic write was triggered by writepages */ -NETFS_WRITETHROUGH ,/* This write was made by netfs_perform_write() */ NETFS_UNBUFFERED_WRITE ,/* This is an unbuffered write */ NETFS_DIO_WRITE ,/* This is a direct I/O write */ NETFS_PGPRIV2_COPY_TO_CACHE, /* [DEPRECATED] This is writing read data to the cache */
include/trace/events/netfs.h +2 -6
@@ -30,8 +30,7 @@ EM(netfs_write_trace_dio_write, "DIO-WRITE") \ EM(netfs_write_trace_unbuffered_write, "UNB-WRITE") \ EM(netfs_write_trace_writeback, "WRITEBACK") \ - EM(netfs_write_trace_writeback_single, "WB-SINGLE") \ - E_(netfs_write_trace_writethrough, "WRITETHRU") + E_(netfs_write_trace_writeback_single, "WB-SINGLE")#define netfs_rreq_origins \ EM(NETFS_READAHEAD, "RA") \
@@ -43,7 +42,6 @@ EM(NETFS_DIO_READ, "DR") \ EM(NETFS_WRITEBACK, "WB") \ EM(NETFS_WRITEBACK_SINGLE, "W1") \ - EM(NETFS_WRITETHROUGH, "WT") \ EM(NETFS_UNBUFFERED_WRITE, "UW") \ EM(NETFS_DIO_WRITE, "DW") \E_ (NETFS_PGPRIV2_COPY_TO_CACHE ,"2C" )
@@ -223,9 +221,7 @@ EM(netfs_folio_trace_sched_copy, "sched-copy") \ EM(netfs_folio_trace_store, "store") \ EM(netfs_folio_trace_store_copy, "store-copy") \ - EM(netfs_folio_trace_store_plus, "store+") \ - EM(netfs_folio_trace_wthru, "wthru") \ - E_(netfs_folio_trace_wthru_plus, "wthru+") + E_(netfs_folio_trace_store_plus, "store+")#define netfs_collect_contig_traces \ EM(netfs_contig_trace_collect, "Collect") \
David Howells
maintainerPATCH v12 3/8 netfs: trace: Change the "clear" folio traces to "endwb"
In reply to David HowellsChange the "clear" folio traces to "endwb" as it's more obvious what it means.
--- fs/netfs/write_collect.c | 8 ++++---- include/trace/events/netfs.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
fs/netfs/write_collect.c +4 -4
@@ -56,7 +56,7 @@ static void netfs_dump_request(const struct netfs_io_request *rreq)*/ int netfs_folio_written_back (struct folio *folio) { -enum netfs_folio_trace why = netfs_folio_trace_clear; +enum netfs_folio_trace why = netfs_folio_trace_endwb;struct inode *inode =folio_inode (folio);struct netfs_inode *ictx =netfs_inode (inode);struct netfs_folio *finfo;
@@ -79,13 +79,13 @@ int netfs_folio_written_back(struct folio *folio) group = finfo->netfs_group; gcount++;kfree (finfo); - why = netfs_folio_trace_clear_s; + why = netfs_folio_trace_endwb_s; goto end_wb; }if ((group =netfs_folio_group (folio))) {if (group ==NETFS_FOLIO_COPY_TO_CACHE ) { - why = netfs_folio_trace_clear_cc; + why = netfs_folio_trace_endwb_cc;folio_detach_private (folio); goto end_wb; }
@@ -98,7 +98,7 @@ int netfs_folio_written_back(struct folio *folio)if (!folio_test_dirty (folio)) {folio_detach_private (folio); gcount++; - why = netfs_folio_trace_clear_g; + why = netfs_folio_trace_endwb_g; } }
include/trace/events/netfs.h +4 -4
@@ -192,11 +192,11 @@ EM(netfs_folio_trace_alloc_buffer, "alloc-buf") \ EM(netfs_folio_trace_cancel_copy, "cancel-copy") \ EM(netfs_folio_trace_cancel_store, "cancel-store") \ - EM(netfs_folio_trace_clear, "clear") \ - EM(netfs_folio_trace_clear_cc, "clear-cc") \ - EM(netfs_folio_trace_clear_g, "clear-g") \ - EM(netfs_folio_trace_clear_s, "clear-s") \ EM(netfs_folio_trace_end_copy, "end-copy") \ + EM(netfs_folio_trace_endwb, "endwb") \ + EM(netfs_folio_trace_endwb_cc, "endwb-cc") \ + EM(netfs_folio_trace_endwb_g, "endwb-g") \ + EM(netfs_folio_trace_endwb_s, "endwb-s") \ EM(netfs_folio_trace_filled_gaps, "filled-gaps") \ EM(netfs_folio_trace_invalidate_all, "inval-all") \EM (netfs_folio_trace_invalidate_front,"inval-front" ) \
David Howells
maintainerPATCH v12 4/8 netfs: trace: Rejig a couple of the tracepoints
In reply to David HowellsRejig the following tracepoints:
(1) Change netfs_folio to show the pfn.
(2) Change netfs_collect_folio to show a folio index range rather than file position range and don't show the cleaned_to or collected_to points.
--- fs/netfs/read_collect.c | 2 +- fs/netfs/read_pgpriv2.c | 2 +- fs/netfs/write_collect.c | 2 +- include/trace/events/netfs.h | 23 ++++++++++------------- 4 files changed, 13 insertions(+), 16 deletions(-)
fs/netfs/read_collect.c +1 -1
@@ -192,7 +192,7 @@ static void netfs_read_unlock_folios(struct netfs_io_request *rreq, fpos =folio_pos (folio); fend = fpos + fsize; -trace_netfs_collect_folio (rreq, folio, fend, collected_to); +trace_netfs_collect_folio (rreq, folio);/* Unlock any folio we've transferred all of. */ if (collected_to < fend)
fs/netfs/read_pgpriv2.c +1 -1
@@ -201,7 +201,7 @@ bool netfs_pgpriv2_unlock_copied_folios(struct netfs_io_request *creq) fend =min_t (uoff_t, fpos + flen, creq->i_size); -trace_netfs_collect_folio (creq, folio, fend, collected_to); +trace_netfs_collect_folio (creq, folio);/* Unlock any folio we've transferred all of. */ if (collected_to < fend)
fs/netfs/write_collect.c +1 -1
@@ -156,7 +156,7 @@ static void netfs_writeback_unlock_folios(struct netfs_io_request *wreq, fend =min_t (uoff_t, fpos + flen, wreq->i_size); -trace_netfs_collect_folio (wreq, folio, fend, collected_to); +trace_netfs_collect_folio (wreq, folio);/* Unlock any folio we've transferred all of. */ if (collected_to < fend)
include/trace/events/netfs.h +10 -13
@@ -497,6 +497,7 @@ TRACE_EVENT(netfs_folio,TP_STRUCT__entry (__field (u64 ,ino )__field (pgoff_t, index) + __field(unsigned long, pfn) __field(unsigned int, nr) __field(enum netfs_folio_trace, why) ),
@@ -507,9 +508,11 @@ TRACE_EVENT(netfs_folio, __entry->why = why; __entry->index = folio->index; __entry->nr =folio_nr_pages (folio); + __entry->pfn =folio_pfn (folio); ), -TP_printk ("i=%05llx ix=%05lx-%05lx %s" , +TP_printk ("p=%lx i=%05llx ix=%05lx-%05lx %s" , + __entry->pfn, __entry->ino, __entry->index, __entry->index + __entry->nr -1 ,__print_symbolic (__entry->why, netfs_folio_traces)) );
@@ -656,31 +659,25 @@ TRACE_EVENT(netfs_collect_sreq,TRACE_EVENT (netfs_collect_folio, TP_PROTO(const struct netfs_io_request *wreq, - const struct folio *folio, - uoff_t fend, uoff_t collected_to), + const struct folio *folio), -TP_ARGS (wreq, folio, fend, collected_to), +TP_ARGS (wreq, folio),TP_STRUCT__entry ( __field(unsigned int, wreq) __field(unsigned long, index) - __field(uoff_t, fend) - __field(uoff_t, cleaned_to) -__field (uoff_t, collected_to) + __field(unsigned int, nr) ),TP_fast_assign ( __entry->wreq = wreq->debug_id; __entry->index = folio->index; - __entry->fend = fend; - __entry->cleaned_to = wreq->cleaned_to; - __entry->collected_to = collected_to; + __entry->nr = folio_nr_pages(folio); ), -TP_printk ("R=%08x ix=%05lx r=%llx-%llx t=%llx/%llx" , +TP_printk ("R=%08x ix=%05lx-%05lx" , __entry->wreq, __entry->index, - (uoff_t )__entry->index *PAGE_SIZE , __entry->fend, - __entry->cleaned_to, __entry->collected_to) + __entry->index + __entry->nr -1 ) ); TRACE_EVENT(netfs_collect_state,
David Howells
maintainerPATCH v12 5/8 netfs: Add the cache object ID to netfs_read/write tracepoints
In reply to David HowellsAdd the cache object debug ID to netfs_read/write tracepoints to make debugging easier as there's now a direct cross-reference with the cachefiles tracepoints that only log that debug ID.
--- fs/cachefiles/io.c | 1 + fs/netfs/fscache_io.c | 2 +- include/linux/netfs.h | 3 ++- include/trace/events/netfs.h | 27 +++++++++++++++------------ 4 files changed, 19 insertions(+), 14 deletions(-)
fs/cachefiles/io.c +1 -0
@@ -721,6 +721,7 @@ bool cachefiles_begin_operation(struct netfs_cache_resources *cres,if (!cachefiles_cres_file (cres)) { cres->ops = &cachefiles_netfs_cache_ops; + cres->object_id = object->debug_id;if (object->file) {spin_lock (&object->lock);if (!cres->cache_priv2 && object->file)
fs/netfs/fscache_io.c +1 -1
@@ -79,7 +79,7 @@ static int fscache_begin_operation(struct netfs_cache_resources *cres, cres->ops =NULL ; cres->cache_priv = cookie; cres->cache_priv2 =NULL ; - cres->debug_id = cookie->debug_id; + cres->cookie_id = cookie->debug_id; cres->inval_counter = cookie->inval_counter;if (!fscache_begin_cookie_access (cookie, why)) {
include/linux/netfs.h +2 -1
@@ -161,7 +161,8 @@ struct netfs_cache_resources {const struct netfs_cache_ops *ops;void *cache_priv;void *cache_priv2; -unsigned int debug_id;/* Cookie debug ID */ +unsigned int cookie_id;/* Cache cookie debug ID */ +unsigned int object_id;/* Cache object debug ID */ unsigned int inval_counter;/* object->inval_counter at begin_op */ };
include/trace/events/netfs.h +15 -12
@@ -305,6 +305,7 @@ TRACE_EVENT(netfs_read,TP_STRUCT__entry (__field (unsigned int ,rreq ) __field(unsigned int, cookie) + __field(unsigned int, object)__field (uoff_t, i_size)__field (uoff_t, start) __field(size_t, len)
@@ -314,7 +315,8 @@ TRACE_EVENT(netfs_read,TP_fast_assign ( __entry->rreq = rreq->debug_id; - __entry->cookie = rreq->cache_resources.debug_id; + __entry->cookie = rreq->cache_resources.cookie_id; + __entry->object = rreq->cache_resources.object_id; __entry->i_size = rreq->i_size; __entry->start = start; __entry->len = len;
@@ -322,10 +324,10 @@ TRACE_EVENT(netfs_read, __entry->netfs_inode = rreq->inode->i_ino; ), -TP_printk ("R=%08x %s c=%08x ni=%llx s=%llx l=%zx sz=%llx" , +TP_printk ("R=%08x %s c=%08x o=%08x ni=%llx s=%llx l=%zx sz=%llx" , __entry->rreq,__print_symbolic (__entry->what, netfs_read_traces), - __entry->cookie, + __entry->cookie, __entry->object, __entry->netfs_inode, __entry->start, __entry->len, __entry->i_size) );
@@ -549,6 +551,7 @@ TRACE_EVENT(netfs_write,TP_STRUCT__entry (__field (unsigned int ,wreq ) __field(unsigned int, cookie) + __field(unsigned int, object) __field(unsigned int, ino) __field(enum netfs_write_trace, what) __field(uoff_t, start)
@@ -556,20 +559,19 @@ TRACE_EVENT(netfs_write, ), TP_fast_assign( - struct netfs_inode *__ctx = netfs_inode(wreq->inode); -struct fscache_cookie *__cookie =netfs_i_cookie (__ctx); __entry->wreq = wreq->debug_id; - __entry->cookie = __cookie ? __cookie->debug_id :0 ; + __entry->cookie = wreq->cache_resources.cookie_id; + __entry->object = wreq->cache_resources.object_id; __entry->ino = wreq->inode->i_ino; __entry->what = what; __entry->start = wreq->start; __entry->len = wreq->len; ), -TP_printk ("R=%08x %s c=%08x i=%x by=%llx-%llx" , +TP_printk ("R=%08x %s c=%08x o=%08x i=%x by=%llx-%llx" , __entry->wreq,__print_symbolic (__entry->what, netfs_write_traces), - __entry->cookie, + __entry->cookie, __entry->object, __entry->ino, __entry->start, __entry->start + __entry->len -1 ) );
@@ -584,22 +586,23 @@ TRACE_EVENT(netfs_copy2cache, __field(unsigned int, rreq) __field(unsigned int, creq) __field(unsigned int, cookie) + __field(unsigned int, object) __field(unsigned int, ino) ),TP_fast_assign ( - struct netfs_inode *__ctx = netfs_inode(rreq->inode); -struct fscache_cookie *__cookie =netfs_i_cookie (__ctx); __entry->rreq = rreq->debug_id; __entry->creq = creq->debug_id; - __entry->cookie = __cookie ? __cookie->debug_id :0 ; + __entry->cookie = rreq->cache_resources.cookie_id; + __entry->object = rreq->cache_resources.object_id; __entry->ino = rreq->inode->i_ino; ), -TP_printk ("R=%08x CR=%08x c=%08x i=%x " , +TP_printk ("R=%08x CR=%08x c=%08x o=%08x i=%x " , __entry->rreq, __entry->creq, __entry->cookie, + __entry->object, __entry->ino) );
David Howells
maintainerPATCH v12 6/8 netfs: Make deprecated PG_private_2 support opt-in
In reply to David HowellsMake the deprecated PG_private_2 support opt-in, requiring it to be selected by the filesystems that might want to use it.
--- fs/ceph/Kconfig | 1 + fs/netfs/Kconfig | 3 +++ fs/netfs/Makefile | 2 +- fs/netfs/internal.h | 28 ++++++++++++++++++++++++++++ fs/netfs/read_collect.c | 4 ++-- fs/nfs/Kconfig | 1 + include/linux/netfs.h | 2 ++ 7 files changed, 38 insertions(+), 3 deletions(-)
fs/ceph/Kconfig +1 -0
@@ -4,6 +4,7 @@ config CEPH_FS depends on INET select CEPH_LIB select NETFS_SUPPORT + select NETFS_PGPRIV2 select FS_ENCRYPTION_ALGS if FS_ENCRYPTION default n help
fs/netfs/Kconfig +3 -0
@@ -22,6 +22,9 @@ config NETFS_STATS between CPUs. On the other hand, the stats are very useful for debugging purposes. Saying 'Y' here is recommended. +config NETFS_PGPRIV2 + bool + config NETFS_DEBUG bool "Enable dynamic debugging netfslib and FS-Cache" depends on NETFS_SUPPORT
fs/netfs/Makefile +1 -1
@@ -11,7 +11,6 @@ netfs-y := \ misc.o \ objects.o \ read_collect.o \ - read_pgpriv2.o \ read_retry.o \ read_single.o \ rolling_buffer.o \
@@ -19,6 +18,7 @@ netfs-y := \ write_issue.o \ write_retry.o +netfs-$(CONFIG_NETFS_PGPRIV2) += read_pgpriv2.o netfs-$(CONFIG_NETFS_STATS) += stats.o netfs-$(CONFIG_FSCACHE) += \
fs/netfs/internal.h +28 -0
@@ -120,9 +120,37 @@ void netfs_cache_read_terminated(void *priv, ssize_t transferred_or_error);/* * read_pgpriv2.c */ +#ifdef CONFIG_NETFS_PGPRIV2 +int netfs_prepare_pgpriv2_write_buffer (struct netfs_io_subrequest *subreq, +unsigned int max_segs);void netfs_pgpriv2_copy_to_cache (struct netfs_io_request *rreq,struct folio *folio);void netfs_pgpriv2_end_copy_to_cache (struct netfs_io_request *rreq);bool netfs_pgpriv2_unlock_copied_folios (struct netfs_io_request *wreq); +static inline bool netfs_using_pgpriv2 (const struct netfs_io_request *rreq) +{ +return test_bit (NETFS_RREQ_USE_PGPRIV2 , &rreq->flags); +} +#else +static inline int netfs_prepare_pgpriv2_write_buffer (struct netfs_io_subrequest *subreq, +unsigned int max_segs) +{ +return -EIO ; +} +static inline void netfs_pgpriv2_copy_to_cache (struct netfs_io_request *rreq,struct folio *folio) +{ +} +static inline void netfs_pgpriv2_end_copy_to_cache (struct netfs_io_request *rreq) +{ +} +static inline bool netfs_pgpriv2_unlock_copied_folios (struct netfs_io_request *wreq) +{ +return true; +} +static inline bool netfs_using_pgpriv2 (const struct netfs_io_request *rreq) +{ +return false; +} +#endif /* * read_retry.c
fs/netfs/read_collect.c +2 -2
@@ -38,7 +38,7 @@ static void netfs_clear_unread(struct netfs_io_subrequest *subreq)*/ void netfs_cancel_copy_to_cache (struct netfs_io_request *rreq,struct folio *folio) { -if (!test_bit (NETFS_RREQ_USE_PGPRIV2 , &rreq->flags)) { +if (!netfs_using_pgpriv2 (rreq)) {if (folio_get_private (folio) ==NETFS_FOLIO_COPY_TO_CACHE ) {folio_detach_private (folio);trace_netfs_folio (folio, netfs_folio_trace_cancel_copy);
@@ -81,7 +81,7 @@ static void netfs_unlock_read_folio(struct netfs_io_request *rreq,if (unlikely (test_bit (NETFS_RREQ_CANCEL_CACHING , &rreq->flags)))netfs_cancel_copy_to_cache (rreq, folio); -if (!test_bit (NETFS_RREQ_USE_PGPRIV2 , &rreq->flags)) { +if (!netfs_using_pgpriv2 (rreq)) {if (netfs_folio_group (folio) ==NETFS_FOLIO_COPY_TO_CACHE ) {trace_netfs_folio (folio, netfs_folio_trace_sched_copy);folio_mark_dirty (folio);
fs/nfs/Kconfig +1 -0
@@ -174,6 +174,7 @@ config NFS_FSCACHE bool "Provide NFS client caching support" depends on NFS_FS select NETFS_SUPPORT + select NETFS_PGPRIV2 select FSCACHE help Say Y here if you want NFS data to be cached locally on disc through
include/linux/netfs.h +2 -0
@@ -279,8 +279,10 @@ struct netfs_io_request {#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 */ +#ifdef CONFIG_NETFS_PGPRIV2 #define NETFS_RREQ_USE_PGPRIV2 31/* [DEPRECATED] Use PG_private_2 to mark * write to cache on read */ +#endif const struct netfs_request_ops *netfs_ops; };
David Howells
maintainerPATCH v12 7/8 netfs: Add some functions to wrap the all-queued handling
In reply to David HowellsAdd some helper functions to wrap the handling of the NETFS_RREQ_ALL_QUEUED flag and to insert the appropriate barriers.
--- fs/netfs/buffered_read.c | 9 +++------ fs/netfs/direct_read.c | 9 +++------ fs/netfs/internal.h | 19 +++++++++++++++++++ fs/netfs/misc.c | 2 +- fs/netfs/read_collect.c | 4 +--- fs/netfs/read_pgpriv2.c | 3 +-- fs/netfs/read_single.c | 9 +++------ fs/netfs/write_collect.c | 3 +-- fs/netfs/write_issue.c | 6 ++---- include/trace/events/netfs.h | 1 + 10 files changed, 35 insertions(+), 30 deletions(-)
fs/netfs/buffered_read.c +3 -6
@@ -355,10 +355,8 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) } start += slice; size -= slice; -if (size <=0 ) { -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); - } +if (size <=0 ) +netfs_all_subreqs_queued (rreq);if (fq) {/* See if the cache indicated this should be cached. */
@@ -378,8 +376,7 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) }while (size >0 );if (unlikely (size >0 )) { -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +netfs_all_subreqs_queued (rreq);netfs_wake_collector (rreq); }
fs/netfs/direct_read.c +3 -6
@@ -84,10 +84,8 @@ static void netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq) size -= slice; start += slice; rreq->submitted += slice; -if (size <=0 ) { -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); - } +if (size <=0 ) +netfs_all_subreqs_queued (rreq); rreq->netfs_ops->issue_read (subreq);
@@ -99,8 +97,7 @@ static void netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq) }while (size >0 );if (unlikely (size >0 )) { -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +netfs_all_subreqs_queued (rreq);netfs_wake_collector (rreq); } }
fs/netfs/internal.h +19 -0
@@ -341,6 +341,25 @@ static inline bool netfs_check_subreq_in_progress(const struct netfs_io_subrequereturn test_bit_acquire (NETFS_SREQ_IN_PROGRESS , &subreq->flags); } +/* +* Indicate that we've generated and queued all the subrequests we're going to. +*/ +static inline void netfs_all_subreqs_queued (struct netfs_io_request *rreq) +{ +smp_wmb ();/* Write lists before ALL_QUEUED. */ +set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +trace_netfs_rreq (rreq, netfs_rreq_trace_all_queued); +} + +/* +* Query if all subrequests are queued. +*/ +static inline bool netfs_are_all_subreqs_queued (const struct netfs_io_request *rreq) +{ +/* Read lists after ALL_QUEUED. */ +return test_bit_acquire (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +} +/* * fscache-cache.c */
fs/netfs/misc.c +1 -1
@@ -424,7 +424,7 @@ static int netfs_collect_in_app(struct netfs_io_request *rreq, need_collect = true;break ; } -if (subreq || !test_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags)) +if (subreq || !netfs_are_all_subreqs_queued (rreq)) done = false; }
fs/netfs/read_collect.c +1 -3
@@ -462,10 +462,8 @@ bool netfs_read_collection(struct netfs_io_request *rreq)/* We're done when the app thread has finished posting subreqs and the * queue is empty. */ -if (!test_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags)) +if (!netfs_are_all_subreqs_queued (rreq))return false; -smp_rmb ();/* Read ALL_QUEUED before subreq lists. */ -if (!list_empty (&stream->subrequests))return false;
fs/netfs/read_pgpriv2.c +1 -2
@@ -158,8 +158,7 @@ void netfs_pgpriv2_end_copy_to_cache(struct netfs_io_request *rreq)return ;netfs_issue_write (creq, &creq->io_streams[1 ]); -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &creq->flags); +netfs_all_subreqs_queued (creq);trace_netfs_rreq (rreq, netfs_rreq_trace_end_copy_to_cache);if (list_empty_careful (&creq->io_streams[1 ].subrequests))netfs_wake_collector (creq);
fs/netfs/read_single.c +3 -6
@@ -113,14 +113,12 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq) goto cancel; } -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +netfs_all_subreqs_queued (rreq); rreq->netfs_ops->issue_read (subreq); rreq->submitted += subreq->len;break ;case NETFS_READ_FROM_CACHE : -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +netfs_all_subreqs_queued (rreq);trace_netfs_sreq (subreq, netfs_sreq_trace_submit);netfs_single_read_cache (rreq, subreq); rreq->submitted += subreq->len;
@@ -136,8 +134,7 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq)return ret; cancel:netfs_cancel_read (subreq, ret); -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &rreq->flags); +netfs_all_subreqs_queued (rreq);netfs_wake_collector (rreq);return ret; }
fs/netfs/write_collect.c +1 -2
@@ -371,9 +371,8 @@ bool netfs_write_collection(struct netfs_io_request *wreq)/* We're done when the app thread has finished posting subreqs and all * the queues in all the streams are empty. */ -if (!test_bit (NETFS_RREQ_ALL_QUEUED , &wreq->flags)) +if (!netfs_are_all_subreqs_queued (wreq))return false; -smp_rmb ();/* Read ALL_QUEUED before lists. */ transferred =LONG_MAX ;for (s =0 ; s <NR_IO_STREAMS ; s++) {
fs/netfs/write_issue.c +2 -4
@@ -520,8 +520,7 @@ static void netfs_end_issue_write(struct netfs_io_request *wreq) {bool needs_poke = true; -smp_wmb ();/* Write subreq lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &wreq->flags); +netfs_all_subreqs_queued (wreq);for (int s =0 ; s <NR_IO_STREAMS ; s++) {struct netfs_io_stream *stream = &wreq->io_streams[s];
@@ -789,8 +788,7 @@ int netfs_writeback_single(struct address_space *mapping, stop:for (int s =0 ; s <NR_IO_STREAMS ; s++)netfs_issue_write (wreq, &wreq->io_streams[s]); -smp_wmb ();/* Write lists before ALL_QUEUED. */ -set_bit (NETFS_RREQ_ALL_QUEUED , &wreq->flags); +netfs_all_subreqs_queued (wreq);netfs_wake_collector (wreq);
include/trace/events/netfs.h +1 -0
@@ -47,6 +47,7 @@ E_(NETFS_PGPRIV2_COPY_TO_CACHE, "2C")#define netfs_rreq_traces \ + EM(netfs_rreq_trace_all_queued, "ALL-Q ") \ EM(netfs_rreq_trace_assess, "ASSESS ") \ EM(netfs_rreq_trace_collect, "COLLECT") \ EM(netfs_rreq_trace_complete, "COMPLET") \
David Howells
maintainerPATCH v12 8/8 netfs: Set subrequest->source at alloc before trace emission
In reply to David HowellsSet subrequest->source in netfs_alloc_subrequest() before we emit the trace line indicating we allocated the subrequest. Note that this requires the allocation of the subreq in netfs_read_to_pagecache() to be pushed to after the decision about what sort of subreq it should be.
--- fs/netfs/buffered_read.c | 4 ++-- fs/netfs/direct_read.c | 3 +-- fs/netfs/internal.h | 3 ++- fs/netfs/objects.c | 4 +++- fs/netfs/read_retry.c | 3 +-- fs/netfs/read_single.c | 2 +- fs/netfs/write_issue.c | 3 +-- fs/netfs/write_retry.c | 3 +-- 8 files changed, 12 insertions(+), 13 deletions(-)
fs/netfs/buffered_read.c +2 -2
@@ -276,10 +276,10 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) do { struct netfs_io_subrequest *subreq; - enum netfs_io_source source = NETFS_SOURCE_UNKNOWN; + enum netfs_io_source source; ssize_t slice; - subreq = netfs_alloc_subrequest(rreq); + subreq = netfs_alloc_subrequest(rreq, NETFS_SOURCE_UNKNOWN); if (!subreq) { ret = -ENOMEM; break;
fs/netfs/direct_read.c +1 -2
@@ -55,7 +55,7 @@ static void netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq)struct netfs_io_subrequest *subreq;ssize_t slice; - subreq =netfs_alloc_subrequest (rreq); + subreq =netfs_alloc_subrequest (rreq,NETFS_DOWNLOAD_FROM_SERVER );if (!subreq) {/* Stash the error in the request if there's not * already an error set.
@@ -64,7 +64,6 @@ static void netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq)break ; } - subreq->source =NETFS_DOWNLOAD_FROM_SERVER ; subreq->start = start; subreq->len = size;
fs/netfs/internal.h +2 -1
@@ -92,7 +92,8 @@ void netfs_get_request(struct netfs_io_request *rreq, enum netfs_rreq_ref_tracevoid netfs_clear_subrequests (struct netfs_io_request *rreq);void netfs_put_request (struct netfs_io_request *rreq,enum netfs_rreq_ref_trace what);void netfs_put_failed_request (struct netfs_io_request *rreq); -struct netfs_io_subrequest *netfs_alloc_subrequest (struct netfs_io_request *rreq); +struct netfs_io_subrequest *netfs_alloc_subrequest (struct netfs_io_request *rreq, +enum netfs_io_source source);static inline void netfs_see_request (struct netfs_io_request *rreq,enum netfs_rreq_ref_trace what)
fs/netfs/objects.c +3 -1
@@ -207,7 +207,8 @@ void netfs_put_failed_request(struct netfs_io_request *rreq)/* * Allocate and partially initialise an I/O request structure. */ -struct netfs_io_subrequest *netfs_alloc_subrequest (struct netfs_io_request *rreq) +struct netfs_io_subrequest *netfs_alloc_subrequest (struct netfs_io_request *rreq, +enum netfs_io_source source) {struct netfs_io_subrequest *subreq;mempool_t *mempool = rreq->netfs_ops->subrequest_pool ?: &netfs_subrequest_pool;
@@ -224,6 +225,7 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreqINIT_WORK (&subreq->work,NULL );INIT_LIST_HEAD (&subreq->rreq_link);refcount_set (&subreq->ref,2 ); + subreq->source = source; subreq->rreq = rreq; subreq->debug_index =atomic_inc_return (&rreq->subreq_counter);netfs_get_request (rreq, netfs_rreq_trace_get_subreq);
fs/netfs/read_retry.c +1 -2
@@ -195,12 +195,11 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq)* and insert them after. */ do { - subreq = netfs_alloc_subrequest(rreq); + subreq = netfs_alloc_subrequest(rreq, NETFS_DOWNLOAD_FROM_SERVER); if (!subreq) { subreq = to; goto abandon_after; } - subreq->source = NETFS_DOWNLOAD_FROM_SERVER; subreq->start = start; subreq->len = len; subreq->stream_nr = stream->stream_nr;
fs/netfs/read_single.c +1 -1
@@ -92,7 +92,7 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq)struct netfs_io_subrequest *subreq;int ret =0 ; - subreq =netfs_alloc_subrequest (rreq); + subreq =netfs_alloc_subrequest (rreq,NETFS_DOWNLOAD_FROM_SERVER );if (!subreq)return -ENOMEM ;
fs/netfs/write_issue.c +1 -2
@@ -168,10 +168,9 @@ void netfs_prepare_write(struct netfs_io_request *wreq, wreq_iter->folioq_slot >= folioq_nr_slots(wreq_iter->folioq))rolling_buffer_make_space (&wreq->buffer, wreq->gfp); - subreq =netfs_alloc_subrequest (wreq); + subreq =netfs_alloc_subrequest (wreq, stream->source);if (!subreq)return ; - subreq->source = stream->source; subreq->start = start; subreq->stream_nr = stream->stream_nr; subreq->io_iter = *wreq_iter;
fs/netfs/write_retry.c +1 -2
@@ -149,8 +149,7 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,* and insert them after. */ do { - subreq = netfs_alloc_subrequest(wreq); - subreq->source = to->source; + subreq = netfs_alloc_subrequest(wreq, stream->source); subreq->start = start; subreq->stream_nr = to->stream_nr; subreq->retry_count = 1;