diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-04-30 23:12:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-22 14:27:58 -0400 |
commit | 04bb1ba14195fb5b7ddb343f7d637149662accc8 (patch) | |
tree | 2cb0b7785a50a0eb4c67105b15e62e10013cced1 | |
parent | 0ed883fd8023db28b9b01633c0612b006d2f0ab4 (diff) |
orangefs_lookup: simplify
d_splice_alias() can handle NULL and ERR_PTR() for inode just fine...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/orangefs/namei.c | 64 |
1 files changed, 8 insertions, 56 deletions
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index 1b5707c44c3f..365cd73d9109 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c | |||
@@ -110,7 +110,6 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, | |||
110 | struct orangefs_inode_s *parent = ORANGEFS_I(dir); | 110 | struct orangefs_inode_s *parent = ORANGEFS_I(dir); |
111 | struct orangefs_kernel_op_s *new_op; | 111 | struct orangefs_kernel_op_s *new_op; |
112 | struct inode *inode; | 112 | struct inode *inode; |
113 | struct dentry *res; | ||
114 | int ret = -EINVAL; | 113 | int ret = -EINVAL; |
115 | 114 | ||
116 | /* | 115 | /* |
@@ -158,65 +157,18 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, | |||
158 | new_op->downcall.resp.lookup.refn.fs_id, | 157 | new_op->downcall.resp.lookup.refn.fs_id, |
159 | ret); | 158 | ret); |
160 | 159 | ||
161 | if (ret < 0) { | 160 | if (ret >= 0) { |
162 | if (ret == -ENOENT) { | 161 | orangefs_set_timeout(dentry); |
163 | /* | 162 | inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); |
164 | * if no inode was found, add a negative dentry to | 163 | } else if (ret == -ENOENT) { |
165 | * dcache anyway; if we don't, we don't hold expected | 164 | inode = NULL; |
166 | * lookup semantics and we most noticeably break | 165 | } else { |
167 | * during directory renames. | ||
168 | * | ||
169 | * however, if the operation failed or exited, do not | ||
170 | * add the dentry (e.g. in the case that a touch is | ||
171 | * issued on a file that already exists that was | ||
172 | * interrupted during this lookup -- no need to add | ||
173 | * another negative dentry for an existing file) | ||
174 | */ | ||
175 | |||
176 | gossip_debug(GOSSIP_NAME_DEBUG, | ||
177 | "orangefs_lookup: Adding *negative* dentry " | ||
178 | "%p for %pd\n", | ||
179 | dentry, | ||
180 | dentry); | ||
181 | |||
182 | d_add(dentry, NULL); | ||
183 | res = NULL; | ||
184 | goto out; | ||
185 | } | ||
186 | |||
187 | /* must be a non-recoverable error */ | 166 | /* must be a non-recoverable error */ |
188 | res = ERR_PTR(ret); | 167 | inode = ERR_PTR(ret); |
189 | goto out; | ||
190 | } | ||
191 | |||
192 | orangefs_set_timeout(dentry); | ||
193 | |||
194 | inode = orangefs_iget(dir->i_sb, &new_op->downcall.resp.lookup.refn); | ||
195 | if (IS_ERR(inode)) { | ||
196 | gossip_debug(GOSSIP_NAME_DEBUG, | ||
197 | "error %ld from iget\n", PTR_ERR(inode)); | ||
198 | res = ERR_CAST(inode); | ||
199 | goto out; | ||
200 | } | 168 | } |
201 | 169 | ||
202 | gossip_debug(GOSSIP_NAME_DEBUG, | ||
203 | "%s:%s:%d " | ||
204 | "Found good inode [%lu] with count [%d]\n", | ||
205 | __FILE__, | ||
206 | __func__, | ||
207 | __LINE__, | ||
208 | inode->i_ino, | ||
209 | (int)atomic_read(&inode->i_count)); | ||
210 | |||
211 | /* update dentry/inode pair into dcache */ | ||
212 | res = d_splice_alias(inode, dentry); | ||
213 | |||
214 | gossip_debug(GOSSIP_NAME_DEBUG, | ||
215 | "Lookup success (inode ct = %d)\n", | ||
216 | (int)atomic_read(&inode->i_count)); | ||
217 | out: | ||
218 | op_release(new_op); | 170 | op_release(new_op); |
219 | return res; | 171 | return d_splice_alias(inode, dentry); |
220 | } | 172 | } |
221 | 173 | ||
222 | /* return 0 on success; non-zero otherwise */ | 174 | /* return 0 on success; non-zero otherwise */ |