* [PATCH v2] block: support zone append bvecs
@ 2021-03-24 15:47 Johannes Thumshirn
2021-03-24 17:33 ` Christoph Hellwig
2021-03-24 17:37 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2021-03-24 15:47 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Damien Le Moal, Johannes Thumshirn, Naohiro Aota,
Christoph Hellwig
Christoph reported that we'll likely trigger the WARN_ON_ONCE() checking
that we're not submitting a bvec with REQ_OP_ZONE_APPEND in
bio_iov_iter_get_pages() some time ago using zoned btrfs, but I couldn't
reproduce it back then.
Now Naohiro was able to trigger the bug as well with xfstests generic/095
on a zoned btrfs.
There is nothing that prevents bvec submissions via REQ_OP_ZONE_APPEND if
the hardware's zone append limit is met.
Reported-by: Naohiro Aota <naohiro.aota@wdc.com>
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
block/bio.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 26b7f721cda8..963d1d406b3a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -949,7 +949,7 @@ void bio_release_pages(struct bio *bio, bool mark_dirty)
}
EXPORT_SYMBOL_GPL(bio_release_pages);
-static int bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
+static void __bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
{
WARN_ON_ONCE(bio->bi_max_vecs);
@@ -959,11 +959,26 @@ static int bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
bio->bi_iter.bi_size = iter->count;
bio_set_flag(bio, BIO_NO_PAGE_REF);
bio_set_flag(bio, BIO_CLONED);
+}
+static int bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter)
+{
+ __bio_iov_bvec_set(bio, iter);
iov_iter_advance(iter, iter->count);
return 0;
}
+static int bio_iov_bvec_set_append(struct bio *bio, struct iov_iter *iter)
+{
+ struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+ struct iov_iter i = *iter;
+
+ iov_iter_truncate(&i, queue_max_zone_append_sectors(q) << 9);
+ __bio_iov_bvec_set(bio, &i);
+ iov_iter_advance(iter, i.count);
+ return 0;
+}
+
#define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *))
/**
@@ -1094,8 +1109,8 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
int ret = 0;
if (iov_iter_is_bvec(iter)) {
- if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND))
- return -EINVAL;
+ if (bio_op(bio) == REQ_OP_ZONE_APPEND)
+ return bio_iov_bvec_set_append(bio, iter);
return bio_iov_bvec_set(bio, iter);
}
--
2.30.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] block: support zone append bvecs
2021-03-24 15:47 [PATCH v2] block: support zone append bvecs Johannes Thumshirn
@ 2021-03-24 17:33 ` Christoph Hellwig
2021-03-24 17:37 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-03-24 17:33 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Jens Axboe, linux-block, Damien Le Moal, Naohiro Aota, Christoph Hellwig
On Thu, Mar 25, 2021 at 12:47:26AM +0900, Johannes Thumshirn wrote:
> Christoph reported that we'll likely trigger the WARN_ON_ONCE() checking
> that we're not submitting a bvec with REQ_OP_ZONE_APPEND in
> bio_iov_iter_get_pages() some time ago using zoned btrfs, but I couldn't
> reproduce it back then.
>
> Now Naohiro was able to trigger the bug as well with xfstests generic/095
> on a zoned btrfs.
>
> There is nothing that prevents bvec submissions via REQ_OP_ZONE_APPEND if
> the hardware's zone append limit is met.
>
> Reported-by: Naohiro Aota <naohiro.aota@wdc.com>
> Reported-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] block: support zone append bvecs
2021-03-24 15:47 [PATCH v2] block: support zone append bvecs Johannes Thumshirn
2021-03-24 17:33 ` Christoph Hellwig
@ 2021-03-24 17:37 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-03-24 17:37 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: linux-block, Damien Le Moal, Naohiro Aota, Christoph Hellwig
On 3/24/21 9:47 AM, Johannes Thumshirn wrote:
> Christoph reported that we'll likely trigger the WARN_ON_ONCE() checking
> that we're not submitting a bvec with REQ_OP_ZONE_APPEND in
> bio_iov_iter_get_pages() some time ago using zoned btrfs, but I couldn't
> reproduce it back then.
>
> Now Naohiro was able to trigger the bug as well with xfstests generic/095
> on a zoned btrfs.
>
> There is nothing that prevents bvec submissions via REQ_OP_ZONE_APPEND if
> the hardware's zone append limit is met.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-24 17:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 15:47 [PATCH v2] block: support zone append bvecs Johannes Thumshirn
2021-03-24 17:33 ` Christoph Hellwig
2021-03-24 17:37 ` Jens Axboe
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.