diff mbox

dm: dm-zoned: Ignore last smaller runt zone

Message ID 20171028073934.23293-1-damien.lemoal@wdc.com (mailing list archive)
State Accepted, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Damien Le Moal Oct. 28, 2017, 7:39 a.m. UTC
The scsi layer allows ZBC drives to have a smaller last runt zone. For
such device, specifying the entire capacity for a dm-zoned target table
entry fails as the specified capacity is not aligned on the device zone
size indicated in the request queue structure of the device.

Fix this problem by ignoring the last runt zone in the entry length
when seting up the dm-zoned target (ctr method) and when iterating table
entries of the target (iterate_devices method). This allows dm-zoned
users to still easily setup a target using the entire device capacity
(as mandated by dm-zoned) or the aligned capacity excluding thelast runt
zone.

While at it, replace direct references to the device queue chunk_sectors
limit with calls to the accessor blk_queue_zone_sectors().

Reported-by: Peter Desnoyers <pjd@ccs.neu.edu>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm-zoned-target.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Mike Snitzer Oct. 30, 2017, 8:05 p.m. UTC | #1
On Sat, Oct 28 2017 at  3:39am -0400,
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> The scsi layer allows ZBC drives to have a smaller last runt zone. For
> such device, specifying the entire capacity for a dm-zoned target table
> entry fails as the specified capacity is not aligned on the device zone
> size indicated in the request queue structure of the device.
> 
> Fix this problem by ignoring the last runt zone in the entry length
> when seting up the dm-zoned target (ctr method) and when iterating table
> entries of the target (iterate_devices method). This allows dm-zoned
> users to still easily setup a target using the entire device capacity
> (as mandated by dm-zoned) or the aligned capacity excluding thelast runt
> zone.
> 
> While at it, replace direct references to the device queue chunk_sectors
> limit with calls to the accessor blk_queue_zone_sectors().
> 
> Reported-by: Peter Desnoyers <pjd@ccs.neu.edu>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>

