# \[PATCH 20/20\] bcache: only initialize nvm-pages allocator when CONFIG\_BCACHE\_NVM\_PAGES configured

- From: Coly Li \<hidden\>
- Date: 2021-02-10 05:09:57 
- List: linux-bcache
- Page: https://ratatoskr.run/linux-bcache/2021/02/6400937
- Thread: https://ratatoskr.run/linux-bcache/2021/02/6400921/t.md

```text
It is unnecessary to initialize the EXPERIMENTAL nvm-pages allocator
when CONFIG_BCACHE_NVM_PAGES is not configured. This patch uses
"#ifdef CONFIG_BCACHE_NVM_PAGES" to wrap bch_nvm_init() and
bch_nvm_exit(), and only calls them when bch_nvm_exit is configured.

Signed-off-by: Coly Li <redacted>
Cc: Jianpeng Ma <redacted>
Cc: Qiaowei Ren <redacted>
---
 drivers/md/bcache/super.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 61fd5802a627..c273eeef0d38 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2845,7 +2845,9 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
+#ifdef CONFIG_BCACHE_NVM_PAGES
 	bch_nvm_exit();
+#endif
 	if (bcache_kobj)
 		kobject_put(bcache_kobj);
 	if (bcache_wq)
@@ -2947,7 +2949,9 @@ static int __init bcache_init(void)
 
 	bch_debug_init();
 	closure_debug_init();
+#ifdef CONFIG_BCACHE_NVM_PAGES
 	bch_nvm_init();
+#endif
 
 	bcache_is_reboot = false;
 
-- 
2.26.2

```
