/*************************************************************************** * * Copyright (C) 2001 International Business Machines * All rights reserved. * * This file is part of the GPFS mmfslinux kernel module. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************** */ /* @(#)41 1.57.1.5 src/avs/fs/mmfs/ts/kernext/gpl-linux/verdep.h, mmfs, avs_rgpfs24, rgpfs24s008a 11/10/06 11:47:24 */ #ifndef _h_verdep #define _h_verdep #if (LINUX_KERNEL_VERSION >= 2060000) /************************************ * Linux 2.6 functional differences * ************************************/ # include # include # include # include # include # include # include # include # include # include # include # include # include /* Inode state indicators. SLES9 2.6.5-7.244+ kernels and SLES10 kernels require truncate_inode_pages to be called from the delete_inode sop and check for I_WILL_FREE flag, RHEL4 kernels do not (thus far). */ # if defined(SUSE_LINUX) && \ ((LINUX_KERNEL_VERSION == 2060507 && \ SUSE_LINUX_UPDATE_SUBLEVEL >= 24400000000) || \ LINUX_KERNEL_VERSION > 2060507) # define INODE_BEING_RELEASED (I_FREEING|I_CLEAR|I_WILL_FREE) # define INODE_IN_CACHE (I_FREEING|I_CLEAR|I_LOCK|I_NEW|I_WILL_FREE) /* required if file system defines delete_inode */ # define MUST_TRUNCATE_INODE_PAGES 1 # else # define INODE_BEING_RELEASED (I_FREEING|I_CLEAR) # define INODE_IN_CACHE (I_FREEING|I_CLEAR|I_LOCK|I_NEW) # define MUST_TRUNCATE_INODE_PAGES 0 # endif /* Retrieve a new empty inode from the vfs */ # define NEW_INODE(SUPER) new_inode(SUPER) /* Uncache a directory entry. Must hold dcache lock. */ # define DENTRY_DROP(DP) \ { \ spin_lock(&(DP)->d_lock); \ __d_drop(DP); \ spin_unlock(&(DP)->d_lock); \ } /* Uncache a directory entry. Must hold *NO* locks. */ /* __d_drop checks state of DCACHE_UNHASHED prior to drop. */ # define DENTRY_D_DROP(DP) \ { \ spin_lock(&dcache_lock); \ spin_lock(&(DP)->d_lock); \ __d_drop(DP); \ spin_unlock(&(DP)->d_lock); \ spin_unlock(&dcache_lock); \ } /* Check if directory is already uncached. Must hold dcache lock. */ # define DENTRY_UNHASHED(DP) d_unhashed(DP) /* Mark buffer in error and call iodone routine */ # define BUFHEAD_ERROR_IODONE(BH) \ { \ clear_buffer_uptodate(BH); \ (BHP)->b_end_io((BH), 0); \ } #if LINUX_KERNEL_VERSION >= 2061300 || \ (LINUX_KERNEL_VERSION == 2060507 && defined(SUSE_LINUX) && SUSE_LINUX_UPDATE_SUBLEVEL >= 13900000000) #define MY_INIT_LIST_HEAD(SINODES) INIT_LIST_HEAD(SINODES) #else #define MY_INIT_LIST_HEAD(SINODES) #endif # define SET_SUPER_BLOCK(SBP,SOPS) \ { \ memset((SBP), 0, sizeof(struct super_block)); \ (SBP)->s_op = SOPS; \ (SBP)->s_flags |= MS_ACTIVE; \ security_sb_alloc(SBP); \ MY_INIT_LIST_HEAD(&((SBP)->s_inodes)); \ } # define UNSET_SUPER_BLOCK(SBP) \ { \ security_sb_free(SBP); \ } # define KSTATFS kstatfs # define HAS_SOP_ALLOC_INODE 1 # define NODE_TOO_BIG_FOR_OSNODE(SZ) 0 /* false if HAS_SOP_ALLOC_INODE */ # define DAEMONIZE(A) daemonize(A); # define FOR_EACH_TASK(T) for_each_process(T) # define DO_EACH_THREAD(G,T) do_each_thread(G,T) # define WHILE_EACH_THREAD(G,T) while_each_thread(G,T) # define NEXT_TASK(T) list_entry((T)->tasks.next, \ struct task_struct, tasks) # define PROCESS_GROUP(T) process_group(T) # define REVOKE_LEASE(INODE,MODE) break_lease(INODE,MODE) # define KDEV_INT(KDEV) ((unsigned int)(KDEV)) # define PAGE_UP_TO_DATE(PAGE) PageUptodate(PAGE) # define PAGE_UNLOCK(PAGE) unlock_page(PAGE) # define HAS_IOP_REVALIDATE 0 /* uses getattr inode op instead */ # define HAS_SOP_READ_INODE2 0 # define SBLOCK_PRIVATE(SBP) (SBP)->s_fs_info # define SBLOCK_BDEVNAME(SBP,BNAME) bdevname((SBP)->s_bdev,(BNAME)) # define DCACHE_DFLAGS_DISCONNECTED DCACHE_DISCONNECTED # define POSIX_UNBLOCK_LOCK(FLP) posix_unblock_lock((FLP)->fl_file,(FLP)) # define POSIX_LOCK_FILE(FLP1,FLP2) posix_lock_file((FLP1),(FLP2)) # define SPIN_LOCK_IRQ(LOCK,FLAGS) spin_lock_irqsave(LOCK,FLAGS) # define SPIN_UNLOCK_IRQ(LOCK,FLAGS) spin_unlock_irqrestore(LOCK,FLAGS) # define GET_INODETIME_SEC(ITIME) (ITIME).tv_sec # define CXITIME_TO_INODETIME(CXITIME, ITIME) \ { \ (ITIME).tv_sec = (CXITIME).tv_sec; \ (ITIME).tv_nsec = (CXITIME).tv_nsec; \ } # define CXITIME_FROM_INODETIME(CXITIME, ITIME) \ { \ (CXITIME).tv_sec = (ITIME).tv_sec; \ (CXITIME).tv_nsec = (ITIME).tv_nsec; \ } #ifdef MODULE /* Module function interfaces for 2.6 kernel */ # define MY_INIT_FUNCTION() static int __init myModuleInit(void) # define MY_EXIT_FUNCTION() static void __exit myModuleExit(void) # define MY_MODULE_INCREMENT() try_module_get(THIS_MODULE) # define MY_MODULE_DECREMENT() module_put(THIS_MODULE) # define MODULE_INCREMENT(MOD) try_module_get(MOD) # define MODULE_DECREMENT(MOD) module_put(MOD) # define DEFINE_MODULE_INIT() module_init(myModuleInit) # define DEFINE_MODULE_EXIT() module_exit(myModuleExit) #endif /* MODULE */ #define SETUP_MODULE_PATH_PARMS \ char progPath[20] = "/usr/lpp/mmfs/bin/"; \ char *prog_path = progPath; \ char mmfsdPath[20] = "/usr/lpp/mmfs/bin/"; \ char *mmfsd_path = mmfsdPath; \ module_param_string(mmfsd_path, mmfsdPath, 0666, sizeof(mmfsdPath)); \ module_param_string(prog_path, progPath, 0666, sizeof(progPath)); /* pte functions */ # define PTE_OFFSET(PMDP,VADDR) pte_offset_map((PMDP),(VADDR)) # define PTE_UNMAP(PTEP) pte_unmap(PTEP); /* mmap functions */ # define ACQUIRE_MMAP_SEM(SEM) down_write(SEM) # define RELEASE_MMAP_SEM(SEM) up_write(SEM) # define FILEMAP_FDATASYNC(RC, M) RC = filemap_fdatawrite(M) # define FILEMAP_FDATAWAIT(RC, M) RC = filemap_fdatawait(M) # define MOD_PGPGIN(amount) add_page_state(pgpgin, (amount)) # define MOD_PGPGOUT(amount) add_page_state(pgpgout, (amount)) #if (LINUX_KERNEL_VERSION >= 2060700) #define PUTNAME __putname #else #define PUTNAME putname #endif #ifdef GPFS_ARCH_IA64 /* user addresses are below region 5 (while PAGE_OFFSET is at region 7) */ #define GPFS_KERNEL_OFFSET 0xa000000000000000UL #elif GPFS_ARCH_I386 #if LINUX_KERNEL_VERSION >= 2060900 #define GPFS_KERNEL_OFFSET (UIntPtr) PAGE_OFFSET - (0x8000000 + 0x100000) #else #define GPFS_KERNEL_OFFSET (UIntPtr) PAGE_OFFSET #endif /* LINUX_KERNEL_VERSION >= 2060900 */ #else #define GPFS_KERNEL_OFFSET (UIntPtr) PAGE_OFFSET #endif /* GPFS_ARCH_IA64 */ #define EXEC_HELPER(PATH,AV,EV,WAIT) call_usermodehelper(PATH,AV,EV,WAIT) #define USING_MOUNT_HELPER() false #if LINUX_KERNEL_VERSION >= 2060600 || \ (LINUX_KERNEL_VERSION == 2060507 && defined(SUSE_LINUX) && SUSE_LINUX_UPDATE_SUBLEVEL >= 13900000000) #define UNMAP_MAPPING_RANGE(MAPPING, START, STOP) unmap_shared_mapping_range(MAPPING, START, STOP); #define MMAP_WRITE_ACCESS(WRITEACCESS) WRITEACCESS = true; #elif defined(MMAP_LINUX_PATCH) #define UNMAP_MAPPING_RANGE(MAPPING, START, STOP) invalidate_mappings(MAPPING, START); #define MMAP_WRITE_ACCESS(WRITEACCESS) WRITEACCESS = true; #else #define UNMAP_MAPPING_RANGE(MAPPING, START, STOP) #define MMAP_WRITE_ACCESS(WRITEACCESS) WRITEACCESS = false; #endif #if LINUX_KERNEL_VERSION >= 2060900 #define VFS_FOLLOW_LINK(RC, ND, BUF) nd_set_link(ND, BUF); BUF = NULL #else #define VFS_FOLLOW_LINK(RC, ND, BUF) RC = vfs_follow_link(ND, BUF) #endif #if LINUX_KERNEL_VERSION >= 2061000 #define MY_RLIM_CUR(WHAT) current->signal->rlim[WHAT].rlim_cur #else #define MY_RLIM_CUR(WHAT) current->rlim[WHAT].rlim_cur #endif #if LINUX_KERNEL_VERSION >= 2061000 /* generic_permission does not have a definition that is expected in struct inode_operations, but it is safe to call it because the only difference is in the last argument, which should not come into play for a GPFS inode. Cast the definition to eliminate compiler warnings. */ #define GENERIC_PERMISSION ((int (*) (struct inode *, int, struct nameidata *))generic_permission) #else #define GENERIC_PERMISSION vfs_permission #endif #if LINUX_KERNEL_VERSION >= 2061600 #define d_child d_u.d_child #endif #if LINUX_KERNEL_VERSION >= 2060900 #define HAS_IOP_PUT_LINK #endif #define cxiDevMajor(D) ((UInt32)((D) >> 20)) #define cxiDevMinor(D) ((UInt32)((D) & 0xfffff)) #define cxiDevToKernelDev(D) new_decode_dev(D) #define cxiDev32ToDev(D) \ (cxiDev_t)((cxiDev32Major(D) << 8) | \ (cxiDev32Minor(D) & 0xFF) | \ ((cxiDev32Minor(D) & ~0xFF) << 12)) #if LINUX_KERNEL_VERSION >= 2061900 #define PRVINODE i_private #else #define PRVINODE u.generic_ip #endif #else /* < 2060000 */ /************************************ * Linux 2.4 functional differences * ********************************** */ # include # include # include # include # include /* Inode state indicators */ #define INODE_BEING_RELEASED (I_FREEING|I_CLEAR) #define INODE_IN_CACHE (I_FREEING|I_CLEAR|I_LOCK) #define MUST_TRUNCATE_INODE_PAGES 0 #define PRVINODE u.generic_ip #define GENERIC_PERMISSION vfs_permission #if defined(REDHAT_AS_LINUX) || defined(SUSE_LINUX) ||\ (defined(REDHAT_LINUX) && LINUX_KERNEL_VERSION >= 2041814) /* Retrieve a new empty inode from the vfs */ # define NEW_INODE(SUPER) new_inode(SUPER) #else # define NEW_INODE(SUPER) get_empty_inode() #endif /* Check if directory is already uncached. Must hold dcache lock. */ # define DENTRY_UNHASHED(DP) list_empty(&(DP)->d_hash) /* Uncache a directory entry. Assumes dcache lock is held */ # define DENTRY_DROP(DP) \ { \ if (!DENTRY_UNHASHED((DP))) \ list_del_init(&(DP)->d_hash); \ } /* Uncache a directory entry. Must hold *NO* locks. */ # define DENTRY_D_DROP(DP) \ { \ spin_lock(&dcache_lock); \ list_del_init(&(DP)->d_hash); \ spin_unlock(&dcache_lock); \ } /* Mark buffer in error and call iodone routine */ # define BUFHEAD_ERROR_IODONE(BH) buffer_IO_error(BH) #if LINUX_KERNEL_VERSION >= 2041800 # define SET_SUPER_BLOCK(SBP,SOPS) \ { \ memset((SBP), 0, sizeof(struct super_block)); \ (SBP)->s_op = SOPS; \ (SBP)->s_flags |= MS_ACTIVE; \ } #else # define SET_SUPER_BLOCK(SBP,SOPS) \ { \ memset((SBP), 0, sizeof(struct super_block)); \ (SBP)->s_op = SOPS; \ } #endif # define UNSET_SUPER_BLOCK(SBP) #if ((defined(REDHAT_LINUX) && (LINUX_DISTRIBUTION_LEVEL >= 90)) || \ (defined(REDHAT_AS_LINUX) && (LINUX_KERNEL_VERSION >= 2042000))) # define HAS_01_SCHED_THREADING #endif #ifdef HAS_01_SCHED_THREADING # define NEXT_TASK(T) list_entry((T)->tasks.next, \ struct task_struct, tasks) # define FOR_EACH_TASK(T) for ((T) = &init_task; \ ((T) = NEXT_TASK(T)) != &init_task; ) #else # define FOR_EACH_TASK(T) for_each_task(T) # define NEXT_TASK(T) (T)->next_task #endif # define DO_EACH_THREAD(G,T) FOR_EACH_TASK(T) # define WHILE_EACH_THREAD(G,T) # define PROCESS_GROUP(T) (T)->pgrp # define KSTATFS statfs # define HAS_SOP_ALLOC_INODE 0 # define NODE_TOO_BIG_FOR_OSNODE(SZ) \ ((sizeof(((struct inode *)0)->u) - sizeof(void *)) < (SZ)) # define DAEMONIZE(A) do { daemonize(); reparent_to_init(); } \ while (0) # define REVOKE_LEASE(INODE,MODE) get_lease(INODE,MODE) # define KDEV_INT(KDEV) (KDEV) # define PAGE_UP_TO_DATE(PAGE) Page_Uptodate(PAGE) # define PAGE_UNLOCK(PAGE) UnlockPage(PAGE) # define HAS_SOP_READ_INODE2 1 /* read_inode2 super block op present */ # define HAS_IOP_REVALIDATE 1 /* revalidate inode op present */ # define SBLOCK_PRIVATE(SBP) (SBP)->u.generic_sbp # define SBLOCK_BDEVNAME(SBP,BNAME) bdevname((SBP)->s_dev) # define BDEVNAME_SIZE 0 /* char array unneeded on 2.4 */ # define DCACHE_DFLAGS_DISCONNECTED DCACHE_NFSD_DISCONNECTED # define POSIX_UNBLOCK_LOCK(FLP) posix_unblock_lock(FLP) # define POSIX_LOCK_FILE(FLP1,FLP2) posix_lock_file((FLP1),(FLP2),0) # define SPIN_LOCK_IRQ(LOCK,FLAGS) spin_lock_irqsave(LOCK,FLAGS) # define SPIN_UNLOCK_IRQ(LOCK,FLAGS) spin_unlock_irqrestore(LOCK,FLAGS) # define GET_INODETIME_SEC(ITIME) (ITIME) # define CXITIME_TO_INODETIME(CXITIME, ITIME) \ { \ (ITIME) = (CXITIME).tv_sec; \ } # define CXITIME_FROM_INODETIME(CXITIME, ITIME) \ { \ (CXITIME).tv_sec = (ITIME); \ (CXITIME).tv_nsec = 0; \ } #ifdef MODULE /* Module function interfaces for 2.4 kernel */ # define MY_INIT_FUNCTION() int init_module(void) # define MY_EXIT_FUNCTION() void cleanup_module(void) # define MY_MODULE_INCREMENT() MOD_INC_USE_COUNT # define MY_MODULE_DECREMENT() if (MOD_IN_USE) \ MOD_DEC_USE_COUNT # define MODULE_INCREMENT(MOD) __MOD_INC_USE_COUNT(MOD) # define MODULE_DECREMENT(MOD) if (__MOD_IN_USE(MOD)) \ __MOD_DEC_USE_COUNT(MOD) # define DEFINE_MODULE_INIT() # define DEFINE_MODULE_EXIT() # define SETUP_MODULE_PATH_PARMS \ char *prog_path = NULL; \ char *mmfsd_path = NULL; \ MODULE_PARM(prog_path,"s"); \ MODULE_PARM(mmfsd_path,"s"); #else /* No ops if not building a module */ # define MY_INIT_FUNCTION() int myInit(void) # define MY_EXIT_FUNCTION() void myExit(void) # define MY_MODULE_INCREMENT() # define MY_MODULE_DECREMENT() # define MODULE_INCREMENT(MOD) # define MODULE_DECREMENT(MOD) # define DEFINE_MODULE_INIT() module_init(myInit) # define DEFINE_MODULE_EXIT() module_exit(myExit) # define SETUP_MODULE_PATH_PARMS \ char *prog_path = NULL; \ char *mmfsd_path = NULL; #endif /* !MODULE */ /* pte functions */ #if defined(REDHAT_AS_LINUX) || \ (defined(REDHAT_LINUX) && (LINUX_KERNEL_VERSION >= 2042006)) # define PTE_OFFSET(PMDP,VADDR) pte_offset_map((PMDP),(VADDR)) # define PTE_UNMAP(PTEP) pte_unmap(PTEP); #else # define PTE_OFFSET(PMDP,VADDR) pte_offset(PMDP, VADDR) # if defined(SUSE_LINUX) && defined(GPFS_ARCH_I386) # define PTE_UNMAP(PTEP) pte_kunmap(PTEP); # else # define PTE_UNMAP(PTEP) /* nothing */ # endif #endif /* pte functions */ #if LINUX_KERNEL_VERSION >= 2040312 || GPFS_ARCH_POWER # define ACQUIRE_MMAP_SEM(SEM) down_write(SEM) # define RELEASE_MMAP_SEM(SEM) up_write(SEM) #else # define ACQUIRE_MMAP_SEM(SEM) down(SEM) # define RELEASE_MMAP_SEM(SEM) up(SEM) #endif #if LINUX_KERNEL_VERSION >= 2041800 /* Earlier kernels do not have a return code */ # define FILEMAP_FDATASYNC(RC, M) RC = filemap_fdatasync(M) # define FILEMAP_FDATAWAIT(RC, M) RC = filemap_fdatawait(M) #else # define FILEMAP_FDATASYNC(RC, M) do { filemap_fdatasync(M); RC = 0; } while (0) # define FILEMAP_FDATAWAIT(RC, M) do { filemap_fdatawait(M); RC = 0; } while (0) #endif #if (defined(REDHAT_AS_LINUX)) && \ (LINUX_KERNEL_VERSION >= 2042100) # define MOD_PGPGIN(amount) kstat_percpu[smp_processor_id()].pgpgin += amount # define MOD_PGPGOUT(amount) kstat_percpu[smp_processor_id()].pgpgout+= amount #else # define MOD_PGPGIN(amount) kstat.pgpgin += amount # define MOD_PGPGOUT(amount) kstat.pgpgout += amount #endif #define PUTNAME putname #ifdef GPFS_ARCH_IA64 /* user addresses are below region 5 (while PAGE_OFFSET is at region 7) */ #define GPFS_KERNEL_OFFSET 0xa000000000000000UL #elif GPFS_ARCH_I386 #define GPFS_KERNEL_OFFSET (UIntPtr) PAGE_OFFSET #else #define GPFS_KERNEL_OFFSET (UIntPtr) PAGE_OFFSET #endif /* GPFS_ARCH_IA64 */ #if defined(GPFS_ARCH_X86_64) # define EXEC_HELPER(PATH,AV,EV,WAIT) exec_usermodehelper(PATH,AV,EV) # define USING_MOUNT_HELPER() false #else # define EXEC_HELPER(PATH,AV,EV,WAIT) execve(PATH,AV,EV) # define USING_MOUNT_HELPER() true #endif #ifdef MMAP_LINUX_PATCH #define UNMAP_MAPPING_RANGE(MAPPING, START, STOP) invalidate_mappings(MAPPING, START); #define MMAP_WRITE_ACCESS(WRITEACCESS) WRITEACCESS = true; #else #define UNMAP_MAPPING_RANGE(MAPPING, START, STOP) #define MMAP_WRITE_ACCESS(WRITEACCESS) WRITEACCESS = false; #endif #define VFS_FOLLOW_LINK(RC, ND, BUF) RC = vfs_follow_link(ND, BUF) #define MY_RLIM_CUR(WHAT) current->rlim[WHAT].rlim_cur #define cxiDevMajor(D) ((Int32)(((UInt32)(D) >> 8) & 0xFF)) #define cxiDevMinor(D) ((Int32)((D) & 0xFF)) /* Extra defines not on other platforms to massage it back down * to a linux kernel specific 16 bits. */ #define cxiDevToKernelDev(D) ((cxiDevMajor(D) << 8) | (cxiDevMinor(D) & 0xFF)) #define cxiDev32ToDev(D) \ (cxiDev_t)((cxiDev32Major(D) << 8) | (cxiDev32Minor(D) & 0xFF)) #endif /* 2.4 kernel */ /* Translate to GPFS native disk format which used high and low 16 bits * for major/minor */ #define cxiDevToDev32(D) \ (cxiDev32_t)((cxiDevMajor(D) << 16) | (cxiDevMinor(D) & 0xFFFF)) #endif /* _h_verdep */