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: 11646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp105872wru; Thu, 27 Oct 2022 01:36:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YyzYj/nv1557Oj4y0wNWv9jw2WoYNLr8e7JiwaKVPh8n8mhvN2tIVje3DxB9hxNFSYRUO X-Received: by 2002:a17:90b:4acd:b0:212:fe7a:a05a with SMTP id mh13-20020a17090b4acd00b00212fe7aa05amr9166402pjb.204.1666859791263; Thu, 27 Oct 2022 01:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859791; cv=none; d=google.com; s=arc-20160816; b=i8YDRdkBlbzB+37bBX5l6z2tlkV1fyjz2wlJi54A9bH5qq4/qTxQ2knyXy32SEmWId 1hkwH5hXymgn2w620uDSDDdgl6FSfVlF2vAvicbZsWd4FkK/UkFSOX8ML9uBLRO+M9B7 F9ONfEuuKHEvIhu3cQ9+Vg//R1ulXDvSeYI3Bbuqp7Y+sq83aKb02qU7K2KwBJ3TRMLd FzgKRJCn/4FcPc6PavDqljKJN0NQIDUGobj6IbzBw47nDjsPac2743WyCAoiFmS1hfyD ZZY0u7nogV1NkFGllGbbGgaQtG3JR5r/kYYWSWLVi28YrB/lxf1MbiBLwi5nMJ1+xtk8 7Otw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ndL2cJ+u/ToSyoG10w3SPZ7wEaT6auOu9p7dHUerdLc=; b=XfbFbujNuq7Vt/GnXIpoXpLrtvorOXF6lp56rIEjf6ti0924zy/O7F/ek9D8R/MoN9 4kIk9xDUKgZBJk+/bAFjN/rsCa9pQIBqiT9uwnWS7n5kSKNDHvCNBU60F5jxdJ6v7gKp dJ0hDTJQV+PyR1mAQSLc6F1YCrlM2awg1A1M8ZtlCQSB5crBihjQdEBA7UJVAIP3oxYb keIb0hMYlRex0oWa8c9VjeCtk8TCY6T/GSAfP7ZGCj+mi+7j1gZ98EAaHvQiBWlyWYBv ZmkT9MuKQDHIU1F/qqTHU1r131xkzmsNexzaLyYHuKXlOOmASWnVt0erLcYNueY4Qi7X p2SQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t24-20020a17090ad15800b0021071bf8d26si974757pjw.29.2022.10.27.01.36.17; Thu, 27 Oct 2022 01:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234946AbiJ0IgE (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:04 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829172436795456?= X-GMAIL-MSGID: =?utf-8?q?1747829172436795456?= 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: 11648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106071wru; Thu, 27 Oct 2022 01:37:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wKRd5T2Rfd6dGskPiN+b95MvBqk3jRZgOpesTgi9F7bK3GE53JMJ/E6r5mZmss6QI8yOr X-Received: by 2002:a17:907:78a:b0:782:2223:a7cd with SMTP id xd10-20020a170907078a00b007822223a7cdmr40197634ejb.532.1666859824654; Thu, 27 Oct 2022 01:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859824; cv=none; d=google.com; s=arc-20160816; b=z7hQRB5y1v0TvPqEcvOUN58hY683og5Ff+uZ3QbTHK1kOOa+EvORDiklOxB794ea5U kbwDQ7ePnYOExXe2oZcMlIUId0KaqpZV5kPP4qiv5QtgclRfM9yI32C3zZ+SVjXE+HAZ l5eMQeLNwpLQEs9wRvw2IS1sjSBfUa/dSTy9978QsSbvbyHpsOnH4aHCH7ojCArKVGhW LqFZIYjA9zkE6iY4BKL06fFOSaAqCGIVHzwUB3JREx26o8QAcH91Beh3ZEhgoiSWtq78 d7Npqwp5tbdN7yOZiwBgrn7jizf9m7ucWScC/QHRSWZ7o5lUaEn9gzaLR7mPPu0MB3Pi o33Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=li2eaGhycIzJRSJW/xCFVpEY7hQMoeGXgrSJ2PJ+tIs=; b=aFAD1XwImLXNeYDJ3xO5R7NAM+u3P0Cd4gyiiSKeHBA7biqZCYLt84z580tlsAYyZW VmgvaAwnqDm2BDzalN1UEvp/gt8KHWcdt0ElLoXaxu/oXd0pUEf8vQ6hje/poPTBY8xM 7ra4TTpUbuMPwCl9SWXOQp+7HW3+Kke2rm0vlxI8+Evp38KGJO53agDTsWZck/ktL1La IuoeV0eNBsDyi2AlyVlMi/YMBmncoSfuP2KCVar78C8YjEPs8o28aAYQoKnq27QE/5lD vE4Xtbyyrti1kRcQjL81939gPjNNZfPHr1iASXxd/cs9a9g4PLj3fVKcfV7XHq81qQB0 Mt3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a1709060f8800b007ad8a7a1a7asi707097ejj.511.2022.10.27.01.36.36; Thu, 27 Oct 2022 01:37:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234923AbiJ0IgI (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:08 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829207637647486?= X-GMAIL-MSGID: =?utf-8?q?1747829207637647486?= 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: 11651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106213wru; Thu, 27 Oct 2022 01:37:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4A3CLeLAYPHTYerOjDs7V4USasPMANWbG4ETd6H5SXuJOTNdCdkp6I1DNatB6Bn09V0dSw X-Received: by 2002:a17:907:9623:b0:7ad:813f:a6f1 with SMTP id gb35-20020a170907962300b007ad813fa6f1mr5773475ejc.202.1666859846468; Thu, 27 Oct 2022 01:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859846; cv=none; d=google.com; s=arc-20160816; b=EYC87iBHv/c9jqmTA8+FffZ9cPeQAOG4LnwPRAlPItLr1AHRQSXN+le3tyKuPG36ys hd8iQQUa0QvzDahSt8Z9MXO/cMDO0mGNxOS8XnJ9of7VMAs9w19vtCL3JAu9pnOpKf/5 km6TXHSiH8L6nhW9F8ElgydBVwQ6/PdUNvKGb2jvYN+z/TK6xWB1oQoNYg03P3A2BHy8 cTY3+YVGB0HMbYcbsgZWxXoh0juJpYnUJtG6ZwrR8QxWLZ8h05nEQqtecAi3x0K8vp3X Pbsn17pk5GkGylm4LmWS6gtlqrxJXFWam+8zAMJyT5rqrpTagUyKYRDTWtD9p/P18S8R vqMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uby/WPTVGsr0WKpo3v83DjjCyUPHXS0O0n0bJKsUu1Y=; b=Eo0XjTSF3hbtZpGMcWWaqZtXi91gHdNke4wAl7qY/E6IjBAF/t5OZlJa7eeSqOEWi/ kZ+l90h5pIeAlIzeXTxUym7gaCF6U75iYXWrobBQmm5dYgfzg3/iZVeWNEbJVT7UyITJ qxoN4kxgVL22xwvCmxeqvLdWJ8G1eZ9KkxqbUDuduiN2hRRH9tc8MbucLYNq/6sQ+jYY 1N4zNMKgoQt6Xf9VVKqBnKgKubBuinZmA/ypHwS6Gj3VzvTVRzzQia2vw2l4febtCdGE UTkE1XvMAQV8/isGvMe65hQJv5cNPOlBODSxVaeXHOBC2ihdsUPfBpZTM2hjyrLf9EOp 47OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc20-20020a1709071c1400b00787ad97302asi333730ejc.863.2022.10.27.01.37.02; Thu, 27 Oct 2022 01:37:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235001AbiJ0IgM (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:12 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829230295589468?= X-GMAIL-MSGID: =?utf-8?q?1747829230295589468?= 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: 11647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp105917wru; Thu, 27 Oct 2022 01:36:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pmKEsuDqly6YgedCdVdiqoqJzZ++0+hCGmJTAA61scaNVj06KX5XjPbbKDZCB+gZXYDrZ X-Received: by 2002:a62:5e81:0:b0:563:1f18:62ab with SMTP id s123-20020a625e81000000b005631f1862abmr47703743pfb.76.1666859797563; Thu, 27 Oct 2022 01:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859797; cv=none; d=google.com; s=arc-20160816; b=sIdQjlZfn03H0H7Xmg6o0EvYPIocP12oL6jjITMy2b0MFWs7oYImQbjS1kWPnYfHLj WJTId2PWrn0H36XaPehiqFrDc+huiaS+APMznMwsoWQemQ5lmDqitUBRv58NoQNdG6d9 hDd3LMyyUy4ted7JrGeaYMRjoelgWD8I9KOjyUOchRDOJk+W4B/MkfoQHhsmqdWq6KGb tF45036Z4AQRyQnc82RdwqyZ13uHmIijcX+CdTNnsGuG7kjhZBFJO5KRKZhY+y5HaVxa u0ICQjseJaeDtq5C06HJ1WdENU1ScC8HbQDNHy2oxBGl6K/XETpQlCyoKLnTRyRojLaR ZXnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SxGtC/9LDSYnDOt1p8cEcL7fIPdJSD2CY8zPs624VIE=; b=z3KM4lcvB079D5VmQjZKAd88TzVcJwpuLvOtxoVQgh+pWucTdkIhEvDHmH7kHZ/J8W 3DWiCHTbc29RYSPNPKNY93Vp3BDV6IxfeRs7FO311+TGEyMs6LboE8v2DETktgyXRgZ0 YYGWNPwTp6iIwzjLtOnEGVFTZFSEM1n6l8hIwHfRrzPIhJ8nCPw95w6OYlOz6D6CKIjT ZitgUdAxdF3F6SqJChWwR7xu9cXajSRYyXZNw8UiiRL0yMbbj7LTJaDzNp25er8csK3R kSeU1iK/SqPAdM9RnmFYQaerNy4aAYPbGQBBW6ib1NZ6ujkEB2xVjHvWx3KZFaMfkJZL gQew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a63e104000000b0046af665ed92si911482pgh.480.2022.10.27.01.36.23; Thu, 27 Oct 2022 01:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234955AbiJ0IgK (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:10 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829179077457939?= X-GMAIL-MSGID: =?utf-8?q?1747829179077457939?= 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: 11649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106195wru; Thu, 27 Oct 2022 01:37:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kNd7I50lW5EkQ5VC07W1sF4sT7EDYNc7D/xy3+DyB96buEPRJdF7/HEBTugwG0k+VShV0 X-Received: by 2002:a17:906:9fc1:b0:761:9192:504f with SMTP id hj1-20020a1709069fc100b007619192504fmr41608976ejc.116.1666859842996; Thu, 27 Oct 2022 01:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859842; cv=none; d=google.com; s=arc-20160816; b=yjQEfR6d0Mhf2xcjUhG48A2xxk91WC+e3LX82SbmROWwZ1c2kRAUUFzE+/cgTlkgYR wA334lue1pmpFt4sMhsqlZPaRoo0ZmLdq3ftqyE+5xfneYEk/9epuKHir1LZvz3ofceR X47DpDTuiAWTPaOATWO2FLHRXBD84rH71JAkCne27DdntHFOIGuB+1oYiBL2+Kd4K2SH 7SPLtxmThr4ks1bR1IxnodYyg8X7C8Tnp7fcpHQ/LTVkL3xNEiluEdsfK0RcD2keMgGE +5VRAhA4q+2y6a4hx1cl6OY8wn/Z+WtppgW5tAefDelafkv/15rng0TuyO14HYZQkfY+ 2IbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Wnk1DtaBSd0FhlThaHC2KcQqqVLBc/NYwdlPrDLOsBk=; b=F5Ix6bClqMF6bnRJu2D+iJuJ3/ozE20J5/zFQdVjSNpkV5bVf8TT5Q5gxLbyqRfNmH Bjo/jpM7qlZhZtc++BspGyML6qRmL2Uuv7CNr5fontDq6YgcJSHHmtML2V1lTYYbz6vP aBp2+es9BK4/7ck9LsPDqw5DO/vOLrmV4sPi86KKSVzZ0VCM2PmwdumBSYd6ATbKRyYS siJCCDuRo7p38WX9DAABq6t9Rxsglk7JH68A+T479fUHX+iQtcjtLuEVq+8ks2HGPt+M vkhLF7BKtYuSaZFAGHMOeS7JttIkqM9SpfySll/d1V+KAF0QFpowYC4Neugrq8Yi9/tr XqOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht21-20020a170907609500b00770872942d8si923068ejc.958.2022.10.27.01.36.58; Thu, 27 Oct 2022 01:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235014AbiJ0IgP (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:15 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829226788136705?= X-GMAIL-MSGID: =?utf-8?q?1747829226788136705?= 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: 11650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106208wru; Thu, 27 Oct 2022 01:37:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4s+wAw4eho+6Ov8DXgTZfPgnmSba/9H8uwZqyhYS1HBzpLsUKoFuGrIrPiYtHC5Wfn+S6H X-Received: by 2002:a17:907:97d5:b0:7ac:5f72:6c1a with SMTP id js21-20020a17090797d500b007ac5f726c1amr11389522ejc.126.1666859845839; Thu, 27 Oct 2022 01:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859845; cv=none; d=google.com; s=arc-20160816; b=U4L9CxxZA6gD92nwG/qXjSHdb5uv5Uvj6yTRb2KYBnKNfjna1M07QKRcpT4ptPiwIV CaDda4XJTJl8rnPq6XMEHgaHysimb3PBBL6o9YlgRNqVb6Ro8uIeA/YBjCMpdX6tcXW9 KJQFKzJ74ZSTlPw4c6pW1SxqoyZOxeMwRlj1yT78LV4a5/ucoQDPxrviuh1CMZEN0X1g e+NDCdGljGzN/PeehpH9wMSzKidi5qqZkTOKyMTHqBVdEv+i7Zb2tgDDUCS2IYitA8FF aqryAhZkIS44H3Ov/3jVcSH0Mz3RuaSrgPPkcBgzksfKG7npfQrrSOgSYGj1OXoOgouK WUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9fsZU1r4e0FdmD7RDcb5+bGB+fyApezzma+OsR7XVLM=; b=fwQbu9BJoXBziiZQDlMAXy4bqlW84+Pgii/FfXQfIpF5leva2WuE9VmtfeXWEvdFDy hZ6AMoB/9NH2/TEoYgG16t1vOjeeiGpWtjT4wYzDCv/AIrs5WiGzoFu08EAbHGr2kt6P m6ZdZsKbgP2SziO7G3JA2ClaCLZuDjupwZoYSma6NDVkbHArtRtDRb38lBF6eahNksov V0KANcVhgOGfl9TD1B4TdHx5e9tCmt5PWIetuHPvhLANhmrSeNtINx7CEaVFAgdt73tq Il+kjzE2FySxW1Qjbq6XPa1Z4hbdaoEVCRQaHoqUcoGjZ2SpSYkDGPRKjZIKhuhnOQJ/ 6HcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a05640205cc00b0045d45f0e69asi1282124edx.561.2022.10.27.01.37.00; Thu, 27 Oct 2022 01:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235034AbiJ0IgT (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:19 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829229915302716?= X-GMAIL-MSGID: =?utf-8?q?1747829229915302716?= 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: 11652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106310wru; Thu, 27 Oct 2022 01:37:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ylzhSwMm74utG8rR74FMYkOmbdMBdIUfAG9xD38kHDKZ7TcmeFlRa1bTgw+62R2dNMpv+ X-Received: by 2002:aa7:d8c4:0:b0:461:8d31:41fc with SMTP id k4-20020aa7d8c4000000b004618d3141fcmr23594134eds.202.1666859861242; Thu, 27 Oct 2022 01:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859861; cv=none; d=google.com; s=arc-20160816; b=xUi1mRmY6dbsCKzX3HKtHFfhoOWj47DduXqc3WqfygKeipYbWVScj8ZVvwMFkaC0Ap ObBIP9PLla98oa4WpnrgNg6ecJb3OP8XJWMknHdPIF91yGGKnMos0yAGR79kEgDfOucy YXqaZYplDibizEdmUipiaL7SNm1gTIRC3YTpZWHPQ5SCAoxe3W+/o5u3IhjqmY3FisIN QFZuVgdAk5U3w09S6aEEbC+XmZyhZpIaHkPa4qutNOm0wqQsjZXVGre4ryd09VE2w3le JhKNqExkTFZbgsSc4c+VupG1UA4UsBAS40TBzO8uby1JzMmOlKo+NyT44Kxd3mHs8j7h q/IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VfCvOQCA892xMqBSLqHtoOX+m4m6SN/b/5JSGGrgMwU=; b=IgNl8JULaq33rtp5tlLnqhv3DPprZ+hEXMNHRYuRO38Cm4PbUA42QpbBFzdPyP+DG2 K9txOPOMFUm/j1gK0IM5Fl/lzmnGYbSzVTsk3AZnlW7l3YDbrkR9XGoO8zBMElAAyqeN zQUeuS43J2UUger2MW8Mkko32v//HbifkOnoc6uu2Kn6xggfZUdRoNzErqVd2cvHZ1aP llfcJJNZZZP6CEvJk3Fh1Z0dCmBaAv0DJNQGCNV2Vw9ppdKtDmWqRMN3yVVpZazARXC0 SYSFIPbMer+nfU93dlditmaPbrNcfuF7tmHhl6BsSQJlTqkwD/5XIjO0KGrtRQcZ+KRq DpZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js15-20020a17090797cf00b007ab34c9d9d3si1078321ejc.733.2022.10.27.01.37.14; Thu, 27 Oct 2022 01:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235045AbiJ0IgX (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:23 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829246107752482?= X-GMAIL-MSGID: =?utf-8?q?1747829246107752482?= 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: 11653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106621wru; Thu, 27 Oct 2022 01:38:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eTi/S5FTuFkbHlbgA/bK1DhHGfXx1iKSGhP8rmt4dHQ5JvBJ0/edJ5XK/RZ3MQfomtRXq X-Received: by 2002:a17:907:a067:b0:7a7:dc5e:eb2d with SMTP id ia7-20020a170907a06700b007a7dc5eeb2dmr18578787ejc.121.1666859926301; Thu, 27 Oct 2022 01:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859926; cv=none; d=google.com; s=arc-20160816; b=YxJruuV0e1kyiazWDlUh2ZeKI7dwzTFPh9uKE6H1dhl1REHTS4TN0RdsEM+SqTbKK2 nC6N/ZKWYMte72p/o131jhSC65hQsRj8e5HaDzGx1vnjUOlQXCUED0CvZZ0MrVTuZSfl 1psiBC5c4lLnHXXewQXjEpfOf8K5jTod+laxzFhSi/AKovE8xWWgLkqVp/huk5WUdtsF qI5d1mCNgYMoVZ6m8oIfsix5e5QZQr5tYf8kWpeZD9VWPNt0LdwcTS2IQr5gx33tevaz /hzEX6PPgZ2Gmf9rQ5rPdNysu7sOAL59sA7gOh6NFqsPUIQKbJOfhNz3xU0pKgCdPvBD nuGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WbCFfjHgTFuGd5kMSTBw1Wrc/0bK4a6afQsjYO+LIKg=; b=QM1vKL1LH954muGMpayF0plrtkLkVNCaFuZqgR7Cmj067qbQvCYKfCd9GYXDS5QuMP UgESfsGaAR+ELvnzm0uJrELUcHsf1VrArjyXpNNOlitcrnBvCz2Vi5kMtP7ggZmdAFhG iGmevB+ZfD8fFkz6Vslpny8LT+jNv1Oyy5pTVklas70m3olUfBmmsxBs1UH8TmIE64JO IABp46506W4IOdQPGa1bEFrVyAqWv3v73EUH95ezGYPzxbVYGs1tCxF9sLNjw7KPQBo1 IR6gJTURDtUSoGNIa/FDuwophkBMGIkZ9JwNGS/BoUcSZzTZ3ZEl2Ac4lCZHdRUPpS1y 2V7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a5099c8000000b0045d088f4b79si1036288edb.258.2022.10.27.01.38.22; Thu, 27 Oct 2022 01:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234768AbiJ0Ig6 (ORCPT + 99 others); Thu, 27 Oct 2022 04:36:58 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829314088814807?= X-GMAIL-MSGID: =?utf-8?q?1747829314088814807?= 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: 11654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp106625wru; Thu, 27 Oct 2022 01:38:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nPlNFE3NTa8TFEgBKH5CpwlVO2Xptlgsnz96f8Sk37XSO2mm/6UFO2CWQtmrG7/66b38P X-Received: by 2002:a17:907:6296:b0:787:d066:9fcf with SMTP id nd22-20020a170907629600b00787d0669fcfmr39179242ejc.692.1666859928156; Thu, 27 Oct 2022 01:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859928; cv=none; d=google.com; s=arc-20160816; b=o1yEMDcZw6CepF8WZStQ8TYLa+SdP/nNel8A4Un3moTuG3LxG5jeVIMzp4NquQ/8j2 DUE/X+v/Te7VjIlrs5A4CSTpazgKz0IaivHVDNnELGGj8GRuGCIkSjMv7ZWqxaEQIOso tdN7JFAs2LVPC9/RVJepnXV0bE69K1DaHzyXzmsgrMVzTkOn5tEhqiLB+Rae6D8KkPGG ebr71k282/omPlD/K1qR00W2RtRt4x6KHaKiYcsNJT6AzU0yW/QJ3Tb77Fmft0mOT93m m6jFsOmeZXFlYtG3+PLMM2wRm4I3BoCesHJK2Ec+dUXyPEXLUjpebwk8t7Mm6J5WpQkk olGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2H3aExUKeWM8owKKICGjqUVAiQ2uwPZya2tKlOpHbYI=; b=DI+hYD2frStmA+xJdcDTtP4zFjCOPXnMxbVFZIxzs2CI+4k2Z8r0ob0GwQHxARNYxP uQDbO/zr9oMUAb0YT/NX7fGT5caCL2wpNdnZ69BLA9JSzesBS0mFZnB1mMHZuWAdagu+ GSdCwTYdt+TOkb2rwQlRhJVmesVtkn0qS7wu5IDApXBjvKkk771ZiaSGcZ+rNPt/tSdX OxTC1gGaoUQZwYTOVgM1io6ckSjzqkXGuxa17adwzdkESpwh2nJ5Itb5QFB6D2+IgbN3 VO8aCDnwRlBinne7th2ZeH9yjHZwqo+2Dbs00JxLBVSCOENXLpX4+iy+vFsXqT+p8AF6 e/6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht8-20020a170907608800b007a072b8240csi829584ejc.927.2022.10.27.01.38.23; Thu, 27 Oct 2022 01:38:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235063AbiJ0IhB (ORCPT + 99 others); Thu, 27 Oct 2022 04:37:01 -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 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747829316270446849?= X-GMAIL-MSGID: =?utf-8?q?1747829316270446849?= 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 *);