diff options
-rw-r--r-- | src/H5FPclient.c | 78 | ||||
-rw-r--r-- | src/H5FPprivate.h | 18 | ||||
-rw-r--r-- | src/H5FPserver.c | 281 |
3 files changed, 201 insertions, 176 deletions
diff --git a/src/H5FPclient.c b/src/H5FPclient.c index 0ddaafe..0abbcb2 100644 --- a/src/H5FPclient.c +++ b/src/H5FPclient.c @@ -42,7 +42,7 @@ static int interface_initialize_g = 0; /* local functions */ static unsigned H5FP_gen_request_id(void); -static herr_t H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id, H5FP_read *sap_read); +static herr_t H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id); /* *===----------------------------------------------------------------------=== @@ -69,7 +69,7 @@ static herr_t H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id, H5FP_read *sap_read * Modifications: */ herr_t -H5FP_request_open(H5FP_obj_t obj_type, MPI_Offset maxaddr, +H5FP_request_open(H5FP_obj_t obj_type, haddr_t maxaddr, unsigned long feature_flags, hsize_t meta_block_size, hsize_t sdata_block_size, hsize_t threshold, hsize_t alignment, unsigned *file_id, unsigned *req_id) @@ -111,11 +111,12 @@ H5FP_request_open(H5FP_obj_t obj_type, MPI_Offset maxaddr, if ((mrc = MPI_Send(&req, 1, H5FP_request_t, (int)H5FP_sap_rank, H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); - } - if ((mrc = MPI_Recv(file_id, 1, MPI_UNSIGNED, (int)H5FP_sap_rank, - H5FP_TAG_FILE_ID, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); + if ((mrc = MPI_Recv(file_id, 1, MPI_UNSIGNED, (int)H5FP_sap_rank, + H5FP_TAG_FILE_ID, H5FP_SAP_COMM, + &mpi_status)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); + } done: *req_id = req.req_id; @@ -288,7 +289,7 @@ H5FP_request_read_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, unsigned *req_id, H5FP_status_t *status) { H5FP_request req; - H5FP_read sap_read; /* metadata info read from the SAP's cache */ + H5FP_read sap_read; MPI_Status mpi_status; int mrc, my_rank; herr_t ret_value = SUCCEED; @@ -345,7 +346,7 @@ H5FP_request_read_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, * the file. We fall through because at this point the metadata * won't be cached on the server anymore. */ - if (H5FP_dump_to_file(file, dxpl_id, &sap_read) == FAIL) + if (H5FP_dump_to_file(file, dxpl_id) == FAIL) HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, "can't write metadata update to file"); /* FALLTHROUGH */ @@ -388,7 +389,6 @@ H5FP_request_write_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, unsigned *req_id, H5FP_status_t *status) { H5FP_reply sap_reply; - H5FP_read sap_read; /* metadata info read from the SAP's cache */ MPI_Status mpi_status; H5FP_request req; int mrc, my_rank; @@ -443,13 +443,7 @@ H5FP_request_write_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, * FIXME: This is probably too much of a hack and could be fixed * for read/write/closing instances... */ - if ((mrc = MPI_Recv(&sap_read, 1, H5FP_read_t, (int)H5FP_sap_rank, - H5FP_TAG_READ, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) { - *status = H5FP_STATUS_DUMPING_FAILED; - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - } - - if (H5FP_dump_to_file(file, dxpl_id, &sap_read) == FAIL) { + if (H5FP_dump_to_file(file, dxpl_id) == FAIL) { *status = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, "can't write metadata update to file"); @@ -488,7 +482,6 @@ H5FP_request_flush_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, unsigned *req_id, H5FP_status_t *status) { H5FP_reply sap_reply; - H5FP_read sap_read; /* metadata info read from the SAP's cache */ H5FP_request req; MPI_Status mpi_status; int mrc, my_rank; @@ -530,18 +523,9 @@ H5FP_request_flush_metadata(H5FD_t *file, unsigned file_id, hid_t dxpl_id, * Collect the metadata updates from the SAP and write them to * the file. The function which sends us the dumping data sends * it to us as an H5FP_read object instead of the H5FP_reply - * object we got above. So we need this "extra" read. - * - * FIXME: This is probably too much of a hack and could be fixed - * for read/write/closing instances... + * object we got above. */ - if ((mrc = MPI_Recv(&sap_read, 1, H5FP_read_t, (int)H5FP_sap_rank, - H5FP_TAG_READ, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) { - *status = H5FP_STATUS_DUMPING_FAILED; - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - } - - if (H5FP_dump_to_file(file, dxpl_id, &sap_read) == FAIL) { + if (H5FP_dump_to_file(file, dxpl_id) == FAIL) { *status = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, "can't write metadata update to file"); @@ -760,8 +744,9 @@ H5FP_gen_request_id() * Modifications: */ static herr_t -H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id, H5FP_read *sap_read) +H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id) { + H5FP_read sap_read; hid_t new_dxpl_id = FAIL; H5P_genplist_t *plist = NULL, *old_plist; unsigned dumping = 1; @@ -771,7 +756,6 @@ H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id, H5FP_read *sap_read) /* check args */ assert(file); - assert(sap_read); if ((old_plist = H5I_object(dxpl_id)) == NULL) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist"); @@ -797,29 +781,41 @@ H5FP_dump_to_file(H5FD_t *file, hid_t dxpl_id, H5FP_read *sap_read) * dumping info to us. There's a metadata read waiting for us right * now... */ - do { + for (;;) { MPI_Status mpi_status; int mrc; char *mdata; - if (H5FP_read_metadata(&mdata, (int)sap_read->md_size, + HDmemset(&mpi_status, 0, sizeof(mpi_status)); + + if ((mrc = MPI_Recv(&sap_read, 1, H5FP_read_t, (int)H5FP_sap_rank, + H5FP_TAG_DUMP, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); + + if (sap_read.status != H5FP_STATUS_DUMPING) { + if (sap_read.status == H5FP_STATUS_DUMPING_FINISHED) + break; + + /* FIXME: ERROR */ + } + + if (H5FP_read_metadata(&mdata, (int)sap_read.md_size, (int)H5FP_sap_rank) != FAIL) { - /* FIXME: Write to the file with this metadata */ + if (H5FD_fphdf5_write_real(file, dxpl_id, sap_read.addr, + (int)sap_read.md_size, mdata) == FAIL) { + HDfree(mdata); + HGOTO_ERROR(H5E_FPHDF5, H5E_WRITEERROR, FAIL, "can't write metadata to file"); + } + HDfree(mdata); } else { /* FIXME: Error */ } - - HDmemset(&mpi_status, 0, sizeof(mpi_status)); - - if ((mrc = MPI_Recv(sap_read, 1, H5FP_read_t, (int)H5FP_sap_rank, H5FP_TAG_READ, - H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc); - } while (sap_read->status != H5FP_STATUS_DUMPING_FINISHED); + } done: if (plist) - /* FIXME: What can I do if this fail?? */ + /* FIXME: What can I do if this fails?? */ H5P_close(plist); FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5FPprivate.h b/src/H5FPprivate.h index f34278f..c033182 100644 --- a/src/H5FPprivate.h +++ b/src/H5FPprivate.h @@ -111,6 +111,7 @@ enum { H5FP_TAG_READ, H5FP_TAG_METADATA, H5FP_TAG_ALLOC, + H5FP_TAG_DUMP, H5FP_TAG_FILE_ID }; @@ -173,12 +174,12 @@ typedef struct { H5FP_lock_t rw_lock; /* Indicates read or write lock */ H5FD_mem_t mem_type; /* Type of memory updated, if req'd */ unsigned md_size; /* Size of the metadata sent in next msg */ - MPI_Offset addr; /* Address of the metadata */ unsigned long feature_flags; /* Feature flags for the file driver */ hsize_t meta_block_size; /* Metadata block size */ hsize_t sdata_block_size; /* Small data block size */ hsize_t threshold; /* Alignment threshold */ hsize_t alignment; /* Alignment (really!) */ + haddr_t addr; /* Address of the metadata */ unsigned char oid[H5R_OBJ_REF_BUF_SIZE]; /* Buffer to store OID of object */ } H5FP_request; @@ -241,6 +242,7 @@ extern MPI_Comm H5FP_SAP_BARRIER_COMM; /* Comm if you want to do a barrier */ extern unsigned H5FP_sap_rank; /* The rank of the SAP: Supplied by user */ extern unsigned H5FP_capt_rank; /* The rank which tells SAP of opens */ +extern unsigned H5FP_capt_barrier_rank;/* Rank of captain in barrier comm */ #ifdef __cplusplus extern "C" { @@ -250,11 +252,15 @@ extern "C" { extern herr_t H5FP_sap_receive_loop(void); /* Use these functions to communicate with the SAP */ -extern herr_t H5FP_request_open(H5FP_obj_t obj_type, MPI_Offset maxaddr, - unsigned long feature_flags, hsize_t - meta_block_size, hsize_t sdata_block_size, - hsize_t threshold, hsize_t alignment, - unsigned *file_id, unsigned *req_id); +extern herr_t H5FP_request_open(H5FP_obj_t obj_type, + haddr_t maxaddr, + unsigned long feature_flags, + hsize_t meta_block_size, + hsize_t sdata_block_size, + hsize_t threshold, + hsize_t alignment, + unsigned *file_id, + unsigned *req_id); extern herr_t H5FP_request_lock(unsigned sap_file_id, unsigned char *mdata, H5FP_lock_t rw_lock, int last, unsigned *req_id, H5FP_status_t *status); diff --git a/src/H5FPserver.c b/src/H5FPserver.c index b1cf6af..3d3913f 100644 --- a/src/H5FPserver.c +++ b/src/H5FPserver.c @@ -82,15 +82,15 @@ typedef struct { *===----------------------------------------------------------------------=== * * This has all the information the SAP cares about for a given file: a - * copy of the H5FD_t structure for keeping track of metadata allocations - * in the file, the file ID assigned by the SAP, whether the file is in - * the process of being closed (and, therefore, can't accept anymore - * modifications), a count of the number of modifications not written to - * the file, a list of modifications (writes) made by clients to the - * metadata, and a list of current locks on objects in the file. + * copy of the H5FD_fphdf5_t structure for keeping track of metadata + * allocations in the file, the file ID assigned by the SAP, whether the + * file is in the process of being closed (and, therefore, can't accept + * anymore modifications), a count of the number of modifications not + * written to the file, a list of modifications (writes) made by clients + * to the metadata, and a list of current locks on objects in the file. */ typedef struct { - H5FD_t file; /* file driver structure */ + H5FD_fphdf5_t file; /* file driver structure */ unsigned file_id; /* the file id the SAP keeps per file */ int closing; /* we're closing the file - no more changes */ unsigned num_mods; /* number of mdata writes outstanding */ @@ -127,37 +127,40 @@ static herr_t H5FP_remove_object_lock_from_list(H5FP_file_info *info, H5FP_object_lock *ol); /* local file information handling functions */ -static herr_t H5FP_add_new_file_info_to_list(unsigned file_id, MPI_Offset maxaddr, - unsigned long feature_flags, - hsize_t meta_block_size, - hsize_t sdata_block_size, - hsize_t threshold, - hsize_t alignment); -static int H5FP_file_info_cmp(H5FP_file_info *k1, H5FP_file_info *k2, int cmparg); -static H5FP_file_info *H5FP_new_file_info_node(unsigned file_id); -static H5FP_file_info *H5FP_find_file_info(unsigned file_id); -static herr_t H5FP_remove_file_id_from_list(unsigned file_id); -static herr_t H5FP_free_file_info_node(H5FP_file_info *info); +static herr_t H5FP_add_new_file_info_to_list(unsigned file_id, + haddr_t maxaddr, + unsigned long feature_flags, + hsize_t meta_block_size, + hsize_t sdata_block_size, + hsize_t threshold, + hsize_t alignment); +static int H5FP_file_info_cmp(H5FP_file_info *k1, + H5FP_file_info *k2, + int cmparg); +static herr_t H5FP_remove_file_id_from_list(unsigned file_id); +static herr_t H5FP_free_file_info_node(H5FP_file_info *info); +static H5FP_file_info *H5FP_new_file_info_node(unsigned file_id); +static H5FP_file_info *H5FP_find_file_info(unsigned file_id); /* local file modification structure handling functions */ -static H5FP_mdata_mod *H5FP_new_file_mod_node(unsigned rank, +static H5FP_mdata_mod *H5FP_new_file_mod_node(unsigned rank, H5FD_mem_t mem_type, - MPI_Offset addr, + haddr_t addr, unsigned md_size, char *metadata); -static herr_t H5FP_free_mod_node(H5FP_mdata_mod *info); +static herr_t H5FP_free_mod_node(H5FP_mdata_mod *info); /* local request handling functions */ -static herr_t H5FP_sap_handle_open_request(H5FP_request req, unsigned md_size); -static herr_t H5FP_sap_handle_lock_request(H5FP_request req); -static herr_t H5FP_sap_handle_release_lock_request(H5FP_request req); -static herr_t H5FP_sap_handle_read_request(H5FP_request req); -static herr_t H5FP_sap_handle_write_request(H5FP_request req, - char *mdata, - unsigned md_size); -static herr_t H5FP_sap_handle_flush_request(H5FP_request req); -static herr_t H5FP_sap_handle_close_request(H5FP_request req); -static herr_t H5FP_sap_handle_alloc_request(H5FP_request req); +static herr_t H5FP_sap_handle_open_request(H5FP_request *req, unsigned md_size); +static herr_t H5FP_sap_handle_lock_request(H5FP_request *req); +static herr_t H5FP_sap_handle_release_lock_request(H5FP_request *req); +static herr_t H5FP_sap_handle_read_request(H5FP_request *req); +static herr_t H5FP_sap_handle_write_request(H5FP_request *req, + char *mdata, + unsigned md_size); +static herr_t H5FP_sap_handle_flush_request(H5FP_request *req); +static herr_t H5FP_sap_handle_close_request(H5FP_request *req); +static herr_t H5FP_sap_handle_alloc_request(H5FP_request *req); /* *===----------------------------------------------------------------------=== @@ -182,6 +185,7 @@ H5FP_sap_receive_loop(void) herr_t ret_value = SUCCEED; int comm_size; int stop = 0; + H5FP_request req; FUNC_ENTER_NOAPI(H5FP_sap_receive_loop, FAIL); @@ -195,7 +199,6 @@ H5FP_sap_receive_loop(void) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTMAKETREE, FAIL, "cannot make TBBT tree"); for (;;) { - H5FP_request req; char *buf = NULL; herr_t hrc; @@ -204,33 +207,34 @@ H5FP_sap_receive_loop(void) switch (req.req_type) { case H5FP_REQ_OPEN: - if ((hrc = H5FP_sap_handle_open_request(req, req.md_size)) != SUCCEED) + if ((hrc = H5FP_sap_handle_open_request(&req, req.md_size)) != SUCCEED) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTOPENOBJ, FAIL, "cannot open file"); break; case H5FP_REQ_LOCK: case H5FP_REQ_LOCK_END: - hrc = H5FP_sap_handle_lock_request(req); + hrc = H5FP_sap_handle_lock_request(&req); break; case H5FP_REQ_RELEASE: case H5FP_REQ_RELEASE_END: - hrc = H5FP_sap_handle_release_lock_request(req); - break; - case H5FP_REQ_WRITE: - hrc = H5FP_sap_handle_write_request(req, buf, req.md_size); + hrc = H5FP_sap_handle_release_lock_request(&req); break; case H5FP_REQ_READ: - hrc = H5FP_sap_handle_read_request(req); + hrc = H5FP_sap_handle_read_request(&req); + break; + case H5FP_REQ_WRITE: + hrc = H5FP_sap_handle_write_request(&req, buf, req.md_size); break; case H5FP_REQ_FLUSH: - hrc = H5FP_sap_handle_flush_request(req); + hrc = H5FP_sap_handle_flush_request(&req); break; case H5FP_REQ_CLOSE: - hrc = H5FP_sap_handle_close_request(req); + hrc = H5FP_sap_handle_close_request(&req); break; case H5FP_REQ_ALLOC: - hrc = H5FP_sap_handle_alloc_request(req); + hrc = H5FP_sap_handle_alloc_request(&req); break; case H5FP_REQ_STOP: + hrc = SUCCEED; if (++stop == comm_size - 1) goto done; break; @@ -241,8 +245,9 @@ H5FP_sap_receive_loop(void) /* * If the above calls didn't succeed, free the buffer */ - if (hrc != SUCCEED) + if (hrc != SUCCEED) { HDfree(buf); + } } done: @@ -463,7 +468,7 @@ H5FP_free_mod_node(H5FP_mdata_mod *info) */ static H5FP_mdata_mod * H5FP_new_file_mod_node(unsigned UNUSED rank, H5FD_mem_t mem_type, - MPI_Offset addr, unsigned md_size, char *metadata) + haddr_t addr, unsigned md_size, char *metadata) { H5FP_mdata_mod *ret_value = NULL; @@ -494,7 +499,7 @@ done: */ static herr_t H5FP_add_file_mod_to_list(H5FP_file_info *info, H5FD_mem_t mem_type, - MPI_Offset addr, unsigned rank, unsigned md_size, + haddr_t addr, unsigned rank, unsigned md_size, char *metadata) { H5FP_mdata_mod *fm, mod; @@ -503,6 +508,7 @@ H5FP_add_file_mod_to_list(H5FP_file_info *info, H5FD_mem_t mem_type, FUNC_ENTER_NOINIT(H5FP_add_file_mod_to_list); + /* check args */ assert(info); mod.addr = addr; /* This is the key field for the TBBT */ @@ -517,14 +523,16 @@ H5FP_add_file_mod_to_list(H5FP_file_info *info, H5FD_mem_t mem_type, HDfree(fm->metadata); fm->metadata = metadata; fm->md_size = md_size; - ret_value = SUCCEED; - } else if ((fm = H5FP_new_file_mod_node(rank, mem_type, addr, - md_size, metadata)) != NULL) { + HGOTO_DONE(SUCCEED); + } + + if ((fm = H5FP_new_file_mod_node(rank, mem_type, addr, md_size, metadata)) != NULL) { if (!H5TB_dins(info->mod_tree, (void *)fm, NULL)) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert modification into tree"); - ret_value = SUCCEED; + ++info->num_mods; + HGOTO_DONE(SUCCEED); } done: @@ -547,7 +555,7 @@ H5FP_free_file_info_node(H5FP_file_info *info) if (info) { H5TB_dfree(info->mod_tree, (void (*)(void*))H5FP_free_mod_node, NULL); H5TB_dfree(info->locks, (void (*)(void*))H5FP_free_object_lock, NULL); - H5FD_free_freelist(&info->file); + H5FD_free_freelist(&info->file.pub); HDfree(info); } @@ -646,7 +654,7 @@ H5FP_find_file_info(unsigned file_id) * Modifications: */ static herr_t -H5FP_add_new_file_info_to_list(unsigned file_id, MPI_Offset maxaddr, +H5FP_add_new_file_info_to_list(unsigned file_id, haddr_t maxaddr, unsigned long feature_flags, hsize_t meta_block_size, hsize_t sdata_block_size, @@ -659,6 +667,8 @@ H5FP_add_new_file_info_to_list(unsigned file_id, MPI_Offset maxaddr, FUNC_ENTER_NOINIT(H5FP_add_new_file_info_to_list); if ((info = H5FP_new_file_info_node(file_id)) != NULL) { + int mrc; + if (!H5TB_dins(file_info_tree, (void *)info, NULL)) { H5FP_free_file_info_node(info); HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, @@ -669,15 +679,23 @@ H5FP_add_new_file_info_to_list(unsigned file_id, MPI_Offset maxaddr, * Initialize some of the information needed for metadata * allocation requests */ - HDmemset(info->file.fl, 0, sizeof(info->file.fl)); - info->file.cls = &H5FD_fphdf5_g; - info->file.maxaddr = maxaddr; - info->file.accum_loc = HADDR_UNDEF; - info->file.feature_flags = feature_flags; - info->file.def_meta_block_size = meta_block_size; - info->file.def_sdata_block_size = sdata_block_size; - info->file.threshold = threshold; - info->file.alignment = alignment; + HDmemset(&info->file, 0, sizeof(info->file)); + info->file.pub.driver_id = H5FD_FPHDF5; + info->file.pub.cls = &H5FD_fphdf5_g; + info->file.pub.maxaddr = maxaddr; + info->file.pub.accum_loc = HADDR_UNDEF; + info->file.pub.feature_flags = feature_flags; + info->file.pub.def_meta_block_size = meta_block_size; + info->file.pub.def_sdata_block_size = sdata_block_size; + info->file.pub.threshold = threshold; + info->file.pub.alignment = alignment; + + if ((mrc = MPI_Comm_rank(H5FP_SAP_COMM, &info->file.mpi_rank)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); + + if ((mrc = MPI_Comm_size(H5FP_SAP_COMM, &info->file.mpi_size)) != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mrc); + ret_value = SUCCEED; } @@ -791,7 +809,7 @@ H5FP_dump(H5FP_file_info *info, unsigned to, unsigned req_id, unsigned file_id) r.addr = m->addr; r.md_size = m->md_size; - if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)to, H5FP_TAG_REPLY, + if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)to, H5FP_TAG_DUMP, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); @@ -808,12 +826,17 @@ H5FP_dump(H5FP_file_info *info, unsigned to, unsigned req_id, unsigned file_id) r.md_size = 0; r.status = H5FP_STATUS_DUMPING_FINISHED; - if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)to, H5FP_TAG_REPLY, + if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)to, H5FP_TAG_DUMP, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); /* Free up the modification tree */ H5TB_dfree(info->mod_tree, (void (*)(void*))H5FP_free_mod_node, NULL); + + if ((info->mod_tree = H5TB_dmake((H5TB_cmp_t)H5FP_file_mod_cmp, + sizeof(H5FP_mdata_mod), FALSE)) == NULL) + HGOTO_ERROR(H5E_FPHDF5, H5E_CANTMAKETREE, NULL, "cannot make TBBT tree"); + info->mod_tree = NULL; info->num_mods = 0; @@ -852,25 +875,25 @@ H5FP_gen_sap_file_id() * Modifications: */ static herr_t -H5FP_sap_handle_open_request(H5FP_request req, unsigned UNUSED md_size) +H5FP_sap_handle_open_request(H5FP_request *req, unsigned UNUSED md_size) { herr_t ret_value = SUCCEED; int mrc; FUNC_ENTER_NOINIT(H5FP_sap_handle_open_request); - if (req.obj_type == H5FP_OBJ_FILE) { + if (req->obj_type == H5FP_OBJ_FILE) { unsigned new_file_id = H5FP_gen_sap_file_id(); - /* N.B. At this point, req.addr is equiv. to maxaddr in H5FD_open() */ - if (H5FP_add_new_file_info_to_list(new_file_id, req.addr, req.feature_flags, - req.meta_block_size, req.sdata_block_size, - req.threshold, req.alignment) != SUCCEED) + /* N.B. At this point, req->addr is equiv. to maxaddr in H5FD_open() */ + if (H5FP_add_new_file_info_to_list(new_file_id, req->addr, req->feature_flags, + req->meta_block_size, req->sdata_block_size, + req->threshold, req->alignment) != SUCCEED) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL, "can't insert new file structure to list"); /* file ID gets broadcast via the captain process */ - if ((mrc = MPI_Send(&new_file_id, 1, MPI_UNSIGNED, (int)H5FP_capt_rank, + if ((mrc = MPI_Send(&new_file_id, 1, MPI_UNSIGNED, (int)req->proc_rank, H5FP_TAG_FILE_ID, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); } @@ -895,10 +918,10 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_lock_request(H5FP_request req) +H5FP_sap_handle_lock_request(H5FP_request *req) { struct lock_group { - unsigned char oid[sizeof(req.oid)]; + unsigned char oid[sizeof(req->oid)]; unsigned file_id; unsigned locked; H5FP_lock_t rw_lock; @@ -923,7 +946,7 @@ H5FP_sap_handle_lock_request(H5FP_request req) * at one time. */ for (i = 0;; ++i) { - if (req.oid[0]) { + if (req->oid[0]) { if (i == list_size) { list_size <<= 1; /* equiv to list_size *= 2; */ oids = HDrealloc(oids, list_size * sizeof(struct lock_group)); @@ -934,17 +957,17 @@ H5FP_sap_handle_lock_request(H5FP_request req) } } - H5FP_COPY_OID(oids[i].oid, req.oid); - oids[i].file_id = req.file_id; - oids[i].rw_lock = req.rw_lock; + H5FP_COPY_OID(oids[i].oid, req->oid); + oids[i].file_id = req->file_id; + oids[i].rw_lock = req->rw_lock; oids[i].locked = FALSE; } - if (req.req_type == H5FP_REQ_LOCK_END) + if (req->req_type == H5FP_REQ_LOCK_END) /* this was the last lock request */ break; - if (H5FP_sap_receive(&req, (int)req.proc_rank, + if (H5FP_sap_receive(req, (int)req->proc_rank, H5FP_TAG_REQUEST, NULL) != SUCCEED) { exit_state = H5FP_STATUS_LOCK_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_CANTRECV, FAIL, "cannot receive messages"); @@ -980,7 +1003,7 @@ H5FP_sap_handle_lock_request(H5FP_request req) oids[j].lock->rw_lock == H5FP_LOCK_READ) || (oids[j].rw_lock == H5FP_LOCK_WRITE && oids[j].lock->rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->owned_rank == req.proc_rank))) { + oids[j].lock->owned_rank == req->proc_rank))) { /* FAILURE */ exit_state = H5FP_STATUS_LOCK_FAILED; HGOTO_DONE(FAIL); @@ -1010,7 +1033,7 @@ H5FP_sap_handle_lock_request(H5FP_request req) oids[j].lock->rw_lock == H5FP_LOCK_READ) || (oids[j].rw_lock == H5FP_LOCK_WRITE && oids[j].lock->rw_lock == H5FP_LOCK_WRITE && - oids[j].lock->owned_rank == req.proc_rank)) { + oids[j].lock->owned_rank == req->proc_rank)) { /* * The requesting process may already have this lock. Might * be a request from some call-back function of some sort. @@ -1026,8 +1049,8 @@ H5FP_sap_handle_lock_request(H5FP_request req) goto rollback; } } else { - H5FP_object_lock *lock = H5FP_new_object_lock(oids[j].oid, req.proc_rank, - req.obj_type, req.rw_lock); + H5FP_object_lock *lock = H5FP_new_object_lock(oids[j].oid, req->proc_rank, + req->obj_type, req->rw_lock); if (lock) { if (!H5TB_dins(oids[j].info->locks, (void *)lock, NULL)) { @@ -1064,7 +1087,7 @@ rollback: for (j = 0; j <= i; ++j) { if (oids[j].locked) { if (oids[j].lock) { - if (oids[j].lock->owned_rank == req.proc_rank) { + if (oids[j].lock->owned_rank == req->proc_rank) { if (--oids[j].lock->ref_count == 0) { H5FP_remove_object_lock_from_list(oids[j].info, oids[j].lock); } @@ -1088,7 +1111,7 @@ HDfprintf(stderr, "%s: locking failure (%d)!!\n", FUNC, ret_value); } HDfree(oids); - H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, exit_state); + H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); FUNC_LEAVE_NOAPI(ret_value); } @@ -1100,10 +1123,10 @@ HDfprintf(stderr, "%s: locking failure (%d)!!\n", FUNC, ret_value); * Modifications: */ static herr_t -H5FP_sap_handle_release_lock_request(H5FP_request req) +H5FP_sap_handle_release_lock_request(H5FP_request *req) { struct release_group { - unsigned char oid[sizeof(req.oid)]; + unsigned char oid[sizeof(req->oid)]; unsigned file_id; H5FP_file_info *info; H5FP_object_lock *lock; @@ -1126,7 +1149,7 @@ H5FP_sap_handle_release_lock_request(H5FP_request req) * release locks at one time. */ for (i = 0;; ++i) { - if (req.oid[0]) { + if (req->oid[0]) { if (i == list_size) { list_size <<= 1; /* equiv to list_size *= 2; */ oids = HDrealloc(oids, list_size * sizeof(struct release_group)); @@ -1137,15 +1160,15 @@ H5FP_sap_handle_release_lock_request(H5FP_request req) } } - H5FP_COPY_OID(oids[i].oid, req.oid); - oids[i].file_id = req.file_id; + H5FP_COPY_OID(oids[i].oid, req->oid); + oids[i].file_id = req->file_id; } - if (req.req_type == H5FP_REQ_RELEASE_END) + if (req->req_type == H5FP_REQ_RELEASE_END) /* this was the last lock request */ break; - if (H5FP_sap_receive(&req, (int)req.proc_rank, H5FP_TAG_REQUEST, NULL) != SUCCEED) { + if (H5FP_sap_receive(req, (int)req->proc_rank, H5FP_TAG_REQUEST, NULL) != SUCCEED) { exit_state = H5FP_STATUS_LOCK_RELEASE_FAILED; HGOTO_DONE(FAIL); } @@ -1163,7 +1186,7 @@ H5FP_sap_handle_release_lock_request(H5FP_request req) oids[j].lock = H5FP_find_object_lock(oids[j].info, oids[j].oid); - if (!oids[j].lock || oids[j].lock->owned_rank != req.proc_rank) { + if (!oids[j].lock || oids[j].lock->owned_rank != req->proc_rank) { exit_state = H5FP_STATUS_BAD_LOCK; HGOTO_DONE(FAIL); } @@ -1176,7 +1199,7 @@ H5FP_sap_handle_release_lock_request(H5FP_request req) */ for (j = 0; j <= i; ++j) { if (oids[j].lock) { - if (oids[j].lock->owned_rank == req.proc_rank) { + if (oids[j].lock->owned_rank == req->proc_rank) { if (--oids[j].lock->ref_count == 0) H5FP_remove_object_lock_from_list(oids[j].info, oids[j].lock); } else { @@ -1193,7 +1216,7 @@ H5FP_sap_handle_release_lock_request(H5FP_request req) done: HDfree(oids); - H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, exit_state); + H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); FUNC_LEAVE_NOAPI(ret_value); } @@ -1209,7 +1232,7 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_read_request(H5FP_request req) +H5FP_sap_handle_read_request(H5FP_request *req) { H5FP_file_info *info; H5FP_read r; @@ -1219,18 +1242,18 @@ H5FP_sap_handle_read_request(H5FP_request req) FUNC_ENTER_NOINIT(H5FP_sap_handle_read_request); - r.req_id = req.req_id; - r.file_id = req.file_id; + r.req_id = req->req_id; + r.file_id = req->file_id; r.md_size = 0; r.addr = 0; r.status = H5FP_STATUS_MDATA_NOT_CACHED; - if ((info = H5FP_find_file_info(req.file_id)) != NULL) { + if ((info = H5FP_find_file_info(req->file_id)) != NULL) { H5FP_mdata_mod mod; /* Used to find the correct modification */ H5TB_NODE *node; if (info->num_mods >= H5FP_MDATA_CACHE_HIGHWATER_MARK) { - if (H5FP_dump(info, req.proc_rank, req.req_id, req.file_id) == FAIL) + if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't dump metadata to client"); @@ -1241,7 +1264,7 @@ H5FP_sap_handle_read_request(H5FP_request req) HGOTO_DONE(SUCCEED); } - mod.addr = req.addr; /* This is the key field for the TBBT */ + mod.addr = req->addr; /* This is the key field for the TBBT */ if ((node = H5TB_dfind(info->mod_tree, (void *)&mod, NULL)) != NULL) { H5FP_mdata_mod *fm = (H5FP_mdata_mod *)node->data; @@ -1253,12 +1276,12 @@ H5FP_sap_handle_read_request(H5FP_request req) } } - if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)req.proc_rank, + if ((mrc = MPI_Send(&r, 1, H5FP_read_t, (int)req->proc_rank, H5FP_TAG_READ, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); if (r.md_size) - if (H5FP_send_metadata(metadata, (int)r.md_size, (int)req.proc_rank) != SUCCEED) + if (H5FP_send_metadata(metadata, (int)r.md_size, (int)req->proc_rank) != SUCCEED) HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't send metadata to client"); @@ -1281,7 +1304,7 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) +H5FP_sap_handle_write_request(H5FP_request *req, char *mdata, unsigned md_size) { H5FP_file_info *info; H5FP_status_t exit_state = H5FP_STATUS_OK; @@ -1289,7 +1312,7 @@ H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) FUNC_ENTER_NOINIT(H5FP_sap_handle_write_request); - if ((info = H5FP_find_file_info(req.file_id)) != NULL) { + if ((info = H5FP_find_file_info(req->file_id)) != NULL) { #if 0 H5FP_object_lock *lock; #endif /* 0 */ @@ -1299,14 +1322,14 @@ H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) * If there are any modifications not written out yet, dump * them to this process */ - if (H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, + if (H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, H5FP_STATUS_DUMPING) == FAIL) { exit_state = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't send message to client"); } - if (H5FP_dump(info, req.proc_rank, req.req_id, req.file_id) == FAIL) { + if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) { exit_state = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "metadata dump failed"); @@ -1326,9 +1349,9 @@ H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) */ /* handle the change request */ - lock = H5FP_find_object_lock(info, req.oid); + lock = H5FP_find_object_lock(info, req->oid); - if (!lock || lock->owned_rank != req.proc_rank + if (!lock || lock->owned_rank != req->proc_rank || lock->rw_lock != H5FP_LOCK_WRITE) { /* * There isn't a write lock or we don't own the write @@ -1339,8 +1362,8 @@ H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) } #endif /* 0 */ - if (H5FP_add_file_mod_to_list(info, req.mem_type, req.addr, - req.proc_rank, md_size, mdata) != SUCCEED) { + if (H5FP_add_file_mod_to_list(info, req->mem_type, (haddr_t)req->addr, + req->proc_rank, md_size, mdata) != SUCCEED) { exit_state = H5FP_STATUS_OOM; HGOTO_DONE(FAIL); } @@ -1351,7 +1374,7 @@ H5FP_sap_handle_write_request(H5FP_request req, char *mdata, unsigned md_size) } done: - H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, exit_state); + H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); FUNC_LEAVE_NOAPI(ret_value); } @@ -1365,7 +1388,7 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_flush_request(H5FP_request req) +H5FP_sap_handle_flush_request(H5FP_request *req) { H5FP_file_info *info; H5FP_status_t exit_state = H5FP_STATUS_OK; @@ -1373,20 +1396,20 @@ H5FP_sap_handle_flush_request(H5FP_request req) FUNC_ENTER_NOINIT(H5FP_sap_handle_flush_request); - if ((info = H5FP_find_file_info(req.file_id)) != NULL) + if ((info = H5FP_find_file_info(req->file_id)) != NULL) if (info->num_mods) { /* * If there are any modifications not written out yet, dump * them to this process */ - if (H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, + if (H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, H5FP_STATUS_DUMPING) == FAIL) { exit_state = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't send message to client"); } - if (H5FP_dump(info, req.proc_rank, req.req_id, req.file_id) == FAIL) { + if (H5FP_dump(info, req->proc_rank, req->req_id, req->file_id) == FAIL) { exit_state = H5FP_STATUS_DUMPING_FAILED; HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't dump metadata to client"); @@ -1394,7 +1417,7 @@ H5FP_sap_handle_flush_request(H5FP_request req) } done: - H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, exit_state); + H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); FUNC_LEAVE_NOAPI(ret_value); } @@ -1407,7 +1430,7 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_close_request(H5FP_request req) +H5FP_sap_handle_close_request(H5FP_request *req) { H5FP_file_info *info; H5FP_status_t exit_state = H5FP_STATUS_OK; @@ -1415,7 +1438,7 @@ H5FP_sap_handle_close_request(H5FP_request req) FUNC_ENTER_NOINIT(H5FP_sap_handle_close_request); - if ((info = H5FP_find_file_info(req.file_id)) != NULL) { + if ((info = H5FP_find_file_info(req->file_id)) != NULL) { int comm_size; /* Get the size of the SAP communicator */ @@ -1424,7 +1447,7 @@ H5FP_sap_handle_close_request(H5FP_request req) if (++info->closing == comm_size - 1) /* all processes have closed the file - remove it from list */ - if (H5FP_remove_file_id_from_list(req.file_id) != SUCCEED) { + if (H5FP_remove_file_id_from_list(req->file_id) != SUCCEED) { exit_state = H5FP_STATUS_BAD_FILE_ID; HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, "cannot remove file ID from list"); @@ -1432,7 +1455,7 @@ H5FP_sap_handle_close_request(H5FP_request req) } done: - H5FP_send_reply(req.proc_rank, req.req_id, req.file_id, exit_state); + H5FP_send_reply(req->proc_rank, req->req_id, req->file_id, exit_state); FUNC_LEAVE_NOAPI(ret_value); } @@ -1445,20 +1468,20 @@ done: * Modifications: */ static herr_t -H5FP_sap_handle_alloc_request(H5FP_request req) +H5FP_sap_handle_alloc_request(H5FP_request *req) { - H5FP_alloc alloc; + H5FP_alloc sap_alloc; H5FP_file_info *info; int mrc; herr_t ret_value = SUCCEED; FUNC_ENTER_NOINIT(H5FP_sap_handle_alloc_request); - if ((info = H5FP_find_file_info(req.file_id)) != NULL) { - alloc.req_id = req.req_id; - alloc.file_id = info->file_id; - alloc.status = H5FP_STATUS_OK; - alloc.mem_type = req.mem_type; + if ((info = H5FP_find_file_info(req->file_id)) != NULL) { + sap_alloc.req_id = req->req_id; + sap_alloc.file_id = info->file_id; + sap_alloc.status = H5FP_STATUS_OK; + sap_alloc.mem_type = req->mem_type; /* * Try allocating from the free-list that is kept on the server @@ -1474,12 +1497,12 @@ H5FP_sap_handle_alloc_request(H5FP_request req) * * Whatta pain. */ - if ((alloc.addr = H5FD_alloc(&info->file, req.mem_type, - H5P_DEFAULT, req.meta_block_size)) == HADDR_UNDEF) + if ((sap_alloc.addr = H5FD_alloc((H5FD_t*)&info->file, req->mem_type, H5P_DEFAULT, + req->meta_block_size)) == HADDR_UNDEF) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "SAP unable to allocate file memory"); - if ((mrc = MPI_Send(&alloc, 1, H5FP_alloc_t, (int)req.proc_rank, + if ((mrc = MPI_Send(&sap_alloc, 1, H5FP_alloc_t, (int)req->proc_rank, H5FP_TAG_ALLOC, H5FP_SAP_COMM)) != MPI_SUCCESS) HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc); } |