summaryrefslogtreecommitdiff
path: root/src/os_posix
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2016-04-04 16:47:33 -0400
committerKeith Bostic <keith@wiredtiger.com>2016-04-04 16:47:33 -0400
commit5b34fb2eed8ba6f5b6e925d689ecb3413bad130a (patch)
tree5acab50bd53dfacbff0040f00585a39e20fbf25a /src/os_posix
parent1d340e2ce9d3f06adb64fe82cf610cc09e610c5f (diff)
downloadmongo-5b34fb2eed8ba6f5b6e925d689ecb3413bad130a.tar.gz
WT-2526: mixing and matching readonly and read/write handles
Change WiredTiger to always open handles in read/write mode unless the database itself is configured read-only. The WT_OPEN_READONLY flag is now OS-specific, and not used above that level. Requires the creation of a new open flag, WT_OPEN_DIRECTIO: this flag is set in the OS layer, based on how the connection is configured. It is also set in the block-manager layer, because that's the only place we know we're opening a read-only data file (required for support of the "direct_io=checkpoint" configuration).
Diffstat (limited to 'src/os_posix')
-rw-r--r--src/os_posix/os_fs.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c
index 86aa8db8f4f..d32cab6cde6 100644
--- a/src/os_posix/os_fs.c
+++ b/src/os_posix/os_fs.c
@@ -539,11 +539,9 @@ __posix_handle_open(WT_SESSION_IMPL *session,
WT_DECL_RET;
mode_t mode;
int f, fd, tret;
- bool direct_io;
const char *stream_mode;
conn = S2C(session);
- direct_io = false;
/* Set up error handling. */
fh->fd = fd = -1;
@@ -589,21 +587,12 @@ __posix_handle_open(WT_SESSION_IMPL *session,
f |= O_CLOEXEC;
#endif
#ifdef O_DIRECT
- /*
- * Direct I/O: file-type is a flag from the set of possible flags stored
- * in the connection handle during configuration, check for a match.
- * Also, "direct_io=checkpoint" configures direct I/O for readonly data
- * files.
- */
- if (FLD_ISSET(conn->direct_io, file_type) ||
- (LF_ISSET(WT_OPEN_READONLY) &&
- file_type == WT_FILE_TYPE_DATA &&
- FLD_ISSET(conn->direct_io, WT_FILE_TYPE_CHECKPOINT))) {
+ /* Direct I/O. */
+ if (LF_ISSET(WT_OPEN_DIRECTIO)) {
f |= O_DIRECT;
- direct_io = true;
+ fh->direct_io = true;
}
#endif
- fh->direct_io = direct_io;
#ifdef O_NOATIME
/* Avoid updating metadata for read-only workloads. */
if (file_type == WT_FILE_TYPE_DATA)
@@ -625,7 +614,7 @@ __posix_handle_open(WT_SESSION_IMPL *session,
WT_SYSCALL_RETRY(((fd = open(name, f, mode)) == -1 ? 1 : 0), ret);
if (ret != 0)
WT_ERR_MSG(session, ret,
- direct_io ?
+ fh->direct_io ?
"%s: handle-open: open: failed with direct I/O configured, "
"some filesystem types do not support direct I/O" :
"%s: handle-open: open", name);