Skip to content

Commit c65c20d

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/md-bitmap: merge md_bitmap_free() into bitmap_operations
So that the implementation won't be exposed, and it'll be possible o invent a new bitmap by replacing bitmap_operations. Signed-off-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent ef1c400 commit c65c20d

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

drivers/md/md-bitmap.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,10 +1828,7 @@ static void bitmap_flush(struct mddev *mddev)
18281828
bitmap_update_sb(bitmap);
18291829
}
18301830

1831-
/*
1832-
* free memory that was allocated
1833-
*/
1834-
void md_bitmap_free(struct bitmap *bitmap)
1831+
static void md_bitmap_free(struct bitmap *bitmap)
18351832
{
18361833
unsigned long k, pages;
18371834
struct bitmap_page *bp;
@@ -1865,7 +1862,6 @@ void md_bitmap_free(struct bitmap *bitmap)
18651862
kfree(bp);
18661863
kfree(bitmap);
18671864
}
1868-
EXPORT_SYMBOL(md_bitmap_free);
18691865

18701866
void md_bitmap_wait_behind_writes(struct mddev *mddev)
18711867
{
@@ -2782,6 +2778,7 @@ static struct bitmap_operations bitmap_ops = {
27822778
.get_from_slot = bitmap_get_from_slot,
27832779
.copy_from_slot = bitmap_copy_from_slot,
27842780
.set_pages = bitmap_set_pages,
2781+
.free = md_bitmap_free,
27852782
};
27862783

27872784
void mddev_set_bitmap_ops(struct mddev *mddev)

drivers/md/md-bitmap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,13 @@ struct bitmap_operations {
280280
int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
281281
sector_t *hi, bool clear_bits);
282282
void (*set_pages)(struct bitmap *bitmap, unsigned long pages);
283+
void (*free)(struct bitmap *bitmap);
283284
};
284285

285286
/* the bitmap API */
286287
void mddev_set_bitmap_ops(struct mddev *mddev);
287288

288289
/* these are exported */
289-
290-
void md_bitmap_free(struct bitmap *bitmap);
291290
void md_bitmap_wait_behind_writes(struct mddev *mddev);
292291

293292
static inline bool md_bitmap_enabled(struct bitmap *bitmap)

drivers/md/md-cluster.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,12 +1201,12 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
12011201
* can't resize bitmap
12021202
*/
12031203
goto out;
1204-
md_bitmap_free(bitmap);
1204+
mddev->bitmap_ops->free(bitmap);
12051205
}
12061206

12071207
return 0;
12081208
out:
1209-
md_bitmap_free(bitmap);
1209+
mddev->bitmap_ops->free(bitmap);
12101210
update_bitmap_size(mddev, oldsize);
12111211
return -1;
12121212
}
@@ -1250,7 +1250,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
12501250
bm_lockres = lockres_init(mddev, str, NULL, 1);
12511251
if (!bm_lockres) {
12521252
pr_err("md-cluster: Cannot initialize %s\n", str);
1253-
md_bitmap_free(bitmap);
1253+
mddev->bitmap_ops->free(bitmap);
12541254
return -1;
12551255
}
12561256
bm_lockres->flags |= DLM_LKF_NOQUEUE;
@@ -1261,17 +1261,17 @@ static int cluster_check_sync_size(struct mddev *mddev)
12611261

12621262
rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
12631263
if (rv) {
1264-
md_bitmap_free(bitmap);
1264+
mddev->bitmap_ops->free(bitmap);
12651265
return rv;
12661266
}
12671267

12681268
if (sync_size == 0) {
12691269
sync_size = stats.sync_size;
12701270
} else if (sync_size != stats.sync_size) {
1271-
md_bitmap_free(bitmap);
1271+
mddev->bitmap_ops->free(bitmap);
12721272
return -1;
12731273
}
1274-
md_bitmap_free(bitmap);
1274+
mddev->bitmap_ops->free(bitmap);
12751275
}
12761276

12771277
return (my_sync_size == sync_size) ? 0 : -1;

0 commit comments

Comments
 (0)