Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5639609pxb; Thu, 20 Jan 2022 01:15:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjNlaPrMmiudGeVAFJTDj3J0PYXyzMGxsOuhPuUc9DYG7EfCwJg8YZRqiKgOjm1pLG9tnR X-Received: by 2002:a17:902:7209:b0:149:64f4:b8a1 with SMTP id ba9-20020a170902720900b0014964f4b8a1mr37520305plb.0.1642670152541; Thu, 20 Jan 2022 01:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642670152; cv=none; d=google.com; s=arc-20160816; b=jC9fKI9fvL+M4tgp+oAEAkmW+05FiZKelg6KW+J0gUlscn+oLZdIemmbRZNP7Wbilm mn3K9z/oe9FunuWiGjlAq5EnLRVXHacvpEewE83gYz63Mcm66etmmeBEKwk1mzDo6WGG idnXs8VZ8pHCYSrtgPztU4ci1N5jKP0ki/aEpMUxNVrFl7RMVJalgqlsdypa8PktS4qt x95kElqOpCNTfEbD7gm0dMGh67UB4BSOkPkjBoUwIDbCGgolNci9nYFUyJJJo3wP+Eta VeXMW9VmXQ/fCooz3tKZh5NsfHxtNcQLbu5ueZInKNgmzmw3PV+osKjsnZO9Mi1wATG5 ++Hg== 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=ehWHEBpcpdSJb+gqlpY/aP7DhaRTA3B+YkzVcQbfzw8=; b=vK4H/Bf9HUnIDw8vvKxFH+jVNgY+exmydaoiUKanBP9cVqHeYMDsv5IJUC+Xz5GCQC RbBtIhTkNiiyiD3jRLNt6OS11AwsTacouifFh2MZ0+EDHKqm9yIm6T1xM7QEa0qWv7Q9 Sv3TpzLTCUKHmDAKicHrWfTP3y9yjM3AzjPC2993oJBJfnVNrHktwvn0kLlA+u+axsIV je00usOM3oTz9PRquIZ1IN1A1uSTw9jLw6BZXppPk2UsRY/oLvRpTNty3yB/GTVx61zD 79lgPjrh3Nobwzup+U1VAH8+NEBcG3UHLmulZUJ4qU4hc8usXUjUhGnMM0Zi8IGf/rMp 0jZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si2706686pfj.335.2022.01.20.01.15.40; Thu, 20 Jan 2022 01:15:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242125AbiARNMc (ORCPT + 99 others); Tue, 18 Jan 2022 08:12:32 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:60715 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242036AbiARNMY (ORCPT ); Tue, 18 Jan 2022 08:12:24 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R481e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0V2C2avm_1642511537; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V2C2avm_1642511537) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Jan 2022 21:12:18 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/20] netfs: make @file optional in netfs_alloc_read_request() Date: Tue, 18 Jan 2022 21:11:57 +0800 Message-Id: <20220118131216.85338-2-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220118131216.85338-1-jefflexu@linux.alibaba.com> References: <20220118131216.85338-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the @file parameter optional, and derive inode from the @folio parameter instead in order to support file system internal requests. @file parameter can't be removed completely, since it also works as the private data of ops->init_rreq(). Signed-off-by: Jeffle Xu --- fs/netfs/read_helper.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index 8c58cff420ba..ca84918b6b5d 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -39,7 +39,7 @@ static void netfs_put_subrequest(struct netfs_read_subrequest *subreq, static struct netfs_read_request *netfs_alloc_read_request( const struct netfs_read_request_ops *ops, void *netfs_priv, - struct file *file) + struct inode *inode, struct file *file) { static atomic_t debug_ids; struct netfs_read_request *rreq; @@ -48,7 +48,7 @@ static struct netfs_read_request *netfs_alloc_read_request( if (rreq) { rreq->netfs_ops = ops; rreq->netfs_priv = netfs_priv; - rreq->inode = file_inode(file); + rreq->inode = inode; rreq->i_size = i_size_read(rreq->inode); rreq->debug_id = atomic_inc_return(&debug_ids); INIT_LIST_HEAD(&rreq->subrequests); @@ -870,6 +870,7 @@ void netfs_readahead(struct readahead_control *ractl, void *netfs_priv) { struct netfs_read_request *rreq; + struct inode *inode = file_inode(ractl->file); unsigned int debug_index = 0; int ret; @@ -878,7 +879,7 @@ void netfs_readahead(struct readahead_control *ractl, if (readahead_count(ractl) == 0) goto cleanup; - rreq = netfs_alloc_read_request(ops, netfs_priv, ractl->file); + rreq = netfs_alloc_read_request(ops, netfs_priv, inode, ractl->file); if (!rreq) goto cleanup; rreq->mapping = ractl->mapping; @@ -948,12 +949,13 @@ int netfs_readpage(struct file *file, void *netfs_priv) { struct netfs_read_request *rreq; + struct inode *inode = folio_file_mapping(folio)->host; unsigned int debug_index = 0; int ret; _enter("%lx", folio_index(folio)); - rreq = netfs_alloc_read_request(ops, netfs_priv, file); + rreq = netfs_alloc_read_request(ops, netfs_priv, inode, file); if (!rreq) { if (netfs_priv) ops->cleanup(folio_file_mapping(folio), netfs_priv); @@ -1122,7 +1124,7 @@ int netfs_write_begin(struct file *file, struct address_space *mapping, } ret = -ENOMEM; - rreq = netfs_alloc_read_request(ops, netfs_priv, file); + rreq = netfs_alloc_read_request(ops, netfs_priv, inode, file); if (!rreq) goto error; rreq->mapping = folio_file_mapping(folio); -- 2.27.0