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: Tue, 09 Jun 2009 14:30:00 -0000 [thread overview] Message-ID: <20090609143017.6822.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2009-06-09 14:30:16 Modified files: tools : vgrename.c Log message: Update vgrename to use vg_lock_newname. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 --- LVM2/tools/vgrename.c 2009/05/21 03:04:54 1.62 +++ LVM2/tools/vgrename.c 2009/06/09 14:30:16 1.63 @@ -28,7 +28,8 @@ char *vg_name_new; const char *vgid = NULL, *vg_name, *vg_name_old; char old_path[NAME_LEN], new_path[NAME_LEN]; - struct volume_group *vg = NULL, *vg_new = NULL; + struct volume_group *vg = NULL; + uint32_t rc; vg_name_old = skip_dev_dir(cmd, old_vg_path, NULL); vg_name_new = skip_dev_dir(cmd, new_vg_path, NULL); @@ -100,17 +101,19 @@ log_verbose("Checking for new volume group \"%s\"", vg_name_new); - if (!lock_vol(cmd, vg_name_new, LCK_VG_WRITE)) { + 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; } - consistent = 0; - if ((vg_new = vg_read_internal(cmd, vg_name_new, NULL, &consistent))) { + if (rc == FAILED_EXIST) { log_error("New volume group \"%s\" already exists", vg_name_new); - goto error; + unlock_and_release_vg(cmd, vg, vg_name_old); + return 0; } if (!archive(vg)) @@ -151,7 +154,7 @@ backup(vg); backup_remove(cmd, vg_name_old); - unlock_and_release_vg(cmd, vg_new, vg_name_new); + unlock_vg(cmd, vg_name_new); unlock_and_release_vg(cmd, vg, vg_name_old); log_print("Volume group \"%s\" successfully renamed to \"%s\"", @@ -164,7 +167,7 @@ return 1; error: - unlock_and_release_vg(cmd, vg_new, vg_name_new); + unlock_vg(cmd, vg_name_new); unlock_and_release_vg(cmd, vg, vg_name_old); return 0; }
next reply other threads:[~2009-06-09 14:30 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-06-09 14:30 wysochanski [this message] -- strict thread matches above, loose matches on Subject: below -- 2009-09-02 21:29 wysochanski 2009-09-02 21:29 wysochanski 2009-07-01 17:02 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=20090609143017.6822.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).