Motr  M0
log_store.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 
24 #pragma once
25 
26 #ifndef __MOTR_BE_LOG_STORE_H__
27 #define __MOTR_BE_LOG_STORE_H__
28 
29 #include "lib/buf.h" /* m0_buf */
30 #include "lib/types.h" /* m0_bcount_t */
31 #include "module/module.h" /* m0_module */
32 #include "stob/stob.h" /* m0_stob_id */
33 
34 #include "be/fmt.h" /* m0_be_fmt_log_store_header */
35 
42 struct m0_be_log_io;
43 struct m0_be_io;
44 struct m0_be_io_credit;
45 struct m0_be_op;
46 struct m0_stob;
47 
106 enum {
123 };
124 
128 };
129 
131  /*
132  * Backing store stob id.
133  * It's used in m0_be_log_store_create() and m0_be_log_store_open().
134  */
149 
150  /*
151  * The following fields are used in m0_be_log_store_create() only.
152  * They are saved in log store header (m0_be_fmt_log_store_header)
153  * (except lsc_stob_domain_key and lsc_stob_domain_create_cfg).
154  */
155 
169 
173  const char *lsc_stob_create_cfg;
180  unsigned lsc_rbuf_nr;
183 };
184 
191 
192  struct m0_stob *ls_stob;
193  /*
194  * Temporary solution.
195  * @see m0_be_log_store_cfg::lsc_stob_domain_location
196  */
198 
199  /* Log store header. */
201  /* Buffer for encoded m0_be_log_store.ls_header. */
211 
218 };
219 
220 M0_INTERNAL bool m0_be_log_store__invariant(struct m0_be_log_store *ls);
221 
222 M0_INTERNAL int m0_be_log_store_open(struct m0_be_log_store *ls,
223  struct m0_be_log_store_cfg *ls_cfg);
224 M0_INTERNAL void m0_be_log_store_close(struct m0_be_log_store *ls);
225 
226 M0_INTERNAL int m0_be_log_store_create(struct m0_be_log_store *ls,
227  struct m0_be_log_store_cfg *ls_cfg);
228 M0_INTERNAL void m0_be_log_store_destroy(struct m0_be_log_store *ls);
229 /* TODO destroy by cfg? */
230 
231 M0_INTERNAL void
233  struct m0_be_log_store_cfg *ls_cfg,
234  bool create_mode);
235 
236 M0_INTERNAL uint32_t m0_be_log_store_bshift(struct m0_be_log_store *ls);
238 M0_INTERNAL void m0_be_log_store_io_credit(struct m0_be_log_store *ls,
239  struct m0_be_io_credit *accum);
250 M0_INTERNAL void m0_be_log_store_io_translate(struct m0_be_log_store *ls,
251  m0_bindex_t position,
252  struct m0_be_io *bio);
253 
260 M0_INTERNAL int m0_be_log_store_io_window(struct m0_be_log_store *ls,
262  m0_bcount_t *length);
269 M0_INTERNAL void m0_be_log_store_io_discard(struct m0_be_log_store *ls,
271  struct m0_be_op *op);
272 
273 M0_INTERNAL bool m0_be_log_store_overwrites(struct m0_be_log_store *ls,
276  m0_bindex_t position);
277 
290 M0_INTERNAL struct m0_buf *
292 M0_INTERNAL struct m0_buf *
294  unsigned *iter);
295 M0_INTERNAL struct m0_buf *
297  unsigned *iter);
298 M0_INTERNAL struct m0_be_log_io *
300  enum m0_be_log_store_io_type io_type,
301  struct m0_be_op **op,
302  unsigned *iter);
303 M0_INTERNAL struct m0_be_log_io *
305  enum m0_be_log_store_io_type io_type,
306  struct m0_be_op **op,
307  unsigned *iter);
308 M0_INTERNAL void
310  enum m0_be_log_store_io_type io_type);
311 
312 M0_INTERNAL bool
314  const struct m0_stob_id *stob_id);
317 #endif /* __MOTR_BE_LOG_STORE_H__ */
318 
319 
320 /*
321  * Local variables:
322  * c-indentation-style: "K&R"
323  * c-basic-offset: 8
324  * tab-width: 8
325  * fill-column: 80
326  * scroll-step: 1
327  * End:
328  */
329 /*
330  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
331  */
M0_INTERNAL void m0_be_log_store_rbuf_io_reset(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type)
Definition: log_store.c:718
M0_INTERNAL void m0_be_log_store_io_discard(struct m0_be_log_store *ls, m0_bindex_t offset, struct m0_be_op *op)
Definition: log_store.c:619
M0_INTERNAL void m0_be_log_store_close(struct m0_be_log_store *ls)
Definition: log_store.c:586
M0_INTERNAL int m0_be_log_store_open(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
Definition: log_store.c:569
char * lsc_stob_domain_location
Definition: log_store.h:144
m0_bindex_t ls_offset_discarded
Definition: log_store.h:210
M0_INTERNAL struct m0_buf * m0_be_log_store_rbuf_read_buf_first(struct m0_be_log_store *ls, unsigned *iter)
Definition: log_store.c:660
struct m0_stob_domain * ls_stob_domain
Definition: log_store.h:197
M0_INTERNAL struct m0_buf * m0_be_log_store_rbuf_read_buf_next(struct m0_be_log_store *ls, unsigned *iter)
Definition: log_store.c:668
uint64_t m0_bindex_t
Definition: types.h:80
bool ls_create_mode
Definition: log_store.h:187
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL m0_bcount_t m0_be_log_store_buf_size(struct m0_be_log_store *ls)
Definition: log_store.c:596
struct m0_be_log_io * ls_rbuf_write_lio
Definition: log_store.h:212
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_first(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
Definition: log_store.c:692
uint64_t lsc_stob_domain_key
Definition: log_store.h:161
op
Definition: libdemo.c:64
unsigned lsc_rbuf_nr
Definition: log_store.h:180
Definition: buf.h:37
M0_INTERNAL void m0_be_log_store_io_translate(struct m0_be_log_store *ls, m0_bindex_t position, struct m0_be_io *bio)
Definition: log_store.c:637
struct m0_be_fmt_log_store_header ls_header
Definition: log_store.h:200
Definition: stob.h:163
struct m0_buf ls_header_buf
Definition: log_store.h:202
bool ls_destroy_mode
Definition: log_store.h:188
const char * lsc_stob_domain_init_cfg
Definition: log_store.h:148
struct m0_buf ls_rbuf_write_buf
Definition: log_store.h:214
M0_INTERNAL bool m0_be_log_store_contains_stob(struct m0_be_log_store *ls, const struct m0_stob_id *stob_id)
Definition: log_store.c:768
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_next(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
Definition: log_store.c:702
M0_INTERNAL bool m0_be_log_store__invariant(struct m0_be_log_store *ls)
Definition: log_store.c:73
m0_bcount_t lsc_size
Definition: log_store.h:171
M0_INTERNAL void m0_be_log_store_module_setup(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg, bool create_mode)
Definition: log_store.c:534
struct m0_module ls_module
Definition: log_store.h:190
struct m0_be_log_io * ls_rbuf_read_lio
Definition: log_store.h:215
static m0_bindex_t offset
Definition: dump.c:173
const char * lsc_stob_create_cfg
Definition: log_store.h:173
M0_INTERNAL bool m0_be_log_store_overwrites(struct m0_be_log_store *ls, m0_bindex_t index, m0_bcount_t size, m0_bindex_t position)
Definition: log_store.c:752
struct m0_be_op * ls_rbuf_write_op
Definition: log_store.h:213
bool ls_stob_destroyed
Definition: log_store.h:189
M0_INTERNAL struct m0_buf * m0_be_log_store_rbuf_write_buf(struct m0_be_log_store *ls)
Definition: log_store.c:654
m0_bcount_t lsc_rbuf_size
Definition: log_store.h:182
const char * lsc_stob_domain_create_cfg
Definition: log_store.h:168
M0_INTERNAL int m0_be_log_store_create(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
Definition: log_store.c:575
m0_bcount_t size
Definition: di.c:39
struct m0_stob * ls_stob
Definition: log_store.h:192
Definition: io.h:87
M0_INTERNAL void m0_be_log_store_io_credit(struct m0_be_log_store *ls, struct m0_be_io_credit *accum)
Definition: log_store.c:601
static bool ls
Definition: mt.c:44
M0_INTERNAL int m0_be_log_store_io_window(struct m0_be_log_store *ls, m0_bindex_t offset, m0_bcount_t *length)
Definition: log_store.c:607
struct m0_buf * ls_rbuf_read_buf
Definition: log_store.h:217
Definition: op.h:74
m0_be_log_store_io_type
Definition: log_store.h:125
struct m0_be_log_store_cfg ls_cfg
Definition: log_store.h:186
M0_INTERNAL void m0_be_log_store_destroy(struct m0_be_log_store *ls)
Definition: log_store.c:581
struct m0_be_op * ls_rbuf_read_op
Definition: log_store.h:216
struct m0_stob_id lsc_stob_id
Definition: log_store.h:135
M0_INTERNAL uint32_t m0_be_log_store_bshift(struct m0_be_log_store *ls)
Definition: log_store.c:591