From: Yu Kuai <yuku...@huawei.com> A new config MD_LLBITMAP is added, user can now using llbitmap to replace the old bitmap.
Signed-off-by: Yu Kuai <yuku...@huawei.com> --- drivers/md/Kconfig | 12 ++++++++++++ drivers/md/Makefile | 1 + drivers/md/md-bitmap.h | 13 +++++++++++++ drivers/md/md-llbitmap.c | 27 +++++++++++++++++++++++++++ drivers/md/md.c | 7 +++++++ 5 files changed, 60 insertions(+) diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index 0da07182494c..e5dc893ad09a 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -52,6 +52,18 @@ config MD_BITMAP If unsure, say Y. +config MD_LLBITMAP + bool "MD RAID lockless bitmap support" + default n + depends on BLK_DEV_MD + help + If you say Y here, support for the lockless write intent bitmap will + be enabled. + + Note, this is an experimental feature. + + If unsure, say N. + config MD_AUTODETECT bool "Autodetect RAID arrays during kernel boot" depends on BLK_DEV_MD=y diff --git a/drivers/md/Makefile b/drivers/md/Makefile index 811731840a5c..e70e4d3cbe29 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -39,6 +39,7 @@ linear-y += md-linear.o obj-$(CONFIG_MD_LINEAR) += linear.o obj-$(CONFIG_MD_RAID0) += raid0.o obj-$(CONFIG_MD_BITMAP) += md-bitmap.o +obj-$(CONFIG_MD_LLBITMAP) += md-llbitmap.o obj-$(CONFIG_MD_RAID1) += raid1.o obj-$(CONFIG_MD_RAID10) += raid10.o obj-$(CONFIG_MD_RAID456) += raid456.o diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h index 7a3cd2f70772..ee0c65e87dba 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -171,4 +171,17 @@ static inline void md_bitmap_exit(void) } #endif +#ifdef CONFIG_MD_LLBITMAP +int md_llbitmap_init(void); +void md_llbitmap_exit(void); +#else +static inline int md_llbitmap_init(void) +{ + return 0; +} +static inline void md_llbitmap_exit(void) +{ +} +#endif + #endif diff --git a/drivers/md/md-llbitmap.c b/drivers/md/md-llbitmap.c index 88ba29111e13..5e2f89137feb 100644 --- a/drivers/md/md-llbitmap.c +++ b/drivers/md/md-llbitmap.c @@ -1381,3 +1381,30 @@ static struct bitmap_operations llbitmap_ops = { .group = &md_llbitmap_group, }; + +int md_llbitmap_init(void) +{ + md_llbitmap_io_wq = alloc_workqueue("md_llbitmap_io", + WQ_MEM_RECLAIM | WQ_UNBOUND, 0); + if (!md_llbitmap_io_wq) + return -ENOMEM; + + md_llbitmap_unplug_wq = alloc_workqueue("md_llbitmap_unplug", + WQ_MEM_RECLAIM | WQ_UNBOUND, 0); + if (!md_llbitmap_unplug_wq) { + destroy_workqueue(md_llbitmap_io_wq); + md_llbitmap_io_wq = NULL; + return -ENOMEM; + } + + return register_md_submodule(&llbitmap_ops.head); +} + +void md_llbitmap_exit(void) +{ + destroy_workqueue(md_llbitmap_io_wq); + md_llbitmap_io_wq = NULL; + destroy_workqueue(md_llbitmap_unplug_wq); + md_llbitmap_unplug_wq = NULL; + unregister_md_submodule(&llbitmap_ops.head); +} diff --git a/drivers/md/md.c b/drivers/md/md.c index c1f13288069a..4d05eae69795 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -10104,6 +10104,10 @@ static int __init md_init(void) if (ret) return ret; + ret = md_llbitmap_init(); + if (ret) + goto err_bitmap; + ret = -ENOMEM; md_wq = alloc_workqueue("md", WQ_MEM_RECLAIM, 0); if (!md_wq) @@ -10135,6 +10139,8 @@ static int __init md_init(void) err_misc_wq: destroy_workqueue(md_wq); err_wq: + md_llbitmap_exit(); +err_bitmap: md_bitmap_exit(); return ret; } @@ -10439,6 +10445,7 @@ static __exit void md_exit(void) destroy_workqueue(md_misc_wq); destroy_workqueue(md_wq); + md_llbitmap_exit(); md_bitmap_exit(); } -- 2.39.2