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/fom_generic.h" /* m0_fop_mod_rep */
39 #include "fop/fom_generic_xc.h" /* m0_fop_mod_rep */
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,
327  COF_VERSIONED = 1 << 9,
328 
340  COF_SHOW_DEAD = 1 << 10,
341 };
342 
356 } M0_XCA_ENUM;
357 
363 } M0_XCA_ENUM;
364 
372 struct m0_cas_op {
374  struct m0_cas_id cg_id;
375 
385 
391  uint32_t cg_flags;
392 
397 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
398 
406 struct m0_cas_rep {
416  int32_t cgr_rc;
417 
428 
431 } M0_XCA_RECORD M0_XCA_DOMAIN(rpc);
432 
434 M0_EXTERN const struct m0_fid m0_cas_meta_fid;
435 M0_EXTERN const struct m0_fid m0_cas_dead_index_fid;
436 M0_EXTERN const struct m0_fid m0_cas_ctidx_fid;
437 M0_EXTERN const struct m0_fid_type m0_cas_index_fid_type;
438 M0_EXTERN const struct m0_fid_type m0_dix_fid_type;
439 M0_EXTERN const struct m0_fid_type m0_cctg_fid_type;
440 
441 M0_EXTERN struct m0_fop_type cas_get_fopt;
442 M0_EXTERN struct m0_fop_type cas_put_fopt;
443 M0_EXTERN struct m0_fop_type cas_del_fopt;
444 M0_EXTERN struct m0_fop_type cas_cur_fopt;
445 M0_EXTERN struct m0_fop_type cas_rep_fopt;
446 M0_EXTERN struct m0_fop_type cas_gc_fopt;
447 extern struct m0_fop_type m0_fop_fsync_cas_fopt;
448 
454 #ifndef __KERNEL__
455 M0_INTERNAL void m0_cas_svc_init(void);
456 M0_INTERNAL void m0_cas_svc_fini(void);
457 M0_INTERNAL void m0_cas_svc_fop_args(struct m0_sm_conf **sm_conf,
458  const struct m0_fom_type_ops **fom_ops,
459  struct m0_reqh_service_type **svctype);
460 M0_INTERNAL void m0_cas__ut_svc_be_set(struct m0_reqh_service *svc,
461  struct m0_be_domain *dom);
462 M0_INTERNAL struct m0_be_domain *
464 M0_INTERNAL int m0_cas_fom_spawn(
465  struct m0_fom *lead,
466  struct m0_fom_thralldom *thrall,
467  struct m0_fop *cas_fop,
468  void (*on_fom_complete)(struct m0_fom_thralldom *,
469  struct m0_fom *));
470 #else
471 #define m0_cas_svc_init()
472 #define m0_cas_svc_fini()
473 #define m0_cas_svc_fop_args(sm_conf, fom_ops, svctype) \
474 do { \
475  *(sm_conf) = NULL; \
476  *(fom_ops) = NULL; \
477  *(svctype) = NULL; \
478 } while (0);
479 #endif /* __KERNEL__ */
480 
481 M0_INTERNAL void m0_cas_id_fini(struct m0_cas_id *cid);
482 M0_INTERNAL bool m0_cas_id_invariant(const struct m0_cas_id *cid);
483 
484 M0_INTERNAL bool cas_in_ut(void);
485 
486 enum {
487  /* Tombstone flag: marks a dead kv pair. We use the MSB here. */
488  M0_CRV_TBS = 1L << (sizeof(uint64_t) * CHAR_BIT - 1),
489  /*
490  * A special value for the empty version.
491  * A record with the empty version is always overwritten by any
492  * PUT or DEL operation that has a valid non-empty version.
493  * A PUT or DEL operation with the empty version always ignores
494  * the version-aware behavior: records are actually removed by DEL,
495  * and overwritten by PUT, no matter what was stored in the catalogue.
496  */
498  /* The maximum possible value of a version. */
500  /* The minimum possible value of a version. */
502 };
503 
504 /*
505  * 100:a == alive record with version 100
506  * 123:d == dead record with version 123
507  */
508 #define CRV_F "%" PRIu64 ":%c"
509 #define CRV_P(__crv) m0_crv_ts(__crv).dts_phys, m0_crv_tbs(__crv) ? 'd' : 'a'
510 
511 #define M0_CRV_INIT_NONE ((struct m0_crv) { .crv_encoded = M0_CRV_VER_NONE })
512 
513 M0_INTERNAL void m0_crv_init(struct m0_crv *crv,
514  const struct m0_dtm0_ts *ts,
515  bool tbs);
516 
517 M0_INTERNAL bool m0_crv_is_none(const struct m0_crv *crv);
518 M0_INTERNAL int m0_crv_cmp(const struct m0_crv *left,
519  const struct m0_crv *right);
520 
521 M0_INTERNAL bool m0_crv_tbs(const struct m0_crv *crv);
522 M0_INTERNAL void m0_crv_tbs_set(struct m0_crv *crv, bool tbs);
523 
524 M0_INTERNAL struct m0_dtm0_ts m0_crv_ts(const struct m0_crv *crv);
525 M0_INTERNAL void m0_crv_ts_set(struct m0_crv *crv,
526  const struct m0_dtm0_ts *ts);
527 
529 #endif /* __MOTR_CAS_CAS_H__ */
530 
531 /*
532  * Local variables:
533  * c-indentation-style: "K&R"
534  * c-basic-offset: 8
535  * tab-width: 8
536  * fill-column: 80
537  * scroll-step: 1
538  * End:
539  */
540 /*
541  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
542  */
M0_INTERNAL bool m0_crv_is_none(const struct m0_crv *crv)
Definition: cas.c:282
Definition: cas.h:352
Definition: cas.h:349
struct m0_dtm0_tx_desc cg_txd
Definition: cas.h:396
M0_INTERNAL void m0_crv_ts_set(struct m0_crv *crv, const struct m0_dtm0_ts *ts)
Definition: cas.c:245
Definition: cas.h:351
m0_cas_op_flags
Definition: cas.h:242
M0_INTERNAL bool cas_in_ut(void)
Definition: cas.c:220
M0_INTERNAL void m0_crv_tbs_set(struct m0_crv *crv, bool tbs)
Definition: cas.c:230
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:225
Definition: cas.h:346
Definition: sm.h:350
Definition: cas.h:347
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:444
Definition: cas.h:360
M0_EXTERN const struct m0_fid_type m0_cas_index_fid_type
Definition: cas.h:437
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:445
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:427
M0_EXTERN const struct m0_fid_type m0_cctg_fid_type
Definition: cas.h:439
static int left
Definition: locality.c:280
M0_INTERNAL struct m0_dtm0_ts m0_crv_ts(const struct m0_crv *crv)
Definition: cas.c:238
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:2570
M0_EXTERN struct m0_fop_type cas_gc_fopt
Definition: cas.h:446
M0_EXTERN struct m0_reqh_service_type m0_cas_service_type
Definition: cas.h:433
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:430
Definition: cas.h:355
uint64_t cr_nr
Definition: cas.h:235
M0_EXTERN const struct m0_fid m0_cas_dead_index_fid
Definition: cas.h:435
Definition: cas.h:126
Definition: cas.h:344
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:251
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:391
static struct m0_stob_domain * dom
Definition: storage.c:38
Definition: cas.h:345
M0_EXTERN struct m0_fop_type cas_get_fopt
Definition: cas.h:441
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:384
struct m0_cas_hint cr_hint
Definition: cas.h:200
m0_cas_opcode
Definition: cas.h:343
Definition: cas.h:372
M0_EXTERN const struct m0_fid_type m0_dix_fid_type
Definition: cas.h:438
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:358
Definition: cas.h:350
M0_EXTERN const struct m0_fid m0_cas_ctidx_fid
Definition: cas.h:436
Definition: fid.h:38
M0_INTERNAL void m0_cas_id_fini(struct m0_cas_id *cid)
Definition: cas.c:198
Definition: cas.h:348
static struct m0_net_test_service svc
Definition: service.c:34
struct m0_fop_type m0_fop_fsync_cas_fopt
Definition: cas.c:53
int32_t cgr_rc
Definition: cas.h:416
uint64_t ch_index
Definition: cas.h:101
M0_INTERNAL bool m0_cas_id_invariant(const struct m0_cas_id *cid)
Definition: cas.c:207
M0_INTERNAL int m0_crv_cmp(const struct m0_crv *left, const struct m0_crv *right)
Definition: cas.c:275
#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:443
M0_EXTERN const struct m0_fid m0_cas_meta_fid
Definition: cas.h:434
Definition: cas.h:359
Definition: cas.h:362
M0_EXTERN struct m0_fop_type cas_put_fopt
Definition: cas.h:442
static struct m0_be_ut_backend be
Definition: service_ut.c:59
Definition: fop.h:79
struct m0_cas_id cg_id
Definition: cas.h:374