Skip to content
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

Merged
merged 6 commits into from
Jan 22, 2021

Conversation

fortnern
Copy link
Member

Modified library to properly ref count H5VL_object_t structs and only consider file vlen and reference types to be equal if their files are the same. Should prevent errors due to files being closed out from under cached types in the type conversion path table. There is still a potential error if the VOL connector closes the underlying file object before closing the datatype returned from H5VLget_file_type().

src/H5T.c Show resolved Hide resolved
src/H5T.c Outdated
/* Reset VOL fields */
/* Increment ref count on owned VOL object */
if (new_dt->shared->owned_vol_obj)
new_dt->shared->owned_vol_obj->rc++;
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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.

src/H5T.c Outdated
@@ -6295,6 +6349,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++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Another refcount increment for a H5VL routine)

src/H5Tcommit.c Outdated
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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)?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

I don't think that's necessary (yet?) and agree, would be far outside of the scope for your PR.

src/H5Tdeprec.c Outdated
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Another candidate for the "setup" H5VL setup routine)

@@ -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 */
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@qkoziol
Copy link
Contributor

qkoziol commented Jan 22, 2021

This is a very nice change and if you could spend 15 minutes with a little refactoring, would be improved further. :-)

@fortnern
Copy link
Member Author

@qkoziol I think I've addressed your concerns.

Copy link
Contributor

@qkoziol qkoziol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - looks great, thanks!

@lrknox lrknox merged commit a8ee859 into HDFGroup:develop Jan 22, 2021
fortnern added a commit to fortnern/hdf5 that referenced this pull request Jan 25, 2021
…ype() (HDFGroup#274)

* Fixed problems with vlens and refs inside compound using H5VLget_file_type()

* Fix date in RELEASE.txt

* Add assertions

* Move some manipulation of H5VL_object_t struct fields into the H5VL
package.
lrknox added a commit that referenced this pull request Jan 27, 2021
* Improve performance of multiple calls to H5Sget_select_elem_pointlist (#270)

* Cache the pointer to the next point to process after the last call to
H5S__get_select_elem_pointlist.  This allows the normal process of
iterating over the points in batches to be much more efficient, as the
library does not need to traverse the entirety of the preceding points
every time the funciton is re-entered.

* Update RELEASE.txt for point selection iteration performance fix.

* Fix problems with vlens and refs inside compound using H5VLget_file_type() (#274)

* Fixed problems with vlens and refs inside compound using H5VLget_file_type()

* Fix date in RELEASE.txt

* Add assertions

* Move some manipulation of H5VL_object_t struct fields into the H5VL
package.

* Add fix that was mistakenly left off merge commit.

* Update src/H5Tprivate.h

Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants