aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ceph
diff options
context:
space:
mode:
authorGreg Farnum <gregf@hq.newdream.net>2010-09-17 13:10:55 -0400
committerSage Weil <sage@newdream.net>2010-10-20 18:38:16 -0400
commitac0b74d8a1ced8ea86147467daf06b15b130dd94 (patch)
treea71aec65be7f71b42ae78907acd5b0f4aeafd3a9 /include/linux/ceph
parent18a38193efcaac1fb3c94ad8fa04bb117850a3c2 (diff)
ceph: add pagelist_reserve, pagelist_truncate, pagelist_set_cursor
These facilitate preallocation of pages so that we can encode into the pagelist in an atomic context. Signed-off-by: Greg Farnum <gregf@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'include/linux/ceph')
-rw-r--r--include/linux/ceph/pagelist.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/ceph/pagelist.h b/include/linux/ceph/pagelist.h
index cc9327aa1c9..9660d6b0a35 100644
--- a/include/linux/ceph/pagelist.h
+++ b/include/linux/ceph/pagelist.h
@@ -8,6 +8,14 @@ struct ceph_pagelist {
8 void *mapped_tail; 8 void *mapped_tail;
9 size_t length; 9 size_t length;
10 size_t room; 10 size_t room;
11 struct list_head free_list;
12 size_t num_pages_free;
13};
14
15struct ceph_pagelist_cursor {
16 struct ceph_pagelist *pl; /* pagelist, for error checking */
17 struct list_head *page_lru; /* page in list */
18 size_t room; /* room remaining to reset to */
11}; 19};
12 20
13static inline void ceph_pagelist_init(struct ceph_pagelist *pl) 21static inline void ceph_pagelist_init(struct ceph_pagelist *pl)
@@ -16,11 +24,24 @@ static inline void ceph_pagelist_init(struct ceph_pagelist *pl)
16 pl->mapped_tail = NULL; 24 pl->mapped_tail = NULL;
17 pl->length = 0; 25 pl->length = 0;
18 pl->room = 0; 26 pl->room = 0;
27 INIT_LIST_HEAD(&pl->free_list);
28 pl->num_pages_free = 0;
19} 29}
30
20extern int ceph_pagelist_release(struct ceph_pagelist *pl); 31extern int ceph_pagelist_release(struct ceph_pagelist *pl);
21 32
22extern int ceph_pagelist_append(struct ceph_pagelist *pl, const void *d, size_t l); 33extern int ceph_pagelist_append(struct ceph_pagelist *pl, const void *d, size_t l);
23 34
35extern int ceph_pagelist_reserve(struct ceph_pagelist *pl, size_t space);
36
37extern int ceph_pagelist_free_reserve(struct ceph_pagelist *pl);
38
39extern void ceph_pagelist_set_cursor(struct ceph_pagelist *pl,
40 struct ceph_pagelist_cursor *c);
41
42extern int ceph_pagelist_truncate(struct ceph_pagelist *pl,
43 struct ceph_pagelist_cursor *c);
44
24static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v) 45static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v)
25{ 46{
26 __le64 ev = cpu_to_le64(v); 47 __le64 ev = cpu_to_le64(v);