All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two fixes for device-mapper with REQ_OP_ZONE_APPEND
@ 2020-06-19  6:59 Johannes Thumshirn
  2020-06-19  6:59 ` [PATCH 1/2] dm: update original bio sector on Zone Append Johannes Thumshirn
  2020-06-19  6:59 ` [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios Johannes Thumshirn
  0 siblings, 2 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2020-06-19  6:59 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: dm-devel, linux-block, Damien Le Moal, Naohiro Aota, Johannes Thumshirn

Two small fixes for issuing REQ_OP_ZONE_APPEND writes to device-mapper. The
first one is an issue reported by Naohiro and fixes a write failure. For
number two I'm not certain if it's the correct fix, hence the RFC tag.

Johannes Thumshirn (2):
  dm: update original bio sector on Zone Append
  dm: don't try to split REQ_OP_ZONE_APPEND bios

 drivers/md/dm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] dm: update original bio sector on Zone Append
  2020-06-19  6:59 [PATCH 0/2] Two fixes for device-mapper with REQ_OP_ZONE_APPEND Johannes Thumshirn
@ 2020-06-19  6:59 ` Johannes Thumshirn
  2020-06-19  7:52   ` Damien Le Moal
  2020-06-19  6:59 ` [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios Johannes Thumshirn
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2020-06-19  6:59 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: dm-devel, linux-block, Damien Le Moal, Naohiro Aota, Johannes Thumshirn

Naohiro reported that issuing zone-append bios to a zoned block device
underneath a dm-linear device does not work as expected.

This because we forgot to reverse-map the sector the device wrote to the
original bio.

For zone-append bios, get the offset in the zone of the written sector
from the clone bio and add that to the original bio's sector position.

Reported-by: Naohiro Aota <Naohiro.Aota@wdc.com>
Fixes: 0512a75b98f8 ("block: Introduce REQ_OP_ZONE_APPEND")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/md/dm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 109e81f33edb..058c34abe9d1 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1009,6 +1009,7 @@ static void clone_endio(struct bio *bio)
 	struct dm_io *io = tio->io;
 	struct mapped_device *md = tio->io->md;
 	dm_endio_fn endio = tio->ti->type->end_io;
+	struct bio *orig_bio = io->orig_bio;
 
 	if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) {
 		if (bio_op(bio) == REQ_OP_DISCARD &&
@@ -1022,6 +1023,18 @@ static void clone_endio(struct bio *bio)
 			disable_write_zeroes(md);
 	}
 
+	/*
+	 * for zone-append bios get offset in zone of the written sector and add
+	 * that to the original bio sector pos.
+	 */
+	if (bio_op(orig_bio) == REQ_OP_ZONE_APPEND) {
+		sector_t written_sector = bio->bi_iter.bi_sector;
+		struct request_queue *q = orig_bio->bi_disk->queue;
+		u64 mask = (u64)blk_queue_zone_sectors(q) - 1;
+
+		orig_bio->bi_iter.bi_sector += written_sector & mask;
+	}
+
 	if (endio) {
 		int r = endio(tio->ti, bio, &error);
 		switch (r) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios
  2020-06-19  6:59 [PATCH 0/2] Two fixes for device-mapper with REQ_OP_ZONE_APPEND Johannes Thumshirn
  2020-06-19  6:59 ` [PATCH 1/2] dm: update original bio sector on Zone Append Johannes Thumshirn
@ 2020-06-19  6:59 ` Johannes Thumshirn
  2020-06-19  7:54   ` Damien Le Moal
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2020-06-19  6:59 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: dm-devel, linux-block, Damien Le Moal, Naohiro Aota, Johannes Thumshirn

REQ_OP_ZONE_APPEND bios cannot be split so return EIO if we can't fit it
into one IO.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 drivers/md/dm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 058c34abe9d1..c720a7e3269a 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1609,6 +1609,9 @@ static int __split_and_process_non_flush(struct clone_info *ci)
 
 	len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);
 
+	if (bio_op(ci->bio) == REQ_OP_ZONE_APPEND && len < ci->sector_count)
+		return -EIO;
+
 	r = __clone_and_map_data_bio(ci, ti, ci->sector, &len);
 	if (r < 0)
 		return r;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] dm: update original bio sector on Zone Append
  2020-06-19  6:59 ` [PATCH 1/2] dm: update original bio sector on Zone Append Johannes Thumshirn
@ 2020-06-19  7:52   ` Damien Le Moal
  0 siblings, 0 replies; 8+ messages in thread
