diff options
| author | Mateusz Guzik <mjguzik@gmail.com> | 2025-10-06 01:15:26 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-10-20 20:22:25 +0200 |
| commit | 31e332b911fca54df467d264d7e2a2ef9317f3ca (patch) | |
| tree | a75a50f16b26f6e8cfbf4869b46b4c5004e5f30a /fs/dcache.c | |
| parent | 0f607a89afe679265602c58097edf952b1e564ab (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.c | 4 |
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 |
