]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/9p: Don't open remote file with APPEND mode when writeback cache is used
authorTingmao Wang <m@maowtm.org>
Sun, 2 Nov 2025 23:56:30 +0000 (23:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 12:54:53 +0000 (13:54 +0100)
commite5b181c4ea852a6d3b9248c1a99b96c4d40466bb
tree51420b4e1043c22cd2f29dc3bcc8443e0d72058a
parent288fa0d792bccc4ebdbb0a759b3b71cd7c20e6c1
fs/9p: Don't open remote file with APPEND mode when writeback cache is used

[ Upstream commit a63dd8fd137933551bfd9aeeeaa942f04c7aad65 ]

When page cache is used, writebacks are done on a page granularity, and it
is expected that the underlying filesystem (such as v9fs) should respect
the write position.  However, currently v9fs will passthrough O_APPEND to
the server even on cached mode.  This causes data corruption if a sync or
fstat gets between two writes to the same file.

This patch removes the APPEND flag from the open request we send to the
server when writeback caching is involved.  I believe keeping server-side
APPEND is probably fine for uncached mode (even if two fds are opened, one
without O_APPEND and one with it, this should still be fine since they
would use separate fid for the writes).

Signed-off-by: Tingmao Wang <m@maowtm.org>
Fixes: 4eb3117888a9 ("fs/9p: Rework cache modes and add new options to Documentation")
Message-ID: <20251102235631.8724-1-m@maowtm.org>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/9p/vfs_file.c
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c