diff options
author | Sage Weil <sage@inktank.com> | 2012-06-07 16:43:35 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 12:29:54 -0400 |
commit | 8842b3be96c376f174ae0d4f282d14728ad5febf (patch) | |
tree | aa7b7380285d7806c4e2a6a1080a169e379505d3 /fs/ceph | |
parent | a2a3258417eb6a1799cf893350771428875a8287 (diff) |
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: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/dir.c | 7 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 11 |
2 files changed, 3 insertions, 15 deletions
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 3e8094be4604..6a66bd2d4da0 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -51,8 +51,7 @@ int ceph_init_dentry(struct dentry *dentry) | |||
51 | goto out_unlock; | 51 | goto out_unlock; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (dentry->d_parent == NULL || /* nfs fh_to_dentry */ | 54 | if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) |
55 | ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) | ||
56 | d_set_d_op(dentry, &ceph_dentry_ops); | 55 | d_set_d_op(dentry, &ceph_dentry_ops); |
57 | else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) | 56 | else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR) |
58 | d_set_d_op(dentry, &ceph_snapdir_dentry_ops); | 57 | d_set_d_op(dentry, &ceph_snapdir_dentry_ops); |
@@ -79,7 +78,7 @@ struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry) | |||
79 | return NULL; | 78 | return NULL; |
80 | 79 | ||
81 | spin_lock(&dentry->d_lock); | 80 | spin_lock(&dentry->d_lock); |
82 | if (dentry->d_parent) { | 81 | if (!IS_ROOT(dentry)) { |
83 | inode = dentry->d_parent->d_inode; | 82 | inode = dentry->d_parent->d_inode; |
84 | ihold(inode); | 83 | ihold(inode); |
85 | } | 84 | } |
@@ -1140,7 +1139,7 @@ static void ceph_d_prune(struct dentry *dentry) | |||
1140 | dout("ceph_d_prune %p\n", dentry); | 1139 | dout("ceph_d_prune %p\n", dentry); |
1141 | 1140 | ||
1142 | /* do we have a valid parent? */ | 1141 | /* do we have a valid parent? */ |
1143 | if (!dentry->d_parent || IS_ROOT(dentry)) | 1142 | if (IS_ROOT(dentry)) |
1144 | return; | 1143 | return; |
1145 | 1144 | ||
1146 | /* if we are not hashed, we don't affect D_COMPLETE */ | 1145 | /* if we are not hashed, we don't affect D_COMPLETE */ |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 5ac6434185ae..418f6a82c90d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1469,11 +1469,6 @@ retry: | |||
1469 | else | 1469 | else |
1470 | len += 1 + temp->d_name.len; | 1470 | len += 1 + temp->d_name.len; |
1471 | temp = temp->d_parent; | 1471 | temp = temp->d_parent; |
1472 | if (temp == NULL) { | ||
1473 | rcu_read_unlock(); | ||
1474 | pr_err("build_path corrupt dentry %p\n", dentry); | ||
1475 | return ERR_PTR(-EINVAL); | ||
1476 | } | ||
1477 | } | 1472 | } |
1478 | rcu_read_unlock(); | 1473 | rcu_read_unlock(); |
1479 | if (len) | 1474 | if (len) |
@@ -1510,12 +1505,6 @@ retry: | |||
1510 | if (pos) | 1505 | if (pos) |
1511 | path[--pos] = '/'; | 1506 | path[--pos] = '/'; |
1512 | temp = temp->d_parent; | 1507 | temp = temp->d_parent; |
1513 | if (temp == NULL) { | ||
1514 | rcu_read_unlock(); | ||
1515 | pr_err("build_path corrupt dentry\n"); | ||
1516 | kfree(path); | ||
1517 | return ERR_PTR(-EINVAL); | ||
1518 | } | ||
1519 | } | 1508 | } |
1520 | rcu_read_unlock(); | 1509 | rcu_read_unlock(); |
1521 | if (pos != 0 || read_seqretry(&rename_lock, seq)) { | 1510 | if (pos != 0 || read_seqretry(&rename_lock, seq)) { |