* [PATCH 0/2] Cleanup sd_zbc zone checks.
@ 2019-12-20 7:58 Damien Le Moal
2019-12-20 7:58 ` [PATCH 1/2] scsi: sd_zbc: Simplify sd_zbc_check_zones() Damien Le Moal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Damien Le Moal @ 2019-12-20 7:58 UTC (permalink / raw)
To: linux-scsi, Martin K . Petersen
A couple of small patches to cleanup sd_zbc zone checks formerly
implemented in sd_zbc_check_zones() and now moved to the block layer as
generic code. The first patch removes a superfluous check present in the
block layer. The second patch renames sd_zbc_check_zones() to be clear
about the function role.
Damien Le Moal (2):
scsi: sd_zbc: Simplify sd_zbc_check_zones()
scsi: sd_zbc: Rename sd_zbc_check_zones()
drivers/scsi/sd_zbc.c | 38 +++++++++++++-------------------------
1 file changed, 13 insertions(+), 25 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] scsi: sd_zbc: Simplify sd_zbc_check_zones()
2019-12-20 7:58 [PATCH 0/2] Cleanup sd_zbc zone checks Damien Le Moal
@ 2019-12-20 7:58 ` Damien Le Moal
2019-12-20 7:58 ` [PATCH 2/2] scsi: sd_zbc: Rename sd_zbc_check_zones() Damien Le Moal
2020-01-03 2:56 ` [PATCH 0/2] Cleanup sd_zbc zone checks Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2019-12-20 7:58 UTC (permalink / raw)
To: linux-scsi, Martin K . Petersen
Now that the block layer generic zone revalidation code in
blk_revalidate_disk_zones() checks for power of 2 zone size, there is
no need to do it in sd_zbc_check_zones(). Remove this check.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
drivers/scsi/sd_zbc.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index e0bd4cf17230..aca6367ced06 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -325,14 +325,11 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
}
/**
- * sd_zbc_check_zones - Check the device capacity and zone sizes
+ * sd_zbc_check_zones - Check the device capacity and zone size
* @sdkp: Target disk
*
* Check that the device capacity as reported by READ CAPACITY matches the
- * max_lba value (plus one)of the report zones command reply. Also check that
- * all zones of the device have an equal size, only allowing the last zone of
- * the disk to have a smaller size (runt zone). The zone size must also be a
- * power of two.
+ * max_lba value (plus one)of the report zones command reply.
*
* Returns the zone size in number of blocks upon success or an error code
* upon failure.
@@ -366,14 +363,6 @@ static int sd_zbc_check_zones(struct scsi_disk *sdkp, unsigned char *buf,
/* Parse REPORT ZONES header */
rec = buf + 64;
zone_blocks = get_unaligned_be64(&rec[8]);
- if (!zone_blocks || !is_power_of_2(zone_blocks)) {
- if (sdkp->first_scan)
- sd_printk(KERN_NOTICE, sdkp,
- "Devices with non power of 2 zone "
- "size are not supported\n");
- return -ENODEV;
- }
-
if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
if (sdkp->first_scan)
sd_printk(KERN_NOTICE, sdkp,
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] scsi: sd_zbc: Rename sd_zbc_check_zones()
2019-12-20 7:58 [PATCH 0/2] Cleanup sd_zbc zone checks Damien Le Moal
2019-12-20 7:58 ` [PATCH 1/2] scsi: sd_zbc: Simplify sd_zbc_check_zones() Damien Le Moal
@ 2019-12-20 7:58 ` Damien Le Moal
2020-01-03 2:56 ` [PATCH 0/2] Cleanup sd_zbc zone checks Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2019-12-20 7:58 UTC (permalink / raw)
To: linux-scsi, Martin K . Petersen
Now that the block layer implement zone checks on revalidate,
sd_zbc_check_zones() is reduced getting the zone size and verifying the
device capacity for device with RC_BASIS=0. Be clear about this by
renaming sd_zbc_check_zones() to sd_zbc_check_capacity() and updating
the function description and comments.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
drivers/scsi/sd_zbc.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index aca6367ced06..e4282bce5834 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -325,19 +325,21 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
}
/**
- * sd_zbc_check_zones - Check the device capacity and zone size
+ * sd_zbc_check_capacity - Check the device capacity
* @sdkp: Target disk
+ * @buf: command buffer
+ * @zblock: zone size in number of blocks
*
- * Check that the device capacity as reported by READ CAPACITY matches the
- * max_lba value (plus one)of the report zones command reply.
+ * Get the device zone size and check that the device capacity as reported
+ * by READ CAPACITY matches the max_lba value (plus one) of the report zones
+ * command reply for devices with RC_BASIS == 0.
*
- * Returns the zone size in number of blocks upon success or an error code
- * upon failure.
+ * Returns 0 upon success or an error code upon failure.
*/
-static int sd_zbc_check_zones(struct scsi_disk *sdkp, unsigned char *buf,
- u32 *zblocks)
+static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,
+ u32 *zblocks)
{
- u64 zone_blocks = 0;
+ u64 zone_blocks;
sector_t max_lba;
unsigned char *rec;
int ret;
@@ -360,7 +362,7 @@ static int sd_zbc_check_zones(struct scsi_disk *sdkp, unsigned char *buf,
}
}
- /* Parse REPORT ZONES header */
+ /* Get the size of the first reported zone */
rec = buf + 64;
zone_blocks = get_unaligned_be64(&rec[8]);
if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
@@ -394,11 +396,8 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
if (ret)
goto err;
- /*
- * Check zone size: only devices with a constant zone size (except
- * an eventual last runt zone) that is a power of 2 are supported.
- */
- ret = sd_zbc_check_zones(sdkp, buf, &zone_blocks);
+ /* Check the device capacity reported by report zones */
+ ret = sd_zbc_check_capacity(sdkp, buf, &zone_blocks);
if (ret != 0)
goto err;
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Cleanup sd_zbc zone checks.
2019-12-20 7:58 [PATCH 0/2] Cleanup sd_zbc zone checks Damien Le Moal
2019-12-20 7:58 ` [PATCH 1/2] scsi: sd_zbc: Simplify sd_zbc_check_zones() Damien Le Moal
2019-12-20 7:58 ` [PATCH 2/2] scsi: sd_zbc: Rename sd_zbc_check_zones() Damien Le Moal
@ 2020-01-03 2:56 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2020-01-03 2:56 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-scsi, Martin K . Petersen
Damien,
> A couple of small patches to cleanup sd_zbc zone checks formerly
> implemented in sd_zbc_check_zones() and now moved to the block layer as
> generic code. The first patch removes a superfluous check present in the
> block layer. The second patch renames sd_zbc_check_zones() to be clear
> about the function role.
Applied to 5.6/scsi-queue, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-03 2:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 7:58 [PATCH 0/2] Cleanup sd_zbc zone checks Damien Le Moal
2019-12-20 7:58 ` [PATCH 1/2] scsi: sd_zbc: Simplify sd_zbc_check_zones() Damien Le Moal
2019-12-20 7:58 ` [PATCH 2/2] scsi: sd_zbc: Rename sd_zbc_check_zones() Damien Le Moal
2020-01-03 2:56 ` [PATCH 0/2] Cleanup sd_zbc zone checks Martin K. Petersen
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).