Skip to contentSkip to conversation

master - locking: Introduce LCK_ACTIVATION.

PATCH Alasdair Kergon 1 participant 1 message Jun 20, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=78533f72d30f6e840f66e0aae89126ef139c1f2c
Commit:        78533f72d30f6e840f66e0aae89126ef139c1f2c
Parent:        f29ae59a4d88ff0f76cfd84a6061222ae178438b
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Fri Jun 20 13:24:02 2014 +0100
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Fri Jun 20 13:24:02 2014 +0100

locking: Introduce LCK_ACTIVATION.

Take a local file lock to prevent concurrent activation/deactivation of LVs. Thin/cache types and an extension for cluster support are excluded for now.

'lvchange -ay $lv' and 'lvchange -an $lv' should no longer cause trouble if issued concurrently: the new lock should make sure they activate/deactivate $lv one-after-the-other, instead of overlapping.

(If anyone wants to experiment with the cluster patch, please get in touch.)

---
 WHATS_NEW                  |    1 +
 lib/locking/file_locking.c |   10 +++++++
 lib/locking/locking.c      |    2 +
 lib/locking/locking.h      |   65 ++++++++++++++++++++++++++++++++++++-------
 lib/locking/no_locking.c   |    2 +
 5 files changed, 69 insertions(+), 11 deletions(-)
WHATS_NEW +1 -0
index 44cef74..c2b443c 100644
@@ -1,5 +1,6 @@
 Version 2.02.107 - 
 ==================================
+  Introduce LCK_ACTIVATION to avoid concurrent activation of basic LV types.
   Fix open_count test for lvchange --refresh or mirrors and raids.
   Update pvs,vgs,lvs and lvm man page for selection support.
   Add -S/--select to lvm devtypes for report selection.
lib/locking/file_locking.c +10 -0
index d332101..e6def3f 100644
@@ -49,6 +49,16 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
 	unsigned revert = (flags & LCK_REVERT) ? 1 : 0;
 
 	switch (flags & LCK_SCOPE_MASK) {
+	case LCK_ACTIVATION:
+		if (dm_snprintf(lockfile, sizeof(lockfile),
+				"%s/A_%s", _lock_dir, resource + 1) < 0) {
+			log_error("Too long locking filename %s/A_%s.", _lock_dir, resource + 1);
+			return 0;
+		}
+
+		if (!lock_file(lockfile, flags))
+			return_0;
+		break;
 	case LCK_VG:
 		/* Skip cache refresh for VG_GLOBAL - the caller handles it */
 		if (strcmp(resource, VG_GLOBAL))
lib/locking/locking.c +2 -0
index 673713a..9432f84 100644
@@ -318,6 +318,8 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, struct lo
 	}
 
 	switch (flags & LCK_SCOPE_MASK) {
+	case LCK_ACTIVATION:
+		break;
 	case LCK_VG:
 		if (!_blocking_supported)
 			flags |= LCK_NONBLOCK;
lib/locking/locking.h +54 -11

100 lines not on this page · raw message

lib/locking/no_locking.c +2 -0
index f7718be..ab95933 100644
@@ -37,6 +37,8 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
 			     uint32_t flags, struct logical_volume *lv)
 {
 	switch (flags & LCK_SCOPE_MASK) {
+	case LCK_ACTIVATION:
+		break;
 	case LCK_VG:
 		if (!strcmp(resource, VG_SYNC_NAMES))
 			fs_unlock();