All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Pankaj Raghav <p.raghav@samsung.com>,
	hch@lst.de, axboe@kernel.dk, snitzer@kernel.org,
	Johannes.Thumshirn@wdc.com
Cc: matias.bjorling@wdc.com, gost.dev@samsung.com,
	linux-kernel@vger.kernel.org, hare@suse.de,
	linux-block@vger.kernel.org, pankydev8@gmail.com,
	bvanassche@acm.org, jaegeuk@kernel.org, dm-devel@redhat.com,
	linux-nvme@lists.infradead.org,
	Luis Chamberlain <mcgrof@kernel.org>,
	Adam Manzanares <a.manzanares@samsung.com>
Subject: Re: [PATCH v8 01/11] block: make bdev_nr_zones and disk_zone_no generic for npo2 zsze
Date: Thu, 28 Jul 2022 11:54:03 +0900	[thread overview]
Message-ID: <8e0c4a9f-de4a-d53e-efef-0b27017ec78d@opensource.wdc.com> (raw)
In-Reply-To: <20220727162245.209794-2-p.raghav@samsung.com>

On 7/28/22 01:22, Pankaj Raghav wrote:
> Adapt bdev_nr_zones and disk_zone_no function so that it can

s/function/functions
s/it/they

> also work for non-power-of-2 zone sizes.
> 
> As the existing deployments of zoned devices had power-of-2

had power-of-2 assumption -> assume that a device zone size is a power of
2 number of sectors

Existing deployments still exist, so do not use the past tense please.

> assumption, power-of-2 optimized calculation is kept for those devices.
> 
> There are no direct hot paths modified and the changes just
> introduce one new branch per call.
> 
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/blk-zoned.c      | 13 +++++++++----
>  include/linux/blkdev.h |  8 +++++++-
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index a264621d4905..dce9c95b4bcd 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -111,17 +111,22 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>   * bdev_nr_zones - Get number of zones
>   * @bdev:	Target device
>   *
> - * Return the total number of zones of a zoned block device.  For a block
> - * device without zone capabilities, the number of zones is always 0.
> + * Return the total number of zones of a zoned block device, including the
> + * eventual small last zone if present. For a block device without zone
> + * capabilities, the number of zones is always 0.
>   */
>  unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
>  	sector_t zone_sectors = bdev_zone_sectors(bdev);
> +	sector_t capacity = bdev_nr_sectors(bdev);
>  
>  	if (!bdev_is_zoned(bdev))
>  		return 0;
> -	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
> -		ilog2(zone_sectors);
> +
> +	if (is_power_of_2(zone_sectors))
> +		return (capacity + zone_sectors - 1) >> ilog2(zone_sectors);
> +
> +	return DIV_ROUND_UP_SECTOR_T(capacity, zone_sectors);
>  }
>  EXPORT_SYMBOL_GPL(bdev_nr_zones);
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index dccdf1551c62..85b832908f28 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -673,9 +673,15 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  
>  static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
> +	sector_t zone_sectors = disk->queue->limits.chunk_sectors;
> +
>  	if (!blk_queue_is_zoned(disk->queue))
>  		return 0;
> -	return sector >> ilog2(disk->queue->limits.chunk_sectors);
> +
> +	if (is_power_of_2(zone_sectors))
> +		return sector >> ilog2(zone_sectors);
> +
> +	return div64_u64(sector, zone_sectors);
>  }
>  
>  static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)


-- 
Damien Le Moal
Western Digital Research

WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Pankaj Raghav <p.raghav@samsung.com>,
	hch@lst.de, axboe@kernel.dk, snitzer@kernel.org,
	Johannes.Thumshirn@wdc.com
Cc: bvanassche@acm.org, pankydev8@gmail.com, gost.dev@samsung.com,
	linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Adam Manzanares <a.manzanares@samsung.com>,
	jaegeuk@kernel.org, matias.bjorling@wdc.com,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [dm-devel] [PATCH v8 01/11] block: make bdev_nr_zones and disk_zone_no generic for npo2 zsze
Date: Thu, 28 Jul 2022 11:54:03 +0900	[thread overview]
Message-ID: <8e0c4a9f-de4a-d53e-efef-0b27017ec78d@opensource.wdc.com> (raw)
In-Reply-To: <20220727162245.209794-2-p.raghav@samsung.com>

On 7/28/22 01:22, Pankaj Raghav wrote:
> Adapt bdev_nr_zones and disk_zone_no function so that it can

s/function/functions
s/it/they

> also work for non-power-of-2 zone sizes.
> 
> As the existing deployments of zoned devices had power-of-2

had power-of-2 assumption -> assume that a device zone size is a power of
2 number of sectors

Existing deployments still exist, so do not use the past tense please.

> assumption, power-of-2 optimized calculation is kept for those devices.
> 
> There are no direct hot paths modified and the changes just
> introduce one new branch per call.
> 
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Reviewed-by: Adam Manzanares <a.manzanares@samsung.com>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/blk-zoned.c      | 13 +++++++++----
>  include/linux/blkdev.h |  8 +++++++-
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index a264621d4905..dce9c95b4bcd 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -111,17 +111,22 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
>   * bdev_nr_zones - Get number of zones
>   * @bdev:	Target device
>   *
> - * Return the total number of zones of a zoned block device.  For a block
> - * device without zone capabilities, the number of zones is always 0.
> + * Return the total number of zones of a zoned block device, including the
> + * eventual small last zone if present. For a block device without zone
> + * capabilities, the number of zones is always 0.
>   */
>  unsigned int bdev_nr_zones(struct block_device *bdev)
>  {
>  	sector_t zone_sectors = bdev_zone_sectors(bdev);
> +	sector_t capacity = bdev_nr_sectors(bdev);
>  
>  	if (!bdev_is_zoned(bdev))
>  		return 0;
> -	return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
> -		ilog2(zone_sectors);
> +
> +	if (is_power_of_2(zone_sectors))
> +		return (capacity + zone_sectors - 1) >> ilog2(zone_sectors);
> +
> +	return DIV_ROUND_UP_SECTOR_T(capacity, zone_sectors);
>  }
>  EXPORT_SYMBOL_GPL(bdev_nr_zones);
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index dccdf1551c62..85b832908f28 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -673,9 +673,15 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk)
>  
>  static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
> +	sector_t zone_sectors = disk->queue->limits.chunk_sectors;
> +
>  	if (!blk_queue_is_zoned(disk->queue))
>  		return 0;
> -	return sector >> ilog2(disk->queue->limits.chunk_sectors);
> +
> +	if (is_power_of_2(zone_sectors))
> +		return sector >> ilog2(zone_sectors);
> +
> +	return div64_u64(sector, zone_sectors);
>  }
>  
>  static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)


-- 
Damien Le Moal
Western Digital Research

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2022-07-28  2:54 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220727162246eucas1p1a758799f13d36ba99d30bf92cc5e2754@eucas1p1.samsung.com>
2022-07-27 16:22 ` [PATCH v8 00/11] support non power of 2 zoned device Pankaj Raghav
2022-07-27 16:22   ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220727162247eucas1p203fc14aa17ecbcb3e6215d5304bb0c85@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 01/11] block: make bdev_nr_zones and disk_zone_no generic for npo2 zsze Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  2:54       ` Damien Le Moal [this message]
2022-07-28  2:54         ` Damien Le Moal
     [not found]   ` <CGME20220727162248eucas1p2ff8c3c2b021bedcae3960024b4e269e9@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 02/11] block: allow blk-zoned devices to have non-power-of-2 zone size Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-27 23:16       ` Bart Van Assche
2022-07-27 23:16         ` [dm-devel] " Bart Van Assche
2022-07-28 12:11         ` Pankaj Raghav
2022-07-28 12:11           ` [dm-devel] " Pankaj Raghav
2022-07-28 13:29           ` Bart Van Assche
2022-07-28 13:29             ` [dm-devel] " Bart Van Assche
2022-07-29  9:09             ` Pankaj Raghav
2022-07-29  9:09               ` [dm-devel] " Pankaj Raghav
2022-07-28  3:07       ` Damien Le Moal
2022-07-28  3:07         ` [dm-devel] " Damien Le Moal
2022-07-28 12:24         ` Pankaj Raghav
2022-07-28 12:24           ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220727162249eucas1p28fa44c840e590f6f1b53e0cc12ee3771@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 03/11] nvme: zns: Allow ZNS drives that have non-power_of_2 " Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220727162250eucas1p133e8a814fee934f7161866122ef93273@eucas1p1.samsung.com>
2022-07-27 16:22     ` [PATCH v8 04/11] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:09       ` Damien Le Moal
2022-07-28  3:09         ` [dm-devel] " Damien Le Moal
2022-07-29  7:45         ` Pankaj Raghav
2022-07-29  7:45           ` Pankaj Raghav
     [not found]   ` <CGME20220727162251eucas1p12939ac3864fd8705ae139eb2d1087d8f@eucas1p1.samsung.com>
2022-07-27 16:22     ` [PATCH v8 05/11] null_blk: allow non power of 2 zoned devices Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-27 21:59       ` Chaitanya Kulkarni
2022-07-27 21:59         ` [dm-devel] " Chaitanya Kulkarni
2022-07-29  7:51         ` Pankaj Raghav
2022-07-29  7:51           ` [dm-devel] " Pankaj Raghav
2022-07-28  3:14       ` Damien Le Moal
2022-07-28  3:14         ` [dm-devel] " Damien Le Moal
     [not found]   ` <CGME20220727162252eucas1p25be8b79231334fa0c759c2475859e93b@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 06/11] zonefs: " Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:16       ` Damien Le Moal
