Whamcloud - gitweb
LU-73 Make register_shrinker argument more visible.
[fs/lustre-release.git] / lustre / include / linux / lustre_compat25.h
index 81f8cc1..f651958 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -43,6 +43,7 @@
 #error sorry, lustre requires at least linux kernel 2.6.9 or later
 #endif
 
+#include <linux/fs_struct.h>
 #include <libcfs/linux/portals_compat25.h>
 
 #include <linux/lustre_patchless_compat.h>
@@ -139,8 +140,8 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
 #endif /* HAVE_DQUOTOFF_MUTEX */
 
-#define current_ngroups current->group_info->ngroups
-#define current_groups current->group_info->small_block
+#define current_ngroups current_cred()->group_info->ngroups
+#define current_groups current_cred()->group_info->small_block
 
 #ifndef page_private
 #define page_private(page) ((page)->private)
@@ -178,7 +179,12 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 
 #define LTIME_S(time)                   (time.tv_sec)
 #define ll_path_lookup                  path_lookup
+
+#ifdef HAVE_EXPORT_INODE_PERMISSION
+#define ll_permission(inode,mask,nd)    inode_permission(inode,mask)
+#else
 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
+#endif
 
 #define ll_pgcache_lock(mapping)          cfs_spin_lock(&mapping->page_lock)
 #define ll_pgcache_unlock(mapping)        cfs_spin_unlock(&mapping->page_lock)
@@ -195,7 +201,18 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define to_kdev_t(dev)                  (dev)
 #define kdev_t_to_nr(dev)               (dev)
 #define val_to_kdev(dev)                (dev)
-#define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, (void *)(data));
+
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+#define ll_blkdev_put(a, b) blkdev_put(a, b)
+#else
+#define ll_blkdev_put(a, b) blkdev_put(a)
+#endif
+
+#ifdef HAVE_DENTRY_OPEN_4ARGS
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
+#else
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
+#endif
 
 #include <linux/writeback.h>
 
@@ -291,11 +308,7 @@ static inline int mapping_has_pages(struct address_space *mapping)
 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
                        vfs_symlink(dir, dentry, path)
 #endif
-#endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
-#define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
-#else
 #define ll_set_dflags(dentry, flags) do { \
                 cfs_spin_lock(&dentry->d_lock); \
                 dentry->d_flags |= flags; \
@@ -429,6 +442,20 @@ int ll_unregister_blkdev(unsigned int dev, const char *name)
 #define LL_RENAME_DOES_D_MOVE   FS_ODD_RENAME
 #endif
 
+#ifndef HAVE_D_OBTAIN_ALIAS
+/* The old d_alloc_anon() didn't free the inode reference on error
+ * like d_obtain_alias().  Hide that difference/inconvenience here. */
+static inline struct dentry *d_obtain_alias(struct inode *inode)
+{
+       struct dentry *anon = d_alloc_anon(inode);
+
+       if (anon == NULL)
+               iput(inode);
+
+       return anon;
+}
+#endif
+
 /* add a lustre compatible layer for crypto API */
 #include <linux/crypto.h>
 #ifdef HAVE_ASYNC_BLOCK_CIPHER
@@ -615,8 +642,11 @@ static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
 #endif /* HAVE_ASYNC_BLOCK_CIPHER */
 
 #ifndef HAVE_SYNCHRONIZE_RCU
+/* Linux 2.6.32 provides define when !CONFIG_TREE_PREEMPT_RCU */
+#ifndef synchronize_rcu
 #define synchronize_rcu() synchronize_kernel()
 #endif
+#endif
 
 #ifdef HAVE_FILE_REMOVE_SUID
 # define ll_remove_suid(file, mnt)       file_remove_suid(file)
@@ -661,7 +691,7 @@ static inline int ll_crypto_hmac(struct crypto_tfm *tfm,
 #endif
 
 #ifdef HAVE_REGISTER_SHRINKER
-typedef int (*cfs_shrinker_t)(int nr_to_scan, gfp_t gfp_mask);
+typedef int (*cfs_shrinker_t)(SHRINKER_FIRST_ARG int nr_to_scan, gfp_t gfp_mask);
 
 static inline
 struct shrinker *cfs_set_shrinker(int seek, cfs_shrinker_t func)
@@ -778,5 +808,60 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount)
                 return -ENOSYS;
 }
 
+#ifndef HAVE_BLK_QUEUE_LOG_BLK_SIZE /* added in 2.6.31 */
+#define blk_queue_logical_block_size(q, sz) blk_queue_hardsect_size(q, sz)
+#endif
+
+#ifndef HAVE_VFS_DQ_OFF
+# define ll_vfs_dq_init             DQUOT_INIT
+# define ll_vfs_dq_drop             DQUOT_DROP
+# define ll_vfs_dq_transfer         DQUOT_TRANSFER
+# define ll_vfs_dq_off(sb, remount) DQUOT_OFF(sb)
+#else
+# define ll_vfs_dq_init             vfs_dq_init
+# define ll_vfs_dq_drop             vfs_dq_drop
+# define ll_vfs_dq_transfer         vfs_dq_transfer
+# define ll_vfs_dq_off(sb, remount) vfs_dq_off(sb, remount)
+#endif
+
+#ifdef HAVE_BDI_INIT
+#define ll_bdi_init(bdi)    bdi_init(bdi)
+#define ll_bdi_destroy(bdi) bdi_destroy(bdi)
+#else
+#define ll_bdi_init(bdi)    0
+#define ll_bdi_destroy(bdi) do { } while(0)
+#endif
+
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+# define ll_bdi_wb_cnt(bdi) ((bdi).wb_cnt)
+#else
+# define ll_bdi_wb_cnt(bdi) 1
+#endif
+
+#ifdef HAVE_BLK_QUEUE_MAX_SECTORS /* removed in rhel6 */
+#define blk_queue_max_hw_sectors(q, sect) blk_queue_max_sectors(q, sect)
+#endif
+
+#ifndef HAVE_REQUEST_QUEUE_LIMITS
+#define queue_max_sectors(rq)             ((rq)->max_sectors)
+#define queue_max_hw_sectors(rq)          ((rq)->max_hw_sectors)
+#define queue_max_phys_segments(rq)       ((rq)->max_phys_segments)
+#define queue_max_hw_segments(rq)         ((rq)->max_hw_segments)
+#endif
+
+#ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
+#define blk_queue_max_segments(rq, seg)                      \
+        do { blk_queue_max_phys_segments(rq, seg);           \
+             blk_queue_max_hw_segments(rq, seg); } while (0)
+#else
+#define queue_max_phys_segments(rq)       queue_max_segments(rq)
+#define queue_max_hw_segments(rq)         queue_max_segments(rq)
+#endif
+
+
+#ifndef HAVE_BI_HW_SEGMENTS
+#define bio_hw_segments(q, bio) 0
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */