diff --git a/include/spdk/dif.h b/include/spdk/dif.h index 684afad4c..440809e19 100644 --- a/include/spdk/dif.h +++ b/include/spdk/dif.h @@ -110,8 +110,8 @@ struct spdk_dif_error { * \param md_size Metadata size in a block. * \param md_interleave If true, metadata is interleaved with block data. * If false, metadata is separated with block data. - * \param dif_loc DIF location. If true, DIF is set in the last 8 bytes of metadata. - * If false, DIF is in the first 8 bytes of metadata. + * \param dif_loc DIF location. If true, DIF is set in the first 8 bytes of metadata. + * If false, DIF is in the last 8 bytes of metadata. * \param dif_type Type of DIF. * \param dif_flags Flag to specify the DIF action. * \param init_ref_tag Initial reference tag. For type 1, this is the diff --git a/lib/util/dif.c b/lib/util/dif.c index 04d61e66e..b39b71658 100644 --- a/lib/util/dif.c +++ b/lib/util/dif.c @@ -158,7 +158,7 @@ _dif_is_disabled(enum spdk_dif_type dif_type) static uint32_t _get_guard_interval(uint32_t block_size, uint32_t md_size, bool dif_loc, bool md_interleave) { - if (dif_loc) { + if (!dif_loc) { /* For metadata formats with more than 8 bytes, if the DIF is * contained in the last 8 bytes of metadata, then the CRC * covers all metadata up to but excluding these last 8 bytes. diff --git a/test/unit/lib/util/dif.c/dif_ut.c b/test/unit/lib/util/dif.c/dif_ut.c index 6859e64d1..99be968a8 100644 --- a/test/unit/lib/util/dif.c/dif_ut.c +++ b/test/unit/lib/util/dif.c/dif_ut.c @@ -183,7 +183,7 @@ dif_generate_and_verify_test(void) /* The case that DIF is contained in the first 8 bytes of metadata. */ _dif_generate_and_verify(&iov, - 4096 + 128, 128, false, + 4096 + 128, 128, true, SPDK_DIF_TYPE1, dif_flags, 22, 22, 0x22, 0xFFFF, 0x22, @@ -191,7 +191,7 @@ dif_generate_and_verify_test(void) /* The case that DIF is contained in the last 8 bytes of metadata. */ _dif_generate_and_verify(&iov, - 4096 + 128, 128, true, + 4096 + 128, 128, false, SPDK_DIF_TYPE1, dif_flags, 22, 22, 0x22, 0xFFFF, 0x22, @@ -613,11 +613,11 @@ dif_inject_error_and_verify(struct iovec *iovs, int iovcnt, { /* The case that DIF is contained in the first 8 bytes of metadata. */ _dif_inject_error_and_verify(iovs, iovcnt, block_size, md_size, num_blocks, - inject_flags, false); + inject_flags, true); /* The case that DIF is contained in the last 8 bytes of metadata. */ _dif_inject_error_and_verify(iovs, iovcnt, block_size, md_size, num_blocks, - inject_flags, true); + inject_flags, false); } static void @@ -935,12 +935,12 @@ dif_copy_inject_error_and_verify(struct iovec *iovs, int iovcnt, struct iovec *b /* The case that DIF is contained in the first 8 bytes of metadata. */ _dif_copy_inject_error_and_verify(iovs, iovcnt, bounce_iov, block_size, md_size, num_blocks, - inject_flags, false); + inject_flags, true); /* The case that DIF is contained in the last 8 bytes of metadata. */ _dif_copy_inject_error_and_verify(iovs, iovcnt, bounce_iov, block_size, md_size, num_blocks, - inject_flags, true); + inject_flags, false); } static void @@ -1219,11 +1219,11 @@ dix_inject_error_and_verify(struct iovec *iovs, int iovcnt, struct iovec *md_iov { /* The case that DIF is contained in the first 8 bytes of metadata. */ _dix_inject_error_and_verify(iovs, iovcnt, md_iov, block_size, md_size, num_blocks, - inject_flags, false); + inject_flags, true); /* The case that DIF is contained in the last 8 bytes of metadata. */ _dix_inject_error_and_verify(iovs, iovcnt, md_iov, block_size, md_size, num_blocks, - inject_flags, true); + inject_flags, false); } static void