public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: agk@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/report/report.c
Date: Sat, 10 Jan 2009 17:09:00 -0000	[thread overview]
Message-ID: <20090110170941.1780.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-01-10 17:09:40

Modified files:
	.              : WHATS_NEW 
	lib/report     : report.c 

Log message:
	More fields can cause segfaults with orphans.
	Fix these by populating the dummy VG struct more completely.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1019&r2=1.1020
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94

--- LVM2/WHATS_NEW	2009/01/10 15:04:28	1.1019
+++ LVM2/WHATS_NEW	2009/01/10 17:09:40	1.1020
@@ -1,6 +1,6 @@
 Version 2.02.44 - 
 ====================================
-  Fix pvs segfault when run with orphan PV and vg_mda_size or vg_mda_free.
+  Fix pvs segfault when run with orphan PV and some VG fields.
   Display a 'dev_size' of zero for missing devices in reports.
   Add pv_mda_size to pvs and vg_mda_size to vgs.
   Fix lvmdump /sys listing to include virtual devices directory.
--- LVM2/lib/report/report.c	2009/01/10 15:04:29	1.93
+++ LVM2/lib/report/report.c	2009/01/10 17:09:40	1.94
@@ -926,13 +926,7 @@
 	const struct volume_group *vg = (const struct volume_group *) data;
 	uint64_t min_mda_size;
 
-	/*
-	 * An orphan PV will have vg->fid == NULL
-	 */
-	if (vg->fid == NULL)
-		min_mda_size = UINT64_C(0);
-	else
-		min_mda_size = _find_min_mda_size(&vg->fid->metadata_areas);
+	min_mda_size = _find_min_mda_size(&vg->fid->metadata_areas);
 
 	return _size64_disp(rh, mem, field, &min_mda_size, private);
 }
@@ -945,12 +939,6 @@
 	uint64_t freespace = UINT64_MAX, mda_free;
 	struct metadata_area *mda;
 
-	/*
-	 * An orphan PV will have vg->fid == NULL
-	 */
-	if (vg->fid == NULL)
-		goto calc_done;
-
 	dm_list_iterate_items(mda, &vg->fid->metadata_areas) {
 		if (!mda->ops->mda_free_sectors)
 			continue;
@@ -958,7 +946,7 @@
 		if (mda_free < freespace)
 			freespace = mda_free;
 	}
-calc_done:
+
 	if (freespace == UINT64_MAX)
 		freespace = UINT64_C(0);
 
@@ -1081,8 +1069,17 @@
 /* Report object types */
 
 /* necessary for displaying something for PVs not belonging to VG */
+static struct format_instance _dummy_fid = {
+	.metadata_areas = { &(_dummy_fid.metadata_areas), &(_dummy_fid.metadata_areas) },
+};
+
 static struct volume_group _dummy_vg = {
+	.fid = &_dummy_fid,
 	.name = (char *) "",
+	.system_id = (char *) "",
+	.pvs = { &(_dummy_vg.pvs), &(_dummy_vg.pvs) },
+	.lvs = { &(_dummy_vg.lvs), &(_dummy_vg.lvs) },
+	.tags = { &(_dummy_vg.tags), &(_dummy_vg.tags) },
 };
 
 static void *_obj_get_vg(void *obj)
@@ -1182,6 +1179,10 @@
 {
 	struct lvm_report_object obj;
 
+	/* The two format fields might as well match. */
+	if (!vg && pv)
+		_dummy_fid.fmt = pv->fmt;
+
 	obj.vg = vg;
 	obj.lv = lv;
 	obj.pv = pv;


             reply	other threads:[~2009-01-10 17:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-10 17:09 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-05-20 22:24 agk
2010-01-07 14:37 zkabelac
2009-02-06 12:41 mbroz
2009-01-10 15:04 wysochanski
2008-12-15 13:30 wysochanski
2007-01-22 15:07 agk
2007-01-18 17:48 agk
2006-10-02 16:46 agk
2004-05-05 18: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=20090110170941.1780.qmail@sourceware.org \
    --to=agk@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).