@@ -7287,12 +7287,18 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
72877287 if (!nvm_ns )
72887288 return - ENOMEM ;
72897289
7290- err = nvme_identify_csi_ns (hdl , nsid , NVME_CSI_NVM , 0 ,
7291- nvm_ns );
7292- if (err )
7290+ err = nvme_identify_csi_ns (hdl , nsid , NVME_CSI_NVM , 0 , nvm_ns );
7291+ if (!err )
7292+ get_pif_sts (ns , nvm_ns , & pif , & sts );
7293+ else if (!nvme_status_equals (err , NVME_STATUS_TYPE_NVME ,
7294+ NVME_SC_INVALID_FIELD ))
7295+ /*
7296+ * Ignore the invalid field error and skip get_pif_sts().
7297+ * Keep the I/O commands behavior same as before.
7298+ * Since the error returned by drives unsupported.
7299+ */
72937300 return - ENAVAIL ;
72947301
7295- get_pif_sts (ns , nvm_ns , & pif , & sts );
72967302 pi_size = (pif == NVME_NVM_PIF_16B_GUARD ) ? 8 : 16 ;
72977303 if (NVME_FLBAS_META_EXT (ns -> flbas )) {
72987304 /*
@@ -7301,7 +7307,7 @@ static int get_pi_info(struct nvme_transport_handle *hdl,
73017307 * 5.2.2.2 Protection Information and Read Commands
73027308 */
73037309 if (!((prinfo & 0x8 ) != 0 && ms == pi_size ))
7304- logical_block_size += ms ;
7310+ lbs += ms ;
73057311 }
73067312
73077313 if (invalid_tags (lbst , ilbrt , sts , pif ))
@@ -7340,18 +7346,24 @@ static int init_pi_tags(struct nvme_transport_handle *hdl,
73407346 return - ENOMEM ;
73417347
73427348 err = nvme_identify_csi_ns (hdl , nsid , NVME_CSI_NVM , 0 , nvm_ns );
7343- if (err )
7349+ if (!err )
7350+ get_pif_sts (ns , nvm_ns , & pif , & sts );
7351+ else if (!nvme_status_equals (err , NVME_STATUS_TYPE_NVME ,
7352+ NVME_SC_INVALID_FIELD ))
7353+ /*
7354+ * Ignore the invalid field error and skip get_pif_sts().
7355+ * Keep the I/O commands behavior same as before.
7356+ * Since the error returned by drives unsupported.
7357+ */
73447358 return - ENAVAIL ;
73457359
7346- get_pif_sts (ns , nvm_ns , & pif , & sts );
7347-
73487360 if (invalid_tags (lbst , ilbrt , sts , pif ))
73497361 return - EINVAL ;
73507362
73517363 nvme_init_var_size_tags (cmd , pif , sts , ilbrt , lbst );
73527364 nvme_init_app_tag (cmd , lbat , lbatm );
73537365
7354- return err ;
7366+ return 0 ;
73557367}
73567368
73577369static int write_zeroes (int argc , char * * argv ,
0 commit comments