public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: wysochanski@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/tools vgrename.c Date: Wed, 02 Sep 2009 21:29:00 -0000 [thread overview] Message-ID: <20090902212923.13584.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2009-09-02 21:29:23 Modified files: tools : vgrename.c Log message: Refactor vgrename into vg_rename_old and vg_rename_new. Should be no functional change. Will allow us to reorder lock obtaining if needed. Author: Dave Wysochanski <dwysocha@redhat.com> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66 --- LVM2/tools/vgrename.c 2009/07/07 01:18:35 1.65 +++ LVM2/tools/vgrename.c 2009/09/02 21:29:23 1.66 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -15,6 +15,52 @@ #include "tools.h" +static struct volume_group *vg_rename_old(struct cmd_context *cmd, + const char *vg_name_old, + const char *vgid) +{ + struct volume_group *vg; + + /* FIXME we used to print an error about EXPORTED, but proceeded + nevertheless. */ + vg = vg_read_for_update(cmd, vg_name_old, vgid, READ_ALLOW_EXPORTED); + if (vg_read_error(vg)) { + vg_release(vg); + return_NULL; + } + + if (lvs_in_vg_activated_by_uuid_only(vg)) { + unlock_and_release_vg(cmd, vg, vg_name_old); + log_error("Volume group \"%s\" still has active LVs", + vg_name_old); + /* FIXME Remove this restriction */ + return NULL; + } + return vg; +} + +static int vg_rename_new(struct cmd_context *cmd, + const char *vg_name_new) +{ + int rc; + + log_verbose("Checking for new volume group \"%s\"", vg_name_new); + + rc = vg_lock_newname(cmd, vg_name_new); + + if (rc == FAILED_LOCKING) { + log_error("Can't get lock for %s", vg_name_new); + return 0; + } + + if (rc == FAILED_EXIST) { + log_error("New volume group \"%s\" already exists", + vg_name_new); + return 0; + } + return 1; +} + static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path, const char *new_vg_path) { @@ -70,35 +116,11 @@ } else vgid = NULL; - /* FIXME we used to print an error about EXPORTED, but proceeded - nevertheless. */ - vg = vg_read_for_update(cmd, vg_name_old, vgid, READ_ALLOW_EXPORTED); - if (vg_read_error(vg)) { - vg_release(vg); - return_0; - } - - if (lvs_in_vg_activated_by_uuid_only(vg)) { - unlock_and_release_vg(cmd, vg, vg_name_old); - log_error("Volume group \"%s\" still has active LVs", - vg_name_old); - /* FIXME Remove this restriction */ + vg = vg_rename_old(cmd, vg_name_old, vgid); + if (!vg) return 0; - } - - log_verbose("Checking for new volume group \"%s\"", vg_name_new); - - rc = vg_lock_newname(cmd, vg_name_new); - if (rc == FAILED_LOCKING) { - unlock_and_release_vg(cmd, vg, vg_name_old); - log_error("Can't get lock for %s", vg_name_new); - return 0; - } - - if (rc == FAILED_EXIST) { - log_error("New volume group \"%s\" already exists", - vg_name_new); + if (!vg_rename_new(cmd, vg_name_new)) { unlock_and_release_vg(cmd, vg, vg_name_old); return 0; } @@ -168,7 +190,7 @@ if (!vg_rename_path(cmd, argv[0], argv[1])) return ECMD_FAILED; - + return ECMD_PROCESSED; }
next reply other threads:[~2009-09-02 21:29 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-09-02 21:29 wysochanski [this message] -- strict thread matches above, loose matches on Subject: below -- 2009-09-02 21:29 wysochanski 2009-07-01 17:02 wysochanski 2009-06-09 14:30 wysochanski 2008-06-06 16:13 agk 2007-08-31 19:09 wysochanski
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=20090902212923.13584.qmail@sourceware.org \ --to=wysochanski@sourceware.org \ --cc=lvm-devel@redhat.com \ --cc=lvm2-cvs@sourceware.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).