[RFC PATCH 5/6] fs/9p: .L: Refresh stale inodes on reuse
Tingmao Wang
m at maowtm.org
Sun Apr 6 20:43:06 UTC 2025
Only for uncached mode for now. We will need to revisit this for cached
mode once we sort out reusing an old inode with changed qid.version.
Note that v9fs_test(_new)?_inode_dotl already makes sure we don't reuse
inodes of the wrong type or different qid.
Signed-off-by: Tingmao Wang <m at maowtm.org>
---
fs/9p/vfs_inode_dotl.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index c1cc3553f2fb..20434a25cb22 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -187,8 +187,23 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
if (!inode)
return ERR_PTR(-ENOMEM);
- if (!(inode->i_state & I_NEW))
+ if (!(inode->i_state & I_NEW)) {
+ /*
+ * If we're returning an existing inode, we might as well refresh
+ * it with the metadata we just got. Refreshing the i_size also
+ * prevents read errors.
+ *
+ * We only do this for uncached mode, since in cached move, any
+ * change on the inode will bump qid.version, which will result in
+ * us getting a new inode in the first place. If we got an old
+ * inode, let's not touch it for now.
+ */
+ if (new) {
+ v9fs_stat2inode_dotl(st, inode,
+ (v9ses->cache & CACHE_LOOSE) ? V9FS_STAT2INODE_KEEP_ISIZE : 0);
+ }
return inode;
+ }
/*
* initialize the inode with the stat info
* FIXME!! we may need support for stale inodes
--
2.39.5
More information about the Linux-security-module-archive
mailing list