Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2906658iog; Mon, 27 Jun 2022 05:31:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uEHHMxydP4RXdOe0pmnCsMzJqxHwDWhqcNpxRLJeXNm65MVizBlxBgVvYmgvM3PECYRe3p X-Received: by 2002:aa7:9911:0:b0:525:1bb3:965a with SMTP id z17-20020aa79911000000b005251bb3965amr14949053pff.79.1656333076789; Mon, 27 Jun 2022 05:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333076; cv=none; d=google.com; s=arc-20160816; b=EWGpN5E59gQlS3df1KSjwRO+mB7r1VeeY9vyBA7C3FRZvfrqoB5FxaG7gsVMXgcncB x+hLwY0RQ6iKF8F9uoVbRooTzxHXYRV2adWSskIsb+kFYNcsW8cIbNJYPPCsrFU7/gS2 jqNVLo4nbj3q4VXBVIX3OICYdYk0UmV09IWJqpSt7JiluXXgQWvANKx6HRR5BCZvsoyX tDJUDvqgVf8H/kPKuoS/g0q+Y0Q++kOyvdCOOTq1SXQHWdMk+MWUjzJecUH73MpzYrAg Jcu26EAEdYrmlMM7J+ewTli9wMeYwvYdjVnovFlbZdqeUHpLG8mOP7Ng9FFtfwW2OK2A mm2g== 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=CI3+NCMjEYEA/HeVhdRbm6FrZltCIITFOv25sbs+5zU=; b=qizYsaynbvbJ9AqPvavX9kP5FIJHqgGN5weLZZlYjBvqKGahVxwxX1X+BQ9uFm0Uuv CfrhUTeFS+E/Xw23iYlUYtOu/JVkVnFQ1ZbiI3PJHhhex19wwrkZpg8zrcyDzHq3upaw DZzSfYe9F5Tx6NVTbhJ6GTuDC04dEFBOiIvhaTKNoyBuodS2O68x1xNPjImxhzjsIZK3 QjLiINSdHCnq7ZSSqQjIyLDLfEpXdgx02g+i6QNd67utgWZ4KTMBLaW/PyAL5T4BRCn+ tMAg8DwQIpt/SSznWjp1qnyry3wVvIvCeKK5VLFFVY7u4tt5hxnKAJdI81nkAO4tFEyQ 3nZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YiCE8S+Q; 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 c14-20020a170903234e00b0016a480d205csi12288275plh.156.2022.06.27.05.31.04; Mon, 27 Jun 2022 05:31:16 -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=YiCE8S+Q; 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 S239162AbiF0LzD (ORCPT + 99 others); Mon, 27 Jun 2022 07:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238554AbiF0Lsp (ORCPT ); Mon, 27 Jun 2022 07:48:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC90C101E2; Mon, 27 Jun 2022 04:42:13 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7F7856120F; Mon, 27 Jun 2022 11:42:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B652C3411D; Mon, 27 Jun 2022 11:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656330132; bh=FYaoYojNg2Ks/W0fzjugy1DmD1KBhOnAMSpztY8eezo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiCE8S+QeLGa+Apj7UT7vzvpOCZWz1xocCu9hy/lUg2S1OQtyW8V+rzkzViaTVbbF toXm68chkyZla3DQGggaA1bI2LL57OO22rFFIgBdxBarYqawAwNb1mkzkvlLf84BZT dZDpyDa2Fa7clMr7KdbskxkDZ31sCDeLnIIXcPJI= 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.18 045/181] scsi: scsi_debug: Fix zone transition to full condition Date: Mon, 27 Jun 2022 13:20:18 +0200 Message-Id: <20220627111945.868643663@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@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 592a290e6cfa..6cdd67f2a08e 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2788,6 +2788,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) { @@ -2800,7 +2818,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; } @@ -2819,7 +2837,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