Whamcloud - gitweb
ORNL-2 MDS only processes child lock for getattr-by-fid
authornasf <yong.fan@whamcloud.com>
Fri, 25 Mar 2011 05:17:49 +0000 (13:17 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 26 Mar 2011 16:07:09 +0000 (09:07 -0700)
Change-Id: I4fd46761702f13173f43c83e1d76ff4b0478e786
Signed-off-by: nasf <yong.fan@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/365
Reviewed-by: wangdi <di.wang@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_handler.c

index 0a86137..f97bf96 100644 (file)
@@ -818,7 +818,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
         struct lu_name         *lname     = NULL;
         const char             *name      = NULL;
         int                     namelen   = 0;
-        struct mdt_lock_handle *lhp;
+        struct mdt_lock_handle *lhp       = NULL;
         struct ldlm_lock       *lock;
         struct ldlm_res_id     *res_id;
         int                     is_resent;
@@ -924,16 +924,15 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                 RETURN(rc);
         }
 
-        /* step 1: lock parent */
-        lhp = &info->mti_lh[MDT_LH_PARENT];
-        mdt_lock_pdo_init(lhp, LCK_PR, name, namelen);
-        rc = mdt_object_lock(info, parent, lhp, MDS_INODELOCK_UPDATE,
-                             MDT_LOCAL_LOCK);
-
-        if (unlikely(rc != 0))
-                RETURN(rc);
-
         if (lname) {
+                /* step 1: lock parent */
+                lhp = &info->mti_lh[MDT_LH_PARENT];
+                mdt_lock_pdo_init(lhp, LCK_PR, name, namelen);
+                rc = mdt_object_lock(info, parent, lhp, MDS_INODELOCK_UPDATE,
+                                     MDT_LOCAL_LOCK);
+                if (unlikely(rc != 0))
+                        RETURN(rc);
+
                 /* step 2: lookup child's fid by name */
                 rc = mdo_lookup(info->mti_env, next, lname, child_fid,
                                 &info->mti_spec);
@@ -1057,7 +1056,8 @@ relock:
 out_child:
         mdt_object_put(info->mti_env, child);
 out_parent:
-        mdt_object_unlock(info, parent, lhp, 1);
+        if (lhp)
+                mdt_object_unlock(info, parent, lhp, 1);
         return rc;
 }