Motr  M0
DTM0 implementation Internals

Data Structures

struct  m0_dtm0_log_rec
 
struct  m0_be_dtm0_log
 

Enumerations

enum  m0_be_dtm0_log_credit_op {
  M0_DTML_CREATE, M0_DTML_SENT, M0_DTML_EXECUTED, M0_DTML_PERSISTENT,
  M0_DTML_PRUNE, M0_DTML_REDO
}
 

Functions

M0_INTERNAL int m0_be_dtm0_log_alloc (struct m0_be_dtm0_log **log)
 
M0_INTERNAL int m0_be_dtm0_log_init (struct m0_be_dtm0_log *log, struct m0_be_seg *seg, struct m0_dtm0_clk_src *cs, bool is_plog)
 
M0_INTERNAL void m0_be_dtm0_log_fini (struct m0_be_dtm0_log *log)
 
M0_INTERNAL void m0_be_dtm0_log_free (struct m0_be_dtm0_log **log)
 
M0_INTERNAL void m0_be_dtm0_log_credit (enum m0_be_dtm0_log_credit_op op, struct m0_dtm0_tx_desc *txd, struct m0_buf *payload, struct m0_be_seg *seg, struct m0_dtm0_log_rec *rec, struct m0_be_tx_credit *accum)
 
M0_INTERNAL int m0_be_dtm0_log_create (struct m0_be_tx *tx, struct m0_be_seg *seg, struct m0_be_dtm0_log **out)
 
M0_INTERNAL void m0_be_dtm0_log_destroy (struct m0_be_tx *tx, struct m0_be_dtm0_log **log)
 
M0_INTERNAL int m0_be_dtm0_log_update (struct m0_be_dtm0_log *log, struct m0_be_tx *tx, struct m0_dtm0_tx_desc *txd, struct m0_buf *payload)
 
M0_INTERNAL struct m0_dtm0_log_recm0_be_dtm0_log_find (struct m0_be_dtm0_log *log, const struct m0_dtm0_tid *id)
 
M0_INTERNAL int m0_be_dtm0_log_prune (struct m0_be_dtm0_log *log, struct m0_be_tx *tx, const struct m0_dtm0_tid *id)
 
M0_INTERNAL bool m0_be_dtm0_plog_can_prune (struct m0_be_dtm0_log *log, const struct m0_dtm0_tid *id, struct m0_be_tx_credit *cred)
 
M0_INTERNAL int m0_be_dtm0_plog_prune (struct m0_be_dtm0_log *log, struct m0_be_tx *tx, const struct m0_dtm0_tid *id)
 
M0_INTERNAL void m0_be_dtm0_log_clear (struct m0_be_dtm0_log *log)
 
M0_INTERNAL int m0_be_dtm0_volatile_log_insert (struct m0_be_dtm0_log *log, struct m0_dtm0_log_rec *rec)
 
M0_INTERNAL void m0_be_dtm0_volatile_log_update (struct m0_be_dtm0_log *log, struct m0_dtm0_log_rec *rec)
 
M0_INTERNAL void m0_be_dtm0_log_pmsg_post (struct m0_be_dtm0_log *log, struct m0_fop *fop)
 

Detailed Description

section describes the dtm0 log related enumerations and structures.

Enumeration Type Documentation

◆ m0_be_dtm0_log_credit_op

m0_be_dtm0_log_credit_op enum

DTM0 persistent log is implemented on top of be modules and uses be_list for storing the log records. m0_be_dtm0_log_credit_op is an enumeration of the operation codes that can be specified to obtain credits for performing the corresponding operation related to dtm0_log.

Enumerator
M0_DTML_CREATE 

m0_be_dtm0_log_create()

M0_DTML_SENT 

m0_be_dtm0_log_update()

M0_DTML_EXECUTED 

m0_be_dtm0_log_update()

M0_DTML_PERSISTENT 

m0_be_dtm0_log_update()

