linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Bernal <andrewlbernal@gmail.com>
To: "James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Bernal <andrewlbernal@gmail.com>
Subject: [PATCH] scsi_debug: add implicit zones in max_open check
Date: Tue, 22 Jul 2025 16:32:13 -0400	[thread overview]
Message-ID: <20250722203213.8762-1-andrewlbernal@gmail.com> (raw)

`max_open` also needs to check implicit open, not just explicit
This is consistent with the logic in `zbc_open_zone`, on line 3809.

https://zonedstorage.io/docs/introduction/zoned-storage Open Zones limit
is defined as a "limit on the total number of zones that can simultaneously
be in an implicit open or explicit open state"

Signed-off-by: Andrew Bernal <andrewlbernal@gmail.com>
---
 drivers/scsi/scsi_debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index aef33d1e346a..0edb9a4698ca 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -3943,7 +3943,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,
 	/* Handle implicit open of closed and empty zones */
 	if (zsp->z_cond == ZC1_EMPTY || zsp->z_cond == ZC4_CLOSED) {
 		if (devip->max_open &&
-		    devip->nr_exp_open >= devip->max_open) {
+		    devip->nr_imp_open + devip->nr_exp_open >= devip->max_open) {
 			mk_sense_buffer(scp, DATA_PROTECT,
 					INSUFF_RES_ASC,
 					INSUFF_ZONE_ASCQ);
@@ -6101,7 +6101,7 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
 	if (all) {
 		/* Check if all closed zones can be open */
 		if (devip->max_open &&
-		    devip->nr_exp_open + devip->nr_closed > devip->max_open) {
+		    devip->nr_imp_open + devip->nr_exp_open + devip->nr_closed > devip->max_open) {
 			mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC,
 					INSUFF_ZONE_ASCQ);
 			res = check_condition_result;
@@ -6136,7 +6136,7 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
 	if (zc == ZC3_EXPLICIT_OPEN || zc == ZC5_FULL)
 		goto fini;
 
-	if (devip->max_open && devip->nr_exp_open >= devip->max_open) {
+	if (devip->max_open && devip->nr_imp_open + devip->nr_exp_open >= devip->max_open) {
 		mk_sense_buffer(scp, DATA_PROTECT, INSUFF_RES_ASC,
 				INSUFF_ZONE_ASCQ);
 		res = check_condition_result;
-- 
2.49.0


             reply	other threads:[~2025-07-22 20:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 20:32 Andrew Bernal [this message]
2025-07-29 16:19 ` [PATCH] scsi_debug: add implicit zones in max_open check Bart Van Assche
2025-07-30 16:25   ` Andrew Bernal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250722203213.8762-1-andrewlbernal@gmail.com \
    --to=andrewlbernal@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).