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

bdev: Add APIs get metadata config via desc depending on hide_metadata option



Add APIs to get metadata configuration via bdev descriptor depending on
the hide_metadata option.

These correspond to the existing APIs to get metadata configuration via
bdev pointer. Hence, most comments in the header file were copied and
pasted. However, in existing functions there were notes were put after
the param/return comments. Fix these nits together in this patch.

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


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>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 16e5e505
Loading
Loading
Loading
Loading
+87 −6
Original line number Diff line number Diff line
@@ -615,6 +615,87 @@ int spdk_for_each_bdev_leaf(void *ctx, spdk_for_each_bdev_fn fn);
 */
struct spdk_bdev *spdk_bdev_desc_get_bdev(struct spdk_bdev_desc *desc);

/**
 * Get logical block size, specific to a bdev descriptor.
 *
 * \param desc Open block device descriptor.
 * \return Size of logical block for this bdev in bytes.
 */
uint32_t spdk_bdev_desc_get_block_size(struct spdk_bdev_desc *desc);

/**
 * Get metadata size, specific to a bdev descriptor.
 *
 * \param desc Open block device descriptor
 * \return Size of metadata for this bdev in bytes.
 */
uint32_t spdk_bdev_desc_get_md_size(struct spdk_bdev_desc *desc);

/**
 * Query whether metadata is interleaved with block data or separated
 * with block data, specific to a bdev descriptor.
 *
 * Note this function is valid only if there is metadata.
 *
 * \param desc Open block device descriptor.
 * \return true if metadata is interleaved with block data or false
 * if metadata is separated with block data.
 */
bool spdk_bdev_desc_is_md_interleaved(struct spdk_bdev_desc *desc);

/**
 * Query whether metadata is interleaved with block data or separated
 * from block data, specific to a bdev descriptor
 *
 * Note this function is valid only if there is metadata.
 *
 * \param desc Open block device descriptor.
 * \return true if metadata is separated from block data, false
 * otherwise.
 */
bool spdk_bdev_desc_is_md_separate(struct spdk_bdev_desc *desc);

/**
 * Get DIF type, specific to a bdev descriptor.
 *
 * \param desc Open block device descriptor.
 * \return DIF type of the block device.
 */
enum spdk_dif_type spdk_bdev_desc_get_dif_type(struct spdk_bdev_desc *desc);

/**
 * Get DIF protection information format of the block device, specific to
 * a bdev descriptor.
 *
 * Note that this function is valid only if DIF type is not SPDK_DIF_DISABLE.
 *
 * \param desc Open block device descriptor.
 * \return DIF protection information format of the block device.
 */
enum spdk_dif_pi_format spdk_bdev_desc_get_dif_pi_format(struct spdk_bdev_desc *desc);

/**
 * Check whether DIF is set in the first 8/16 bytes or the last 8/16 bytes of metadata,
 * specific to a bdev descriptor.
 *
 * Note that this function is valid only if DIF type is not SPDK_DIF_DISABLE.
 *
 * \param desc Open block device descriptor..
 * \return true if DIF is set in the first 8/16 bytes of metadata, or false
 * if DIF is set in the last 8/16 bytes of metadata.
 */
bool spdk_bdev_desc_is_dif_head_of_md(struct spdk_bdev_desc *desc);

/**
 * Check whether the DIF check type is enabled, specific to a bdev descriptor.
 *
 * \param desc Open block device descriptor.
 * \param check_type The specific DIF check type.
 * \return true if enabled, false otherwise.
 */
bool spdk_bdev_desc_is_dif_check_enabled(struct spdk_bdev_desc *desc,
		enum spdk_dif_check_type check_type);

/**
 * Set a time limit for the timeout IO of the bdev and timeout callback.
 * We can use this function to enable/disable the timeout handler. If
@@ -814,11 +895,11 @@ uint32_t spdk_bdev_get_md_size(const struct spdk_bdev *bdev);
 * Query whether metadata is interleaved with block data or separated
 * with block data.
 *
 * Note this function is valid only if there is metadata.
 *
 * \param bdev Block device to query.
 * \return true if metadata is interleaved with block data or false
 * if metadata is separated with block data.
 *
 * Note this function is valid only if there is metadata.
 */