M0_DTML_PRUNE 

m0_be_dtm0_log_prune()

M0_DTML_REDO 

m0_be_dtm0_log_update()

Definition at line 141 of file dtm0_log.h.

Function Documentation

◆ m0_be_dtm0_log_alloc()

M0_INTERNAL int m0_be_dtm0_log_alloc ( struct m0_be_dtm0_log **  out)

Typical call flow for calling DTM0 log interface routines:

** Initialisation/Finalisation for volatile fields of the log ** Create a persistent log or just allocate a volatile (in-memory) log m0_be_dtm0_log_create / m0_be_dtm0_log_alloc

Precondition
log != NULL.
Postcondition
*log is allocated and ready to be initialized.
Parameters
logPointer to variable in which to return the allocate memory address.
Returns
0 on success. Anything else is a failure.

Allocate memory for a dtm0 volatile log structure.

Definition at line 70 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_clear()

M0_INTERNAL void m0_be_dtm0_log_clear ( struct m0_be_dtm0_log log)

Given a pointer to a dtm0 volatile log clear the log and finalize it.

Precondition
log is not a persistent log
m0_dtm0_tx_desc_state_eq == M0_DTPS_PERSISTENT for all records in the log.
Postcondition
None
Parameters
logPointer to the volatile log that we want to clear.
Returns
None.

TODO: rename this to indicate that it's used for volatile usecase only. TODO: remove later. Removes all records from the volatile log.

Definition at line 520 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_create()

M0_INTERNAL int m0_be_dtm0_log_create ( struct m0_be_tx tx,
struct m0_be_seg seg,
struct m0_be_dtm0_log **  out 
)

This routine is used to create a dtm0 persistent log.

Precondition
tx != NULL
seg != NULL
Postcondition
None
Parameters
txhandle to an already opened transaction.
segbe segment on which to create the log.
outvariable in which to store the pointer to the newly created log.
Returns
0 on success, anything else is a failure.

Definition at line 237 of file dtm0_log.c.

Here is the caller graph for this function:

◆ m0_be_dtm0_log_credit()

M0_INTERNAL void m0_be_dtm0_log_credit ( enum m0_be_dtm0_log_credit_op  op,
struct m0_dtm0_tx_desc txd,
struct m0_buf payload,
struct m0_be_seg seg,
struct m0_dtm0_log_rec rec,
struct m0_be_tx_credit accum 
)

For performing an operation on a persistent log, we need to take the appropriate number of be transaction credit.

Precondition
op in enum m0_be_dtm0_log_credit_op seg != NULL accum != NULL
Postcondition
None
Parameters
opOperation code for the type of dtm0 log operation that we want to perform.
See also
m0_be_dtm0_log_credit_op.
Parameters
txdA valid dtm0 tx descriptor that we want to store in the log record.
payloadThe payload is an opaque structure for dtm0 log to store in the log record.
segThe be segment on which the log resides.
Apointer to a valid m0_dtm0_log_rec.
accumThis contains the number of credits required for performing the operation.
Returns
None

Definition at line 202 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_destroy()

M0_INTERNAL void m0_be_dtm0_log_destroy ( struct m0_be_tx tx,
struct m0_be_dtm0_log **  log 
)

This routine is used to destroy a previously created persistent dtm0 log

Precondition
tx != NULL
*log != NULL
Postcondition
None
Parameters
txhandle to an already opened transaction.
logPointer to the dtm0 log which we wish to destroy
Returns
None

Definition at line 260 of file dtm0_log.c.

Here is the caller graph for this function:

◆ m0_be_dtm0_log_find()

M0_INTERNAL struct m0_dtm0_log_rec* m0_be_dtm0_log_find ( struct m0_be_dtm0_log log,
const struct m0_dtm0_tid id 
)

Given a pointer to a dtm0 transaction id, this routine searches the log for the log record matching this tx id and returns it.

