Motr  M0
balloc.c File Reference
#include "lib/trace.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "dtm/dtm.h"
#include "be/tx_bulk.h"
#include "be/op.h"
#include "lib/misc.h"
#include "lib/errno.h"
#include "lib/arith.h"
#include "lib/locality.h"
#include "balloc.h"
#include "motr/magic.h"
Include dependency graph for balloc.c:

Go to the source code of this file.

Data Structures

struct  balloc_allocation_context
 
struct  balloc_group_write_cfg
 
struct  balloc_groups_write_cfg
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_BALLOC
 
#define MAX_ALLOCATION_CHUNK   2048ULL
 
#define M0_BALLOC_DEFAULT_MAX_TO_SCAN   200
 
#define M0_BALLOC_DEFAULT_MIN_TO_SCAN   10
 
#define M0_BALLOC_DEFAULT_MAX_GROUPS_TO_SCAN   5
 

Enumerations

enum  m0_balloc_allocation_status { M0_BALLOC_AC_FOUND = 1, M0_BALLOC_AC_CONTINUE = 2, M0_BALLOC_AC_BREAK = 3 }
 

Functions

static int btree_lookup_sync (struct m0_be_btree *tree, const struct m0_buf *key, struct m0_buf *val)
 
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)
 
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)
 
static int btree_delete_sync (struct m0_be_btree *tree, struct m0_be_tx *tx, const struct m0_buf *key)
 
static int is_group_good_enough (struct balloc_allocation_context *bac, m0_bcount_t maxchunk, m0_bcount_t free, m0_bcount_t fragments)
 
static m0_bindex_t zone_start_get (struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag)
 
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 m0_bcount_t group_spare_freeblocks_get (struct m0_balloc_group_info *grp)
 
static m0_bcount_t group_freeblocks_get (struct m0_balloc_group_info *grp)
 
static m0_bcount_t group_maxchunk_get (struct m0_balloc_group_info *grp)
 
static m0_bcount_t group_spare_maxchunk_get (struct m0_balloc_group_info *grp)
 
static m0_bcount_t group_fragments_get (struct m0_balloc_group_info *grp)
 
static m0_bcount_t group_spare_fragments_get (struct m0_balloc_group_info *grp)
 
static struct m0_listgroup_normal_ext (struct m0_balloc_group_info *grp)
 
static struct m0_listgroup_spare_ext (struct m0_balloc_group_info *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)
 
static uint64_t ext_range_locate (struct m0_ext *ip_ext, struct m0_balloc_group_info *grp)
 
static bool is_spare (uint64_t alloc_flags)
 
static bool is_normal (uint64_t alloc_flags)
 
static bool is_any (uint64_t alloc_flag)
 
static void balloc_debug_dump_extent (const char *tag, struct m0_ext *ex)
 
M0_INTERNAL void m0_balloc_debug_dump_group (const char *tag, struct m0_balloc_group_info *grp)
 
M0_INTERNAL void m0_balloc_debug_dump_group_extent (const char *tag, struct m0_balloc_group_info *grp)
 
M0_INTERNAL void m0_balloc_debug_dump_sb (const char *tag, struct m0_balloc_super_block *sb)
 
static m0_bindex_t balloc_bn2gn (m0_bindex_t blockno, struct m0_balloc *cb)
 
M0_INTERNAL struct m0_balloc_group_infom0_balloc_gn2info (struct m0_balloc *cb, m0_bindex_t groupno)
 
static struct m0_mutexbgi_mutex (struct m0_balloc_group_info *grp)
 
static void lext_del (struct m0_lext *le)
 
static struct m0_lextlext_create (struct m0_ext *ex)
 
static void extents_release (struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag zone_type)
 
M0_INTERNAL int m0_balloc_release_extents (struct m0_balloc_group_info *grp)
 
M0_INTERNAL void m0_balloc_lock_group (struct m0_balloc_group_info *grp)
 
M0_INTERNAL int m0_balloc_trylock_group (struct m0_balloc_group_info *grp)
 
M0_INTERNAL void m0_balloc_unlock_group (struct m0_balloc_group_info *grp)
 
M0_INTERNAL void m0_balloc_group_desc_init (struct m0_balloc_group_desc *desc)
 
