diff mbox

[v2] block: Check partition alignment on zoned block devices

Message ID 778a9799-fed0-3337-e186-2a761cafa0aa@wdc.com (mailing list archive)
State New, archived
Headers show

Commit Message

Damien Le Moal Dec. 1, 2016, 2:38 a.m. UTC
Jens,

On 12/1/16 10:40, Jens Axboe wrote:
> This looks better, thanks. Are the zone sizes mandated by spec to be a
> power-of-2?

No, the standards allow any zone size, and different sizes for the zones
too. However, the sd_zbc code down in the SCSI stack limits support to
HM & HA drives that have a power of 2 zone size, with all zones of the
same size, except for an eventual smaller last zone (Seagate drives have
that). This restriction was necessary so that limits.chunk_sectors can
be used to avoid BIO spawning zones.

See 89d9475610771b5e5fe1879075f0fc9ba6e3755f:

Comments

Jens Axboe Dec. 1, 2016, 3:03 a.m. UTC | #1
On 11/30/2016 07:38 PM, Damien Le Moal wrote:
> 
> Jens,
> 
> On 12/1/16 10:40, Jens Axboe wrote:
>> This looks better, thanks. Are the zone sizes mandated by spec to be a
>> power-of-2?
> 
> No, the standards allow any zone size, and different sizes for the zones
> too. However, the sd_zbc code down in the SCSI stack limits support to
> HM & HA drives that have a power of 2 zone size, with all zones of the
> same size, except for an eventual smaller last zone (Seagate drives have
> that). This restriction was necessary so that limits.chunk_sectors can
> be used to avoid BIO spawning zones.
> 
> See 89d9475610771b5e5fe1879075f0fc9ba6e3755f:
> 
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> new file mode 100644
> index 0000000..16d3fa6
> --- /dev/null
> +++ b/drivers/scsi/sd_zbc.c
> @@ -0,0 +1,642 @@
> +/*
> + * SCSI Zoned Block commands
> ...
> +       if (!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;
> +       }
> +
> 
> Martin, Shaun and myself agreed on the restriction. All ZBC/ZAC disks on
> the market today match these so there are no problems. And it is
> unlikely that we will ever see weirdly sized SMR drives (customers
> generally do not want that).

I'm fine with that, my only concern is that part_zone_aligned() assumes
this, and it's a bit fragile. If we remove the power-of-2 restriction.
Not sure what the best way to fix it is. Ideally it'd have a
WARN_ON_ONCE() and a fallback to a modulo calculation instead of the
AND.
Damien Le Moal Dec. 1, 2016, 3:42 a.m. UTC | #2
Jens,

On 12/1/16 12:03, Jens Axboe wrote:
>> Martin, Shaun and myself agreed on the restriction. All ZBC/ZAC disks on
>> the market today match these so there are no problems. And it is
>> unlikely that we will ever see weirdly sized SMR drives (customers
>> generally do not want that).
> 
> I'm fine with that, my only concern is that part_zone_aligned() assumes
> this, and it's a bit fragile. If we remove the power-of-2 restriction.
> Not sure what the best way to fix it is. Ideally it'd have a
> WARN_ON_ONCE() and a fallback to a modulo calculation instead of the
> AND.

I can have a crack at it. Should I resubmit a new version ?
Jens Axboe Dec. 1, 2016, 3:59 a.m. UTC | #3
> On Nov 30, 2016, at 8:42 PM, Damien Le Moal <damien.lemoal@wdc.com> wrote:
> 
> 
> Jens,
> 
> On 12/1/16 12:03, Jens Axboe wrote:
>>> Martin, Shaun and myself agreed on the restriction. All ZBC/ZAC disks on
>>> the market today match these so there are no problems. And it is
>>> unlikely that we will ever see weirdly sized SMR drives (customers
>>> generally do not want that).
>> 
>> I'm fine with that, my only concern is that part_zone_aligned() assumes
>> this, and it's a bit fragile. If we remove the power-of-2 restriction.
>> Not sure what the best way to fix it is. Ideally it'd have a
>> WARN_ON_ONCE() and a fallback to a modulo calculation instead of the
>> AND.
> 
> I can have a crack at it. Should I resubmit a new version ?

That'd be great, thanks. 


--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
new file mode 100644
index 0000000..16d3fa6
--- /dev/null
+++ b/drivers/scsi/sd_zbc.c
@@ -0,0 +1,642 @@ 
+/*
+ * SCSI Zoned Block commands
...
+       if (!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;
+       }
+

Martin, Shaun and myself agreed on the restriction. All ZBC/ZAC disks on
the market today match these so there are no problems. And it is
unlikely that we will ever see weirdly sized SMR drives (customers
generally do not want that).

Best regards.

-- 
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital Corporation
Damien.LeMoal@wdc.com
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html