Commit 1b9c5629 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Jim Harris
Browse files

raid: move the raid I/O wrappers back to the header



Instead of having these in bdev_raid.c, just make
raid_bdev_remap_dix_reftag() public. This allows to have the unit tests
a little simpler and better reflecting the real behavior.

This effectively reverts 2c9dfc37 ("module/raid: Move the RAID I/O
wrappers").

Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Change-Id: I92de84d7cbc233f5d744aedf6e77d0728ecdaa72
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22828


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 698da718
Loading
Loading
Loading
Loading
+1 −40
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ raid_bdev_destruct(void *ctx)
	return 1;
}

static int
int
raid_bdev_remap_dix_reftag(void *md_buf, uint64_t num_blocks,
			   struct spdk_bdev *bdev, uint32_t remapped_offset)
{
@@ -564,45 +564,6 @@ raid_bdev_verify_dix_reftag(struct iovec *iovs, int iovcnt, void *md_buf,
	return rc;
}

/**
 * Raid bdev I/O read/write wrapper for spdk_bdev_readv_blocks_ext function.
 */
int
raid_bdev_readv_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			   struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			   uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
			   struct spdk_bdev_ext_io_opts *opts)
{
	return spdk_bdev_readv_blocks_ext(base_info->desc, ch, iov, iovcnt,
					  base_info->data_offset + offset_blocks, num_blocks, cb, cb_arg, opts);
}

/**
 * Raid bdev I/O read/write wrapper for spdk_bdev_writev_blocks_ext function.
 */
int
raid_bdev_writev_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			    struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			    uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
			    struct spdk_bdev_ext_io_opts *opts)
{
	int rc;
	uint64_t remapped_offset_blocks = base_info->data_offset + offset_blocks;

	if (spdk_unlikely(spdk_bdev_get_dif_type(&base_info->raid_bdev->bdev) != SPDK_DIF_DISABLE &&
			  base_info->raid_bdev->bdev.dif_check_flags & SPDK_DIF_FLAGS_REFTAG_CHECK)) {

		rc = raid_bdev_remap_dix_reftag(opts->metadata, num_blocks, &base_info->raid_bdev->bdev,
						remapped_offset_blocks);
		if (rc != 0) {
			return rc;
		}
	}

	return spdk_bdev_writev_blocks_ext(base_info->desc, ch, iov, iovcnt,
					   remapped_offset_blocks, num_blocks, cb, cb_arg, opts);
}

void
raid_bdev_io_complete(struct raid_bdev_io *raid_io, enum spdk_bdev_io_status status)
{
+32 −8
Original line number Diff line number Diff line
@@ -374,24 +374,48 @@ raid_bdev_base_bdev_slot(struct raid_base_bdev_info *base_info)
	return base_info - base_info->raid_bdev->base_bdev_info;
}

int raid_bdev_remap_dix_reftag(void *md_buf, uint64_t num_blocks,
			       struct spdk_bdev *bdev, uint32_t remapped_offset);
int raid_bdev_verify_dix_reftag(struct iovec *iovs, int iovcnt, void *md_buf,
				uint64_t num_blocks, struct spdk_bdev *bdev, uint32_t offset_blocks);

/**
 * Raid bdev I/O read/write wrapper for spdk_bdev_readv_blocks_ext function.
 */
int raid_bdev_readv_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
static inline int
raid_bdev_readv_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			   struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			   uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
			       struct spdk_bdev_ext_io_opts *opts);
			   struct spdk_bdev_ext_io_opts *opts)
{
	return spdk_bdev_readv_blocks_ext(base_info->desc, ch, iov, iovcnt,
					  base_info->data_offset + offset_blocks, num_blocks, cb, cb_arg, opts);
}

/**
 * Raid bdev I/O read/write wrapper for spdk_bdev_writev_blocks_ext function.
 */
int raid_bdev_writev_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
static inline int
raid_bdev_writev_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			    struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			    uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
				struct spdk_bdev_ext_io_opts *opts);
			    struct spdk_bdev_ext_io_opts *opts)
{
	int rc;
	uint64_t remapped_offset_blocks = base_info->data_offset + offset_blocks;

	if (spdk_unlikely(spdk_bdev_get_dif_type(&base_info->raid_bdev->bdev) != SPDK_DIF_DISABLE &&
			  (base_info->raid_bdev->bdev.dif_check_flags & SPDK_DIF_FLAGS_REFTAG_CHECK))) {
		rc = raid_bdev_remap_dix_reftag(opts->metadata, num_blocks, &base_info->raid_bdev->bdev,
						remapped_offset_blocks);
		if (rc != 0) {
			return rc;
		}
	}

