Message ID | 20190417183959.11296-4-jlayton@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ceph: dentry->d_name handing fixes | expand |
On Thu, Apr 18, 2019 at 2:43 AM Jeff Layton <jlayton@kernel.org> wrote: > > 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> > --- > fs/ceph/dir.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c > index a8f429882249..0637149fb9f9 100644 > --- a/fs/ceph/dir.c > +++ b/fs/ceph/dir.c > @@ -1766,6 +1766,7 @@ 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 */ > @@ -1773,8 +1774,11 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) > 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; > } > } > > -- > 2.20.1 > Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index a8f429882249..0637149fb9f9 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1766,6 +1766,7 @@ 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 */ @@ -1773,8 +1774,11 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) 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; } }
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> --- fs/ceph/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)