From patchwork Mon Oct 2 07:15:30 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: 9980335 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 86A9360365 for ; Mon, 2 Oct 2017 07:16:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 796A42022B for ; Mon, 2 Oct 2017 07:16:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E5D12839C; Mon, 2 Oct 2017 07:16:04 +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 18A6C2022B for ; Mon, 2 Oct 2017 07:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751251AbdJBHQC (ORCPT ); Mon, 2 Oct 2017 03:16:02 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:22502 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204AbdJBHPs (ORCPT ); Mon, 2 Oct 2017 03:15:48 -0400 X-IronPort-AV: E=Sophos;i="5.42,468,1500912000"; d="scan'208";a="151954156" Received: from sjappemgw11.hgst.com (HELO sjappemgw12.hgst.com) ([199.255.44.62]) by ob1.hgst.iphmx.com with ESMTP; 02 Oct 2017 15:24:02 +0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by sjappemgw12.hgst.com with ESMTP; 02 Oct 2017 00:15:46 -0700 From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , linux-block@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig , Bart Van Assche Subject: [PATCH V6 09/14] scsi: sd_zbc: Disable zone write locking with scsi-mq Date: Mon, 2 Oct 2017 16:15:30 +0900 Message-Id: <20171002071535.8007-10-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171002071535.8007-1-damien.lemoal@wdc.com> References: <20171002071535.8007-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 In the case of a ZBC disk used with scsi-mq, zone write locking does not prevent write reordering in sequential zones. Unlike the legacy case, zone locking is done after the command request is removed from the scheduler dispatch queue. That is, at the time of zone locking, the write command may already be out of order, making locking ineffective. Write order guarantees can only be provided by an adapted I/O scheduler. Disable zone write locking in sd_zbc_write_lock_zone() if the disk is used with scsi-mq. As the disk zones_wlock bitmap is not necessry, do not allocate it. Signed-off-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- drivers/scsi/sd_zbc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 4cb271619fc6..f56ed1bc3eaa 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -287,6 +287,7 @@ int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd) { struct request *rq = cmd->request; + struct request_queue *q = rq->q; struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); sector_t sector = blk_rq_pos(rq); sector_t zone_sectors = sd_zbc_zone_sectors(sdkp); @@ -297,10 +298,14 @@ int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd) */ /* Do not allow zone boundaries crossing on host-managed drives */ - if (blk_queue_zoned_model(rq->q) == BLK_ZONED_HM && + if (blk_queue_zoned_model(q) == BLK_ZONED_HM && (sector & (zone_sectors - 1)) + blk_rq_sectors(rq) > zone_sectors) return BLKPREP_KILL; + /* No write locking with scsi-mq */ + if (q->mq_ops) + return BLKPREP_OK; + /* * There is no write constraints on conventional zones. So any write * command can be sent. But do not issue more than one write command @@ -711,7 +716,7 @@ static int sd_zbc_setup(struct scsi_disk *sdkp) if (sdkp->first_scan) return 0; - if (!sdkp->zones_wlock) { + if (!q->mq_ops && !sdkp->zones_wlock) { sdkp->zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp); if (!sdkp->zones_wlock) return -ENOMEM;