From patchwork Thu Oct 11 07:09:42 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: 10636203 X-Patchwork-Delegate: snitzer@redhat.com 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 25B4F3CF1 for ; Thu, 11 Oct 2018 07:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7E82AE79 for ; Thu, 11 Oct 2018 07:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3AC62AEFF; Thu, 11 Oct 2018 07:10:53 +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=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99CA32AE79 for ; Thu, 11 Oct 2018 07:10:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8990C300C22E; Thu, 11 Oct 2018 07:10:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 573BC62959; Thu, 11 Oct 2018 07:10:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 082F618005B1; Thu, 11 Oct 2018 07:10:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9B7AgC0010594 for ; Thu, 11 Oct 2018 03:10:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F340764D9; Thu, 11 Oct 2018 07:10:42 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B42C4DA85; Thu, 11 Oct 2018 07:10:36 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE800300272B; Thu, 11 Oct 2018 07:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1539241847; x=1570777847; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=QdlCwj7T3uwpk6pGHuhzbGRZhSSpDT6ZbjNrN/+llZw=; b=CrClUF9ZNUINXC/vsVCKpXEp0/jix3gHdeTKBUuPPh3XoiADZcRL5nrQ m59XuXZUCLjysipRaaQYIenhow7J97KuyJJt+hCnSfk1kgAesLCjbwI+s tYaqklxz0yqQ06a0xVmrzqU6iZkVxt8c9EhagoodlTPOCBBVu0t7MXyUa YpKkoQFnP1ptEq7WPR+auHplwIx+l5/6JJ8Y7L5usbgkLis8Sn9ABeUQa Tpzbm+8I6R5GxiubEdjRdbdt2e4R3u7noAkvItADCD6na8/MHaKATga/I IT9aspjXgxq9YqWKqqlMcslfkggqpa6ZDwJhGXKPAB2FmgFpDLYWzr1Hm Q==; X-IronPort-AV: E=Sophos;i="5.54,367,1534780800"; d="scan'208";a="189389094" 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; 11 Oct 2018 15:10:03 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 10 Oct 2018 23:55:19 -0700 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 11 Oct 2018 00:09:55 -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 Date: Thu, 11 Oct 2018 16:09:42 +0900 Message-Id: <20181011070952.13248-2-damien.lemoal@wdc.com> In-Reply-To: <20181011070952.13248-1-damien.lemoal@wdc.com> References: <20181011070952.13248-1-damien.lemoal@wdc.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 11 Oct 2018 07:10:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 11 Oct 2018 07:10:24 +0000 (UTC) for IP:'68.232.143.124' DOMAIN:'esa2.hgst.iphmx.com' HELO:'esa2.hgst.iphmx.com' FROM:'damien.lemoal@wdc.com' RCPT:'' X-RedHat-Spam-Score: -0.8 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW) 68.232.143.124 esa2.hgst.iphmx.com 68.232.143.124 esa2.hgst.iphmx.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Christoph Hellwig , Matias Bjorling Subject: [dm-devel] [PATCH v2 01/11] scsi: sd_zbc: Rearrange code X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 11 Oct 2018 07:10:53 +0000 (UTC) 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 --- 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)