Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions libnvme/src/nvme/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
#define LINE_MAX 2048
#endif

/* Some error codes aren't defined on all platforms. Use best equivalents. */
#ifndef EREMOTEIO
#define EREMOTEIO ENXIO
#endif
#ifndef EDQUOT
#define EDQUOT ENOSPC
#endif
#ifndef ERESTART
#define ERESTART EAGAIN
#endif

/* Source Code Control System, query version of binary with 'what' */
const char sccsid[] = "@(#)libnvme " GIT_VERSION;

Expand Down
16 changes: 11 additions & 5 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -7371,6 +7371,12 @@ static void get_pif_sts(struct nvme_id_ns *ns, struct nvme_nvm_id_ns *nvm_ns,
*pif = (elbaf & NVME_NVM_ELBAF_QPIF_MASK) >> 9;
}

/*
* Internal return code used to flag that an invalid field error was received
* and should be ignored by the calling code.
*/
#define ERR_IGNORE_INVALID_FIELD 0x2000 /* invalid field error - ignore */

static int get_pi_info(struct libnvme_transport_handle *hdl,
__u32 nsid, __u8 prinfo, __u64 ilbrt, __u64 lbst,
unsigned int *logical_block_size, __u16 *metadata_size)
Expand Down Expand Up @@ -7412,7 +7418,7 @@ static int get_pi_info(struct libnvme_transport_handle *hdl,
* Keep the I/O commands behavior same as before.
* Since the error returned by drives unsupported.
*/
return -ENAVAIL;
return ERR_IGNORE_INVALID_FIELD;

pi_size = (pif == NVME_NVM_PIF_16B_GUARD) ? 8 : 16;
if (NVME_FLBAS_META_EXT(ns->flbas)) {
Expand Down Expand Up @@ -7467,7 +7473,7 @@ static int init_pi_tags(struct libnvme_transport_handle *hdl,
* Keep the I/O commands behavior same as before.
* Since the error returned by drives unsupported.
*/
return -ENAVAIL;
return ERR_IGNORE_INVALID_FIELD;

if (invalid_tags(lbst, ilbrt, sts, pif))
return -EINVAL;
Expand Down Expand Up @@ -7583,7 +7589,7 @@ static int write_zeroes(int argc, char **argv,

err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst, cfg.lbat,
cfg.lbatm);
if (err && err != -ENAVAIL)
if (err && err != ERR_IGNORE_INVALID_FIELD)
return err;

err = libnvme_submit_io_passthru(hdl, &cmd);
Expand Down Expand Up @@ -7926,7 +7932,7 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
cfg.fua, cfg.lr, 0, cfg.dspec, copy->f0);
err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst, cfg.lbat,
cfg.lbatm);
if (err != 0 && err != -ENAVAIL)
if (err != 0 && err != ERR_IGNORE_INVALID_FIELD)
return err;
err = libnvme_submit_io_passthru(hdl, &cmd);
if (err) {
Expand Down Expand Up @@ -8765,7 +8771,7 @@ static int verify_cmd(int argc, char **argv, struct command *acmd, struct plugin
cfg.block_count, control, 0, NULL, 0, NULL, 0);
err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst,
cfg.lbat, cfg.lbatm);
if (err != 0 && err != -ENAVAIL)
if (err != 0 && err != ERR_IGNORE_INVALID_FIELD)
return err;
err = libnvme_submit_io_passthru(hdl, &cmd);
if (err) {
Expand Down
Loading