@@ -7359,6 +7359,40 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73597359 return err ;
73607360}
73617361
7362+ static int
7363+ identify_pif_sts (struct nvme_transport_handle * hdl ,
7364+ __u32 nsid , __u8 * pif , __u8 * sts )
7365+ {
7366+ _cleanup_free_ struct nvme_nvm_id_ns * nvm_ns = NULL ;
7367+
7368+ _cleanup_free_ struct nvme_id_ns * ns = NULL ;
7369+
7370+ int err ;
7371+
7372+ ns = nvme_alloc (sizeof (* ns ));
7373+ if (!ns )
7374+ return - ENOMEM ;
7375+
7376+ err = nvme_identify_ns (hdl , nsid , ns );
7377+ if (err > 0 ) {
7378+ nvme_show_status (err );
7379+ return err ;
7380+ } else if (err < 0 ) {
7381+ nvme_show_error ("identify namespace: %s" , nvme_strerror (- err ));
7382+ return err ;
7383+ }
7384+
7385+ nvm_ns = nvme_alloc (sizeof (* nvm_ns ));
7386+ if (!nvm_ns )
7387+ return - ENOMEM ;
7388+
7389+ err = nvme_identify_csi_ns (hdl , nsid , NVME_CSI_NVM , 0 , nvm_ns );
7390+ if (!err )
7391+ get_pif_sts (ns , nvm_ns , pif , sts );
7392+
7393+ return 0 ;
7394+ }
7395+
73627396static int copy_cmd (int argc , char * * argv , struct command * acmd , struct plugin * plugin )
73637397{
73647398 const char * desc = "The Copy command is used by the host to copy data\n"
@@ -7391,6 +7425,8 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
73917425 __u64 slbas [256 ] = { 0 };
73927426 __u32 snsids [256 ] = { 0 };
73937427 __u16 sopts [256 ] = { 0 };
7428+ __u8 pif = 0 ;
7429+ __u8 sts = 0 ;
73947430 int err ;
73957431
73967432 union {
@@ -7554,11 +7590,18 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
75547590 break ;
75557591 }
75567592
7593+ err = identify_pif_sts (hdl , cfg .namespace_id , & pif , & sts );
7594+ if (err )
7595+ return err ;
7596+
7597+ if (invalid_tags (0 , cfg .ilbrt , sts , pif ))
7598+ return - EINVAL ;
7599+
75577600 nvme_init_copy (& cmd , cfg .namespace_id , cfg .sdlba , nr , cfg .format ,
75587601 cfg .prinfor , cfg .prinfow , 0 , cfg .dtype , false, false,
75597602 cfg .fua , cfg .lr , 0 , cfg .dspec , copy -> f0 );
7560- nvme_init_var_size_tags ((struct nvme_passthru_cmd64 * )& cmd ,
7561- NVME_NVM_PIF_32B_GUARD , 0 , cfg .ilbrt , 0 );
7603+ nvme_init_var_size_tags ((struct nvme_passthru_cmd64 * )& cmd , pif , sts ,
7604+ cfg .ilbrt , 0 );
75627605 nvme_init_app_tag ((struct nvme_passthru_cmd64 * )& cmd , cfg .lbat ,
75637606 cfg .lbatm );
75647607 err = nvme_submit_io_passthru (hdl , & cmd , NULL );
0 commit comments