From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.137 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795978562; b=RkWjUU+y379EHeUeERct85/7xgjjsbA/o7odc86ZMCRgDrU9LPocJe9MSzs71hRHwpKM sgQz+Vzwaij1DuMZSo6k+03VsTxDnY4TJCcZgtDkR/JHhZydcpRyLwK0GFejCKogtLikX 5gqkPUfkC3CDXdyYy1RcQDMHuxlH5JHhKJcqjyeQUjb2wa0bEnVjwW+8uk4u07Of6YZmU Dp8rVisPnt3a7u07Ha3VUfl2gPXN7dlFT+31+egTi+JXYxozkX1w0CF/tsEvbnmUn3/Xs ygeMpyY4p17AQReUEdJxZguUH0EU2mZ20xvOqIp0Jbbh5emYOFn1igHr/hSW/gzolNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795978562; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=GPBifKGg8NAHxbrvngSq99q6wIhqyp+ZrhGuxJh2SD4=; b=gtL+d+xQGEGf+yOyU06YOk401q+cUF9r7Fs0uJKOfbsDK+iq7Pgg4AHtAD1vg6m83fEX SQcjiQ6aS5zLfYVsx5LDPj4YDZTnSYgqP6163ngI8UMjAAa8jk8TTj3XVzncW5KlV+2zF n8tOrLj9oH5nLILFAEmzet2orE3/OCodpm8NDEh+75szVcgykwQLXQkqq2FuMHzLpciKG FXB64s4nDkgYEkEx5X0WQyCkaG4X8ivIU17mObGLms2cx+0ULnkkCLCsVUeOWvFBeFgf3 nqkAGnyjJbwiDu1QJGJjtvUgiwWgDAp76aRbo+Q1wstSQEBdNy0rU8aNIVsEWjYFbYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="eN5q4/ge"; arc=none smtp.remote-ip=95.215.58.137 Received: from mta1.migadu.com (out-137.mta1.migadu.com [95.215.58.137]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10436606A31C for ; Sun, 29 Nov 2026 18:56:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 10436606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=eN5q4/ge X-Envelope-To: linux-scsi@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=x8Z/3VdQULIW3rSVHaNZnbtYGQ+utbp+ZfcWs+8OSxQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795978559; v=1; x=1796583359; b=eN5q4/geeij24Qt5KqO7Dd8phz9uhQdW7xqwJw3VEGrEQy6OfAuHj/r1xC2egUiuodw1/5lg i60uE53vAOj17bBf5ks+L6MfskYq4PnEAVz7k7gimo5lVVwQ4t23usYDjHfhUcCAOSXhAOKiVpG 5blEajIF3GrBuSFDgL62nYl0= X-Envelope-To: linux-scsi@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id 12a59ae090e5d677; Sun, 29 Nov 2026 18:55:59 +0000 X-Mizu-Trace-ID: 12a59ae090e5d677 X-Migadu-Flow: FLOW_OUT From: John Garry To: James.Bottomley@HansenPartnership.com, mkp@kernel.org Cc: linux-scsi@vger.kernel.org, bvanassche@acm.org, John Garry Subject: [PATCH v3] scsi: core: Clear cmd->flags for terminal queuing error Date: Sun, 29 Nov 2026 18:55:49 +0000 Message-ID: <20261129185549.98746-1-john.garry@linux.dev> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If a request can't be queued in scsi_queue_rq(), then we error out with a blk_status_t code. Such a scenario may be the scsi_device has its transport offline. For BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE, the request may be requeued in the block layer. For other errors, the block layer ends the request and so we won't see it again (until recycled). Normally when a request completes scmd->flags is cleared in scsi_end_request(). However for the error scenario mentioned above, scsi_end_request() is not called and so scmd->flags is not cleared. As such, when the request is recycled we see the old value in scmd->flags. Fix this issue by clearing scmd->flags in the error scenario mentioned by calling scsi_cleanup_rq(). Fixes: 64104f703212f ("scsi: Call scsi_initialize_rq() for filesystem requests") Signed-off-by: John Garry --- Differences to v2 (https://lore.kernel.org/linux-scsi/20261108204733.557995-2-john.garry@linux.dev/) - Adding same handling for BLK_STS_AGAIN - Add fixes tag v1 was sent in https://lore.kernel.org/linux-scsi/20260911075415.634921-1-john.garry@linux.dev/ diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ab39514cc0c6..3d9ef83d3d10 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1976,8 +1976,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, break; case BLK_STS_AGAIN: cmd->result = DID_BUS_BUSY << 16; - if (req->rq_flags & RQF_DONTPREP) - scsi_mq_uninit_cmd(cmd); + scsi_cleanup_rq(req); break; default: if (unlikely(!scsi_device_online(sdev))) @@ -1989,8 +1988,8 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, * we hit an error, as we will never see this command * again. */ - if (req->rq_flags & RQF_DONTPREP) - scsi_mq_uninit_cmd(cmd); + scsi_cleanup_rq(req); + scsi_run_queue_async(sdev); break; } -- 2.43.0