Motr  M0
m0_cob Struct Reference

#include <cob.h>

Collaboration diagram for m0_cob:
Collaboration graph

Data Fields

struct m0_cob_domainco_dom
 
struct m0_stobco_stob
 
struct m0_ref co_ref
 
uint64_t co_flags
 
struct m0_file co_file
 
struct m0_cob_nskeyco_nskey
 
struct m0_cob_oikey co_oikey
 
struct m0_cob_nsrec co_nsrec
 
struct m0_cob_fabrecco_fabrec
 
struct m0_cob_omgrec co_omgrec
 

Detailed Description

In-memory representation of a component object.

m0_cob is an in-memory structure, populated from database tables on demand. m0_cob is not cached for long time (except for root) and is only used as a temporary handle of database structures for the sake of handiness. This means, we don't need to bother with locking as every time we pass cob to some function this is new instance of it.

The exposed methods to get a new instance of cob are:

  • m0_cob_lookup() - allocate new in-memory cob and populate it with lookup by name.
  • m0_cob_locate() - allocate new in-memory cob and populate it with lookup by fid.
  • m0_cob_create() - allocate new in-memory cob, populate it with passed records and create database structures.

The cobs returned by these methods are always populated.

Not populated cob is only exposed with m0_cob_alloc() method, which is used by request handler and (possibly) others. Such a cob is used as an input parameter to functions mentioned above.

Users use m0_cob_get/put to hold/release references; a cob may be destroyed on the last put, or it may be cached for some time (just like root cob is).

Todo:
at some point, we may replace the co_ref by taking a reference on the underlying co_stob. At that point, we will need a callback at last put. We wait to see how cob users will use these references, whether they need callbacks in turn, etc.

A m0_cob serves several purposes:

  • it acts as a handle for the underlying metadata storage. Meta-data operations can be executed on persistent storage by calling functions on m0_cob;
  • it caches certain metadata attributes in memory (controlled by ->co_flags);

Liveness A m0_cob may be freed when the reference count drops to 0.

Note
m0_cob_nskey is allocated separately because it is variable length. Once allocated, it can be released if M0_CA_NSKEY_FREE flag is specified in its allocation time.

Caching and concurrency Cobs are not cached by cob domain, neither by cob API users. Rationale is the following:

  • we use db[45] for storing metadata and it already has cache that may work in a way that satisfies our needs;
  • using cache means substantial complications with locking and concurrent access. Currently these issues are completely covered by db[45].

Definition at line 581 of file cob.h.


The documentation for this struct was generated from the following file: