Motr  M0
conf_mgmt.c
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 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_SPIEL
24 #include "lib/trace.h"
25 
26 #include "lib/errno.h"
27 #include "lib/finject.h" /* M0_FI_ENABLED */
28 #include "lib/memory.h" /* m0_alloc, M0_ALLOC_ARR */
29 #include "lib/string.h" /* m0_strdup, m0_strings_dup */
30 #include "lib/tlist.h"
31 #include "fid/fid.h"
32 #include "conf/cache.h"
33 #include "conf/flip_fop.h"
34 #include "conf/load_fop.h"
35 #include "conf/obj.h"
36 #include "conf/onwire_xc.h" /* m0_confx_xc */
37 #include "conf/preload.h" /* m0_confx_free, m0_confx_to_string */
38 #include "conf/obj_ops.h" /* m0_conf_obj_find */
39 #include "conf/dir.h" /* m0_conf_dir_new */
40 #include "conf/helpers.h" /* m0_conf_pvers */
41 #include "rm/rm_rwlock.h" /* m0_rw_lockable */
42 #include "rpc/link.h"
43 #include "rpc/rpclib.h" /* m0_rpc_client_connect */
44 #include "ioservice/fid_convert.h" /* M0_FID_DEVICE_ID_MAX */
45 #include "spiel/spiel.h"
46 #include "spiel/conf_mgmt.h"
47 #include "spiel/spiel_internal.h"
48 #ifndef __KERNEL__
49 # include <stdio.h> /* FILE, fopen */
50 #endif
51 
57 M0_TL_DESCR_DECLARE(rpcbulk, M0_EXTERN);
58 
60  const struct m0_fid *scp_fid;
61  const struct m0_conf_obj_type *scp_type;
62  struct m0_conf_obj **scp_obj;
63 };
64 
66 {
68 }
69 
71 {
73 }
74 
75 #define SPIEL_CONF_CHECK(cache, ...) \
76  spiel_conf_parameter_check(cache, (struct spiel_conf_param []) { \
77  __VA_ARGS__, \
78  { NULL, NULL, NULL }, });
79 
84 static int spiel_root_ver_update(struct m0_spiel_tx *tx, uint64_t verno)
85 {
86  int rc;
87  struct m0_conf_obj *obj;
88  struct m0_conf_root *root;
89 
90  M0_ENTRY();
91 
92  m0_mutex_lock(&tx->spt_lock);
94  if (obj == NULL || obj->co_status == M0_CS_MISSING)
95  rc = M0_ERR(-ENOENT);
96  if (rc == 0) {
98  root->rt_verno = verno;
99  }
101 
102  return M0_RC(rc);
103 }
104 
105 void m0_spiel_tx_open(struct m0_spiel *spiel, struct m0_spiel_tx *tx)
106 {
107  struct m0_mutex *lock = &tx->spt_lock;
108  struct m0_conf_obj *obj;
109  int rc;
110 
111  M0_ENTRY("tx=%p", tx);
112  M0_PRE(tx != NULL);
113 
114  tx->spt_spiel = spiel;
115  tx->spt_buffer = NULL;
116 
119 
120  /* Create root object. */
124  M0_ASSERT(rc == 0); /* XXX Error handling is for cowards. */
125 
126  M0_POST(obj->co_status == M0_CS_MISSING);
127  M0_LEAVE();
128 }
129 M0_EXPORTED(m0_spiel_tx_open);
130 
137 {
138  struct m0_conf_obj *obj;
139  struct m0_conf_obj *obj_parent;
140  struct m0_conf_cache *cache = &tx->spt_cache;
141 
142  M0_ENTRY();
143 
144  m0_tl_for(m0_conf_cache, &cache->ca_registry, obj) {
146  /* Check status*/
147  if (obj->co_status != M0_CS_READY)
148  return M0_ERR(-EBUSY);
149 
151  /* Check parent */
152  if (obj->co_parent == NULL)
153  return M0_ERR(-ENOENT);
154  /* Check parent in cache */
155  obj_parent = m0_conf_cache_lookup(cache,
156  &obj->co_parent->co_id);
157  if (obj_parent == NULL ||
158  obj_parent != obj->co_parent)
159  return M0_ERR(-ENOENT);
160  }
161  }
162  } m0_tl_endfor;
163 
164  return M0_RC(0);
165 }
166 M0_EXPORTED(m0_spiel_tx_validate);
167 
172 {
173  M0_ENTRY("tx=%p", tx);
175  m0_mutex_fini(&tx->spt_lock);
176  M0_LEAVE();
177 }
178 M0_EXPORTED(m0_spiel_tx_close);
179 
181 {
182  return _0C(cmd != NULL) &&
184 }
185 
186 static uint64_t spiel_root_conf_version(struct m0_spiel_tx *tx)
187 {
188  int rc;
189  uint64_t verno;
190  struct m0_conf_obj *obj;
191 
192  M0_ENTRY("tx=%p", tx);
193 
194  m0_mutex_lock(&tx->spt_lock);
196  M0_ASSERT(_0C(rc == 0) && _0C(obj != NULL));
197  verno = M0_CONF_CAST(obj, m0_conf_root)->rt_verno;
199 
200  return verno;
201 }
206 static void spiel_load_fop_fini(struct m0_spiel_load_command *spiel_cmd)
207 {
208  M0_PRE(spiel_load_cmd_invariant(spiel_cmd));
210  m0_rpc_bulk_fini(&spiel_cmd->slc_rbulk);
211  m0_fop_fini(&spiel_cmd->slc_load_fop);
212 }
213 
218 static void spiel_load_fop_release(struct m0_ref *ref)
219 {
220  struct m0_fop *fop = M0_AMB(fop, ref, f_ref);
221  struct m0_spiel_load_command *spiel_cmd = M0_AMB(spiel_cmd, fop,
222  slc_load_fop);
223  spiel_load_fop_fini(spiel_cmd);
224 }
225 
232 static int spiel_load_fop_init(struct m0_spiel_load_command *spiel_cmd,
233  struct m0_spiel_tx *tx)
234 {
235  int rc;
236  struct m0_fop_conf_load *conf_fop;
237 
238  M0_ENTRY();
239  M0_PRE(spiel_cmd != NULL);
240  M0_PRE(tx != NULL);
241 
244  rc = m0_fop_data_alloc(&spiel_cmd->slc_load_fop);
245  if (rc == 0) {
246  /* Fill Spiel Conf FOP specific data*/
247  conf_fop = m0_conf_fop_to_load_fop(&spiel_cmd->slc_load_fop);
248  conf_fop->clf_version = spiel_root_conf_version(tx);
249  conf_fop->clf_tx_id = (uint64_t)tx;
250  m0_rpc_bulk_init(&spiel_cmd->slc_rbulk);
251  M0_POST(spiel_load_cmd_invariant(spiel_cmd));
252  }
253  return M0_RC(rc);
254 }
255 
256 static int spiel_load_fop_create(struct m0_spiel_tx *tx,
257  struct m0_spiel_load_command *spiel_cmd)
258 {
259  int rc;
260  struct m0_rpc_bulk_buf *rbuf;
261  struct m0_net_domain *nd;
262  int i;
263  int segs_nr;
265  m0_bcount_t size = strlen(tx->spt_buffer)+1;
266 
267  rc = spiel_load_fop_init(spiel_cmd, tx);
268  if (rc != 0)
269  return M0_ERR(rc);
270 
271  /* Fill RPC Bulk part of Spiel FOM */
274  /*
275  * Calculate number of segments for given data size.
276  * Segments number is rounded up.
277  */
278  segs_nr = (size + seg_size - 1) / seg_size;
279  rc = m0_rpc_bulk_buf_add(&spiel_cmd->slc_rbulk, segs_nr, size, nd,
280  NULL, &rbuf);
281  for (i = 0; i < segs_nr; ++i) {
283  tx->spt_buffer + i*seg_size,
284  min_check(size, seg_size), i, nd);
285  size -= seg_size;
286  }
288  return rc;
289 }
290 
291 static int spiel_load_fop_send(struct m0_spiel_tx *tx,
292  struct m0_spiel_load_command *spiel_cmd)
293 {
294  int rc;
295  struct m0_fop_conf_load *load_fop;
296  struct m0_fop *rep;
297  struct m0_fop_conf_load_rep *load_rep;
298 
299  M0_ENTRY();
300  rc = spiel_load_fop_create(tx, spiel_cmd);
301  if (rc != 0)
302  return M0_ERR(rc);
303 
304  load_fop = m0_conf_fop_to_load_fop(&spiel_cmd->slc_load_fop);
305  rc = m0_rpc_bulk_store(&spiel_cmd->slc_rbulk,
306  &spiel_cmd->slc_connect,
307  &load_fop->clf_desc,
309  if (rc != 0)
310  return M0_ERR(rc);
311 
312  rc = m0_rpc_post_sync(&spiel_cmd->slc_load_fop,
313  &spiel_cmd->slc_session,
314  NULL,
315  0/*M0_TIME_NEVER*/);
316  rep = rc == 0 ? m0_rpc_item_to_fop(
317  spiel_cmd->slc_load_fop.f_item.ri_reply)
318  : NULL;
319  load_rep = rep != NULL ? m0_conf_fop_to_load_fop_rep(rep) : NULL;
320 
321  if (load_rep != NULL) {
322  rc = load_rep->clfr_rc;
323  spiel_cmd->slc_version = load_rep->clfr_version;
324  } else {
325  rc = M0_ERR(-ENOENT);
326  }
327  m0_fop_put_lock(&spiel_cmd->slc_load_fop);
328  return M0_RC(rc);
329 }
330 
331 static void spiel_flip_fop_release(struct m0_ref *ref)
332 {
333  m0_fop_fini(container_of(ref, struct m0_fop, f_ref));
334 }
335 
336 static int spiel_flip_fop_send(struct m0_spiel_tx *tx,
337  struct m0_spiel_load_command *spiel_cmd)
338 {
339  int rc;
340  struct m0_fop_conf_flip *flip_fop;
341  struct m0_fop *rep;
342  struct m0_fop_conf_flip_rep *flip_rep;
343 
344  M0_ENTRY();
345  M0_PRE(spiel_cmd != NULL);
346 
349  rc = m0_fop_data_alloc(&spiel_cmd->slc_flip_fop);
350  if (rc == 0) {
351  flip_fop = m0_conf_fop_to_flip_fop(&spiel_cmd->slc_flip_fop);
352  flip_fop->cff_prev_version = spiel_cmd->slc_version;
354  flip_fop->cff_tx_id = (uint64_t)tx;
355  rc = m0_rpc_post_sync(&spiel_cmd->slc_flip_fop,
356  &spiel_cmd->slc_session, NULL, 0);
357  }
358  rep = rc == 0 ? m0_rpc_item_to_fop(
359  spiel_cmd->slc_flip_fop.f_item.ri_reply)
360  : NULL;
361  flip_rep = rep != NULL ? m0_conf_fop_to_flip_fop_rep(rep) : NULL;
362  rc = flip_rep != NULL ? flip_rep->cffr_rc : M0_ERR(-ENOENT);
363  m0_fop_put_lock(&spiel_cmd->slc_flip_fop);
364  return M0_RC(rc);
365 }
366 
368 {
369  return m0_semaphore_init(&wlx->wlc_sem, 0);
370 }
371 
373 {
375 }
376 
377 static int wlock_ctx_create(struct m0_spiel *spl)
378 {
379  struct m0_spiel_wlock_ctx *wlx;
380  int rc;
381 
382  M0_ENTRY();
383  M0_PRE(spl->spl_wlock_ctx == NULL);
384 
385  M0_ALLOC_PTR(wlx);
386  if (wlx == NULL)
387  return M0_ERR(-ENOMEM);
388 
389  wlx->wlc_rmach = spiel_rmachine(spl);
394  &wlx->wlc_rwlock, NULL);
397  if (rc != 0) {
398  m0_free(wlx);
399  return M0_ERR(rc);
400  }
401  spl->spl_wlock_ctx = wlx;
402  return M0_RC(0);
403 }
404 
406 {
407  M0_ENTRY("wlx=%p", wlx);
408  M0_PRE(wlx != NULL);
409 
413  M0_LEAVE();
414 }
415 
417 {
418  enum { MAX_RPCS_IN_FLIGHT = 15 };
419 
420  M0_ENTRY("wlx=%p", wlx);
421  M0_PRE(wlx != NULL);
425  M0_TIME_NEVER));
426 }
427 
429 {
430  int rc;
431 
432  M0_ENTRY("wlx=%p", wlx);
433  M0_PRE(_0C(wlx != NULL) && _0C(!M0_IS0(&wlx->wlc_sess)));
435  if (rc != 0)
436  M0_LOG(M0_ERROR, "Failed to destroy wlock session; rc=%d", rc);
438  if (rc != 0)
439  M0_LOG(M0_ERROR, "Failed to destroy wlock connection; rc=%d",
440  rc);
441  M0_LEAVE();
442 }
443 
445  int32_t rc)
446 {
447  struct m0_spiel_wlock_ctx *wlx = M0_AMB(wlx, in, wlc_req);
448 
449  M0_ENTRY("in=%p rc=%d", in, rc);
450  wlx->wlc_rc = rc;
452  M0_LEAVE();
453 }
454 
456 {
457  /* Do nothing */
458 }
459 
462  .rio_conflict = spiel_tx_write_lock_conflict,
463 };
464 
466 {
467  struct m0_rm_owner *owner;
468  struct m0_rm_remote *creditor;
469 
470  M0_ENTRY("wlx=%p", wlx);
471  M0_PRE(wlx != NULL);
472  owner = &wlx->wlc_owner;
477  M0_LEAVE();
478 }
479 
481 {
482  struct m0_rm_incoming *req;
483 
484  M0_ENTRY("wlx=%p", wlx);
485  M0_PRE(wlx != NULL);
486  req = &wlx->wlc_req;
491  M0_LEAVE();
492 }
493 
495 {
496  M0_ENTRY("wlx=%p", wlx);
497  M0_PRE(wlx != NULL);
501  M0_LEAVE();
502 }
503 
505 {
506  M0_ENTRY("wlx=%p", wlx);
508  M0_LEAVE();
509 }
510 
512 {
513  int rc;
514 
515  M0_ENTRY("wlx=%p", wlx);
519  M0_TIME_NEVER);
520  M0_ASSERT(rc == 0);
521  M0_LEAVE();
522 }
523 
524 static int spiel_tx_write_lock_get(struct m0_spiel_tx *tx)
525 {
526  struct m0_spiel *spl;
527  struct m0_spiel_wlock_ctx *wlx;
528  int rc;
529 
530  M0_ENTRY("tx=%p", tx);
531  M0_PRE(tx != NULL);
532 
533  spl = tx->spt_spiel;
534  rc = wlock_ctx_create(spl);
535  if (rc != 0)
536  return M0_ERR(rc);
537  wlx = spl->spl_wlock_ctx;
539  if (rc != 0)
540  goto err;
542  if (M0_FI_ENABLED("borrow-request-failure")) {
543  wlx->wlc_rc = -EIO; /* simulate MOTR-2364 */
544  goto wlock_err;
545  }
548  if (wlx->wlc_rc == 0)
549  return M0_RC(0);
550 wlock_err:
551  rc = wlx->wlc_rc;
556 err:
558  m0_free0(&spl->spl_wlock_ctx);
559  return M0_ERR(rc);
560 }
561 
563 {
564  struct m0_rm_incoming *req;
565 
566  M0_ENTRY("wlx=%p", wlx);
567  M0_PRE(wlx != NULL);
568  req = &wlx->wlc_req;
573  M0_LEAVE();
574 }
575 
576 static void spiel_tx_write_lock_put(struct m0_spiel_tx *tx)
577 {
578  struct m0_spiel_wlock_ctx *wlx;
579 
580  M0_ENTRY("tx=%p", tx);
581  M0_PRE(_0C(tx != NULL) && _0C(tx->spt_spiel != NULL));
582  wlx = tx->spt_spiel->spl_wlock_ctx;
588  M0_LEAVE();
589 }
590 
592  bool forced,
593  uint64_t ver_forced,
594  uint32_t *rquorum)
595 {
596  enum { MAX_RPCS_IN_FLIGHT = 2 };
597  int rc;
598  struct m0_spiel_load_command *spiel_cmd = NULL;
599  const char **confd_eps = NULL;
600  uint32_t confd_count = 0;
601  uint32_t quorum = 0;
602  uint32_t idx;
603  uint64_t rconfc_ver;
604 
605  M0_ENTRY();
607  if (rc != 0)
608  goto rconfc_fail;
609  /*
610  * in case ver_forced value is other than M0_CONF_VER_UNKNOWN, override
611  * transaction version number with ver_forced, otherwise leave the one
612  * intact
613  */
614  if (ver_forced != M0_CONF_VER_UNKNOWN) {
615  rc = spiel_root_ver_update(tx, ver_forced);
616  M0_ASSERT(rc == 0);
617  } else {
618  rconfc_ver = m0_rconfc_ver_max_read(&tx->spt_spiel->spl_rconfc);
619  if (rconfc_ver != M0_CONF_VER_UNKNOWN) {
620  ++rconfc_ver;
621  } else {
622  /*
623  * Version number may be unknown due to cluster quorum
624  * issues at runtime, so need to return error code to
625  * client.
626  */
627  rc = -ENODATA;
628  goto tx_fini;
629  }
630  rc = spiel_root_ver_update(tx, rconfc_ver);
631  M0_ASSERT(rc == 0);
632  }
633 
634  rc = m0_spiel_tx_validate(tx) ?:
635  m0_conf_cache_to_string(&tx->spt_cache, &tx->spt_buffer, false);
636  if (M0_FI_ENABLED("encode_fail"))
637  rc = -ENOMEM;
638  if (rc != 0)
639  goto tx_fini;
640 
642  &confd_eps);
643  if (confd_count == 0) {
644  rc = M0_ERR(-ENODATA);
645  goto tx_fini;
646  }
647  if (!M0_FI_ENABLED("cmd_alloc_fail"))
648  M0_ALLOC_ARR(spiel_cmd, confd_count);
649  if (spiel_cmd == NULL) {
650  rc = M0_ERR(-ENOMEM);
651  goto tx_fini;
652  }
653  for (idx = 0; idx < confd_count; ++idx) {
654  spiel_cmd[idx].slc_status =
655  m0_rpc_client_connect(&spiel_cmd[idx].slc_connect,
656  &spiel_cmd[idx].slc_session,
658  confd_eps[idx], NULL,
660  M0_TIME_NEVER) ?:
661  spiel_load_fop_send(tx, &spiel_cmd[idx]);
662  }
663 
664  quorum = m0_count(idx, confd_count, (spiel_cmd[idx].slc_status == 0));
665  /*
666  * Unless forced transaction committing requested, make sure the quorum
667  * at least reached the value specified at m0_spiel_start_quorum(), or
668  * better went beyond it.
669  */
670  if (!forced && quorum < tx->spt_spiel->spl_rconfc.rc_quorum) {
671  rc = M0_ERR(-ENOENT);
672  goto tx_fini;
673  }
674 
675  quorum = 0;
677  if (rc != 0)
678  goto tx_fini;
679  for (idx = 0; idx < confd_count; ++idx) {
680  if (spiel_cmd[idx].slc_status == 0) {
681  rc = spiel_flip_fop_send(tx, &spiel_cmd[idx]);
682  if (rc == 0)
683  ++quorum;
684  }
685  }
686  /* TODO: handle creditor death */
688  rc = !forced && quorum < tx->spt_spiel->spl_rconfc.rc_quorum ?
689  M0_ERR(-ENOENT) : 0;
690 
691 tx_fini:
694  m0_strings_free(confd_eps);
695  if (tx->spt_buffer != NULL)
697 
698  if (spiel_cmd != NULL) {
699  for (idx = 0; idx < confd_count; ++idx) {
700  struct m0_rpc_session *ss = &spiel_cmd[idx].slc_session;
701  struct m0_rpc_conn *sc = &spiel_cmd[idx].slc_connect;
702 
703  if (!M0_IN(ss->s_sm.sm_state,
707  if (!M0_IN(sc->c_sm.sm_state,
711  }
712  m0_free(spiel_cmd);
713  }
714 
715  /* report resultant quorum value reached during committing */
716  if (rquorum != NULL)
717  *rquorum = quorum;
718 
719  return M0_RC(rc);
720 }
721 M0_EXPORTED(m0_spiel_tx_commit_forced);
722 
724 {
726 }
727 M0_EXPORTED(m0_spiel_tx_commit);
728 
733 {
734  struct m0_conf_obj *obj = &r->rt_obj;
735 
736  return M0_RC(m0_conf_dir_new(obj, &M0_CONF_ROOT_NODES_FID,
737  &M0_CONF_NODE_TYPE, NULL, &r->rt_nodes) ?:
738  m0_conf_dir_new(obj, &M0_CONF_ROOT_POOLS_FID,
739  &M0_CONF_POOL_TYPE, NULL, &r->rt_pools) ?:
740  m0_conf_dir_new(obj, &M0_CONF_ROOT_SITES_FID,
741  &M0_CONF_SITE_TYPE, NULL, &r->rt_sites) ?:
742  m0_conf_dir_new(obj, &M0_CONF_ROOT_PROFILES_FID,
744  &r->rt_profiles) ?:
745  m0_conf_dir_new(obj, &M0_CONF_ROOT_FDMI_FLT_GRPS_FID,
747  &r->rt_fdmi_flt_grps));
748 }
749 
752 {
753  return M0_RC(m0_conf_dir_new(&node->cn_obj,
754  &M0_CONF_NODE_PROCESSES_FID,
756  &node->cn_processes));
757 }
758 
760 static int spiel_process_dirs_create(struct m0_conf_process *process)
761 {
762  return M0_RC(m0_conf_dir_new(&process->pc_obj,
763  &M0_CONF_PROCESS_SERVICES_FID,
765  &process->pc_services));
766 }
767 
770 {
771  return M0_RC(m0_conf_dir_new(&service->cs_obj,
772  &M0_CONF_SERVICE_SDEVS_FID,
774  &service->cs_sdevs));
775 }
776 
779 {
780  return M0_RC(m0_conf_dir_new(&pool->pl_obj,
781  &M0_CONF_POOL_PVERS_FID,
783  &pool->pl_pvers));
784 }
785 
789 static int spiel_site_dirs_create(struct m0_conf_site *site)
790 {
791  return M0_RC(m0_conf_dir_new(&site->ct_obj,
792  &M0_CONF_SITE_RACKS_FID,
794  &site->ct_racks));
795 }
796 
800 static int spiel_rack_dirs_create(struct m0_conf_rack *rack)
801 {
802  return M0_RC(m0_conf_dir_new(&rack->cr_obj,
803  &M0_CONF_RACK_ENCLS_FID,
805  &rack->cr_encls));
806 }
807 
809 static int spiel_enclosure_dirs_create(struct m0_conf_enclosure *enclosure)
810 {
811  return M0_RC(m0_conf_dir_new(&enclosure->ce_obj,
812  &M0_CONF_ENCLOSURE_CTRLS_FID,
814  &enclosure->ce_ctrls));
815 }
816 
818 static int spiel_controller_dirs_create(struct m0_conf_controller *controller)
819 {
820  return M0_RC(m0_conf_dir_new(&controller->cc_obj,
821  &M0_CONF_CONTROLLER_DRIVES_FID,
823  &controller->cc_drives));
824 }
825 
828 {
829  return M0_RC(m0_conf_dir_new(&pver->pv_obj,
830  &M0_CONF_PVER_SITEVS_FID,
832  &pver->pv_u.subtree.pvs_sitevs));
833 }
834 
838 static int spiel_sitev_dirs_create(struct m0_conf_objv *objv)
839 {
840  return M0_RC(m0_conf_dir_new(&objv->cv_obj,
841  &M0_CONF_SITEV_RACKVS_FID,
843  &objv->cv_children));
844 }
845 
849 static int spiel_rackv_dirs_create(struct m0_conf_objv *objv)
850 {
851  return M0_RC(m0_conf_dir_new(&objv->cv_obj,
852  &M0_CONF_RACKV_ENCLVS_FID,
854  &objv->cv_children));
855 }
856 
859 {
860  return M0_RC(m0_conf_dir_new(&objv->cv_obj,
861  &M0_CONF_ENCLV_CTRLVS_FID,
863  &objv->cv_children));
864 }
865 
868 {
869  return M0_RC(m0_conf_dir_new(&objv->cv_obj,
870  &M0_CONF_CTRLV_DRIVEVS_FID,
872  &objv->cv_children));
873 }
874 
876  struct spiel_conf_param *parameters)
877 {
878  struct spiel_conf_param *param;
879  const struct m0_conf_obj *obj;
880  int rc;
881 
882  M0_PRE(cache != NULL);
883  M0_PRE(parameters != NULL);
884 
885  for (param = parameters; param->scp_type != NULL; ++param) {
886  if (param->scp_fid == NULL ||
887  m0_conf_fid_type(param->scp_fid) != param->scp_type)
888  return M0_ERR(-EINVAL);
889  rc = m0_conf_obj_find(cache, param->scp_fid, param->scp_obj);
890  if (rc != 0)
891  return M0_ERR(rc);
892  }
893  obj = *parameters->scp_obj;
894  if (obj->co_status == M0_CS_MISSING) {
895  M0_LOG(M0_INFO, FID_F": OK", FID_P(&obj->co_id));
896  return M0_RC(0);
897  }
898  M0_ASSERT(obj->co_status == M0_CS_READY);
899  return M0_ERR_INFO(-EEXIST, FID_F": Not a stub", FID_P(&obj->co_id));
900 }
901 
903  const struct m0_fid *rootfid,
904  const struct m0_fid *mdpool,
905  const struct m0_fid *imeta_pver,
906  uint32_t mdredundancy,
907  const char **params)
908 {
909  int rc;
910  struct m0_conf_obj *root_obj;
911  struct m0_conf_root *root;
912  struct m0_conf_obj *pool;
913  struct m0_conf_obj *pver;
914 
915  M0_ENTRY();
916  if (M0_IN(NULL, (rootfid, mdpool, imeta_pver, params)))
917  return M0_ERR(-EPROTO);
918 
919  m0_mutex_lock(&tx->spt_lock);
921  &tx->spt_cache,
922  /*
923  * Note: currently there are no constraints on the type of
924  * `rootfid'.
925  */
926  {mdpool, &M0_CONF_POOL_TYPE, &pool},
927  {&M0_CONF_ROOT_FID, &M0_CONF_ROOT_TYPE, &root_obj});
928  if (rc == 0 && m0_fid_is_set(imeta_pver))
930  {imeta_pver, &M0_CONF_PVER_TYPE, &pver});
931  if (rc != 0)
932  goto out;
933 
934  M0_PRE(root_obj->co_status == M0_CS_MISSING);
935  root = M0_CONF_CAST(root_obj, m0_conf_root);
936 
938  if (root->rt_params == NULL) {
939  rc = M0_ERR(-ENOMEM);
940  goto out;
941  }
942  root->rt_rootfid = *rootfid;
943  root->rt_mdpool = *mdpool;
944  root->rt_imeta_pver = *imeta_pver;
945  root->rt_mdredundancy = mdredundancy;
946  /*
947  * Real version number will be set during transaction commit in
948  * one of two ways:
949  *
950  * 1. Spiel client may provide version number explicitly when
951  * calling m0_spiel_tx_commit_forced().
952  *
953  * 2. In case client does not provide any valid version number,
954  * current maximum version number known among confd services
955  * will be fetched by rconfc. This value will be incremented
956  * and used as version number of the currently populated
957  * conf DB.
958  */
960 
962  if (rc != 0) {
964  goto out;
965  }
966  root_obj->co_status = M0_CS_READY;
967  M0_POST(m0_conf_obj_invariant(root_obj));
968 out:
970  return M0_RC(rc);
971 }
972 M0_EXPORTED(m0_spiel_root_add);
973 
975  const struct m0_fid *fid,
976  uint32_t memsize,
977  uint32_t nr_cpu,
978  uint64_t last_state,
979  uint64_t flags)
980 {
981  int rc;
982  struct m0_conf_obj *obj = NULL;
983  struct m0_conf_obj *obj_parent;
984  struct m0_conf_node *node;
985  struct m0_conf_root *root;
986 
987  M0_ENTRY();
988 
989  m0_mutex_lock(&tx->spt_lock);
991  {fid, &M0_CONF_NODE_TYPE, &obj },
992  {&M0_CONF_ROOT_FID, &M0_CONF_ROOT_TYPE,
993  &obj_parent});
994  if (rc != 0)
995  goto fail;
996 
998  node->cn_memsize = memsize;
999  node->cn_nr_cpu = nr_cpu;
1000  node->cn_last_state = last_state;
1001  node->cn_flags = flags;
1002 
1004  if (rc != 0)
1005  goto fail;
1006  root = M0_CONF_CAST(obj_parent, m0_conf_root);
1007  if (root->rt_nodes == NULL) {
1008  /* Parent dir does not exist ==> create it. */
1010  if (rc != 0)
1011  goto fail;
1012  }
1014  obj->co_status = M0_CS_READY;
1015 
1017  m0_mutex_unlock(&tx->spt_lock);
1018  return M0_RC(0);
1019 fail:
1020  if (obj != NULL && rc != -EEXIST)
1022  m0_mutex_unlock(&tx->spt_lock);
1023  return M0_ERR(rc);
1024 }
1025 M0_EXPORTED(m0_spiel_node_add);
1026 
1027 static bool spiel_cores_is_valid(const struct m0_bitmap *cores)
1028 {
1029  return cores != NULL && m0_exists(i, cores->b_nr,
1030  cores->b_words[i] != 0);
1031 }
1032 
1034  const struct m0_fid *fid,
1035  const struct m0_fid *parent,
1036  struct m0_bitmap *cores,
1037  uint64_t memlimit_as,
1038  uint64_t memlimit_rss,
1039  uint64_t memlimit_stack,
1040  uint64_t memlimit_memlock,
1041  const char *endpoint)
1042 {
1043  int rc;
1044  struct m0_conf_obj *obj = NULL;
1045  struct m0_conf_process *process;
1046  struct m0_conf_obj *obj_parent;
1047  struct m0_conf_node *node;
1048 
1049  M0_ENTRY();
1050  if (!spiel_cores_is_valid(cores) || endpoint == NULL)
1051  return M0_ERR(-EINVAL);
1052  m0_mutex_lock(&tx->spt_lock);
1053 
1054  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1055  {fid, &M0_CONF_PROCESS_TYPE, &obj },
1056  {parent, &M0_CONF_NODE_TYPE, &obj_parent});
1057  if (rc != 0)
1058  goto fail;
1059 
1060  process = M0_CONF_CAST(obj, m0_conf_process);
1061  rc = m0_bitmap_init(&process->pc_cores, cores->b_nr);
1062  if (rc != 0)
1063  goto fail;
1064  /* XXX FIXME: process->pc_cores.b_words will leak in case of error */
1065  m0_bitmap_copy(&process->pc_cores, cores);
1066  process->pc_memlimit_as = memlimit_as;
1067  process->pc_memlimit_rss = memlimit_rss;
1068  process->pc_memlimit_stack = memlimit_stack;
1069  process->pc_memlimit_memlock = memlimit_memlock;
1070  process->pc_endpoint = m0_strdup(endpoint);
1071  if (process->pc_endpoint == NULL) {
1072  rc = M0_ERR(-ENOMEM);
1073  goto fail;
1074  }
1075  /* XXX FIXME: process->pc_endpoint will leak in case of error */
1076 
1077  rc = spiel_process_dirs_create(process);
1078  if (rc != 0)
1079  goto fail;
1080  node = M0_CONF_CAST(obj_parent, m0_conf_node);
1081  if (node->cn_processes == NULL) {
1082  /* Parent dir does not exist ==> create it. */
1084  if (rc != 0)
1085  goto fail;
1086  }
1087  m0_conf_dir_add(node->cn_processes, obj);
1088  obj->co_status = M0_CS_READY;
1089 
1091  m0_mutex_unlock(&tx->spt_lock);
1092  return M0_RC(0);
1093 fail:
1094  if (obj != NULL && rc != -EEXIST)
1096  m0_mutex_unlock(&tx->spt_lock);
1097  return M0_ERR(rc);
1098 }
1099 M0_EXPORTED(m0_spiel_process_add);
1100 
1102  const struct m0_fid *fid,
1103  const struct m0_fid *parent,
1104  const struct m0_spiel_service_info *service_info)
1105 {
1106  int rc;
1107  struct m0_conf_obj *obj = NULL;
1108  struct m0_conf_service *service;
1109  struct m0_conf_obj *obj_parent;
1110  struct m0_conf_process *process;
1111 
1112  M0_ENTRY();
1113  if (service_info == NULL ||
1114  !m0_conf_service_type_is_valid(service_info->svi_type))
1115  return M0_ERR(-EINVAL);
1116  m0_mutex_lock(&tx->spt_lock);
1117 
1118  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1119  {fid, &M0_CONF_SERVICE_TYPE, &obj },
1120  {parent, &M0_CONF_PROCESS_TYPE, &obj_parent});
1121  if (rc != 0)
1122  goto fail;
1123 
1125  service->cs_type = service_info->svi_type;
1126  service->cs_endpoints = m0_strings_dup(service_info->svi_endpoints);
1127  if (service->cs_endpoints == NULL) {
1128  rc = M0_ERR(-ENOMEM);
1129  goto fail;
1130  }
1131 
1133  if (rc != 0)
1134  goto fail;
1135  process = M0_CONF_CAST(obj_parent, m0_conf_process);
1136  if (process->pc_services == NULL) {
1137  /* Parent dir does not exist ==> create it. */
1138  rc = spiel_process_dirs_create(process);
1139  if (rc != 0)
1140  goto fail;
1141  }
1142  m0_conf_dir_add(process->pc_services, obj);
1143  obj->co_status = M0_CS_READY;
1144 
1146  m0_mutex_unlock(&tx->spt_lock);
1147  return M0_RC(0);
1148 fail:
1149  if (obj != NULL && rc != -EEXIST)
1151  m0_mutex_unlock(&tx->spt_lock);
1152  return M0_ERR(rc);
1153 }
1154 M0_EXPORTED(m0_spiel_service_add);
1155 
1157  const struct m0_fid *fid,
1158  const struct m0_fid *parent,
1159  const struct m0_fid *drive,
1160  uint32_t dev_idx,
1163  uint32_t bsize,
1164  uint64_t size,
1165  uint64_t last_state,
1166  uint64_t flags,
1167  const char *filename)
1168 {
1169  int rc;
1170  struct m0_conf_obj *obj = NULL;
1171  struct m0_conf_sdev *device;
1172  struct m0_conf_obj *svc_obj;
1173  struct m0_conf_obj *drv_obj;
1174  struct m0_conf_service *service;
1175  struct m0_conf_drive *drv;
1176 
1177  M0_ENTRY();
1178  if (dev_idx > M0_FID_DEVICE_ID_MAX ||
1181  filename == NULL)
1182  return M0_ERR(-EINVAL);
1183 
1184  m0_mutex_lock(&tx->spt_lock);
1185 
1186  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1187  {fid, &M0_CONF_SDEV_TYPE, &obj },
1188  {parent, &M0_CONF_SERVICE_TYPE, &svc_obj},
1189  {drive, &M0_CONF_DRIVE_TYPE, &drv_obj});
1190  if (rc != 0)
1191  goto fail;
1192 
1193  device = M0_CONF_CAST(obj, m0_conf_sdev);
1194  device->sd_dev_idx = dev_idx;
1195  device->sd_iface = iface;
1196  device->sd_media = media;
1197  device->sd_bsize = bsize;
1198  device->sd_size = size;
1199  device->sd_last_state = last_state;
1200  device->sd_flags = flags;
1201  device->sd_filename = m0_strdup(filename);
1202  if (device->sd_filename == NULL) {
1203  rc = M0_ERR(-ENOMEM);
1204  goto fail;
1205  }
1206  /* XXX FIXME: device->sd_filename will leak in case of error */
1207 
1208  service = M0_CONF_CAST(svc_obj, m0_conf_service);
1209  if (service->cs_sdevs == NULL) {
1210  /* Parent dir does not exist ==> create it. */
1212  if (rc != 0)
1213  goto fail;
1214  }
1215  m0_conf_dir_add(service->cs_sdevs, obj);
1216  drv = M0_CONF_CAST(drv_obj, m0_conf_drive);
1217  if (drv->ck_sdev != NULL) {
1218  m0_conf_dir_del(service->cs_sdevs, obj);
1219  rc = M0_ERR(-EINVAL);
1220  goto fail;
1221  }
1222  drv->ck_sdev = device;
1223  obj->co_status = M0_CS_READY;
1224 
1226  m0_mutex_unlock(&tx->spt_lock);
1227  return M0_RC(0);
1228 fail:
1229  if (obj != NULL && rc != -EEXIST)
1231  m0_mutex_unlock(&tx->spt_lock);
1232  return M0_ERR(rc);
1233 }
1234 M0_EXPORTED(m0_spiel_device_add);
1235 
1236 int m0_spiel_profile_add(struct m0_spiel_tx *tx, const struct m0_fid *fid)
1237 {
1238  int rc;
1239  struct m0_conf_obj *obj = NULL;
1240  struct m0_conf_obj *obj_parent;
1241  struct m0_conf_root *root;
1242 
1243  M0_ENTRY();
1244 
1245  m0_mutex_lock(&tx->spt_lock);
1246 
1247  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1248  {fid, &M0_CONF_PROFILE_TYPE, &obj},
1249  {&M0_CONF_ROOT_FID, &M0_CONF_ROOT_TYPE,
1250  &obj_parent});
1251  if (rc != 0)
1252  goto fail;
1253 
1254  root = M0_CONF_CAST(obj_parent, m0_conf_root);
1255  if (root->rt_profiles == NULL) {
1256  /* Parent dir does not exist ==> create it. */
1258  if (rc != 0)
1259  goto fail;
1260  }
1262  obj->co_status = M0_CS_READY;
1263 
1265  m0_mutex_unlock(&tx->spt_lock);
1266  return M0_RC(0);
1267 fail:
1268  if (obj != NULL && rc != -EEXIST)
1270  m0_mutex_unlock(&tx->spt_lock);
1271  return M0_ERR(rc);
1272 }
1273 M0_EXPORTED(m0_spiel_profile_add);
1274 
1276  const struct m0_fid *pool)
1277 {
1278  struct m0_fid_arr *fids = &prof->cp_pools;
1279  struct m0_fid *tmp;
1280 
1281  M0_ENTRY();
1282 
1283  if (m0_exists(i, fids->af_count, m0_fid_eq(&fids->af_elems[i], pool)))
1284  return M0_ERR_INFO(-EEXIST, "prof="FID_F" pool="FID_F,
1285  FID_P(&prof->cp_obj.co_id), FID_P(pool));
1286 
1287  M0_ALLOC_ARR(tmp, fids->af_count + 1);
1288  if (tmp == NULL)
1289  return M0_ERR(-ENOMEM);
1290 
1291  /* Copy existing fids to `tmp` array .. */
1292  memcpy(tmp, fids->af_elems, fids->af_count * sizeof(fids->af_elems[0]));
1293  /* .. and add new fid. */
1294  tmp[fids->af_count] = *pool;
1295 
1296  /* Update prof->cp_pools. */
1297  m0_free(fids->af_elems);
1298  fids->af_elems = tmp;
1299  M0_CNT_INC(fids->af_count);
1300 
1301  return M0_RC(0);
1302 }
1303 
1305  const struct m0_fid *profile,
1306  const struct m0_fid *pool)
1307 {
1308  int rc;
1309  struct m0_conf_obj *obj;
1310  struct m0_conf_profile *prof;
1311 
1312  M0_ENTRY("profile="FID_F" pool="FID_F, FID_P(profile), FID_P(pool));
1313  m0_mutex_lock(&tx->spt_lock);
1314 
1316  if (rc != 0) {
1317  M0_ERR(rc);
1318  goto out;
1319  }
1320  if (obj->co_status != M0_CS_READY) {
1321  rc = M0_ERR_INFO(-EPROTO, "No profile to add pool to."
1322  " m0_spiel_profile_add() missing?");
1323  goto out;
1324  }
1326 
1328  if (rc != 0) {
1329  M0_ERR(rc);
1330  goto out;
1331  }
1333 out:
1334  m0_mutex_unlock(&tx->spt_lock);
1335  return M0_RC(rc);
1336 }
1337 M0_EXPORTED(m0_spiel_profile_pool_add);
1338 
1340  const struct m0_fid *fid,
1341  uint32_t pver_policy)
1342 {
1343  int rc;
1344  struct m0_conf_obj *obj = NULL;
1345  struct m0_conf_pool *pool;
1346  struct m0_conf_obj *parent;
1347  struct m0_conf_root *root;
1348 
1349  M0_ENTRY(FID_F, FID_P(fid));
1350 
1351  m0_mutex_lock(&tx->spt_lock);
1352  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1353  {fid, &M0_CONF_POOL_TYPE, &obj },
1354  {&M0_CONF_ROOT_FID, &M0_CONF_ROOT_TYPE, &parent});
1355  if (rc != 0)
1356  goto out;
1357 
1359  pool->pl_pver_policy = pver_policy;
1360  if (pool->pl_pvers == NULL) {
1362  if (rc != 0)
1363  goto out;
1364  }
1365  root = M0_CONF_CAST(parent, m0_conf_root);
1366  if (root->rt_pools == NULL) {
1367  /* Parent dir does not exist ==> create it. */
1369  if (rc != 0)
1370  goto out;
1371  }
1373  obj->co_status = M0_CS_READY;
1374 
1376 out:
1377  m0_mutex_unlock(&tx->spt_lock);
1378  return M0_RC(rc);
1379 }
1380 M0_EXPORTED(m0_spiel_pool_add);
1381 
1383  const struct m0_fid *fid)
1384 {
1385  int rc;
1386  struct m0_conf_obj *obj = NULL;
1387  struct m0_conf_site *site;
1388  struct m0_conf_obj *obj_parent;
1389  struct m0_conf_root *root;
1390 
1391  M0_ENTRY();
1392 
1393  m0_mutex_lock(&tx->spt_lock);
1394  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1395  {fid, &M0_CONF_SITE_TYPE, &obj },
1396  {&M0_CONF_ROOT_FID, &M0_CONF_ROOT_TYPE,
1397  &obj_parent});
1398  if (rc != 0)
1399  goto fail;
1400 
1401  site = M0_CONF_CAST(obj, m0_conf_site);
1402  rc = spiel_site_dirs_create(site);
1403  if (rc != 0)
1404  goto fail;
1405  root = M0_CONF_CAST(obj_parent, m0_conf_root);
1406  if (root->rt_sites == NULL) {
1407  /* Parent dir does not exist ==> create it. */
1409  if (rc != 0)
1410  goto fail;
1411  }
1413  obj->co_status = M0_CS_READY;
1414 
1416  m0_mutex_unlock(&tx->spt_lock);
1417  return M0_RC(0);
1418 fail:
1419  if (obj != NULL && rc != -EEXIST)
1421  m0_mutex_unlock(&tx->spt_lock);
1422  return M0_ERR(rc);
1423 }
1424 M0_EXPORTED(m0_spiel_site_add);
1425 
1427  const struct m0_fid *fid,
1428  const struct m0_fid *parent)
1429 {
1430  int rc;
1431  struct m0_conf_obj *obj = NULL;
1432  struct m0_conf_rack *rack;
1433  struct m0_conf_obj *obj_parent;
1434  struct m0_conf_site *site;
1435 
1436  M0_ENTRY();
1437 
1438  m0_mutex_lock(&tx->spt_lock);
1439  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1440  {fid, &M0_CONF_RACK_TYPE, &obj },
1441  {parent, &M0_CONF_SITE_TYPE, &obj_parent});
1442  if (rc != 0)
1443  goto fail;
1444 
1445  rack = M0_CONF_CAST(obj, m0_conf_rack);
1446  rc = spiel_rack_dirs_create(rack);
1447  if (rc != 0)
1448  goto fail;
1449  site = M0_CONF_CAST(obj_parent, m0_conf_site);
1450  if (site->ct_racks == NULL) {
1451  /* Parent dir does not exist ==> create it. */
1452  rc = spiel_site_dirs_create(site);
1453  if (rc != 0)
1454  goto fail;
1455  }
1456  m0_conf_dir_add(site->ct_racks, obj);
1457  obj->co_status = M0_CS_READY;
1458 
1460  m0_mutex_unlock(&tx->spt_lock);
1461  return M0_RC(0);
1462 fail:
1463  if (obj != NULL && rc != -EEXIST)
1465  m0_mutex_unlock(&tx->spt_lock);
1466  return M0_ERR(rc);
1467 }
1468 M0_EXPORTED(m0_spiel_rack_add);
1469 
1471  const struct m0_fid *fid,
1472  const struct m0_fid *parent,
1473  const struct m0_fid *node)
1474 {
1475  int rc;
1476  struct m0_conf_obj *obj = NULL;
1477  struct m0_conf_obj *node_obj;
1478  struct m0_conf_enclosure *enclosure;
1479  struct m0_conf_obj *obj_parent;
1480  struct m0_conf_rack *rack;
1481 
1482  M0_ENTRY();
1483 
1484  m0_mutex_lock(&tx->spt_lock);
1485  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1486  {fid, &M0_CONF_ENCLOSURE_TYPE, &obj },
1487  {parent, &M0_CONF_RACK_TYPE, &obj_parent},
1488  {node, &M0_CONF_NODE_TYPE, &node_obj});
1489  if (rc != 0)
1490  goto fail;
1491 
1492  enclosure = M0_CONF_CAST(obj, m0_conf_enclosure);
1493  enclosure->ce_node = M0_CONF_CAST(node_obj, m0_conf_node);
1494  rc = spiel_enclosure_dirs_create(enclosure);
1495  if (rc != 0)
1496  goto fail;
1497  rack = M0_CONF_CAST(obj_parent, m0_conf_rack);
1498  if (rack->cr_encls == NULL) {
1499  /* Parent dir does not exist ==> create it. */
1500  rc = spiel_rack_dirs_create(rack);
1501  if (rc != 0)
1502  goto fail;
1503  }
1504  m0_conf_dir_add(rack->cr_encls, obj);
1505  obj->co_status = M0_CS_READY;
1506 
1508  m0_mutex_unlock(&tx->spt_lock);
1509  return M0_RC(0);
1510 fail:
1511  if (obj != NULL && rc != -EEXIST)
1513  m0_mutex_unlock(&tx->spt_lock);
1514  return M0_ERR(rc);
1515 }
1516 M0_EXPORTED(m0_spiel_enclosure_add);
1517 
1519  const struct m0_fid *fid,
1520  const struct m0_fid *parent)
1521 {
1522  int rc;
1523  struct m0_conf_obj *obj = NULL;
1524  struct m0_conf_controller *controller;
1525  struct m0_conf_obj *obj_parent;
1526  struct m0_conf_enclosure *enclosure;
1527 
1528  M0_ENTRY();
1529 
1530  m0_mutex_lock(&tx->spt_lock);
1531  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1532  {fid, &M0_CONF_CONTROLLER_TYPE, &obj },
1533  {parent, &M0_CONF_ENCLOSURE_TYPE, &obj_parent});
1534  if (rc != 0)
1535  goto fail;
1536 
1537  controller = M0_CONF_CAST(obj, m0_conf_controller);
1538  rc = spiel_controller_dirs_create(controller);
1539  if (rc != 0)
1540  goto fail;
1541  enclosure = M0_CONF_CAST(obj_parent, m0_conf_enclosure);
1542  if (enclosure->ce_ctrls == NULL) {
1543  /* Parent dir does not exist ==> create it. */
1544  rc = spiel_enclosure_dirs_create(enclosure);
1545  if (rc != 0)
1546  goto fail;
1547  }
1548  m0_conf_dir_add(enclosure->ce_ctrls, obj);
1549  obj->co_status = M0_CS_READY;
1550 
1552  m0_mutex_unlock(&tx->spt_lock);
1553  return M0_RC(0);
1554 fail:
1555  if (obj != NULL && rc != -EEXIST)
1557  m0_mutex_unlock(&tx->spt_lock);
1558  return M0_ERR(rc);
1559 }
1560 M0_EXPORTED(m0_spiel_controller_add);
1561 
1563  const struct m0_fid *fid,
1564  const struct m0_fid *parent)
1565 {
1566  int rc;
1567  struct m0_conf_obj *obj = NULL;
1568  struct m0_conf_obj *obj_parent;
1569  struct m0_conf_controller *controller;
1570 
1571  M0_ENTRY();
1572 
1573  m0_mutex_lock(&tx->spt_lock);
1574  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1575  {fid, &M0_CONF_DRIVE_TYPE, &obj },
1576  {parent, &M0_CONF_CONTROLLER_TYPE, &obj_parent});
1577  if (rc != 0)
1578  goto fail;
1579 
1580  controller = M0_CONF_CAST(obj_parent, m0_conf_controller);
1581  if (controller->cc_drives == NULL) {
1582  /* Parent dir does not exist ==> create it. */
1583  rc = spiel_controller_dirs_create(controller);
1584  if (rc != 0)
1585  goto fail;
1586  }
1587  m0_conf_dir_add(controller->cc_drives, obj);
1588  obj->co_status = M0_CS_READY;
1589 
1591  m0_mutex_unlock(&tx->spt_lock);
1592  return M0_RC(0);
1593 fail:
1594  if (obj != NULL && rc != -EEXIST)
1596  m0_mutex_unlock(&tx->spt_lock);
1597  return M0_ERR(rc);
1598 }
1599 M0_EXPORTED(m0_spiel_drive_add);
1600 
1602  const struct m0_fid *fid,
1603  const struct m0_fid *parent,
1604  const struct m0_pdclust_attr *attrs,
1605  uint32_t *tolerance,
1606  uint32_t tolerance_len)
1607 {
1608  int rc;
1609  struct m0_conf_obj *obj = NULL;
1610  struct m0_conf_pver *pver = NULL;
1611  struct m0_conf_obj *obj_parent;
1612  struct m0_conf_pool *pool;
1613 
1614  M0_ENTRY();
1615 
1616  if (tolerance_len != M0_CONF_PVER_HEIGHT)
1617  return M0_ERR(-EINVAL);
1618  if (!m0_pdclust_attr_check(attrs))
1619  return M0_ERR(-EINVAL);
1620 
1621  m0_mutex_lock(&tx->spt_lock);
1622 
1623  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1624  {fid, &M0_CONF_PVER_TYPE, &obj},
1625  {parent, &M0_CONF_POOL_TYPE, &obj_parent});
1626  if (rc != 0)
1627  goto fail;
1628 
1630  pver->pv_kind = M0_CONF_PVER_ACTUAL;
1631  memcpy(pver->pv_u.subtree.pvs_tolerance, tolerance,
1632  M0_CONF_PVER_HEIGHT * sizeof(*tolerance));
1633  pver->pv_u.subtree.pvs_attr = *attrs;
1634 
1636  if (rc != 0)
1637  goto fail;
1638  pool = M0_CONF_CAST(obj_parent, m0_conf_pool);
1639  if (pool->pl_pvers == NULL) {
1640  /* Parent dir does not exist ==> create it. */
1642  if (rc != 0)
1643  goto fail;
1644  }
1645  m0_conf_dir_add(pool->pl_pvers, obj);
1646  obj->co_status = M0_CS_READY;
1647 
1649  m0_mutex_unlock(&tx->spt_lock);
1650  return M0_RC(0);
1651 fail:
1652  if (obj != NULL && rc != -EEXIST)
1654  m0_mutex_unlock(&tx->spt_lock);
1655  return M0_ERR(rc);
1656 }
1657 M0_EXPORTED(m0_spiel_pver_actual_add);
1658 
1660  const struct m0_fid *fid,
1661  const struct m0_fid *parent,
1662  uint32_t index,
1663  const struct m0_fid *base_pver,
1664  uint32_t *allowance,
1665  uint32_t allowance_len)
1666 {
1667  int rc;
1668  struct m0_conf_obj *obj = NULL;
1669  struct m0_conf_obj *base_obj = NULL;
1670  struct m0_conf_pver *pver = NULL;
1671  struct m0_conf_obj *obj_parent;
1672  struct m0_conf_pool *pool;
1673 
1674  M0_ENTRY();
1675 
1676  if (allowance_len != M0_CONF_PVER_HEIGHT)
1677  return M0_ERR(-EINVAL);
1678  m0_mutex_lock(&tx->spt_lock);
1679 
1680  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1681  {fid, &M0_CONF_PVER_TYPE, &obj},
1682  {base_pver, &M0_CONF_PVER_TYPE, &base_obj},
1683  {parent, &M0_CONF_POOL_TYPE, &obj_parent});
1684  if (rc != 0)
1685  goto fail;
1686 
1688  pver->pv_kind = M0_CONF_PVER_FORMULAIC;
1689  memcpy(pver->pv_u.formulaic.pvf_allowance, allowance,
1690  M0_CONF_PVER_HEIGHT * sizeof(*allowance));
1691  pver->pv_u.formulaic.pvf_id = index;
1692  pver->pv_u.formulaic.pvf_base = *base_pver;
1693 
1694  pool = M0_CONF_CAST(obj_parent, m0_conf_pool);
1695  if (pool->pl_pvers == NULL) {
1696  /* Parent dir does not exist ==> create it. */
1698  if (rc != 0)
1699  goto fail;
1700  }
1701 
1702  m0_conf_dir_add(pool->pl_pvers, obj);
1703  obj->co_status = M0_CS_READY;
1704 
1706  m0_mutex_unlock(&tx->spt_lock);
1707  return M0_RC(0);
1708 fail:
1709  if (obj != NULL && rc != -EEXIST)
1711  m0_mutex_unlock(&tx->spt_lock);
1712  return M0_ERR(rc);
1713 }
1714 M0_EXPORTED(m0_spiel_pver_formulaic_add);
1715 
1717  const struct m0_fid *fid,
1718  const struct m0_fid *parent,
1719  const struct m0_fid *real)
1720 {
1721  int rc;
1722  struct m0_conf_obj *obj = NULL;
1723  struct m0_conf_objv *objv;
1724  struct m0_conf_obj *obj_parent;
1725  struct m0_conf_pver *pver;
1726  struct m0_conf_obj *real_obj;
1727 
1728  M0_ENTRY();
1729 
1730  real_obj = m0_conf_cache_lookup(&tx->spt_cache, real);
1731  if (real_obj == NULL)
1732  return M0_ERR(-ENOENT);
1733 
1734  m0_mutex_lock(&tx->spt_lock);
1735  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1736  {fid, &M0_CONF_OBJV_TYPE, &obj },
1737  {parent, &M0_CONF_PVER_TYPE, &obj_parent},
1738  {real, &M0_CONF_SITE_TYPE, &real_obj});
1739  if (rc != 0)
1740  goto fail;
1741 
1742  objv = M0_CONF_CAST(obj, m0_conf_objv);
1743  objv->cv_real = real_obj;
1744  rc = spiel_sitev_dirs_create(objv);
1745  if (rc != 0)
1746  goto fail;
1747  pver = M0_CONF_CAST(obj_parent, m0_conf_pver);
1748  if (pver->pv_u.subtree.pvs_sitevs == NULL) {
1749  /* Parent dir does not exist ==> create it. */
1751  if (rc != 0)
1752  goto fail;
1753  }
1754  m0_conf_dir_add(pver->pv_u.subtree.pvs_sitevs, obj);
1755  obj->co_status = M0_CS_READY;
1756 
1758  m0_mutex_unlock(&tx->spt_lock);
1759  return M0_RC(0);
1760 fail:
1761  if (obj != NULL && rc != -EEXIST)
1763  m0_mutex_unlock(&tx->spt_lock);
1764  return M0_ERR(rc);
1765 }
1766 M0_EXPORTED(m0_spiel_site_v_add);
1767 
1769  const struct m0_fid *fid,
1770  const struct m0_fid *parent,
1771  const struct m0_fid *real)
1772 {
1773  int rc;
1774  struct m0_conf_obj *obj = NULL;
1775  struct m0_conf_objv *objv;
1776  struct m0_conf_obj *obj_parent;
1777  struct m0_conf_objv *objv_parent;
1778  struct m0_conf_obj *real_obj;
1779 
1780  M0_ENTRY();
1781 
1782  m0_mutex_lock(&tx->spt_lock);
1783  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1784  {fid, &M0_CONF_OBJV_TYPE, &obj },
1785  {parent, &M0_CONF_OBJV_TYPE, &obj_parent},
1786  {real, &M0_CONF_RACK_TYPE, &real_obj});
1787  if (rc != 0)
1788  goto fail;
1789 
1790  objv = M0_CONF_CAST(obj, m0_conf_objv);
1791  objv->cv_real = real_obj;
1792  rc = spiel_rackv_dirs_create(objv);
1793  if (rc != 0)
1794  goto fail;
1795  objv_parent = M0_CONF_CAST(obj_parent, m0_conf_objv);
1796  if (objv_parent->cv_children == NULL) {
1797  /* Parent dir does not exist ==> create it. */
1798  rc = spiel_sitev_dirs_create(objv_parent);
1799  if (rc != 0)
1800  goto fail;
1801  }
1802  m0_conf_dir_add(objv_parent->cv_children, obj);
1803  obj->co_status = M0_CS_READY;
1804 
1806  m0_mutex_unlock(&tx->spt_lock);
1807  return M0_RC(0);
1808 fail:
1809  if (obj != NULL && rc != -EEXIST)
1811  m0_mutex_unlock(&tx->spt_lock);
1812  return M0_ERR(rc);
1813 }
1814 M0_EXPORTED(m0_spiel_rack_v_add);
1815 
1817  const struct m0_fid *fid,
1818  const struct m0_fid *parent,
1819  const struct m0_fid *real)
1820 {
1821  int rc;
1822  struct m0_conf_obj *obj = NULL;
1823  struct m0_conf_objv *objv;
1824  struct m0_conf_obj *obj_parent;
1825  struct m0_conf_objv *objv_parent;
1826  struct m0_conf_obj *real_obj;
1827 
1828  M0_ENTRY();
1829 
1830  m0_mutex_lock(&tx->spt_lock);
1831  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1832  {fid, &M0_CONF_OBJV_TYPE, &obj },
1833  {parent, &M0_CONF_OBJV_TYPE, &obj_parent},
1834  {real, &M0_CONF_ENCLOSURE_TYPE, &real_obj});
1835  if (rc != 0)
1836  goto fail;
1837 
1838  objv = M0_CONF_CAST(obj, m0_conf_objv);
1839  objv->cv_real = real_obj;
1841  if (rc != 0)
1842  goto fail;
1843  objv_parent = M0_CONF_CAST(obj_parent, m0_conf_objv);
1844  if (objv_parent->cv_children == NULL) {
1845  /* Parent dir does not exist ==> create it. */
1846  rc = spiel_rackv_dirs_create(objv_parent);
1847  if (rc != 0)
1848  goto fail;
1849  }
1850  m0_conf_dir_add(objv_parent->cv_children, obj);
1851  obj->co_status = M0_CS_READY;
1852 
1854  m0_mutex_unlock(&tx->spt_lock);
1855  return M0_RC(0);
1856 fail:
1857  if (obj != NULL && rc != -EEXIST)
1859  m0_mutex_unlock(&tx->spt_lock);
1860  return M0_ERR(rc);
1861 }
1862 M0_EXPORTED(m0_spiel_enclosure_v_add);
1863 
1865  const struct m0_fid *fid,
1866  const struct m0_fid *parent,
1867  const struct m0_fid *real)
1868 {
1869  int rc;
1870  struct m0_conf_obj *obj = NULL;
1871  struct m0_conf_objv *objv;
1872  struct m0_conf_obj *obj_parent;
1873  struct m0_conf_objv *objv_parent;
1874  struct m0_conf_obj *real_obj;
1875 
1876  M0_ENTRY();
1877 
1878  m0_mutex_lock(&tx->spt_lock);
1879  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1880  {fid, &M0_CONF_OBJV_TYPE, &obj },
1881  {parent, &M0_CONF_OBJV_TYPE, &obj_parent},
1882  {real, &M0_CONF_CONTROLLER_TYPE, &real_obj});
1883  if (rc != 0)
1884  goto fail;
1885 
1886  objv = M0_CONF_CAST(obj, m0_conf_objv);
1887  objv->cv_real = real_obj;
1889  if (rc != 0)
1890  goto fail;
1891  objv_parent = M0_CONF_CAST(obj_parent, m0_conf_objv);
1892  if (objv_parent->cv_children == NULL) {
1893  /* Parent dir does not exist ==> create it. */
1894  rc = spiel_enclosurev_dirs_create(objv_parent);
1895  if (rc != 0)
1896  goto fail;
1897  }
1898  m0_conf_dir_add(objv_parent->cv_children, obj);
1899  obj->co_status = M0_CS_READY;
1900 
1902  m0_mutex_unlock(&tx->spt_lock);
1903  return M0_RC(0);
1904 fail:
1905  if (obj != NULL && rc != -EEXIST)
1907  m0_mutex_unlock(&tx->spt_lock);
1908  return M0_ERR(rc);
1909 }
1910 M0_EXPORTED(m0_spiel_controller_v_add);
1911 
1913  const struct m0_fid *fid,
1914  const struct m0_fid *parent,
1915  const struct m0_fid *real)
1916 {
1917  int rc;
1918  struct m0_conf_obj *obj = NULL;
1919  struct m0_conf_objv *objv;
1920  struct m0_conf_obj *obj_parent;
1921  struct m0_conf_objv *objv_parent;
1922  struct m0_conf_obj *real_obj;
1923 
1924  M0_ENTRY();
1925 
1926  m0_mutex_lock(&tx->spt_lock);
1927  rc = SPIEL_CONF_CHECK(&tx->spt_cache,
1928  {fid, &M0_CONF_OBJV_TYPE, &obj },
1929  {parent, &M0_CONF_OBJV_TYPE, &obj_parent},
1930  {real, &M0_CONF_DRIVE_TYPE, &real_obj});
1931  if (rc != 0)
1932  goto fail;
1933 
1934  objv = M0_CONF_CAST(obj, m0_conf_objv);
1935  objv->cv_real = real_obj;
1936 
1937  objv_parent = M0_CONF_CAST(obj_parent, m0_conf_objv);
1938  if (objv_parent->cv_children == NULL) {
1939  /* Parent dir does not exist ==> create it. */
1940  rc = spiel_controllerv_dirs_create(objv_parent);
1941  if (rc != 0)
1942  goto fail;
1943  }
1944  m0_conf_dir_add(objv_parent->cv_children, obj);
1945  obj->co_status = M0_CS_READY;
1946 
1948  m0_mutex_unlock(&tx->spt_lock);
1949  return M0_RC(0);
1950 fail:
1951  if (obj != NULL && rc != -EEXIST)
1953  m0_mutex_unlock(&tx->spt_lock);
1954  return M0_ERR(rc);
1955 }
1956 M0_EXPORTED(m0_spiel_drive_v_add);
1957 
1958 static int spiel_pver_add(struct m0_conf_obj **obj_v, struct m0_conf_pver *pver)
1959 {
1960  struct m0_conf_obj *obj;
1961  const struct m0_conf_obj_type *obj_type;
1962  struct m0_conf_pver **pvers;
1963  struct m0_conf_pver **pvers_new;
1964  unsigned nr_pvers;
1965 
1966  M0_ENTRY();
1967  /*
1968  * XXX TODO: pver->pv_u.subtree.pvs_tolerance should be validated.
1969  * m0_fd_tolerance_check() performs the validation, but it requires
1970  * m0_confc, which spiel_pver_add() does not have access to
1971  * (tx->spt_cache does not belong to any confc instance). We might
1972  * need to rewrite m0_fd_tolerance_check() to not use confc and work
1973  * with m0_conf_cache only.
1974  */
1975  obj = M0_CONF_CAST(*obj_v, m0_conf_objv)->cv_real;
1977  pvers = m0_conf_pvers(obj);
1978  for (nr_pvers = 0; pvers != NULL && pvers[nr_pvers] != NULL; ++nr_pvers)
1979  /* count the elements */;
1980 
1981  /* Element count = old count + new + finish NULL */
1982  M0_ALLOC_ARR(pvers_new, nr_pvers + 2);
1983  if (pvers_new == NULL || M0_FI_ENABLED("fail_allocation"))
1984  return M0_ERR(-ENOMEM);
1985  memcpy(pvers_new, pvers, nr_pvers * sizeof(*pvers));
1986  pvers_new[nr_pvers] = pver;
1987 
1988  if (obj_type == &M0_CONF_SITE_TYPE)
1989  M0_CONF_CAST(obj, m0_conf_site)->ct_pvers = pvers_new;
1990  else if (obj_type == &M0_CONF_RACK_TYPE)
1991  M0_CONF_CAST(obj, m0_conf_rack)->cr_pvers = pvers_new;
1992  else if (obj_type == &M0_CONF_ENCLOSURE_TYPE)
1993  M0_CONF_CAST(obj, m0_conf_enclosure)->ce_pvers = pvers_new;
1994  else if (obj_type == &M0_CONF_CONTROLLER_TYPE)
1995  M0_CONF_CAST(obj, m0_conf_controller)->cc_pvers = pvers_new;
1996  else if (obj_type == &M0_CONF_DRIVE_TYPE)
1997  M0_CONF_CAST(obj, m0_conf_drive)->ck_pvers = pvers_new;
1998  else
1999  M0_IMPOSSIBLE("");
2000 
2001  m0_free(pvers);
2002  return M0_RC(0);
2003 }
2004 
2011 static int spiel_pver_delete(struct m0_conf_obj *obj,
2012  const struct m0_conf_pver *pver)
2013 {
2014  struct m0_conf_pver **pvers = m0_conf_pvers(obj);
2015  unsigned i;
2016  bool found = false;
2017 
2018  M0_ENTRY();
2019  M0_PRE(pver != NULL);
2020 
2021  if (pvers == NULL)
2022  return M0_ERR(-ENOENT);
2023 
2024  for (i = 0; pvers[i] != NULL; ++i) {
2025  if (pvers[i] == pver)
2026  found = true;
2027  if (found)
2028  pvers[i] = pvers[i + 1];
2029  }
2030  return M0_RC(found ? 0 : -ENOENT);
2031 }
2032 
2033 static int spiel_objv_remove(struct m0_conf_obj **obj,
2034  struct m0_conf_pver *pver)
2035 {
2036  struct m0_conf_objv *objv = M0_CONF_CAST(*obj, m0_conf_objv);
2037 
2038  if (objv->cv_children != NULL)
2039  m0_conf_cache_del((*obj)->co_cache, &objv->cv_children->cd_obj);
2040  m0_conf_obj_put(*obj);
2041  m0_conf_dir_tlist_del(*obj);
2042  m0_conf_cache_del((*obj)->co_cache, *obj);
2043  *obj = NULL;
2044  return M0_RC(0);
2045 }
2046 
2048  struct m0_conf_pver *pver,
2049  int (*action)(struct m0_conf_obj**,
2050  struct m0_conf_pver*))
2051 {
2052  int rc;
2053  struct m0_conf_obj *entry;
2054  struct m0_conf_objv *objv;
2055 
2056  m0_conf_obj_get(dir); /* required by ->coo_readdir() */
2057  for (entry = NULL; (rc = dir->co_ops->coo_readdir(dir, &entry)) > 0; ) {
2058  /* All configuration is expected to be available. */
2060 
2061  objv = M0_CONF_CAST(entry, m0_conf_objv);
2062  rc = objv->cv_children == NULL ? 0 :
2064  action);
2065  rc = rc ?: action(&entry, pver);
2066  if (rc != 0) {
2067  m0_conf_obj_put(entry);
2068  break;
2069  }
2070  }
2072  return M0_RC(rc);
2073 }
2074 
2076  const struct m0_fid *fid)
2077 {
2078  int rc;
2079  struct m0_conf_pver *pver;
2080 
2081  M0_ENTRY();
2082 
2083  m0_mutex_lock(&tx->spt_lock);
2085  m0_conf_pver);
2086  M0_ASSERT(pver != NULL);
2087  rc = spiel_pver_iterator(&pver->pv_u.subtree.pvs_sitevs->cd_obj, pver,
2088  &spiel_pver_add);
2089  if (rc != 0) {
2090  spiel_pver_iterator(&pver->pv_u.subtree.pvs_sitevs->cd_obj,
2092  /*
2093  * TODO: Remove this line once m0_spiel_element_del removes
2094  * the object itself and all its m0_conf_dir members.
2095  */
2097  &pver->pv_u.subtree.pvs_sitevs->cd_obj);
2098 
2099  m0_mutex_unlock(&tx->spt_lock);
2101  } else {
2102  m0_mutex_unlock(&tx->spt_lock);
2103  }
2104  return M0_RC(rc);
2105 }
2106 M0_EXPORTED(m0_spiel_pool_version_done);
2107 
2109  struct m0_conf_pver *pver)
2110 {
2111  struct m0_conf_obj *obj;
2112 
2113  M0_ENTRY();
2114  m0_tl_for (m0_conf_cache, &cache->ca_registry, obj) {
2115  if (M0_IN(m0_conf_obj_type(obj),
2118  &M0_CONF_DRIVE_TYPE)))
2120  } m0_tl_endfor;
2121  M0_LEAVE();
2122 }
2123 
2124 int m0_spiel_element_del(struct m0_spiel_tx *tx, const struct m0_fid *fid)
2125 {
2126  int rc = 0;
2127  struct m0_conf_obj *obj;
2128 
2129  M0_ENTRY();
2130 
2131  m0_mutex_lock(&tx->spt_lock);
2133  if (obj != NULL) {
2137  m0_conf_dir_tlist_del(obj);
2139  }
2140  m0_mutex_unlock(&tx->spt_lock);
2141  return M0_RC(rc);
2142 }
2143 M0_EXPORTED(m0_spiel_element_del);
2144 
2145 static int spiel_str_to_file(char *str, const char *filename)
2146 {
2147 #ifdef __KERNEL__
2148  return 0;
2149 #else
2150  int rc;
2151  FILE *file;
2152 
2153  file = fopen(filename, "w+");
2154  if (file == NULL)
2155  return -errno;
2156  rc = fwrite(str, strlen(str), 1, file) == 1 ? 0 : -EINVAL;
2157  fclose(file);
2158  return rc;
2159 #endif
2160 }
2161 
2162 static int spiel_tx_to_str(struct m0_spiel_tx *tx,
2163  uint64_t ver_forced,
2164  char **str,
2165  bool debug)
2166 {
2167  M0_ENTRY();
2168  M0_PRE(ver_forced != M0_CONF_VER_UNKNOWN);
2169 
2170  return M0_RC(spiel_root_ver_update(tx, ver_forced) ?:
2171  m0_conf_cache_to_string(&tx->spt_cache, str, debug));
2172 }
2173 
2175  uint64_t ver_forced,
2176  char **str)
2177 {
2178  return spiel_tx_to_str(tx, ver_forced, str, false);
2179 }
2180 M0_EXPORTED(m0_spiel_tx_to_str);
2181 
2182 void m0_spiel_tx_str_free(char *str)
2183 {
2184  m0_confx_string_free(str);
2185 }
2186 M0_EXPORTED(m0_spiel_tx_str_free);
2187 
2188 static int spiel_tx_dump(struct m0_spiel_tx *tx,
2189  uint64_t ver_forced,
2190  const char *filename,
2191  bool debug)
2192 {
2193  int rc;
2194  char *buffer;
2195 
2196  M0_ENTRY();
2197  rc = spiel_tx_to_str(tx, ver_forced, &buffer, debug);
2198  if (rc == 0) {
2201  }
2202  return M0_RC(rc);
2203 }
2204 
2205 int m0_spiel_tx_dump(struct m0_spiel_tx *tx, uint64_t ver_forced,
2206  const char *filename)
2207 {
2208  return M0_RC(spiel_tx_dump(tx, ver_forced, filename, false));
2209 }
2210 M0_EXPORTED(m0_spiel_tx_dump);
2211 
2212 int m0_spiel_tx_dump_debug(struct m0_spiel_tx *tx, uint64_t ver_forced,
2213  const char *filename)
2214 {
2215  return M0_RC(spiel_tx_dump(tx, ver_forced, filename, true));
2216 }
2217 M0_EXPORTED(m0_spiel_tx_dump_debug);
2218 
2220 #undef M0_TRACE_SUBSYSTEM
2221 
2222 /*
2223  * Local variables:
2224  * c-indentation-style: "K&R"
2225  * c-basic-offset: 8
2226  * tab-width: 8
2227  * fill-column: 80
2228  * scroll-step: 1
2229  * End:
2230  */
static int spiel_rack_dirs_create(struct m0_conf_rack *rack)
Definition: conf_mgmt.c:800
static m0_bcount_t seg_size
Definition: net.c:118
const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
Definition: obj.c:363
static int spiel_process_dirs_create(struct m0_conf_process *process)
Definition: conf_mgmt.c:760
int m0_spiel_pver_formulaic_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, uint32_t index, const struct m0_fid *base_pver, uint32_t *allowance, uint32_t allowance_len)
Definition: conf_mgmt.c:1659
const char * sd_filename
Definition: obj.h:649
M0_INTERNAL m0_bcount_t m0_net_domain_get_max_buffer_segment_size(struct m0_net_domain *dom)
Definition: beck.c:235
static void wlock_ctx_creditor_setup(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:465
static struct m0_mutex lock
Definition: transmit.c:326
struct m0_fid rt_rootfid
Definition: obj.h:392
static bool spiel_cores_is_valid(const struct m0_bitmap *cores)
Definition: conf_mgmt.c:1027
static int spiel_site_dirs_create(struct m0_conf_site *site)
Definition: conf_mgmt.c:789
const char * pc_endpoint
Definition: obj.h:590
#define M0_PRE(cond)
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
static int spiel_load_fop_send(struct m0_spiel_tx *tx, struct m0_spiel_load_command *spiel_cmd)
Definition: conf_mgmt.c:291
const struct m0_conf_obj_type M0_CONF_OBJV_TYPE
Definition: objv.c:151
M0_INTERNAL const char ** m0_strings_dup(const char **src)
Definition: string.c:55
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
M0_INTERNAL struct m0_fop_conf_load * m0_conf_fop_to_load_fop(const struct m0_fop *fop)
Definition: load_fop.c:47
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
static void wlock_ctx_semaphore_down(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:504
int m0_spiel_tx_dump_debug(struct m0_spiel_tx *tx, uint64_t ver_forced, const char *filename)
Definition: conf_mgmt.c:2212
#define m0_strdup(s)
Definition: string.h:43
struct m0_conf_obj ce_obj
Definition: obj.h:680
int const char const void size_t int flags
Definition: dir.c:328
int m0_spiel_tx_commit(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:723
int32_t wlc_rc
Definition: wlock_helper.c:54
struct m0_rw_lockable wlc_rwlock
Definition: wlock_helper.c:36
#define NULL
Definition: misc.h:38
struct m0_rpc_session slc_session
Definition: conf_mgmt.h:97
const struct m0_conf_obj_type M0_CONF_PROFILE_TYPE
Definition: profile.c:97
static void _spiel_tx_write_lock_get(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:480
static struct m0_rm_remote creditor
Definition: file.c:95
M0_INTERNAL int m0_rpc_bulk_store(struct m0_rpc_bulk *rbulk, const struct m0_rpc_conn *conn, struct m0_net_buf_desc_data *to_desc, const struct m0_net_buffer_callbacks *bulk_cb)
Definition: bulk.c:520
int m0_spiel_tx_validate(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:136
struct m0_rm_remote * ro_creditor
Definition: rm.h:1026
int m0_spiel_service_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_spiel_service_info *service_info)
Definition: conf_mgmt.c:1101
static int spiel_str_to_file(char *str, const char *filename)
Definition: conf_mgmt.c:2145
int m0_spiel_profile_add(struct m0_spiel_tx *tx, const struct m0_fid *fid)
Definition: conf_mgmt.c:1236
int m0_spiel_pool_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, uint32_t pver_policy)
Definition: conf_mgmt.c:1339
static void spiel_tx_write_lock_complete(struct m0_rm_incoming *in, int32_t rc)
Definition: conf_mgmt.c:444
struct m0_conf_obj cd_obj
Definition: obj.h:358
const struct m0_conf_obj_type M0_CONF_SITE_TYPE
Definition: site.c:121
void(* rio_complete)(struct m0_rm_incoming *in, int32_t rc)
Definition: rm.h:1493
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
static struct io_request req
Definition: file.c:100
struct m0_fop slc_flip_fop
Definition: conf_mgmt.h:91
struct m0_file file
Definition: di.c:36
uint64_t pc_memlimit_memlock
Definition: obj.h:588
#define m0_count(var, nr,...)
Definition: misc.h:79
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
Definition: cache.c:106
#define M0_CFG_SDEV_INTERFACE_TYPE_IS_VALID(dtype)
Definition: schema.h:131
M0_INTERNAL void m0_conf_dir_add(struct m0_conf_dir *dir, struct m0_conf_obj *obj)
Definition: dir.c:43
M0_INTERNAL void m0_fop_init(struct m0_fop *fop, struct m0_fop_type *fopt, void *data, void(*fop_release)(struct m0_ref *))
Definition: fop.c:79
M0_INTERNAL int m0_rpc_bulk_buf_databuf_add(struct m0_rpc_bulk_buf *rbuf, void *buf, m0_bcount_t count, m0_bindex_t index, struct m0_net_domain *netdom)
Definition: bulk.c:331
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
const struct m0_conf_obj_type * m0_conf_fid_type(const struct m0_fid *fid)
Definition: obj.c:368
#define min_check(a, b)
Definition: arith.h:88
const struct m0_conf_obj_type M0_CONF_PVER_TYPE
Definition: pver.c:260
const struct m0_conf_obj_type M0_CONF_SERVICE_TYPE
Definition: service.c:156
Definition: beck.c:189
M0_INTERNAL void m0_confx_string_free(char *str)
Definition: preload.c:86
static struct net_test_cmd_node * node
Definition: commands.c:72
void m0_spiel_tx_str_free(char *str)
Definition: conf_mgmt.c:2182
M0_INTERNAL void m0_rm_rwlock_req_init(struct m0_rm_incoming *req, struct m0_rm_owner *owner, const struct m0_rm_incoming_ops *ops, enum m0_rm_incoming_flags flags, enum m0_rm_rwlock_req_type type)
Definition: rm_rwlock.c:548
static int spiel_pool_dirs_create(struct m0_conf_pool *pool)
Definition: conf_mgmt.c:778
static uint64_t spiel_root_conf_version(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:186
static void _spiel_tx_write_lock_put(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:562
M0_INTERNAL void m0_rpc_bulk_fini(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:263
static int spiel_node_dirs_create(struct m0_conf_node *node)
Definition: conf_mgmt.c:751
int m0_rpc_session_destroy(struct m0_rpc_session *session, m0_time_t abs_timeout)
Definition: session.c:559
int m0_spiel_pool_version_done(struct m0_spiel_tx *tx, const struct m0_fid *fid)
Definition: conf_mgmt.c:2075
const struct m0_conf_obj_type M0_CONF_SDEV_TYPE
Definition: sdev.c:122
uint32_t rc_quorum
Definition: rconfc.h:258
M0_INTERNAL void m0_conf_obj_put(struct m0_conf_obj *obj)
Definition: obj_ops.c:205
void m0_spiel_rconfc_stop(struct m0_spiel *spiel)
Definition: spiel.c:91
int m0_spiel_root_add(struct m0_spiel_tx *tx, const struct m0_fid *rootfid, const struct m0_fid *mdpool, const struct m0_fid *imeta_pver, uint32_t mdredundancy, const char **params)
Definition: conf_mgmt.c:902
struct m0_net_domain * ntm_dom
Definition: net.h:853
static int spiel_pver_iterator(struct m0_conf_obj *dir, struct m0_conf_pver *pver, int(*action)(struct m0_conf_obj **, struct m0_conf_pver *))
Definition: conf_mgmt.c:2047
static void wlock_ctx_creditor_unset(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:494
const struct m0_conf_obj_type M0_CONF_ROOT_TYPE
Definition: root.c:214
const char ** svi_endpoints
Definition: spiel.h:445
const struct m0_conf_obj_type M0_CONF_POOL_TYPE
Definition: pool.c:249
static int spiel_service_dirs_create(struct m0_conf_service *service)
Definition: conf_mgmt.c:769
#define m0_exists(var, nr,...)
Definition: misc.h:134
#define M0_BITS(...)
Definition: misc.h:236
M0_INTERNAL void m0_rm_remote_init(struct m0_rm_remote *rem, struct m0_rm_resource *res)
Definition: rm.c:1411
uint64_t m0_bcount_t
Definition: types.h:77
uint64_t sd_flags
Definition: obj.h:647
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
static char * prof
Definition: st_kmain.c:50
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
struct m0_rpc_session * rem_session
Definition: rm.h:755
M0_INTERNAL struct m0_conf_pver ** m0_conf_pvers(const struct m0_conf_obj *obj)
Definition: helpers.c:400
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
Definition: fid.c:106
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
static int struct dentry int struct nameidata * nd
Definition: dir.c:593
M0_INTERNAL void m0_rw_lockable_fini(struct m0_rw_lockable *lockable)
Definition: rm_rwlock.c:523
static struct foo * obj
Definition: tlist.c:302
static void spiel_tx_write_lock_put(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:576
M0_INTERNAL int m0_rm_owner_timedwait(struct m0_rm_owner *owner, uint64_t state, const m0_time_t abs_timeout)
Definition: rm.c:892
const struct m0_conf_obj_type M0_CONF_CONTROLLER_TYPE
Definition: controller.c:131
int m0_spiel_tx_commit_forced(struct m0_spiel_tx *tx, bool forced, uint64_t ver_forced, uint32_t *rquorum)
Definition: conf_mgmt.c:591
M0_INTERNAL void m0_rpc_bulk_buflist_empty(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:279
static void spiel_load_fop_fini(struct m0_spiel_load_command *spiel_cmd)
Definition: conf_mgmt.c:206
struct m0_fop slc_load_fop
Definition: conf_mgmt.h:89
#define m0_tl_endfor
Definition: tlist.h:700
struct m0_fid fid
Definition: di.c:46
uint64_t pc_memlimit_as
Definition: obj.h:585
void m0_spiel_tx_close(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:171
struct m0_sm c_sm
Definition: conn.h:322
static int spiel_root_ver_update(struct m0_spiel_tx *tx, uint64_t verno)
Definition: conf_mgmt.c:84
return M0_RC(rc)
uint32_t sd_media
Definition: obj.h:639
struct m0_fop_type m0_fop_conf_load_fopt
Definition: fop.c:58
struct m0_rpc_machine * wlc_rmach
Definition: wlock_helper.c:31
int m0_spiel_site_add(struct m0_spiel_tx *tx, const struct m0_fid *fid)
Definition: conf_mgmt.c:1382
M0_INTERNAL int m0_rconfc_rm_endpoint(struct m0_rconfc *rconfc, char **ep)
Definition: rconfc.c:3106
static int spiel_enclosure_dirs_create(struct m0_conf_enclosure *enclosure)
Definition: conf_mgmt.c:809
M0_TL_DESCR_DECLARE(rpcbulk, M0_EXTERN)
struct m0_conf_dir * ce_ctrls
Definition: obj.h:684
#define M0_ENTRY(...)
Definition: trace.h:170
struct m0_rpc_bulk slc_rbulk
Definition: conf_mgmt.h:93
M0_INTERNAL void m0_rm_rwlock_owner_init(struct m0_rm_owner *owner, struct m0_fid *fid, struct m0_rw_lockable *lockable, struct m0_rm_remote *creditor)
Definition: rm_rwlock.c:532
static int spiel_objv_remove(struct m0_conf_obj **obj, struct m0_conf_pver *pver)
Definition: conf_mgmt.c:2033
M0_INTERNAL int m0_conf_dir_new(struct m0_conf_obj *parent, const struct m0_fid *relfid, const struct m0_conf_obj_type *children_type, const struct m0_fid_arr *children_ids, struct m0_conf_dir **out)
Definition: dir.c:159
uint32_t sd_dev_idx
Definition: obj.h:635
int i
Definition: dir.c:1033
M0_INTERNAL void m0_conf_obj_get(struct m0_conf_obj *obj)
Definition: obj_ops.c:186
struct m0_fop_type * f_type
Definition: fop.h:81
static void spiel_flip_fop_release(struct m0_ref *ref)
Definition: conf_mgmt.c:331
uint64_t pc_memlimit_stack
Definition: obj.h:587
static bool spiel_load_cmd_invariant(struct m0_spiel_load_command *cmd)
Definition: conf_mgmt.c:180
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
static void spiel_load_fop_release(struct m0_ref *ref)
Definition: conf_mgmt.c:218
static int spiel_load_fop_create(struct m0_spiel_tx *tx, struct m0_spiel_load_command *spiel_cmd)
Definition: conf_mgmt.c:256
struct m0_conf_root * root
Definition: note.c:50
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL int m0_rpc_client_connect(struct m0_rpc_conn *conn, struct m0_rpc_session *session, struct m0_rpc_machine *rpc_mach, const char *remote_addr, struct m0_fid *svc_fid, uint64_t max_rpcs_in_flight, m0_time_t abs_timeout)
Definition: rpclib.c:102
int m0_spiel_enclosure_v_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *real)
Definition: conf_mgmt.c:1816
Definition: trace.h:482
static void wlock_ctx_owner_windup(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:511
struct wlock_ctx wlx
static bool m0_conf_service_type_is_valid(enum m0_conf_service_type t)
Definition: schema.h:204
M0_INTERNAL void m0_rm_rwlock_owner_fini(struct m0_rm_owner *owner)
Definition: rm_rwlock.c:542
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
const struct m0_conf_obj_type M0_CONF_ENCLOSURE_TYPE
Definition: enclosure.c:140
Definition: refs.h:34
static int spiel_pver_add(struct m0_conf_obj **obj_v, struct m0_conf_pver *pver)
Definition: conf_mgmt.c:1958
static void wlock_ctx_semaphore_up(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:372
struct m0_fid rt_imeta_pver
Definition: obj.h:403
enum m0_net_queue_type nb_qtype
Definition: net.h:1363
int m0_spiel_drive_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent)
Definition: conf_mgmt.c:1562
int m0_spiel_tx_dump(struct m0_spiel_tx *tx, uint64_t ver_forced, const char *filename)
Definition: conf_mgmt.c:2205
struct m0_conf_dir * cc_drives
Definition: obj.h:697
struct m0_net_buffer * bb_nbuf
Definition: bulk.h:177
obj_type
Definition: rmut.h:35
#define m0_free0(pptr)
Definition: memory.h:77
struct m0_net_transfer_mc rm_tm
Definition: rpc_machine.h:88
#define M0_ASSERT(cond)
struct m0_semaphore wlc_sem
Definition: wlock_helper.c:42
M0_INTERNAL int m0_conf_cache_to_string(struct m0_conf_cache *cache, char **str, bool debug)
Definition: cache.c:257
struct m0_conf_dir * rt_nodes
Definition: obj.h:373
int m0_spiel_profile_pool_add(struct m0_spiel_tx *tx, const struct m0_fid *profile, const struct m0_fid *pool)
Definition: conf_mgmt.c:1304
M0_INTERNAL void m0_fid_tgenerate(struct m0_fid *fid, const uint8_t tid)
Definition: fid.c:155
M0_INTERNAL void m0_rpc_bulk_init(struct m0_rpc_bulk *rbulk)
Definition: bulk.c:247
static void wlock_ctx_destroy(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:405
struct m0_fid pver
Definition: idx_dix.c:74
M0_INTERNAL void m0_rw_lockable_init(struct m0_rw_lockable *lockable, const struct m0_fid *fid, struct m0_rm_domain *dom)
Definition: rm_rwlock.c:508
static void rconfc_fail(struct m0_rconfc *rconfc, int rc)
Definition: rconfc.c:1195
struct m0_net_buf_desc_data clf_desc
Definition: load_fop.h:101
#define SPIEL_CONF_CHECK(cache,...)
Definition: conf_mgmt.c:75
M0_INTERNAL void m0_conf_cache_init(struct m0_conf_cache *cache, struct m0_mutex *lock)
Definition: cache.c:66
int m0_spiel_element_del(struct m0_spiel_tx *tx, const struct m0_fid *fid)
Definition: conf_mgmt.c:2124
struct m0_conf_obj cv_obj
Definition: obj.h:544
int m0_rpc_conn_destroy(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:974
int m0_spiel_rack_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent)
Definition: conf_mgmt.c:1426
static int spiel_pver_dirs_create(struct m0_conf_pver *pver)
Definition: conf_mgmt.c:827
struct m0_mutex spt_lock
Definition: spiel.h:266
struct m0_rpc_item * ri_reply
Definition: item.h:163
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
static int spiel_flip_fop_send(struct m0_spiel_tx *tx, struct m0_spiel_load_command *spiel_cmd)
Definition: conf_mgmt.c:336
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
struct m0_conf_dir * rt_sites
Definition: obj.h:374
const char ** rt_params
Definition: obj.h:411
int m0_rpc_post_sync(struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
Definition: rpclib.c:284
Definition: fid.h:43
#define M0_POST(cond)
uint32_t rt_mdredundancy
Definition: obj.h:405
const struct m0_conf_obj_type M0_CONF_DRIVE_TYPE
Definition: drive.c:108
const struct m0_fid M0_RWLOCK_FID
Definition: rm_rwlock.c:596
int m0_spiel_enclosure_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *node)
Definition: conf_mgmt.c:1470
struct m0_bitmap pc_cores
Definition: obj.h:584
static struct m0_rpc_machine * spiel_rmachine(struct m0_spiel *spl)
struct m0_fid rt_mdpool
Definition: obj.h:394
int m0_spiel_pver_actual_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_pdclust_attr *attrs, uint32_t *tolerance, uint32_t tolerance_len)
Definition: conf_mgmt.c:1601
uint64_t clf_tx_id
Definition: load_fop.h:96
struct m0_rm_incoming wlc_req
Definition: conf_mgmt.h:63
struct m0_rm_owner wlc_owner
Definition: wlock_helper.c:37
M0_INTERNAL int m0_conf_obj_find(struct m0_conf_cache *cache, const struct m0_fid *id, struct m0_conf_obj **out)
Definition: obj_ops.c:136
static int spiel_tx_write_lock_get(struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:524
M0_INTERNAL int m0_fop_data_alloc(struct m0_fop *fop)
Definition: fop.c:71
uint64_t sd_size
Definition: obj.h:643
static const struct m0_fid fids[]
Definition: diter.c:76
uint64_t rt_verno
Definition: obj.h:390
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
struct m0_rm_incoming wlc_req
Definition: wlock_helper.c:40
int m0_spiel_controller_v_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *real)
Definition: conf_mgmt.c:1864
#define M0_CONF_CAST(ptr, type)
Definition: obj.h:780
struct m0_conf_sdev * ck_sdev
Definition: obj.h:710
M0_INTERNAL int m0_rwlockable_domain_type_init(struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
Definition: rm_rwlock.c:256
int m0_spiel_controller_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent)
Definition: conf_mgmt.c:1518
struct m0_conf_dir * rt_profiles
Definition: obj.h:376
int m0_spiel_device_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *drive, uint32_t dev_idx, enum m0_cfg_storage_device_interface_type iface, enum m0_cfg_storage_device_media_type media, uint32_t bsize, uint64_t size, uint64_t last_state, uint64_t flags, const char *filename)
Definition: conf_mgmt.c:1156
struct m0_conf_dir * rt_pools
Definition: obj.h:375
struct m0_conf_obj ** scp_obj
Definition: conf_mgmt.c:62
uint32_t cff_prev_version
Definition: flip_fop.h:83
#define FID_P(f)
Definition: fid.h:77
static int spiel_enclosurev_dirs_create(struct m0_conf_objv *objv)
Definition: conf_mgmt.c:858
static int spiel_controller_dirs_create(struct m0_conf_controller *controller)
Definition: conf_mgmt.c:818
struct m0_fid wlc_owner_fid
Definition: wlock_helper.c:38
m0_cfg_storage_device_media_type
Definition: schema.h:136
struct m0_conf_obj cc_obj
Definition: obj.h:695
struct m0_sm s_sm
Definition: session.h:325
static int spiel_root_dirs_create(struct m0_conf_root *r)
Definition: conf_mgmt.c:732
static int spiel_conf_parameter_check(struct m0_conf_cache *cache, struct spiel_conf_param *parameters)
Definition: conf_mgmt.c:875
static struct m0_pool pool
Definition: iter_ut.c:58
M0_INTERNAL void m0_bitmap_copy(struct m0_bitmap *dst, const struct m0_bitmap *src)
Definition: bitmap.c:158
const struct m0_conf_obj_type * scp_type
Definition: conf_mgmt.c:61
struct m0_conf_node * ce_node
Definition: obj.h:682
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
void m0_spiel_tx_open(struct m0_spiel *spiel, struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:105
M0_INTERNAL int m0_rconfc_confd_endpoints(struct m0_rconfc *rconfc, const char ***eps)
Definition: rconfc.c:3081
uint32_t cff_next_version
Definition: flip_fop.h:85
static void wlock_ctx_disconnect(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:428
struct m0_conf_obj pc_obj
Definition: obj.h:581
uint32_t sd_iface
Definition: obj.h:637
M0_INTERNAL void m0_rm_credit_put(struct m0_rm_incoming *in)
Definition: rm.c:1797
struct m0_conf_dir * pc_services
Definition: obj.h:582
struct m0_rpc_session wlc_sess
Definition: wlock_helper.c:33
static uint8_t fail[DATA_UNIT_COUNT_MAX+PARITY_UNIT_COUNT_MAX]
m0_cfg_storage_device_interface_type
Definition: schema.h:120
struct m0_rpc_conn slc_connect
Definition: conf_mgmt.h:95
static struct m0_fid profile
Definition: rconfc.c:49
static int wlock_ctx_semaphore_init(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:367
struct m0_conf_obj ct_obj
Definition: obj.h:654
static void spiel_tx_write_lock_conflict(struct m0_rm_incoming *in)
Definition: conf_mgmt.c:455
int m0_spiel_tx_to_str(struct m0_spiel_tx *tx, uint64_t ver_forced, char **str)
Definition: conf_mgmt.c:2174
uint64_t * b_words
Definition: bitmap.h:46
int m0_spiel_rack_v_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *real)
Definition: conf_mgmt.c:1768
int m0_spiel_rconfc_start(struct m0_spiel *spiel, m0_rconfc_cb_t expired_cb)
Definition: spiel.c:66
int m0_spiel_drive_v_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *real)
Definition: conf_mgmt.c:1912
int m0_spiel_process_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, struct m0_bitmap *cores, uint64_t memlimit_as, uint64_t memlimit_rss, uint64_t memlimit_stack, uint64_t memlimit_memlock, const char *endpoint)
Definition: conf_mgmt.c:1033
M0_INTERNAL void m0_strings_free(const char **arr)
Definition: string.c:45
struct m0_conf_cache spt_cache
Definition: spiel.h:264
static void spiel_rwlockable_write_domain_fini(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:70
#define M0_CNT_INC(cnt)
Definition: arith.h:226
#define M0_CFG_SDEV_MEDIA_TYPE_IS_VALID(dtype)
Definition: schema.h:151
static int spiel_sitev_dirs_create(struct m0_conf_objv *objv)
Definition: conf_mgmt.c:838
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
struct m0_ref f_ref
Definition: fop.h:80
Definition: fid.h:38
const struct m0_conf_obj_type M0_CONF_NODE_TYPE
Definition: node.c:128
static int confd_count(const struct m0_conf_service *service, struct m0_ha_entrypoint_rep *rep, uint32_t index)
Definition: ha.c:88
M0_INTERNAL void m0_rm_remote_fini(struct m0_rm_remote *rem)
Definition: rm.c:1431
#define M0_IS0(obj)
Definition: misc.h:70
struct m0_spiel * spt_spiel
Definition: spiel.h:262
M0_INTERNAL void m0_conf_cache_del(const struct m0_conf_cache *cache, struct m0_conf_obj *obj)
Definition: cache.c:124
static void spiel_pver_remove(struct m0_conf_cache *cache, struct m0_conf_pver *pver)
Definition: conf_mgmt.c:2108
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static int r[NR]
Definition: thread.c:46
uint32_t clfr_version
Definition: load_fop.h:86
static int spiel_load_fop_init(struct m0_spiel_load_command *spiel_cmd, struct m0_spiel_tx *tx)
Definition: conf_mgmt.c:232
const struct m0_fid M0_CONF_ROOT_FID
Definition: root.c:226
struct m0_spiel spiel
Definition: spiel_conf_ut.c:42
Definition: addb2.c:200
Definition: rm.h:863
uint32_t clf_version
Definition: load_fop.h:94
static int spiel_tx_dump(struct m0_spiel_tx *tx, uint64_t ver_forced, const char *filename, bool debug)
Definition: conf_mgmt.c:2188
M0_INTERNAL void m0_rm_owner_windup(struct m0_rm_owner *owner)
Definition: rm.c:930
int m0_spiel_node_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, uint32_t memsize, uint32_t nr_cpu, uint64_t last_state, uint64_t flags)
Definition: conf_mgmt.c:974
Definition: common.h:34
static int spiel_rwlockable_write_domain_init(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:65
m0_bcount_t size
Definition: di.c:39
#define _0C(exp)
Definition: assert.h:311
uint64_t cff_tx_id
Definition: flip_fop.h:87
struct m0_rm_resource_type wlc_rt
Definition: wlock_helper.c:52
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL uint64_t m0_rconfc_ver_max_read(struct m0_rconfc *rconfc)
Definition: rconfc.c:3052
void m0_fop_put_lock(struct m0_fop *fop)
Definition: fop.c:199
struct m0_fop_type m0_fop_conf_flip_fopt
Definition: fop.c:67
static struct m0_fop * fop
Definition: item.c:57
enum m0_conf_status co_status
Definition: obj.h:210
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
M0_INTERNAL void m0_rm_incoming_fini(struct m0_rm_incoming *in)
Definition: rm.c:1099
struct m0_conf_dir * cv_children
Definition: obj.h:545
struct m0_conf_dir * cr_encls
Definition: obj.h:669
M0_INTERNAL void m0_rm_owner_creditor_reset(struct m0_rm_owner *owner, struct m0_rm_remote *creditor)
Definition: rm.c:904
static int spiel_profile_pool_add(struct m0_conf_profile *prof, const struct m0_fid *pool)
Definition: conf_mgmt.c:1275
struct m0_rconfc spl_rconfc
Definition: spiel.h:213
static int spiel_rackv_dirs_create(struct m0_conf_objv *objv)
Definition: conf_mgmt.c:849
static uint64_t found
Definition: base.c:376
struct m0_rm_domain wlc_dom
Definition: wlock_helper.c:47
const struct m0_conf_obj_type M0_CONF_FDMI_FLT_GRP_TYPE
Definition: fdmi_flt_grp.c:151
struct m0_conf_dir * ct_racks
Definition: obj.h:656
enum m0_conf_service_type svi_type
Definition: spiel.h:440
struct m0_rm_remote wlc_creditor
Definition: wlock_helper.c:39
struct inode * dir
Definition: dir.c:1028
M0_INTERNAL void m0_conf_dir_del(struct m0_conf_dir *dir, struct m0_conf_obj *obj)
Definition: dir.c:53
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
const struct m0_conf_obj_type M0_CONF_PROCESS_TYPE
Definition: process.c:161
int m0_spiel_site_v_add(struct m0_spiel_tx *tx, const struct m0_fid *fid, const struct m0_fid *parent, const struct m0_fid *real)
Definition: conf_mgmt.c:1716
#define out(...)
Definition: gen.c:41
uint32_t sd_bsize
Definition: obj.h:641
M0_INTERNAL struct m0_fop_conf_flip * m0_conf_fop_to_flip_fop(const struct m0_fop *fop)
Definition: flip_fop.c:42
const struct m0_net_buffer_callbacks m0_rpc__buf_bulk_cb
Definition: bulk.c:238
size_t b_nr
Definition: bitmap.h:44
char * spt_buffer
Definition: spiel.h:272
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
static int wlock_ctx_create(struct m0_spiel *spl)
Definition: conf_mgmt.c:377
uint64_t sd_last_state
Definition: obj.h:645
struct m0_spiel_wlock_ctx * spl_wlock_ctx
Definition: spiel.h:215
M0_INTERNAL void m0_conf_cache_fini(struct m0_conf_cache *cache)
Definition: cache.c:183
static int spiel_pver_delete(struct m0_conf_obj *obj, const struct m0_conf_pver *pver)
Definition: conf_mgmt.c:2011
M0_INTERNAL int m0_rpc_bulk_buf_add(struct m0_rpc_bulk *rbulk, uint32_t segs_nr, m0_bcount_t length, struct m0_net_domain *netdom, struct m0_net_buffer *nb, struct m0_rpc_bulk_buf **out)
Definition: bulk.c:291
const struct m0_conf_obj_type M0_CONF_DIR_TYPE
Definition: dir.c:206
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL void m0_rwlockable_domain_type_fini(struct m0_rm_domain *rwl_dom, struct m0_rm_resource_type *rwl_rt)
Definition: rm_rwlock.c:267
Definition: mutex.h:47
uint64_t pc_memlimit_rss
Definition: obj.h:586
const struct m0_fid * scp_fid
Definition: conf_mgmt.c:60
struct m0_rpc_item f_item
Definition: fop.h:83
static int wlock_ctx_connect(struct m0_spiel_wlock_ctx *wlx)
Definition: conf_mgmt.c:416
uint32_t sm_state
Definition: sm.h:307
struct m0_rpc_conn wlc_conn
Definition: wlock_helper.c:32
struct m0_conf_obj cr_obj
Definition: obj.h:667
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
int32_t rc
Definition: trigger_fop.h:47
static struct m0_rm_incoming_ops spiel_tx_ri_ops
Definition: conf_mgmt.c:460
M0_INTERNAL bool m0_conf_obj_invariant(const struct m0_conf_obj *obj)
Definition: obj_ops.c:52
static int spiel_controllerv_dirs_create(struct m0_conf_objv *objv)
Definition: conf_mgmt.c:867
M0_INTERNAL struct m0_fop_conf_flip_rep * m0_conf_fop_to_flip_fop_rep(const struct m0_fop *fop)
Definition: flip_fop.c:51
M0_INTERNAL struct m0_fop_conf_load_rep * m0_conf_fop_to_load_fop_rep(const struct m0_fop *fop)
Definition: load_fop.c:56
const struct m0_conf_obj_type M0_CONF_RACK_TYPE
Definition: rack.c:124
static int spiel_tx_to_str(struct m0_spiel_tx *tx, uint64_t ver_forced, char **str, bool debug)
Definition: conf_mgmt.c:2162
Definition: fop.h:79
M0_INTERNAL void m0_rm_credit_get(struct m0_rm_incoming *in)
Definition: rm.c:1758
struct m0_conf_obj * cv_real
Definition: obj.h:558
struct m0_rm_resource * ro_resource
Definition: rm.h:1015
#define FID_F
Definition: fid.h:75
int const char void * buffer
Definition: dir.c:435
char * wlc_rm_addr
Definition: wlock_helper.c:34
#define M0_IMPOSSIBLE(fmt,...)
M0_INTERNAL bool m0_pdclust_attr_check(const struct m0_pdclust_attr *attr)
Definition: pdclust.c:340