23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_BALLOC 119 return grp->bgi_spare.bzp_freeblocks;
123 return grp->bgi_normal.bzp_freeblocks;
127 return grp->bgi_normal.bzp_maxchunk;
131 return grp->bgi_spare.bzp_maxchunk;
135 return grp->bgi_normal.bzp_fragments;
139 return grp->bgi_spare.bzp_fragments;
143 return &
grp->bgi_normal.bzp_extents;
147 return &
grp->bgi_spare.bzp_extents;
155 static bool is_spare(uint64_t alloc_flags);
156 static bool is_normal(uint64_t alloc_flags);
157 static bool is_any(uint64_t alloc_flag);
179 "normal: free=%08llx maxchunk=0x%08llx frags=0x%08llx" 180 " spare: free=%08llx maxchunk=0x%08llx frags=0x%08llx",
182 (
unsigned long long)
grp->bgi_groupno,
183 (
unsigned long long)
grp->bgi_normal.bzp_freeblocks,
184 (
unsigned long long)
grp->bgi_normal.bzp_maxchunk,
185 (
unsigned long long)
grp->bgi_normal.bzp_fragments,
186 (
unsigned long long)
grp->bgi_spare.bzp_freeblocks,
187 (
unsigned long long)
grp->bgi_spare.bzp_maxchunk,
188 (
unsigned long long)
grp->bgi_spare.bzp_fragments);
202 grp, (
char*)
tag, (
unsigned long long)
grp->bgi_groupno);
220 "|-----magic=%llx state=%llu version=%llu\n" 221 "|-----total=%llu free=%llu bs=%llu(bits=%lu)",
223 (
unsigned long long)
sb->bsb_magic,
224 (
unsigned long long)
sb->bsb_state,
225 (
unsigned long long)
sb->bsb_version,
226 (
unsigned long long)
sb->bsb_totalsize,
227 (
unsigned long long)
sb->bsb_freeblocks,
228 (
unsigned long long)
sb->bsb_blocksize,
229 (
unsigned long )
sb->bsb_bsbits);
233 "|-----time format=%llu\n" 237 (
unsigned long long)
sb->bsb_groupsize,
238 (
unsigned long )
sb->bsb_gsbits,
239 (
unsigned long long)
sb->bsb_groupcount,
240 (
unsigned long long)
sb->bsb_prealloc_count,
241 (
unsigned long long)
sb->bsb_format_time,
242 (
unsigned long long)
sb->bsb_write_time,
243 (
unsigned long long)
sb->bsb_mnt_time,
244 (
unsigned long long)
sb->bsb_last_check_time);
246 M0_LOG(
M0_DEBUG,
"|-----mount=%llu max_mnt=%llu stripe_size=%llu",
247 (
unsigned long long)
sb->bsb_mnt_count,
248 (
unsigned long long)
sb->bsb_max_mnt_count,
249 (
unsigned long long)
sb->bsb_stripe_size
268 return &
grp->bgi_mutex.bm_u.mutex;
307 "bzp_frags=%d", (
int)zone_type,
grp,
grp->bgi_groupno,
339 #define MAX_ALLOCATION_CHUNK 2048ULL 344 .ot_version = M0_BALLOC_GROUP_DESC_FORMAT_VERSION,
345 .ot_type = M0_FORMAT_TYPE_BALLOC_GROUP_DESC,
346 .ot_footer_offset = offsetof(struct m0_balloc_group_desc, bgd_footer)
354 .ot_version = M0_BALLOC_FORMAT_VERSION,
355 .ot_type = M0_FORMAT_TYPE_BALLOC,
356 .ot_footer_offset = offsetof(struct m0_balloc, cb_footer)
386 #ifdef __SPARE__SPACE__ 388 gd.bgd_sparestart, spare_zone_size,
389 gd.bgd_spare_freeblocks, gd.bgd_spare_frags,
390 gd.bgd_spare_maxchunk);
395 spare_zone_size, 0, 0, 0);
425 while (
rc != 0 &&
i > 0) {
510 gettimeofday(&now,
NULL);
511 sb->bsb_write_time = ((uint64_t)now.tv_sec) << 32 | now.tv_usec;
564 number_of_groups =
req->bfr_totalsize /
req->bfr_blocksize /
566 if (number_of_groups < 1)
567 number_of_groups = 1;
571 (
unsigned long long)
req->bfr_totalsize,
572 (
unsigned long long)
req->bfr_blocksize,
573 (
unsigned long long)
req->bfr_groupsize,
574 (
unsigned long long)number_of_groups,
575 (
unsigned long long)(
req->bfr_totalsize - number_of_groups *
576 req->bfr_groupsize *
req->bfr_blocksize));
578 gettimeofday(&now,
NULL);
589 sb->bsb_totalsize = number_of_groups *
req->bfr_groupsize *
592 sb->bsb_blocksize =
req->bfr_blocksize;
594 sb->bsb_groupsize =
req->bfr_groupsize;
595 sb->bsb_bsbits = ffs(
req->bfr_blocksize) - 1;
596 sb->bsb_gsbits = ffs(
req->bfr_groupsize) - 1;
597 sb->bsb_groupcount = number_of_groups;
598 #ifdef __SPARE_SPACE__ 600 sb->bsb_sparesize =
req->bfr_spare_reserved_blocks;
601 sb->bsb_freespare = number_of_groups *
602 req->bfr_spare_reserved_blocks;
603 sb->bsb_freeblocks = (number_of_groups <<
sb->bsb_gsbits) -
606 sb->bsb_freeblocks = (number_of_groups <<
sb->bsb_gsbits);
608 sb->bsb_prealloc_count = 16;
609 sb->bsb_format_time = ((uint64_t)now.tv_sec) << 32 | now.tv_usec;
610 sb->bsb_write_time =
sb->bsb_format_time;
611 sb->bsb_mnt_time =
sb->bsb_format_time;
612 sb->bsb_last_check_time =
sb->bsb_format_time;
613 sb->bsb_mnt_count = 0;
614 sb->bsb_max_mnt_count = 1024;
615 sb->bsb_stripe_size = 0;
687 uint64_t worker_index,
705 (
unsigned long long)
i);
718 "rc=%d", (
unsigned long long)
i,
rc);
721 #ifdef __SPARE_SPACE__ 723 ext.
e_start = (
i <<
sb->bsb_gsbits) +
sb->bsb_groupsize -
731 "rc=%d", (
unsigned long long)
i,
rc);
736 (
unsigned long long)
i);
738 #ifdef __SPARE_SPACE__ 739 gd.bgd_spare_freeblocks =
sb->bsb_sparesize;
740 gd.bgd_sparestart = (
i <<
sb->bsb_gsbits) +
sb->bsb_groupsize -
742 gd.bgd_spare_frags = 1;
743 gd.bgd_spare_maxchunk =
sb->bsb_sparesize;
755 (
unsigned long long)
i,
rc);
769 uint64_t worker_index,
773 "partition=%"PRIu64, tb, datum, user, worker_index, partition);
806 .bgs_max =
sb->bsb_groupcount,
817 .bqc_q_size_max = 0x100,
818 .bqc_producers_nr_max = 1,
820 .tbc_workers_nr = 0x40,
821 .tbc_partitions_nr = 1,
822 .tbc_work_items_per_tx_max = 1,
918 #ifdef __SPARE_SPACE__ 939 gettimeofday(&now,
NULL);
975 req.bfr_totalsize = container_size;
976 req.bfr_blocksize = 1 << bshift;
977 req.bfr_groupsize = blocks_per_group;
978 req.bfr_spare_reserved_blocks = spare_blocks_per_group;
1027 if (
req->bar_goal == 0)
1028 req->bar_goal =
motr->cb_last;
1080 (
unsigned long long)
ctx->cb_sb.bsb_freeblocks,
1081 (
unsigned long long)blocks);
1083 #ifdef __SPARE_SPACE__ 1084 is_any(alloc_flags) ? (
ctx->cb_sb.bsb_freespare >= blocks ||
1085 ctx->cb_sb.bsb_freeblocks >= blocks) :
1086 is_spare(alloc_flags) ?
ctx->cb_sb.bsb_freespare >= blocks :
1088 (
ctx->cb_sb.bsb_freeblocks >= blocks);
1134 }
else if (
size <= 8) {
1136 }
else if (
size <= 16) {
1138 }
else if (
size <= 32) {
1140 }
else if (
size <= 64) {
1142 }
else if (
size <= 128) {
1144 }
else if (
size <= 256) {
1146 }
else if (
size <= 512) {
1148 }
else if (
size <= 1024) {
1150 }
else if (
size <= 2048) {
1153 M0_LOG(
M0_WARN,
"length %llu is too large, truncate to %llu",
1167 M0_LOG(
M0_DEBUG,
"goal: start=%llu=(0x%08llx), size=%llu(was %llu)",
1177 #ifdef __SPARE_SPACE__ 1186 struct m0_ext spare_range;
1187 struct m0_ext normal_range;
1192 M0_ENTRY(
"grp=%d non-spare-frags=%d spare-frags=%d",
1197 if (
grp->bgi_extents !=
NULL) {
1205 return M0_RC(-ENOMEM);
1215 spare_range.e_start =
grp->bgi_spare.bzp_range.e_start;
1219 normal_range.e_end = spare_range.e_start;
1222 ex =
grp->bgi_extents;
1252 (
unsigned long long)
i,
1262 struct m0_ext *ext, uint64_t balloc_zone)
1267 &
grp->bgi_normal : &
grp->bgi_spare;
1280 struct m0_ext spare_range;
1281 struct m0_ext normal_range;
1288 M0_ENTRY(
"grp=%d non-spare-frags=%d spare-frags=%d",
1293 if (
grp->bgi_extents !=
NULL) {
1307 return M0_RC(-ENOMEM);
1309 spare_range.
e_start =
grp->bgi_spare.bzp_range.e_start;
1316 ex =
grp->bgi_extents;
1320 grp->bgi_normal.bzp_maxchunk = 0;
1321 grp->bgi_normal.bzp_freeblocks = 0;
1322 grp->bgi_spare.bzp_maxchunk = 0;
1323 grp->bgi_spare.bzp_freeblocks = 0;
1355 (
unsigned long long)
i,
1361 grp->bgi_normal.bzp_fragments = normal_frags;
1362 grp->bgi_spare.bzp_fragments = spare_frags;
1371 static int balloc_find_extent_exact(
struct m0_balloc_allocation_context *bac,
1382 for (
i = 0;
i <
grp->bgi_fragments;
i++) {
1383 fragment = &
grp->bgi_extents[
i];
1413 .e_end = 0xffffffff,
1472 while (start < bac->bac_best.e_start)
1477 if (start < bac->bac_best.e_end && len <= bac->bac_best.e_end -
start)
1538 const struct m0_ext *
tgt, uint64_t alloc_type,
1560 struct m0_ext *
tgt, uint64_t alloc_type,
1601 if (
cur->e_end ==
tgt->e_end) {
1608 if (
cur->e_start <
tgt->e_start) {
1613 cur->e_end =
tgt->e_start;
1636 cur->e_start =
tgt->e_end;
1646 if (
new.e_start < tgt->
e_start) {
1651 new.e_end =
tgt->e_start;
1654 return M0_RC(-ENOMEM);
1674 #ifdef __SPARE_SPACE__ 1692 struct m0_ext *
tgt, uint64_t alloc_flag)
1717 if (
cur->e_start >=
tgt->e_start) {
1729 "tgt_end=%llu cur_start=%llu",
1730 (
unsigned long long)
tgt->e_end,
1731 (
unsigned long long)
cur->e_start);
1733 "double free with cur",
grp);
1734 return M0_RC(-EINVAL);
1736 if (pre && pre->
e_end >
tgt->e_start) {
1738 "pre_end=%llu tgt_start=%llu",
1739 (
unsigned long long)pre->
e_end,
1740 (
unsigned long long)
tgt->e_start);
1742 "double free with pre",
grp);
1743 return M0_RC(-EINVAL);
1757 return M0_RC(-ENOMEM);
1770 if (
cur->e_end <
tgt->e_start) {
1778 return M0_RC(-ENOMEM);
1809 if (
tgt->e_end <
cur->e_start) {
1817 return M0_RC(-ENOMEM);
1835 cur->e_start =
tgt->e_start;
1846 tgt->e_end ==
cur->e_start) {
1866 }
else if (pre->
e_end ==
tgt->e_start) {
1882 }
else if (
tgt->e_end ==
cur->e_start) {
1888 cur->e_start =
tgt->e_start;
1903 return M0_RC(-ENOMEM);
1923 #ifdef __SPARE_SPACE__ 1940 static int balloc_find_by_goal(
struct m0_balloc_allocation_context *bac)
1947 struct m0_ext ex = { 0 };
1955 M0_LOG(
M0_DEBUG,
"groupno=%llu start=%llu len=%llu groupsize=%llu",
1956 (
unsigned long long)
group,
1957 (
unsigned long long)bac->bac_goal.e_start,
1959 (
unsigned long long)bac->bac_ctxt->cb_sb.bsb_groupsize
1978 found = balloc_find_extent_exact(bac,
grp, &bac->bac_goal, &ex);
1984 bac->bac_best.e_start = bac->bac_goal.e_start;
1985 bac->bac_best.e_end = ex.
e_end;
1991 if (bac->bac_goal.e_end < bac->bac_best.e_end)
2040 if (fragments == 0) {
2118 return is_spare(alloc_flag) ?
grp->bgi_spare.bzp_range.e_start :
2119 grp->bgi_normal.bzp_range.e_start;
2132 #define M0_BALLOC_DEFAULT_MAX_TO_SCAN 200 2137 #define M0_BALLOC_DEFAULT_MIN_TO_SCAN 10 2142 #define M0_BALLOC_DEFAULT_MAX_GROUPS_TO_SCAN 5 2156 (
unsigned long long)
grp->bgi_groupno,
2171 if ((end_of_group || bac->
bac_found >= min_to_scan)) {
2186 struct m0_ext *ex,
int end_of_group)
2243 int end_of_group = 0;
2246 #ifdef __SPARE_SPACE__ 2250 &
grp->bgi_normal.bzp_extents;
2253 list = &
grp->bgi_normal.bzp_extents;
2281 (
unsigned long long)
grp->bgi_groupno,
2282 (
unsigned long long)free);
2288 "ex=[0x%08llx:0x%08llx)",
2289 (
unsigned long long)
grp->bgi_groupno,
2290 (
unsigned long long)ex->
e_start,
2291 (
unsigned long long)ex->
e_end);
2292 return M0_RC(-EINVAL);
2386 uint64_t alloc_flags)
2389 #ifdef __SPARE_SPACE__ 2415 rc = balloc_find_by_goal(bac);
2447 for (
i = 0;
i < ngroups;
group++,
i++) {
2450 if (
group >= ngroups)
2484 #ifdef __SPARE_SPACE__ 2509 #ifdef __SPARE_SPACE__ 2609 while (
req->bar_len &&
2613 rc =
req->bar_len == 0 ? -ENOSPC : 0;
2662 uint64_t alloc_flag;
2669 M0_LOG(
M0_DEBUG,
"bal=%p start=0x%llx len=0x%llx start_group=%llu " 2670 "end_group=%llu group_count=%llu",
ctx,
2671 (
unsigned long long)
start,
2672 (
unsigned long long)len,
2675 (
unsigned long long)
sb->bsb_groupcount);
2677 if (
group >
sb->bsb_groupcount)
2680 while (
rc == 0 && len > 0) {
2692 off =
start & (
sb->bsb_groupsize - 1);
2693 step = (off + len >
sb->bsb_groupsize) ?
2694 sb->bsb_groupsize - off : len;
2704 if (
is_any(alloc_flag)) {
2705 fex.
e_end =
grp->bgi_spare.bzp_range.e_start;
2746 static int balloc_discard_prealloc(
struct m0_balloc *
ctx,
2798 uint64_t alloc_zone)
2868 uint64_t alloc_zone)
2876 (
unsigned long)
out->e_start,
2877 (
unsigned long)
count);
2880 req.bar_goal =
out->e_start;
2882 #ifdef __SPARE_SPACE__ 2883 req.bar_flags = alloc_zone ;
2890 freeblocks =
motr->cb_sb.bsb_freeblocks;
2896 out->e_start =
req.bar_result.e_start;
2897 out->e_end =
req.bar_result.e_end;
2906 (
unsigned long long)freeblocks,
2907 (
unsigned long long)
motr->cb_sb.bsb_freeblocks);
2928 freeblocks =
motr->cb_sb.bsb_freeblocks;
2932 (
unsigned long long)freeblocks,
2933 (
unsigned long long)
motr->cb_sb.bsb_freeblocks);
2954 blocks_per_group, spare_blocks_per_group);
3073 #undef M0_TRACE_SUBSYSTEM static m0_bcount_t group_fragments_get(struct m0_balloc_group_info *grp)
M0_INTERNAL int m0_mutex_trylock(struct m0_mutex *mutex)
#define M0_BE_TX_CREDIT_PTR(ptr)
#define M0_BE_ALLOC_CREDIT_PTR(ptr, seg, accum)
struct m0_be_btree cb_db_group_desc
struct m0_be_domain * bs_domain
static const struct m0_be_btree_kv_ops ge_btree_ops
M0_INTERNAL void m0_list_add(struct m0_list *head, struct m0_list_link *new)
#define M0_BE_ALLOC_PTR_SYNC(ptr, seg, tx)
static void balloc_group_write_do(struct m0_be_tx_bulk *tb, struct m0_be_tx *tx, struct m0_be_op *op, void *datum, void *user, uint64_t worker_index, uint64_t partition)
#define M0_ALLOC_ARR(arr, nr)
M0_INTERNAL void m0_be_btree_delete_credit(const struct m0_be_btree *tree, m0_bcount_t nr, m0_bcount_t ksize, m0_bcount_t vsize, struct m0_be_tx_credit *accum)
M0_INTERNAL m0_bcount_t m0_ext_length(const struct m0_ext *ext)
M0_INTERNAL void m0_be_tx_bulk_run(struct m0_be_tx_bulk *tb, struct m0_be_op *op)
M0_INTERNAL int m0_be_tx_bulk_init(struct m0_be_tx_bulk *tb, struct m0_be_tx_bulk_cfg *tb_cfg)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
static struct m0_list list
struct m0_balloc * bgs_bal
static void balloc_debug_dump_extent(const char *tag, struct m0_ext *ex)
struct m0_ad_balloc cb_ballroom
M0_INTERNAL int m0_balloc_load_extents(struct m0_balloc *cb, struct m0_balloc_group_info *grp)
M0_INTERNAL void m0_be_tx_bulk_end(struct m0_be_tx_bulk *tb)
static int balloc_free_db_update(struct m0_balloc *motr, struct m0_be_tx *tx, struct m0_balloc_group_info *grp, struct m0_ext *tgt, uint64_t alloc_flag)
M0_INTERNAL void m0_balloc_debug_dump_sb(const char *tag, struct m0_balloc_super_block *sb)
M0_INTERNAL void m0_list_add_before(struct m0_list_link *anchor, struct m0_list_link *new)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
static int balloc_use_best_found(struct balloc_allocation_context *bac, m0_bindex_t start)
static int balloc_free(struct m0_ad_balloc *ballroom, struct m0_dtx *tx, struct m0_ext *ext)
M0_INTERNAL void m0_list_init(struct m0_list *head)
#define M0_MEMBER_SIZE(type, member)
M0_INTERNAL void m0_be_btree_lookup(struct m0_be_btree *tree, struct m0_be_op *op, const struct m0_buf *key, struct m0_buf *value)
static struct io_request req
static uint64_t tag(uint8_t code, uint64_t id)
struct m0_balloc_allocate_req * bac_req
static struct m0_sm_group * grp
static m0_bcount_t ge_tree_kv_size(const void *kv)
#define M0_LOG(level,...)
m0_bcount_t bzp_freeblocks
#define ENABLE_BALLOC_DUMP
static void balloc_group_work_put(struct m0_balloc *bal, struct m0_be_tx_bulk *tb, struct balloc_groups_write_cfg *bgs)
struct m0_balloc_group_info * cb_group_info
static int btree_insert_sync(struct m0_be_btree *tree, struct m0_be_tx *tx, const struct m0_buf *key, const struct m0_buf *val)
struct m0_be_btree cb_db_group_extents
M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
static int balloc_init_ac(struct balloc_allocation_context *bac, struct m0_balloc *motr, struct m0_be_tx *tx, struct m0_balloc_allocate_req *req)
#define M0_BE_OP_SYNC(op_obj, action)
static bool m0_is_po2(uint64_t val)
#define M0_BALLOC_DEFAULT_MAX_TO_SCAN
int(* bo_init)(struct m0_ad_balloc *ballroom, struct m0_be_seg *db, uint32_t bshift, m0_bcount_t container_size, m0_bcount_t blocks_per_group, m0_bcount_t spare_blocks_per_group)
static int balloc_new_preallocation(struct balloc_allocation_context *bac)
static const struct m0_ad_balloc_ops balloc_ops
static void balloc_group_write_done(struct m0_be_tx_bulk *tb, void *datum, void *user, uint64_t worker_index, uint64_t partition)
static void zone_params_update(struct m0_balloc_group_info *grp, struct m0_ext *ext, uint64_t balloc_zone)
static void balloc_free_credit(const struct m0_ad_balloc *balroom, int nr, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_list_fini(struct m0_list *head)
static int balloc_is_good_group(struct balloc_allocation_context *bac, struct m0_balloc_group_info *gi)
m0_bcount_t bgd_fragments
static int balloc_use_prealloc(struct balloc_allocation_context *bac)
#define M0_BALLOC_DEFAULT_MIN_TO_SCAN
#define MAX_ALLOCATION_CHUNK
M0_INTERNAL void m0_list_del(struct m0_list_link *old)
static int balloc_init_internal(struct m0_balloc *bal, struct m0_be_seg *seg, struct m0_sm_group *grp, uint32_t bshift, m0_bcount_t container_size, m0_bcount_t blocks_per_group, m0_bcount_t spare_blocks_per_group)
static const struct m0_be_btree_kv_ops gd_btree_ops
M0_INTERNAL void m0_be_tx_prep(struct m0_be_tx *tx, const struct m0_be_tx_credit *credit)
const struct m0_ad_balloc_ops * ab_ops
#define M0_BE_TX_CAPTURE_PTR(seg, tx, ptr)
static int balloc_format(struct m0_balloc *bal, struct m0_balloc_format_req *req, struct m0_sm_group *grp)
static int btree_lookup_sync(struct m0_be_btree *tree, const struct m0_buf *key, struct m0_buf *val)
static m0_bcount_t gd_tree_key_size(const void *k)
static bool is_spare(uint64_t alloc_flags)
static int ge_tree_cmp(const void *k0, const void *k1)
static int balloc_regular_allocator(struct balloc_allocation_context *bac)
M0_INTERNAL int m0_balloc_create(uint64_t cid, struct m0_be_seg *seg, struct m0_sm_group *grp, struct m0_balloc **out, const struct m0_fid *fid)
static bool is_normal(uint64_t alloc_flags)
M0_INTERNAL void m0_be_btree_create(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_fid *btree_fid)
#define container_of(ptr, type, member)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
static int balloc_groups_write(struct m0_balloc *bal)
static void balloc_normalize_group_request(struct balloc_allocation_context *bac)
struct m0_balloc * bgc_bal
M0_INTERNAL void m0_be_btree_delete(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_buf *key)
M0_INTERNAL void m0_be_btree_cursor_fini(struct m0_be_btree_cursor *cursor)
m0_bcount_t bsb_groupsize
struct m0_list bzp_extents
static bool is_extent_free(struct m0_balloc_group_info *grp, const struct m0_ext *tgt, uint64_t alloc_type, struct m0_ext **current)
static int btree(struct scanner *s, struct rectype *r, char *buf)
#define M0_BE_TX_CREDIT(nr, size)
static int balloc_free_internal(struct m0_balloc *ctx, struct m0_be_tx *tx, struct m0_balloc_free_req *req)
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
static m0_bindex_t zone_start_get(struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag)
M0_INTERNAL bool m0_ext_equal(const struct m0_ext *a, const struct m0_ext *b)
union m0_be_mutex::@196 bm_u
M0_INTERNAL int m0_balloc_trylock_group(struct m0_balloc_group_info *grp)
static struct m0_list * group_spare_ext(struct m0_balloc_group_info *grp)
return M0_ERR(-EOPNOTSUPP)
static m0_bcount_t gd_tree_val_size(const void *v)
M0_INTERNAL void m0_be_btree_update_credit(const struct m0_be_btree *tree, m0_bcount_t nr, m0_bcount_t vsize, struct m0_be_tx_credit *accum)
#define M0_BE_OP_SYNC_RET(op_obj, action, member)
M0_INTERNAL void m0_balloc_lock_group(struct m0_balloc_group_info *grp)
M0_INTERNAL int m0_be_tx_bulk_status(struct m0_be_tx_bulk *tb)
M0_INTERNAL void m0_be_btree_create_credit(const struct m0_be_btree *tree, m0_bcount_t nr, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_be_btree_insert(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_buf *key, const struct m0_buf *val)
static m0_bcount_t group_spare_fragments_get(struct m0_balloc_group_info *grp)
#define M0_FID_TINIT(type, container, key)
static int balloc_find_extent_buddy(struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, m0_bcount_t len, enum m0_balloc_allocation_flag alloc_flag, struct m0_ext *ex)
static m0_bcount_t group_maxchunk_get(struct m0_balloc_group_info *grp)
static int allocate_blocks(int cr, struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, m0_bcount_t len, enum m0_balloc_allocation_flag alloc_type)
static bool balloc_got_freespace(const struct m0_balloc *ctx, m0_bcount_t blocks, uint64_t alloc_flags)
M0_INTERNAL void m0_be_btree_insert_credit(const struct m0_be_btree *tree, m0_bcount_t nr, m0_bcount_t ksize, m0_bcount_t vsize, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_be_tx_credit_mac(struct m0_be_tx_credit *c, const struct m0_be_tx_credit *c1, m0_bcount_t k)
#define m0_list_for_each_entry(head, pos, type, member)
static bool is_any(uint64_t alloc_flag)
M0_INTERNAL void m0_be_btree_destroy(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op)
static int gd_tree_cmp(const void *k0, const void *k1)
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
#define M0_BALLOC_DEFAULT_MAX_GROUPS_TO_SCAN
M0_INTERNAL void m0_ext_init(struct m0_ext *ext)
static int balloc_simple_scan_group(struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag)
static struct m0_balloc * b2m0(const struct m0_ad_balloc *ballroom)
struct m0_balloc_zone_param bgi_normal
struct m0_be_mutex cb_sb_mutex
struct m0_balloc_zone_param bgi_spare
M0_INTERNAL void m0_be_tx_credit_add(struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
M0_INTERNAL void m0_balloc_unlock_group(struct m0_balloc_group_info *grp)
M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
static int btree_update_sync(struct m0_be_btree *tree, struct m0_be_tx *tx, const struct m0_buf *key, const struct m0_buf *val)
M0_INTERNAL void m0_balloc_init(struct m0_balloc *cb)
static void balloc_fini(struct m0_ad_balloc *ballroom)
static int balloc_alloc(struct m0_ad_balloc *ballroom, struct m0_dtx *tx, m0_bcount_t count, struct m0_ext *out, uint64_t alloc_zone)
static struct ff2c_term * alloc(void)
M0_INTERNAL bool m0_ext_is_partof(const struct m0_ext *super, const struct m0_ext *sub)
M0_INTERNAL void m0_balloc_debug_dump_group_extent(const char *tag, struct m0_balloc_group_info *grp)
void * m0_alloc(size_t size)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
M0_INTERNAL void m0_balloc_debug_dump_group(const char *tag, struct m0_balloc_group_info *grp)
static int balloc_check_limits(struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, int end_of_group, enum m0_balloc_allocation_flag alloc_flag)
M0_INTERNAL void m0_be_btree_fini(struct m0_be_btree *tree)
static int balloc_init(struct m0_ad_balloc *ballroom, struct m0_be_seg *db, uint32_t bshift, m0_bcount_t container_size, m0_bcount_t blocks_per_group, m0_bcount_t spare_blocks_per_group)
m0_bcount_t bsb_stripe_size
static void lext_del(struct m0_lext *le)
struct m0_balloc * bac_ctxt
struct m0_sm_group * lo_grp
static int balloc_trees_create(struct m0_balloc *bal, struct m0_be_tx *tx, const struct m0_fid *fid)
M0_INTERNAL void m0_be_op_done(struct m0_be_op *op)
m0_bcount_t bzp_fragments
m0_bcount_t bsb_blocksize
static m0_bcount_t group_spare_maxchunk_get(struct m0_balloc_group_info *grp)
static int is_group_good_enough(struct balloc_allocation_context *bac, m0_bcount_t maxchunk, m0_bcount_t free, m0_bcount_t fragments)
static void balloc_group_write_credit(struct m0_balloc *bal, struct m0_be_tx_bulk *tb, struct balloc_groups_write_cfg *bgs, struct m0_be_tx_credit *credit)
static m0_bindex_t balloc_bn2gn(m0_bindex_t blockno, struct m0_balloc *cb)
static struct m0_clink l[NR]
struct m0_lext * bgi_extents
M0_INTERNAL bool m0_ext_is_empty(const struct m0_ext *ext)
static int balloc_try_best_found(struct balloc_allocation_context *bac, enum m0_balloc_allocation_flag alloc_flag)
static void balloc_alloc_credit(const struct m0_ad_balloc *balroom, int nr, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_be_btree_cursor_kv_get(struct m0_be_btree_cursor *cur, struct m0_buf *key, struct m0_buf *val)
static void balloc_format_init(struct m0_balloc *cb)
M0_INTERNAL void m0_be_tx_init(struct m0_be_tx *tx, uint64_t tid, struct m0_be_domain *dom, struct m0_sm_group *sm_group, m0_be_tx_cb_t persistent, m0_be_tx_cb_t discarded, void(*filler)(struct m0_be_tx *tx, void *payload), void *datum)
m0_bcount_t bsb_groupcount
M0_INTERNAL int m0_balloc_release_extents(struct m0_balloc_group_info *grp)
M0_INTERNAL void m0_be_btree_update(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_buf *key, const struct m0_buf *val)
static void balloc_db_update_credit(const struct m0_balloc *bal, int nr, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_be_btree_lookup_slant(struct m0_be_btree *tree, struct m0_be_op *op, struct m0_buf *key, struct m0_buf *value)
M0_INTERNAL bool m0_be_tx_bulk_put(struct m0_be_tx_bulk *tb, struct m0_be_op *op, struct m0_be_tx_credit *credit, m0_bcount_t payload_credit, uint64_t partition, void *user)
struct m0_pdclust_tgt_addr tgt
static uint64_t ext_range_locate(struct m0_ext *ip_ext, struct m0_balloc_group_info *grp)
static struct super_block sb
static long long min(long long a, long long b)
M0_INTERNAL void m0_be_op_active(struct m0_be_op *op)
M0_INTERNAL void m0_be_tx_bulk_fini(struct m0_be_tx_bulk *tb)
#define M0_BUF_INIT_PTR(p)
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
static int balloc_group_info_init(struct m0_balloc_group_info *gi, struct m0_balloc *cb)
M0_INTERNAL void m0_list_add_after(struct m0_list_link *anchor, struct m0_list_link *new)
static int balloc_sb_write(struct m0_balloc *bal, struct m0_balloc_format_req *req, struct m0_sm_group *grp)
static int sb_update(struct m0_balloc *bal, struct m0_sm_group *grp)
static void balloc_zone_init(struct m0_balloc_zone_param *zone, uint64_t type, m0_bcount_t start, m0_bcount_t size, m0_bcount_t freeblocks, m0_bcount_t fragments, m0_bcount_t maxchunk)
struct m0_format_header bgd_header
static int start(struct m0_fom *fom)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL m0_bcount_t m0_stob_ad_spares_calc(m0_bcount_t grp_blocks)
static int balloc_allocate_internal(struct m0_balloc *ctx, struct m0_be_tx *tx, struct m0_balloc_allocate_req *req)
M0_INTERNAL void m0_be_btree_init(struct m0_be_btree *tree, struct m0_be_seg *seg, const struct m0_be_btree_kv_ops *ops)
static m0_bcount_t group_spare_freeblocks_get(struct m0_balloc_group_info *grp)
M0_INTERNAL void m0_be_btree_cursor_init(struct m0_be_btree_cursor *cur, struct m0_be_btree *btree)
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
static m0_bcount_t group_freeblocks_get(struct m0_balloc_group_info *grp)
static struct m0_be_seg * seg
struct balloc_group_write_cfg * bgs_bgc
m0_balloc_allocation_flag
static int balloc_gi_sync(struct m0_balloc *cb, struct m0_be_tx *tx, struct m0_balloc_group_info *gi)
struct m0_balloc_super_block cb_sb
M0_INTERNAL int m0_be_btree_cursor_get_sync(struct m0_be_btree_cursor *cur, const struct m0_buf *key, bool slant)
static void extents_release(struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag zone_type)
m0_balloc_allocation_status
static int btree_delete_sync(struct m0_be_btree *tree, struct m0_be_tx *tx, const struct m0_buf *key)
static int balloc_group_info_load(struct m0_balloc *bal)
static void balloc_sb_sync(struct m0_balloc *cb, struct m0_be_tx *tx)
static int balloc_alloc_db_update(struct m0_balloc *motr, struct m0_be_tx *tx, struct m0_balloc_group_info *grp, struct m0_ext *tgt, uint64_t alloc_type, struct m0_ext *cur)
static int balloc_reserve_extent(struct m0_ad_balloc *ballroom, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t alloc_zone)
static struct m0_list_link * m0_list_first(const struct m0_list *head)
M0_INTERNAL void m0_list_add_tail(struct m0_list *head, struct m0_list_link *new)
static void balloc_fini_internal(struct m0_balloc *bal)
M0_INTERNAL struct m0_balloc_group_info * m0_balloc_gn2info(struct m0_balloc *cb, m0_bindex_t groupno)
static struct m0_list * group_normal_ext(struct m0_balloc_group_info *grp)
static void balloc_normalize_request(struct balloc_allocation_context *bac)
static void balloc_gi_sync_credit(const struct m0_balloc *cb, struct m0_be_tx_credit *accum)
struct m0_be_seg * cb_be_seg
static int sb_mount(struct m0_balloc *bal, struct m0_sm_group *grp)
struct m0_list_link le_link
m0_bcount_t bgd_freeblocks
static void balloc_group_info_fini(struct m0_balloc_group_info *gi)
static int balloc_wild_scan_group(struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag)
static struct m0_mutex * bgi_mutex(struct m0_balloc_group_info *grp)
static bool is_free_space_unavailable(struct m0_balloc_group_info *grp, uint64_t alloc_flags)
#define m0_list_entry(link, type, member)
static void balloc_sb_sync_credit(const struct m0_balloc *bal, struct m0_be_tx_credit *accum)
M0_INTERNAL void m0_balloc_group_desc_init(struct m0_balloc_group_desc *desc)
enum m0_balloc_allocation_flag bzp_type
static int balloc_measure_extent(struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag, struct m0_ext *ex, int end_of_group)
struct m0_format_header cb_header
static struct m0_lext * lext_create(struct m0_ext *ex)
M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)