lvm2app: Possible implementation of missing pv resize.
PATCH 1/1 lvm2app: Possible implementation of missing pv resize.
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
Signed-off-by Tony Asleson <[email protected]>
--- lib/metadata/metadata-exported.h | 10 ++- lib/metadata/pv_manip.c | 120 +++++++++++++++++++++++++++++++++++++- liblvm/lvm_pv.c | 19 +++++- tools/pvresize.c | 113 +----------------------------------- 4 files changed, 142 insertions(+), 120 deletions(-)
lib/metadata/metadata-exported.h +7 -3
@@ -462,7 +462,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,struct volume_group *vg_read_for_update (struct cmd_context *cmd,const char *vg_name,const char *vgid,uint32_t flags); -/* +/* * Test validity of a VG handle. */ uint32_t vg_read_error (struct volume_group *vg_handle);
@@ -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 +118 -2
141 lines not on this page · raw message
liblvm/lvm_pv.c +15 -4
@@ -120,10 +120,21 @@ 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 ; +/*Input is in bytes, we need to convert to blocks, is there a constant for +* this? */ +uint64_t size = new_size /512 ; + +if ( new_size %512 ) { +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.1