提交 d2f65a9f 编写于 作者: J Jeff Layton 提交者: Xie XiuQi

ceph: ensure d_name stability in ceph_dentry_hash()

commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream.

Take the d_lock here to ensure that d_name doesn't change.

Cc: stable@vger.kernel.org
Signed-off-by: NJeff Layton <jlayton@kernel.org>
Reviewed-by: N"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 800e027d
...@@ -1470,6 +1470,7 @@ void ceph_dentry_lru_del(struct dentry *dn) ...@@ -1470,6 +1470,7 @@ void ceph_dentry_lru_del(struct dentry *dn)
unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
{ {
struct ceph_inode_info *dci = ceph_inode(dir); struct ceph_inode_info *dci = ceph_inode(dir);
unsigned hash;
switch (dci->i_dir_layout.dl_dir_hash) { switch (dci->i_dir_layout.dl_dir_hash) {
case 0: /* for backward compat */ case 0: /* for backward compat */
...@@ -1477,8 +1478,11 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) ...@@ -1477,8 +1478,11 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
return dn->d_name.hash; return dn->d_name.hash;
default: 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); dn->d_name.name, dn->d_name.len);
spin_unlock(&dn->d_lock);
return hash;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册