All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Rockai <prockai@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 6/14] Add vg_read_error and vg_might_exist.
Date: Thu, 22 Jan 2009 11:10:02 +0100	[thread overview]
Message-ID: <1232619010-4858-7-git-send-email-prockai@redhat.com> (raw)
In-Reply-To: <1232619010-4858-6-git-send-email-prockai@redhat.com>

Thu Jan 15 10:55:43 CET 2009  Petr Rockai <me@mornfall.net>
  * Add vg_read_error and vg_might_exist.
diff -rN -u -p old-temp.4430/lib/metadata/metadata.c new-temp.4430/lib/metadata/metadata.c
--- old-temp.4430/lib/metadata/metadata.c	2009-01-22 11:02:42.462777778 +0100
+++ new-temp.4430/lib/metadata/metadata.c	2009-01-22 11:02:42.510780457 +0100
@@ -2669,6 +2669,40 @@ vg_t *vg_read_for_update(struct cmd_cont
 }
 
 /*
+ * Check whether a vg_read (or vg_read_for_update) operation resulted in an
+ * error, or completed successfully. If EXISTENCE_CHECK has been given to
+ * vg_read, we do not consider nonexistence of the volume group an error. The
+ * caller is responsible for using vg_might_exist:
+ * - !vg_read_error(vg) && vg_might_exist(vg) -> vg is a valid handle
+ * - vg_read_error(vg) && vg_might_exist(vg) -> vg is not valid, but the VG in
+ *   question probably exists, it just cannot be opened (consult vg_read_error
+ *   return code for reason).
+ * - !vg_read_error(vg) && !vg_might_exist(vg) -> the VG does not exist
+ * - vg_read_error(vg) && !vg_might_exist(vg) -> cannot happen
+ */
+uint32_t vg_read_error(vg_t *vg)
+{
+	if (!vg)
+		return FAILED_ALLOCATION;
+	if (vg->read_failed & EXISTENCE_CHECK)
+		return vg->read_failed & ~(EXISTENCE_CHECK | FAILED_NOTFOUND);
+	return vg->read_failed;
+}
+
+/*
+ * Returns true if the volume group already exists. If unsure, it will return
+ * true (it might exist, but we are not sure, as the read failed for some other
+ * reason).
+ */
+uint32_t vg_might_exist(vg_t *vg) {
+	if (!vg)
+		return 1;
+	if (vg->read_failed == (FAILED_NOTFOUND | EXISTENCE_CHECK))
+		return 0;
+	return 1;
+}
+
+/*
  * Gets/Sets for external LVM library
  */
 struct id pv_id(const pv_t *pv)
diff -rN -u -p old-temp.4430/lib/metadata/metadata-exported.h new-temp.4430/lib/metadata/metadata-exported.h
--- old-temp.4430/lib/metadata/metadata-exported.h	2009-01-22 11:02:42.462777778 +0100
+++ new-temp.4430/lib/metadata/metadata-exported.h	2009-01-22 11:02:42.510780457 +0100
@@ -399,6 +399,10 @@ vg_t *vg_read(struct cmd_context *cmd, c
 vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
                          const char *vgid, uint32_t flags);
 
+/* Queries on a (possibly error-indicating) VG handle. */
+uint32_t vg_read_error(vg_t *vg);
+uint32_t vg_might_exist(vg_t *vg);
+
 /* 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,



  reply	other threads:[~2009-01-22 10:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-22 10:09 [PATCH] Another take on vg_read Petr Rockai
2009-01-22 10:09 ` [PATCH 1/14] Move vg_read out of the way, renaming it to vg_read_internal Petr Rockai
2009-01-22 10:09   ` [PATCH 2/14] Provide _vg_lock_and_read, a new implementation of lock+vg_read_internal Petr Rockai
2009-01-22 10:09     ` [PATCH 3/14] Properly enforce cluster locking in _vg_lock_and_read Petr Rockai
2009-01-22 10:10       ` [PATCH 4/14] Replace implementation of vg_check_status with a call to _vg_check_status Petr Rockai
2009-01-22 10:10         ` [PATCH 5/14] Implement vg_read and vg_read_for_update Petr Rockai
2009-01-22 10:10           ` Petr Rockai [this message]
2009-01-22 10:10             ` [PATCH 7/14] Convert the straight instances of vg_lock_and_read to new vg_read(_for_update) Petr Rockai
2009-01-22 10:10               ` [PATCH 8/14] Convert vgreduce to use vg_read_for_update Petr Rockai
2009-01-22 10:10                 ` [PATCH 9/14] Convert vgrename to vg_read_for_update Petr Rockai
2009-01-22 10:10                   ` [PATCH 10/14] Convert vgsplit to use vg_read_for_update Petr Rockai
2009-01-22 10:10                     ` [PATCH 11/14] Rework the toollib interface (process_each_*) on top of new vg_read Petr Rockai
2009-01-22 10:10                       ` [PATCH 12/14] Port process_each_pv to " Petr Rockai
2009-01-22 10:10                         ` [PATCH 13/14] Remove now-unused vg_lock_and_read Petr Rockai
2009-01-22 10:10                           ` [PATCH 14/14] Un-export vg_read_internal Petr Rockai
2009-01-26 16:05                             ` Dave Wysochanski
2009-01-22 16:13                         ` [PATCH 12/14] Port process_each_pv to new vg_read Dave Wysochanski
2009-01-24 21:45                 ` [PATCH updated] Convert vgreduce to use vg_read_for_update Dave Wysochanski
2009-01-24 21:46                   ` [PATCH] " Dave Wysochanski
2009-01-25  0:21                     ` [PATCH update2] " Dave Wysochanski
2009-01-25  0:21                       ` [PATCH] " Dave Wysochanski
2009-01-22 18:17       ` [PATCH 3/14] Properly enforce cluster locking in _vg_lock_and_read Dave Wysochanski
2009-01-22 20:15         ` Petr Rockai
2009-02-06 18:21     ` [PATCH 2/14] Provide _vg_lock_and_read, a new implementation of lock+vg_read_internal Dave Wysochanski
2009-01-22 17:36 ` [PATCH] Another take on vg_read Dave Wysochanski
2009-01-22 17:48   ` Petr Rockai

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=1232619010-4858-7-git-send-email-prockai@redhat.com \
    --to=prockai@redhat.com \
    --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.