mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 00:21:32 +00:00
b6c1d5b81e
We never allocate the ceph_buffer and buffer separtely, so use a single constructor. Disallow put on NULL buffer; make the caller check. Signed-off-by: Sage Weil <sage@newdream.net>
38 lines
741 B
C
38 lines
741 B
C
#ifndef __FS_CEPH_BUFFER_H
|
|
#define __FS_CEPH_BUFFER_H
|
|
|
|
#include <linux/kref.h>
|
|
#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 {
|
|
struct kref kref;
|
|
struct kvec vec;
|
|
size_t alloc_len;
|
|
bool is_vmalloc;
|
|
};
|
|
|
|
extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
|
|
extern void ceph_buffer_release(struct kref *kref);
|
|
|
|
static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
|
|
{
|
|
kref_get(&b->kref);
|
|
return b;
|
|
}
|
|
|
|
static inline void ceph_buffer_put(struct ceph_buffer *b)
|
|
{
|
|
kref_put(&b->kref, ceph_buffer_release);
|
|
}
|
|
|
|
#endif
|