From: Alex Zhuravlev Date: Tue, 24 Dec 2024 15:37:30 +0000 (+0300) Subject: LU-18599 mdc: assign mod_close_req when RPC is ready X-Git-Tag: 2.16.53~130 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=5c120ce3ad31675fe9dbae3ec05182dae2ff20b2;p=fs%2Flustre-release.git LU-18599 mdc: assign mod_close_req when RPC is ready we shouldn't assign mod_close_req before the corresponding close RPC is fully populated, otherwise mdc_replay_open() can be accessing RPC with no rq_reqmsg set. Signed-off-by: Alex Zhuravlev Change-Id: I78f7ba2b18c7e9c431accce591cd4a921e25f4da Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57587 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Feng Lei Reviewed-by: Nikitas Angelinas Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 2e4c8d0..9708ad2 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -898,23 +898,6 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, else req = ptlrpc_request_alloc(class_exp2cliimp(exp), req_fmt); - /* Ensure that this close's handle is fixed up during replay. */ - if (likely(mod != NULL)) { - LASSERTF(mod->mod_open_req != NULL && - mod->mod_open_req->rq_type != LI_POISON, - "POISONED open %px!\n", mod->mod_open_req); - - mod->mod_close_req = req; - - DEBUG_REQ(D_RPCTRACE, mod->mod_open_req, "matched open"); - /* We no longer want to preserve this open for replay even - * though the open was committed. b=3632, b=3633 */ - spin_lock(&mod->mod_open_req->rq_lock); - mod->mod_open_req->rq_replay = 0; - spin_unlock(&mod->mod_open_req->rq_lock); - } else { - CDEBUG(D_HA, "couldn't find open req; expecting close error\n"); - } if (req == NULL) { /** * TODO: repeat close after errors @@ -954,6 +937,26 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_request_set_replen(req); + /* Ensure that this close's handle is fixed up during replay. */ + if (likely(mod != NULL)) { + LASSERTF(mod->mod_open_req != NULL && + mod->mod_open_req->rq_type != LI_POISON, + "POISONED open %px!\n", mod->mod_open_req); + + /* Set only when the close RPC has been filled, otherwise + * mdc_replay_open() can access RPC with no rq_reqmsg */ + mod->mod_close_req = req; + + DEBUG_REQ(D_RPCTRACE, mod->mod_open_req, "matched open"); + /* We no longer want to preserve this open for replay even + * though the open was committed. b=3632, b=3633 */ + spin_lock(&mod->mod_open_req->rq_lock); + mod->mod_open_req->rq_replay = 0; + spin_unlock(&mod->mod_open_req->rq_lock); + } else { + CDEBUG(D_HA, "couldn't find open req; expecting close error\n"); + } + ptlrpc_get_mod_rpc_slot(req); rc = ptlrpc_queue_wait(req); ptlrpc_put_mod_rpc_slot(req);