Whamcloud - gitweb
LU-329 fix missing ost_lock_put() calls
authorLai Siyao <laisiyao@whamcloud.com>
Tue, 17 May 2011 05:39:49 +0000 (22:39 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 13 Jun 2011 23:47:01 +0000 (16:47 -0700)
* The taken ost lock may be no put in some error cases.
* typo in ost_blocking_ost: oa --> oinfo.

Change-Id: I021494fcf901d2daeeb97f60e23562bcc88d990a
Signed-off-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/554
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: wangdi <di.wang@whamcloud.com>
lustre/ost/ost_handler.c

index 135d423..1eeaabf 100644 (file)
@@ -275,13 +275,13 @@ static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
                 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
                 if (capa == NULL) {
                         CERROR("Missing capability for OST GETATTR");
                 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
                 if (capa == NULL) {
                         CERROR("Missing capability for OST GETATTR");
-                        RETURN (-EFAULT);
+                        GOTO(unlock, rc = -EFAULT);
                 }
         }
 
         OBD_ALLOC_PTR(oinfo);
         if (!oinfo)
                 }
         }
 
         OBD_ALLOC_PTR(oinfo);
         if (!oinfo)
-                RETURN(-ENOMEM);
+                GOTO(unlock, rc = -ENOMEM);
         oinfo->oi_oa = &body->oa;
         oinfo->oi_capa = capa;
 
         oinfo->oi_oa = &body->oa;
         oinfo->oi_capa = capa;
 
@@ -291,10 +291,11 @@ static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
 
         repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
         repbody->oa = body->oa;
 
         repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
         repbody->oa = body->oa;
+        ost_drop_id(exp, &repbody->oa);
 
 
+unlock:
         ost_lock_put(exp, &lh, LCK_PR);
 
         ost_lock_put(exp, &lh, LCK_PR);
 
-        ost_drop_id(exp, &repbody->oa);
         RETURN(0);
 }
 
         RETURN(0);
 }
 
@@ -399,13 +400,13 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
                                                       &RMF_CAPA1);
                         if (capa == NULL) {
                                 CERROR("Missing capability for OST PUNCH");
                                                       &RMF_CAPA1);
                         if (capa == NULL) {
                                 CERROR("Missing capability for OST PUNCH");
-                                RETURN (-EFAULT);
+                                GOTO(unlock, rc = -EFAULT);
                         }
                 }
 
                 OBD_ALLOC_PTR(oinfo);
                 if (!oinfo)
                         }
                 }
 
                 OBD_ALLOC_PTR(oinfo);
                 if (!oinfo)
-                        RETURN(-ENOMEM);
+                        GOTO(unlock, rc = -ENOMEM);
                 oinfo->oi_oa = &body->oa;
                 oinfo->oi_policy.l_extent.start = oinfo->oi_oa->o_size;
                 oinfo->oi_policy.l_extent.end = oinfo->oi_oa->o_blocks;
                 oinfo->oi_oa = &body->oa;
                 oinfo->oi_policy.l_extent.start = oinfo->oi_oa->o_size;
                 oinfo->oi_policy.l_extent.end = oinfo->oi_oa->o_blocks;
@@ -413,6 +414,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
 
                 req->rq_status = obd_punch(exp, oinfo, oti, NULL);
                 OBD_FREE_PTR(oinfo);
 
                 req->rq_status = obd_punch(exp, oinfo, oti, NULL);
                 OBD_FREE_PTR(oinfo);
+unlock:
                 ost_lock_put(exp, &lh, LCK_PW);
         }
 
                 ost_lock_put(exp, &lh, LCK_PW);
         }
 
@@ -1787,7 +1789,7 @@ int ost_blocking_ast(struct ldlm_lock *lock,
                         RETURN(-ENOMEM);
                 OBDO_ALLOC(oa);
                 if (!oa) {
                         RETURN(-ENOMEM);
                 OBDO_ALLOC(oa);
                 if (!oa) {
-                        OBD_FREE_PTR(oa);
+                        OBD_FREE_PTR(oinfo);
                         RETURN(-ENOMEM);
                 }
                 oa->o_id = lock->l_resource->lr_name.name[0];
                         RETURN(-ENOMEM);
                 }
                 oa->o_id = lock->l_resource->lr_name.name[0];