Re: [PATCH v8 04/11] block: Introduce REQ_OP_ZONE_APPEND

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/04/28 14:20, Bart Van Assche wrote:
> 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?

Bart, I think I already answered... But writing again an answer to your
question, I realized that you are correct. My previous answer was: no, the tests
are not equivalent. But thinking again about this, since the block layer BIUO
splitting code will decide on BIO split or not based on pos+nr_sectors exceeding
the zone size or not, yes, the first test is not necessary.

We can reduce this to only testing that nr_sectors does not exceed
q->limits.max_zone_append_sectors since we already tested pos alignment to the
zone start.

> 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?

Yes, it is.

> 
> Thanks,
> 
> Bart.
> 


-- 
Damien Le Moal
Western Digital Research




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux