85 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LAYOUT 127 struct m0_layout, l_list_linkage, l_magic,
139 m0_layout_bob_check(
l) &&
142 l->l_dom->ld_type[
l->l_type->lt_id] ==
l->l_type &&
152 l->l_user_count == 0;
167 l->l_user_count >= 0;
173 m0_layout_enum_bob_check(e) &&
202 m0_layout_instance_bob_check(li) &&
264 M0_ENTRY(
"dom %p, lid %llu",
dom, (
unsigned long long)
l->l_id);
267 layout_tlink_init_at(
l, &
l->l_dom->ld_layout_list);
269 M0_LEAVE(
"lid %llu", (
unsigned long long)
l->l_id);
292 if (
l !=
NULL && ref_increment)
334 M0_ENTRY(
"lid %llu, layout-type-id %lu", (
unsigned long long)lid,
335 (
unsigned long)lt->
lt_id);
346 m0_layout_bob_init(
l);
349 M0_LEAVE(
"lid %llu", (
unsigned long long)lid);
359 M0_ENTRY(
"lid %llu", (
unsigned long long)
l->l_id);
360 l->l_user_count = user_count;
363 M0_LEAVE(
"lid %llu", (
unsigned long long)
l->l_id);
372 m0_layout_bob_fini(
l);
382 M0_ENTRY(
"lid %llu", (
unsigned long long)
l->l_id);
394 M0_ENTRY(
"lid %llu", (
unsigned long long)
l->l_id);
395 layout_tlink_fini(
l);
412 M0_ENTRY(
"lid %llu", (
unsigned long long)lid);
417 M0_LEAVE(
"lid %llu", (
unsigned long long)lid);
434 M0_ENTRY(
"lid %llu, enum-type-id %lu",
499 m0_layout_enum_bob_init(le);
514 m0_layout_enum_bob_fini(le);
543 e_recsize =
dom->ld_enum[
i]->let_ops->leto_max_recsize();
544 max_recsize =
max64u(max_recsize, e_recsize);
571 recsize =
dom->ld_type[
i]->lt_ops->lto_max_recsize(
dom);
572 max_recsize =
max64u(max_recsize, recsize);
597 (
const char *)fn_name, (
unsigned long long)lid,
598 (
const char *)err_msg,
rc);
623 "m0_table_init() failed",
627 layout_tlist_init(&
dom->ld_layout_list);
641 M0_PRE(layout_tlist_is_empty(&
dom->ld_layout_list));
650 layout_tlist_fini(&
dom->ld_layout_list);
661 while (!layout_tlist_is_empty(&
dom->ld_layout_list)) {
662 l = layout_tlist_head(&
dom->ld_layout_list);
717 M0_ENTRY(
"Layout-type-id %lu, domain %p",
732 "lto_register() failed",
749 M0_ENTRY(
"Layout-type-id %lu, domain %p",
769 M0_ENTRY(
"Enum_type_id %lu, domain %p",
784 "leto_register() failed",
800 M0_ENTRY(
"Enum_type_id %lu, domain %p",
838 "Found lid=%d (pver+lid hash=%lx, unit_size=%d, N=%d) " 839 "by buffer size %d.",
i, (
unsigned long int)hash,
846 return M0_ERR_INFO(-EINVAL,
"Something went really bad, " 847 "wrong pver (%p)?",
pver);
869 M0_ENTRY(
"lid %llu", (
unsigned long long)lid);
876 M0_LEAVE(
"lid %llu, l_pointer %p", (
unsigned long long)lid,
l);
884 M0_ENTRY(
"lid %llu, ref_count %ld", (
unsigned long long)
l->l_id,
890 M0_LEAVE(
"lid %llu", (
unsigned long long)
l->l_id);
899 M0_ENTRY(
"lid %llu, ref_count %ld", (
unsigned long long)
l->l_id,
925 M0_ENTRY(
"lid %llu, user_count %lu", (
unsigned long long)
l->l_id,
926 (
unsigned long)
l->l_user_count);
931 M0_LEAVE(
"lid %llu", (
unsigned long long)
l->l_id);
938 M0_ENTRY(
"lid %llu, user_count %lu", (
unsigned long long)
l->l_id,
939 (
unsigned long)
l->l_user_count);
944 M0_LEAVE(
"lid %llu", (
unsigned long long)
l->l_id);
963 M0_ENTRY(
"lid %llu", (
unsigned long long)
l->l_id);
996 M0_LEAVE(
"lid %llu, rc %d", (
unsigned long long)
l->l_id,
rc);
1018 M0_ENTRY(
"lid %llu", (
unsigned long long)
l->l_id);
1026 rc =
l->l_ops->lo_encode(
l,
op, tx,
out);
1033 M0_LEAVE(
"lid %llu, rc %d", (
unsigned long long)
l->l_id,
rc);
1042 return dom->ld_max_recsize;
1101 m0_layout_instance_bob_init(li);
1110 m0_layout_instance_bob_fini(li);
1120 return l->l_ops->lo_instance_build(
l,
fid,
out);
1144 const struct m0_fid *target)
1151 for (
i = 0;
i <
nr; ++
i) {
1159 #undef M0_TRACE_SUBSYSTEM M0_INTERNAL struct m0_layout * m0_layout_find(struct m0_layout_domain *dom, uint64_t lid)
int(* leto_register)(struct m0_layout_domain *dom, const struct m0_layout_enum_type *et)
M0_INTERNAL m0_bcount_t m0_layout_max_recsize(const struct m0_layout_domain *dom)
M0_INTERNAL struct m0_striped_layout * m0_layout_to_striped(const struct m0_layout *l)
struct m0_layout_enum_type m0_linear_enum_type
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
M0_INTERNAL void m0_layout__fini_internal(struct m0_layout *l)
M0_INTERNAL void m0_layout_enum_type_unregister(struct m0_layout_domain *dom, struct m0_layout_enum_type *let)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
static void layout_type_get(struct m0_layout_domain *ldom, struct m0_layout_type *lt)
const struct m0_layout_enum_type_ops * let_ops
M0_INTERNAL int m0_layout_domain_init(struct m0_layout_domain *dom)
#define M0_LOG(level,...)
void(* leo_fini)(struct m0_layout_enum *e)
M0_INTERNAL bool m0_mutex_is_not_locked(const struct m0_mutex *mutex)
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)
M0_INTERNAL struct m0_layout_enum * m0_striped_layout_to_enum(const struct m0_striped_layout *stl)
static const struct m0_bob_type enum_bob
M0_INTERNAL void m0_layout_domain_fini(struct m0_layout_domain *dom)
M0_INTERNAL bool m0_layout__instance_invariant(const struct m0_layout_instance *li)
M0_INTERNAL void m0_layout_enum_fini(struct m0_layout_enum *le)
struct m0_layout_enum *(* lio_to_enum)(const struct m0_layout_instance *li)
M0_INTERNAL void * m0_bufvec_cursor_addr(struct m0_bufvec_cursor *cur)
M0_TL_DESCR_DEFINE(layout, "layout-list", static, struct m0_layout, l_list_linkage, l_magic, M0_LAYOUT_MAGIC, M0_LAYOUT_HEAD_MAGIC)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
M0_INTERNAL bool m0_layout__striped_allocated_invariant(const struct m0_striped_layout *stl)
void(* lto_unregister)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
struct m0_pdclust_attr pl_attr
static void layout_type_put(struct m0_layout_domain *ldom, struct m0_layout_type *lt)
struct m0_layout_enum_type * le_type
M0_INTERNAL int m0_layout_instance_build(struct m0_layout *l, const struct m0_fid *fid, struct m0_layout_instance **out)
struct m0_layout_type * ld_type[M0_LAYOUT_TYPE_MAX]
M0_INTERNAL bool m0_layout__enum_invariant(const struct m0_layout_enum *e)
M0_INTERNAL bool m0_bufvec_cursor_move(struct m0_bufvec_cursor *cur, m0_bcount_t count)
M0_INTERNAL void m0_layout_add(struct m0_layout_domain *dom, struct m0_layout *l)
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)
M0_INTERNAL void m0_layout__fini(struct m0_layout *l)
M0_INTERNAL void m0_layout__enum_fini(struct m0_layout_enum *le)
M0_INTERNAL void m0_ref_put(struct m0_ref *ref)
#define M0_ERR_INFO(rc, fmt,...)
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_ref_get(struct m0_ref *ref)
static void max_recsize_update(struct m0_layout_domain *dom)
M0_INTERNAL uint64_t m0_pool_version2layout_id(const struct m0_fid *pv_fid, uint64_t lid)
M0_INTERNAL void m0_layout__striped_delete(struct m0_striped_layout *stl)
M0_INTERNAL int m0_pool_version_get(struct m0_pools_common *pc, const struct m0_fid *pool, struct m0_pool_version **pv)
const struct m0_layout_enum_ops * le_ops
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_step(const struct m0_bufvec_cursor *cur)
struct m0_layout_domain * le_dom
static struct m0_cob * cob
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)
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
M0_INTERNAL int64_t m0_layout_find_by_objsz(struct m0_client *cli, struct m0_fid *pool, size_t sz)
M0_INTERNAL m0_bcount_t m0_layout__enum_max_recsize(struct m0_layout_domain *dom)
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)
#define bob_of(ptr, type, field, bt)
struct m0_layout_enum * sl_enum
static const struct m0_bob_type layout_bob
static struct m0_stob_domain * dom
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)
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)
M0_INTERNAL void m0_layout__striped_fini(struct m0_striped_layout *str_l)
M0_INTERNAL struct m0_pdclust_layout * m0_layout_to_pdl(const struct m0_layout *l)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
M0_INTERNAL uint32_t m0_layout_enum_nr(const struct m0_layout_enum *e)
M0_INTERNAL void m0_layout_user_count_dec(struct m0_layout *l)
M0_BOB_DEFINE(static, &layout_bob, m0_layout)
M0_INTERNAL bool m0_layout__domain_invariant(const struct m0_layout_domain *dom)
struct m0_layout_domain rh_ldom
M0_INTERNAL bool m0_layout__striped_invariant(const struct m0_striped_layout *stl)
static const struct m0_bob_type layout_instance_bob
M0_INTERNAL void m0_layout__log(const char *fn_name, const char *err_msg, uint64_t lid, int rc)
M0_INTERNAL int m0_layout_enum_type_register(struct m0_layout_domain *dom, struct m0_layout_enum_type *let)
M0_INTERNAL int m0_layout_standard_types_register(struct m0_layout_domain *dom)
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)
M0_INTERNAL void m0_layout__instance_fini(struct m0_layout_instance *li)
static struct m0_clink l[NR]
void(* leo_get)(const struct m0_layout_enum *e, uint32_t idx, const struct m0_fid *gfid, struct m0_fid *out)
struct m0_layout_enum_type * ld_enum[M0_LAYOUT_ENUM_TYPE_MAX]
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)
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
#define m0_forall(var, nr,...)
M0_INTERNAL bool m0_layout__allocated_invariant(const struct m0_layout *l)
static void enum_type_put(struct m0_layout_domain *ldom, struct m0_layout_enum_type *let)
const struct m0_layout_type_ops * lt_ops
static struct m0_pool pool
M0_INTERNAL int64_t m0_layout_find_by_buffsize(struct m0_layout_domain *dom, struct m0_fid *pver, size_t buffsize)
M0_INTERNAL void m0_layout_get(struct m0_layout *l)
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
M0_INTERNAL void m0_layout_user_count_inc(struct m0_layout *l)
const int m0_lid_to_unit_map_nr
const struct m0_layout_instance_ops * li_ops
M0_INTERNAL void m0_layout_domain_cleanup(struct m0_layout_domain *dom)
#define M0_FI_ENABLED(tag)
M0_INTERNAL void m0_layout__delete(struct m0_layout *l)
struct m0_layout_type m0_pdclust_layout_type
int(* lto_register)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
M0_INTERNAL struct m0_layout_enum * m0_layout_instance_to_enum(const struct m0_layout_instance *li)
void(* lio_fini)(struct m0_layout_instance *li)
M0_INTERNAL bool m0_layout__invariant(const struct m0_layout *l)
M0_INTERNAL m0_bcount_t m0_bufvec_cursor_copyto(struct m0_bufvec_cursor *dcur, void *sdata, m0_bcount_t num_bytes)
M0_INTERNAL void m0_layouts_fini(void)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL int m0_layout_type_register(struct m0_layout_domain *dom, struct m0_layout_type *lt)
struct m0_striped_layout * le_sl
#define IS_IN_ARRAY(idx, array)
M0_INTERNAL void m0_layout_standard_types_unregister(struct m0_layout_domain *dom)
M0_INTERNAL struct m0_layout_enum * m0_layout_to_enum(const struct m0_layout *l)
M0_INTERNAL void m0_layout_type_unregister(struct m0_layout_domain *dom, struct m0_layout_type *lt)
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)
M0_INTERNAL void m0_layout_instance_fini(struct m0_layout_instance *li)
static void enum_type_get(struct m0_layout_domain *ldom, struct m0_layout_enum_type *let)
static bool layout_invariant_internal(const struct m0_layout *l)
uint32_t(* leo_nr)(const struct m0_layout_enum *e)
M0_INTERNAL void m0_layout_put(struct m0_layout *l)
static struct m0_layout * list_lookup(struct m0_layout_domain *dom, uint64_t lid)
M0_INTERNAL bool m0_fid_is_valid(const struct m0_fid *fid)
#define m0_tl_find(name, var, head,...)
void(* leto_unregister)(struct m0_layout_domain *dom, const struct m0_layout_enum_type *et)
M0_INTERNAL void m0_layout__populate(struct m0_layout *l, uint32_t user_count)
M0_INTERNAL struct m0_layout * m0_layout__list_lookup(const struct m0_layout_domain *dom, uint64_t lid, bool ref_increment)
#define offsetof(typ, memb)
M0_INTERNAL int m0_layouts_init(void)
static uint64_t max64u(uint64_t a, uint64_t b)