public inbox for v9fs@lists.linux.dev
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Pierre Barre <pierre@barre.sh>
Cc: dhowells@redhat.com, ericvh@kernel.org, lucho@ionkov.net,
	asmadeus@codewreck.org, linux_oss@crudebyte.com,
	v9fs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] 9p: fix i_size update race in getattr with writeback caching
Date: Wed, 18 Feb 2026 13:38:03 +0000	[thread overview]
Message-ID: <1642497.1771421883@warthog.procyon.org.uk> (raw)
In-Reply-To: <20251227180137.730385-1-pierre@barre.sh>

Pierre Barre <pierre@barre.sh> wrote:

> With writeback caching (cache=mmap), v9fs_stat2inode() and
> v9fs_stat2inode_dotl() unconditionally overwrite i_size from the server
> response, even when dirty pages may exist locally. This causes processes
> using lseek(SEEK_END) to see incorrect file sizes, leading to data
> corruption when extending files while concurrent stat() calls occur.
> 
> Fix by passing V9FS_STAT2INODE_KEEP_ISIZE when CACHE_WRITEBACK is
> enabled to preserve the client's authoritative i_size.

I think this might be the wrong approach.

A better way is probably, in v9fs_stat2inode() and v9fs_stat2inode_dotl(), if
the inode isn't new, compare the values for stat->mtime to inode->i_mtime and
stat->length to v9inode->netfs.remote_i_size and if they differ mark the inode
as being remotely modified, invalidate the pagecache and reset inode->i_size.

If stat->mtime == inode->i_mtime and stat->length ==
v9inode->netfs.remote_i_size, then don't alter inode->i_size.

David


  parent reply	other threads:[~2026-02-18 13:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-27 18:01 [PATCH v2] 9p: fix i_size update race in getattr with writeback caching Pierre Barre
2026-01-05 11:35 ` Christian Schoenebeck
2026-01-07  0:27   ` Pierre Barre
2026-02-04 11:48     ` Christian Schoenebeck
2026-02-15  9:21       ` Dominique Martinet
2026-02-17 14:48   ` David Howells
2026-02-17 15:05   ` David Howells
2026-02-17 16:54     ` David Howells
2026-02-18 13:38 ` David Howells [this message]
2026-02-18 13:41   ` David Howells
2026-02-18 14:11     ` Dominique Martinet

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=1642497.1771421883@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=ericvh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=pierre@barre.sh \
    --cc=v9fs@lists.linux.dev \
    /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