buffer.h 818 字节
Newer Older
S
Sage Weil 已提交
1 2 3
#ifndef __FS_CEPH_BUFFER_H
#define __FS_CEPH_BUFFER_H

S
Sage Weil 已提交
4
#include <linux/kref.h>
S
Sage Weil 已提交
5 6 7 8 9 10 11 12 13 14 15 16
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/types.h>
#include <linux/uio.h>

/*
 * a simple reference counted buffer.
 *
 * use kmalloc for small sizes (<= one page), vmalloc for larger
 * sizes.
 */
struct ceph_buffer {
S
Sage Weil 已提交
17
	struct kref kref;
S
Sage Weil 已提交
18 19 20 21 22
	struct kvec vec;
	size_t alloc_len;
	bool is_vmalloc;
};

S
Sage Weil 已提交
23 24
extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
extern void ceph_buffer_release(struct kref *kref);
S
Sage Weil 已提交
25 26 27

static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
{
S
Sage Weil 已提交
28
	kref_get(&b->kref);
S
Sage Weil 已提交
29 30 31 32 33
	return b;
}

static inline void ceph_buffer_put(struct ceph_buffer *b)
{
S
Sage Weil 已提交
34
	kref_put(&b->kref, ceph_buffer_release);
S
Sage Weil 已提交
35 36
}

S
Sage Weil 已提交
37 38
extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);

S
Sage Weil 已提交
39
#endif