[svn-r6220] Purpose:

Update
Description:
    A few generic changes to the FPHDF5 code. Some error messages
    reworked a bit. Cleaning up in case of failure improved in some
    cases. Added another field to the synchronization messages...
Platforms tested:
    Linux
This commit is contained in:
Bill Wendling 2002-12-19 16:48:07 -05:00
parent ac3d122def
commit d8198f2f83
4 changed files with 330 additions and 187 deletions

View File

@ -66,6 +66,13 @@ H5FPinit(MPI_Comm comm, int sap_rank)
FUNC_ENTER_API(H5FPinit, FAIL);
H5TRACE2("e","McIs",comm,sap_rank);
/* initialize to NULL so that we can release if an error occurs */
SAP_request_t = MPI_DATATYPE_NULL;
SAP_reply_t = MPI_DATATYPE_NULL;
SAP_sync_t = MPI_DATATYPE_NULL;
H5FP_SAP_COMM = MPI_COMM_NULL;
H5FP_SAP_BARRIER_COMM = MPI_COMM_NULL;
/* Set the global variable to track the SAP's rank */
H5FP_sap_rank = sap_rank;
@ -110,6 +117,30 @@ H5FPinit(MPI_Comm comm, int sap_rank)
/* Fall through and return to user, if not SAP */
done:
if (ret_value == FAIL) {
/* we've encountered an error...clean up */
if (SAP_request_t != MPI_DATATYPE_NULL)
if (MPI_Type_free(&SAP_request_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed");
if (SAP_reply_t != MPI_DATATYPE_NULL)
if (MPI_Type_free(&SAP_reply_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed");
if (SAP_sync_t != MPI_DATATYPE_NULL)
if (MPI_Type_free(&SAP_sync_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_free failed");
if (H5FP_SAP_BARRIER_COMM != MPI_COMM_NULL)
/* this comm will be NULL for the SAP */
if (MPI_Comm_free(&H5FP_SAP_BARRIER_COMM) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed");
if (H5FP_SAP_COMM != MPI_COMM_NULL)
if (MPI_Comm_free(&H5FP_SAP_COMM) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_free failed");
}
if (sap_group != MPI_GROUP_NULL)
MPI_Group_free(&sap_group);
@ -218,19 +249,20 @@ H5FP_commit_sap_datatypes(void)
MPI_Aint displs[2];
MPI_Datatype old_types[2];
struct SAP_request req;
struct SAP_sync sap_sync;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5FP_commit_sap_datatypes, FAIL);
/* Commit the SAP_request_t datatype */
block_length[0] = 8;
block_length[0] = 10;
block_length[1] = sizeof(req.oid);
old_types[0] = MPI_INT;
old_types[1] = MPI_UNSIGNED_CHAR;
MPI_Address(&req.req_type, &displs[0]);
MPI_Address(&req.oid, &displs[1]);
displs[1] -= displs[0];
displs[0] -= displs[0];
old_types[0] = MPI_INT;
old_types[1] = MPI_UNSIGNED_CHAR;
if (MPI_Type_struct(2, block_length, displs, old_types, &SAP_request_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed");
@ -250,9 +282,14 @@ H5FP_commit_sap_datatypes(void)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_commit failed");
/* Commit the SAP_sync_t datatype */
block_length[0] = 8;
displs[0] = 0;
block_length[0] = 9;
block_length[1] = 1;
old_types[0] = MPI_INT;
old_types[1] = MPI_LONG_LONG;
MPI_Address(&sap_sync.req_id, &displs[0]);
MPI_Address(&sap_sync.size, &displs[1]);
displs[1] -= displs[0];
displs[0] -= displs[0];
if (MPI_Type_struct(1, block_length, displs, old_types, &SAP_sync_t) != MPI_SUCCESS)
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Type_struct failed");

View File

@ -37,11 +37,44 @@ static int interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/* local functions */
static unsigned int H5FP_gen_request_id(void);
static herr_t H5FP_update_metadata_cache(hid_t file_id, struct SAP_sync *sap_sync, uint8_t *msg);
static unsigned H5FP_gen_request_id(void);
static herr_t H5FP_update_file_cache(hid_t file_id, struct SAP_sync *sap_sync, uint8_t *msg);
/** Public Library (non-API) Functions **/
/*
* Function: H5FP_fill_fphdf5_struct
* Purpose: Nice function to fill in the H5O_fphdf5_t structure
* before transmission to the SAP.
* Return: Nothing: Doesn't fail after asserts pass.
* Programmer: Bill Wendling, 13. November, 2002
* Modifications:
*/
void
H5FP_fill_fphdf5_struct(H5O_fphdf5_t *fphdf5, uint8_t *oid, haddr_t header,
struct H5S_simple_t *sdim, H5T_t *dtype, time_t *mtime,
H5O_layout_t *layout, H5O_name_t *group, H5O_name_t *dataset,
struct H5P_genplist_t *plist)
{
/* check args */
assert(fphdf5);
assert(oid);
assert(sdim);
assert(dtype);
assert(layout);
assert(plist);
HDmemcpy(fphdf5->oid, oid, sizeof(fphdf5->oid));
fphdf5->header = header;
fphdf5->layout = layout;
fphdf5->sdim = sdim;
fphdf5->mtime = mtime;
fphdf5->group = group;
fphdf5->dset = dataset;
fphdf5->dtype = dtype;
fphdf5->plist = plist;
}
/*
* Function: H5FP_request_open
* Purpose: Request an open of a file from the SAP. You pass in the
@ -50,6 +83,11 @@ static herr_t H5FP_update_metadata_cache(hid_t file_id, struct SAP_sync *sap_syn
* open (OBJ_TYPE). The request ID is returned in a pointer
* supplied by the user.
*
* The so-called "captain" process is in charge of telling
* the SAP that the processes opened a file. All processes
* opening the file, though, should call this function so
* that they can get the file ID that the SAP assigns to it.
*
* N.B. This could be expanded to handle the opening of more
* than just a file, if that becomes necessary. Right now,
* we are only keeping track of file opens.
@ -69,9 +107,11 @@ H5FP_request_open(const char *mdata, int md_len, enum sap_obj_type obj_type,
FUNC_ENTER_NOAPI(H5FP_request_open, FAIL);
/* check args */
assert(mdata);
assert(file_id);
assert(req_id);
HDmemset(&mpi_status, 0, sizeof(MPI_Status));
if (H5FP_my_rank == H5FP_capt_rank) {
@ -86,8 +126,6 @@ H5FP_request_open(const char *mdata, int md_len, enum sap_obj_type obj_type,
H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS)
HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc);
/* The first MPI_Send will have been sent before this one will be read. */
if (H5FP_send_metadata(mdata, md_len, (int)H5FP_sap_rank))
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL,
"can't send metadata to server");
@ -250,10 +288,13 @@ done:
* Modifications:
*/
herr_t
H5FP_request_change(unsigned int sap_file_id, enum sap_obj_type obj_type,
enum sap_action action, int mdata_len, const char *mdata,
unsigned *req_id)
H5FP_request_change(unsigned int sap_file_id, unsigned char *obj_oid,
enum sap_obj_type obj_type, enum sap_action action,
int mdata_len, const char *mdata, unsigned *req_id,
enum sap_status *status)
{
struct SAP_reply sap_reply;
MPI_Status mpi_status;
struct SAP_request req;
herr_t ret_value = SUCCEED;
int mrc;
@ -271,6 +312,11 @@ H5FP_request_change(unsigned int sap_file_id, enum sap_obj_type obj_type,
req.md_len = mdata_len;
req.proc_rank = H5FP_my_rank;
if (obj_oid)
H5FP_COPY_OID(req.oid, obj_oid);
else
HDmemset(req.oid, '\0', sizeof(req.oid));
if ((mrc = MPI_Send(&req, 1, SAP_request_t, (int)H5FP_sap_rank,
H5FP_TAG_REQUEST, H5FP_SAP_COMM)) != MPI_SUCCESS)
HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc);
@ -279,11 +325,81 @@ H5FP_request_change(unsigned int sap_file_id, enum sap_obj_type obj_type,
if (H5FP_send_metadata(mdata, mdata_len, (int)H5FP_sap_rank) != SUCCEED)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTSENDMDATA, FAIL, "can't send metadata to server");
HDmemset(&mpi_status, 0, sizeof(mpi_status));
if ((mrc = MPI_Recv(&sap_reply, 1, SAP_reply_t, (int)H5FP_sap_rank,
H5FP_TAG_REPLY, H5FP_SAP_COMM, &mpi_status)) != MPI_SUCCESS)
HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mrc);
*status = sap_reply.status;
if (sap_reply.status != H5FP_STATUS_OK)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTUNLOCK, FAIL, "can't register change with server");
done:
*req_id = req.req_id;
FUNC_LEAVE(ret_value);
}
#if 0
herr_t
H5FP_generate_message(fid_t fid, const char *dataset, const char *group,
H5D_t *dset, H5S_t *space, H5O_fphdf5_t *fphdf5 /* out */)
{
hobj_ref_t gr_ref, ds_ref;
H5O_efl_t efl;
H5F_t *file = NULL;
H5S_t *space = NULL;
H5G_entry_t *ent = NULL;
int i;
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5FP_generate_message, FAIL);
if ((file = H5I_object(file_id)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier");
if ((grp = H5G_open(file, group)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
if ((ent = H5G_entof(grp)) == NULL)
/* this will never be executed */
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to get entry info of group");
memcpy(fphdf5->oid, (void *)&ent->header, sizeof(ent->header));
if ((loc = H5G_loc(did)) == NULL) {
exit(1);
}
memcpy(ds_ref.oid, (void *)&loc->header, sizeof(loc->header));
memcpy(fphdf5.oid, ds_ref.oid, sizeof(ds_ref.oid));
fphdf5->header = dset->ent.header;
fphdf5->layout = &dset->layout;
fphdf5->sdim = &(space->extent.u.simple);
#if 0
fphdf5->mtime = ;
#endif
fphdf5->group = group;
fphdf5->dset = dataset;
fphdf5->dtype = dset->type;
if ((fphdf5->plist = H5P_object_verify(dset->dcpl_id,
H5P_DATASET_CREATE)) == NULL) {
exit(1);
}
if (H5P_get(fphdf5->plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
fphdf5->efl = &efl;
done:
FUNC_LEAVE(ret_value);
}
#endif
/*
* Function: H5FP_request_sync
* Purpose: Tell the SAP that we want all of the structural changes
@ -336,13 +452,11 @@ H5FP_request_sync(unsigned int sap_file_id, hid_t hdf_file_id,
HGOTO_DONE(FAIL);
}
if (sap_sync.last_msg)
break;
/* use the info in the SAP_sync_t structure to update the
* metadata */
/*
* use the info in the SAP_sync_t structure to update the
* metadata
*/
if (sap_sync.md_len) {
H5O_fphdf5_t *fmeta;
uint8_t *buf;
if ((buf = (uint8_t *)HDcalloc((size_t)sap_sync.md_len + 1, 1)) == NULL)
@ -360,13 +474,14 @@ H5FP_request_sync(unsigned int sap_file_id, hid_t hdf_file_id,
* FIXME: perform whatever metadata updates we can with the
* metadata returned from the SAP
*/
if (H5FP_update_metadata_cache(hdf_file_id, &sap_sync, buf) != SUCCEED) {
H5O_FPHDF5[0].free(fmeta);
if (H5FP_update_file_cache(hdf_file_id, &sap_sync, buf) != SUCCEED)
HGOTO_DONE(FAIL);
}
HDfree(buf);
}
if (sap_sync.last_msg)
break;
}
done:
@ -374,95 +489,6 @@ done:
FUNC_LEAVE(ret_value);
}
static herr_t
H5FP_update_metadata_cache(hid_t file_id, struct SAP_sync *sap_sync, uint8_t *msg)
{
herr_t ret_value = SUCCEED;
H5G_entry_t *ent = NULL;
H5O_fphdf5_t *fmeta = NULL;
H5S_t *space = NULL;
H5F_t *file = NULL;
H5G_t *grp = NULL;
H5D_t *dset = NULL;
FUNC_ENTER_NOINIT(H5FP_update_metadata_cache);
/* check args */
assert(sap_sync);
assert(msg);
if ((file = H5I_object(file_id)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier");
if ((fmeta = H5O_FPHDF5[0].decode(file, msg, NULL)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory");
if ((grp = H5G_open(file, fmeta->group->s)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
switch (sap_sync->action) {
case H5FP_ACT_CREATE:
if (sap_sync->obj_type == H5FP_OBJ_DATASET) {
if ((ent = H5MM_malloc(sizeof(H5G_entry_t))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory");
if ((space = H5S_create(H5S_SIMPLE)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL,
"can't create simple dataspace");
if (H5S_set_extent_simple(space, fmeta->sdim->rank,
fmeta->sdim->size, fmeta->sdim->max) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions");
if (H5D_update_entry_cache(file, ent, H5G_entof(grp),
fmeta->dset->s, space,
fmeta->plist, fmeta->layout, fmeta->dtype,
FALSE, fmeta->header) == FAIL)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINIT, FAIL, "can't update metadata cache");
if (H5D_update_external_storage_cache(file, ent, fmeta->efl,
fmeta->layout) == FAIL)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINIT, FAIL,
"can't update external file layout metadata cache");
}
break;
case H5FP_ACT_EXTEND:
if (sap_sync->obj_type == H5FP_OBJ_DATASET) {
if ((dset = H5D_open(H5G_entof(grp), fmeta->dset->s)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open dataset");
if (H5D_extend(dset, fmeta->sdim->size) != SUCCEED)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset");
}
break;
case H5FP_ACT_DELETE:
default:
break;
}
done:
if (fmeta)
H5O_FPHDF5[0].free(fmeta);
if (dset)
H5D_close(dset);
if (grp)
H5G_close(grp);
if (space)
H5S_close(space);
if (ret_value == FAIL)
H5MM_xfree(ent);
FUNC_LEAVE(ret_value);
}
/*
* Function: H5FP_request_close
* Purpose: Tell the SAP that we want all of the structural changes
@ -508,7 +534,8 @@ done:
* Programmer: Bill Wendling, 30. July, 2002
* Modifications:
*/
static unsigned int H5FP_gen_request_id()
static unsigned
H5FP_gen_request_id()
{
static unsigned int i = 0;
@ -516,4 +543,111 @@ static unsigned int H5FP_gen_request_id()
FUNC_LEAVE(i++);
}
/*
* Function: H5FP_update_file_cache
* Purpose: Take the information returned by a "sync" call and update
* the file cache. The MSG parameter should be an encoded
* version of the H5O_fphdf5_t object.
* Return: Success: SUCCEED
* Failure: FAIL
* Programmer: Bill Wendling, 16. December, 2002
* Modifications:
*/
static herr_t
H5FP_update_file_cache(hid_t file_id, struct SAP_sync *sap_sync, uint8_t *msg)
{
herr_t ret_value = SUCCEED;
H5G_entry_t *ent = NULL, *file_ent = NULL;
H5O_fphdf5_t *fmeta = NULL;
H5S_t *space = NULL;
H5F_t *file = NULL;
H5G_t *grp = NULL;
H5D_t *dset = NULL;
FUNC_ENTER_NOINIT(H5FP_update_file_cache);
/* check args */
assert(sap_sync);
assert(msg);
if ((file = H5I_object(file_id)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier");
if ((fmeta = H5O_FPHDF5[0].decode(file, msg, NULL)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory");
if ((file_ent = H5G_loc(file_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
if ((grp = H5G_open(file_ent, fmeta->group->s)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
switch (sap_sync->action) {
case H5FP_ACT_CREATE:
if (sap_sync->obj_type == H5FP_OBJ_DATASET) {
H5O_efl_t efl;
if ((ent = H5MM_malloc(sizeof(H5G_entry_t))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "out of memory");
if ((space = H5S_create(H5S_SIMPLE)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL,
"can't create simple dataspace");
if (H5S_set_extent_simple(space, fmeta->sdim->rank,
fmeta->sdim->size, fmeta->sdim->max) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions");
if (H5D_update_entry_cache(file, ent, H5G_entof(grp),
fmeta->dset->s, space,
fmeta->plist, fmeta->layout, fmeta->dtype,
FALSE, fmeta->header) == FAIL)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINIT, FAIL, "can't update metadata cache");
if (H5P_get(fmeta->plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
if (H5D_update_external_storage_cache(file, ent, &efl, fmeta->layout) == FAIL)
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINIT, FAIL,
"can't update external file layout metadata cache");
}
break;
case H5FP_ACT_EXTEND:
if (sap_sync->obj_type == H5FP_OBJ_DATASET) {
if ((dset = H5D_open(H5G_entof(grp), fmeta->dset->s)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open dataset");
if (H5D_extend(dset, fmeta->sdim->size) != SUCCEED)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset");
}
break;
case H5FP_ACT_DELETE:
default:
break;
}
done:
/* cleanup */
if (fmeta)
H5O_FPHDF5[0].free(fmeta);
if (dset)
H5D_close(dset);
if (grp)
H5G_close(grp);
if (space)
H5S_close(space);
if (ret_value == FAIL)
H5MM_xfree(ent);
FUNC_LEAVE(ret_value);
}
#endif /* H5_HAVE_FPHDF5 */

View File

@ -15,6 +15,7 @@
#define H5FPPRIVATE_H__ 0
#include "H5FPpublic.h" /* Flexible Parallel HDF5 */
#include "H5Oprivate.h" /* Object Headers */
#include "H5Rprivate.h" /* References */
#define H5FP_BYTE_BITS 8
@ -36,22 +37,23 @@
* for that object.
*/
enum sap_request {
H5FP_REQ_OPEN, /* Open a file (or eventually an object) */
H5FP_REQ_LOCK, /* Lock an object (in a sequence) */
H5FP_REQ_LOCK_END, /* Last lock request in lock sequence */
H5FP_REQ_RELEASE, /* Unlock an object (in a sequence) */
H5FP_REQ_RELEASE_END, /* Last unlock request in unlock sequence */
H5FP_REQ_CHANGE, /* Change an object */
H5FP_REQ_SYNC, /* Syncronize changes in file */
H5FP_REQ_CLOSE, /* Close a file (or eventually an object) */
H5FP_REQ_STOP /* Stop SAP */
H5FP_REQ_OPEN, /* Open a file (or eventually an object) */
H5FP_REQ_LOCK, /* Lock an object (in a sequence) */
H5FP_REQ_LOCK_END, /* Last lock request in lock sequence */
H5FP_REQ_RELEASE, /* Unlock an object (in a sequence) */
H5FP_REQ_RELEASE_END, /* Last unlock request in unlock sequence */
H5FP_REQ_CHANGE, /* Change an object */
H5FP_REQ_SYNC, /* Syncronize changes in file */
H5FP_REQ_CLOSE, /* Close a file (or eventually an object) */
H5FP_REQ_STOP /* Stop SAP */
};
/* Actions to take when performing a change */
enum sap_action {
H5FP_ACT_CREATE,
H5FP_ACT_EXTEND,
H5FP_ACT_DELETE
H5FP_ACT_DELETE,
H5FP_ACT_UPDATE
};
/* Types of objects we can change */
@ -60,7 +62,8 @@ enum sap_obj_type {
H5FP_OBJ_GROUP,
H5FP_OBJ_DATASET,
H5FP_OBJ_DATATYPE,
H5FP_OBJ_ATTRIBUTE
H5FP_OBJ_ATTRIBUTE,
H5FP_OBJ_MEMORY
};
/* Types of locks we can get */
@ -75,10 +78,12 @@ struct SAP_request {
unsigned int req_id; /* ID for request set by sending process */
unsigned int proc_rank; /* Rank of sending process */
unsigned int sap_file_id; /* SAP's file ID for the specific file */
int md_len; /* Length of the metadata sent in next msg */
enum sap_obj_type obj_type; /* Type of object */
enum sap_action action; /* Action to do to object (H5FP_REQ_CHANGE only) */
enum sap_lock_type rw_lock; /* Indicates read or write lock */
H5FD_mem_t mem_type; /* Type of memory updated, if req'd */
unsigned long size; /* Size of memory updated, if req'd */
int md_len; /* Length of the metadata sent in next msg */
unsigned char oid[H5R_OBJ_REF_BUF_SIZE]; /* Buffer to store OID of object referenced */
};
@ -95,7 +100,7 @@ enum sap_status {
/* For releasing locks */
H5FP_STATUS_LOCK_RELEASED,
H5FP_STATUS_LOCK_RELEASE_FAILED,
H5FP_STATUS_BAD_LOCK, /* Process doesn't own a lock on the OID */
H5FP_STATUS_BAD_LOCK, /* Process doesn't own a lock on the OID */
/* For change requests */
H5FP_STATUS_FILE_CLOSING,
@ -126,10 +131,12 @@ struct SAP_sync {
unsigned int sync_id; /* Sync ID to order the sync messages */
unsigned int sap_file_id; /* SAP's file ID for the specific file */
unsigned int last_msg; /* Indicates this is the last sync msg sent */
int md_len; /* Length of the metadata sent in next msg */
enum sap_obj_type obj_type; /* Type of object */
enum sap_action action; /* Action done on the object */
enum sap_status status; /* Status of the request */
int md_len; /* Length of the metadata sent in next msg */
H5FD_mem_t mem_type; /* Type of memory updated, if req'd */
hsize_t size; /* Size of memory updated, if req'd */
};
extern MPI_Datatype SAP_sync_t; /* MPI datatype for the SAP_sync obj */
@ -178,14 +185,23 @@ extern herr_t H5FP_request_lock(unsigned int sap_file_id, unsigned char *mdata,
enum sap_lock_type rw_lock, int last, unsigned *req_id,
enum sap_status *status);
extern herr_t H5FP_request_release_lock(unsigned int sap_file_id, unsigned char *mdata,
int last, unsigned *req_id, enum sap_status *status);
extern herr_t H5FP_request_change(unsigned int sap_file_id, enum sap_obj_type obj_type,
enum sap_action action, int mdata_len, const char *mdata,
unsigned *req_id);
int last, unsigned *req_id,
enum sap_status *status);
extern herr_t H5FP_request_change(unsigned int sap_file_id, unsigned char *obj_oid,
enum sap_obj_type obj_type, enum sap_action action,
int mdata_len, const char *mdata, unsigned *req_id,
enum sap_status *status);
extern herr_t H5FP_request_sync(unsigned int sap_file_id, hid_t hdf_file_id,
unsigned *req_id, enum sap_status *status);
extern herr_t H5FP_request_close(unsigned sap_file_id, unsigned *req_id);
/* Helper functions */
extern void H5FP_fill_fphdf5_struct(H5O_fphdf5_t *fphdf5, uint8_t *oid, haddr_t header,
struct H5S_simple_t *sdim, H5T_t *dtype,
time_t *mtime, H5O_layout_t *layout,
H5O_name_t *group, H5O_name_t *dataset,
struct H5P_genplist_t *plist);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -89,7 +89,7 @@ static H5TB_TREE *fs_tree;
* is a mod by 8. (Note that rank should be unsigned at this point). So, the
* code
*
* fm->procs_notified[rank << 3] |= 1 << (rank & 7);
* fm->procs_notified[rank >> 3] |= 1 << (rank & 7);
*
* is equivalent to
*
@ -192,7 +192,7 @@ H5FP_sap_receive_loop(void)
switch (req.req_type) {
case H5FP_REQ_OPEN:
if ((hrc = H5FP_sap_handle_open_request(req, buf, req.md_len)) != SUCCEED)
fprintf(stderr, "Failed on opening file: %d\n", hrc);
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTOPENOBJ, FAIL, "cannot open file");
break;
case H5FP_REQ_LOCK:
@ -218,9 +218,7 @@ H5FP_sap_receive_loop(void)
break;
default:
HDfprintf(stderr,
"error: H5FP_sap_receive_loop: invalid request type %d\n",
req.req_type);
HGOTO_ERROR(H5E_FPHDF5, H5E_ARGS, FAIL, "invalid request type");
}
if (hrc != SUCCEED)
@ -283,12 +281,11 @@ done:
*/
static int H5FP_object_lock_cmp(struct sap_obj_lock *o1,
struct sap_obj_lock *o2,
int cmparg)
int UNUSED cmparg)
{
FUNC_ENTER_NOINIT(H5FP_object_lock_cmp);
assert(o1);
assert(o2);
cmparg = cmparg;
FUNC_LEAVE(HDmemcmp(o1->oid, o2->oid, sizeof(o1->oid)));
}
@ -410,12 +407,11 @@ H5FP_remove_object_lock_from_list(struct sap_file_struct *fs,
* Modifications:
*/
static int
H5FP_file_mod_cmp(struct sap_file_mod *k1, struct sap_file_mod *k2, int cmparg)
H5FP_file_mod_cmp(struct sap_file_mod *k1, struct sap_file_mod *k2, int UNUSED cmparg)
{
FUNC_ENTER_NOINIT(H5FP_file_mod_cmp);
assert(k1);
assert(k2);
cmparg = cmparg; /* shut compiler up */
FUNC_LEAVE(k1->key - k2->key);
}
@ -597,12 +593,11 @@ H5FP_free_file_struct_node(struct sap_file_struct *fs)
* Modifications:
*/
static int
H5FP_file_struct_cmp(struct sap_file_struct *k1, struct sap_file_struct *k2, int cmparg)
H5FP_file_struct_cmp(struct sap_file_struct *k1, struct sap_file_struct *k2, int UNUSED cmparg)
{
FUNC_ENTER_NOINIT(H5FP_file_struct_cmp);
assert(k1);
assert(k2);
cmparg = cmparg; /* shut compiler up */
FUNC_LEAVE(k1->sap_file_id - k2->sap_file_id);
}
@ -626,7 +621,7 @@ H5FP_new_file_struct_node(unsigned int sap_file_id, char *filename)
ret_value->sap_file_id = sap_file_id;
ret_value->filename = filename;
ret_value->closing = 0;
ret_value->closing = FALSE;
ret_value->mod_tree = NULL;
ret_value->locks = NULL;
@ -785,7 +780,7 @@ H5FP_gen_sap_file_id()
* Modifications:
*/
static herr_t
H5FP_sap_handle_open_request(struct SAP_request req, char *mdata, int md_len)
H5FP_sap_handle_open_request(struct SAP_request req, char *mdata, int UNUSED md_len)
{
herr_t ret_value = SUCCEED;
int mrc;
@ -797,9 +792,8 @@ H5FP_sap_handle_open_request(struct SAP_request req, char *mdata, int md_len)
int i;
if (H5FP_add_new_file_struct_to_list(new_file_id, mdata) != SUCCEED)
/* FIXME: This should be a different error message */
HGOTO_ERROR(H5E_FPHDF5, H5E_CANTINSERT, FAIL,
"can't insert file structure into tree");
"can't insert new file structure to list");
/* broadcast the file id to all processes */
/* FIXME: Isn't there some way to broadcast this result to the barrier group? -QAK */
@ -822,18 +816,8 @@ H5FP_sap_handle_open_request(struct SAP_request req, char *mdata, int md_len)
* we couldn't continue...but how to do that?!?
*/
HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc);
printf("broadcast %d from %d\n", new_file_id, H5FP_sap_rank);
HDfflush(stdout);
}
md_len = md_len;
printf("request_type == H5FP_REQ_OPEN, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
HDfflush(stdout);
done:
FUNC_LEAVE(ret_value);
}
@ -1008,12 +992,6 @@ H5FP_sap_handle_lock_request(struct SAP_request req)
}
}
printf("request_type == H5FP_REQ_LOCK, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
HDfflush(stdout);
goto done;
/* Error handling code */
@ -1024,7 +1002,7 @@ rollback:
* possible to release those locks, we're in big trouble. The file is
* now in an inconsistent state, as far as the SAP is concerned. The
* only options left to the program are either to abort or completely
* close the file and reopen.
* close the file and reopen which could cause corruption.
*/
for (j = 0; j <= i; ++j) {
if (oids[j].locked) {
@ -1049,8 +1027,7 @@ rollback:
done:
if (ret_value != SUCCEED) {
/* Can't lock the whole group at one time for some reason */
printf("locking failure!!\n");
HDfflush(stdout);
HDfprintf(stderr, "%s: locking failure (%d)!!\n", FUNC, ret_value);
}
HDfree(oids);
@ -1158,14 +1135,8 @@ H5FP_sap_handle_release_lock_request(struct SAP_request req)
}
}
printf("request_type == H5FP_REQ_RELEASE, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
HDfflush(stdout);
done:
HDfprintf(stderr, "exit_state == %d\n", exit_state);
HDfree(oids);
H5FP_send_reply(req.proc_rank, req.req_id, req.sap_file_id, exit_state);
FUNC_LEAVE(ret_value);
@ -1217,12 +1188,6 @@ H5FP_sap_handle_change_request(struct SAP_request req, char *mdata, int md_len)
ret_value = FAIL;
}
printf("request_type == H5FP_REQ_CHANGE, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
printf("metadata received == %s, len == %d\n", mdata, md_len);
H5FP_send_reply(req.proc_rank, req.req_id, req.sap_file_id, exit_state);
FUNC_LEAVE(ret_value);
}
@ -1246,6 +1211,8 @@ H5FP_sap_handle_sync_request(struct SAP_request req)
FUNC_ENTER_NOINIT(H5FP_sap_handle_sync_request);
HDfprintf(stderr, "%s: Trying to Synchronize!\n", FUNC);
s.req_id = req.req_id;
s.sap_file_id = req.sap_file_id;
s.last_msg = FALSE;
@ -1302,12 +1269,6 @@ H5FP_sap_handle_sync_request(struct SAP_request req)
H5FP_TAG_SYNC, H5FP_SAP_COMM)) != MPI_SUCCESS)
HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mrc);
printf("request_type == H5FP_REQ_SYNC, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
HDfflush(stdout);
done:
FUNC_LEAVE(ret_value);
}
@ -1339,11 +1300,6 @@ H5FP_sap_handle_close_request(struct SAP_request req)
HGOTO_ERROR(H5E_FPHDF5, H5E_NOTFOUND, FAIL, "cannot remove file ID from list");
}
printf("request_type == H5FP_REQ_CLOSE, request_id == %d, proc_rank == %d,\n"
"sap_file_id == %d, obj_type == %d, action == %d\n",
req.req_id, req.proc_rank, req.sap_file_id, req.obj_type,
req.action);
done:
FUNC_LEAVE(ret_value);
}