diff options
author | Kaixu Xia <kaixuxia@tencent.com> | 2020-10-10 10:10:16 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-10-18 16:37:26 +0200 |
commit | d3e7d20befd9d07db2955015a3f294c0a0a771d3 (patch) | |
tree | 2ffe9d71f346dc1afbc24217c493b8097822c69d /fs/ext4/dir.c | |
parent | ext4: fix bs < ps issue reported with dioread_nolock mount opt (diff) | |
download | linux-d3e7d20befd9d07db2955015a3f294c0a0a771d3.tar.xz linux-d3e7d20befd9d07db2955015a3f294c0a0a771d3.zip |
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>
Diffstat (limited to '')
-rw-r--r-- | fs/ext4/dir.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 1d82336b1cd4..3bf6cb8e55f6 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -674,7 +674,7 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len, { struct qstr qstr = {.name = str, .len = len }; const struct dentry *parent = READ_ONCE(dentry->d_parent); - const struct inode *inode = READ_ONCE(parent->d_inode); + const struct inode *inode = d_inode_rcu(parent); char strbuf[DNAME_INLINE_LEN]; if (!inode || !IS_CASEFOLDED(inode) || @@ -706,7 +706,7 @@ static int ext4_d_hash(const struct dentry *dentry, struct qstr *str) { const struct ext4_sb_info *sbi = EXT4_SB(dentry->d_sb); const struct unicode_map *um = sbi->s_encoding; - const struct inode *inode = READ_ONCE(dentry->d_inode); + const struct inode *inode = d_inode_rcu(dentry); unsigned char *norm; int len, ret = 0; |