@@ -748,7 +748,6 @@ void process_client_gfids_rpc(client_rpc_req_t* creq)
748748 // files, but only use the gfids. The client must then issue
749749 // a separate metaget request for each gfid.
750750 unifyfs_file_attr_t * file_attrs = NULL ;
751- hg_bulk_t bulk_gfids = HG_BULK_NULL ;
752751 int * new_gfid_list = NULL ;
753752 int num_file_attrs = 0 ;
754753 ret = unifyfs_invoke_broadcast_metaget_all (& file_attrs ,
@@ -759,24 +758,26 @@ void process_client_gfids_rpc(client_rpc_req_t* creq)
759758 // Package all the gfids up into one list
760759 new_gfid_list = (int * ) calloc (num_file_attrs , sizeof (int ));
761760 if (NULL != new_gfid_list ) {
762- /* initialize bulk handle for the gfid_list */
761+ for (int i = 0 ; i < num_file_attrs ; i ++ ) {
762+ new_gfid_list [i ] = file_attrs [i ].gfid ;
763+ }
763764
764- hg_size_t sizes [1 ] = { num_file_attrs * sizeof (int ) };
765- void * ptrs [1 ] = { (void * )new_gfid_list };
765+ /* initialize bulk for the gfid_list */
766+ hg_bulk_t bulk_gfids = HG_BULK_NULL ;
767+ hg_size_t bulk_sz = (hg_size_t ) num_file_attrs * sizeof (int );
766768 hret = margo_bulk_create (unifyfsd_rpc_context -> shm_mid ,
767- 1 , ptrs , sizes ,
769+ 1 , ( void * * ) & new_gfid_list , & bulk_sz ,
768770 HG_BULK_READ_ONLY , & bulk_gfids );
769771 if (hret != HG_SUCCESS ) {
770772 LOGDBG ("margo_bulk_create() failed - %s" ,
771773 HG_Error_to_string (hret ));
772774 free (new_gfid_list );
773775 ret = UNIFYFS_ERROR_MARGO ;
774776 } else {
775- for (int i = 0 ; i < num_file_attrs ; i ++ ) {
776- new_gfid_list [i ] = file_attrs [i ].gfid ;
777- }
778777 out -> bulk_gfids = bulk_gfids ;
779- creq -> req_state -> bulk = bulk_gfids ; // free on rpc cleanup
778+
779+ /* request bulk free on rpc cleanup */
780+ creq -> req_state -> bulk = bulk_gfids ;
780781 }
781782 } else {
782783 ret = ENOMEM ;
@@ -806,9 +807,38 @@ void process_client_node_local_extents_rpc(client_rpc_req_t* creq)
806807 unifyfs_node_local_extents_get_out_t * out = creq -> req_state -> outputs ;
807808 assert ((in != NULL ) && (out != NULL ));
808809
809- /* MJB TODO - rewrite to take a single gfid and return the local extents
810- * if the file is laminated and has not been reverse-synced */
811- ret = UNIFYFS_ERROR_NYI ;
810+ unifyfs_fops_ctx_t ctx = {
811+ .client_req = creq ,
812+ .app_id = in -> app_id ,
813+ .client_id = in -> client_id ,
814+ };
815+
816+ int gfid = (int ) in -> gfid ;
817+ size_t n_extents = 0 ;
818+ unifyfs_data_chunk_t * extents = NULL ;
819+ ret = unifyfs_fops_local_extents (& ctx , gfid , & n_extents , & extents );
820+ if (ret != UNIFYFS_SUCCESS ) {
821+ LOGERR ("unifyfs_fops_local_extents() failed" );
822+ } else {
823+ out -> ext_count = (hg_size_t ) n_extents ;
824+
825+ /* register user buffer for bulk access */
826+ hg_bulk_t bulk_local ;
827+ hg_size_t bulk_sz = (hg_size_t ) n_extents * sizeof (unifyfs_data_chunk_t );
828+ hg_return_t hret = margo_bulk_create (unifyfsd_rpc_context -> shm_mid ,
829+ 1 , (void * * )& extents , & bulk_sz ,
830+ HG_BULK_READ_ONLY , & bulk_local );
831+ if (hret != HG_SUCCESS ) {
832+ LOGERR ("margo_bulk_create() failed" );
833+ ret = UNIFYFS_ERROR_MARGO ;
834+ } else {
835+ out -> bulk_extents = bulk_local ;
836+ out -> bulk_size = bulk_sz ;
837+
838+ /* request bulk free on rpc cleanup */
839+ creq -> req_state -> bulk = bulk_local ;
840+ }
841+ }
812842
813843 out -> ret = (int32_t ) ret ;
814844
@@ -1163,7 +1193,7 @@ static void unifyfs_node_local_extents_get_rpc(hg_handle_t handle)
11631193 if (NULL == creq ) {
11641194 unifyfs_node_local_extents_get_out_t out ;
11651195 out .ret = (int32_t ) ENOMEM ;
1166- out .chunk_count = 0 ;
1196+ out .ext_count = 0 ;
11671197 hg_return_t hret = margo_respond (handle , & out );
11681198 if (hret != HG_SUCCESS ) {
11691199 LOGERR ("margo_respond() failed - %s" , HG_Error_to_string (hret ));
0 commit comments