Files
mongo/src/include/os_fstream.i
Keith Bostic 82323cf72f WT-2760 Fix a bug in backup related to directory sync. Change the filesystem API to make durable the default (#2867)
Change the default remove/rename calls to flush the enclosing directory.

Simplify the pluggable file system API by replacing the directory-sync method
with "durable" boolean argument to the remove, rename and open-file methods.

* Add "durable" arguments to relevant functions so that each remove or rename
call specifies its durability requirements.

* Switch the  WT_FILE_SYSTEM::fs_open_file type enum from WT_OPEN_FILE_TYPE,
with WT_OPEN_XXX names, to the WT_FS_OPEN_FILE_TYPE, with WT_FS_OPEN_XXX
names.

Switch the  WT_FILE_SYSTEM::fs_open_file flags from WT_OPEN_XXX names to
WT_FS_OPEN_XXX names.

* Replace the "bool durable" argument to WT_FILE_SYSTEM.fs_remove and
WT_FILE_SYSTEM.fs_rename with a "uint32_t flags" argument, and the
WT_FS_DURABLE flag.

* Remove a stray bracket.

(cherry picked from commit 11f018322c)
2016-07-29 16:18:32 +10:00

98 lines
1.9 KiB
OpenEdge ABL

/*-
* Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
* See the file LICENSE for redistribution information.
*/
/*
* __wt_getline --
* Get a line from a stream.
*/
static inline int
__wt_getline(WT_SESSION_IMPL *session, WT_FSTREAM *fstr, WT_ITEM *buf)
{
return (fstr->fstr_getline(session, fstr, buf));
}
/*
* __wt_fclose --
* Close a stream.
*/
static inline int
__wt_fclose(WT_SESSION_IMPL *session, WT_FSTREAM **fstrp)
{
WT_FSTREAM *fstr;
if ((fstr = *fstrp) == NULL)
return (0);
*fstrp = NULL;
return (fstr->close(session, fstr));
}
/*
* __wt_fflush --
* Flush a stream.
*/
static inline int
__wt_fflush(WT_SESSION_IMPL *session, WT_FSTREAM *fstr)
{
return (fstr->fstr_flush(session, fstr));
}
/*
* __wt_vfprintf --
* ANSI C vfprintf.
*/
static inline int
__wt_vfprintf(
WT_SESSION_IMPL *session, WT_FSTREAM *fstr, const char *fmt, va_list ap)
{
WT_RET(__wt_verbose(
session, WT_VERB_HANDLEOPS, "%s: handle-printf", fstr->name));
return (fstr->fstr_printf(session, fstr, fmt, ap));
}
/*
* __wt_fprintf --
* ANSI C fprintf.
*/
static inline int
__wt_fprintf(WT_SESSION_IMPL *session, WT_FSTREAM *fstr, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format (printf, 3, 4)))
{
WT_DECL_RET;
va_list ap;
va_start(ap, fmt);
ret = __wt_vfprintf(session, fstr, fmt, ap);
va_end(ap);
return (ret);
}
/*
* __wt_sync_and_rename --
* Flush and close a stream, then swap it into place.
*/
static inline int
__wt_sync_and_rename(WT_SESSION_IMPL *session,
WT_FSTREAM **fstrp, const char *from, const char *to)
{
WT_DECL_RET;
WT_FSTREAM *fstr;
fstr = *fstrp;
*fstrp = NULL;
/* Flush to disk and close the handle. */
WT_TRET(__wt_fflush(session, fstr));
WT_TRET(__wt_fsync(session, fstr->fh, true));
WT_TRET(__wt_fclose(session, &fstr));
WT_RET(ret);
return (__wt_fs_rename(session, from, to, true));
}