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

[lvm-devel] [PATCH LVM2] set stripes = 0 for the log device only allocation



Hi,

This patch fixes the allocation failure at adding mirror log
if there is only one PV available.


In lib/metadata/lv_manip.c:_allocate(), the number of stripes
is used for calculation of the number of necessary PVs.
    if (areas_size < ah->area_count + ah->log_count) {

On the other hand, lvconvert gives stripes = 1 even if the
allocation request is for log device only.

As a result, the check above will fail if there is only one
PV available and the command will fail as followings:
  Not enough PVs with free space available for parallel allocation.

even though the log device should be allocated from the free PV
without problem.

For log-only allocation, don't give stripes = 1 to the allocator.
The stripes value is considered to be the number of stripes
for which the allocation is requested. (i.e. ah->area_count)


Patch applicable to LVM2 2.02.16.
The patch depends on safe-area_multiple.patch for correct handling
of stripes = 0 by the allocator.

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
For log-only allocation, don't give stripes = 1 to the allocator.
The stripes value is considered to be the number of stripes
for which the allocation is requested. (i.e. ah->area_count)

As a result, the check like this will fail if there is only one free PV:
  In lib/metadata/lv_manip.c:_allocate(),
    if (areas_size < ah->area_count + ah->log_count) {

and the command will fail as followings:
  Not enough PVs with free space available for parallel allocation.

even though the log device should be allocated from the free PV
without problem.

Patch applicable to LVM2 2.02.16.
The patch depends on safe-area_multiple.patch for correct handling
of stripes = 0 by the allocator.

---
 tools/lvconvert.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: LVM2.cvs/tools/lvconvert.c
===================================================================
--- LVM2.cvs.orig/tools/lvconvert.c	2006-12-13 00:08:32.000000000 -0500
+++ LVM2.cvs/tools/lvconvert.c	2006-12-13 00:08:43.000000000 -0500
@@ -297,7 +297,7 @@ static int lvconvert_mirrors(struct cmd_
 
 					segtype = get_segtype_from_string(cmd, "striped");
 
-					if (!(ah = allocate_extents(lv->vg, NULL, segtype, 1,
+					if (!(ah = allocate_extents(lv->vg, NULL, segtype, 0,
 								    0, 1, 0,
 								    NULL, 0, 0, lp->pvh,
 								    lp->alloc,

Attachment: lvm2-logalloc-from-only-one-free-PV.sh
Description: Bourne shell script

# Generated by LVM2: Tue Dec 12 20:33:50 2006

contents = "Text Format Volume Group"
version = 1

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

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 = 1165973630	# Tue Dec 12 20:33:50 2006

vg0 {
	id = "43o0ac-wTOh-4cPk-iGkU-PwXR-0Yxv-6WmdEO"
	seqno = 2
	status = ["RESIZEABLE", "READ", "WRITE"]
	extent_size = 8			# 4 Kilobytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "PgGq3b-9KJF-EZX4-GUUB-NQQD-BPQ2-JVcFKU"
			device = "/dev/mapper/pv0"	# Hint only

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

		pv1 {
			id = "llAgwA-9v9w-QR0C-r238-n8bu-LZrm-npQjiX"
			device = "/dev/mapper/pv1"	# Hint only

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

		pv2 {
			id = "rSSipA-22K7-yvNq-kSxN-9Z2h-vj3E-IMSSln"
			device = "/dev/mapper/pv2"	# Hint only

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

	logical_volumes {

		lv0 {
			id = "WTH911-TeD4-0g3m-hpS3-AOAo-xAjN-Kc8kus"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 1	# 4 Kilobytes

				type = "mirror"
				mirror_count = 2
				region_size = 8

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

		lv0_mimage_0 {
			id = "Ibdp2t-b8Lb-tCyd-UJIW-oT7G-Ena3-KtPjsl"
			status = ["READ", "WRITE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 1	# 4 Kilobytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
		}

		lv0_mimage_1 {
			id = "2C3yBE-Lg1X-T8kU-URRR-8xQI-xLCb-n70JZ9"
			status = ["READ", "WRITE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 1	# 4 Kilobytes

				type = "striped"
				stripe_count = 1	# linear

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

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