Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-42-yukuai1@huaweicloud.com
Signed-off-by: Song Liu <song@kernel.org>

authored by

Yu Kuai and committed by
Song Liu
dab2ce55 49f5f5e3

+20 -9
+18 -1
drivers/md/md-bitmap.c
··· 40 40 return bitmap->mddev ? mdname(bitmap->mddev) : "mdX"; 41 41 } 42 42 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 + 43 59 /* 44 60 * check a page and, if necessary, allocate it (or hijack it if the alloc fails) 45 61 * ··· 1051 1035 int dirty, need_write; 1052 1036 int writing = 0; 1053 1037 1054 - if (!md_bitmap_enabled(bitmap)) 1038 + if (!__bitmap_enabled(bitmap)) 1055 1039 return; 1056 1040 1057 1041 /* look at each page to see if there are any set bits that need to be ··· 2769 2753 }; 2770 2754 2771 2755 static struct bitmap_operations bitmap_ops = { 2756 + .enabled = bitmap_enabled, 2772 2757 .create = bitmap_create, 2773 2758 .resize = bitmap_resize, 2774 2759 .load = bitmap_load,
+1 -7
drivers/md/md-bitmap.h
··· 247 247 }; 248 248 249 249 struct bitmap_operations { 250 + bool (*enabled)(struct mddev *mddev); 250 251 int (*create)(struct mddev *mddev, int slot); 251 252 int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize, 252 253 bool init); ··· 288 287 /* the bitmap API */ 289 288 void mddev_set_bitmap_ops(struct mddev *mddev); 290 289 291 - static inline bool md_bitmap_enabled(struct bitmap *bitmap) 292 - { 293 - return bitmap && bitmap->storage.filemap && 294 - !test_bit(BITMAP_STALE, &bitmap->flags); 295 - } 296 - 297 290 #endif 298 - 299 291 #endif
+1 -1
drivers/md/raid1-10.c
··· 140 140 * If bitmap is not enabled, it's safe to submit the io directly, and 141 141 * this can get optimal performance. 142 142 */ 143 - if (!md_bitmap_enabled(mddev->bitmap)) { 143 + if (!mddev->bitmap_ops->enabled(mddev)) { 144 144 raid1_submit_write(bio); 145 145 return true; 146 146 }