1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*-
* Copyright (c) 2014-present MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
* See the file LICENSE for redistribution information.
*/
#include "wt_internal.h"
/*
* __wt_block_tiered_flush --
* Flush this file, start another file.
*/
int
__wt_block_tiered_flush(
WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t **flush_cookie, size_t *cookie_size)
{
/* TODO: tiered: fill in the cookie. */
(void)flush_cookie;
(void)cookie_size;
return (__wt_block_tiered_newfile(session, block));
}
/*
* __wt_block_tiered_load --
* Set up log-structured processing when loading a new root page.
*/
int
__wt_block_tiered_load(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_BLOCK_CKPT *ci)
{
/*
* TODO: tiered: this call currently advances the object id, that's probably not appropriate for
* readonly opens. Perhaps it's also not appropriate for opening at an older checkpoint?
*/
if (block->log_structured) {
block->logid = ci->root_logid;
/* Advance to the next file for future changes. */
WT_RET(__wt_block_tiered_newfile(session, block));
}
return (0);
}
/*
* __wt_block_tiered_newfile --
* Switch a log-structured block object to a new file.
*/
int
__wt_block_tiered_newfile(WT_SESSION_IMPL *session, WT_BLOCK *block)
{
WT_DECL_ITEM(tmp);
WT_DECL_RET;
WT_STORAGE_SOURCE *storage_source;
const char *filename;
/* Get the old file name again. */
WT_ERR(__wt_scr_alloc(session, 0, &tmp));
/*
* TODO: tiered: We will get rid of the log id, and this name generation will be replaced by the
* name generated by __tiered_switch.
*/
WT_ERR(__wt_buf_fmt(session, tmp, "%s.%08" PRIu32, block->name, block->logid));
filename = tmp->data;
WT_ERR(__wt_close(session, &block->fh));
/*
* TODO: tiered: Assert that session->bucket_storage is not NULL. We can't do that while we have
* tests that use block_allocation=log without setting up bucket storage. This whole function is
* going to look very different when flush_tier is fully integrated.
*/
if (session->bucket_storage != NULL && block->logid != 0) {
storage_source = session->bucket_storage->storage_source;
WT_ASSERT(session, storage_source != NULL);
WT_ERR(storage_source->ss_flush(
storage_source, &session->iface, session->bucket_storage->file_system, filename, NULL));
}
/* Bump to a new file ID. */
++block->logid;
WT_ERR(__wt_buf_fmt(session, tmp, "%s.%08" PRIu32, block->name, block->logid));
filename = tmp->data;
WT_WITH_BUCKET_STORAGE(session->bucket_storage, session, {
ret = __wt_open(session, filename, WT_FS_OPEN_FILE_TYPE_DATA,
WT_FS_OPEN_CREATE | block->file_flags, &block->fh);
});
WT_ERR(ret);
WT_ERR(__wt_desc_write(session, block->fh, block->allocsize));
block->size = block->allocsize;
__wt_block_ckpt_destroy(session, &block->live);
WT_ERR(__wt_block_ckpt_init(session, &block->live, "live"));
err:
__wt_scr_free(session, &tmp);
return (ret);
}
|