[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] (11/11) re-instantiate automatic VG recovery


This one restores the functionality that has been severed from the toollib,
that is the automatic metadata recovery in case of running after an interrupted
commit. This could do with a better naming and all, but that will be dealt with
in later patches (in another series, I suppose).

All in all, this is a fairly big bundle, and hopefully it should hit CVS soon
after the dust from the device-mapper merge has settled. It is definitely work
in progress and there will be regressions. However, since it's now easier than
ever to write tests for the testsuite, using the new tools, I would welcome
this as a good opportunity to augment our suite with all the regressions we can
find that the bundle has created (and even more). This is essential to improve
confidence in new code and makes it a lot less hassle to change things. I have
been running the branch through our resident buildbot
(http://nevrast.englab.brq.redhat.com:8010/waterfall) for a while now -- and
it's pretty much green.

I would also like to thank everyone who's worked on the testsuite, it's already
been of great help in development -- and I hope it will become even much more
useful, as it covers more and more use-cases, bugs and, hopefully, all of our
favourite regressions.

Now, I'm done for. I have been staring at diffs just a little too long by now,
but I'll try to write up a summary on what still needs to be done, and some
ideas on how to approach that, in not-so-distant (I hope) future.


Tue Oct 14 22:42:49 CEST 2008  Petr Rockai <me mornfall net>
  * Restore the automatic VG recovery even in the no write lock case.
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata.c new-lvmlib-b/lib/metadata/metadata.c
--- old-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:42:21.293833026 +0100
+++ new-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:42:21.361836292 +0100
@@ -2497,6 +2497,26 @@ vg_t *vg_read(struct cmd_context *cmd, c
 	return vg_lock_and_read(cmd, vg_name, vgid, lock, status, flags);
+static vg_t *_recover_vg(struct cmd_context *cmd, const char *lock, const char *vg_name,
+			 const char *vgid, uint32_t lock_flags )
+	int consistent = 1;
+	struct volume_group *vg;
+	lock_flags &= ~LCK_TYPE_MASK;
+	lock_flags |= LCK_WRITE;
+	unlock_vg(cmd, lock);
+	if (!lock_vol(cmd, lock, lock_flags))
+		return_NULL;
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
+		return_NULL;
+	if (!consistent)
+		return_NULL;
+	return vg;
  * vg_lock_and_read - consolidate vg locking, reading, and status flag checking
@@ -2523,7 +2543,7 @@ vg_t *vg_lock_and_read(struct cmd_contex
 	int failure = 0;
 	if (misc_flags & ALLOW_INCONSISTENT || !(lock_flags & LCK_WRITE))
-		consistent = 0;
+	consistent = 0;
 	if (!validate_name(vg_name) && !is_orphan_vg(vg_name)) {
 		log_error("Volume group name %s has invalid characters",
@@ -2562,9 +2582,13 @@ vg_t *vg_lock_and_read(struct cmd_contex
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
 	if (!consistent && !vg->read_failed) {
-		log_error("Volume group \"%s\" inconsistent.", vg_name);
-		goto_bad;
+		vg = _recover_vg(cmd, lock, vg_name, vgid, lock_flags);
+		if (!vg) {
+			log_error("Recovery of volume group \"%s\" failed.",
+			  vg_name);
+			goto_bad;
+		}
 	failure |= _vg_check_status(vg, status_flags);

Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]