Skip to content

Commit

Permalink
Flush domain before requesting allocated bytes
Browse files Browse the repository at this point in the history
Without this, if the size of the dataset changed
in the last minute or so, get storage size is
very likely to return an incorrect value.
  • Loading branch information
mattjala committed Oct 10, 2023
1 parent c2ab7ab commit 508e406
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/rest_vol.h
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,12 @@ herr_t RV_curl_multi_perform(CURL *curl_multi_ptr, dataset_transfer_info *transf
(version.major > major_needed) || (version.major == major_needed && version.minor > minor_needed) || \
(version.major == major_needed && version.minor == minor_needed && version.patch >= patch_needed)

#define SERVER_VERISON_SUPPORTS_FILL_VALUE_ENCODING(version) \
#define SERVER_VERSION_SUPPORTS_FILL_VALUE_ENCODING(version) \
(SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 1))

#define SERVER_VERSION_SUPPORTS_GET_STORAGE_SIZE(version) \
(SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 5))

#ifdef __cplusplus
}
#endif
Expand Down
21 changes: 17 additions & 4 deletions src/rest_vol_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,10 @@ RV_dataset_get(void *obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **r
RV_object_t *dset = (RV_object_t *)obj;
herr_t ret_value = SUCCEED;

size_t host_header_len = 0;
char *host_header = NULL;
char request_url[URL_MAX_LENGTH];
H5VL_file_specific_args_t vol_flush_args;
size_t host_header_len = 0;
char *host_header = NULL;
char request_url[URL_MAX_LENGTH];

#ifdef RV_CONNECTOR_DEBUG
printf("-> Received dataset get call with following parameters:\n");
Expand Down Expand Up @@ -1286,6 +1287,18 @@ RV_dataset_get(void *obj, H5VL_dataset_get_args_t *args, hid_t dxpl_id, void **r
/* H5Dget_storage_size */
case H5VL_DATASET_GET_STORAGE_SIZE:

if (!(SERVER_VERSION_SUPPORTS_GET_STORAGE_SIZE(dset->domain->u.file.server_version)))
FUNC_GOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"H5Dget_storage_size requires HSDS 0.8.5 or higher");

/* First, flush domain to make server update allocated bytes */
vol_flush_args.op_type = H5VL_FILE_FLUSH;
vol_flush_args.args.flush.obj_type = H5I_FILE;
vol_flush_args.args.flush.scope = H5F_SCOPE_LOCAL;

if (RV_file_specific((void *)dset->domain, &vol_flush_args, H5P_DEFAULT, NULL) < 0)
FUNC_GOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "can't flush datase's domain");

/* Make GET request to dataset with 'verbose' parameter for HSDS. */
snprintf(request_url, URL_MAX_LENGTH, "%s%s%s%s", base_URL, "/datasets/", dset->URI,
"?verbose=1");
Expand Down Expand Up @@ -2407,7 +2420,7 @@ RV_convert_dataset_creation_properties_to_JSON(hid_t dcpl, char **creation_prope
out_string_curr_pos += null_value_len;
}
else if (H5D_FILL_VALUE_USER_DEFINED == fill_status) {
if (!(SERVER_VERISON_SUPPORTS_FILL_VALUE_ENCODING(version)))
if (!(SERVER_VERSION_SUPPORTS_FILL_VALUE_ENCODING(version)))
FUNC_GOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"server API version %zu.%zu.%zu does not support fill value encoding\n",
version.major, version.minor, version.patch);
Expand Down
2 changes: 1 addition & 1 deletion src/rest_vol_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ RV_file_specific(void *obj, H5VL_file_specific_args_t *args, hid_t dxpl_id, void
* the containing domain. */
RV_object_t *target_domain = file->domain;
filename = target_domain->u.file.filepath_name;
const char *flush_string = "/?flush=1";
const char *flush_string = "/?flush=1&rescan=1";

name_length = strlen(filename);

Expand Down

0 comments on commit 508e406

Please sign in to comment.