Motr  M0
layout.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
77 #include "lib/errno.h"
78 #include "lib/memory.h" /* M0_ALLOC_PTR() */
79 #include "lib/misc.h" /* strlen(), M0_IN() */
80 #include "lib/vec.h" /* m0_bufvec_cursor_step(), m0_bufvec_cursor_addr() */
81 #include "lib/bob.h"
82 #include "lib/finject.h"
83 #include "lib/hash.h" /* m0_hash */
84 
85 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LAYOUT
86 #include "lib/trace.h"
87 
88 #include "motr/magic.h"
89 #include "motr/client_internal.h"
90 #include "layout/layout_internal.h"
91 #include "layout/layout.h"
92 #include "pool/pool.h" /* M0_TL_DESCR_DECLARE(pools, M0_EXTERN) */
93 
94 enum {
95  LNET_MAX_PAYLOAD = 1 << 20,
96 };
97 
99 //extern struct m0_layout_enum_type m0_list_enum_type;
101 
102 static const struct m0_bob_type layout_bob = {
103  .bt_name = "layout",
104  .bt_magix_offset = offsetof(struct m0_layout, l_magic),
105  .bt_magix = M0_LAYOUT_MAGIC,
106  .bt_check = NULL
107 };
109 
110 static const struct m0_bob_type enum_bob = {
111  .bt_name = "enum",
112  .bt_magix_offset = offsetof(struct m0_layout_enum, le_magic),
113  .bt_magix = M0_LAYOUT_ENUM_MAGIC,
114  .bt_check = NULL
115 };
117 
118 static const struct m0_bob_type layout_instance_bob = {
119  .bt_name = "layout_instance",
120  .bt_magix_offset = offsetof(struct m0_layout_instance, li_magic),
121  .bt_magix = M0_LAYOUT_INSTANCE_MAGIC,
122  .bt_check = NULL
123 };
125 
126 M0_TL_DESCR_DEFINE(layout, "layout-list", static,
127  struct m0_layout, l_list_linkage, l_magic,
129 M0_TL_DEFINE(layout, static, struct m0_layout);
130 
131 M0_INTERNAL bool m0_layout__domain_invariant(const struct m0_layout_domain *dom)
132 {
133  return dom != NULL;
134 }
135 
136 static bool layout_invariant_internal(const struct m0_layout *l)
137 {
138  return
139  m0_layout_bob_check(l) &&
140  l->l_id > 0 &&
141  l->l_type != NULL &&
142  l->l_dom->ld_type[l->l_type->lt_id] == l->l_type &&
143  m0_layout__domain_invariant(l->l_dom) &&
144  l->l_ops != NULL;
145 }
146 
147 M0_INTERNAL bool m0_layout__allocated_invariant(const struct m0_layout *l)
148 {
149  return
151  m0_ref_read(&l->l_ref) == 1 &&
152  l->l_user_count == 0;
153 }
154 
155 M0_INTERNAL bool m0_layout__invariant(const struct m0_layout *l)
156 {
157  /*
158  * l->l_ref is always going to be > 0 throughout the life of
159  * an in-memory layout except when 'its last reference is
160  * released through m0_layout_put() causing it to get deleted using
161  * l->l_ops->lo_fini()'. In that exceptional case, l->l_ref will be
162  * equal to 0.
163  */
164  return
166  m0_ref_read(&l->l_ref) >= 0 &&
167  l->l_user_count >= 0;
168 }
169 
170 M0_INTERNAL bool m0_layout__enum_invariant(const struct m0_layout_enum *e)
171 {
172  return
173  m0_layout_enum_bob_check(e) &&
174  e->le_type != NULL &&
175  ergo(!e->le_sl_is_set, e->le_sl == NULL) &&
176  ergo(e->le_sl_is_set, e->le_sl != NULL) &&
177  e->le_ops != NULL;
178 }
179 
180 M0_INTERNAL bool
182 {
183  return
184  stl != NULL &&
185  stl->sl_enum == NULL &&
187 }
188 
189 M0_INTERNAL bool m0_layout__striped_invariant(const struct m0_striped_layout
190  *stl)
191 {
192  return
193  stl != NULL &&
196 }
197 
199  *li)
200 {
201  return
202  m0_layout_instance_bob_check(li) &&
203  m0_fid_is_valid(&li->li_gfid) &&
204  li->li_ops != NULL;
205 }
206 
208 static void layout_type_get(struct m0_layout_domain *ldom,
209  struct m0_layout_type *lt)
210 {
211  M0_PRE(ldom != NULL);
212  M0_PRE(lt != NULL);
213 
214  m0_mutex_lock(&ldom->ld_lock);
215  M0_PRE(lt == ldom->ld_type[lt->lt_id]);
217  m0_mutex_unlock(&ldom->ld_lock);
218 }
219 
221 static void layout_type_put(struct m0_layout_domain *ldom,
222  struct m0_layout_type *lt)
223 {
224  M0_PRE(ldom != NULL);
225  M0_PRE(lt != NULL);
226 
227  m0_mutex_lock(&ldom->ld_lock);
228  M0_PRE(lt == ldom->ld_type[lt->lt_id]);
230  m0_mutex_unlock(&ldom->ld_lock);
231 }
232 
234 static void enum_type_get(struct m0_layout_domain *ldom,
235  struct m0_layout_enum_type *let)
236 {
237  M0_PRE(ldom != NULL);
238  M0_PRE(let != NULL);
239 
240  m0_mutex_lock(&ldom->ld_lock);
241  M0_PRE(let == ldom->ld_enum[let->let_id]);
243  m0_mutex_unlock(&ldom->ld_lock);
244 }
245 
247 static void enum_type_put(struct m0_layout_domain *ldom,
248  struct m0_layout_enum_type *let)
249 {
250  M0_PRE(ldom != NULL);
251  M0_PRE(let != NULL);
252 
253  m0_mutex_lock(&ldom->ld_lock);
254  M0_PRE(let == ldom->ld_enum[let->let_id]);
256  m0_mutex_unlock(&ldom->ld_lock);
257 }
258 
262 M0_INTERNAL void m0_layout_add(struct m0_layout_domain *dom, struct m0_layout *l)
263 {
264  M0_ENTRY("dom %p, lid %llu", dom, (unsigned long long)l->l_id);
265  m0_mutex_lock(&dom->ld_lock);
266  M0_PRE(m0_layout__list_lookup(dom, l->l_id, false) == NULL);
267  layout_tlink_init_at(l, &l->l_dom->ld_layout_list);
268  m0_mutex_unlock(&dom->ld_lock);
269  M0_LEAVE("lid %llu", (unsigned long long)l->l_id);
270 }
271 
282 M0_INTERNAL struct m0_layout *m0_layout__list_lookup(const struct
284  uint64_t lid,
285  bool ref_increment)
286 {
287  struct m0_layout *l;
288 
289  M0_PRE(m0_mutex_is_locked(&dom->ld_lock));
290 
291  l = m0_tl_find(layout, l, &dom->ld_layout_list, l->l_id == lid);
292  if (l != NULL && ref_increment)
293  /*
294  * The dom->ld_lock is held at this points that protects
295  * the deletion of a layout entry from the layout list.
296  * Hence, it is safe to increment the l->l_ref without
297  * acquiring the l->l_lock. Acquiring the l->l_lock here would
298  * have violated the locking sequence that 'first the layout
299  * lock should be held and then the domain lock'.
300  */
301  m0_ref_get(&l->l_ref);
302  return l;
303 }
304 
305 /* Used for assertions. */
306 static struct m0_layout *list_lookup(struct m0_layout_domain *dom,
307  uint64_t lid)
308 {
309  struct m0_layout *l;
310 
311  m0_mutex_lock(&dom->ld_lock);
312  l = m0_layout__list_lookup(dom, lid, false);
313  m0_mutex_unlock(&dom->ld_lock);
314  return l;
315 }
316 
321 M0_INTERNAL void m0_layout__init(struct m0_layout *l,
322  struct m0_layout_domain *dom,
323  uint64_t lid,
324  struct m0_layout_type *lt,
325  const struct m0_layout_ops *ops)
326 {
327  M0_PRE(l != NULL);
329  M0_PRE(lid > 0);
330  M0_PRE(lt != NULL);
331  M0_PRE(lt == dom->ld_type[lt->lt_id]);
332  M0_PRE(ops != NULL);
333 
334  M0_ENTRY("lid %llu, layout-type-id %lu", (unsigned long long)lid,
335  (unsigned long)lt->lt_id);
336 
337  l->l_id = lid;
338  l->l_dom = dom;
339  l->l_user_count = 0;
340  l->l_ops = ops;
341  l->l_type = lt;
342 
343  m0_ref_init(&l->l_ref, 1, l->l_ops->lo_fini);
344  layout_type_get(dom, lt);
345  m0_mutex_init(&l->l_lock);
346  m0_layout_bob_init(l);
347 
349  M0_LEAVE("lid %llu", (unsigned long long)lid);
350 }
351 
355 M0_INTERNAL void m0_layout__populate(struct m0_layout *l, uint32_t user_count)
356 {
358 
359  M0_ENTRY("lid %llu", (unsigned long long)l->l_id);
360  l->l_user_count = user_count;
361  m0_layout_add(l->l_dom, l);
363  M0_LEAVE("lid %llu", (unsigned long long)l->l_id);
364 }
365 
366 M0_INTERNAL void m0_layout__fini_internal(struct m0_layout *l)
367 {
368  M0_PRE(m0_mutex_is_not_locked(&l->l_lock));
369  m0_mutex_fini(&l->l_lock);
370  layout_type_put(l->l_dom, l->l_type);
371  l->l_type = NULL;
372  m0_layout_bob_fini(l);
373 }
374 
375 /* Used only in case of exceptions or errors. */
376 M0_INTERNAL void m0_layout__delete(struct m0_layout *l)
377 {
379  M0_PRE(list_lookup(l->l_dom, l->l_id) != l);
380  M0_PRE(m0_ref_read(&l->l_ref) == 1);
381 
382  M0_ENTRY("lid %llu", (unsigned long long)l->l_id);
384  M0_LEAVE();
385 }
386 
388 M0_INTERNAL void m0_layout__fini(struct m0_layout *l)
389 {
391  M0_PRE(list_lookup(l->l_dom, l->l_id) == NULL);
392  M0_PRE(m0_ref_read(&l->l_ref) == 0);
393 
394  M0_ENTRY("lid %llu", (unsigned long long)l->l_id);
395  layout_tlink_fini(l);
397  M0_LEAVE();
398 }
399 
400 M0_INTERNAL void m0_layout__striped_init(struct m0_striped_layout *stl,
401  struct m0_layout_domain *dom,
402  uint64_t lid,
403  struct m0_layout_type *type,
404  const struct m0_layout_ops *ops)
405 {
406  M0_PRE(stl != NULL);
408  M0_PRE(lid > 0);
409  M0_PRE(type != NULL);
410  M0_PRE(ops != NULL);
411 
412  M0_ENTRY("lid %llu", (unsigned long long)lid);
413  m0_layout__init(&stl->sl_base, dom, lid, type, ops);
414  /* stl->sl_enum will be set through m0_layout__striped_populate(). */
415  stl->sl_enum = NULL;
417  M0_LEAVE("lid %llu", (unsigned long long)lid);
418 }
419 
427 M0_INTERNAL void m0_layout__striped_populate(struct m0_striped_layout *str_l,
428  struct m0_layout_enum *e,
429  uint32_t user_count)
430 {
432  M0_PRE(e != NULL);
433 
434  M0_ENTRY("lid %llu, enum-type-id %lu",
435  (unsigned long long)str_l->sl_base.l_id,
436  (unsigned long)e->le_type->let_id);
437  m0_layout__populate(&str_l->sl_base, user_count);
438  str_l->sl_enum = e;
439  str_l->sl_enum->le_sl_is_set = true;
440  str_l->sl_enum->le_sl = str_l;
441 
442  /*
443  * m0_layout__enum_invariant() invoked internally from within
444  * m0_layout__striped_invariant() verifies that
445  * str_l->sl_base->le_sl is set appropriately, using the enum
446  * invariant.
447  */
449  M0_LEAVE("lid %llu", (unsigned long long)str_l->sl_base.l_id);
450 }
451 
452 M0_INTERNAL void m0_layout__striped_delete(struct m0_striped_layout *stl)
453 {
455 
456  M0_ENTRY("lid %llu", (unsigned long long)stl->sl_base.l_id);
457  m0_layout__delete(&stl->sl_base);
458  M0_LEAVE("lid %llu", (unsigned long long)stl->sl_base.l_id);
459 }
460 
466 M0_INTERNAL void m0_layout__striped_fini(struct m0_striped_layout *str_l)
467 {
469 
470  M0_ENTRY("lid %llu", (unsigned long long)str_l->sl_base.l_id);
471  str_l->sl_enum->le_ops->leo_fini(str_l->sl_enum);
472  m0_layout__fini(&str_l->sl_base);
473  M0_LEAVE("lid %llu", (unsigned long long)str_l->sl_base.l_id);
474 }
475 
480 M0_INTERNAL void m0_layout__enum_init(struct m0_layout_domain *dom,
481  struct m0_layout_enum *le,
482  struct m0_layout_enum_type *let,
483  const struct m0_layout_enum_ops *ops)
484 {
486  M0_PRE(le != NULL);
487  M0_PRE(let != NULL);
488  M0_PRE(let == dom->ld_enum[let->let_id]);
489  M0_PRE(ops != NULL);
490 
491  M0_ENTRY("Enum-type-id %lu", (unsigned long)let->let_id);
492  /* le->le_sl will be set through m0_layout__striped_populate(). */
493  le->le_sl_is_set = false;
494  le->le_sl = NULL;
495  le->le_ops = ops;
496  le->le_dom = dom;
497  enum_type_get(dom, let);
498  le->le_type = let;
499  m0_layout_enum_bob_init(le);
500  M0_LEAVE("Enum-type-id %lu", (unsigned long)let->let_id);
501 }
502 
507 M0_INTERNAL void m0_layout__enum_fini(struct m0_layout_enum *le)
508 {
510 
511  M0_ENTRY("Enum-type-id %lu", (unsigned long)le->le_type->let_id);
512  enum_type_put(le->le_dom, le->le_type);
513  le->le_type = NULL;
514  m0_layout_enum_bob_fini(le);
515  M0_LEAVE();
516 }
517 
518 M0_INTERNAL void m0_layout_enum_fini(struct m0_layout_enum *le)
519 {
520  M0_PRE(le != NULL);
521  M0_PRE(le->le_ops != NULL);
522  M0_PRE(le->le_ops->leo_fini != NULL);
523 
524  le->le_ops->leo_fini(le);
525 }
526 
528  *dom)
529 {
530  m0_bcount_t e_recsize;
531  m0_bcount_t max_recsize = 0;
532  uint32_t i;
533 
534  M0_PRE(dom != NULL);
535 
536  /*
537  * Iterate over all the enum types to find the maximum possible
538  * recsize.
539  */
540  for (i = 0; i < ARRAY_SIZE(dom->ld_enum); ++i) {
541  if (dom->ld_enum[i] == NULL)
542  continue;
543  e_recsize = dom->ld_enum[i]->let_ops->leto_max_recsize();
544  max_recsize = max64u(max_recsize, e_recsize);
545  }
546  return max_recsize;
547 }
548 
556 {
557  uint32_t i;
558  m0_bcount_t recsize;
559  m0_bcount_t max_recsize = 0;
560 
562  M0_PRE(m0_mutex_is_locked(&dom->ld_lock));
563 
564  /*
565  * Iterate over all the layout types to find the maximum possible
566  * recsize.
567  */
568  for (i = 0; i < ARRAY_SIZE(dom->ld_type); ++i) {
569  if (dom->ld_type[i] == NULL)
570  continue;
571  recsize = dom->ld_type[i]->lt_ops->lto_max_recsize(dom);
572  max_recsize = max64u(max_recsize, recsize);
573  }
574  dom->ld_max_recsize = sizeof(struct m0_layout_rec) + max_recsize;
575 }
576 
586 M0_INTERNAL void m0_layout__log(const char *fn_name,
587  const char *err_msg,
588  uint64_t lid,
589  int rc)
590 {
591  M0_PRE(fn_name != NULL);
592  M0_PRE(err_msg != NULL);
593  M0_PRE(rc < 0);
594 
595  /* Trace record logging. */
596  M0_LOG(M0_DEBUG, "%s(): lid %llu, %s, rc %d",
597  (const char *)fn_name, (unsigned long long)lid,
598  (const char *)err_msg, rc);
599 }
600 
601 M0_INTERNAL int m0_layouts_init(void)
602 {
603  return 0;
604 }
605 
606 M0_INTERNAL void m0_layouts_fini(void)
607 {
608 }
609 
611 {
612  int rc = 0;
613 
614  M0_PRE(dom != NULL);
615 
616  M0_SET0(dom);
617 
618  if (M0_FI_ENABLED("table_init_err"))
619  { rc = L_TABLE_INIT_ERR; goto err1_injected; }
620 err1_injected:
621  if (rc != 0) {
622  m0_layout__log("m0_layout_domain_init",
623  "m0_table_init() failed",
624  LID_NONE, rc);
625  return M0_RC(rc);
626  }
627  layout_tlist_init(&dom->ld_layout_list);
628  m0_mutex_init(&dom->ld_lock);
630  return M0_RC(rc);
631 }
632 
633 M0_INTERNAL void m0_layout_domain_fini(struct m0_layout_domain *dom)
634 {
636  M0_PRE(m0_mutex_is_not_locked(&dom->ld_lock));
637  /*
638  * Verify that all the layout objects belonging to this domain have
639  * been finalised.
640  */
641  M0_PRE(layout_tlist_is_empty(&dom->ld_layout_list));
642 
643  /* Verify that all the layout types are unregistered. */
644  M0_PRE(m0_forall(i, ARRAY_SIZE(dom->ld_type), dom->ld_type[i] == NULL));
645 
646  /* Verify that all the enum types are unregistered. */
647  M0_PRE(m0_forall(i, ARRAY_SIZE(dom->ld_enum), dom->ld_enum[i] == NULL));
648 
649  m0_mutex_fini(&dom->ld_lock);
650  layout_tlist_fini(&dom->ld_layout_list);
651 }
652 
654 {
655  int count = 0;
656  struct m0_layout *l;
657 
658  M0_ENTRY();
659  M0_PRE(dom != NULL);
660 
661  while (!layout_tlist_is_empty(&dom->ld_layout_list)) {
662  l = layout_tlist_head(&dom->ld_layout_list);
663  m0_layout_put(l);
664  count++;
665  }
666  if (count > 0)
667  M0_LOG(M0_INFO, "Killed %d layout(s)", count);
668  M0_LEAVE();
669 }
670 
672 {
673  int rc;
674 
676 
678  if (rc != 0)
679  return M0_RC(rc);
680 
681 /* rc = m0_layout_enum_type_register(dom, &m0_list_enum_type);
682  if (rc != 0) {
683  m0_layout_type_unregister(dom, &m0_pdclust_layout_type);
684  return M0_RC(rc);
685  }*/
686 
688  if (rc != 0) {
690 // m0_layout_enum_type_unregister(dom, &m0_list_enum_type);
691  return M0_RC(rc);
692  }
693 
694  return M0_RC(rc);
695 }
696 
698  *dom)
699 {
701 
702 // m0_layout_enum_type_unregister(dom, &m0_list_enum_type);
705 }
706 
708  struct m0_layout_type *lt)
709 {
710  int rc;
711 
713  M0_PRE(lt != NULL);
714  M0_PRE(IS_IN_ARRAY(lt->lt_id, dom->ld_type));
715  M0_PRE(lt->lt_ops != NULL);
716 
717  M0_ENTRY("Layout-type-id %lu, domain %p",
718  (unsigned long)lt->lt_id, dom);
719  m0_mutex_lock(&dom->ld_lock);
720  M0_PRE(dom->ld_type[lt->lt_id] == NULL);
721  dom->ld_type[lt->lt_id] = lt;
722 
723  /* Allocate type specific schema data. */
724  if (M0_FI_ENABLED("lto_reg_err"))
725  { rc = LTO_REG_ERR; goto err1_injected; }
726  rc = lt->lt_ops->lto_register(dom, lt);
727 err1_injected:
728  if (rc == 0) {
730  } else {
731  m0_layout__log("m0_layout_type_register",
732  "lto_register() failed",
733  LID_NONE, rc);
734  dom->ld_type[lt->lt_id] = NULL;
735  }
736  m0_mutex_unlock(&dom->ld_lock);
737  M0_LEAVE("Layout-type-id %lu, rc %d", (unsigned long)lt->lt_id, rc);
738  return M0_RC(rc);
739 }
740 
742  struct m0_layout_type *lt)
743 {
745  M0_PRE(lt != NULL);
746  M0_PRE(dom->ld_type[lt->lt_id] == lt); /* Registered layout type */
747  M0_PRE(lt->lt_ops != NULL);
748 
749  M0_ENTRY("Layout-type-id %lu, domain %p",
750  (unsigned long)lt->lt_id, dom);
751  m0_mutex_lock(&dom->ld_lock);
752  lt->lt_ops->lto_unregister(dom, lt);
753  dom->ld_type[lt->lt_id] = NULL;
755  m0_mutex_unlock(&dom->ld_lock);
756  M0_LEAVE("Layout-type-id %lu", (unsigned long)lt->lt_id);
757 }
758 
760  struct m0_layout_enum_type *let)
761 {
762  int rc;
763 
765  M0_PRE(let != NULL);
766  M0_PRE(IS_IN_ARRAY(let->let_id, dom->ld_enum));
767  M0_PRE(let->let_ops != NULL);
768 
769  M0_ENTRY("Enum_type_id %lu, domain %p",
770  (unsigned long)let->let_id, dom);
771  m0_mutex_lock(&dom->ld_lock);
772  M0_PRE(dom->ld_enum[let->let_id] == NULL);
773  dom->ld_enum[let->let_id] = let;
774 
775  /* Allocate enum type specific schema data. */
776  if (M0_FI_ENABLED("leto_reg_err"))
777  { rc = LETO_REG_ERR; goto err1_injected; }
778  rc = let->let_ops->leto_register(dom, let);
779 err1_injected:
780  if (rc == 0) {
782  } else {
783  m0_layout__log("m0_layout_enum_type_register",
784  "leto_register() failed",
785  LID_NONE, rc);
786  dom->ld_enum[let->let_id] = NULL;
787  }
788  m0_mutex_unlock(&dom->ld_lock);
789  M0_LEAVE("Enum_type_id %lu, rc %d", (unsigned long)let->let_id, rc);
790  return M0_RC(rc);
791 }
792 
794  struct m0_layout_enum_type *let)
795 {
797  M0_PRE(let != NULL);
798  M0_PRE(dom->ld_enum[let->let_id] == let); /* Registered enum type */
799 
800  M0_ENTRY("Enum_type_id %lu, domain %p",
801  (unsigned long)let->let_id, dom);
802  m0_mutex_lock(&dom->ld_lock);
803  let->let_ops->leto_unregister(dom, let);
804  dom->ld_enum[let->let_id] = NULL;
806  m0_mutex_unlock(&dom->ld_lock);
807  M0_LEAVE("Enum_type_id %lu", (unsigned long)let->let_id);
808 }
809 
810 M0_INTERNAL int64_t m0_layout_find_by_buffsize(struct m0_layout_domain *dom,
811  struct m0_fid *pver,
812  size_t buffsize)
813 {
814  struct m0_pdclust_attr *pa = NULL;
815  struct m0_layout *l = NULL;
816  uint64_t hash = 0;
817  int i;
818 
819  m0_mutex_lock(&dom->ld_lock);
820  for (i = M0_DEFAULT_LAYOUT_ID; i < m0_lid_to_unit_map_nr; ++i) {
822  l = m0_layout__list_lookup(dom, hash, true);
823  if (l != NULL) {
824  pa = &m0_layout_to_pdl(l)->pl_attr;
825  if (pa->pa_unit_size * pa->pa_N >= buffsize ||
826  /*
827  * Performance degrades for units bigger than
828  * 4 * LNET_MAX_PAYLOAD (4MB atm), as tests show.
829  */
831  break;
832  m0_ref_put(&l->l_ref);
833  }
834  }
835 
836  if (i < m0_lid_to_unit_map_nr && l != NULL) {
837  M0_LOG(M0_INFO,
838  "Found lid=%d (pver+lid hash=%lx, unit_size=%d, N=%d) "
839  "by buffer size %d.", i, (unsigned long int)hash,
840  (int)pa->pa_unit_size, (int)pa->pa_N, (int)buffsize);
841  m0_ref_put(&l->l_ref);
842  }
843  m0_mutex_unlock(&dom->ld_lock);
844 
845  if (i == m0_lid_to_unit_map_nr)
846  return M0_ERR_INFO(-EINVAL, "Something went really bad, "
847  "wrong pver (%p)?", pver);
848  return i;
849 }
850 
851 M0_INTERNAL int64_t m0_layout_find_by_objsz(struct m0_client *cli,
852  struct m0_fid *pool, size_t sz)
853 {
854  struct m0_pool_version *pver;
855 
856  return m0_pool_version_get(&cli->m0c_pools_common, pool, &pver) ?:
858  &pver->pv_id, sz);
859 }
860 
861 M0_INTERNAL struct m0_layout *m0_layout_find(struct m0_layout_domain *dom,
862  uint64_t lid)
863 {
864  struct m0_layout *l;
865 
867  M0_PRE(lid != LID_NONE);
868 
869  M0_ENTRY("lid %llu", (unsigned long long)lid);
870  m0_mutex_lock(&dom->ld_lock);
871  l = m0_layout__list_lookup(dom, lid, true);
872  m0_mutex_unlock(&dom->ld_lock);
873 
875  m0_ref_read(&l->l_ref) > 1));
876  M0_LEAVE("lid %llu, l_pointer %p", (unsigned long long)lid, l);
877  return l;
878 }
879 
880 M0_INTERNAL void m0_layout_get(struct m0_layout *l)
881 {
883 
884  M0_ENTRY("lid %llu, ref_count %ld", (unsigned long long)l->l_id,
885  (long)m0_ref_read(&l->l_ref));
886  m0_mutex_lock(&l->l_lock);
887  M0_PRE(list_lookup(l->l_dom, l->l_id) == l);
888  m0_ref_get(&l->l_ref);
889  m0_mutex_unlock(&l->l_lock);
890  M0_LEAVE("lid %llu", (unsigned long long)l->l_id);
891 }
892 
893 M0_INTERNAL void m0_layout_put(struct m0_layout *l)
894 {
895  bool killme;
896 
898 
899  M0_ENTRY("lid %llu, ref_count %ld", (unsigned long long)l->l_id,
900  (long)m0_ref_read(&l->l_ref));
901  m0_mutex_lock(&l->l_lock);
902  m0_mutex_lock(&l->l_dom->ld_lock);
903  killme = m0_ref_read(&l->l_ref) == 1;
904  if (killme)
905  /*
906  * The layout should not be found anymore using
907  * m0_layout_find().
908  */
909  layout_tlist_del(l);
910  else
911  m0_ref_put(&l->l_ref);
912  m0_mutex_unlock(&l->l_dom->ld_lock);
913  m0_mutex_unlock(&l->l_lock);
914 
915  /* Finalise outside of the domain lock to improve concurrency. */
916  if (killme)
917  m0_ref_put(&l->l_ref);
918  M0_LEAVE();
919 }
920 
921 M0_INTERNAL void m0_layout_user_count_inc(struct m0_layout *l)
922 {
924 
925  M0_ENTRY("lid %llu, user_count %lu", (unsigned long long)l->l_id,
926  (unsigned long)l->l_user_count);
927  m0_mutex_lock(&l->l_lock);
928  M0_PRE(list_lookup(l->l_dom, l->l_id) == l);
929  M0_CNT_INC(l->l_user_count);
930  m0_mutex_unlock(&l->l_lock);
931  M0_LEAVE("lid %llu", (unsigned long long)l->l_id);
932 }
933 
934 M0_INTERNAL void m0_layout_user_count_dec(struct m0_layout *l)
935 {
937 
938  M0_ENTRY("lid %llu, user_count %lu", (unsigned long long)l->l_id,
939  (unsigned long)l->l_user_count);
940  m0_mutex_lock(&l->l_lock);
941  M0_PRE(list_lookup(l->l_dom, l->l_id) == l);
942  M0_CNT_DEC(l->l_user_count);
943  m0_mutex_unlock(&l->l_lock);
944  M0_LEAVE("lid %llu", (unsigned long long)l->l_id);
945 }
946 
947 M0_INTERNAL int m0_layout_decode(struct m0_layout *l,
948  struct m0_bufvec_cursor *cur,
949  enum m0_layout_xcode_op op,
950  struct m0_be_tx *tx)
951 {
952  struct m0_layout_rec *rec;
953  int rc;
954 
956  M0_PRE(m0_mutex_is_locked(&l->l_lock));
957  M0_PRE(list_lookup(l->l_dom, l->l_id) == NULL);
958  M0_PRE(cur != NULL);
959  M0_PRE(m0_bufvec_cursor_step(cur) >= sizeof *rec);
961  M0_PRE(ergo(op == M0_LXO_DB_LOOKUP, tx != NULL));
962 
963  M0_ENTRY("lid %llu", (unsigned long long)l->l_id);
964 
965  rec = m0_bufvec_cursor_addr(cur);
966  /* Move the cursor to point to the layout type specific payload. */
967  m0_bufvec_cursor_move(cur, sizeof *rec);
968  /*
969  * It is fine if any of the layout does not contain any data in
970  * rec->lr_data[], unless it is required by the specific layout type,
971  * which will be caught by the respective lo_decode() implementation.
972  * Hence, ignoring the return status of m0_bufvec_cursor_move() here.
973  */
974 
975  if (M0_FI_ENABLED("attr_err"))
976  { rec->lr_lt_id = M0_LAYOUT_TYPE_MAX + 1; }
977  if (!IS_IN_ARRAY(rec->lr_lt_id, l->l_dom->ld_type)) {
978  m0_layout__log("m0_layout_decode", "Invalid layout type",
979  l->l_id, -EPROTO);
980  return M0_ERR(-EPROTO);
981  }
982  M0_ASSERT(rec->lr_lt_id == l->l_type->lt_id);
983 
984  if (M0_FI_ENABLED("lo_decode_err"))
985  { rc = LO_DECODE_ERR; goto err1_injected; }
986  rc = l->l_ops->lo_decode(l, cur, op, tx, rec->lr_user_count);
987 err1_injected:
988  if (rc != 0)
989  m0_layout__log("m0_layout_decode", "lo_decode() failed",
990  l->l_id, rc);
991 
993  list_lookup(l->l_dom, l->l_id) == l));
995  M0_POST(m0_mutex_is_locked(&l->l_lock));
996  M0_LEAVE("lid %llu, rc %d", (unsigned long long)l->l_id, rc);
997  return M0_RC(rc);
998 }
999 
1000 M0_INTERNAL int m0_layout_encode(struct m0_layout *l,
1001  enum m0_layout_xcode_op op,
1002  struct m0_be_tx *tx,
1003  struct m0_bufvec_cursor *out)
1004 {
1005  struct m0_layout_rec rec;
1006  m0_bcount_t nbytes;
1007  int rc;
1008 
1010  M0_PRE(m0_mutex_is_locked(&l->l_lock));
1011  M0_PRE(list_lookup(l->l_dom, l->l_id) == l);
1014  M0_PRE(ergo(op != M0_LXO_BUFFER_OP, tx != NULL));
1015  M0_PRE(out != NULL);
1016  M0_PRE(m0_bufvec_cursor_step(out) >= sizeof rec);
1017 
1018  M0_ENTRY("lid %llu", (unsigned long long)l->l_id);
1019  rec.lr_lt_id = l->l_type->lt_id;
1020  rec.lr_user_count = l->l_user_count;
1021  nbytes = m0_bufvec_cursor_copyto(out, &rec, sizeof rec);
1022  M0_ASSERT(nbytes == sizeof rec);
1023 
1024  if (M0_FI_ENABLED("lo_encode_err"))
1025  { rc = LO_ENCODE_ERR; goto err1_injected; }
1026  rc = l->l_ops->lo_encode(l, op, tx, out);
1027 err1_injected:
1028  if (rc != 0)
1029  m0_layout__log("m0_layout_encode", "lo_encode() failed",
1030  l->l_id, rc);
1031 
1032  M0_POST(m0_mutex_is_locked(&l->l_lock));
1033  M0_LEAVE("lid %llu, rc %d", (unsigned long long)l->l_id, rc);
1034  return M0_RC(rc);
1035 }
1036 
1038  *dom)
1039 {
1041  M0_POST(dom->ld_max_recsize >= sizeof (struct m0_layout_rec));
1042  return dom->ld_max_recsize;
1043 }
1044 
1045 M0_INTERNAL struct m0_striped_layout *m0_layout_to_striped(const struct
1046  m0_layout *l)
1047 {
1048  struct m0_striped_layout *stl;
1049 
1051  stl = bob_of(l, struct m0_striped_layout, sl_base, &layout_bob);
1053  return stl;
1054 }
1055 
1056 M0_INTERNAL struct m0_layout_enum *m0_striped_layout_to_enum(const struct
1058  *stl)
1059 {
1061  return stl->sl_enum;
1062 }
1063 
1064 M0_INTERNAL struct m0_layout_enum *m0_layout_to_enum(const struct m0_layout *l)
1065 {
1066  struct m0_striped_layout *stl;
1067 
1068  M0_PRE(l != NULL);
1069  stl = bob_of(l, struct m0_striped_layout, sl_base, &layout_bob);
1071  return stl->sl_enum;
1072 }
1073 
1074 M0_INTERNAL uint32_t m0_layout_enum_nr(const struct m0_layout_enum *e)
1075 {
1077  return e->le_ops->leo_nr(e);
1078 }
1079 
1080 M0_INTERNAL void m0_layout_enum_get(const struct m0_layout_enum *e,
1081  uint32_t idx,
1082  const struct m0_fid *gfid,
1083  struct m0_fid *out)
1084 {
1086  e->le_ops->leo_get(e, idx, gfid, out);
1087 }
1088 
1089 M0_INTERNAL void m0_layout__instance_init(struct m0_layout_instance *li,
1090  const struct m0_fid *gfid,
1091  struct m0_layout *l,
1092  const struct m0_layout_instance_ops
1093  *ops)
1094 {
1095  M0_PRE(li != NULL);
1097 
1098  li->li_gfid = *gfid;
1099  li->li_l = l;
1100  li->li_ops = ops;
1101  m0_layout_instance_bob_init(li);
1102  m0_layout_get(l);
1104 }
1105 
1106 M0_INTERNAL void m0_layout__instance_fini(struct m0_layout_instance *li)
1107 {
1109  m0_layout_put(li->li_l);
1110  m0_layout_instance_bob_fini(li);
1111 }
1112 
1113 M0_INTERNAL int m0_layout_instance_build(struct m0_layout *l,
1114  const struct m0_fid *fid,
1115  struct m0_layout_instance **out)
1116 {
1118  M0_PRE(l->l_ops->lo_instance_build != NULL);
1119 
1120  return l->l_ops->lo_instance_build(l, fid, out);
1121 }
1122 
1123 M0_INTERNAL void m0_layout_instance_fini(struct m0_layout_instance *li)
1124 {
1126  M0_PRE(li->li_ops->lio_fini != NULL);
1127 
1128  /* For example, see pdclust_instance_fini() in layout/pdclust.c */
1129  li->li_ops->lio_fini(li);
1130 }
1131 
1132 M0_INTERNAL struct m0_layout_enum *m0_layout_instance_to_enum(const struct
1134  *li)
1135 {
1137  M0_PRE(li->li_ops->lio_to_enum != NULL);
1138 
1139  return li->li_ops->lio_to_enum(li);
1140 }
1141 
1142 M0_INTERNAL uint32_t m0_layout_enum_find(const struct m0_layout_enum *e,
1143  const struct m0_fid *gfid,
1144  const struct m0_fid *target)
1145 {
1146  uint32_t i;
1147  uint32_t nr;
1148  struct m0_fid cob;
1149 
1150  nr = e->le_ops->leo_nr(e);
1151  for (i = 0; i < nr; ++i) {
1152  e->le_ops->leo_get(e, i, gfid, &cob);
1153  if (m0_fid_eq(&cob, target))
1154  return i;
1155  }
1156  return ~0;
1157 }
1158 
1159 #undef M0_TRACE_SUBSYSTEM
1160 
1163 /*
1164  * Local variables:
1165  * c-indentation-style: "K&R"
1166  * c-basic-offset: 8
1167  * tab-width: 8
1168  * fill-column: 80
1169  * scroll-step: 1
1170  * End:
1171  */
M0_INTERNAL struct m0_layout * m0_layout_find(struct m0_layout_domain *dom, uint64_t lid)
Definition: layout.c:861
int(* leto_register)(struct m0_layout_domain *dom, const struct m0_layout_enum_type *et)
Definition: layout.h:548
M0_INTERNAL m0_bcount_t m0_layout_max_recsize(const struct m0_layout_domain *dom)
Definition: layout.c:1037
M0_INTERNAL struct m0_striped_layout * m0_layout_to_striped(const struct m0_layout *l)
Definition: layout.c:1045
static size_t nr
Definition: dump.c:1505
#define M0_PRE(cond)
struct m0_layout_enum_type m0_linear_enum_type
Definition: linear_enum.c:342
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
struct m0_layout * li_l
Definition: layout.h:590
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_layout__fini_internal(struct m0_layout *l)
Definition: layout.c:366
uint64_t pa_unit_size
Definition: pdclust.h:118
M0_INTERNAL void m0_layout_enum_type_unregister(struct m0_layout_domain *dom, struct m0_layout_enum_type *let)
Definition: layout.c:793
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
#define ergo(a, b)
Definition: misc.h:293
static void layout_type_get(struct m0_layout_domain *ldom, struct m0_layout_type *lt)
Definition: layout.c:208
const struct m0_layout_enum_type_ops * let_ops
Definition: layout.h:540
M0_INTERNAL int m0_layout_domain_init(struct m0_layout_domain *dom)
Definition: layout.c:610
uint32_t pa_N
Definition: pdclust.h:104
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
void(* leo_fini)(struct m0_layout_enum *e)
Definition: layout.h:460
M0_INTERNAL bool m0_mutex_is_not_locked(const struct m0_mutex *mutex)
Definition: mutex.c:101
M0_INTERNAL void m0_layout__striped_init(struct m0_striped_layout *stl, struct m0_layout_domain *dom, uint64_t lid, struct m0_layout_type *type, const struct m0_layout_ops *ops)
Definition: layout.c:400
M0_INTERNAL struct m0_layout_enum * m0_striped_layout_to_enum(const struct m0_striped_layout *stl)
Definition: layout.c:1056
static const struct m0_bob_type enum_bob
Definition: layout.c:110
M0_INTERNAL void m0_layout_domain_fini(struct m0_layout_domain *dom)
Definition: layout.c:633
M0_INTERNAL bool m0_layout__instance_invariant(const struct m0_layout_instance *li)
Definition: layout.c:198
M0_INTERNAL void m0_layout_enum_fini(struct m0_layout_enum *le)
Definition: layout.c:518
struct m0_layout_enum *(* lio_to_enum)(const struct m0_layout_instance *li)
Definition: layout.h:614
M0_INTERNAL void * m0_bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
Definition: vec.c:597
uint64_t m0_bcount_t
Definition: types.h:77
M0_TL_DESCR_DEFINE(layout, "layout-list", static, struct m0_layout, l_list_linkage, l_magic, M0_LAYOUT_MAGIC, M0_LAYOUT_HEAD_MAGIC)
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
M0_INTERNAL bool m0_layout__striped_allocated_invariant(const struct m0_striped_layout *stl)
Definition: layout.c:181
void(* lto_unregister)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: layout.h:382
struct m0_pdclust_attr pl_attr
Definition: pdclust.h:150
static void layout_type_put(struct m0_layout_domain *ldom, struct m0_layout_type *lt)
Definition: layout.c:221
struct m0_layout_enum_type * le_type
Definition: layout.h:409
const char * bt_name
Definition: bob.h:73
static m0_bcount_t count
Definition: xcode.c:167
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
int m0_lid_to_unit_map[]
Definition: layout_pver.c:99
uint32_t let_ref_count
Definition: layout.h:537
struct m0_fid fid
Definition: di.c:46
return M0_RC(rc)
op
Definition: libdemo.c:64
struct m0_layout_type * ld_type[M0_LAYOUT_TYPE_MAX]
Definition: layout.h:196
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL bool m0_layout__enum_invariant(const struct m0_layout_enum *e)
Definition: layout.c:170
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
Definition: vec.c:574
M0_INTERNAL void m0_layout_add(struct m0_layout_domain *dom, struct m0_layout *l)
Definition: layout.c:262
int i
Definition: dir.c:1033
struct m0_pools_common m0c_pools_common
M0_INTERNAL uint32_t m0_layout_enum_find(const struct m0_layout_enum *e, const struct m0_fid *gfid, const struct m0_fid *target)
Definition: layout.c:1142
M0_INTERNAL void m0_layout__fini(struct m0_layout *l)
Definition: layout.c:388
M0_INTERNAL void m0_layout__enum_fini(struct m0_layout_enum *le)
Definition: layout.c:507
M0_INTERNAL void m0_ref_put(struct m0_ref *ref)
Definition: refs.c:38
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
Definition: refs.c:24
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_ref_get(struct m0_ref *ref)
Definition: refs.c:32
static void max_recsize_update(struct m0_layout_domain *dom)
Definition: layout.c:555
Definition: trace.h:482
M0_INTERNAL uint64_t m0_pool_version2layout_id(const struct m0_fid *pv_fid, uint64_t lid)
Definition: pool.c:1900
M0_INTERNAL void m0_layout__striped_delete(struct m0_striped_layout *stl)
Definition: layout.c:452
M0_INTERNAL int m0_pool_version_get(struct m0_pools_common *pc, const struct m0_fid *pool, struct m0_pool_version **pv)
Definition: pool.c:662
const struct m0_layout_enum_ops * le_ops
Definition: layout.h:423
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step(const struct m0_bufvec_cursor *cur)
Definition: vec.c:581
struct m0_layout_domain * le_dom
Definition: layout.h:412
static struct m0_cob * cob
Definition: bytecount.c:40
#define M0_ASSERT(cond)
M0_INTERNAL int m0_layout_encode(struct m0_layout *l, enum m0_layout_xcode_op op, struct m0_be_tx *tx, struct m0_bufvec_cursor *out)
Definition: layout.c:1000
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
Definition: mutex.c:95
M0_INTERNAL int64_t m0_layout_find_by_objsz(struct m0_client *cli, struct m0_fid *pool, size_t sz)
Definition: layout.c:851
M0_INTERNAL m0_bcount_t m0_layout__enum_max_recsize(struct m0_layout_domain *dom)
Definition: layout.c:527
struct m0_fid pver
Definition: idx_dix.c:74
uint32_t lt_ref_count
Definition: layout.h:367
M0_INTERNAL void m0_layout__enum_init(struct m0_layout_domain *dom, struct m0_layout_enum *le, struct m0_layout_enum_type *let, const struct m0_layout_enum_ops *ops)
Definition: layout.c:480
struct m0_reqh m0c_reqh
#define bob_of(ptr, type, field, bt)
Definition: bob.h:140
struct m0_layout_enum * sl_enum
Definition: layout.h:577
static const struct m0_bob_type layout_bob
Definition: layout.c:102
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL void m0_layout__instance_init(struct m0_layout_instance *li, const struct m0_fid *gfid, struct m0_layout *l, const struct m0_layout_instance_ops *ops)
Definition: layout.c:1089
M0_INTERNAL void m0_layout_enum_get(const struct m0_layout_enum *e, uint32_t idx, const struct m0_fid *gfid, struct m0_fid *out)
Definition: layout.c:1080
M0_INTERNAL void m0_layout__striped_fini(struct m0_striped_layout *str_l)
Definition: layout.c:466
M0_INTERNAL struct m0_pdclust_layout * m0_layout_to_pdl(const struct m0_layout *l)
Definition: pdclust.c:382
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL uint32_t m0_layout_enum_nr(const struct m0_layout_enum *e)
Definition: layout.c:1074
M0_INTERNAL void m0_layout_user_count_dec(struct m0_layout *l)
Definition: layout.c:934
#define M0_POST(cond)
M0_BOB_DEFINE(static, &layout_bob, m0_layout)
M0_INTERNAL bool m0_layout__domain_invariant(const struct m0_layout_domain *dom)
Definition: layout.c:131
struct m0_layout_domain rh_ldom
Definition: reqh.h:153
M0_INTERNAL bool m0_layout__striped_invariant(const struct m0_striped_layout *stl)
Definition: layout.c:189
static const struct m0_bob_type layout_instance_bob
Definition: layout.c:118
M0_INTERNAL void m0_layout__log(const char *fn_name, const char *err_msg, uint64_t lid, int rc)
Definition: layout.c:586
M0_INTERNAL int m0_layout_enum_type_register(struct m0_layout_domain *dom, struct m0_layout_enum_type *let)
Definition: layout.c:759
uint32_t lr_lt_id
Definition: layout.h:653
uint32_t lt_id
Definition: layout.h:360
M0_INTERNAL int m0_layout_standard_types_register(struct m0_layout_domain *dom)
Definition: layout.c:671
M0_INTERNAL int m0_layout_decode(struct m0_layout *l, struct m0_bufvec_cursor *cur, enum m0_layout_xcode_op op, struct m0_be_tx *tx)
Definition: layout.c:947
M0_INTERNAL void m0_layout__instance_fini(struct m0_layout_instance *li)
Definition: layout.c:1106
static struct m0_clink l[NR]
Definition: chan.c:37
void(* leo_get)(const struct m0_layout_enum *e, uint32_t idx, const struct m0_fid *gfid, struct m0_fid *out)
Definition: layout.h:437
struct m0_layout_enum_type * ld_enum[M0_LAYOUT_ENUM_TYPE_MAX]
Definition: layout.h:199
struct m0_fid li_gfid
Definition: layout.h:587
M0_TL_DEFINE(layout, static, struct m0_layout)
M0_INTERNAL void m0_layout__striped_populate(struct m0_striped_layout *str_l, struct m0_layout_enum *e, uint32_t user_count)
Definition: layout.c:427
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
#define m0_forall(var, nr,...)
Definition: misc.h:112
M0_INTERNAL bool m0_layout__allocated_invariant(const struct m0_layout *l)
Definition: layout.c:147
static void enum_type_put(struct m0_layout_domain *ldom, struct m0_layout_enum_type *let)
Definition: layout.c:247
const struct m0_layout_type_ops * lt_ops
Definition: layout.h:370
static struct m0_pool pool
Definition: layout.c:50
M0_INTERNAL int64_t m0_layout_find_by_buffsize(struct m0_layout_domain *dom, struct m0_fid *pver, size_t buffsize)
Definition: layout.c:810
M0_INTERNAL void m0_layout_get(struct m0_layout *l)
Definition: layout.c:880
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
Definition: refs.c:44
static int rc
Definition: layout.c:51
bool le_sl_is_set
Definition: layout.h:417
M0_INTERNAL void m0_layout_user_count_inc(struct m0_layout *l)
Definition: layout.c:921
const int m0_lid_to_unit_map_nr
Definition: layout_pver.c:116
struct m0_mutex ld_lock
Definition: layout.h:217
#define M0_CNT_INC(cnt)
Definition: arith.h:226
const struct m0_layout_instance_ops * li_ops
Definition: layout.h:593
M0_INTERNAL void m0_layout_domain_cleanup(struct m0_layout_domain *dom)
Definition: layout.c:653
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
Definition: fid.h:38
M0_INTERNAL void m0_layout__delete(struct m0_layout *l)
Definition: layout.c:376
struct m0_layout_type m0_pdclust_layout_type
Definition: pdclust.c:968
int(* lto_register)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: layout.h:378
M0_INTERNAL struct m0_layout_enum * m0_layout_instance_to_enum(const struct m0_layout_instance *li)
Definition: layout.c:1132
void(* lio_fini)(struct m0_layout_instance *li)
Definition: layout.h:607
M0_INTERNAL bool m0_layout__invariant(const struct m0_layout *l)
Definition: layout.c:155
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto(struct m0_bufvec_cursor *dcur, void *sdata, m0_bcount_t num_bytes)
Definition: vec.c:677
M0_INTERNAL void m0_layouts_fini(void)
Definition: layout.c:606
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
struct m0_layout sl_base
Definition: layout.h:574
M0_INTERNAL int m0_layout_type_register(struct m0_layout_domain *dom, struct m0_layout_type *lt)
Definition: layout.c:707
struct m0_striped_layout * le_sl
Definition: layout.h:420
#define IS_IN_ARRAY(idx, array)
Definition: misc.h:311
M0_INTERNAL void m0_layout_standard_types_unregister(struct m0_layout_domain *dom)
Definition: layout.c:697
M0_INTERNAL struct m0_layout_enum * m0_layout_to_enum(const struct m0_layout *l)
Definition: layout.c:1064
M0_INTERNAL void m0_layout_type_unregister(struct m0_layout_domain *dom, struct m0_layout_type *lt)
Definition: layout.c:741
#define M0_CNT_DEC(cnt)
Definition: arith.h:219
M0_INTERNAL void m0_layout__init(struct m0_layout *l, struct m0_layout_domain *dom, uint64_t lid, struct m0_layout_type *lt, const struct m0_layout_ops *ops)
Definition: layout.c:321
M0_INTERNAL void m0_layout_instance_fini(struct m0_layout_instance *li)
Definition: layout.c:1123
static void enum_type_get(struct m0_layout_domain *ldom, struct m0_layout_enum_type *let)
Definition: layout.c:234
uint32_t lr_user_count
Definition: layout.h:659
static bool layout_invariant_internal(const struct m0_layout *l)
Definition: layout.c:136
uint32_t(* leo_nr)(const struct m0_layout_enum *e)
Definition: layout.h:431
M0_INTERNAL void m0_layout_put(struct m0_layout *l)
Definition: layout.c:893
#define out(...)
Definition: gen.c:41
int type
Definition: dir.c:1031
static struct m0_layout * list_lookup(struct m0_layout_domain *dom, uint64_t lid)
Definition: layout.c:306
struct m0_fid gfid
Definition: dir.c:626
M0_INTERNAL bool m0_fid_is_valid(const struct m0_fid *fid)
Definition: fid.c:96
struct m0_fom_ops ops
Definition: io_foms.c:623
#define m0_tl_find(name, var, head,...)
Definition: tlist.h:757
void(* leto_unregister)(struct m0_layout_domain *dom, const struct m0_layout_enum_type *et)
Definition: layout.h:552
M0_INTERNAL void m0_layout__populate(struct m0_layout *l, uint32_t user_count)
Definition: layout.c:355
M0_INTERNAL struct m0_layout * m0_layout__list_lookup(const struct m0_layout_domain *dom, uint64_t lid, bool ref_increment)
Definition: layout.c:282
#define ARRAY_SIZE(a)
Definition: misc.h:45
#define offsetof(typ, memb)
Definition: misc.h:29
M0_INTERNAL int m0_layouts_init(void)
Definition: layout.c:601
m0_layout_xcode_op
Definition: layout.h:161
static uint64_t max64u(uint64_t a, uint64_t b)
Definition: arith.h:71
uint32_t let_id
Definition: layout.h:530
Definition: tx.h:280
uint64_t l_id
Definition: layout.h:225