Precondition
m0_be_dtm0_log__invariant(log)
m0_dtm0_tid__invariant(id))
m0_mutex_is_locked(&log->dl_lock)
Postcondition
None
Parameters
logPointer to the dtm0 log in which we wish to search.
tidPointer to a dtm0 transaction id corresponding to the record that we wish to fetch from the log.
Returns
m0_dtm0_log_rec corresponding to the input tid or NULL if no such record is found.

Definition at line 270 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_fini()

M0_INTERNAL void m0_be_dtm0_log_fini ( struct m0_be_dtm0_log log)

Finalize a dtm0 log. We need to call this routine once after we have finished performing all operations on it.

Precondition
m0_be_dtm0_log__invariant needs to be satisfied.
Postcondition
All fields of *log are finalized. For volatile log the memory allocated by m0_be_dtm0_log_alloc is freed.
Parameters
logPointer to a valid log.
Returns
None

Definition at line 111 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_free()

M0_INTERNAL void m0_be_dtm0_log_free ( struct m0_be_dtm0_log **  log)

Free the memory allocated by m0_be_dtm0_log_alloc

Precondition
m0_be_dtm0_log->dl_is_persistent needs to be false.
Postcondition
*log is set to NULL.
Parameters
logPointer to a log structure that has been previously allocated.
Returns
None

Definition at line 119 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_init()

M0_INTERNAL int m0_be_dtm0_log_init ( struct m0_be_dtm0_log log,
struct m0_be_seg seg,
struct m0_dtm0_clk_src cs,
bool  is_plog 
)

Initialize a dtm0 log. We need to call this routine once before we can perform any operations on it.

Precondition
log != NULL;
cs != NULL;
Postcondition
*log is initialized and ready to be used
Parameters
logPointer to a m0_be_dtm0_log that has to be initialized.
csPointer to a clock source. This will be used for comparisons involving log record timestamps.
is_plogA flag to indicate whether the dtm0 log that we are trying to init is a volatile of persistent store.
Returns
0 on success. Anything else is a failure.

Definition at line 94 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_pmsg_post()

M0_INTERNAL void m0_be_dtm0_log_pmsg_post ( struct m0_be_dtm0_log log,
struct m0_fop fop 
)

Deliver a persistent message to the log.

Precondition
log is a volatile log
fop->f_type ==
Postcondition
None
Parameters
logPointer to the dtm0 log which we wish to destroy
fopThis is a fop for the request carrying a PERSISTENT notice
Returns
None

TODO: Only volatile log is supported so far.

Definition at line 637 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_prune()

M0_INTERNAL int m0_be_dtm0_log_prune ( struct m0_be_dtm0_log log,
struct m0_be_tx tx,
const struct m0_dtm0_tid id 
)

Given a pointer to a dtm0 transaction id, this routine searches the log for the log record matching this tx id and removes all the records having id lower or equal to the specified id.

Precondition
*log->dl_is_persistent == false (This is a volatile log)
m0_be_dtm0_log__invariant(log)
m0_dtm0_tid__invariant(id)
m0_mutex_is_locked(&log->dl_lock)
Postcondition
None
Parameters
logPointer to the log from which we want to delete the record.
txPointer to an open be transaction.
idPointer to a dtm0 transaction id corresponding to the record that we wish to delete from the log.
Returns
-ENOENT if no record exists for this id, 0 if the record is found and successfully deleted, Anything else is considered a failure.

Definition at line 477 of file dtm0_log.c.

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

◆ m0_be_dtm0_log_update()

M0_INTERNAL int m0_be_dtm0_log_update ( struct m0_be_dtm0_log log,
struct m0_be_tx tx,
struct m0_dtm0_tx_desc txd,
struct m0_buf payload 
)

This routine is used to update a record in the dtm0 log. If the record does not exist it will be inserted.

