All of lore.kernel.org
 help / color / mirror / Atom feed
From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/format1/disk-rep.h lib/fo ...
Date: 19 Oct 2006 12:53:47 -0000	[thread overview]
Message-ID: <20061019125347.28026.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk at sourceware.org	2006-10-19 12:53:47

Modified files:
	.              : WHATS_NEW 
	lib/format1    : disk-rep.h format1.c import-export.c 
	lib/format_text: import_vsn1.c 

Log message:
	Set PV size to current device size if it is found to be zero.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.474&r2=1.475
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37

--- LVM2/WHATS_NEW	2006/10/18 18:01:51	1.474
+++ LVM2/WHATS_NEW	2006/10/19 12:53:46	1.475
@@ -1,5 +1,6 @@
 Version 2.02.13 -
 ===================================
+  Set PV size to current device size if it is found to be zero.
   Add segment parameter to target_present functions.
 
 Version 2.02.12 - 16th October 2006
--- LVM2/lib/format1/disk-rep.h	2006/08/17 19:15:27	1.48
+++ LVM2/lib/format1/disk-rep.h	2006/10/19 12:53:46	1.49
@@ -203,8 +203,8 @@
  * Functions to translate to between disk and in
  * core structures.
  */
-int import_pv(struct dm_pool *mem, struct device *dev,
-	      struct volume_group *vg,
+int import_pv(const struct format_type *fmt, struct dm_pool *mem,
+	      struct device *dev, struct volume_group *vg,
 	      struct physical_volume *pv, struct pv_disk *pvd,
 	      struct vg_disk *vgd);
 int export_pv(struct cmd_context *cmd, struct dm_pool *mem,
--- LVM2/lib/format1/format1.c	2006/08/17 19:15:27	1.98
+++ LVM2/lib/format1/format1.c	2006/10/19 12:53:46	1.99
@@ -312,7 +312,7 @@
 		goto out;
 	}
 
-	if (!import_pv(fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd)) {
+	if (!import_pv(fmt, fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd, &dl->vgd)) {
 		stack;
 		goto out;
 	}
--- LVM2/lib/format1/import-export.c	2006/08/21 12:54:52	1.83
+++ LVM2/lib/format1/import-export.c	2006/10/19 12:53:46	1.84
@@ -24,6 +24,7 @@
 #include "toolcontext.h"
 #include "segtype.h"
 #include "pv_alloc.h"
+#include "display.h"
 
 #include <time.h>
 
@@ -47,11 +48,13 @@
 	return dm_pool_strdup(mem, ptr);
 }
 
-int import_pv(struct dm_pool *mem, struct device *dev,
-	      struct volume_group *vg,
+int import_pv(const struct format_type *fmt, struct dm_pool *mem,
+	      struct device *dev, struct volume_group *vg,
 	      struct physical_volume *pv, struct pv_disk *pvd,
 	      struct vg_disk *vgd)
 {
+	uint64_t size;
+
 	memset(pv, 0, sizeof(*pv));
 	memcpy(&pv->id, pvd->pv_uuid, ID_LEN);
 
@@ -89,6 +92,25 @@
 	pv->pe_count = pvd->pe_total;
 	pv->pe_alloc_count = 0;
 
+	/* Fix up pv size if missing */
+	if (!pv->size) {
+		if (!dev_get_size(dev, &pv->size)) {
+			log_error("%s: Couldn't get size.", dev_name(pv->dev));
+			return 0;
+		}
+		log_verbose("Fixing up missing format1 size (%s) "
+			    "for PV %s", display_size(fmt->cmd, pv->size),
+			    dev_name(pv->dev));
+		if (vg) {
+			size = pv->pe_count * (uint64_t) vg->extent_size +
+			       pv->pe_start;
+			if (size > pv->size)
+				log_error("WARNING: Physical Volume %s is too "
+					  "large for underlying device",
+					  dev_name(pv->dev));
+		}
+	}
+
 	list_init(&pv->tags);
 	list_init(&pv->segments);
 
@@ -427,7 +449,7 @@
 			return 0;
 		}
 
-		if (!import_pv(mem, dl->dev, vg, pvl->pv, &dl->pvd, &dl->vgd)) {
+		if (!import_pv(fmt, mem, dl->dev, vg, pvl->pv, &dl->pvd, &dl->vgd)) {
 			stack;
 			return 0;
 		}
--- LVM2/lib/format_text/import_vsn1.c	2006/10/07 23:17:17	1.36
+++ LVM2/lib/format_text/import_vsn1.c	2006/10/19 12:53:47	1.37
@@ -116,6 +116,7 @@
 	struct physical_volume *pv;
 	struct pv_list *pvl;
 	struct config_node *cn;
+	uint64_t size;
 
 	if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl))) ||
 	    !(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv)))) {
@@ -213,6 +214,25 @@
 	pv->pe_alloc_count = 0;
 	pv->fmt = fid->fmt;
 
+        /* Fix up pv size if missing */
+        if (!pv->size && pv->dev) {
+                if (!dev_get_size(pv->dev, &pv->size)) {
+                        log_error("%s: Couldn't get size.", dev_name(pv->dev));
+                        return 0;
+                }
+                log_verbose("Fixing up missing format1 size (%s) "
+                            "for PV %s", display_size(fid->fmt->cmd, pv->size),
+                            dev_name(pv->dev));
+                if (vg) {
+                        size = pv->pe_count * (uint64_t) vg->extent_size +
+                               pv->pe_start;
+                        if (size > pv->size)
+                                log_error("WARNING: Physical Volume %s is too "
+                                          "large for underlying device",
+                                          dev_name(pv->dev));
+                }
+        }
+
 	if (!alloc_pv_segment_whole_pv(mem, pv)) {
 		stack;
 		return 0;



                 reply	other threads:[~2006-10-19 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20061019125347.28026.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.