From: NeilBrown <[email protected]> "Best practice" is to use d_splice_alias() at the end of a ->lookup function. d_add() often works and is not incorrect in tracefs, as the inode is always NULL, but as it is planned to remove d_add(), change to use d_splice_alias().
Signed-off-by: NeilBrown <[email protected]> --- fs/ceph/dir.c | 5 ++--- fs/ceph/inode.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 86d7aa594ea9..c7dac71b55bd 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -769,7 +769,7 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, d_drop(dentry); err = -ENOENT; } else { - d_add(dentry, NULL); + d_splice_alias(NULL, dentry); } } } @@ -840,9 +840,8 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, spin_unlock(&ci->i_ceph_lock); doutc(cl, " dir %llx.%llx complete, -ENOENT\n", ceph_vinop(dir)); - d_add(dentry, NULL); di->lease_shared_gen = atomic_read(&ci->i_shared_gen); - return NULL; + return d_splice_alias(NULL, dentry); } spin_unlock(&ci->i_ceph_lock); } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index d76f9a79dc0c..59f9f6948bb2 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1773,7 +1773,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) d_delete(dn); } else if (have_lease) { if (d_unhashed(dn)) - d_add(dn, NULL); + d_splice_alias(NULL, dn); } if (!d_unhashed(dn) && have_lease) -- 2.50.0.107.gf914562f5916.dirty