static void balloc_format_init (struct m0_balloc *cb)
 
static int balloc_group_info_init (struct m0_balloc_group_info *gi, struct m0_balloc *cb)
 
static void balloc_group_info_fini (struct m0_balloc_group_info *gi)
 
static int balloc_group_info_load (struct m0_balloc *bal)
 
static void balloc_fini_internal (struct m0_balloc *bal)
 
static m0_bcount_t ge_tree_kv_size (const void *kv)
 
static int ge_tree_cmp (const void *k0, const void *k1)
 
static m0_bcount_t gd_tree_key_size (const void *k)
 
static m0_bcount_t gd_tree_val_size (const void *v)
 
static int gd_tree_cmp (const void *k0, const void *k1)
 
static void balloc_sb_sync (struct m0_balloc *cb, struct m0_be_tx *tx)
 
static int sb_update (struct m0_balloc *bal, struct m0_sm_group *grp)
 
static int balloc_sb_write (struct m0_balloc *bal, struct m0_balloc_format_req *req, struct m0_sm_group *grp)
 
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 void balloc_group_work_put (struct m0_balloc *bal, struct m0_be_tx_bulk *tb, struct balloc_groups_write_cfg *bgs)
 
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)
 
static void balloc_group_write_done (struct m0_be_tx_bulk *tb, void *datum, void *user, uint64_t worker_index, uint64_t partition)
 
static int balloc_groups_write (struct m0_balloc *bal)
 
static int balloc_format (struct m0_balloc *bal, struct m0_balloc_format_req *req, struct m0_sm_group *grp)
 
static void balloc_gi_sync_credit (const struct m0_balloc *cb, struct m0_be_tx_credit *accum)
 
static int balloc_gi_sync (struct m0_balloc *cb, struct m0_be_tx *tx, struct m0_balloc_group_info *gi)
 
static int sb_mount (struct m0_balloc *bal, struct m0_sm_group *grp)
 
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 int balloc_init_ac (struct balloc_allocation_context *bac, struct m0_balloc *motr, struct m0_be_tx *tx, struct m0_balloc_allocate_req *req)
 
static int balloc_use_prealloc (struct balloc_allocation_context *bac)
 
static bool balloc_got_freespace (const struct m0_balloc *ctx, m0_bcount_t blocks, uint64_t alloc_flags)
 
static void balloc_normalize_group_request (struct balloc_allocation_context *bac)
 
static void balloc_normalize_request (struct balloc_allocation_context *bac)
 
static void zone_params_update (struct m0_balloc_group_info *grp, struct m0_ext *ext, uint64_t balloc_zone)
 
M0_INTERNAL int m0_balloc_load_extents (struct m0_balloc *cb, struct m0_balloc_group_info *grp)
 
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 int balloc_use_best_found (struct balloc_allocation_context *bac, m0_bindex_t start)
 
static int balloc_new_preallocation (struct balloc_allocation_context *bac)
 
static void balloc_sb_sync_credit (const struct m0_balloc *bal, struct m0_be_tx_credit *accum)
 
static void balloc_db_update_credit (const struct m0_balloc *bal, int nr, struct m0_be_tx_credit *accum)
 
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 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_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)
 
static int balloc_is_good_group (struct balloc_allocation_context *bac, struct m0_balloc_group_info *gi)
 
static int balloc_simple_scan_group (struct balloc_allocation_context *bac, struct m0_balloc_group_info *grp, enum m0_balloc_allocation_flag alloc_flag)
 
 __attribute__ ((unused))
 
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)
 
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)
 
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 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)
 
static bool is_free_space_unavailable (struct m0_balloc_group_info *grp, uint64_t alloc_flags)
 
static int balloc_regular_allocator (struct balloc_allocation_context *bac)
 
static int balloc_allocate_internal (struct m0_balloc *ctx, struct m0_be_tx *tx, struct m0_balloc_allocate_req *req)
 
static void balloc_free_credit (const struct m0_ad_balloc *balroom, int nr, struct m0_be_tx_credit *accum)
 
static int balloc_free_internal (struct m0_balloc *ctx, struct m0_be_tx *tx, struct m0_balloc_free_req *req)
 
