Re: [PATCH v6 2/2] fuse: add new function to invalidate cache for all inodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 19 Feb 2025 at 12:23, Luis Henriques <luis@xxxxxxxxxx> wrote:

> +static int fuse_notify_update_epoch(struct fuse_conn *fc)
> +{
> +       struct fuse_mount *fm;
> +       struct inode *inode;
> +
> +       inode = fuse_ilookup(fc, FUSE_ROOT_ID, &fm);
> +       if (!inode) || !fm)
> +               return -ENOENT;
> +
> +       iput(inode);
> +       atomic_inc(&fc->epoch);
> +       shrink_dcache_sb(fm->sb);

This is just an optimization and could be racy, kicking out valid
cache (harmlessly of course).  I'd leave it out of the first version.

There could be more than one fuse_mount instance.  Wondering if epoch
should be per-fm not per-fc...

> @@ -204,6 +204,12 @@ static int fuse_dentry_revalidate(struct inode *dir, const struct qstr *name,
>         int ret;
>
>         inode = d_inode_rcu(entry);
> +       if (inode) {
> +               fm = get_fuse_mount(inode);
> +               if (entry->d_time < atomic_read(&fm->fc->epoch))
> +                       goto invalid;
> +       }

Negative dentries need to be invalidated too.

> @@ -446,6 +452,12 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
>                 goto out_err;
>
>         entry = newent ? newent : entry;
> +       if (inode) {
> +               struct fuse_mount *fm = get_fuse_mount(inode);
> +               entry->d_time = atomic_read(&fm->fc->epoch);
> +       } else {
> +               entry->d_time = 0;
> +       }

Again, should do the same for positive and negative dentries.

Need to read out fc->epoch before sending the request to the server,
otherwise might get a stale dentry with an updated epoch.

This also needs to be done in fuse_create_open(), create_new_entry()
and fuse_direntplus_link().

Thanks,
Miklos




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux