Whamcloud - gitweb
LU-11770 osc: allow build without blk_integrity or crc-t10pi 23/33923/9
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 26 Dec 2018 09:05:37 +0000 (02:05 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 18 Feb 2019 06:38:23 +0000 (06:38 +0000)
Allow the client to build if blk_integrity or crc-t10pi is not
enabled in the kernel.

Fixes: ccf3674c9ca ("LU-10472 osd-ldiskfs: T10PI between RPC and BIO")
Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I97c4e75ad084e99927bcb41cf0df8a680525a5b1
Reviewed-on: https://review.whamcloud.com/33923
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_compat.h
lustre/include/obd_cksum.h
lustre/obdclass/integrity.c
lustre/osc/osc_request.c
lustre/osd-ldiskfs/osd_integrity.c
lustre/osd-ldiskfs/osd_io.c

index 03de741..f951411 100644 (file)
@@ -702,7 +702,7 @@ static inline struct timespec current_time(struct inode *inode)
 #define READ_ONCE ACCESS_ONCE
 #endif
 
-#ifdef HAVE_BLK_INTEGRITY_ENABLED
+#if IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)
 static inline unsigned short blk_integrity_interval(struct blk_integrity *bi)
 {
 #ifdef HAVE_INTERVAL_EXP_BLK_INTEGRITY
@@ -711,7 +711,7 @@ static inline unsigned short blk_integrity_interval(struct blk_integrity *bi)
        return bi->interval;
 #else
        return bi->sector_size;
-#endif
+#endif /* !HAVE_INTERVAL_EXP_BLK_INTEGRITY */
 }
 
 static inline const char *blk_integrity_name(struct blk_integrity *bi)
@@ -722,7 +722,16 @@ static inline const char *blk_integrity_name(struct blk_integrity *bi)
        return bi->name;
 #endif
 }
+
+static inline unsigned int bip_size(struct bio_integrity_payload *bip)
+{
+#ifdef HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
+       return bip->bip_iter.bi_size;
 #else
+       return bip->bip_size;
+#endif
+}
+#else /* !CONFIG_BLK_DEV_INTEGRITY */
 static inline unsigned short blk_integrity_interval(struct blk_integrity *bi)
 {
        return 0;
@@ -732,18 +741,8 @@ static inline const char *blk_integrity_name(struct blk_integrity *bi)
        /* gcc8 dislikes when strcmp() is called against NULL */
        return "";
 }
-#endif
+#endif /* !CONFIG_BLK_DEV_INTEGRITY */
 
-static inline unsigned int bip_size(struct bio_integrity_payload *bip)
-{
-#ifdef HAVE_BIP_ITER_BIO_INTEGRITY_PAYLOAD
-       return bip->bip_iter.bi_size;
-#else
-       return bip->bip_size;
-#endif
-}
-
-#ifdef HAVE_BLK_INTEGRITY_ENABLED
 #ifndef INTEGRITY_FLAG_READ
 #define INTEGRITY_FLAG_READ BLK_INTEGRITY_VERIFY
 #endif
@@ -754,6 +753,7 @@ static inline unsigned int bip_size(struct bio_integrity_payload *bip)
 
 static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw)
 {
+#if IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)
        struct blk_integrity *bi = bdev_get_integrity(bdev);
 
        if (bi == NULL)
@@ -775,16 +775,11 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw)
        if (rw == 1 && bi->generate_fn != NULL &&
            (bi->flags & INTEGRITY_FLAG_WRITE))
                return true;
-#endif
+#endif /* !HAVE_INTERVAL_EXP_BLK_INTEGRITY */
+#endif /* !CONFIG_BLK_DEV_INTEGRITY */
 
        return false;
 }
-#else
-static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw)
-{
-       return false;
-}
-#endif /* HAVE_BLK_INTEGRITY_ENABLED */
 
 #ifdef HAVE_PAGEVEC_INIT_ONE_PARAM
 #define ll_pagevec_init(pvec, n) pagevec_init(pvec)
index a2ce2ec..6e807d7 100644 (file)
@@ -144,6 +144,7 @@ static inline void obd_t10_cksum2dif(enum cksum_types cksum_type,
        *fn = NULL;
        *sector_size = 0;
 
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
        switch (cksum_type) {
        case OBD_CKSUM_T10IP512:
                *fn = obd_dif_ip_fn;
@@ -164,6 +165,7 @@ static inline void obd_t10_cksum2dif(enum cksum_types cksum_type,
        default:
                break;
        }
+#endif /* CONFIG_CRC_T10DIF */
 }
 
 enum obd_t10_cksum_type {
index c203fee..e6d6d85 100644 (file)
@@ -31,6 +31,7 @@
 #include <obd_class.h>
 #include <obd_cksum.h>
 
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
 __u16 obd_dif_crc_fn(void *data, unsigned int len)
 {
        return cpu_to_be16(crc_t10dif(data, len));
@@ -251,10 +252,12 @@ out:
                       obd_t10_cksum_speeds[index]);
        }
 }
