From: Mike Snitzer <snitzer@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, dm-devel@redhat.com,
Mike Snitzer <snitzer@kernel.org>
Subject: Re: [dm-devel] [PATCH 1/6] block: factor out a chunk_size_left helper
Date: Thu, 16 Jun 2022 19:05:48 -0400 [thread overview]
Message-ID: <Yqu3TKf5MUwcnUty@redhat.com> (raw)
In-Reply-To: <20220614090934.570632-2-hch@lst.de>
On Tue, Jun 14 2022 at 5:09P -0400,
Christoph Hellwig <hch@lst.de> wrote:
> Factor out a helper from blk_max_size_offset so that it can be reused
> independently.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> include/linux/blkdev.h | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 914c613d81da7..e66ad451274ec 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -933,6 +933,17 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
> return q->limits.max_sectors;
> }
>
> +/*
> + * Return how much of the chunk is left to be used for I/O at a given offset.
> + */
> +static inline unsigned int blk_chunk_sectors_left(sector_t offset,
> + unsigned int chunk_sectors)
> +{
> + if (unlikely(!is_power_of_2(chunk_sectors)))
> + return chunk_sectors - sector_div(offset, chunk_sectors);
> + return chunk_sectors - (offset & (chunk_sectors - 1));
> +}
> +
> /*
> * Return maximum size of a request at given offset. Only valid for
> * file system requests.
> @@ -948,12 +959,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
> return q->limits.max_sectors;
> }
>
> - if (likely(is_power_of_2(chunk_sectors)))
> - chunk_sectors -= offset & (chunk_sectors - 1);
> - else
> - chunk_sectors -= sector_div(offset, chunk_sectors);
> -
> - return min(q->limits.max_sectors, chunk_sectors);
> + return min(q->limits.max_sectors,
> + blk_chunk_sectors_left(offset, chunk_sectors));
> }
While you're at it, any reason not to use queue_max_sectors() here?
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Mike Snitzer <snitzer@kernel.org>,
dm-devel@redhat.com, linux-block@vger.kernel.org
Subject: Re: [PATCH 1/6] block: factor out a chunk_size_left helper
Date: Thu, 16 Jun 2022 19:05:48 -0400 [thread overview]
Message-ID: <Yqu3TKf5MUwcnUty@redhat.com> (raw)
In-Reply-To: <20220614090934.570632-2-hch@lst.de>
On Tue, Jun 14 2022 at 5:09P -0400,
Christoph Hellwig <hch@lst.de> wrote:
> Factor out a helper from blk_max_size_offset so that it can be reused
> independently.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> include/linux/blkdev.h | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 914c613d81da7..e66ad451274ec 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -933,6 +933,17 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
> return q->limits.max_sectors;
> }
>
> +/*
> + * Return how much of the chunk is left to be used for I/O at a given offset.
> + */
> +static inline unsigned int blk_chunk_sectors_left(sector_t offset,
> + unsigned int chunk_sectors)
> +{
> + if (unlikely(!is_power_of_2(chunk_sectors)))
> + return chunk_sectors - sector_div(offset, chunk_sectors);
> + return chunk_sectors - (offset & (chunk_sectors - 1));
> +}
> +
> /*
> * Return maximum size of a request at given offset. Only valid for
> * file system requests.
> @@ -948,12 +959,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
> return q->limits.max_sectors;
> }
>
> - if (likely(is_power_of_2(chunk_sectors)))
> - chunk_sectors -= offset & (chunk_sectors - 1);
> - else
> - chunk_sectors -= sector_div(offset, chunk_sectors);
> -
> - return min(q->limits.max_sectors, chunk_sectors);
> + return min(q->limits.max_sectors,
> + blk_chunk_sectors_left(offset, chunk_sectors));
> }
While you're at it, any reason not to use queue_max_sectors() here?
next prev parent reply other threads:[~2022-06-16 23:06 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 9:09 [dm-devel] clean up the chunk_sizehandling helpers a little Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 9:09 ` [dm-devel] [PATCH 1/6] block: factor out a chunk_size_left helper Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 16:39 ` [dm-devel] " Bart Van Assche
2022-06-14 16:39 ` Bart Van Assche
2022-06-15 10:32 ` [dm-devel] " Pankaj Raghav
2022-06-15 10:32 ` Pankaj Raghav
2022-06-16 23:05 ` Mike Snitzer [this message]
2022-06-16 23:05 ` Mike Snitzer
2022-06-17 6:22 ` [dm-devel] " Christoph Hellwig
2022-06-17 6:22 ` Christoph Hellwig
2022-06-14 9:09 ` [dm-devel] [PATCH 2/6] dm: open code blk_max_size_offset in max_io_len Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-16 23:21 ` [dm-devel] " Mike Snitzer
2022-06-16 23:21 ` Mike Snitzer
2022-06-14 9:09 ` [dm-devel] [PATCH 3/6] block: open code blk_max_size_offset in blk_rq_get_max_sectors Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 16:43 ` [dm-devel] " Bart Van Assche
2022-06-14 16:43 ` Bart Van Assche
2022-06-14 16:45 ` [dm-devel] " Bart Van Assche
2022-06-14 16:45 ` Bart Van Assche
2022-06-14 9:09 ` [dm-devel] [PATCH 4/6] block: cleanup variable naming in get_max_io_size Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 16:50 ` [dm-devel] " Bart Van Assche
2022-06-14 16:50 ` Bart Van Assche
2022-06-15 6:27 ` [dm-devel] " Christoph Hellwig
2022-06-15 6:27 ` Christoph Hellwig
2022-06-14 9:09 ` [dm-devel] [PATCH 5/6] block: fold blk_max_size_offset into get_max_io_size Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 16:51 ` [dm-devel] " Bart Van Assche
2022-06-14 16:51 ` Bart Van Assche
2022-06-15 10:48 ` [dm-devel] " Pankaj Raghav
2022-06-15 10:48 ` Pankaj Raghav
2022-06-14 9:09 ` [dm-devel] [PATCH 6/6] block: move blk_queue_get_max_sectors to blk.h Christoph Hellwig
2022-06-14 9:09 ` Christoph Hellwig
2022-06-14 16:48 ` [dm-devel] " Bart Van Assche
2022-06-14 16:48 ` Bart Van Assche
2022-06-17 12:39 ` [dm-devel] clean up the chunk_sizehandling helpers a little Jens Axboe
2022-06-17 12:39 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2021-10-13 17:12 [dm-devel] simplify I/O size calculation helpers v2 Christoph Hellwig
2021-10-13 17:12 ` [dm-devel] [PATCH 1/6] block: factor out a chunk_size_left helper 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=Yqu3TKf5MUwcnUty@redhat.com \
--to=snitzer@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--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.