From patchwork Sat Feb 18 00:33:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 58867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp149917wrn; Fri, 17 Feb 2023 16:55:08 -0800 (PST) X-Google-Smtp-Source: AK7set/5GT9JmWdt4wPkzR9BXr/EISupygtzwot4cqyKgaZNNmD9NZCPAFBYMvb1rsPgyDWV1jrW X-Received: by 2002:a62:7b4b:0:b0:5a9:b910:6d98 with SMTP id w72-20020a627b4b000000b005a9b9106d98mr4904394pfc.13.1676681707574; Fri, 17 Feb 2023 16:55:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681707; cv=none; d=google.com; s=arc-20160816; b=WzEEQzySoWudl0qugCszsDcfqoxj7bdmPvKjq1oof1gMEnqbMgZabewyTI+HvwJ1b3 d/7JbT9Cy1hb/5QCZZhvrtrrl12RY/XlJdPvw80o1NO/Ayst2/AEZffCcr82x7F1xR1d uufuRLuIdhLoK1LmcmtYUL6ckcbf+KF8PNREyfc22xv8XuPJyHpCRoGRYTt/Bo4i2iGN Hf5jsFzpckxEZghtOA5LHvX8msi2Kdc4aG8kR21LnCCosFMWMiCUYKXYeNXgQ0nQwxfw eC0SYc9SjkDwGEIAJCX6szz153Ig1WMgDP8zWpzz+JEZVW3fMBwpiw6SziltZtru7KGU ZoYw== 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 :dkim-signature; bh=X0V/KawfFNJl1zGVWDEhGCN7DsNC3uc1c6XDDWJfx1M=; b=ItI1l9FP0Z7s4D7YRMjeDQk8nNZ/UhlFjjYmU8h4LAgc3f+o/PjevS5i5rqN8UkaCO /w6q2IJBD/jNvec7AsCQsxhLH42pf2a7wiqGzUTTI2BAAoUECryec+FLUNVNLtRT02Of S+JTRczpGpZwlnad0If5Tmx+VxBQK5AQ6Tv5mASsJquVPvD7JfUb8RrKZylFqRB2K6Ze CFPKzg6YXG0QdG9RQyohtWDFfqDSiQOlOEevaGcEBH6Ss9Stc6udDSgQTu4gRVHuO/PN KLEldtQI0NLYC9B61fKmky7YascS/N8zN+JMFfnY08yEwruDBpE9DPAwDa3NcXf+E4Hk 9piQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P0fOYxs8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a056a001a1600b00593af3fcbe5si6741691pfv.223.2023.02.17.16.54.42; Fri, 17 Feb 2023 16:55:07 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P0fOYxs8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjBRAtJ (ORCPT + 99 others); Fri, 17 Feb 2023 19:49:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjBRAtE (ORCPT ); Fri, 17 Feb 2023 19:49:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2233B86F; Fri, 17 Feb 2023 16:48:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 57792B82ED4; Sat, 18 Feb 2023 00:33:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2510FC4339B; Sat, 18 Feb 2023 00:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680435; bh=SK5Jy+6rCKveBD5nbCJDN3evu772cvxZ/alFpEsNfhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0fOYxs8c6GQ3wDUi9RThrIWsEWcmhutUXhMt2Bp7pkuvCF4YW1cbSIfmtu1xMyZQ ZbVmW6/+yg7AWH54gZXk/Yh/LdUllzhhH4A3589o/MgFuG7kGSvu90qLZRIuX1W7o9 0ws7j+OIQ+zGthBGMrTewYG7dq662bt4yhnoCRgmcZb0TDTwUYsNvcoAv5CM5wbH6X RM2OH7MBZfuUYqfjJJc6H1DTzOkDBnHLBtRfFq14vBzInZGann7vrvml+nlSy5T98Y WxGzBCcu6L+3nZoFGhnF+HRywhz71AdlIQk/yzcbiOWmX5aXGmuOnDkLaohVfv5V0B aM9CEe1HOhuUw== From: Eric Van Hensbergen To: v9fs-developer@lists.sourceforge.net, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux_oss@crudebyte.com, Eric Van Hensbergen Subject: [PATCH v4 02/11] fs/9p: Expand setup of writeback cache to all levels Date: Sat, 18 Feb 2023 00:33:14 +0000 Message-Id: <20230218003323.2322580-3-ericvh@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230218003323.2322580-1-ericvh@kernel.org> References: <20230124023834.106339-1-ericvh@kernel.org> <20230218003323.2322580-1-ericvh@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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?1758128198491205966?= X-GMAIL-MSGID: =?utf-8?q?1758128198491205966?= If cache is enabled, make sure we are putting the right things in place (mainly impacts mmap). This also sets us up for more cache levels. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- fs/9p/v9fs.c | 2 +- fs/9p/vfs_addr.c | 2 -- fs/9p/vfs_file.c | 7 ++++--- fs/9p/vfs_inode.c | 3 +-- fs/9p/vfs_inode_dotl.c | 7 ++++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 3a9c4517265f..61a51b90600d 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -468,7 +468,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, #ifdef CONFIG_9P_FSCACHE /* register the session for caching */ - if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { + if (v9ses->cache == CACHE_FSCACHE) { rc = v9fs_cache_session_get_cookie(v9ses, dev_name); if (rc < 0) goto err_clnt; diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 97599edbc300..6f46d7e4c750 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c @@ -279,8 +279,6 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping, p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); - BUG_ON(!v9inode->writeback_fid); - /* Prefetch area to be written into the cache if we're caching this * file. We need to do this before we get a lock on the page in case * there's more than one writer competing for the same cache block. diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index b740017634ef..3b6458846a0b 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -73,8 +73,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) } mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && - !v9inode->writeback_fid && + if ((v9ses->cache) && !v9inode->writeback_fid && ((file->f_flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -92,9 +91,11 @@ int v9fs_file_open(struct inode *inode, struct file *file) v9inode->writeback_fid = (void *) writeback_fid; } mutex_unlock(&v9inode->v_mutex); - if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) +#ifdef CONFIG_9P_FSCACHE + if (v9ses->cache == CACHE_FSCACHE) fscache_use_cookie(v9fs_inode_cookie(v9inode), file->f_mode & FMODE_WRITE); +#endif v9fs_open_fid_add(inode, &fid); return 0; out_error: diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 27a04a226d97..33e521c60e2c 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -843,8 +843,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, inode = d_inode(dentry); v9inode = V9FS_I(inode); mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && - !v9inode->writeback_fid && + if ((v9ses->cache) && !v9inode->writeback_fid && ((flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index f806b3f11649..bff37a312e64 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -316,8 +316,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, v9inode = V9FS_I(inode); mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && - !v9inode->writeback_fid && + if ((v9ses->cache) && !v9inode->writeback_fid && ((flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -340,9 +339,11 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, if (err) goto out; file->private_data = ofid; - if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) +#ifdef CONFIG_9P_FSCACHE + if (v9ses->cache == CACHE_FSCACHE) fscache_use_cookie(v9fs_inode_cookie(v9inode), file->f_mode & FMODE_WRITE); +#endif v9fs_open_fid_add(inode, &ofid); file->f_mode |= FMODE_CREATED; out: