USB: io_ti: check firmware version before updating
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / ceph / pagelist.c
blob5f8dbf7c745a7c7a1864ff97cd646a497a9e08e6
2 #include <linux/gfp.h>
3 #include <linux/pagemap.h>
4 #include <linux/highmem.h>
6 #include "pagelist.h"
8 int ceph_pagelist_release(struct ceph_pagelist *pl)
10 if (pl->mapped_tail)
11 kunmap(pl->mapped_tail);
12 while (!list_empty(&pl->head)) {
13 struct page *page = list_first_entry(&pl->head, struct page,
14 lru);
15 list_del(&page->lru);
16 __free_page(page);
18 return 0;
21 static int ceph_pagelist_addpage(struct ceph_pagelist *pl)
23 struct page *page = alloc_page(GFP_NOFS);
24 if (!page)
25 return -ENOMEM;
26 pl->room += PAGE_SIZE;
27 list_add_tail(&page->lru, &pl->head);
28 if (pl->mapped_tail)
29 kunmap(pl->mapped_tail);
30 pl->mapped_tail = kmap(page);
31 return 0;
34 int ceph_pagelist_append(struct ceph_pagelist *pl, void *buf, size_t len)
36 while (pl->room < len) {
37 size_t bit = pl->room;
38 int ret;
40 memcpy(pl->mapped_tail + (pl->length & ~PAGE_CACHE_MASK),
41 buf, bit);
42 pl->length += bit;
43 pl->room -= bit;
44 buf += bit;
45 len -= bit;
46 ret = ceph_pagelist_addpage(pl);
47 if (ret)
48 return ret;
51 memcpy(pl->mapped_tail + (pl->length & ~PAGE_CACHE_MASK), buf, len);
52 pl->length += len;
53 pl->room -= len;
54 return 0;