Motr  M0
ufid.c File Reference
#include "helpers/ufid.h"
#include "lib/errno.h"
#include "lib/arith.h"
#include "lib/finject.h"
#include "lib/trace.h"
Include dependency graph for ufid.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT
 

Functions

static bool ufid_invariant (struct m0_ufid *ufid)
 
static void ufid_salt_refresh (struct m0_ufid_generator *gr)
 
static int ufid_generation_id_refresh (struct m0_ufid_generator *gr)
 
static int ufid_proc_id_refresh (struct m0_ufid_generator *gr)
 
static int ufid_seq_id_refresh (struct m0_ufid_generator *gr, uint32_t nr_seqs)
 
static void ufid_to_id128 (struct m0_ufid *ufid, struct m0_uint128 *id128)
 
int m0_ufid_init (struct m0_client *m0c, struct m0_ufid_generator *gr)
 
void m0_ufid_fini (struct m0_ufid_generator *gr)
 
int m0_ufid_new (struct m0_ufid_generator *gr, uint32_t nr_ids, uint32_t nr_skip_ids, struct m0_uint128 *id128)
 
int m0_ufid_next (struct m0_ufid_generator *gr, uint32_t nr_ids, struct m0_uint128 *id128)
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CLIENT

Definition at line 29 of file ufid.c.

Function Documentation

◆ m0_ufid_fini()

void m0_ufid_fini ( struct m0_ufid_generator gr)

Finalises Unique File/object ID (UFID) generator.

Parameters
grThe UFID generator to be finalised.

Definition at line 283 of file ufid.c.

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

◆ m0_ufid_init()

int m0_ufid_init ( struct m0_client m0c,
struct m0_ufid_generator gr 
)

Initialises Unique File/object ID (UFID) generator.

Parameters
m0cThe Client instance contains required process FID.
grThe UFID generator to be initialised.
Returns
Returns 0 on success. Negative errno in case of error.

Definition at line 248 of file ufid.c.

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

◆ m0_ufid_new()

int m0_ufid_new ( struct m0_ufid_generator gr,
uint32_t  nr_ids,
uint32_t  nr_skip_ids,
struct m0_uint128 id128 
)

Primary interface to obtain one or more unique file/object IDs of 128 bits.

m0_ufid_new() obtains new FID range which is unique across nodes/processes.

Input Params:

Parameters
grPointer to an UFID generator.
nr_idsNumber of IDs that should be allocated. nr_ids value cannot be greater than (2^20-1).
nr_skip_idsNumber of FIDs to skip. It invalidates nr_skip_ids ID range and cannot be greater than (2^20-1).
id128[Output]Starting ID of generated range.
Returns
Returns 0 on success. Negative errno in case of error.

Error Values: -EINVAL In case of errors in parameters. -ETIME In case clock errors are detected. -EPERM In case module is not initialized before invoking this interface.

Definition at line 298 of file ufid.c.

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

◆ m0_ufid_next()

int m0_ufid_next ( struct m0_ufid_generator gr,
uint32_t  nr_ids,
struct m0_uint128 id128 
)

m0_ufid_next() is a simple wrapper of m0_ufid_new() which always tries to allocate FID range starting from current available FID.

See also
m0_ufid_new() above for argument descriptions.

Definition at line 338 of file ufid.c.

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

◆ ufid_generation_id_refresh()

static int ufid_generation_id_refresh ( struct m0_ufid_generator gr)
static

Refreshes generation ID of UFID structure

Parameters
gr- Pointer to the UFID generator.
Returns
- Returns 0 on success. Negative errno in case of error.

Definition at line 60 of file ufid.c.

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

◆ ufid_invariant()

static bool ufid_invariant ( struct m0_ufid ufid)
static

Definition at line 32 of file ufid.c.

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

◆ ufid_proc_id_refresh()

static int ufid_proc_id_refresh ( struct m0_ufid_generator gr)
static

Refreshes process id of an ufid generator

Parameters
gr- Pointer to the UFID generator.
Returns
- Returns 0 on success. Negative errno in case of error.

Definition at line 124 of file ufid.c.

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

◆ ufid_salt_refresh()

static void ufid_salt_refresh ( struct m0_ufid_generator gr)
static

Fills random number as salt.

Parameters
gr- Pointer to the UFID generator.

Definition at line 45 of file ufid.c.

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

◆ ufid_seq_id_refresh()

static int ufid_seq_id_refresh ( struct m0_ufid_generator gr,
uint32_t  nr_seqs 
)
static

Reserves a range of seq IDs by incrementing current sequence id stored in UFID generator. If the number of available sequence ids under current generation id cann't satisfy the number of sequence ids wanted, a new generation id will be created.

Parameters
gr- Pointer to the UFID generator.
nr_seqs- Number of sequences to reserve/skip
Returns
- Returns 0 on success. Negative errno in case of error.

Definition at line 178 of file ufid.c.

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

◆ ufid_to_id128()

static void ufid_to_id128 ( struct m0_ufid ufid,
struct m0_uint128 id128 
)
static

Definition at line 209 of file ufid.c.

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