public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: jbrassow@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/metadata/raid_manip.c
Date: Thu, 01 Dec 2011 00:21:00 -0000	[thread overview]
Message-ID: <20111201002105.27148.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-12-01 00:21:04

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : raid_manip.c 

Log message:
	Don't allow two images to be split and tracked from a RAID LV at one time
	
	Also, don't allow a splitmirror operation on a RAID LV that is already tracking
	a split, unless the operation is to stop the tracking and complete the split.
	Example:
	~> lvconvert --splitmirrors 1 --trackchanges vg/lv /dev/sdc1
	# Now tracking changes - image can be merged back or split-off for good
	~> lvconvert --splitmirrors 1 -n new_name vg/lv /dev/sdc1
	# ^ Completes split ^
	
	If a split is performed on a RAID that is tracking an already split image and
	PVs are provided, we must ensure that
	1) the already split LV is represented in the PVs
	2) we are careful to split only the tracked image

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2202&r2=1.2203
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/raid_manip.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20

--- LVM2/WHATS_NEW	2011/12/01 00:13:16	1.2202
+++ LVM2/WHATS_NEW	2011/12/01 00:21:04	1.2203
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Don't allow two images to be split and tracked from a RAID LV at one time
   Don't allow size change of RAID LV that is tracking changes for a split image
   Don't allow size change of RAID sub-LVs independently
   Don't allow name change of RAID LV that is tracking changes for a split image
--- LVM2/lib/metadata/raid_manip.c	2011/12/01 00:09:35	1.19
+++ LVM2/lib/metadata/raid_manip.c	2011/12/01 00:21:04	1.20
@@ -26,20 +26,32 @@
 
 #define RAID_REGION_SIZE 1024
 
-int lv_is_raid_with_tracking(const struct logical_volume *lv)
+static int _lv_is_raid_with_tracking(const struct logical_volume *lv,
+				     struct logical_volume **tracking)
 {
 	uint32_t s;
 	struct lv_segment *seg;
 
-	if (lv->status & RAID) {
-		seg = first_seg(lv);
+	*tracking = NULL;
+	seg = first_seg(lv);
 
-		for (s = 0; s < seg->area_count; s++)
-			if (lv_is_visible(seg_lv(seg, s)) &&
-			    !(seg_lv(seg, s)->status & LVM_WRITE))
-				return 1;
-	}
-	return 0;
+	if (!(lv->status & RAID))
+		return 0;
+
+	for (s = 0; s < seg->area_count; s++)
+		if (lv_is_visible(seg_lv(seg, s)) &&
+		    !(seg_lv(seg, s)->status & LVM_WRITE))
+			*tracking = seg_lv(seg, s);
+
+
+	return *tracking ? 1 : 0;
+}
+
+int lv_is_raid_with_tracking(const struct logical_volume *lv)
+{
+	struct logical_volume *tracking;
+
+	return _lv_is_raid_with_tracking(lv, &tracking);
 }
 
 uint32_t lv_raid_image_count(const struct logical_volume *lv)
@@ -1051,6 +1063,8 @@
 	struct dm_list removal_list, data_list;
 	struct cmd_context *cmd = lv->vg->cmd;
 	uint32_t old_count = lv_raid_image_count(lv);
+	struct logical_volume *tracking;
+	struct dm_list tracking_pvs;
 
 	dm_list_init(&removal_list);
 	dm_list_init(&data_list);
@@ -1079,6 +1093,25 @@
 		return 0;
 	}
 
+	/*
+	 * We only allow a split while there is tracking if it is to
+	 * complete the split of the tracking sub-LV
+	 */
+	if (_lv_is_raid_with_tracking(lv, &tracking)) {
+		if (!_lv_is_on_pvs(tracking, splittable_pvs)) {
+			log_error("Unable to split additional image from %s "
+				  "while tracking changes for %s",
+				  lv->name, tracking->name);
+			return 0;
+		} else {
+			/* Ensure we only split the tracking image */
+			dm_list_init(&tracking_pvs);
+			splittable_pvs = &tracking_pvs;
+			if (!_get_pv_list_for_lv(tracking, splittable_pvs))
+				return_0;
+		}
+	}
+
 	if (!_raid_extract_images(lv, new_count, splittable_pvs, 1,
 				 &removal_list, &data_list)) {
 		log_error("Failed to extract images from %s/%s",
@@ -1181,6 +1214,12 @@
 		return 0;
 	}
 
+	/* Cannot track two split images at once */
+	if (lv_is_raid_with_tracking(lv)) {
+		log_error("Cannot track more than one split image at a time");
+		return 0;
+	}
+
 	for (s = seg->area_count - 1; s >= 0; s--) {
 		if (!_lv_is_on_pvs(seg_lv(seg, s), splittable_pvs))
 			continue;


             reply	other threads:[~2011-12-01  0:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01  0:21 jbrassow [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-04-24 20:05 jbrassow
2012-04-12  3:16 jbrassow
2012-04-11 14:20 jbrassow
2012-04-11  1:23 jbrassow
2012-02-13 11:10 zkabelac
2011-09-13 16:33 jbrassow
2011-08-18 19:31 jbrassow

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=20111201002105.27148.qmail@sourceware.org \
    --to=jbrassow@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).