2009-10-07 01:31:07 +07:00
|
|
|
#ifndef __FS_CEPH_BUFFER_H
|
|
|
|
#define __FS_CEPH_BUFFER_H
|
|
|
|
|
2009-12-06 01:13:33 +07:00
|
|
|
#include <linux/kref.h>
|
2009-10-07 01:31:07 +07:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* a simple reference counted buffer.
|
|
|
|
*
|
2014-10-23 19:32:57 +07:00
|
|
|
* use kmalloc for smaller sizes, vmalloc for larger sizes.
|
2009-10-07 01:31:07 +07:00
|
|
|
*/
|
|
|
|
struct ceph_buffer {
|
2009-12-06 01:13:33 +07:00
|
|
|
struct kref kref;
|
2009-10-07 01:31:07 +07:00
|
|
|
struct kvec vec;
|
|
|
|
size_t alloc_len;
|
|
|
|
};
|
|
|
|
|
2009-12-08 03:17:17 +07:00
|
|
|
extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
|
|
|
|
extern void ceph_buffer_release(struct kref *kref);
|
2009-10-07 01:31:07 +07:00
|
|
|
|
|
|
|
static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
|
|
|
|
{
|
2009-12-06 01:13:33 +07:00
|
|
|
kref_get(&b->kref);
|
2009-10-07 01:31:07 +07:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ceph_buffer_put(struct ceph_buffer *b)
|
|
|
|
{
|
2009-12-08 03:17:17 +07:00
|
|
|
kref_put(&b->kref, ceph_buffer_release);
|
2009-10-07 01:31:07 +07:00
|
|
|
}
|
|
|
|
|
2010-02-03 07:11:19 +07:00
|
|
|
extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
|
|
|
|
|
2009-10-07 01:31:07 +07:00
|
|
|
#endif
|