Re: [PATCH] fuse: writeback_cache consistency enhancement (writeback_cache_v2)

From: Miklos Szeredi
Date: Mon Jul 18 2022 - 04:18:41 EST


On Mon, 18 Jul 2022 at 08:01, Jiachen Zhang
<zhangjiachen.jaycee@xxxxxxxxxxxxx> wrote:
>
> On Fri, Jul 15, 2022 at 6:07 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
> >
> > On Fri, 24 Jun 2022 at 07:58, Jiachen Zhang
> > <zhangjiachen.jaycee@xxxxxxxxxxxxx> wrote:

> > > + if (fc->writeback_cache_v2 && S_ISREG(inode->i_mode)) {
> > > + inode_lock(inode);
> >
> > I don't think this can work. fuse_change_attributes() might be
> > called from within inlode locked context. E.g.
> >
> > lookup_slow -> __lookup_slow -> d_revalidate -> fuse_dentry_revalidate
> > -> fuse_change_attributes
> >
>
> Yes, this is a problem that should be fixed. As we can not check the
> inode lock state from the inode->i_rwsem structure, I think we can
> pass the inode lock state along the FUSE function call-path to
> fuse_change_attributes(), and only when we can certainly know whether
> the inode is locked or unlocked then we continue the
> writeback_cache_v2 logics. What do you think?

Not liking it very much.

Better create a new lock for this purpose that we do always know the state of.

Thanks,
Miklos