Whamcloud - gitweb
- create special lock with bits fix for cross-ref objects
authortappro <tappro>
Fri, 22 Sep 2006 12:35:07 +0000 (12:35 +0000)
committertappro <tappro>
Fri, 22 Sep 2006 12:35:07 +0000 (12:35 +0000)
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_reint.c

index 313333a..a0a6275 100644 (file)
@@ -489,7 +489,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                          * needed here but update is.
                          */
                         child_bits &= ~MDS_INODELOCK_LOOKUP;
-                        //child_bits |= MDS_INODELOCK_UPDATE;
+                        child_bits |= MDS_INODELOCK_UPDATE;
                         rc = mdt_object_lock(info, child, lhc, child_bits);
                 }
                 if (rc == 0) {
@@ -537,12 +537,9 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
         } else {
                 mdt_lock_handle_init(lhc);
                 lhc->mlh_mode = LCK_CR;
-                if (lu_object_exists(&child->mot_obj.mo_lu) < 0) {
-                        /* we should take LOOKUP lock for cross-ref object */
-                        child_bits &= ~MDS_INODELOCK_UPDATE;
-                        child_bits |= MDS_INODELOCK_LOOKUP;
-                }
-                mdt_object_lock(info, child, lhc, child_bits);
+                rc = mdt_object_cr_lock(info, child, lhc, child_bits);
+                if (rc != 0)
+                        GOTO(out_child, rc);
         }
 
         /* finally, we can get attr for child. */
@@ -580,8 +577,9 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                 
 
         }
-        mdt_object_put(info->mti_ctxt, child);
         EXIT;
+out_child:
+        mdt_object_put(info->mti_ctxt, child);
 out_parent:
         mdt_object_unlock(info, parent, lhp, 1);
 out:
@@ -1190,12 +1188,10 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
 
         LASSERT(!lustre_handle_is_used(&lh->mlh_lh));
         LASSERT(lh->mlh_mode != LCK_MINMODE);
-#if 0
         if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
                 LASSERT(!(ibits & MDS_INODELOCK_UPDATE));
                 LASSERT(ibits & MDS_INODELOCK_LOOKUP);
         }
-#endif
         policy->l_inodebits.bits = ibits;
 
         rc = fid_lock(ns, mdt_object_fid(o), &lh->mlh_lh, lh->mlh_mode,
@@ -1203,6 +1199,18 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
         RETURN(rc);
 }
 
+/* lock with cross-ref fixes */
+int mdt_object_cr_lock(struct mdt_thread_info *info, struct mdt_object *o,
+                       struct mdt_lock_handle *lh, __u64 ibits)
+{
+        if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
+                /* cross-ref object fix */
+                ibits &= ~MDS_INODELOCK_UPDATE;
+                ibits |= MDS_INODELOCK_LOOKUP;
+        }
+        return mdt_object_lock(info, o, lh, ibits);
+}
+
 /*
  * Just call ldlm_lock_decref() if decref, else we only call ptlrpc_save_lock()
  * to save this lock in req.  when transaction committed, req will be released,
index 935f713..5d4ebde 100644 (file)
@@ -362,9 +362,12 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
                  GOTO(out_unlock_parent, rc);
 
         /* we will lock the child regardless it is local or remote. No harm. */
-        mc = mdt_object_find_lock(info, child_fid, child_lh, MDS_INODELOCK_FULL);
+        mc = mdt_object_find(info->mti_ctxt, info->mti_mdt, child_fid);
         if (IS_ERR(mc))
                 GOTO(out_unlock_parent, rc = PTR_ERR(mc));
+        rc = mdt_object_cr_lock(info, mc, lhc, MDS_INODELOCK_FULL);
+        if (rc != 0)
+                GOTO(out_put_child, rc);
 
         mdt_fail_write(info->mti_ctxt, info->mti_mdt->mdt_bottom,
                        OBD_FAIL_MDS_REINT_UNLINK_WRITE);
@@ -383,7 +386,9 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
 
         GOTO(out_unlock_child, rc);
 out_unlock_child:
-        mdt_object_unlock_put(info, mc, child_lh, rc);
+        mdt_object_unlock(info, mc, lhc, rc);
+out_put_child:
+        mdt_object_put(info->mti_ctxt, mc);
 out_unlock_parent:
         mdt_object_unlock_put(info, mp, parent_lh, rc);
 out: