linux/fs/9p
Dominique Martinet 43c36a56cc Revert "fs/9p: Refresh metadata in d_revalidate for uncached mode too"
This reverts commit 290434474c.

That commit broke cache=mmap, a mode that doesn't cache metadata,
but still has writeback cache.

In commit 290434474c ("fs/9p: Refresh metadata in d_revalidate
for uncached mode too") we considered metadata cache to be enough to
not look at the server, but in writeback cache too looking at the server
size would make the vfs consider the file has been truncated before the
data has been flushed out, making the following repro fail (nothing is
ever read back, the resulting file ends up with no data written)
```
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

char buf[4096];

int main(int argc, char *argv[])
{
        int ret, i;
        int fdw, fdr;

        if (argc < 2)
                return 1;

        fdw = openat(AT_FDCWD, argv[1], O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600);
        if (fdw < 0) {
                fprintf(stderr, "cannot open fdw\n");
                return 1;
        }
        write(fdw, buf, sizeof(buf));

        fdr = openat(AT_FDCWD, argv[1], O_RDONLY|O_CLOEXEC);

        if (fdr < 0) {
                fprintf(stderr, "cannot open fdr\n");
                close(fdw);
                return 1;
        }

        for (i = 0; i < 10; i++) {
                ret = read(fdr, buf, sizeof(buf));
                fprintf(stderr, "i: %d, read returns %d\n", i, ret);
        }

        close(fdr);
        close(fdw);
        return 0;
}
```

There is a fix for this particular reproducer but it looks like there
are other problems around metadata refresh (e.g. around file rename), so
revert this to avoid d_revalidate in uncached mode for now.

Reported-by: Song Liu <song@kernel.org>
Link: https://lkml.kernel.org/r/CAHzjS_u_SYdt5=2gYO_dxzMKXzGMt-TfdE_ueowg-Hq5tRCAiw@mail.gmail.com
Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Link: https://lore.kernel.org/bpf/CAEf4BzZbCE4tLoDZyUf_aASpgAGFj75QMfSXX4a4dLYixnOiLg@mail.gmail.com/
Fixes: 290434474c ("fs/9p: Refresh metadata in d_revalidate for uncached mode too")
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
2025-10-22 14:25:27 +09:00
..
Kconfig 9p: Remove INET dependency 2023-05-04 21:46:57 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acl.c fs: port inode_owner_or_capable() to mnt_idmap 2023-01-19 09:24:29 +01:00
acl.h fs: port ->set_acl() to pass mnt_idmap 2023-01-19 09:24:27 +01:00
cache.c mm, netfs, fscache: stop read optimisation when folio removed from pagecache 2023-08-18 10:12:13 -07:00
cache.h fs/9p: Rework cache modes and add new options to Documentation 2023-04-09 21:41:21 +00:00
fid.c 9p: v9fs_fid_find: also lookup by inode if not found dentry 2024-09-23 05:51:27 +09:00
fid.h fs/9p: fix the cache always being enabled on files with qid flags 2024-03-28 15:10:29 +00:00
v9fs.c 9p: sysfs_init: don't hardcode error to ENOMEM 2025-09-27 21:44:38 +09:00
v9fs.h 9p: fix ->rename_sem exclusion 2025-01-27 19:25:24 -05:00
v9fs_vfs.h Revert "fs/9p: simplify iget to remove unnecessary paths" 2024-10-25 06:26:09 +09:00
vfs_addr.c vfs-6.16-rc1.netfs 2025-06-02 15:04:06 -07:00
vfs_dentry.c Revert "fs/9p: Refresh metadata in d_revalidate for uncached mode too" 2025-10-22 14:25:27 +09:00
vfs_dir.c fs/9p: rework qid2ino logic 2024-01-26 16:46:56 +00:00
vfs_file.c fs: convert most other generic_file_*mmap() users to .mmap_prepare() 2025-06-19 13:56:57 +02:00
vfs_inode.c Revert "fs/9p: Refresh metadata in d_revalidate for uncached mode too" 2025-10-22 14:25:27 +09:00
vfs_inode_dotl.c Revert "fs/9p: Refresh metadata in d_revalidate for uncached mode too" 2025-10-22 14:25:27 +09:00
vfs_super.c fs: rename generic_delete_inode() and generic_drop_inode() 2025-09-15 16:09:42 +02:00
xattr.c Bunch of small fixes: 2023-11-04 09:20:04 -10:00
xattr.h 9p: move xattr-related structs to .rodata 2023-10-09 16:24:16 +02:00