[PATCH v13 06/12] bcache: get recs list head for allocated pages by specific uuid

Coly Li
2021-12-12T17:06:33Z

From: Jianpeng Ma <jianpeng.ma@intel.com>

This patch implements bch_get_nvmpg_head() of the buddy allocator
to be used to get recs list head for allocated pages by specific
uuid. Then the requester (owner) can find all previous allocated
nvdimm pages by iterating the recs list.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Co-developed-by: Qiaowei Ren <qiaowei.ren@intel.com>
Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jens Axboe <axboe@kernel.dk>
---
drivers/md/bcache/nvmpg.c | 5 +++++
drivers/md/bcache/nvmpg.h | 6 ++++++
2 files changed, 11 insertions(+)

diff --git a/drivers/md/bcache/nvmpg.c b/drivers/md/bcache/nvmpg.c
index 8ce0c4389b42..e26c7b578a62 100644
--- a/drivers/md/bcache/nvmpg.c
+++ b/drivers/md/bcache/nvmpg.c
@@ -539,6 +539,11 @@ unsigned long bch_nvmpg_alloc_pages(int order, const char *uuid)
return nvmpg_offset;
}

+struct bch_nvmpg_head *bch_get_nvmpg_head(const char *uuid)
+{
+ return find_nvmpg_head(uuid, false);
+}
+
static inline void *nvm_end_addr(struct bch_nvmpg_ns *ns)
{
return ns->base_addr + (ns->pages_total << PAGE_SHIFT);
diff --git a/drivers/md/bcache/nvmpg.h b/drivers/md/bcache/nvmpg.h
index e089936e7f13..2361cabf18be 100644
--- a/drivers/md/bcache/nvmpg.h
+++ b/drivers/md/bcache/nvmpg.h
@@ -94,6 +94,7 @@ int bch_nvmpg_init(void);
void bch_nvmpg_exit(void);
unsigned long bch_nvmpg_alloc_pages(int order, const char *uuid);
void bch_nvmpg_free_pages(unsigned long nvmpg_offset, int order, const char *uuid);
+struct bch_nvmpg_head *bch_get_nvmpg_head(const char *uuid);

#else

@@ -116,6 +117,11 @@ static inline unsigned long bch_nvmpg_alloc_pages(int order, const char *uuid)

static inline void bch_nvmpg_free_pages(void *addr, int order, const char *uuid) { }

+static inline struct bch_nvmpg_head *bch_get_nvmpg_head(const char *uuid)
+{
+ return NULL;
+}
+
#endif /* CONFIG_BCACHE_NVM_PAGES */

#endif /* _BCACHE_NVM_PAGES_H */
--
2.31.1