提交 eb1b3fa5 编写于 作者: J Jeff Layton 提交者: Steve French

cifs: rename cifs_readdir_lookup to cifs_prime_dcache and make it void return

The caller doesn't do anything with the dentry, so there's no point in
holding a reference to it on return. Also cifs_prime_dcache better
describes the actual purpose of the function.
Signed-off-by: NJeff Layton <jlayton@redhat.com>
Signed-off-by: NSteve French <smfrench@gmail.com>
上级 471b1f98
...@@ -66,18 +66,20 @@ static inline void dump_cifs_file_struct(struct file *file, char *label) ...@@ -66,18 +66,20 @@ static inline void dump_cifs_file_struct(struct file *file, char *label)
#endif /* DEBUG2 */ #endif /* DEBUG2 */
/* /*
* Attempt to preload the dcache with the results from the FIND_FIRST/NEXT
*
* Find the dentry that matches "name". If there isn't one, create one. If it's * Find the dentry that matches "name". If there isn't one, create one. If it's
* a negative dentry or the uniqueid changed, then drop it and recreate it. * a negative dentry or the uniqueid changed, then drop it and recreate it.
*/ */
static struct dentry * static void
cifs_readdir_lookup(struct dentry *parent, struct qstr *name, cifs_prime_dcache(struct dentry *parent, struct qstr *name,
struct cifs_fattr *fattr) struct cifs_fattr *fattr)
{ {
struct dentry *dentry, *alias; struct dentry *dentry, *alias;
struct inode *inode; struct inode *inode;
struct super_block *sb = parent->d_inode->i_sb; struct super_block *sb = parent->d_inode->i_sb;
cFYI(1, "For %s", name->name); cFYI(1, "%s: for %s", __func__, name->name);
if (parent->d_op && parent->d_op->d_hash) if (parent->d_op && parent->d_op->d_hash)
parent->d_op->d_hash(parent, parent->d_inode, name); parent->d_op->d_hash(parent, parent->d_inode, name);
...@@ -87,37 +89,32 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, ...@@ -87,37 +89,32 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
dentry = d_lookup(parent, name); dentry = d_lookup(parent, name);
if (dentry) { if (dentry) {
int err; int err;
inode = dentry->d_inode; inode = dentry->d_inode;
/* update inode in place if i_ino didn't change */ /* update inode in place if i_ino didn't change */
if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
cifs_fattr_to_inode(inode, fattr); cifs_fattr_to_inode(inode, fattr);
return dentry; goto out;
} }
err = d_invalidate(dentry); err = d_invalidate(dentry);
dput(dentry); dput(dentry);
if (err) if (err)
return NULL; return;
} }
dentry = d_alloc(parent, name); dentry = d_alloc(parent, name);
if (dentry == NULL) if (!dentry)
return NULL; return;
inode = cifs_iget(sb, fattr); inode = cifs_iget(sb, fattr);
if (!inode) { if (!inode)
dput(dentry); goto out;
return NULL;
}
alias = d_materialise_unique(dentry, inode); alias = d_materialise_unique(dentry, inode);
if (alias != NULL) { if (alias && !IS_ERR(alias))
dput(dentry); dput(alias);
if (IS_ERR(alias)) out:
return NULL; dput(dentry);
dentry = alias;
}
return dentry;
} }
static void static void
...@@ -662,7 +659,6 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, ...@@ -662,7 +659,6 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir,
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifs_dirent de = { NULL, }; struct cifs_dirent de = { NULL, };
struct cifs_fattr fattr; struct cifs_fattr fattr;
struct dentry *dentry;
struct qstr name; struct qstr name;
int rc = 0; int rc = 0;
ino_t ino; ino_t ino;
...@@ -733,13 +729,11 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, ...@@ -733,13 +729,11 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir,
*/ */
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); cifs_prime_dcache(file->f_dentry, &name, &fattr);
dentry = cifs_readdir_lookup(file->f_dentry, &name, &fattr);
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
rc = filldir(dirent, name.name, name.len, file->f_pos, ino, rc = filldir(dirent, name.name, name.len, file->f_pos, ino,
fattr.cf_dtype); fattr.cf_dtype);
dput(dentry);
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册