1 #ifndef __LIBCFS_USER_MEM_H__
2 #define __LIBCFS_USER_MEM_H__
4 #ifndef __LIBCFS_LIBCFS_H__
5 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
9 #error "This is only for user space."
14 * for this moment, liblusre will not rely OST for non-page-aligned write
16 #define LIBLUSTRE_HANDLE_UNALIGNED_PAGE
21 struct list_head list;
22 unsigned long private;
24 /* internally used by liblustre file i/o */
27 #ifdef LIBLUSTRE_HANDLE_UNALIGNED_PAGE
30 struct list_head _node;
35 #define CFS_PAGE_SHIFT 12
36 #define CFS_PAGE_SIZE (1UL << CFS_PAGE_SHIFT)
37 #define CFS_PAGE_MASK (~((__u64)CFS_PAGE_SIZE-1))
39 cfs_page_t *cfs_alloc_pages(int mask, unsigned long order);
40 void cfs_free_pages(cfs_page_t *pg, int what);
41 cfs_page_t *cfs_alloc_page(unsigned int flags);
42 void cfs_free_page(cfs_page_t *pg);
43 void *cfs_page_address(cfs_page_t *pg);
44 void *cfs_kmap(cfs_page_t *pg);
45 void cfs_kunmap(cfs_page_t *pg);
47 #define __cfs_free_pages(pg, what) cfs_free_pages((pg), (what))
49 #define cfs_get_page(p) __I_should_not_be_called__(at_all)
50 #define cfs_page_count(p) __I_should_not_be_called__(at_all)
51 #define cfs_page_index(p) ((p)->index)
55 * Inline function, so utils can use them without linking of libcfs
57 #define __ALLOC_ZERO (1 << 2)
58 static inline void *cfs_alloc(size_t nr_bytes, u_int32_t flags)
62 result = malloc(nr_bytes);
63 if (result != NULL && (flags & __ALLOC_ZERO))
64 memset(result, 0, nr_bytes);
68 #define cfs_free(addr) free(addr)
69 #define cfs_alloc_large(nr_bytes) cfs_alloc(nr_bytes, 0)
70 #define cfs_free_large(addr) cfs_free(addr)
72 #define CFS_ALLOC_ATOMIC_TRY (0)
80 #define SLAB_HWCACHE_ALIGN 0
85 cfs_mem_cache_create(const char *, size_t, size_t, unsigned long);
86 int cfs_mem_cache_destroy(cfs_mem_cache_t *c);
87 void *cfs_mem_cache_alloc(cfs_mem_cache_t *c, int gfp);
88 void cfs_mem_cache_free(cfs_mem_cache_t *c, void *addr);
93 static inline int copy_from_user(void *a,void *b, int c)
99 static inline int copy_to_user(void *a,void *b, int c)