Merge pull request #2287 from wiredtiger/wt-2196-keith
WT-2196: Fix size-only statistics when there are LSM tables.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user