Motr  M0
confc.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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_CONFC_H__
24 #define __MOTR_CONF_CONFC_H__
25 
26 #include "conf/cache.h" /* m0_conf_cache */
27 #include "conf/onwire.h" /* m0_conf_fetch */
28 #include "lib/mutex.h" /* m0_mutex */
29 #include "sm/sm.h" /* m0_sm, m0_sm_ast */
30 #include "rpc/link.h" /* m0_rpc_link */
31 
32 struct m0_conf_obj;
33 
331 
350 };
351 
362 };
363 
364 /* ------------------------------------------------------------------
365  * confc instance
366  * ------------------------------------------------------------------ */
367 
368 struct m0_confc_gate_ops;
369 
371 struct m0_confc {
377 
392 
395 
405 
408 
418  uint32_t cc_nr_ctx;
419 
427 
434 
436  uint64_t cc_rpc_timeout;
437 
444 
447 
449  uint64_t cc_magic;
450 };
451 
462  bool (*go_check)(struct m0_confc *confc);
474  int (*go_skip)(struct m0_confc *confc);
481  bool (*go_drain)(struct m0_clink *clink);
482 };
483 
499 M0_INTERNAL int m0_confc_init_wait(struct m0_confc *confc,
500  struct m0_sm_group *sm_group,
501  const char *confd_addr,
502  struct m0_rpc_machine *rpc_mach,
503  const char *local_conf,
504  uint64_t timeout_ns);
505 
507 M0_INTERNAL int m0_confc_init(struct m0_confc *confc,
508  struct m0_sm_group *sm_group,
509  const char *confd_addr,
510  struct m0_rpc_machine *rpc_mach,
511  const char *local_conf);
512 
520 M0_INTERNAL void m0_confc_fini(struct m0_confc *confc);
521 
523 M0_INTERNAL struct m0_confc *m0_confc_from_obj(const struct m0_conf_obj *obj);
524 
525 M0_INTERNAL void m0_confc_gate_ops_set(struct m0_confc *confc,
526  struct m0_confc_gate_ops *gops);
527 
528 /* ------------------------------------------------------------------
529  * context
530  * ------------------------------------------------------------------ */
531 
533 struct m0_confc_ctx {
536 
538  struct m0_sm fc_mach;
539 
545 
548 
558 
561 
567 
575 
578 
581 
583  uint64_t fc_magic;
584 };
585 
594 M0_INTERNAL int m0_confc_ctx_init(struct m0_confc_ctx *ctx,
595  struct m0_confc *confc);
596 
597 M0_INTERNAL void m0_confc_ctx_fini(struct m0_confc_ctx *ctx);
598 
603 M0_INTERNAL void m0_confc_ctx_fini_locked(struct m0_confc_ctx *ctx);
604 
612 M0_INTERNAL int m0_confc_reconnect(struct m0_confc *confc,
613  struct m0_rpc_machine *rpc_mach,
614  const char *confd_addr);
615 
626 M0_INTERNAL bool m0_confc_ctx_is_completed(const struct m0_confc_ctx *ctx);
627 
628 M0_INTERNAL bool m0_confc_ctx_is_completed_lock(const struct m0_confc_ctx *ctx);
629 
639 M0_INTERNAL int32_t m0_confc_ctx_error(const struct m0_confc_ctx *ctx);
640 
641 M0_INTERNAL int32_t m0_confc_ctx_error_lock(const struct m0_confc_ctx *ctx);
642 
657 M0_INTERNAL struct m0_conf_obj *m0_confc_ctx_result(struct m0_confc_ctx *ctx);
658 
659 /* ------------------------------------------------------------------
660  * open/close
661  * ------------------------------------------------------------------ */
662 
678 #define m0_confc_open(ctx, origin, ...) \
679  m0_confc__open((ctx), (origin), (const struct m0_fid []){ \
680  __VA_ARGS__, M0_FID0 })
681 M0_INTERNAL void m0_confc__open(struct m0_confc_ctx *ctx,
682  struct m0_conf_obj *origin,
683  const struct m0_fid *path);
684 
707 #define m0_confc_open_sync(result, origin, ...) \
708  m0_confc__open_sync((result), (origin), (const struct m0_fid []){ \
709  __VA_ARGS__, M0_FID0 })
710 M0_INTERNAL int m0_confc__open_sync(struct m0_conf_obj **result,
711  struct m0_conf_obj *origin,
712  const struct m0_fid *path);
713 
722 M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj);
723 
731 M0_INTERNAL void m0_confc_open_by_fid(struct m0_confc_ctx *ctx,
732  const struct m0_fid *fid);
733 
735 M0_INTERNAL int m0_confc_open_by_fid_sync(struct m0_confc *confc,
736  const struct m0_fid *fid,
737  struct m0_conf_obj **result);
738 
739 /* ------------------------------------------------------------------
740  * readdir
741  * ------------------------------------------------------------------ */
742 
782 M0_INTERNAL int m0_confc_readdir(struct m0_confc_ctx *ctx,
783  struct m0_conf_obj *dir,
784  struct m0_conf_obj **pptr);
785 
812 M0_INTERNAL int m0_confc_readdir_sync(struct m0_conf_obj *dir,
813  struct m0_conf_obj **pptr);
814 
815 M0_INTERNAL bool m0_confc_invariant(const struct m0_confc *confc);
816 
817 M0_INTERNAL bool m0_confc_is_inited(const struct m0_confc *confc);
818 M0_INTERNAL bool m0_confc_is_online(const struct m0_confc *confc);
819 
820 M0_INTERNAL struct m0_rpc_conn *m0_confc2conn(struct m0_confc *confc);
821 M0_INTERNAL struct m0_rpc_session *m0_confc2sess(struct m0_confc *confc);
822 
824 #endif /* __MOTR_CONF_CONFC_H__ */
M0_INTERNAL void m0_confc_open_by_fid(struct m0_confc_ctx *ctx, const struct m0_fid *fid)
Definition: confc.c:930
struct m0_sm_group * cc_group
Definition: confc.h:376
struct m0_conf_obj * cc_root
Definition: confc.h:404
struct m0_clink cc_drain
Definition: confc.h:433
M0_INTERNAL struct m0_conf_obj * m0_confc_ctx_result(struct m0_confc_ctx *ctx)
Definition: confc.c:771
uint64_t cc_magic
Definition: confc.h:449
uint64_t fc_magic
Definition: confc.h:583
M0_INTERNAL int m0_confc_readdir(struct m0_confc_ctx *ctx, struct m0_conf_obj *dir, struct m0_conf_obj **pptr)
Definition: confc.c:990
struct m0_sm fc_mach
Definition: confc.h:538
bool(* go_check)(struct m0_confc *confc)
Definition: confc.h:462
M0_INTERNAL int m0_confc__open_sync(struct m0_conf_obj **result, struct m0_conf_obj *origin, const struct m0_fid *path)
Definition: confc.c:899
int(* go_skip)(struct m0_confc *confc)
Definition: confc.h:474
M0_INTERNAL int m0_confc_readdir_sync(struct m0_conf_obj *dir, struct m0_conf_obj **pptr)
Definition: confc.c:1020
M0_INTERNAL struct m0_rpc_conn * m0_confc2conn(struct m0_confc *confc)
Definition: confc.c:1045
struct m0_confc * fc_confc
Definition: confc.h:535
struct m0_conf_obj * fc_result
Definition: confc.h:574
M0_INTERNAL int m0_confc_open_by_fid_sync(struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_obj **result)
Definition: confc.c:943
Definition: sm.h:504
uint64_t cc_rpc_timeout
Definition: confc.h:436
static struct foo * obj
Definition: tlist.c:302
struct m0_fid fid
Definition: di.c:46
struct m0_confc_gate_ops * cc_gops
Definition: confc.h:426
M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj)
Definition: confc.c:921
M0_INTERNAL int32_t m0_confc_ctx_error(const struct m0_confc_ctx *ctx)
Definition: confc.c:759
M0_INTERNAL struct m0_rpc_session * m0_confc2sess(struct m0_confc *confc)
Definition: confc.c:1050
static struct m0_confc * confc
Definition: file.c:94
struct m0_mutex cus_lock
Definition: confc.h:361
M0_INTERNAL void m0_confc__open(struct m0_confc_ctx *ctx, struct m0_conf_obj *origin, const struct m0_fid *path)
Definition: confc.c:850
bool(* go_drain)(struct m0_clink *clink)
Definition: confc.h:481
static char local_conf[]
Definition: file.c:115
struct m0_conf_cache cc_cache
Definition: confc.h:394
const char * confd_addr[]
M0_INTERNAL int m0_confc_reconnect(struct m0_confc *confc, struct m0_rpc_machine *rpc_mach, const char *confd_addr)
Definition: confc.c:484
M0_INTERNAL bool m0_confc_invariant(const struct m0_confc *confc)
Definition: confc.c:425
struct m0_sm_ast fc_ast
Definition: confc.h:544
M0_INTERNAL bool m0_confc_is_online(const struct m0_confc *confc)
Definition: confc.c:453
Definition: chan.h:229
M0_INTERNAL void m0_confc_ctx_fini(struct m0_confc_ctx *ctx)
Definition: confc.c:716
M0_INTERNAL struct m0_confc * m0_confc_from_obj(const struct m0_conf_obj *obj)
Definition: confc.c:592
static struct m0_clink clink[RDWR_REQUEST_MAX]
struct m0_fid fc_path[M0_CONF_PATH_MAX+1]
Definition: confc.h:560
enum m0_confc_state cus_state
Definition: confc.h:359
m0_confc_state
Definition: confc.h:345
struct m0_mutex cc_lock
Definition: confc.h:391
M0_INTERNAL int m0_confc_ctx_init(struct m0_confc_ctx *ctx, struct m0_confc *confc)
Definition: confc.c:643
struct m0_rpc_link cc_rlink
Definition: confc.h:407
struct m0_rpc_item * fc_rpc_item
Definition: confc.h:577
struct m0_mutex cc_unatt_guard
Definition: confc.h:446
struct m0_clink fc_clink
Definition: confc.h:566
M0_INTERNAL int m0_confc_init_wait(struct m0_confc *confc, struct m0_sm_group *sm_group, const char *confd_addr, struct m0_rpc_machine *rpc_mach, const char *local_conf, uint64_t timeout_ns)
Definition: confc.c:512
Definition: fid.h:38
M0_INTERNAL int m0_confc_init(struct m0_confc *confc, struct m0_sm_group *sm_group, const char *confd_addr, struct m0_rpc_machine *rpc_mach, const char *local_conf)
Definition: confc.c:560
M0_INTERNAL void m0_confc_fini(struct m0_confc *confc)
Definition: confc.c:570
Definition: sm.h:301
uint32_t cc_nr_ctx
Definition: confc.h:418
M0_INTERNAL void m0_confc_ctx_fini_locked(struct m0_confc_ctx *ctx)
Definition: confc.c:680
M0_INTERNAL bool m0_confc_ctx_is_completed(const struct m0_confc_ctx *ctx)
Definition: confc.c:742
struct inode * dir
Definition: dir.c:1028
Definition: nucleus.c:42
M0_INTERNAL bool m0_confc_ctx_is_completed_lock(const struct m0_confc_ctx *ctx)
Definition: confc.c:749
M0_INTERNAL int32_t m0_confc_ctx_error_lock(const struct m0_confc_ctx *ctx)
Definition: confc.c:765
int fc_ast_datum
Definition: confc.h:547
struct m0_chan cc_unattached
Definition: confc.h:443
Definition: mutex.h:47
M0_INTERNAL void m0_confc_gate_ops_set(struct m0_confc *confc, struct m0_confc_gate_ops *gops)
Definition: confc.c:597
M0_INTERNAL bool m0_confc_is_inited(const struct m0_confc *confc)
Definition: confc.c:448
struct m0_conf_obj * fc_origin
Definition: confc.h:557
bool fc_finalized
Definition: confc.h:580