Skip to content

Commit

Permalink
ceph: always initialize the dentry in open_root_dentry()
Browse files Browse the repository at this point in the history
When open_root_dentry() gets a dentry via d_obtain_alias() it does
not get initialized.  If the dentry obtained came from the cache,
this is OK.  But if not, the result is an improperly initialized
dentry.

To fix this, call ceph_init_dentry() regardless of which path
produced the dentry.  That function returns immediately for a dentry
that is already initialized, it is safe to use either way.

(Credit to Sage, who suggested this fix.)

Signed-off-by: Alex Elder <aelder@sgi.com>
  • Loading branch information
Alex Elder authored and Sage Weil committed Jan 12, 2012
1 parent 56e925b commit d46cfba
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs/ceph/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,11 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
if (err == 0) {
dout("open_root_inode success\n");
if (ceph_ino(req->r_target_inode) == CEPH_INO_ROOT &&
fsc->sb->s_root == NULL) {
fsc->sb->s_root == NULL)
root = d_alloc_root(req->r_target_inode);
ceph_init_dentry(root);
} else {
else
root = d_obtain_alias(req->r_target_inode);
}
ceph_init_dentry(root);
req->r_target_inode = NULL;
dout("open_root_inode success, root dentry is %p\n", root);
} else {
Expand Down

0 comments on commit d46cfba

Please sign in to comment.