Re: [PATCH v7 4/4] 9p: Enable symlink caching in page cache

From: Dominique Martinet

Date: Fri Jul 03 2026 - 10:47:23 EST


Remi Pommarel wrote on Thu, May 21, 2026 at 11:40:32AM +0200:
> Currently, when cache=loose is enabled, file reads are cached in the
> page cache, but symlink reads are not. This patch allows the results
> of p9_client_readlink() to be stored in the page cache, eliminating
> the need for repeated 9P transactions on subsequent symlink accesses.
>
> This change improves performance for workloads that involve frequent
> symlink resolution.

Hi Remi, David,

This is similar to what is being discussed in [1] about file size not
matching data in sysfs, but this breaks symlinks there as well because
they have a size of 0...
[1] https://lore.kernel.org/all/akfHGcqke9qixd3Q@xxxxxxxxxxxxx/


With /sys exported with tag 'test':
-virtfs local,path=/sys,mount_tag=test,security_model=none,multidevs=forbid

Then
# mount -t 9p -o cache=loose test /mnt
# ls -l /mnt/class/net
total 0
lrwxrwxrwx 1 nobody nogroup 0 Apr 30 22:07 lo -> ''
lrwxrwxrwx 1 nobody nogroup 0 Apr 30 22:07 dummy0 -> ''


I think we could just straight up ignore the size for symlinks and just
try to read it like we do with cache=none (that still works)?

OTOH someone mounting /sys with cache is likely to get rough surprises
so I'm not sure it's worth spending much time on such bogus files,
leaving this up to you, but wanted to bring symlinks up separately as
it's a new feature

Thanks,
--
Dominique Martinet | Asmadeus