Motr  M0
obj.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 #pragma once
23 #ifndef __MOTR_CONF_OBJ_H__
24 #define __MOTR_CONF_OBJ_H__
25 
26 #include "conf/schema.h" /* m0_conf_service_type */
27 #include "ha/note.h" /* m0_ha_obj_state */
28 #include "layout/pdclust.h" /* m0_pdclust_attr */
29 #include "lib/protocol.h" /* m0_protocol_id */
30 #include "lib/bob.h"
31 #include "fid/fid.h" /* m0_fid */
32 #include "conf/schema.h" /* m0_conf_service_type */
33 #include "fdmi/filter.h" /* m0_fdmi_filter */
34 #include "fdmi/fdmi.h" /* m0_fdmi_rec_type_id */
35 
36 struct m0_conf_obj_ops;
37 struct m0_confx_obj;
38 struct m0_xcode_type;
39 
177 
197 };
198 
206 struct m0_conf_obj {
208  struct m0_fid co_id;
209 
211 
212  const struct m0_conf_obj_ops *co_ops;
213 
224 
231  uint64_t co_nrefs;
232 
238  struct m0_chan co_chan;
239 
242 
249 
252 
255 
258 
267  uint64_t co_gen_magic;
268 
278  uint64_t co_con_magic;
279 
288 
293  const char *co_name;
294 
295  /*
296  * XXX TODO: Introduce .co_extra_attrs field --- optional array
297  * of {name, value} pairs of strings.
298  *
299  * Fixed set of conf objects' attributes is expensive to change.
300  * To add new attribute to a conf object type, one has to modify:
301  * - conf/obj.h and conf.onwire.h data structures,
302  * - conf/objs/ *.c files,
303  * - Spiel,
304  * - m0confgen utility,
305  * - Halon code.
306  *
307  * m0_conf_obj::co_extra_attrs will let us experiment with new
308  * sets of attributes without code changes. This may prove useful
309  * for testing, debugging, and maintenance.
310  */
311 };
312 
314  const struct m0_fid_type cot_ftype;
315  struct m0_conf_obj *(*cot_create)(void);
316  uint64_t cot_magic;
326  const char *cot_branch;
327  void (*cot_xc_init)(void);
328 };
329 
330 void m0_conf_obj_type_register(const struct m0_conf_obj_type *otype);
331 void m0_conf_obj_type_unregister(const struct m0_conf_obj_type *otype);
332 
333 const struct m0_conf_obj_type *m0_conf_obj_type(const struct m0_conf_obj *obj);
334 const struct m0_conf_obj_type *m0_conf_fid_type(const struct m0_fid *id);
335 const struct m0_fid *m0_conf_objx_fid(const struct m0_confx_obj *obj);
336 const struct m0_conf_obj_type *
337 m0_conf_objx_type(const struct m0_confx_obj *obj);
338 
339 bool m0_conf_fid_is_valid(const struct m0_fid *fid);
340 
346 M0_INTERNAL bool m0_conf_obj_is_stub(const struct m0_conf_obj *obj);
347 
348 struct m0_conf_obj *m0_conf_obj_grandparent(const struct m0_conf_obj *obj);
349 
350 enum { M0_CONF_OBJ_TYPE_MAX = 256 };
351 
352 /* ------------------------------------------------------------------
353  * Concrete configuration objects
354  * ------------------------------------------------------------------ */
355 
357 struct m0_conf_dir {
360  struct m0_tl cd_items;
365 };
366 
368 struct m0_conf_root {
383 /* configuration data (for the application) */
390  uint64_t rt_verno;
394  struct m0_fid rt_mdpool; // XXX-MULTIPOOLS: DELETEME
405  uint32_t rt_mdredundancy;
411  const char **rt_params;
413 };
414 
423 /* configuration data (for the application) */
425 };
426 
431 struct m0_conf_pool {
440 /* configuration data (for the application) */
449  uint32_t pl_pver_policy;
450 };
451 
458 enum {
465 };
466 
479 /* configuration data (for the application) */
488 };
489 
493  uint32_t pvf_id;
501  struct m0_fid pvf_base;
513 };
514 
519  /*
520  * Virtual pvers exist in local conf cache only, they are not
521  * mentioned in the conf database.
522  *
523  * Virtual pvers are not linked to the conf DAG.
524  */
526 };
527 
532 struct m0_conf_pver {
534 /* configuration data (for the application) */
536  union {
539  } pv_u;
540 };
541 
543 struct m0_conf_objv {
550  int cv_ix;
551 /* configuration data (for the application) */
559 };
560 
561 struct m0_conf_node {
564 /* configuration data (for the application) */
566  uint32_t cn_memsize;
568  uint32_t cn_nr_cpu;
570  uint64_t cn_last_state;
572  uint64_t cn_flags;
573 };
574 
583 /* configuration data (for the application) */
585  uint64_t pc_memlimit_as;
586  uint64_t pc_memlimit_rss;
590  const char *pc_endpoint;
591 };
592 
597 /* configuration data (for the application) */
605  const char **cs_endpoints;
611  const char **cs_params;
612 };
613 
615 struct m0_conf_sdev {
617 /* configuration data (for the application) */
628  struct m0_fid sd_drive;
635  uint32_t sd_dev_idx;
637  uint32_t sd_iface;
639  uint32_t sd_media;
641  uint32_t sd_bsize;
643  uint64_t sd_size;
645  uint64_t sd_last_state;
647  uint64_t sd_flags;
649  const char *sd_filename;
650 };
651 
653 struct m0_conf_site {
657 /* configuration data (for the application) */
663 };
664 
666 struct m0_conf_rack {
670 /* configuration data (for the application) */
676 };
677 
685 /* configuration data (for the application) */
691 };
692 
698 /* configuration data (for the application) */
704 };
705 
708 /* configuration data (for the application) */
716 };
717 
721  /* Type of the record that filters of this group support. */
723  /* Directory of filters for this filters group. */
725 };
726 
752  const char **ff_substrings;
760  const char **ff_endpoints;
762  uint64_t ff_magic;
763 };
764 
765 /* ------------------------------------------------------------------
766  * Cast
767  * ------------------------------------------------------------------ */
768 
780 #define M0_CONF_CAST(ptr, type) \
781  bob_of(ptr, struct type, type ## _cast_field, &type ## _bob)
782 
783 #define m0_conf_dir_cast_field cd_obj
784 #define m0_conf_root_cast_field rt_obj
785 #define m0_conf_profile_cast_field cp_obj
786 #define m0_conf_pool_cast_field pl_obj
787 #define m0_conf_pver_cast_field pv_obj
788 #define m0_conf_objv_cast_field cv_obj
789 #define m0_conf_node_cast_field cn_obj
790 #define m0_conf_process_cast_field pc_obj
791 #define m0_conf_service_cast_field cs_obj
792 #define m0_conf_sdev_cast_field sd_obj
793 #define m0_conf_site_cast_field ct_obj
794 #define m0_conf_rack_cast_field cr_obj
795 #define m0_conf_enclosure_cast_field ce_obj
796 #define m0_conf_controller_cast_field cc_obj
797 #define m0_conf_drive_cast_field ck_obj
798 #define m0_conf_fdmi_filter_cast_field ff_obj
799 #define m0_conf_fdmi_flt_grp_cast_field ffg_obj
800 
801 #define M0_CONF_OBJ_TYPES \
802  X_CONF(root, ROOT, 't') \
803  X_CONF(dir, DIR, 'D') \
804  X_CONF(profile, PROFILE, 'p') \
805  X_CONF(pool, POOL, 'o') \
806  X_CONF(pver, PVER, 'v') \
807  X_CONF(objv, OBJV, 'j') \
808  X_CONF(node, NODE, 'n') \
809  X_CONF(process, PROCESS, 'r') \
810  X_CONF(service, SERVICE, 's') \
811  X_CONF(sdev, SDEV, 'd') \
812  X_CONF(site, SITE, 'S') \
813  X_CONF(rack, RACK, 'a') \
814  X_CONF(enclosure, ENCLOSURE, 'e') \
815  X_CONF(controller, CONTROLLER, 'c') \
816  X_CONF(drive, DRIVE, 'k') \
817  X_CONF(fdmi_flt_grp, FDMI_FLT_GRP, 'g') \
818  X_CONF(fdmi_filter, FDMI_FILTER, 'l')
819 
820 #define X_CONF(name, NAME, _) \
821 extern const struct m0_bob_type m0_conf_ ## name ## _bob; \
822 extern const struct m0_conf_obj_type M0_CONF_ ## NAME ## _TYPE;
823 
825 #undef X_CONF
826 
827 /*
828  * Relation fids. They represent parent-child relations between
829  * conf objects.
830  */
831 #define M0_CONF_REL_FIDS \
832  X_CONF(ANY, -1) \
833  \
834  X_CONF(ROOT_NODES, 1) \
835  X_CONF(ROOT_SITES, 2) \
836  X_CONF(ROOT_POOLS, 3) \
837  X_CONF(ROOT_PROFILES, 4) \
838  X_CONF(ROOT_FDMI_FLT_GRPS, 5) \
839  X_CONF(FDMI_FGRP_FILTERS, 6) \
840  \
841  X_CONF(POOL_PVERS, 7) \
842  X_CONF(PVER_SITEVS, 8) \
843  X_CONF(SITEV_RACKVS, 9) \
844  X_CONF(RACKV_ENCLVS, 10) \
845  X_CONF(ENCLV_CTRLVS, 11) \
846  X_CONF(CTRLV_DRIVEVS, 12) \
847  \
848  X_CONF(NODE_PROCESSES, 13) \
849  X_CONF(PROCESS_SERVICES, 14) \
850  X_CONF(SERVICE_SDEVS, 15) \
851  \
852  X_CONF(SITE_RACKS, 16) \
853  X_CONF(RACK_ENCLS, 17) \
854  X_CONF(ENCLOSURE_CTRLS, 18) \
855  X_CONF(CONTROLLER_DRIVES, 19)
856 
857 #define X_CONF(name, _) \
858 extern const struct m0_fid M0_CONF_ ## name ## _FID;
859 
861 #undef X_CONF
862 extern const struct m0_fid_type M0_CONF_RELFID_TYPE;
863 
868 extern const struct m0_fid M0_CONF_ROOT_FID;
869 
884 M0_INTERNAL const struct m0_conf_obj_type *
885 m0_conf_obj_type_next(const struct m0_conf_obj_type *otype);
886 
887 M0_INTERNAL int m0_conf_obj_init(void);
888 M0_INTERNAL void m0_conf_obj_fini(void);
889 
890 M0_INTERNAL void m0_conf_child_adopt(struct m0_conf_obj *parent,
891  struct m0_conf_obj *child);
892 
894 #endif /* __MOTR_CONF_OBJ_H__ */
const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
Definition: obj.c:363
const char * sd_filename
Definition: obj.h:649
struct m0_fid co_id
Definition: obj.h:208
void m0_conf_obj_type_unregister(const struct m0_conf_obj_type *otype)
Definition: obj.c:340
struct m0_fid rt_rootfid
Definition: obj.h:392
const struct m0_conf_obj_type * cd_item_type
Definition: obj.h:362
struct m0_conf_pver ** cr_pvers
Definition: obj.h:675
void m0_conf_obj_type_register(const struct m0_conf_obj_type *otype)
Definition: obj.c:313
const char * pc_endpoint
Definition: obj.h:590
struct m0_fid ff_filter_id
Definition: obj.h:730
const struct m0_conf_obj_type * m0_conf_objx_type(const struct m0_confx_obj *obj)
Definition: obj_ops.c:271
struct m0_conf_dir * cs_sdevs
Definition: obj.h:596
struct m0_conf_dir * pvs_sitevs
Definition: obj.h:478
void(* cot_xc_init)(void)
Definition: obj.h:327
struct m0_protocol_id rt_protocol
Definition: obj.h:412
struct m0_conf_obj ce_obj
Definition: obj.h:680
struct m0_pdclust_attr pvs_attr
Definition: obj.h:481
m0_conf_service_type
Definition: schema.h:194
struct m0_conf_obj cd_obj
Definition: obj.h:358
uint64_t pc_memlimit_memlock
Definition: obj.h:588
M0_CONF_REL_FIDS const struct m0_fid_type M0_CONF_RELFID_TYPE
Definition: dir.c:215
struct m0_conf_obj rt_obj
Definition: obj.h:372
struct m0_conf_obj pl_obj
Definition: obj.h:432
const struct m0_conf_obj_type * m0_conf_fid_type(const struct m0_fid *id)
Definition: obj.c:368
const char ** ff_substrings
Definition: obj.h:752
m0_fdmi_filter_type_id
Definition: filter.h:76
struct m0_conf_pver ** cc_pvers
Definition: obj.h:703
struct m0_conf_pver ** ce_pvers
Definition: obj.h:690
enum m0_fdmi_rec_type_id ffg_rec_type
Definition: obj.h:722
#define M0_CONF_OBJ_TYPES
Definition: obj.h:801
uint32_t pvs_recd[M0_CONF_PVER_HEIGHT]
Definition: obj.h:477
struct m0_chan co_chan
Definition: obj.h:238
struct m0_conf_obj pv_obj
Definition: obj.h:533
struct m0_fdmi_filter ff_filter
Definition: obj.h:731
struct m0_conf_cache * co_cache
Definition: obj.h:251
uint64_t sd_flags
Definition: obj.h:647
struct m0_fid cd_relfid
Definition: obj.h:364
uint32_t pvf_allowance[M0_CONF_PVER_HEIGHT]
Definition: obj.h:512
struct m0_conf_pver ** ck_pvers
Definition: obj.h:715
struct m0_conf_obj * co_parent
Definition: obj.h:223
const char ** ff_endpoints
Definition: obj.h:760
M0_INTERNAL bool m0_conf_obj_is_stub(const struct m0_conf_obj *obj)
Definition: obj.c:302
m0_conf_pver_kind
Definition: obj.h:516
static struct foo * obj
Definition: tlist.c:302
uint64_t ff_magic
Definition: obj.h:762
enum m0_conf_pver_kind pv_kind
Definition: obj.h:535
struct m0_fid fid
Definition: di.c:46
uint64_t pc_memlimit_as
Definition: obj.h:585
uint32_t sd_media
Definition: obj.h:639
M0_INTERNAL void m0_conf_obj_fini(void)
Definition: obj.c:413
uint32_t pl_pver_policy
Definition: obj.h:449
struct m0_conf_dir * ce_ctrls
Definition: obj.h:684
struct m0_fid pvf_base
Definition: obj.h:501
const char * cot_branch
Definition: obj.h:326
uint32_t sd_dev_idx
Definition: obj.h:635
struct m0_tl cd_items
Definition: obj.h:360
uint64_t co_nrefs
Definition: obj.h:231
uint64_t pc_memlimit_stack
Definition: obj.h:587
uint64_t co_con_magic
Definition: obj.h:278
struct m0_conf_dir * rt_fdmi_flt_grps
Definition: obj.h:382
M0_INTERNAL void m0_conf_child_adopt(struct m0_conf_obj *parent, struct m0_conf_obj *child)
Definition: obj.c:425
const char ** cs_endpoints
Definition: obj.h:605
struct m0_conf_obj cp_obj
Definition: obj.h:422
struct m0_conf_dir * pl_pvers
Definition: obj.h:439
uint64_t cn_last_state
Definition: obj.h:570
struct m0_tlink co_dir_link
Definition: obj.h:257
uint32_t cn_memsize
Definition: obj.h:566
struct m0_fid rt_imeta_pver
Definition: obj.h:403
uint64_t cot_magic
Definition: obj.h:316
int cv_ix
Definition: obj.h:550
struct m0_conf_dir * cc_drives
Definition: obj.h:697
const struct m0_fid_type cot_ftype
Definition: obj.h:314
struct m0_conf_pver ** ct_pvers
Definition: obj.h:662
bool co_deleted
Definition: obj.h:287
struct m0_conf_dir * rt_nodes
Definition: obj.h:373
union m0_conf_pver::@122 pv_u
struct m0_fid_arr cp_pools
Definition: obj.h:424
struct m0_conf_obj * m0_conf_obj_grandparent(const struct m0_conf_obj *obj)
Definition: obj.c:384
enum m0_ha_obj_state co_ha_state
Definition: obj.h:241
Definition: tlist.h:251
uint32_t pvs_tolerance[M0_CONF_PVER_HEIGHT]
Definition: obj.h:487
m0_ha_obj_state
Definition: note.h:119
struct m0_tlink co_cache_link
Definition: obj.h:254
struct m0_conf_obj cv_obj
Definition: obj.h:544
uint64_t co_gen_magic
Definition: obj.h:267
struct m0_conf_pver * ff_dix_pver
Definition: obj.h:740
const char * co_name
Definition: obj.h:293
uint64_t cn_flags
Definition: obj.h:572
struct m0_xcode_type ** cot_xt
Definition: obj.h:321
uint32_t pvf_id
Definition: obj.h:493
struct m0_conf_dir * rt_sites
Definition: obj.h:374
const char ** rt_params
Definition: obj.h:411
Definition: fid.h:43
uint32_t rt_mdredundancy
Definition: obj.h:405
struct m0_chan co_ha_chan
Definition: obj.h:248
struct m0_bitmap pc_cores
Definition: obj.h:584
struct m0_fid rt_mdpool
Definition: obj.h:394
Definition: chan.h:229
enum m0_conf_service_type cs_type
Definition: obj.h:598
uint64_t sd_size
Definition: obj.h:643
uint64_t rt_verno
Definition: obj.h:390
struct m0_conf_sdev * ck_sdev
Definition: obj.h:710
m0_fdmi_rec_type_id
Definition: fdmi.h:234
struct m0_conf_dir * rt_profiles
Definition: obj.h:376
M0_INTERNAL const struct m0_conf_obj_type * m0_conf_obj_type_next(const struct m0_conf_obj_type *otype)
Definition: obj.c:351
struct m0_conf_dir * rt_pools
Definition: obj.h:375
bool m0_conf_fid_is_valid(const struct m0_fid *fid)
Definition: obj.c:378
struct m0_conf_obj cc_obj
Definition: obj.h:695
const char ** cs_params
Definition: obj.h:611
struct m0_conf_obj ffg_obj
Definition: obj.h:720
struct m0_conf_pver_subtree subtree
Definition: obj.h:537
struct m0_conf_node * ce_node
Definition: obj.h:682
struct m0_conf_obj pc_obj
Definition: obj.h:581
uint32_t sd_iface
Definition: obj.h:637
struct m0_conf_dir * pc_services
Definition: obj.h:582
struct m0_conf_obj ct_obj
Definition: obj.h:654
m0_conf_status
Definition: obj.h:193
Definition: fid.h:38
uint32_t cn_nr_cpu
Definition: obj.h:568
struct m0_conf_obj ff_obj
Definition: obj.h:728
struct m0_conf_obj cn_obj
Definition: obj.h:562
struct m0_conf_obj cs_obj
Definition: obj.h:595
const struct m0_fid M0_CONF_ROOT_FID
Definition: root.c:226
struct m0_conf_pver_formulaic formulaic
Definition: obj.h:538
struct m0_conf_obj sd_obj
Definition: obj.h:616
struct m0_conf_dir * ffg_filters
Definition: obj.h:724
enum m0_conf_status co_status
Definition: obj.h:210
struct m0_conf_dir * cv_children
Definition: obj.h:545
struct m0_conf_dir * cr_encls
Definition: obj.h:669
struct m0_conf_dir * ct_racks
Definition: obj.h:656
M0_INTERNAL int m0_conf_obj_init(void)
Definition: obj.c:397
struct m0_fid sd_drive
Definition: obj.h:628
uint32_t sd_bsize
Definition: obj.h:641
uint64_t sd_last_state
Definition: obj.h:645
#define M0_CONF_REL_FIDS
Definition: obj.h:831
struct m0_conf_dir * cn_processes
Definition: obj.h:563
uint64_t pc_memlimit_rss
Definition: obj.h:586
enum m0_fdmi_filter_type_id ff_type
Definition: obj.h:729
struct m0_conf_obj cr_obj
Definition: obj.h:667
struct m0_conf_obj ck_obj
Definition: obj.h:707
struct m0_conf_obj * cv_real
Definition: obj.h:558
struct m0_conf_node * ff_node
Definition: obj.h:733
const struct m0_fid * m0_conf_objx_fid(const struct m0_confx_obj *obj)
Definition: obj_ops.c:266
struct m0_tlink ff_linkage
Definition: obj.h:761
const struct m0_conf_obj_ops * co_ops
Definition: obj.h:212