summaryrefslogtreecommitdiff
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjguzik@gmail.com>2025-10-06 01:15:26 +0200
committerChristian Brauner <brauner@kernel.org>2025-10-20 20:22:25 +0200
commit31e332b911fca54df467d264d7e2a2ef9317f3ca (patch)
treea75a50f16b26f6e8cfbf4869b46b4c5004e5f30a /fs/dcache.c
parent0f607a89afe679265602c58097edf952b1e564ab (diff)
fs: add missing fences to I_NEW handling
Suppose there are 2 CPUs racing inode hash lookup func (say ilookup5()) and unlock_new_inode(). In principle the latter can clear the I_NEW flag before prior stores into the inode were made visible. The former can in turn observe I_NEW is cleared and proceed to use the inode, while possibly reading from not-yet-published areas. Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index a067fa0a965a..806d6a665124 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1981,6 +1981,10 @@ void d_instantiate_new(struct dentry *entry, struct inode *inode)
spin_lock(&inode->i_lock);
__d_instantiate(entry, inode);
WARN_ON(!(inode->i_state & I_NEW));
+ /*
+ * Pairs with smp_rmb in wait_on_inode().
+ */
+ smp_wmb();
inode->i_state &= ~I_NEW & ~I_CREATING;
/*
* Pairs with the barrier in prepare_to_wait_event() to make sure