aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-05-07 20:55:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-11-03 15:21:12 -0500
commit74d01958a7ebca8c018ce03090eccb3b15ae8635 (patch)
tree71a1e67f56327f4ee69b469deec308d78f00bbe4
parentc139f3cef36291902d7a29a334acd25a1251cd9d (diff)
lustre: opened file can't have negative dentry
... and ll_md_close() gets inode already equal to file_inode(file), along with ll_file_release() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 3f00a40cf387..c3be2f26dfa3 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -266,6 +266,10 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
266{ 266{
267 struct ll_file_data *fd = LUSTRE_FPRIVATE(file); 267 struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
268 struct ll_inode_info *lli = ll_i2info(inode); 268 struct ll_inode_info *lli = ll_i2info(inode);
269 int lockmode;
270 __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
271 struct lustre_handle lockh;
272 ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
269 int rc = 0; 273 int rc = 0;
270 274
271 /* clear group lock, if present */ 275 /* clear group lock, if present */
@@ -292,39 +296,26 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
292 296
293 /* Let's see if we have good enough OPEN lock on the file and if 297 /* Let's see if we have good enough OPEN lock on the file and if
294 we can skip talking to MDS */ 298 we can skip talking to MDS */
295 if (file->f_dentry->d_inode) { /* Can this ever be false? */
296 int lockmode;
297 __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
298 struct lustre_handle lockh;
299 struct inode *inode = file->f_dentry->d_inode;
300 ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
301
302 mutex_lock(&lli->lli_och_mutex);
303 if (fd->fd_omode & FMODE_WRITE) {
304 lockmode = LCK_CW;
305 LASSERT(lli->lli_open_fd_write_count);
306 lli->lli_open_fd_write_count--;
307 } else if (fd->fd_omode & FMODE_EXEC) {
308 lockmode = LCK_PR;
309 LASSERT(lli->lli_open_fd_exec_count);
310 lli->lli_open_fd_exec_count--;
311 } else {
312 lockmode = LCK_CR;
313 LASSERT(lli->lli_open_fd_read_count);
314 lli->lli_open_fd_read_count--;
315 }
316 mutex_unlock(&lli->lli_och_mutex);
317 299
318 if (!md_lock_match(md_exp, flags, ll_inode2fid(inode), 300 mutex_lock(&lli->lli_och_mutex);
319 LDLM_IBITS, &policy, lockmode, 301 if (fd->fd_omode & FMODE_WRITE) {
320 &lockh)) { 302 lockmode = LCK_CW;
321 rc = ll_md_real_close(file->f_dentry->d_inode, 303 LASSERT(lli->lli_open_fd_write_count);
322 fd->fd_omode); 304 lli->lli_open_fd_write_count--;
323 } 305 } else if (fd->fd_omode & FMODE_EXEC) {
306 lockmode = LCK_PR;
307 LASSERT(lli->lli_open_fd_exec_count);
308 lli->lli_open_fd_exec_count--;
324 } else { 309 } else {
325 CERROR("Releasing a file %p with negative dentry %p. Name %s", 310 lockmode = LCK_CR;
326 file, file->f_dentry, file->f_dentry->d_name.name); 311 LASSERT(lli->lli_open_fd_read_count);
312 lli->lli_open_fd_read_count--;
327 } 313 }
314 mutex_unlock(&lli->lli_och_mutex);
315
316 if (!md_lock_match(md_exp, flags, ll_inode2fid(inode),
317 LDLM_IBITS, &policy, lockmode, &lockh))
318 rc = ll_md_real_close(inode, fd->fd_omode);
328 319
329out: 320out:
330 LUSTRE_FPRIVATE(file) = NULL; 321 LUSTRE_FPRIVATE(file) = NULL;