X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fptlrpc%2Fservice.c;h=ab19b5cc4dc2f49bbe4e2a519d1271c045dd1e83;hp=cd94b258a5ad7e9a86e205e49ef2fde4be4904e1;hb=be025f5580a0cc4958267d2e4317aac4e2ebc0c3;hpb=8e249d43f19a4d227c76e6def41d7eb19e6a207f diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index cd94b25..ab19b5c 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -125,9 +125,25 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) int rc = 0; int i; + if (svcpt->scp_rqbd_allocating) + goto try_post; + + spin_lock(&svcpt->scp_lock); + /* check again with lock */ + if (svcpt->scp_rqbd_allocating) { + /* NB: we might allow more than one thread in the future */ + LASSERT(svcpt->scp_rqbd_allocating == 1); + spin_unlock(&svcpt->scp_lock); + goto try_post; + } + + svcpt->scp_rqbd_allocating++; + spin_unlock(&svcpt->scp_lock); + + for (i = 0; i < svc->srv_nbuf_per_group; i++) { - /* NB: another thread might be doing this as well, we need to - * make sure that it wouldn't over-allocate, see LU-1212. */ + /* NB: another thread might have recycled enough rqbds, we + * need to make sure it wouldn't over-allocate, see LU-1212. */ if (svcpt->scp_nrqbds_posted >= svc->srv_nbuf_per_group) break; @@ -141,11 +157,19 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service_part *svcpt, int post) } } + spin_lock(&svcpt->scp_lock); + + LASSERT(svcpt->scp_rqbd_allocating == 1); + svcpt->scp_rqbd_allocating--; + + spin_unlock(&svcpt->scp_lock); + CDEBUG(D_RPCTRACE, "%s: allocate %d new %d-byte reqbufs (%d/%d left), rc = %d\n", svc->srv_name, i, svc->srv_buf_size, svcpt->scp_nrqbds_posted, svcpt->scp_nrqbds_total, rc); + try_post: if (post && rc == 0) rc = ptlrpc_server_post_idle_rqbds(svcpt);