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

[lvm-devel] [PATCH LVM2] Detect allocation failure of log device



Hi,

This patch fixes the testing of allocation result
so that it doesn't miss the failure of log device allocation.


Current code only checks whether the number of extents for
normal devices are allocated as requested.
The number of extents allocated for the log device is out of
consideration.

As a result, the allocator returns success and the later operation
to the allocated extents will cause error with misleading error
messages like this:
  LV lv0_mlog: segment 1 has inconsistent PV area 0
  Internal error: LV segments corrupted in lv0_mlog.

We have to check for the case that only the allocation attempt for
the log device failed,


Patch applicable to LVM2 2.02.16.
Shell script to reproduce the problem and the sample metadata
is attached for reference.
You can reproduce the problem with just executing the script
without additional parameters.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
We have to check for the case that only the allocation attempt for
the log device failed,

Otherwise, the allocator returns success and the later operation
to the allocated extents will cause error with misleading error
messages like this:
  LV lv0_mlog: segment 1 has inconsistent PV area 0
  Internal error: LV segments corrupted in lv0_mlog.

Patch applicable to LVM2 2.02.16.

---
 lib/metadata/lv_manip.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: LVM2.cvs/lib/metadata/lv_manip.c
===================================================================
--- LVM2.cvs.orig/lib/metadata/lv_manip.c	2006-12-13 00:08:44.000000000 -0500
+++ LVM2.cvs/lib/metadata/lv_manip.c	2006-12-13 00:08:45.000000000 -0500
@@ -1162,6 +1162,11 @@ static int _allocate(struct alloc_handle
 			  (new_extents - allocated) * ah->area_count
 			  / ah->area_multiple);
 		goto out;
+	} else if (ah->log_count && ah->log_area.len == 0) {
+		log_error("Log area cannot be allocated "
+			  "for logical volume %s",
+			  lv ? lv->name : "");
+		goto out;
 	}
 
 	r = 1;

Attachment: lvm2-logonly-alloc-failure.sh
Description: Bourne shell script

# Generated by LVM2: Tue Dec 12 21:07:56 2006

contents = "Text Format Volume Group"
version = 1

description = "Created *before* executing 'lvconvert -m1 vg0/lv0'"

creation_host = "tetsuo.lab"	# Linux tetsuo.lab 2.6.18-1.2839.el5 #1 SMP Wed Dec 6 01:01:57 EST 2006 i686
creation_time = 1165975676	# Tue Dec 12 21:07:56 2006

vg0 {
	id = "1JvEWG-3GnB-zJG2-BCCM-odlD-R5cg-wBXXq3"
	seqno = 2
	status = ["RESIZEABLE", "READ", "WRITE"]
	extent_size = 8			# 4 Kilobytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "IHpvun-FEnl-QuR2-mCT0-mpM8-J5Ep-vIE8yc"
			device = "/dev/mapper/pv0"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 40960	# 20 Megabytes
			pe_start = 384
			pe_count = 5072	# 19.8125 Megabytes
		}

		pv1 {
			id = "qLr42s-uzTL-UHpf-5yOK-jTkA-DtmA-mLJLIA"
			device = "/dev/mapper/pv1"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 40960	# 20 Megabytes
			pe_start = 384
			pe_count = 5072	# 19.8125 Megabytes
		}
	}

	logical_volumes {

		lv0 {
			id = "bHcfc0-Dc2n-qtUm-BJ41-n0Rv-y500-0zAUwi"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 5072	# 19.8125 Megabytes

				type = "mirror"
				mirror_count = 2
				region_size = 128

				mirrors = [
					"lv0_mimage_0", 0,
					"lv0_mimage_1", 0
				]
			}
		}

		lv0_mimage_0 {
			id = "reSeH9-Ia57-OaNe-aIw3-F5tq-3Mwb-1J2nOU"
			status = ["READ", "WRITE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 5072	# 19.8125 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
		}

		lv0_mimage_1 {
			id = "k8pk3O-M9un-WJw3-QUf1-m8EU-aCs1-Og57Du"
			status = ["READ", "WRITE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 5072	# 19.8125 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv1", 0
				]
			}
		}
	}
}

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