mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Implement a no_locking module that *does* attempt activation.
This commit is contained in:
parent
63def4e716
commit
7e3d403b88
@ -38,9 +38,10 @@ SOURCES=\
|
||||
format_text/import.c \
|
||||
label/label.c \
|
||||
label/uuid-map.c \
|
||||
locking/file_locking.c \
|
||||
locking/external_locking.c \
|
||||
locking/file_locking.c \
|
||||
locking/locking.c \
|
||||
locking/no_locking.c \
|
||||
log/log.c \
|
||||
metadata/lv_manip.c \
|
||||
metadata/merge.c \
|
||||
|
@ -65,26 +65,6 @@ static inline void _update_lock_count(int flags)
|
||||
_lock_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* No locking - currently does nothing.
|
||||
*/
|
||||
int no_lock_resource(struct cmd_context *cmd, const char *resource, int flags)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void no_fin_locking(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void _init_no_locking(struct locking_type *locking,
|
||||
struct config_file *cf)
|
||||
{
|
||||
locking->lock_resource = no_lock_resource;
|
||||
locking->fin_locking = no_fin_locking;
|
||||
}
|
||||
|
||||
/*
|
||||
* Select a locking type
|
||||
*/
|
||||
@ -92,7 +72,7 @@ int init_locking(int type, struct config_file *cf)
|
||||
{
|
||||
switch (type) {
|
||||
case 0:
|
||||
_init_no_locking(&_locking, cf);
|
||||
init_no_locking(&_locking, cf);
|
||||
log_print("WARNING: Locking disabled. Be careful! "
|
||||
"This could corrupt your metadata.");
|
||||
break;
|
||||
|
@ -24,6 +24,8 @@ struct locking_type {
|
||||
/*
|
||||
* Locking types
|
||||
*/
|
||||
int init_no_locking(struct locking_type *locking, struct config_file *cf);
|
||||
|
||||
int init_file_locking(struct locking_type *locking, struct config_file *cf);
|
||||
|
||||
int init_external_locking(struct locking_type *locking, struct config_file *cf);
|
||||
|
60
lib/locking/no_locking.c
Normal file
60
lib/locking/no_locking.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||
*
|
||||
* This file is released under the LGPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "locking.h"
|
||||
#include "locking_types.h"
|
||||
#include "lvm-string.h"
|
||||
#include "activate.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* No locking
|
||||
*/
|
||||
|
||||
static void _no_fin_locking(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
int flags)
|
||||
{
|
||||
switch (flags & LCK_SCOPE_MASK) {
|
||||
case LCK_VG:
|
||||
break;
|
||||
case LCK_LV:
|
||||
switch (flags & LCK_TYPE_MASK) {
|
||||
case LCK_UNLOCK:
|
||||
return lv_resume_if_active(cmd, resource);
|
||||
case LCK_READ:
|
||||
return lv_activate(cmd, resource);
|
||||
case LCK_WRITE:
|
||||
return lv_suspend_if_active(cmd, resource);
|
||||
case LCK_EXCL:
|
||||
return lv_deactivate(cmd, resource);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_error("Unrecognised lock scope: %d",
|
||||
flags & LCK_SCOPE_MASK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int init_no_locking(struct locking_type *locking, struct config_file *cf)
|
||||
{
|
||||
locking->lock_resource = _no_lock_resource;
|
||||
locking->fin_locking = _no_fin_locking;
|
||||
|
||||
return 1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user