Whamcloud - gitweb
Branch:HEAD
authorwangdi <wangdi>
Thu, 19 Apr 2007 15:40:59 +0000 (15:40 +0000)
committerwangdi <wangdi>
Thu, 19 Apr 2007 15:40:59 +0000 (15:40 +0000)
According to shadow's advice, move BRW_WRITE check for grant to the right place
to avoid cl_loi_list_lock for read.
b:11662
r:adilger,green

lustre/osc/osc_request.c

index dacd3f3..d9db97d 100644 (file)
@@ -1310,13 +1310,14 @@ static int async_internal(int cmd, struct obd_export *exp, struct obdo *oa,
 
         /* Consume write credits even if doing a sync write -
          * otherwise we may run out of space on OST due to grant. */
-        spin_lock(&cli->cl_loi_list_lock);
-        for (i = 0; i < page_count; i++) {
-                if (cli->cl_avail_grant >= CFS_PAGE_SIZE &&
-                    cmd == OBD_BRW_WRITE)
-                        osc_consume_write_grant(cli, pga[i]);
+        if (cmd == OBD_BRW_WRITE) {
+                spin_lock(&cli->cl_loi_list_lock);
+                for (i = 0; i < page_count; i++) {
+                        if (cli->cl_avail_grant >= CFS_PAGE_SIZE)
+                                osc_consume_write_grant(cli, pga[i]);
+                }
+                spin_unlock(&cli->cl_loi_list_lock);
         }
-        spin_unlock(&cli->cl_loi_list_lock);
 
         rc = osc_brw_prep_request(cmd, &exp->exp_obd->u.cli, oa, lsm,
                                   page_count, pga, &request);
@@ -1324,7 +1325,7 @@ static int async_internal(int cmd, struct obd_export *exp, struct obdo *oa,
         if (rc == 0) {
                 request->rq_interpret_reply = brw_interpret;
                 ptlrpc_set_add_req(set, request);
-        } else {
+        } else if (cmd == OBD_BRW_WRITE) {
                 spin_lock(&cli->cl_loi_list_lock);
                 for (i = 0; i < page_count; i++)
                         osc_release_write_grant(cli, pga[i], 0);