From: wangdi Date: Thu, 19 Apr 2007 15:40:59 +0000 (+0000) Subject: Branch:HEAD X-Git-Tag: 1.6.0~31 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=22534b95070af08f66862c081188319c06cbb374;p=fs%2Flustre-release.git Branch:HEAD 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 --- diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index dacd3f3..d9db97d 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -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);