Re: [PATCH 5.15] fuse: Fix race condition in writethrough path A race

Miklos Szeredi
2025-10-14T07:48:46Z

On Mon, 13 Oct 2025 at 20:49, Brian Foster <bfoster@redhat.com> wrote:

> Hrm Ok. But even if we did miss remote changes, whose to say we can even
> resolve that correctly from the kernel anyways..?

No, I'm worrying about the case of

- range1 cached locally,
- range1 changed remotely (mtime changed)
- range2 changed locally (mtime changed, cached mtime invalidated)
- range1 read locally

That last one will update mtime in cache, see that old cached mtime is
stale and happily read the stale data.

What we currently have is more correct in the sense that it will
invalidate data on any mtime change, be it of local or remote origin.

> > Yes, reproducer has auto_inval_data turned on (libfuse turns it on by default).
> >
>
> I was more wondering if the problem goes away if it were disabled..

I haven't tried, @guangming?

> Ah, yeah that makes sense. Though invalidate waits on writeback. Any
> reason this path couldn't skip the dirty state but mark the pages as
> under writeback across the op?

Maybe that'd work. It *is* under writeback after all.

Maybe the solution is to change the write-through to regular cached
write + fsync range? That could even be a complexity reduction.

Thanks,
Miklos