linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: lu gu <giveme.gulu@gmail.com>
Cc: Joanne Koong <joannelkoong@gmail.com>,
	linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5.15] fuse: Fix race condition in writethrough path A race
Date: Fri, 10 Oct 2025 10:46:28 +0200	[thread overview]
Message-ID: <CAJfpegsFCsEgG74bMUH2rb=9-72rMGrHhFjWik2fV4335U0sCw@mail.gmail.com> (raw)
In-Reply-To: <CAFS-8+V1QU8kCWV1eF3-SZtpQwWAuiSuKzCOwKKnEAjmz+rrmw@mail.gmail.com>

On Fri, 10 Oct 2025 at 08:25, lu gu <giveme.gulu@gmail.com> wrote:

> This should serialize backend reads and writes for overlapping ranges
> while avoiding the deadlock risk, since the waiting happens at the
> FUSE layer rather than under a page lock.
>
> Does this approach sound reasonable to you? I’d really appreciate your
> feedback on whether this design makes sense, or if you see any
> potential pitfalls I’ve missed.

Thanks for the great report.

The underlying issue here I think is that auto invalidation happens
(based on mtime change) despite the file not having been changed
externally.   This can happen because fuse_change_attributes_i() will
look at an old mtime value even if it's known to have been invalidated
by a write for example.

My idea is to introduce FUSE_I_MTIME_UNSTABLE (which would work
similarly to FUSE_I_SIZE_UNSTABLE) and when fetching old_mtime, verify
that it hasn't been invalidated.  If old_mtime is invalid or if
FUSE_I_MTIME_UNSTABLE signals that a write is in progress, the page
cache is not invalidated.

Will try this and send a patch.

Thanks,
Miklos

  reply	other threads:[~2025-10-10  8:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 11:06 [PATCH 5.15] fuse: Fix race condition in writethrough path A race guangming.zhao
2025-10-09 22:11 ` Joanne Koong
     [not found]   ` <CAFS-8+VcZn7WZgjV9pHz4c8DYHRdP0on6-er5fm9TZF9RAO0xQ@mail.gmail.com>
2025-10-10  6:25     ` lu gu
2025-10-10  8:46       ` Miklos Szeredi [this message]
2025-10-13 13:39         ` Miklos Szeredi
2025-10-13 17:44           ` Brian Foster
2025-10-13 18:23             ` Miklos Szeredi
2025-10-13 18:53               ` Brian Foster
2025-10-14  7:48                 ` Miklos Szeredi
2025-10-14 12:43                   ` Miklos Szeredi
2025-10-14 16:15                     ` Miklos Szeredi
2025-10-14 17:01                     ` Joanne Koong
2025-10-14 17:56                       ` Brian Foster
2025-10-15  3:59                         ` lu gu
2025-10-15 14:09                           ` Miklos Szeredi
2025-10-15 17:19                             ` Joanne Koong
2025-10-15 19:48                               ` Brian Foster
2025-10-15 20:28                                 ` Joanne Koong
2025-10-20 10:10                                   ` lu gu
2025-10-14 14:01                   ` Brian Foster
2025-10-14 16:10                     ` Miklos Szeredi
2025-10-14 16:15                       ` Bernd Schubert
2025-10-14 16:21                       ` Brian Foster
2025-10-13 20:16           ` Bernd Schubert
2025-10-13 20:27             ` Joanne Koong
2025-10-13 20:40               ` Bernd Schubert
2025-10-13 23:32                 ` Joanne Koong
2025-10-14  8:06             ` Miklos Szeredi
2025-10-13 23:43           ` Joanne Koong
2025-10-14  8:11             ` Miklos Szeredi
2025-10-14  9:36               ` lu gu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJfpegsFCsEgG74bMUH2rb=9-72rMGrHhFjWik2fV4335U0sCw@mail.gmail.com' \
    --to=miklos@szeredi.hu \
    --cc=giveme.gulu@gmail.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).