From: wysochanski@sourceware.org <wysochanski@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/tools vgreduce.c
Date: 1 Jul 2009 17:01:47 -0000 [thread overview]
Message-ID: <20090701170147.5429.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2009-07-01 17:01:46
Modified files:
tools : vgreduce.c
Log message:
Convert vgreduce to use vg_read_for_update.
Sun May 3 12:50:58 CEST 2009 Petr Rockai <me@mornfall.net>
* Convert vgreduce to use vg_read_for_update.
Rebased 6/26/2009 - Dave W.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93
--- LVM2/tools/vgreduce.c 2009/06/15 14:47:40 1.92
+++ LVM2/tools/vgreduce.c 2009/07/01 17:01:46 1.93
@@ -382,7 +382,6 @@
{
struct pv_list *pvl;
struct volume_group *orphan_vg = NULL;
- int consistent = 1;
int r = ECMD_FAILED;
const char *name = pv_dev_name(pv);
@@ -424,11 +423,11 @@
vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
vg->extent_count -= pv_pe_count(pv);
- if(!(orphan_vg = vg_read_internal(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
- !consistent) {
- log_error("Unable to read existing orphan PVs");
+ orphan_vg = vg_read_for_update(cmd, vg->fid->fmt->orphan_vg_name,
+ NULL, LOCK_NONBLOCKING);
+
+ if (vg_read_error(orphan_vg))
goto bad;
- }
if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) {
log_error("Cannot remove final metadata area on \"%s\" from \"%s\"",
@@ -463,7 +462,6 @@
struct volume_group *vg;
char *vg_name;
int ret = ECMD_FAILED;
- int consistent = 1;
int fixed = 1;
int repairing = arg_count(cmd, removemissing_ARG);
int saved_ignore_suspended_devices = ignore_suspended_devices();
@@ -511,25 +509,22 @@
}
log_verbose("Finding volume group \"%s\"", vg_name);
- if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
- log_error("Can't get lock for %s", vg_name);
- return ECMD_FAILED;
- }
if (repairing)
init_ignore_suspended_devices(1);
- if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
- && !repairing) {
- log_error("Volume group \"%s\" doesn't exist", vg_name);
+ vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED);
+ if (vg_read_error(vg) == FAILED_ALLOCATION ||
+ vg_read_error(vg) == FAILED_NOTFOUND)
goto out;
- }
- if (vg && !vg_check_status(vg, CLUSTERED))
+ /* FIXME We want to allow read-only VGs to be changed here? */
+ if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
+ && !arg_count(cmd, removemissing_ARG))
goto out;
if (repairing) {
- if (vg && consistent && !vg_missing_pv_count(vg)) {
+ if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
log_error("Volume group \"%s\" is already consistent",
vg_name);
ret = ECMD_PROCESSED;
@@ -537,13 +532,16 @@
}
vg_release(vg);
- consistent = !arg_count(cmd, force_ARG);
- if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
- log_error("Volume group \"%s\" not found", vg_name);
- goto out;
- }
- if (!vg_check_status(vg, CLUSTERED))
+ log_verbose("Trying to open VG %s for recovery...", vg_name);
+
+ vg = vg_read_for_update(cmd, vg_name, NULL,
+ READ_ALLOW_INCONSISTENT
+ | READ_ALLOW_EXPORTED);
+
+ if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
+ && vg_read_error(vg) != FAILED_INCONSISTENT)
goto out;
+
if (!archive(vg))
goto out;
next reply other threads:[~2009-07-01 17:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-01 17:01 wysochanski [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-02-15 12:30 LVM2/tools vgreduce.c mornfall
2009-12-17 13:54 mornfall
2009-07-24 11:13 wysochanski
2008-09-19 3:45 agk
2007-11-19 18:24 agk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090701170147.5429.qmail@sourceware.org \
--to=wysochanski@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.