From: NeilBrown Date: Sun, 14 Jul 2019 23:41:20 +0000 (-0400) Subject: LU-4423 ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool() X-Git-Tag: 2.12.57~48 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a0240c3ef723a7e1ad20f261bb4d47b29f719276;p=fs%2Flustre-release.git LU-4423 ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool() This spinlock is only needed in this function to protect the list_add_tail(), so make that more obvious. This change means that prp_rq_size is set outside of the spinlock, but as it is only ever read outside of the spinlock, that cannot matter. Change-Id: Ie986bf3737f0da157d991d8880148512bc4dd777 Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/35511 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 6812cdb..7338cd6 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -583,13 +583,11 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) "Trying to change pool size with nonempty pool from %d to %d bytes\n", pool->prp_rq_size, size); - spin_lock(&pool->prp_lock); pool->prp_rq_size = size; for (i = 0; i < num_rq; i++) { struct ptlrpc_request *req; struct lustre_msg *msg; - spin_unlock(&pool->prp_lock); req = ptlrpc_request_cache_alloc(GFP_NOFS); if (!req) return i; @@ -603,8 +601,8 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) req->rq_pool = pool; spin_lock(&pool->prp_lock); list_add_tail(&req->rq_list, &pool->prp_req_list); + spin_unlock(&pool->prp_lock); } - spin_unlock(&pool->prp_lock); return num_rq; } EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);