Re: [PATCH 04/14] bcache: initialize the nvm pages allocator
From: Coly Li <hidden>
Date: 2021-06-23 09:34:51
Also in:
linux-block
On 6/23/21 5:16 PM, Hannes Reinecke wrote:
On 6/23/21 7:26 AM, Coly Li wrote:quoted
On 6/22/21 6:39 PM, Hannes Reinecke wrote:quoted
On 6/15/21 7:49 AM, Coly Li wrote:quoted
From: Jianpeng Ma <redacted> This patch define the prototype data structures in memory and initializes the nvm pages allocator. The nvm address space which is managed by this allocator can consist of many nvm namespaces, and some namespaces can compose into one nvm set, like cache set. For this initial implementation, only one set can be supported. The users of this nvm pages allocator need to call register_namespace() to register the nvdimm device (like /dev/pmemX) into this allocator as the instance of struct nvm_namespace. Reported-by: Randy Dunlap <redacted> Signed-off-by: Jianpeng Ma <redacted> Co-developed-by: Qiaowei Ren <redacted> Signed-off-by: Qiaowei Ren <redacted> Signed-off-by: Coly Li <redacted> --- drivers/md/bcache/Kconfig | 10 ++ drivers/md/bcache/Makefile | 1 + drivers/md/bcache/nvm-pages.c | 295 ++++++++++++++++++++++++++++++++++ drivers/md/bcache/nvm-pages.h | 74 +++++++++ drivers/md/bcache/super.c | 3 + 5 files changed, 383 insertions(+) create mode 100644 drivers/md/bcache/nvm-pages.c create mode 100644 drivers/md/bcache/nvm-pages.hdiff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig index d1ca4d059c20..a69f6c0e0507 100644 --- a/drivers/md/bcache/Kconfig +++ b/drivers/md/bcache/Kconfig@@ -35,3 +35,13 @@ config BCACHE_ASYNC_REGISTRATIONdevice path into this file will returns immediately and the real registration work is handled in kernel work queue in asynchronous way. + +config BCACHE_NVM_PAGES + bool "NVDIMM support for bcache (EXPERIMENTAL)" + depends on BCACHE + depends on 64BIT + depends on LIBNVDIMM + depends on DAX + help + Allocate/release NV-memory pages for bcache and provide allocated pages + for each requestor after system reboot.diff --git a/drivers/md/bcache/Makefile b/drivers/md/bcache/Makefile index 5b87e59676b8..2397bb7c7ffd 100644 --- a/drivers/md/bcache/Makefile +++ b/drivers/md/bcache/Makefile@@ -5,3 +5,4 @@ obj-$(CONFIG_BCACHE) += bcache.obcache-y := alloc.o bset.o btree.o closure.o debug.o extents.o\ io.o journal.o movinggc.o request.o stats.o super.o sysfs.o trace.o\ util.o writeback.o features.o +bcache-$(CONFIG_BCACHE_NVM_PAGES) += nvm-pages.odiff --git a/drivers/md/bcache/nvm-pages.cb/drivers/md/bcache/nvm-pages.c new file mode 100644 index 000000000000..18fdadbc502f--- /dev/null +++ b/drivers/md/bcache/nvm-pages.c@@ -0,0 +1,295 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Nvdimm page-buddy allocator + * + * Copyright (c) 2021, Intel Corporation. + * Copyright (c) 2021, Qiaowei Ren <qiaowei.ren@intel.com>. + * Copyright (c) 2021, Jianpeng Ma <jianpeng.ma@intel.com>. + */ + +#if defined(CONFIG_BCACHE_NVM_PAGES) +No need for this 'if' statement as it'll be excluded by the Makefile anyway if the config option isn't set.Such if is necessary because stub routines are defined when CONFIG_BCACHE_NVM_PAGES is not defined, e.g. 426 +#else 427 + 428 +static inline struct bch_nvm_namespace *bch_register_namespace(const char *dev_path) 429 +{ 430 + return NULL; 431 +} 432 +static inline int bch_nvm_init(void) 433 +{ 434 + return 0; 435 +} 436 +static inline void bch_nvm_exit(void) { } 437 + 438 +#endif /* CONFIG_BCACHE_NVM_PAGES */But then these stubs should be defined in the header file, not here. [ .. ]
Copied, it will be improved in next post. Thanks for your review and comment. Coly Li