Commit cd92cdb9 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe

null_blk: cleanup zoned mode initialization

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, simplify the
calculation of the total number of zones of the device using the
round_up() macro.
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e2579c76
...@@ -6,7 +6,10 @@ ...@@ -6,7 +6,10 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include "trace.h" #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) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect)
{ {
...@@ -77,12 +80,11 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) ...@@ -77,12 +80,11 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
return -EINVAL; return -EINVAL;
} }
zone_capacity_sects = MB_TO_SECTS(dev->zone_capacity); zone_capacity_sects = mb_to_sects(dev->zone_capacity);
dev_capacity_sects = MB_TO_SECTS(dev->size); dev_capacity_sects = mb_to_sects(dev->size);
dev->zone_size_sects = MB_TO_SECTS(dev->zone_size); dev->zone_size_sects = mb_to_sects(dev->zone_size);
dev->nr_zones = dev_capacity_sects >> ilog2(dev->zone_size_sects); dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects)
if (dev_capacity_sects & (dev->zone_size_sects - 1)) >> ilog2(dev->zone_size_sects);
dev->nr_zones++;
dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
GFP_KERNEL | __GFP_ZERO); GFP_KERNEL | __GFP_ZERO);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment