-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix problems with vlens and refs inside compound using H5VLget_file_type() #274
Changes from 4 commits
85c948d
4f2167b
8e0e868
84c88b1
003ff76
389fb22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1479,6 +1479,8 @@ H5T__init_package(void) | |
if (copied_dtype) | ||
(void)H5T_close_real(dt); | ||
else { | ||
if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object") | ||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); | ||
dt = H5FL_FREE(H5T_t, dt); | ||
} /* end else */ | ||
|
@@ -3447,6 +3449,8 @@ H5T__create(H5T_class_t type, size_t size) | |
done: | ||
if (NULL == ret_value) { | ||
if (dt) { | ||
if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); | ||
dt = H5FL_FREE(H5T_t, dt); | ||
} | ||
|
@@ -3489,18 +3493,24 @@ H5T__initiate_copy(const H5T_t *old_dt) | |
/* Copy shared information */ | ||
*(new_dt->shared) = *(old_dt->shared); | ||
|
||
/* Reset VOL fields */ | ||
/* Increment ref count on owned VOL object */ | ||
if (new_dt->shared->owned_vol_obj) | ||
new_dt->shared->owned_vol_obj->rc++; | ||
|
||
/* Reset vol_obj field */ | ||
new_dt->vol_obj = NULL; | ||
new_dt->shared->owned_vol_obj = NULL; | ||
|
||
/* Set return value */ | ||
ret_value = new_dt; | ||
|
||
done: | ||
if (ret_value == NULL) | ||
if (new_dt) { | ||
if (new_dt->shared) | ||
if (new_dt->shared) { | ||
if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); | ||
} /* end if */ | ||
new_dt = H5FL_FREE(H5T_t, new_dt); | ||
} /* end if */ | ||
|
||
|
@@ -3829,6 +3839,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) | |
if (ret_value == NULL) | ||
if (new_dt) { | ||
HDassert(new_dt->shared); | ||
if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); | ||
new_dt = H5FL_FREE(H5T_t, new_dt); | ||
} /* end if */ | ||
|
@@ -3896,6 +3908,8 @@ H5T_copy_reopen(H5T_t *old_dt) | |
/* The object is already open. Free the H5T_shared_t struct | ||
* we had been using and use the one that already exists. | ||
* Not terribly efficient. */ | ||
if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); | ||
new_dt->shared = reopened_fo; | ||
|
||
|
@@ -3932,6 +3946,8 @@ H5T_copy_reopen(H5T_t *old_dt) | |
if (ret_value == NULL) | ||
if (new_dt) { | ||
HDassert(new_dt->shared); | ||
if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared); | ||
new_dt = H5FL_FREE(H5T_t, new_dt); | ||
} /* end if */ | ||
|
@@ -4026,8 +4042,10 @@ H5T__alloc(void) | |
done: | ||
if (ret_value == NULL) | ||
if (dt) { | ||
if (dt->shared) | ||
if (dt->shared) { | ||
HDassert(!dt->shared->owned_vol_obj); | ||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); | ||
} /* end if */ | ||
dt = H5FL_FREE(H5T_t, dt); | ||
} /* end if */ | ||
|
||
|
@@ -4148,6 +4166,7 @@ H5T_close_real(H5T_t *dt) | |
if (H5T__free(dt) < 0) | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); | ||
|
||
HDassert(!dt->shared->owned_vol_obj); | ||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); | ||
} /* end if */ | ||
else | ||
|
@@ -4473,6 +4492,31 @@ H5T_get_size(const H5T_t *dt) | |
FUNC_LEAVE_NOAPI(dt->shared->size) | ||
} /* end H5T_get_size() */ | ||
|
||
/*------------------------------------------------------------------------- | ||
* Function: H5T_get_force_conv | ||
* | ||
* Purpose: Determines if the type has forced conversion. This will be | ||
* true if and only if the type keeps a pointer to a file VOL | ||
* object internally. | ||
* | ||
* Return: TRUE/FALSE (never fails) | ||
* | ||
* Programmer: Neil Fortner | ||
* Thursday, January 21, 2021 | ||
*------------------------------------------------------------------------- | ||
*/ | ||
hbool_t | ||
H5T_get_force_conv(const H5T_t *dt) | ||
{ | ||
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ | ||
FUNC_ENTER_NOAPI_NOINIT_NOERR | ||
|
||
/* check args */ | ||
HDassert(dt); | ||
|
||
fortnern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
FUNC_LEAVE_NOAPI(dt->shared->force_conv) | ||
} /* end H5T_get_force_conv() */ | ||
|
||
/*------------------------------------------------------------------------- | ||
* Function: H5T_cmp | ||
* | ||
|
@@ -4914,6 +4958,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) | |
HGOTO_DONE(-1); | ||
if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc) | ||
HGOTO_DONE(1); | ||
if (dt1->shared->u.atomic.u.r.file < dt2->shared->u.atomic.u.r.file) | ||
HGOTO_DONE(-1); | ||
if (dt1->shared->u.atomic.u.r.file > dt2->shared->u.atomic.u.r.file) | ||
HGOTO_DONE(1); | ||
break; | ||
|
||
case H5T_NO_CLASS: | ||
|
@@ -6295,6 +6343,7 @@ H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj) | |
|
||
/* Take ownership */ | ||
dt->shared->owned_vol_obj = vol_obj; | ||
vol_obj->rc++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Another refcount increment for a H5VL routine) |
||
|
||
done: | ||
FUNC_LEAVE_NOAPI(ret_value) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ H5T__commit_api_common(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl | |
new_obj->connector = (*vol_obj_ptr)->connector; | ||
new_obj->connector->nrefs++; | ||
new_obj->data = data; | ||
new_obj->rc = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this piece of code (which I admit wasn't originally written by you) - could you please add a small routine in the H5VL code that encapsulated this setup and then call it here (and down below in this routine)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can replace this with H5VL_create_object, though again there are still other places in the library that peek into H5VL_object_t. In fact this code would still need to do that ((*vol_obj_ptr)->connector), so we would need to write another routine to retrieve that, then propagate it to everywhere that currently gets the connector directly, which includes many (all?) of the *_api_common() routines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you thinking we should move H5VL_object_t to H5VLpkg.h? This is kind of outside the scope of this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree - I would volunteer to pick up more of the changes like this in another PR, based on the start you make here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think that's necessary (yet?) and agree, would be far outside of the scope for your PR. |
||
|
||
/* Set the committed type object to the VOL connector pointer in the H5T_t struct */ | ||
dt->vol_obj = new_obj; | ||
|
@@ -375,6 +376,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) | |
new_obj->connector = vol_obj->connector; | ||
new_obj->connector->nrefs++; | ||
new_obj->data = dt; | ||
new_obj->rc = 1; | ||
|
||
/* Set the committed type object to the VOL connector pointer in the H5T_t struct */ | ||
type->vol_obj = new_obj; | ||
|
@@ -1114,8 +1116,11 @@ H5T_open(const H5G_loc_t *loc) | |
done: | ||
if (ret_value == NULL) { | ||
if (dt) { | ||
if (shared_fo == NULL) /* Need to free shared fo */ | ||
if (shared_fo == NULL) { /* Need to free shared fo */ | ||
if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0) | ||
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object") | ||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); | ||
} /* end if */ | ||
|
||
H5O_loc_free(&(dt->oloc)); | ||
H5G_name_free(&(dt->path)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,7 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) | |
new_obj->connector = vol_obj->connector; | ||
new_obj->connector->nrefs++; | ||
new_obj->data = data; | ||
new_obj->rc = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Another candidate for the "setup" H5VL setup routine) |
||
|
||
/* Set the committed type object to the VOL connector pointer in the H5T_t struct */ | ||
dt->vol_obj = new_obj; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ typedef struct H5VL_t { | |
typedef struct H5VL_object_t { | ||
void * data; /* Pointer to connector-managed data for this object */ | ||
H5VL_t *connector; /* Pointer to VOL connector struct */ | ||
hsize_t rc; /* Reference count */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a 'size_t', since you are counting objects in memory. |
||
} H5VL_object_t; | ||
|
||
/* Internal structure to hold the connector ID & info for FAPLs */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having other parts of the library modify fields in the H5VL structs is going to be difficult to maintain. Could you please add a "increment refcount" routine in the H5VL code and call that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this, though looking through the code there are many other places that directly manipulate the H5VL_object_t struct outside the H5VL package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No doubt! I would suggest that you just herd as many cats as you have time for now and we'll keep tracking them down over time.