Motr
M0
|
Data Structures | |
struct | m0_long_lock_addb2 |
struct | m0_long_lock_link |
struct | m0_long_lock |
struct | m0_be_long_lock |
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_FOP |
#define | M0_BE_LONG_LOCK_PAD (264 + 88) |
#define | M0_FOM_LONG_LOCK_RETURN(rc) ((rc) ? M0_FSO_AGAIN : M0_FSO_WAIT) |
Enumerations | |
enum | m0_long_lock_state { M0_LONG_LOCK_UNLOCKED, M0_LONG_LOCK_RD_LOCKED, M0_LONG_LOCK_WR_LOCKED } |
enum | m0_long_lock_type { M0_LONG_LOCK_READER, M0_LONG_LOCK_WRITER } |
Variables | |
static const struct m0_bob_type | long_lock_bob |
static struct m0_bob_type | long_lock_link_bob |
#define M0_BE_LONG_LOCK_PAD (264 + 88) |
Definition at line 190 of file fom_long_lock.h.
#define M0_FOM_LONG_LOCK_RETURN | ( | rc | ) | ((rc) ? M0_FSO_AGAIN : M0_FSO_WAIT) |
A macros to request a long lock from a fom phase transition function. The value of macros should be returned from the phase transition function. The fom transitions into next_phase when the lock is acquired:
Definition at line 214 of file fom_long_lock.h.
#define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_FOP |
Definition at line 29 of file fom_long_lock.c.
enum m0_long_lock_state |
Long lock states.
Enumerator | |
---|---|
M0_LONG_LOCK_UNLOCKED | |
M0_LONG_LOCK_RD_LOCKED | |
M0_LONG_LOCK_WR_LOCKED |
Definition at line 132 of file fom_long_lock.h.
enum m0_long_lock_type |
Type of long lock link, requesting the lock
Enumerator | |
---|---|
M0_LONG_LOCK_READER | |
M0_LONG_LOCK_WRITER |
Definition at line 141 of file fom_long_lock.h.
|
static |
True, iff "link" can acquire "lock", provided "link" is at the head of waiters queue.
Definition at line 173 of file fom_long_lock.c.
|
static |
Definition at line 181 of file fom_long_lock.c.
|
static |
|
static |
Definition at line 90 of file fom_long_lock.c.
|
static |
|
static |
Definition at line 107 of file fom_long_lock.c.
|
static |
|
static |
Definition at line 192 of file fom_long_lock.c.
|
static |
This invariant is established by m0_long_lock_init(). Every top-level long lock entry point assumes that this invariant holds right after the lock's mutex is taken and restores the invariant before releasing the mutex.
Definition at line 133 of file fom_long_lock.c.
M0_BASSERT | ( | sizeof(struct m0_long_lock)<=sizeof(M0_FIELD_VALUE(struct m0_be_long_lock, bll_u.pad)) | ) |
M0_BOB_DECLARE | ( | M0_EXTERN | , |
m0_long_lock | |||
) |
M0_BOB_DECLARE | ( | M0_EXTERN | , |
m0_long_lock_link | |||
) |
M0_BOB_DEFINE | ( | M0_INTERNAL | , |
& | long_lock_bob, | ||
m0_long_lock | |||
) |
M0_BOB_DEFINE | ( | M0_INTERNAL | , |
& | long_lock_link_bob, | ||
m0_long_lock_link | |||
) |
M0_INTERNAL void m0_fom_ll_global_init | ( | void | ) |
Initializes bob-type for m0_long_lock and m0_long_lock_link. Should be called once, during system initialisation.
Definition at line 60 of file fom_long_lock.c.
M0_INTERNAL bool m0_long_is_read_locked | ( | struct m0_long_lock * | lock, |
const struct m0_fom * | fom | ||
) |
Definition at line 318 of file fom_long_lock.c.
M0_INTERNAL bool m0_long_is_write_locked | ( | struct m0_long_lock * | lock, |
const struct m0_fom * | fom | ||
) |
Definition at line 332 of file fom_long_lock.c.
M0_INTERNAL bool m0_long_lock | ( | struct m0_long_lock * | lock, |
bool | write, | ||
struct m0_long_lock_link * | link, | ||
int | next_phase | ||
) |
Takes write or read long term lock, depending on the value of the "write" parameter.
Definition at line 237 of file fom_long_lock.c.
M0_INTERNAL void m0_long_lock_fini | ( | struct m0_long_lock * | lock | ) |
Definition at line 360 of file fom_long_lock.c.
M0_INTERNAL void m0_long_lock_init | ( | struct m0_long_lock * | lock | ) |
Definition at line 348 of file fom_long_lock.c.
M0_INTERNAL void m0_long_lock_link_fini | ( | struct m0_long_lock_link * | link | ) |
Finalize long lock link object.
Definition at line 76 of file fom_long_lock.c.
M0_INTERNAL void m0_long_lock_link_init | ( | struct m0_long_lock_link * | link, |
struct m0_fom * | fom, | ||
struct m0_long_lock_addb2 * | addb2 | ||
) |
Initialize long lock link object with given fom.
addb2 optional argument which is used to collect counters on lock wait/hold times by the link
Definition at line 66 of file fom_long_lock.c.
M0_INTERNAL bool m0_long_read_lock | ( | struct m0_long_lock * | lock, |
struct m0_long_lock_link * | link, | ||
int | next_phase | ||
) |
Obtains given lock for reading for given fom. Taking recursive read-lock is not permitted. If the lock is not obtained the invoking FOM should wait; it will eventually be awoken when the lock has been obtained, and will be transitioned to the next_phase state.
link | - Long lock link associated with the FOM which has to obtain the lock. |
Definition at line 229 of file fom_long_lock.c.
M0_INTERNAL void m0_long_read_unlock | ( | struct m0_long_lock * | lock, |
struct m0_long_lock_link * | link | ||
) |
Unlocks given read-lock.
link | - Long lock link associated with the FOM which has to obtain the lock. |
Definition at line 306 of file fom_long_lock.c.
M0_INTERNAL void m0_long_unlock | ( | struct m0_long_lock * | lock, |
struct m0_long_lock_link * | link | ||
) |
Unlocks read or write lock.
Definition at line 312 of file fom_long_lock.c.
M0_INTERNAL bool m0_long_write_lock | ( | struct m0_long_lock * | lock, |
struct m0_long_lock_link * | link, | ||
int | next_phase | ||
) |
Obtains given lock for writing for given fom. Taking recursive write-lock is not permitted. If the lock is not obtained the invoking FOM should wait; it will eventually be awoken when the lock has been obtained, and will be transitioned to the next_phase state.
link | - Long lock link associated with the FOM which has to obtain the lock. |
Definition at line 221 of file fom_long_lock.c.
M0_INTERNAL void m0_long_write_unlock | ( | struct m0_long_lock * | lock, |
struct m0_long_lock_link * | link | ||
) |
Unlocks given write-lock.
link | - Long lock link associated with the FOM which has to obtain the lock. |
Definition at line 300 of file fom_long_lock.c.
M0_TL_DEFINE | ( | m0_lll | , |
M0_INTERNAL | , | ||
struct m0_long_lock_link | |||
) |
M0_TL_DESCR_DEFINE | ( | m0_lll | , |
"list of lock-links in longlock" | , | ||
M0_INTERNAL | , | ||
struct m0_long_lock_link | , | ||
lll_lock_linkage | , | ||
lll_magix | , | ||
M0_FOM_LL_LINK_MAGIC | , | ||
M0_FOM_LL_LINK_MAGIC | |||
) |
Descriptor of typed list used in m0_long_lock with m0_long_lock_link::lll_lock_linkage.
struct m0_be_long_lock M0_XCA_DOMAIN | ( | be | ) |
|
static |
Initially, here the following assertion was checked: M0_ASSERT(next->lll_fom->fo_transitions_saved + 1 == next->lll_fom->fo_transitions);
For the reason fom->fo_transitions counter is updated after control returns from fom_tick() without any locks taken, it can be so, that long lock is queued to be taken by one fom (thread) and the contorol is still inside fom_tick(), and other fom (thread) has already unlocked() -> granted() the long lock. In this case fom->fo_transitions is still not updated, so fom->fo_transitions_saved can be equal to fom->fo_transitions in this case. In other cases it has to be greater by 1.
Definition at line 245 of file fom_long_lock.c.
|
static |
Definition at line 49 of file fom_long_lock.c.
|
static |
Definition at line 57 of file fom_long_lock.c.