All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
@ 2023-03-17 19:50 Bart Van Assche
  2023-03-17 22:39 ` Damien Le Moal
  2023-03-18  6:25 ` Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-03-17 19:50 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Bart Van Assche, Christoph Hellwig, Keith Busch,
	Damien Le Moal, Josef Bacik, Johannes Thumshirn, David Sterba

Make it easier for filesystems to submit zone append bios that exceed
the block device limits by adding support for REQ_OP_ZONE_APPEND in
bio_split(). See also commit 0512a75b98f8 ("block: Introduce
REQ_OP_ZONE_APPEND").

This patch is a bug fix for commit d5e4377d5051 because that commit
introduces a call to bio_split() for zone append bios without adding
support for splitting REQ_OP_ZONE_APPEND bios in bio_split().

Untested.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Fixes: d5e4377d5051 ("btrfs: split zone append bios in btrfs_submit_bio")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/bio.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index fc98c1c723ca..8a4805565638 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1631,10 +1631,6 @@ struct bio *bio_split(struct bio *bio, int sectors,
 	BUG_ON(sectors <= 0);
 	BUG_ON(sectors >= bio_sectors(bio));
 
-	/* Zone append commands cannot be split */
-	if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND))
-		return NULL;
-
 	split = bio_alloc_clone(bio->bi_bdev, bio, gfp, bs);
 	if (!split)
 		return NULL;
@@ -1644,7 +1640,8 @@ struct bio *bio_split(struct bio *bio, int sectors,
 	if (bio_integrity(split))
 		bio_integrity_trim(split);
 
-	bio_advance(bio, split->bi_iter.bi_size);
+	if (bio_op(bio) != REQ_OP_ZONE_APPEND)
+		bio_advance(bio, split->bi_iter.bi_size);
 
 	if (bio_flagged(bio, BIO_TRACE_COMPLETION))
 		bio_set_flag(split, BIO_TRACE_COMPLETION);

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

* Re: [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
  2023-03-17 19:50 [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios Bart Van Assche
@ 2023-03-17 22:39 ` Damien Le Moal
  2023-03-18  0:09   ` Bart Van Assche
  2023-03-18  6:25 ` Christoph Hellwig
  1 sibling, 1 reply; 6+ messages in thread
From: Damien Le Moal @ 2023-03-17 22:39 UTC (permalink / raw)
  To: Bart Van Assche, Jens Axboe
  Cc: linux-block, Christoph Hellwig, Keith Busch, Josef Bacik,
	Johannes Thumshirn, David Sterba

On 3/18/23 04:50, Bart Van Assche wrote:
> Make it easier for filesystems to submit zone append bios that exceed
> the block device limits by adding support for REQ_OP_ZONE_APPEND in
> bio_split(). See also commit 0512a75b98f8 ("block: Introduce
> REQ_OP_ZONE_APPEND").
> 
> This patch is a bug fix for commit d5e4377d5051 because that commit
> introduces a call to bio_split() for zone append bios without adding
> support for splitting REQ_OP_ZONE_APPEND bios in bio_split().
> 
> Untested.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Fixes: d5e4377d5051 ("btrfs: split zone append bios in btrfs_submit_bio")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Nack. This will break zonefs.
zonefs uses zone append commands for sync writes. If zonefs does not have
guarantees that a single write is processed with a single command, the user data
can get corrupted because of the possible reordering of zone append commands.


-- 
Damien Le Moal
Western Digital Research


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

* Re: [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
  2023-03-17 22:39 ` Damien Le Moal
@ 2023-03-18  0:09   ` Bart Van Assche
  2023-03-18  2:21     ` Damien Le Moal
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2023-03-18  0:09 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe
  Cc: linux-block, Christoph Hellwig, Keith Busch, Josef Bacik,
	Johannes Thumshirn, David Sterba

On 3/17/23 15:39, Damien Le Moal wrote:
> On 3/18/23 04:50, Bart Van Assche wrote:
>> Make it easier for filesystems to submit zone append bios that exceed
>> the block device limits by adding support for REQ_OP_ZONE_APPEND in
>> bio_split(). See also commit 0512a75b98f8 ("block: Introduce
>> REQ_OP_ZONE_APPEND").
>>
>> This patch is a bug fix for commit d5e4377d5051 because that commit
>> introduces a call to bio_split() for zone append bios without adding
>> support for splitting REQ_OP_ZONE_APPEND bios in bio_split().
>>
>> Untested.
>>
>> Cc: Christoph Hellwig <hch@lst.de>
>> Cc: Keith Busch <kbusch@kernel.org>
>> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>> Cc: Josef Bacik <josef@toxicpanda.com>
>> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> Fixes: d5e4377d5051 ("btrfs: split zone append bios in btrfs_submit_bio")
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> 
> Nack. This will break zonefs.
> zonefs uses zone append commands for sync writes. If zonefs does not have
> guarantees that a single write is processed with a single command, the user data
> can get corrupted because of the possible reordering of zone append commands.

Hi Damien,

It is not clear to me how this would break zonefs? Is my understanding 
correct that the size of bios built by zonefs is such that bio_split() 
won't split these?

Thanks,

Bart.

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

* Re: [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
  2023-03-18  0:09   ` Bart Van Assche
@ 2023-03-18  2:21     ` Damien Le Moal
  2023-03-20 17:17       ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Damien Le Moal @ 2023-03-18  2:21 UTC (permalink / raw)
  To: Bart Van Assche, Jens Axboe
  Cc: linux-block, Christoph Hellwig, Keith Busch, Josef Bacik,
	Johannes Thumshirn, David Sterba

On 3/18/23 09:09, Bart Van Assche wrote:
> On 3/17/23 15:39, Damien Le Moal wrote:
>> On 3/18/23 04:50, Bart Van Assche wrote:
>>> Make it easier for filesystems to submit zone append bios that exceed
>>> the block device limits by adding support for REQ_OP_ZONE_APPEND in
>>> bio_split(). See also commit 0512a75b98f8 ("block: Introduce
>>> REQ_OP_ZONE_APPEND").
>>>
>>> This patch is a bug fix for commit d5e4377d5051 because that commit
>>> introduces a call to bio_split() for zone append bios without adding
>>> support for splitting REQ_OP_ZONE_APPEND bios in bio_split().
>>>
>>> Untested.
>>>
>>> Cc: Christoph Hellwig <hch@lst.de>
>>> Cc: Keith Busch <kbusch@kernel.org>
>>> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>>> Cc: Josef Bacik <josef@toxicpanda.com>
>>> Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>>> Fixes: d5e4377d5051 ("btrfs: split zone append bios in btrfs_submit_bio")
>>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>>
>> Nack. This will break zonefs.
>> zonefs uses zone append commands for sync writes. If zonefs does not have
>> guarantees that a single write is processed with a single command, the user data
>> can get corrupted because of the possible reordering of zone append commands.
> 
> Hi Damien,
> 
> It is not clear to me how this would break zonefs? Is my understanding 
> correct that the size of bios built by zonefs is such that bio_split() 
> won't split these?

It does, but your patch removes the guarantee that the split actually never
happens, and thus that we cannot see silent data corruptions due to append
commands being fragmented and the fragments being reordered. I do not like that.

I am not sure what is going on with the patch d5e4377d5051 you mention, I have
not followed that. For btrfs, since file data mapping for zone append commands
is updated on command completion, reordering does not matter so splitting is
fine I think. zonefs has static direct zone sector to file offset mapping which
cannot support reordering of zone append fragments.

Given that explicit split in commit d5e4377d5051, I can see that a fix is
needed, but I do not like the solution you have.

> 
> Thanks,
> 
> Bart.

-- 
Damien Le Moal
Western Digital Research


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

* Re: [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
  2023-03-17 19:50 [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios Bart Van Assche
  2023-03-17 22:39 ` Damien Le Moal
@ 2023-03-18  6:25 ` Christoph Hellwig
  1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2023-03-18  6:25 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Jens Axboe, linux-block, Christoph Hellwig, Keith Busch,
	Damien Le Moal, Josef Bacik, Johannes Thumshirn, David Sterba

On Fri, Mar 17, 2023 at 12:50:35PM -0700, Bart Van Assche wrote:
> Make it easier for filesystems to submit zone append bios that exceed
> the block device limits by adding support for REQ_OP_ZONE_APPEND in
> bio_split(). See also commit 0512a75b98f8 ("block: Introduce
> REQ_OP_ZONE_APPEND").

You can't do that.  ZONE_APPEND reports the written sector in bi_sector,
so it can't be split.

> This patch is a bug fix for commit d5e4377d5051 because that commit
> introduces a call to bio_split() for zone append bios without adding
> support for splitting REQ_OP_ZONE_APPEND bios in bio_split().

That commit never splits ZONE_APPEND bios, and it pre-splits bios
about to become ZONE_APPEND bios specifically using bio_split_rw
instead of bio_split.

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

* Re: [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios
  2023-03-18  2:21     ` Damien Le Moal
@ 2023-03-20 17:17       ` Bart Van Assche
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-03-20 17:17 UTC (permalink / raw)
  To: Damien Le Moal, Jens Axboe
  Cc: linux-block, Christoph Hellwig, Keith Busch, Josef Bacik,
	Johannes Thumshirn, David Sterba

On 3/17/23 19:21, Damien Le Moal wrote:
> On 3/18/23 09:09, Bart Van Assche wrote:
>> It is not clear to me how this would break zonefs? Is my understanding
>> correct that the size of bios built by zonefs is such that bio_split()
>> won't split these?
> 
> It does, but your patch removes the guarantee that the split actually never
> happens, and thus that we cannot see silent data corruptions due to append
> commands being fragmented and the fragments being reordered. I do not like that.

That's fair. Let's drop this patch.

Thanks,

Bart.

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

end of thread, other threads:[~2023-03-20 17:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 19:50 [PATCH] block: Support splitting REQ_OP_ZONE_APPEND bios Bart Van Assche
2023-03-17 22:39 ` Damien Le Moal
2023-03-18  0:09   ` Bart Van Assche
2023-03-18  2:21     ` Damien Le Moal
2023-03-20 17:17       ` Bart Van Assche
2023-03-18  6:25 ` Christoph Hellwig

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.