Commit f5304d66 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

bdev/malloc: Fix unexpected DIF verification error for initial read

The patch
https://github.com/spdk/spdk/commit/e1f15ba5418b38056fdb6d67186075aa1fada9e7


set reference tag to 0xFFFFFFFF and set application tag to 0xFFFF.

However, these are actually written to DIF fields only if their checks
are enabled. Usually, reference tag check is enabled but application tag
check is disabled.

For DIF type 1 or 2, DIF check is disabled only if application tag is
0xFFFF.

Hence, the value of 0xFFFFFFFF in the reference tag caused verification
error for any read.

The previous patch fixed DIF library to set application tag to 0 if its
check is disabled.
This patch fixes another problem, to set application tag to 0xFFFF as
source code comment says even if application tag check is disabled.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I1d444eb6cc6de2e36abc7b0b85364c11dbe1df67
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25324


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent baa2dd0a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -106,19 +106,22 @@ malloc_unmap_write_zeroes_generate_pi(struct spdk_bdev_io *bdev_io)
	struct spdk_bdev *bdev = bdev_io->bdev;
	struct malloc_disk *mdisk = bdev_io->bdev->ctxt;
	uint32_t block_size = bdev_io->bdev->blocklen;
	uint32_t dif_check_flags;
	struct spdk_dif_ctx dif_ctx;
	struct spdk_dif_ctx_init_ext_opts dif_opts;
	int rc;

	dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
	dif_opts.dif_pi_format = bdev->dif_pi_format;
	dif_check_flags = bdev->dif_check_flags | SPDK_DIF_CHECK_TYPE_REFTAG |
			  SPDK_DIF_FLAGS_APPTAG_CHECK;
	rc = spdk_dif_ctx_init(&dif_ctx,
			       bdev->blocklen,
			       bdev->md_len,
			       bdev->md_interleave,
			       bdev->dif_is_head_of_md,
			       bdev->dif_type,
			       bdev->dif_check_flags,
			       dif_check_flags,
			       SPDK_DIF_REFTAG_IGNORE,
			       0xFFFF, SPDK_DIF_APPTAG_IGNORE,
			       0, 0, &dif_opts);
@@ -662,19 +665,22 @@ malloc_disk_setup_pi(struct malloc_disk *mdisk)
	struct spdk_bdev *bdev = &mdisk->disk;
	struct spdk_dif_ctx dif_ctx;
	struct iovec iov, md_iov;
	uint32_t dif_check_flags;
	int rc;
	struct spdk_dif_ctx_init_ext_opts dif_opts;

	dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
	dif_opts.dif_pi_format = bdev->dif_pi_format;
	/* Set APPTAG|REFTAG_IGNORE to PI fields after creation of malloc bdev */
	dif_check_flags = bdev->dif_check_flags | SPDK_DIF_CHECK_TYPE_REFTAG |
			  SPDK_DIF_FLAGS_APPTAG_CHECK;
	rc = spdk_dif_ctx_init(&dif_ctx,
			       bdev->blocklen,
			       bdev->md_len,
			       bdev->md_interleave,
			       bdev->dif_is_head_of_md,
			       bdev->dif_type,
			       bdev->dif_check_flags,
			       dif_check_flags,
			       SPDK_DIF_REFTAG_IGNORE,
			       0xFFFF, SPDK_DIF_APPTAG_IGNORE,
			       0, 0, &dif_opts);