Commit d112ea1a authored by Slawomir Ptak's avatar Slawomir Ptak Committed by Tomasz Zawadzki
Browse files

lib/util/dif: Reference tag optional check on remap



Add a parameter to skip the reference tag check during the remap
operations.

This is needed in cases, when the check and remap operations happen
in two different places on the I/O path. This is true, for example,
for RAID bdev, where there are multiple levels of LBA remapping happening
on different layers.

Change-Id: Ic7692ddc9337cde93063038e19395ae51b3e537c
Signed-off-by: default avatarSlawomir Ptak <slawomir.ptak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21569


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent dd3deac4
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -433,12 +433,14 @@ uint32_t spdk_dif_get_length_with_md(uint32_t data_len, const struct spdk_dif_ct
 * \param num_blocks Number of blocks of the payload.
 * \param ctx DIF context.
 * \param err_blk Error information of the block in which DIF error is found.
 * \param check_ref_tag If true, check the reference tag before updating.
 *
 * \return 0 on success and negated errno otherwise.
 */
int spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
			   const struct spdk_dif_ctx *dif_ctx,
			   struct spdk_dif_error *err_blk);
			   struct spdk_dif_error *err_blk,
			   bool check_ref_tag);

/**
 * Remap reference tag for separate metadata payload.
@@ -451,10 +453,12 @@ int spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
 * \param num_blocks Number of blocks of the payload.
 * \param ctx DIF context.
 * \param err_blk Error information of the block in which DIF error is found.
 * \param check_ref_tag If true, check the reference tag before updating.
 *
 * \return 0 on success and negated errno otherwise.
 */
int spdk_dix_remap_ref_tag(struct iovec *md_iov, uint32_t num_blocks,
			   const struct spdk_dif_ctx *dif_ctx,
			   struct spdk_dif_error *err_blk);
			   struct spdk_dif_error *err_blk,
			   bool check_ref_tag);
#endif /* SPDK_DIF_H */
+2 −2
Original line number Diff line number Diff line
@@ -222,14 +222,14 @@ bdev_part_remap_dif(struct spdk_bdev_io *bdev_io, uint32_t offset,

	if (bdev->md_interleave) {
		rc = spdk_dif_remap_ref_tag(bdev_io->u.bdev.iovs, bdev_io->u.bdev.iovcnt,
					    bdev_io->u.bdev.num_blocks, &dif_ctx, &err_blk);
					    bdev_io->u.bdev.num_blocks, &dif_ctx, &err_blk, true);
	} else {
		struct iovec md_iov = {
			.iov_base	= bdev_io->u.bdev.md_buf,
			.iov_len	= bdev_io->u.bdev.num_blocks * bdev->md_len,
		};

		rc = spdk_dix_remap_ref_tag(&md_iov, bdev_io->u.bdev.num_blocks, &dif_ctx, &err_blk);
		rc = spdk_dix_remap_ref_tag(&md_iov, bdev_io->u.bdev.num_blocks, &dif_ctx, &err_blk, true);
	}

	if (rc != 0) {
+12 −8
Original line number Diff line number Diff line
@@ -2056,7 +2056,8 @@ spdk_dif_get_length_with_md(uint32_t data_len, const struct spdk_dif_ctx *ctx)

static int
_dif_remap_ref_tag(struct _dif_sgl *sgl, uint32_t offset_blocks,
		   const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk)
		   const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk,
		   bool check_ref_tag)
{
	uint32_t offset, buf_len;
	uint64_t expected = 0, remapped;
@@ -2096,7 +2097,7 @@ _dif_remap_ref_tag(struct _dif_sgl *sgl, uint32_t offset_blocks,
	}

	/* Verify the stored Reference Tag. */
	if (!_dif_reftag_check(&dif, ctx, expected, offset_blocks, err_blk)) {
	if (check_ref_tag && !_dif_reftag_check(&dif, ctx, expected, offset_blocks, err_blk)) {
		return -1;
	}

@@ -2122,7 +2123,8 @@ end:

int
spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
		       const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk)
		       const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk,
		       bool check_ref_tag)
{
	struct _dif_sgl sgl;
	uint32_t offset_blocks;
@@ -2144,7 +2146,7 @@ spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
	}

	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		rc = _dif_remap_ref_tag(&sgl, offset_blocks, ctx, err_blk);
		rc = _dif_remap_ref_tag(&sgl, offset_blocks, ctx, err_blk, check_ref_tag);
		if (rc != 0) {
			return rc;
		}
@@ -2155,7 +2157,8 @@ spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,

static int
_dix_remap_ref_tag(struct _dif_sgl *md_sgl, uint32_t offset_blocks,
		   const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk)
		   const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk,
		   bool check_ref_tag)
{
	uint64_t expected = 0, remapped;
	uint8_t *md_buf;
@@ -2181,7 +2184,7 @@ _dix_remap_ref_tag(struct _dif_sgl *md_sgl, uint32_t offset_blocks,
	}

	/* Verify the stored Reference Tag. */
	if (!_dif_reftag_check(dif, ctx, expected, offset_blocks, err_blk)) {
	if (check_ref_tag && !_dif_reftag_check(dif, ctx, expected, offset_blocks, err_blk)) {
		return -1;
	}

@@ -2197,7 +2200,8 @@ end:
int
spdk_dix_remap_ref_tag(struct iovec *md_iov, uint32_t num_blocks,
		       const struct spdk_dif_ctx *ctx,
		       struct spdk_dif_error *err_blk)
		       struct spdk_dif_error *err_blk,
		       bool check_ref_tag)
{
	struct _dif_sgl md_sgl;
	uint32_t offset_blocks;
@@ -2219,7 +2223,7 @@ spdk_dix_remap_ref_tag(struct iovec *md_iov, uint32_t num_blocks,
	}

	for (offset_blocks = 0; offset_blocks < num_blocks; offset_blocks++) {
		rc = _dix_remap_ref_tag(&md_sgl, offset_blocks, ctx, err_blk);
		rc = _dix_remap_ref_tag(&md_sgl, offset_blocks, ctx, err_blk, check_ref_tag);
		if (rc != 0) {
			return rc;
		}
+2 −2
Original line number Diff line number Diff line
@@ -3741,7 +3741,7 @@ dif_generate_remap_and_verify(struct iovec *iovs, int iovcnt,

	spdk_dif_ctx_set_remapped_init_ref_tag(&ctx, remapped_init_ref_tag);

	rc = spdk_dif_remap_ref_tag(iovs, iovcnt, num_blocks, &ctx, NULL);
	rc = spdk_dif_remap_ref_tag(iovs, iovcnt, num_blocks, &ctx, NULL, true);
	CU_ASSERT(rc == 0);

	rc = spdk_dif_ctx_init(&ctx, block_size, md_size, true, dif_loc, dif_type, dif_flags,
@@ -3901,7 +3901,7 @@ dix_generate_remap_and_verify(struct iovec *iovs, int iovcnt, struct iovec *md_i

	spdk_dif_ctx_set_remapped_init_ref_tag(&ctx, remapped_init_ref_tag);

	rc = spdk_dix_remap_ref_tag(md_iov, num_blocks, &ctx, NULL);
	rc = spdk_dix_remap_ref_tag(md_iov, num_blocks, &ctx, NULL, true);
	CU_ASSERT(rc == 0);

	rc = spdk_dif_ctx_init(&ctx, block_size, md_size, false, dif_loc, dif_type, dif_flags,