diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-08-18 03:08:55 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-08-18 03:08:55 (GMT) |
commit | dfd5e0bf3e5e360786143bf0486d52120342ef14 (patch) | |
tree | 462f6da5d3fe75d02e1a08b0089e0c6c2b3b5fcd /src | |
parent | 30574df1655e212721746db9a21fd432503eb5c1 (diff) | |
download | hdf5-dfd5e0bf3e5e360786143bf0486d52120342ef14.zip hdf5-dfd5e0bf3e5e360786143bf0486d52120342ef14.tar.gz hdf5-dfd5e0bf3e5e360786143bf0486d52120342ef14.tar.bz2 |
Brings H5Fstart_swmr_write changes from develop
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Fint.c | 17 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5Fprivate.h | 3 | ||||
-rw-r--r-- | src/H5Fquery.c | 21 |
4 files changed, 36 insertions, 7 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c index 2b030e7..8b9d923 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1730,9 +1730,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) set_flag = TRUE; } /* end else */ - /* Set the file locking flag */ - file->use_file_locking = use_file_locking; - /* Check to see if both SWMR and cache image are requested. Fail if so */ if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") @@ -1746,6 +1743,15 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) shared = file->shared; lf = shared->lf; + /* Set the file locking flag. If the file is already open, the file + * requested file locking flag must match that of the open file. + */ + if(shared->nrefs == 1) + file->shared->use_file_locking = use_file_locking; + else if(shared->nrefs > 1) + if(file->shared->use_file_locking != use_file_locking) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file locking flag values don't match") + /* Check if page buffering is enabled */ if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size") @@ -3433,7 +3439,6 @@ H5F__start_swmr_write(H5F_t *f) H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ size_t u; /* Local index variable */ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ - hbool_t use_file_locking = TRUE;/* Using file locks? */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3546,7 +3551,7 @@ H5F__start_swmr_write(H5F_t *f) setup = TRUE; /* Place an advisory lock on the file */ - if(f->use_file_locking) + if(H5F_USE_FILE_LOCKING(f)) if(H5FD_lock(f->shared->lf, TRUE) < 0) { HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, FAIL, "unable to lock the file") } @@ -3597,7 +3602,7 @@ done: } /* end if */ /* Unlock the file */ - if(f->use_file_locking) + if(H5F_USE_FILE_LOCKING(f)) if(H5FD_unlock(f->shared->lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file") diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 7122d36..cc37d19 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -306,6 +306,7 @@ struct H5F_shared_t { struct H5G_t *root_grp; /* Open root group */ H5FO_t *open_objs; /* Open objects in file */ H5UC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ + hbool_t use_file_locking; /* Whether or not to use file locking */ /* File space allocation information */ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ @@ -373,7 +374,6 @@ struct H5F_t { hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ - hbool_t use_file_locking; /* Whether or not to use file locking */ #ifdef H5_HAVE_PARALLEL H5P_coll_md_read_flag_t coll_md_read; /* Do all metadata reads collectively */ hbool_t coll_md_write; /* Do all metadata writes collectively */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index fd161e2..469a37c 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -336,6 +336,7 @@ typedef struct H5F_t H5F_t; #define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) #define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) #define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) +#define H5F_USE_FILE_LOCKING(F) ((F)->shared->use_file_locking) #else /* H5F_MODULE */ #define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) #define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) @@ -397,6 +398,7 @@ typedef struct H5F_t H5F_t; #define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) #define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) #define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) +#define H5F_USE_FILE_LOCKING(F) (H5F_get_use_file_locking(F)) #endif /* H5F_MODULE */ @@ -756,6 +758,7 @@ H5_DLL hbool_t H5F_get_first_alloc_dealloc(const H5F_t *f); H5_DLL haddr_t H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f); H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); +H5_DLL hbool_t H5F_get_file_locking(const H5F_t *f); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 4125a23..32587bf 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1302,3 +1302,24 @@ H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f) FUNC_LEAVE_NOAPI(f->shared->eoa_pre_fsm_fsalloc) } /* end H5F_get_eoa_pre_fsm_fsalloc() */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_file_locking + * + * Purpose: Get the file locking flag for the file + * + * Return: TRUE/FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_file_locking(const H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + HDassert(f->shared); + + FUNC_LEAVE_NOAPI(f->shared->use_file_locking) +} /* end H5F_get_file_locking */ + |