Motr  M0
oid.c File Reference
#include "motr/client.h"
#include "motr/st/st_misc.h"
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <pthread.h>
Include dependency graph for oid.c:

Go to the source code of this file.

Data Structures

struct  oid_extent
 

Enumerations

enum  { M0_MIN_APP_OID = 0x100000UL }
 

Functions

static void oid_extent_lock (void)
 
static void oid_extent_unlock (void)
 
static int oid_extent_is_overlapped (uint64_t start1, uint64_t range1, uint64_t start2, uint64_t range2)
 
static void oid_extent_delete (struct oid_extent *oe)
 
static void oid_extent_split (struct oid_extent *oe, uint64_t wanted)
 
static void oid_extent_merge (struct oid_extent *oe, uint64_t s_oid, uint64_t nr_oids, int direction)
 
static void oid_extent_insert_head (uint64_t s_oid, uint64_t nr_oids)
 
static void oid_extent_insert (uint64_t s_oid, uint64_t nr_oids)
 
static void oid_fill (struct m0_uint128 *oids, uint64_t s_id, int nr_id)
 
static uint64_t oid_alloc (struct m0_uint128 *oids, uint64_t nr_oids)
 
int oid_get (struct m0_uint128 *oid)
 
void oid_put (struct m0_uint128 oid)
 
uint64_t oid_get_many (struct m0_uint128 *oids, uint64_t nr_oids)
 
void oid_put_many (struct m0_uint128 *oids, uint64_t nr_oids)
 
int oid_allocator_init (void)
 
int oid_allocator_fini (void)
 

Variables

static pthread_mutex_t oid_extent_list_lock
 
static struct oid_extent oid_extent_lh
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
M0_MIN_APP_OID 

Definition at line 72 of file oid.c.

Function Documentation

◆ oid_alloc()

static uint64_t oid_alloc ( struct m0_uint128 oids,
uint64_t  nr_oids 
)
static

Lookup the first available set of oids and allocate

Parameters
oidsarray for returned object IDs
nr_oidsnumber of wanted object IDs
Returns
: < 0, no free

Definition at line 322 of file oid.c.

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

◆ oid_extent_delete()

static void oid_extent_delete ( struct oid_extent oe)
static

Definition at line 103 of file oid.c.

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

◆ oid_extent_insert()

static void oid_extent_insert ( uint64_t  s_oid,
uint64_t  nr_oids 
)
static

Insert oe to a place where: a. s_oid > prev->oe_start + prev->oe_range b. oe->oe_start > s_oid + nr_oids

Definition at line 245 of file oid.c.

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

◆ oid_extent_insert_head()

static void oid_extent_insert_head ( uint64_t  s_oid,
uint64_t  nr_oids 
)
static

Insert an extent in head

Definition at line 183 of file oid.c.

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

◆ oid_extent_is_overlapped()

static int oid_extent_is_overlapped ( uint64_t  start1,
uint64_t  range1,
uint64_t  start2,
uint64_t  range2 
)
static

Definition at line 90 of file oid.c.

Here is the caller graph for this function:

◆ oid_extent_lock()

static void oid_extent_lock ( void  )
static

Definition at line 76 of file oid.c.

Here is the caller graph for this function:

◆ oid_extent_merge()

static void oid_extent_merge ( struct oid_extent oe,
uint64_t  s_oid,
uint64_t  nr_oids,
int  direction 
)
static

Definition at line 143 of file oid.c.

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

◆ oid_extent_split()

static void oid_extent_split ( struct oid_extent oe,
uint64_t  wanted 
)
static

Definition at line 129 of file oid.c.

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

◆ oid_extent_unlock()

static void oid_extent_unlock ( void  )
static

Definition at line 83 of file oid.c.

Here is the caller graph for this function:

◆ oid_fill()

static void oid_fill ( struct m0_uint128 oids,
uint64_t  s_id,
int  nr_id 
)
static

Definition at line 305 of file oid.c.

Here is the caller graph for this function:

Variable Documentation

◆ oid_extent_lh

struct oid_extent oid_extent_lh
static
Initial value:
= {
.oe_start = 0x100000UL,
.oe_range = 0xfffffffffffffeffUL,
.oe_prev = &oid_extent_lh,
}
static struct oid_extent oid_extent_lh
Definition: oid.c:65
struct oid_extent * oe_next
Definition: oid.c:57

Definition at line 65 of file oid.c.

◆ oid_extent_list_lock

pthread_mutex_t oid_extent_list_lock
static

A simple implementation of extent-based oid allocator for ST. (1) It supports single oid and range oid allocation and free. (2) FID extents are linked in a ordered list and performance is not our focus for this version (3) Simple allocation policy: the first found free oids first if there is no free object ID, we simply return with an error and we don't wait for others to release object IDs.

Definition at line 49 of file oid.c.