From patchwork Sat Feb 18 00:33:13 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: 58865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp149052wrn; Fri, 17 Feb 2023 16:51:54 -0800 (PST) X-Google-Smtp-Source: AK7set/GQigHMn9dVyFX96FXeZmALwPa9i4Zd9Gvt2d4Ej2uhbR60lfZW+9CzDnql+9LWFYGEby5 X-Received: by 2002:a62:1cc8:0:b0:5a9:c682:f489 with SMTP id c191-20020a621cc8000000b005a9c682f489mr5086868pfc.3.1676681513972; Fri, 17 Feb 2023 16:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681513; cv=none; d=google.com; s=arc-20160816; b=eAMMv4URNqzoEnUnULVHRbOKUUe6lH4XrfLnD5dmLm1XvT57PrkLvhWbWD64L8hC1o f9mi/gJY2QCH46m2Fh5eqf+lI2clnTxk8f2F5ShH2VdghGNDv01XxNDQN1woJIyBpQXi dCzqTrAgUdGFrZ9/G8ewuZsypstd+wcDG1yYhZSylJMLtUZJMHzZr+QVWUWZRKEUUkAn dz2Ya7LX+Of/VkLWmBzlad5Bzrg2I3t+y3evCbdhM1a1maZ0FkEophWsFXPRfb9+duXh hQeWKLE155zMMqck0HdnwYaOPB+oWUSI8/GAGdFuNqTOLjD6Lgze9ZvrB8s7FSyAy3JG +roQ== 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=Fw9lpMcRlQ98cMWAJ6yr69bVmkSt3U+zp7vHa9aUgRs=; b=wYBCbAM3q5iuWMxfX9oCY8bHxvKvBjSAQ7erXm4ZXiKwlKIJnuXSfm9CKupNkSqfjm 5ufc3vnUE6CkRh3us3CpoJBHT7c+bkY0y7zbGlolyI1q7rAPcL5vZNDhoAC+oVWhWHRh dQ4sg3RvZ9SCj1P/a3nSa+0wAoEIHFG3K91a+xhpYqWwCYAILAenDtaw6KY93zcRJlnH 9H9psUplQ1qqsLBMS6eJPRXVfQ+sepGRK9mHhc5KPeEZebRKbhRaPKeXE60Ab2BwCfXM waQlXhVXncykIwWanqhkwBsgg8UVQIpAoKEvawPNVppjygX+cG/NWJWt7mShUw7NA/mZ zQvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uoiSvOjV; 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 195-20020a6302cc000000b004fc235bd318si5028763pgc.669.2023.02.17.16.51.41; Fri, 17 Feb 2023 16:51:53 -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=uoiSvOjV; 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 S229709AbjBRAs7 (ORCPT + 99 others); Fri, 17 Feb 2023 19:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjBRAs4 (ORCPT ); Fri, 17 Feb 2023 19:48:56 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DFF53EC8; Fri, 17 Feb 2023 16:48:30 -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 sin.source.kernel.org (Postfix) with ESMTPS id 99FFFCE2D11; Sat, 18 Feb 2023 00:33:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17A3FC433EF; Sat, 18 Feb 2023 00:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680434; bh=PwWjKgBCrFlHwrWRE5cwXvsrY7AklcLgKZPzMWv8M98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoiSvOjVFdldq06YEWUWJ5d6yYyCFmNKfK/nQJ1caAuYFBSe7ItFqXHlKS9KpiDJb MSsdsh4qjW9ARIQiNRph5Oo4iG0l1JDWo7qyb67VWywhZy7Dywf1a7xANo3+otCeum GJ9XzUoh9k+IeI7+mGixH2//iLtq8jT8swpMNuKcsuSABU0n7xrejOOIThxQV3L8iI MSdh9sPUNQS7hNH8DRYKMfA+gocsbqWcCxOCX5k/OPtHxLqSW3D4lpZgHvTTDFNx08 tqSwZFSqXIshydzqltmUOmhWXj+UD5dqeCchUFrIMIE3GNcsjsq41AlA5uz+B1MiwH FuDUdno65CPvg== 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 01/11] net/9p: Adjust maximum MSIZE to account for p9 header Date: Sat, 18 Feb 2023 00:33:13 +0000 Message-Id: <20230218003323.2322580-2-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?1758127994939256517?= X-GMAIL-MSGID: =?utf-8?q?1758127994939256517?= Add maximum p9 header size to MSIZE to make sure we can have page aligned data. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- net/9p/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/9p/client.c b/net/9p/client.c index 622ec6a586ee..6c2a768a6ab1 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -28,7 +28,11 @@ #define CREATE_TRACE_POINTS #include -#define DEFAULT_MSIZE (128 * 1024) +/* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ + + * room for write (16 extra) or read (11 extra) operands. + */ + +#define DEFAULT_MSIZE ((128 * 1024) + P9_IOHDRSZ) /* Client Option Parsing (code inspired by NFS code) * - a little lazy - parse all client options 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: From patchwork Sat Feb 18 00:33:15 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: 58859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148402wrn; Fri, 17 Feb 2023 16:49:26 -0800 (PST) X-Google-Smtp-Source: AK7set+R2XmcD2woVR9WiU7GAFt8hL+QtAtm/8dmRBazmCP9jumwl2RTqKoVptbGHULc8up9WofS X-Received: by 2002:a05:6a20:9888:b0:c7:5b1a:8ff0 with SMTP id jk8-20020a056a20988800b000c75b1a8ff0mr4692840pzb.44.1676681366459; Fri, 17 Feb 2023 16:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681366; cv=none; d=google.com; s=arc-20160816; b=pK4wHO6JXhbCJWju2i1xuXb2/SSn9rONkU/kCbfP2AFivwHfwMOrkx/VeceWbbmP5a tXo411QbFWAS3phrKJ7rxNPBylyN/AKjvabBBtcqmLlSBCFrAN4Mt49AQW2dSt5c6QXl uAxh9uAe1txl1o1AZ98pvJmERmMLBQlrJKFT7fGOKqkT6T3/eTP9mfmm4B9mS63WwKZM kFhCrBsqe1IKK1jpwkA4ynxKXyXu42viRDHKb23RO6Dz8SzyJnls9gCi/k+yOuvfOfIm QyYEggUZIancGWbUiYP01BNBCgjwiEbqfKseGHvQTiJnOydO92w3NvW5stCZN2tZNwUj XsmA== 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=hhyxN4bri7sizYFrMj1P5UH7mWEqWgsKr0WV9fagKm8=; b=uZsCGf+X+0L43Os8IMTsfjmyoSQNAzw71LrCIdSbHNUvy5LQKCtY0n1d6mKaGxAk4v 75mR3VLqHvdWyiERNUugaYYbGbX5zF4p/SsOELzbAeNyR6UZtoVnGrJ7LM6/9ucLy4pG WvunLB1X7jQ81kdQ25i8sFoKwYNpFpEjwqeaQPlV8tKfYWZt3DbrvYzP4iOtes2Z3oGS 9kGVbwrtq8tGWM4D1xUHb28EB8tRPDJ12hul4s1DafgdbNEB7LphSWbhqQjKwLpCR0VI +yKVIfvkG/ji81JEYowcYzsaJghY7XIeIv8OqMpVdanJIxjoXpZo6obofB1THtwmY9Th wzaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uLQAga7q; 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 y186-20020a638ac3000000b004fd1ec2bf42si3615693pgd.567.2023.02.17.16.49.14; Fri, 17 Feb 2023 16:49:26 -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=uLQAga7q; 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 S230039AbjBRAoN (ORCPT + 99 others); Fri, 17 Feb 2023 19:44:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbjBRAoL (ORCPT ); Fri, 17 Feb 2023 19:44:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69C012F2C; Fri, 17 Feb 2023 16:43:33 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 925BA620A2; Sat, 18 Feb 2023 00:33:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3027CC4339E; Sat, 18 Feb 2023 00:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680437; bh=mymNDkevMQYIG0EuJKwW+vW2nl/JDaGZIYQfwskVSfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uLQAga7q/Yf63DHmXWtGMAdDbmgyinqRuLR5Cd4JwVopda5N651oAOiuuFjWrePhF Hu31gqYKiKFt11Dz/jceTkCER1qHjNY4tcKY9WgNG4hDVsLxmJTG0kdunfReq5itkq NAMdyp64Ry9U2e3Armd8itTU7D9YNaQmm8lEkvlCswRXwvfoHoD6ZjQwc5w7+3FB9T yOpvYyHwcgjjH2A7nywMpHok7NXN/bNl9RIRBbCajXBWsIIqY8yENgfl9kp4F6NVfm caX5mh1zBdlGRpLon08U5Nt8fodGzMWF9uVCuJRxMf7LXTFFzWKzCYMUBaSzVOSkO/ 8BPrVqMfdBtlA== 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 03/11] fs/9p: Consolidate file operations and add readahead and writeback Date: Sat, 18 Feb 2023 00:33:15 +0000 Message-Id: <20230218003323.2322580-4-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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1758127840330247865?= X-GMAIL-MSGID: =?utf-8?q?1758127840330247865?= We had 3 different sets of file operations across 2 different protocol variants differentiated by cache which really only changed 3 functions. But the real problem is that certain file modes, mount options, and other factors weren't being considered when we decided whether or not to use caches. This consolidates all the operations and switches to conditionals within a common set to decide whether or not to do different aspects of caching. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- fs/9p/v9fs.c | 30 ++++------ fs/9p/v9fs.h | 3 + fs/9p/v9fs_vfs.h | 4 -- fs/9p/vfs_dir.c | 3 + fs/9p/vfs_file.c | 131 +++++++---------------------------------- fs/9p/vfs_inode.c | 62 ++++++++++++------- fs/9p/vfs_inode_dotl.c | 22 +++++-- 7 files changed, 98 insertions(+), 157 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 61a51b90600d..a46bf9121f11 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -39,8 +39,6 @@ enum { Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ Opt_nodevmap, - /* Cache options */ - Opt_cache_loose, Opt_fscache, Opt_mmap, /* Access options */ Opt_access, Opt_posixacl, /* Lock timeout option */ @@ -58,9 +56,6 @@ static const match_table_t tokens = { {Opt_remotename, "aname=%s"}, {Opt_nodevmap, "nodevmap"}, {Opt_cache, "cache=%s"}, - {Opt_cache_loose, "loose"}, - {Opt_fscache, "fscache"}, - {Opt_mmap, "mmap"}, {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, {Opt_posixacl, "posixacl"}, @@ -69,10 +64,12 @@ static const match_table_t tokens = { }; static const char *const v9fs_cache_modes[nr__p9_cache_modes] = { - [CACHE_NONE] = "none", - [CACHE_MMAP] = "mmap", - [CACHE_LOOSE] = "loose", - [CACHE_FSCACHE] = "fscache", + [CACHE_NONE] = "none", + [CACHE_READAHEAD] = "readahead", + [CACHE_WRITEBACK] = "writeback", + [CACHE_MMAP] = "mmap", + [CACHE_LOOSE] = "loose", + [CACHE_FSCACHE] = "fscache", }; /* Interpret mount options for cache mode */ @@ -89,6 +86,12 @@ static int get_cache_mode(char *s) } else if (!strcmp(s, "mmap")) { version = CACHE_MMAP; p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n"); + } else if (!strcmp(s, "writeback")) { + version = CACHE_WRITEBACK; + p9_debug(P9_DEBUG_9P, "Cache mode: writeback\n"); + } else if (!strcmp(s, "readahead")) { + version = CACHE_READAHEAD; + p9_debug(P9_DEBUG_9P, "Cache mode: readahead\n"); } else if (!strcmp(s, "none")) { version = CACHE_NONE; p9_debug(P9_DEBUG_9P, "Cache mode: none\n"); @@ -266,15 +269,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) case Opt_nodevmap: v9ses->nodev = 1; break; - case Opt_cache_loose: - v9ses->cache = CACHE_LOOSE; - break; - case Opt_fscache: - v9ses->cache = CACHE_FSCACHE; - break; - case Opt_mmap: - v9ses->cache = CACHE_MMAP; - break; case Opt_cachetag: #ifdef CONFIG_9P_FSCACHE kfree(v9ses->cachetag); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 6acabc2e7dc9..517b2201ad24 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -51,6 +51,8 @@ enum p9_session_flags { enum p9_cache_modes { CACHE_NONE, CACHE_MMAP, + CACHE_READAHEAD, + CACHE_WRITEBACK, CACHE_LOOSE, CACHE_FSCACHE, nr__p9_cache_modes @@ -155,6 +157,7 @@ extern int v9fs_vfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); +extern int v9fs_flush_inode_writeback(struct inode *inode); extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, struct super_block *sb, int new); diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index bc417da7e9c1..cce87c9bdd8b 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -36,10 +36,6 @@ extern const struct file_operations v9fs_dir_operations; extern const struct file_operations v9fs_dir_operations_dotl; extern const struct dentry_operations v9fs_dentry_operations; extern const struct dentry_operations v9fs_cached_dentry_operations; -extern const struct file_operations v9fs_cached_file_operations; -extern const struct file_operations v9fs_cached_file_operations_dotl; -extern const struct file_operations v9fs_mmap_file_operations; -extern const struct file_operations v9fs_mmap_file_operations_dotl; extern struct kmem_cache *v9fs_inode_cache; struct inode *v9fs_alloc_inode(struct super_block *sb); diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 59b0e8948f78..bd31593437f3 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -214,6 +214,9 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n", inode, filp, fid ? fid->fid : -1); if (fid) { + if ((fid->qid.type == P9_QTFILE) && (filp->f_mode & FMODE_WRITE)) + v9fs_flush_inode_writeback(inode); + spin_lock(&inode->i_lock); hlist_del(&fid->ilist); spin_unlock(&inode->i_lock); diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 3b6458846a0b..20e4bd299fc2 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -28,7 +28,6 @@ #include "fid.h" #include "cache.h" -static const struct vm_operations_struct v9fs_file_vm_ops; static const struct vm_operations_struct v9fs_mmap_file_vm_ops; /** @@ -73,7 +72,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) } mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache) && !v9inode->writeback_fid && + if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && ((file->f_flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -367,10 +366,15 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct p9_fid *fid = iocb->ki_filp->private_data; int ret, err = 0; + struct inode *inode = file_inode(iocb->ki_filp); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", iov_iter_count(to), iocb->ki_pos); + if (v9ses->cache > CACHE_MMAP) + return generic_file_read_iter(iocb, to); + if (iocb->ki_filp->f_flags & O_NONBLOCK) ret = p9_client_read_once(fid, iocb->ki_pos, to, &err); else @@ -395,6 +399,11 @@ v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ssize_t retval; loff_t origin; int err = 0; + struct inode *inode = file_inode(iocb->ki_filp); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); + + if (v9ses->cache >= CACHE_WRITEBACK) + return generic_file_write_iter(iocb, from); retval = generic_write_checks(iocb, from); if (retval <= 0) @@ -477,25 +486,16 @@ static int v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) { int retval; - - - retval = generic_file_mmap(filp, vma); - if (!retval) - vma->vm_ops = &v9fs_file_vm_ops; - - return retval; -} - -static int -v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma) -{ - int retval; - struct inode *inode; - struct v9fs_inode *v9inode; + struct inode *inode = file_inode(filp); + struct v9fs_inode *v9inode = V9FS_I(inode); + struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); struct p9_fid *fid; - inode = file_inode(filp); - v9inode = V9FS_I(inode); + if (v9ses->cache < CACHE_MMAP) { + invalidate_inode_pages2(filp->f_mapping); + return generic_file_readonly_mmap(filp, vma); + } + mutex_lock(&v9inode->v_mutex); if (!v9inode->writeback_fid && (vma->vm_flags & VM_SHARED) && @@ -563,35 +563,6 @@ v9fs_vm_page_mkwrite(struct vm_fault *vmf) return VM_FAULT_NOPAGE; } -/** - * v9fs_mmap_file_read_iter - read from a file - * @iocb: The operation parameters - * @to: The buffer to read into - * - */ -static ssize_t -v9fs_mmap_file_read_iter(struct kiocb *iocb, struct iov_iter *to) -{ - /* TODO: Check if there are dirty pages */ - return v9fs_file_read_iter(iocb, to); -} - -/** - * v9fs_mmap_file_write_iter - write to a file - * @iocb: The operation parameters - * @from: The data to write - * - */ -static ssize_t -v9fs_mmap_file_write_iter(struct kiocb *iocb, struct iov_iter *from) -{ - /* - * TODO: invalidate mmaps on filp's inode between - * offset and offset+count - */ - return v9fs_file_write_iter(iocb, from); -} - static void v9fs_mmap_vm_close(struct vm_area_struct *vma) { struct inode *inode; @@ -614,13 +585,6 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma) filemap_fdatawrite_wbc(inode->i_mapping, &wbc); } - -static const struct vm_operations_struct v9fs_file_vm_ops = { - .fault = filemap_fault, - .map_pages = filemap_map_pages, - .page_mkwrite = v9fs_vm_page_mkwrite, -}; - static const struct vm_operations_struct v9fs_mmap_file_vm_ops = { .close = v9fs_mmap_vm_close, .fault = filemap_fault, @@ -628,34 +592,6 @@ static const struct vm_operations_struct v9fs_mmap_file_vm_ops = { .page_mkwrite = v9fs_vm_page_mkwrite, }; - -const struct file_operations v9fs_cached_file_operations = { - .llseek = generic_file_llseek, - .read_iter = generic_file_read_iter, - .write_iter = generic_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock, - .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync, -}; - -const struct file_operations v9fs_cached_file_operations_dotl = { - .llseek = generic_file_llseek, - .read_iter = generic_file_read_iter, - .write_iter = generic_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock_dotl, - .flock = v9fs_file_flock_dotl, - .mmap = v9fs_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync_dotl, -}; - const struct file_operations v9fs_file_operations = { .llseek = generic_file_llseek, .read_iter = v9fs_file_read_iter, @@ -677,34 +613,7 @@ const struct file_operations v9fs_file_operations_dotl = { .release = v9fs_dir_release, .lock = v9fs_file_lock_dotl, .flock = v9fs_file_flock_dotl, - .mmap = generic_file_readonly_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync_dotl, -}; - -const struct file_operations v9fs_mmap_file_operations = { - .llseek = generic_file_llseek, - .read_iter = v9fs_mmap_file_read_iter, - .write_iter = v9fs_mmap_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock, - .mmap = v9fs_mmap_file_mmap, - .splice_read = generic_file_splice_read, - .splice_write = iter_file_splice_write, - .fsync = v9fs_file_fsync, -}; - -const struct file_operations v9fs_mmap_file_operations_dotl = { - .llseek = generic_file_llseek, - .read_iter = v9fs_mmap_file_read_iter, - .write_iter = v9fs_mmap_file_write_iter, - .open = v9fs_file_open, - .release = v9fs_dir_release, - .lock = v9fs_file_lock_dotl, - .flock = v9fs_file_flock_dotl, - .mmap = v9fs_mmap_file_mmap, + .mmap = v9fs_file_mmap, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fsync = v9fs_file_fsync_dotl, diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 33e521c60e2c..8ffa6631b1fd 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -219,6 +219,35 @@ v9fs_blank_wstat(struct p9_wstat *wstat) wstat->extension = NULL; } +/** + * v9fs_flush_inode_writeback - writeback any data associated with inode + * @inode: inode to writeback + * + * This is used to make sure anything that needs to be written + * to server gets flushed before we do certain operations (setattr, getattr, close) + * + */ + +int v9fs_flush_inode_writeback(struct inode *inode) +{ + struct writeback_control wbc = { + .nr_to_write = LONG_MAX, + .sync_mode = WB_SYNC_ALL, + .range_start = 0, + .range_end = -1, + }; + + int retval = filemap_fdatawrite_wbc(inode->i_mapping, &wbc); + + if (retval != 0) { + p9_debug(P9_DEBUG_ERROR, + "trying to flush inode %p failed with error code %d\n", + inode, retval); + } + + return retval; +} + /** * v9fs_alloc_inode - helper function to allocate an inode * @sb: The superblock to allocate the inode from @@ -287,24 +316,10 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, case S_IFREG: if (v9fs_proto_dotl(v9ses)) { inode->i_op = &v9fs_file_inode_operations_dotl; - if (v9ses->cache == CACHE_LOOSE || - v9ses->cache == CACHE_FSCACHE) - inode->i_fop = - &v9fs_cached_file_operations_dotl; - else if (v9ses->cache == CACHE_MMAP) - inode->i_fop = &v9fs_mmap_file_operations_dotl; - else - inode->i_fop = &v9fs_file_operations_dotl; + inode->i_fop = &v9fs_file_operations_dotl; } else { inode->i_op = &v9fs_file_inode_operations; - if (v9ses->cache == CACHE_LOOSE || - v9ses->cache == CACHE_FSCACHE) - inode->i_fop = - &v9fs_cached_file_operations; - else if (v9ses->cache == CACHE_MMAP) - inode->i_fop = &v9fs_mmap_file_operations; - else - inode->i_fop = &v9fs_file_operations; + inode->i_fop = &v9fs_file_operations; } break; @@ -843,7 +858,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) && !v9inode->writeback_fid && + if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && ((flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid @@ -1030,6 +1045,7 @@ v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) { struct dentry *dentry = path->dentry; + struct inode *inode = d_inode(dentry); struct v9fs_session_info *v9ses; struct p9_fid *fid; struct p9_wstat *st; @@ -1039,6 +1055,9 @@ v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { generic_fillattr(&init_user_ns, d_inode(dentry), stat); return 0; + } else if (v9ses->cache >= CACHE_WRITEBACK) { + if (S_ISREG(inode->i_mode)) + v9fs_flush_inode_writeback(inode); } fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) @@ -1116,7 +1135,7 @@ static int v9fs_vfs_setattr(struct user_namespace *mnt_userns, /* Write all dirty data */ if (d_is_reg(dentry)) - filemap_write_and_wait(inode->i_mapping); + v9fs_flush_inode_writeback(inode); retval = p9_client_wstat(fid, &wstat); @@ -1127,9 +1146,12 @@ static int v9fs_vfs_setattr(struct user_namespace *mnt_userns, return retval; if ((iattr->ia_valid & ATTR_SIZE) && - iattr->ia_size != i_size_read(inode)) { + iattr->ia_size != i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); - fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) + fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + else + invalidate_mapping_pages(&inode->i_data, 0, -1); } v9fs_invalidate_inode_attr(inode); diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index bff37a312e64..4f01808c3bae 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -458,6 +458,7 @@ v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, struct dentry *dentry = path->dentry; struct v9fs_session_info *v9ses; struct p9_fid *fid; + struct inode *inode = d_inode(dentry); struct p9_stat_dotl *st; p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); @@ -465,6 +466,10 @@ v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { generic_fillattr(&init_user_ns, d_inode(dentry), stat); return 0; + } else if (v9ses->cache >= CACHE_WRITEBACK) { + if (S_ISREG(inode->i_mode)) + v9fs_flush_inode_writeback(inode); + } fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) @@ -540,12 +545,14 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, struct dentry *dentry, struct iattr *iattr) { int retval, use_dentry = 0; + struct inode *inode = d_inode(dentry); + struct v9fs_inode *v9inode = V9FS_I(inode); + struct v9fs_session_info *v9ses; struct p9_fid *fid = NULL; struct p9_iattr_dotl p9attr = { .uid = INVALID_UID, .gid = INVALID_GID, }; - struct inode *inode = d_inode(dentry); p9_debug(P9_DEBUG_VFS, "\n"); @@ -553,6 +560,8 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, if (retval) return retval; + v9ses = v9fs_dentry2v9ses(dentry); + p9attr.valid = v9fs_mapped_iattr_valid(iattr->ia_valid); if (iattr->ia_valid & ATTR_MODE) p9attr.mode = iattr->ia_mode; @@ -584,7 +593,7 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, /* Write all dirty data */ if (S_ISREG(inode->i_mode)) - filemap_write_and_wait(inode->i_mapping); + v9fs_flush_inode_writeback(inode); retval = p9_client_setattr(fid, &p9attr); if (retval < 0) { @@ -593,9 +602,14 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, return retval; } - if ((iattr->ia_valid & ATTR_SIZE) && - iattr->ia_size != i_size_read(inode)) + if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size != + i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) + fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); + else + invalidate_mapping_pages(&inode->i_data, 0, -1); + } v9fs_invalidate_inode_attr(inode); setattr_copy(&init_user_ns, inode, iattr); From patchwork Sat Feb 18 00:33:16 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: 58851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp146959wrn; Fri, 17 Feb 2023 16:44:41 -0800 (PST) X-Google-Smtp-Source: AK7set+fy+v4m6GXXIHTq96THW6L2nq1DkhOUHJxSwm28GZasbJbkALo8BF/DvI2Ncp4jpzdEpxM X-Received: by 2002:a05:6a20:4b14:b0:c7:49c4:c28c with SMTP id fp20-20020a056a204b1400b000c749c4c28cmr5767246pzb.20.1676681080764; Fri, 17 Feb 2023 16:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681080; cv=none; d=google.com; s=arc-20160816; b=OVY5bEFPDYzIDnprow8etKLrZqhUolDAm9hf3kAfqBN/0ZqToeBQxkbRUlKSsf9tme t99Lcrpv0XKwXtdOvAXQtGMP8gTnBqiNHqbQh0lfe2FNfRWndnU9cS0ExO7GkcaaP6Hb khVPkZXTGZ46+u1esGfAa/o+C4YsjTphAOlvdTnBi2rOYiaU5P3ThwJXCRqjwmDK/Sjh t/Eu8M3ImR8XjUwDnOsXVMPHTumPJGK18meNrdh/adzutlbrmeqyJXZ1x+vqLJOSSEBR TLrWDaB0nbUTey+yFzVqvDAyGgs3QMOEKYV9+BItlTUKR9NtfA9lw+HaYImbXPgMs1PZ YDZQ== 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=gRV/L1eN8c4leoO294fZ9F5eOKzUWH55ikdGdVVmuQs=; b=z+cLt32fZKy9PBFs2Nl1+RqXQv+EeS4GMf7j3fM51+4Iiu8dEiwtkN0tprd3lfdMIh Eeu6r1d72fA15OE+ym8z4PE6gQmUWNcXPyLLEG6Lwr4HW/K41lYg5UcjG5VivGo06Vzg tLeHpEwYg4VOcx1MgSizvRW0UthkuRo+uC+is83CfTgsLySdqvaBfA8bK7v6mJ7FzUdm tfTtkSxL8hHvP3GeePS7CEAOYc73/n32mBiSEn2KDoBYQhQNA4lutiOmDHNnaN2RRHrn WbdusTowgG42h3FggTukWGxYme79UPrIm+LtYfeZ0lGavIidfMXhn5FIeyzjSdRx1gQe Eh6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sDJ1tW0n; 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 b12-20020a655ccc000000b004fb3861be41si6670103pgt.290.2023.02.17.16.44.28; Fri, 17 Feb 2023 16:44:40 -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=sDJ1tW0n; 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 S229555AbjBRAfx (ORCPT + 99 others); Fri, 17 Feb 2023 19:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjBRAfw (ORCPT ); Fri, 17 Feb 2023 19:35:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFC883F7; Fri, 17 Feb 2023 16:35:19 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 98EF6620A7; Sat, 18 Feb 2023 00:33:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F4C2C433A0; Sat, 18 Feb 2023 00:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680438; bh=r7VYuVAQDU98smxxlBwk5mo68iLowdZ4mILXuE17YKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sDJ1tW0nJd35lXKg/oEsGs3Ne79q5RUlNKJDhBoD/8r2U17+sfDm/9TIdBPUfTFp8 PGDwxrROXHSZvpgHxEO+DmkbufWFUSZ1tKsY+eywqQMKQhG7nOrY8YylC0Co29AjER Tang6L0vTIU+SYJJo8r3oqG3c5+CWkIRlNTZfMw73FCXjXQXE0yqX8lqC4pzGL0qzo UUg22R5WDeTe3nTQpDehgTaMut4l+XnBpZp+H7x9EoaPrWg7WKqkTEgdW5zMQEYbl9 zcULamDlKZwhtpnYeq+ogRkPovsOb9QrWMOLPWUvUGdr+iCZLPQ6TWtpvjrGlEfsw/ TaEUfsQFg9uWg== 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 04/11] fs/9p: Remove unnecessary superblock flags Date: Sat, 18 Feb 2023 00:33:16 +0000 Message-Id: <20230218003323.2322580-5-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?1758127540940980581?= X-GMAIL-MSGID: =?utf-8?q?1758127540940980581?= These flags just add unnecessary extra operations. When 9p is run without cache, it inherently implements these options so we don't need them in the superblock (which ends up sending extraneous fsyncs, etc.). User can still request these options on mount, but we don't need to set them as default. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_super.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 266c4693e20c..65d96fa94ba2 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -84,9 +84,7 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, sb->s_bdi->io_pages = v9ses->maxdata >> PAGE_SHIFT; } - sb->s_flags |= SB_ACTIVE | SB_DIRSYNC; - if (!v9ses->cache) - sb->s_flags |= SB_SYNCHRONOUS; + sb->s_flags |= SB_ACTIVE; #ifdef CONFIG_9P_FS_POSIX_ACL if ((v9ses->flags & V9FS_ACL_MASK) == V9FS_POSIX_ACL) From patchwork Sat Feb 18 00:33:17 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: 58868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp150114wrn; Fri, 17 Feb 2023 16:55:43 -0800 (PST) X-Google-Smtp-Source: AK7set/bmrCnDtzjvNe2TfZFnFRvBurdGaNTdqp7UF7C+WVwM8ncYdGYqqcQ+VsM7nHGvda+GW3k X-Received: by 2002:a17:90b:3b43:b0:233:ee50:d28b with SMTP id ot3-20020a17090b3b4300b00233ee50d28bmr2564849pjb.16.1676681742755; Fri, 17 Feb 2023 16:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681742; cv=none; d=google.com; s=arc-20160816; b=I8DNblQEnAXyc0v+218uizCTgC0Cn6yfc6MlBSybBIVN5hOlwsHMVlmnOGlMg//0ag 3xkVVpSDBedFfigoQNpI4pQ+Gog4T/2LyP//gPveBVmXIL1DaeacbeltbtOJgHwrYcVy QiXvMJJSm23rwGzrnkn9fRLn1kZsh9kdT8XCuxBVt4K0RJLKJ/HkiVFYartJSzPVD00I +bDwNqiGXZKK0CZjpqGWyFQCfy90OeFumbnXNtKuMh0HSZSuP2hjeuaGhmxvq/BRjhiS YqkYQomxIAkGxALdutwAWnhtqIDlJ4/lPBgxCLF4vOCEVXkKg2OOsDvl6keF5uPF+173 pw7Q== 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=iPzr/SCbR7V+qcOT1Z8iyiSYxerQCt3e0AEMU4boRQg=; b=wgbCjryTU1IpkXFgaqFuQIbTjUtJtDrBbyvmVgOQItL9YR8DYe96lNpWiY1guAZi+g 3i+7mxmnbaaWG/uJNfR5TdNdPt5gLVOBNCJEzfesUa0scd59jstgxMW8jfnswrI3JRer HDwQzslLvHlejmaMemOn6oyS+J9JswcDtMQ3AeuxaLq5QBhcVVOleMP/ATBgIgT+CEkz FzfgcH8xa+8wbGXODdur9I28QXzJtQstVEfBW7aHefTRv7PoFoOx0vqIrDwyolgY6wPS DpI4Sev1riHwSbSGvOX0CiC8rNJ43kdZkZHGNx+EzPyroYeEJCEoaKg3xak8hzlb2+mN Xn2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y5s5bduu; 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 b17-20020a656691000000b004fbc4d51d21si6553117pgw.342.2023.02.17.16.55.30; Fri, 17 Feb 2023 16:55:42 -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=Y5s5bduu; 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 S229776AbjBRAtM (ORCPT + 99 others); Fri, 17 Feb 2023 19:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjBRAtF (ORCPT ); Fri, 17 Feb 2023 19:49:05 -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 051305CF3A; 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 65B10B82EA6; Sat, 18 Feb 2023 00:34:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49C24C4339B; Sat, 18 Feb 2023 00:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680439; bh=rvDymktanf6MSiAzIPMCTiULQZumTY7dlyrm9CYAra8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5s5bduuvTJwpmyQLndx1q3QKOTxY+MAvEohBtO6bBJ6vHrq0ksXVYJ4u2Gl+9nSl 7K/36OoDsVN6AUW7UiEMpCLQvbsTDVB7peDF132Xy4u9m9XIYPWa2aYp3Wj9zjVFq6 dq2VzOo8zBT6Jd0kbQdknCeq3vsB4VPHVDGQ/9AoqdOE2m6TiKPvYLl5cjsJWaYmFF CfCy0IhVlokPKNpaYe5gmjDFNdJSAG0uMMBTD1/lORsD75nBYeYx5MoeU0sdMMi9IX F063gTxW5kJw2iG0n9bqEs/7mmCZmQ5AyzI/CjWrvUtFGYWbfDHeCRqs6hfLuBgADl OkLTeNp9oxs8g== 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 05/11] fs/9p: allow disable of xattr support on mount Date: Sat, 18 Feb 2023 00:33:17 +0000 Message-Id: <20230218003323.2322580-6-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?1758128235175298429?= X-GMAIL-MSGID: =?utf-8?q?1758128235175298429?= xattr creates a lot of additional messages for 9p in the current implementation. This allows users to conditionalize xattr support on 9p mount if they are on a connection with bad latency. Using this flag is also useful when debugging other aspects of 9p as it reduces the noise in the trace files. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- Documentation/filesystems/9p.rst | 2 ++ fs/9p/v9fs.c | 9 ++++++++- fs/9p/v9fs.h | 3 ++- fs/9p/vfs_super.c | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/9p.rst b/Documentation/filesystems/9p.rst index 7b5964bc8865..0e800b8f73cc 100644 --- a/Documentation/filesystems/9p.rst +++ b/Documentation/filesystems/9p.rst @@ -137,6 +137,8 @@ Options This can be used to share devices/named pipes/sockets between hosts. This functionality will be expanded in later versions. + noxattr do not offer xattr functions on this mount. + access there are four access modes. user if a user tries to access a file on v9fs diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index a46bf9121f11..f8e952c013f9 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -38,7 +38,7 @@ enum { /* String options */ Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ - Opt_nodevmap, + Opt_nodevmap, Opt_noxattr, /* Access options */ Opt_access, Opt_posixacl, /* Lock timeout option */ @@ -55,6 +55,7 @@ static const match_table_t tokens = { {Opt_uname, "uname=%s"}, {Opt_remotename, "aname=%s"}, {Opt_nodevmap, "nodevmap"}, + {Opt_noxattr, "noxattr"}, {Opt_cache, "cache=%s"}, {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, @@ -149,6 +150,9 @@ int v9fs_show_options(struct seq_file *m, struct dentry *root) if (v9ses->flags & V9FS_POSIX_ACL) seq_puts(m, ",posixacl"); + if (v9ses->flags & V9FS_NO_XATTR) + seq_puts(m, ",noxattr"); + return p9_show_client_options(m, v9ses->clnt); } @@ -269,6 +273,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) case Opt_nodevmap: v9ses->nodev = 1; break; + case Opt_noxattr: + v9ses->flags |= V9FS_NO_XATTR; + break; case Opt_cachetag: #ifdef CONFIG_9P_FSCACHE kfree(v9ses->cachetag); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 517b2201ad24..d90141d25d0d 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -36,7 +36,8 @@ enum p9_session_flags { V9FS_ACCESS_SINGLE = 0x04, V9FS_ACCESS_USER = 0x08, V9FS_ACCESS_CLIENT = 0x10, - V9FS_POSIX_ACL = 0x20 + V9FS_POSIX_ACL = 0x20, + V9FS_NO_XATTR = 0x40 }; /* possible values of ->cache */ diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 65d96fa94ba2..5fc6a945bfff 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -64,7 +64,8 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, sb->s_magic = V9FS_MAGIC; if (v9fs_proto_dotl(v9ses)) { sb->s_op = &v9fs_super_ops_dotl; - sb->s_xattr = v9fs_xattr_handlers; + if (!(v9ses->flags & V9FS_NO_XATTR)) + sb->s_xattr = v9fs_xattr_handlers; } else { sb->s_op = &v9fs_super_ops; sb->s_time_max = U32_MAX; From patchwork Sat Feb 18 00:33:18 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: 58858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148354wrn; Fri, 17 Feb 2023 16:49:21 -0800 (PST) X-Google-Smtp-Source: AK7set991aWFQSEKrAsRU3IbEvhTzxFoChCb+YOKh82E8nyD7RZlr/r0ox9jMLqlhdql+ADQIfIB X-Received: by 2002:a05:6a20:7d8a:b0:af:7233:5bfc with SMTP id v10-20020a056a207d8a00b000af72335bfcmr8115155pzj.8.1676681361202; Fri, 17 Feb 2023 16:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681361; cv=none; d=google.com; s=arc-20160816; b=FH/qrT1XPt2SyuM2ReBwxmDyNw7ZzztUS842TgofoMYD6XSI+3UnHUGVoQMyCR9R5o 010Clee23fTgVKd4nGSFymResUQWOAizwR0gMnO07OwvXpbLb/15WY1hEkNV4NcVWWlx QHHv2T6wxiPkQeHkbz2LH7bYOdsSo5Z+y7dlG5BJRJLaXDCY7iUR+yaOmpwhFh/wTxh5 G1cN98o+bCIBq34bSWhiRELrfRTQhbl7ImOl4xSwwAv7bg4dY9UHxScC1VCPl3YR3GLM uPANr3lKRICj5Ox9nQOAFZVuiVLjJarc3qG1XNfJFx1PWdjE86bFOMh+MdKgOyabn3hd qIFg== 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=fQ1wIVJNt5DXLKBshV7W2ww1uzBSJEoD/iEzMJIiQpg=; b=bL430gJmvcpwjZj84R+HSAU8n4QCLd4Qj9jeU4CBuokJ6GZSybu5YTa4/flp32fqXv EnFaaTHjsgW8Rty39DqMRbc83JVKpwzZIEd/bkX6RfESHn6PlMvOP0nDVX4bKTPFv0pI 6Ak6xB70LUrBSq7b06Bl7J9n0fxx0CuLOkwAUHtt0Z2EGuCIiDZYK98PSX3Nr9pu1v9p p//mgCQjJmzjll9X92uzFlkegTVb/OgHgUcpbq/UAZnrvQM42ZV/IJdzVlHvT1VMktG7 2HYGx3QEJ/YlalP6M3Wzz3VCO3/404ooDO3auXCMswEweJBaPIjyDPs4QgL8gRZX2L1Q 8eVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ca0eOXl9; 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 i15-20020a633c4f000000b004d39932df65si6512795pgn.585.2023.02.17.16.49.08; Fri, 17 Feb 2023 16:49:21 -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=Ca0eOXl9; 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 S229897AbjBRAlX (ORCPT + 99 others); Fri, 17 Feb 2023 19:41:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbjBRAlV (ORCPT ); Fri, 17 Feb 2023 19:41:21 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043616D245; Fri, 17 Feb 2023 16:40:42 -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 4E242B82EB3; Sat, 18 Feb 2023 00:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5136AC433EF; Sat, 18 Feb 2023 00:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680440; bh=Ok4fLl47ydowKVxThK8D575DI78XULsYZEvV5sQqQ3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ca0eOXl9ADJhsTGTNxOb4mqO6T2bOzENafCVhVAm0mc7ONXbnuaPYU4OAjdctPxYr PUo1IhvajR87EijDJTzX5g0oyLby1fPOxQCK1LLzQ8rGhDkD/uNKawSj1QTf5rqFJ6 F6mvmr32jGwLhcDR0laMVj5xemgb0Eakz5y0vZjaNyROYFV6vho8H3FhFJ3B8H4eFV E3CfKi4Z1mmtBNAfXEfv3iT6OqevRcyCRHUjcsZgxucBOoAEJKeXS+cq0cvwWFKYiu U9BFA32XpUCxRjDCchHpdIKUxb+xC9llr2zVITdTbqaafSWtqPCoX59XT5oWGUh5Ps z5Mi5F8D5jXNA== 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 06/11] net/9p: fix bug in client create for .L Date: Sat, 18 Feb 2023 00:33:18 +0000 Message-Id: <20230218003323.2322580-7-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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1758127834813727092?= X-GMAIL-MSGID: =?utf-8?q?1758127834813727092?= We are supposed to set fid->mode to reflect the flags that were used to open the file. We were actually setting it to the creation mode which is the default perms of the file not the flags the file was opened with. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- net/9p/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/9p/client.c b/net/9p/client.c index 6c2a768a6ab1..2adcb5e7b0e2 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1293,7 +1293,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, qid->type, qid->path, qid->version, iounit); memmove(&ofid->qid, qid, sizeof(struct p9_qid)); - ofid->mode = mode; + ofid->mode = flags; ofid->iounit = iounit; free_and_error: From patchwork Sat Feb 18 00:33:19 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: 58855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp147997wrn; Fri, 17 Feb 2023 16:48:10 -0800 (PST) X-Google-Smtp-Source: AK7set+67DeSiWh1RAh/OAItJ/E9T+aiqbMtsZBqyotFFa6Gjkv7fhR8ZEkUqln0X0nAJwx6n0e/ X-Received: by 2002:a05:6a20:4c24:b0:c7:885b:450b with SMTP id fm36-20020a056a204c2400b000c7885b450bmr3029166pzb.22.1676681290052; Fri, 17 Feb 2023 16:48:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681290; cv=none; d=google.com; s=arc-20160816; b=psFNGitv6Tb4auQ60g5YwQbL3XCEnszqtzyeecQg6AvsVt2oQ/YEs2mvp6JhNK4mFG /sKzCWHuPFBsg+Uyjw52DSWooj6mNxpEhBE66y1D5OxBVhi6WVrdMlN5FSh6BaiH7TR/ 8H1RylNLdyFVI340wJSz90mntvBsy6fs9go42zzxVHuC7j4ZfoYM1c1SuXCg//HL5jAH dS3x5rXSrKqvB8LvHFwe+EBgcr8FbiCcD3l/nb10RuRebfw/dnyRs8W6rhkZRv8uvM4M +uNcXfJqvR3708DWPM9dgKX4/fnn520X+JVFMpqa53DLGJVBdozYusBrvtbJzh9K50po /SOw== 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=fljFV7VThIWvGg9YGEMXmL5GRBoFbMTuiom63QhKsw0=; b=RvR0Tj7IF3//KrXanjuSCyt94RuGVY+V75XkJ4EIlWuGB1rsES90q/QTSVOp9/fd2N dzNzhDXwfweHl1PLlueRUl2oJHgQ+BN3+4gD05H6aa1gmVBo/g4YhaRj5ET020EsUUrF uSJvDc1FGh4Ku7ynSqKLOMmA6SLolnDcRP2NJgRsn5pRTmTSKgWHSzrJ7sVuez/jTfOH +TKD9ZHDe+dwDy9m+POrE1sOYSzJpadWczaA8etrPYdw+f1EXnB58QwURqi6yzip94TH bwYgsEciZKfXU63ilfFLA7QZJWz/8V2/bAmwovEHRou6CqxVioqbw9IWX1v3/yi8IKs9 ZQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n66eBIPF; 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 y64-20020a633243000000b004fb97acac30si6031471pgy.774.2023.02.17.16.47.57; Fri, 17 Feb 2023 16:48:10 -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=n66eBIPF; 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 S229585AbjBRAg3 (ORCPT + 99 others); Fri, 17 Feb 2023 19:36:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbjBRAg2 (ORCPT ); Fri, 17 Feb 2023 19:36:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FF36D251; Fri, 17 Feb 2023 16:35:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B308E6209C; Sat, 18 Feb 2023 00:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54E37C433D2; Sat, 18 Feb 2023 00:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680441; bh=cW3tqr7Wz1/+iCrGEv007ARmFZP9bjEOtTw2DUtSkXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n66eBIPF5VOPlydJO6o1F9Id9ahHIQmnpN9qb9pfpbH2CclkG8oyade30qFmGYJHc IkNEcigIpm9Y/Zk6c0an3pmtrIf93u6e9mKMpaQ7ROqpkAN9p6+TWZxSOoGtn1GEsl qMARtGiDDlKjmJOUEqJtvKAjUahxqFbIHqf4kjlDvYueYDzZ5qqygu9fGUe1wobML8 JaSTrVbi1pGfB2C8zeD9slAWsW39qcybUL1TwF8ZtrKB9WyIS2P9Sr3J0npQgsfUTH r2oG9P+csiuyYPLQKnAo0fwOg5jXFwYauD+0V5i7nALf/3S8dUGbE1BFAFyD1ysu5O X/SFmxVdZ2vGg== 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 07/11] 9p: Add additional debug flags and open modes Date: Sat, 18 Feb 2023 00:33:19 +0000 Message-Id: <20230218003323.2322580-8-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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1758127760454071759?= X-GMAIL-MSGID: =?utf-8?q?1758127760454071759?= Add some additional debug flags to assist with debugging cache changes. Also add some additional open modes so we can track cache state in fids more directly. Signed-off-by: Eric Van Hensbergen --- include/net/9p/9p.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 429adf6be29c..61c20b89becd 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -42,6 +42,8 @@ enum p9_debug_flags { P9_DEBUG_PKT = (1<<10), P9_DEBUG_FSC = (1<<11), P9_DEBUG_VPKT = (1<<12), + P9_DEBUG_CACHE = (1<<13), + P9_DEBUG_MMAP = (1<<14), }; #ifdef CONFIG_NET_9P_DEBUG @@ -213,6 +215,9 @@ enum p9_open_mode_t { P9_ORCLOSE = 0x40, P9_OAPPEND = 0x80, P9_OEXCL = 0x1000, + P9L_DIRECT = 0x2000, /* cache disabled */ + P9L_NOWRITECACHE = 0x4000, /* no write caching */ + P9L_LOOSE = 0x8000, /* loose cache */ }; /** From patchwork Sat Feb 18 00:33:20 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: 58864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148953wrn; Fri, 17 Feb 2023 16:51:28 -0800 (PST) X-Google-Smtp-Source: AK7set9dKCiP7NjbTEeKEunf/sB7zo0AWfEQpxCFNUZEBqArN0dgqUkA2oGT7vQH8FXOuwgfoA5v X-Received: by 2002:aa7:96a1:0:b0:5a9:ea47:cd00 with SMTP id g1-20020aa796a1000000b005a9ea47cd00mr4240560pfk.17.1676681488127; Fri, 17 Feb 2023 16:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681488; cv=none; d=google.com; s=arc-20160816; b=plLahgkSVSbiKy8Uicce701gsS0FGLpGfAFThmK4jiIrNekV3D8+iTE+oB3fiukdj9 3Ts9l4sLncfkxj0XxH9Fv98UEf1i1fTdApE2spp/zwjW0tlfHULfLNWwHjrtKTtmfVHV CWCezUTmHqyUzXVnJK052oKLcv5G5/rffXCETfVdAOg6gDar5lavcuryBBbWbemT19pS 8wllnm8XgztZOzolAgGjUurVFB6EvGpoJviHAc2DoC9rBvkvP8MmFt2PSirUlBc5c1Lq Q6Ey3Rov1BKlpN9mfLo3mglYOJHLuZ676qRZpbXdHMribGMcBdN9x4kKuQMGfnaycQix pA5A== 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=Y2tqT6fwp6T5QHm0N3zU6Kii1Y4H4eg32RlXAYJ9LZA=; b=YJzVZwjBLTHOKn5ahsfGu3APRz/1NN4RIMVu4or+dq4fFz2cRefUqnqCB0qcNj9yQP qg/VxqLfqSKcRvDFIeuvbx8zBzjV2rx2ZEJo1NchFYu1l5oVDxrdGC3uA3oD6jC0Orz+ 66lw0MPwk5qFZb17EBbtIX5uAPi7bgQVvMwN3X6wr4EA4NXIk9mHW1wIcIqwgT6Qwpwp /H9fEzJO7kA61QkEDLgiZgEUPvpfQKssxrGydHrwDq+bglyN6pFnxFHaVczPsof60xgn YNcWAXVUp4NNlViueM7xnleGJpcPVT9okAA3i8CvlC+clIu8WorPwRYwJ2sU/qMPhrLE gPaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k2zvKVLY; 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 d12-20020a056a00198c00b005a7ea9c6d7csi6411835pfl.41.2023.02.17.16.51.16; Fri, 17 Feb 2023 16:51:28 -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=k2zvKVLY; 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 S229712AbjBRApV (ORCPT + 99 others); Fri, 17 Feb 2023 19:45:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbjBRApI (ORCPT ); Fri, 17 Feb 2023 19:45:08 -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 1B2D56E67E; Fri, 17 Feb 2023 16:44:36 -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 856D6B82EDB; Sat, 18 Feb 2023 00:34:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61CB8C4339E; Sat, 18 Feb 2023 00:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680442; bh=KENVm6Mybvc2iHuCzsErqi8WG1g+ScHvDff49cLzyDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2zvKVLYQRYHVPCHNW4CkVsb+xtQmWFci14aAHMmH5MuhKOi5lq8QRlpLTzVC7jcv +eKBBcUB1xn7Q8YXHws7r0KqMU64v+Hi78jLoj4GRyIfUsAFqRsGXYacyVThPsKL7N Y7p2mn4y024cFomTPs83Gt2ARvuZAqJ/fwgVKQiCtYM95oCIhecekSRfR9jXd863Ht 77GpUmI/2rEgtZAJD0ZIhaSB8mx1SbPlR2DAPqNt2fhJZF+tB56mq8rV+jXxKQux+1 aXAjJvGX0vsSjDqF3W1R2BABHde2pKPUvB7UU3gXu/FR9oXlQb4LnLXTnTe3sTMhvt TkZX5pCShykFQ== 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 08/11] fs/9p: Add new mount modes Date: Sat, 18 Feb 2023 00:33:20 +0000 Message-Id: <20230218003323.2322580-9-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?1758127967956010874?= X-GMAIL-MSGID: =?utf-8?q?1758127967956010874?= Add some additional mount modes for cache management including specifying directio as a mount option and an option for ignore qid.version for determining whether or not a file is cacheable. Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs.c | 16 ++++++++++++++-- fs/9p/v9fs.h | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index f8e952c013f9..43d3806150a9 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -38,7 +38,7 @@ enum { /* String options */ Opt_uname, Opt_remotename, Opt_cache, Opt_cachetag, /* Options that take no arguments */ - Opt_nodevmap, Opt_noxattr, + Opt_nodevmap, Opt_noxattr, Opt_directio, Opt_ignoreqv, /* Access options */ Opt_access, Opt_posixacl, /* Lock timeout option */ @@ -56,6 +56,8 @@ static const match_table_t tokens = { {Opt_remotename, "aname=%s"}, {Opt_nodevmap, "nodevmap"}, {Opt_noxattr, "noxattr"}, + {Opt_directio, "directio"}, + {Opt_ignoreqv, "ignoreqv"}, {Opt_cache, "cache=%s"}, {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, @@ -125,7 +127,7 @@ int v9fs_show_options(struct seq_file *m, struct dentry *root) if (v9ses->nodev) seq_puts(m, ",nodevmap"); if (v9ses->cache) - seq_printf(m, ",%s", v9fs_cache_modes[v9ses->cache]); + seq_printf(m, ",cache=%s", v9fs_cache_modes[v9ses->cache]); #ifdef CONFIG_9P_FSCACHE if (v9ses->cachetag && v9ses->cache == CACHE_FSCACHE) seq_printf(m, ",cachetag=%s", v9ses->cachetag); @@ -147,6 +149,10 @@ int v9fs_show_options(struct seq_file *m, struct dentry *root) break; } + if (v9ses->flags & V9FS_IGNORE_QV) + seq_puts(m, ",ignoreqv"); + if (v9ses->flags & V9FS_DIRECT_IO) + seq_puts(m, ",directio"); if (v9ses->flags & V9FS_POSIX_ACL) seq_puts(m, ",posixacl"); @@ -276,6 +282,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) case Opt_noxattr: v9ses->flags |= V9FS_NO_XATTR; break; + case Opt_directio: + v9ses->flags |= V9FS_DIRECT_IO; + break; + case Opt_ignoreqv: + v9ses->flags |= V9FS_IGNORE_QV; + break; case Opt_cachetag: #ifdef CONFIG_9P_FSCACHE kfree(v9ses->cachetag); diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index d90141d25d0d..48c7614c9333 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -37,7 +37,10 @@ enum p9_session_flags { V9FS_ACCESS_USER = 0x08, V9FS_ACCESS_CLIENT = 0x10, V9FS_POSIX_ACL = 0x20, - V9FS_NO_XATTR = 0x40 + V9FS_NO_XATTR = 0x40, + V9FS_IGNORE_QV = 0x80, + V9FS_DIRECT_IO = 0x100, + V9FS_SYNC = 0x200 }; /* possible values of ->cache */ From patchwork Sat Feb 18 00:33:21 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: 58860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148490wrn; Fri, 17 Feb 2023 16:49:44 -0800 (PST) X-Google-Smtp-Source: AK7set+utwakU50TAvFUQN0WeU7HHcfYGEQZ1Wk17hk4SEOZG0rL6/xb2g7FqXN+Ydqxteby/slq X-Received: by 2002:aa7:953a:0:b0:5a8:bfe5:3076 with SMTP id c26-20020aa7953a000000b005a8bfe53076mr2231682pfp.19.1676681383801; Fri, 17 Feb 2023 16:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681383; cv=none; d=google.com; s=arc-20160816; b=PTyUjx0eAMdRLl28/+pYoStpHlAaTu3nIXnNXYVockzAcP6mi/SxeBI/65zPNuy+3w nHB3WgDETWsfU6ZAlXOfNH7YQtLZBTNW5CCmIxu7wO7vvM0pbEWK+JuK+iC2f+7yXBoq epBj6+JKiwRngAfwZ5uEqRkiKv7RzWsm5JMSAYSs9D3Ld0vYUiuLtEo1V439CDI+cxQ5 7148nNQAItShQotMu/V89cw7zgGRaVlBwnnQlh/ZYB8GbgdyYrVUvTNZPncn49DJkBge SJamCvTuDu6Yeh0m5zVkGcM+IzWZkS+uUTgGAWB0WerIT2pocxPBY0i6obEAKuDZwD9E ygFw== 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=TeYIToiVg2O35jlhMJSdfLvBxlgQfLrWWPqRGWfBvuM=; b=JS2gNscG1oVeU2WytnvHo220Es61BWl01DBOSYolNV+UBfJwwZrXT9rPL88lYXxwmS BIR+Otd84cRPVBp0WNj/lA/8k+DDXGMOBpUiEGeFvWV+YidNcbmZ5Hlb5lpEgb5slnw9 T0tSSps6gGCQKyirHzfc0qVEpq1Mdk1dctWaRNtkiCNdjBZDh65UdDd41ct3holpeGIu XauFq/KDKKTP2XqVDUAgHJXtFFKz0XQzhRLhr5ZzOrruUBR/LFHN8pjEGLBFSSp/Nhr9 xqK+ForaBrNfnKNxsPOdrMYPlWpGruETUJ8+kGBapYoCBY/joR4LKA3BQ9O/AITV7QJf lyjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JyAPiway; 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 e6-20020a056a00162600b0056ea2b1b0fesi5971981pfc.119.2023.02.17.16.49.31; Fri, 17 Feb 2023 16:49:43 -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=JyAPiway; 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 S230095AbjBRAoR (ORCPT + 99 others); Fri, 17 Feb 2023 19:44:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbjBRAoN (ORCPT ); Fri, 17 Feb 2023 19:44:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B1C3B21A; Fri, 17 Feb 2023 16:43:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C8907620AA; Sat, 18 Feb 2023 00:34:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F8D0C433A0; Sat, 18 Feb 2023 00:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680443; bh=nMiGIejp8egMtRxiDVnE9HTGeqlIR/0m0XbHmw05N0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyAPiwayh+ahtkxPDlCeK7rK+JUasC7BwIhvdjEuJhjHIYVnxqfM2wATkuMr0ZAIZ YSNB8lijKrih19gWPp32j8lOYicYvyUbLGyYi8b5XoijJiA3+Vin2rtaO1tJdV5OQb YJAr3fDCRLKsT360UgqC7Gxy+zlVuThPw2uLjCAzP9S3RzY6zJ/v9QwsB7hYN8yj4U JTXQPgvYlhcjzVWOzYXDKQ+zef2mRPa13qwrhZM8GlOUN9GrET9ZUTaRSszMOMO+Qq xMnjHtPnfV3kyzh0iF8/k/YiezbHtJlLwOPN2HfvZtXY1/CwMLsvzwKT0lmglvUSKN fdvTZXscyjCzg== 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 09/11] fs/9p: fix error reporting in v9fs_dir_release Date: Sat, 18 Feb 2023 00:33:21 +0000 Message-Id: <20230218003323.2322580-10-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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1758127858599639479?= X-GMAIL-MSGID: =?utf-8?q?1758127858599639479?= Checking the p9_fid_put value allows us to pass back errors involved if we end up clunking the fid as part of dir_release. This can help with more graceful response to errors in writeback among other things. Signed-off-by: Eric Van Hensbergen Reviewed-by: Dominique Martinet --- fs/9p/vfs_dir.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index bd31593437f3..44918c60357f 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -197,7 +197,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx) /** - * v9fs_dir_release - close a directory + * v9fs_dir_release - called on a close of a file or directory * @inode: inode of the directory * @filp: file pointer to a directory * @@ -209,6 +209,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) struct p9_fid *fid; __le32 version; loff_t i_size; + int retval = 0; fid = filp->private_data; p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n", @@ -220,7 +221,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) spin_lock(&inode->i_lock); hlist_del(&fid->ilist); spin_unlock(&inode->i_lock); - p9_fid_put(fid); + retval = p9_fid_put(fid); } if ((filp->f_mode & FMODE_WRITE)) { @@ -231,7 +232,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) } else { fscache_unuse_cookie(v9fs_inode_cookie(v9inode), NULL, NULL); } - return 0; + return retval; } const struct file_operations v9fs_dir_operations = { From patchwork Sat Feb 18 00:33:22 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: 58861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148662wrn; Fri, 17 Feb 2023 16:50:14 -0800 (PST) X-Google-Smtp-Source: AK7set+btg7LEd+/C8EwJ6BzCqzF4yfkofo/HXKOXoZbonZ0yzWrR8ao2n4nOgx9aOsTLv1YqFD8 X-Received: by 2002:a17:90b:2246:b0:235:31e9:e793 with SMTP id hk6-20020a17090b224600b0023531e9e793mr5079264pjb.13.1676681414480; Fri, 17 Feb 2023 16:50:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681414; cv=none; d=google.com; s=arc-20160816; b=JT18FpgEMx90ngNeOamJrvcXRcvhGMWZ77HVAUmnToj7Ku/C94vtkd9SokOF3oYDOf 60UkZsfET4qlaN+7KbAubKaPYc4vc2xIrtDm/mggRCCCSXzz+blqgA8owK8tVmvr7JT2 pHLgv8/66I5Iw6hGteTl3QNX2b6hHbsFxxJ/9nq02n5FFyE/wYeoru8MJe0iJBOBJGtd aSlaRds8eELh3+7liVZBBMGq3F1mev7GXSl8npjItOH7IVmYjmO7aDJX2sjMQLSpDo1X dHoCZ2gOX3MW7NPrZToAiLWvK05FLvSqNa6RJvlfQr1s57cUUwpwH2IHEWgfZdErURAZ UATQ== 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=TzlfO1/f6O12vTcYWDsGGx9ioG8kEI4Oe5ghl7vp0xY=; b=hIRWMhFl99L+twX9CwDwHFzUApnSacQ2WvFN4GqMiJOEzcdntAC1Oh4kqIkeODmUrf QdVm+W1tU1cSYnO4GlPKx4N4sHufYS5NHYDTwAPdQwSVp1cHrJ4k4wiDeNH3QfCo5gpM EGuwmL/ZNWDsRqEl5sz1DQkKBzPOdq6IN6GxliAwsoaTLUtOxOGzoMjIPXH6I/6IyNt5 mgyzBXiysOH/pkGJasFKhj6syIOKdmDQS+mAYFpZWkBl/f7UE4IvwgrdhpvYdh2Ww3nX CZ8V+YmDbe1Kl8uZCkbaDT0uGNzVPaJArwU7QKKNG+UlU55WUnRYJfIcduaIBy3av2nb LGpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M0BKipAa; 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 u134-20020a63798c000000b004fbbfd33a67si6582381pgc.13.2023.02.17.16.50.02; Fri, 17 Feb 2023 16:50:14 -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=M0BKipAa; 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 S229842AbjBRAkt (ORCPT + 99 others); Fri, 17 Feb 2023 19:40:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjBRAkr (ORCPT ); Fri, 17 Feb 2023 19:40:47 -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 71442F776; Fri, 17 Feb 2023 16:40:09 -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 8F07DB82ED6; Sat, 18 Feb 2023 00:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ACFFC4339C; Sat, 18 Feb 2023 00:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680444; bh=KJ9deFMojFpl3u+l/cyL8DHjpFaJjqmrjoujoFfiocQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0BKipAaAwkd0Ow0bFmI5SmgYkvSBEEodiVCJMTDYkQ1uODcitDAer3LnfXinRp9a PO58nt7Dl3nmIvsEB+jQua+FFHlOdItBQQZjh68JnrP16SBEkv6A0W6QkLQHKbI5cO ZFwPguvCRAIHpHn2BJXScdsmaGplb83KjPLGPJjXpxqE1qhAiCa6PHT1tEPuCHUBVh 8650e8r52KDmKC27JnLnEXHLaTW4r/o1P6e3fLg2Qs/tVJ/tIzFFnpqS3b1my5rS4J pFQ+uBl1d+Qkvl9dQi4cOp33euL06l8u0Dw6Db1Hw1TbhuKPvIzcRpo5D2OQ6wQD+G WqPuYOHvrwkvA== 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 10/11] fs/9p: writeback mode fixes Date: Sat, 18 Feb 2023 00:33:22 +0000 Message-Id: <20230218003323.2322580-11-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?1758127891040794434?= X-GMAIL-MSGID: =?utf-8?q?1758127891040794434?= This fixes several detected problems from preivous patches when running with writeback mode. In particular this fixes issues with files which are opened as write only and getattr on files which dirty caches. This patch makes sure that cache behavior for an open file is stored in the client copy of fid->mode. This allows us to reflect cache behavior from mount flags, open mode, and information from the server to inform readahead and writeback behavior. This includes adding support for a 9p semantic that qid.version==0 is used to mark a file as non-cachable which is important for synthetic files. This may have a side-effect of not supporting caching on certain legacy file servers that do not properly set qid.version. There is also now a mount flag which can disable the qid.version behavior. Signed-off-by: Eric Van Hensbergen --- Documentation/filesystems/9p.rst | 24 ++++----- fs/9p/fid.c | 49 +++++++---------- fs/9p/fid.h | 33 +++++++++++- fs/9p/v9fs.h | 1 - fs/9p/vfs_addr.c | 22 ++++---- fs/9p/vfs_file.c | 91 +++++++++++--------------------- fs/9p/vfs_inode.c | 45 ++++++---------- fs/9p/vfs_inode_dotl.c | 50 +++++++----------- fs/9p/vfs_super.c | 21 +++++--- 9 files changed, 153 insertions(+), 183 deletions(-) diff --git a/Documentation/filesystems/9p.rst b/Documentation/filesystems/9p.rst index 0e800b8f73cc..0c2c7a181d85 100644 --- a/Documentation/filesystems/9p.rst +++ b/Documentation/filesystems/9p.rst @@ -79,18 +79,14 @@ Options cache=mode specifies a caching policy. By default, no caches are used. - none - default no cache policy, metadata and data - alike are synchronous. - loose - no attempts are made at consistency, - intended for exclusive, read-only mounts - fscache - use FS-Cache for a persistent, read-only - cache backend. - mmap - minimal cache that is only used for read-write - mmap. Northing else is cached, like cache=none + ========= ============================================= + none no cache of file or metadata + readahead readahead caching of files + writeback delayed writeback of files + mmap support mmap operations read/write with cache + loose meta-data and file cache with no coherency + fscache use FS-Cache for a persistent cache backend + ========= ============================================= debug=n specifies debug level. The debug level is a bitmask. @@ -137,6 +133,10 @@ Options This can be used to share devices/named pipes/sockets between hosts. This functionality will be expanded in later versions. + directio bypass page cache on all read/write operations + + ignoreqv ignore qid.version==0 as a marker to ignore cache + noxattr do not offer xattr functions on this mount. access there are four access modes. diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 805151114e96..8c1697619f3d 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -23,7 +23,6 @@ static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid) hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); } - /** * v9fs_fid_add - add a fid to a dentry * @dentry: dentry that the fid is being added to @@ -41,14 +40,24 @@ void v9fs_fid_add(struct dentry *dentry, struct p9_fid **pfid) *pfid = NULL; } +static bool v9fs_is_writeable(int mode) +{ + if ((mode & P9_OWRITE) || (mode & P9_ORDWR)) + return true; + else + return false; +} + /** * v9fs_fid_find_inode - search for an open fid off of the inode list * @inode: return a fid pointing to a specific inode + * @writeable: only consider fids which are writeable * @uid: return a fid belonging to the specified user + * @any: ignore uid as a selection criteria * */ - -static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid) +struct p9_fid *v9fs_fid_find_inode(struct inode *inode, bool want_writeable, + kuid_t uid, bool any) { struct hlist_head *h; struct p9_fid *fid, *ret = NULL; @@ -58,7 +67,12 @@ static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid) spin_lock(&inode->i_lock); h = (struct hlist_head *)&inode->i_private; hlist_for_each_entry(fid, h, ilist) { - if (uid_eq(fid->uid, uid)) { + if (any || uid_eq(fid->uid, uid)) { + if (want_writeable && !v9fs_is_writeable(fid->mode)) { + p9_debug(P9_DEBUG_VFS, " mode: %x not writeable?\n", + fid->mode); + continue; + } p9_fid_get(fid); ret = fid; break; @@ -118,7 +132,7 @@ static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) spin_unlock(&dentry->d_lock); } else { if (dentry->d_inode) - ret = v9fs_fid_find_inode(dentry->d_inode, uid); + ret = v9fs_fid_find_inode(dentry->d_inode, false, uid, any); } return ret; @@ -299,28 +313,3 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) return v9fs_fid_lookup_with_uid(dentry, uid, any); } -struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) -{ - int err; - struct p9_fid *fid, *ofid; - - ofid = v9fs_fid_lookup_with_uid(dentry, GLOBAL_ROOT_UID, 0); - fid = clone_fid(ofid); - if (IS_ERR(fid)) - goto error_out; - p9_fid_put(ofid); - /* - * writeback fid will only be used to write back the - * dirty pages. We always request for the open fid in read-write - * mode so that a partial page write which result in page - * read can work. - */ - err = p9_client_open(fid, O_RDWR); - if (err < 0) { - p9_fid_put(fid); - fid = ERR_PTR(err); - goto error_out; - } -error_out: - return fid; -} diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 8a4e8cd12ca2..11576e1364bf 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h @@ -7,14 +7,16 @@ #ifndef FS_9P_FID_H #define FS_9P_FID_H #include +#include "v9fs.h" +struct p9_fid *v9fs_fid_find_inode(struct inode *inode, bool want_writeable, + kuid_t uid, bool any); struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); static inline struct p9_fid *v9fs_parent_fid(struct dentry *dentry) { return v9fs_fid_lookup(dentry->d_parent); } void v9fs_fid_add(struct dentry *dentry, struct p9_fid **fid); -struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); void v9fs_open_fid_add(struct inode *inode, struct p9_fid **fid); static inline struct p9_fid *clone_fid(struct p9_fid *fid) { @@ -32,4 +34,33 @@ static inline struct p9_fid *v9fs_fid_clone(struct dentry *dentry) p9_fid_put(fid); return nfid; } +/** + * v9fs_fid_addmodes - add cache flags to fid mode (for client use only) + * @fid: fid to augment + * @s_flags: session info mount flags + * @s_cache: session info cache flags + * @f_flags: unix open flags + * + * make sure mode reflects flags of underlying mounts + * also qid.version == 0 reflects a synthetic or legacy file system + * NOTE: these are set after open so only reflect 9p client not + * underlying file system on server. + */ +static inline void v9fs_fid_add_modes(struct p9_fid *fid, int s_flags, + int s_cache, unsigned int f_flags) +{ + if (fid->qid.type != P9_QTFILE) + return; + + if ((!s_cache) || + ((fid->qid.version == 0) && !(s_flags & V9FS_IGNORE_QV)) || + (s_flags & V9FS_DIRECT_IO) || (f_flags & O_DIRECT)) { + fid->mode |= P9L_DIRECT; /* no read or write cache */ + } else if ((s_cache < CACHE_WRITEBACK) || + (f_flags & O_DSYNC) | (s_flags & V9FS_SYNC)) { + fid->mode |= P9L_NOWRITECACHE; + } else if (s_cache == CACHE_LOOSE) { + fid->mode |= P9L_LOOSE; /* noncoherent cache */ + } +} #endif diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 48c7614c9333..8be9c0f59679 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -118,7 +118,6 @@ struct v9fs_inode { struct netfs_inode netfs; /* Netfslib context and vfs inode */ struct p9_qid qid; unsigned int cache_validity; - struct p9_fid *writeback_fid; struct mutex v_mutex; }; diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c index 6f46d7e4c750..211165430a8a 100644 --- a/fs/9p/vfs_addr.c +++ b/fs/9p/vfs_addr.c @@ -57,8 +57,6 @@ static void v9fs_issue_read(struct netfs_io_subrequest *subreq) */ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) { - struct inode *inode = file_inode(file); - struct v9fs_inode *v9inode = V9FS_I(inode); struct p9_fid *fid = file->private_data; BUG_ON(!fid); @@ -66,11 +64,8 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) /* we might need to read from a fid that was opened write-only * for read-modify-write of page cache, use the writeback fid * for that */ - if (rreq->origin == NETFS_READ_FOR_WRITE && - (fid->mode & O_ACCMODE) == O_WRONLY) { - fid = v9inode->writeback_fid; - BUG_ON(!fid); - } + WARN_ON(rreq->origin == NETFS_READ_FOR_WRITE && + !(fid->mode & P9_ORDWR)); p9_fid_get(fid); rreq->netfs_priv = fid; @@ -164,6 +159,7 @@ static int v9fs_vfs_write_folio_locked(struct folio *folio) loff_t i_size = i_size_read(inode); struct iov_iter from; size_t len = folio_size(folio); + struct p9_fid *writeback_fid; int err; if (start >= i_size) @@ -173,13 +169,17 @@ static int v9fs_vfs_write_folio_locked(struct folio *folio) iov_iter_xarray(&from, ITER_SOURCE, &folio_mapping(folio)->i_pages, start, len); - /* We should have writeback_fid always set */ - BUG_ON(!v9inode->writeback_fid); + writeback_fid = v9fs_fid_find_inode(inode, true, INVALID_UID, true); + if (!writeback_fid) { + WARN_ONCE(1, "folio expected an open fid inode->i_private=%p\n", + inode->i_private); + return -EINVAL; + } folio_wait_fscache(folio); folio_start_writeback(folio); - p9_client_write(v9inode->writeback_fid, start, &from, &err); + p9_client_write(writeback_fid, start, &from, &err); if (err == 0 && fscache_cookie_enabled(cookie) && @@ -192,6 +192,8 @@ static int v9fs_vfs_write_folio_locked(struct folio *folio) } folio_end_writeback(folio); + p9_fid_put(writeback_fid); + return err; } diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 20e4bd299fc2..936daff9f948 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -42,7 +42,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) int err; struct v9fs_inode *v9inode; struct v9fs_session_info *v9ses; - struct p9_fid *fid, *writeback_fid; + struct p9_fid *fid; int omode; p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file); @@ -59,7 +59,19 @@ int v9fs_file_open(struct inode *inode, struct file *file) if (IS_ERR(fid)) return PTR_ERR(fid); - err = p9_client_open(fid, omode); + if ((v9ses->cache >= CACHE_WRITEBACK) && (omode & P9_OWRITE)) { + int writeback_omode = (omode & !P9_OWRITE) | P9_ORDWR; + + p9_debug(P9_DEBUG_CACHE, "write-only file with writeback enabled, try opening O_RDWR\n"); + err = p9_client_open(fid, writeback_omode); + if (err < 0) { + p9_debug(P9_DEBUG_CACHE, "could not open O_RDWR, disabling caches\n"); + err = p9_client_open(fid, omode); + fid->mode |= P9L_DIRECT; + } + } else { + err = p9_client_open(fid, omode); + } if (err < 0) { p9_fid_put(fid); return err; @@ -71,36 +83,14 @@ int v9fs_file_open(struct inode *inode, struct file *file) file->private_data = fid; } - mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && - ((file->f_flags & O_ACCMODE) != O_RDONLY)) { - /* - * clone a fid and add it to writeback_fid - * we do it during open time instead of - * page dirty time via write_begin/page_mkwrite - * because we want write after unlink usecase - * to work. - */ - writeback_fid = v9fs_writeback_fid(file_dentry(file)); - if (IS_ERR(writeback_fid)) { - err = PTR_ERR(writeback_fid); - mutex_unlock(&v9inode->v_mutex); - goto out_error; - } - v9inode->writeback_fid = (void *) writeback_fid; - } - mutex_unlock(&v9inode->v_mutex); #ifdef CONFIG_9P_FSCACHE if (v9ses->cache == CACHE_FSCACHE) fscache_use_cookie(v9fs_inode_cookie(v9inode), file->f_mode & FMODE_WRITE); #endif + v9fs_fid_add_modes(fid, v9ses->flags, v9ses->cache, file->f_flags); v9fs_open_fid_add(inode, &fid); return 0; -out_error: - p9_fid_put(file->private_data); - file->private_data = NULL; - return err; } /** @@ -366,14 +356,14 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct p9_fid *fid = iocb->ki_filp->private_data; int ret, err = 0; - struct inode *inode = file_inode(iocb->ki_filp); - struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); - p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n", - iov_iter_count(to), iocb->ki_pos); + p9_debug(P9_DEBUG_VFS, "fid %d count %zu offset %lld\n", + fid->fid, iov_iter_count(to), iocb->ki_pos); - if (v9ses->cache > CACHE_MMAP) + if (!(fid->mode & P9L_DIRECT)) { + p9_debug(P9_DEBUG_VFS, "(cached)\n"); return generic_file_read_iter(iocb, to); + } if (iocb->ki_filp->f_flags & O_NONBLOCK) ret = p9_client_read_once(fid, iocb->ki_pos, to, &err); @@ -396,14 +386,17 @@ static ssize_t v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; + struct p9_fid *fid = file->private_data; ssize_t retval; loff_t origin; int err = 0; - struct inode *inode = file_inode(iocb->ki_filp); - struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); - if (v9ses->cache >= CACHE_WRITEBACK) + p9_debug(P9_DEBUG_VFS, "fid %d\n", fid->fid); + + if (!(fid->mode & (P9L_DIRECT | P9L_NOWRITECACHE))) { + p9_debug(P9_DEBUG_CACHE, "(cached)\n"); return generic_file_write_iter(iocb, from); + } retval = generic_write_checks(iocb, from); if (retval <= 0) @@ -487,36 +480,18 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) { int retval; struct inode *inode = file_inode(filp); - struct v9fs_inode *v9inode = V9FS_I(inode); struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); - struct p9_fid *fid; + + p9_debug(P9_DEBUG_MMAP, "filp :%p\n", filp); if (v9ses->cache < CACHE_MMAP) { + p9_debug(P9_DEBUG_CACHE, "(no mmap mode)"); + if (vma->vm_flags & VM_MAYSHARE) + return -ENODEV; invalidate_inode_pages2(filp->f_mapping); return generic_file_readonly_mmap(filp, vma); } - mutex_lock(&v9inode->v_mutex); - if (!v9inode->writeback_fid && - (vma->vm_flags & VM_SHARED) && - (vma->vm_flags & VM_WRITE)) { - /* - * clone a fid and add it to writeback_fid - * we do it during mmap instead of - * page dirty time via write_begin/page_mkwrite - * because we want write after unlink usecase - * to work. - */ - fid = v9fs_writeback_fid(file_dentry(filp)); - if (IS_ERR(fid)) { - retval = PTR_ERR(fid); - mutex_unlock(&v9inode->v_mutex); - return retval; - } - v9inode->writeback_fid = (void *) fid; - } - mutex_unlock(&v9inode->v_mutex); - retval = generic_file_mmap(filp, vma); if (!retval) vma->vm_ops = &v9fs_mmap_file_vm_ops; @@ -527,7 +502,6 @@ v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma) static vm_fault_t v9fs_vm_page_mkwrite(struct vm_fault *vmf) { - struct v9fs_inode *v9inode; struct folio *folio = page_folio(vmf->page); struct file *filp = vmf->vma->vm_file; struct inode *inode = file_inode(filp); @@ -536,8 +510,6 @@ v9fs_vm_page_mkwrite(struct vm_fault *vmf) p9_debug(P9_DEBUG_VFS, "folio %p fid %lx\n", folio, (unsigned long)filp->private_data); - v9inode = V9FS_I(inode); - /* Wait for the page to be written to the cache before we allow it to * be modified. We then assume the entire page will need writing back. */ @@ -550,7 +522,6 @@ v9fs_vm_page_mkwrite(struct vm_fault *vmf) /* Update file times before taking page lock */ file_update_time(filp); - BUG_ON(!v9inode->writeback_fid); if (folio_lock_killable(folio) < 0) return VM_FAULT_RETRY; if (folio_mapping(folio) != inode->i_mapping) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 8ffa6631b1fd..d53475e1ba27 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -259,7 +259,6 @@ struct inode *v9fs_alloc_inode(struct super_block *sb) v9inode = alloc_inode_sb(sb, v9fs_inode_cache, GFP_KERNEL); if (!v9inode) return NULL; - v9inode->writeback_fid = NULL; v9inode->cache_validity = 0; mutex_init(&v9inode->v_mutex); return &v9inode->netfs.inode; @@ -412,9 +411,6 @@ void v9fs_evict_inode(struct inode *inode) filemap_fdatawrite(&inode->i_data); fscache_relinquish_cookie(v9fs_inode_cookie(v9inode), false); - /* clunk the fid stashed in writeback_fid */ - p9_fid_put(v9inode->writeback_fid); - v9inode->writeback_fid = NULL; } static int v9fs_test_inode(struct inode *inode, void *data) @@ -825,9 +821,10 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, u32 perm; struct v9fs_inode *v9inode; struct v9fs_session_info *v9ses; - struct p9_fid *fid, *inode_fid; + struct p9_fid *fid; struct dentry *res = NULL; struct inode *inode; + int p9_omode; if (d_in_lookup(dentry)) { res = v9fs_vfs_lookup(dir, dentry, 0); @@ -846,9 +843,14 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, v9ses = v9fs_inode2v9ses(dir); perm = unixmode2p9mode(v9ses, mode); - fid = v9fs_create(v9ses, dir, dentry, NULL, perm, - v9fs_uflags2omode(flags, - v9fs_proto_dotu(v9ses))); + p9_omode = v9fs_uflags2omode(flags, v9fs_proto_dotu(v9ses)); + + if ((v9ses->cache >= CACHE_WRITEBACK) && (p9_omode & P9_OWRITE)) { + p9_omode = (p9_omode & !P9_OWRITE) | P9_ORDWR; + p9_debug(P9_DEBUG_CACHE, + "write-only file with writeback enabled, creating w/ O_RDWR\n"); + } + fid = v9fs_create(v9ses, dir, dentry, NULL, perm, p9_omode); if (IS_ERR(fid)) { err = PTR_ERR(fid); goto error; @@ -857,25 +859,6 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, v9fs_invalidate_inode_attr(dir); inode = d_inode(dentry); v9inode = V9FS_I(inode); - mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache >= CACHE_WRITEBACK) && !v9inode->writeback_fid && - ((flags & O_ACCMODE) != O_RDONLY)) { - /* - * clone a fid and add it to writeback_fid - * we do it during open time instead of - * page dirty time via write_begin/page_mkwrite - * because we want write after unlink usecase - * to work. - */ - inode_fid = v9fs_writeback_fid(dentry); - if (IS_ERR(inode_fid)) { - err = PTR_ERR(inode_fid); - mutex_unlock(&v9inode->v_mutex); - goto error; - } - v9inode->writeback_fid = (void *) inode_fid; - } - mutex_unlock(&v9inode->v_mutex); err = finish_open(file, dentry, generic_file_open); if (err) goto error; @@ -884,6 +867,8 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) fscache_use_cookie(v9fs_inode_cookie(v9inode), file->f_mode & FMODE_WRITE); + + v9fs_fid_add_modes(fid, v9ses->flags, v9ses->cache, file->f_flags); v9fs_open_fid_add(inode, &fid); file->f_mode |= FMODE_CREATED; @@ -1053,7 +1038,7 @@ v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path, p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); v9ses = v9fs_dentry2v9ses(dentry); if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { - generic_fillattr(&init_user_ns, d_inode(dentry), stat); + generic_fillattr(&init_user_ns, inode, stat); return 0; } else if (v9ses->cache >= CACHE_WRITEBACK) { if (S_ISREG(inode->i_mode)) @@ -1148,10 +1133,10 @@ static int v9fs_vfs_setattr(struct user_namespace *mnt_userns, if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size != i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); + truncate_pagecache(inode, iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); - else - invalidate_mapping_pages(&inode->i_data, 0, -1); } v9fs_invalidate_inode_attr(inode); diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 4f01808c3bae..f5f15878cbb7 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -232,12 +232,12 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, int err = 0; kgid_t gid; umode_t mode; + int p9_omode = v9fs_open_to_dotl_flags(flags); const unsigned char *name = NULL; struct p9_qid qid; struct inode *inode; struct p9_fid *fid = NULL; - struct v9fs_inode *v9inode; - struct p9_fid *dfid = NULL, *ofid = NULL, *inode_fid = NULL; + struct p9_fid *dfid = NULL, *ofid = NULL; struct v9fs_session_info *v9ses; struct posix_acl *pacl = NULL, *dacl = NULL; struct dentry *res = NULL; @@ -282,14 +282,19 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, /* Update mode based on ACL value */ err = v9fs_acl_mode(dir, &mode, &dacl, &pacl); if (err) { - p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n", + p9_debug(P9_DEBUG_VFS, "Failed to get acl values in create %d\n", err); goto out; } - err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags), - mode, gid, &qid); + + if ((v9ses->cache >= CACHE_WRITEBACK) && (p9_omode & P9_OWRITE)) { + p9_omode = (p9_omode & !P9_OWRITE) | P9_ORDWR; + p9_debug(P9_DEBUG_CACHE, + "write-only file with writeback enabled, creating w/ O_RDWR\n"); + } + err = p9_client_create_dotl(ofid, name, p9_omode, mode, gid, &qid); if (err < 0) { - p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n", + p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in create %d\n", err); goto out; } @@ -314,36 +319,19 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, v9fs_fid_add(dentry, &fid); d_instantiate(dentry, inode); - v9inode = V9FS_I(inode); - mutex_lock(&v9inode->v_mutex); - if ((v9ses->cache) && !v9inode->writeback_fid && - ((flags & O_ACCMODE) != O_RDONLY)) { - /* - * clone a fid and add it to writeback_fid - * we do it during open time instead of - * page dirty time via write_begin/page_mkwrite - * because we want write after unlink usecase - * to work. - */ - inode_fid = v9fs_writeback_fid(dentry); - if (IS_ERR(inode_fid)) { - err = PTR_ERR(inode_fid); - mutex_unlock(&v9inode->v_mutex); - goto out; - } - v9inode->writeback_fid = (void *) inode_fid; - } - mutex_unlock(&v9inode->v_mutex); /* Since we are opening a file, assign the open fid to the file */ err = finish_open(file, dentry, generic_file_open); if (err) goto out; file->private_data = ofid; #ifdef CONFIG_9P_FSCACHE - if (v9ses->cache == CACHE_FSCACHE) + if (v9ses->cache == CACHE_FSCACHE) { + struct v9fs_inode *v9inode = V9FS_I(inode); fscache_use_cookie(v9fs_inode_cookie(v9inode), file->f_mode & FMODE_WRITE); + } #endif + v9fs_fid_add_modes(ofid, v9ses->flags, v9ses->cache, flags); v9fs_open_fid_add(inode, &ofid); file->f_mode |= FMODE_CREATED; out: @@ -464,9 +452,9 @@ v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns, p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); v9ses = v9fs_dentry2v9ses(dentry); if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { - generic_fillattr(&init_user_ns, d_inode(dentry), stat); + generic_fillattr(&init_user_ns, inode, stat); return 0; - } else if (v9ses->cache >= CACHE_WRITEBACK) { + } else if (v9ses->cache) { if (S_ISREG(inode->i_mode)) v9fs_flush_inode_writeback(inode); @@ -605,10 +593,10 @@ int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns, if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size != i_size_read(inode)) { truncate_setsize(inode, iattr->ia_size); + truncate_pagecache(inode, iattr->ia_size); + if (v9ses->cache == CACHE_FSCACHE) fscache_resize_cookie(v9fs_inode_cookie(v9inode), iattr->ia_size); - else - invalidate_mapping_pages(&inode->i_data, 0, -1); } v9fs_invalidate_inode_attr(inode); diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 5fc6a945bfff..797f717e1a91 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -292,23 +292,26 @@ static int v9fs_write_inode(struct inode *inode, { int ret; struct p9_wstat wstat; + struct p9_fid *fid = v9fs_fid_find_inode(inode, false, INVALID_UID, true); struct v9fs_inode *v9inode; + /* * send an fsync request to server irrespective of * wbc->sync_mode. */ - p9_debug(P9_DEBUG_VFS, "%s: inode %p\n", __func__, inode); + p9_debug(P9_DEBUG_VFS, "%s: inode %p writeback_fid: %p\n", __func__, inode, fid); v9inode = V9FS_I(inode); - if (!v9inode->writeback_fid) - return 0; + if (!fid) + return -EINVAL; v9fs_blank_wstat(&wstat); - ret = p9_client_wstat(v9inode->writeback_fid, &wstat); + ret = p9_client_wstat(fid, &wstat); if (ret < 0) { __mark_inode_dirty(inode, I_DIRTY_DATASYNC); return ret; } fscache_unpin_writeback(wbc, v9fs_inode_cookie(v9inode)); + p9_fid_put(fid); return 0; } @@ -316,6 +319,7 @@ static int v9fs_write_inode_dotl(struct inode *inode, struct writeback_control *wbc) { int ret; + struct p9_fid *fid = v9fs_fid_find_inode(inode, FMODE_WRITE, INVALID_UID, 1); struct v9fs_inode *v9inode; /* * send an fsync request to server irrespective of @@ -323,16 +327,17 @@ static int v9fs_write_inode_dotl(struct inode *inode, */ v9inode = V9FS_I(inode); p9_debug(P9_DEBUG_VFS, "%s: inode %p, writeback_fid %p\n", - __func__, inode, v9inode->writeback_fid); - if (!v9inode->writeback_fid) - return 0; + __func__, inode, fid); + if (!fid) + return -EINVAL; - ret = p9_client_fsync(v9inode->writeback_fid, 0); + ret = p9_client_fsync(fid, 0); if (ret < 0) { __mark_inode_dirty(inode, I_DIRTY_DATASYNC); return ret; } fscache_unpin_writeback(wbc, v9fs_inode_cookie(v9inode)); + p9_fid_put(fid); return 0; } From patchwork Sat Feb 18 00:33:23 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: 58866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp149201wrn; Fri, 17 Feb 2023 16:52:34 -0800 (PST) X-Google-Smtp-Source: AK7set8lACYOoXrhjgH2BhJkV2U/79vJ6UETCa04XB3FwiD1cJ05tPZtrDwVuYfNrl2ZkTltqqkz X-Received: by 2002:a17:903:187:b0:19a:a6cd:35a8 with SMTP id z7-20020a170903018700b0019aa6cd35a8mr8386812plg.25.1676681553929; Fri, 17 Feb 2023 16:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681553; cv=none; d=google.com; s=arc-20160816; b=oi7/VccFkVsaI3skXkazEa3pc3weLNF7dVbVxH7AnoxX2ePoLnz9olwwzmSNQ+2TD+ ynqqlz6/8hVIgSNN6FYhSl+ruF4xhE47/WKkQOqlhpO/PWfedpIKEilSR4xuj2rtP/WJ wR93t0hbAsFGgAkJHbZnejlsxl24TJCnXmd/eBVOgWFQcfdyiM40zaTRO9sKlNTVU0X8 Z/o53jnpQopbFp2E1fPb0B1ao9Rzp6lbJwcUUc8padWyDDQKwLFakZZV3r0NrdlgSIom bXhtOVVs19L1oJghCprtYn3AP21Fzazg/z4LXJ9MZ5UUmrBniLjQBcCRdtPP+Hhw7q3m YDPg== 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=4ca/fSLz84+8zt25NEHBciinMYKl2LpEMEovBvxwZ9Y=; b=liy6icuXtmnOUNIAI9yVnOkdjdfoayu8qfHgEeN5s5euXNMs3sMu9GWmAe3GT1zdFw JU4KmpTMNj2mNuCX3IgAvGxjODo5W4W3UsP5ENWaHYcpY3PbAHR1vAARRaHNlh+cH2w9 tL7HdtF1A0VNP35bgW0dq9autdeB2HtkmsHWWlEVU0xH4fJPLI59hs6ddlFLFtasdwXN 15EmQUXv8OSilzFa9R2LMbZ15oB5Cy147aVfZ33POjKfkkUjy7we5rXH5IvuYfpmfh7d GoOqMIVYWt6YuLF57TUKlQHUICa09IPSnR+MQ4hyrz/lAjLzNQJ6QdN6IvWL1KW6y0/I F4qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AnkqWYzF; 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 e4-20020a635004000000b004fb165e159bsi5678067pgb.794.2023.02.17.16.52.21; Fri, 17 Feb 2023 16:52:33 -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=AnkqWYzF; 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 S229703AbjBRAs0 (ORCPT + 99 others); Fri, 17 Feb 2023 19:48:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjBRAsY (ORCPT ); Fri, 17 Feb 2023 19:48:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BBA1193F9; Fri, 17 Feb 2023 16:47:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 01D01620AE; Sat, 18 Feb 2023 00:34:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 938A9C433D2; Sat, 18 Feb 2023 00:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676680445; bh=fE7TnKGk+7sECniXW1Co7rrNpfck1npdV3aCIbmWvVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AnkqWYzFMTcdBZm4UR/n3WPvCPfwOaEkymB8fMNPzSu0yOxGLVyau2YonIEyaQqoL H1m4s4pnyONyULyAczlSbveBWREsET+3AZnQvVr4sFVPoAraoRstlRDW6lPMP7r6sW JRybBRGFFujDXu1tXKRT4axSewCYNlRcsbjD9pw8XxGl0dOkA0kU/UXUkV2npA5J44 HpQr5oj/1qWUKUfbEVz5eb1EIRclPNLvl5RzZiDwy9Mp76CoaCttX1bgibxDb5KiUB d+3vnLsbMfPviaSfeaSy2zMxKTpYZxc5BKlfl7BtGImwSvyHie7kCN9dknVu4ClUGO IzO9GwMrSJcdw== 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 11/11] fs/9p: Fix revalidate Date: Sat, 18 Feb 2023 00:33:23 +0000 Message-Id: <20230218003323.2322580-12-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?1758128036828850117?= X-GMAIL-MSGID: =?utf-8?q?1758128036828850117?= Unclear if this case ever happens, but if no inode in dentry, then the dentry is definitely invalid. Seemed to be the opposite in the existing code. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_dentry.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 65fa2df5e49b..b0c3f8e8ea00 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c @@ -68,7 +68,7 @@ static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) inode = d_inode(dentry); if (!inode) - goto out_valid; + return 0; v9inode = V9FS_I(inode); if (v9inode->cache_validity & V9FS_INO_INVALID_ATTR) { @@ -91,7 +91,6 @@ static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) if (retval < 0) return retval; } -out_valid: return 1; }