public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: agk@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/metadata metadata-exported.h metadata.c Date: Tue, 27 Jan 2009 00:40:00 -0000 [thread overview] Message-ID: <20090127004045.13721.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2009-01-27 00:40:45 Modified files: lib/metadata : metadata-exported.h metadata.c Log message: Introduce as-yet-unused replacement vg_read() and vg_read_for_update() functions. (mornfall) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201 --- LVM2/lib/metadata/metadata-exported.h 2009/01/26 22:13:22 1.58 +++ LVM2/lib/metadata/metadata-exported.h 2009/01/27 00:40:44 1.59 @@ -387,6 +387,12 @@ uint32_t lock_flags, uint32_t status_flags, uint32_t misc_flags); +/* Loading volume group metadata. */ +vg_t *vg_read(struct cmd_context *cmd, const char *vg_name, + const char *vgid, uint32_t flags); +vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name, + const char *vgid, uint32_t flags); + /* pe_start and pe_end relate to any existing data so that new metadata * areas can avoid overlap */ pv_t *pv_create(const struct cmd_context *cmd, --- LVM2/lib/metadata/metadata.c 2009/01/26 22:43:00 1.200 +++ LVM2/lib/metadata/metadata.c 2009/01/27 00:40:44 1.201 @@ -2610,6 +2610,70 @@ } /* + * vg_read: High-level volume group metadata read function. + * + * vg_read_error() must be used on any handle returned to check for errors. + * + * - metadata inconsistent and automatic correction failed: FAILED_INCONSISTENT + * - VG is read-only: FAILED_READ_ONLY + * - VG is EXPORTED, unless flags has READ_ALLOW_EXPORTED: FAILED_EXPORTED + * - VG is not RESIZEABLE, unless flags has ALLOW_NONRESIZEABLE: + * FAILED_RESIZEABLE + * - locking failed: FAILED_LOCKING + * + * On failures, all locks are released, unless LOCK_KEEP has been supplied. + * + * Volume groups are opened read-only unless flags contains READ_FOR_UPDATE. + * + * Checking for VG existence: + * + * If READ_CHECK_EXISTENCE is set in flags, if the VG exists, a non-NULL struct + * volume_group will be returned every time, but if it has INCONSISTENT_VG set, + * the other fields will be uninitialized. You must check for INCONSISTENT_VG + * if passing READ_CHECK_EXISTENCE. You also must not use it if it has + * INCONSISTENT_VG set. + * + * FIXME: We want vg_read to attempt automatic recovery after acquiring a + * temporary write lock: if that fails, we bail out as usual, with failed & + * FAILED_INCONSISTENT. If it works, we are good to go. Code that's been in + * toollib just set lock_flags to LCK_VG_WRITE and called vg_read_internal with + * *consistent = 1. + */ +vg_t *vg_read(struct cmd_context *cmd, const char *vg_name, + const char *vgid, uint32_t flags) +{ + uint32_t status = CLUSTERED; + uint32_t lock_flags = LCK_VG_READ; + + if (flags & READ_FOR_UPDATE) { + status |= EXPORTED_VG | LVM_WRITE; + lock_flags = LCK_VG_WRITE; + } + + if (flags & READ_ALLOW_EXPORTED) + status &= ~EXPORTED_VG; + + if (flags & READ_REQUIRE_RESIZEABLE) + status |= RESIZEABLE_VG; + + if (flags & LOCK_NONBLOCKING) + lock_flags |= LCK_NONBLOCK; + + return _vg_lock_and_read(cmd, vg_name, vgid, lock_flags, status, flags); +} + +/* + * A high-level volume group metadata reading function. Open a volume group for + * later update (this means the user code can change the metadata and later + * request the new metadata to be written and committed). + */ +vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name, + const char *vgid, uint32_t flags) +{ + return vg_read(cmd, vg_name, vgid, flags | READ_FOR_UPDATE); +} + +/* * Gets/Sets for external LVM library */ struct id pv_id(const pv_t *pv)
next reply other threads:[~2009-01-27 0:40 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-01-27 0:40 agk [this message] -- strict thread matches above, loose matches on Subject: below -- 2010-06-29 22:41 wysochanski 2010-06-28 20:36 wysochanski 2010-05-19 11:52 wysochanski 2010-04-13 17:26 wysochanski 2009-07-26 2:02 wysochanski 2009-07-26 1:53 wysochanski 2009-07-15 17:26 agk 2009-07-15 6:10 mornfall 2009-07-10 21:19 wysochanski 2009-07-08 14:31 wysochanski 2009-07-08 14:28 wysochanski 2009-06-09 14:29 wysochanski 2009-01-27 1:48 agk 2009-01-26 22:13 agk 2008-03-13 22:51 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=20090127004045.13721.qmail@sourceware.org \ --to=agk@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).