Commit 8842b3be authored by Sage Weil's avatar Sage Weil

ceph: clean up useless d_parent checks

d_parent is never NULL, and IS_ROOT() is the proper way to check for a
(non-self-referential) parent.
Reported-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: default avatarSage Weil <sage@inktank.com>
parent a2a32584
...@@ -51,8 +51,7 @@ int ceph_init_dentry(struct dentry *dentry) ...@@ -51,8 +51,7 @@ int ceph_init_dentry(struct dentry *dentry)
goto out_unlock; goto out_unlock;
} }
if (dentry->d_parent == NULL || /* nfs fh_to_dentry */ if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)
ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)
d_set_d_op(dentry, &ceph_dentry_ops); d_set_d_op(dentry, &ceph_dentry_ops);
else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR)
d_set_d_op(dentry, &ceph_snapdir_dentry_ops); d_set_d_op(dentry, &ceph_snapdir_dentry_ops);
...@@ -79,7 +78,7 @@ struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry) ...@@ -79,7 +78,7 @@ struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry)
return NULL; return NULL;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (dentry->d_parent) { if (!IS_ROOT(dentry)) {
inode = dentry->d_parent->d_inode; inode = dentry->d_parent->d_inode;
ihold(inode); ihold(inode);
} }
...@@ -1140,7 +1139,7 @@ static void ceph_d_prune(struct dentry *dentry) ...@@ -1140,7 +1139,7 @@ static void ceph_d_prune(struct dentry *dentry)
dout("ceph_d_prune %p\n", dentry); dout("ceph_d_prune %p\n", dentry);
/* do we have a valid parent? */ /* do we have a valid parent? */
if (!dentry->d_parent || IS_ROOT(dentry)) if (IS_ROOT(dentry))
return; return;
/* if we are not hashed, we don't affect D_COMPLETE */ /* if we are not hashed, we don't affect D_COMPLETE */
......
...@@ -1469,11 +1469,6 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base, ...@@ -1469,11 +1469,6 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
else else
len += 1 + temp->d_name.len; len += 1 + temp->d_name.len;
temp = temp->d_parent; temp = temp->d_parent;
if (temp == NULL) {
rcu_read_unlock();
pr_err("build_path corrupt dentry %p\n", dentry);
return ERR_PTR(-EINVAL);
}
} }
rcu_read_unlock(); rcu_read_unlock();
if (len) if (len)
...@@ -1510,12 +1505,6 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base, ...@@ -1510,12 +1505,6 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
if (pos) if (pos)
path[--pos] = '/'; path[--pos] = '/';
temp = temp->d_parent; temp = temp->d_parent;
if (temp == NULL) {
rcu_read_unlock();
pr_err("build_path corrupt dentry\n");
kfree(path);
return ERR_PTR(-EINVAL);
}
} }
rcu_read_unlock(); rcu_read_unlock();
if (pos != 0 || read_seqretry(&rename_lock, seq)) { if (pos != 0 || read_seqretry(&rename_lock, seq)) {
......
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