summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index b381369..504a555 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -1075,8 +1075,9 @@ H5F__super_init(H5F_t *f)
FALSE; /* Whether the driver info block has been inserted into the metadata cache */
H5P_genplist_t *plist; /* File creation property list */
H5AC_ring_t orig_ring = H5AC_RING_INV;
- hsize_t userblock_size; /* Size of userblock, in bytes */
- hsize_t superblock_size; /* Size of superblock, in bytes */
+ hsize_t userblock_size; /* Size of userblock, in bytes */
+ hsize_t superblock_size = 0; /* Size of superblock, in bytes */
+ haddr_t superblock_addr = HADDR_UNDEF;
size_t driver_size; /* Size of driver info block (bytes) */
unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */
H5O_loc_t ext_loc; /* Superblock extension object location */
@@ -1276,7 +1277,7 @@ H5F__super_init(H5F_t *f)
f->shared->sblock = sblock;
/* Allocate space for the superblock */
- if (HADDR_UNDEF == H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size))
+ if (HADDR_UNDEF == (superblock_addr = H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock");
/* set the drvinfo filed to NULL -- will overwrite this later if needed */
@@ -1468,6 +1469,19 @@ done:
/* Check if the superblock has been allocated yet */
if (sblock) {
+ if (non_default_fs_settings && H5_addr_defined(superblock_addr)) {
+ /*
+ * For non-default free-space settings, the allocation of
+ * space in the file for the superblock may have have allocated
+ * memory for the free-space manager and inserted it into the
+ * metadata cache. Clean that up before returning or we may fail
+ * to close the file later due to the metadata cache's metadata
+ * free space manager ring (H5AC_RING_MDFSM) not being clean.
+ */
+ if (H5MF_try_close(f) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close file free space manager");
+ }
+
/* Check if we've cached it already */
if (sblock_in_cache) {
/* Unpin superblock in cache */