Linux block layer
 help / color / mirror / Atom feed
* [PATCH] block: support zone append bvecs
@ 2021-03-23 11:06 Johannes Thumshirn
  2021-03-23 12:30 ` Christoph Hellwig
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Thumshirn @ 2021-03-23 11:06 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 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 26b7f721cda8..215fe24a01ee 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1094,8 +1094,14 @@ 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) {
+			struct request_queue *q = bio->bi_bdev->bd_disk->queue;
+			unsigned int max_append =
+				queue_max_zone_append_sectors(q) << 9;
+
+			if (WARN_ON_ONCE(iter->count > max_append))
+				return -EINVAL;
+		}
 		return bio_iov_bvec_set(bio, iter);
 	}
 
-- 
2.30.0


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

end of thread, other threads:[~2021-03-24 12:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-23 11:06 [PATCH] block: support zone append bvecs Johannes Thumshirn
2021-03-23 12:30 ` Christoph Hellwig
2021-03-24  7:07   ` Johannes Thumshirn
2021-03-24  7:11     ` Christoph Hellwig
2021-03-24  7:12       ` Johannes Thumshirn
2021-03-24 10:09         ` Johannes Thumshirn
2021-03-24 10:22           ` Damien Le Moal
2021-03-24 11:05           ` Christoph Hellwig
2021-03-24 12:12             ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox