diff options
author | NeilBrown <neilb@suse.de> | 2024-03-25 16:36:05 +1100 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@hammerspace.com> | 2024-05-20 11:09:20 -0400 |
commit | 7c6c5249f061b64fc6b5b90bc147169a048691bf (patch) | |
tree | 4cee132b6fdee4725ba9f47071c21be42c1f0bf4 /fs/bcachefs/inode.h | |
parent | 464b424fb09b894f792a494f10539c190db503cf (diff) | |
download | linux-7c6c5249f061b64fc6b5b90bc147169a048691bf.tar.gz linux-7c6c5249f061b64fc6b5b90bc147169a048691bf.tar.bz2 linux-7c6c5249f061b64fc6b5b90bc147169a048691bf.zip |
NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.
With two clients, each with NFSv3 mounts of the same directory, the sequence:
client1 client2
ls -l afile
echo hello there > afile
echo HELLO > afile
cat afile
will show
HELLO
there
because the O_TRUNC requested in the final 'echo' doesn't take effect.
This is because the "Negative dentry, just create a file" section in
lookup_open() assumes that the file *does* get created since the dentry
was negative, so it sets FMODE_CREATED, and this causes do_open() to
clear O_TRUNC and so the file doesn't get truncated.
Even mounting with -o lookupcache=none does not help as
nfs_neg_need_reval() always returns false if LOOKUP_CREATE is set.
This patch fixes the problem by providing an atomic_open inode operation
for NFSv3 (and v2). The code is largely the code from the branch in
lookup_open() when atomic_open is not provided. The significant change
is that the O_TRUNC flag is passed a new nfs_do_create() which add
'trunc' handling to nfs_create().
With this change we also optimise away an unnecessary LOOKUP before the
file is created.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/bcachefs/inode.h')
0 files changed, 0 insertions, 0 deletions