@@ -293,16 +293,17 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin
293293 const char * namespace_id = "Namespace identifier" ;
294294 const char * raw = "use binary output" ;
295295
296- _cleanup_nvme_global_ctx_ struct nvme_global_ctx * ctx = NULL ;
297296 _cleanup_nvme_transport_handle_ struct nvme_transport_handle * hdl = NULL ;
297+ _cleanup_nvme_global_ctx_ struct nvme_global_ctx * ctx = NULL ;
298298 _cleanup_free_ void * buf = NULL ;
299299 struct nvme_fdp_ruh_status hdr ;
300+ struct nvme_passthru_cmd cmd ;
300301 nvme_print_flags_t flags ;
301302 int err = -1 ;
302303 size_t len ;
303304
304305 struct config {
305- __u32 namespace_id ;
306+ __u32 nsid ;
306307 char * output_format ;
307308 bool raw_binary ;
308309 };
@@ -313,9 +314,9 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin
313314 };
314315
315316 OPT_ARGS (opts ) = {
316- OPT_UINT ("namespace-id" , 'n' , & cfg .namespace_id , namespace_id ),
317- OPT_FMT ("output-format" , 'o' , & cfg .output_format , output_format ),
318- OPT_FLAG ("raw-binary" , 'b' , & cfg .raw_binary , raw ),
317+ OPT_UINT ("namespace-id" , 'n' , & cfg .nsid , namespace_id ),
318+ OPT_FMT ("output-format" , 'o' , & cfg .output_format , output_format ),
319+ OPT_FLAG ("raw-binary" , 'b' , & cfg .raw_binary , raw ),
319320 OPT_END ()
320321 };
321322
@@ -330,16 +331,17 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin
330331 if (cfg .raw_binary )
331332 flags = BINARY ;
332333
333- if (!cfg .namespace_id ) {
334- err = nvme_get_nsid (hdl , & cfg .namespace_id );
334+ if (!cfg .nsid ) {
335+ err = nvme_get_nsid (hdl , & cfg .nsid );
335336 if (err < 0 ) {
336337 perror ("get-namespace-id" );
337338 return err ;
338339 }
339340 }
340341
341- err = nvme_fdp_reclaim_unit_handle_status (hdl ,
342- cfg .namespace_id , sizeof (hdr ), & hdr );
342+ nvme_init_fdp_reclaim_unit_handle_status (& cmd , cfg .nsid , & hdr ,
343+ sizeof (hdr ));
344+ err = nvme_submit_io_passthru (hdl , & cmd , NULL );
343345 if (err ) {
344346 nvme_show_status (err );
345347 return err ;
@@ -351,8 +353,8 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin
351353 if (!buf )
352354 return - ENOMEM ;
353355
354- err = nvme_fdp_reclaim_unit_handle_status ( hdl ,
355- cfg . namespace_id , len , buf );
356+ nvme_init_fdp_reclaim_unit_handle_status ( & cmd , cfg . nsid , buf , len );
357+ err = nvme_submit_io_passthru ( hdl , & cmd , NULL );
356358 if (err ) {
357359 nvme_show_status (err );
358360 return err ;
@@ -369,15 +371,16 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin
369371 const char * namespace_id = "Namespace identifier" ;
370372 const char * _pids = "Comma-separated list of placement identifiers to update" ;
371373
372- _cleanup_nvme_global_ctx_ struct nvme_global_ctx * ctx = NULL ;
373374 _cleanup_nvme_transport_handle_ struct nvme_transport_handle * hdl = NULL ;
375+ _cleanup_nvme_global_ctx_ struct nvme_global_ctx * ctx = NULL ;
376+ struct nvme_passthru_cmd cmd ;
374377 unsigned short pids [256 ];
375378 __u16 buf [256 ];
376- int npids ;
377379 int err = -1 ;
380+ int npids ;
378381
379382 struct config {
380- __u32 namespace_id ;
383+ __u32 nsid ;
381384 char * pids ;
382385 };
383386
@@ -386,8 +389,8 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin
386389 };
387390
388391 OPT_ARGS (opts ) = {
389- OPT_UINT ("namespace-id" , 'n' , & cfg .namespace_id , namespace_id ),
390- OPT_LIST ("pids" , 'p' , & cfg .pids , _pids ),
392+ OPT_UINT ("namespace-id" , 'n' , & cfg .nsid , namespace_id ),
393+ OPT_LIST ("pids" , 'p' , & cfg .pids , _pids ),
391394 OPT_END ()
392395 };
393396
@@ -404,8 +407,8 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin
404407 return - EINVAL ;
405408 }
406409
407- if (!cfg .namespace_id ) {
408- err = nvme_get_nsid (hdl , & cfg .namespace_id );
410+ if (!cfg .nsid ) {
411+ err = nvme_get_nsid (hdl , & cfg .nsid );
409412 if (err < 0 ) {
410413 perror ("get-namespace-id" );
411414 return err ;
@@ -415,7 +418,8 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin
415418 for (unsigned int i = 0 ; i < npids ; i ++ )
416419 buf [i ] = cpu_to_le16 (pids [i ]);
417420
418- err = nvme_fdp_reclaim_unit_handle_update (hdl , cfg .namespace_id , npids , buf );
421+ nvme_init_fdp_reclaim_unit_handle_status (& cmd , cfg .nsid , buf , npids );
422+ err = nvme_submit_io_passthru (hdl , & cmd , NULL );
419423 if (err ) {
420424 nvme_show_status (err );
421425 return err ;
0 commit comments