mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd@bsbernd.com>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>, lu gu <giveme.gulu@gmail.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brian Foster <bfoster@redhat.com>
Subject: Re: [PATCH 5.15] fuse: Fix race condition in writethrough path A race
Date: Mon, 13 Oct 2025 22:40:23 +0200	[thread overview]
Message-ID: <54e30e4a-36c3-4775-a788-dc15e3558b9b@bsbernd.com> (raw)
In-Reply-To: <CAJnrk1ZCXcM4iDq5bN6YVK75Q4udJNytVe2OpF3DmZ_FpuR7nA@mail.gmail.com>



On 10/13/25 22:27, Joanne Koong wrote:
> On Mon, Oct 13, 2025 at 1:16 PM Bernd Schubert <bernd@bsbernd.com> wrote:
>>
>> On 10/13/25 15:39, Miklos Szeredi wrote:
>>> On Fri, 10 Oct 2025 at 10:46, Miklos Szeredi <miklos@szeredi.hu> wrote:
>>>
>>>> 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.
>>>
>>> [Adding Brian Foster, the author of FUSE_AUTO_INVAL_DATA patches.
>>> Link to complete thread:
>>> https://lore.kernel.org/all/20251009110623.3115511-1-giveme.gulu@gmail.com/#r]
>>>
>>> In summary: auto_inval_data invalidates data cache even if the
>>> modification was done in a cache consistent manner (i.e. write
>>> through). This is not generally a consistency problem, because the
>>> backing file and the cache should be in sync.  The exception is when
>>> the writeback to the backing file hasn't yet finished and a getattr()
>>> call triggers invalidation (mtime change could be from a previous
>>> write), and the not yet written data is invalidated and replaced with
>>> stale data.
>>>
>>> The proposed fix was to exclude concurrent reads and writes to the same region.
>>>
>>> But the real issue here is that mtime changes triggered by this client
>>> should not cause data to be invalidated.  It's not only racy, but it's
>>> fundamentally wrong.  Unfortunately this is hard to do this correctly.
>>> Best I can come up with is that any request that expects mtime to be
>>> modified returns the mtime after the request has completed.
>>>
>>> This would be much easier to implement in the fuse server: perform the
>>> "file changed remotely" check when serving a FUSE_GETATTR request and
>>> return a flag indicating whether the data needs to be invalidated or
>>> not.
>>
>> For an intelligent server maybe, but let's say one uses
>> <libfuse>/example/passthrough*, in combination with some external writes
>> to the underlying file system outside of fuse. How would passthrough*
>> know about external changes?
>>
>> The part I don't understand yet is why invalidate_inode_pages2() causes
>> an issue - it has folio_wait_writeback()?
>>
> 
> This issue is for the writethrough path which doesn't use writeback.


Oh right. So we need some kind of fuse_invalidate_pages(), that would
wait for for all current fuse_send_write_pages() to complete? Is that
what you meant with 'fi->writectr bias'?

Thanks,
Bernd

  reply	other threads:[~2025-10-13 20:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 11:06 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
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 [this message]
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=54e30e4a-36c3-4775-a788-dc15e3558b9b@bsbernd.com \
    --to=bernd@bsbernd.com \
    --cc=bfoster@redhat.com \
    --cc=giveme.gulu@gmail.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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

all inboxes | Powered by JetHome®