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 01:48:00 -0000	[thread overview]
Message-ID: <20090127014849.12671.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-01-27 01:48:48

Modified files:
	lib/metadata   : metadata-exported.h metadata.c 

Log message:
	Add as-yet-unused vg_read_error() and vg_might_exist().  (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.201&r2=1.202

--- LVM2/lib/metadata/metadata-exported.h	2009/01/27 00:40:44	1.59
+++ LVM2/lib/metadata/metadata-exported.h	2009/01/27 01:48:47	1.60
@@ -387,12 +387,20 @@
 		       uint32_t lock_flags, uint32_t status_flags,
 		       uint32_t misc_flags);
 
-/* Loading volume group metadata. */
+/*
+ * Return a handle to VG 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);
 
+/* 
+ * Test validity of a VG handle.
+ */
+uint32_t vg_read_error(vg_t *vg_handle);
+uint32_t vg_might_exist(vg_t *vg_handle);
+
 /* 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/27 00:40:44	1.201
+++ LVM2/lib/metadata/metadata.c	2009/01/27 01:48:47	1.202
@@ -2674,6 +2674,46 @@
 }
 
 /*
+ * Test the validity of a VG handle returned by vg_read() or vg_read_for_update().
+ *
+ * If READ_CHECK_EXISTENCE was supplied the non-existence of the volume group
+ * is not considered an error.
+ *
+ * !vg_read_error() && vg_might_exist() => valid handle to VG.
+ * vg_read_error() && vg_might_exist() => handle invalid, but VG might
+ *					  exist but cannot be read.
+ * !vg_read_error() && !vg_might_exist() => the VG does not exist
+ * vg_read_error() && !vg_might_exist() is impossible.
+ */
+uint32_t vg_read_error(vg_t *vg_handle)
+{
+	if (!vg_handle)
+		return FAILED_ALLOCATION;
+
+	if (vg_handle->read_status & READ_CHECK_EXISTENCE)
+		return vg_handle->read_status &
+		       ~(READ_CHECK_EXISTENCE | FAILED_NOTFOUND);
+
+	return vg_handle->read_status;
+}
+
+/*
+ * Returns true if the volume group already exists.
+ * If unsure, it will return true. It might exist but the read failed
+ * for some other reason.
+ */
+uint32_t vg_might_exist(vg_t *vg_handle)
+{
+	if (!vg_handle)
+		return 1;
+
+	if (vg_handle->read_status == (FAILED_NOTFOUND | READ_CHECK_EXISTENCE))
+		return 0;
+
+	return 1;
+}
+
+/*
  * Gets/Sets for external LVM library
  */
 struct id pv_id(const pv_t *pv)


             reply	other threads:[~2009-01-27  1:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-27  1:48 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  0:40 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=20090127014849.12671.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: link
Be 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).