nvme: add spdk_nvme_ns_get_extended_sector_size
spdk_nvme_ns_get_sector_size returns the sector size of the data only. This new function adds in the metadata size, if any. While here, modify the bdev/nvme driver to use this function - this is needed for ongoing extended sector size work through the bdev layer. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ic8070a7f8d29b0b2ac2a2d65e0df5f4736488351 Reviewed-on: https://review.gerrithub.io/422445 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
fdf5e5854b
commit
5b900148e5
@ -2,6 +2,12 @@
|
||||
|
||||
## v18.10: (Upcoming Release)
|
||||
|
||||
### nvme
|
||||
|
||||
spdk_nvme_ns_get_extended_sector_size() was added. This function includes
|
||||
the metadata size per sector (if any). spdk_nvme_ns_get_sector_size() still
|
||||
returns only the data size per sector, not including metadata.
|
||||
|
||||
## v18.07:
|
||||
|
||||
### bdev
|
||||
|
||||
@ -1290,6 +1290,9 @@ uint32_t spdk_nvme_ns_get_max_io_xfer_size(struct spdk_nvme_ns *ns);
|
||||
/**
|
||||
* Get the sector size, in bytes, of the given namespace.
|
||||
*
|
||||
* This function returns the size of the data sector only. It does not
|
||||
* include metadata size.
|
||||
*
|
||||
* This function is thread safe and can be called at any point while the controller
|
||||
* is attached to the SPDK NVMe driver.
|
||||
*
|
||||
@ -1299,6 +1302,20 @@ uint32_t spdk_nvme_ns_get_max_io_xfer_size(struct spdk_nvme_ns *ns);
|
||||
*/
|
||||
uint32_t spdk_nvme_ns_get_sector_size(struct spdk_nvme_ns *ns);
|
||||
|
||||
/**
|
||||
* Get the extended sector size, in bytes, of the given namespace.
|
||||
*
|
||||
* This function returns the size of the data sector plus metadata.
|
||||
*
|
||||
* This function is thread safe and can be called at any point while the controller
|
||||
* is attached to the SPDK NVMe driver.
|
||||
*
|
||||
* \param ns Namespace to query.
|
||||
*
|
||||
* /return the extended sector size in bytes.
|
||||
*/
|
||||
uint32_t spdk_nvme_ns_get_extended_sector_size(struct spdk_nvme_ns *ns);
|
||||
|
||||
/**
|
||||
* Get the number of sectors for the given namespace.
|
||||
*
|
||||
|
||||
@ -727,7 +727,7 @@ nvme_ctrlr_create_bdev(struct nvme_ctrlr *nvme_ctrlr, uint32_t nsid)
|
||||
/* Enable if the Volatile Write Cache exists */
|
||||
bdev->disk.write_cache = 1;
|
||||
}
|
||||
bdev->disk.blocklen = spdk_nvme_ns_get_sector_size(ns);
|
||||
bdev->disk.blocklen = spdk_nvme_ns_get_extended_sector_size(ns);
|
||||
bdev->disk.blockcnt = spdk_nvme_ns_get_num_sectors(ns);
|
||||
bdev->disk.optimal_io_boundary = spdk_nvme_ns_get_optimal_io_boundary(ns);
|
||||
|
||||
@ -1621,7 +1621,7 @@ bdev_nvme_io_passthru_md(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes, void *md_buf, size_t md_len)
|
||||
{
|
||||
struct nvme_io_channel *nvme_ch = spdk_io_channel_get_ctx(ch);
|
||||
size_t nr_sectors = nbytes / spdk_nvme_ns_get_sector_size(nbdev->ns);
|
||||
size_t nr_sectors = nbytes / spdk_nvme_ns_get_extended_sector_size(nbdev->ns);
|
||||
uint32_t max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nbdev->nvme_ctrlr->ctrlr);
|
||||
|
||||
if (nbytes > max_xfer_size) {
|
||||
|
||||
@ -170,6 +170,12 @@ spdk_nvme_ns_get_sector_size(struct spdk_nvme_ns *ns)
|
||||
return ns->sector_size;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_nvme_ns_get_extended_sector_size(struct spdk_nvme_ns *ns)
|
||||
{
|
||||
return ns->extended_lba_size;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
spdk_nvme_ns_get_num_sectors(struct spdk_nvme_ns *ns)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user