VFS: Impose ordering on accesses of d_inode and d_flags
Impose ordering on accesses of d_inode and d_flags to avoid the need to do this: if (!dentry->d_inode || d_is_negative(dentry)) { when this: if (d_is_negative(dentry)) { should suffice. This check is especially problematic if a dentry can have its type field set to something other than DENTRY_MISS_TYPE when d_inode is NULL (as in unionmount). What we really need to do is stick a write barrier between setting d_inode and setting d_flags and a read barrier between reading d_flags and reading d_inode. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -404,26 +404,11 @@ static inline bool d_mountpoint(const struct dentry *dentry)
|
||||
/*
|
||||
* Directory cache entry type accessor functions.
|
||||
*/
|
||||
static inline void __d_set_type(struct dentry *dentry, unsigned type)
|
||||
{
|
||||
dentry->d_flags = (dentry->d_flags & ~DCACHE_ENTRY_TYPE) | type;
|
||||
}
|
||||
|
||||
static inline void __d_clear_type(struct dentry *dentry)
|
||||
{
|
||||
__d_set_type(dentry, DCACHE_MISS_TYPE);
|
||||
}
|
||||
|
||||
static inline void d_set_type(struct dentry *dentry, unsigned type)
|
||||
{
|
||||
spin_lock(&dentry->d_lock);
|
||||
__d_set_type(dentry, type);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
}
|
||||
|
||||
static inline unsigned __d_entry_type(const struct dentry *dentry)
|
||||
{
|
||||
return dentry->d_flags & DCACHE_ENTRY_TYPE;
|
||||
unsigned type = READ_ONCE(dentry->d_flags);
|
||||
smp_rmb();
|
||||
return type & DCACHE_ENTRY_TYPE;
|
||||
}
|
||||
|
||||
static inline bool d_is_miss(const struct dentry *dentry)
|
||||
|
Reference in New Issue
Block a user