xfs: Check new inode size is OK before preallocating
[safe/jmp/linux-2.6] / fs / ceph / buffer.h
index 16b1930..58d1901 100644 (file)
@@ -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>
  * sizes.
  */
 struct ceph_buffer {
-       atomic_t nref;
+       struct kref kref;
        struct kvec vec;
        size_t alloc_len;
        bool is_vmalloc;
 };
 
-struct ceph_buffer *ceph_buffer_new(gfp_t gfp);
-int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp);
+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)
 {
-       atomic_inc(&b->nref);
+       kref_get(&b->kref);
        return b;
 }
 
 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);
-       }
+       kref_put(&b->kref, ceph_buffer_release);
 }
 
-static inline struct ceph_buffer *ceph_buffer_new_alloc(int len, gfp_t gfp)
-{
-       struct ceph_buffer *b = ceph_buffer_new(gfp);
-
-       if (b && ceph_buffer_alloc(b, len, gfp) < 0) {
-               ceph_buffer_put(b);
-               b = NULL;
-       }
-       return b;
-}
+extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
 
 #endif