Whamcloud - gitweb
b=22891 Objects not getting deleted for files which have been removed
authorDmitry Zogin <dmitry.zoguine@oracle.com>
Mon, 9 Aug 2010 12:51:27 +0000 (08:51 -0400)
committerJohann Lombardi <johann.lombardi@oracle.com>
Tue, 10 Aug 2010 08:33:08 +0000 (10:33 +0200)
 ll_have_md_lock() should differentiate between CR and CW OPEN locks.
 Also sanityN.sh test_36b was added.

 i=oleg.drokin
 i=johann.lombardi

lustre/llite/dcache.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/namei.c

index e4c3762..74925d5 100644 (file)
@@ -406,7 +406,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
                         RETURN(0);
 #endif
 
-                rc = ll_have_md_lock(parent, MDS_INODELOCK_UPDATE);
+                rc = ll_have_md_lock(parent, MDS_INODELOCK_UPDATE, LCK_MINMODE);
                 GOTO(out_sa, rc);
         }
 
@@ -459,7 +459,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;
                 down(&lli->lli_och_sem);
                 if (*och_p) { /* Everything is open already, do nothing */
index 2a1f463..882bfaa 100644 (file)
@@ -3264,12 +3264,14 @@ 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;
         struct ldlm_res_id res_id;
         struct obd_device *obddev;
         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;
         int flags;
         ENTRY;
 
@@ -3279,14 +3281,15 @@ int ll_have_md_lock(struct inode *inode, __u64 bits)
         obddev = ll_i2mdcexp(inode)->exp_obd;
         fid_build_reg_res_name(ll_inode_lu_fid(inode), &res_id);
 
-        CDEBUG(D_INFO, "trying to match res "LPU64":"LPU64":"LPU64"\n",
+        CDEBUG(D_INFO, "trying to match res "LPU64":"LPU64":"LPU64" mode %s\n",
                 res_id.name[0],
                 res_id.name[1],
-                res_id.name[2]);
+                res_id.name[2],
+                ldlm_lockname[mode]);
 
         flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
         if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_IBITS,
-                            &policy, LCK_CR|LCK_CW|LCK_PR|LCK_PW, &lockh)) {
+                            &policy, mode, &lockh)) {
                 RETURN(1);
         }
 
@@ -3370,7 +3373,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);
                 struct ll_fid fid;
                 obd_valid valid = OBD_MD_FLGETATTR;
index fecaac5..17897b1 100644 (file)
@@ -739,7 +739,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);
 int ll_region_mapped(unsigned long addr, size_t count);
 int ll_extent_lock(struct ll_file_data *, struct inode *,
                    struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
index 501c609..28a404b 100644 (file)
@@ -241,6 +241,7 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                 struct inode *inode = ll_inode_from_lock(lock);
                 __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)
@@ -249,14 +250,15 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                 fid = ll_inode_lu_fid(inode);;
 
                 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;
 
                 if (!fid_res_name_eq(fid, &lock->l_resource->lr_name)) {
@@ -555,7 +557,7 @@ int lookup_it_finish(struct ptlrpc_request *request, int offset,
                 /* 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, inode);
                         spin_unlock(&dcache_lock);