public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: mbroz@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW tools/pvmove.c
Date: Mon, 26 Mar 2012 20:32:00 -0000	[thread overview]
Message-ID: <20120326203258.15672.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2012-03-26 20:32:58

Modified files:
	.              : WHATS_NEW 
	tools          : pvmove.c 

Log message:
	Do not allow pvmove if some affected LVs are activated
	locally or on more nodes while others are activated exclusively.
	
	Current pvmove code can either use local mirror (for exclusive
	activation) or cmirror (for clustered LVs).
	
	Because the whole intenal pvmove LV is just segmented LV containing
	segments of several top-level LVs, code cannot properly handle
	situation if some segment need to be activated exclusively.
	
	Previously, it wrongly activated exclusive LV on all nodes
	(locing code allowed it) but now this is no lnger possible.
	
	If there is exclusively activated LV, pvmove is only
	possible if all affected LVs are aslo activated exclusively.
	
	(Note that in non-exclusive mode pvmove still activates LVs
	on other nodes during move.)
	
	# lvchange -aly vg_test/lv1
	# lvchange -aey vg_test/lv2
	# pvmove -i 1 /dev/sdc
	Error locking on node bar-01: Device or resource busy
	Error locking on node bar-03: Volume is busy on another node
	...
	Failed to activate lv2

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2368&r2=1.2369
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96

--- LVM2/WHATS_NEW	2012/03/26 20:29:45	1.2368
+++ LVM2/WHATS_NEW	2012/03/26 20:32:58	1.2369
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Disallow pvmove for exclusive LV if some affected LVs are not exclusively activated.
   Remove unused and wrongly set cluster VG flag from clvmd lock query command.
   Fix pvmove for exclusively activated LV pvmove in clustered VG. (2.02.86)
   Always free hash table on update_pvid_to_vgid() in lvmetad.
--- LVM2/tools/pvmove.c	2012/03/26 20:31:01	1.95
+++ LVM2/tools/pvmove.c	2012/03/26 20:32:58	1.96
@@ -175,13 +175,16 @@
 						const char *lv_name,
 						struct dm_list *allocatable_pvs,
 						alloc_policy_t alloc,
-						struct dm_list **lvs_changed)
+						struct dm_list **lvs_changed,
+						unsigned *exclusive)
 {
 	struct logical_volume *lv_mirr, *lv;
 	struct lv_list *lvl;
 	uint32_t log_count = 0;
 	int lv_found = 0;
 	int lv_skipped = 0;
+	int lv_active_count = 0;
+	int lv_exclusive_count = 0;
 
 	/* FIXME Cope with non-contiguous => splitting existing segments */
 	if (!(lv_mirr = lv_create_empty("pvmove%d", NULL,
@@ -235,6 +238,14 @@
 			log_print("Skipping locked LV %s", lv->name);
 			continue;
 		}
+
+		if (vg_is_clustered(vg)) {
+			if (lv_is_active_exclusive_locally(lv))
+				lv_exclusive_count++;
+			else if (lv_is_active(lv))
+				lv_active_count++;
+		}
+
 		if (!_insert_pvmove_mirrors(cmd, lv_mirr, source_pvl, lv,
 					    *lvs_changed))
 			return_NULL;
@@ -255,6 +266,17 @@
 		return NULL;
 	}
 
+	if (lv_exclusive_count) {
+		if (lv_active_count) {
+			log_error("Cannot move in clustered VG %s "
+				  "if some LVs are activated "
+				  "exclusively while others don't.",
+				  vg->name);
+			return NULL;
+		}
+		*exclusive = 1;
+	}
+
 	if (!lv_add_mirrors(cmd, lv_mirr, 1, 1, 0, 0, log_count,
 			    allocatable_pvs, alloc, MIRROR_BY_SEG)) {
 		log_error("Failed to convert pvmove LV to mirrored");
@@ -510,7 +532,7 @@
 
 		if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, source_pvl, lv_name,
 						  allocatable_pvs, alloc,
-						  &lvs_changed)))
+						  &lvs_changed, &exclusive)))
 			goto_out;
 	}
 


             reply	other threads:[~2012-03-26 20:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 20:32 mbroz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-13 20:21 agk
2011-09-27 17:29 agk
2010-01-27 13:29 mbroz
2010-01-26  8:01 mbroz
2009-12-03 19:22 mbroz
2004-09-14 15:23 agk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120326203258.15672.qmail@sourceware.org \
    --to=mbroz@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).