All of lore.kernel.org
 help / color / mirror / Atom feed
From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/lib/metadata mirror.c
Date: 16 Jan 2008 19:11:39 -0000	[thread overview]
Message-ID: <20080116191139.13718.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2008-01-16 19:11:39

Modified files:
	lib/metadata   : mirror.c 

Log message:
	move removable_pvs checking

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55

--- LVM2/lib/metadata/mirror.c	2008/01/16 19:09:35	1.54
+++ LVM2/lib/metadata/mirror.c	2008/01/16 19:11:39	1.55
@@ -335,6 +335,39 @@
 	remove_seg_from_segs_using_this_lv(log_lv, mirrored_seg);
 }
 
+/* Check if mirror image LV is removable with regard to given removable_pvs */
+static int _is_mirror_image_removable(struct logical_volume *mimage_lv,
+				      struct list *removable_pvs)
+{
+	struct physical_volume *pv;
+	struct lv_segment *seg;
+	int pv_found;
+	struct pv_list *pvl;
+	uint32_t s;
+
+	list_iterate_items(seg, &mimage_lv->segments) {
+		for (s = 0; s < seg->area_count; s++) {
+			if (seg_type(seg, s) != AREA_PV)
+				/* FIXME Recurse for AREA_LV */
+				continue;
+
+			pv = seg_pv(seg, s);
+
+			pv_found = 0;
+			list_iterate_items(pvl, removable_pvs) {
+				if (pv->dev->dev == pvl->pv->dev->dev) {
+					pv_found = 1;
+					break;
+				}
+			}
+			if (!pv_found)
+				return 0;
+		}
+	}
+
+	return 1;
+}
+
 /*
  * Remove num_removed images from mirrored_seg
  */
@@ -344,15 +377,12 @@
 				 unsigned remove_log, unsigned collapse)
 {
 	uint32_t m;
-	uint32_t s, s1;
+	uint32_t s;
 	struct logical_volume *sub_lv;
 	struct logical_volume *log_lv = NULL;
 	struct logical_volume *lv1 = NULL;
-	struct physical_volume *pv;
-	struct lv_segment *seg, *mirrored_seg = first_seg(lv);
+	struct lv_segment *mirrored_seg = first_seg(lv);
 	struct lv_segment_area area;
-	int all_pvs_removable, pv_found;
-	struct pv_list *pvl;
 	uint32_t old_area_count = mirrored_seg->area_count;
 	uint32_t new_area_count = mirrored_seg->area_count;
 	struct lv_list *lvl;
@@ -373,32 +403,8 @@
 	if (removable_pvs) {
 		for (s = 0; s < mirrored_seg->area_count &&
 			    old_area_count - new_area_count < num_removed; s++) {
-			all_pvs_removable = 1;
 			sub_lv = seg_lv(mirrored_seg, s);
-			list_iterate_items(seg, &sub_lv->segments) {
-				for (s1 = 0; s1 < seg->area_count; s1++) {
-					if (seg_type(seg, s1) != AREA_PV)
-						/* FIXME Recurse for AREA_LV */
-						continue;
-
-					pv = seg_pv(seg, s1);
-
-					pv_found = 0;
-					list_iterate_items(pvl, removable_pvs) {
-						if (pv->dev->dev == pvl->pv->dev->dev) {
-							pv_found = 1;
-							break;
-						}
-					}
-					if (!pv_found) {
-						all_pvs_removable = 0;
-						break;
-					}
-				}
-				if (!all_pvs_removable)
-					break;
-			}
-			if (all_pvs_removable) {
+			if (_is_mirror_image_removable(sub_lv, removable_pvs)) {
 				/* Swap segment to end */
 				new_area_count--;
 				area = mirrored_seg->areas[new_area_count];



             reply	other threads:[~2008-01-16 19:11 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-16 19:11 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-01 15:05 LVM2/lib/metadata mirror.c agk
2011-09-19 14:28 jbrassow
2011-09-16 16:41 jbrassow
2011-09-14  9:54 zkabelac
2011-09-14  4:10 jbrassow
2011-09-13 18:11 jbrassow
2011-06-24 23:39 agk
2011-04-12 14:13 zkabelac
2011-03-24 12:28 mornfall
2011-01-11 17:21 jbrassow
2010-07-09 17:57 jbrassow
2010-06-23 13:57 jbrassow
2010-04-20 12:14 agk
2010-04-01 14:54 agk
2010-01-08 10:50 zkabelac
2009-12-17 15:59 mornfall
2009-12-09 19:43 mbroz
2009-11-19 13:42 mornfall
2009-11-19 12:09 mornfall
2009-11-18 18:23 mornfall
2009-10-14 14:55 jbrassow
2009-04-23 16:43 mornfall
2009-04-24  0:38 ` Alasdair G Kergon
2009-05-03 16:37   ` Petr Rockai
2008-09-19  4:30 agk
2008-09-19  0:20 agk
2008-01-17 13:37 agk
2008-01-16 19:50 agk
2008-01-16 19:38 agk
2008-01-16 19:09 agk
2006-11-10 20:15 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=20080116191139.13718.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.