static int balloc_reserve_extent (struct m0_ad_balloc *ballroom, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t alloc_zone)
 
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 int balloc_free (struct m0_ad_balloc *ballroom, struct m0_dtx *tx, struct m0_ext *ext)
 
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)
 
static void balloc_fini (struct m0_ad_balloc *ballroom)
 
static int balloc_trees_create (struct m0_balloc *bal, struct m0_be_tx *tx, const struct m0_fid *fid)
 
M0_INTERNAL void m0_balloc_init (struct m0_balloc *cb)
 
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)
 

Variables

static const struct m0_be_btree_kv_ops ge_btree_ops
 
static const struct m0_be_btree_kv_ops gd_btree_ops
 
static const struct m0_ad_balloc_ops balloc_ops
 

Macro Definition Documentation

◆ M0_BALLOC_DEFAULT_MAX_GROUPS_TO_SCAN

#define M0_BALLOC_DEFAULT_MAX_GROUPS_TO_SCAN   5

Definition at line 2142 of file balloc.c.

◆ M0_BALLOC_DEFAULT_MAX_TO_SCAN

#define M0_BALLOC_DEFAULT_MAX_TO_SCAN   200

Definition at line 2132 of file balloc.c.

◆ M0_BALLOC_DEFAULT_MIN_TO_SCAN

#define M0_BALLOC_DEFAULT_MIN_TO_SCAN   10

Definition at line 2137 of file balloc.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_BALLOC

Definition at line 23 of file balloc.c.

◆ MAX_ALLOCATION_CHUNK

#define MAX_ALLOCATION_CHUNK   2048ULL

Definition at line 339 of file balloc.c.

Enumeration Type Documentation

◆ m0_balloc_allocation_status

M0 Data Block Allocator. BALLOC is a multi-block allocator, with pre-allocation. All metadata about block allocation is stored in BE segment.

Enumerator
M0_BALLOC_AC_FOUND 
M0_BALLOC_AC_CONTINUE 
M0_BALLOC_AC_BREAK 

Definition at line 50 of file balloc.c.

Function Documentation

◆ __attribute__()

__attribute__ ( (unused)  )

Discard the pre-allocation for object.

Parameters
ctxballoc operation context environment.
reqdiscard request which includes all parameters.
Returns
0 means success. Upon failure, non-zero error number is returned.

modify the allocation status forcibly.

This function may be used by fsck or some other tools to modify the allocation status directly.

Parameters
ctxballoc operation context environment.
alloctrue to make the specifed extent as allocated, otherwise make the extent as free.
extuser supplied extent to check.
Returns
0 means success. Upon failure, non-zero error number is returned.

Query the allocation status.

Parameters
ctxballoc operation context environment.
extuser supplied extent to check.
Returns
true if the extent is fully allocated. Otherwise, false is returned.

Definition at line 2122 of file balloc.c.

◆ allocate_blocks()

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

Definition at line 2540 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_alloc()

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

allocate from underlying container.

Parameters
countcount of bytes. count will be first aligned to block boundry.
outresult is stored there. space is still in bytes.

Definition at line 2866 of file balloc.c.

Here is the call graph for this function:

◆ balloc_alloc_credit()

static void balloc_alloc_credit ( const struct m0_ad_balloc balroom,
int  nr,
struct m0_be_tx_credit accum 
)
static

Definition at line 2371 of file balloc.c.

Here is the call graph for this function:

◆ balloc_alloc_db_update()

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

Definition at line 1558 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_allocate_internal()

static int balloc_allocate_internal ( struct m0_balloc ctx,
struct m0_be_tx tx,
struct m0_balloc_allocate_req req 
)
static

Allocate multiple blocks for some object.

This routine will search suitable free space, and determine where to allocate from. Caller can provide some hint (goal). Pre-allocation is used depending the character of the I/O sequences, and the current state of the active I/O. When trying allocate blocks from free space, we will allocate from the best suitable chunks, which are represented as buddy.

Allocation will first try to use pre-allocation if it exists. Pre-allocation can be per-object, or group based.

This routine will first check the group description to see if enough free space is available, and if largest contiguous chunk satisfy the request. This checking will be done group by group, until allocation succeeded or failed. If failed, the largest available contiguous chunk size is returned, and the caller can decide whether to use a smaller request.

