Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2903394iog; Mon, 27 Jun 2022 05:26:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uSErlVm2swrviQJmbAcqwrAAZ9F7heAbl6q7oz1jPO0hzxTgsOQw1Gxy1mK0mMLs/I8GBj X-Received: by 2002:a63:af1c:0:b0:40c:f9d6:9f07 with SMTP id w28-20020a63af1c000000b0040cf9d69f07mr12320580pge.384.1656332816063; Mon, 27 Jun 2022 05:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332816; cv=none; d=google.com; s=arc-20160816; b=hDMb06HWgieUh28zcKlVPqhYttumkiCo2eYb3Z5BiG9+t0dKON+oqfELqCbkCtmc1s CWz30b69Mv4m8I0G5sxGPKKjFaaSMW/XCSpxK1fmunn95bl2p+yPMWiyfbriTTodsn0O dxcWFrmSuwTzLxfCd8eIy0WBY2X/WtcGHniLUepvEByZ8831yFBJQicTU61Q64xdTUmX nf3lt5EW3ffMsxSQBCFtCeMBWTHQbnAlGl1gjGW9rJiLg7+4NENg96+ZCcHZIkp7/+Y8 RjiAmnTvxZ7o2EBFqeFUHJJRs8oxN+nXhLBA2p8J5Ph3hBSN5m1ZL6qG7Z8frC76bYw7 kpjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pqDPoWccFevoTOAa8R4x3erBnNDMq14noA13+wnU3f4=; b=lr3zfiNQroM2+u72l7IvJo8setWgkXUfv86uwJm5Wkxxytoy+XoFLKo0jJXGS3biit Utcq8iyNJW5UFvuqfl57zzMz2hRl/5Q4uvUYSmbRzAQFPy0crDxjuFXa9ROP6XHxAEzQ XZhTD8Cabawb+e4ivi/hW7qm6uVE8UHJX+jsbrtYkhl9a5Le9Qi+3cJxgq4Qak2U0OMh nOAENLLhkMPZfEKTppfpddecRV97L46bO/ZxFF6VRa/4j6JGMIy/VP3pFXFcwQJ5hnZu capIU2C9sgYL2TYyzYKPI6ZerFWhs1u/u/MqMFZU80ztXhF7db9ND0fc0Ctmb8gSGcLA e/lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dX8E6P9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902d48600b0015e87e34d42si17112546plg.448.2022.06.27.05.26.40; Mon, 27 Jun 2022 05:26:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dX8E6P9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234682AbiF0LYG (ORCPT + 99 others); Mon, 27 Jun 2022 07:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234642AbiF0LXs (ORCPT ); Mon, 27 Jun 2022 07:23:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A608B6465; Mon, 27 Jun 2022 04:23:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 623F3B81125; Mon, 27 Jun 2022 11:23:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B715AC3411D; Mon, 27 Jun 2022 11:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329025; bh=6g+0kDNDTJ6rzAV6vLpGtfTRgDWoLZS/lo3rJxyabA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dX8E6P9BDtHJlTi9k3NIpJEFq1dSEUUQJYTxOw5+7AGYdqPanj/0myt+VLtCgKmKt UEf9IC+yrO87R+5QXavm8Vra0jyzY/qgNMfehY9wne0h+ARj2llAbghuRflLbf6+Ho p4ocINOiQ0sYCtq7az+yPD1BCECmyI7ylV0Ga3kE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Douglas Gilbert , Damien Le Moal , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 025/102] scsi: scsi_debug: Fix zone transition to full condition Date: Mon, 27 Jun 2022 13:20:36 +0200 Message-Id: <20220627111934.213721698@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Damien Le Moal [ Upstream commit 566d3c57eb526f32951af15866086e236ce1fc8a ] When a write command to a sequential write required or sequential write preferred zone result in the zone write pointer reaching the end of the zone, the zone condition must be set to full AND the number of implicitly or explicitly open zones updated to have a correct accounting for zone resources. However, the function zbc_inc_wp() only sets the zone condition to full without updating the open zone counters, resulting in a zone state machine breakage. Introduce the helper function zbc_set_zone_full() and use it in zbc_inc_wp() to correctly transition zones to the full condition. Link: https://lore.kernel.org/r/20220608011302.92061-1-damien.lemoal@opensource.wdc.com Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands") Reviewed-by: Niklas Cassel Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_debug.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 6b00de6b6f0e..5eb959b5f701 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2746,6 +2746,24 @@ static void zbc_open_zone(struct sdebug_dev_info *devip, } } +static inline void zbc_set_zone_full(struct sdebug_dev_info *devip, + struct sdeb_zone_state *zsp) +{ + switch (zsp->z_cond) { + case ZC2_IMPLICIT_OPEN: + devip->nr_imp_open--; + break; + case ZC3_EXPLICIT_OPEN: + devip->nr_exp_open--; + break; + default: + WARN_ONCE(true, "Invalid zone %llu condition %x\n", + zsp->z_start, zsp->z_cond); + break; + } + zsp->z_cond = ZC5_FULL; +} + static void zbc_inc_wp(struct sdebug_dev_info *devip, unsigned long long lba, unsigned int num) { @@ -2758,7 +2776,7 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, if (zsp->z_type == ZBC_ZONE_TYPE_SWR) { zsp->z_wp += num; if (zsp->z_wp >= zend) - zsp->z_cond = ZC5_FULL; + zbc_set_zone_full(devip, zsp); return; } @@ -2777,7 +2795,7 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, n = num; } if (zsp->z_wp >= zend) - zsp->z_cond = ZC5_FULL; + zbc_set_zone_full(devip, zsp); num -= n; lba += n; -- 2.35.1