From 27ff8813da360da17c974f47e6e376fefddfd2f5 Mon Sep 17 00:00:00 2001 From: Jonathan Earl Brassow Date: Fri, 4 Feb 2011 20:30:17 +0000 Subject: Allow snapshots in a cluster as long as they are exclusively activated. In order to achieve this, we need to be able to query whether the origin is active exclusively (a condition of being able to add an exclusive snapshot). Once we are able to query the exclusive activation of an LV, we can safely create/activate the snapshot. A change to 'hold_lock' was also made so that a request to aquire a WRITE lock did not replace an EX lock, which is already a form of write lock. --- daemons/clvmd/lvm-functions.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'daemons/clvmd/lvm-functions.c') diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 1fa23483..81e8b884 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -240,9 +240,17 @@ static int hold_lock(char *resource, int mode, int flags) lvi = lookup_info(resource); - if (lvi && lvi->lock_mode == mode) { - DEBUGLOG("hold_lock, lock mode %d already held\n", mode); - return 0; + if (lvi) { + if (lvi->lock_mode == mode) { + DEBUGLOG("hold_lock, lock mode %d already held\n", + mode); + return 0; + } + if ((lvi->lock_mode == LCK_EXCL) && (mode == LCK_WRITE)) { + DEBUGLOG("hold_lock, lock already held LCK_EXCL, " + "ignoring LCK_WRITE request"); + return 0; + } } /* Only allow explicit conversions */ -- cgit