2022-07-28  3:16         ` [dm-devel] " Damien Le Moal
     [not found]   ` <CGME20220727162253eucas1p1a5912e0494f6918504cc8ff15ad5d31f@eucas1p1.samsung.com>
2022-07-27 16:22     ` [PATCH v8 07/11] dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:18       ` Damien Le Moal
2022-07-28  3:18         ` [dm-devel] " Damien Le Moal
2022-07-28 12:15       ` David Sterba
2022-07-28 12:15         ` [dm-devel] " David Sterba
2022-07-29  8:00         ` Pankaj Raghav
2022-07-29  8:00           ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220727162254eucas1p1fd990f746d9f9870b8d58ee0bd01fedd@eucas1p1.samsung.com>
2022-07-27 16:22     ` [PATCH v8 08/11] dm-zone: use generic helpers to calculate offset from zone start Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:20       ` Damien Le Moal
2022-07-28  3:20         ` [dm-devel] " Damien Le Moal
     [not found]   ` <CGME20220727162255eucas1p2945c6dca42b799bb3b4abf3edb83dde8@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 09/11] dm-table: allow non po2 zoned devices Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:22       ` Damien Le Moal
2022-07-28  3:22         ` [dm-devel] " Damien Le Moal
     [not found]   ` <CGME20220727162256eucas1p284a15532173cce3eca46eee0cee3acdd@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 10/11] dm: call dm_zone_endio after the target endio callback for " Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  3:25       ` Damien Le Moal
2022-07-28  3:25         ` [dm-devel] " Damien Le Moal
2022-07-29  8:48         ` Pankaj Raghav
2022-07-29  8:48           ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220727162257eucas1p2848a75c4aa7e559abb5d9ae0fbd374c1@eucas1p2.samsung.com>
2022-07-27 16:22     ` [PATCH v8 11/11] dm: add power-of-2 zoned target for non-power-of-2 " Pankaj Raghav
2022-07-27 16:22       ` [dm-devel] " Pankaj Raghav
2022-07-28  4:33       ` Damien Le Moal
2022-07-28  4:33         ` [dm-devel] " Damien Le Moal
2022-08-01  8:35         ` Pankaj Raghav
2022-08-01  8:35           ` [dm-devel] " Pankaj Raghav
2022-07-27 23:19   ` [PATCH v8 00/11] support non power of 2 zoned device Bart Van Assche
2022-07-27 23:19     ` [dm-devel] " Bart Van Assche
2022-07-28  1:52     ` Damien Le Moal
2022-07-28  1:52       ` [dm-devel] " Damien Le Moal
2022-07-28  2:58       ` Bart Van Assche
2022-07-28  2:58         ` [dm-devel] " Bart Van Assche
2022-07-28  3:28         ` Damien Le Moal
2022-07-28  3:28           ` [dm-devel] " Damien Le Moal
2022-07-28 11:57     ` Pankaj Raghav
2022-07-28 11:57       ` [dm-devel] " Pankaj Raghav
2022-07-28 13:30       ` Bart Van Assche
2022-07-28 13:30         ` [dm-devel] " Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e0c4a9f-de4a-d53e-efef-0b27017ec78d@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=a.manzanares@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=dm-devel@redhat.com \
    --cc=gost.dev@samsung.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jaegeuk@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=matias.bjorling@wdc.com \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=pankydev8@gmail.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.