Motr  M0
File operations log

Data Structures

struct  m0_fol
 
struct  m0_fol_rec_header
 
struct  m0_fol_rec
 
struct  m0_fol_frag
 
struct  m0_fol_frag_type
 
struct  m0_fol_frag_type_ops
 
struct  m0_fol_frag_ops
 
struct  m0_fol_frag_header
 

Macros

#define FRAG_HEADER_XCODE_OBJ(ptr)   M0_XCODE_OBJ(m0_fol_frag_header_xc, ptr)
 
#define FRAG_XCODE_OBJ(r)
 
#define M0_FOL_FRAG_TYPE_DECLARE(frag, scope, undo, redo, undo_cred, redo_cred)
 
#define M0_FOL_FRAG_TYPE_XC_OPS(name, frag_xc, frag_type_ops)
 
#define M0_FOL_FRAG_TYPE_INIT(frag, name)
 

Enumerations

enum  { FOL_FRAG_TYPE_MAX = 128, PART_TYPE_START_INDEX = 1 }
 
enum  { FOL_REC_MAXSIZE = 1024 * 256 }
 

Functions

 M0_TL_DESCR_DEFINE (m0_rec_frag, "fol record fragment", M0_INTERNAL, struct m0_fol_frag, rp_link, rp_magic, M0_FOL_FRAG_LINK_MAGIC, M0_FOL_FRAG_HEAD_MAGIC)
 
 M0_TL_DEFINE (m0_rec_frag, M0_INTERNAL, struct m0_fol_frag)
 
static size_t fol_rec_header_pack_size (struct m0_fol_rec_header *h)
 
M0_INTERNAL void m0_fol_init (struct m0_fol *fol)
 
M0_INTERNAL void m0_fol_fini (struct m0_fol *fol)
 
M0_INTERNAL void m0_fol_rec_init (struct m0_fol_rec *rec, struct m0_fol *fol)
 
M0_INTERNAL void m0_fol_rec_fini (struct m0_fol_rec *rec)
 
M0_INTERNAL bool m0_fol_rec_invariant (const struct m0_fol_rec *rec)
 
M0_INTERNAL void m0_fol_frag_init (struct m0_fol_frag *frag, void *data, const struct m0_fol_frag_type *type)
 
M0_INTERNAL void m0_fol_frag_fini (struct m0_fol_frag *frag)
 
M0_INTERNAL int m0_fols_init (void)
 
M0_INTERNAL void m0_fols_fini (void)
 
M0_INTERNAL int m0_fol_frag_type_register (struct m0_fol_frag_type *type)
 
M0_INTERNAL void m0_fol_frag_type_deregister (struct m0_fol_frag_type *type)
 
static const struct m0_fol_frag_typefol_frag_type_lookup (uint32_t index)
 
static size_t fol_record_pack_size (struct m0_fol_rec *rec)
 
static int fol_rec_encdec (struct m0_fol_rec *rec, struct m0_bufvec_cursor *cur, enum m0_xcode_what what)
 
static int fol_record_pack (struct m0_fol_rec *rec, struct m0_buf *buf)
 
M0_INTERNAL int m0_fol_rec_encode (struct m0_fol_rec *rec, struct m0_buf *at)
 
M0_INTERNAL int m0_fol_rec_decode (struct m0_fol_rec *rec, struct m0_buf *at)
 
int m0_fol_rec_to_str (struct m0_fol_rec *rec, char *str, int str_len)
 
M0_INTERNAL void m0_fol_frag_add (struct m0_fol_rec *rec, struct m0_fol_frag *frag)
 
 M0_BASSERT (M0_IS_8ALIGNED(sizeof(struct m0_fol_rec_header)))
 
 M0_TL_DESCR_DECLARE (m0_rec_frag, M0_EXTERN)
 
 M0_TL_DECLARE (m0_rec_frag, M0_INTERNAL, struct m0_fol_frag)
 

Variables

static const struct m0_fol_frag_typerptypes [FOL_FRAG_TYPE_MAX]
 
static struct m0_mutex rptypes_lock
 

Detailed Description

File operations log (fol) is a per-node collection of records, describing updates to file system state carried out on the node. See HLD for the description of requirements, usage patterns and constraints on fol, as well as important terminology (update, operation, etc.):

For documentation links, please refer to this file : doc/motr-design-doc-list.rst

A fol is represented by an instance of struct m0_fol. A fol record is represented by the m0_fol_rec data type.

A fol record contains the list of fol record fragments, belonging to fol record fragment types, added during updates. These fol record fragments provide flexibility for modules to participate in a transaction without global knowledge.

See also
m0_fol_frag : FOL record fragment.
m0_fol_frag_type : FOL record fragment type.

m0_fol_frag_ops structure contains operations for undo and redo of FOL record fragments.

See also
m0_fol_frag_init() : Initializes m0_fol_frag with m0_fol_frag_type_ops.
m0_fol_frag_fini() : Finalizes FOL record fragment.
m0_fol_frag_type_register() : Registers FOL record fragment type.
m0_fol_frag_type_deregister() : Deregisters FOL record fragment type.

FOL record fragments list is kept in m0_fol_rec::fr_frags which is initialized in m0_fol_rec_init().

m0_fol_rec_encode() is used to compose FOL record from FOL record descriptor and fragments. It encodes the FOL record fragments in the list m0_fol_rec:fr_frags in a buffer, which then will be added into the BE log.

See also
m0_fol_rec_encode()
m0_fol_rec_decode()

m0_fol_frag_type_init() and m0_fol_frag_type_fini() are added to initialize and finalize FOL fragment types. FOL record fragment types are registered in a global array of FOL record fragments using m0_fol_frag_type::rpt_index.

After successful execution of updates on server side, in FOM generic phase using m0_fom_fol_rec_encode() FOL record fragments in the list are combined in a FOL record and is made persistent. Before this phase all FOL record fragments need to be added in the list after completing their updates.

After retrieving FOL record from the storage, FOL record fragments are decoded based on fragment type using index and are used in undo or redo operations.

Implementation notes.

FOL stores its records in BE log at transaction payloads and identifies them by transaction id.

When a record is fetched from the fol, it is decoded by m0_fol_rec_decode(). When a record is placed into the fol, its representation is prepared by m0_fol_rec_encode().

Macro Definition Documentation

◆ FRAG_HEADER_XCODE_OBJ

#define FRAG_HEADER_XCODE_OBJ (   ptr)    M0_XCODE_OBJ(m0_fol_frag_header_xc, ptr)

Definition at line 64 of file fol.c.

◆ FRAG_XCODE_OBJ

#define FRAG_XCODE_OBJ (   r)
Value:
(struct m0_xcode_obj) { \
.xo_type = frag->rp_ops != NULL ? \
frag->rp_ops->rpo_type->rpt_xt : \
m0_fop_fol_frag_type.rpt_xt, \
.xo_ptr = r->rp_data \
}
#define NULL
Definition: misc.h:38
static int r[NR]
Definition: thread.c:46

Definition at line 67 of file fol.c.

◆ M0_FOL_FRAG_TYPE_DECLARE

#define M0_FOL_FRAG_TYPE_DECLARE (   frag,
  scope,
  undo,
  redo,
  undo_cred,
  redo_cred 
)
Value:
scope struct m0_fol_frag_type frag ## _type; \
static const struct m0_fol_frag_ops frag ## _ops = { \
.rpo_type = &frag ## _type, \
.rpo_undo = undo, \
.rpo_redo = redo, \
.rpo_undo_credit = undo_cred, \
.rpo_redo_credit = redo_cred, \
}; \
static void frag ## _ops_init(struct m0_fol_frag *frag) \
{ \
frag->rp_ops = &frag ## _ops; \
} \
static const struct m0_fol_frag_type_ops frag ## _type_ops = { \
.rpto_rec_frag_init = frag ##_ops_init \
};
const struct m0_fol_frag_type * rpo_type
Definition: fol.h:283
void(* rpto_rec_frag_init)(struct m0_fol_frag *frag)
Definition: fol.h:275

Definition at line 324 of file fol.h.

◆ M0_FOL_FRAG_TYPE_INIT

#define M0_FOL_FRAG_TYPE_INIT (   frag,
  name 
)
Value:
frag ## _type = M0_FOL_FRAG_TYPE_XC_OPS(name, frag ## _xc, \
&frag ## _type_ops)
const char * name
Definition: trace.c:110
#define M0_FOL_FRAG_TYPE_XC_OPS(name, frag_xc, frag_type_ops)
Definition: fol.h:342

Definition at line 349 of file fol.h.

◆ M0_FOL_FRAG_TYPE_XC_OPS

#define M0_FOL_FRAG_TYPE_XC_OPS (   name,
  frag_xc,
  frag_type_ops 
)
Value:
(struct m0_fol_frag_type) { \
.rpt_name = name, \
.rpt_xt = (frag_xc), \
.rpt_ops = (frag_type_ops) \
};
const struct m0_fol_frag_type_ops * rpt_ops
Definition: fol.h:270
const char * name
Definition: trace.c:110

Definition at line 342 of file fol.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FOL_FRAG_TYPE_MAX 
PART_TYPE_START_INDEX 

Definition at line 158 of file fol.c.

◆ anonymous enum

anonymous enum
Enumerator
FOL_REC_MAXSIZE 

Definition at line 108 of file fol.h.

Function Documentation

◆ fol_frag_type_lookup()

static const struct m0_fol_frag_type* fol_frag_type_lookup ( uint32_t  index)
static

Definition at line 218 of file fol.c.

Here is the caller graph for this function:

◆ fol_rec_encdec()

static int fol_rec_encdec ( struct m0_fol_rec rec,
struct m0_bufvec_cursor cur,
enum m0_xcode_what  what 
)
static

Definition at line 258 of file fol.c.

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

◆ fol_rec_header_pack_size()

static size_t fol_rec_header_pack_size ( struct m0_fol_rec_header h)
static

Definition at line 228 of file fol.c.

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

◆ fol_record_pack()

static int fol_record_pack ( struct m0_fol_rec rec,
struct m0_buf buf 
)
static

Definition at line 275 of file fol.c.

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

◆ fol_record_pack_size()

static size_t fol_record_pack_size ( struct m0_fol_rec rec)
static

Definition at line 237 of file fol.c.

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

◆ M0_BASSERT()

M0_BASSERT ( M0_IS_8ALIGNED(sizeof(struct m0_fol_rec_header))  )

◆ m0_fol_fini()

M0_INTERNAL void m0_fol_fini ( struct m0_fol fol)

Definition at line 89 of file fol.c.

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

◆ m0_fol_frag_add()

M0_INTERNAL void m0_fol_frag_add ( struct m0_fol_rec rec,
struct m0_fol_frag frag 
)

Definition at line 468 of file fol.c.

Here is the caller graph for this function:

◆ m0_fol_frag_fini()

M0_INTERNAL void m0_fol_frag_fini ( struct m0_fol_frag frag)

Definition at line 132 of file fol.c.

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

◆ m0_fol_frag_init()

M0_INTERNAL void m0_fol_frag_init ( struct m0_fol_frag frag,
void *  data,
const struct m0_fol_frag_type type 
)

During encoding of FOL record data points to the in-memory FOL record fragment object allocated by the calling function. In case if decoding data should be NULL, as it is allocated by xcode.

Precondition
frag != NULL
type != NULL

Definition at line 121 of file fol.c.

Here is the caller graph for this function:

◆ m0_fol_frag_type_deregister()

M0_INTERNAL void m0_fol_frag_type_deregister ( struct m0_fol_frag_type type)

Definition at line 201 of file fol.c.

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

◆ m0_fol_frag_type_register()

M0_INTERNAL int m0_fol_frag_type_register ( struct m0_fol_frag_type type)

Register a new fol record fragment type.

Definition at line 178 of file fol.c.

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

◆ m0_fol_init()

M0_INTERNAL void m0_fol_init ( struct m0_fol fol)

Initialise in-memory fol structure.

Definition at line 84 of file fol.c.

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

◆ m0_fol_rec_decode()

M0_INTERNAL int m0_fol_rec_decode ( struct m0_fol_rec rec,
struct m0_buf at 
)

Decodes a record into from the specified buffer .

is m0_be_tx::t_payload.

must be initialized with m0_fol_rec_init() beforehand. The user must call m0_fol_rec_fini() when finished dealing with the record.

Definition at line 331 of file fol.c.

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

◆ m0_fol_rec_encode()

M0_INTERNAL int m0_fol_rec_encode ( struct m0_fol_rec rec,
struct m0_buf at 
)

Encodes the fol record at the specified buffer .

See also
m0_fol_rec_put()

Definition at line 314 of file fol.c.

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

◆ m0_fol_rec_fini()

M0_INTERNAL void m0_fol_rec_fini ( struct m0_fol_rec rec)

Finalizes fol record fragments list.

Definition at line 104 of file fol.c.

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

◆ m0_fol_rec_init()

M0_INTERNAL void m0_fol_rec_init ( struct m0_fol_rec rec,
struct m0_fol fol 
)

Initializes fol record fragments list.

The user must call m0_fol_rec_fini() when finished dealing with the record.

Definition at line 98 of file fol.c.

Here is the caller graph for this function:

◆ m0_fol_rec_invariant()

M0_INTERNAL bool m0_fol_rec_invariant ( const struct m0_fol_rec rec)

Definition at line 114 of file fol.c.

◆ m0_fol_rec_to_str()

int m0_fol_rec_to_str ( struct m0_fol_rec rec,
char *  str,
int  str_len 
)

Definition at line 380 of file fol.c.

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

◆ m0_fols_fini()

M0_INTERNAL void m0_fols_fini ( void  )

Definition at line 172 of file fol.c.

Here is the call graph for this function:

◆ m0_fols_init()

M0_INTERNAL int m0_fols_init ( void  )

Definition at line 166 of file fol.c.

Here is the call graph for this function:

◆ M0_TL_DECLARE()

M0_TL_DECLARE ( m0_rec_frag  ,
M0_INTERNAL  ,
struct m0_fol_frag   
)

◆ M0_TL_DEFINE()

M0_TL_DEFINE ( m0_rec_frag  ,
M0_INTERNAL  ,
struct m0_fol_frag   
)

◆ M0_TL_DESCR_DECLARE()

M0_TL_DESCR_DECLARE ( m0_rec_frag  ,
M0_EXTERN   
)

Descriptor for the tlist of fol record fragments.

◆ M0_TL_DESCR_DEFINE()

M0_TL_DESCR_DEFINE ( m0_rec_frag  ,
"fol record fragment"  ,
M0_INTERNAL  ,
struct m0_fol_frag  ,
rp_link  ,
rp_magic  ,
M0_FOL_FRAG_LINK_MAGIC  ,
M0_FOL_FRAG_HEAD_MAGIC   
)

Variable Documentation

◆ rptypes

const struct m0_fol_frag_type* rptypes[FOL_FRAG_TYPE_MAX]
static

Definition at line 163 of file fol.c.

◆ rptypes_lock

struct m0_mutex rptypes_lock
static

Definition at line 164 of file fol.c.