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

dif: Set DIF field to 0 explicitly if its check is disabled

Each DIF generation/verification function has two modes, non-split and
split. For split mode, DIF fields are copied. However, for non-split
mode, DIF fields are updated directly. If check is disabled, the DIF
field is not touched for non-split case.

This is inconsistent.

Not only inconsistency but also this caused a real problem for the
malloc bdev module.

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


caused the problem.

When malloc bdev is created, its reference tags are initialized to
0xFFFFFFFF. This means reference tag should be ignored. However, this
makes sense only if application tags are initialized to 0xFFFF for DIF
type 1. However, in SPDK, usually application tag check is disabled.
If application tag is not 0xFFFF, verification always detects reference
tag error.

Hence, in the following patches, we will change the malloc bdev module
to set application tags to 0xFFFF by enabling check only at disk
creation.

However, after that, we have no way to enable DIF check if application
tag check is not enabled.

If any valid meaningfull value is written to guard tag or reference tag,
DIF check should not be disabled.

This patch can resolve the problem.

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


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent a91d250f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -673,10 +673,14 @@ _dif_generate(void *_dif, uint64_t guard, uint32_t offset_blocks,

	if (ctx->dif_flags & SPDK_DIF_FLAGS_GUARD_CHECK) {
		_dif_set_guard(dif, guard, ctx->dif_pi_format);
	} else {
		_dif_set_guard(dif, 0, ctx->dif_pi_format);
	}

	if (ctx->dif_flags & SPDK_DIF_FLAGS_APPTAG_CHECK) {
		_dif_set_apptag(dif, ctx->app_tag, ctx->dif_pi_format);
	} else {
		_dif_set_apptag(dif, 0, ctx->dif_pi_format);
	}

	if (ctx->dif_flags & SPDK_DIF_FLAGS_REFTAG_CHECK) {
@@ -702,6 +706,8 @@ _dif_generate(void *_dif, uint64_t guard, uint32_t offset_blocks,
		}

		_dif_set_reftag(dif, ref_tag, ctx->dif_pi_format);
	} else {
		_dif_set_reftag(dif, 0, ctx->dif_pi_format);
	}
}