Skip to contentSkip to conversation

master - lvm2app: Implementation of pv resize (v6)

PATCH tasleson 1 participant 1 message Jul 2, 2013

lore
Share & tools
lore

tasleson

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d52b6be455126e7b6a46c39127ca343982955b19
Commit:        d52b6be455126e7b6a46c39127ca343982955b19
Parent:        4d5de8322b3a6050def60542b167b46d97b2824d
Author:        Tony Asleson <[email protected]>
AuthorDate:    Wed Mar 13 14:39:56 2013 -0500
Committer:     Tony Asleson <[email protected]>
CommitterDate: Tue Jul 2 14:24:33 2013 -0500

lvm2app: Implementation of pv resize (v6)

---
 liblvm/lvm2app.h |    2 --
 liblvm/lvm_pv.c  |   20 +++++++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)
liblvm/lvm2app.h +0 -2
index b1d6abd..633b026 100644
@@ -1759,8 +1759,6 @@ pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid);
  *
  * \memberof pv_t
  *
- * NOTE: This function is currently not implemented.
- *
  * \param   pv
  * Physical volume handle.
  *
liblvm/lvm_pv.c +17 -3
index 3924af4..18b1069 100644
@@ -123,7 +123,21 @@ pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid)
 
 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 (!vg_check_write_mode(pv->vg)) {
+		return -1;
+	}
+
+	if (!pv_resize(pv, pv->vg, size)) {
+		log_error("PV re-size failed!");
+		return -1;
+	} else {
+		return 0;
+	}
 }