Motr  M0
Layout DB

Detailed functional specification for Layout DB. More...

Functions

M0_INTERNAL int m0_layout_lookup (struct m0_layout_domain *dom, uint64_t lid, struct m0_layout_type *lt, struct m0_db_tx *tx, struct m0_db_pair *pair, struct m0_layout **out)
 
M0_INTERNAL int m0_layout_add (struct m0_layout *l, struct m0_db_tx *tx, struct m0_db_pair *pair)
 
M0_INTERNAL int m0_layout_update (struct m0_layout *l, struct m0_db_tx *tx, struct m0_db_pair *pair)
 
M0_INTERNAL int m0_layout_delete (struct m0_layout *l, struct m0_db_tx *tx, struct m0_db_pair *pair)
 
M0_INTERNAL void m0_layout_pair_set (struct m0_db_pair *pair, uint64_t *lid, void *area, m0_bcount_t num_bytes)
 

Detailed Description

Detailed functional specification for Layout DB.

Detailed functional specification provides documentation of all the data structures and interfaces (internal and external).

See also
Layout DB DLD and its Layout DB Functional Specification.

Function Documentation

◆ m0_layout_add()

M0_INTERNAL int m0_layout_add ( struct m0_layout l,
struct m0_db_tx *  tx,
struct m0_db_pair *  pair 
)

Adds a new layout record entry into the layouts table. If applicable, adds layout type and enum type specific entries into the relevant tables.

Parameters
pairA m0_db_pair sent by the caller along with having set pair->dp_key.db_buf and pair->dp_rec.db_buf. This is to leave the buffer allocation with the caller.

Regarding the size of the pair->dp_rec.db_buf: The buffer size should be large enough to contain the data that is to be written specifically to the layouts table. It means it needs to be at the most the size returned by m0_layout_max_recsize().

Definition at line 542 of file layout_db.c.

Here is the call graph for this function:

◆ m0_layout_delete()

M0_INTERNAL int m0_layout_delete ( struct m0_layout l,
struct m0_db_tx *  tx,
struct m0_db_pair *  pair 
)

Deletes a layout record with given layout id and its related information from the relevant tables.

Parameters
pairA m0_db_pair sent by the caller along with having set pair->dp_key.db_buf and pair->dp_rec.db_buf. This is to leave the buffer allocation with the caller.

Regarding the size of the pair->dp_rec.db_buf: The buffer size should be large enough to contain the data that is to be written specifically to the layouts table. It means it needs to be at the most the size returned by m0_layout_max_recsize().

Definition at line 601 of file layout_db.c.

Here is the call graph for this function:

◆ m0_layout_lookup()

M0_INTERNAL int m0_layout_lookup ( struct m0_layout_domain dom,
uint64_t  lid,
struct m0_layout_type lt,
struct m0_db_tx *  tx,
struct m0_db_pair *  pair,
struct m0_layout **  out 
)

Looks for an in-memory layout object with the given identifier in the list of layout objects maintained in the layout domain. If not found there, looks up for a persistent layout record in the layout DB with the given identifier. If present in the layout DB, prepares an in-memory layout object with the information from the DB and adds the layout object to the list of layout objects in the layout domain.

All operations are performed in the context of the caller-supplied transaction.

Parameters
pairA m0_db_pair sent by the caller along with having set pair->dp_key.db_buf and pair->dp_rec.db_buf. This is to leave the buffer allocation with the caller.

Regarding the size of the pair->dp_rec.db_buf: The buffer size should be large enough to contain the data that is to be read specifically from the layouts table. It means it needs to be at the most the size returned by m0_layout_max_recsize(). It is no harm if it is bigger than that.

Postcondition
  • Returns a layout object with the given identifier if it exists in the list of the layout objects maintained in the layout domain.
  • If it does not exist in that list, then it read from the database. If its entry exists in the database, then using it, a new layout object is built internally (along with enumeration object being built if applicable).
  • In case of successful return, an additional reference is acquired on the layout object returned in the variable "out".

Definition at line 428 of file layout_db.c.

Here is the call graph for this function:

◆ m0_layout_pair_set()

M0_INTERNAL void m0_layout_pair_set ( struct m0_db_pair *  pair,
uint64_t *  lid,
void *  area,
m0_bcount_t  num_bytes 
)

Definition at line 370 of file layout_db.c.

◆ m0_layout_update()

M0_INTERNAL int m0_layout_update ( struct m0_layout l,
struct m0_db_tx *  tx,
struct m0_db_pair *  pair 
)

Updates a layout record from the DB. The only field that can be updated for an existing layout in the layout DB is its user count. It is not prevented through the implementation to update any other fields since it was found to be costly through performance perspective.

Parameters
pairA m0_db_pair sent by the caller along with having set pair->dp_key.db_buf and pair->dp_rec.db_buf. This is to leave the buffer allocation with the caller.

Regarding the size of the pair->dp_rec.db_buf: The buffer size should be large enough to contain the data that is to be written specifically to the layouts table. It means it needs to be at the most the size returned by m0_layout_max_recsize().

Note
Even a non-existing record can be written to the database using the database update operation. In other words, not using m0_layout_add() and directly using m0_layout_update() results into the layout record being written to the DB.

Definition at line 570 of file layout_db.c.

Here is the call graph for this function: