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

Brings the native implementation of H5Fdelete() from Bitbucket #524

Merged
merged 32 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ba9deae
Committing clang-format changes
github-actions[bot] Mar 19, 2021
00f9750
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 21, 2021
e997283
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 22, 2021
3eac585
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 23, 2021
71643b7
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
d242911
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
bc70f95
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
3d7ad8e
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
aeb16b7
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 26, 2021
8f6749f
Brings the native VFD H5Fdelete() implementation from Bitbucket
derobins Mar 26, 2021
dc923ae
Formatter changes
derobins Mar 26, 2021
3ec6bc5
Committing clang-format changes
github-actions[bot] Mar 26, 2021
f296b1e
Merge branch 'major/H5Fdelete_new' of https://github.com/derobins/hdf…
derobins Mar 26, 2021
765cb5b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 27, 2021
6398d61
Fixes direct VFD callback name
derobins Mar 27, 2021
18401fc
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 29, 2021
222242c
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 29, 2021
8d0cafa
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 30, 2021
76a0d06
Removes UNUSED macro from family API call
derobins Apr 2, 2021
486769f
Merge branch 'develop' into major/H5Fdelete_new
derobins Apr 2, 2021
d3694d1
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 2, 2021
909765f
Adds barrier and rank 0 check to MPI-I/O VFD delete
derobins Apr 3, 2021
9f276f4
Merge branch 'develop' into major/H5Fdelete_new
derobins Apr 3, 2021
9b04bef
Revert "Adds barrier and rank 0 check to MPI-I/O VFD delete"
derobins Apr 9, 2021
d498949
Revert "Revert "Adds barrier and rank 0 check to MPI-I/O VFD delete""
derobins Apr 9, 2021
95cba16
Adds a second barrier after the delete in MPI-I/O VFD
derobins Apr 9, 2021
45f2191
Only delete files in the core VFD when the backing store flag is set
derobins Apr 10, 2021
1c7bcc2
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 15, 2021
faf30d8
Merge branch 'develop' into major/H5Fdelete_new
derobins Apr 15, 2021
9543d6e
Fixes string issues in multi VFD
derobins Apr 15, 2021
89d3715
Formatted source
derobins Apr 16, 2021
a75843b
Rework fapl checks for MPI-I/O VFD delete callback
derobins Apr 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/H5FD.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,3 +1886,37 @@ H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDdriver_query() */

/*-------------------------------------------------------------------------
* Function: H5FDdelete
*
* Purpose: Deletes a file
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5FDdelete(const char *filename, hid_t fapl_id)
{
herr_t ret_value = SUCCEED;

FUNC_ENTER_API(FAIL)
H5TRACE2("e", "*si", filename, fapl_id);

/* Check arguments */
if (!filename || !*filename)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified")

if (H5P_DEFAULT == fapl_id)
fapl_id = H5P_FILE_ACCESS_DEFAULT;
else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")

