]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/ceph/pagelist.h
1 #ifndef __FS_CEPH_PAGELIST_H
2 #define __FS_CEPH_PAGELIST_H
4 #include <asm/byteorder.h>
5 #include <linux/atomic.h>
6 #include <linux/list.h>
7 #include <linux/types.h>
10 struct list_head head
;
14 struct list_head free_list
;
15 size_t num_pages_free
;
19 struct ceph_pagelist_cursor
{
20 struct ceph_pagelist
*pl
; /* pagelist, for error checking */
21 struct list_head
*page_lru
; /* page in list */
22 size_t room
; /* room remaining to reset to */
25 static inline void ceph_pagelist_init(struct ceph_pagelist
*pl
)
27 INIT_LIST_HEAD(&pl
->head
);
28 pl
->mapped_tail
= NULL
;
31 INIT_LIST_HEAD(&pl
->free_list
);
32 pl
->num_pages_free
= 0;
33 atomic_set(&pl
->refcnt
, 1);
36 extern void ceph_pagelist_release(struct ceph_pagelist
*pl
);
38 extern int ceph_pagelist_append(struct ceph_pagelist
*pl
, const void *d
, size_t l
);
40 extern int ceph_pagelist_reserve(struct ceph_pagelist
*pl
, size_t space
);
42 extern int ceph_pagelist_free_reserve(struct ceph_pagelist
*pl
);
44 extern void ceph_pagelist_set_cursor(struct ceph_pagelist
*pl
,
45 struct ceph_pagelist_cursor
*c
);
47 extern int ceph_pagelist_truncate(struct ceph_pagelist
*pl
,
48 struct ceph_pagelist_cursor
*c
);
50 static inline int ceph_pagelist_encode_64(struct ceph_pagelist
*pl
, u64 v
)
52 __le64 ev
= cpu_to_le64(v
);
53 return ceph_pagelist_append(pl
, &ev
, sizeof(ev
));
55 static inline int ceph_pagelist_encode_32(struct ceph_pagelist
*pl
, u32 v
)
57 __le32 ev
= cpu_to_le32(v
);
58 return ceph_pagelist_append(pl
, &ev
, sizeof(ev
));
60 static inline int ceph_pagelist_encode_16(struct ceph_pagelist
*pl
, u16 v
)
62 __le16 ev
= cpu_to_le16(v
);
63 return ceph_pagelist_append(pl
, &ev
, sizeof(ev
));
65 static inline int ceph_pagelist_encode_8(struct ceph_pagelist
*pl
, u8 v
)
67 return ceph_pagelist_append(pl
, &v
, 1);
69 static inline int ceph_pagelist_encode_string(struct ceph_pagelist
*pl
,
72 int ret
= ceph_pagelist_encode_32(pl
, len
);
76 return ceph_pagelist_append(pl
, s
, len
);