From nobody Thu Sep 26 01:15:24 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XDbHw5xZLz5XyZy; Thu, 26 Sep 2024 01:15:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XDbHw5Q0qz4K2m; Thu, 26 Sep 2024 01:15:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727313324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NbXMsSHjXOF/oS9g7m764L2i7a2oCCZFlNF9Tu9Vo8A=; b=q9UUbNvj4jaBRwUQxfvcmwYwiRy9fsnD7bdtL+jpX2mVs/RYHRvIpDmEkDZZD3r4f/ReEJ ubnDzudnAenddRtGxqK3zflycPAlQkgenrYm0pJjBudL5+LIt3pKVR/qqn3OxF564ga9qF DPWtrDcoeC8Y1NEVHn3o5RJuSjHDEw9MXyCSEthFrCWwSnohk+0rkK3cQ+10Ut2/ENonUk R9p7wsay4tKCZTtJrXZnTKJ7HwMNzMkbPXGWbQiZqmEuynoQpCxRtxyM+Jm+QYMVHDvmne j+KqqSyANN5Y8D5KLDzboBrZNz/RDlM+ol+w+Xfv9OcJKUONYpaN9FEV+1a3Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727313324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NbXMsSHjXOF/oS9g7m764L2i7a2oCCZFlNF9Tu9Vo8A=; b=mId3Wx8GRjq6AQFN6hIOrQfPxyfnOO7moRsz2hTvL+r/dVSCBiLJ12tvSqL+2xiSW5b6V3 O+gQll8Du8uapx0vjJlJFMrbbgOgZ28mqaz2g9sPzeUq92wUb7x4I3qkgpm/KwEU3PW1vo J0/EBUhDMWJZFVEsnCmJwSb5rKM6jSk4+uOzhOZL8kjOare1PP2T4E6VZv7DluFqdYK0b+ sHkcimgLGV+67FqSt1aQA1qzg/UQ66zyaxVRIbUrxS+ttDoy7iciZoUUIfkE4Ot8soNfyV 6G2CYpEruIrjFqIa2W6xqbSRerw1mAjJV3vKQ9YfBO6761l/FU76R8gxhnNycg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727313324; a=rsa-sha256; cv=none; b=g6QJM34Q8clKH01smerP+XDBkPeZDsGd9AYSISqObCu78ZpvEd/fY3jZH++7sTTfXZ0P1/ Igt3jmisFNv+OBSHtlO2ygv7N/izkwpgcqyzJ96nWWcfuwtN4k/T+MYZTiTQ3EY3HfvvG2 BgKPHRLD9OkFcPnq018KyCNbwlu9S78powXjmWyGCCNwhH2mIymaiRayq0uE1U2pznKnWR GGbcEPskmxVMXB1hJxqnbD0HiHPJ5xyb1N6dKlxNkUbw9rAqQ8JSC9zo6qkE8uIL3ZH8HP ftxvBnsKDmPpqOFWwyRxEoDk1i2s21tpue48RDE8EUytDx+HMMVJrCPJrSU3OQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XDbHw51FXzbby; Thu, 26 Sep 2024 01:15:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48Q1FOv6061330; Thu, 26 Sep 2024 01:15:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48Q1FOHV061327; Thu, 26 Sep 2024 01:15:24 GMT (envelope-from git) Date: Thu, 26 Sep 2024 01:15:24 GMT Message-Id: <202409260115.48Q1FOHV061327@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ef052adf09f2 - main - nvmf: Narrow scope of sim lock in nvmf_sim_io List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ef052adf09f25a20e694c3375cc7a0edd4cb0a52 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ef052adf09f25a20e694c3375cc7a0edd4cb0a52 commit ef052adf09f25a20e694c3375cc7a0edd4cb0a52 Author: John Baldwin AuthorDate: 2024-09-26 01:14:06 +0000 Commit: John Baldwin CommitDate: 2024-09-26 01:14:06 +0000 nvmf: Narrow scope of sim lock in nvmf_sim_io 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 --- sys/dev/nvmf/host/nvmf_sim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/dev/nvmf/host/nvmf_sim.c b/sys/dev/nvmf/host/nvmf_sim.c index 8850174edf24..de9e958d8afd 100644 --- a/sys/dev/nvmf/host/nvmf_sim.c +++ b/sys/dev/nvmf/host/nvmf_sim.c @@ -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; @@ -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