X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flinux%2Fkp30.h;h=ff7c36f34a9b230ee99c6c95706cae7e8db5783e;hp=2f9ef67159e2a07f7f8d176268ecec2ce94985a1;hb=f95393b0d0a59cf3dc2f29cffc35dcc4cc9d7728;hpb=421d7a675265d697a1a9308aa9dac8030eab497a diff --git a/libcfs/include/libcfs/linux/kp30.h b/libcfs/include/libcfs/linux/kp30.h index 2f9ef67..ff7c36f 100644 --- a/libcfs/include/libcfs/linux/kp30.h +++ b/libcfs/include/libcfs/linux/kp30.h @@ -16,8 +16,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -76,6 +76,7 @@ # include # include #endif +#include #include @@ -89,12 +90,7 @@ do { \ #define PageUptodate Page_Uptodate #define our_recalc_sigpending(current) recalc_sigpending(current) -#define num_online_cpus() smp_num_cpus -static inline void our_cond_resched(void) -{ - if (current->need_resched) - schedule (); -} +#define cfs_num_online_cpus() smp_num_cpus #define work_struct_t struct tq_struct #define cfs_get_work_data(type,field,data) (data) #else @@ -119,24 +115,29 @@ do { \ #endif +#define cfs_num_online_cpus() num_online_cpus() #define wait_on_page wait_on_page_locked #define our_recalc_sigpending(current) recalc_sigpending() #define strtok(a,b) strpbrk(a, b) -static inline void our_cond_resched(void) -{ - cond_resched(); -} #define work_struct_t struct work_struct #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */ #ifdef CONFIG_SMP #define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock)) +#define LINVRNT_SPIN_LOCKED(lock) LINVRNT(spin_is_locked(lock)) #else -#define LASSERT_SPIN_LOCKED(lock) do {} while(0) +#define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) +#define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0) #endif #define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0) +#ifdef HAVE_SEM_COUNT_ATOMIC +#define SEM_COUNT(sem) (atomic_read(&(sem)->count)) +#else +#define SEM_COUNT(sem) ((sem)->count) +#endif + #define LIBCFS_PANIC(msg) panic(msg) /* ------------------------------------------------------------------- */ @@ -201,7 +202,9 @@ static inline void our_cond_resched(void) # define time(a) CURRENT_TIME #ifndef num_possible_cpus -#define num_possible_cpus() NR_CPUS +#define cfs_num_possible_cpus() NR_CPUS +#else +#define cfs_num_possible_cpus() num_possible_cpus() #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #define i_size_read(a) ((a)->i_size) @@ -246,9 +249,9 @@ typedef struct { # if !KLWT_SUPPORT typedef struct _lwt_page { - struct list_head lwtp_list; - struct page *lwtp_page; - lwt_event_t *lwtp_events; + cfs_list_t lwtp_list; + struct page *lwtp_page; + lwt_event_t *lwtp_events; } lwt_page_t; typedef struct { @@ -283,8 +286,8 @@ do { \ \ if (cpu->lwtc_current_index >= LWT_EVENTS_PER_PAGE) { \ cpu->lwtc_current_page = \ - list_entry (p->lwtp_list.next, \ - lwt_page_t, lwtp_list); \ + cfs_list_entry (p->lwtp_list.next, \ + lwt_page_t, lwtp_list); \ cpu->lwtc_current_index = 0; \ } \ \ @@ -307,7 +310,7 @@ extern void lwt_fini (void); extern int lwt_lookup_string (int *size, char *knlptr, char *usrptr, int usrsize); extern int lwt_control (int enable, int clear); -extern int lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, +extern int lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size, void *user_ptr, int user_size); # else /* __KERNEL__ */ # define LWT_EVENT(p1,p2,p3,p4) /* no userland implementation yet */ @@ -342,29 +345,32 @@ extern int lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, #define _LWORDSIZE BITS_PER_LONG -#if defined(HAVE_U64_LONG_LONG) +#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \ + (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG)) # define LPU64 "%Lu" # define LPD64 "%Ld" # define LPX64 "%#Lx" +# define LPX64i "%Lx" # define LPF64 "L" #else # define LPU64 "%lu" # define LPD64 "%ld" # define LPX64 "%#lx" +# define LPX64i "%lx" # define LPF64 "l" #endif -#ifdef HAVE_SIZE_T_LONG -# define LPSZ "%lu" -#else -# define LPSZ "%u" -#endif +/* + * long_ptr_t & ulong_ptr_t, same to "long" for gcc + */ +# define LPLU "%lu" +# define LPLD "%ld" +# define LPLX "%#lx" -#ifdef HAVE_SSIZE_T_LONG -# define LPSSZ "%ld" -#else -# define LPSSZ "%d" -#endif +/* + * pid_t + */ +# define LPPID "%d" #ifndef LPU64 # error "No word size defined" @@ -372,4 +378,30 @@ extern int lwt_snapshot (cycles_t *now, int *ncpu, int *total_size, #undef _LWORDSIZE +/* compat macroses */ +#ifndef HAVE_SCATTERLIST_SETPAGE +static inline void sg_set_page(struct scatterlist *sg, struct page *page, + unsigned int len, unsigned int offset) +{ + sg->page = page; + sg->offset = offset; + sg->length = len; +} +#endif + +#define cfs_smp_processor_id() smp_processor_id() + +#ifndef get_cpu +# ifdef CONFIG_PREEMPT +# define cfs_get_cpu() ({ preempt_disable(); smp_processor_id(); }) +# define cfs_put_cpu() preempt_enable() +# else +# define cfs_get_cpu() smp_processor_id() +# define cfs_put_cpu() +# endif +#else +# define cfs_get_cpu() get_cpu() +# define cfs_put_cpu() put_cpu() +#endif /* get_cpu & put_cpu */ + #endif