Lines Matching refs:pl

11 	struct ceph_pagelist *pl;  in ceph_pagelist_alloc()  local
13 pl = kmalloc(sizeof(*pl), gfp_flags); in ceph_pagelist_alloc()
14 if (!pl) in ceph_pagelist_alloc()
17 INIT_LIST_HEAD(&pl->head); in ceph_pagelist_alloc()
18 pl->mapped_tail = NULL; in ceph_pagelist_alloc()
19 pl->length = 0; in ceph_pagelist_alloc()
20 pl->room = 0; in ceph_pagelist_alloc()
21 INIT_LIST_HEAD(&pl->free_list); in ceph_pagelist_alloc()
22 pl->num_pages_free = 0; in ceph_pagelist_alloc()
23 refcount_set(&pl->refcnt, 1); in ceph_pagelist_alloc()
25 return pl; in ceph_pagelist_alloc()
29 static void ceph_pagelist_unmap_tail(struct ceph_pagelist *pl) in ceph_pagelist_unmap_tail() argument
31 if (pl->mapped_tail) { in ceph_pagelist_unmap_tail()
32 struct page *page = list_entry(pl->head.prev, struct page, lru); in ceph_pagelist_unmap_tail()
34 pl->mapped_tail = NULL; in ceph_pagelist_unmap_tail()
38 void ceph_pagelist_release(struct ceph_pagelist *pl) in ceph_pagelist_release() argument
40 if (!refcount_dec_and_test(&pl->refcnt)) in ceph_pagelist_release()
42 ceph_pagelist_unmap_tail(pl); in ceph_pagelist_release()
43 while (!list_empty(&pl->head)) { in ceph_pagelist_release()
44 struct page *page = list_first_entry(&pl->head, struct page, in ceph_pagelist_release()
49 ceph_pagelist_free_reserve(pl); in ceph_pagelist_release()
50 kfree(pl); in ceph_pagelist_release()
54 static int ceph_pagelist_addpage(struct ceph_pagelist *pl) in ceph_pagelist_addpage() argument
58 if (!pl->num_pages_free) { in ceph_pagelist_addpage()
61 page = list_first_entry(&pl->free_list, struct page, lru); in ceph_pagelist_addpage()
63 --pl->num_pages_free; in ceph_pagelist_addpage()
67 pl->room += PAGE_SIZE; in ceph_pagelist_addpage()
68 ceph_pagelist_unmap_tail(pl); in ceph_pagelist_addpage()
69 list_add_tail(&page->lru, &pl->head); in ceph_pagelist_addpage()
70 pl->mapped_tail = kmap(page); in ceph_pagelist_addpage()
74 int ceph_pagelist_append(struct ceph_pagelist *pl, const void *buf, size_t len) in ceph_pagelist_append() argument
76 while (pl->room < len) { in ceph_pagelist_append()
77 size_t bit = pl->room; in ceph_pagelist_append()
80 memcpy(pl->mapped_tail + (pl->length & ~PAGE_MASK), in ceph_pagelist_append()
82 pl->length += bit; in ceph_pagelist_append()
83 pl->room -= bit; in ceph_pagelist_append()
86 ret = ceph_pagelist_addpage(pl); in ceph_pagelist_append()
91 memcpy(pl->mapped_tail + (pl->length & ~PAGE_MASK), buf, len); in ceph_pagelist_append()
92 pl->length += len; in ceph_pagelist_append()
93 pl->room -= len; in ceph_pagelist_append()
102 int ceph_pagelist_reserve(struct ceph_pagelist *pl, size_t space) in ceph_pagelist_reserve() argument
104 if (space <= pl->room) in ceph_pagelist_reserve()
106 space -= pl->room; in ceph_pagelist_reserve()
109 while (space > pl->num_pages_free) { in ceph_pagelist_reserve()
113 list_add_tail(&page->lru, &pl->free_list); in ceph_pagelist_reserve()
114 ++pl->num_pages_free; in ceph_pagelist_reserve()
121 int ceph_pagelist_free_reserve(struct ceph_pagelist *pl) in ceph_pagelist_free_reserve() argument
123 while (!list_empty(&pl->free_list)) { in ceph_pagelist_free_reserve()
124 struct page *page = list_first_entry(&pl->free_list, in ceph_pagelist_free_reserve()
128 --pl->num_pages_free; in ceph_pagelist_free_reserve()
130 BUG_ON(pl->num_pages_free); in ceph_pagelist_free_reserve()
136 void ceph_pagelist_set_cursor(struct ceph_pagelist *pl, in ceph_pagelist_set_cursor() argument
139 c->pl = pl; in ceph_pagelist_set_cursor()
140 c->page_lru = pl->head.prev; in ceph_pagelist_set_cursor()
141 c->room = pl->room; in ceph_pagelist_set_cursor()
150 int ceph_pagelist_truncate(struct ceph_pagelist *pl, in ceph_pagelist_truncate() argument
155 if (pl != c->pl) in ceph_pagelist_truncate()
157 ceph_pagelist_unmap_tail(pl); in ceph_pagelist_truncate()
158 while (pl->head.prev != c->page_lru) { in ceph_pagelist_truncate()
159 page = list_entry(pl->head.prev, struct page, lru); in ceph_pagelist_truncate()
161 list_move_tail(&page->lru, &pl->free_list); in ceph_pagelist_truncate()
162 ++pl->num_pages_free; in ceph_pagelist_truncate()
164 pl->room = c->room; in ceph_pagelist_truncate()
165 if (!list_empty(&pl->head)) { in ceph_pagelist_truncate()
166 page = list_entry(pl->head.prev, struct page, lru); in ceph_pagelist_truncate()
167 pl->mapped_tail = kmap(page); in ceph_pagelist_truncate()