aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/ceph/pagelist.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2018-09-28 15:38:34 +0200
committerIlya Dryomov <idryomov@gmail.com>2018-10-22 10:28:21 +0200
commit33165d472310262d8c79c7e4d1a17dc60cea7e35 (patch)
treebf498d59251d10a2f8c603ef28200d7d42d6bee4 /net/ceph/pagelist.c
parentlibceph: osd_req_op_cls_init() doesn't need to take opcode (diff)
downloadwireguard-linux-33165d472310262d8c79c7e4d1a17dc60cea7e35.tar.xz
wireguard-linux-33165d472310262d8c79c7e4d1a17dc60cea7e35.zip
libceph: introduce ceph_pagelist_alloc()
struct ceph_pagelist cannot be embedded into anything else because it has its own refcount. Merge allocation and initialization together. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph/pagelist.c')
-rw-r--r--net/ceph/pagelist.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/ceph/pagelist.c b/net/ceph/pagelist.c
index 2ea0564771d2..65e34f78b05d 100644
--- a/net/ceph/pagelist.c
+++ b/net/ceph/pagelist.c
@@ -6,6 +6,26 @@
#include <linux/highmem.h>
#include <linux/ceph/pagelist.h>
+struct ceph_pagelist *ceph_pagelist_alloc(gfp_t gfp_flags)
+{
+ struct ceph_pagelist *pl;
+
+ pl = kmalloc(sizeof(*pl), gfp_flags);
+ if (!pl)
+ return NULL;
+
+ INIT_LIST_HEAD(&pl->head);
+ pl->mapped_tail = NULL;
+ pl->length = 0;
+ pl->room = 0;
+ INIT_LIST_HEAD(&pl->free_list);
+ pl->num_pages_free = 0;
+ refcount_set(&pl->refcnt, 1);
+
+ return pl;
+}
+EXPORT_SYMBOL(ceph_pagelist_alloc);
+
static void ceph_pagelist_unmap_tail(struct ceph_pagelist *pl)
{
if (pl->mapped_tail) {