Re: [PATCH 09/11] zbd: rename zbd_zone_idx() and zbd_zone_nr()

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

 



On Fri, Dec 10, 2021 at 11:15:39AM +0900, Damien Le Moal wrote:
> Rename zbd_zone_idx() to zbd_zone_idx_from_offset() to make it clear
> that the argument determining the zone is a file offset. To be
> consistent, rename zbd_zone_nr() to zbd_zone_idx() to avoid confusion
> with a number of zones.
> 
> No functional changes.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
> ---
>  zbd.c | 45 ++++++++++++++++++++++++---------------------
>  1 file changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/zbd.c b/zbd.c
> index 49aee9b8..7204f68f 100644
> --- a/zbd.c
> +++ b/zbd.c
> @@ -27,19 +27,20 @@ static bool is_valid_offset(const struct fio_file *f, uint64_t offset)
>  	return (uint64_t)(offset - f->file_offset) < f->io_size;
>  }
>  
> -static inline unsigned int zbd_zone_nr(const struct fio_file *f,
> -				       struct fio_zone_info *zone)
> +static inline unsigned int zbd_zone_idx(const struct fio_file *f,
> +					struct fio_zone_info *zone)
>  {
>  	return zone - f->zbd_info->zone_info;
>  }
>  
>  /**
> - * zbd_zone_idx - convert an offset into a zone number
> + * zbd_zone_idx_from_offset - convert an offset into a zone number
>   * @f: file pointer.
>   * @offset: offset in bytes. If this offset is in the first zone_size bytes
>   *	    past the disk size then the index of the sentinel is returned.
>   */
> -static uint32_t zbd_zone_idx(const struct fio_file *f, uint64_t offset)
> +static uint32_t zbd_zone_idx_from_offset(const struct fio_file *f,
> +					 uint64_t offset)

Perhaps instead of having _from_ in the name, use _to_ ?
(Like virt_to_phys())

e.g. zbd_offset_to_zone_idx()

What do you think?


It does seem weird that one function that gets the zone_idx returns a
unsigned int, while the function that get the zone_idx returns a uint32_t.


Keeping the _from_ name would be fine by me as well, if you think
that having a similar prefix is more important than the function
name length.


Kind regards,
Niklas



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux