Motr  M0
rm.h File Reference
#include "lib/tlist.h"
#include "lib/types.h"
#include "lib/cookie.h"
#include "lib/chan.h"
#include "fid/fid.h"
#include "net/net.h"
#include "sm/sm.h"
#include "rm/rm_ha.h"
Include dependency graph for rm.h:

Go to the source code of this file.

Data Structures

struct  m0_rm_domain
 
struct  m0_rm_resource
 
struct  m0_rm_resource_ops
 
struct  m0_rm_resource_type
 
struct  m0_rm_resource_type_ops
 
struct  m0_rm_credit
 
struct  m0_rm_credit_ops
 
struct  m0_rm_remote
 
struct  m0_rm_owner
 
struct  m0_rm_loan
 
struct  m0_rm_reserve_prio
 
struct  m0_rm_incoming
 
struct  m0_rm_incoming_ops
 
struct  m0_rm_outgoing
 
struct  m0_rm_pin
 

Macros

#define __MOTR_RM_RM_H__
 
#define M0_RM_REMOTE_GET(remote)
 
#define M0_RM_REMOTE_PUT(remote)
 

Enumerations

enum  { M0_RM_RESOURCE_TYPE_ID_MAX = 64 }
 
enum  { M0_RM_OWNER_FT = 'O' }
 
enum  m0_rm_incoming_type { M0_RIT_LOCAL, M0_RIT_BORROW, M0_RIT_REVOKE, M0_RIT_NR }
 
enum  m0_res_type_id { M0_RM_FLOCK_RT = 1, M0_RM_RWLOCKABLE_RT = 2 }
 
enum  m0_rm_remote_state {
  REM_FREED = 0, REM_INITIALISED, REM_SERVICE_LOCATING, REM_SERVICE_LOCATED,
  REM_OWNER_LOCATING, REM_OWNER_LOCATED
}
 
enum  m0_rm_owner_state {
  ROS_INITIAL = 1, ROS_INITIALISING, ROS_ACTIVE, ROS_QUIESCE,
  ROS_FINALISING, ROS_DEAD_CREDITOR, ROS_INSOLVENT, ROS_FINAL
}
 
enum  { M0_RM_REQUEST_PRIORITY_MAX = 3, M0_RM_REQUEST_PRIORITY_NR }
 
enum  m0_rm_owner_owned_state { OWOS_HELD, OWOS_CACHED, OWOS_NR }
 
enum  m0_rm_owner_queue_state { OQS_GROUND, OQS_EXCITED, OQS_NR }
 
enum  { M0_RM_LOAN_SELF_ID = 1 }
 
enum  m0_rm_incoming_state {
  RI_INITIALISED = 1, RI_CHECK, RI_SUCCESS, RI_FAILURE,
  RI_WAIT, RI_RELEASED, RI_FINAL
}
 
enum  m0_rm_incoming_policy {
  RIP_NONE = 1, RIP_INPLACE, RIP_STRICT, RIP_JOIN,
  RIP_MAX, RIP_NR
}
 
enum  m0_rm_incoming_flags {
  RIF_MAY_REVOKE = (1 << 0), RIF_MAY_BORROW = (1 << 1), RIF_LOCAL_WAIT = (1 << 2), RIF_LOCAL_TRY = (1 << 3),
  RIF_RESERVE = (1 << 4)
}
 
enum  m0_rm_outgoing_type { M0_ROT_BORROW = 1, M0_ROT_CANCEL, M0_ROT_REVOKE }
 
enum  m0_rm_pin_flags { M0_RPF_TRACK = (1 << 0), M0_RPF_PROTECT = (1 << 1), M0_RPF_BARRIER = (1 << 2) }
 

Functions

M0_INTERNAL void m0_rm_domain_init (struct m0_rm_domain *dom)
 
M0_INTERNAL void m0_rm_domain_fini (struct m0_rm_domain *dom)
 
M0_INTERNAL int m0_rm_type_register (struct m0_rm_domain *dom, struct m0_rm_resource_type *rt)
 
M0_INTERNAL void m0_rm_type_deregister (struct m0_rm_resource_type *rt)
 
M0_INTERNAL struct m0_rm_resource_typem0_rm_resource_type_lookup (const struct m0_rm_domain *dom, const uint64_t rtype_id)
 
M0_INTERNAL struct m0_rm_resourcem0_rm_resource_find (const struct m0_rm_resource_type *rt, const struct m0_rm_resource *res)
 
M0_INTERNAL void m0_rm_resource_add (struct m0_rm_resource_type *rtype, struct m0_rm_resource *res)
 
M0_INTERNAL void m0_rm_resource_del (struct m0_rm_resource *res)
 
M0_INTERNAL void m0_rm_resource_free (struct m0_rm_resource *res)
 
M0_INTERNAL int m0_rm_resource_encode (struct m0_rm_resource *res, struct m0_buf *buf)
 
M0_INTERNAL void m0_rm_resource_initial_credit (const struct m0_rm_resource *resource, struct m0_rm_credit *credit)
 
M0_INTERNAL void m0_rm_owner_init (struct m0_rm_owner *owner, struct m0_fid *fid, const struct m0_uint128 *group, struct m0_rm_resource *res, struct m0_rm_remote *creditor)
 
M0_INTERNAL void m0_rm_owner_init_rfid (struct m0_rm_owner *owner, const struct m0_uint128 *group, struct m0_rm_resource *res, struct m0_rm_remote *creditor)
 
M0_INTERNAL int m0_rm_owner_selfadd (struct m0_rm_owner *owner, struct m0_rm_credit *r)
 
M0_INTERNAL void m0_rm_owner_windup (struct m0_rm_owner *owner)
 
M0_INTERNAL void m0_rm_owner_creditor_reset (struct m0_rm_owner *owner, struct m0_rm_remote *creditor)
 
M0_INTERNAL int m0_rm_owner_timedwait (struct m0_rm_owner *owner, uint64_t state, const m0_time_t abs_timeout)
 
M0_INTERNAL void m0_rm_owner_fini (struct m0_rm_owner *owner)
 
M0_INTERNAL void m0_rm_owner_lock (struct m0_rm_owner *owner)
 
M0_INTERNAL void m0_rm_owner_unlock (struct m0_rm_owner *owner)
 
M0_INTERNAL void m0_rm_credit_init (struct m0_rm_credit *credit, struct m0_rm_owner *owner)
 
M0_INTERNAL void m0_rm_credit_fini (struct m0_rm_credit *credit)
 
M0_INTERNAL void m0_rm_incoming_init (struct m0_rm_incoming *in, struct m0_rm_owner *owner, enum m0_rm_incoming_type type, enum m0_rm_incoming_policy policy, uint64_t flags)
 
M0_INTERNAL void m0_rm_incoming_fini (struct m0_rm_incoming *in)
 
M0_INTERNAL void m0_rm_remote_init (struct m0_rm_remote *rem, struct m0_rm_resource *res)
 
M0_INTERNAL void m0_rm_remote_fini (struct m0_rm_remote *rem)
 
M0_INTERNAL int m0_rm_net_locate (struct m0_rm_credit *credit, struct m0_rm_remote *other)
 
M0_INTERNAL void m0_rm_remote_owner_set (struct m0_rm_remote *rem, uint64_t id)
 
Credit helpers
M0_INTERNAL int m0_rm_credit_dup (const struct m0_rm_credit *src_credit, struct m0_rm_credit **dest_credit)
 
M0_INTERNAL int m0_rm_credit_copy (struct m0_rm_credit *dst, const struct m0_rm_credit *src)
 
M0_INTERNAL int m0_rm_credit_encode (struct m0_rm_credit *credit, struct m0_buf *buf)
 
M0_INTERNAL int m0_rm_credit_decode (struct m0_rm_credit *credit, struct m0_buf *buf)
 
Owner state machine

m0_rm_owner and m0_rm_incoming together form a state machine where basic resource management functionality is implemented.

This state machine reacts to the following external events:

  • an incoming request from a local user;
  • an incoming loan request from another domain;
  • an incoming revocation request from another domain;
  • local user releases a pin on a credit (as a by-product of destroying an incoming request);
  • completion of an outgoing request to another domain (including a timeout or a failure).

Any event is processed in a uniform manner:

  1. m0_rm_owner::ro_sm_grp Group lock is taken;
  2. m0_rm_owner lists are updated to reflect the event, see details below. This temporarily violates the owner_invariant();
  3. owner_balance() is called to restore the invariant, this might create new imbalances and go through several iterations;
  4. m0_rm_owner::ro_sm_grp Group lock is released.

Event handling is serialised by the owner lock. It is not legal to wait for networking or IO events under this lock.

M0_INTERNAL void m0_rm_credit_get (struct m0_rm_incoming *in)
 
M0_INTERNAL void m0_rm_credit_put (struct m0_rm_incoming *in)
 

Variables

const struct m0_uint128 m0_rm_no_group
 

Macro Definition Documentation

◆ __MOTR_RM_RM_H__

#define __MOTR_RM_RM_H__

Definition at line 26 of file rm.h.