Motr  M0
reqh.c
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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_RPC
24 #include "lib/trace.h"
25 
26 #include "lib/finject.h" /* M0_FI_ENABLED */
27 #include "lib/errno.h"
28 #include "lib/assert.h"
29 #include "lib/memory.h"
30 #include "lib/misc.h"
31 #include "lib/atomic.h"
32 #include "lib/locality.h"
33 #include "lib/semaphore.h"
34 
35 #include "motr/magic.h"
36 #include "addb2/sys.h"
37 #include "addb2/global.h"
38 #include "stob/stob.h"
39 #include "net/net.h"
40 #include "fop/fop.h"
41 #include "fop/fom_generic.h"
42 #include "dtm/dtm.h"
43 #include "rpc/rpc.h"
44 #include "rpc/item_internal.h" /* m0_rpc_item_is_request */
45 #include "reqh/reqh_service.h"
46 #include "reqh/reqh.h"
47 #include "layout/pdclust.h"
48 #include "fd/fd.h" /* m0_fd_fwd_map */
49 #include "fop/fom_simple.h"
50 #include "pool/pool.h"
51 #include "conf/obj.h" /* M0_CONF_PROCESS_TYPE, m0_conf_fid_type */
52 #include "conf/confc.h" /* m0_confc_init */
53 #include "conf/helpers.h" /* m0_confc_args */
54 #include "be/ut/helper.h"
55 
64 M0_TL_DESCR_DEFINE(m0_reqh_svc, "reqh service", M0_INTERNAL,
65  struct m0_reqh_service, rs_linkage, rs_magix,
67 
68 M0_TL_DEFINE(m0_reqh_svc, M0_INTERNAL, struct m0_reqh_service);
69 
70 static struct m0_bob_type rqsvc_bob;
72 
76 M0_TL_DESCR_DEFINE(m0_reqh_rpc_mach, "rpc machines", ,
77  struct m0_rpc_machine, rm_rh_linkage, rm_magix,
79 
80 M0_TL_DEFINE(m0_reqh_rpc_mach, , struct m0_rpc_machine);
81 
82 M0_LOCKERS_DEFINE(M0_INTERNAL, m0_reqh, rh_lockers);
83 
85 
86 static void __reqh_fini(struct m0_reqh *reqh);
87 
90  struct m0_fop *ffr_fop;
91  int ffr_rc;
92 };
93 
98  [M0_REQH_ST_INIT] = {
100  .sd_name = "Init",
101  .sd_allowed = M0_BITS(M0_REQH_ST_NORMAL,
103  },
104  [M0_REQH_ST_NORMAL] = {
105  .sd_flags = 0,
106  .sd_name = "Normal",
107  .sd_allowed = M0_BITS(M0_REQH_ST_DRAIN,
109  },
110  [M0_REQH_ST_DRAIN] = {
111  .sd_flags = 0,
112  .sd_name = "Drain",
113  .sd_allowed = M0_BITS(M0_REQH_ST_SVCS_STOP)
114  },
116  .sd_flags = 0,
117  .sd_name = "ServicesStop",
118  .sd_allowed = M0_BITS(M0_REQH_ST_STOPPED)
119  },
120  [M0_REQH_ST_STOPPED] = {
121  .sd_flags = M0_SDF_TERMINAL,
122  .sd_name = "Stopped",
123  .sd_allowed = 0
124  },
125 };
126 
130 static const struct m0_sm_conf m0_reqh_sm_conf = {
131  .scf_name = "Request Handler States",
132  .scf_nr_states = ARRAY_SIZE(m0_reqh_sm_descr),
133  .scf_state = m0_reqh_sm_descr,
134 };
135 
136 M0_INTERNAL bool m0_reqh_invariant(const struct m0_reqh *reqh)
137 {
138  return _0C(reqh != NULL) &&
141  reqh->rh_mdstore != NULL)) &&
143 }
144 
145 M0_INTERNAL int m0_reqh_mdpool_layout_build(struct m0_reqh *reqh)
146 {
147  struct m0_pools_common *pc = reqh->rh_pools;
148  struct m0_pool_version *pv;
149  struct m0_layout *layout;
150  int rc;
151  uint64_t lid;
152 
153  M0_ENTRY();
154  M0_PRE(_0C(pc != NULL) && _0C(pc->pc_md_pool != NULL));
155 
156  pv = pool_version_tlist_head(&pc->pc_md_pool->po_vers);
157  lid = m0_pool_version2layout_id(&pv->pv_id, M0_DEFAULT_LAYOUT_ID);
158  layout = m0_layout_find(&reqh->rh_ldom, lid);
159  if (layout == NULL)
160  return M0_RC(-EINVAL);
161 
162  rc = m0_layout_instance_build(layout, &pv->pv_id,
163  &pc->pc_md_pool_linst);
164  m0_layout_put(layout);
165 
166  return M0_RC(rc);
167 }
168 
169 M0_INTERNAL void m0_reqh_layouts_cleanup(struct m0_reqh *reqh)
170 {
174 }
175 
176 M0_INTERNAL struct m0_rpc_session *
178  const struct m0_fid *gob_fid,
179  uint32_t index)
180 {
181  struct m0_reqh_service_ctx *ctx;
182  struct m0_rpc_session *session;
183  struct m0_pdclust_instance *pi;
184  struct m0_pdclust_src_addr src;
185  struct m0_pdclust_tgt_addr tgt;
186  uint64_t mds_nr;
187  struct m0_pool_version *md_pv;
188  const struct m0_pools_common *pc = reqh->rh_pools;
189  uint32_t idx;
190 
191  M0_ENTRY();
192 
193  M0_LOG(M0_INFO, "index=%d redundancy =%d", index,
194  (unsigned int)pc->pc_md_redundancy);
196 
197  md_pv = pool_version_tlist_head(&pc->pc_md_pool->po_vers);
198  mds_nr = md_pv->pv_attr.pa_P;
199  M0_LOG(M0_DEBUG, "number of mdservices =%d", (unsigned int)mds_nr);
201  (md_pv->pv_attr.pa_N + 2 * md_pv->pv_attr.pa_K));
202  M0_ASSERT(index <= mds_nr);
203 
206  src.sa_unit = index;
207 
209  m0_fd_fwd_map(pi, &src, &tgt);
211  M0_ASSERT(tgt.ta_obj < mds_nr);
213  pd_sdev_idx;
214  ctx = md_pv->pv_pc->pc_dev2svc[idx].pds_ctx;
215  M0_ASSERT(ctx != NULL);
216  M0_ASSERT(ctx->sc_type == M0_CST_IOS);
217  session = &ctx->sc_rlink.rlk_sess;
218 
219  M0_LOG(M0_DEBUG, "device index %d id %d -> ctx=%p session=%p", idx,
220  (unsigned int)tgt.ta_obj, ctx, session);
222  M0_LEAVE();
223  return session;
224 }
225 
226 M0_INTERNAL int
228 {
229  int rc = 0;
230 
231  M0_ENTRY("%p", reqh);
235 
240  reqh->rh_oostore = false;
242 
246  m0_reqh_lockers_init(reqh);
247 
248  m0_reqh_svc_tlist_init(&reqh->rh_services);
249  m0_reqh_rpc_mach_tlist_init(&reqh->rh_rpc_machines);
252  &reqh->rh_sm_grp);
253 
259 
260  if (reqh->rh_beseg != NULL) {
262  if (rc != 0)
263  __reqh_fini(reqh);
264  }
265  return M0_RC(rc);
266 }
267 
268 M0_INTERNAL int
270 {
271  int rc = 0;
272 
273  M0_PRE(seg != NULL);
274 
275  M0_ENTRY();
276 
278  if (rc == 0) {
280  if (rc != 0)
282  reqh->rh_beseg = seg;
284  }
285 
286  return M0_RC(rc);
287 }
288 
289 M0_INTERNAL void m0_reqh_be_fini(struct m0_reqh *reqh)
290 {
291  if (reqh->rh_beseg != NULL) {
294  reqh->rh_beseg = NULL;
295  }
296 }
297 
298 static void __reqh_fini(struct m0_reqh *reqh)
299 {
301  m0_sm_fini(&reqh->rh_sm);
304  m0_reqh_svc_tlist_fini(&reqh->rh_services);
305  m0_reqh_rpc_mach_tlist_fini(&reqh->rh_rpc_machines);
306  m0_reqh_lockers_fini(reqh);
310 
318 }
319 
320 M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
321 {
322  M0_ENTRY();
324  __reqh_fini(reqh);
325  M0_LEAVE();
326 }
327 
328 M0_INTERNAL void m0_reqhs_fini(void)
329 {
331 }
332 
333 M0_INTERNAL int m0_reqhs_init(void)
334 {
336  m0_bob_type_tlist_init(&rqsvc_bob, &m0_reqh_svc_tl);
337  return 0;
338 }
339 
340 #ifndef __KERNEL__
341 M0_INTERNAL int m0_reqh_addb2_init(struct m0_reqh *reqh, const char *location,
342  uint64_t key, bool mkfs, bool force,
344 {
345  struct m0_addb2_sys *sys = m0_fom_dom()->fd_addb2_sys;
346  struct m0_addb2_sys *gsys = m0_addb2_global_get();
347  int result;
348 
349  if (size == 0)
354  result = m0_addb2_sys_stor_start(sys, location, key, mkfs, force,
355  size);
356  if (result == 0) {
357  result = m0_addb2_sys_net_start(sys);
358  if (result == 0) {
359  m0_addb2_sys_attach(gsys, sys);
361  m0_addb2_sys_sm_start(gsys);
362  } else
364  }
365  return result;
366 }
367 
368 #else /* !__KERNEL__ */
369 M0_INTERNAL int m0_reqh_addb2_init(struct m0_reqh *reqh, const char *location,
370  uint64_t key, bool mkfs, bool force,
372 {
373  struct m0_addb2_sys *sys = m0_fom_dom()->fd_addb2_sys;
374  int result;
375 
376  result = m0_addb2_sys_net_start(sys);
377  if (result == 0)
379  return result;
380 }
381 #endif
382 
383 M0_INTERNAL void m0_reqh_addb2_fini(struct m0_reqh *reqh)
384 {
385  struct m0_addb2_sys *sys = m0_fom_dom()->fd_addb2_sys;
386 
387 #ifndef __KERNEL__
388  struct m0_addb2_sys *gsys = m0_addb2_global_get();
389 
390  m0_addb2_sys_detach(gsys);
391  m0_addb2_sys_sm_stop(gsys);
392 #endif
396 }
397 
398 M0_INTERNAL int m0_reqh_state_get(struct m0_reqh *reqh)
399 {
401 
402  return reqh->rh_sm.sm_state;
403 }
404 
405 static void reqh_state_set(struct m0_reqh *reqh,
406  enum m0_reqh_states state)
407 {
409  m0_sm_state_set(&reqh->rh_sm, state);
411 }
412 
413 M0_INTERNAL int m0_reqh_services_state_count(struct m0_reqh *reqh, int state)
414 {
415  int cnt = 0;
416  struct m0_reqh_service *svc;
417 
418  M0_PRE(reqh != NULL);
423  m0_tl_for(m0_reqh_svc, &reqh->rh_services, svc) {
424  if (m0_reqh_service_state_get(svc) == state)
425  ++cnt;
426  } m0_tl_endfor;
428  return cnt;
429 }
430 
431 extern struct m0_reqh_service_type m0_ha_entrypoint_service_type; /* XXX !!! */
432 extern struct m0_reqh_service_type m0_ha_link_service_type; /* XXX !!! */
433 #ifndef __KERNEL__
434 M0_EXTERN struct m0_reqh_service_type m0_cas_service_type; /* XXX !!! */
435 #endif
436 
437 M0_INTERNAL int m0_reqh_fop_allow(struct m0_reqh *reqh, struct m0_fop *fop)
438 {
439  int rh_st;
440  int svc_st;
441  struct m0_reqh_service *svc;
442  const struct m0_reqh_service_type *stype;
443 
444  M0_ENTRY("fop:%p, reqh:%p", fop, reqh);
445  M0_PRE(reqh != NULL);
446  M0_PRE(fop != NULL && fop->f_type != NULL);
447 
449  if (stype == NULL)
450  return M0_ERR(-ENOSYS);
451 
453  if (svc == NULL)
454  return M0_ERR(-ECONNREFUSED);
455 
456  rh_st = m0_reqh_state_get(reqh);
457  if (rh_st == M0_REQH_ST_INIT) {
458  /*
459  * Allow rpc connection fops from other services during
460  * startup.
461  */
462  if (svc != NULL && M0_IN(stype, (&m0_rpc_service_type,
463 #ifndef __KERNEL__
465 #endif
468  return M0_RC(0);
469  return M0_ERR(-EAGAIN);
470  }
471  if (rh_st == M0_REQH_ST_STOPPED)
472  return M0_ERR(-ESHUTDOWN);
473 
474  M0_ASSERT(svc->rs_ops != NULL);
475  svc_st = m0_reqh_service_state_get(svc);
476 
477  switch (rh_st) {
478  case M0_REQH_ST_NORMAL:
479  if (svc_st == M0_RST_STARTED)
480  return M0_RC(0);
481  if (svc_st == M0_RST_STARTING)
482  return M0_ERR(-EAGAIN);
483  if (svc_st == M0_RST_STOPPING &&
484  svc->rs_ops->rso_fop_accept != NULL)
485  return (*svc->rs_ops->rso_fop_accept)(svc, fop);
486  return M0_ERR(-ESHUTDOWN);
487  case M0_REQH_ST_DRAIN:
488  if (M0_IN(svc_st, (M0_RST_STARTED, M0_RST_STOPPING)) &&
489  svc->rs_ops->rso_fop_accept != NULL)
490  return (*svc->rs_ops->rso_fop_accept)(svc, fop);
491  return M0_ERR(-ESHUTDOWN);
493  return M0_ERR(-ESHUTDOWN);
494  default:
495  return M0_ERR(-ENOSYS);
496  }
497 }
498 
499 static int disallowed_fop_tick(struct m0_fom *fom, void *data, int *phase)
500 {
501  struct m0_fop *fop;
502  struct disallowed_fop_reply *reply = data;
503  static const char msg[] = "No service running.";
504 
506  if (fop != NULL) {
508 
509  rep->gr_rc = reply->ffr_rc;
510  rep->gr_msg.s_buf = m0_alloc(sizeof msg);
511  if (rep->gr_msg.s_buf != NULL) {
512  rep->gr_msg.s_len = sizeof msg;
513  memcpy(rep->gr_msg.s_buf, msg, rep->gr_msg.s_len);
514  }
515  m0_rpc_reply_post(&reply->ffr_fop->f_item, &fop->f_item);
516  }
517  return -1;
518 }
519 
520 static void disallowed_fop_free(struct m0_fom_simple *sfom)
521 {
522  m0_free(container_of(sfom, struct disallowed_fop_reply, ffr_sfom));
523 }
524 
525 static void fop_disallowed(struct m0_reqh *reqh,
526  struct m0_fop *req_fop,
527  int rc)
528 {
529  struct disallowed_fop_reply *reply;
530 
531  M0_PRE(rc != 0);
532  M0_PRE(req_fop != NULL);
533 
535  if (reply == NULL)
536  return;
537 
538  m0_fop_get(req_fop);
539  reply->ffr_fop = req_fop;
540  reply->ffr_rc = rc;
543 
544 }
545 
546 M0_INTERNAL int m0_reqh_fop_handle(struct m0_reqh *reqh, struct m0_fop *fop)
547 {
548  struct m0_fom *fom;
549  int rc;
550 
551  M0_ENTRY("%p", reqh);
552  M0_PRE(reqh != NULL);
553  M0_PRE(fop != NULL);
554 
556 
558  if (rc != 0) {
560  M0_LOG(M0_WARN, "fop \"%s\"@%p disallowed: %i.",
561  m0_fop_name(fop), fop, rc);
563  struct m0_reqh_service_type *rst =
564  m0_reqh_service_type_find("simple-fom-service");
565  if (rst != NULL &&
566  m0_reqh_service_find(rst, reqh) == NULL)
567  return M0_ERR_INFO(-ESHUTDOWN,
568  "Service shutdown.");
570  }
571  /*
572  * Note :
573  * Since client will receive generic reply for
574  * this error, for RPC layer this fop is accepted.
575  */
576  return M0_RC(0);
577  }
578 
579  M0_ASSERT(fop->f_type != NULL);
582 
584  if (rc == 0)
585  m0_fom_queue(fom);
586 
588  return M0_RC(rc);
589 }
590 
591 M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh,
592  struct m0_reqh_service *service)
593 {
594  struct m0_clink clink;
595 
597 
604 }
605 
606 M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh)
607 {
608  struct m0_reqh_service *service;
609 
610  M0_PRE(reqh != NULL);
611 
612  m0_tl_for(m0_reqh_svc, &reqh->rh_services, service) {
615  continue;
617  } m0_tl_endfor;
618 }
619 
621  unsigned level)
622 {
623  struct m0_reqh_service *service;
624 
625  M0_LOG(M0_DEBUG, "-- Preparing to stop at level [%d] --", level);
626  m0_tl_for(m0_reqh_svc, &reqh->rh_services, service) {
628  if (service->rs_level < level ||
631  continue;
633  } m0_tl_endfor;
634 }
635 
636 M0_INTERNAL void m0_reqh_shutdown(struct m0_reqh *reqh)
637 {
638  M0_PRE(reqh != NULL);
645 }
646 
647 M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh)
648 {
651 }
652 
653 static void __reqh_svcs_stop(struct m0_reqh *reqh, unsigned level)
654 {
655  struct m0_reqh_service *service;
656 
657  m0_tl_for(m0_reqh_svc, &reqh->rh_services, service) {
659  if (service->rs_level < level)
660  continue;
666  }
667  M0_LOG(M0_DEBUG, "service=%s level=%d srvlev=%d",
670  if (service == reqh->rh_rpc_service)
672  } m0_tl_endfor;
673 }
674 
675 M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
676 {
679 }
680 
682 {
683  M0_PRE(reqh != NULL);
688 
691 
698 
702 }
703 
705 {
709 }
710 
711 M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
712 {
713  M0_PRE(reqh != NULL);
716 
719 
721 }
722 
723 M0_INTERNAL uint64_t m0_reqh_nr_localities(const struct m0_reqh *reqh)
724 {
726  return m0_fom_dom()->fd_localities_nr;
727 }
728 
729 M0_INTERNAL int m0_reqh_conf_setup(struct m0_reqh *reqh,
730  struct m0_confc_args *args)
731 {
732  struct m0_rconfc *rconfc = &reqh->rh_rconfc;
733  struct m0_fid profile;
734  int rc;
735 
736  M0_PRE(args->ca_group != NULL && args->ca_rmach != NULL);
737 
738  rc = m0_fid_sscanf(args->ca_profile, &profile);
739  if (rc != 0)
740  return M0_ERR_INFO(rc, "Cannot parse profile `%s'",
741  args->ca_profile);
742 
743  rc = m0_rconfc_init(rconfc, &profile, args->ca_group, args->ca_rmach,
745  if (rc == 0 && args->ca_confstr != NULL) {
746  rconfc->rc_local_conf = m0_strdup(args->ca_confstr);
747  if (rconfc->rc_local_conf == NULL)
748  return M0_ERR(-ENOMEM);
749  }
750  return M0_RC(rc);
751 }
752 
753 M0_INTERNAL struct m0_confc *m0_reqh2confc(struct m0_reqh *reqh)
754 {
755  return &reqh->rh_rconfc.rc_confc;
756 }
757 
758 M0_INTERNAL struct m0_fid *m0_reqh2profile(struct m0_reqh *reqh)
759 {
760  return &reqh->rh_rconfc.rc_profile;
761 }
762 
763 #undef M0_TRACE_SUBSYSTEM
764 
766 /*
767  * Local variables:
768  * c-indentation-style: "K&R"
769  * c-basic-offset: 8
770  * tab-width: 8
771  * fill-column: 80
772  * scroll-step: 1
773  * End:
774  */
M0_INTERNAL struct m0_layout * m0_layout_find(struct m0_layout_domain *dom, uint64_t lid)
Definition: layout.c:861
M0_INTERNAL int m0_reqh_service_state_get(const struct m0_reqh_service *s)
Definition: reqh_service.c:560
struct m0_layout_instance * pc_md_pool_linst
Definition: pool.h:214
struct m0_poolmach_state * pm_state
Definition: pool_machine.h:169
static struct m0_fid gob_fid
Definition: net.c:115
static const struct m0_sm_conf m0_reqh_sm_conf
Definition: reqh.c:130
M0_INTERNAL void m0_reqh_be_fini(struct m0_reqh *reqh)
Definition: reqh.c:289
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
Definition: chan.c:336
struct m0_be_seg * rhia_db
Definition: reqh.h:239
static int disallowed_fop_tick(struct m0_fom *fom, void *data, int *phase)
Definition: reqh.c:499
#define M0_PRE(cond)
M0_INTERNAL void m0_fol_fini(struct m0_fol *fol)
Definition: fol.c:89
M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
Definition: reqh.c:675
M0_INTERNAL int m0_reqh_service_types_init(void)
Definition: reqh_service.c:520
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
struct m0_reqh_service_type m0_rpc_service_type
Definition: service.c:120
#define m0_strdup(s)
Definition: string.h:43
void m0_addb2_sys_net_stop(struct m0_addb2_sys *sys)
Definition: sys.c:322
char * rc_local_conf
Definition: rconfc.h:390
struct m0_tl po_vers
Definition: pool.h:84
uint64_t sa_group
Definition: pdclust.h:241
M0_INTERNAL uint64_t m0_fid_hash(const struct m0_fid *fid)
Definition: fid.c:295
M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:402
struct m0_ha_domain rh_hadom
Definition: reqh.h:156
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
struct m0_pools_common * rhia_pc
Definition: reqh.h:241
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
Definition: chan.c:293
void m0_addb2_sys_sm_stop(struct m0_addb2_sys *sys)
Definition: sys.c:384
#define ergo(a, b)
Definition: misc.h:293
struct m0_mdstore * rh_mdstore
Definition: reqh.h:115
M0_EXTERN struct m0_reqh_service_type m0_cas_service_type
Definition: reqh.c:434
M0_INTERNAL int m0_layout_domain_init(struct m0_layout_domain *dom)
Definition: layout.c:610
Definition: sm.h:350
void m0_addb2_sys_sm_start(struct m0_addb2_sys *sys)
Definition: sys.c:377
struct m0_chan rh_conf_cache_ready_async
Definition: reqh.h:227
unsigned rs_level
Definition: reqh_service.h:236
uint32_t pa_N
Definition: pdclust.h:104
struct m0_pool_version * pv
Definition: dir.c:629
struct m0_poolmach pv_mach
Definition: pool.h:133
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
M0_INTERNAL void m0_reqh_layouts_cleanup(struct m0_reqh *reqh)
Definition: reqh.c:169
M0_INTERNAL int m0_reqh_fop_handle(struct m0_reqh *reqh, struct m0_fop *fop)
Definition: reqh.c:546
M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:375
const struct m0_conf_obj_type * m0_conf_fid_type(const struct m0_fid *fid)
Definition: obj.c:368
enum m0_trace_level level
Definition: trace.c:111
M0_INTERNAL const uint64_t M0_HA_EPOCH_NONE
Definition: epoch.c:77
uint32_t pa_K
Definition: pdclust.h:107
int(* fto_create)(struct m0_fop *fop, struct m0_fom **out, struct m0_reqh *reqh)
Definition: fom.h:650
M0_INTERNAL void m0_layout_domain_fini(struct m0_layout_domain *dom)
Definition: layout.c:633
M0_INTERNAL void m0_rwlock_write_lock(struct m0_rwlock *lock)
Definition: rwlock.c:42
struct m0_bufvec data
Definition: di.c:40
uint64_t ta_obj
Definition: pdclust.h:256
struct m0_chan rh_conf_cache_ready
Definition: reqh.h:205
struct m0_pool * pc_md_pool
Definition: pool.h:212
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
M0_INTERNAL void m0_reqhs_fini(void)
Definition: reqh.c:328
struct m0_chan s_chan
Definition: sm.h:518
void m0_addb2_sys_attach(struct m0_addb2_sys *sys, struct m0_addb2_sys *src)
Definition: sys.c:408
struct m0_fop * ffr_fop
Definition: reqh.c:90
#define M0_BITS(...)
Definition: misc.h:236
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_tl rh_services
Definition: reqh.h:127
#define container_of(ptr, type, member)
Definition: misc.h:33
static struct m0_rpc_session session
Definition: formation2.c:38
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
Definition: ub.c:49
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
struct m0_rwlock rh_rwlock
Definition: reqh.h:143
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
struct m0_reqh_service * rh_rpc_service
Definition: reqh.h:140
M0_INTERNAL int m0_reqh_addb2_init(struct m0_reqh *reqh, const char *location, uint64_t key, bool mkfs, bool force, m0_bcount_t size)
Definition: reqh.c:341
static void __reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:298
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
const char * location
Definition: storage.c:50
static struct m0_pools_common pc
Definition: iter_ut.c:59
M0_INTERNAL int m0_layout_instance_build(struct m0_layout *l, const struct m0_fid *fid, struct m0_layout_instance **out)
Definition: layout.c:1113
struct m0_fom_type ft_fom_type
Definition: fop.h:232
M0_INTERNAL struct m0_reqh_service_type * m0_reqh_service_type_find(const char *sname)
Definition: reqh_service.c:168
M0_INTERNAL bool m0_rpc_item_is_request(const struct m0_rpc_item *item)
Definition: item.c:509
M0_INTERNAL void m0_rwlock_init(struct m0_rwlock *lock)
Definition: rwlock.c:32
#define m0_tl_endfor
Definition: tlist.h:700
struct m0_pooldev * pst_devices_array
Definition: pool_machine.h:111
M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh)
Definition: reqh.c:647
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL void m0_ha_domain_fini(struct m0_ha_domain *dom)
Definition: epoch.c:96
struct m0_mutex rh_guard
Definition: reqh.h:180
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
M0_INTERNAL struct m0_fid * m0_reqh2profile(struct m0_reqh *reqh)
Definition: reqh.c:758
struct m0_fop_type * f_type
Definition: fop.h:81
M0_INTERNAL bool m0_reqh_invariant(const struct m0_reqh *reqh)
Definition: reqh.c:136
struct m0_mutex rh_guard_async
Definition: reqh.h:183
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL const char * m0_fop_name(const struct m0_fop *fop)
Definition: fop.c:55
Definition: trace.h:482
uint32_t pc_md_redundancy
Definition: pool.h:210
Definition: cnt.h:36
M0_INTERNAL uint64_t m0_pool_version2layout_id(const struct m0_fid *pv_fid, uint64_t lid)
Definition: pool.c:1900
struct m0_dtm * rh_dtm
Definition: reqh.h:109
M0_INTERNAL struct m0_confc * m0_reqh2confc(struct m0_reqh *reqh)
Definition: reqh.c:753
M0_INTERNAL bool m0_fom_domain_is_idle_for(const struct m0_reqh_service *svc)
Definition: fom.c:1281
static const struct socktype stype[]
Definition: sock.c:1156
struct m0_fid pv_id
Definition: pool.h:113
void m0_addb2_sys_detach(struct m0_addb2_sys *sys)
Definition: sys.c:416
M0_INTERNAL int m0_reqh_conf_setup(struct m0_reqh *reqh, struct m0_confc_args *args)
Definition: reqh.c:729
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
Definition: chan.c:96
#define M0_ASSERT(cond)
M0_TL_DESCR_DEFINE(m0_reqh_svc, "reqh service", M0_INTERNAL, struct m0_reqh_service, rs_linkage, rs_magix, M0_REQH_SVC_MAGIC, M0_REQH_SVC_HEAD_MAGIC)
const char * scf_name
Definition: sm.h:352
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
void m0_sm_state_set(struct m0_sm *mach, int state)
Definition: sm.c:478
const char * rst_name
Definition: reqh_service.h:447
M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service)
Definition: reqh_service.c:457
M0_INTERNAL struct m0_rpc_session * m0_reqh_mdpool_service_index_to_session(const struct m0_reqh *reqh, const struct m0_fid *gob_fid, uint32_t index)
Definition: reqh.c:177
M0_INTERNAL int m0_reqh_init(struct m0_reqh *reqh, const struct m0_reqh_init_args *reqh_args)
Definition: reqh.c:227
struct m0_tl rh_rpc_machines
Definition: reqh.h:135
M0_INTERNAL void m0_fol_init(struct m0_fol *fol)
Definition: fol.c:84
M0_INTERNAL bool m0_reqh_service_invariant(const struct m0_reqh_service *svc)
Definition: reqh_service.c:143
M0_INTERNAL void m0_reqh_shutdown(struct m0_reqh *reqh)
Definition: reqh.c:636
struct m0_fop * m0_fop_get(struct m0_fop *fop)
Definition: fop.c:162
M0_BOB_DEFINE(M0_INTERNAL, &rqsvc_bob, m0_reqh_service)
M0_INTERNAL int m0_reqh_mdpool_layout_build(struct m0_reqh *reqh)
Definition: reqh.c:145
void * m0_alloc(size_t size)
Definition: memory.c:126
bool rh_oostore
Definition: reqh.h:171
struct m0_fid rc_profile
Definition: rconfc.h:392
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL uint64_t m0_reqh_nr_localities(const struct m0_reqh *reqh)
Definition: reqh.c:723
struct m0_reqh_service_type m0_ha_link_service_type
Definition: link_service.c:263
struct m0_pdclust_instance pi
Definition: fd.c:107
M0_INTERNAL int m0_reqhs_init(void)
Definition: reqh.c:333
#define M0_POST(cond)
M0_INTERNAL void m0_ha_domain_init(struct m0_ha_domain *dom, uint64_t epoch)
Definition: epoch.c:85
struct m0_pools_common * pv_pc
Definition: pool.h:130
Definition: reqh.h:94
struct m0_layout_domain rh_ldom
Definition: reqh.h:153
struct m0_mdstore * rhia_mdstore
Definition: reqh.h:240
Definition: dump.c:103
M0_INTERNAL void m0_reqh_post_storage_fini_svcs_stop(struct m0_reqh *reqh)
Definition: reqh.c:704
M0_INTERNAL void m0_rwlock_write_unlock(struct m0_rwlock *lock)
Definition: rwlock.c:47
void m0_rpc_reply_post(struct m0_rpc_item *request, struct m0_rpc_item *reply)
Definition: rpc.c:135
struct m0_pool_device_to_service * pc_dev2svc
Definition: pool.h:207
static struct m0_clink clink[RDWR_REQUEST_MAX]
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
Definition: fid.c:227
M0_INTERNAL int m0_reqh_fop_allow(struct m0_reqh *reqh, struct m0_fop *fop)
Definition: reqh.c:437
struct m0_sm rh_sm
Definition: reqh.h:99
Definition: seg.h:66
M0_INTERNAL int m0_layout_standard_types_register(struct m0_layout_domain *dom)
Definition: layout.c:671
static struct fdmi_ctx ctx
Definition: main.c:80
struct m0_fop_type m0_fop_generic_reply_fopt
Definition: fom_generic.c:50
M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh)
Definition: reqh.c:606
M0_INTERNAL bool m0_fom_domain_invariant(const struct m0_fom_domain *dom)
Definition: fom.c:255
static struct m0_bob_type rqsvc_bob
Definition: reqh.c:70
const struct m0_fom_type_ops * ft_ops
Definition: fom.h:614
M0_INTERNAL int m0_reqh_state_get(struct m0_reqh *reqh)
Definition: reqh.c:398
struct m0_fop * m0_fop_reply_alloc(struct m0_fop *req, struct m0_fop_type *rept)
Definition: fop.c:129
struct m0_reqh_service_ctx * pds_ctx
Definition: pool.h:74
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:255
uint64_t sa_unit
Definition: pdclust.h:243
uint32_t sd_flags
Definition: sm.h:378
Definition: fom.h:481
struct m0_mutex pi_mutex
Definition: pdclust.h:230
M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
Definition: reqh.c:711
struct m0_pdclust_tgt_addr tgt
Definition: fd.c:110
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find(const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
Definition: reqh_service.c:538
struct m0_reqh reqh
Definition: rm_foms.c:48
static struct m0_fid profile
Definition: rconfc.c:49
struct m0_dtm * rhia_dtm
Definition: reqh.h:237
M0_INTERNAL void m0_reqh_service_types_fini(void)
Definition: reqh_service.c:530
M0_LOCKERS_DEFINE(M0_INTERNAL, m0_reqh, rh_lockers)
M0_INTERNAL void m0_layout_domain_cleanup(struct m0_layout_domain *dom)
Definition: layout.c:653
Definition: fid.h:38
struct m0_confc rc_confc
Definition: rconfc.h:235
const struct m0_reqh_service_type * rs_type
Definition: reqh_service.h:227
static void __reqh_svcs_stop(struct m0_reqh *reqh, unsigned level)
Definition: reqh.c:653
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
Definition: sm.c:313
struct m0_chan rh_conf_cache_exp
Definition: reqh.h:194
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
struct m0_sm_group rh_sm_grp
Definition: reqh.h:107
int m0_addb2_sys_stor_start(struct m0_addb2_sys *sys, const char *location, uint64_t key, bool mkfs, bool force, m0_bcount_t size)
Definition: sys.c:357
M0_INTERNAL struct m0_fom_domain * m0_fom_dom(void)
Definition: locality.c:575
uint32_t pa_P
Definition: pdclust.h:115
M0_INTERNAL struct m0_addb2_sys * m0_addb2_global_get(void)
Definition: global.c:99
static struct m0_net_test_service svc
Definition: service.c:34
static struct m0_sm_state_descr m0_reqh_sm_descr[]
Definition: reqh.c:97
m0_bcount_t size
Definition: di.c:39
#define _0C(exp)
Definition: assert.h:311
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
M0_TL_DEFINE(m0_reqh_svc, M0_INTERNAL, struct m0_reqh_service)
struct m0_pools_common * rh_pools
Definition: reqh.h:118
M0_INTERNAL void m0_reqh_pre_storage_fini_svcs_stop(struct m0_reqh *reqh)
Definition: reqh.c:681
static struct m0_fop * fop
Definition: item.c:57
M0_INTERNAL void m0_rwlock_read_lock(struct m0_rwlock *lock)
Definition: rwlock.c:52
struct m0_reqh_service_type m0_ha_entrypoint_service_type
Definition: entrypoint.c:135
M0_INTERNAL void m0_rwlock_fini(struct m0_rwlock *lock)
Definition: rwlock.c:37
M0_INTERNAL void m0_layout_standard_types_unregister(struct m0_layout_domain *dom)
Definition: layout.c:697
struct m0_fol rh_fol
Definition: reqh.h:121
M0_INTERNAL void m0_reqh_idle_wait_for(struct m0_reqh *reqh, struct m0_reqh_service *service)
Definition: reqh.c:591
struct m0_be_seg * rh_beseg
Definition: reqh.h:112
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
int m0_addb2_sys_net_start(struct m0_addb2_sys *sys)
Definition: sys.c:312
M0_INTERNAL void m0_fom_queue(struct m0_fom *fom)
Definition: fom.c:624
struct m0_fid rh_fid
Definition: reqh.h:177
static struct m0_be_seg * seg
Definition: btree.c:40
static struct m0_rconfc * rconfc(struct m0_client *m0c)
Definition: client_init.c:310
M0_INTERNAL void m0_reqh_services_prepare_to_stop(struct m0_reqh *reqh, unsigned level)
Definition: reqh.c:620
struct m0_fom_simple ffr_sfom
Definition: reqh.c:89
struct m0_addb2_sys * fd_addb2_sys
Definition: fom.h:338
M0_INTERNAL void m0_chan_fini(struct m0_chan *chan)
Definition: chan.c:104
struct m0_rconfc rh_rconfc
Definition: reqh.h:166
M0_INTERNAL void m0_confc_ready_cb(struct m0_rconfc *rconfc)
Definition: helpers.c:488
M0_INTERNAL void m0_layout_instance_fini(struct m0_layout_instance *li)
Definition: layout.c:1123
static void reqh_state_set(struct m0_reqh *reqh, enum m0_reqh_states state)
Definition: reqh.c:405
M0_INTERNAL struct m0_pdclust_instance * m0_layout_instance_to_pdi(const struct m0_layout_instance *li)
Definition: pdclust.c:400
static void disallowed_fop_free(struct m0_fom_simple *sfom)
Definition: reqh.c:520
M0_INTERNAL int m0_rconfc_init(struct m0_rconfc *rconfc, const struct m0_fid *profile, struct m0_sm_group *sm_group, struct m0_rpc_machine *rmach, m0_rconfc_cb_t expired_cb, m0_rconfc_cb_t ready_cb)
Definition: rconfc.c:2860
M0_INTERNAL void m0_rwlock_read_unlock(struct m0_rwlock *lock)
Definition: rwlock.c:57
const struct m0_conf_obj_type M0_CONF_PROCESS_TYPE
Definition: process.c:161
Definition: nucleus.c:42
M0_INTERNAL void m0_layout_put(struct m0_layout *l)
Definition: layout.c:893
M0_INTERNAL void m0_confc_expired_cb(struct m0_rconfc *rconfc)
Definition: helpers.c:465
M0_INTERNAL bool m0_fid_is_valid(const struct m0_fid *fid)
Definition: fid.c:96
M0_INTERNAL void m0_fd_fwd_map(struct m0_pdclust_instance *pi, const struct m0_pdclust_src_addr *src, struct m0_pdclust_tgt_addr *tgt)
Definition: fd.c:838
static void fop_disallowed(struct m0_reqh *reqh, struct m0_fop *req_fop, int rc)
Definition: reqh.c:525
static struct m0_dtm_oper_descr reply
Definition: transmit.c:94
void m0_addb2_sys_stor_stop(struct m0_addb2_sys *sys)
Definition: sys.c:370
M0_INTERNAL void m0_reqh_addb2_fini(struct m0_reqh *reqh)
Definition: reqh.c:383
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
Definition: chan.c:112
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL int m0_reqh_be_init(struct m0_reqh *reqh, struct m0_be_seg *seg)
Definition: reqh.c:269
#define M0_FOM_SIMPLE_POST(s, r, c, t, f, d, l)
Definition: fom_simple.h:165
static struct m0_reqh_init_args reqh_args
Definition: note.c:89
size_t fd_localities_nr
Definition: fom.h:333
struct m0_rpc_item f_item
Definition: fop.h:83
const struct m0_reqh_service_type * ft_rstype
Definition: fom.h:617
uint32_t sm_state
Definition: sm.h:307
M0_INTERNAL int m0_reqh_services_state_count(struct m0_reqh *reqh, int state)
Definition: reqh.c:413
struct m0_pdclust_attr pv_attr
Definition: pool.h:122
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
struct m0_pdclust_src_addr src
Definition: fd.c:108
M0_INTERNAL void m0_bob_type_tlist_init(struct m0_bob_type *bt, const struct m0_tl_descr *td)
Definition: bob.c:41
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_rpc_conn * s_conn
Definition: session.h:312
Definition: fop.h:79
Definition: trace.h:478
m0_reqh_states
Definition: reqh.h:82
Definition: idx_mock.c:47
const struct m0_fid * rhia_fid
Definition: reqh.h:242
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)
Definition: sm.c:331