summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2015-11-03 10:33:14 -0500
committerKeith Bostic <keith@wiredtiger.com>2015-11-03 10:33:14 -0500
commit465dca8b4652a94923f3c9e0eba075c82b63fc65 (patch)
tree6d5ee0a539de49b9dc9adc7143d9dea4e954962b
parentf95877af13eabf7d7a83284702c48ca89c85a786 (diff)
parenta887cb222e516febfe768967701e811cc8dea66d (diff)
downloadmongo-465dca8b4652a94923f3c9e0eba075c82b63fc65.tar.gz
Merge branch 'develop' into mongodb-3.2mongodb-3.2.0-rc2
-rw-r--r--src/block/block_open.c6
-rw-r--r--src/include/extern.h2
-rw-r--r--src/lsm/lsm_tree.c5
-rw-r--r--src/meta/meta_track.c2
-rw-r--r--src/os_posix/os_filesize.c15
-rw-r--r--src/os_win/os_filesize.c20
-rw-r--r--src/schema/schema_stat.c16
7 files changed, 38 insertions, 28 deletions
diff --git a/src/block/block_open.c b/src/block/block_open.c
index e97e86d9aaa..7cf12d36066 100644
--- a/src/block/block_open.c
+++ b/src/block/block_open.c
@@ -422,13 +422,9 @@ int
__wt_block_manager_size(
WT_SESSION_IMPL *session, const char *filename, WT_DSRC_STATS *stats)
{
- WT_DECL_RET;
wt_off_t filesize;
- ret = __wt_filesize_name(session, filename, &filesize);
- if (ret != 0)
- WT_RET_MSG(session, ret, "%s: file size", filename);
-
+ 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 7371f3a407c..30af051bbcf 100644
--- a/src/lsm/lsm_tree.c
+++ b/src/lsm/lsm_tree.c
@@ -213,7 +213,6 @@ int
__wt_lsm_tree_set_chunk_size(
WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk)
{
- WT_DECL_RET;
wt_off_t size;
const char *filename;
@@ -221,9 +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);
- ret = __wt_filesize_name(session, filename, &size);
- if (ret != 0)
- WT_RET_MSG(session, ret, "%s: file size", filename);
+ WT_RET(__wt_filesize_name(session, filename, false, &size));
chunk->size = (uint64_t)size;
diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c
index 1a773ef67c4..ea1757129c5 100644
--- a/src/meta/meta_track.c
+++ b/src/meta/meta_track.c
@@ -471,7 +471,7 @@ __wt_meta_track_handle_lock(WT_SESSION_IMPL *session, bool created)
/*
* __wt_meta_track_init --
- * Intialize metadata tracking.
+ * Initialize metadata tracking.
*/
int
__wt_meta_track_init(WT_SESSION_IMPL *session)
diff --git a/src/os_posix/os_filesize.c b/src/os_posix/os_filesize.c
index 09174ffcd90..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;
@@ -47,9 +47,16 @@ __wt_filesize_name(
__wt_free(session, path);
- if (ret == 0)
+ if (ret == 0) {
*sizep = sb.st_size;
+ return (0);
+ }
- /* Some callers expect failure, so don't log an error message. */
+ /*
+ * 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 c51303d7215..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));
@@ -47,10 +47,18 @@ __wt_filesize_name(
__wt_free(session, path);
- if (ret != 0)
+ if (ret != 0) {
*sizep =
((int64_t)data.nFileSizeHigh << 32) | data.nFileSizeLow;
+ return (0);
+ }
- /* Some callers expect failure, so don't log an error message. */
+ /*
+ * 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 355abf8f343..88f92b71599 100644
--- a/src/schema/schema_stat.c
+++ b/src/schema/schema_stat.c
@@ -89,6 +89,7 @@ __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. This will fail for anything
* other than simple tables (LSM for example) and will fail if there
@@ -96,13 +97,14 @@ __curstat_size_only(WT_SESSION_IMPL *session,
* fine - failing here results in falling back to the slow path of
* opening the handle.
*/
- if (__wt_filesize_name(session, namebuf.data, &filesize) == 0) {
- /* Setup and populate the statistics structure */
- __wt_stat_dsrc_init_single(&cst->u.dsrc_stats);
- cst->u.dsrc_stats.block_size = filesize;
- __wt_curstat_dsrc_final(cst);
- *was_fast = true;
- }
+ 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);
+ cst->u.dsrc_stats.block_size = filesize;
+ __wt_curstat_dsrc_final(cst);
+
+ *was_fast = true;
err: __wt_free(session, tableconf);
__wt_buf_free(session, &namebuf);