public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools pvresize.c
@ 2007-08-30 20:16 wysochanski
0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2007-08-30 20:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-08-30 20:16:02
Modified files:
tools : pvresize.c
Log message:
prepare to move guts of pvresize into library
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
--- LVM2/tools/pvresize.c 2007/08/20 20:55:30 1.13
+++ LVM2/tools/pvresize.c 2007/08/30 20:16:01 1.14
@@ -23,10 +23,10 @@
unsigned total;
};
-static int _pvresize_single(struct cmd_context *cmd,
+static int pv_resize_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ uint64_t new_size)
{
struct pv_list *pvl;
int consistent = 1;
@@ -34,25 +34,22 @@
uint32_t new_pe_count = 0;
struct list mdas;
const char *pv_name = dev_name(pv_dev(pv));
- struct pvresize_params *params = (struct pvresize_params *) handle;
const char *vg_name;
list_init(&mdas);
- params->total++;
-
if (!*pv_vg_name(pv)) {
vg_name = ORPHAN;
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for orphans");
- return ECMD_FAILED;
+ return 0;
}
if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) {
unlock_vg(cmd, vg_name);
log_error("Unable to read PV \"%s\"", pv_name);
- return ECMD_FAILED;
+ return 0;
}
/* FIXME Create function to test compatibility properly */
@@ -60,76 +57,76 @@
log_error("%s: too many metadata areas for pvresize",
pv_name);
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
} else {
vg_name = pv_vg_name(pv);
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", pv_vg_name(pv));
- return ECMD_FAILED;
+ return 0;
}
if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
unlock_vg(cmd, vg_name);
log_error("Unable to find volume group of \"%s\"",
pv_name);
- return ECMD_FAILED;
+ return 0;
}
if (!vg_check_status(vg, CLUSTERED | EXPORTED_VG | LVM_WRITE)) {
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
unlock_vg(cmd, vg_name);
log_error("Unable to find \"%s\" in volume group \"%s\"",
pv_name, vg->name);
- return ECMD_FAILED;
+ return 0;
}
pv = pvl->pv;
if (!archive(vg))
- return ECMD_FAILED;
+ return 0;
}
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
pv_name);
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
/* Get new size */
if (!dev_get_size(pv_dev(pv), &size)) {
log_error("%s: Couldn't get size.", pv_name);
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
- if (params->new_size) {
- if (params->new_size > size)
+ if (new_size) {
+ if (new_size > size)
log_warn("WARNING: %s: Overriding real size. "
"You could lose data.", pv_name);
log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
- " sectors.", pv_name, params->new_size, pv_size(pv));
- size = params->new_size;
+ " sectors.", pv_name, new_size, pv_size(pv));
+ size = new_size;
}
if (size < PV_MIN_SIZE) {
log_error("%s: Size must exceed minimum of %ld sectors.",
pv_name, PV_MIN_SIZE);
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
if (size < pv_pe_start(pv)) {
log_error("%s: Size must exceed physical extent start of "
"%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
pv->size = size;
@@ -144,13 +141,13 @@
"%" PRIu32 " sectors.", pv_name,
pv_pe_size(pv));
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
if (!pv_resize(pv, vg, new_pe_count)) {
stack;
unlock_vg(cmd, vg_name);
- return ECMD_FAILED;
+ return 0;
}
}
@@ -163,7 +160,7 @@
unlock_vg(cmd, pv_vg_name(pv));
log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name);
- return ECMD_FAILED;
+ return 0;
}
backup(vg);
unlock_vg(cmd, vg_name);
@@ -172,16 +169,31 @@
unlock_vg(cmd, ORPHAN);
log_error("Failed to store physical volume \"%s\"",
pv_name);
- return ECMD_FAILED;
+ return 0;
}
unlock_vg(cmd, vg_name);
}
log_print("Physical volume \"%s\" changed", pv_name);
+ return 1;
+}
+
+
+static int _pvresize_single(struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct physical_volume *pv,
+ void *handle)
+{
+ struct pvresize_params *params = (struct pvresize_params *) handle;
+
+ params->total++;
+ if (!pv_resize_single(cmd, vg, pv, params->new_size))
+ return ECMD_FAILED;
+
params->done++;
- return 1;
+ return ECMD_PROCESSED;
}
int pvresize(struct cmd_context *cmd, int argc, char **argv)
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2/tools pvresize.c
@ 2011-02-28 17:08 prajnoha
0 siblings, 0 replies; 3+ messages in thread
From: prajnoha @ 2011-02-28 17:08 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2011-02-28 17:08:09
Modified files:
tools : pvresize.c
Log message:
Add a hint for manual revert if there's an error in pv_write, vg_write, vg_commit for pvresize.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
--- LVM2/tools/pvresize.c 2011/02/28 13:19:03 1.42
+++ LVM2/tools/pvresize.c 2011/02/28 17:08:09 1.43
@@ -35,6 +35,7 @@
const char *pv_name = pv_dev_name(pv);
const char *vg_name = pv_vg_name(pv);
struct volume_group *old_vg = vg;
+ int vg_needs_pv_write = 0;
if (is_orphan_vg(vg_name)) {
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
@@ -100,7 +101,8 @@
/* 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)) &&
+ (vg_needs_pv_write = (fid_get_mda_indexed(vg->fid,
+ (const char *) &pv->id, ID_LEN, 1) != NULL))) &&
!pv_write(cmd, pv, 1)) {
log_error("Failed to store physical volume \"%s\"",
pv_name);
@@ -120,6 +122,9 @@
r = 1;
out:
+ if (!r && vg_needs_pv_write)
+ log_error("Use pvcreate and vgcfgrestore "
+ "to repair from archived metadata.");
unlock_vg(cmd, vg_name);
if (!old_vg)
free_vg(vg);
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2/tools pvresize.c
@ 2007-06-13 22:16 wysochanski
0 siblings, 0 replies; 3+ messages in thread
From: wysochanski @ 2007-06-13 22:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2007-06-13 22:16:27
Modified files:
tools : pvresize.c
Log message:
Convert pv->pe_start to get_pv_pe_start
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
--- LVM2/tools/pvresize.c 2007/06/06 19:40:28 1.4
+++ LVM2/tools/pvresize.c 2007/06/13 22:16:27 1.5
@@ -125,9 +125,9 @@
return ECMD_FAILED;
}
- if (size < pv->pe_start) {
+ if (size < get_pv_pe_start(pv)) {
log_error("%s: Size must exceed physical extent start of "
- "%" PRIu64 " sectors.", pv_name, pv->pe_start);
+ "%" PRIu64 " sectors.", pv_name, get_pv_pe_start(pv));
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
@@ -135,7 +135,7 @@
pv->size = size;
if (vg) {
- pv->size -= pv->pe_start;
+ pv->size -= get_pv_pe_start(pv);
new_pe_count = pv->size / vg->extent_size;
if (!new_pe_count) {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-28 17:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-30 20:16 LVM2/tools pvresize.c wysochanski
-- strict thread matches above, loose matches on Subject: below --
2011-02-28 17:08 prajnoha
2007-06-13 22:16 wysochanski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).