Loading fs/ceph/buffer.c +13 −1 Original line number Diff line number Diff line Loading @@ -9,13 +9,25 @@ struct ceph_buffer *ceph_buffer_new(gfp_t gfp) b = kmalloc(sizeof(*b), gfp); if (!b) return NULL; atomic_set(&b->nref, 1); kref_init(&b->kref); b->vec.iov_base = NULL; b->vec.iov_len = 0; b->alloc_len = 0; return b; } void ceph_buffer_release(struct kref *kref) { struct ceph_buffer *b = container_of(kref, struct ceph_buffer, kref); if (b->vec.iov_base) { if (b->is_vmalloc) vfree(b->vec.iov_base); else kfree(b->vec.iov_base); } kfree(b); } int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp) { b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN); Loading fs/ceph/buffer.h +7 −11 Original line number Diff line number Diff line #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> Loading @@ -13,7 +14,7 @@ * sizes. */ struct ceph_buffer { atomic_t nref; struct kref kref; struct kvec vec; size_t alloc_len; bool is_vmalloc; Loading @@ -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) Loading Loading
fs/ceph/buffer.c +13 −1 Original line number Diff line number Diff line Loading @@ -9,13 +9,25 @@ struct ceph_buffer *ceph_buffer_new(gfp_t gfp) b = kmalloc(sizeof(*b), gfp); if (!b) return NULL; atomic_set(&b->nref, 1); kref_init(&b->kref); b->vec.iov_base = NULL; b->vec.iov_len = 0; b->alloc_len = 0; return b; } void ceph_buffer_release(struct kref *kref) { struct ceph_buffer *b = container_of(kref, struct ceph_buffer, kref); if (b->vec.iov_base) { if (b->is_vmalloc) vfree(b->vec.iov_base); else kfree(b->vec.iov_base); } kfree(b); } int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp) { b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN); Loading
fs/ceph/buffer.h +7 −11 Original line number Diff line number Diff line #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> Loading @@ -13,7 +14,7 @@ * sizes. */ struct ceph_buffer { atomic_t nref; struct kref kref; struct kvec vec; size_t alloc_len; bool is_vmalloc; Loading @@ -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) Loading