Skip to content

Commit 0f88488

Browse files
ikegami-tigaw
authored andcommitted
nvme: fix get_pi_info() handling for submit_io() error
If nvme_identify_csi_ns() failed so caused floating point exception. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 728cee5 commit 0f88488

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

nvme.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7245,12 +7245,18 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
72457245
if (!nvm_ns)
72467246
return -ENOMEM;
72477247

7248-
err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0,
7249-
nvm_ns);
7250-
if (err)
7248+
err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
7249+
if (!err)
7250+
get_pif_sts(ns, nvm_ns, &pif, &sts);
7251+
else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
7252+
NVME_SC_INVALID_FIELD))
7253+
/*
7254+
* Ignore the invalid field error and skip get_pif_sts().
7255+
* Keep the I/O commands behavior same as before.
7256+
* Since the error returned by drives unsupported.
7257+
*/
72517258
return -ENAVAIL;
72527259

7253-
get_pif_sts(ns, nvm_ns, &pif, &sts);
72547260
pi_size = (pif == NVME_NVM_PIF_16B_GUARD) ? 8 : 16;
72557261
if (NVME_FLBAS_META_EXT(ns->flbas)) {
72567262
/*
@@ -7259,7 +7265,7 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
72597265
* 5.2.2.2 Protection Information and Read Commands
72607266
*/
72617267
if (!((prinfo & 0x8) != 0 && ms == pi_size))
7262-
logical_block_size += ms;
7268+
lbs += ms;
72637269
}
72647270

72657271
if (invalid_tags(lbst, ilbrt, sts, pif))
@@ -7295,18 +7301,24 @@ static int init_pi_tags(struct nvme_transport_handle *hdl,
72957301
return -ENOMEM;
72967302

72977303
err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
7298-
if (err)
7304+
if (!err)
7305+
get_pif_sts(ns, nvm_ns, &pif, &sts);
7306+
else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
7307+
NVME_SC_INVALID_FIELD))
7308+
/*
7309+
* Ignore the invalid field error and skip get_pif_sts().
7310+
* Keep the I/O commands behavior same as before.
7311+
* Since the error returned by drives unsupported.
7312+
*/
72997313
return -ENAVAIL;
73007314

7301-
get_pif_sts(ns, nvm_ns, &pif, &sts);
7302-
73037315
if (invalid_tags(lbst, ilbrt, sts, pif))
73047316
return -EINVAL;
73057317

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

7309-
return err;
7321+
return 0;
73107322
}
73117323

73127324
static int write_zeroes(int argc, char **argv,

0 commit comments

Comments
 (0)