@@ -7384,6 +7384,37 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73847384 return err ;
73857385}
73867386
7387+ static int identify_pif_sts (struct nvme_transport_handle * hdl ,
7388+ __u32 nsid , __u8 * pif , __u8 * sts )
7389+ {
7390+ _cleanup_free_ struct nvme_nvm_id_ns * nvm_ns = NULL ;
7391+ _cleanup_free_ struct nvme_id_ns * ns = NULL ;
7392+ int err ;
7393+
7394+ ns = nvme_alloc (sizeof (* ns ));
7395+ if (!ns )
7396+ return - ENOMEM ;
7397+
7398+ err = nvme_identify_ns (hdl , nsid , ns );
7399+ if (err > 0 ) {
7400+ nvme_show_status (err );
7401+ return err ;
7402+ } else if (err < 0 ) {
7403+ nvme_show_error ("identify namespace: %s" , nvme_strerror (- err ));
7404+ return err ;
7405+ }
7406+
7407+ nvm_ns = nvme_alloc (sizeof (* nvm_ns ));
7408+ if (!nvm_ns )
7409+ return - ENOMEM ;
7410+
7411+ err = nvme_identify_csi_ns (hdl , nsid , NVME_CSI_NVM , 0 , nvm_ns );
7412+ if (!err )
7413+ get_pif_sts (ns , nvm_ns , pif , sts );
7414+
7415+ return 0 ;
7416+ }
7417+
73877418static int copy_cmd (int argc , char * * argv , struct command * acmd , struct plugin * plugin )
73887419{
73897420 const char * desc = "The Copy command is used by the host to copy data\n"
@@ -7416,6 +7447,8 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
74167447 __u64 slbas [256 ] = { 0 };
74177448 __u32 snsids [256 ] = { 0 };
74187449 __u16 sopts [256 ] = { 0 };
7450+ __u8 pif = 0 ;
7451+ __u8 sts = 0 ;
74197452 int err ;
74207453
74217454 union {
@@ -7578,11 +7611,18 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
75787611 break ;
75797612 }
75807613
7614+ err = identify_pif_sts (hdl , cfg .namespace_id , & pif , & sts );
7615+ if (err )
7616+ return err ;
7617+
7618+ if (invalid_tags (0 , cfg .ilbrt , sts , pif ))
7619+ return - EINVAL ;
7620+
75817621 nvme_init_copy (& cmd , cfg .namespace_id , cfg .sdlba , nr , cfg .format ,
75827622 cfg .prinfor , cfg .prinfow , 0 , cfg .dtype , false, false,
75837623 cfg .fua , cfg .lr , 0 , cfg .dspec , copy -> f0 );
7584- nvme_init_var_size_tags ((struct nvme_passthru_cmd64 * )& cmd ,
7585- NVME_NVM_PIF_32B_GUARD , 0 , cfg .ilbrt , 0 );
7624+ nvme_init_var_size_tags ((struct nvme_passthru_cmd64 * )& cmd , pif , sts ,
7625+ cfg .ilbrt , 0 );
75867626 nvme_init_app_tag ((struct nvme_passthru_cmd64 * )& cmd , cfg .lbat ,
75877627 cfg .lbatm );
75887628 err = nvme_submit_io_passthru (hdl , & cmd , NULL );
0 commit comments