lib/bdev: Expose metadata size and setting of bdev

To support DIF, bdev will need to expose the following information:
- Metadata format
 - Block size
 - Metadata size
 - Metadata setting (interleave or separate)
- DIF settings
 - DIF type 1, 2, or 3
 - DIF location
- DIF check types
 - Guard check
 - Reference tag check
 - Application tag check

This patch is for the metadata format. Subsequent patches will do for the DIF
setting and DIF check types.

Add fields, md_len and md_interleave, to struct spdk_bdev and add APIs,
spdk_bdev_get_md_size and spdk_bdev_is_md_interleaved, to bdev APIs.

The fields, md_len and md_interleave, are added to the bdev JSON infomation dump.

DIF will be used only in the NVMe bdev module and the upcoming virtual
DIF bdev module first. But additional required storage by md_len and md_interleave
will be very small and they are simple. Hence add them to struct spdk_bdev simply.

Change-Id: I4109f6a63e6f0576efe424feb0305a9a17b9b2e8
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/443183
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-02-04 17:21:20 +09:00 committed by Jim Harris
parent 7ce3117c64
commit 139da44c43
4 changed files with 48 additions and 0 deletions

View File

@ -405,6 +405,26 @@ bool spdk_bdev_has_write_cache(const struct spdk_bdev *bdev);
*/
const struct spdk_uuid *spdk_bdev_get_uuid(const struct spdk_bdev *bdev);
/**
* Get block device metadata size.
*
* \param bdev Block device to query.
* \return Size of metadata for this bdev in bytes.
*/
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.
*
* \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);
/**
* Get the most recently measured queue depth from a bdev.
*

View File

@ -292,6 +292,17 @@ struct spdk_bdev {
*/
struct spdk_uuid uuid;
/** Size in bytes of a metadata for the backend */
uint32_t md_len;
/**
* Specify metadata location and set to true if metadata is interleaved
* with block data or false if metadata is separated with block data.
*
* Note that this field is valid only if there is metadata.
*/
bool md_interleave;
/**
* Pointer to the bdev module that registered this bdev.
*/

View File

@ -2319,6 +2319,18 @@ spdk_bdev_get_uuid(const struct spdk_bdev *bdev)
return &bdev->uuid;
}
uint32_t
spdk_bdev_get_md_size(const struct spdk_bdev *bdev)
{
return bdev->md_len;
}
bool
spdk_bdev_is_md_interleaved(const struct spdk_bdev *bdev)
{
return (bdev->md_len != 0) && bdev->md_interleave;
}
uint64_t
spdk_bdev_get_qd(const struct spdk_bdev *bdev)
{

View File

@ -245,6 +245,11 @@ spdk_rpc_dump_bdev_info(struct spdk_json_write_ctx *w,
spdk_json_write_named_string(w, "uuid", uuid_str);
}
if (spdk_bdev_get_md_size(bdev) != 0) {
spdk_json_write_named_uint32(w, "md_size", spdk_bdev_get_md_size(bdev));
spdk_json_write_named_bool(w, "md_interleave", spdk_bdev_is_md_interleaved(bdev));
}
spdk_json_write_named_object_begin(w, "assigned_rate_limits");
spdk_bdev_get_qos_rate_limits(bdev, qos_limits);
for (i = 0; i < SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES; i++) {