Motr  M0
flock.c File Reference
#include <sys/stat.h>
#include "lib/misc.h"
#include "lib/memory.h"
#include "lib/finject.h"
#include "lib/locality.h"
#include "reqh/reqh_service.h"
#include "reqh/reqh.h"
#include "motr/setup.h"
#include "sns/cm/repair/ag.h"
#include "sns/cm/cm.h"
#include "sns/cm/file.h"
#include "sns/cm/repair/ut/cp_common.h"
#include "fop/fom_simple.h"
#include "mdservice/md_fid.h"
#include "rm/rm_service.h"
Include dependency graph for flock.c:

Go to the source code of this file.

Data Structures

struct  flock_ut_fom
 

Enumerations

enum  {
  SINGLE_THREAD_TEST = 1, MULTI_THREAD_TEST, KEY_START = 1ULL << 16, NR = 3,
  KEY_MAX = KEY_START + NR, NR_FIDS = 10
}
 
enum  { FILE_LOCK = M0_FOM_PHASE_FINISH + 1, FILE_LOCK_WAIT, FILE_LOCKED, FILE_UNLOCK_WAIT }
 

Functions

static int file_lock_verify (struct m0_sns_cm *scm, struct m0_fid *fid, int64_t ref)
 
static struct flock_ut_fomfom_simple2flock_fom (struct m0_fom_simple *fs)
 
static int flock_ut_fom_tick (struct m0_fom *fom, void *data, int *phase)
 
void flock_ut_fom_free (struct m0_fom_simple *sfom)
 
static void sns_flock_multi_fom (void)
 
static void sns_flock_single_fom (void)
 
static int fids_set (void)
 
static int test_setup (void)
 
static int test_fini (void)
 
static void file_lock_wait (struct m0_sns_cm_file_ctx *fctx, struct m0_clink *clink)
 
static void file_unlock_and_wait (struct m0_sns_cm_file_ctx *fctx, struct m0_clink *clink)
 
static void sns_file_lock_unlock (void)
 

Variables

static struct m0_reqhreqh
 
static struct m0_reqh_serviceservice
 
static struct m0_cmcm
 
static struct m0_sns_cmscm
 
static struct flock_ut_fom fs [NR]
 
static struct m0_fid test_fids [NR_FIDS]
 
static struct m0_fid gfid
 
static int fid_index
 
static struct m0_sm_state_descr flock_ut_fom_phases []
 
static struct m0_sm_conf flock_ut_conf
 
struct m0_ut_suite sns_flock_ut
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SINGLE_THREAD_TEST 
MULTI_THREAD_TEST 
KEY_START 
NR 
KEY_MAX 
NR_FIDS 

Definition at line 41 of file flock.c.

◆ anonymous enum

anonymous enum
Enumerator
FILE_LOCK 
FILE_LOCK_WAIT 
FILE_LOCKED 
FILE_UNLOCK_WAIT 

Definition at line 64 of file flock.c.

Function Documentation

◆ fids_set()

static int fids_set ( void  )
static

Definition at line 224 of file flock.c.

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

◆ file_lock_verify()

static int file_lock_verify ( struct m0_sns_cm scm,
struct m0_fid fid,
int64_t  ref 
)
static

Definition at line 105 of file flock.c.

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

◆ file_lock_wait()

static void file_lock_wait ( struct m0_sns_cm_file_ctx fctx,
struct m0_clink clink 
)
static

Definition at line 274 of file flock.c.

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

◆ file_unlock_and_wait()

static void file_unlock_and_wait ( struct m0_sns_cm_file_ctx fctx,
struct m0_clink clink 
)
static

Definition at line 300 of file flock.c.

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

◆ flock_ut_fom_free()

void flock_ut_fom_free ( struct m0_fom_simple sfom)

Definition at line 189 of file flock.c.

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

◆ flock_ut_fom_tick()

static int flock_ut_fom_tick ( struct m0_fom fom,
void *  data,
int *  phase 
)
static

Definition at line 123 of file flock.c.

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

◆ fom_simple2flock_fom()

static struct flock_ut_fom* fom_simple2flock_fom ( struct m0_fom_simple fs)
static

Definition at line 118 of file flock.c.

Here is the caller graph for this function:

◆ sns_file_lock_unlock()

static void sns_file_lock_unlock ( void  )
static

Definition at line 310 of file flock.c.

Here is the call graph for this function:

◆ sns_flock_multi_fom()

static void sns_flock_multi_fom ( void  )
static

Definition at line 196 of file flock.c.

Here is the call graph for this function:

◆ sns_flock_single_fom()

static void sns_flock_single_fom ( void  )
static

Definition at line 213 of file flock.c.

Here is the call graph for this function:

◆ test_fini()

static int test_fini ( void  )
static

Definition at line 266 of file flock.c.

Here is the call graph for this function:

◆ test_setup()

static int test_setup ( void  )
static

Definition at line 241 of file flock.c.

Here is the call graph for this function:

Variable Documentation

◆ cm

struct m0_cm* cm
static

Definition at line 57 of file flock.c.

◆ fid_index

int fid_index
static

Definition at line 62 of file flock.c.

◆ flock_ut_conf

struct m0_sm_conf flock_ut_conf
static
Initial value:
= {
.scf_name = "flock ut fom",
.scf_nr_states = ARRAY_SIZE(flock_ut_fom_phases),
.scf_state = flock_ut_fom_phases,
}
static struct m0_sm_state_descr flock_ut_fom_phases[]
Definition: flock.c:71
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 99 of file flock.c.

◆ flock_ut_fom_phases

struct m0_sm_state_descr flock_ut_fom_phases[]
static
Initial value:
= {
.sd_name = "init",
.sd_allowed = M0_BITS(FILE_LOCK),
.sd_flags = M0_SDF_INITIAL
},
[FILE_LOCK] = {
.sd_name = "File lock acquire",
},
.sd_name = "Wait for file lock",
},
.sd_name = "file locked, now unlock",
},
.sd_name = "file unlocked, now fini",
},
.sd_name = "fini",
.sd_flags = M0_SDF_TERMINAL
}
}
#define M0_BITS(...)
Definition: misc.h:236

Definition at line 71 of file flock.c.

◆ fs

struct flock_ut_fom fs[NR]
static

Definition at line 59 of file flock.c.

◆ gfid

struct m0_fid gfid
static

Definition at line 61 of file flock.c.

◆ reqh

struct m0_reqh* reqh
static

Definition at line 55 of file flock.c.

◆ scm

struct m0_sns_cm* scm
static

Definition at line 58 of file flock.c.

◆ service

struct m0_reqh_service* service
static

Definition at line 56 of file flock.c.

◆ sns_flock_ut

struct m0_ut_suite sns_flock_ut
Initial value:
= {
.ts_name = "sns-file-lock-ut",
.ts_init = test_setup,
.ts_fini = test_fini,
.ts_tests = {
{ "sns-file-lock-unlock", sns_file_lock_unlock},
{ "sns-flock-single-fom", sns_flock_single_fom},
{ "sns-flock-multi-fom", sns_flock_multi_fom},
{ NULL, NULL }
}
}
#define NULL
Definition: misc.h:38
static void sns_flock_single_fom(void)
Definition: flock.c:213
static void sns_file_lock_unlock(void)
Definition: flock.c:310
static int test_setup(void)
Definition: flock.c:241
static void sns_flock_multi_fom(void)
Definition: flock.c:196
static int test_fini(void)
Definition: flock.c:266

Definition at line 343 of file flock.c.

◆ test_fids

struct m0_fid test_fids[NR_FIDS]
static

Definition at line 60 of file flock.c.