Commit 467c5251 authored by Sage Weil's avatar Sage Weil

ceph: fix dn offset during readdir_prepopulate

When adding the readdir results to the cache, ceph_set_dentry_offset was
clobbered our just-set offset.  This can cause the readdir result offsets
to get out of sync with the server.  Add an argument to the helper so
that it does not.

This bug was introduced by 1cd3935b.
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent a77d9f7d
...@@ -845,7 +845,7 @@ static void ceph_set_dentry_offset(struct dentry *dn) ...@@ -845,7 +845,7 @@ static void ceph_set_dentry_offset(struct dentry *dn)
* the caller) if we fail. * the caller) if we fail.
*/ */
static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
bool *prehash) bool *prehash, bool set_offset)
{ {
struct dentry *realdn; struct dentry *realdn;
...@@ -877,7 +877,8 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, ...@@ -877,7 +877,8 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
} }
if ((!prehash || *prehash) && d_unhashed(dn)) if ((!prehash || *prehash) && d_unhashed(dn))
d_rehash(dn); d_rehash(dn);
ceph_set_dentry_offset(dn); if (set_offset)
ceph_set_dentry_offset(dn);
out: out:
return dn; return dn;
} }
...@@ -1062,7 +1063,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, ...@@ -1062,7 +1063,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
d_delete(dn); d_delete(dn);
goto done; goto done;
} }
dn = splice_dentry(dn, in, &have_lease); dn = splice_dentry(dn, in, &have_lease, true);
if (IS_ERR(dn)) { if (IS_ERR(dn)) {
err = PTR_ERR(dn); err = PTR_ERR(dn);
goto done; goto done;
...@@ -1105,7 +1106,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, ...@@ -1105,7 +1106,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
goto done; goto done;
} }
dout(" linking snapped dir %p to dn %p\n", in, dn); dout(" linking snapped dir %p to dn %p\n", in, dn);
dn = splice_dentry(dn, in, NULL); dn = splice_dentry(dn, in, NULL, true);
if (IS_ERR(dn)) { if (IS_ERR(dn)) {
err = PTR_ERR(dn); err = PTR_ERR(dn);
goto done; goto done;
...@@ -1237,7 +1238,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, ...@@ -1237,7 +1238,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
err = PTR_ERR(in); err = PTR_ERR(in);
goto out; goto out;
} }
dn = splice_dentry(dn, in, NULL); dn = splice_dentry(dn, in, NULL, false);
if (IS_ERR(dn)) if (IS_ERR(dn))
dn = NULL; dn = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment