Re: [PATCH v4 38/68] vfs, cachefiles: Mark a backing file in use with an inode flag

From: David Howells
Date: Sat Jan 08 2022 - 03:41:47 EST


Amir Goldstein <amir73il@xxxxxxxxx> wrote:

> > - if (is_local_mountpoint(dentry))
> > + if (is_local_mountpoint(dentry) ||
> > + (dentry->d_inode->i_flags & S_KERNEL_FILE))
>
> Better as this check to the many other checks in may_delete()

Okay. It will make things a bit more complicated, so I'll do it in a follow
up patch. The problem is that it will prevent the cachefiles driver in the
kernel from renaming directories and unlinking files as it's currently
removing the mark *after* moving/deleting them.

> > +#define S_KERNEL_FILE (1 << 17) /* File is in use by the kernel (eg. fs/cachefiles) */
> >
>
> Trying to brand this flag as a generic "in use by kernel" is misleading.
> Modules other than cachefiles cannot set/clear this flag, because then
> cachefiles won't know that it is allowed to set/clear the flag.

If the flag is set, then cachefiles thinks some other kernel driver is using
the file and it shouldn't try to use it. It doesn't matter who has it open.

It should never happen as other kernel drivers shouldn't be poking around
inside cachefiles's cache, but possibly someone could misconfigure something.

David