* [PATCH] null_blk: cleanup zoned mode initialization
@ 2021-01-12 3:44 Damien Le Moal
2021-01-12 6:14 ` Chaitanya Kulkarni
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Damien Le Moal @ 2021-01-12 3:44 UTC (permalink / raw)
To: linux-block, Jens Axboe
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>
---
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);
--
2.29.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] null_blk: cleanup zoned mode initialization
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
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2021-01-12 6:14 UTC (permalink / raw)
To: Damien Le Moal, linux-block, Jens Axboe
On 1/11/21 19: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>
Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] null_blk: cleanup zoned mode initialization
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
2021-01-29 0:06 ` Damien Le Moal
2021-01-29 0:10 ` Jens Axboe
3 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2021-01-27 1:09 UTC (permalink / raw)
To: linux-block, Jens Axboe
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] null_blk: cleanup zoned mode initialization
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
@ 2021-01-29 0:06 ` Damien Le Moal
2021-01-29 0:10 ` Jens Axboe
3 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2021-01-29 0:06 UTC (permalink / raw)
To: linux-block, Jens Axboe
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>
> ---
> 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);
>
Jens,
Looks like this one has fallen through the cracks...
Could ypu pick it up please ?
Thanks !
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] null_blk: cleanup zoned mode initialization
2021-01-12 3:44 [PATCH] null_blk: cleanup zoned mode initialization Damien Le Moal
` (2 preceding siblings ...)
2021-01-29 0:06 ` Damien Le Moal
@ 2021-01-29 0:10 ` Jens Axboe
2021-01-29 0:11 ` Damien Le Moal
3 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2021-01-29 0:10 UTC (permalink / raw)
To: Damien Le Moal, linux-block
On 1/11/21 8:44 PM, 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.
Sorry missed this, applide for 5.11.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] null_blk: cleanup zoned mode initialization
2021-01-29 0:10 ` Jens Axboe
@ 2021-01-29 0:11 ` Damien Le Moal
0 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2021-01-29 0:11 UTC (permalink / raw)
To: Jens Axboe, linux-block
On 2021/01/29 9:11, Jens Axboe wrote:
> On 1/11/21 8:44 PM, 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.
>
> Sorry missed this, applide for 5.11.
Thanks !
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-29 0:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-01-29 0:06 ` Damien Le Moal
2021-01-29 0:10 ` Jens Axboe
2021-01-29 0:11 ` Damien Le Moal
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.