#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
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)
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;
/* 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
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)
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)
*fn = NULL;
*sector_size = 0;
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
switch (cksum_type) {
case OBD_CKSUM_T10IP512:
*fn = obd_dif_ip_fn;
default:
break;
}
+#endif /* CONFIG_CRC_T10DIF */
}
enum obd_t10_cksum_type {
#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));
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)) {
}
return obd_t10_cksum_speeds[index];
+#else /* !CONFIG_CRC_T10DIF */
+ return 0;
+#endif /* !CONFIG_CRC_T10DIF */
}
EXPORT_SYMBOL(obd_t10_cksum_speed);
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,
__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,
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;
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;
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,
#include "osd_internal.h"
+#if IS_ENABLED(CONFIG_CRC_T10DIF)
/*
* Data Integrity Field tuple.
*/
return 0;
}
+#endif /* CONFIG_CRC_T10DIF */
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
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,