Applied for 3.15 (also cc'd stable@)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Damien Le Moal Oct. 31, 2017, 12:48 a.m. UTC | #2
Mike,

On 10/31/17 05:05, Mike Snitzer wrote:
> On Sat, Oct 28 2017 at  3:39am -0400,
> Damien Le Moal <damien.lemoal@wdc.com> wrote:
> 
>> The scsi layer allows ZBC drives to have a smaller last runt zone. For
>> such device, specifying the entire capacity for a dm-zoned target table
>> entry fails as the specified capacity is not aligned on the device zone
>> size indicated in the request queue structure of the device.
>>
>> Fix this problem by ignoring the last runt zone in the entry length
>> when seting up the dm-zoned target (ctr method) and when iterating table
>> entries of the target (iterate_devices method). This allows dm-zoned
>> users to still easily setup a target using the entire device capacity
>> (as mandated by dm-zoned) or the aligned capacity excluding thelast runt
>> zone.
>>
>> While at it, replace direct references to the device queue chunk_sectors
>> limit with calls to the accessor blk_queue_zone_sectors().
>>
>> Reported-by: Peter Desnoyers <pjd@ccs.neu.edu>
>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> 
> Applied for 3.15 (also cc'd stable@)

Thank you. Since this is a bug fix, I was hoping to get this in 4.14 as
this is scheduled as an LTS. Is it too late for that ?
Mike Snitzer Oct. 31, 2017, 2:15 a.m. UTC | #3
On Mon, Oct 30 2017 at  8:48pm -0400,
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> Mike,
> 
> On 10/31/17 05:05, Mike Snitzer wrote:
> > On Sat, Oct 28 2017 at  3:39am -0400,
> > Damien Le Moal <damien.lemoal@wdc.com> wrote:
> > 
> >> The scsi layer allows ZBC drives to have a smaller last runt zone. For
> >> such device, specifying the entire capacity for a dm-zoned target table
> >> entry fails as the specified capacity is not aligned on the device zone
> >> size indicated in the request queue structure of the device.
> >>
> >> Fix this problem by ignoring the last runt zone in the entry length
> >> when seting up the dm-zoned target (ctr method) and when iterating table
> >> entries of the target (iterate_devices method). This allows dm-zoned
> >> users to still easily setup a target using the entire device capacity
> >> (as mandated by dm-zoned) or the aligned capacity excluding thelast runt
> >> zone.
> >>
> >> While at it, replace direct references to the device queue chunk_sectors
> >> limit with calls to the accessor blk_queue_zone_sectors().
> >>
> >> Reported-by: Peter Desnoyers <pjd@ccs.neu.edu>
> >> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> > 
> > Applied for 3.15 (also cc'd stable@)
> 
> Thank you. Since this is a bug fix, I was hoping to get this in 4.14 as
> this is scheduled as an LTS. Is it too late for that ?

Not opposed to sending another 3.14 pull to Linus but I'd really
prefer not to (especially in that we're already past rc7).

Since 3.14 is LTS then there is no concern about 3.14's ability to get
this fix via stable@ (once it is merged for 3.15).

Mike

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Damien Le Moal Oct. 31, 2017, 6:55 a.m. UTC | #4
On 10/31/17 11:15, Mike Snitzer wrote:
> On Mon, Oct 30 2017 at  8:48pm -0400,
> Damien Le Moal <damien.lemoal@wdc.com> wrote:
> 
>> Mike,
>>
>> On 10/31/17 05:05, Mike Snitzer wrote:
>>> On Sat, Oct 28 2017 at  3:39am -0400,
>>> Damien Le Moal <damien.lemoal@wdc.com> wrote:
>>>
>>>> The scsi layer allows ZBC drives to have a smaller last runt zone. For
>>>> such device, specifying the entire capacity for a dm-zoned target table
>>>> entry fails as the specified capacity is not aligned on the device zone
>>>> size indicated in the request queue structure of the device.
>>>>
>>>> Fix this problem by ignoring the last runt zone in the entry length
>>>> when seting up the dm-zoned target (ctr method) and when iterating table
>>>> entries of the target (iterate_devices method). This allows dm-zoned
>>>> users to still easily setup a target using the entire device capacity
>>>> (as mandated by dm-zoned) or the aligned capacity excluding thelast runt
>>>> zone.
>>>>
>>>> While at it, replace direct references to the device queue chunk_sectors
>>>> limit with calls to the accessor blk_queue_zone_sectors().
>>>>
>>>> Reported-by: Peter Desnoyers <pjd@ccs.neu.edu>
>>>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>>>
>>> Applied for 3.15 (also cc'd stable@)
>>
>> Thank you. Since this is a bug fix, I was hoping to get this in 4.14 as
>> this is scheduled as an LTS. Is it too late for that ?
> 
> Not opposed to sending another 3.14 pull to Linus but I'd really
> prefer not to (especially in that we're already past rc7).
> 
> Since 3.14 is LTS then there is no concern about 3.14's ability to get
> this fix via stable@ (once it is merged for 3.15).

OK. Thank you.
diff mbox

Patch

diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index b87c1741da4b..6d7bda6f8190 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -660,6 +660,7 @@  static int dmz_get_zoned_device(struct dm_target *ti, char *path)
 	struct dmz_target *dmz = ti->private;
 	struct request_queue *q;
 	struct dmz_dev *dev;
+	sector_t aligned_capacity;
 	int ret;
 
 	/* Get the target device */
@@ -685,15 +686,17 @@  static int dmz_get_zoned_device(struct dm_target *ti, char *path)
 		goto err;
 	}
 
+	q = bdev_get_queue(dev->bdev);
 	dev->capacity = i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT;
-	if (ti->begin || (ti->len != dev->capacity)) {
+	aligned_capacity = dev->capacity & ~(blk_queue_zone_sectors(q) - 1);
+	if (ti->begin ||
+	    ((ti->len != dev->capacity) && (ti->len != aligned_capacity))) {
 		ti->error = "Partial mapping not supported";
 		ret = -EINVAL;
 		goto err;
 	}
 
-	q = bdev_get_queue(dev->bdev);
-	dev->zone_nr_sectors = q->limits.chunk_sectors;
+	dev->zone_nr_sectors = blk_queue_zone_sectors(q);
 	dev->zone_nr_sectors_shift = ilog2(dev->zone_nr_sectors);
 
 	dev->zone_nr_blocks = dmz_sect2blk(dev->zone_nr_sectors);
@@ -929,8 +932,10 @@  static int dmz_iterate_devices(struct dm_target *ti,
 			       iterate_devices_callout_fn fn, void *data)
 {
 	struct dmz_target *dmz = ti->private;
+	struct dmz_dev *dev = dmz->dev;
+	sector_t capacity = dev->capacity & ~(dev->zone_nr_sectors - 1);
 
-	return fn(ti, dmz->ddev, 0, dmz->dev->capacity, data);
+	return fn(ti, dmz->ddev, 0, capacity, data);
 }
 
 static struct target_type dmz_type = {