From 6cf7362917e52632a6df34700c8578412d94cc86 Mon Sep 17 00:00:00 2001 From: bobijam Date: Thu, 2 Aug 2007 02:26:30 +0000 Subject: [PATCH] Branch:b1_6 b=12606 i=shadow, nikita Description: don't use GFP_* in generic Lustre code. Details : Use cfs_alloc_* functions and CFS_* flags for code portability. --- lnet/include/libcfs/libcfs.h | 14 +++++++------- lnet/include/libcfs/linux/linux-mem.h | 10 +++++++--- lnet/libcfs/linux/linux-mem.c | 14 +++++++++++--- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h index 188924e..88f1a37 100644 --- a/lnet/include/libcfs/libcfs.h +++ b/lnet/include/libcfs/libcfs.h @@ -546,18 +546,18 @@ static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout) */ enum cfs_alloc_flags { /* allocation is not allowed to block */ - CFS_ALLOC_ATOMIC = (1 << 0), + CFS_ALLOC_ATOMIC = 0x1, /* allocation is allowed to block */ - CFS_ALLOC_WAIT = (1 << 1), + CFS_ALLOC_WAIT = 0x2, /* allocation should return zeroed memory */ - CFS_ALLOC_ZERO = (1 << 2), + CFS_ALLOC_ZERO = 0x4, /* allocation is allowed to call file-system code to free/clean * memory */ - CFS_ALLOC_FS = (1 << 3), + CFS_ALLOC_FS = 0x8, /* allocation is allowed to do io to free/clean memory */ - CFS_ALLOC_IO = (1 << 4), + CFS_ALLOC_IO = 0x10, /* don't report allocation failure to the console */ - CFS_ALLOC_NOWARN = (1 << 5), + CFS_ALLOC_NOWARN = 0x20, /* standard allocator flag combination */ CFS_ALLOC_STD = CFS_ALLOC_FS | CFS_ALLOC_IO, CFS_ALLOC_USER = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO, @@ -567,7 +567,7 @@ enum cfs_alloc_flags { enum cfs_alloc_page_flags { /* allow to return page beyond KVM. It has to be mapped into KVM by * cfs_page_map(); */ - CFS_ALLOC_HIGH = (1 << 5), + CFS_ALLOC_HIGH = 0x40, CFS_ALLOC_HIGHUSER = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO | CFS_ALLOC_HIGH, }; diff --git a/lnet/include/libcfs/linux/linux-mem.h b/lnet/include/libcfs/linux/linux-mem.h index 9a49dda..4f19edd 100644 --- a/lnet/include/libcfs/linux/linux-mem.h +++ b/lnet/include/libcfs/linux/linux-mem.h @@ -43,9 +43,6 @@ typedef struct page cfs_page_t; #define CFS_PAGE_SHIFT PAGE_CACHE_SHIFT #define CFS_PAGE_MASK (~((__u64)CFS_PAGE_SIZE-1)) -cfs_page_t *cfs_alloc_page(unsigned int flags); -#define cfs_free_page(p) __free_pages(p, 0) - static inline void *cfs_page_address(cfs_page_t *page) { /* @@ -87,6 +84,13 @@ extern void cfs_free(void *addr); extern void *cfs_alloc_large(size_t nr_bytes); extern void cfs_free_large(void *addr); +extern cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order); +extern void __cfs_free_pages(cfs_page_t *page, unsigned int order); + +#define cfs_alloc_page(flags) cfs_alloc_pages(flags, 0) +#define __cfs_free_page(page) __cfs_free_pages(page, 0) +#define cfs_free_page(p) __free_pages(p, 0) + /* * In Linux there is no way to determine whether current execution context is * blockable. diff --git a/lnet/libcfs/linux/linux-mem.c b/lnet/libcfs/linux/linux-mem.c index f327814..fc3896a 100644 --- a/lnet/libcfs/linux/linux-mem.c +++ b/lnet/libcfs/linux/linux-mem.c @@ -51,6 +51,8 @@ static unsigned int cfs_alloc_flags_to_gfp(u_int32_t flags) #endif if (flags & CFS_ALLOC_FS) mflags |= __GFP_FS; + if (flags & CFS_ALLOC_HIGH) + mflags |= __GFP_HIGH; return mflags; } @@ -83,13 +85,18 @@ cfs_free_large(void *addr) vfree(addr); } -cfs_page_t *cfs_alloc_page(unsigned int flags) +cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order) { /* * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT) * from here: this will lead to infinite recursion. */ - return alloc_pages(cfs_alloc_flags_to_gfp(flags), 0); + return alloc_pages(cfs_alloc_flags_to_gfp(flags), order); +} + +void __cfs_free_pages(cfs_page_t *page, unsigned int order) +{ + __free_pages(page, order); } cfs_mem_cache_t * @@ -126,7 +133,8 @@ EXPORT_SYMBOL(cfs_alloc); EXPORT_SYMBOL(cfs_free); EXPORT_SYMBOL(cfs_alloc_large); EXPORT_SYMBOL(cfs_free_large); -EXPORT_SYMBOL(cfs_alloc_page); +EXPORT_SYMBOL(cfs_alloc_pages); +EXPORT_SYMBOL(__cfs_free_pages); EXPORT_SYMBOL(cfs_mem_cache_create); EXPORT_SYMBOL(cfs_mem_cache_destroy); EXPORT_SYMBOL(cfs_mem_cache_alloc); -- 1.8.3.1