Skip to content

Commit

Permalink
nvmf: Narrow scope of sim lock in nvmf_sim_io
Browse files Browse the repository at this point in the history
nvmf_submit_request() handles races with concurrent queue pair
destruction (or the queue pair being destroyed between
nvmf_allocate_request and nvmf_submit_request), so the lock is not
needed here.  This avoids holding the lock across transport-specific
logic such as queueing mbufs for PDUs to a socket buffer, etc.

Holding the lock across nvmf_allocate_request() ensures that the queue
pair pointers in the softc are still valid as shutdown attempts will
block on the lock before destroying the queue pairs.

Sponsored by:	Chelsio Communications
  • Loading branch information
bsdjhb committed Sep 26, 2024
1 parent aec2ae8 commit ef052ad
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sys/dev/nvmf/host/nvmf_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ nvmf_sim_io(struct nvmf_softc *sc, union ccb *ccb)
qp = sc->admin;
req = nvmf_allocate_request(qp, &nvmeio->cmd, nvmf_ccb_complete,
ccb, M_NOWAIT);
mtx_unlock(&sc->sim_mtx);
if (req == NULL) {
mtx_unlock(&sc->sim_mtx);
nvmeio->ccb_h.status = CAM_RESRC_UNAVAIL;
xpt_done(ccb);
return;
Expand All @@ -150,7 +150,6 @@ nvmf_sim_io(struct nvmf_softc *sc, union ccb *ccb)
("%s: incoming CCB is not in-progress", __func__));
ccb->ccb_h.status |= CAM_SIM_QUEUED;
nvmf_submit_request(req);
mtx_unlock(&sc->sim_mtx);
}

static void
Expand Down

0 comments on commit ef052ad

Please sign in to comment.