Skip to contentSkip to conversation

lvm2app: Possible implementation of missing pv resize (v2).

PATCH New Tony Asleson 1 participant 1 message Oct 16, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lvm2app: Possible implementation of missing pv resize (v2).

This patch implements pv resize and it appears to work in my simple testing. I would appreciate others who know the code better to review and make suggestions.

Thanks,
-Tony

---
 lib/metadata/metadata-exported.h |   8 ++-
 lib/metadata/pv_manip.c          | 118 ++++++++++++++++++++++++++++++++++++++-
 liblvm/lvm_pv.c                  |  17 ++++--
 tools/pvresize.c                 | 113 +------------------------------------
 4 files changed, 138 insertions(+), 118 deletions(-)
lib/metadata/metadata-exported.h +6 -2
index d149f95..cf38d9e 100644
@@ -482,8 +482,12 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
 				  unsigned pvmetadatacopies,
 				  uint64_t pvmetadatasize,
 				  unsigned metadataignore);
-int pv_resize(struct physical_volume *pv, struct volume_group *vg,
-	      uint64_t size);
+
+int pv_resize(struct cmd_context *cmd,
+				struct volume_group *vg,
+				struct physical_volume *pv,
+				const uint64_t new_size);
+
 int pv_analyze(struct cmd_context *cmd, const char *pv_name,
 	       uint64_t label_sector);
 
lib/metadata/pv_manip.c +117 -1

133 lines not on this page · raw message

liblvm/lvm_pv.c +13 -4
index 90edaed..446051a 100644
@@ -120,10 +120,19 @@ pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid)
 	return NULL;
 }
 
-
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
-	/* FIXME: add pv resize code here */
-	log_error("NOT IMPLEMENTED YET");
-	return -1;
+	uint64_t size = new_size >> SECTOR_SHIFT;
+
+	if (new_size % SECTOR_SIZE) {
+		log_errno(EINVAL, "Size not a multiple of 512");
+		return -1;
+	}
+
+	if (!pv_resize(pv->vg->cmd, pv->vg, pv, size)) {
+		log_error("PV re-size failed!");
+		return -1;
+	} else {
+		return 0;
+	}
 }
tools/pvresize.c +2 -111

128 lines not on this page · raw message

Signature · 1 line
1.7.11.7