Commit cdc37d69 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev: Add PI format to bdev structure together with query function



Add enum dif_pi_format to spdk_bdev structure and add a public API
spdk_bdev_get_dif_pi_format() for the upper layer to get it.

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 172d5791
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -811,6 +811,16 @@ uint32_t spdk_bdev_get_physical_block_size(const struct spdk_bdev *bdev);
 */
enum spdk_dif_type spdk_bdev_get_dif_type(const struct spdk_bdev *bdev);

/**
 * Get DIF protection information format of the block device.
 *
 * Note that this function is valid only if DIF type is not SPDK_DIF_DISABLE.
 *
 * \param bdev Block device to query.
 * \return DIF protection information format of the block device.
 */
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.
 *
+8 −0
Original line number Diff line number Diff line
@@ -548,6 +548,14 @@ struct spdk_bdev {
	 */
	enum spdk_dif_type dif_type;

	/**
	 * DIF protection information format for this bdev.
	 *
	 * Note that this field is valid only if there is metadata and dif_type is
	 * not SPDK_DIF_DISABLE.
	 */
	enum spdk_dif_pi_format dif_pi_format;

	/*
	 * DIF location.
	 *
+7 −0
Original line number Diff line number Diff line
@@ -4896,6 +4896,7 @@ _bdev_get_block_size_with_md(const struct spdk_bdev *bdev)

/* We have to use the typedef in the function declaration to appease astyle. */
typedef enum spdk_dif_type spdk_dif_type_t;
typedef enum spdk_dif_pi_format spdk_dif_pi_format_t;

spdk_dif_type_t
spdk_bdev_get_dif_type(const struct spdk_bdev *bdev)
@@ -4907,6 +4908,12 @@ spdk_bdev_get_dif_type(const struct spdk_bdev *bdev)
	}
}

spdk_dif_pi_format_t
spdk_bdev_get_dif_pi_format(const struct spdk_bdev *bdev)
{
	return bdev->dif_pi_format;
}

bool
spdk_bdev_is_dif_head_of_md(const struct spdk_bdev *bdev)
{
+2 −0
Original line number Diff line number Diff line
@@ -668,6 +668,8 @@ rpc_dump_bdev_info(void *ctx, struct spdk_bdev *bdev)
			spdk_json_write_named_bool(w, "guard",
						   spdk_bdev_is_dif_check_enabled(bdev, SPDK_DIF_CHECK_TYPE_GUARD));
			spdk_json_write_object_end(w);

			spdk_json_write_named_uint32(w, "dif_pi_format", spdk_bdev_get_dif_pi_format(bdev));
		}
	}

+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
	spdk_bdev_get_data_block_size;
	spdk_bdev_get_physical_block_size;
	spdk_bdev_get_dif_type;
	spdk_bdev_get_dif_pi_format;
	spdk_bdev_is_dif_head_of_md;
	spdk_bdev_is_dif_check_enabled;
	spdk_bdev_get_current_qd;