Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -7287,12 +7287,18 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
if (!nvm_ns)
return -ENOMEM;

err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0,
nvm_ns);
if (err)
err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
if (!err)
get_pif_sts(ns, nvm_ns, &pif, &sts);
else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
NVME_SC_INVALID_FIELD))
/*
* Ignore the invalid field error and skip get_pif_sts().
* Keep the I/O commands behavior same as before.
* Since the error returned by drives unsupported.
*/
return -ENAVAIL;

get_pif_sts(ns, nvm_ns, &pif, &sts);
pi_size = (pif == NVME_NVM_PIF_16B_GUARD) ? 8 : 16;
if (NVME_FLBAS_META_EXT(ns->flbas)) {
/*
Expand All @@ -7301,7 +7307,7 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
* 5.2.2.2 Protection Information and Read Commands
*/
if (!((prinfo & 0x8) != 0 && ms == pi_size))
logical_block_size += ms;
lbs += ms;
}

if (invalid_tags(lbst, ilbrt, sts, pif))
Expand Down Expand Up @@ -7340,18 +7346,24 @@ static int init_pi_tags(struct nvme_transport_handle *hdl,
return -ENOMEM;

err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
if (err)
if (!err)
get_pif_sts(ns, nvm_ns, &pif, &sts);
else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
NVME_SC_INVALID_FIELD))
/*
* Ignore the invalid field error and skip get_pif_sts().
* Keep the I/O commands behavior same as before.
* Since the error returned by drives unsupported.
*/
return -ENAVAIL;

get_pif_sts(ns, nvm_ns, &pif, &sts);

if (invalid_tags(lbst, ilbrt, sts, pif))
return -EINVAL;

nvme_init_var_size_tags(cmd, pif, sts, ilbrt, lbst);
nvme_init_app_tag(cmd, lbat, lbatm);

return err;
return 0;
}

static int write_zeroes(int argc, char **argv,
Expand Down