public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Pankaj Raghav <p.raghav@samsung.com>, axboe@kernel.dk
Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org,
	hare@suse.de, bvanassche@acm.org, snitzer@kernel.org,
	dm-devel@redhat.com, linux-nvme@lists.infradead.org, hch@lst.de,
	linux-block@vger.kernel.org, gost.dev@samsung.com
Subject: Re: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start}
Date: Fri, 6 Jan 2023 20:00:38 +0900	[thread overview]
Message-ID: <32aaa034-dc39-75dd-f4ec-e0e5ef9dd29c@opensource.wdc.com> (raw)
In-Reply-To: <20230106083317.93938-3-p.raghav@samsung.com>

On 1/6/23 17:33, Pankaj Raghav wrote:
> Instead of open coding to check for zone start, add a helper to improve
> readability and store the logic in one place.
> 
> bdev_offset_from_zone_start() will be used later in the series.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  block/blk-core.c       |  2 +-
>  block/blk-zoned.c      |  4 ++--
>  include/linux/blkdev.h | 18 ++++++++++++++++++
>  3 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 9321767470dc..0405b3144e7a 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
>  		return BLK_STS_NOTSUPP;
>  
>  	/* The bio sector must point to the start of a sequential zone */
> -	if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
> +	if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
>  	    !bio_zone_is_seq(bio))
>  		return BLK_STS_IOERR;
>  
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index db829401d8d0..614b575be899 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
>  		return -EINVAL;
>  
>  	/* Check alignment (handle eventual smaller last zone) */
> -	if (sector & (zone_sectors - 1))
> +	if (!bdev_is_zone_start(bdev, sector))
>  		return -EINVAL;
>  
> -	if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
> +	if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
>  		return -EINVAL;
>  
>  	/*
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 0e40b014c40b..04b7cbfd7a2a 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
>  {
>  	return 0;
>  }
> +

whiteline change

>  static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
>  {
>  	return 0;
> @@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
>  	return q->limits.chunk_sectors;
>  }
>  
> +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
> +						   sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))

this helper should never be called outside of code supporting zones. So
why this check ?

> +		return 0;
> +
> +	return sec & (bdev_zone_sectors(bdev) - 1);
> +}
> +
> +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
> +{
> +	if (!bdev_is_zoned(bdev))
> +		return false;

Same here.

> +
> +	return bdev_offset_from_zone_start(bdev, sec) == 0;
> +}
> +
>  static inline int queue_dma_alignment(const struct request_queue *q)
>  {
>  	return q ? q->limits.dma_alignment : 511;

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2023-01-06 11:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230106083318eucas1p1a2ab71a95ab2906b4651538c63a94ae2@eucas1p1.samsung.com>
2023-01-06  8:33 ` [PATCH 0/7] block zoned cleanups Pankaj Raghav
2023-01-06  8:33   ` [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned Pankaj Raghav
2023-01-06 11:01     ` Damien Le Moal
2023-01-06 22:34     ` Bart Van Assche
2023-01-09  7:41     ` Chaitanya Kulkarni
2023-01-09  8:55     ` Johannes Thumshirn
2023-01-10  6:52     ` Christoph Hellwig
2023-01-06  8:33   ` [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start} Pankaj Raghav
2023-01-06 11:00     ` Damien Le Moal [this message]
2023-01-06 22:36     ` Bart Van Assche
2023-01-09  7:42     ` Chaitanya Kulkarni
2023-01-10  6:54     ` Christoph Hellwig
2023-01-06  8:33   ` [PATCH 3/7] nvmet: introduce bdev_zone_no helper Pankaj Raghav
2023-01-06 11:02     ` Damien Le Moal
2023-01-06 22:39     ` Bart Van Assche
2023-01-09  7:42     ` Chaitanya Kulkarni
2023-01-10  6:55     ` Christoph Hellwig
2023-01-06  8:33   ` [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index Pankaj Raghav
2023-01-06 11:05     ` Damien Le Moal
2023-01-06  8:33   ` [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2023-01-10  6:56     ` Christoph Hellwig
2023-01-10  8:39       ` Pankaj Raghav
2023-01-06  8:33   ` [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start Pankaj Raghav
2023-01-10  6:57     ` Christoph Hellwig
2023-01-10  9:06       ` Pankaj Raghav
2023-01-06  8:33   ` [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices Pankaj Raghav
2023-01-10  6:58     ` Christoph Hellwig
2023-01-10  9:07       ` Pankaj Raghav
2023-01-10  9:43         ` Christoph Hellwig

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=32aaa034-dc39-75dd-f4ec-e0e5ef9dd29c@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.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=kernel@pankajraghav.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=p.raghav@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox