From patchwork Wed Nov 8 08:11:18 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: 10047959 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 68C27603FA for ; Wed, 8 Nov 2017 08:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A9A329526 for ; Wed, 8 Nov 2017 08:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F7AE2A503; Wed, 8 Nov 2017 08:11: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 0BD2729526 for ; Wed, 8 Nov 2017 08:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751111AbdKHILw (ORCPT ); Wed, 8 Nov 2017 03:11:52 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:29610 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751035AbdKHILr (ORCPT ); Wed, 8 Nov 2017 03:11:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1510128708; x=1541664708; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Jv9kWKnxbVglLx/M9IdZ6EB3N3So5DYtCYG9M5oNyGs=; b=kSR4+vHevrBjFg0xI3tjpPtrsCBxyVThvLc83wU+DnQMpTVwtptQ/E9C SePNak2dP9erd9zB9bVhfg1x6wYTcQ8JQ6LUkcPzMLsx0IwOBCrmy6wrl yEyGqDQOSBiOIcH3LyKcU+FNj7PQSXnnOWgMbktLtaAmneF8XkMlNaDOW Mkbemw6XbQHdsBnkfaA1yl4O3PpsClOza/p+6Ec4C8RJDdh8uYmt9ziB3 WXR2AGzY0/Adcywar9kp+8K7ptG/B1Qza5/XLv3gvrg3I2MMMGAMwGSCg B7pYTVN26kzVnPEd6k9eVcU4VdaUDtNkgkrBBggkhlytwO511oyBib4WD w==; X-IronPort-AV: E=Sophos;i="5.44,363,1505750400"; d="scan'208";a="61761473" Received: from sjappemgw12.hgst.com (HELO sjappemgw11.hgst.com) ([199.255.44.66]) by ob1.hgst.iphmx.com with ESMTP; 08 Nov 2017 16:11:48 +0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by sjappemgw11.hgst.com with ESMTP; 08 Nov 2017 00:11:46 -0800 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 V7 8/8] scsi: sd_zbc: Fix zone information initialization Date: Wed, 8 Nov 2017 17:11:18 +0900 Message-Id: <20171108081118.7632-9-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171108081118.7632-1-damien.lemoal@wdc.com> References: <20171108081118.7632-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 Make sure that the device request queue zone information (number of zones and zone bitmaps) are reinitialized if the number of zones changes (e.g. on a drive capacity change on revalidate). Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- drivers/scsi/sd_zbc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index d2121e7738d7..6c348a211ebb 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -632,29 +632,29 @@ static int sd_zbc_setup(struct scsi_disk *sdkp) round_up(sdkp->capacity, sdkp->zone_blocks) >> sdkp->zone_shift; /* - * Wait for the disk capacity to stabilize before - * initializing zone related information. + * Initialize the device request queue information if the number + * of zones changed. */ - if (sdkp->first_scan) - return 0; + if (sdkp->nr_zones != q->nr_zones) { - if (!q->seq_zones_wlock) { - q->seq_zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp); - if (!q->seq_zones_wlock) { - ret = -ENOMEM; - goto err; - } - } + sd_zbc_cleanup(sdkp); - if (!q->seq_zones_bitmap) { - ret = sd_zbc_setup_seq_zones_bitmap(sdkp); - if (ret) { - sd_zbc_cleanup(sdkp); - goto err; + q->nr_zones = sdkp->nr_zones; + if (sdkp->nr_zones) { + q->seq_zones_wlock = sd_zbc_alloc_zone_bitmap(sdkp); + if (!q->seq_zones_wlock) { + ret = -ENOMEM; + goto err; + } + + ret = sd_zbc_setup_seq_zones_bitmap(sdkp); + if (ret) { + sd_zbc_cleanup(sdkp); + goto err; + } } - } - q->nr_zones = sdkp->nr_zones; + } return 0;