summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/block/block_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/block/block_open.c')
-rw-r--r--src/third_party/wiredtiger/src/block/block_open.c71
1 files changed, 29 insertions, 42 deletions
diff --git a/src/third_party/wiredtiger/src/block/block_open.c b/src/third_party/wiredtiger/src/block/block_open.c
index 7cf12d36066..dd0f3f0716a 100644
--- a/src/third_party/wiredtiger/src/block/block_open.c
+++ b/src/third_party/wiredtiger/src/block/block_open.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -11,36 +11,13 @@
static int __desc_read(WT_SESSION_IMPL *, WT_BLOCK *);
/*
- * __wt_block_manager_truncate --
- * Truncate a file.
+ * __wt_block_manager_drop --
+ * Drop a file.
*/
int
-__wt_block_manager_truncate(
- WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize)
+__wt_block_manager_drop(WT_SESSION_IMPL *session, const char *filename)
{
- WT_DECL_RET;
- WT_FH *fh;
-
- /* Open the underlying file handle. */
- WT_RET(__wt_open(
- session, filename, false, false, WT_FILE_TYPE_DATA, &fh));
-
- /* Truncate the file. */
- WT_ERR(__wt_block_truncate(session, fh, (wt_off_t)0));
-
- /* Write out the file's meta-data. */
- WT_ERR(__wt_desc_init(session, fh, allocsize));
-
- /*
- * Ensure the truncated file has made it to disk, then the upper-level
- * is never surprised.
- */
- WT_ERR(__wt_fsync(session, fh));
-
- /* Close the file handle. */
-err: WT_TRET(__wt_close(session, &fh));
-
- return (ret);
+ return (__wt_remove_if_exists(session, filename));
}
/*
@@ -405,27 +382,37 @@ __wt_block_stat(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_DSRC_STATS *stats)
* Reading from the live system's structure normally requires locking,
* but it's an 8B statistics read, there's no need.
*/
- stats->allocation_size = block->allocsize;
- stats->block_checkpoint_size = (int64_t)block->live.ckpt_size;
- stats->block_magic = WT_BLOCK_MAGIC;
- stats->block_major = WT_BLOCK_MAJOR_VERSION;
- stats->block_minor = WT_BLOCK_MINOR_VERSION;
- stats->block_reuse_bytes = (int64_t)block->live.avail.bytes;
- stats->block_size = block->fh->size;
+ WT_STAT_WRITE(stats, allocation_size, block->allocsize);
+ WT_STAT_WRITE(
+ stats, block_checkpoint_size, (int64_t)block->live.ckpt_size);
+ WT_STAT_WRITE(stats, block_magic, WT_BLOCK_MAGIC);
+ WT_STAT_WRITE(stats, block_major, WT_BLOCK_MAJOR_VERSION);
+ WT_STAT_WRITE(stats, block_minor, WT_BLOCK_MINOR_VERSION);
+ WT_STAT_WRITE(
+ stats, block_reuse_bytes, (int64_t)block->live.avail.bytes);
+ WT_STAT_WRITE(stats, block_size, block->fh->size);
}
/*
* __wt_block_manager_size --
- * Set the size statistic for a file.
+ * Return the size of a live block handle.
*/
int
-__wt_block_manager_size(
- WT_SESSION_IMPL *session, const char *filename, WT_DSRC_STATS *stats)
+__wt_block_manager_size(WT_BM *bm, WT_SESSION_IMPL *session, wt_off_t *sizep)
{
- wt_off_t filesize;
-
- WT_RET(__wt_filesize_name(session, filename, false, &filesize));
- stats->block_size = filesize;
+ WT_UNUSED(session);
+ *sizep = bm->block->fh == NULL ? 0 : bm->block->fh->size;
return (0);
}
+
+/*
+ * __wt_block_manager_named_size --
+ * Return the size of a named file.
+ */
+int
+__wt_block_manager_named_size(
+ WT_SESSION_IMPL *session, const char *name, wt_off_t *sizep)
+{
+ return (__wt_filesize_name(session, name, false, sizep));
+}