	return spdk_bdev_writev_blocks_ext(base_info->desc, ch, iov, iovcnt,
					   remapped_offset_blocks, num_blocks, cb, cb_arg, opts);
}

/**
 * Raid bdev I/O read/write wrapper for spdk_bdev_unmap_blocks function.
+12 −20
Original line number Diff line number Diff line
@@ -11,6 +11,18 @@ struct spdk_bdev_desc {
	struct spdk_bdev *bdev;
};

typedef enum spdk_dif_type spdk_dif_type_t;

spdk_dif_type_t
spdk_bdev_get_dif_type(const struct spdk_bdev *bdev)
{
	if (bdev->md_len != 0) {
		return bdev->dif_type;
	} else {
		return SPDK_DIF_DISABLE;
	}
}

enum raid_params_md_type {
	RAID_PARAMS_MD_NONE,
	RAID_PARAMS_MD_SEPARATE,
@@ -271,23 +283,3 @@ raid_bdev_io_complete_part(struct raid_bdev_io *raid_io, uint64_t completed,
		return false;
	}
}

int
raid_bdev_readv_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			   struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			   uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
			   struct spdk_bdev_ext_io_opts *opts)
{
	return spdk_bdev_readv_blocks_ext(base_info->desc, ch, iov, iovcnt,
					  base_info->data_offset + offset_blocks, num_blocks, cb, cb_arg, opts);
}

int
raid_bdev_writev_blocks_ext(struct raid_base_bdev_info *base_info, struct spdk_io_channel *ch,
			    struct iovec *iov, int iovcnt, uint64_t offset_blocks,
			    uint64_t num_blocks, spdk_bdev_io_completion_cb cb, void *cb_arg,
			    struct spdk_bdev_ext_io_opts *opts)
{
	return spdk_bdev_writev_blocks_ext(base_info->desc, ch, iov, iovcnt,
					   base_info->data_offset + offset_blocks, num_blocks, cb, cb_arg, opts);
}
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ DEFINE_STUB(spdk_bdev_writev_blocks_with_md, int, (struct spdk_bdev_desc *desc,
		struct iovec *iov, int iovcnt, void *md,
		uint64_t offset_blocks, uint64_t num_blocks,
		spdk_bdev_io_completion_cb cb, void *cb_arg), 0);
DEFINE_STUB(raid_bdev_remap_dix_reftag, int, (void *md_buf, uint64_t num_blocks,
		struct spdk_bdev *bdev, uint32_t remapped_offset), -1);

#define BLOCK_LEN (4096)

+9 −14
Original line number Diff line number Diff line
@@ -58,18 +58,6 @@ DEFINE_STUB(spdk_bdev_flush_blocks, int, (struct spdk_bdev_desc *desc, struct sp
DEFINE_STUB(spdk_bdev_is_dif_head_of_md, bool, (const struct spdk_bdev *bdev), false);
DEFINE_STUB(spdk_bdev_notify_blockcnt_change, int, (struct spdk_bdev *bdev, uint64_t size), 0);

typedef enum spdk_dif_type spdk_dif_type_t;

spdk_dif_type_t
spdk_bdev_get_dif_type(const struct spdk_bdev *bdev)
{
	if (bdev->md_len != 0) {
		return bdev->dif_type;
	} else {
		return SPDK_DIF_DISABLE;
	}
}

bool
spdk_bdev_is_md_interleaved(const struct spdk_bdev *bdev)
{
@@ -278,6 +266,15 @@ raid_test_bdev_io_complete(struct raid_bdev_io *raid_io, enum spdk_bdev_io_statu
	g_io_comp_status = ((status == SPDK_BDEV_IO_STATUS_SUCCESS) ? true : false);
}

int
raid_bdev_remap_dix_reftag(void *md_buf, uint64_t num_blocks,
			   struct spdk_bdev *bdev, uint32_t remapped_offset)
{
	remap_dif(md_buf, num_blocks, bdev, remapped_offset);

	return 0;
}

int
raid_bdev_verify_dix_reftag(struct iovec *iovs, int iovcnt, void *md_buf,
			    uint64_t num_blocks, struct spdk_bdev *bdev, uint32_t offset_blocks)
@@ -356,8 +353,6 @@ spdk_bdev_writev_blocks_ext(struct spdk_bdev_desc *desc, struct spdk_io_channel
		      SPDK_BDEV_IO_TYPE_WRITE, iov, iovcnt, opts->metadata);
	g_io_output_index++;

	remap_dif(opts->metadata, num_blocks, desc->bdev, offset_blocks);

	child_io = get_child_io(output);
	child_io_complete(child_io, cb, cb_arg);

Loading