Files
NeilBrown 72d750886b NFS: add barriers when testing for NFS_FSDATA_BLOCKED
commit 99bc9f2eb3 upstream.

dentry->d_fsdata is set to NFS_FSDATA_BLOCKED while unlinking or
renaming-over a file to ensure that no open succeeds while the NFS
operation progressed on the server.

Setting dentry->d_fsdata to NFS_FSDATA_BLOCKED is done under ->d_lock
after checking the refcount is not elevated.  Any attempt to open the
file (through that name) will go through lookp_open() which will take
->d_lock while incrementing the refcount, we can be sure that once the
new value is set, __nfs_lookup_revalidate() *will* see the new value and
will block.

We don't have any locking guarantee that when we set ->d_fsdata to NULL,
the wait_var_event() in __nfs_lookup_revalidate() will notice.
wait/wake primitives do NOT provide barriers to guarantee order.  We
must use smp_load_acquire() in wait_var_event() to ensure we look at an
up-to-date value, and must use smp_store_release() before wake_up_var().

This patch adds those barrier functions and factors out
block_revalidate() and unblock_revalidate() far clarity.

There is also a hypothetical bug in that if memory allocation fails
(which never happens in practice) we might leave ->d_fsdata locked.
This patch adds the missing call to unblock_revalidate().

Reported-and-tested-by: Richard Kojedzinszky <richard+debian+bugreport@kojedz.in>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071501
Fixes: 3c59366c20 ("NFS: don't unhash dentry during unlink/rename")
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-01-19 13:10:19 +01:00
..
2025-10-19 16:21:28 +02:00
2024-10-22 15:40:40 +02:00
2026-01-19 13:10:08 +01:00
2024-02-23 08:54:51 +01:00
2026-01-19 13:10:10 +01:00
2026-01-19 13:10:18 +01:00
2025-03-13 12:49:51 +01:00
2025-10-19 16:21:28 +02:00
2025-04-10 14:31:50 +02:00
2024-03-01 13:21:43 +01:00
2023-09-23 11:10:01 +02:00
2025-10-29 14:03:09 +01:00
2025-03-13 12:49:50 +01:00
2023-08-30 16:18:19 +02:00
2026-01-19 13:10:10 +01:00