Skip to content

Commit dab2ce5

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
So that the implementation won't be exposed, and it'll be possible to 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 49f5f5e commit dab2ce5

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

drivers/md/md-bitmap.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ static inline char *bmname(struct bitmap *bitmap)
4040
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
4141
}
4242

43+
static bool __bitmap_enabled(struct bitmap *bitmap)
44+
{
45+
return bitmap->storage.filemap &&
46+
!test_bit(BITMAP_STALE, &bitmap->flags);
47+
}
48+
49+
static bool bitmap_enabled(struct mddev *mddev)
50+
{
51+
struct bitmap *bitmap = mddev->bitmap;
52+
53+
if (!bitmap)
54+
return false;
55+
56+
return __bitmap_enabled(bitmap);
57+
}
58+
4359
/*
4460
* check a page and, if necessary, allocate it (or hijack it if the alloc fails)
4561
*
@@ -1035,7 +1051,7 @@ static void __bitmap_unplug(struct bitmap *bitmap)
10351051
int dirty, need_write;
10361052
int writing = 0;
10371053

1038-
if (!md_bitmap_enabled(bitmap))
1054+
if (!__bitmap_enabled(bitmap))
10391055
return;
10401056

10411057
/* look at each page to see if there are any set bits that need to be
@@ -2753,6 +2769,7 @@ const struct attribute_group md_bitmap_group = {
27532769
};
27542770

27552771
static struct bitmap_operations bitmap_ops = {
2772+
.enabled = bitmap_enabled,
27562773
.create = bitmap_create,
27572774
.resize = bitmap_resize,
27582775
.load = bitmap_load,

drivers/md/md-bitmap.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ struct md_bitmap_stats {
247247
};
248248

249249
struct bitmap_operations {
250+
bool (*enabled)(struct mddev *mddev);
250251
int (*create)(struct mddev *mddev, int slot);
251252
int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize,
252253
bool init);
@@ -287,12 +288,5 @@ struct bitmap_operations {
287288
/* the bitmap API */
288289
void mddev_set_bitmap_ops(struct mddev *mddev);
289290

290-
static inline bool md_bitmap_enabled(struct bitmap *bitmap)
291-
{
292-
return bitmap && bitmap->storage.filemap &&
293-
!test_bit(BITMAP_STALE, &bitmap->flags);
294-
}
295-
296291
#endif
297-
298292
#endif

drivers/md/raid1-10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
140140
* If bitmap is not enabled, it's safe to submit the io directly, and
141141
* this can get optimal performance.
142142
*/
143-
if (!md_bitmap_enabled(mddev->bitmap)) {
143+
if (!mddev->bitmap_ops->enabled(mddev)) {
144144
raid1_submit_write(bio);
145145
return true;
146146
}

0 commit comments

Comments
 (0)