Precondition
payload != NULL
m0_be_dtm0_log__invariant(log)
m0_dtm0_tx_desc__invariant(txd)
m0_mutex_is_locked(&log->dl_lock)
Postcondition
None
Parameters
logPointer to the dtm0 log which we wish to update.
txhandle to an already opened transaction.
txdA valid dtm0 tx descriptor that we want to store in the log record.
payloadThe payload is an opaque structure for dtm0 log to store in the log record.
Returns
0 on success, anything else is a failure.

Definition at line 460 of file dtm0_log.c.

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

◆ m0_be_dtm0_plog_can_prune()

M0_INTERNAL bool m0_be_dtm0_plog_can_prune ( struct m0_be_dtm0_log log,
const struct m0_dtm0_tid id,
struct m0_be_tx_credit accum 
)

Given a pointer to a dtm0 persistent log and a transaction id, this routine searches the log for the log record matching this tx id and checks whether all log records with id lower or equal to the specified id are persistent and if they can be pruned.

Precondition
m0_be_dtm0_log__invariant(log)
m0_dtm0_tid__invariant(id)
m0_mutex_is_locked(&log->dl_lock)
Postcondition
None
Parameters
logPointer to the log from which we want to delete the record.
txPointer to an open be transaction.
idPointer to a dtm0 transaction id corresponding to the record that we wish to delete from the log.
Returns
-ENOENT if no record exists for this tid, 0 if the record is found and all previous records in the log including this record can be successfully deleted, -EPROTO if the record is found but NOT all previous records in the log can be deleted, Anything else is considered a failure.

To prune a record from the log, it needs to be persistent in the log and all the records in the log with id lower than this must be persistent as well. And, when we delete this record we will need to delete all such records. This function is used to determine whether the record with the given id can be pruned from the log and if yes, it also returns a count of the number of be tx credits that would be requried to delete these many records.

Definition at line 573 of file dtm0_log.c.

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

◆ m0_be_dtm0_plog_prune()

M0_INTERNAL int m0_be_dtm0_plog_prune ( struct m0_be_dtm0_log log,
struct m0_be_tx tx,
const struct m0_dtm0_tid id 
)

Given a pointer to a dtm0 persistent log and a transaction id, this routine searches the log for the log record matching this tx id and removes all the log records with id lower or equal to the specified id that are persistent.

Precondition
*log->dl_is_persistent == true
m0_be_dtm0_log__invariant(log)
m0_dtm0_tid__invariant(id)
m0_mutex_is_locked(&log->dl_lock)
Postcondition
None
Parameters
logPointer to the log from which we want to delete the record.
txPointer to an open be transaction.
idPointer to a dtm0 transaction id corresponding to the record that we wish to delete from the log.
Returns
-ENOENT if no record exists for this id, 0 if the record is found and successfully deleted, Anything else is considered a failure.

Definition at line 609 of file dtm0_log.c.

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

◆ m0_be_dtm0_volatile_log_insert()

M0_INTERNAL int m0_be_dtm0_volatile_log_insert ( struct m0_be_dtm0_log log,
struct m0_dtm0_log_rec rec 
)

Given a pointer to a dtm0 volatile log and a log record, insert the record in the log.

Precondition
log is a volatile log
rec is initialized and valid
Postcondition
None
Parameters
logPointer to the volatile log into which that we want to insert the record.
Returns
None.

Definition at line 540 of file dtm0_log.c.

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

◆ m0_be_dtm0_volatile_log_update()

M0_INTERNAL void m0_be_dtm0_volatile_log_update ( struct m0_be_dtm0_log log,
struct m0_dtm0_log_rec rec 
)

This routine is used to update a record in a dtm0 volatile log.

Precondition
log is a volatile log
rec is initialized and valid
Postcondition
None
Parameters
logPointer to the dtm0 log which we wish to destroy
recPointer to a valid dtm0 log record that we want to update.
Returns
None

Definition at line 555 of file dtm0_log.c.

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