public inbox for linux-bcache@vger.kernel.org
 help / color / mirror / Atom feed
From: Qiaowei Ren <qiaowei.ren@intel.com>
To: Coly Li <colyli@suse.de>
Cc: Qiaowei Ren <qiaowei.ren@intel.com>,
	Jianpeng Ma <jianpeng.ma@intel.com>,
	linux-bcache@vger.kernel.org
Subject: [PATCH 6/8] bcache: get allocated pages from specific owner
Date: Wed, 23 Dec 2020 09:41:34 -0500	[thread overview]
Message-ID: <20201223144136.24966-7-qiaowei.ren@intel.com> (raw)
In-Reply-To: <20201223144136.24966-1-qiaowei.ren@intel.com>

This patch implements get_allocated_pages() of the buddy to be used to
get allocated pages from specific owner.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
---
 drivers/md/bcache/nvm-pages.c | 36 +++++++++++++++++++++++++++++++++++
 drivers/md/bcache/nvm-pages.h |  7 +++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/md/bcache/nvm-pages.c b/drivers/md/bcache/nvm-pages.c
index 16b65a866041..e8765b0b3398 100644
--- a/drivers/md/bcache/nvm-pages.c
+++ b/drivers/md/bcache/nvm-pages.c
@@ -373,6 +373,42 @@ void *nvm_alloc_pages(int order, const char *owner_uuid)
 }
 EXPORT_SYMBOL_GPL(nvm_alloc_pages);
 
+struct extent *get_allocated_pages(const char *owner_uuid)
+{
+	struct owner_list *owner_list = find_owner_list(owner_uuid, false);
+	int i;
+	struct extent *head = NULL;
+
+	if (owner_list == NULL)
+		return NULL;
+
+	for (i = 0; i < only_set->total_namespaces_nr; i++) {
+		struct list_head *l;
+		struct nvm_alloced_recs *alloced_recs = owner_list->alloced_recs[i];
+
+		if (!alloced_recs || alloced_recs->size == 0)
+			continue;
+
+		l = alloced_recs->extent_head.next;
+		while (l != &alloced_recs->extent_head) {
+			struct extent *e = container_of(l, struct extent, list);
+			struct extent *tmp = kzalloc(sizeof(struct extent), GFP_KERNEL);
+
+			tmp->kaddr = e->kaddr;
+			tmp->nr = e->nr;
+
+			if (head != NULL)
+				list_add_tail(&tmp->list, &head->list);
+			else
+				head = tmp;
+
+			l = l->next;
+		}
+	}
+	return head;
+}
+EXPORT_SYMBOL_GPL(get_allocated_pages);
+
 static void init_owner_info(struct nvm_namespace *ns)
 {
 	struct owner_list_head *owner_list_head;
diff --git a/drivers/md/bcache/nvm-pages.h b/drivers/md/bcache/nvm-pages.h
index 1e435ce0ddf4..4f0374459459 100644
--- a/drivers/md/bcache/nvm-pages.h
+++ b/drivers/md/bcache/nvm-pages.h
@@ -80,6 +80,8 @@ extern void bch_nvm_exit(void);
 extern void *nvm_alloc_pages(int order, const char *owner_uuid);
 extern void nvm_free_pages(void *addr, int order, const char *owner_uuid);
 
+extern struct extent *get_allocated_pages(const char *owner_uuid);
+
 #else
 
 static inline struct nvm_namespace *register_namespace(const char *dev_path)
@@ -95,6 +97,11 @@ static inline void bch_nvm_exit(void) { }
 static inline void *nvm_alloc_pages(int order, const char *owner_uuid) { }
 static inline void nvm_free_pages(void *addr, int order, const char *owner_uuid) { }
 
+static inline struct extent *get_allocated_pages(const char *owner_uuid)
+{
+	return NULL;
+}
+
 #endif /* CONFIG_BCACHE_NVM_PAGES */
 
 #endif /* _BCACHE_NVM_PAGES_H */
-- 
2.17.1


  parent reply	other threads:[~2020-12-23  7:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 14:41 [RFC PATCH 0/8] nvm page allocator for bcache Qiaowei Ren
2020-12-23 14:41 ` [PATCH 1/8] bcache: add initial data structures for nvm pages Qiaowei Ren
2020-12-23 14:41 ` [PATCH 2/8] bcache: initialize the nvm pages allocator Qiaowei Ren
2020-12-23 14:41 ` [PATCH 3/8] bcache: initialization of the buddy Qiaowei Ren
2020-12-23 14:41 ` [PATCH 4/8] bcache: nvm_alloc_pages() " Qiaowei Ren
2020-12-23 14:41 ` [PATCH 5/8] bcache: nvm_free_pages() " Qiaowei Ren
2020-12-23 14:41 ` Qiaowei Ren [this message]
2020-12-23 14:41 ` [PATCH 7/8] bcache: persist owner info when alloc/free pages Qiaowei Ren
2020-12-23 14:41 ` [PATCH 8/8] bcache: testing module for nvm pages allocator Qiaowei Ren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201223144136.24966-7-qiaowei.ren@intel.com \
    --to=qiaowei.ren@intel.com \
    --cc=colyli@suse.de \
    --cc=jianpeng.ma@intel.com \
    --cc=linux-bcache@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox