Motr  M0
cas.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-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 #pragma once
24 
25 #ifndef __MOTR_CAS_CAS_H__
26 #define __MOTR_CAS_CAS_H__
27 
28 #include "xcode/xcode_attr.h"
29 #include "fid/fid.h"
30 #include "fid/fid_xc.h"
31 #include "lib/types.h"
32 #include "lib/buf.h"
33 #include "lib/buf_xc.h"
34 #include "lib/cookie.h"
35 #include "lib/cookie_xc.h"
36 #include "rpc/at.h" /* m0_rpc_at_buf */
37 #include "rpc/at_xc.h" /* m0_rpc_at_buf_xc */
38 #include "fop/wire.h" /* m0_fop_mod_rep */
39 #include "fop/wire_xc.h"
40 #include "fop/fom_interpose.h" /* m0_fom_thralldom */
41 #include "dix/layout.h"
42 #include "dix/layout_xc.h"
43 #include "dtm0/tx_desc.h" /* tx_desc */
44 #include "dtm0/tx_desc_xc.h" /* xc for tx_desc */
45 
83 /* Import */
84 struct m0_sm_conf;
85 struct m0_fom_type_ops;
87 
97 struct m0_cas_hint {
101  uint64_t ch_index;
102 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
103 
107 struct m0_cas_id {
113  struct m0_fid ci_fid;
121 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
122 
126 struct m0_cas_kv {
129 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
130 
135  uint64_t cv_nr;
136  struct m0_cas_kv *cv_rec;
137 } M0_XCA_SEQUENCE M0_XCA_DOMAIN(rpc);
138 
157 struct m0_crv {
158  uint64_t crv_encoded;
159 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc|be);
160 
164 struct m0_cas_rec {
173 
183 
196 
201 
221  uint64_t cr_rc;
222 
228  struct m0_crv cr_ver;
229 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
230 
234 struct m0_cas_recv {
235  uint64_t cr_nr;
237 } M0_XCA_SEQUENCE M0_XCA_DOMAIN(rpc);
238 
247  COF_SLANT = 1 << 0,
252  COF_CREATE = 1 << 1,
257  COF_OVERWRITE = 1 << 2,
264  COF_CROW = 1 << 3,
268  COF_RESERVE = 1 << 4,
274  COF_DEL_LOCK = 1 << 5,
284  COF_SYNC_WAIT = 1 << 7,
289  COF_SKIP_LAYOUT = 1 << 8,
290 
327  COF_VERSIONED = 1 << 9,
328 
340  COF_SHOW_DEAD = 1 << 10,
344  COF_NO_DTM = 1 << 11,
345 };
346 
360 } M0_XCA_ENUM;
361 
367 } M0_XCA_ENUM;
368 
376 struct m0_cas_op {
378  struct m0_cas_id cg_id;
379 
389 
395  uint32_t cg_flags;
396 
401 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
402 
410 struct m0_cas_rep {
420  int32_t cgr_rc;
421 
432 
435 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
436 
438 M0_EXTERN const struct m0_fid m0_cas_meta_fid;
439 M0_EXTERN const struct m0_fid m0_cas_dead_index_fid;
440 M0_EXTERN const struct m0_fid m0_cas_ctidx_fid;
441 M0_EXTERN const struct m0_fid_type m0_cas_index_fid_type;
442 M0_EXTERN const struct m0_fid_type m0_dix_fid_type;
443 M0_EXTERN const struct m0_fid_type m0_cctg_fid_type;
444 
445 M0_EXTERN struct m0_fop_type cas_get_fopt;
446 M0_EXTERN struct m0_fop_type cas_put_fopt;
447 M0_EXTERN struct m0_fop_type cas_del_fopt;
448 M0_EXTERN struct m0_fop_type cas_cur_fopt;
449 M0_EXTERN struct m0_fop_type cas_rep_fopt;
450 M0_EXTERN struct m0_fop_type cas_gc_fopt;
451 extern struct m0_fop_type m0_fop_fsync_cas_fopt;
452 
458 #ifndef __KERNEL__
459 M0_INTERNAL void m0_cas_svc_init(void);
460 M0_INTERNAL void m0_cas_svc_fini(void);
461 M0_INTERNAL void m0_cas_svc_fop_args(struct m0_sm_conf **sm_conf,
462  const struct m0_fom_type_ops **fom_ops,
463  struct m0_reqh_service_type **svctype);
464 M0_INTERNAL void m0_cas__ut_svc_be_set(struct m0_reqh_service *svc,
465  struct m0_be_domain *dom);
466 M0_INTERNAL struct m0_be_domain *
468 M0_INTERNAL int m0_cas_fom_spawn(
469  struct m0_fom *lead,
470  struct m0_fom_thralldom *thrall,
471  struct m0_fop *cas_fop,
472  void (*on_fom_complete)(struct m0_fom_thralldom *,
473  struct m0_fom *));
474 #else
475 #define m0_cas_svc_init()
476 #define m0_cas_svc_fini()
477 #define m0_cas_svc_fop_args(sm_conf, fom_ops, svctype) \
478 do { \
479  *(sm_conf) = NULL; \
480  *(fom_ops) = NULL; \
481  *(svctype) = NULL; \
482 } while (0);
483 #endif /* __KERNEL__ */
484 
485 M0_INTERNAL void m0_cas_id_fini(struct m0_cas_id *cid);
486 M0_INTERNAL bool m0_cas_id_invariant(const struct m0_cas_id *cid);
487 
488 M0_INTERNAL bool cas_in_ut(void);
489 
490 enum {
491  /* Tombstone flag: marks a dead kv pair. We use the MSB here. */
492  M0_CRV_TBS = 1L << (sizeof(uint64_t) * CHAR_BIT - 1),
493  /*
494  * A special value for the empty version.
495  * A record with the empty version is always overwritten by any
496  * PUT or DEL operation that has a valid non-empty version.
497  * A PUT or DEL operation with the empty version always ignores
498  * the version-aware behavior: records are actually removed by DEL,
499  * and overwritten by PUT, no matter what was stored in the catalogue.
500  */
502  /* The maximum possible value of a version. */
504  /* The minimum possible value of a version. */
506 };
507 
508 /*
509  * 100:a == alive record with version 100
510  * 123:d == dead record with version 123
511  */
512 #define CRV_F "%" PRIu64 ":%c"
513 #define CRV_P(__crv) m0_crv_ts(__crv).dts_phys, m0_crv_tbs(__crv) ? 'd' : 'a'
514 
515 #define M0_CRV_INIT_NONE ((struct m0_crv) { .crv_encoded = M0_CRV_VER_NONE })
516 
517 M0_INTERNAL void m0_crv_init(struct m0_crv *crv,
518  const struct m0_dtm0_ts *ts,
519  bool tbs);
520 
521 M0_INTERNAL bool m0_crv_is_none(const struct m0_crv *crv);
522 M0_INTERNAL int m0_crv_cmp(const struct m0_crv *left,
523  const struct m0_crv *right);
524 
525 M0_INTERNAL bool m0_crv_tbs(const struct m0_crv *crv);
526 M0_INTERNAL void m0_crv_tbs_set(struct m0_crv *crv, bool tbs);
527 
528 M0_INTERNAL struct m0_dtm0_ts m0_crv_ts(const struct m0_crv *crv);
529 M0_INTERNAL void m0_crv_ts_set(struct m0_crv *crv,
530  const struct m0_dtm0_ts *ts);
531 
533 #endif /* __MOTR_CAS_CAS_H__ */
534 
535 /*
536  * Local variables:
537  * c-indentation-style: "K&R"
538  * c-basic-offset: 8
539  * tab-width: 8
540  * fill-column: 80
541  * scroll-step: 1
542  * End:
543  */
544 /*
545  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
546  */
M0_INTERNAL bool m0_crv_is_none(const struct m0_crv *crv)
Definition: cas.c:283
Definition: cas.h:356
Definition: cas.h:353
struct m0_dtm0_tx_desc cg_txd
Definition: cas.h:400
M0_INTERNAL void m0_crv_ts_set(struct m0_crv *crv, const struct m0_dtm0_ts *ts)
Definition: cas.c:246
Definition: cas.h:355
m0_cas_op_flags
Definition: cas.h:242
M0_INTERNAL bool cas_in_ut(void)
Definition: cas.c:221
M0_INTERNAL void m0_crv_tbs_set(struct m0_crv *crv, bool tbs)
Definition: cas.c:231
struct m0_rpc_at_buf ck_key
Definition: cas.h:127
M0_INTERNAL bool m0_crv_tbs(const struct m0_crv *crv)
Definition: cas.c:226
Definition: cas.h:350
Definition: sm.h:350
Definition: cas.h:351
M0_INTERNAL void m0_cas_svc_init(void)
Definition: service.c:515
uint64_t cv_nr
Definition: cas.h:135
M0_EXTERN struct m0_fop_type cas_cur_fopt
Definition: cas.h:448
Definition: cas.h:364
M0_EXTERN const struct m0_fid_type m0_cas_index_fid_type
Definition: cas.h:441
Definition: cas.h:247
struct m0_cookie ch_cookie
Definition: cas.h:99
uint64_t crv_encoded
Definition: cas.h:158
M0_EXTERN struct m0_fop_type cas_rep_fopt
Definition: cas.h:449
M0_INTERNAL void m0_cas__ut_svc_be_set(struct m0_reqh_service *svc, struct m0_be_domain *dom)
Definition: service.c:545
struct m0_dix_layout ci_layout
Definition: cas.h:120
struct m0_cas_recv cgr_rep
Definition: cas.h:431
M0_EXTERN const struct m0_fid_type m0_cctg_fid_type
Definition: cas.h:443
static int left
Definition: locality.c:280
M0_INTERNAL struct m0_dtm0_ts m0_crv_ts(const struct m0_crv *crv)
Definition: cas.c:239
M0_INTERNAL int m0_cas_fom_spawn(struct m0_fom *lead, struct m0_fom_thralldom *thrall, struct m0_fop *cas_fop, void(*on_fom_complete)(struct m0_fom_thralldom *, struct m0_fom *))
Definition: service.c:2578
M0_EXTERN struct m0_fop_type cas_gc_fopt
Definition: cas.h:450
M0_EXTERN struct m0_reqh_service_type m0_cas_service_type
Definition: cas.h:437
struct m0_rpc_at_buf cr_val
Definition: cas.h:182
struct m0_cas_rec * cr_rec
Definition: cas.h:236
struct m0_rpc_at_buf ck_val
Definition: cas.h:128
struct m0_rpc_at_buf cr_key
Definition: cas.h:172
enum m0_cas_op_flags M0_XCA_DOMAIN
struct m0_cas_hint ci_hint
Definition: cas.h:115
struct m0_fop_mod_rep cgr_mod_rep
Definition: cas.h:434
Definition: cas.h:359
uint64_t cr_nr
Definition: cas.h:235
M0_EXTERN const struct m0_fid m0_cas_dead_index_fid
Definition: cas.h:439
Definition: cas.h:126
Definition: cas.h:348
struct m0_fom_thralldom thrall
Definition: ms_fom_ut.c:110
Definition: cas.h:264
M0_INTERNAL void m0_crv_init(struct m0_crv *crv, const struct m0_dtm0_ts *ts, bool tbs)
Definition: cas.c:252
Definition: cas.h:157
M0_INTERNAL void m0_cas_svc_fini(void)
Definition: service.c:529
struct m0_crv cr_ver
Definition: cas.h:228
uint32_t cg_flags
Definition: cas.h:395
static struct m0_stob_domain * dom
Definition: storage.c:38
Definition: cas.h:349
M0_EXTERN struct m0_fop_type cas_get_fopt
Definition: cas.h:445
struct m0_cas_kv * cv_rec
Definition: cas.h:136
M0_INTERNAL struct m0_be_domain * m0_cas__ut_svc_be_get(struct m0_reqh_service *svc)
Definition: service.c:553
#define UINT64_MAX
Definition: types.h:44
struct m0_fid ci_fid
Definition: cas.h:113
struct m0_cas_kv_vec cr_kv_bufs
Definition: cas.h:195
enum m0_cas_opcode M0_XCA_ENUM
struct m0_cas_recv cg_rec
Definition: cas.h:388
struct m0_cas_hint cr_hint
Definition: cas.h:200
m0_cas_opcode
Definition: cas.h:347
Definition: cas.h:376
M0_EXTERN const struct m0_fid_type m0_dix_fid_type
Definition: cas.h:442
M0_INTERNAL void m0_cas_svc_fop_args(struct m0_sm_conf **sm_conf, const struct m0_fom_type_ops **fom_ops, struct m0_reqh_service_type **svctype)
Definition: service.c:536
Definition: fom.h:481
m0_cas_type
Definition: cas.h:362
Definition: cas.h:354
M0_EXTERN const struct m0_fid m0_cas_ctidx_fid
Definition: cas.h:440
Definition: fid.h:38
M0_INTERNAL void m0_cas_id_fini(struct m0_cas_id *cid)
Definition: cas.c:199
Definition: cas.h:352
static struct m0_net_test_service svc
Definition: service.c:34
struct m0_fop_type m0_fop_fsync_cas_fopt
Definition: cas.c:54
int32_t cgr_rc
Definition: cas.h:420
uint64_t ch_index
Definition: cas.h:101
M0_INTERNAL bool m0_cas_id_invariant(const struct m0_cas_id *cid)
Definition: cas.c:208
M0_INTERNAL int m0_crv_cmp(const struct m0_crv *left, const struct m0_crv *right)
Definition: cas.c:276
#define CHAR_BIT
Definition: misc.h:32
uint64_t cr_rc
Definition: cas.h:221
Definition: cas.h:107
M0_EXTERN struct m0_fop_type cas_del_fopt
Definition: cas.h:447
M0_EXTERN const struct m0_fid m0_cas_meta_fid
Definition: cas.h:438
Definition: cas.h:363
Definition: cas.h:366
M0_EXTERN struct m0_fop_type cas_put_fopt
Definition: cas.h:446
static struct m0_be_ut_backend be
Definition: service_ut.c:59
Definition: fop.h:80
struct m0_cas_id cg_id
Definition: cas.h:378