From nobody Thu Dec 02 21:05:30 2021 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 BFC7718C4CBD; Thu, 2 Dec 2021 21:05:30 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J4pQ23dKMz3Hqp; Thu, 2 Dec 2021 21:05:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 5D229242BE; Thu, 2 Dec 2021 21:05:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B2L5UpP056697; Thu, 2 Dec 2021 21:05:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B2L5UCE056696; Thu, 2 Dec 2021 21:05:30 GMT (envelope-from git) Date: Thu, 2 Dec 2021 21:05:30 GMT Message-Id: <202112022105.1B2L5UCE056696@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: a10253cffea8 - main - mps(4): Fix unmatched devq release. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a10253cffea84c0c980a36ba6776b00ed96c3e3b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638479130; 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=TS3++vqyJE8/HcjUKVrXhPAKmT7gr8NeIy6A0A6lmGI=; b=nUwslVjylCoq49iXQNb+TONybIBWcqcEEydCBTnFWpncsG/nHD0WXSVUlMAgHPfRNxL8hr LJXGauvEMshCTGjquLXHKkKyHEdSMk9MgtjAEbHLuxpA6ca+ad9i+PbRMVn5ZQZGwnu3gJ dob4EhM2c7X8FdgLosyZPjdjr9nRLPgLfCH7Bvm3pAmVg/auyRTBEI4ZT6jB9i+ARJ4XGT 5e5P03LA48GnRsBNVzOyN2FSLgHUCUvtUcSvTl0eJSSYiXWCzIYf/+R5XRifT3B1ZuRgNm Ly/QGzg9VOg9BP+FEvEXrlyg1my7a1CafyncfEslXZAvqpgIPmvetQKbroSbVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638479130; a=rsa-sha256; cv=none; b=om+HSmZR1vDJxbykoh4EZs730LN5uXABPNolVcBj5LRwXWim3B7SbrBgntFo/NjUGtPib6 mm2EEMrX0OyfccpcyAYseq7wyCIhYKr34BtRbUDjOohw8a/if1g2PTGnxEM3w2ALKfVut4 d6eN6c9WFwuwuEben9TTk3I9IOTDMO7SDUjVxEbmWR/9lipHSID5nlCNM8oKKeWFKAHhH9 4vpooiT56+j7rv0+9QkO6rbZ/M1R1+ZGyLAjYG36JogVepFCBP1pa/nM99enuHfisdPa0I 7f3jo+ZoiwP4tyajoRAS6pfSWBF99/hehywQcDmiokOQFNS8uH6cQEf0YEVMsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a10253cffea84c0c980a36ba6776b00ed96c3e3b commit a10253cffea84c0c980a36ba6776b00ed96c3e3b Author: Warner Losh AuthorDate: 2021-12-02 20:53:44 +0000 Commit: Warner Losh CommitDate: 2021-12-02 20:53:44 +0000 mps(4): Fix unmatched devq release. Port 9781c28c6d63 and a8837c77efd0 to the mps driver. Before this change devq was frozen only if some command was sent to the target after reset started, but release was called always. This change freezes the devq immediately, leaving mprsas_action_scsiio() check only to cover race condition due to different lock devq use. This should also avoid unnecessary requeue of the commands, creating additional log noise and confusing some broken apps. It also avoids a 'busy' requeue of I/Os failing when we're doing recovery that takes longer than the normal busy timeout. These I/Os failing can lead to filesystems being unmounted in the force unmount case for I/O errors. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D33228 --- sys/dev/mps/mps_sas.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c index c54c2a82faff..681565aca2d1 100644 --- a/sys/dev/mps/mps_sas.c +++ b/sys/dev/mps/mps_sas.c @@ -235,8 +235,6 @@ mpssas_alloc_tm(struct mps_softc *sc) void mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm) { - int target_id = 0xFFFFFFFF; - if (tm == NULL) return; @@ -245,13 +243,11 @@ mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm) * free the resources used for freezing the devq. Must clear the * INRESET flag as well or scsi I/O will not work. */ - if (tm->cm_targ != NULL) { - tm->cm_targ->flags &= ~MPSSAS_TARGET_INRESET; - target_id = tm->cm_targ->tid; - } if (tm->cm_ccb) { - mps_dprint(sc, MPS_INFO, "Unfreezing devq for target ID %d\n", - target_id); + mps_dprint(sc, MPS_XINFO | MPS_RECOVERY, + "Unfreezing devq for target ID %d\n", + tm->cm_targ->tid); + tm->cm_targ->flags &= ~MPSSAS_TARGET_INRESET; xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE); xpt_free_path(tm->cm_ccb->ccb_h.path); xpt_free_ccb(tm->cm_ccb); @@ -1699,11 +1695,11 @@ mpssas_action_scsiio(struct mpssas_softc *sassc, union ccb *ccb) } /* - * If target has a reset in progress, freeze the devq and return. The - * devq will be released when the TM reset is finished. + * If target has a reset in progress, the devq should be frozen. + * Geting here we likely hit a race, so just requeue. */ if (targ->flags & MPSSAS_TARGET_INRESET) { - ccb->ccb_h.status = CAM_BUSY | CAM_DEV_QFRZN; + ccb->ccb_h.status = CAM_REQUEUE_REQ | CAM_DEV_QFRZN; mps_dprint(sc, MPS_INFO, "%s: Freezing devq for target ID %d\n", __func__, targ->tid); xpt_freeze_devq(ccb->ccb_h.path, 1); @@ -3244,11 +3240,15 @@ mpssas_async(void *callback_arg, uint32_t code, struct cam_path *path, } /* - * Set the INRESET flag for this target so that no I/O will be sent to - * the target until the reset has completed. If an I/O request does - * happen, the devq will be frozen. The CCB holds the path which is - * used to release the devq. The devq is released and the CCB is freed + * Freeze the devq and set the INRESET flag so that no I/O will be sent to + * the target until the reset has completed. The CCB holds the path which + * is used to release the devq. The devq is released and the CCB is freed * when the TM completes. + * We only need to do this when we're entering reset, not at each time we + * need to send an abort (which will happen if multiple commands timeout + * while we're sending the abort). We do not release the queue for each + * command we complete (just at the end when we free the tm), so freezing + * it each time doesn't make sense. */ void mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm, @@ -3266,7 +3266,13 @@ mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm, } else { tm->cm_ccb = ccb; tm->cm_targ = target; - target->flags |= MPSSAS_TARGET_INRESET; + if ((target->flags & MPSSAS_TARGET_INRESET) == 0) { + mps_dprint(sc, MPS_XINFO | MPS_RECOVERY, + "%s: Freezing devq for target ID %d\n", + __func__, target->tid); + xpt_freeze_devq(ccb->ccb_h.path, 1); + target->flags |= MPSSAS_TARGET_INRESET; + } } } }