All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] lvm2app: Implementation of pv resize (v6)
@ 2013-03-14 18:14 Tony Asleson
  2013-03-14 18:14 ` [PATCH 2/5] lvm2app: Move percent_of_extents to lvm-percent.[h|c] Tony Asleson
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Tony Asleson @ 2013-03-14 18:14 UTC (permalink / raw)
  To: lvm-devel

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 liblvm/lvm2app.h |  2 --
 liblvm/lvm_pv.c  | 20 +++++++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 93a78c3..935c53b 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -1626,8 +1626,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.
  *
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 90edaed..bf9f630 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -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;
+	}
 }
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [PATCH 1/5] lvm2app: Implementation of pv resize (v6)
@ 2013-03-13 22:13 Tony Asleson
  2013-03-13 22:13 ` [PATCH 4/5] lvm2app: Move core lv re-size code (v2) Tony Asleson
  0 siblings, 1 reply; 14+ messages in thread
From: Tony Asleson @ 2013-03-13 22:13 UTC (permalink / raw)
  To: lvm-devel

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 liblvm/lvm2app.h |  2 --
 liblvm/lvm_pv.c  | 20 +++++++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index 93a78c3..935c53b 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -1626,8 +1626,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.
  *
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 90edaed..bf9f630 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -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;
+	}
 }
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-03-15 16:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14 18:14 [PATCH 1/5] lvm2app: Implementation of pv resize (v6) Tony Asleson
2013-03-14 18:14 ` [PATCH 2/5] lvm2app: Move percent_of_extents to lvm-percent.[h|c] Tony Asleson
2013-03-14 18:14 ` [PATCH 3/5] lvm2app: Rework argument handling for lv resize Tony Asleson
2013-03-14 18:14 ` [PATCH 4/5] lvm2app: Move core lv re-size code (v2) Tony Asleson
2013-03-15  8:17   ` Zdenek Kabelac
2013-03-15 16:30     ` Tony Asleson
2013-03-14 18:14 ` [PATCH 5/5] lvm2app: Implement lv resize (v2) Tony Asleson
  -- strict thread matches above, loose matches on Subject: below --
2013-03-13 22:13 [PATCH 1/5] lvm2app: Implementation of pv resize (v6) Tony Asleson
2013-03-13 22:13 ` [PATCH 4/5] lvm2app: Move core lv re-size code (v2) Tony Asleson
2013-03-14 14:12   ` Zdenek Kabelac
2013-03-14 15:12     ` Tony Asleson
2013-03-14 15:14       ` Zdenek Kabelac
2013-03-14 15:29         ` Tony Asleson
2013-03-14 15:39           ` Zdenek Kabelac
2013-03-14 14:17   ` Zdenek Kabelac

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.