| Sage Weil | 58bb3b3 | 2009-12-23 12:12:31 -0800 | [diff] [blame] | 1 | #ifndef __FS_CEPH_PAGELIST_H | 
|  | 2 | #define __FS_CEPH_PAGELIST_H | 
|  | 3 |  | 
|  | 4 | #include <linux/list.h> | 
|  | 5 |  | 
|  | 6 | struct ceph_pagelist { | 
|  | 7 | struct list_head head; | 
|  | 8 | void *mapped_tail; | 
|  | 9 | size_t length; | 
|  | 10 | size_t room; | 
|  | 11 | }; | 
|  | 12 |  | 
|  | 13 | static inline void ceph_pagelist_init(struct ceph_pagelist *pl) | 
|  | 14 | { | 
|  | 15 | INIT_LIST_HEAD(&pl->head); | 
|  | 16 | pl->mapped_tail = NULL; | 
|  | 17 | pl->length = 0; | 
|  | 18 | pl->room = 0; | 
|  | 19 | } | 
|  | 20 | extern int ceph_pagelist_release(struct ceph_pagelist *pl); | 
|  | 21 |  | 
|  | 22 | extern int ceph_pagelist_append(struct ceph_pagelist *pl, void *d, size_t l); | 
|  | 23 |  | 
|  | 24 | static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v) | 
|  | 25 | { | 
|  | 26 | __le64 ev = cpu_to_le64(v); | 
|  | 27 | return ceph_pagelist_append(pl, &ev, sizeof(ev)); | 
|  | 28 | } | 
|  | 29 | static inline int ceph_pagelist_encode_32(struct ceph_pagelist *pl, u32 v) | 
|  | 30 | { | 
|  | 31 | __le32 ev = cpu_to_le32(v); | 
|  | 32 | return ceph_pagelist_append(pl, &ev, sizeof(ev)); | 
|  | 33 | } | 
|  | 34 | static inline int ceph_pagelist_encode_16(struct ceph_pagelist *pl, u16 v) | 
|  | 35 | { | 
|  | 36 | __le16 ev = cpu_to_le16(v); | 
|  | 37 | return ceph_pagelist_append(pl, &ev, sizeof(ev)); | 
|  | 38 | } | 
|  | 39 | static inline int ceph_pagelist_encode_8(struct ceph_pagelist *pl, u8 v) | 
|  | 40 | { | 
|  | 41 | return ceph_pagelist_append(pl, &v, 1); | 
|  | 42 | } | 
|  | 43 | static inline int ceph_pagelist_encode_string(struct ceph_pagelist *pl, | 
|  | 44 | char *s, size_t len) | 
|  | 45 | { | 
|  | 46 | int ret = ceph_pagelist_encode_32(pl, len); | 
|  | 47 | if (ret) | 
|  | 48 | return ret; | 
|  | 49 | if (len) | 
|  | 50 | return ceph_pagelist_append(pl, s, len); | 
|  | 51 | return 0; | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | #endif |