/* Call private function */
if (H5FD_delete(filename, fapl_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file")

done:
FUNC_LEAVE_API(ret_value)
} /* end H5FDdelete() */
27 changes: 27 additions & 0 deletions src/H5FDcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ static herr_t H5FD__core_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__core_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD__core_unlock(H5FD_t *_file);
static herr_t H5FD__core_delete(const char *filename, hid_t fapl_id);

static const H5FD_class_t H5FD_core_g = {
"core", /* name */
Expand Down Expand Up @@ -181,6 +182,7 @@ static const H5FD_class_t H5FD_core_g = {
H5FD__core_truncate, /* truncate */
H5FD__core_lock, /* lock */
H5FD__core_unlock, /* unlock */
H5FD__core_delete, /* del */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};

Expand Down Expand Up @@ -1708,3 +1710,28 @@ H5FD__core_unlock(H5FD_t *_file)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__core_unlock() */

/*-------------------------------------------------------------------------
* Function: H5FD__core_delete
*
* Purpose: Delete a file
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5FD__core_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_STATIC

HDassert(filename);

if (HDremove(filename) < 0)
qkoziol marked this conversation as resolved.
Show resolved Hide resolved
HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file")

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__core_delete() */
27 changes: 27 additions & 0 deletions src/H5FDdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static herr_t H5FD__direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id,
static herr_t H5FD__direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__direct_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD__direct_unlock(H5FD_t *_file);
static herr_t H5FD__direct_delete(const char *filename, hid_t fapl_id);

static const H5FD_class_t H5FD_direct_g = {
"direct", /* name */
Expand Down Expand Up @@ -170,6 +171,7 @@ static const H5FD_class_t H5FD_direct_g = {
H5FD__direct_truncate, /* truncate */
H5FD__direct_lock, /* lock */
H5FD__direct_unlock, /* unlock */
H5FD__direct_delete, /* del */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};

Expand Down Expand Up @@ -1380,4 +1382,29 @@ H5FD__direct_unlock(H5FD_t *_file)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__direct_unlock() */

/*-------------------------------------------------------------------------
* Function: H5FD__direct_delete
*
* Purpose: Delete a file
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5FD__direct_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
{
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_STATIC

HDassert(filename);

if (HDremove(filename) < 0)
HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file")

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__direct_delete() */

#endif /* H5_HAVE_DIRECT */
147 changes: 120 additions & 27 deletions src/H5FDfamily.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,40 +101,42 @@ static herr_t H5FD__family_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing)
static herr_t H5FD__family_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing);
static herr_t H5FD__family_lock(H5FD_t *_file, hbool_t rw);
static herr_t H5FD__family_unlock(H5FD_t *_file);
static herr_t H5FD__family_delete(const char *filename, hid_t fapl_id);

/* The class struct */
static const H5FD_class_t H5FD_family_g = {
"family", /* name */
HADDR_MAX, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
"family", /* name */
HADDR_MAX, /* maxaddr */
H5F_CLOSE_WEAK, /* fc_degree */
H5FD__family_term, /* terminate */
H5FD__family_sb_size, /* sb_size */
H5FD__family_sb_encode, /* sb_encode */
H5FD__family_sb_decode, /* sb_decode */
sizeof(H5FD_family_fapl_t), /* fapl_size */
H5FD__family_fapl_get, /* fapl_get */
H5FD__family_fapl_copy, /* fapl_copy */
H5FD__family_fapl_free, /* fapl_free */
0, /* dxpl_size */
NULL, /* dxpl_copy */
NULL, /* dxpl_free */
H5FD__family_open, /* open */
H5FD__family_close, /* close */
H5FD__family_cmp, /* cmp */
H5FD__family_query, /* query */
NULL, /* get_type_map */
NULL, /* alloc */
NULL, /* free */
H5FD__family_get_eoa, /* get_eoa */
H5FD__family_set_eoa, /* set_eoa */
H5FD__family_get_eof, /* get_eof */
H5FD__family_sb_size, /* sb_size */
H5FD__family_sb_encode, /* sb_encode */
H5FD__family_sb_decode, /* sb_decode */
sizeof(H5FD_family_fapl_t), /* fapl_size */
H5FD__family_fapl_get, /* fapl_get */
H5FD__family_fapl_copy, /* fapl_copy */
H5FD__family_fapl_free, /* fapl_free */
0, /* dxpl_size */
NULL, /* dxpl_copy */
NULL, /* dxpl_free */
H5FD__family_open, /* open */
H5FD__family_close, /* close */
H5FD__family_cmp, /* cmp */
H5FD__family_query, /* query */
NULL, /* get_type_map */
NULL, /* alloc */
NULL, /* free */
H5FD__family_get_eoa, /* get_eoa */
H5FD__family_set_eoa, /* set_eoa */
H5FD__family_get_eof, /* get_eof */
H5FD__family_get_handle, /* get_handle */
H5FD__family_read, /* read */
H5FD__family_write, /* write */
H5FD__family_flush, /* flush */
H5FD__family_truncate, /* truncate */
H5FD__family_read, /* read */
H5FD__family_write, /* write */
H5FD__family_flush, /* flush */
H5FD__family_truncate, /* truncate */
H5FD__family_lock, /* lock */
H5FD__family_unlock, /* unlock */
H5FD__family_delete, /* del */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};

Expand Down Expand Up @@ -1343,3 +1345,94 @@ H5FD__family_unlock(H5FD_t *_file)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__family_unlock() */

/*-------------------------------------------------------------------------
* Function: H5FD__family_delete
*
* Purpose: Delete a file
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5FD__family_delete(const char *filename, hid_t H5_ATTR_UNUSED fapl_id)
{
H5P_genplist_t * plist;
const H5FD_family_fapl_t *fa;
hid_t memb_fapl_id = H5I_INVALID_HID;
unsigned current_member;
char * member_name = NULL;
char * temp = NULL;
herr_t delete_error = FAIL;
herr_t ret_value = SUCCEED;

FUNC_ENTER_STATIC

HDassert(filename);

/* Get the driver info (for the member fapl)
* The family_open call accepts H5P_DEFAULT, so we'll accept that here, too.
*/
if (H5P_FILE_ACCESS_DEFAULT == fapl_id)
memb_fapl_id = H5P_FILE_ACCESS_DEFAULT;
else {
if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
if (NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad family VFD driver info")
memb_fapl_id = fa->memb_fapl_id;
}

/* Allocate space for the string buffers */
if (NULL == (member_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE)))
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate member name")
if (NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE)))
HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate temporary member name")

