From 19105bbaa47251c8ae3c2cfd0cb5798d6a2cc66c Mon Sep 17 00:00:00 2001 From: Dmitry Zogin Date: Mon, 30 Aug 2010 17:02:14 +0400 Subject: [PATCH] b=22891 Objects are not getting deleted for files which have been removed ll_have_md_lock() should differentiate between CR and CW OPEN locks. i=oleg.drokin i=johann.lombardi --- lustre/llite/dcache.c | 4 ++-- lustre/llite/file.c | 11 +++++++---- lustre/llite/llite_capa.c | 3 ++- lustre/llite/llite_internal.h | 2 +- lustre/llite/namei.c | 10 ++++++---- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 13c4d989..02a2f1f 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -411,7 +411,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if (de->d_flags & DCACHE_LUSTRE_INVALID) RETURN(0); - rc = ll_have_md_lock(parent, MDS_INODELOCK_UPDATE); + rc = ll_have_md_lock(parent, MDS_INODELOCK_UPDATE, LCK_MINMODE); GOTO(out_sa, rc); } @@ -471,7 +471,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, och_usecount = &lli->lli_open_fd_read_count; } /* Check for the proper lock. */ - if (!ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP)) + if (!ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP, LCK_MINMODE)) goto do_lock; cfs_down(&lli->lli_och_sem); if (*och_p) { /* Everything is open already, do nothing */ diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7cb5232..8397433 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2076,10 +2076,12 @@ int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) RETURN(-ENOSYS); } -int ll_have_md_lock(struct inode *inode, __u64 bits) +int ll_have_md_lock(struct inode *inode, __u64 bits, ldlm_mode_t l_req_mode) { struct lustre_handle lockh; ldlm_policy_data_t policy = { .l_inodebits = {bits}}; + ldlm_mode_t mode = (l_req_mode == LCK_MINMODE) ? + (LCK_CR|LCK_CW|LCK_PR|LCK_PW) : l_req_mode; struct lu_fid *fid; int flags; ENTRY; @@ -2088,11 +2090,12 @@ int ll_have_md_lock(struct inode *inode, __u64 bits) RETURN(0); fid = &ll_i2info(inode)->lli_fid; - CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); + CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid), + ldlm_lockname[mode]); flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; if (md_lock_match(ll_i2mdexp(inode), flags, fid, LDLM_IBITS, &policy, - LCK_CR|LCK_CW|LCK_PR|LCK_PW, &lockh)) { + mode, &lockh)) { RETURN(1); } RETURN(0); @@ -2201,7 +2204,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, } ll_lookup_finish_locks(&oit, dentry); - } else if (!ll_have_md_lock(dentry->d_inode, ibits)) { + } else if (!ll_have_md_lock(dentry->d_inode, ibits, LCK_MINMODE)) { struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode); obd_valid valid = OBD_MD_FLGETATTR; struct md_op_data *op_data; diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index 08f2bd7..483f026 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -212,7 +212,8 @@ static int capa_thread_main(void *unused) !S_ISDIR(ocapa->u.cli.inode->i_mode) && obd_capa_open_count(ocapa) == 0 && !ll_have_md_lock(ocapa->u.cli.inode, - MDS_INODELOCK_LOOKUP)) { + MDS_INODELOCK_LOOKUP, + LCK_MINMODE)) { DEBUG_CAPA(D_SEC, &ocapa->c_capa, "skip renewal for"); sort_add_capa(ocapa, &ll_idle_capas); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 691b505..49f76dd 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -624,7 +624,7 @@ extern struct file_operations ll_file_operations_flock; extern struct file_operations ll_file_operations_noflock; extern struct inode_operations ll_file_inode_operations; extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *); -extern int ll_have_md_lock(struct inode *inode, __u64 bits); +extern int ll_have_md_lock(struct inode *inode, __u64 bits, ldlm_mode_t l_req_mode); extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, struct lustre_handle *lockh); int __ll_inode_revalidate_it(struct dentry *, struct lookup_intent *, __u64 bits); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index ee51be1..04e7b37 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -200,20 +200,22 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, struct ll_inode_info *lli; __u64 bits = lock->l_policy_data.l_inodebits.bits; struct lu_fid *fid; + ldlm_mode_t mode = lock->l_req_mode; /* Invalidate all dentries associated with this inode */ if (inode == NULL) break; LASSERT(lock->l_flags & LDLM_FL_CANCELING); + /* For OPEN locks we differentiate between lock modes - CR, CW. PR - bug 22891 */ if ((bits & MDS_INODELOCK_LOOKUP) && - ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP)) + ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP, LCK_MINMODE)) bits &= ~MDS_INODELOCK_LOOKUP; if ((bits & MDS_INODELOCK_UPDATE) && - ll_have_md_lock(inode, MDS_INODELOCK_UPDATE)) + ll_have_md_lock(inode, MDS_INODELOCK_UPDATE, LCK_MINMODE)) bits &= ~MDS_INODELOCK_UPDATE; if ((bits & MDS_INODELOCK_OPEN) && - ll_have_md_lock(inode, MDS_INODELOCK_OPEN)) + ll_have_md_lock(inode, MDS_INODELOCK_OPEN, mode)) bits &= ~MDS_INODELOCK_OPEN; fid = ll_inode2fid(inode); @@ -505,7 +507,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, /* Check that parent has UPDATE lock. If there is none, we cannot afford to hash this dentry (done by ll_d_add) as it might get picked up later when UPDATE lock will appear */ - if (ll_have_md_lock(parent, MDS_INODELOCK_UPDATE)) { + if (ll_have_md_lock(parent, MDS_INODELOCK_UPDATE, LCK_MINMODE)) { spin_lock(&dcache_lock); ll_d_add(*de, NULL); spin_unlock(&dcache_lock); -- 1.8.3.1