summaryrefslogtreecommitdiff
path: root/src/block/block_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/block/block_open.c')
-rw-r--r--src/block/block_open.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/block/block_open.c b/src/block/block_open.c
index f4da5ca7c05..e58bef30a6d 100644
--- a/src/block/block_open.c
+++ b/src/block/block_open.c
@@ -33,7 +33,6 @@ __wt_block_manager_create(
WT_FH *fh;
int suffix;
bool exists;
- char *path;
/*
* Create the underlying file and open a handle.
@@ -44,7 +43,7 @@ __wt_block_manager_create(
* in our space. Move any existing files out of the way and complain.
*/
for (;;) {
- if ((ret = __wt_open(session, filename, WT_FILE_TYPE_DATA,
+ if ((ret = __wt_open(session, filename, WT_OPEN_FILE_TYPE_DATA,
WT_OPEN_CREATE | WT_OPEN_EXCLUSIVE, &fh)) == 0)
break;
WT_ERR_TEST(ret != EEXIST, ret);
@@ -54,10 +53,10 @@ __wt_block_manager_create(
for (suffix = 1;; ++suffix) {
WT_ERR(__wt_buf_fmt(
session, tmp, "%s.%d", filename, suffix));
- WT_ERR(__wt_exist(session, tmp->data, &exists));
+ WT_ERR(__wt_fs_exist(session, tmp->data, &exists));
if (!exists) {
- WT_ERR(
- __wt_rename(session, filename, tmp->data));
+ WT_ERR(__wt_fs_rename(
+ session, filename, tmp->data));
WT_ERR(__wt_msg(session,
"unexpected file %s found, renamed to %s",
filename, (char *)tmp->data));
@@ -82,14 +81,12 @@ __wt_block_manager_create(
* Some filesystems require that we sync the directory to be confident
* that the file will appear.
*/
- if (ret == 0 && (ret = __wt_filename(session, filename, &path)) == 0) {
- ret = __wt_directory_sync(session, path);
- __wt_free(session, path);
- }
+ if (ret == 0)
+ WT_TRET(__wt_fs_directory_sync(session, filename));
/* Undo any create on error. */
if (ret != 0)
- WT_TRET(__wt_remove(session, filename));
+ WT_TRET(__wt_fs_remove(session, filename));
err: __wt_scr_free(session, &tmp);
@@ -156,8 +153,7 @@ __wt_block_open(WT_SESSION_IMPL *session,
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
uint64_t bucket, hash;
-
- WT_UNUSED(readonly);
+ uint32_t flags;
WT_RET(__wt_verbose(session, WT_VERB_BLOCK, "open: %s", filename));
@@ -204,12 +200,18 @@ __wt_block_open(WT_SESSION_IMPL *session,
/* Set the file extension information. */
block->extend_len = conn->data_extend_len;
- /* Set the asynchronous flush, preload availability. */
- block->nowait_sync_available = true;
- block->preload_available = true;
-
- /* Open the underlying file handle. */
- WT_ERR(__wt_open(session, filename, WT_FILE_TYPE_DATA, 0, &block->fh));
+ /*
+ * Open the underlying file handle.
+ *
+ * "direct_io=checkpoint" configures direct I/O for readonly data files.
+ */
+ flags = 0;
+ if (readonly && FLD_ISSET(conn->direct_io, WT_DIRECT_IO_CHECKPOINT))
+ LF_SET(WT_OPEN_DIRECTIO);
+ if (!readonly && FLD_ISSET(conn->direct_io, WT_DIRECT_IO_DATA))
+ LF_SET(WT_OPEN_DIRECTIO);
+ WT_ERR(__wt_open(
+ session, filename, WT_OPEN_FILE_TYPE_DATA, flags, &block->fh));
/* Set the file's size. */
WT_ERR(__wt_filesize(session, block->fh, &block->size));
@@ -422,5 +424,5 @@ int
__wt_block_manager_named_size(
WT_SESSION_IMPL *session, const char *name, wt_off_t *sizep)
{
- return (__wt_filesize_name(session, name, false, sizep));
+ return (__wt_fs_size(session, name, sizep));
}