return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
}
-static bool __bitmap_enabled(struct bitmap *bitmap, bool flush)
+static bool bitmap_enabled(void *data, bool flush)
{
+ struct bitmap *bitmap = data;
+
if (!flush)
return true;
bitmap->storage.filemap != NULL;
}
-static bool bitmap_enabled(struct mddev *mddev, bool flush)
-{
- struct bitmap *bitmap = mddev->bitmap;
-
- if (!bitmap)
- return false;
-
- return __bitmap_enabled(bitmap, flush);
-}
-
/*
* check a page and, if necessary, allocate it (or hijack it if the alloc fails)
*
int dirty, need_write;
int writing = 0;
- if (!__bitmap_enabled(bitmap, true))
+ 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 flush);
+ bool (*enabled)(void *data, bool flush);
int (*create)(struct mddev *mddev);
int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize);
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
+static inline bool md_bitmap_registered(struct mddev *mddev)
+{
+ return mddev->bitmap_ops != NULL;
+}
+
+static inline bool md_bitmap_enabled(struct mddev *mddev, bool flush)
+{
+ /* bitmap_ops must be registered before creating bitmap. */
+ if (!md_bitmap_registered(mddev))
+ return false;
+
+ if (!mddev->bitmap)
+ return false;
+
+ return mddev->bitmap_ops->enabled(mddev->bitmap, flush);
+}
+
#endif
* 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, true)) {
+ if (!md_bitmap_enabled(mddev, true)) {
raid1_submit_write(bio);
return true;
}