While searching free space from group to group, the free space extent will be loaded into cache. We cache as much free space extent up to some specified memory limitation. This is a configurable parameter, or default value will be chosen based on system memory.

Parameters
ctxballoc operation context environment.
reqallocate request which includes all parameters.
Returns
0 means success. Result allocated blocks are again stored in "req": result physical block number = bar_physical, result count of blocks = bar_len. Upon failure, non-zero error number is returned.

Definition at line 2600 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_bn2gn()

static m0_bindex_t balloc_bn2gn ( m0_bindex_t  blockno,
struct m0_balloc cb 
)
inlinestatic

Definition at line 255 of file balloc.c.

Here is the caller graph for this function:

◆ balloc_check_limits()

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 
)
static

Definition at line 2145 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_db_update_credit()

static void balloc_db_update_credit ( const struct m0_balloc bal,
int  nr,
struct m0_be_tx_credit accum 
)
static

Definition at line 1508 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_debug_dump_extent()

static void balloc_debug_dump_extent ( const char *  tag,
struct m0_ext ex 
)
static

Definition at line 160 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_find_extent_buddy()

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

Definition at line 1400 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_fini()

static void balloc_fini ( struct m0_ad_balloc ballroom)
static

Definition at line 2960 of file balloc.c.

Here is the call graph for this function:

◆ balloc_fini_internal()

static void balloc_fini_internal ( struct m0_balloc bal)
static

finalization of the balloc environment.

Definition at line 434 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_format()

static int balloc_format ( struct m0_balloc bal,
struct m0_balloc_format_req req,
struct m0_sm_group grp 
)
static

Format the container: create database, fill them with initial information.

This routine will create a "super_block" database to store global parameters for this container. It will also create "group free extent" and "group_desc" for every group. If some groups are reserved for special purpose, then they will be marked as "allocated" at the format time, and those groups will not be used by normal allocation routines.

Parameters
reqpointer to this format request. All configuration will be passed by this parameter.
Returns
0 means success. Otherwise, error number will be returned.

XXX Kludge.

It should be removed after either fdatasync() for stobs is moved to ioq thread or direct I/O is used for seg I/O.

The problem is that currently fdatasync() for seg stob is done in locality0 thread. If it's locked then it's possible that engine will wait for fdatasync() and ast that does fdatasync() can't be executed because locality0 is locked.

Definition at line 864 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_format_init()

static void balloc_format_init ( struct m0_balloc cb)
static

Definition at line 351 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_free()

static int balloc_free ( struct m0_ad_balloc ballroom,
struct m0_dtx tx,
struct m0_ext ext 
)
static

free spaces to container.

Parameters
extthe space to be freed. This space must align to block boundry.

Definition at line 2917 of file balloc.c.

Here is the call graph for this function:

◆ balloc_free_credit()

static void balloc_free_credit ( const struct m0_ad_balloc balroom,
int  nr,
struct m0_be_tx_credit accum 
)
static

Definition at line 2636 of file balloc.c.

Here is the call graph for this function:

◆ balloc_free_db_update()

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 
)
static

Definition at line 1689 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_free_internal()

static int balloc_free_internal ( struct m0_balloc ctx,
struct m0_be_tx tx,
struct m0_balloc_free_req req 
)
static

Free multiple blocks owned by some object to free space.

Parameters
ctxballoc operation context environment.
reqblock free request which includes all parameters.
Returns
0 means success. Upon failure, non-zero error number is returned.

Definition at line 2649 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_gi_sync()

static int balloc_gi_sync ( struct m0_balloc cb,
struct m0_be_tx tx,
struct m0_balloc_group_info gi 
)
static

Definition at line 901 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_gi_sync_credit()

static void balloc_gi_sync_credit ( const struct m0_balloc cb,
struct m0_be_tx_credit accum 
)
static

Definition at line 894 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_got_freespace()

static bool balloc_got_freespace ( const struct m0_balloc ctx,
m0_bcount_t  blocks,
uint64_t  alloc_flags 
)
static

Checks if enough free blocks are present in super block.

Parameters
ctxballoc operation context environment.
blocksnumber of requested blocks.
alloc_flagsallocation type.
Returns
true on enough free blocks. false on requested number of free blocks not available.

