test/nvme: allocate separate metadata buffer when enable PRACT

The specification says when PRACT is 1 and metadata size is 8, the
controller generates and appends protection information to the end
of the logical block data, this looks like only valid for extended
LBA format, but from real test with different drives, for separate
metadata case, some drives require host allocated buffer while some
not, for metadata bigger than 8 bytes cases, they all need host
buffer, so we allocate this buffer in host for all cases here.

Change-Id: I1aca8eb84e089ff5819a5f2680409c193847c40b
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1391
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Changpeng Liu 2020-03-19 21:28:35 -04:00 committed by Tomasz Zawadzki
parent 63d55304e8
commit 2cf937fb92

View File

@ -174,17 +174,29 @@ static uint32_t dp_guard_check_extended_lba_test(struct spdk_nvme_ns *ns, struct
static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *req,
uint32_t *io_flags)
{
uint32_t sector_size;
uint32_t md_size, sector_size, data_len;
req->lba_count = 8;
sector_size = spdk_nvme_ns_get_sector_size(ns);
/* No additional metadata buffer provided */
req->contig = spdk_zmalloc(sector_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
md_size = spdk_nvme_ns_get_md_size(ns);
if (md_size == 8) {
/* No additional metadata buffer provided */
data_len = sector_size * req->lba_count;
} else {
data_len = (sector_size + md_size) * req->lba_count;
}
req->contig = spdk_zmalloc(data_len, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
SPDK_MALLOC_DMA);
if (!req->contig) {
return 0;
}
req->metadata = spdk_zmalloc(md_size * req->lba_count, 0x1000, NULL, SPDK_ENV_LCORE_ID_ANY,
SPDK_MALLOC_DMA);
if (!req->metadata) {
spdk_free(req->contig);
return 0;
}
switch (spdk_nvme_ns_get_pi_type(ns)) {
case SPDK_NVME_FMT_NVM_PROTECTION_TYPE3:
@ -202,7 +214,6 @@ static uint32_t dp_with_pract_test(struct spdk_nvme_ns *ns, struct io_request *r
req->lba = 0x100000;
req->use_extended_lba = false;
req->metadata = NULL;
return req->lba_count;
}