summaryrefslogtreecommitdiff
path: root/tools/pvresize.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2011-02-28 13:19:02 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2011-02-28 13:19:02 +0000
commit3b97e8d643d06f3f3391bc3625d49726fc0f5ad8 (patch)
tree9c7250ba454f87ea13b0885b4f667371be24279d /tools/pvresize.c
parent1a52fa6858ed6cc849914bf0c23259bd8821289c (diff)
downloadlvm2-3b97e8d643d06f3f3391bc3625d49726fc0f5ad8.tar.gz
Allow non-orphan PVs with two metadata areas to be resized.
We allow writing non-orphan PVs only for resize now. The "orphan PV" assert in pv_write fn uses the "allow_non_orphan" parameter to control this assert. However, we should find a more elaborate solution so we can remove this restriction altogether (pv_write together with vg_write is not atomic, we need to find a safe mechanism so there's an easy revert possible in case of an error).
Diffstat (limited to 'tools/pvresize.c')
-rw-r--r--tools/pvresize.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 636c0adaa..43c0b2ec6 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -15,6 +15,7 @@
*/
#include "tools.h"
+#include "metadata.h"
struct pvresize_params {
uint64_t new_size;
@@ -96,6 +97,16 @@ static int _pv_resize_single(struct cmd_context *cmd,
goto_out;
log_verbose("Updating physical volume \"%s\"", pv_name);
+
+ /* Write PV label only if this an orphan PV or it has 2nd mda. */
+ if ((is_orphan_vg(vg_name) ||
+ fid_get_mda_indexed(vg->fid, (const char *) &pv->id, ID_LEN, 1)) &&
+ !pv_write(cmd, pv, 1)) {
+ log_error("Failed to store physical volume \"%s\"",
+ pv_name);
+ goto out;
+ }
+
if (!is_orphan_vg(vg_name)) {
if (!vg_write(vg) || !vg_commit(vg)) {
log_error("Failed to store physical volume \"%s\" in "
@@ -103,10 +114,6 @@ static int _pv_resize_single(struct cmd_context *cmd,
goto out;
}
backup(vg);
- } else if (!(pv_write(cmd, pv))) {
- log_error("Failed to store physical volume \"%s\"",
- pv_name);
- goto out;
}
log_print("Physical volume \"%s\" changed", pv_name);