Definition at line 1073 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_info_fini()

static void balloc_group_info_fini ( struct m0_balloc_group_info gi)
static

Definition at line 402 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_info_init()

static int balloc_group_info_init ( struct m0_balloc_group_info gi,
struct m0_balloc cb 
)
static

Definition at line 361 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_info_load()

static int balloc_group_info_load ( struct m0_balloc bal)
static

Definition at line 409 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_work_put()

static void balloc_group_work_put ( struct m0_balloc bal,
struct m0_be_tx_bulk tb,
struct balloc_groups_write_cfg bgs 
)
static

Definition at line 651 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_write_credit()

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

Definition at line 638 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_write_do()

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 
)
static

Definition at line 682 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_group_write_done()

static void balloc_group_write_done ( struct m0_be_tx_bulk tb,
void *  datum,
void *  user,
uint64_t  worker_index,
uint64_t  partition 
)
static

Definition at line 766 of file balloc.c.

Here is the caller graph for this function:

◆ balloc_groups_write()

static int balloc_groups_write ( struct m0_balloc bal)
static

Definition at line 790 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_init()

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 
)
static

Definition at line 2940 of file balloc.c.

Here is the call graph for this function:

◆ balloc_init_ac()

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 
)
static

Definition at line 1007 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_init_internal()

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

Definition at line 952 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_is_good_group()

static int balloc_is_good_group ( struct balloc_allocation_context bac,
struct m0_balloc_group_info gi 
)
static

Definition at line 2007 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_measure_extent()

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 
)
static

Definition at line 2183 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_new_preallocation()

static int balloc_new_preallocation ( struct balloc_allocation_context bac)
static

Definition at line 1490 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_normalize_group_request()

static void balloc_normalize_group_request ( struct balloc_allocation_context bac)
static

Definition at line 1098 of file balloc.c.

Here is the caller graph for this function:

◆ balloc_normalize_request()

static void balloc_normalize_request ( struct balloc_allocation_context bac)
static

Definition at line 1107 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_regular_allocator()

static int balloc_regular_allocator ( struct balloc_allocation_context bac)
static

Definition at line 2398 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_reserve_extent()

static int balloc_reserve_extent ( struct m0_ad_balloc ballroom,
struct m0_be_tx tx,
struct m0_ext ext,
uint64_t  alloc_zone 
)
static

Marks given extent as used in the allocator.

Parameters
extrequested extent for block reservation.
alloc_zoneallocation zone.
Returns
0 on successful reservation of the extent. -ENOSPC on not enough space in superblock/group/fragment. -EEXIST on overlap extent. -errno on other failures, non-zero error number is returned.

Definition at line 2796 of file balloc.c.

Here is the call graph for this function:

◆ balloc_sb_sync()

static void balloc_sb_sync ( struct m0_balloc cb,
struct m0_be_tx tx 
)
static

Definition at line 500 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_sb_sync_credit()

static void balloc_sb_sync_credit ( const struct m0_balloc bal,
struct m0_be_tx_credit accum 
)
static

Definition at line 1500 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_sb_write()

static int balloc_sb_write ( struct m0_balloc bal,
struct m0_balloc_format_req req,
struct m0_sm_group grp 
)
static

Definition at line 550 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_simple_scan_group()

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

Definition at line 2069 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_trees_create()

static int balloc_trees_create ( struct m0_balloc bal,
struct m0_be_tx tx,
const struct m0_fid fid 
)
static

Definition at line 2981 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_try_best_found()

static int balloc_try_best_found ( struct balloc_allocation_context bac,
enum m0_balloc_allocation_flag  alloc_flag 
)
static

Definition at line 2310 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_use_best_found()

static int balloc_use_best_found ( struct balloc_allocation_context bac,
m0_bindex_t  start 
)
static

Definition at line 1467 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_use_prealloc()

static int balloc_use_prealloc ( struct balloc_allocation_context bac)
static

Definition at line 1044 of file balloc.c.

Here is the caller graph for this function:

◆ balloc_wild_scan_group()

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

This function scans the specified group for a goal. If maximal group is locked.

