Whamcloud - gitweb
b=22891 Objects are not getting deleted for files which have been removed
authorDmitry Zogin <dmitry.zoguine@oracle.com>
Mon, 30 Aug 2010 13:02:14 +0000 (17:02 +0400)
committerMikhail Pershin <tappro@sun.com>
Wed, 8 Sep 2010 16:37:18 +0000 (20:37 +0400)
 ll_have_md_lock() should differentiate between CR and CW OPEN locks.

 i=oleg.drokin
 i=johann.lombardi

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

index 13c4d98..02a2f1f 100644 (file)
@@ -411,7 +411,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
                 if (de->d_flags & DCACHE_LUSTRE_INVALID)
                         RETURN(0);
 
                 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);
         }
 
                 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. */
                         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 */
                         goto do_lock;
                 cfs_down(&lli->lli_och_sem);
                 if (*och_p) { /* Everything is open already, do nothing */
index 7cb5232..8397433 100644 (file)
@@ -2076,10 +2076,12 @@ int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
         RETURN(-ENOSYS);
 }
 
         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}};
 {
         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;
         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;
                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,
 
         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);
                 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);
                 }
 
                 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;
                 struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
                 obd_valid valid = OBD_MD_FLGETATTR;
                 struct md_op_data *op_data;
index 08f2bd7..483f026 100644 (file)
@@ -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,
                             !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);
                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
                                            "skip renewal for");
                                 sort_add_capa(ocapa, &ll_idle_capas);
index 691b505..49f76dd 100644 (file)
@@ -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 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);
 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);
index ee51be1..04e7b37 100644 (file)
@@ -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;
                 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);
 
                 /* 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) &&
                 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) &&
                         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) &&
                         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);
                         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 */
                 /* 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);
                         spin_lock(&dcache_lock);
                         ll_d_add(*de, NULL);
                         spin_unlock(&dcache_lock);