From fbc34d70b000a94abf18ee9e72b7829c45cc7e5a Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Fri, 12 Sep 2008 15:26:45 +0000 Subject: [PATCH] Fix pvresize to not allow resize if PV has two metadata areas. If the PV has two metadata areas, second one is located at the end of the device. Do not allow resize of PV or second metadata area can be overwritten. (The check was active only for orphan PVs.) --- WHATS_NEW | 1 + tools/pvresize.c | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 52c381978..d6e541591 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Fix pvresize to not allow resize if PV has two metadata areas. Fix setting of volume limit count if converting to lvm1 format. Fix vgconvert logical volume id metadata validation. Fix lvmdump metadata gather option (-m) to work correctly. diff --git a/tools/pvresize.c b/tools/pvresize.c index 5508fda30..4f38ca3d3 100644 --- a/tools/pvresize.c +++ b/tools/pvresize.c @@ -35,6 +35,8 @@ static int _pv_resize_single(struct cmd_context *cmd, struct list mdas; const char *pv_name = pv_dev_name(pv); const char *vg_name; + struct lvmcache_info *info; + int mda_count = 0; list_init(&mdas); @@ -51,13 +53,7 @@ static int _pv_resize_single(struct cmd_context *cmd, return 0; } - /* FIXME Create function to test compatibility properly */ - if (list_size(&mdas) > 1) { - log_error("%s: too many metadata areas for pvresize", - pv_name); - unlock_vg(cmd, vg_name); - return 0; - } + mda_count = list_size(&mdas); } else { vg_name = pv_vg_name(pv); @@ -87,10 +83,26 @@ static int _pv_resize_single(struct cmd_context *cmd, pv = pvl->pv; + if (!(info = info_from_pvid(pv->dev->pvid, 0))) { + unlock_vg(cmd, vg_name); + log_error("Can't get info for PV %s in volume group %s", + pv_name, vg->name); + return 0; + } + + mda_count = list_size(&info->mdas); + if (!archive(vg)) return 0; } + /* FIXME Create function to test compatibility properly */ + if (mda_count > 1) { + log_error("%s: too many metadata areas for pvresize", pv_name); + unlock_vg(cmd, vg_name); + return 0; + } + if (!(pv->fmt->features & FMT_RESIZE_PV)) { log_error("Physical volume %s format does not support resizing.", pv_name); -- 2.43.5