From patchwork Fri Oct 12 02:30:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10637725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D01C117E3 for ; Fri, 12 Oct 2018 02:30:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B70682C24A for ; Fri, 12 Oct 2018 02:30:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB3792C258; Fri, 12 Oct 2018 02:30:16 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 45A662C24A for ; Fri, 12 Oct 2018 02:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbeJLKAV (ORCPT ); Fri, 12 Oct 2018 06:00:21 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:6549 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbeJLKAV (ORCPT ); Fri, 12 Oct 2018 06:00:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1539311424; x=1570847424; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QdlCwj7T3uwpk6pGHuhzbGRZhSSpDT6ZbjNrN/+llZw=; b=GgEeNkJKTJLBAaQgLk9HEUd/mEuqBisORZwXoEqMQmRenQAfeOv3s7vw 4saGEzIp7JB//i4zswbj42oxr0Oacg213ogqlRW8+TuIwV2mixOSGPvn5 p8mjAhhv4p0cnQafohrGnCZSkahUxHgn6/C8TVSCzBFF/mBfCNZLOaez4 YSI/f74xTlEj2HD8DqTFaEetyamWnKXM0aWukjrnrR8Pt/7oLBn110fvW xSSQH/wX86gxbW11Px/K1WiN5c9/5XCjGbaLjiP3OuP2Wmyut9I70Fgw0 cJHA4xP/RWiQymHsQciqmA02GZskGi9fAfKzRAT7hTA1VMt84DgWpdUuF A==; X-IronPort-AV: E=Sophos;i="5.54,370,1534780800"; d="scan'208";a="189468208" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2018 10:30:24 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 11 Oct 2018 19:15:35 -0700 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 11 Oct 2018 19:30:14 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" , dm-devel@redhat.com, Mike Snitzer Cc: Christoph Hellwig , Matias Bjorling Subject: [PATCH v3 01/11] scsi: sd_zbc: Rearrange code Date: Fri, 12 Oct 2018 11:30:02 +0900 Message-Id: <20181012023012.29923-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181012023012.29923-1-damien.lemoal@wdc.com> References: <20181012023012.29923-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 Move the urswrz check out of sd_zbc_read_zones() and into sd_zbc_read_zoned_characteristics() where that value is obtained (read from the disk zoned characteristics VPD page). Since this function now does more than simply reading the VPD page, rename it to sd_zbc_check_zoned_characteristics(). Also fix the error message displayed when reading that VPD page fails. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/scsi/sd_zbc.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 412c1787dcd9..0b7d8787f785 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -305,19 +305,19 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, } /** - * sd_zbc_read_zoned_characteristics - Read zoned block device characteristics + * sd_zbc_check_zoned_characteristics - Check zoned block device characteristics * @sdkp: Target disk * @buf: Buffer where to store the VPD page data * - * Read VPD page B6. + * Read VPD page B6, get information and check that reads are unconstrained. */ -static int sd_zbc_read_zoned_characteristics(struct scsi_disk *sdkp, - unsigned char *buf) +static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, + unsigned char *buf) { if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) { sd_printk(KERN_NOTICE, sdkp, - "Unconstrained-read check failed\n"); + "Read zoned characteristics VPD page failed\n"); return -ENODEV; } @@ -335,6 +335,18 @@ static int sd_zbc_read_zoned_characteristics(struct scsi_disk *sdkp, sdkp->zones_max_open = get_unaligned_be32(&buf[16]); } + /* + * Check for unconstrained reads: host-managed devices with + * constrained reads (drives failing read after write pointer) + * are not supported. + */ + if (!sdkp->urswrz) { + if (sdkp->first_scan) + sd_printk(KERN_NOTICE, sdkp, + "constrained reads devices are not supported\n"); + return -ENODEV; + } + return 0; } @@ -675,24 +687,11 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) */ return 0; - /* Get zoned block device characteristics */ - ret = sd_zbc_read_zoned_characteristics(sdkp, buf); + /* Check zoned block device characteristics (unconstrained reads) */ + ret = sd_zbc_check_zoned_characteristics(sdkp, buf); if (ret) goto err; - /* - * Check for unconstrained reads: host-managed devices with - * constrained reads (drives failing read after write pointer) - * are not supported. - */ - if (!sdkp->urswrz) { - if (sdkp->first_scan) - sd_printk(KERN_NOTICE, sdkp, - "constrained reads devices are not supported\n"); - ret = -ENODEV; - goto err; - } - /* Check capacity */ ret = sd_zbc_check_capacity(sdkp, buf); if (ret)