1/*
2 * drv_ssd_ce.c
3 *
4 * Copyright (C) 2014-2019 Aerospike, Inc.
5 *
6 * Portions may be licensed to Aerospike, Inc. under one or more contributor
7 * license agreements.
8 *
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU Affero General Public License as published by the Free
11 * Software Foundation, either version 3 of the License, or (at your option) any
12 * later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see http://www.gnu.org/licenses/
21 */
22
23#include "storage/drv_ssd.h"
24#include <stdbool.h>
25#include <stddef.h>
26#include <stdint.h>
27#include "fault.h"
28#include "base/datamodel.h"
29#include "storage/flat.h"
30#include "storage/storage.h"
31
32
33void
34ssd_resume_devices(drv_ssds* ssds)
35{
36 // Should not get here - for enterprise version only.
37 cf_crash(AS_DRV_SSD, "community edition called ssd_resume_devices()");
38}
39
40void*
41run_ssd_cool_start(void* udata)
42{
43 // Should not get here - for enterprise version only.
44 cf_crash(AS_DRV_SSD, "community edition called run_ssd_cool_start()");
45
46 return NULL;
47}
48
49void
50ssd_header_init_cfg(const as_namespace* ns, drv_ssd* ssd,
51 ssd_device_header* header)
52{
53 if (ns->single_bin) {
54 header->common.prefix.flags |= SSD_HEADER_FLAG_SINGLE_BIN;
55 }
56}
57
58void
59ssd_header_validate_cfg(const as_namespace* ns, drv_ssd* ssd,
60 const ssd_device_header* header)
61{
62 if ((header->common.prefix.flags & SSD_HEADER_FLAG_SINGLE_BIN) != 0) {
63 if (! ns->single_bin) {
64 cf_crash(AS_DRV_SSD, "device has 'single-bin' data but 'single-bin' is not configured");
65 }
66 }
67 else {
68 if (ns->single_bin) {
69 cf_crash(AS_DRV_SSD, "device has multi-bin data but 'single-bin' is configured");
70 }
71 }
72}
73
74void
75ssd_flush_final_cfg(as_namespace* ns)
76{
77}
78
79bool
80ssd_cold_start_is_valid_n_bins(uint32_t n_bins)
81{
82 // FIXME - what should we do here?
83 cf_assert(n_bins != 0, AS_DRV_SSD,
84 "community edition found tombstone - erase drive and restart");
85
86 return n_bins <= BIN_NAMES_QUOTA;
87}
88
89void
90ssd_cold_start_adjust_cenotaph(as_namespace* ns, bool block_has_bins,
91 uint32_t block_void_time, as_record* r)
92{
93 // Nothing to do - relevant for enterprise version only.
94}
95
96void
97ssd_cold_start_transition_record(as_namespace* ns, const as_flat_record* flat,
98 as_record* r, bool is_create)
99{
100 // Nothing to do - relevant for enterprise version only.
101}
102
103void
104ssd_cold_start_drop_cenotaphs(as_namespace* ns)
105{
106 // Nothing to do - relevant for enterprise version only.
107}
108
109void
110ssd_adjust_versions(as_namespace* ns, ssd_common_pmeta* pmeta)
111{
112 // Nothing to do - relevant for enterprise version only.
113}
114
115conflict_resolution_pol
116ssd_cold_start_policy(as_namespace *ns)
117{
118 return AS_NAMESPACE_CONFLICT_RESOLUTION_POLICY_LAST_UPDATE_TIME;
119}
120
121void
122ssd_cold_start_init_repl_state(as_namespace* ns, as_record* r)
123{
124 // Nothing to do - relevant for enterprise version only.
125}
126
127void
128ssd_init_commit(drv_ssd *ssd)
129{
130 // Nothing to do - relevant for enterprise version only.
131}
132
133uint64_t
134ssd_flush_max_us(const as_namespace *ns)
135{
136 return ns->storage_flush_max_us;
137}
138
139int
140ssd_write_bins(as_storage_rd *rd)
141{
142 return ssd_buffer_bins(rd);
143}
144
145void
146as_storage_start_tomb_raider_ssd(as_namespace* ns)
147{
148 // Tomb raider is for enterprise version only.
149}
150
151int
152as_storage_record_write_ssd(as_storage_rd* rd)
153{
154 // All record writes except defrag come through here!
155 return as_bin_inuse_has(rd) ? ssd_write(rd) : 0;
156}
157
158void
159as_storage_cfg_init_ssd(as_namespace* ns)
160{
161}
162
163void
164ssd_encrypt(drv_ssd *ssd, uint64_t off, as_flat_record *flat)
165{
166}
167
168void
169ssd_decrypt(drv_ssd *ssd, uint64_t off, as_flat_record *flat)
170{
171}
172
173void
174ssd_decrypt_whole(drv_ssd *ssd, uint64_t off, uint32_t n_rblocks,
175 as_flat_record *flat)
176{
177}
178
179void
180ssd_prefetch_wblock(drv_ssd *ssd, uint64_t file_offset, uint8_t *read_buf)
181{
182 // Should not get here - for enterprise version only.
183 cf_crash(AS_DRV_SSD, "community edition called ssd_prefetch_wblock()");
184}
185