diff mbox series

[v3,1/2] scsi: sd_zbc: Simplify zone full condition check

Message ID 20211201142821.64650-1-Niklas.Cassel@wdc.com (mailing list archive)
State Accepted
Headers show
Series [v3,1/2] scsi: sd_zbc: Simplify zone full condition check | expand

Commit Message

Niklas Cassel Dec. 1, 2021, 2:28 p.m. UTC
From: Niklas Cassel <niklas.cassel@wdc.com>

According to the ZBC (and ZAC) specification, a zone that has Zone Type set
to Conventional, must also have its Zone Condition set to
"Not Write Pointer".

Therefore, a conventional zone will never have Zone Condition set to
"Full", which means that we can omit the non-conventional prerequisite from
the zone full condition check.

Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
Changes since v2:
- New patch in series, as suggested by Damien.

 drivers/scsi/sd_zbc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Damien Le Moal Dec. 1, 2021, 11:51 p.m. UTC | #1
On 2021/12/01 23:28, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> According to the ZBC (and ZAC) specification, a zone that has Zone Type set
> to Conventional, must also have its Zone Condition set to
> "Not Write Pointer".
> 
> Therefore, a conventional zone will never have Zone Condition set to
> "Full", which means that we can omit the non-conventional prerequisite from
> the zone full condition check.
> 
> Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
> Changes since v2:
> - New patch in series, as suggested by Damien.
> 
>  drivers/scsi/sd_zbc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index ed06798983f8..749c5e5a70c7 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -62,8 +62,7 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf,
>  	zone.capacity = zone.len;
>  	zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));
>  	zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24]));
> -	if (zone.type != ZBC_ZONE_TYPE_CONV &&
> -	    zone.cond == ZBC_ZONE_COND_FULL)
> +	if (zone.cond == ZBC_ZONE_COND_FULL)
>  		zone.wp = zone.start + zone.len;
>  
>  	ret = cb(&zone, idx, data);
> 

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Johannes Thumshirn Dec. 2, 2021, 7:22 a.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Martin K. Petersen Dec. 3, 2021, 2:54 a.m. UTC | #3
Niklas,

> According to the ZBC (and ZAC) specification, a zone that has Zone
> Type set to Conventional, must also have its Zone Condition set to
> "Not Write Pointer".

Applied to 5.17/scsi-staging, thanks!
Martin K. Petersen Dec. 7, 2021, 3:46 a.m. UTC | #4
On Wed, 1 Dec 2021 14:28:30 +0000, Niklas Cassel wrote:

> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> According to the ZBC (and ZAC) specification, a zone that has Zone Type set
> to Conventional, must also have its Zone Condition set to
> "Not Write Pointer".
> 
> Therefore, a conventional zone will never have Zone Condition set to
> "Full", which means that we can omit the non-conventional prerequisite from
> the zone full condition check.
> 
> [...]

Applied to 5.17/scsi-queue, thanks!

[1/2] scsi: sd_zbc: Simplify zone full condition check
      https://git.kernel.org/mkp/scsi/c/13202ebf5f33
[2/2] scsi: sd_zbc: Clean up sd_zbc_parse_report() setting of wp
      https://git.kernel.org/mkp/scsi/c/bf3f120fd61c
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index ed06798983f8..749c5e5a70c7 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -62,8 +62,7 @@  static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf,
 	zone.capacity = zone.len;
 	zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));
 	zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24]));
-	if (zone.type != ZBC_ZONE_TYPE_CONV &&
-	    zone.cond == ZBC_ZONE_COND_FULL)
+	if (zone.cond == ZBC_ZONE_COND_FULL)
 		zone.wp = zone.start + zone.len;
 
 	ret = cb(&zone, idx, data);