diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-09-09 14:45:50 +1000 |
---|---|---|
committer | Luke Chen <luke.chen@mongodb.com> | 2019-09-09 14:48:15 +1000 |
commit | d1c52b7aafac44e16dd62ce94663eab1aa16f921 (patch) | |
tree | 2aea018150b745b0fc7ef3dc626c4ef4164d2704 /src/third_party/wiredtiger/src/include/os.h | |
parent | b326fd656716e95418e563ff12368a3015994b5e (diff) | |
download | mongo-d1c52b7aafac44e16dd62ce94663eab1aa16f921.tar.gz |
Import wiredtiger: c600bde20363629405082a3ea985b70dfb00850e from branch mongodb-4.2
ref: 280c572c80..c600bde203
for: 4.2.1
WT-4535 Enhance wt command line utility to use read-only mode
WT-4658 Apply Clang Format
WT-4810 Adding WT_ERR_ASSERT and WT_RET_ASSERT macros
WT-4831 Add option to python tests to not fail if stdout is not empty
WT-4884 Test for recovery correctness with modify operations
WT-4935 Add a perf test to find out the wiredtiger_calc_modify overhead
WT-4966 Fix valgrind detected memory leak from test/csuite/import/smoke.sh
WT-5043 Add debugging to aid in test/format hang
WT-5046 Prepared transactions aren't properly cleared from global table with WT_CONN_LOG_DEBUG_MODE enabled
WT-5062 Adjust the record size to consume less size
WT-5063 Return proper error message for cursor modify operation for not supported cursor types
WT-5074 Fix "make check" on exotic architectures
WT-5076 Cut WiredTiger 3.2.1 release
WT-5080 New wtperf workload modify_distribute option
WT-5085 Fix spacing in wtperf output
WT-5087 Add time tracking at start of reconciliation
WT-5088 Refine clearing and setting of debug timer
WT-5100 Update test format to disable readonly mode in utility
Diffstat (limited to 'src/third_party/wiredtiger/src/include/os.h')
-rw-r--r-- | src/third_party/wiredtiger/src/include/os.h | 289 |
1 files changed, 142 insertions, 147 deletions
diff --git a/src/third_party/wiredtiger/src/include/os.h b/src/third_party/wiredtiger/src/include/os.h index 37e0799ef16..919edeec586 100644 --- a/src/third_party/wiredtiger/src/include/os.h +++ b/src/third_party/wiredtiger/src/include/os.h @@ -6,179 +6,174 @@ * See the file LICENSE for redistribution information. */ -#define WT_SYSCALL(call, ret) do { \ - /* \ - * A call returning 0 indicates success; any call where \ - * 0 is not the only successful return must provide an \ - * expression evaluating to 0 in all successful cases. \ - * \ - * XXX \ - * Casting the call's return to int is because CentOS 7.3.1611 \ - * complains about syscall returning a long and the loss of \ - * integer precision in the assignment to ret. The cast should \ - * be a no-op everywhere. \ - */ \ - if (((ret) = (int)(call)) == 0) \ - break; \ - /* \ - * The call's error was either returned by the call or \ - * is in errno, and there are cases where it depends on \ - * the software release as to which it is (for example, \ - * posix_fadvise on FreeBSD and OS X). Failing calls \ - * must either return a non-zero error value, or -1 if \ - * the error value is in errno. (The WiredTiger errno \ - * function returns WT_ERROR if errno is 0, which isn't \ - * ideal but won't discard the failure.) \ - */ \ - if ((ret) == -1) \ - (ret) = __wt_errno(); \ -} while (0) - -#define WT_RETRY_MAX 10 - -#define WT_SYSCALL_RETRY(call, ret) do { \ - int __retry; \ - for (__retry = 0; __retry < WT_RETRY_MAX; ++__retry) { \ - WT_SYSCALL(call, ret); \ - switch (ret) { \ - case EAGAIN: \ - case EBUSY: \ - case EINTR: \ - case EIO: \ - case EMFILE: \ - case ENFILE: \ - case ENOSPC: \ - __wt_sleep(0L, 50000L); \ - continue; \ - default: \ - break; \ - } \ - break; \ - } \ -} while (0) - -#define WT_TIMEDIFF_NS(end, begin) \ - (WT_BILLION * (uint64_t)((end).tv_sec - (begin).tv_sec) + \ - (uint64_t)(end).tv_nsec - (uint64_t)(begin).tv_nsec) -#define WT_TIMEDIFF_US(end, begin) \ - (WT_TIMEDIFF_NS((end), (begin)) / WT_THOUSAND) -#define WT_TIMEDIFF_MS(end, begin) \ - (WT_TIMEDIFF_NS((end), (begin)) / WT_MILLION) -#define WT_TIMEDIFF_SEC(end, begin) \ - (WT_TIMEDIFF_NS((end), (begin)) / WT_BILLION) - -#define WT_CLOCKDIFF_NS(end, begin) \ - (__wt_clock_to_nsec(end, begin)) -#define WT_CLOCKDIFF_US(end, begin) \ - (WT_CLOCKDIFF_NS(end, begin) / WT_THOUSAND) -#define WT_CLOCKDIFF_MS(end, begin) \ - (WT_CLOCKDIFF_NS(end, begin) / WT_MILLION) -#define WT_CLOCKDIFF_SEC(end, begin) \ - (WT_CLOCKDIFF_NS(end, begin) / WT_BILLION) - -#define WT_TIMECMP(t1, t2) \ - ((t1).tv_sec < (t2).tv_sec ? -1 : \ - (t1).tv_sec == (t2).tv_sec ? \ - (t1).tv_nsec < (t2).tv_nsec ? -1 : \ - (t1).tv_nsec == (t2).tv_nsec ? 0 : 1 : 1) +#define WT_SYSCALL(call, ret) \ + do { \ + /* \ + * A call returning 0 indicates success; any call where \ + * 0 is not the only successful return must provide an \ + * expression evaluating to 0 in all successful cases. \ + * \ + * XXX \ + * Casting the call's return to int is because CentOS 7.3.1611 \ + * complains about syscall returning a long and the loss of \ + * integer precision in the assignment to ret. The cast should \ + * be a no-op everywhere. \ + */ \ + if (((ret) = (int)(call)) == 0) \ + break; \ + /* \ + * The call's error was either returned by the call or \ + * is in errno, and there are cases where it depends on \ + * the software release as to which it is (for example, \ + * posix_fadvise on FreeBSD and OS X). Failing calls \ + * must either return a non-zero error value, or -1 if \ + * the error value is in errno. (The WiredTiger errno \ + * function returns WT_ERROR if errno is 0, which isn't \ + * ideal but won't discard the failure.) \ + */ \ + if ((ret) == -1) \ + (ret) = __wt_errno(); \ + } while (0) + +#define WT_RETRY_MAX 10 + +#define WT_SYSCALL_RETRY(call, ret) \ + do { \ + int __retry; \ + for (__retry = 0; __retry < WT_RETRY_MAX; ++__retry) { \ + WT_SYSCALL(call, ret); \ + switch (ret) { \ + case EAGAIN: \ + case EBUSY: \ + case EINTR: \ + case EIO: \ + case EMFILE: \ + case ENFILE: \ + case ENOSPC: \ + __wt_sleep(0L, 50000L); \ + continue; \ + default: \ + break; \ + } \ + break; \ + } \ + } while (0) + +#define WT_TIMEDIFF_NS(end, begin) \ + (WT_BILLION * (uint64_t)((end).tv_sec - (begin).tv_sec) + (uint64_t)(end).tv_nsec - \ + (uint64_t)(begin).tv_nsec) +#define WT_TIMEDIFF_US(end, begin) (WT_TIMEDIFF_NS((end), (begin)) / WT_THOUSAND) +#define WT_TIMEDIFF_MS(end, begin) (WT_TIMEDIFF_NS((end), (begin)) / WT_MILLION) +#define WT_TIMEDIFF_SEC(end, begin) (WT_TIMEDIFF_NS((end), (begin)) / WT_BILLION) + +#define WT_CLOCKDIFF_NS(end, begin) (__wt_clock_to_nsec(end, begin)) +#define WT_CLOCKDIFF_US(end, begin) (WT_CLOCKDIFF_NS(end, begin) / WT_THOUSAND) +#define WT_CLOCKDIFF_MS(end, begin) (WT_CLOCKDIFF_NS(end, begin) / WT_MILLION) +#define WT_CLOCKDIFF_SEC(end, begin) (WT_CLOCKDIFF_NS(end, begin) / WT_BILLION) + +#define WT_TIMECMP(t1, t2) \ + ((t1).tv_sec < (t2).tv_sec ? -1 : (t1).tv_sec == (t2).tv_sec ? \ + (t1).tv_nsec < (t2).tv_nsec ? -1 : (t1).tv_nsec == (t2).tv_nsec ? \ + 0 : \ + 1 : \ + 1) /* - * Macros to ensure a file handle is inserted or removed from both the main and - * the hashed queue, used by connection-level and in-memory data structures. + * Macros to ensure a file handle is inserted or removed from both the main and the hashed queue, + * used by connection-level and in-memory data structures. */ -#define WT_FILE_HANDLE_INSERT(h, fh, bucket) do { \ - TAILQ_INSERT_HEAD(&(h)->fhqh, fh, q); \ - TAILQ_INSERT_HEAD(&(h)->fhhash[bucket], fh, hashq); \ -} while (0) - -#define WT_FILE_HANDLE_REMOVE(h, fh, bucket) do { \ - TAILQ_REMOVE(&(h)->fhqh, fh, q); \ - TAILQ_REMOVE(&(h)->fhhash[bucket], fh, hashq); \ -} while (0) +#define WT_FILE_HANDLE_INSERT(h, fh, bucket) \ + do { \ + TAILQ_INSERT_HEAD(&(h)->fhqh, fh, q); \ + TAILQ_INSERT_HEAD(&(h)->fhhash[bucket], fh, hashq); \ + } while (0) + +#define WT_FILE_HANDLE_REMOVE(h, fh, bucket) \ + do { \ + TAILQ_REMOVE(&(h)->fhqh, fh, q); \ + TAILQ_REMOVE(&(h)->fhhash[bucket], fh, hashq); \ + } while (0) struct __wt_fh { - /* - * There is a file name field in both the WT_FH and WT_FILE_HANDLE - * structures, which isn't ideal. There would be compromises to keeping - * a single copy: If it were in WT_FH, file systems could not access - * the name field, if it were just in the WT_FILE_HANDLE internal - * WiredTiger code would need to maintain a string inside a structure - * that is owned by the user (since we care about the content of the - * file name). Keeping two copies seems most reasonable. - */ - const char *name; /* File name */ - - uint64_t name_hash; /* hash of name */ - uint64_t last_sync; /* time of background fsync */ - volatile uint64_t written; /* written since fsync */ - TAILQ_ENTRY(__wt_fh) q; /* internal queue */ - TAILQ_ENTRY(__wt_fh) hashq; /* internal hash queue */ - u_int ref; /* reference count */ - WT_FS_OPEN_FILE_TYPE file_type; /* file type */ - - WT_FILE_HANDLE *handle; + /* + * There is a file name field in both the WT_FH and WT_FILE_HANDLE structures, which isn't + * ideal. There would be compromises to keeping a single copy: If it were in WT_FH, file systems + * could not access the name field, if it were just in the WT_FILE_HANDLE internal WiredTiger + * code would need to maintain a string inside a structure that is owned by the user (since we + * care about the content of the file name). Keeping two copies seems most reasonable. + */ + const char *name; /* File name */ + + uint64_t name_hash; /* hash of name */ + uint64_t last_sync; /* time of background fsync */ + volatile uint64_t written; /* written since fsync */ + TAILQ_ENTRY(__wt_fh) q; /* internal queue */ + TAILQ_ENTRY(__wt_fh) hashq; /* internal hash queue */ + u_int ref; /* reference count */ + WT_FS_OPEN_FILE_TYPE file_type; /* file type */ + + WT_FILE_HANDLE *handle; }; #ifdef _WIN32 struct __wt_file_handle_win { - WT_FILE_HANDLE iface; - - /* - * Windows specific file handle fields - */ - HANDLE filehandle; /* Windows file handle */ - HANDLE filehandle_secondary; /* Windows file handle - for file size changes */ - bool direct_io; /* O_DIRECT configured */ + WT_FILE_HANDLE iface; + + /* + * Windows specific file handle fields + */ + HANDLE filehandle; /* Windows file handle */ + HANDLE filehandle_secondary; /* Windows file handle + for file size changes */ + bool direct_io; /* O_DIRECT configured */ }; #else struct __wt_file_handle_posix { - WT_FILE_HANDLE iface; + WT_FILE_HANDLE iface; - /* - * POSIX specific file handle fields - */ - int fd; /* POSIX file handle */ + /* + * POSIX specific file handle fields + */ + int fd; /* POSIX file handle */ - bool direct_io; /* O_DIRECT configured */ + bool direct_io; /* O_DIRECT configured */ }; #endif struct __wt_file_handle_inmem { - WT_FILE_HANDLE iface; + WT_FILE_HANDLE iface; - /* - * In memory specific file handle fields - */ - uint64_t name_hash; /* hash of name */ - TAILQ_ENTRY(__wt_file_handle_inmem) q; /* internal queue, hash queue */ - TAILQ_ENTRY(__wt_file_handle_inmem) hashq; + /* + * In memory specific file handle fields + */ + uint64_t name_hash; /* hash of name */ + TAILQ_ENTRY(__wt_file_handle_inmem) q; /* internal queue, hash queue */ + TAILQ_ENTRY(__wt_file_handle_inmem) hashq; - WT_ITEM buf; /* Data */ - u_int ref; /* Reference count */ + WT_ITEM buf; /* Data */ + u_int ref; /* Reference count */ }; struct __wt_fstream { - const char *name; /* Stream name */ + const char *name; /* Stream name */ - FILE *fp; /* stdio FILE stream */ - WT_FH *fh; /* WT file handle */ - wt_off_t off; /* Read/write offset */ - wt_off_t size; /* File size */ - WT_ITEM buf; /* Data */ + FILE *fp; /* stdio FILE stream */ + WT_FH *fh; /* WT file handle */ + wt_off_t off; /* Read/write offset */ + wt_off_t size; /* File size */ + WT_ITEM buf; /* Data */ /* AUTOMATIC FLAG VALUE GENERATION START */ -#define WT_STREAM_APPEND 0x1u /* Open a stream for append */ -#define WT_STREAM_READ 0x2u /* Open a stream for read */ -#define WT_STREAM_WRITE 0x4u /* Open a stream for write */ -/* AUTOMATIC FLAG VALUE GENERATION STOP */ - uint32_t flags; - - int (*close)(WT_SESSION_IMPL *, WT_FSTREAM *); - int (*fstr_flush)(WT_SESSION_IMPL *, WT_FSTREAM *); - int (*fstr_getline)(WT_SESSION_IMPL *, WT_FSTREAM *, WT_ITEM *); - int (*fstr_printf)( - WT_SESSION_IMPL *, WT_FSTREAM *, const char *, va_list); +#define WT_STREAM_APPEND 0x1u /* Open a stream for append */ +#define WT_STREAM_READ 0x2u /* Open a stream for read */ +#define WT_STREAM_WRITE 0x4u /* Open a stream for write */ + /* AUTOMATIC FLAG VALUE GENERATION STOP */ + uint32_t flags; + + int (*close)(WT_SESSION_IMPL *, WT_FSTREAM *); + int (*fstr_flush)(WT_SESSION_IMPL *, WT_FSTREAM *); + int (*fstr_getline)(WT_SESSION_IMPL *, WT_FSTREAM *, WT_ITEM *); + int (*fstr_printf)(WT_SESSION_IMPL *, WT_FSTREAM *, const char *, va_list); }; |