]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - net/ceph/pagelist.c
2 #include <linux/module.h>
4 #include <linux/pagemap.h>
5 #include <linux/highmem.h>
6 #include <linux/ceph/pagelist.h>
8 static void ceph_pagelist_unmap_tail(struct ceph_pagelist
*pl
)
10 struct page
*page
= list_entry(pl
->head
.prev
, struct page
,
15 int ceph_pagelist_release(struct ceph_pagelist
*pl
)
18 ceph_pagelist_unmap_tail(pl
);
20 while (!list_empty(&pl
->head
)) {
21 struct page
*page
= list_first_entry(&pl
->head
, struct page
,
28 EXPORT_SYMBOL(ceph_pagelist_release
);
30 static int ceph_pagelist_addpage(struct ceph_pagelist
*pl
)
32 struct page
*page
= __page_cache_alloc(GFP_NOFS
);
35 pl
->room
+= PAGE_SIZE
;
36 list_add_tail(&page
->lru
, &pl
->head
);
38 ceph_pagelist_unmap_tail(pl
);
39 pl
->mapped_tail
= kmap(page
);
43 int ceph_pagelist_append(struct ceph_pagelist
*pl
, const void *buf
, size_t len
)
45 while (pl
->room
< len
) {
46 size_t bit
= pl
->room
;
49 memcpy(pl
->mapped_tail
+ (pl
->length
& ~PAGE_CACHE_MASK
),
55 ret
= ceph_pagelist_addpage(pl
);
60 memcpy(pl
->mapped_tail
+ (pl
->length
& ~PAGE_CACHE_MASK
), buf
, len
);
65 EXPORT_SYMBOL(ceph_pagelist_append
);