From patchwork Thu Oct 27 08:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71AF0C67871 for ; Thu, 27 Oct 2022 08:36:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbiJ0If7 (ORCPT ); Thu, 27 Oct 2022 04:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234590AbiJ0If4 (ORCPT ); Thu, 27 Oct 2022 04:35:56 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13E08B2E4; Thu, 27 Oct 2022 01:35:53 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAlX.h_1666859748; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAlX.h_1666859748) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:49 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] fscache: decouple prepare_read() from netfs_io_subrequest Date: Thu, 27 Oct 2022 16:35:39 +0800 Message-Id: <20221027083547.46933-2-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org All methods except prepare_read() of netfs_cache_ops works without netfs_io_request/netfs_io_subrequest, which accept netfs_cache_resources and a file range to be handled. As fscache is now also used for local fs (e.g. erofs) in on-demand read scenarios, we'd better make raw fscache APIs more neutral independent on libnetfs. Thus decouple prepare_read() from netfs_io_subrequest, just like other methods do. This is a cleanup without logic change, except that some debug info retrieved from netfs_io_subrequest is removed from trace_cachefiles_prep_read(). Signed-off-by: Jingbo Xu --- fs/cachefiles/io.c | 46 ++++++++++++++++--------------- fs/erofs/fscache.c | 3 +- fs/netfs/io.c | 3 +- include/linux/netfs.h | 5 ++-- include/trace/events/cachefiles.h | 23 ++++++---------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 000a28f46e59..d5b6a2a75161 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -389,34 +389,35 @@ static int cachefiles_write(struct netfs_cache_resources *cres, * Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ -static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest *subreq, - loff_t i_size) +static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources *cres, + loff_t *_start, size_t *_len, + unsigned long *_flags, loff_t i_size) { enum cachefiles_prepare_read_trace why; - struct netfs_io_request *rreq = subreq->rreq; - struct netfs_cache_resources *cres = &rreq->cache_resources; struct cachefiles_object *object; struct cachefiles_cache *cache; struct fscache_cookie *cookie = fscache_cres_cookie(cres); const struct cred *saved_cred; struct file *file = cachefiles_cres_file(cres); enum netfs_io_source ret = NETFS_DOWNLOAD_FROM_SERVER; + loff_t start = *_start; + size_t len = *_len; loff_t off, to; ino_t ino = file ? file_inode(file)->i_ino : 0; int rc; - _enter("%zx @%llx/%llx", subreq->len, subreq->start, i_size); + _enter("%zx @%llx/%llx", len, start, i_size); - if (subreq->start >= i_size) { + if (start >= i_size) { ret = NETFS_FILL_WITH_ZEROES; why = cachefiles_trace_read_after_eof; goto out_no_object; } if (test_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags)) { - __set_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags); + __set_bit(NETFS_SREQ_COPY_TO_CACHE, _flags); why = cachefiles_trace_read_no_data; - if (!test_bit(NETFS_SREQ_ONDEMAND, &subreq->flags)) + if (!test_bit(NETFS_SREQ_ONDEMAND, _flags)) goto out_no_object; } @@ -437,7 +438,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest * retry: off = cachefiles_inject_read_error(); if (off == 0) - off = vfs_llseek(file, subreq->start, SEEK_DATA); + off = vfs_llseek(file, start, SEEK_DATA); if (off < 0 && off >= (loff_t)-MAX_ERRNO) { if (off == (loff_t)-ENXIO) { why = cachefiles_trace_read_seek_nxio; @@ -449,21 +450,22 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest * goto out; } - if (off >= subreq->start + subreq->len) { + if (off >= start + len) { why = cachefiles_trace_read_found_hole; goto download_and_store; } - if (off > subreq->start) { + if (off > start) { off = round_up(off, cache->bsize); - subreq->len = off - subreq->start; + len = off - start; + *_len = len; why = cachefiles_trace_read_found_part; goto download_and_store; } to = cachefiles_inject_read_error(); if (to == 0) - to = vfs_llseek(file, subreq->start, SEEK_HOLE); + to = vfs_llseek(file, start, SEEK_HOLE); if (to < 0 && to >= (loff_t)-MAX_ERRNO) { trace_cachefiles_io_error(object, file_inode(file), to, cachefiles_trace_seek_error); @@ -471,12 +473,13 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest * goto out; } - if (to < subreq->start + subreq->len) { - if (subreq->start + subreq->len >= i_size) + if (to < start + len) { + if (start + len >= i_size) to = round_up(to, cache->bsize); else to = round_down(to, cache->bsize); - subreq->len = to - subreq->start; + len = to - start; + *_len = len; } why = cachefiles_trace_read_have_data; @@ -484,12 +487,11 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest * goto out; download_and_store: - __set_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags); - if (test_bit(NETFS_SREQ_ONDEMAND, &subreq->flags)) { - rc = cachefiles_ondemand_read(object, subreq->start, - subreq->len); + __set_bit(NETFS_SREQ_COPY_TO_CACHE, _flags); + if (test_bit(NETFS_SREQ_ONDEMAND, _flags)) { + rc = cachefiles_ondemand_read(object, start, len); if (!rc) { - __clear_bit(NETFS_SREQ_ONDEMAND, &subreq->flags); + __clear_bit(NETFS_SREQ_ONDEMAND, _flags); goto retry; } ret = NETFS_INVALID_READ; @@ -497,7 +499,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest * out: cachefiles_end_secure(cache, saved_cred); out_no_object: - trace_cachefiles_prep_read(subreq, ret, why, ino); + trace_cachefiles_prep_read(start, len, *_flags, ret, why, ino); return ret; } diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index fe05bc51f9f2..a4013f9bdb5c 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -176,7 +176,8 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, list_add_tail(&subreq->rreq_link, &rreq->subrequests); - source = cres->ops->prepare_read(subreq, LLONG_MAX); + source = cres->ops->prepare_read(cres, &subreq->start, + &subreq->len, &subreq->flags, LLONG_MAX); if (WARN_ON(subreq->len == 0)) source = NETFS_INVALID_READ; if (source != NETFS_READ_FROM_CACHE) { diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 428925899282..297423220fb1 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -487,7 +487,8 @@ static enum netfs_io_source netfs_cache_prepare_read(struct netfs_io_subrequest struct netfs_cache_resources *cres = &rreq->cache_resources; if (cres->ops) - return cres->ops->prepare_read(subreq, i_size); + return cres->ops->prepare_read(cres, &subreq->start, + &subreq->len, &subreq->flags, i_size); if (subreq->start >= rreq->i_size) return NETFS_FILL_WITH_ZEROES; return NETFS_DOWNLOAD_FROM_SERVER; diff --git a/include/linux/netfs.h b/include/linux/netfs.h index f2402ddeafbf..b8171b3b9e2d 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -257,8 +257,9 @@ struct netfs_cache_ops { /* Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ - enum netfs_io_source (*prepare_read)(struct netfs_io_subrequest *subreq, - loff_t i_size); + enum netfs_io_source (*prepare_read)(struct netfs_cache_resources *cres, + loff_t *_start, size_t *_len, + unsigned long *_flags, loff_t i_size); /* Prepare a write operation, working out what part of the write we can * actually do. diff --git a/include/trace/events/cachefiles.h b/include/trace/events/cachefiles.h index d8d4d73fe7b6..62da0596f65b 100644 --- a/include/trace/events/cachefiles.h +++ b/include/trace/events/cachefiles.h @@ -428,44 +428,39 @@ TRACE_EVENT(cachefiles_vol_coherency, ); TRACE_EVENT(cachefiles_prep_read, - TP_PROTO(struct netfs_io_subrequest *sreq, + TP_PROTO(loff_t start, + size_t len, + unsigned short flags, enum netfs_io_source source, enum cachefiles_prepare_read_trace why, ino_t cache_inode), - TP_ARGS(sreq, source, why, cache_inode), + TP_ARGS(start, len, flags, source, why, cache_inode), TP_STRUCT__entry( - __field(unsigned int, rreq ) - __field(unsigned short, index ) __field(unsigned short, flags ) __field(enum netfs_io_source, source ) __field(enum cachefiles_prepare_read_trace, why ) __field(size_t, len ) __field(loff_t, start ) - __field(unsigned int, netfs_inode ) __field(unsigned int, cache_inode ) ), TP_fast_assign( - __entry->rreq = sreq->rreq->debug_id; - __entry->index = sreq->debug_index; - __entry->flags = sreq->flags; + __entry->flags = flags; __entry->source = source; __entry->why = why; - __entry->len = sreq->len; - __entry->start = sreq->start; - __entry->netfs_inode = sreq->rreq->inode->i_ino; + __entry->len = len; + __entry->start = start; __entry->cache_inode = cache_inode; ), - TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx ni=%x B=%x", - __entry->rreq, __entry->index, + TP_printk("%s %s f=%02x s=%llx %zx B=%x", __print_symbolic(__entry->source, netfs_sreq_sources), __print_symbolic(__entry->why, cachefiles_prepare_read_traces), __entry->flags, __entry->start, __entry->len, - __entry->netfs_inode, __entry->cache_inode) + __entry->cache_inode) ); TRACE_EVENT(cachefiles_read, From patchwork Thu Oct 27 08:35:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80DB6C38A2D for ; Thu, 27 Oct 2022 08:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234932AbiJ0IgB (ORCPT ); Thu, 27 Oct 2022 04:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234768AbiJ0If5 (ORCPT ); Thu, 27 Oct 2022 04:35:57 -0400 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986428C47D; Thu, 27 Oct 2022 01:35:54 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R671e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAtIcr_1666859749; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAtIcr_1666859749) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:51 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] fscache,netfs: rename netfs_io_source as fscache_io_source Date: Thu, 27 Oct 2022 16:35:40 +0800 Message-Id: <20221027083547.46933-3-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Fscache is now also used for local fs (e.g. erofs) in on-demand read scenarios, which tends to access backing files with raw fscache API such as fscache_read() instead of libnetfs. Thus we'd better make raw fscache APIs more neutral independent on libnetfs to facilitate those who are not using libnetfs yet. Rename netfs_io_source as fscache_io_source. This is a cleanup without logic change. It is worth noting that the structure declaration is temporarily placed in netfs.h, and will be moved to fscache.h when all related structures are transformed to "fscache_" prefix finally. The reason is that, in the intermediate state during the transition, the declarations of related structures are scattered among fscache.h and netfs.h. This will cause a bidirectional reference of these two headers, and compilation error then. As a work around, keep the declaration in netfs.h temporarily. Signed-off-by: Jingbo Xu --- fs/cachefiles/io.c | 10 ++++---- fs/erofs/fscache.c | 6 ++--- fs/netfs/io.c | 42 +++++++++++++++---------------- include/linux/netfs.h | 14 +++++------ include/trace/events/cachefiles.h | 4 +-- include/trace/events/netfs.h | 14 +++++------ 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index d5b6a2a75161..9214060b4781 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -389,7 +389,7 @@ static int cachefiles_write(struct netfs_cache_resources *cres, * Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ -static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources *cres, +static enum fscache_io_source cachefiles_prepare_read(struct netfs_cache_resources *cres, loff_t *_start, size_t *_len, unsigned long *_flags, loff_t i_size) { @@ -399,7 +399,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources struct fscache_cookie *cookie = fscache_cres_cookie(cres); const struct cred *saved_cred; struct file *file = cachefiles_cres_file(cres); - enum netfs_io_source ret = NETFS_DOWNLOAD_FROM_SERVER; + enum fscache_io_source ret = FSCACHE_DOWNLOAD_FROM_SERVER; loff_t start = *_start; size_t len = *_len; loff_t off, to; @@ -409,7 +409,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources _enter("%zx @%llx/%llx", len, start, i_size); if (start >= i_size) { - ret = NETFS_FILL_WITH_ZEROES; + ret = FSCACHE_FILL_WITH_ZEROES; why = cachefiles_trace_read_after_eof; goto out_no_object; } @@ -483,7 +483,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources } why = cachefiles_trace_read_have_data; - ret = NETFS_READ_FROM_CACHE; + ret = FSCACHE_READ_FROM_CACHE; goto out; download_and_store: @@ -494,7 +494,7 @@ static enum netfs_io_source cachefiles_prepare_read(struct netfs_cache_resources __clear_bit(NETFS_SREQ_ONDEMAND, _flags); goto retry; } - ret = NETFS_INVALID_READ; + ret = FSCACHE_INVALID_READ; } out: cachefiles_end_secure(cache, saved_cred); diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index a4013f9bdb5c..bf216478afa2 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -141,7 +141,7 @@ static void erofc_fscache_subreq_complete(void *priv, static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, struct netfs_io_request *rreq, loff_t pstart) { - enum netfs_io_source source; + enum fscache_io_source source; struct super_block *sb = rreq->mapping->host->i_sb; struct netfs_io_subrequest *subreq; struct netfs_cache_resources *cres = &rreq->cache_resources; @@ -179,8 +179,8 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, source = cres->ops->prepare_read(cres, &subreq->start, &subreq->len, &subreq->flags, LLONG_MAX); if (WARN_ON(subreq->len == 0)) - source = NETFS_INVALID_READ; - if (source != NETFS_READ_FROM_CACHE) { + source = FSCACHE_INVALID_READ; + if (source != FSCACHE_READ_FROM_CACHE) { erofs_err(sb, "failed to fscache prepare_read (source %d)", source); ret = -EIO; diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 297423220fb1..992f3eebd2ee 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -250,7 +250,7 @@ static void netfs_rreq_short_read(struct netfs_io_request *rreq, netfs_get_subrequest(subreq, netfs_sreq_trace_get_short_read); atomic_inc(&rreq->nr_outstanding); - if (subreq->source == NETFS_READ_FROM_CACHE) + if (subreq->source == FSCACHE_READ_FROM_CACHE) netfs_read_from_cache(rreq, subreq, NETFS_READ_HOLE_CLEAR); else netfs_read_from_server(rreq, subreq); @@ -276,9 +276,9 @@ static bool netfs_rreq_perform_resubmissions(struct netfs_io_request *rreq) __clear_bit(NETFS_RREQ_INCOMPLETE_IO, &rreq->flags); list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { if (subreq->error) { - if (subreq->source != NETFS_READ_FROM_CACHE) + if (subreq->source != FSCACHE_READ_FROM_CACHE) break; - subreq->source = NETFS_DOWNLOAD_FROM_SERVER; + subreq->source = FSCACHE_DOWNLOAD_FROM_SERVER; subreq->error = 0; netfs_stat(&netfs_n_rh_download_instead); trace_netfs_sreq(subreq, netfs_sreq_trace_download_instead); @@ -310,7 +310,7 @@ static void netfs_rreq_is_still_valid(struct netfs_io_request *rreq) return; list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { - if (subreq->source == NETFS_READ_FROM_CACHE) { + if (subreq->source == FSCACHE_READ_FROM_CACHE) { subreq->error = -ESTALE; __set_bit(NETFS_RREQ_INCOMPLETE_IO, &rreq->flags); } @@ -401,10 +401,10 @@ void netfs_subreq_terminated(struct netfs_io_subrequest *subreq, transferred_or_error); switch (subreq->source) { - case NETFS_READ_FROM_CACHE: + case FSCACHE_READ_FROM_CACHE: netfs_stat(&netfs_n_rh_read_done); break; - case NETFS_DOWNLOAD_FROM_SERVER: + case FSCACHE_DOWNLOAD_FROM_SERVER: netfs_stat(&netfs_n_rh_download_done); break; default: @@ -468,7 +468,7 @@ void netfs_subreq_terminated(struct netfs_io_subrequest *subreq, goto out; failed: - if (subreq->source == NETFS_READ_FROM_CACHE) { + if (subreq->source == FSCACHE_READ_FROM_CACHE) { netfs_stat(&netfs_n_rh_read_failed); set_bit(NETFS_RREQ_INCOMPLETE_IO, &rreq->flags); } else { @@ -480,7 +480,7 @@ void netfs_subreq_terminated(struct netfs_io_subrequest *subreq, } EXPORT_SYMBOL(netfs_subreq_terminated); -static enum netfs_io_source netfs_cache_prepare_read(struct netfs_io_subrequest *subreq, +static enum fscache_io_source netfs_cache_prepare_read(struct netfs_io_subrequest *subreq, loff_t i_size) { struct netfs_io_request *rreq = subreq->rreq; @@ -490,26 +490,26 @@ static enum netfs_io_source netfs_cache_prepare_read(struct netfs_io_subrequest return cres->ops->prepare_read(cres, &subreq->start, &subreq->len, &subreq->flags, i_size); if (subreq->start >= rreq->i_size) - return NETFS_FILL_WITH_ZEROES; - return NETFS_DOWNLOAD_FROM_SERVER; + return FSCACHE_FILL_WITH_ZEROES; + return FSCACHE_DOWNLOAD_FROM_SERVER; } /* * Work out what sort of subrequest the next one will be. */ -static enum netfs_io_source +static enum fscache_io_source netfs_rreq_prepare_read(struct netfs_io_request *rreq, struct netfs_io_subrequest *subreq) { - enum netfs_io_source source; + enum fscache_io_source source; _enter("%llx-%llx,%llx", subreq->start, subreq->start + subreq->len, rreq->i_size); source = netfs_cache_prepare_read(subreq, rreq->i_size); - if (source == NETFS_INVALID_READ) + if (source == FSCACHE_INVALID_READ) goto out; - if (source == NETFS_DOWNLOAD_FROM_SERVER) { + if (source == FSCACHE_DOWNLOAD_FROM_SERVER) { /* Call out to the netfs to let it shrink the request to fit * its own I/O sizes and boundaries. If it shinks it here, it * will be called again to make simultaneous calls; if it wants @@ -521,13 +521,13 @@ netfs_rreq_prepare_read(struct netfs_io_request *rreq, if (rreq->netfs_ops->clamp_length && !rreq->netfs_ops->clamp_length(subreq)) { - source = NETFS_INVALID_READ; + source = FSCACHE_INVALID_READ; goto out; } } if (WARN_ON(subreq->len == 0)) - source = NETFS_INVALID_READ; + source = FSCACHE_INVALID_READ; out: subreq->source = source; @@ -542,7 +542,7 @@ static bool netfs_rreq_submit_slice(struct netfs_io_request *rreq, unsigned int *_debug_index) { struct netfs_io_subrequest *subreq; - enum netfs_io_source source; + enum fscache_io_source source; subreq = netfs_alloc_subrequest(rreq); if (!subreq) @@ -564,7 +564,7 @@ static bool netfs_rreq_submit_slice(struct netfs_io_request *rreq, * again and ask it to download the next piece. */ source = netfs_rreq_prepare_read(rreq, subreq); - if (source == NETFS_INVALID_READ) + if (source == FSCACHE_INVALID_READ) goto subreq_failed; atomic_inc(&rreq->nr_outstanding); @@ -573,13 +573,13 @@ static bool netfs_rreq_submit_slice(struct netfs_io_request *rreq, trace_netfs_sreq(subreq, netfs_sreq_trace_submit); switch (source) { - case NETFS_FILL_WITH_ZEROES: + case FSCACHE_FILL_WITH_ZEROES: netfs_fill_with_zeroes(rreq, subreq); break; - case NETFS_DOWNLOAD_FROM_SERVER: + case FSCACHE_DOWNLOAD_FROM_SERVER: netfs_read_from_server(rreq, subreq); break; - case NETFS_READ_FROM_CACHE: + case FSCACHE_READ_FROM_CACHE: netfs_read_from_cache(rreq, subreq, NETFS_READ_HOLE_IGNORE); break; default: diff --git a/include/linux/netfs.h b/include/linux/netfs.h index b8171b3b9e2d..4cd7341c79b4 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -108,11 +108,11 @@ static inline int wait_on_page_fscache_killable(struct page *page) return folio_wait_private_2_killable(page_folio(page)); } -enum netfs_io_source { - NETFS_FILL_WITH_ZEROES, - NETFS_DOWNLOAD_FROM_SERVER, - NETFS_READ_FROM_CACHE, - NETFS_INVALID_READ, +enum fscache_io_source { + FSCACHE_FILL_WITH_ZEROES, + FSCACHE_DOWNLOAD_FROM_SERVER, + FSCACHE_READ_FROM_CACHE, + FSCACHE_INVALID_READ, } __mode(byte); typedef void (*netfs_io_terminated_t)(void *priv, ssize_t transferred_or_error, @@ -153,7 +153,7 @@ struct netfs_io_subrequest { refcount_t ref; short error; /* 0 or error that occurred */ unsigned short debug_index; /* Index in list (for debugging output) */ - enum netfs_io_source source; /* Where to read from/write to */ + enum fscache_io_source source; /* Where to read from/write to */ unsigned long flags; #define NETFS_SREQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ #define NETFS_SREQ_CLEAR_TAIL 1 /* Set if the rest of the read should be cleared */ @@ -257,7 +257,7 @@ struct netfs_cache_ops { /* Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ - enum netfs_io_source (*prepare_read)(struct netfs_cache_resources *cres, + enum fscache_io_source (*prepare_read)(struct netfs_cache_resources *cres, loff_t *_start, size_t *_len, unsigned long *_flags, loff_t i_size); diff --git a/include/trace/events/cachefiles.h b/include/trace/events/cachefiles.h index 62da0596f65b..cb39fa750735 100644 --- a/include/trace/events/cachefiles.h +++ b/include/trace/events/cachefiles.h @@ -431,7 +431,7 @@ TRACE_EVENT(cachefiles_prep_read, TP_PROTO(loff_t start, size_t len, unsigned short flags, - enum netfs_io_source source, + enum fscache_io_source source, enum cachefiles_prepare_read_trace why, ino_t cache_inode), @@ -439,7 +439,7 @@ TRACE_EVENT(cachefiles_prep_read, TP_STRUCT__entry( __field(unsigned short, flags ) - __field(enum netfs_io_source, source ) + __field(enum fscache_io_source, source ) __field(enum cachefiles_prepare_read_trace, why ) __field(size_t, len ) __field(loff_t, start ) diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h index beec534cbaab..abf506453125 100644 --- a/include/trace/events/netfs.h +++ b/include/trace/events/netfs.h @@ -36,10 +36,10 @@ E_(netfs_rreq_trace_unmark, "UNMARK ") #define netfs_sreq_sources \ - EM(NETFS_FILL_WITH_ZEROES, "ZERO") \ - EM(NETFS_DOWNLOAD_FROM_SERVER, "DOWN") \ - EM(NETFS_READ_FROM_CACHE, "READ") \ - E_(NETFS_INVALID_READ, "INVL") \ + EM(FSCACHE_FILL_WITH_ZEROES, "ZERO") \ + EM(FSCACHE_DOWNLOAD_FROM_SERVER, "DOWN") \ + EM(FSCACHE_READ_FROM_CACHE, "READ") \ + E_(FSCACHE_INVALID_READ, "INVL") \ #define netfs_sreq_traces \ EM(netfs_sreq_trace_download_instead, "RDOWN") \ @@ -195,7 +195,7 @@ TRACE_EVENT(netfs_sreq, __field(unsigned short, index ) __field(short, error ) __field(unsigned short, flags ) - __field(enum netfs_io_source, source ) + __field(enum fscache_io_source, source ) __field(enum netfs_sreq_trace, what ) __field(size_t, len ) __field(size_t, transferred ) @@ -235,7 +235,7 @@ TRACE_EVENT(netfs_failure, __field(short, index ) __field(short, error ) __field(unsigned short, flags ) - __field(enum netfs_io_source, source ) + __field(enum fscache_io_source, source ) __field(enum netfs_failure, what ) __field(size_t, len ) __field(size_t, transferred ) @@ -247,7 +247,7 @@ TRACE_EVENT(netfs_failure, __entry->index = sreq ? sreq->debug_index : -1; __entry->error = error; __entry->flags = sreq ? sreq->flags : 0; - __entry->source = sreq ? sreq->source : NETFS_INVALID_READ; + __entry->source = sreq ? sreq->source : FSCACHE_INVALID_READ; __entry->what = what; __entry->len = sreq ? sreq->len : rreq->len; __entry->transferred = sreq ? sreq->transferred : 0; From patchwork Thu Oct 27 08:35:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43874FA3746 for ; Thu, 27 Oct 2022 08:36:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234954AbiJ0IgF (ORCPT ); Thu, 27 Oct 2022 04:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234884AbiJ0If6 (ORCPT ); Thu, 27 Oct 2022 04:35:58 -0400 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76698D228; Thu, 27 Oct 2022 01:35:55 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R491e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAawYM_1666859751; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAawYM_1666859751) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:52 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] fscache,netfs: rename netfs_io_terminated_t as fscache_io_terminated_t Date: Thu, 27 Oct 2022 16:35:41 +0800 Message-Id: <20221027083547.46933-4-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Rename netfs_io_terminated_t as fscache_io_terminated_t to make raw fscache APIs more neutral independent on libnetfs. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/cachefiles/internal.h | 2 +- fs/cachefiles/io.c | 8 ++++---- fs/fscache/io.c | 4 ++-- include/linux/fscache.h | 8 ++++---- include/linux/netfs.h | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 2ad58c465208..897cc01b8b56 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -239,7 +239,7 @@ extern int __cachefiles_write(struct cachefiles_object *object, struct file *file, loff_t start_pos, struct iov_iter *iter, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv); /* diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 9214060b4781..6931032b837c 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -23,7 +23,7 @@ struct cachefiles_kiocb { size_t len; }; struct cachefiles_object *object; - netfs_io_terminated_t term_func; + fscache_io_terminated_t term_func; void *term_func_priv; bool was_async; unsigned int inval_counter; /* Copy of cookie->inval_counter */ @@ -74,7 +74,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, enum netfs_read_from_hole read_hole, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv) { struct cachefiles_object *object; @@ -281,7 +281,7 @@ int __cachefiles_write(struct cachefiles_object *object, struct file *file, loff_t start_pos, struct iov_iter *iter, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv) { struct cachefiles_cache *cache; @@ -370,7 +370,7 @@ int __cachefiles_write(struct cachefiles_object *object, static int cachefiles_write(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv) { if (!fscache_wait_for_operation(cres, FSCACHE_WANT_WRITE)) { diff --git a/fs/fscache/io.c b/fs/fscache/io.c index 3af3b08a9bb3..3ef93fdcb3b3 100644 --- a/fs/fscache/io.c +++ b/fs/fscache/io.c @@ -204,7 +204,7 @@ struct fscache_write_request { loff_t start; size_t len; bool set_bits; - netfs_io_terminated_t term_func; + fscache_io_terminated_t term_func; void *term_func_priv; }; @@ -248,7 +248,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, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv, bool cond) { diff --git a/include/linux/fscache.h b/include/linux/fscache.h index 36e5dd84cf59..ee8e14f142e8 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -173,7 +173,7 @@ extern int __fscache_begin_read_operation(struct netfs_cache_resources *, struct extern int __fscache_begin_write_operation(struct netfs_cache_resources *, struct fscache_cookie *); extern void __fscache_write_to_cache(struct fscache_cookie *, struct address_space *, - loff_t, size_t, loff_t, netfs_io_terminated_t, void *, + loff_t, size_t, loff_t, fscache_io_terminated_t, void *, bool); extern void __fscache_clear_page_bits(struct address_space *, loff_t, size_t); @@ -508,7 +508,7 @@ int fscache_read(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, enum netfs_read_from_hole read_hole, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv) { const struct netfs_cache_ops *ops = fscache_operation_valid(cres); @@ -566,7 +566,7 @@ static inline int fscache_write(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv) { const struct netfs_cache_ops *ops = fscache_operation_valid(cres); @@ -617,7 +617,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, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv, bool caching) { diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 4cd7341c79b4..2cac478607a8 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -115,7 +115,7 @@ enum fscache_io_source { FSCACHE_INVALID_READ, } __mode(byte); -typedef void (*netfs_io_terminated_t)(void *priv, ssize_t transferred_or_error, +typedef void (*fscache_io_terminated_t)(void *priv, ssize_t transferred_or_error, bool was_async); /* @@ -240,14 +240,14 @@ struct netfs_cache_ops { loff_t start_pos, struct iov_iter *iter, enum netfs_read_from_hole read_hole, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv); /* Write data to the cache */ int (*write)(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - netfs_io_terminated_t term_func, + fscache_io_terminated_t term_func, void *term_func_priv); /* Expand readahead request */ From patchwork Thu Oct 27 08:35:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9886FA3743 for ; Thu, 27 Oct 2022 08:36:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234851AbiJ0IgD (ORCPT ); Thu, 27 Oct 2022 04:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234899AbiJ0If7 (ORCPT ); Thu, 27 Oct 2022 04:35:59 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37DD8A7C8; Thu, 27 Oct 2022 01:35:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAsArv_1666859753; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAsArv_1666859753) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:54 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] fscache,netfs: rename netfs_read_from_hole as fscache_read_from_hole Date: Thu, 27 Oct 2022 16:35:42 +0800 Message-Id: <20221027083547.46933-5-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Rename netfs_read_from_hole as fscache_read_from_hole to make raw fscache APIs more neutral independent on libnetfs. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/cachefiles/io.c | 6 +++--- fs/cifs/fscache.c | 2 +- fs/erofs/fscache.c | 2 +- fs/netfs/io.c | 6 +++--- fs/nfs/fscache.c | 2 +- include/linux/fscache.h | 8 ++++---- include/linux/netfs.h | 10 +++++----- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 6931032b837c..2dce7af0fbcf 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -73,7 +73,7 @@ static void cachefiles_read_complete(struct kiocb *iocb, long ret) static int cachefiles_read(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - enum netfs_read_from_hole read_hole, + enum fscache_read_from_hole read_hole, fscache_io_terminated_t term_func, void *term_func_priv) { @@ -98,7 +98,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres, /* If the caller asked us to seek for data before doing the read, then * we should do that now. If we find a gap, we fill it with zeros. */ - if (read_hole != NETFS_READ_HOLE_IGNORE) { + if (read_hole != FSCACHE_READ_HOLE_IGNORE) { loff_t off = start_pos, off2; off2 = cachefiles_inject_read_error(); @@ -116,7 +116,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres, * return success. */ ret = -ENODATA; - if (read_hole == NETFS_READ_HOLE_FAIL) + if (read_hole == FSCACHE_READ_HOLE_FAIL) goto presubmission_error; iov_iter_zero(len, iter); diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c index a1751b956318..3145e0993313 100644 --- a/fs/cifs/fscache.c +++ b/fs/cifs/fscache.c @@ -156,7 +156,7 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page) if (ret < 0) return ret; - ret = fscache_read(&cres, page_offset(page), &iter, NETFS_READ_HOLE_FAIL, + ret = fscache_read(&cres, page_offset(page), &iter, FSCACHE_READ_HOLE_FAIL, NULL, NULL); fscache_end_operation(&cres); return ret; diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index bf216478afa2..1cc0437eab50 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -195,7 +195,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, start + done, subreq->len); ret = fscache_read(cres, subreq->start, &iter, - NETFS_READ_HOLE_FAIL, + FSCACHE_READ_HOLE_FAIL, erofc_fscache_subreq_complete, subreq); if (ret == -EIOCBQUEUED) ret = 0; diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 992f3eebd2ee..2fc211376dc2 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -43,7 +43,7 @@ static void netfs_cache_read_terminated(void *priv, ssize_t transferred_or_error */ static void netfs_read_from_cache(struct netfs_io_request *rreq, struct netfs_io_subrequest *subreq, - enum netfs_read_from_hole read_hole) + enum fscache_read_from_hole read_hole) { struct netfs_cache_resources *cres = &rreq->cache_resources; struct iov_iter iter; @@ -251,7 +251,7 @@ static void netfs_rreq_short_read(struct netfs_io_request *rreq, netfs_get_subrequest(subreq, netfs_sreq_trace_get_short_read); atomic_inc(&rreq->nr_outstanding); if (subreq->source == FSCACHE_READ_FROM_CACHE) - netfs_read_from_cache(rreq, subreq, NETFS_READ_HOLE_CLEAR); + netfs_read_from_cache(rreq, subreq, FSCACHE_READ_HOLE_CLEAR); else netfs_read_from_server(rreq, subreq); } @@ -580,7 +580,7 @@ static bool netfs_rreq_submit_slice(struct netfs_io_request *rreq, netfs_read_from_server(rreq, subreq); break; case FSCACHE_READ_FROM_CACHE: - netfs_read_from_cache(rreq, subreq, NETFS_READ_HOLE_IGNORE); + netfs_read_from_cache(rreq, subreq, FSCACHE_READ_HOLE_IGNORE); break; default: BUG(); diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index e861d7bae305..509236f8b750 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -258,7 +258,7 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page) if (ret < 0) return ret; - ret = fscache_read(&cres, page_offset(page), &iter, NETFS_READ_HOLE_FAIL, + ret = fscache_read(&cres, page_offset(page), &iter, FSCACHE_READ_HOLE_FAIL, NULL, NULL); fscache_end_operation(&cres); return ret; diff --git a/include/linux/fscache.h b/include/linux/fscache.h index ee8e14f142e8..80455e00c520 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -496,18 +496,18 @@ static inline void fscache_end_operation(struct netfs_cache_resources *cres) * @read_hole indicates how a partially populated region in the cache should be * handled. It can be one of a number of settings: * - * NETFS_READ_HOLE_IGNORE - Just try to read (may return a short read). + * FSCACHE_READ_HOLE_IGNORE - Just try to read (may return a short read). * - * NETFS_READ_HOLE_CLEAR - Seek for data, clearing the part of the buffer + * FSCACHE_READ_HOLE_CLEAR - Seek for data, clearing the part of the buffer * skipped over, then do as for IGNORE. * - * NETFS_READ_HOLE_FAIL - Give ENODATA if we encounter a hole. + * FSCACHE_READ_HOLE_FAIL - Give ENODATA if we encounter a hole. */ static inline int fscache_read(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - enum netfs_read_from_hole read_hole, + enum fscache_read_from_hole read_hole, fscache_io_terminated_t term_func, void *term_func_priv) { diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 2cac478607a8..998402e34c00 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -221,10 +221,10 @@ struct netfs_request_ops { /* * How to handle reading from a hole. */ -enum netfs_read_from_hole { - NETFS_READ_HOLE_IGNORE, - NETFS_READ_HOLE_CLEAR, - NETFS_READ_HOLE_FAIL, +enum fscache_read_from_hole { + FSCACHE_READ_HOLE_IGNORE, + FSCACHE_READ_HOLE_CLEAR, + FSCACHE_READ_HOLE_FAIL, }; /* @@ -239,7 +239,7 @@ struct netfs_cache_ops { int (*read)(struct netfs_cache_resources *cres, loff_t start_pos, struct iov_iter *iter, - enum netfs_read_from_hole read_hole, + enum fscache_read_from_hole read_hole, fscache_io_terminated_t term_func, void *term_func_priv); From patchwork Thu Oct 27 08:35:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82DDDFA3748 for ; Thu, 27 Oct 2022 08:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234981AbiJ0IgH (ORCPT ); Thu, 27 Oct 2022 04:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234925AbiJ0IgB (ORCPT ); Thu, 27 Oct 2022 04:36:01 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A33A8E7A9; Thu, 27 Oct 2022 01:35:58 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R811e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAtIeX_1666859754; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAtIeX_1666859754) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:55 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] fscache,netfs: rename netfs_cache_ops as fscache_ops Date: Thu, 27 Oct 2022 16:35:43 +0800 Message-Id: <20221027083547.46933-6-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Rename netfs_cache_ops as fscache_ops to make raw fscache APIs more neutral independent on libnetfs. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/cachefiles/io.c | 4 ++-- include/linux/fscache.h | 8 ++++---- include/linux/netfs.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 2dce7af0fbcf..ff4d8a309d51 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -617,7 +617,7 @@ static void cachefiles_end_operation(struct netfs_cache_resources *cres) fscache_end_cookie_access(fscache_cres_cookie(cres), fscache_access_io_end); } -static const struct netfs_cache_ops cachefiles_netfs_cache_ops = { +static const struct fscache_ops cachefiles_fscache_ops = { .end_operation = cachefiles_end_operation, .read = cachefiles_read, .write = cachefiles_write, @@ -635,7 +635,7 @@ bool cachefiles_begin_operation(struct netfs_cache_resources *cres, struct cachefiles_object *object = cachefiles_cres_object(cres); if (!cachefiles_cres_file(cres)) { - cres->ops = &cachefiles_netfs_cache_ops; + cres->ops = &cachefiles_fscache_ops; if (object->file) { spin_lock(&object->lock); if (!cres->cache_priv2 && object->file) diff --git a/include/linux/fscache.h b/include/linux/fscache.h index 80455e00c520..d6546dc714b8 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -423,7 +423,7 @@ void fscache_invalidate(struct fscache_cookie *cookie, * Returns a pointer to the operations table if usable or NULL if not. */ static inline -const struct netfs_cache_ops *fscache_operation_valid(const struct netfs_cache_resources *cres) +const struct fscache_ops *fscache_operation_valid(const struct netfs_cache_resources *cres) { return fscache_resources_valid(cres) ? cres->ops : NULL; } @@ -466,7 +466,7 @@ int fscache_begin_read_operation(struct netfs_cache_resources *cres, */ static inline void fscache_end_operation(struct netfs_cache_resources *cres) { - const struct netfs_cache_ops *ops = fscache_operation_valid(cres); + const struct fscache_ops *ops = fscache_operation_valid(cres); if (ops) ops->end_operation(cres); @@ -511,7 +511,7 @@ int fscache_read(struct netfs_cache_resources *cres, fscache_io_terminated_t term_func, void *term_func_priv) { - const struct netfs_cache_ops *ops = fscache_operation_valid(cres); + const struct fscache_ops *ops = fscache_operation_valid(cres); return ops->read(cres, start_pos, iter, read_hole, term_func, term_func_priv); } @@ -569,7 +569,7 @@ int fscache_write(struct netfs_cache_resources *cres, fscache_io_terminated_t term_func, void *term_func_priv) { - const struct netfs_cache_ops *ops = fscache_operation_valid(cres); + const struct fscache_ops *ops = fscache_operation_valid(cres); return ops->write(cres, start_pos, iter, term_func, term_func_priv); } diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 998402e34c00..2ff3a65458a6 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -134,7 +134,7 @@ struct netfs_inode { * Resources required to do operations on a cache. */ struct netfs_cache_resources { - const struct netfs_cache_ops *ops; + const struct fscache_ops *ops; void *cache_priv; void *cache_priv2; unsigned int debug_id; /* Cookie debug ID */ @@ -231,7 +231,7 @@ enum fscache_read_from_hole { * Table of operations for access to a cache. This is obtained by * rreq->ops->begin_cache_operation(). */ -struct netfs_cache_ops { +struct fscache_ops { /* End an operation */ void (*end_operation)(struct netfs_cache_resources *cres); From patchwork Thu Oct 27 08:35:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C938FA373D for ; Thu, 27 Oct 2022 08:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235006AbiJ0IgO (ORCPT ); Thu, 27 Oct 2022 04:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234961AbiJ0IgF (ORCPT ); Thu, 27 Oct 2022 04:36:05 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC2168F26C; Thu, 27 Oct 2022 01:35:59 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAtIf8_1666859755; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAtIf8_1666859755) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:56 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] fscache,netfs: rename netfs_cache_resources as fscache_resources Date: Thu, 27 Oct 2022 16:35:44 +0800 Message-Id: <20221027083547.46933-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Rename netfs_cache_resources as fscache_resources to make raw fscache APIs more neutral independent on libnetfs. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/cachefiles/interface.c | 2 +- fs/cachefiles/internal.h | 6 +++--- fs/cachefiles/io.c | 14 +++++++------- fs/cifs/fscache.c | 6 +++--- fs/erofs/fscache.c | 2 +- fs/fscache/io.c | 14 +++++++------- fs/netfs/buffered_read.c | 2 +- fs/netfs/io.c | 6 +++--- fs/nfs/fscache.c | 4 ++-- include/linux/fscache-cache.h | 8 ++++---- include/linux/fscache.h | 16 ++++++++-------- include/linux/netfs.h | 18 +++++++++--------- 12 files changed, 49 insertions(+), 49 deletions(-) diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index a69073a1d3f0..82ccbd957725 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c @@ -270,7 +270,7 @@ static bool cachefiles_shorten_object(struct cachefiles_object *object, /* * Resize the backing object. */ -static void cachefiles_resize_cookie(struct netfs_cache_resources *cres, +static void cachefiles_resize_cookie(struct fscache_resources *cres, loff_t new_size) { struct cachefiles_object *object = cachefiles_cres_object(cres); diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 897cc01b8b56..be8e0367ca0f 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -134,13 +134,13 @@ struct cachefiles_req { #include static inline -struct file *cachefiles_cres_file(struct netfs_cache_resources *cres) +struct file *cachefiles_cres_file(struct fscache_resources *cres) { return cres->cache_priv2; } static inline -struct cachefiles_object *cachefiles_cres_object(struct netfs_cache_resources *cres) +struct cachefiles_object *cachefiles_cres_object(struct fscache_resources *cres) { return fscache_cres_cookie(cres)->cache_priv; } @@ -229,7 +229,7 @@ extern void cachefiles_put_object(struct cachefiles_object *object, /* * io.c */ -extern bool cachefiles_begin_operation(struct netfs_cache_resources *cres, +extern bool cachefiles_begin_operation(struct fscache_resources *cres, enum fscache_want_state want_state); extern int __cachefiles_prepare_write(struct cachefiles_object *object, struct file *file, diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index ff4d8a309d51..9aace92a7503 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -70,7 +70,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, +static int cachefiles_read(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, enum fscache_read_from_hole read_hole, @@ -194,7 +194,7 @@ static int cachefiles_read(struct netfs_cache_resources *cres, * Query the occupancy of the cache in a region, returning where the next chunk * of data starts and how long it is. */ -static int cachefiles_query_occupancy(struct netfs_cache_resources *cres, +static int cachefiles_query_occupancy(struct fscache_resources *cres, loff_t start, size_t len, size_t granularity, loff_t *_data_start, size_t *_data_len) { @@ -367,7 +367,7 @@ int __cachefiles_write(struct cachefiles_object *object, return ret; } -static int cachefiles_write(struct netfs_cache_resources *cres, +static int cachefiles_write(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, fscache_io_terminated_t term_func, @@ -389,7 +389,7 @@ static int cachefiles_write(struct netfs_cache_resources *cres, * Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ -static enum fscache_io_source cachefiles_prepare_read(struct netfs_cache_resources *cres, +static enum fscache_io_source cachefiles_prepare_read(struct fscache_resources *cres, loff_t *_start, size_t *_len, unsigned long *_flags, loff_t i_size) { @@ -581,7 +581,7 @@ int __cachefiles_prepare_write(struct cachefiles_object *object, cachefiles_has_space_for_write); } -static int cachefiles_prepare_write(struct netfs_cache_resources *cres, +static int cachefiles_prepare_write(struct fscache_resources *cres, loff_t *_start, size_t *_len, loff_t i_size, bool no_space_allocated_yet) { @@ -608,7 +608,7 @@ static int cachefiles_prepare_write(struct netfs_cache_resources *cres, /* * Clean up an operation. */ -static void cachefiles_end_operation(struct netfs_cache_resources *cres) +static void cachefiles_end_operation(struct fscache_resources *cres) { struct file *file = cachefiles_cres_file(cres); @@ -629,7 +629,7 @@ static const struct fscache_ops cachefiles_fscache_ops = { /* * Open the cache file when beginning a cache operation. */ -bool cachefiles_begin_operation(struct netfs_cache_resources *cres, +bool cachefiles_begin_operation(struct fscache_resources *cres, enum fscache_want_state want_state) { struct cachefiles_object *object = cachefiles_cres_object(cres); diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c index 3145e0993313..6d5431a6a9a0 100644 --- a/fs/cifs/fscache.c +++ b/fs/cifs/fscache.c @@ -140,7 +140,7 @@ void cifs_fscache_release_inode_cookie(struct inode *inode) */ static int fscache_fallback_read_page(struct inode *inode, struct page *page) { - struct netfs_cache_resources cres; + struct fscache_resources cres; struct fscache_cookie *cookie = cifs_inode_cookie(inode); struct iov_iter iter; struct bio_vec bvec[1]; @@ -168,7 +168,7 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page) static int fscache_fallback_write_page(struct inode *inode, struct page *page, bool no_space_allocated_yet) { - struct netfs_cache_resources cres; + struct fscache_resources cres; struct fscache_cookie *cookie = cifs_inode_cookie(inode); struct iov_iter iter; struct bio_vec bvec[1]; @@ -229,7 +229,7 @@ int __cifs_fscache_query_occupancy(struct inode *inode, pgoff_t *_data_first, unsigned int *_data_nr_pages) { - struct netfs_cache_resources cres; + struct fscache_resources cres; struct fscache_cookie *cookie = cifs_inode_cookie(inode); loff_t start, data_start; size_t len, data_len; diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 1cc0437eab50..6fbdf067a669 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -144,7 +144,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, enum fscache_io_source source; struct super_block *sb = rreq->mapping->host->i_sb; struct netfs_io_subrequest *subreq; - struct netfs_cache_resources *cres = &rreq->cache_resources; + struct fscache_resources *cres = &rreq->cache_resources; struct iov_iter iter; loff_t start = rreq->start; size_t len = rreq->len; diff --git a/fs/fscache/io.c b/fs/fscache/io.c index 3ef93fdcb3b3..b328914c2ba5 100644 --- a/fs/fscache/io.c +++ b/fs/fscache/io.c @@ -20,7 +20,7 @@ * See if the target cache object is at the specified minimum state of * accessibility yet, and if not, wait for it. */ -bool fscache_wait_for_operation(struct netfs_cache_resources *cres, +bool fscache_wait_for_operation(struct fscache_resources *cres, enum fscache_want_state want_state) { struct fscache_cookie *cookie = fscache_cres_cookie(cres); @@ -68,7 +68,7 @@ EXPORT_SYMBOL(fscache_wait_for_operation); * * Attaches the resources required to the operation resources record. */ -static int fscache_begin_operation(struct netfs_cache_resources *cres, +static int fscache_begin_operation(struct fscache_resources *cres, struct fscache_cookie *cookie, enum fscache_want_state want_state, enum fscache_access_trace why) @@ -142,7 +142,7 @@ static int fscache_begin_operation(struct netfs_cache_resources *cres, return -ENOBUFS; } -int __fscache_begin_read_operation(struct netfs_cache_resources *cres, +int __fscache_begin_read_operation(struct fscache_resources *cres, struct fscache_cookie *cookie) { return fscache_begin_operation(cres, cookie, FSCACHE_WANT_PARAMS, @@ -150,7 +150,7 @@ int __fscache_begin_read_operation(struct netfs_cache_resources *cres, } EXPORT_SYMBOL(__fscache_begin_read_operation); -int __fscache_begin_write_operation(struct netfs_cache_resources *cres, +int __fscache_begin_write_operation(struct fscache_resources *cres, struct fscache_cookie *cookie) { return fscache_begin_operation(cres, cookie, FSCACHE_WANT_PARAMS, @@ -199,7 +199,7 @@ bool fscache_dirty_folio(struct address_space *mapping, struct folio *folio, EXPORT_SYMBOL(fscache_dirty_folio); struct fscache_write_request { - struct netfs_cache_resources cache_resources; + struct fscache_resources cache_resources; struct address_space *mapping; loff_t start; size_t len; @@ -253,7 +253,7 @@ void __fscache_write_to_cache(struct fscache_cookie *cookie, bool cond) { struct fscache_write_request *wreq; - struct netfs_cache_resources *cres; + struct fscache_resources *cres; struct iov_iter iter; int ret = -ENOBUFS; @@ -306,7 +306,7 @@ EXPORT_SYMBOL(__fscache_write_to_cache); */ void __fscache_resize_cookie(struct fscache_cookie *cookie, loff_t new_size) { - struct netfs_cache_resources cres; + struct fscache_resources cres; trace_fscache_resize(cookie, new_size); if (fscache_begin_operation(&cres, cookie, FSCACHE_WANT_WRITE, diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 0ce535852151..6bf215da4c93 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -97,7 +97,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq) static void netfs_cache_expand_readahead(struct netfs_io_request *rreq, loff_t *_start, size_t *_len, loff_t i_size) { - struct netfs_cache_resources *cres = &rreq->cache_resources; + struct fscache_resources *cres = &rreq->cache_resources; if (cres->ops && cres->ops->expand_readahead) cres->ops->expand_readahead(cres, _start, _len, i_size); diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 2fc211376dc2..7fd2627e259a 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -45,7 +45,7 @@ static void netfs_read_from_cache(struct netfs_io_request *rreq, struct netfs_io_subrequest *subreq, enum fscache_read_from_hole read_hole) { - struct netfs_cache_resources *cres = &rreq->cache_resources; + struct fscache_resources *cres = &rreq->cache_resources; struct iov_iter iter; netfs_stat(&netfs_n_rh_read); @@ -165,7 +165,7 @@ static void netfs_rreq_copy_terminated(void *priv, ssize_t transferred_or_error, */ static void netfs_rreq_do_write_to_cache(struct netfs_io_request *rreq) { - struct netfs_cache_resources *cres = &rreq->cache_resources; + struct fscache_resources *cres = &rreq->cache_resources; struct netfs_io_subrequest *subreq, *next, *p; struct iov_iter iter; int ret; @@ -484,7 +484,7 @@ static enum fscache_io_source netfs_cache_prepare_read(struct netfs_io_subreques loff_t i_size) { struct netfs_io_request *rreq = subreq->rreq; - struct netfs_cache_resources *cres = &rreq->cache_resources; + struct fscache_resources *cres = &rreq->cache_resources; if (cres->ops) return cres->ops->prepare_read(cres, &subreq->start, diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 509236f8b750..cea5f11c0af9 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -242,7 +242,7 @@ void nfs_fscache_release_file(struct inode *inode, struct file *filp) */ static int fscache_fallback_read_page(struct inode *inode, struct page *page) { - struct netfs_cache_resources cres; + struct fscache_resources cres; struct fscache_cookie *cookie = nfs_i_fscache(inode); struct iov_iter iter; struct bio_vec bvec[1]; @@ -270,7 +270,7 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page) static int fscache_fallback_write_page(struct inode *inode, struct page *page, bool no_space_allocated_yet) { - struct netfs_cache_resources cres; + struct fscache_resources cres; struct fscache_cookie *cookie = nfs_i_fscache(inode); struct iov_iter iter; struct bio_vec bvec[1]; diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index a174cedf4d90..a05ab349c26e 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h @@ -65,14 +65,14 @@ struct fscache_cache_ops { void (*withdraw_cookie)(struct fscache_cookie *cookie); /* Change the size of a data object */ - void (*resize_cookie)(struct netfs_cache_resources *cres, + void (*resize_cookie)(struct fscache_resources *cres, loff_t new_size); /* Invalidate an object */ bool (*invalidate_cookie)(struct fscache_cookie *cookie); /* Begin an operation for the netfs lib */ - bool (*begin_operation)(struct netfs_cache_resources *cres, + bool (*begin_operation)(struct fscache_resources *cres, enum fscache_want_state want_state); /* Prepare to write to a live cache object */ @@ -110,7 +110,7 @@ extern void fscache_end_cookie_access(struct fscache_cookie *cookie, extern void fscache_cookie_lookup_negative(struct fscache_cookie *cookie); extern void fscache_resume_after_invalidation(struct fscache_cookie *cookie); extern void fscache_caching_failed(struct fscache_cookie *cookie); -extern bool fscache_wait_for_operation(struct netfs_cache_resources *cred, +extern bool fscache_wait_for_operation(struct fscache_resources *cres, enum fscache_want_state state); /** @@ -140,7 +140,7 @@ static inline void *fscache_get_key(struct fscache_cookie *cookie) return cookie->key; } -static inline struct fscache_cookie *fscache_cres_cookie(struct netfs_cache_resources *cres) +static inline struct fscache_cookie *fscache_cres_cookie(struct fscache_resources *cres) { return cres->cache_priv; } diff --git a/include/linux/fscache.h b/include/linux/fscache.h index d6546dc714b8..e955df30845b 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -169,8 +169,8 @@ extern void __fscache_unuse_cookie(struct fscache_cookie *, const void *, const 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 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 *); +extern int __fscache_begin_read_operation(struct fscache_resources *, struct fscache_cookie *); +extern int __fscache_begin_write_operation(struct fscache_resources *, struct fscache_cookie *); extern void __fscache_write_to_cache(struct fscache_cookie *, struct address_space *, loff_t, size_t, loff_t, fscache_io_terminated_t, void *, @@ -423,7 +423,7 @@ void fscache_invalidate(struct fscache_cookie *cookie, * Returns a pointer to the operations table if usable or NULL if not. */ static inline -const struct fscache_ops *fscache_operation_valid(const struct netfs_cache_resources *cres) +const struct fscache_ops *fscache_operation_valid(const struct fscache_resources *cres) { return fscache_resources_valid(cres) ? cres->ops : NULL; } @@ -450,7 +450,7 @@ const struct fscache_ops *fscache_operation_valid(const struct netfs_cache_resou * * Other error code from the cache, such as -ENOMEM. */ static inline -int fscache_begin_read_operation(struct netfs_cache_resources *cres, +int fscache_begin_read_operation(struct fscache_resources *cres, struct fscache_cookie *cookie) { if (fscache_cookie_enabled(cookie)) @@ -464,7 +464,7 @@ int fscache_begin_read_operation(struct netfs_cache_resources *cres, * * Clean up the resources at the end of the read request. */ -static inline void fscache_end_operation(struct netfs_cache_resources *cres) +static inline void fscache_end_operation(struct fscache_resources *cres) { const struct fscache_ops *ops = fscache_operation_valid(cres); @@ -504,7 +504,7 @@ static inline void fscache_end_operation(struct netfs_cache_resources *cres) * FSCACHE_READ_HOLE_FAIL - Give ENODATA if we encounter a hole. */ static inline -int fscache_read(struct netfs_cache_resources *cres, +int fscache_read(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, enum fscache_read_from_hole read_hole, @@ -535,7 +535,7 @@ int fscache_read(struct netfs_cache_resources *cres, * * Other error code from the cache, such as -ENOMEM. */ static inline -int fscache_begin_write_operation(struct netfs_cache_resources *cres, +int fscache_begin_write_operation(struct fscache_resources *cres, struct fscache_cookie *cookie) { if (fscache_cookie_enabled(cookie)) @@ -563,7 +563,7 @@ int fscache_begin_write_operation(struct netfs_cache_resources *cres, * error code otherwise. */ static inline -int fscache_write(struct netfs_cache_resources *cres, +int fscache_write(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, fscache_io_terminated_t term_func, diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 2ff3a65458a6..91a4382cbd1f 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -133,7 +133,7 @@ struct netfs_inode { /* * Resources required to do operations on a cache. */ -struct netfs_cache_resources { +struct fscache_resources { const struct fscache_ops *ops; void *cache_priv; void *cache_priv2; @@ -177,7 +177,7 @@ struct netfs_io_request { struct work_struct work; struct inode *inode; /* The file being accessed */ struct address_space *mapping; /* The mapping being accessed */ - struct netfs_cache_resources cache_resources; + struct fscache_resources cache_resources; struct list_head subrequests; /* Contributory I/O operations */ void *netfs_priv; /* Private data for the netfs */ unsigned int debug_id; @@ -233,10 +233,10 @@ enum fscache_read_from_hole { */ struct fscache_ops { /* End an operation */ - void (*end_operation)(struct netfs_cache_resources *cres); + void (*end_operation)(struct fscache_resources *cres); /* Read data from the cache */ - int (*read)(struct netfs_cache_resources *cres, + int (*read)(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, enum fscache_read_from_hole read_hole, @@ -244,34 +244,34 @@ struct fscache_ops { void *term_func_priv); /* Write data to the cache */ - int (*write)(struct netfs_cache_resources *cres, + int (*write)(struct fscache_resources *cres, loff_t start_pos, struct iov_iter *iter, fscache_io_terminated_t term_func, void *term_func_priv); /* Expand readahead request */ - void (*expand_readahead)(struct netfs_cache_resources *cres, + void (*expand_readahead)(struct fscache_resources *cres, loff_t *_start, size_t *_len, loff_t i_size); /* Prepare a read operation, shortening it to a cached/uncached * boundary as appropriate. */ - enum fscache_io_source (*prepare_read)(struct netfs_cache_resources *cres, + enum fscache_io_source (*prepare_read)(struct fscache_resources *cres, loff_t *_start, size_t *_len, unsigned long *_flags, loff_t i_size); /* Prepare a write operation, working out what part of the write we can * actually do. */ - int (*prepare_write)(struct netfs_cache_resources *cres, + int (*prepare_write)(struct fscache_resources *cres, loff_t *_start, size_t *_len, loff_t i_size, bool no_space_allocated_yet); /* Query the occupancy of the cache in a region, returning where the * next chunk of data starts and how long it is. */ - int (*query_occupancy)(struct netfs_cache_resources *cres, + int (*query_occupancy)(struct fscache_resources *cres, loff_t start, size_t len, size_t granularity, loff_t *_data_start, size_t *_data_len); }; From patchwork Thu Oct 27 08:35:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75765C38A2D for ; Thu, 27 Oct 2022 08:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235022AbiJ0IgQ (ORCPT ); Thu, 27 Oct 2022 04:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbiJ0IgF (ORCPT ); Thu, 27 Oct 2022 04:36:05 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF8728E714; Thu, 27 Oct 2022 01:36:00 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R911e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAl7c2_1666859756; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAl7c2_1666859756) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:57 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] fscache,netfs: define flags for prepare_read() Date: Thu, 27 Oct 2022 16:35:45 +0800 Message-Id: <20221027083547.46933-8-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Decouple flags used in prepare_read() from netfs_io_subrequest flags to make raw fscache APIs more neutral independent on libnetfs. Currently only *REQ_[COPY_TO_CACHE|ONDEMAND] flags are exposed to fscache, thus define these two flags for fscache variant, while keep other netfs_io_subrequest flags untouched. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/cachefiles/io.c | 10 +++++----- fs/erofs/fscache.c | 5 +++-- fs/netfs/io.c | 14 ++++++++++---- include/linux/fscache.h | 3 +++ include/linux/netfs.h | 1 - 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index 9aace92a7503..a9c7463eb3e1 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -415,9 +415,9 @@ static enum fscache_io_source cachefiles_prepare_read(struct fscache_resources * } if (test_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags)) { - __set_bit(NETFS_SREQ_COPY_TO_CACHE, _flags); + __set_bit(FSCACHE_REQ_COPY_TO_CACHE, _flags); why = cachefiles_trace_read_no_data; - if (!test_bit(NETFS_SREQ_ONDEMAND, _flags)) + if (!test_bit(FSCACHE_REQ_ONDEMAND, _flags)) goto out_no_object; } @@ -487,11 +487,11 @@ static enum fscache_io_source cachefiles_prepare_read(struct fscache_resources * goto out; download_and_store: - __set_bit(NETFS_SREQ_COPY_TO_CACHE, _flags); - if (test_bit(NETFS_SREQ_ONDEMAND, _flags)) { + __set_bit(FSCACHE_REQ_COPY_TO_CACHE, _flags); + if (test_bit(FSCACHE_REQ_ONDEMAND, _flags)) { rc = cachefiles_ondemand_read(object, start, len); if (!rc) { - __clear_bit(NETFS_SREQ_ONDEMAND, _flags); + __clear_bit(FSCACHE_REQ_ONDEMAND, _flags); goto retry; } ret = FSCACHE_INVALID_READ; diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 6fbdf067a669..e30a42a35ae7 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -148,6 +148,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, struct iov_iter iter; loff_t start = rreq->start; size_t len = rreq->len; + unsigned long flags; size_t done = 0; int ret; @@ -172,12 +173,12 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, subreq->start = pstart + done; subreq->len = len - done; - subreq->flags = 1 << NETFS_SREQ_ONDEMAND; list_add_tail(&subreq->rreq_link, &rreq->subrequests); + flags = 1 << FSCACHE_REQ_ONDEMAND; source = cres->ops->prepare_read(cres, &subreq->start, - &subreq->len, &subreq->flags, LLONG_MAX); + &subreq->len, &flags, LLONG_MAX); if (WARN_ON(subreq->len == 0)) source = FSCACHE_INVALID_READ; if (source != FSCACHE_READ_FROM_CACHE) { diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 7fd2627e259a..13ac74f2e32f 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -485,10 +485,16 @@ static enum fscache_io_source netfs_cache_prepare_read(struct netfs_io_subreques { struct netfs_io_request *rreq = subreq->rreq; struct fscache_resources *cres = &rreq->cache_resources; - - if (cres->ops) - return cres->ops->prepare_read(cres, &subreq->start, - &subreq->len, &subreq->flags, i_size); + enum fscache_io_source source; + unsigned long flags = 0; + + if (cres->ops) { + source = cres->ops->prepare_read(cres, &subreq->start, + &subreq->len, &flags, i_size); + if (test_bit(FSCACHE_REQ_COPY_TO_CACHE, &flags)) + __set_bit(NETFS_SREQ_COPY_TO_CACHE, &subreq->flags); + return source; + } if (subreq->start >= rreq->i_size) return FSCACHE_FILL_WITH_ZEROES; return FSCACHE_DOWNLOAD_FROM_SERVER; diff --git a/include/linux/fscache.h b/include/linux/fscache.h index e955df30845b..9df2988be804 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -147,6 +147,9 @@ struct fscache_cookie { }; }; +#define FSCACHE_REQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ +#define FSCACHE_REQ_ONDEMAND 1 /* Set if it's from on-demand read mode */ + /* * slow-path functions for when there is actually caching available, and the * netfs does actually have a valid token diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 91a4382cbd1f..146a13e6a9d2 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -160,7 +160,6 @@ struct netfs_io_subrequest { #define NETFS_SREQ_SHORT_IO 2 /* Set if the I/O was short */ #define NETFS_SREQ_SEEK_DATA_READ 3 /* Set if ->read() should SEEK_DATA first */ #define NETFS_SREQ_NO_PROGRESS 4 /* Set if we didn't manage to read any data */ -#define NETFS_SREQ_ONDEMAND 5 /* Set if it's from on-demand read mode */ }; enum netfs_io_origin { From patchwork Thu Oct 27 08:35:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F335DC38A2D for ; Thu, 27 Oct 2022 08:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235084AbiJ0Ig5 (ORCPT ); Thu, 27 Oct 2022 04:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235000AbiJ0IgM (ORCPT ); Thu, 27 Oct 2022 04:36:12 -0400 Received: from out199-9.us.a.mail.aliyun.com (out199-9.us.a.mail.aliyun.com [47.90.199.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 883EB9411F; Thu, 27 Oct 2022 01:36:03 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAkmCy_1666859758; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAkmCy_1666859758) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:35:59 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] fscache,netfs: move PageFsCache() family helpers to fscache.h Date: Thu, 27 Oct 2022 16:35:46 +0800 Message-Id: <20221027083547.46933-9-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Later all structures transformed with "fscache_" prefix will be moved to fscache.h from netfs.h, and then netfs.h will include fscache.h rather than the other way around. If that's the case, the PageFsCache() family helpers also needs to be moved to fscache.h, since end_page_fscache() is referenced inside fscache. Besides, it's also quite reasonable to move these helpers to fscache.h given their names. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- include/linux/fscache.h | 90 +++++++++++++++++++++++++++++++++++++++++ include/linux/netfs.h | 89 ---------------------------------------- 2 files changed, 90 insertions(+), 89 deletions(-) diff --git a/include/linux/fscache.h b/include/linux/fscache.h index 9df2988be804..034d009c0de7 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -17,6 +17,7 @@ #include #include #include +#include #if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE) #define __fscache_available (1) @@ -695,4 +696,93 @@ void fscache_note_page_release(struct fscache_cookie *cookie) clear_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags); } +/* + * Overload PG_private_2 to give us PG_fscache - this is used to indicate that + * a page is currently backed by a local disk cache + */ +#define folio_test_fscache(folio) folio_test_private_2(folio) +#define PageFsCache(page) PagePrivate2((page)) +#define SetPageFsCache(page) SetPagePrivate2((page)) +#define ClearPageFsCache(page) ClearPagePrivate2((page)) +#define TestSetPageFsCache(page) TestSetPagePrivate2((page)) +#define TestClearPageFsCache(page) TestClearPagePrivate2((page)) + +/** + * folio_start_fscache - Start an fscache write on a folio. + * @folio: The folio. + * + * Call this function before writing a folio to a local cache. Starting a + * second write before the first one finishes is not allowed. + */ +static inline void folio_start_fscache(struct folio *folio) +{ + VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio); + folio_get(folio); + folio_set_private_2(folio); +} + +/** + * folio_end_fscache - End an fscache write on a folio. + * @folio: The folio. + * + * Call this function after the folio has been written to the local cache. + * This will wake any sleepers waiting on this folio. + */ +static inline void folio_end_fscache(struct folio *folio) +{ + folio_end_private_2(folio); +} + +/** + * folio_wait_fscache - Wait for an fscache write on this folio to end. + * @folio: The folio. + * + * If this folio is currently being written to a local cache, wait for + * the write to finish. Another write may start after this one finishes, + * unless the caller holds the folio lock. + */ +static inline void folio_wait_fscache(struct folio *folio) +{ + folio_wait_private_2(folio); +} + +/** + * folio_wait_fscache_killable - Wait for an fscache write on this folio to end. + * @folio: The folio. + * + * If this folio is currently being written to a local cache, wait + * for the write to finish or for a fatal signal to be received. + * Another write may start after this one finishes, unless the caller + * holds the folio lock. + * + * Return: + * - 0 if successful. + * - -EINTR if a fatal signal was encountered. + */ +static inline int folio_wait_fscache_killable(struct folio *folio) +{ + return folio_wait_private_2_killable(folio); +} + +static inline void set_page_fscache(struct page *page) +{ + folio_start_fscache(page_folio(page)); +} + +static inline void end_page_fscache(struct page *page) +{ + folio_end_private_2(page_folio(page)); +} + +static inline void wait_on_page_fscache(struct page *page) +{ + folio_wait_private_2(page_folio(page)); +} + +static inline int wait_on_page_fscache_killable(struct page *page) +{ + return folio_wait_private_2_killable(page_folio(page)); +} + + #endif /* _LINUX_FSCACHE_H */ diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 146a13e6a9d2..2ad4e1e88106 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -16,98 +16,9 @@ #include #include -#include enum netfs_sreq_ref_trace; -/* - * Overload PG_private_2 to give us PG_fscache - this is used to indicate that - * a page is currently backed by a local disk cache - */ -#define folio_test_fscache(folio) folio_test_private_2(folio) -#define PageFsCache(page) PagePrivate2((page)) -#define SetPageFsCache(page) SetPagePrivate2((page)) -#define ClearPageFsCache(page) ClearPagePrivate2((page)) -#define TestSetPageFsCache(page) TestSetPagePrivate2((page)) -#define TestClearPageFsCache(page) TestClearPagePrivate2((page)) - -/** - * folio_start_fscache - Start an fscache write on a folio. - * @folio: The folio. - * - * Call this function before writing a folio to a local cache. Starting a - * second write before the first one finishes is not allowed. - */ -static inline void folio_start_fscache(struct folio *folio) -{ - VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio); - folio_get(folio); - folio_set_private_2(folio); -} - -/** - * folio_end_fscache - End an fscache write on a folio. - * @folio: The folio. - * - * Call this function after the folio has been written to the local cache. - * This will wake any sleepers waiting on this folio. - */ -static inline void folio_end_fscache(struct folio *folio) -{ - folio_end_private_2(folio); -} - -/** - * folio_wait_fscache - Wait for an fscache write on this folio to end. - * @folio: The folio. - * - * If this folio is currently being written to a local cache, wait for - * the write to finish. Another write may start after this one finishes, - * unless the caller holds the folio lock. - */ -static inline void folio_wait_fscache(struct folio *folio) -{ - folio_wait_private_2(folio); -} - -/** - * folio_wait_fscache_killable - Wait for an fscache write on this folio to end. - * @folio: The folio. - * - * If this folio is currently being written to a local cache, wait - * for the write to finish or for a fatal signal to be received. - * Another write may start after this one finishes, unless the caller - * holds the folio lock. - * - * Return: - * - 0 if successful. - * - -EINTR if a fatal signal was encountered. - */ -static inline int folio_wait_fscache_killable(struct folio *folio) -{ - return folio_wait_private_2_killable(folio); -} - -static inline void set_page_fscache(struct page *page) -{ - folio_start_fscache(page_folio(page)); -} - -static inline void end_page_fscache(struct page *page) -{ - folio_end_private_2(page_folio(page)); -} - -static inline void wait_on_page_fscache(struct page *page) -{ - folio_wait_private_2(page_folio(page)); -} - -static inline int wait_on_page_fscache_killable(struct page *page) -{ - return folio_wait_private_2_killable(page_folio(page)); -} - enum fscache_io_source { FSCACHE_FILL_WITH_ZEROES, FSCACHE_DOWNLOAD_FROM_SERVER, From patchwork Thu Oct 27 08:35:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13021805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69773FA3744 for ; Thu, 27 Oct 2022 08:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235111AbiJ0Ig6 (ORCPT ); Thu, 27 Oct 2022 04:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235047AbiJ0IgZ (ORCPT ); Thu, 27 Oct 2022 04:36:25 -0400 Received: from out199-3.us.a.mail.aliyun.com (out199-3.us.a.mail.aliyun.com [47.90.199.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CE097D4C; Thu, 27 Oct 2022 01:36:06 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VTAlX3P_1666859759; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VTAlX3P_1666859759) by smtp.aliyun-inc.com; Thu, 27 Oct 2022 16:36:00 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] fscache,netfs: move "fscache_" prefixed structures to fscache.h Date: Thu, 27 Oct 2022 16:35:47 +0800 Message-Id: <20221027083547.46933-10-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com> References: <20221027083547.46933-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since all related structures has been transformed with "fscache_" prefix, move all these structures to fscache.h as a final cleanup. Besides, make netfs.h include fscache.h rather than the other way around. This is an intuitive change since libnetfs lives one layer above fscache, accessing backing files with facache. This is a cleanup without logic change. Signed-off-by: Jingbo Xu --- fs/afs/internal.h | 2 +- fs/erofs/fscache.c | 1 + fs/nfs/fscache.h | 2 +- include/linux/fscache.h | 80 ++++++++++++++++++++++++++++++++++++++++- include/linux/netfs.h | 80 +---------------------------------------- 5 files changed, 83 insertions(+), 82 deletions(-) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 723d162078a3..5d1314265e3d 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index e30a42a35ae7..69531be66b28 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -4,6 +4,7 @@ * Copyright (C) 2022, Bytedance Inc. All rights reserved. */ #include +#include #include "internal.h" static DEFINE_MUTEX(erofs_domain_list_lock); diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h index 2a37af880978..a0715f83a529 100644 --- a/fs/nfs/fscache.h +++ b/fs/nfs/fscache.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_NFS_FSCACHE diff --git a/include/linux/fscache.h b/include/linux/fscache.h index 034d009c0de7..457226a396d2 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -15,7 +15,6 @@ #define _LINUX_FSCACHE_H #include -#include #include #include @@ -151,6 +150,85 @@ struct fscache_cookie { #define FSCACHE_REQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */ #define FSCACHE_REQ_ONDEMAND 1 /* Set if it's from on-demand read mode */ +enum fscache_io_source { + FSCACHE_FILL_WITH_ZEROES, + FSCACHE_DOWNLOAD_FROM_SERVER, + FSCACHE_READ_FROM_CACHE, + FSCACHE_INVALID_READ, +} __mode(byte); + +typedef void (*fscache_io_terminated_t)(void *priv, ssize_t transferred_or_error, + bool was_async); + +/* + * Resources required to do operations on a cache. + */ +struct fscache_resources { + const struct fscache_ops *ops; + void *cache_priv; + void *cache_priv2; + unsigned int debug_id; /* Cookie debug ID */ + unsigned int inval_counter; /* object->inval_counter at begin_op */ +}; + +/* + * How to handle reading from a hole. + */ +enum fscache_read_from_hole { + FSCACHE_READ_HOLE_IGNORE, + FSCACHE_READ_HOLE_CLEAR, + FSCACHE_READ_HOLE_FAIL, +}; + +/* + * Table of operations for access to a cache. This is obtained by + * rreq->ops->begin_cache_operation(). + */ +struct fscache_ops { + /* End an operation */ + void (*end_operation)(struct fscache_resources *cres); + + /* Read data from the cache */ + int (*read)(struct fscache_resources *cres, + loff_t start_pos, + struct iov_iter *iter, + enum fscache_read_from_hole read_hole, + fscache_io_terminated_t term_func, + void *term_func_priv); + + /* Write data to the cache */ + int (*write)(struct fscache_resources *cres, + loff_t start_pos, + struct iov_iter *iter, + fscache_io_terminated_t term_func, + void *term_func_priv); + + /* Expand readahead request */ + void (*expand_readahead)(struct fscache_resources *cres, + loff_t *_start, size_t *_len, loff_t i_size); + + /* Prepare a read operation, shortening it to a cached/uncached + * boundary as appropriate. + */ + enum fscache_io_source (*prepare_read)(struct fscache_resources *cres, + loff_t *_start, size_t *_len, + unsigned long *_flags, loff_t i_size); + + /* Prepare a write operation, working out what part of the write we can + * actually do. + */ + int (*prepare_write)(struct fscache_resources *cres, + loff_t *_start, size_t *_len, loff_t i_size, + bool no_space_allocated_yet); + + /* Query the occupancy of the cache in a region, returning where the + * next chunk of data starts and how long it is. + */ + int (*query_occupancy)(struct fscache_resources *cres, + loff_t start, size_t len, size_t granularity, + loff_t *_data_start, size_t *_data_len); +}; + /* * slow-path functions for when there is actually caching available, and the * netfs does actually have a valid token diff --git a/include/linux/netfs.h b/include/linux/netfs.h index 2ad4e1e88106..1977f953633a 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -16,19 +16,10 @@ #include #include +#include enum netfs_sreq_ref_trace; -enum fscache_io_source { - FSCACHE_FILL_WITH_ZEROES, - FSCACHE_DOWNLOAD_FROM_SERVER, - FSCACHE_READ_FROM_CACHE, - FSCACHE_INVALID_READ, -} __mode(byte); - -typedef void (*fscache_io_terminated_t)(void *priv, ssize_t transferred_or_error, - bool was_async); - /* * Per-inode context. This wraps the VFS inode. */ @@ -41,17 +32,6 @@ struct netfs_inode { loff_t remote_i_size; /* Size of the remote file */ }; -/* - * Resources required to do operations on a cache. - */ -struct fscache_resources { - const struct fscache_ops *ops; - void *cache_priv; - void *cache_priv2; - unsigned int debug_id; /* Cookie debug ID */ - unsigned int inval_counter; /* object->inval_counter at begin_op */ -}; - /* * Descriptor for a single component subrequest. */ @@ -128,64 +108,6 @@ struct netfs_request_ops { void (*done)(struct netfs_io_request *rreq); }; -/* - * How to handle reading from a hole. - */ -enum fscache_read_from_hole { - FSCACHE_READ_HOLE_IGNORE, - FSCACHE_READ_HOLE_CLEAR, - FSCACHE_READ_HOLE_FAIL, -}; - -/* - * Table of operations for access to a cache. This is obtained by - * rreq->ops->begin_cache_operation(). - */ -struct fscache_ops { - /* End an operation */ - void (*end_operation)(struct fscache_resources *cres); - - /* Read data from the cache */ - int (*read)(struct fscache_resources *cres, - loff_t start_pos, - struct iov_iter *iter, - enum fscache_read_from_hole read_hole, - fscache_io_terminated_t term_func, - void *term_func_priv); - - /* Write data to the cache */ - int (*write)(struct fscache_resources *cres, - loff_t start_pos, - struct iov_iter *iter, - fscache_io_terminated_t term_func, - void *term_func_priv); - - /* Expand readahead request */ - void (*expand_readahead)(struct fscache_resources *cres, - loff_t *_start, size_t *_len, loff_t i_size); - - /* Prepare a read operation, shortening it to a cached/uncached - * boundary as appropriate. - */ - enum fscache_io_source (*prepare_read)(struct fscache_resources *cres, - loff_t *_start, size_t *_len, - unsigned long *_flags, loff_t i_size); - - /* Prepare a write operation, working out what part of the write we can - * actually do. - */ - int (*prepare_write)(struct fscache_resources *cres, - loff_t *_start, size_t *_len, loff_t i_size, - bool no_space_allocated_yet); - - /* Query the occupancy of the cache in a region, returning where the - * next chunk of data starts and how long it is. - */ - int (*query_occupancy)(struct fscache_resources *cres, - loff_t start, size_t len, size_t granularity, - loff_t *_data_start, size_t *_data_len); -}; - struct readahead_control; void netfs_readahead(struct readahead_control *); int netfs_read_folio(struct file *, struct folio *);