bool spdk_bdev_is_md_interleaved(const struct spdk_bdev *bdev);

@@ -826,11 +907,11 @@ bool spdk_bdev_is_md_interleaved(const struct spdk_bdev *bdev);
 * Query whether metadata is interleaved with block data or separated
 * from block data.
 *
 * Note this function is valid only if there is metadata.
 *
 * \param bdev Block device to query.
 * \return true if metadata is separated from block data, false
 * otherwise.
 *
 * Note this function is valid only if there is metadata.
 */
bool spdk_bdev_is_md_separate(const struct spdk_bdev *bdev);

@@ -884,11 +965,11 @@ enum spdk_dif_pi_format spdk_bdev_get_dif_pi_format(const struct spdk_bdev *bdev
/**
 * Check whether DIF is set in the first 8/16 bytes or the last 8/16 bytes of metadata.
 *
 * Note that this function is valid only if DIF type is not SPDK_DIF_DISABLE.
 *
 * \param bdev Block device to query.
 * \return true if DIF is set in the first 8/16 bytes of metadata, or false
 * if DIF is set in the last 8/16 bytes of metadata.
 *
 * Note that this function is valid only if DIF type is not SPDK_DIF_DISABLE.
 */
bool spdk_bdev_is_dif_head_of_md(const struct spdk_bdev *bdev);

+65 −0
Original line number Diff line number Diff line
@@ -5061,6 +5061,71 @@ spdk_bdev_get_nvme_nsid(struct spdk_bdev *bdev)
	return bdev->nsid;
}

uint32_t
spdk_bdev_desc_get_block_size(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? bdev->blocklen - bdev->md_len : bdev->blocklen;
}

uint32_t
spdk_bdev_desc_get_md_size(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? 0 : bdev->md_len;
}

bool
spdk_bdev_desc_is_md_interleaved(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? false : spdk_bdev_is_md_interleaved(bdev);
}

bool
spdk_bdev_desc_is_md_separate(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? false : spdk_bdev_is_md_separate(bdev);
}

spdk_dif_type_t
spdk_bdev_desc_get_dif_type(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? SPDK_DIF_DISABLE : spdk_bdev_get_dif_type(bdev);
}

spdk_dif_pi_format_t
spdk_bdev_desc_get_dif_pi_format(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? SPDK_DIF_PI_FORMAT_16 : spdk_bdev_get_dif_pi_format(bdev);
}

bool
spdk_bdev_desc_is_dif_head_of_md(struct spdk_bdev_desc *desc)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? false : spdk_bdev_is_dif_head_of_md(bdev);
}

bool
spdk_bdev_desc_is_dif_check_enabled(struct spdk_bdev_desc *desc,
				    enum spdk_dif_check_type check_type)
{
	struct spdk_bdev *bdev = desc->bdev;

	return desc->opts.hide_metadata ? false : spdk_bdev_is_dif_check_enabled(bdev, check_type);
}

static void bdev_update_qd_sampling_period(void *ctx);

static void
+8 −0
Original line number Diff line number Diff line
@@ -50,6 +50,14 @@
	spdk_bdev_get_dif_pi_format;
	spdk_bdev_is_dif_head_of_md;
	spdk_bdev_is_dif_check_enabled;
	spdk_bdev_desc_get_block_size;
	spdk_bdev_desc_get_md_size;
	spdk_bdev_desc_is_md_interleaved;
	spdk_bdev_desc_is_md_separate;
	spdk_bdev_desc_get_dif_type;
	spdk_bdev_desc_get_dif_pi_format;
	spdk_bdev_desc_is_dif_head_of_md;
	spdk_bdev_desc_is_dif_check_enabled;
	spdk_bdev_get_current_qd;
	spdk_bdev_get_qd;
	spdk_bdev_get_qd_sampling_period;