diff options
-rw-r--r-- | src/block/block_open.c | 2 | ||||
-rw-r--r-- | src/include/extern.h | 2 | ||||
-rw-r--r-- | src/lsm/lsm_tree.c | 2 | ||||
-rw-r--r-- | src/os_posix/os_filesize.c | 12 | ||||
-rw-r--r-- | src/os_win/os_filesize.c | 17 | ||||
-rw-r--r-- | src/schema/schema_stat.c | 11 |
6 files changed, 31 insertions, 15 deletions
diff --git a/src/block/block_open.c b/src/block/block_open.c index e1f3e6de0fe..7cf12d36066 100644 --- a/src/block/block_open.c +++ b/src/block/block_open.c @@ -424,7 +424,7 @@ __wt_block_manager_size( { wt_off_t filesize; - WT_RET(__wt_filesize_name(session, filename, &filesize)); + WT_RET(__wt_filesize_name(session, filename, false, &filesize)); stats->block_size = filesize; return (0); diff --git a/src/include/extern.h b/src/include/extern.h index 4c934f95c2b..75064c56334 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -477,7 +477,7 @@ extern int __wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *exis extern void __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh); extern int __wt_fallocate( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, wt_off_t len); extern int __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep); -extern int __wt_filesize_name( WT_SESSION_IMPL *session, const char *filename, wt_off_t *sizep); +extern int __wt_filesize_name(WT_SESSION_IMPL *session, const char *filename, bool silent, wt_off_t *sizep); extern int __wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock); extern int __wt_directory_sync_fh(WT_SESSION_IMPL *session, WT_FH *fh); extern int __wt_directory_sync(WT_SESSION_IMPL *session, char *path); diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c index bd54202de5e..30af051bbcf 100644 --- a/src/lsm/lsm_tree.c +++ b/src/lsm/lsm_tree.c @@ -220,7 +220,7 @@ __wt_lsm_tree_set_chunk_size( if (!WT_PREFIX_SKIP(filename, "file:")) WT_RET_MSG(session, EINVAL, "Expected a 'file:' URI: %s", chunk->uri); - WT_RET(__wt_filesize_name(session, filename, &size)); + WT_RET(__wt_filesize_name(session, filename, false, &size)); chunk->size = (uint64_t)size; diff --git a/src/os_posix/os_filesize.c b/src/os_posix/os_filesize.c index b01fc91514b..c58f73b0665 100644 --- a/src/os_posix/os_filesize.c +++ b/src/os_posix/os_filesize.c @@ -34,8 +34,8 @@ __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep) * Return the size of a file in bytes, given a file name. */ int -__wt_filesize_name( - WT_SESSION_IMPL *session, const char *filename, wt_off_t *sizep) +__wt_filesize_name(WT_SESSION_IMPL *session, + const char *filename, bool silent, wt_off_t *sizep) { struct stat sb; WT_DECL_RET; @@ -52,5 +52,11 @@ __wt_filesize_name( return (0); } - WT_RET_MSG(session, ret, "%s: fstat", filename); + /* + * Some callers of this function expect failure if the file doesn't + * exist, and don't want an error message logged. + */ + if (!silent) + WT_RET_MSG(session, ret, "%s: fstat", filename); + return (ret); } diff --git a/src/os_win/os_filesize.c b/src/os_win/os_filesize.c index dfeadc31fc4..7f231b5ba9a 100644 --- a/src/os_win/os_filesize.c +++ b/src/os_win/os_filesize.c @@ -15,8 +15,8 @@ int __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep) { - WT_DECL_RET; LARGE_INTEGER size; + WT_DECL_RET; WT_RET(__wt_verbose( session, WT_VERB_FILEOPS, "%s: GetFileSizeEx", fh->name)); @@ -34,11 +34,11 @@ __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep) * Return the size of a file in bytes, given a file name. */ int -__wt_filesize_name( - WT_SESSION_IMPL *session, const char *filename, wt_off_t *sizep) +__wt_filesize_name(WT_SESSION_IMPL *session, + const char *filename, bool silent, wt_off_t *sizep) { - WT_DECL_RET; WIN32_FILE_ATTRIBUTE_DATA data; + WT_DECL_RET; char *path; WT_RET(__wt_filename(session, filename, &path)); @@ -53,5 +53,12 @@ __wt_filesize_name( return (0); } - WT_RET_MSG(session, __wt_errno(), "%s: GetFileAttributesEx", filename); + /* + * Some callers of this function expect failure if the file doesn't + * exist, and don't want an error message logged. + */ + ret = __wt_errno(); + if (!silent) + WT_RET_MSG(session, ret, "%s: GetFileAttributesEx", filename); + return (ret); } diff --git a/src/schema/schema_stat.c b/src/schema/schema_stat.c index d14b81d389f..88f92b71599 100644 --- a/src/schema/schema_stat.c +++ b/src/schema/schema_stat.c @@ -89,12 +89,15 @@ __curstat_size_only(WT_SESSION_IMPL *session, /* Build up the file name from the table URI. */ WT_ERR(__wt_buf_fmt( session, &namebuf, "%s.wt", uri + strlen("table:"))); + /* - * Get the size of the underlying file. There is nothing stopping a - * race with schema level table operations (for example drop) if there - * is a race there will be an error message generated. + * Get the size of the underlying file. This will fail for anything + * other than simple tables (LSM for example) and will fail if there + * are concurrent schema level operations (for example drop). That is + * fine - failing here results in falling back to the slow path of + * opening the handle. */ - WT_ERR(__wt_filesize_name(session, namebuf.data, &filesize)); + WT_ERR(__wt_filesize_name(session, namebuf.data, true, &filesize)); /* Setup and populate the statistics structure */ __wt_stat_dsrc_init_single(&cst->u.dsrc_stats); |