/* Sanity check to make sure that generated names are unique */
HDsnprintf(member_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, filename, 0);
HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, filename, 1);
if (!HDstrcmp(member_name, temp))
HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "provided file name cannot generate unique sub-files")

/* Delete all the family members */
current_member = 0;
while (1) {
/* Fix up the filename with the current member's number */
HDsnprintf(member_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, filename, current_member);

/* Attempt to delete the member files. If the first file throws an error
* we always consider this an error. With subsequent member files, however,
* errors usually mean that we hit the last member file so we ignore them.
*
* Note that this means that any missing files in the family will leave
* undeleted members behind.
*/
H5E_BEGIN_TRY
{
delete_error = H5FD_delete(member_name, memb_fapl_id);
}
H5E_END_TRY;
if (FAIL == delete_error) {
if (0 == current_member)
HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete member file")
else
H5E_clear_stack(NULL);
break;
}
current_member++;
} /* end while */

done:
if (member_name)
H5MM_xfree(member_name);
if (temp)
H5MM_xfree(temp);

/* Don't close memb_fapl_id - We didn't bump its reference count since we're
* only using it in this call.
*/

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD__family_delete() */
1 change: 1 addition & 0 deletions src/H5FDhdfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ static const H5FD_class_t H5FD_hdfs_g = {
H5FD__hdfs_truncate, /* truncate */
NULL, /* lock */
NULL, /* unlock */
NULL, /* del */
H5FD_FLMAP_DICHOTOMY /* fl_map */
};

Expand Down
44 changes: 44 additions & 0 deletions src/H5FDint.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,47 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/)

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_driver_query() */

/*-------------------------------------------------------------------------
* Function: H5FD_delete
*
* Purpose: Private version of H5FDdelete()
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5FD_delete(const char *filename, hid_t fapl_id)
{
H5FD_class_t * driver; /* VFD for file */
H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
H5P_genplist_t * plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

/* Sanity checks */
HDassert(filename);

/* Get file access property list */
if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")

/* Get the VFD to open the file with */
if (H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID & info")

/* Get driver info */
if (NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id)))
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid driver ID in file access property list")
if (NULL == driver->del)
HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no 'del' method")

/* Dispatch to file driver */
if ((driver->del)(filename, fapl_id))
HGOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "delete failed")

done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_delete() */
Loading