Commit 34b2a88f authored by Al Viro's avatar Al Viro

afs_lookup(): switch to d_splice_alias()

->lookup() methods can (and should) use d_splice_alias() instead of
d_add().  Even if they are not going to be hit by open_by_handle(),
code does get copied around; besides, d_splice_alias() has better
calling conventions for use in ->lookup(), so the code gets simpler.
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 855371bd
...@@ -822,6 +822,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -822,6 +822,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
{ {
struct afs_vnode *dvnode = AFS_FS_I(dir); struct afs_vnode *dvnode = AFS_FS_I(dir);
struct inode *inode; struct inode *inode;
struct dentry *d;
struct key *key; struct key *key;
int ret; int ret;
...@@ -862,43 +863,19 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -862,43 +863,19 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
afs_stat_v(dvnode, n_lookup); afs_stat_v(dvnode, n_lookup);
inode = afs_do_lookup(dir, dentry, key); inode = afs_do_lookup(dir, dentry, key);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
if (ret == -ENOENT) {
inode = afs_try_auto_mntpt(dentry, dir);
if (!IS_ERR(inode)) {
key_put(key);
goto success;
}
ret = PTR_ERR(inode);
}
key_put(key);
if (ret == -ENOENT) {
d_add(dentry, NULL);
_leave(" = NULL [negative]");
return NULL;
}
_leave(" = %d [do]", ret);
return ERR_PTR(ret);
}
dentry->d_fsdata = (void *)(unsigned long)dvnode->status.data_version;
/* instantiate the dentry */
key_put(key); key_put(key);
if (IS_ERR(inode)) { if (inode == ERR_PTR(-ENOENT)) {
_leave(" = %ld", PTR_ERR(inode)); inode = afs_try_auto_mntpt(dentry, dir);
return ERR_CAST(inode); if (inode == ERR_PTR(-ENOENT))
inode = NULL;
} else {
dentry->d_fsdata =
(void *)(unsigned long)dvnode->status.data_version;
} }
d = d_splice_alias(inode, dentry);
success: if (!IS_ERR_OR_NULL(d))
d_add(dentry, inode); d->d_fsdata = dentry->d_fsdata;
_leave(" = 0 { ino=%lu v=%u }", return d;
d_inode(dentry)->i_ino,
d_inode(dentry)->i_generation);
return 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