From patchwork Fri Oct 21 08:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 6581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp574217wrr; Fri, 21 Oct 2022 01:58:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KiogzXfYKFQrhOCp0xbdmmoQKqSnJ+Ky3TqZjT6Imj1d1WrZ0++vGRY4edYl+X8+9D3/F X-Received: by 2002:a17:907:6d29:b0:78d:d12d:15af with SMTP id sa41-20020a1709076d2900b0078dd12d15afmr14614916ejc.53.1666342710811; Fri, 21 Oct 2022 01:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342710; cv=none; d=google.com; s=arc-20160816; b=D2+POgrskG2nBID9y7gTpwTFidgOUmyKzn5f1aEBq6+yE9o5QXjQOzKA6qK3rtWCz0 sokGOspd+QWRWk6bgH0GwVbqGeTl7Qi6kWhS8p7yejxrDb9G0XIUUnNX7TrfSDVpUDZL 2MJWRc7v+A6sR294JUwJ7oZdKpJSeaP76tvg/aiASmc+QXSlIM6/9nir5OLC2HZjQXWW 8j+8Rg8OKI209wyfE6g5ukd2REqIKt+2IqZgHoWL4ZbDAPE/j7JaMVtVuj2d6IL6F5uE 9WiEcvdk1xFqKEusPpTnwbHvorfa220s62sSvKJI3vJ9hyI7rDaJAu9GcQNrOdUTAZmM VE0g== 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=TTV7fZMSgYAeQwWr6Y2ml6KK/nZql6QZDtzjjblaJ6I=; b=huroRr7ad4b/L2ztu7rNL4S4qu1RyqhrpPmnN+009xP8LwT9p9uQ/f/7jLbiGI/KSD 0exqGRje3n+7wOidEevWdNKpKtNhS8HrvvvCNqFj4J1yOwWZH99jh1lja8tdnqmQYkCa pfFG8mGCiO4c52ggl587GHv+bl3YKQsyb6u7PDXiym3mex5Vb04hwznOuLGKfrVE1em0 sBZvhnvYWnqPL07DnmNvFRnvwE6RvmXuXpDWBkca5gNKzouEc0i0z5mcjiz12urNuT63 odrHXIjBDmFNgyqOEC9KB1LnLpMIioVJoYCKI3ys8kZ0ERUJY2PAnqqJ2+kl1/pCfpC2 46Dg== 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 qf38-20020a1709077f2600b007823754ecd5si21184693ejc.43.2022.10.21.01.58.06; Fri, 21 Oct 2022 01:58:30 -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 S229849AbiJUIuI (ORCPT + 99 others); Fri, 21 Oct 2022 04:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiJUIuD (ORCPT ); Fri, 21 Oct 2022 04:50:03 -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 4C39C13D49; Fri, 21 Oct 2022 01:49:49 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R291e4;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=7;SR=0;TI=SMTPD_---0VSioR4e_1666342153; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VSioR4e_1666342153) by smtp.aliyun-inc.com; Fri, 21 Oct 2022 16:49:14 +0800 From: Jingbo Xu To: dhowells@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: jlayton@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 1/2] netfs: export helpers for request and subrequest Date: Fri, 21 Oct 2022 16:49:11 +0800 Message-Id: <20221021084912.61468-2-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221021084912.61468-1-jefflexu@linux.alibaba.com> References: <20221021084912.61468-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?1747286974815844005?= X-GMAIL-MSGID: =?utf-8?q?1747286974815844005?= Export netfs_put_subrequest() and netfs_rreq_completed(). Signed-off-by: Jingbo Xu Reviewed-by: Gao Xiang --- fs/netfs/io.c | 3 ++- fs/netfs/objects.c | 1 + include/linux/netfs.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 428925899282..58dd56e3e780 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -94,12 +94,13 @@ static void netfs_read_from_server(struct netfs_io_request *rreq, /* * Release those waiting. */ -static void netfs_rreq_completed(struct netfs_io_request *rreq, bool was_async) +void netfs_rreq_completed(struct netfs_io_request *rreq, bool was_async) { trace_netfs_rreq(rreq, netfs_rreq_trace_done); netfs_clear_subrequests(rreq, was_async); netfs_put_request(rreq, was_async, netfs_rreq_trace_put_complete); } +EXPORT_SYMBOL(netfs_rreq_completed); /* * Deal with the completion of writing the data to the cache. We have to clear diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index e17cdf53f6a7..478cc1a1664c 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -158,3 +158,4 @@ void netfs_put_subrequest(struct netfs_io_subrequest *subreq, bool was_async, if (dead) netfs_free_subrequest(subreq, was_async); } +EXPORT_SYMBOL(netfs_put_subrequest); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index f2402ddeafbf..d519fb709d7f 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -282,6 +282,8 @@ int netfs_write_begin(struct netfs_inode *, struct file *, struct address_space *, loff_t pos, unsigned int len, struct folio **, void **fsdata); +void netfs_rreq_completed(struct netfs_io_request *rreq, bool was_async); + void netfs_subreq_terminated(struct netfs_io_subrequest *, ssize_t, bool); void netfs_get_subrequest(struct netfs_io_subrequest *subreq, enum netfs_sreq_ref_trace what); From patchwork Fri Oct 21 08:49:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 6582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp574369wrr; Fri, 21 Oct 2022 01:58:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fX1D5MB2lNo9hSYCIJ0zFe+EHG2V3F96MmKsR+QtceMwMhfm/mF1c2LPKAlvPQOYkSowo X-Received: by 2002:a17:902:ef4d:b0:181:98d1:69c0 with SMTP id e13-20020a170902ef4d00b0018198d169c0mr18756117plx.45.1666342734282; Fri, 21 Oct 2022 01:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666342734; cv=none; d=google.com; s=arc-20160816; b=otMj1hMXCeZMsnL/f1RyEY6g1hDwgXAaUjtDX6QNFe9EFAD1Tw8TjUZ+uvpmuLphT+ 4l0bdMH/YmbYKZTj8wYD+c0uolRPzCoL6PWt9C0nx9Ly/ex120yQF9t4/2T31GtctoYm inCeArXf0dmNrKauPw+/A1Kk7GbhstcDfzw9Jn/R9hAU1iBFIAO2CiC7XHwM98d4YkEW HO3E1at+6TzIW3VTaELTCmIzuNXMMxYG2KO3IPMKbhA2URmeHk65g7Fdq0es7WX9syY5 LXS0MdjMn16lYyq0+RtgsMe6jKiFR9+h10ckQILoESKBORHCr+kC6JyBEmKneiIBUZyG Z2cg== 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=lcucQ8y79HRVSr1y0l5qwGEZusOCL/u0Z04trO+/YvY=; b=c/QDZH4xMKHloYGoufWfy3ut7581TFbV8OL74e88umzBpy0PZyut8gtxyVcUiFrSyu /MOdrAg5yYuapYv+/Tru/e/A2RR3LeWKI6cMwuhOJ2d+HDCH8jXyQwiG8T06aLbjNN1R +Jz6ytUigIoJL/tWDWQ+ZSe6h5s4JggUs2OsCFfxMUC/8xL4qvWzMro64CaxPX5lFZ5E cFnlr+gOsKfe9NavHCYx5lMmWmajkDPkWIcv6+JDWSWw9+NHRlkXKXhBfjB7jOb6P1Am 8MZ/GiNuDw8FcrG9Lboz7dMFMFWwpStBCvfGIvI7IPu8y3oBXdGz0ZgrpSrJxpe16B9/ k1Fg== 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 m22-20020a056a00081600b00557eeeb099csi25581114pfk.339.2022.10.21.01.58.40; Fri, 21 Oct 2022 01:58:54 -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 S230175AbiJUIuS (ORCPT + 99 others); Fri, 21 Oct 2022 04:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbiJUIuF (ORCPT ); Fri, 21 Oct 2022 04:50:05 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7F624FEE8; Fri, 21 Oct 2022 01:49:50 -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=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VSikm2i_1666342154; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VSikm2i_1666342154) by smtp.aliyun-inc.com; Fri, 21 Oct 2022 16:49:16 +0800 From: Jingbo Xu To: dhowells@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: jlayton@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/2] erofs: use netfs helpers manipulating request and subrequest Date: Fri, 21 Oct 2022 16:49:12 +0800 Message-Id: <20221021084912.61468-3-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20221021084912.61468-1-jefflexu@linux.alibaba.com> References: <20221021084912.61468-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?1747286998725639515?= X-GMAIL-MSGID: =?utf-8?q?1747286998725639515?= Use netfs_put_subrequest() and netfs_rreq_completed() completing request and subrequest. It is worth noting that a noop netfs_request_ops is introduced for erofs since some netfs routine, e.g. netfs_free_request(), will call into this ops. Signed-off-by: Jingbo Xu Reviewed-by: Gao Xiang --- fs/erofs/fscache.c | 47 ++++++++++------------------------------------ 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index fe05bc51f9f2..fa3f4ab5e3b6 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); @@ -11,6 +12,8 @@ static DEFINE_MUTEX(erofs_domain_cookies_lock); static LIST_HEAD(erofs_domain_list); static struct vfsmount *erofs_pseudo_mnt; +static const struct netfs_request_ops erofs_noop_req_ops; + static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space *mapping, loff_t start, size_t len) { @@ -24,40 +27,12 @@ static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space rreq->len = len; rreq->mapping = mapping; rreq->inode = mapping->host; + rreq->netfs_ops = &erofs_noop_req_ops; INIT_LIST_HEAD(&rreq->subrequests); refcount_set(&rreq->ref, 1); return rreq; } -static void erofs_fscache_put_request(struct netfs_io_request *rreq) -{ - if (!refcount_dec_and_test(&rreq->ref)) - return; - if (rreq->cache_resources.ops) - rreq->cache_resources.ops->end_operation(&rreq->cache_resources); - kfree(rreq); -} - -static void erofs_fscache_put_subrequest(struct netfs_io_subrequest *subreq) -{ - if (!refcount_dec_and_test(&subreq->ref)) - return; - erofs_fscache_put_request(subreq->rreq); - kfree(subreq); -} - -static void erofs_fscache_clear_subrequests(struct netfs_io_request *rreq) -{ - struct netfs_io_subrequest *subreq; - - while (!list_empty(&rreq->subrequests)) { - subreq = list_first_entry(&rreq->subrequests, - struct netfs_io_subrequest, rreq_link); - list_del(&subreq->rreq_link); - erofs_fscache_put_subrequest(subreq); - } -} - static void erofs_fscache_rreq_unlock_folios(struct netfs_io_request *rreq) { struct netfs_io_subrequest *subreq; @@ -114,11 +89,10 @@ static void erofs_fscache_rreq_unlock_folios(struct netfs_io_request *rreq) static void erofs_fscache_rreq_complete(struct netfs_io_request *rreq) { erofs_fscache_rreq_unlock_folios(rreq); - erofs_fscache_clear_subrequests(rreq); - erofs_fscache_put_request(rreq); + netfs_rreq_completed(rreq, false); } -static void erofc_fscache_subreq_complete(void *priv, +static void erofs_fscache_subreq_complete(void *priv, ssize_t transferred_or_error, bool was_async) { struct netfs_io_subrequest *subreq = priv; @@ -130,7 +104,7 @@ static void erofc_fscache_subreq_complete(void *priv, if (atomic_dec_and_test(&rreq->nr_outstanding)) erofs_fscache_rreq_complete(rreq); - erofs_fscache_put_subrequest(subreq); + netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_terminated); } /* @@ -171,9 +145,8 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, } subreq->start = pstart + done; - subreq->len = len - done; + subreq->len = len - done; subreq->flags = 1 << NETFS_SREQ_ONDEMAND; - list_add_tail(&subreq->rreq_link, &rreq->subrequests); source = cres->ops->prepare_read(subreq, LLONG_MAX); @@ -184,7 +157,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, source); ret = -EIO; subreq->error = ret; - erofs_fscache_put_subrequest(subreq); + netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_failed); goto out; } @@ -195,7 +168,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie, ret = fscache_read(cres, subreq->start, &iter, NETFS_READ_HOLE_FAIL, - erofc_fscache_subreq_complete, subreq); + erofs_fscache_subreq_complete, subreq); if (ret == -EIOCBQUEUED) ret = 0; if (ret) {