From: asmadeus@codewreck.org
To: Eric Van Hensbergen <ericvh@kernel.org>
Cc: v9fs-developer@lists.sourceforge.net, rminnich@gmail.com,
lucho@ionkov.net, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux_oss@crudebyte.com
Subject: Re: [PATCH v4 03/11] fs/9p: Consolidate file operations and add readahead and writeback
Date: Sat, 18 Feb 2023 18:24:36 +0900 [thread overview]
Message-ID: <Y/CZVEQPFFo0zMjo@codewreck.org> (raw)
In-Reply-To: <20230218003323.2322580-4-ericvh@kernel.org>
Eric Van Hensbergen wrote on Sat, Feb 18, 2023 at 12:33:15AM +0000:
> 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 <ericvh@kernel.org>
Reviewed-by: Dominique Martinet <asmadeus@codewreck.org>
> ---
> 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);
> +
Ok so this bugged me to no end; that seems to be because we use the same
v9fs_dir_release for v9fs_file_operations's .release and not just
v9fs_dir_operations... So it's to be expected we'll get files here.
At this point I'd suggest to use two functions, but that's probably
overdoing it.
Let's check S_ISREG(inode->i_mode) instead of fid->qid though; it
shouldn't make any difference but that's what you use in other parts of
the code and it will be easier to understand for people familiar with
the vfs.
> 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);
Hmm, that function only starts the writeback, but doesn't wait for it.
Wasn't the point to replace 'filemap_write_and_wait' with
v9fs_flush_inode_writeback?
I don't think it's a good idea to remove the wait before setattrs and
the like; if you don't want to wait on close()'s release (but we
probably should too) perhaps split this in two?
> 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
> @@ -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);
Hm, I don't think these are exclusive; resize_cookie doesn't seem to do
much about the page cache.
However, truncate_setsize calls trucate_pagecache which I believe does
the right thing; and I don't see why we would need to invalidate
[0;size[ here? We didn't before.
. . . . . . .
Ah, you've replaced it preciesly with that in "fs/9p: writeback mode
fixes"; this is annoying to review :/
So with that problem gone, I think I'm ok with this patch with the
exception of the flush inode writeback that doesn't wait (and the
nitpick on S_ISREG)
--
Dominique
next prev parent reply other threads:[~2023-02-18 9:25 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221217183142.1425132-1-evanhensbergen@icloud.com>
2022-12-18 23:22 ` [PATCH v2 00/10] Performance fixes for 9p filesystem Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 01/10] Adjust maximum MSIZE to account for p9 header Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 02/10] Expand setup of writeback cache to all levels Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 03/10] Consolidate file operations and add readahead and writeback Eric Van Hensbergen
2023-01-24 2:43 ` asmadeus
2023-01-24 3:03 ` Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 04/10] Remove unnecessary superblock flags Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 05/10] allow disable of xattr support on mount Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 06/10] fix bug in client create for .L Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 07/10] Add additional debug flags and open modes Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 08/10] Add new mount modes Eric Van Hensbergen
2023-01-24 3:35 ` Amir Goldstein
2022-12-18 23:22 ` [PATCH v2 09/10] fix error reporting in v9fs_dir_release Eric Van Hensbergen
2022-12-18 23:22 ` [PATCH v2 10/10] writeback mode fixes Eric Van Hensbergen
2023-01-23 16:31 ` [PATCH v2 00/10] Performance fixes for 9p filesystem Christian Schoenebeck
2023-01-24 2:33 ` evanhensbergen
2023-01-24 2:49 ` asmadeus
2023-01-24 2:38 ` [PATCH v3 00/11] " Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 01/11] Adjust maximum MSIZE to account for p9 header Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 02/11] Expand setup of writeback cache to all levels Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 03/11] Consolidate file operations and add readahead and writeback Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 04/11] Remove unnecessary superblock flags Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 05/11] allow disable of xattr support on mount Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 06/11] fix bug in client create for .L Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 07/11] Add additional debug flags and open modes Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 08/11] Add new mount modes Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 09/11] fix error reporting in v9fs_dir_release Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 10/11] writeback mode fixes Eric Van Hensbergen
2023-01-24 2:38 ` [PATCH v3 11/11] Fix revalidate Eric Van Hensbergen
2023-02-02 11:27 ` [PATCH v3 00/11] Performance fixes for 9p filesystem Christian Schoenebeck
2023-02-03 19:12 ` Eric Van Hensbergen
2023-02-04 13:40 ` Christian Schoenebeck
2023-02-04 21:38 ` Eric Van Hensbergen
2023-02-05 16:37 ` Eric Van Hensbergen
2023-02-06 13:20 ` Christian Schoenebeck
2023-02-06 13:37 ` Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 " Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 01/11] net/9p: Adjust maximum MSIZE to account for p9 header Eric Van Hensbergen
2023-02-18 7:50 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 02/11] fs/9p: Expand setup of writeback cache to all levels Eric Van Hensbergen
2023-02-18 8:57 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 03/11] fs/9p: Consolidate file operations and add readahead and writeback Eric Van Hensbergen
2023-02-18 9:24 ` asmadeus [this message]
2023-02-18 16:17 ` Eric Van Hensbergen
2023-02-18 16:19 ` Eric Van Hensbergen
2023-02-18 20:35 ` asmadeus
2023-02-27 2:50 ` [PATCH v5 3/11] " Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 04/11] fs/9p: Remove unnecessary superblock flags Eric Van Hensbergen
2023-02-18 9:33 ` asmadeus
2023-02-18 16:24 ` Eric Van Hensbergen
2023-02-18 20:30 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 05/11] fs/9p: allow disable of xattr support on mount Eric Van Hensbergen
2023-02-18 7:52 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 06/11] net/9p: fix bug in client create for .L Eric Van Hensbergen
2023-02-18 8:01 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 07/11] 9p: Add additional debug flags and open modes Eric Van Hensbergen
2023-02-18 8:05 ` asmadeus
2023-02-27 2:53 ` [PATCH v5 7/11] " Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 08/11] fs/9p: Add new mount modes Eric Van Hensbergen
2023-02-18 8:46 ` asmadeus
2023-02-27 2:55 ` [PATCH v5 8/11] " Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 09/11] fs/9p: fix error reporting in v9fs_dir_release Eric Van Hensbergen
2023-02-18 8:49 ` asmadeus
2023-02-18 0:33 ` [PATCH v4 10/11] fs/9p: writeback mode fixes Eric Van Hensbergen
2023-02-18 8:38 ` asmadeus
2023-02-18 10:01 ` asmadeus
2023-02-18 12:15 ` asmadeus
2023-02-18 16:40 ` Eric Van Hensbergen
2023-02-18 20:29 ` asmadeus
2023-03-21 1:12 ` Eric Van Hensbergen
2023-02-18 19:58 ` Christian Schoenebeck
2023-02-18 22:24 ` Eric Van Hensbergen
2023-02-18 23:40 ` asmadeus
2023-02-18 23:52 ` Eric Van Hensbergen
2023-03-27 2:59 ` [PATCH v5] fs/9p: remove writeback fid and fix per-file modes Eric Van Hensbergen
2023-04-25 7:11 ` Christophe JAILLET
2023-04-25 11:13 ` asmadeus
2023-04-26 0:01 ` Eric Van Hensbergen
2023-02-18 0:33 ` [PATCH v4 11/11] fs/9p: Fix revalidate Eric Van Hensbergen
2023-02-18 8:55 ` asmadeus
2023-02-18 7:48 ` [PATCH v4 00/11] Performance fixes for 9p filesystem asmadeus
2023-02-19 21:36 ` Christian Schoenebeck
2023-02-20 1:13 ` Eric Van Hensbergen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/CZVEQPFFo0zMjo@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=ericvh@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=rminnich@gmail.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox