4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "locking_types.h"
21 #include "lvm-string.h"
30 static void _no_fin_locking(void)
35 static void _no_reset_locking(void)
40 static int _no_lock_resource(struct cmd_context
*cmd
, const char *resource
,
43 switch (flags
& LCK_SCOPE_MASK
) {
47 switch (flags
& LCK_TYPE_MASK
) {
49 return lv_deactivate(cmd
, resource
);
51 return lv_resume_if_active(cmd
, resource
);
53 return lv_activate_with_filter(cmd
, resource
, 0);
55 return lv_suspend_if_active(cmd
, resource
);
57 return lv_activate_with_filter(cmd
, resource
, 1);
63 log_error("Unrecognised lock scope: %d",
64 flags
& LCK_SCOPE_MASK
);
71 static int _readonly_lock_resource(struct cmd_context
*cmd
,
75 if ((flags
& LCK_TYPE_MASK
) == LCK_WRITE
&&
76 (flags
& LCK_SCOPE_MASK
) == LCK_VG
&&
77 !(flags
& LCK_CACHE
) &&
78 strcmp(resource
, VG_GLOBAL
)) {
79 log_error("Write locks are prohibited with --ignorelockingfailure.");
83 return _no_lock_resource(cmd
, resource
, flags
);
86 int init_no_locking(struct locking_type
*locking
, struct cmd_context
*cmd
__attribute((unused
)))
88 locking
->lock_resource
= _no_lock_resource
;
89 locking
->reset_locking
= _no_reset_locking
;
90 locking
->fin_locking
= _no_fin_locking
;
91 locking
->flags
= LCK_CLUSTERED
;
96 int init_readonly_locking(struct locking_type
*locking
, struct cmd_context
*cmd
__attribute((unused
)))
98 locking
->lock_resource
= _readonly_lock_resource
;
99 locking
->reset_locking
= _no_reset_locking
;
100 locking
->fin_locking
= _no_fin_locking
;