diff options
Diffstat (limited to 'src/os_common/filename.c')
-rw-r--r-- | src/os_common/filename.c | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/src/os_common/filename.c b/src/os_common/filename.c index dfd67284948..5f174288350 100644 --- a/src/os_common/filename.c +++ b/src/os_common/filename.c @@ -60,9 +60,9 @@ __wt_remove_if_exists(WT_SESSION_IMPL *session, const char *name) { bool exist; - WT_RET(__wt_exist(session, name, &exist)); + WT_RET(__wt_fs_exist(session, name, &exist)); if (exist) - WT_RET(__wt_remove(session, name)); + WT_RET(__wt_fs_remove(session, name)); return (0); } @@ -78,7 +78,7 @@ __wt_rename_and_sync_directory( bool same_directory; /* Rename the source file to the target. */ - WT_RET(__wt_rename(session, from, to)); + WT_RET(__wt_fs_rename(session, from, to)); /* * Flush the backing directory to guarantee the rename. My reading of @@ -89,7 +89,7 @@ __wt_rename_and_sync_directory( * with specific mount options. Flush both of the from/to directories * until it's a performance problem. */ - WT_RET(__wt_directory_sync(session, from)); + WT_RET(__wt_fs_directory_sync(session, from)); /* * In almost all cases, we're going to be renaming files in the same @@ -101,29 +101,7 @@ __wt_rename_and_sync_directory( (fp != NULL && tp != NULL && fp - from == tp - to && memcmp(from, to, (size_t)(fp - from)) == 0); - return (same_directory ? 0 : __wt_directory_sync(session, to)); -} - -/* - * __wt_sync_handle_and_rename -- - * Sync and close a handle, and swap it into place. - */ -int -__wt_sync_handle_and_rename( - WT_SESSION_IMPL *session, WT_FH **fhp, const char *from, const char *to) -{ - WT_DECL_RET; - WT_FH *fh; - - fh = *fhp; - *fhp = NULL; - - /* Flush to disk and close the handle. */ - ret = __wt_fsync(session, fh, true); - WT_TRET(__wt_close(session, &fh)); - WT_RET(ret); - - return (__wt_rename_and_sync_directory(session, from, to)); + return (same_directory ? 0 : __wt_fs_directory_sync(session, to)); } /* @@ -160,10 +138,9 @@ __wt_copy_and_sync(WT_SESSION *wt_session, const char *from, const char *to) WT_ERR(__wt_remove_if_exists(session, tmp->data)); /* Open the from and temporary file handles. */ - WT_ERR(__wt_open(session, from, - WT_FILE_TYPE_REGULAR, WT_OPEN_READONLY, &ffh)); - WT_ERR(__wt_open(session, tmp->data, - WT_FILE_TYPE_REGULAR, WT_OPEN_CREATE | WT_OPEN_EXCLUSIVE, &tfh)); + WT_ERR(__wt_open(session, from, WT_OPEN_FILE_TYPE_REGULAR, 0, &ffh)); + WT_ERR(__wt_open(session, tmp->data, WT_OPEN_FILE_TYPE_REGULAR, + WT_OPEN_CREATE | WT_OPEN_EXCLUSIVE, &tfh)); /* * Allocate a copy buffer. Don't use a scratch buffer, this thing is @@ -182,7 +159,10 @@ __wt_copy_and_sync(WT_SESSION *wt_session, const char *from, const char *to) /* Close the from handle, then swap the temporary file into place. */ WT_ERR(__wt_close(session, &ffh)); - ret = __wt_sync_handle_and_rename(session, &tfh, tmp->data, to); + WT_ERR(__wt_fsync(session, tfh, true)); + WT_ERR(__wt_close(session, &tfh)); + + ret = __wt_rename_and_sync_directory(session, tmp->data, to); err: WT_TRET(__wt_close(session, &ffh)); WT_TRET(__wt_close(session, &tfh)); |