+#endif /* CONFIG_CRC_T10DIF */
 
 int obd_t10_cksum_speed(const char *obd_name,
                        enum cksum_types cksum_type)
 {
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
        enum obd_t10_cksum_type index = obd_t10_cksum2type(cksum_type);
 
        if (unlikely(obd_t10_cksum_speeds[index] == 0)) {
@@ -267,5 +270,8 @@ int obd_t10_cksum_speed(const char *obd_name,
        }
 
        return obd_t10_cksum_speeds[index];
+#else /* !CONFIG_CRC_T10DIF */
+       return 0;
+#endif /* !CONFIG_CRC_T10DIF */
 }
 EXPORT_SYMBOL(obd_t10_cksum_speed);
index 5b67cdb..0bdb7b7 100644 (file)
@@ -1100,6 +1100,7 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
         return (p1->off + p1->count == p2->off);
 }
 
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
 static int osc_checksum_bulk_t10pi(const char *obd_name, int nob,
                                   size_t pg_count, struct brw_page **pga,
                                   int opc, obd_dif_csum_fn *fn,
@@ -1197,6 +1198,12 @@ out:
        __free_page(__page);
        return rc;
 }
+#else /* !CONFIG_CRC_T10DIF */
+#define obd_dif_ip_fn NULL
+#define obd_dif_crc_fn NULL
+#define osc_checksum_bulk_t10pi(name, nob, pgc, pga, opc, fn, ssize, csum)  \
+       -EOPNOTSUPP
+#endif /* CONFIG_CRC_T10DIF */
 
 static int osc_checksum_bulk(int nob, size_t pg_count,
                             struct brw_page **pga, int opc,
@@ -1626,7 +1633,6 @@ check_write_checksum(struct obdo *oa, const struct lnet_process_id *peer,
        enum cksum_types cksum_type;
        obd_dif_csum_fn *fn = NULL;
        int sector_size = 0;
-       bool t10pi = false;
        __u32 new_cksum;
        char *msg;
        int rc;
@@ -1645,22 +1651,18 @@ check_write_checksum(struct obdo *oa, const struct lnet_process_id *peer,
 
        switch (cksum_type) {
        case OBD_CKSUM_T10IP512:
-               t10pi = true;
                fn = obd_dif_ip_fn;
                sector_size = 512;
                break;
        case OBD_CKSUM_T10IP4K:
-               t10pi = true;
                fn = obd_dif_ip_fn;
                sector_size = 4096;
                break;
        case OBD_CKSUM_T10CRC512:
-               t10pi = true;
                fn = obd_dif_crc_fn;
                sector_size = 512;
                break;
        case OBD_CKSUM_T10CRC4K:
-               t10pi = true;
                fn = obd_dif_crc_fn;
                sector_size = 4096;
                break;
@@ -1668,13 +1670,10 @@ check_write_checksum(struct obdo *oa, const struct lnet_process_id *peer,
                break;
        }
 
-       if (t10pi)
+       if (fn)
                rc = osc_checksum_bulk_t10pi(obd_name, aa->aa_requested_nob,
-                                            aa->aa_page_count,
-                                            aa->aa_ppga,
-                                            OST_WRITE,
-                                            fn,
-                                            sector_size,
+                                            aa->aa_page_count, aa->aa_ppga,
+                                            OST_WRITE, fn, sector_size,
                                             &new_cksum);
        else
                rc = osc_checksum_bulk(aa->aa_requested_nob, aa->aa_page_count,
index bb2ce93..3a6433d 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "osd_internal.h"
 
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
 /*
  * Data Integrity Field tuple.
  */
@@ -262,3 +263,4 @@ int osd_get_integrity_profile(struct osd_device *osd,
 
        return 0;
 }
+#endif /* CONFIG_CRC_T10DIF */
index 134dcdb..59c87fc 100644 (file)
@@ -271,6 +271,7 @@ static int can_be_merged(struct bio *bio, sector_t sector)
        return bio_end_sector(bio) == sector ? 1 : 0;
 }
 
+#if IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)
 /*
  * This function will change the data written, thus it should only be
  * used when checking data integrity feature
@@ -406,7 +407,11 @@ static void dio_integrity_complete_routine(struct bio *bio, int error)
 
        OBD_FREE_PTR(bio_private);
 }
-#endif
+#endif /* HAVE_BIO_INTEGRITY_PREP_FN */
+#else  /* !CONFIG_BLK_DEV_INTEGRITY */
+#define osd_bio_integrity_handle(osd, bio, iobuf, start_page_idx, \
+                                fault_inject, integrity_enabled) 0
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
 
 static int osd_bio_init(struct bio *bio, struct osd_iobuf *iobuf,
                        bool integrity_enabled, int start_page_idx,