Skip to content

Commit d3e7d20

Browse files
kaixuxiakxtytso
authored andcommitted
ext4: use the normal helper to get the actual inode
Here we use the READ_ONCE to fix race conditions in ->d_compare() and ->d_hash() when they are called in RCU-walk mode, seems we can use the normal helper d_inode_rcu() to get the actual inode. Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Link: https://lore.kernel.org/r/1602317416-1260-1-git-send-email-kaixuxia@tencent.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent d1e18b8 commit d3e7d20

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎fs/ext4/dir.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
674674
{
675675
struct qstr qstr = {.name = str, .len = len };
676676
const struct dentry *parent = READ_ONCE(dentry->d_parent);
677-
const struct inode *inode = READ_ONCE(parent->d_inode);
677+
const struct inode *inode = d_inode_rcu(parent);
678678
char strbuf[DNAME_INLINE_LEN];
679679

680680
if (!inode || !IS_CASEFOLDED(inode) ||
@@ -706,7 +706,7 @@ static int ext4_d_hash(const struct dentry *dentry, struct qstr *str)
706706
{
707707
const struct ext4_sb_info *sbi = EXT4_SB(dentry->d_sb);
708708
const struct unicode_map *um = sbi->s_encoding;
709-
const struct inode *inode = READ_ONCE(dentry->d_inode);
709+
const struct inode *inode = d_inode_rcu(dentry);
710710
unsigned char *norm;
711711
int len, ret = 0;
712712

0 commit comments

Comments
 (0)