From: Damien Le Moal @ 2020-06-19  7:52 UTC (permalink / raw)
  To: Johannes Thumshirn, Mike Snitzer; +Cc: dm-devel, linux-block, Naohiro Aota

On 2020/06/19 15:59, Johannes Thumshirn wrote:
> Naohiro reported that issuing zone-append bios to a zoned block device
> underneath a dm-linear device does not work as expected.
> 
> This because we forgot to reverse-map the sector the device wrote to the
> original bio.
> 
> For zone-append bios, get the offset in the zone of the written sector
> from the clone bio and add that to the original bio's sector position.
> 
> Reported-by: Naohiro Aota <Naohiro.Aota@wdc.com>
> Fixes: 0512a75b98f8 ("block: Introduce REQ_OP_ZONE_APPEND")
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/md/dm.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 109e81f33edb..058c34abe9d1 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1009,6 +1009,7 @@ static void clone_endio(struct bio *bio)
>  	struct dm_io *io = tio->io;
>  	struct mapped_device *md = tio->io->md;
>  	dm_endio_fn endio = tio->ti->type->end_io;
> +	struct bio *orig_bio = io->orig_bio;
>  
>  	if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) {
>  		if (bio_op(bio) == REQ_OP_DISCARD &&
> @@ -1022,6 +1023,18 @@ static void clone_endio(struct bio *bio)
>  			disable_write_zeroes(md);
>  	}
>  
> +	/*
> +	 * for zone-append bios get offset in zone of the written sector and add
> +	 * that to the original bio sector pos.
> +	 */
> +	if (bio_op(orig_bio) == REQ_OP_ZONE_APPEND) {
> +		sector_t written_sector = bio->bi_iter.bi_sector;
> +		struct request_queue *q = orig_bio->bi_disk->queue;
> +		u64 mask = (u64)blk_queue_zone_sectors(q) - 1;
> +
> +		orig_bio->bi_iter.bi_sector += written_sector & mask;
> +	}
> +
>  	if (endio) {
>  		int r = endio(tio->ti, bio, &error);
>  		switch (r) {
> 

Looks good.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios
  2020-06-19  6:59 ` [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios Johannes Thumshirn
@ 2020-06-19  7:54   ` Damien Le Moal
  2020-06-19 16:26     ` Mike Snitzer
  0 siblings, 1 reply; 8+ messages in thread
From: Damien Le Moal @ 2020-06-19  7:54 UTC (permalink / raw)
  To: Johannes Thumshirn, Mike Snitzer; +Cc: dm-devel, linux-block, Naohiro Aota

On 2020/06/19 15:59, Johannes Thumshirn wrote:
> REQ_OP_ZONE_APPEND bios cannot be split so return EIO if we can't fit it
> into one IO.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/md/dm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> index 058c34abe9d1..c720a7e3269a 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1609,6 +1609,9 @@ static int __split_and_process_non_flush(struct clone_info *ci)
>  
>  	len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);
>  
> +	if (bio_op(ci->bio) == REQ_OP_ZONE_APPEND && len < ci->sector_count)
> +		return -EIO;
> +
>  	r = __clone_and_map_data_bio(ci, ti, ci->sector, &len);
>  	if (r < 0)
>  		return r;
> 

I think this is OK. The stacked max_zone_append_sectors limit should have
prevented that to happen  in the first place I think, but better safe than sorry.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios
  2020-06-19  7:54   ` Damien Le Moal
@ 2020-06-19 16:26     ` Mike Snitzer
  2020-06-22  0:27       ` Damien Le Moal
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Snitzer @ 2020-06-19 16:26 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: Johannes Thumshirn, dm-devel, linux-block, Naohiro Aota

On Fri, Jun 19 2020 at  3:54am -0400,
Damien Le Moal <Damien.LeMoal@wdc.com> wrote:

> On 2020/06/19 15:59, Johannes Thumshirn wrote:
> > REQ_OP_ZONE_APPEND bios cannot be split so return EIO if we can't fit it
> > into one IO.
> > 
> > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> > ---
> >  drivers/md/dm.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/md/dm.c b/drivers/md/dm.c
> > index 058c34abe9d1..c720a7e3269a 100644
> > --- a/drivers/md/dm.c
> > +++ b/drivers/md/dm.c
> > @@ -1609,6 +1609,9 @@ static int __split_and_process_non_flush(struct clone_info *ci)
> >  
> >  	len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);
> >  
> > +	if (bio_op(ci->bio) == REQ_OP_ZONE_APPEND && len < ci->sector_count)
> > +		return -EIO;
> > +
> >  	r = __clone_and_map_data_bio(ci, ti, ci->sector, &len);
> >  	if (r < 0)
> >  		return r;
> > 
> 
> I think this is OK. The stacked max_zone_append_sectors limit should have
> prevented that to happen  in the first place I think, but better safe than sorry.
> 
> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

If stacked max_zone_append_sectors limit should prevent it then I'd
rather not sprinkle more zoned specific checks in DM core.

Thanks,
Mike


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios
  2020-06-19 16:26     ` Mike Snitzer
@ 2020-06-22  0:27       ` Damien Le Moal
  2020-06-22  7:51         ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Damien Le Moal @ 2020-06-22  0:27 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Johannes Thumshirn, dm-devel, linux-block, Naohiro Aota

On 2020/06/20 1:27, Mike Snitzer wrote:
> On Fri, Jun 19 2020 at  3:54am -0400,
> Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
> 
>> On 2020/06/19 15:59, Johannes Thumshirn wrote:
>>> REQ_OP_ZONE_APPEND bios cannot be split so return EIO if we can't fit it
>>> into one IO.
>>>
>>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>> ---
>>>  drivers/md/dm.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/md/dm.c b/drivers/md/dm.c
>>> index 058c34abe9d1..c720a7e3269a 100644
>>> --- a/drivers/md/dm.c
>>> +++ b/drivers/md/dm.c
>>> @@ -1609,6 +1609,9 @@ static int __split_and_process_non_flush(struct clone_info *ci)
>>>  
>>>  	len = min_t(sector_t, max_io_len(ci->sector, ti), ci->sector_count);
>>>  
>>> +	if (bio_op(ci->bio) == REQ_OP_ZONE_APPEND && len < ci->sector_count)
>>> +		return -EIO;
>>> +
>>>  	r = __clone_and_map_data_bio(ci, ti, ci->sector, &len);
>>>  	if (r < 0)
>>>  		return r;
>>>
>>
>> I think this is OK. The stacked max_zone_append_sectors limit should have
>> prevented that to happen  in the first place I think, but better safe than sorry.
>>
>> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
> 
> If stacked max_zone_append_sectors limit should prevent it then I'd
> rather not sprinkle more zoned specific checks in DM core.

Mike,

Just to be extra sure, I checked this again. Since for zoned block devices the
mapping of a target must be zoned aligned and a zone append command is always
fully contained within a zone, we do not need this check. The stacked limits and
submit_bio() code will fail a zone append command that is too large or that
spans zones before we get here.

That is of course assuming that the target does not expose zones that are mapped
using multiple chunks from different devices. There is currently no target doing
that, so this is OK. We can safely drop this patch.

Thanks.

> 
> Thanks,
> Mike
> 
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios
  2020-06-22  0:27       ` Damien Le Moal
@ 2020-06-22  7:51         ` Johannes Thumshirn
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2020-06-22  7:51 UTC (permalink / raw)
  To: Damien Le Moal, Mike Snitzer; +Cc: dm-devel, linux-block, Naohiro Aota

On 22/06/2020 02:27, Damien Le Moal wrote:
[...]
> Just to be extra sure, I checked this again. Since for zoned block devices the
> mapping of a target must be zoned aligned and a zone append command is always
> fully contained within a zone, we do not need this check. The stacked limits and
> submit_bio() code will fail a zone append command that is too large or that
> spans zones before we get here.
> 
> That is of course assuming that the target does not expose zones that are mapped
> using multiple chunks from different devices. There is currently no target doing
> that, so this is OK. We can safely drop this patch.

Yeah I think we can drop that one.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-06-22  7:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19  6:59 [PATCH 0/2] Two fixes for device-mapper with REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-06-19  6:59 ` [PATCH 1/2] dm: update original bio sector on Zone Append Johannes Thumshirn
2020-06-19  7:52   ` Damien Le Moal
2020-06-19  6:59 ` [RFC PATCH 2/2] dm: don't try to split REQ_OP_ZONE_APPEND bios Johannes Thumshirn
2020-06-19  7:54   ` Damien Le Moal
2020-06-19 16:26     ` Mike Snitzer
2020-06-22  0:27       ` Damien Le Moal
2020-06-22  7:51         ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.