Re: [PATCH v8 04/11] block: Introduce REQ_OP_ZONE_APPEND
From: Bart Van Assche <bvanassche@acm.org>
Date: 2020-04-28 05:20:38
Also in:
linux-fsdevel, linux-scsi
On 2020-04-27 04:31, Johannes Thumshirn wrote:
+/*
+ * Check write append to a zoned block device.
+ */
+static inline blk_status_t blk_check_zone_append(struct request_queue *q,
+ struct bio *bio)
+{
+ sector_t pos = bio->bi_iter.bi_sector;
+ int nr_sectors = bio_sectors(bio);
+
+ /* Only applicable to zoned block devices */
+ if (!blk_queue_is_zoned(q))
+ return BLK_STS_NOTSUPP;
+
+ /* The bio sector must point to the start of a sequential zone */
+ if (pos & (blk_queue_zone_sectors(q) - 1) ||
+ !blk_queue_zone_is_seq(q, pos))
+ return BLK_STS_IOERR;
+
+ /*
+ * Not allowed to cross zone boundaries. Otherwise, the BIO will be
+ * split and could result in non-contiguous sectors being written in
+ * different zones.
+ */
+ if (blk_queue_zone_no(q, pos) != blk_queue_zone_no(q, pos + nr_sectors))
+ return BLK_STS_IOERR;
+
+ /* Make sure the BIO is small enough and will not get split */
+ if (nr_sectors > q->limits.max_zone_append_sectors)
+ return BLK_STS_IOERR;
+
+ bio->bi_opf |= REQ_NOMERGE;
+
+ return BLK_STS_OK;
+}Since the above function has not changed compared to v7, I will repeat my question about this function. Since 'pos' refers to the start of a zone, is the "blk_queue_zone_no(q, pos) != blk_queue_zone_no(q, pos + nr_sectors)" check identical to nr_sectors < q->limits.chunk_sectors? Since q->limits.max_zone_append_sectors is guaranteed to be less than or equal to the size of a zone, does that mean that the check "blk_queue_zone_no(q, pos) != blk_queue_zone_no(q, pos + nr_sectors)" is superfluous? Thanks, Bart.