Thread (44 messages) 44 messages, 9 authors, 2017-02-09
STALE3416d
Revisions (3)
  1. rfc current
  2. v2 [diff vs current]
  3. v3 [diff vs current]

[PATCH 01/24] block: Provide bdi_alloc()

From: Jan Kara <jack@suse.cz>
Date: 2017-02-02 17:41:26
Also in: linux-fsdevel
Subsystem: memory management, memory management - misc, the rest · Maintainers: Andrew Morton, David Hildenbrand, Linus Torvalds

Provide bdi_alloc() forsimple allocation of a BDI that can be used by
filesystems that don't need anything fancy. We use this function when
converting filesystems from embedded struct backing_dev_info into a
dynamically allocated one.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/backing-dev.h |  1 +
 mm/backing-dev.c            | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index c52a48cb9a66..81c07ade4305 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -37,6 +37,7 @@ void bdi_unregister(struct backing_dev_info *bdi);
 int __must_check bdi_setup_and_register(struct backing_dev_info *, char *);
 void bdi_destroy(struct backing_dev_info *bdi);
 struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id);
+struct backing_dev_info *bdi_alloc(gfp_t gfp_mask);
 
 void wb_start_writeback(struct bdi_writeback *wb, long nr_pages,
 			bool range_cyclic, enum wb_reason reason);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 28ce6cf7b2ff..7a5ba4163656 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -809,6 +809,21 @@ struct backing_dev_info *bdi_alloc_node(gfp_t gfp_mask, int node_id)
 	return bdi;
 }
 
+struct backing_dev_info *bdi_alloc(gfp_t gfp_mask)
+{
+	struct backing_dev_info *bdi;
+
+	bdi = kmalloc(sizeof(struct backing_dev_info), gfp_mask | __GFP_ZERO);
+	if (!bdi)
+		return NULL;
+	if (bdi_init(bdi)) {
+		kfree(bdi);
+		return NULL;
+	}
+	return bdi;
+}
+EXPORT_SYMBOL(bdi_alloc);
+
 int bdi_register(struct backing_dev_info *bdi, struct device *parent,
 		const char *fmt, ...)
 {
-- 
2.10.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help