Whamcloud - gitweb
LU-8210 osd-ldiskfs: fix setting pages PageUptodate state
[fs/lustre-release.git] / lustre / include / lustre_compat.h
index 0c0dc91..d777993 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <linux/fs_struct.h>
 #include <linux/namei.h>
+#include <linux/bio.h>
 
 #include <lustre_patchless_compat.h>
 
@@ -123,13 +124,9 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
 #ifdef HAVE_INODE_DIO_WAIT
 /* inode_dio_wait(i) use as-is for write lock */
 # define inode_dio_write_done(i)       do {} while (0) /* for write unlock */
-# define inode_dio_read(i)             atomic_inc(&(i)->i_dio_count)
-/* inode_dio_done(i) use as-is for read unlock */
 #else
 # define inode_dio_wait(i)             down_write(&(i)->i_alloc_sem)
 # define inode_dio_write_done(i)       up_write(&(i)->i_alloc_sem)
-# define inode_dio_read(i)             down_read(&(i)->i_alloc_sem)
-# define inode_dio_done(i)             up_read(&(i)->i_alloc_sem)
 #endif
 
 #ifndef FS_HAS_FIEMAP
@@ -188,6 +185,7 @@ unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
 #ifdef HAVE_BVEC_ITER
 #define bio_idx(bio)                   (bio->bi_iter.bi_idx)
 #define bio_set_sector(bio, sector)    (bio->bi_iter.bi_sector = sector)
+#define bvl_to_page(bvl)               (bvl.bv_page)
 #else
 #define bio_idx(bio)                   (bio->bi_idx)
 #define bio_set_sector(bio, sector)    (bio->bi_sector = sector)
@@ -195,7 +193,7 @@ unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm)
 #ifndef HAVE_BIO_END_SECTOR
 #define bio_end_sector(bio)            (bio->bi_sector + bio_sectors(bio))
 #endif
-#define bvec_iter_page(bvec, iter)     (*bvec->bv_page)
+#define bvl_to_page(bvl)               (bvl->bv_page)
 #endif
 
 #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
@@ -301,12 +299,17 @@ static inline int ll_namei_to_lookup_intent_flag(int flag)
        return flag;
 }
 
-#ifdef HAVE_VOID_MAKE_REQUEST_FN
-# define ll_mrf_ret void
-# define LL_MRF_RETURN(rc)
+#ifdef HAVE_QC_MAKE_REQUEST_FN
+# define ll_mrf_ret blk_qc_t
+# define LL_MRF_RETURN(rc) RETURN(BLK_QC_T_NONE)
 #else
-# define ll_mrf_ret int
-# define LL_MRF_RETURN(rc) RETURN(rc)
+# ifdef HAVE_VOID_MAKE_REQUEST_FN
+#  define ll_mrf_ret void
+#  define LL_MRF_RETURN(rc)
+# else
+#  define ll_mrf_ret int
+#  define LL_MRF_RETURN(rc) RETURN(rc)
+# endif
 #endif
 
 #include <linux/fs.h>
@@ -391,4 +394,24 @@ static inline void truncate_inode_pages_final(struct address_space *map)
 #define SIZE_MAX       (~(size_t)0)
 #endif
 
+#ifdef HAVE_SECURITY_IINITSEC_CALLBACK
+# define ll_security_inode_init_security(inode, dir, name, value, len, \
+                                        initxattrs, dentry)           \
+        security_inode_init_security(inode, dir, &((dentry)->d_name), \
+                                     initxattrs, dentry)
+#elif defined HAVE_SECURITY_IINITSEC_QSTR
+# define ll_security_inode_init_security(inode, dir, name, value, len, \
+                                        initxattrs, dentry)           \
+        security_inode_init_security(inode, dir, &((dentry)->d_name), \
+                                     name, value, len)
+#else /* !HAVE_SECURITY_IINITSEC_CALLBACK && !HAVE_SECURITY_IINITSEC_QSTR */
+# define ll_security_inode_init_security(inode, dir, name, value, len, \
+                                        initxattrs, dentry)           \
+        security_inode_init_security(inode, dir, name, value, len)
+#endif
+
+#ifndef bio_for_each_segment_all /* since kernel version 3.9 */
+#define bio_for_each_segment_all(bv, bio, it) bio_for_each_segment(bv, bio, it)
+#endif
+
 #endif /* _LUSTRE_COMPAT_H */