##### Dirty Bits syncronization IO fast path will set bits to dirty, and those dirty bits will be cleared by daemon after IO is done. llbitmap_barrier is used to synchronize between IO path and daemon; IO path: 1) try to grab a reference, if succeed, set expire time after 5s and return; 2) if failed to grab a reference, wait for daemon to finish clearing dirty bits; Daemon(Daemon will be waken up every daemon_sleep seconds): For each page: 1) check if page expired, if not skip this page; for expired page: 2) suspend the page and wait for inflight write IO to be done; 3) change dirty page to clean; 4) resume the page; Noted: 1) user must apply the following mdadm patch, and then llbitmap can be enabled by --bitmap=lockless https://lore.kernel.org/all/20250509101411.2093911-1-yukuai1@xxxxxxxxxxxxxxx/ 2) following branch for review or test: https://git.kernel.org/pub/scm/linux/kernel/git/yukuai/linux.git/log/?h=yukuai/md-6.16 Yu Kuai (19): md/md-bitmap: add {start, end}_discard in bitmap_operations md: support discard for bitmap ops md/md-bitmap: remove parameter slot from bitmap_create() md: add a new sysfs api bitmap_version md: delay registration of bitmap_ops until creating bitmap md: add a new parameter 'offset' to md_super_write() md/md-bitmap: add a new helper skip_sync_blocks() in bitmap_operations md/md-bitmap: add a new helper blocks_synced() in bitmap_operations md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER md/md-llbitmap: add data structure definition and comments md/md-llbitmap: implement bitmap IO md/md-llbitmap: implement bit state machine md/md-llbitmap: implement APIs for page level dirty bits synchronization md/md-llbitmap: implement APIs to mange bitmap lifetime md/md-llbitmap: implement APIs to dirty bits and clear bits md/md-llbitmap: implement APIs for sync_thread md/md-llbitmap: implement all bitmap operations md/md-llbitmap: implement sysfs APIs md/md-llbitmap: add Kconfig drivers/md/Kconfig | 12 + drivers/md/Makefile | 1 + drivers/md/md-bitmap.c | 9 +- drivers/md/md-bitmap.h | 25 +- drivers/md/md-llbitmap.c | 1465 ++++++++++++++++++++++++++++++++++++++ drivers/md/md.c | 221 ++++-- drivers/md/md.h | 8 +- drivers/md/raid5.c | 6 + 8 files changed, 1700 insertions(+), 47 deletions(-) create mode 100644 drivers/md/md-llbitmap.c -- 2.39.2