From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH] null_blk: cleanup zoned mode initialization
Date: Wed, 27 Jan 2021 01:09:38 +0000 [thread overview]
Message-ID: <BL0PR04MB65148F93DBF17D752D599166E7BB9@BL0PR04MB6514.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20210112034453.1220131-1-damien.lemoal@wdc.com
On 2021/01/12 12:47, Damien Le Moal wrote:
> To avoid potential compilation problems, replaced the badly written
> MB_TO_SECTS macro (missing parenthesis around the argument use) with
> the inline function mb_to_sects(). And while at it, use DIV_ROUND_UP()
> to calculate the total number of zones of a zoned device, simplifying
> the code.
>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Jens,
Ping ?
> ---
> drivers/block/null_blk/zoned.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 148b871f263b..535351570bb2 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -6,7 +6,10 @@
> #define CREATE_TRACE_POINTS
> #include "trace.h"
>
> -#define MB_TO_SECTS(mb) (((sector_t)mb * SZ_1M) >> SECTOR_SHIFT)
> +static inline sector_t mb_to_sects(unsigned long mb)
> +{
> + return ((sector_t)mb * SZ_1M) >> SECTOR_SHIFT;
> +}
>
> static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect)
> {
> @@ -77,12 +80,10 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
> return -EINVAL;
> }
>
> - zone_capacity_sects = MB_TO_SECTS(dev->zone_capacity);
> - dev_capacity_sects = MB_TO_SECTS(dev->size);
> - dev->zone_size_sects = MB_TO_SECTS(dev->zone_size);
> - dev->nr_zones = dev_capacity_sects >> ilog2(dev->zone_size_sects);
> - if (dev_capacity_sects & (dev->zone_size_sects - 1))
> - dev->nr_zones++;
> + zone_capacity_sects = mb_to_sects(dev->zone_capacity);
> + dev_capacity_sects = mb_to_sects(dev->size);
> + dev->zone_size_sects = mb_to_sects(dev->zone_size);
> + dev->nr_zones = DIV_ROUND_UP(dev_capacity_sects, dev->zone_size_sects);
>
> dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
> GFP_KERNEL | __GFP_ZERO);
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2021-01-27 4:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 3:44 [PATCH] null_blk: cleanup zoned mode initialization Damien Le Moal
2021-01-12 6:14 ` Chaitanya Kulkarni
2021-01-27 1:09 ` Damien Le Moal [this message]
2021-01-29 0:06 ` Damien Le Moal
2021-01-29 0:10 ` Jens Axboe
2021-01-29 0:11 ` Damien Le Moal
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=BL0PR04MB65148F93DBF17D752D599166E7BB9@BL0PR04MB6514.namprd04.prod.outlook.com \
--to=damien.lemoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.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.