1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

Add locking flags + memlock option.

This commit is contained in:
Alasdair Kergon 2004-03-26 20:17:11 +00:00
parent 4291ce3cac
commit 05896e787c
4 changed files with 11 additions and 4 deletions

View File

@ -14,7 +14,8 @@ static void *_locking_lib = NULL;
static void (*_end_fn) (void) = NULL;
static int (*_lock_fn) (struct cmd_context * cmd, const char *resource,
int flags) = NULL;
static int (*_init_fn) (int type, struct config_tree * cft) = NULL;
static int (*_init_fn) (int type, struct config_tree * cft,
uint32_t *flags) = NULL;
static int _lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
@ -49,6 +50,7 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
locking->lock_resource = _lock_resource;
locking->fin_locking = _fin_external_locking;
locking->flags = 0;
libname = find_config_str(cft->root, "global/locking_library",
DEFAULT_LOCKING_LIB);
@ -59,9 +61,9 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
}
/* Get the functions we need */
if (!(_init_fn = dlsym(_locking_lib, "init_locking")) ||
if (!(_init_fn = dlsym(_locking_lib, "locking_init")) ||
!(_lock_fn = dlsym(_locking_lib, "lock_resource")) ||
!(_end_fn = dlsym(_locking_lib, "end_locking"))) {
!(_end_fn = dlsym(_locking_lib, "locking_end"))) {
log_error("Shared library %s does not contain locking "
"functions", libname);
dlclose(_locking_lib);
@ -70,5 +72,5 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cft)
}
log_verbose("Loaded external locking library %s", libname);
return _init_fn(2, cft);
return _init_fn(2, cft, &locking->flags);
}

View File

@ -257,6 +257,7 @@ int init_file_locking(struct locking_type *locking, struct config_tree *cft)
locking->lock_resource = _file_lock_resource;
locking->reset_locking = _reset_file_locking;
locking->fin_locking = _fin_file_locking;
locking->flags = 0;
/* Get lockfile directory from config file */
strncpy(_lock_dir, find_config_str(cft->root, "global/locking_dir",

View File

@ -14,7 +14,10 @@ typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
typedef void (*fin_lock_fn) (void);
typedef void (*reset_lock_fn) (void);
#define LCK_PRE_MEMLOCK 0x00000001 /* Is memlock() needed before calls? */
struct locking_type {
uint32_t flags;
lock_resource_fn lock_resource;
reset_lock_fn reset_locking;

View File

@ -71,6 +71,7 @@ int init_no_locking(struct locking_type *locking, struct config_tree *cft)
locking->lock_resource = _no_lock_resource;
locking->reset_locking = _no_reset_locking;
locking->fin_locking = _no_fin_locking;
locking->flags = 0;
return 1;
}