Re: [PATCH 1/2] block: introduce zone capacity helper

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

 



On 3/12/25 16:00, Christoph Hellwig wrote:
> On Wed, Mar 12, 2025 at 03:55:31PM +0900, Damien Le Moal wrote:
>> On 3/12/25 14:27, Christoph Hellwig wrote:
>>> On Wed, Mar 12, 2025 at 10:31:03AM +0900, Naohiro Aota wrote:
>>>> +#ifdef CONFIG_BLK_DEV_ZONED
>>>> +static inline unsigned int disk_zone_capacity(struct gendisk *disk, sector_t pos)
>>>
>>> Overly long line.
>>>
>>>> +{
>>>> +	sector_t zone_sectors = disk->queue->limits.chunk_sectors;
>>>> +
>>>> +	if (pos + zone_sectors >= get_capacity(disk))
>>>> +		return disk->last_zone_capacity;
>>>> +	return disk->zone_capacity;
>>>
>>> But I also don't understand how pos plays in here.  Maybe add a
>>> kerneldoc comment describing what the function is supposed to do?
>>
>> The last zone can be smaller than all other zones, hence we have
>> disk->zone_capacity and disk->last_zone_capacity. Pos is a sector used to
>> indicate the zone for which you want the capacity.
>>
>> But yes, agreed, a kernel doc would be nice to clarify that.
> 
> Should it be zoned_start then to make that obvious?

Well, it does not have to be the zone start. It can be any sector contained in
the zone you are interested in. With a comment, that should be clear, and also
the same as helpers such as disk_zone_no() which do not require the zone start
sector.


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