#ifndef LIBPMEMOBJ_LANE_H
#define LIBPMEMOBJ_LANE_H 1
#include <stdint.h>
#include "libpmemobj.h"
#include "redo.h"
#define LANE_SECTION_LEN 1024
#define REDO_NUM_ENTRIES \
((LANE_SECTION_LEN - 2 * sizeof(uint64_t)) / sizeof(struct redo_log))
#define LANE_JUMP (64 / sizeof(uint64_t))
#define LANE_PRIMARY_ATTEMPTS 128
#define RLANE_DEFAULT 0
enum lane_section_type {
LANE_SECTION_ALLOCATOR,
LANE_SECTION_LIST,
LANE_SECTION_TRANSACTION,
MAX_LANE_SECTION,
LANE_ID = MAX_LANE_SECTION
};
struct lane_section_layout {
unsigned char data[LANE_SECTION_LEN];
};
struct lane_section {
struct lane_section_layout *layout;
void *runtime;
};
struct lane_layout {
struct lane_section_layout sections[MAX_LANE_SECTION];
};
struct lane {
struct lane_section sections[MAX_LANE_SECTION];
};
struct lane_descriptor {
unsigned runtime_nlanes;
unsigned next_lane_idx;
uint64_t *lane_locks;
struct lane *lane;
};
typedef int (*section_layout_op)(PMEMobjpool *pop, void *data, unsigned length);
typedef void *(*section_constr)(PMEMobjpool *pop);
typedef void (*section_destr)(PMEMobjpool *pop, void *rt);
typedef int (*section_global_op)(PMEMobjpool *pop);
struct section_operations {
section_constr construct_rt;
section_destr destroy_rt;
section_layout_op check;
section_layout_op recover;
section_global_op boot;
};
struct lane_info {
uint64_t pop_uuid_lo;
uint64_t lane_idx;
unsigned long nest_count;
uint64_t primary;
int primary_attempts;
struct lane_info *prev, *next;
};
extern struct section_operations *Section_ops[MAX_LANE_SECTION];
void lane_info_boot(void);
void lane_info_destroy(void);
int lane_boot(PMEMobjpool *pop);
void lane_cleanup(PMEMobjpool *pop);
int lane_recover_and_section_boot(PMEMobjpool *pop);
int lane_check(PMEMobjpool *pop);
unsigned lane_hold(PMEMobjpool *pop, struct lane_section **section,
enum lane_section_type type);
void lane_release(PMEMobjpool *pop);
void lane_attach(PMEMobjpool *pop, unsigned lane);
unsigned lane_detach(PMEMobjpool *pop);
#ifndef _MSC_VER
#define SECTION_PARM(n, ops)\
__attribute__((constructor)) static void _section_parm_##n(void)\
{ Section_ops[n] = ops; }
#else
#define SECTION_PARM(n, ops)\
static void _section_parm_##n(void)\
{ Section_ops[n] = ops; }\
MSVC_CONSTR(_section_parm_##n)
#endif
#endif