summaryrefslogtreecommitdiff
path: root/drivers/md/md-bitmap.c
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2024-08-26 15:44:51 +0800
committerSong Liu <song@kernel.org>2024-08-27 12:43:16 -0700
commitdab2ce5534ef7a7b8db70d1abd4225ee8a7798c7 (patch)
treee48e8bd9c15ddbeeb77f53b8945bea18aaf4d0cc /drivers/md/md-bitmap.c
parent49f5f5e309e6127957babed7834f5a0e1022f936 (diff)
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>
Diffstat (limited to 'drivers/md/md-bitmap.c')
-rw-r--r--drivers/md/md-bitmap.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b5dbfa9728dc..098bffac2167 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -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,