Skip to content

Commit

Permalink
ceph: ensure d_name stability in ceph_dentry_hash()
Browse files Browse the repository at this point in the history
Take the d_lock here to ensure that d_name doesn't change.

Cc: [email protected]
Signed-off-by: Jeff Layton <[email protected]>
Reviewed-by: "Yan, Zheng" <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
jtlayton authored and idryomov committed Apr 23, 2019
1 parent 1bcb344 commit 76a495d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,15 +1766,19 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
{
struct ceph_inode_info *dci = ceph_inode(dir);
unsigned hash;

switch (dci->i_dir_layout.dl_dir_hash) {
case 0: /* for backward compat */
case CEPH_STR_HASH_LINUX:
return dn->d_name.hash;

default:
return ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
spin_lock(&dn->d_lock);
hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash,
dn->d_name.name, dn->d_name.len);
spin_unlock(&dn->d_lock);
return hash;
}
}

Expand Down

0 comments on commit 76a495d

Please sign in to comment.