diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-12-03 06:05:37 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-12-05 17:54:38 -0500 |
commit | eb1b3fa5cdb9c27bdec8f262acf757a06588eb2d (patch) | |
tree | 12fbac3e84fae186df626f07bc259d493b44de97 /fs | |
parent | 471b1f98719a8e8f34f3a696d488e50754f8cf73 (diff) |
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: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/readdir.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 64920920d908..6002fdc920ae 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -66,18 +66,20 @@ static inline void dump_cifs_file_struct(struct file *file, char *label) | |||
66 | #endif /* DEBUG2 */ | 66 | #endif /* DEBUG2 */ |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * Attempt to preload the dcache with the results from the FIND_FIRST/NEXT | ||
70 | * | ||
69 | * Find the dentry that matches "name". If there isn't one, create one. If it's | 71 | * Find the dentry that matches "name". If there isn't one, create one. If it's |
70 | * a negative dentry or the uniqueid changed, then drop it and recreate it. | 72 | * a negative dentry or the uniqueid changed, then drop it and recreate it. |
71 | */ | 73 | */ |
72 | static struct dentry * | 74 | static void |
73 | cifs_readdir_lookup(struct dentry *parent, struct qstr *name, | 75 | cifs_prime_dcache(struct dentry *parent, struct qstr *name, |
74 | struct cifs_fattr *fattr) | 76 | struct cifs_fattr *fattr) |
75 | { | 77 | { |
76 | struct dentry *dentry, *alias; | 78 | struct dentry *dentry, *alias; |
77 | struct inode *inode; | 79 | struct inode *inode; |
78 | struct super_block *sb = parent->d_inode->i_sb; | 80 | struct super_block *sb = parent->d_inode->i_sb; |
79 | 81 | ||
80 | cFYI(1, "For %s", name->name); | 82 | cFYI(1, "%s: for %s", __func__, name->name); |
81 | 83 | ||
82 | if (parent->d_op && parent->d_op->d_hash) | 84 | if (parent->d_op && parent->d_op->d_hash) |
83 | parent->d_op->d_hash(parent, parent->d_inode, name); | 85 | parent->d_op->d_hash(parent, parent->d_inode, name); |
@@ -87,37 +89,32 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, | |||
87 | dentry = d_lookup(parent, name); | 89 | dentry = d_lookup(parent, name); |
88 | if (dentry) { | 90 | if (dentry) { |
89 | int err; | 91 | int err; |
92 | |||
90 | inode = dentry->d_inode; | 93 | inode = dentry->d_inode; |
91 | /* update inode in place if i_ino didn't change */ | 94 | /* update inode in place if i_ino didn't change */ |
92 | if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { | 95 | if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { |
93 | cifs_fattr_to_inode(inode, fattr); | 96 | cifs_fattr_to_inode(inode, fattr); |
94 | return dentry; | 97 | goto out; |
95 | } | 98 | } |
96 | err = d_invalidate(dentry); | 99 | err = d_invalidate(dentry); |
97 | dput(dentry); | 100 | dput(dentry); |
98 | if (err) | 101 | if (err) |
99 | return NULL; | 102 | return; |
100 | } | 103 | } |
101 | 104 | ||
102 | dentry = d_alloc(parent, name); | 105 | dentry = d_alloc(parent, name); |
103 | if (dentry == NULL) | 106 | if (!dentry) |
104 | return NULL; | 107 | return; |
105 | 108 | ||
106 | inode = cifs_iget(sb, fattr); | 109 | inode = cifs_iget(sb, fattr); |
107 | if (!inode) { | 110 | if (!inode) |
108 | dput(dentry); | 111 | goto out; |
109 | return NULL; | ||
110 | } | ||
111 | 112 | ||
112 | alias = d_materialise_unique(dentry, inode); | 113 | alias = d_materialise_unique(dentry, inode); |
113 | if (alias != NULL) { | 114 | if (alias && !IS_ERR(alias)) |
114 | dput(dentry); | 115 | dput(alias); |
115 | if (IS_ERR(alias)) | 116 | out: |
116 | return NULL; | 117 | dput(dentry); |
117 | dentry = alias; | ||
118 | } | ||
119 | |||
120 | return dentry; | ||
121 | } | 118 | } |
122 | 119 | ||
123 | static void | 120 | static void |
@@ -662,7 +659,6 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, | |||
662 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 659 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
663 | struct cifs_dirent de = { NULL, }; | 660 | struct cifs_dirent de = { NULL, }; |
664 | struct cifs_fattr fattr; | 661 | struct cifs_fattr fattr; |
665 | struct dentry *dentry; | ||
666 | struct qstr name; | 662 | struct qstr name; |
667 | int rc = 0; | 663 | int rc = 0; |
668 | ino_t ino; | 664 | ino_t ino; |
@@ -733,13 +729,11 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, | |||
733 | */ | 729 | */ |
734 | fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; | 730 | fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; |
735 | 731 | ||
736 | ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); | 732 | cifs_prime_dcache(file->f_dentry, &name, &fattr); |
737 | dentry = cifs_readdir_lookup(file->f_dentry, &name, &fattr); | ||
738 | 733 | ||
734 | ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); | ||
739 | rc = filldir(dirent, name.name, name.len, file->f_pos, ino, | 735 | rc = filldir(dirent, name.name, name.len, file->f_pos, ino, |
740 | fattr.cf_dtype); | 736 | fattr.cf_dtype); |
741 | |||
742 | dput(dentry); | ||
743 | return rc; | 737 | return rc; |
744 | } | 738 | } |
745 | 739 | ||