Check to detect the block allocation request which came earlier for criteria 1 on same group and come again for criteria 2 with already set best extent. In criteria 1 bac_status not marked to M0_BALLOC_AC_FOUND because bac_found < M0_BALLOC_DEFAULT_MIN_TO_SCAN Now with criteria 2 on same group with already set best extent may not part of extent in free extent list because another requests may have updated extents in free list. Reset best extent by detecting this case so that it will find correct best extent, also set end_of_group flag so balloc_check_limits() could call balloc_use_best_found() to set final extent from best extent.

Definition at line 2234 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balloc_zone_init()

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 
)
static

Definition at line 776 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bgi_mutex()

static struct m0_mutex* bgi_mutex ( struct m0_balloc_group_info grp)
static

Definition at line 266 of file balloc.c.

Here is the caller graph for this function:

◆ btree_delete_sync()

static int btree_delete_sync ( struct m0_be_btree tree,
struct m0_be_tx tx,
const struct m0_buf key 
)
inlinestatic

Definition at line 100 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ btree_insert_sync()

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 
)
inlinestatic

Definition at line 80 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ btree_lookup_sync()

static int btree_lookup_sync ( struct m0_be_btree tree,
const struct m0_buf key,
struct m0_buf val 
)
inlinestatic

Definition at line 72 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ btree_update_sync()

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 
)
inlinestatic

Definition at line 90 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ext_range_locate()

static uint64_t ext_range_locate ( struct m0_ext ip_ext,
struct m0_balloc_group_info grp 
)
static

Definition at line 2728 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extents_release()

static void extents_release ( struct m0_balloc_group_info grp,
enum m0_balloc_allocation_flag  zone_type 
)
static

Definition at line 292 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gd_tree_cmp()

static int gd_tree_cmp ( const void *  k0,
const void *  k1 
)
static

Definition at line 488 of file balloc.c.

Here is the call graph for this function:

◆ gd_tree_key_size()

static m0_bcount_t gd_tree_key_size ( const void *  k)
static

Definition at line 478 of file balloc.c.

Here is the caller graph for this function:

◆ gd_tree_val_size()

static m0_bcount_t gd_tree_val_size ( const void *  v)
static

Definition at line 483 of file balloc.c.

◆ ge_tree_cmp()

static int ge_tree_cmp ( const void *  k0,
const void *  k1 
)
static

Definition at line 463 of file balloc.c.

◆ ge_tree_kv_size()

static m0_bcount_t ge_tree_kv_size ( const void *  kv)
static

Definition at line 458 of file balloc.c.

◆ group_fragments_get()

static m0_bcount_t group_fragments_get ( struct m0_balloc_group_info grp)
static

Definition at line 133 of file balloc.c.

Here is the caller graph for this function:

◆ group_freeblocks_get()

static m0_bcount_t group_freeblocks_get ( struct m0_balloc_group_info grp)
static

Definition at line 121 of file balloc.c.

Here is the caller graph for this function:

◆ group_maxchunk_get()

static m0_bcount_t group_maxchunk_get ( struct m0_balloc_group_info grp)
static

Definition at line 125 of file balloc.c.

Here is the caller graph for this function:

◆ group_normal_ext()

static struct m0_list* group_normal_ext ( struct m0_balloc_group_info grp)
static

Definition at line 141 of file balloc.c.

Here is the caller graph for this function:

◆ group_spare_ext()

static struct m0_list* group_spare_ext ( struct m0_balloc_group_info grp)
static

Definition at line 145 of file balloc.c.

Here is the caller graph for this function:

◆ group_spare_fragments_get()

static m0_bcount_t group_spare_fragments_get ( struct m0_balloc_group_info grp)
static

Definition at line 137 of file balloc.c.

Here is the caller graph for this function:

◆ group_spare_freeblocks_get()

static m0_bcount_t group_spare_freeblocks_get ( struct m0_balloc_group_info grp)
static

Definition at line 117 of file balloc.c.

Here is the caller graph for this function:

◆ group_spare_maxchunk_get()

static m0_bcount_t group_spare_maxchunk_get ( struct m0_balloc_group_info grp)
static

Definition at line 129 of file balloc.c.

Here is the caller graph for this function:

◆ is_any()

static bool is_any ( uint64_t  alloc_flag)
static

Definition at line 1059 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_extent_free()

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

