]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
authorYu Kuai <yukuai3@huawei.com>
Mon, 26 Aug 2024 07:44:51 +0000 (15:44 +0800)
committerSong Liu <song@kernel.org>
Tue, 27 Aug 2024 19:43:16 +0000 (12:43 -0700)
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>
drivers/md/md-bitmap.c
drivers/md/md-bitmap.h
drivers/md/raid1-10.c

index b5dbfa9728dc077032fbd4bf265bc791e202d22a..098bffac21677439e092419fe5126afe4d64afe8 100644 (file)
@@ -40,6 +40,22 @@ static inline char *bmname(struct bitmap *bitmap)
        return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
 }
 
+static bool __bitmap_enabled(struct bitmap *bitmap)
+{
+       return bitmap->storage.filemap &&
+              !test_bit(BITMAP_STALE, &bitmap->flags);
+}
+
+static bool bitmap_enabled(struct mddev *mddev)
+{
+       struct bitmap *bitmap = mddev->bitmap;
+
+       if (!bitmap)
+               return false;
+
+       return __bitmap_enabled(bitmap);
+}
+
 /*
  * check a page and, if necessary, allocate it (or hijack it if the alloc fails)
  *
@@ -1035,7 +1051,7 @@ static void __bitmap_unplug(struct bitmap *bitmap)
        int dirty, need_write;
        int writing = 0;
 
-       if (!md_bitmap_enabled(bitmap))
+       if (!__bitmap_enabled(bitmap))
                return;
 
        /* 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 = {
 };
 
 static struct bitmap_operations bitmap_ops = {
+       .enabled                = bitmap_enabled,
        .create                 = bitmap_create,
        .resize                 = bitmap_resize,
        .load                   = bitmap_load,
index bc9cb4ca676e7caab7f5f6e94e306c6cc20753be..c720729687e222f1bb63983ce8ac6bf41f03039b 100644 (file)
@@ -247,6 +247,7 @@ struct md_bitmap_stats {
 };
 
 struct bitmap_operations {
+       bool (*enabled)(struct mddev *mddev);
        int (*create)(struct mddev *mddev, int slot);
        int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize,
                      bool init);
@@ -287,12 +288,5 @@ struct bitmap_operations {
 /* the bitmap API */
 void mddev_set_bitmap_ops(struct mddev *mddev);
 
-static inline bool md_bitmap_enabled(struct bitmap *bitmap)
-{
-       return bitmap && bitmap->storage.filemap &&
-              !test_bit(BITMAP_STALE, &bitmap->flags);
-}
-
 #endif
-
 #endif
index e8207513eb1b649b96159e26e38e4e78fe8982bc..4378d3250bd757c105fd569b1cf5ba3d890b76ea 100644 (file)
@@ -140,7 +140,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
         * If bitmap is not enabled, it's safe to submit the io directly, and
         * this can get optimal performance.
         */
-       if (!md_bitmap_enabled(mddev->bitmap)) {
+       if (!mddev->bitmap_ops->enabled(mddev)) {
                raid1_submit_write(bio);
                return true;
        }