From patchwork Tue Nov 19 00:28:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 13879278 Received: from 009.lax.mailroute.net (009.lax.mailroute.net [199.89.1.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09388DDD9; Tue, 19 Nov 2024 00:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.89.1.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731976150; cv=none; b=m4ymKYP2PrYOhwqADtRE9c1+WPogR4w3wIUtN7bLlAzqHVsKfPFEo92XDbgLjo58WzTnyOpag6kaY7ZE6g/hfChWnNFvbBLNyzMYg+La7KxnSFttVzPZHuPi/1YHV4zAPof0QI1ho9KllkwOzfLXgU7jolVj7EgwWD7KzbmOg18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731976150; c=relaxed/simple; bh=kLLkt4Fs0e4m0K2fT+/PzOsB07T/v4pilQwrgq8wzs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rE1lsH0RHDl9d7A53kJNAnkpg04+70XB1/SGh81vxgdrg+1hDG4w16/mqgmSO7PX3ySe2VZA+7H1Gip7oWSx0GnTN3acy37GJ12WobaZ3xv7Sto5gSOXP09dqADvFqecYYtry2Q4t74LfmNWpl5cmeWneHOeB9OL1gQmrDuniAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b=t2LccxBM; arc=none smtp.client-ip=199.89.1.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=acm.org header.i=@acm.org header.b="t2LccxBM" Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4Xsljc5dj7zlgMVP; Tue, 19 Nov 2024 00:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1731976144; x=1734568145; bh=nx4KB RxMaCf8LrtAVRN8jammCUAU/H3BD9B61OciwYM=; b=t2LccxBMxnagLI07+TFDz MpuXTCRcaMkJNi0AkSFi7NrcNgn2uwQnNfLBWgy02AhfssCyByRoYPvL61j48WIg I+pp1KRrF5AdRGB4n0cuhU0V+F5DDwP1TxkZvc0tlX1zJC3xR/CrKmJQmtICcB59 Gw9rclRJwWVdKXpbGCAQ1q+yLwUmLzqYquuyGExGXPeXgIzZRxiJAp8UEaNYioL/ hOt895qOyq9TH5qbPBP3aTYmxPLVw47WQINPbJ+X0w0c9RX+WAnuniszMWtSZijc 4sLNDCgz6k+IOsYvZeAp+zWCi/JnR6cWpB27Rrh/MlaLPEsGWf6/IbmKatQRfoyy A== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id MVrqmIfq7uqQ; Tue, 19 Nov 2024 00:29:04 +0000 (UTC) Received: from bvanassche.mtv.corp.google.com (unknown [104.135.204.82]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 009.lax.mailroute.net (Postfix) with ESMTPSA id 4XsljV5PW1zlgMVV; Tue, 19 Nov 2024 00:29:02 +0000 (UTC) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Jaegeuk Kim , Bart Van Assche , "Martin K. Petersen" , Ming Lei Subject: [PATCH v16 21/26] scsi: core: Retry unaligned zoned writes Date: Mon, 18 Nov 2024 16:28:10 -0800 Message-ID: <20241119002815.600608-22-bvanassche@acm.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241119002815.600608-1-bvanassche@acm.org> References: <20241119002815.600608-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If zoned writes (REQ_OP_WRITE) for a sequential write required zone have a starting LBA that differs from the write pointer, e.g. because zoned writes have been reordered, then the storage device will respond with an UNALIGNED WRITE COMMAND error. Retry commands that failed with an unaligned write error. The block layer core will sort the SCSI commands per LBA before these are resubmitted. If the write order is preserved, increase the number of retries for write commands sent to a sequential zone to the maximum number of outstanding commands because in the worst case the number of times reordered zoned writes have to be retried is (number of outstanding writes per sequential zone) - 1. Reviewed-by: Damien Le Moal Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 10154d78e336..24cd8e8538e5 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -700,6 +700,22 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) fallthrough; case ILLEGAL_REQUEST: + /* + * Unaligned write command. This may indicate that zoned writes + * have been received by the device in the wrong order. If write + * pipelining is enabled, retry. + */ + if (sshdr.asc == 0x21 && sshdr.ascq == 0x04 && + req->q->limits.driver_preserves_write_order && + blk_rq_is_seq_zoned_write(req) && + scsi_cmd_retry_allowed(scmd)) { + SCSI_LOG_ERROR_RECOVERY(1, + sdev_printk(KERN_WARNING, scmd->device, + "Retrying unaligned write at LBA %#llx.\n", + scsi_get_lba(scmd))); + return NEEDS_RETRY; + } + if (sshdr.asc == 0x20 || /* Invalid command operation code */ sshdr.asc == 0x21 || /* Logical block address out of range */ sshdr.asc == 0x22 || /* Invalid function */