bdev/nvme: check passthru cmd size against MDTS
We can't split passthru commands, since we don't know how they behave, so make sure they do not exceed the NVMe controller's declared maximum data transfer size. Change-Id: I27845dcb04d98e5d64a93f66731e6ed9db5fbbe7 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/410519 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
ace321df22
commit
2aced8c74c
@ -1338,8 +1338,10 @@ bdev_nvme_admin_passthru(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||
struct nvme_bdev_io *bio,
|
||||
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes)
|
||||
{
|
||||
if (nbytes > UINT32_MAX) {
|
||||
SPDK_ERRLOG("nbytes is greater than UINT32_MAX.\n");
|
||||
uint32_t max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nbdev->nvme_ctrlr->ctrlr);
|
||||
|
||||
if (nbytes > max_xfer_size) {
|
||||
SPDK_ERRLOG("nbytes is greater than MDTS %" PRIu32 ".\n", max_xfer_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -1355,9 +1357,10 @@ bdev_nvme_io_passthru(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes)
|
||||
{
|
||||
struct nvme_io_channel *nvme_ch = spdk_io_channel_get_ctx(ch);
|
||||
uint32_t max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nbdev->nvme_ctrlr->ctrlr);
|
||||
|
||||
if (nbytes > UINT32_MAX) {
|
||||
SPDK_ERRLOG("nbytes is greater than UINT32_MAX.\n");
|
||||
if (nbytes > max_xfer_size) {
|
||||
SPDK_ERRLOG("nbytes is greater than MDTS %" PRIu32 ".\n", max_xfer_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -1378,9 +1381,10 @@ bdev_nvme_io_passthru_md(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||
{
|
||||
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);
|
||||
uint32_t max_xfer_size = spdk_nvme_ctrlr_get_max_xfer_size(nbdev->nvme_ctrlr->ctrlr);
|
||||
|
||||
if (nbytes > UINT32_MAX) {
|
||||
SPDK_ERRLOG("nbytes is greater than UINT32_MAX.\n");
|
||||
if (nbytes > max_xfer_size) {
|
||||
SPDK_ERRLOG("nbytes is greater than MDTS %" PRIu32 ".\n", max_xfer_size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user