aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md-bitmap.c
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2025-07-07 09:27:01 +0800
committerYu Kuai <yukuai3@huawei.com>2025-09-06 17:11:42 +0800
commit9c41ead04ec0d3ee54505039879aee20cf495e0a (patch)
treec54d58748a50adcab28cb26ab309f909c9e874a7 /drivers/md/md-bitmap.c
parentmd/md-bitmap: merge md_bitmap_group into bitmap_operations (diff)
downloadlinux-9c41ead04ec0d3ee54505039879aee20cf495e0a.tar.gz
linux-9c41ead04ec0d3ee54505039879aee20cf495e0a.zip
md/md-bitmap: add a new parameter 'flush' to bitmap_ops->enabled
The method is only used from raid1/raid10 IO path, to check if write bio should be pluged, the parameter is always set to true for now, following patch will use this helper in other context like updating superblock. Link: https://lore.kernel.org/linux-raid/20250707012711.376844-6-yukuai1@huaweicloud.com Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Xiao Ni <xni@redhat.com>
Diffstat (limited to 'drivers/md/md-bitmap.c')
-rw-r--r--drivers/md/md-bitmap.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 30b6b42b9a48..69e4a43c38b4 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -232,20 +232,27 @@ static inline char *bmname(struct bitmap *bitmap)
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
}
-static bool __bitmap_enabled(struct bitmap *bitmap)
+static bool __bitmap_enabled(struct bitmap *bitmap, bool flush)
{
- return bitmap->storage.filemap &&
- !test_bit(BITMAP_STALE, &bitmap->flags);
+ if (!flush)
+ return true;
+
+ /*
+ * If caller want to flush bitmap pages to underlying disks, check if
+ * there are cached pages in filemap.
+ */
+ return !test_bit(BITMAP_STALE, &bitmap->flags) &&
+ bitmap->storage.filemap != NULL;
}
-static bool bitmap_enabled(struct mddev *mddev)
+static bool bitmap_enabled(struct mddev *mddev, bool flush)
{
struct bitmap *bitmap = mddev->bitmap;
if (!bitmap)
return false;
- return __bitmap_enabled(bitmap);
+ return __bitmap_enabled(bitmap, flush);
}
/*
@@ -1244,7 +1251,7 @@ static void __bitmap_unplug(struct bitmap *bitmap)
int dirty, need_write;
int writing = 0;
- if (!__bitmap_enabled(bitmap))
+ if (!__bitmap_enabled(bitmap, true))
return;
/* look at each page to see if there are any set bits that need to be