Checks if requested extent is free in target group.

Parameters
[in]grptarget group.
[in]tgtrequested extent.
[in]alloc_typeallocation type.
[out]currentfree extent in target group for requested extent.
Returns
true if extent is free. false if extent is already allocated.

Definition at line 1537 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_free_space_unavailable()

static bool is_free_space_unavailable ( struct m0_balloc_group_info grp,
uint64_t  alloc_flags 
)
static

Definition at line 2385 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_group_good_enough()

static int is_group_good_enough ( struct balloc_allocation_context bac,
m0_bcount_t  maxchunk,
m0_bcount_t  free,
m0_bcount_t  fragments 
)
static

Definition at line 2031 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_normal()

static bool is_normal ( uint64_t  alloc_flags)
static

Definition at line 1054 of file balloc.c.

Here is the caller graph for this function:

◆ is_spare()

static bool is_spare ( uint64_t  alloc_flags)
static

Definition at line 1049 of file balloc.c.

Here is the caller graph for this function:

◆ lext_create()

static struct m0_lext* lext_create ( struct m0_ext ex)
static

Definition at line 278 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lext_del()

static void lext_del ( struct m0_lext le)
static

Definition at line 271 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sb_mount()

static int sb_mount ( struct m0_balloc bal,
struct m0_sm_group grp 
)
static

Definition at line 935 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sb_update()

static int sb_update ( struct m0_balloc bal,
struct m0_sm_group grp 
)
static

Definition at line 523 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_params_update()

static void zone_params_update ( struct m0_balloc_group_info grp,
struct m0_ext ext,
uint64_t  balloc_zone 
)
static

Definition at line 1261 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_start_get()

static m0_bindex_t zone_start_get ( struct m0_balloc_group_info grp,
enum m0_balloc_allocation_flag  alloc_flag 
)
static

Definition at line 2115 of file balloc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ balloc_ops

const struct m0_ad_balloc_ops balloc_ops
static
Initial value:
= {
.bo_init = balloc_init,
.bo_fini = balloc_fini,
.bo_alloc = balloc_alloc,
.bo_free = balloc_free,
.bo_alloc_credit = balloc_alloc_credit,
.bo_free_credit = balloc_free_credit,
.bo_reserve_extent = balloc_reserve_extent,
}
static int balloc_free(struct m0_ad_balloc *ballroom, struct m0_dtx *tx, struct m0_ext *ext)
Definition: balloc.c:2917
static void balloc_free_credit(const struct m0_ad_balloc *balroom, int nr, struct m0_be_tx_credit *accum)
Definition: balloc.c:2636
static void balloc_fini(struct m0_ad_balloc *ballroom)
Definition: balloc.c:2960
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)
Definition: balloc.c:2866
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)
Definition: balloc.c:2940
static void balloc_alloc_credit(const struct m0_ad_balloc *balroom, int nr, struct m0_be_tx_credit *accum)
Definition: balloc.c:2371
static int balloc_reserve_extent(struct m0_ad_balloc *ballroom, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t alloc_zone)
Definition: balloc.c:2796

Definition at line 2971 of file balloc.c.

◆ gd_btree_ops

const struct m0_be_btree_kv_ops gd_btree_ops
static
Initial value:
= {
.ko_ksize = gd_tree_key_size,
.ko_vsize = gd_tree_val_size,
.ko_compare = gd_tree_cmp
}
static m0_bcount_t gd_tree_key_size(const void *k)
Definition: balloc.c:478
static m0_bcount_t gd_tree_val_size(const void *v)
Definition: balloc.c:483
static int gd_tree_cmp(const void *k0, const void *k1)
Definition: balloc.c:488

Definition at line 493 of file balloc.c.

◆ ge_btree_ops

const struct m0_be_btree_kv_ops ge_btree_ops
static
Initial value:
= {
.ko_ksize = ge_tree_kv_size,
.ko_vsize = ge_tree_kv_size,
.ko_compare = ge_tree_cmp
}
static m0_bcount_t ge_tree_kv_size(const void *kv)
Definition: balloc.c:458
static int ge_tree_cmp(const void *k0, const void *k1)
Definition: balloc.c:463

Definition at line 471 of file balloc.c.