mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
dm zone: Use the bitmap API to allocate bitmaps
Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
This commit is contained in:
parent
d483001206
commit
e118029cb7
1 changed files with 7 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/bitmap.h>
|
||||||
|
|
||||||
#include "dm-core.h"
|
#include "dm-core.h"
|
||||||
|
|
||||||
|
@ -140,9 +141,9 @@ bool dm_is_zone_write(struct mapped_device *md, struct bio *bio)
|
||||||
void dm_cleanup_zoned_dev(struct mapped_device *md)
|
void dm_cleanup_zoned_dev(struct mapped_device *md)
|
||||||
{
|
{
|
||||||
if (md->disk) {
|
if (md->disk) {
|
||||||
kfree(md->disk->conv_zones_bitmap);
|
bitmap_free(md->disk->conv_zones_bitmap);
|
||||||
md->disk->conv_zones_bitmap = NULL;
|
md->disk->conv_zones_bitmap = NULL;
|
||||||
kfree(md->disk->seq_zones_wlock);
|
bitmap_free(md->disk->seq_zones_wlock);
|
||||||
md->disk->seq_zones_wlock = NULL;
|
md->disk->seq_zones_wlock = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,9 +183,8 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
|
||||||
switch (zone->type) {
|
switch (zone->type) {
|
||||||
case BLK_ZONE_TYPE_CONVENTIONAL:
|
case BLK_ZONE_TYPE_CONVENTIONAL:
|
||||||
if (!disk->conv_zones_bitmap) {
|
if (!disk->conv_zones_bitmap) {
|
||||||
disk->conv_zones_bitmap =
|
disk->conv_zones_bitmap = bitmap_zalloc(disk->nr_zones,
|
||||||
kcalloc(BITS_TO_LONGS(disk->nr_zones),
|
GFP_NOIO);
|
||||||
sizeof(unsigned long), GFP_NOIO);
|
|
||||||
if (!disk->conv_zones_bitmap)
|
if (!disk->conv_zones_bitmap)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -193,9 +193,8 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx,
|
||||||
case BLK_ZONE_TYPE_SEQWRITE_REQ:
|
case BLK_ZONE_TYPE_SEQWRITE_REQ:
|
||||||
case BLK_ZONE_TYPE_SEQWRITE_PREF:
|
case BLK_ZONE_TYPE_SEQWRITE_PREF:
|
||||||
if (!disk->seq_zones_wlock) {
|
if (!disk->seq_zones_wlock) {
|
||||||
disk->seq_zones_wlock =
|
disk->seq_zones_wlock = bitmap_zalloc(disk->nr_zones,
|
||||||
kcalloc(BITS_TO_LONGS(disk->nr_zones),
|
GFP_NOIO);
|
||||||
sizeof(unsigned long), GFP_NOIO);
|
|
||||||
if (!disk->seq_zones_wlock)
|
if (!disk->seq_zones_wlock)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue