[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z7UED8Gh7Uo-Yj6K@dread.disaster.area>
Date: Wed, 19 Feb 2025 09:05:03 +1100
From: Dave Chinner <david@...morbit.com>
To: Luis Henriques <luis@...lia.com>
Cc: Miklos Szeredi <miklos@...redi.hu>, Bernd Schubert <bschubert@....com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Matt Harvey <mharvey@...ptrading.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Valentin Volkl <valentin.volkl@...n.ch>,
Laura Promberger <laura.promberger@...n.ch>
Subject: Re: [PATCH v6 2/2] fuse: add new function to invalidate cache for
all inodes
On Tue, Feb 18, 2025 at 06:11:17PM +0000, Luis Henriques wrote:
> On Tue, Feb 18 2025, Miklos Szeredi wrote:
>
> > On Tue, 18 Feb 2025 at 12:51, Luis Henriques <luis@...lia.com> wrote:
> >>
> >> On Tue, Feb 18 2025, Miklos Szeredi wrote:
> >>
> >> > On Tue, 18 Feb 2025 at 11:04, Luis Henriques <luis@...lia.com> wrote:
> >> >
> >> >> The problem I'm trying to solve is that, if a filesystem wants to ask the
> >> >> kernel to get rid of all inodes, it has to request the kernel to forget
> >> >> each one, individually. The specific filesystem I'm looking at is CVMFS,
> >> >> which is a read-only filesystem that needs to be able to update the full
> >> >> set of filesystem objects when a new generation snapshot becomes
> >> >> available.
> >> >
> >> > Yeah, we talked about this use case. As I remember there was a
> >> > proposal to set an epoch, marking all objects for "revalidate needed",
> >> > which I think is a better solution to the CVMFS problem, than just
> >> > getting rid of unused objects.
> >>
> >> OK, so I think I'm missing some context here. And, obviously, I also miss
> >> some more knowledge on the filesystem itself. But, if I understand it
> >> correctly, the concept of 'inode' in CVMFS is very loose: when a new
> >> snapshot generation is available (you mentioned 'epoch', which is, I
> >> guess, the same thing) the inodes are all renewed -- the inode numbers
> >> aren't kept between generations/epochs.
> >>
> >> Do you have any links for such discussions, or any details on how this
> >> proposal is being implemented? This would probably be done mostly in
> >> user-space I guess, but it would still need a way to get rid of the unused
> >> inodes from old snapshots, right? (inodes from old snapshots still in use
> >> would obvious be kept aroud).
> >
> > I don't have links. Adding Valentin Volkl and Laura Promberger to the
> > Cc list, maybe they can help with clarification.
> >
> > As far as I understand it would work by incrementing fc->epoch on
> > FUSE_INVALIDATE_ALL. When an object is looked up/created the current
> > epoch is copied to e.g. dentry->d_time. fuse_dentry_revalidate() then
> > compares d_time with fc->epoch and forces an invalidate on mismatch.
>
> OK, so hopefully Valentin or Laura will be able to help providing some
> more details. But, from your description, we would still require this
> FUSE_INVALIDATE_ALL operation to exist in order to increment the epoch.
> And this new operation could do that *and* also already invalidate those
> unused objects.
I think you are still looking at this from the wrong direction.
Invalidation is -not the operation- that is being requested. The
CVMFS fuse server needs to update some global state in the kernel
side fuse mount (i.e. the snapshot ID/epoch), and the need to evict
cached inodes from previous IDs is a CVMFS implementation
optimisation related to changing the global state.
> > Only problem with this is that it seems very CVMFS specific, but I
> > guess so is your proposal.
> >
> > Implementing the LRU purge is more generally useful, but I'm not sure
> > if that helps CVMFS, since it would only get rid of unused objects.
>
> The LRU inodes purge can indeed work for me as well, because my patch is
> also only getting rid of unused objects, right? Any inode still being
> referenced will be kept around.
>
> So, based on your reply, let me try to summarize a possible alternative
> solution, that I think would be useful for CVMFS but also generic enough
> for other filesystems:
>
> - Add a new operation FUSE_INVAL_LRU_INODES, which would get rid of, at
> most, 'N' unused inodes.
>
> - This operation would have an argument 'N' with the maximum number of
> inodes to invalidate.
>
> - In addition, it would also increment this new fuse_connection attribute
> 'epoch', to be used in the dentry revalidation as you suggested above
As per above: invalidation is an implementation optimisation for the
CVMFS epoch update. Invalidation, OTOH, does not imply that any fuse
mount/connector global state (e.g. the epoch) needs to change...
ii.e. the operation should be FUSE_UPDATE_EPOCH, not
FUSE_INVAL_LRU_INODES...
>
> - This 'N' could also be set to a pre-#define'ed value that would mean
> *all* (unused) inodes.
Saying "only invalidate N inodes" makes no sense to me - it is
fundamentally impossible for userspace to get right. Either the
epoch update should evict all unreferenced inodes immediately, or it
should leave them all behind to be purged by memory pressure or
other periodic garbage collection mechanisms.
-Dave.
--
Dave Chinner
david@...morbit.com
Powered by blists - more mailing lists