From patchwork Fri Aug 4 15:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 710603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DE9EC41513 for ; Fri, 4 Aug 2023 15:48:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232067AbjHDPsb (ORCPT ); Fri, 4 Aug 2023 11:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjHDPs3 (ORCPT ); Fri, 4 Aug 2023 11:48:29 -0400 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DF2D2D71; Fri, 4 Aug 2023 08:48:29 -0700 (PDT) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-68783004143so1710361b3a.2; Fri, 04 Aug 2023 08:48:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164108; x=1691768908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MRGGTee1EfuJznTKSeCwQWUyvPF1KRjQA3G7OxPoxWA=; b=EB8qEO4xYlaf+400CtuPNsBA9WG9iIpaoq4rMN0XNY357j1lyhaAUgRF6pQE9FwG6E rHQj1OmlFQJl2urB/y2N37tTyoR7k5v5TG+2mqww4XXg5uFWkW7bxveex0+InPwQ8/f5 ZGfHWRJU61IzIs9ZqfpMQETooliP20k5lmV5M9nzIXy+70kmwit8dhQ2iEBIACeBnQ8x pzqztbJ1a6M8PLmHhP0JQISpIjQLkh7Bv17dL3KIW3cmLapqgtC6ikI515Sviqd0YUGm DDV4sGd7EieZsUTzNBWkZk9+DvgIiaNvzyrLcKGe9G8/o5Snj00Hz6lMhW/8JZvNMVkd agpQ== X-Gm-Message-State: AOJu0YxZ2ri4N/EnVbjOdWQUQsiOa5fVb9B5u/r3aGRar7YlFZqhRVJS XtAbyFtmK9gNsMn/kCiFVVw= X-Google-Smtp-Source: AGHT+IGa1EAXh0qhNk01FU/LJgav8URArUMP/5xjHCiJgt9k/3QPP96L0zPlTaRn4E6A5Tfa7E7SNA== X-Received: by 2002:a05:6a00:23cc:b0:686:6e90:a99b with SMTP id g12-20020a056a0023cc00b006866e90a99bmr2306242pfc.25.1691164108549; Fri, 04 Aug 2023 08:48:28 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:28 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Damien Le Moal , Ming Lei Subject: [PATCH v6 1/7] block: Introduce the flag QUEUE_FLAG_NO_ZONE_WRITE_LOCK Date: Fri, 4 Aug 2023 08:47:59 -0700 Message-ID: <20230804154821.3232094-2-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Writes in sequential write required zones must happen at the write pointer. Even if the submitter of the write commands (e.g. a filesystem) submits writes for sequential write required zones in order, the block layer or the storage controller may reorder these write commands. The zone locking mechanism in the mq-deadline I/O scheduler serializes write commands for sequential zones. Some but not all storage controllers require this serialization. Introduce a new request queue flag to allow block drivers to indicate that they preserve the order of write commands and thus do not require serialization of writes per zone. Reviewed-by: Damien Le Moal Cc: Christoph Hellwig Cc: Ming Lei Signed-off-by: Bart Van Assche --- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2f5371b8482c..b6eb988f81f3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -534,6 +534,12 @@ struct request_queue { #define QUEUE_FLAG_NONROT 6 /* non-rotational device (SSD) */ #define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ #define QUEUE_FLAG_IO_STAT 7 /* do disk/partitions IO accounting */ +/* + * The device supports not using the zone write locking mechanism to serialize + * write operations (REQ_OP_WRITE, REQ_OP_WRITE_ZEROES) issued to a sequential + * write required zone (BLK_ZONE_TYPE_SEQWRITE_REQ). + */ +#define QUEUE_FLAG_NO_ZONE_WRITE_LOCK 8 #define QUEUE_FLAG_NOXMERGES 9 /* No extended merges */ #define QUEUE_FLAG_ADD_RANDOM 10 /* Contributes to random pool */ #define QUEUE_FLAG_SYNCHRONOUS 11 /* always completes in submit context */ @@ -597,6 +603,11 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q); #define blk_queue_skip_tagset_quiesce(q) \ test_bit(QUEUE_FLAG_SKIP_TAGSET_QUIESCE, &(q)->queue_flags) +static inline bool blk_queue_no_zone_write_lock(struct request_queue *q) +{ + return test_bit(QUEUE_FLAG_NO_ZONE_WRITE_LOCK, &q->queue_flags); +} + extern void blk_set_pm_only(struct request_queue *q); extern void blk_clear_pm_only(struct request_queue *q); From patchwork Fri Aug 4 15:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 711089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 707C0C41513 for ; Fri, 4 Aug 2023 15:48:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbjHDPsh (ORCPT ); Fri, 4 Aug 2023 11:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbjHDPsc (ORCPT ); Fri, 4 Aug 2023 11:48:32 -0400 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DAF52D71; Fri, 4 Aug 2023 08:48:31 -0700 (PDT) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-686f1240a22so2059036b3a.0; Fri, 04 Aug 2023 08:48:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164110; x=1691768910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dgxEXFnorII/KCLaOV4R9mvcBZp+FsMdRey1KII0Yw=; b=ak8HBgVYIjMGaCC5XR/UVRLaOs3pM60VRHsNpZBZ7gBiAvP4oNzAJwP4s8bRs+4trf Bh0YqU8Ss9vbxybGi+6FKNpwEBIuEnCElvaCyExmBNbrxbV3xCC6qpbs4zjmYgAyA+OQ euPs/r9b6pOYL+al9mY0AIk6PXKills9tJj4xLPEorZugVpatQQV5N7BQtT3NW12CgtJ rrJeOY5/aVKKILepNqaDX5j6DmRlq20AbyS6XtdIDOSZCqeYYCZ/BSCpS+YDbdyqnX+y HZ60MzMnYqxjUb8YxH5dSkLRr2D09wmGxRarBxCVqtaHShDOypRKFtMbrrgUEtYZ73Po Rvnw== X-Gm-Message-State: AOJu0YxcJyX7tfNWi+Cd5cfZQvn1RGS8Kut4fw97D5ijyZ/Lkexdakkh ItArraQaYue12k9UFc8scHQ= X-Google-Smtp-Source: AGHT+IFWBWo9WoVkeoqVtei66Au+rXkw/bmznip5BJsQzjlXJa+HYw6p7t4RGUdRjnh+gEap6Ym9pQ== X-Received: by 2002:a05:6a20:6a28:b0:135:293b:9b14 with SMTP id p40-20020a056a206a2800b00135293b9b14mr2587253pzk.55.1691164110488; Fri, 04 Aug 2023 08:48:30 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:29 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Damien Le Moal , Ming Lei Subject: [PATCH v6 2/7] block/mq-deadline: Only use zone locking if necessary Date: Fri, 4 Aug 2023 08:48:00 -0700 Message-ID: <20230804154821.3232094-3-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Measurements have shown that limiting the queue depth to one per zone for zoned writes has a significant negative performance impact on zoned UFS devices. Hence this patch that disables zone locking by the mq-deadline scheduler if the storage controller preserves the command order. This patch is based on the following assumptions: - It happens infrequently that zoned write requests are reordered by the block layer. - The I/O priority of all write requests is the same per zone. - Either no I/O scheduler is used or an I/O scheduler is used that serializes write requests per zone. Reviewed-by: Damien Le Moal Cc: Christoph Hellwig Cc: Ming Lei Signed-off-by: Bart Van Assche --- block/mq-deadline.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index 02a916ba62ee..1f4124dd4a0b 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -338,6 +338,16 @@ static struct request *deadline_skip_seq_writes(struct deadline_data *dd, return rq; } +/* + * Use write locking if either QUEUE_FLAG_NO_ZONE_WRITE_LOCK has not been set. + * Not using zone write locking is only safe if the block driver preserves the + * request order. + */ +static bool dd_use_zone_write_locking(struct request_queue *q) +{ + return blk_queue_is_zoned(q) && !blk_queue_no_zone_write_lock(q); +} + /* * For the specified data direction, return the next request to * dispatch using arrival ordered lists. @@ -353,7 +363,7 @@ deadline_fifo_request(struct deadline_data *dd, struct dd_per_prio *per_prio, return NULL; rq = rq_entry_fifo(per_prio->fifo_list[data_dir].next); - if (data_dir == DD_READ || !blk_queue_is_zoned(rq->q)) + if (data_dir == DD_READ || !dd_use_zone_write_locking(rq->q)) return rq; /* @@ -398,7 +408,7 @@ deadline_next_request(struct deadline_data *dd, struct dd_per_prio *per_prio, if (!rq) return NULL; - if (data_dir == DD_READ || !blk_queue_is_zoned(rq->q)) + if (data_dir == DD_READ || !dd_use_zone_write_locking(rq->q)) return rq; /* @@ -526,8 +536,9 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd, } /* - * For a zoned block device, if we only have writes queued and none of - * them can be dispatched, rq will be NULL. + * For a zoned block device that requires write serialization, if we + * only have writes queued and none of them can be dispatched, rq will + * be NULL. */ if (!rq) return NULL; @@ -552,7 +563,8 @@ static struct request *__dd_dispatch_request(struct deadline_data *dd, /* * If the request needs its target zone locked, do it. */ - blk_req_zone_write_lock(rq); + if (dd_use_zone_write_locking(rq->q)) + blk_req_zone_write_lock(rq); rq->rq_flags |= RQF_STARTED; return rq; } @@ -933,7 +945,7 @@ static void dd_finish_request(struct request *rq) atomic_inc(&per_prio->stats.completed); - if (blk_queue_is_zoned(q)) { + if (dd_use_zone_write_locking(rq->q)) { unsigned long flags; spin_lock_irqsave(&dd->zone_lock, flags); From patchwork Fri Aug 4 15:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 710602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44455C04A94 for ; Fri, 4 Aug 2023 15:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjHDPsi (ORCPT ); Fri, 4 Aug 2023 11:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232088AbjHDPsd (ORCPT ); Fri, 4 Aug 2023 11:48:33 -0400 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C88B33C3D; Fri, 4 Aug 2023 08:48:32 -0700 (PDT) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-686b9920362so1645769b3a.1; Fri, 04 Aug 2023 08:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164112; x=1691768912; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cKob5yfr1F98047yz5yKCajSfKdMgNwlUre3zfhdDvI=; b=dsmzaPC10hxZpZ9FdlYg0Bt8APWvuy75WTWAPKmmR90FnN0D6XZUsOAuKdKan8739i bUuTcfoEtacWbyqpketFtpqbpOspEyYLvmzA1zi5bA4BiiFddU0UJ806eUhuT72b3R1r 2LoRm4uPlk7AaITd9srR9Atr5F+1ou9WpPB6wIq9uLw4L3JAx4cTlBh8TksEjAVgIN4u xQ2hFwCvM/SODzz25gA91rkMDlzVm6FeodFDvzVIOg1v0wcKSRMU9T2RDN5+sJFLCqSK SEEH1hnqtik2U3dl7U5d3wtm9jqo0QOn868n5AW3CFM7Z0IaD8uY2ehbh21ME6+QlITw gUfg== X-Gm-Message-State: AOJu0YxmRcjpEWU94iY7W3PrvrGUOMCIfTjoS6yTPUEUDM/EKYmfsuZG HJNnCmPHufpFtcm5o5SlKOw= X-Google-Smtp-Source: AGHT+IGQ0ab0MoOn9aYfyCv0wQWxOPLxuimGkKvj/KED8sVDVmqsDV/1eIpJJdB9gTs6HguTD38SCg== X-Received: by 2002:a05:6a00:1903:b0:682:7d8a:f887 with SMTP id y3-20020a056a00190300b006827d8af887mr2066625pfi.30.1691164112074; Fri, 04 Aug 2023 08:48:32 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:31 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Damien Le Moal , Ming Lei , "James E.J. Bottomley" Subject: [PATCH v6 3/7] scsi: core: Retry unaligned zoned writes Date: Fri, 4 Aug 2023 08:48:01 -0700 Message-ID: <20230804154821.3232094-4-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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. Send commands that failed with an unaligned write error to the SCSI error handler if zone write locking is disabled. Let the SCSI error handler sort SCSI commands per LBA before resubmitting these. If zone write locking is disabled, 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 | 37 +++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_lib.c | 1 + drivers/scsi/sd.c | 3 +++ include/scsi/scsi.h | 1 + 4 files changed, 42 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index c67cdcdc3ba8..766a576b9be6 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -698,6 +699,16 @@ 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 zone + * write locking is disabled, retry after all pending commands + * have completed. + */ + if (sshdr.asc == 0x21 && sshdr.ascq == 0x04 && + blk_queue_no_zone_write_lock(scsi_cmd_to_rq(scmd)->q)) + return NEEDS_DELAYED_RETRY; + if (sshdr.asc == 0x20 || /* Invalid command operation code */ sshdr.asc == 0x21 || /* Logical block address out of range */ sshdr.asc == 0x22 || /* Invalid function */ @@ -2186,6 +2197,25 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost, } EXPORT_SYMBOL_GPL(scsi_eh_ready_devs); +/* + * Returns a negative value if @_a has a lower starting sector than @_b, zero if + * both have the same starting sector and a positive value otherwise. + */ +static int scsi_cmp_sector(void *priv, const struct list_head *_a, + const struct list_head *_b) +{ + struct scsi_cmnd *a = list_entry(_a, typeof(*a), eh_entry); + struct scsi_cmnd *b = list_entry(_b, typeof(*b), eh_entry); + const sector_t pos_a = blk_rq_pos(scsi_cmd_to_rq(a)); + const sector_t pos_b = blk_rq_pos(scsi_cmd_to_rq(b)); + + if (pos_a < pos_b) + return -1; + if (pos_a > pos_b) + return 1; + return 0; +} + /** * scsi_eh_flush_done_q - finish processed commands or retry them. * @done_q: list_head of processed commands. @@ -2194,6 +2224,13 @@ void scsi_eh_flush_done_q(struct list_head *done_q) { struct scsi_cmnd *scmd, *next; + /* + * Sort pending SCSI commands in starting sector order. This is + * important if one of the SCSI devices associated with @shost is a + * zoned block device for which zone write locking is disabled. + */ + list_sort(NULL, done_q, scsi_cmp_sector); + list_for_each_entry_safe(scmd, next, done_q, eh_entry) { list_del_init(&scmd->eh_entry); if (scsi_device_online(scmd->device) && diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 59176946ab56..69da8aee13df 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1443,6 +1443,7 @@ static void scsi_complete(struct request *rq) case ADD_TO_MLQUEUE: scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); break; + case NEEDS_DELAYED_RETRY: default: scsi_eh_scmd_add(cmd); break; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 68b12afa0721..27b9ebe05b90 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1235,6 +1235,9 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) cmd->transfersize = sdp->sector_size; cmd->underflow = nr_blocks << 9; cmd->allowed = sdkp->max_retries; + if (blk_queue_no_zone_write_lock(rq->q) && + blk_rq_is_seq_zoned_write(rq)) + cmd->allowed += rq->q->nr_requests; cmd->sdb.length = nr_blocks * sdp->sector_size; SCSI_LOG_HLQUEUE(1, diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index ec093594ba53..6600db046227 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -93,6 +93,7 @@ static inline int scsi_status_is_check_condition(int status) * Internal return values. */ enum scsi_disposition { + NEEDS_DELAYED_RETRY = 0x2000, NEEDS_RETRY = 0x2001, SUCCESS = 0x2002, FAILED = 0x2003, From patchwork Fri Aug 4 15:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 711088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29CC9C001DB for ; Fri, 4 Aug 2023 15:48:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbjHDPsk (ORCPT ); Fri, 4 Aug 2023 11:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjHDPsf (ORCPT ); Fri, 4 Aug 2023 11:48:35 -0400 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B1A849CC; Fri, 4 Aug 2023 08:48:34 -0700 (PDT) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-686bc261111so1691387b3a.3; Fri, 04 Aug 2023 08:48:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164114; x=1691768914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iKserUc7+qK0U76dK5VQGcFoPHl5fU7xJij7hQDUDFE=; b=L/qrKScd1HOaP9tfNf66d3acO7IJ3nsxdW0UvhOXplUZcD9ga3Y5GmS42WNLNYYn7K 7WMZM4ETQv9YtR/trKf7XyBcDIWLMDREXa2X6WsgLx6T8v7TAxHXBxEqudJId7sfZc+e RInv8TnFGX/kJwanDm6mdtz5gRoA5WpALot+FT2Nct4CGsx8BQYP1Ntsr3kqlMEa/4J/ b8wp2hGdn9nlkZCNOFHyelobxh+7BUeTayKB/noZtu8DJr42IiNkGHGWEDjyr7gsyTev DCRZTshJRL5cOdoCSVnKGEAVbMBQ4VFo1AoTffcwpLW/W/lwmxSrUp2B0izvWMeb+XhN 4oCw== X-Gm-Message-State: AOJu0YyqeLB+ksyIpKp0a3n6J0qgM1L3A5ndgrMq6RXbDjMxj3e4MGNZ ZVGHs3iA2rCfc+uO4H8eo60jTTGlRVs= X-Google-Smtp-Source: AGHT+IHq/LODUFwVPhm9/l3MznRO5BfLb9qFl2e4yClrfOn1hQJLpg7yicoblQURkA/Caa/HbdJHHA== X-Received: by 2002:a05:6a00:24c5:b0:687:542b:f11 with SMTP id d5-20020a056a0024c500b00687542b0f11mr2290922pfv.25.1691164113763; Fri, 04 Aug 2023 08:48:33 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:33 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Douglas Gilbert , "James E.J. Bottomley" Subject: [PATCH v6 4/7] scsi: scsi_debug: Support disabling zone write locking Date: Fri, 4 Aug 2023 08:48:02 -0700 Message-ID: <20230804154821.3232094-5-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make it easier to test handling of QUEUE_FLAG_NO_ZONE_WRITE_LOCK by adding support for setting this flag for scsi_debug request queues. Cc: Martin K. Petersen Cc: Douglas Gilbert Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_debug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 9c0af50501f9..57c6242bfb26 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -832,6 +832,7 @@ static int dix_reads; static int dif_errors; /* ZBC global data */ +static bool sdeb_no_zwrl; static bool sdeb_zbc_in_use; /* true for host-aware and host-managed disks */ static int sdeb_zbc_zone_cap_mb; static int sdeb_zbc_zone_size_mb; @@ -5138,9 +5139,13 @@ static struct sdebug_dev_info *find_build_dev_info(struct scsi_device *sdev) static int scsi_debug_slave_alloc(struct scsi_device *sdp) { + struct request_queue *q = sdp->request_queue; + if (sdebug_verbose) pr_info("slave_alloc <%u %u %u %llu>\n", sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); + if (sdeb_no_zwrl) + blk_queue_flag_set(QUEUE_FLAG_NO_ZONE_WRITE_LOCK, q); return 0; } @@ -5738,6 +5743,7 @@ module_param_named(ndelay, sdebug_ndelay, int, S_IRUGO | S_IWUSR); module_param_named(no_lun_0, sdebug_no_lun_0, int, S_IRUGO | S_IWUSR); module_param_named(no_rwlock, sdebug_no_rwlock, bool, S_IRUGO | S_IWUSR); module_param_named(no_uld, sdebug_no_uld, int, S_IRUGO); +module_param_named(no_zone_write_lock, sdeb_no_zwrl, bool, S_IRUGO); module_param_named(num_parts, sdebug_num_parts, int, S_IRUGO); module_param_named(num_tgts, sdebug_num_tgts, int, S_IRUGO | S_IWUSR); module_param_named(opt_blks, sdebug_opt_blks, int, S_IRUGO); @@ -5812,6 +5818,8 @@ MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)"); MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)"); MODULE_PARM_DESC(no_rwlock, "don't protect user data reads+writes (def=0)"); MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))"); +MODULE_PARM_DESC(no_zone_write_lock, + "Disable serialization of zoned writes (def=0)"); MODULE_PARM_DESC(num_parts, "number of partitions(def=0)"); MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); MODULE_PARM_DESC(opt_blks, "optimal transfer length in blocks (def=1024)"); From patchwork Fri Aug 4 15:48:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 710601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2720AC001DF for ; Fri, 4 Aug 2023 15:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjHDPsl (ORCPT ); Fri, 4 Aug 2023 11:48:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbjHDPsg (ORCPT ); Fri, 4 Aug 2023 11:48:36 -0400 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9536212D; Fri, 4 Aug 2023 08:48:35 -0700 (PDT) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso1707303b3a.3; Fri, 04 Aug 2023 08:48:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164115; x=1691768915; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dgVJwigdvLnC3PLQrDWBl0zwhzVQqSuEsytYp17x/Y=; b=M4Ot9OTmkOPk+bUQurRH6a97qDMsh8YdTY7WFWWYd8xk8/kPPvX+yqDotL1Fx5OBon A4ySavAUZamGF1PzooWnHeoaWXj5LXIXSgviIS4AjUyDOAD2dahFQoEH4v0j8AsOX2QC uDHpmUbj/MvqbZ8eMtsWlIp7WtMyRWBhhLdNj9mDK+1Nf2mHjDIUk4dZqaP/mVL/1Gwk SwT5UcxVu8Xb5+z3NWbvuG4C3zElGZgZAd4zQUPvIHXQ25eZ5yI5ozUWQScnkRKQnB4e jm6zsaKjQDu3kr39qUzTsHxUVtJd9U2RvrmJqpZ/Ak9+S6LdkS75+4U2qp2lqNjXMuBd Nvag== X-Gm-Message-State: AOJu0YzuRWmbitPH6flf4ITxN/klifSvyJ0pTtPPTUs0/pJBjAx4M69K +4oPnla5CQHehdx7PZJs+I4= X-Google-Smtp-Source: AGHT+IE6UXeJ8m7847TPVs7vLSEAfOlH6ykY+KbSZLgMvhXxq6urbq5zJmbU1hdzw9B2bAQnGhyBoQ== X-Received: by 2002:a05:6a00:22c2:b0:687:3e8f:2211 with SMTP id f2-20020a056a0022c200b006873e8f2211mr2370496pfj.34.1691164115160; Fri, 04 Aug 2023 08:48:35 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:34 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Douglas Gilbert , "James E.J. Bottomley" Subject: [PATCH v6 5/7] scsi: scsi_debug: Support injecting unaligned write errors Date: Fri, 4 Aug 2023 08:48:03 -0700 Message-ID: <20230804154821.3232094-6-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Allow user space software, e.g. a blktests test, to inject unaligned write errors. Cc: Martin K. Petersen Cc: Douglas Gilbert Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_debug.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 57c6242bfb26..051b0605f11f 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -181,6 +181,7 @@ static const char *sdebug_version_date = "20210520"; #define SDEBUG_OPT_NO_CDB_NOISE 0x4000 #define SDEBUG_OPT_HOST_BUSY 0x8000 #define SDEBUG_OPT_CMD_ABORT 0x10000 +#define SDEBUG_OPT_UNALIGNED_WRITE 0x20000 #define SDEBUG_OPT_ALL_NOISE (SDEBUG_OPT_NOISE | SDEBUG_OPT_Q_NOISE | \ SDEBUG_OPT_RESET_NOISE) #define SDEBUG_OPT_ALL_INJECTING (SDEBUG_OPT_RECOVERED_ERR | \ @@ -188,7 +189,8 @@ static const char *sdebug_version_date = "20210520"; SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR | \ SDEBUG_OPT_SHORT_TRANSFER | \ SDEBUG_OPT_HOST_BUSY | \ - SDEBUG_OPT_CMD_ABORT) + SDEBUG_OPT_CMD_ABORT | \ + SDEBUG_OPT_UNALIGNED_WRITE) #define SDEBUG_OPT_RECOV_DIF_DIX (SDEBUG_OPT_RECOVERED_ERR | \ SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR) @@ -3587,6 +3589,14 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) struct sdeb_store_info *sip = devip2sip(devip, true); u8 *cmd = scp->cmnd; + if (unlikely(sdebug_opts & SDEBUG_OPT_UNALIGNED_WRITE && + atomic_read(&sdeb_inject_pending))) { + atomic_set(&sdeb_inject_pending, 0); + mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, + UNALIGNED_WRITE_ASCQ); + return check_condition_result; + } + switch (cmd[0]) { case WRITE_16: ei_lba = 0; From patchwork Fri Aug 4 15:48:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 711087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7655C04A6A for ; Fri, 4 Aug 2023 15:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232080AbjHDPsz (ORCPT ); Fri, 4 Aug 2023 11:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbjHDPsv (ORCPT ); Fri, 4 Aug 2023 11:48:51 -0400 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE6F649F8; Fri, 4 Aug 2023 08:48:43 -0700 (PDT) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6874d1c8610so1724565b3a.0; Fri, 04 Aug 2023 08:48:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691164123; x=1691768923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0xs3eQ100BztgYl07Pu6o58l3Ii8LAwrgxPmcbK9FQY=; b=Fo47HGjOiUH7J6XbECMINFLAABy7/5vWz/OtvBDJj5caWY4zoiS+F0g51plcegbOMH 2StHhehcOhPb+2GtjtyZyk9+o3dxV5ZaGpkpMq01UVcUUqy15+U+Tsz9dQdBITaelc63 cNrRB+2gS3Tl8R2NrZQpwttFNkJ/amOzU9vDFMysIkcaEbjGoweiqGL5ICia0VYAlRsr uW+xhCpCRw80aG3IO+U6bzlSgHQoFhjELpMWTErXOR3/bxb0+MAVIy5jGcX4zTqdfjNF b/HKcv5Vshn3SSpse3/n0mVVJwAkS2bM8r6/9/aW4REve9Pc3eI3CNX6V0O+McF5XY4J Pj+g== X-Gm-Message-State: AOJu0YxDKPBl1PqlnSKr5EzPkWOVMV8VUQC6ziN4Gi6oqxkPlmrpooi1 JtxbdhpqdARlOf+V1jKra5E= X-Google-Smtp-Source: AGHT+IHZCQ3UPiQ9ncmK9kDDJeXUOC+U1BZeg7wHMRQrxmqJFjwZTWOeY+c2Lb9jBPk042JEHYUcDw== X-Received: by 2002:a05:6a00:c8b:b0:676:20f8:be41 with SMTP id a11-20020a056a000c8b00b0067620f8be41mr2300430pfv.16.1691164123066; Fri, 04 Aug 2023 08:48:43 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:4af5:d063:a66d:403b]) by smtp.gmail.com with ESMTPSA id h8-20020a62b408000000b00640ddad2e0dsm1760839pfn.47.2023.08.04.08.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 08:48:42 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Avri Altman , Damien Le Moal , Ming Lei , "James E.J. Bottomley" , Stanley Chu , Can Guo , Bean Huo , Asutosh Das , "Bao D. Nguyen" , Arthur Simchaev Subject: [PATCH v6 6/7] scsi: ufs: Split an if-condition Date: Fri, 4 Aug 2023 08:48:04 -0700 Message-ID: <20230804154821.3232094-7-bvanassche@acm.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230804154821.3232094-1-bvanassche@acm.org> References: <20230804154821.3232094-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Make the next patch in this series easier to read. No functionality is changed. Cc: Martin K. Petersen Cc: Avri Altman Cc: Christoph Hellwig Cc: Damien Le Moal Cc: Ming Lei Signed-off-by: Bart Van Assche Reviewed-by: Can Guo --- drivers/ufs/core/ufshcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 129446775796..ae7b868f9c26 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4352,8 +4352,9 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) } spin_unlock_irqrestore(hba->host->host_lock, flags); - if (update && - !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { + if (!update) + return; + if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { ufshcd_rpm_get_sync(hba); ufshcd_hold(hba); ufshcd_auto_hibern8_enable(hba);