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);
}
/*
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
};
struct bitmap_operations {
- bool (*enabled)(struct mddev *mddev);
+ bool (*enabled)(struct mddev *mddev, bool flush);
int (*create)(struct mddev *mddev);
int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize);
* If bitmap is not enabled, it's safe to submit the io directly, and
* this can get optimal performance.
*/
- if (!mddev->bitmap_ops->enabled(mddev)) {
+ if (!mddev->bitmap_ops->enabled(mddev, true)) {
raid1_submit_write(bio);
return true;
}