From patchwork Tue Aug 1 09:39:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9874005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 67BEE6037D for ; Tue, 1 Aug 2017 09:40:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D4928699 for ; Tue, 1 Aug 2017 09:40:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ED2E2869A; Tue, 1 Aug 2017 09:40:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43F21286AB for ; Tue, 1 Aug 2017 09:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751750AbdHAJkz (ORCPT ); Tue, 1 Aug 2017 05:40:55 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:62518 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbdHAJkx (ORCPT ); Tue, 1 Aug 2017 05:40:53 -0400 X-IronPort-AV: E=Sophos;i="5.41,305,1498492800"; d="scan'208";a="38079839" Received: from sjappemgw12.hgst.com (HELO sjappemgw11.hgst.com) ([199.255.44.66]) by ob1.hgst.iphmx.com with ESMTP; 01 Aug 2017 17:40:07 +0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by sjappemgw11.hgst.com with ESMTP; 01 Aug 2017 02:39:35 -0700 From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , Jens Axboe Cc: Hannes Reinecke , Bart Van Assche , Christoph Hellwig Subject: [PATCH 1/2] block: Zoned block device single-threaded submission Date: Tue, 1 Aug 2017 18:39:16 +0900 Message-Id: <20170801093917.4131-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170801093917.4131-1-damien.lemoal@wdc.com> References: <20170801093917.4131-1-damien.lemoal@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hannes Reinecke The scsi_request_fn() dispatch function internally unlocks the request queue before submitting a request to the underlying LLD. This can potentially lead to write request reordering if the context executing scsi_request_fn() is preempted before the request is submitted to the LLD and another context start the same function execution. This is not a problem for regular disks but leads to write I/O errors on host managed zoned block devices and reduce the effectivness of sequential write optimizations for host aware disks. (Note: the zone write lock in place in the scsi command init code will prevent multiple writes from being issued simultaneously to the same zone to avoid HBA level reordering issues, but this locking mechanism is ineffective to prevent reordering at this level) Prevent this from happening by limiting the number of context that can simultaneously execute the queue request_fn() function to a single thread. A similar patch was originally proposed by Hannes Reinecke in a first set of patches implementing ZBC support but ultimately not included in the final support implementation. See commit 92f5e2a295 "block: add flag for single-threaded submission" in the tree https://git.kernel.org/pub/scm/linux/kernel/git/hare/scsi-devel.git/log/?h=zac.v3 Authorship thus goes to Hannes. Signed-off-by: Hannes Reinecke Signed-off-by: Damien Le Moal --- block/blk-core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index dbecbf4a64e0..cf590cbddcfd 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -371,7 +371,14 @@ inline void __blk_run_queue_uncond(struct request_queue *q) * running such a request function concurrently. Keep track of the * number of active request_fn invocations such that blk_drain_queue() * can wait until all these request_fn calls have finished. + * + * For zoned block devices, do not allow multiple threads to + * dequeue requests as this can lead to write request reordering + * during the time the queue is unlocked. */ + if (blk_queue_is_zoned(q) && q->request_fn_active) + return; + q->request_fn_active++; q->request_fn(q); q->request_fn_active--;