Motr  M0
m0hsm_api.c File Reference
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/time.h>
#include <getopt.h>
#include <stdarg.h>
#include "lib/trace.h"
#include "conf/obj.h"
#include "fid/fid.h"
#include "motr/idx.h"
#include "motr/layout.h"
#include "m0hsm_api.h"
#include "motr/magic.h"
Include dependency graph for m0hsm_api.c:

Go to the source code of this file.

Data Structures

struct  extent
 
struct  param
 
struct  io_ctx
 
struct  min_gen_check_arg
 
struct  release_cb_ctx
 
struct  copy_cb_ctx
 

Macros

#define MAX_BLOCK_COUNT   (200)
 
#define HSM_EXTENT_SCAN_BATCH   8
 
#define ERROR(_fmt, ...)
 
#define INFO(_fmt, ...)
 
#define VERB(_fmt, ...)
 
#define DBG(_fmt, ...)
 
#define ENTRY   DBG("> ENTERING %s()\n", __func__)
 
#define RETURN(_rc)
 
#define HSM_ANY_TIER   UINT8_MAX
 
#define HSM_ID_MASK_HI   (1LL<<31)
 
#define MAX(_x, _y)   ((_x) > (_y) ? (_x) : (_y))
 
#define MIN(_x, _y)   ((_x) < (_y) ? (_x) : (_y))
 

Typedefs

typedef int(* match_layer_cb_t) (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *layer, const struct extent *match, bool *stop)
 

Enumerations

enum  { MAX_LEN =128, MAX_POOLS = 16 }
 
enum  ext_match_code { EM_ERROR = -1, EM_NONE = 0, EM_PARTIAL = (1 << 0), EM_FULL = (1 << 2) }
 
enum  ext_match_type { EMT_INTERSECT, EMT_MERGE }
 

Functions

static int read_params (FILE *in, struct param *p, int max_params)
 
static int hsm_pool_fid_set (struct param *p)
 
static int hsm_pools_fids_set (struct param p[], int n)
 
int m0hsm_init (struct m0_client *instance, struct m0_realm *uber_realm, const struct m0hsm_options *in_options)
 
static bool is_hsm_reserved (struct m0_uint128 id)
 
static uint32_t hsm_prio (uint32_t generation, uint8_t tier_idx)
 
static struct m0_uint128 hsm_subobj_id (struct m0_uint128 id, uint32_t gen, uint8_t tier)
 
static uint32_t hsm_prio2gen (uint32_t priority)
 
static uint8_t hsm_prio2tier (uint32_t priority)
 
static struct m0_fidhsm_tier2pool (uint8_t tier_idx)
 
static int open_entity (struct m0_entity *entity)
 
static int create_obj (struct m0_uint128 id, struct m0_obj *obj, bool close_entity, uint8_t tier_idx)
 
static int delete_obj (struct m0_uint128 id) __attribute__((unused))
 
static int create_obj_with_layout (struct m0_uint128 id, struct m0_obj *obj, struct m0_client_layout *layout, bool close_entity)
 
static int delete_obj_set_parent_layout (struct m0_uint128 id, struct m0_uint128 parent_id, struct m0_client_layout *parent_layout)
 
static int obj_layout_get (struct m0_obj *obj, struct m0_client_layout **layout)
 
static int layout_get (struct m0_uint128 id, struct m0_client_layout **layout)
 
static int obj_layout_set (struct m0_obj *obj, struct m0_client_layout *layout)
 
static int layout_set (struct m0_uint128 id, struct m0_client_layout *layout)
 
 M0_TL_DESCR_DEFINE (clayer, "composite layout layers", static, struct m0_composite_layer, ccr_tlink, ccr_tlink_magic, M0_CLAYER_TL_MAGIC, M0_CLAYER_TL_MAGIC)
 
 M0_TL_DEFINE (clayer, static, struct m0_composite_layer)
 
 M0_TL_DESCR_DEFINE (cext, "composite layout extents", static, struct m0_composite_extent, ce_tlink, ce_tlink_magic, M0_CEXT_TL_MAGIC, M0_CEXT_TL_MAGIC)
 
 M0_TL_DEFINE (cext, static, struct m0_composite_extent)
 
static int get_next_extents (struct m0_idx *idx, struct m0_bufvec *keys, struct m0_bufvec *vals, int *rc_list, int32_t flags)
 
static int read_extent_keys (struct m0_uint128 subobjid, struct m0_bufvec *keys, struct m0_bufvec *vals, int *rc_list, struct m0_tl *ext_list, struct m0_composite_layer_idx_key *last_key)
 
static void extent_list_free (struct m0_tl *ext_list)
 
static void reset_bufvec (struct m0_bufvec *keys, int count)
 
static int layer_load_extent_list (struct m0_uint128 subobjid, bool write, struct m0_tl *ext_list)
 
static void print_extents (FILE *stream, const struct m0_tl *ext_list, bool details)
 
static void print_layer (FILE *stream, struct m0_composite_layer *layer, bool details)
 
static void print_layout (FILE *stream, const struct m0_client_layout *layout, bool details)
 
int m0hsm_dump (FILE *stream, struct m0_uint128 id, bool details)
 
static int layer_extent_add (struct m0_uint128 subobjid, const struct extent *ext, bool write, bool overwrite)
 
static int layer_extent_del (struct m0_uint128 subobjid, off_t off, bool write)
 
static void layout_top_prio (struct m0_client_layout *layout, int32_t *max_gen, struct m0_uint128 *max_gen_id, uint8_t *top_tier)
 
static int layer_clean (struct m0_uint128 parent_id, struct m0_client_layout *layout, struct m0_composite_layer *layer)
 
static int layer_check_clean (struct m0_uint128 parent_id, struct m0_client_layout *layout, struct m0_composite_layer *layer)
 
static int layout_layer_clean (struct m0_uint128 parent_id, struct m0_client_layout *layout, struct m0_uint128 subobj_id)
 
static int layout_add_top_layer (struct m0_uint128 id, struct m0_client_layout *layout, uint8_t tier)
 
static struct m0_composite_layertop_layer_get (struct m0_client_layout *layout)
 
int m0hsm_set_write_tier (struct m0_uint128 id, uint8_t tier_idx)
 
static enum ext_match_code ext_match (struct m0_uint128 layer_id, struct m0_tl *ext_list, const struct extent *ext_in, struct extent *match, enum ext_match_type mode, bool is_write, bool del_prev)
 
static int ext_subtract (struct m0_uint128 layer_id, struct m0_tl *ext_list, const struct extent *ext_in, bool is_write, bool *layer_empty)
 
static int add_merge_read_extent (struct m0_composite_layer *layer, const struct extent *ext_in)
 
static int m0hsm_release_maxgen (struct m0_uint128 id, uint8_t tier, int max_gen, off_t offset, size_t len, enum hsm_rls_flags flags, bool user_display)
 
static int top_layer_add_read_extent (struct m0_obj *obj, const struct extent *ext)
 
int m0hsm_create (struct m0_uint128 id, struct m0_obj *obj, uint8_t tier_idx, bool keep_open)
 
static int do_io_op (struct m0_obj *obj, enum m0_obj_opcode opcode, struct io_ctx *ctx)
 
static int write_blocks (struct m0_obj *obj, struct io_ctx *ctx)
 
static int read_blocks (struct m0_obj *obj, struct io_ctx *ctx)
 
static void gen_data (struct m0_bufvec *data, size_t bsize, int seed)
 
static void dump_data (struct m0_bufvec *data, size_t bsize)
 
static int prepare_io_ctx (struct io_ctx *ctx, int blocks, size_t block_size, bool alloc_io_buff)
 
static int check_vec (struct m0_bufvec *vec, int blocks)
 
static int map_io_ctx (struct io_ctx *ctx, int blocks, size_t b_size, off_t offset, char *buff)
 
static void free_io_ctx (struct io_ctx *ctx, bool alloc_io_buff)
 
static uint64_t roundup_power2 (uint64_t x)
 
uint64_t get_optimal_bs (struct m0_obj *obj, uint64_t obj_sz)
 
int m0hsm_test_write (struct m0_uint128 id, off_t offset, size_t len, int seed)
 
int m0hsm_pwrite (struct m0_obj *obj, void *buffer, size_t length, off_t offset)
 
int m0hsm_test_read (struct m0_uint128 id, off_t offset, size_t len)
 
static int copy_extent_data (struct m0_uint128 src_id, struct m0_uint128 tgt_id, const struct extent *range)
 
static int check_top_layer_writable (struct m0_client_layout *layout, int max_prio, int tier)
 
static int match_layer_foreach (struct m0_client_layout *layout, uint8_t tier, const struct extent *ext, match_layer_cb_t cb, void *cb_arg, bool stop_on_error)
 
static struct m0_composite_layerlayer_get_by_prio (struct m0_client_layout *layout, int prio)
 
static int min_gen_check_cb (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *layer, const struct extent *match, bool *stop)
 
static int check_min_gen_exists (struct m0_client_layout *layout, const struct extent *ext, int gen, struct m0_composite_layer *except_layer)
 
static int release_cb (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *layer, const struct extent *match, bool *stop)
 
int m0hsm_release (struct m0_uint128 id, uint8_t tier, off_t offset, size_t len, enum hsm_rls_flags flags)
 
int m0hsm_multi_release (struct m0_uint128 id, uint8_t max_tier, off_t offset, size_t length, enum hsm_rls_flags flags)
 
static int copy_cb (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *src_layer, const struct extent *match, bool *stop)
 
int m0hsm_copy (struct m0_uint128 id, uint8_t src_tier, uint8_t tgt_tier, off_t offset, size_t len, enum hsm_cp_flags flags)
 
static int stage_cb (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *src_layer, const struct extent *match, bool *stop)
 
int m0hsm_stage (struct m0_uint128 id, uint8_t tgt_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
 
static int archive_cb (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *src_layer, const struct extent *match, bool *stop)
 
int m0hsm_archive (struct m0_uint128 id, uint8_t tgt_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
 

Variables

struct m0hsm_options options
 
static struct m0_clientm0_instance
 
static struct m0_realmm0_uber_realm
 
static const struct extent EXT_FULLRANGE
 
static struct param hsm_rc_params [128]
 
static struct m0_fid hsm_pools [MAX_POOLS] = {}
 

Macro Definition Documentation

◆ DBG

#define DBG (   _fmt,
  ... 
)
Value:
fprintf(options.log_stream, _fmt, ##__VA_ARGS__)
FILE * log_stream
Definition: m0hsm_api.h:56
struct m0hsm_options options
Definition: m0hsm_api.c:56
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52

Definition at line 72 of file m0hsm_api.c.

◆ ENTRY

#define ENTRY   DBG("> ENTERING %s()\n", __func__)

Definition at line 75 of file m0hsm_api.c.

◆ ERROR

#define ERROR (   _fmt,
  ... 
)
Value:
fprintf(options.log_stream, _fmt, ##__VA_ARGS__)
FILE * log_stream
Definition: m0hsm_api.h:56
struct m0hsm_options options
Definition: m0hsm_api.c:56
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52

Definition at line 66 of file m0hsm_api.c.

◆ HSM_ANY_TIER

#define HSM_ANY_TIER   UINT8_MAX

Special value meaning any tier.

Definition at line 202 of file m0hsm_api.c.

◆ HSM_EXTENT_SCAN_BATCH

#define HSM_EXTENT_SCAN_BATCH   8

batch create + set_layout operation? How many extents we get in a batch from the extent index (arbitrary)

Definition at line 53 of file m0hsm_api.c.

◆ HSM_ID_MASK_HI

#define HSM_ID_MASK_HI   (1LL<<31)

Definition at line 205 of file m0hsm_api.c.

◆ INFO

#define INFO (   _fmt,
  ... 
)
Value:
fprintf(options.log_stream, _fmt, ##__VA_ARGS__)
FILE * log_stream
Definition: m0hsm_api.h:56
struct m0hsm_options options
Definition: m0hsm_api.c:56
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52

Definition at line 68 of file m0hsm_api.c.

◆ MAX

#define MAX (   _x,
  _y 
)    ((_x) > (_y) ? (_x) : (_y))

Definition at line 1264 of file m0hsm_api.c.

◆ MAX_BLOCK_COUNT

#define MAX_BLOCK_COUNT   (200)

Definition at line 48 of file m0hsm_api.c.

◆ MIN

#define MIN (   _x,
  _y 
)    ((_x) < (_y) ? (_x) : (_y))

Definition at line 1265 of file m0hsm_api.c.

◆ RETURN

#define RETURN (   _rc)
Value:
do { DBG("< LEAVING %s() line %d, rc=%d\n", \
__func__, __LINE__, (_rc)); \
return (_rc); } while(0)
#define DBG(_fmt,...)
Definition: m0hsm_api.c:72

Definition at line 76 of file m0hsm_api.c.

◆ VERB

#define VERB (   _fmt,
  ... 
)
Value:
fprintf(options.log_stream, _fmt, ##__VA_ARGS__)
FILE * log_stream
Definition: m0hsm_api.h:56
struct m0hsm_options options
Definition: m0hsm_api.c:56
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52

Definition at line 70 of file m0hsm_api.c.

Typedef Documentation

◆ match_layer_cb_t

typedef int(* match_layer_cb_t) (void *cb_arg, struct m0_client_layout *layout, struct m0_composite_layer *layer, const struct extent *match, bool *stop)

Callback function type for match_layer_foreach().

Parameters
[in,out]cb_argCustom callback argument.
[in]layoutThe whole composite layout structure.
[in]layerLayer of the matching extent.
[in]matchMatching extent.
[out]stopsetting to true will interupt the iteration.

Definition at line 2218 of file m0hsm_api.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_LEN 
MAX_POOLS 

Definition at line 92 of file m0hsm_api.c.

◆ ext_match_code

Enumerator
EM_ERROR 
EM_NONE 
EM_PARTIAL 
EM_FULL 

Definition at line 1250 of file m0hsm_api.c.

◆ ext_match_type

Enumerator
EMT_INTERSECT 
EMT_MERGE 

Definition at line 1259 of file m0hsm_api.c.

Function Documentation

◆ add_merge_read_extent()

static int add_merge_read_extent ( struct m0_composite_layer layer,
const struct extent ext_in 
)
static

Add and merge read extent in a given layer

Definition at line 1487 of file m0hsm_api.c.

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

◆ archive_cb()

static int archive_cb ( void *  cb_arg,
struct m0_client_layout layout,
struct m0_composite_layer src_layer,
const struct extent match,
bool *  stop 
)
static

This callback is called for eaching match extent for archiving

Definition at line 2810 of file m0hsm_api.c.

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

◆ check_min_gen_exists()

static int check_min_gen_exists ( struct m0_client_layout layout,
const struct extent ext,
int  gen,
struct m0_composite_layer except_layer 
)
static

check that an extent with at least the given generation exists (except in the designated subobj)

Definition at line 2358 of file m0hsm_api.c.

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

◆ check_top_layer_writable()

static int check_top_layer_writable ( struct m0_client_layout layout,
int  max_prio,
int  tier 
)
static

Definition at line 2192 of file m0hsm_api.c.

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

◆ check_vec()

static int check_vec ( struct m0_bufvec vec,
int  blocks 
)
inlinestatic

Definition at line 1758 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ copy_cb()

static int copy_cb ( void *  cb_arg,
struct m0_client_layout layout,
struct m0_composite_layer src_layer,
const struct extent match,
bool *  stop 
)
static

This callback is called for each match extent in the source tier

Definition at line 2540 of file m0hsm_api.c.

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

◆ copy_extent_data()

static int copy_extent_data ( struct m0_uint128  src_id,
struct m0_uint128  tgt_id,
const struct extent range 
)
static

copy an extent from one (flat) object to another

Definition at line 2107 of file m0hsm_api.c.

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

◆ create_obj()

static int create_obj ( struct m0_uint128  id,
struct m0_obj obj,
bool  close_entity,
uint8_t  tier_idx 
)
static

Helper to create an object with the given id.

Parameters
tier_idxdefines the object location (HSM_ANY_TIER to leave it unspecified)

Definition at line 301 of file m0hsm_api.c.

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

◆ create_obj_with_layout()

static int create_obj_with_layout ( struct m0_uint128  id,
struct m0_obj obj,
struct m0_client_layout layout,
bool  close_entity 
)
static

Create an object with the given layout.

Definition at line 386 of file m0hsm_api.c.

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

◆ delete_obj()

static int delete_obj ( struct m0_uint128  id)
static

Helper to delete an object. (actually unused because we batch delete of subobject

  • update of parent layout in a single operation).

Definition at line 356 of file m0hsm_api.c.

Here is the call graph for this function:

◆ delete_obj_set_parent_layout()

static int delete_obj_set_parent_layout ( struct m0_uint128  id,
struct m0_uint128  parent_id,
struct m0_client_layout parent_layout 
)
static

Combine a subobject deletion + setting parent layout

Definition at line 433 of file m0hsm_api.c.

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

◆ do_io_op()

static int do_io_op ( struct m0_obj obj,
enum m0_obj_opcode  opcode,
struct io_ctx ctx 
)
static

write a block to an open entity

Definition at line 1648 of file m0hsm_api.c.

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

◆ dump_data()

static void dump_data ( struct m0_bufvec data,
size_t  bsize 
)
static

Definition at line 1695 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ ext_match()

static enum ext_match_code ext_match ( struct m0_uint128  layer_id,
struct m0_tl ext_list,
const struct extent ext_in,
struct extent match,
enum ext_match_type  mode,
bool  is_write,
bool  del_prev 
)
static

Definition at line 1267 of file m0hsm_api.c.

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

◆ ext_subtract()

static int ext_subtract ( struct m0_uint128  layer_id,
struct m0_tl ext_list,
const struct extent ext_in,
bool  is_write,
bool *  layer_empty 
)
static

Subtract an extent from existing extents. This function is supposed to be called with an intersecting extent, computed by ext_match. So the only possible case is a full matching extent.

Definition at line 1390 of file m0hsm_api.c.

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

◆ extent_list_free()

static void extent_list_free ( struct m0_tl ext_list)
static

Free all extents in an extent list

Definition at line 696 of file m0hsm_api.c.

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

◆ free_io_ctx()

static void free_io_ctx ( struct io_ctx ctx,
bool  alloc_io_buff 
)
static

release resources in an IO context

Definition at line 1811 of file m0hsm_api.c.

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

◆ gen_data()

static void gen_data ( struct m0_bufvec data,
size_t  bsize,
int  seed 
)
static

Generate and Write data to the I/O vector, using the given seed

Definition at line 1687 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ get_next_extents()

static int get_next_extents ( struct m0_idx idx,
struct m0_bufvec keys,
struct m0_bufvec vals,
int *  rc_list,
int32_t  flags 
)
static

Wrap a single "get next" operation on the extent index (read a batch of extents).

Definition at line 613 of file m0hsm_api.c.

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

◆ get_optimal_bs()

uint64_t get_optimal_bs ( struct m0_obj obj,
uint64_t  obj_sz 
)

Calculate the optimal block size for the object store I/O

Definition at line 1834 of file m0hsm_api.c.

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

◆ hsm_pool_fid_set()

static int hsm_pool_fid_set ( struct param p)
static

Definition at line 127 of file m0hsm_api.c.

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

◆ hsm_pools_fids_set()

static int hsm_pools_fids_set ( struct param  p[],
int  n 
)
static

Definition at line 147 of file m0hsm_api.c.

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

◆ hsm_prio()

static uint32_t hsm_prio ( uint32_t  generation,
uint8_t  tier_idx 
)
static

Build layer priority from generation number and tier number

Definition at line 221 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ hsm_prio2gen()

static uint32_t hsm_prio2gen ( uint32_t  priority)
static

Extract generation number from layer priority.

Definition at line 252 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ hsm_prio2tier()

static uint8_t hsm_prio2tier ( uint32_t  priority)
static

Extract tier index from layer priority.

Definition at line 260 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ hsm_subobj_id()

static struct m0_uint128 hsm_subobj_id ( struct m0_uint128  id,
uint32_t  gen,
uint8_t  tier 
)
static

Build subobject id from parent object id, generation number and tier number.

Definition at line 237 of file m0hsm_api.c.

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

◆ hsm_tier2pool()

static struct m0_fid* hsm_tier2pool ( uint8_t  tier_idx)
static

Returns a pointer to a pool fid for the given tier index.

Definition at line 269 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ is_hsm_reserved()

static bool is_hsm_reserved ( struct m0_uint128  id)
static

Definition at line 206 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ layer_check_clean()

static int layer_check_clean ( struct m0_uint128  parent_id,
struct m0_client_layout layout,
struct m0_composite_layer layer 
)
static

Check that the given layer no longer have readable extents. If so, release and drop the layer. It is expected that the subobject no longer have writable extent before this function is called.

Definition at line 1100 of file m0hsm_api.c.

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

◆ layer_clean()

static int layer_clean ( struct m0_uint128  parent_id,
struct m0_client_layout layout,
struct m0_composite_layer layer 
)
static

Release and drop the layer. It is expected that the subobject no longer have writable extent before this function is called.

Definition at line 1077 of file m0hsm_api.c.

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

◆ layer_extent_add()

static int layer_extent_add ( struct m0_uint128  subobjid,
const struct extent ext,
bool  write,
bool  overwrite 
)
static

Add an extent to a layer.

Parameters
subobjidLayer id.
extExtent to be added.
writeWhether to set a read or write extents (true for write).
overwriteWhether to overwrite a previous extent starting at the same offset.

Definition at line 904 of file m0hsm_api.c.

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

◆ layer_extent_del()

static int layer_extent_del ( struct m0_uint128  subobjid,
off_t  off,
bool  write 
)
static

Definition at line 980 of file m0hsm_api.c.

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

◆ layer_get_by_prio()

static struct m0_composite_layer* layer_get_by_prio ( struct m0_client_layout layout,
int  prio 
)
static

Return the layer with the given priority

Definition at line 2294 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ layer_load_extent_list()

static int layer_load_extent_list ( struct m0_uint128  subobjid,
bool  write,
struct m0_tl ext_list 
)
static

Helper to load a list of extents for a given layer.

Parameters
subobjidLayer id
writeWhether to load the read or write extents (true for write).
ext_listList of extents to be populated.

Definition at line 723 of file m0hsm_api.c.

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

◆ layout_add_top_layer()

static int layout_add_top_layer ( struct m0_uint128  id,
struct m0_client_layout layout,
uint8_t  tier 
)
static

Definition at line 1155 of file m0hsm_api.c.

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

◆ layout_get()

static int layout_get ( struct m0_uint128  id,
struct m0_client_layout **  layout 
)
static

Get the layout of an object designated by its fid.

Definition at line 527 of file m0hsm_api.c.

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

◆ layout_layer_clean()

static int layout_layer_clean ( struct m0_uint128  parent_id,
struct m0_client_layout layout,
struct m0_uint128  subobj_id 
)
static

Release and drop the layer with the given subobj_id in the layout if it no longer has readable extents. It is expected that the subobject no longer have writable extent before this function is called. If successfull, the function sets the layout.

Definition at line 1133 of file m0hsm_api.c.

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

◆ layout_set()

static int layout_set ( struct m0_uint128  id,
struct m0_client_layout layout 
)
static

Set the layout of an object designated by its fid

Definition at line 573 of file m0hsm_api.c.

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

◆ layout_top_prio()

static void layout_top_prio ( struct m0_client_layout layout,
int32_t *  max_gen,
struct m0_uint128 max_gen_id,
uint8_t *  top_tier 
)
static

Retrieves the max generation number and the smallest tier index from layers of composite layout.

Definition at line 1042 of file m0hsm_api.c.

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

◆ M0_TL_DEFINE() [1/2]

M0_TL_DEFINE ( clayer  ,
static  ,
struct m0_composite_layer   
)

◆ M0_TL_DEFINE() [2/2]

M0_TL_DEFINE ( cext  ,
static  ,
struct m0_composite_extent   
)

◆ M0_TL_DESCR_DEFINE() [1/2]

M0_TL_DESCR_DEFINE ( clayer  ,
"composite layout layers"  ,
static  ,
struct m0_composite_layer  ,
ccr_tlink  ,
ccr_tlink_magic  ,
M0_CLAYER_TL_MAGIC  ,
M0_CLAYER_TL_MAGIC   
)

◆ M0_TL_DESCR_DEFINE() [2/2]

M0_TL_DESCR_DEFINE ( cext  ,
"composite layout extents"  ,
static  ,
struct m0_composite_extent  ,
ce_tlink  ,
ce_tlink_magic  ,
M0_CEXT_TL_MAGIC  ,
M0_CEXT_TL_MAGIC   
)

◆ m0hsm_archive()

int m0hsm_archive ( struct m0_uint128  obj_id,
uint8_t  target_tier,
off_t  offset,
size_t  length,
enum hsm_cp_flags  flags 
)

Request to archive data to a slower tier.

Parameters
obj_idId of the object to be archived.
targer_tierTarget tier index (0 is the top tier).
offsetStart offset of the region to be staged.
lengthSize of the region to be staged.
flagsSet of OR'ed hsm_cp_flags.

Definition at line 2831 of file m0hsm_api.c.

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

◆ m0hsm_copy()

int m0hsm_copy ( struct m0_uint128  obj_id,
uint8_t  src_tier_idx,
uint8_t  tgt_tier_idx,
off_t  offset,
size_t  length,
enum hsm_cp_flags  flags 
)

Copy a region of an object from one tier to another. This is transparent to applications if they use the I/O calls defined above (m0hsm_create/pread/pwrite).

Parameters
obj_idId of the object to be copied.
src_tier_idxSource tier index (0 is the top tier).
tgt_tier_idxTarget tier index (0 is the top tier).
offsetStart offset of the region to be copied.
lengthSize of the region to be copied.
flagsSet of OR'ed hsm_cp_flags.

Definition at line 2715 of file m0hsm_api.c.

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

◆ m0hsm_create()

int m0hsm_create ( struct m0_uint128  id,
struct m0_obj obj,
uint8_t  tier_idx,
bool  keep_open 
)

Create an object to be managed by HSM.

Parameters
idIdentifier of the object to be created.
objPointer to the created object.
tier_idxIndex of the target tier (0 is the top tier).
keep_openKeep the object entity opened.

Definition at line 1571 of file m0hsm_api.c.

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

◆ m0hsm_dump()

int m0hsm_dump ( FILE *  stream,
struct m0_uint128  id,
bool  details 
)

Dump HSM information about a composite object.

Parameters
streamFILE* to write information to.
idIdentifier of the object to dump.
detailsIf true dump all details, else print brief output.

Definition at line 875 of file m0hsm_api.c.

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

◆ m0hsm_init()

int m0hsm_init ( struct m0_client instance,
struct m0_realm uber_realm,
const struct m0hsm_options options 
)

Initialize HSM API.

Parameters
optionsHSM options. NULL to keep defaults.

Definition at line 166 of file m0hsm_api.c.

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

◆ m0hsm_multi_release()

int m0hsm_multi_release ( struct m0_uint128  obj_id,
uint8_t  max_tier,
off_t  offset,
size_t  length,
enum hsm_rls_flags  flags 
)

Release a region of an object from multiple tiers. All data in tiers up to max_tier are released.

Parameters
obj_idId of the object to be archived.
targer_tierTarget tier index (0 is the top tier).
offsetStart offset of the region to be staged.
lengthSize of the region to be staged.
flagsSet of OR'ed hsm_rls_flags.

Definition at line 2499 of file m0hsm_api.c.

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

◆ m0hsm_pwrite()

int m0hsm_pwrite ( struct m0_obj obj,
void *  buf,
size_t  len,
off_t  off 
)

[WORKAROUND CALL] This call fixes a miss in composite layout management i.e. create a associated read extent when a data is written.

Write data to an object. Object's entity must be opened prior to calling this. offset and length must respect usual m0 requirements of alignment (PAGE_SIZE minimum).

Parameters
objObject to write data to.
iovData buffer.
offStart offset.

Definition at line 1968 of file m0hsm_api.c.

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

◆ m0hsm_release()

int m0hsm_release ( struct m0_uint128  obj_id,
uint8_t  tier_idx,
off_t  offset,
size_t  length,
enum hsm_rls_flags  flags 
)

Release a region of an object from the given tier.

Parameters
obj_idId of the object to be released.
tier_idxTier to drop the data from.
offsetStart offset of the region to be released.
lengthSize of the region to be released.
flagsSet of OR'ed hsm_rls_flags.

Definition at line 2493 of file m0hsm_api.c.

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

◆ m0hsm_release_maxgen()

static int m0hsm_release_maxgen ( struct m0_uint128  id,
uint8_t  tier,
int  max_gen,
off_t  offset,
size_t  len,
enum hsm_rls_flags  flags,
bool  user_display 
)
static

same as release, but precise max generation

Definition at line 2462 of file m0hsm_api.c.

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

◆ m0hsm_set_write_tier()

int m0hsm_set_write_tier ( struct m0_uint128  id,
uint8_t  tier_idx 
)

Selects the target tier for next write operations. This does not move existing data.

Parameters
objObject for which we want to change the write tier.

Definition at line 1224 of file m0hsm_api.c.

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

◆ m0hsm_stage()

int m0hsm_stage ( struct m0_uint128  obj_id,
uint8_t  target_tier,
off_t  offset,
size_t  length,
enum hsm_cp_flags  flags 
)

Request to stage data to a faster tier.

Parameters
obj_idId of the object to be staged.
targer_tierTarget tier index (0 is the top tier).
offsetStart offset of the region to be staged.
lengthSize of the region to be staged.
flagsHSM_WRITE_TO_DEST if next write operations should also be directed to the same fast tier (intensive writes expected).

Definition at line 2773 of file m0hsm_api.c.

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

◆ m0hsm_test_read()

int m0hsm_test_read ( struct m0_uint128  id,
off_t  offset,
size_t  len 
)

read data from an existing object at the given offset.

Definition at line 2045 of file m0hsm_api.c.

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

◆ m0hsm_test_write()

int m0hsm_test_write ( struct m0_uint128  id,
off_t  offset,
size_t  len,
int  seed 
)

write data to an existing object at the given offset

Parameters
seedUsed to generate block contents so it can be used to verify we read the right layer.

Definition at line 1875 of file m0hsm_api.c.

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

◆ map_io_ctx()

static int map_io_ctx ( struct io_ctx ctx,
int  blocks,
size_t  b_size,
off_t  offset,
char *  buff 
)
static

Fill in an I/O context for a given I/O operation. Map user provided buffer if not NULL.

Definition at line 1775 of file m0hsm_api.c.

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

◆ match_layer_foreach()

static int match_layer_foreach ( struct m0_client_layout layout,
uint8_t  tier,
const struct extent ext,
match_layer_cb_t  cb,
void *  cb_arg,
bool  stop_on_error 
)
static

Iterate on object layers that match the given tier and the given extent. Iteration stops if a callback returns non-zero or sets the "stop" boolean.

Definition at line 2228 of file m0hsm_api.c.

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

◆ min_gen_check_cb()

static int min_gen_check_cb ( void *  cb_arg,
struct m0_client_layout layout,
struct m0_composite_layer layer,
const struct extent match,
bool *  stop 
)
static

Definition at line 2319 of file m0hsm_api.c.

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

◆ obj_layout_get()

static int obj_layout_get ( struct m0_obj obj,
struct m0_client_layout **  layout 
)
static

Get the layout of an object

Definition at line 500 of file m0hsm_api.c.

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

◆ obj_layout_set()

static int obj_layout_set ( struct m0_obj obj,
struct m0_client_layout layout 
)
static

Set the layout of an object

Definition at line 549 of file m0hsm_api.c.

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

◆ open_entity()

static int open_entity ( struct m0_entity entity)
static

Helper to open an object entity

Definition at line 277 of file m0hsm_api.c.

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

◆ prepare_io_ctx()

static int prepare_io_ctx ( struct io_ctx ctx,
int  blocks,
size_t  block_size,
bool  alloc_io_buff 
)
static

Allocate I/O context for a particular number of blocks and block size

Parameters
alloc_io_buffDoes the function allocate I/O buffers or are they provided by the user?

Definition at line 1709 of file m0hsm_api.c.

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

◆ print_extents()

static void print_extents ( FILE *  stream,
const struct m0_tl ext_list,
bool  details 
)
static

Definition at line 789 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ print_layer()

static void print_layer ( FILE *  stream,
struct m0_composite_layer layer,
bool  details 
)
static

Definition at line 813 of file m0hsm_api.c.

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

◆ print_layout()

static void print_layout ( FILE *  stream,
const struct m0_client_layout layout,
bool  details 
)
static

Definition at line 850 of file m0hsm_api.c.

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

◆ read_blocks()

static int read_blocks ( struct m0_obj obj,
struct io_ctx ctx 
)
static

read data from an open object

Definition at line 1681 of file m0hsm_api.c.

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

◆ read_extent_keys()

static int read_extent_keys ( struct m0_uint128  subobjid,
struct m0_bufvec keys,
struct m0_bufvec vals,
int *  rc_list,
struct m0_tl ext_list,
struct m0_composite_layer_idx_key last_key 
)
static

Read returned keys and add them to the extent list

Returns
The number of read extents, or a negative error code.

Definition at line 642 of file m0hsm_api.c.

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

◆ read_params()

static int read_params ( FILE *  in,
struct param p,
int  max_params 
)
static

Definition at line 105 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ release_cb()

static int release_cb ( void *  cb_arg,
struct m0_client_layout layout,
struct m0_composite_layer layer,
const struct extent match,
bool *  stop 
)
static

TODO actually release the data region

Definition at line 2392 of file m0hsm_api.c.

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

◆ reset_bufvec()

static void reset_bufvec ( struct m0_bufvec keys,
int  count 
)
static

Reset a list of buffers

Definition at line 705 of file m0hsm_api.c.

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

◆ roundup_power2()

static uint64_t roundup_power2 ( uint64_t  x)
static

Definition at line 1821 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ stage_cb()

static int stage_cb ( void *  cb_arg,
struct m0_client_layout layout,
struct m0_composite_layer src_layer,
const struct extent match,
bool *  stop 
)
static

This callback is called for eaching match extent for staging

Definition at line 2751 of file m0hsm_api.c.

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

◆ top_layer_add_read_extent()

static int top_layer_add_read_extent ( struct m0_obj obj,
const struct extent ext 
)
static

Definition at line 1537 of file m0hsm_api.c.

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

◆ top_layer_get()

static struct m0_composite_layer* top_layer_get ( struct m0_client_layout layout)
static

Definition at line 1213 of file m0hsm_api.c.

Here is the caller graph for this function:

◆ write_blocks()

static int write_blocks ( struct m0_obj obj,
struct io_ctx ctx 
)
static

write a block to an open entity

Definition at line 1675 of file m0hsm_api.c.

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

Variable Documentation

◆ EXT_FULLRANGE

const struct extent EXT_FULLRANGE
static
Initial value:
= {
.off = 0,
.len = M0_BCOUNT_MAX,
}

largest extent possible

Definition at line 87 of file m0hsm_api.c.

◆ hsm_pools

struct m0_fid hsm_pools[MAX_POOLS] = {}
static

Definition at line 103 of file m0hsm_api.c.

◆ hsm_rc_params

struct param hsm_rc_params[128]
static

Definition at line 102 of file m0hsm_api.c.

◆ m0_instance

struct m0_client* m0_instance
static

Definition at line 62 of file m0hsm_api.c.

◆ m0_uber_realm

struct m0_realm* m0_uber_realm
static

Definition at line 63 of file m0hsm_api.c.

◆ options

struct m0hsm_options options
Initial value:
= {
.trace_level = LOG_INFO,
.op_timeout = 10,
.log_stream = NULL,
}
#define NULL
Definition: misc.h:38

Definition at line 56 of file m0hsm_api.c.