1 /* $NetBSD: no_locking.c,v 1.1.1.1 2008/12/22 00:18:02 haad Exp $ */ 2 3 /* 4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. 5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 6 * 7 * This file is part of LVM2. 8 * 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. 12 * 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 16 */ 17 18 #include "lib.h" 19 #include "locking.h" 20 #include "locking_types.h" 21 #include "lvm-string.h" 22 #include "activate.h" 23 24 #include <signal.h> 25 26 /* 27 * No locking 28 */ 29 30 static void _no_fin_locking(void) 31 { 32 return; 33 } 34 35 static void _no_reset_locking(void) 36 { 37 return; 38 } 39 40 static int _no_lock_resource(struct cmd_context *cmd, const char *resource, 41 uint32_t flags) 42 { 43 switch (flags & LCK_SCOPE_MASK) { 44 case LCK_VG: 45 break; 46 case LCK_LV: 47 switch (flags & LCK_TYPE_MASK) { 48 case LCK_NULL: 49 return lv_deactivate(cmd, resource); 50 case LCK_UNLOCK: 51 return lv_resume_if_active(cmd, resource); 52 case LCK_READ: 53 return lv_activate_with_filter(cmd, resource, 0); 54 case LCK_WRITE: 55 return lv_suspend_if_active(cmd, resource); 56 case LCK_EXCL: 57 return lv_activate_with_filter(cmd, resource, 1); 58 default: 59 break; 60 } 61 break; 62 default: 63 log_error("Unrecognised lock scope: %d", 64 flags & LCK_SCOPE_MASK); 65 return 0; 66 } 67 68 return 1; 69 } 70 71 int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused))) 72 { 73 locking->lock_resource = _no_lock_resource; 74 locking->reset_locking = _no_reset_locking; 75 locking->fin_locking = _no_fin_locking; 76 locking->flags = LCK_CLUSTERED; 77 78 return 1; 79 } 80