-#define __ALLOC_ZERO (1 << 2)
-static inline void *cfs_alloc(size_t nr_bytes, u_int32_t flags)
+
+/*
+ * Universal memory allocator API
+ */
+enum cfs_alloc_flags {
+ /* allocation is not allowed to block */
+ GFP_ATOMIC = 0x1,
+ /* allocation is allowed to block */
+ __GFP_WAIT = 0x2,
+ /* allocation should return zeroed memory */
+ __GFP_ZERO = 0x4,
+ /* allocation is allowed to call file-system code to free/clean
+ * memory */
+ __GFP_FS = 0x8,
+ /* allocation is allowed to do io to free/clean memory */
+ __GFP_IO = 0x10,
+ /* don't report allocation failure to the console */
+ __GFP_NOWARN = 0x20,
+ /* standard allocator flag combination */
+ GFP_IOFS = __GFP_FS | __GFP_IO,
+ GFP_USER = __GFP_WAIT | __GFP_FS | __GFP_IO,
+ GFP_NOFS = __GFP_WAIT | __GFP_IO,
+ GFP_KERNEL = __GFP_WAIT | __GFP_IO | __GFP_FS,
+};
+
+/* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */
+enum cfs_alloc_page_flags {
+ /* allow to return page beyond KVM. It has to be mapped into KVM by
+ * kmap() and unmapped with kunmap(). */
+ __GFP_HIGHMEM = 0x40,
+ GFP_HIGHUSER = __GFP_WAIT | __GFP_FS | __GFP_IO |
+ __GFP_HIGHMEM,
+};
+
+static inline void *kmalloc(size_t nr_bytes, u_int32_t flags)