File Index
Files and directories
Sign in
FILE

pagelist.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/ceph/pagelist.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __FS_CEPH_PAGELIST_H
 3#define __FS_CEPH_PAGELIST_H
 4
 5#include <asm/byteorder.h>
 6#include <linux/refcount.h>
 7#include <linux/list.h>
 8#include <linux/types.h>
 9
10struct ceph_pagelist {
11	struct list_head head;
12	void *mapped_tail;
13	size_t length;
14	size_t room;
15	struct list_head free_list;
16	size_t num_pages_free;
17	refcount_t refcnt;
18};
19
20struct ceph_pagelist *ceph_pagelist_alloc(gfp_t gfp_flags);
21
22extern void ceph_pagelist_release(struct ceph_pagelist *pl);
23
24extern int ceph_pagelist_append(struct ceph_pagelist *pl, const void *d, size_t l);
25
26extern int ceph_pagelist_reserve(struct ceph_pagelist *pl, size_t space);
27
28extern int ceph_pagelist_free_reserve(struct ceph_pagelist *pl);
29
30static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v)
31{
32	__le64 ev = cpu_to_le64(v);
33	return ceph_pagelist_append(pl, &ev, sizeof(ev));
34}
35static inline int ceph_pagelist_encode_32(struct ceph_pagelist *pl, u32 v)
36{
37	__le32 ev = cpu_to_le32(v);
38	return ceph_pagelist_append(pl, &ev, sizeof(ev));
39}
40static inline int ceph_pagelist_encode_16(struct ceph_pagelist *pl, u16 v)
41{
42	__le16 ev = cpu_to_le16(v);
43	return ceph_pagelist_append(pl, &ev, sizeof(ev));
44}
45static inline int ceph_pagelist_encode_8(struct ceph_pagelist *pl, u8 v)
46{
47	return ceph_pagelist_append(pl, &v, 1);
48}
49static inline int ceph_pagelist_encode_string(struct ceph_pagelist *pl,
50					      char *s, u32 len)
51{
52	int ret = ceph_pagelist_encode_32(pl, len);
53	if (ret)
54		return ret;
55	if (len)
56		return ceph_pagelist_append(pl, s, len);
57	return 0;
58}
59
60#endif
~/ Read-only file preview.