linux/include
NeilBrown 7c6c5249f0 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>
2024-05-20 11:09:20 -04:00
..
acpi
asm-generic sched: Add missing memory barrier in switch_mm_cid 2024-04-16 13:59:45 +02:00
clocksource
crypto
drm
dt-bindings
keys
kunit
kvm
linux NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly. 2024-05-20 11:09:20 -04:00
math-emu
media
memory
misc
net ipsec-2024-05-02 2024-05-03 15:56:15 -07:00
pcmcia
ras
rdma
rv
scsi
soc
sound ASoC: Fixes for v6.9 2024-05-01 18:05:13 +02:00
target
trace 11 hotfixes. 8 are cc:stable and the remaining 3 (nice ratio!) address 2024-04-26 13:48:03 -07:00
uapi ipsec-2024-05-02 2024-05-03 15:56:15 -07:00
ufs
vdso
video
xen