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/pvresize.c
Date: Fri, 12 Sep 2008 15:26:00 -0000	[thread overview]
Message-ID: <20080912152646.21990.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2008-09-12 15:26:45

Modified files:
	.              : WHATS_NEW 
	tools          : pvresize.c 

Log message:
	Fix pvresize to not allow resize if PV has two metadata areas.
	
	If the PV has two metadata areas, second one is located at the end of the device.
	
	Do not allow resize of PV or second metadata area can be overwritten.
	(The check was active only for orphan PVs.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.950&r2=1.951
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22

--- LVM2/WHATS_NEW	2008/08/29 13:41:21	1.950
+++ LVM2/WHATS_NEW	2008/09/12 15:26:44	1.951
@@ -1,5 +1,6 @@
 Version 2.02.40 - 
 ================================
+  Fix pvresize to not allow resize if PV has two metadata areas.
   Fix setting of volume limit count if converting to lvm1 format.
   Fix vgconvert logical volume id metadata validation.
   Fix lvmdump metadata gather option (-m) to work correctly.
--- LVM2/tools/pvresize.c	2008/01/30 14:00:02	1.21
+++ LVM2/tools/pvresize.c	2008/09/12 15:26:45	1.22
@@ -35,6 +35,8 @@
 	struct list mdas;
 	const char *pv_name = pv_dev_name(pv);
 	const char *vg_name;
+	struct lvmcache_info *info;
+	int mda_count = 0;
 
 	list_init(&mdas);
 
@@ -51,13 +53,7 @@
 			return 0;
 		}
 
-		/* FIXME Create function to test compatibility properly */
-		if (list_size(&mdas) > 1) {
-			log_error("%s: too many metadata areas for pvresize",
-				  pv_name);
-			unlock_vg(cmd, vg_name);
-			return 0;
-		}
+		mda_count = list_size(&mdas);
 	} else {
 		vg_name = pv_vg_name(pv);
 
@@ -87,10 +83,26 @@
 
 		pv = pvl->pv;
 
+		if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
+			unlock_vg(cmd, vg_name);
+			log_error("Can't get info for PV %s in volume group %s",
+				  pv_name, vg->name);
+			return 0;
+		}
+
+		mda_count = list_size(&info->mdas);
+
 		if (!archive(vg))
 			return 0;
 	}
 
+	/* FIXME Create function to test compatibility properly */
+	if (mda_count > 1) {
+		log_error("%s: too many metadata areas for pvresize", pv_name);
+		unlock_vg(cmd, vg_name);
+		return 0;
+	}
+
 	if (!(pv->fmt->features & FMT_RESIZE_PV)) {
 		log_error("Physical volume %s format does not support resizing.",
 			  pv_name);


             reply	other threads:[~2008-09-12 15:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 15:26 mbroz [this message]
2010-10-25 12:01 zkabelac

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=20080912152646.21990.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).