summaryrefslogtreecommitdiff
path: root/fs/ceph/buffer.h
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2009-12-05 10:13:33 -0800
committerSage Weil <sage@newdream.net>2009-12-07 12:10:04 -0800
commitdd26d857a7bf1b5b734a23180c19eac3e46db944 (patch)
tree24b7ef04c08959df09739056b097ccd157e0251f /fs/ceph/buffer.h
parent2f2ffd35822688a3650e503197b8724f47312748 (diff)
ceph: use kref for ceph_buffer
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/buffer.h')
-rw-r--r--fs/ceph/buffer.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/ceph/buffer.h b/fs/ceph/buffer.h
index 16b1930acc45..3f541a13094f 100644
--- a/fs/ceph/buffer.h
+++ b/fs/ceph/buffer.h
@@ -1,6 +1,7 @@
#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>
@@ -13,7 +14,7 @@
* sizes.
*/
struct ceph_buffer {
- atomic_t nref;
+ struct kref kref;
struct kvec vec;
size_t alloc_len;
bool is_vmalloc;
@@ -24,21 +25,16 @@ int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp);
static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
{
- atomic_inc(&b->nref);
+ kref_get(&b->kref);
return b;
}
+void ceph_buffer_release(struct kref *kref);
+
static inline void ceph_buffer_put(struct ceph_buffer *b)
{
- if (b && atomic_dec_and_test(&b->nref)) {
- if (b->vec.iov_base) {
- if (b->is_vmalloc)
- vfree(b->vec.iov_base);
- else
- kfree(b->vec.iov_base);
- }
- kfree(b);
- }
+ if (b)
+ kref_put(&b->kref, ceph_buffer_release);
}
static inline struct ceph_buffer *ceph_buffer_new_alloc(int len, gfp_t gfp)