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: Jeff Layton <jlayton@kernel.org> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2f14dae915
commit
811fb30278
1 changed files with 5 additions and 1 deletions
|
@ -1288,6 +1288,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 */
|
||||||
|
@ -1295,8 +1296,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue