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

[lvm-devel] [LVM2 PATCH] (0/5) Fix mirror log allocation



Hi Alasdair, Jonathan,

This series of patches fix the following mirror log allocation
problem:
  1. lvconvert from linear to mirror can allocate log device
     from the same PV as mirror images
  2. lvconvert from corelog to disklog can allocate log device
     from the same PV as mirror images
  3. "--alloc anywhere" doesn't help mirror log allocation
     when the number of available PVs are equal to the number of
     mirror images, though lvcreate/lvconvert suggest to try it.

Patches are applicable to and tested on LVM2 2.02.17.
Please consider to apply.


The first 2 problems happen because of the wrong application
of parallel area constraint. The constraint should be:
  - mirror image should avoid PVs used by the parallel areas of
    the matching range of LE
  - mirror log should avoid PVs used by the parallel areas of
    the whole range of the LV
However, current code applies the first constraint for both
mirror log and mirror images.
So the log allocation avoids only the areas parallel to LE:0:1.

To apply the different constraints effectively, this patch set
makes the allocation done in 2 steps.
  1. do log allocation
  2. do mirror image allocation

As a result of this, the 3rd problem is fixed as well.

The patches are:
  1. Rearrange _alloc_parallel_areas() and moves out log allocation
     part as a separate function.
  2. Fix handling of log-only allocation failure.
  3. Changes _find_parallel_space() to do log allocation first.
  4. Removing unnecessary prev_lvseg checks.
  5. Removing ix_offset variable.

3 is the core part of this fix.
1 and 2 are preparation for it.
4 and 5 are cleaning up of the related codes.


Reproducible test scripts and corresponding metadatas are attached.

The test scripts automatically set up loop-back device and test
PVs and VG on it. You might want to change vgname defined in
the top of the script.
Then, you can just run it as:
  # sh testcase-lvconvert-linear-mirror-multiseg.sh
  ...
    LV             Devices                         SSize
    lv0            lv0_mimage_0(0),lv0_mimage_1(0) 196.00M
    [lv0_mimage_0] /dev/mapper/d1(24)              100.00M
    [lv0_mimage_0] /dev/mapper/d2(24)               96.00M
    [lv0_mimage_1] /dev/mapper/d3(0)               100.00M
    [lv0_mimage_1] /dev/mapper/d4(0)                96.00M
    [lv0_mlog]     /dev/mapper/d2(0)                 4.00M
  ...
  ERROR: /dev/mapper/d2 is used in both testvg/lv0_mlog and testvg/lv0_mimage_0
  ERROR: /dev/mapper/d2 is used in both testvg/lv0_mimage_0 and testvg/lv0_mlog
  Number of failures: 2
  FAIL

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America

Attachment: testcase-lvconvert-addlog-multiseg.sh
Description: Bourne shell script

Attachment: testcase-lvconvert-linear-mirror-multiseg.sh
Description: Bourne shell script

# Generated by LVM2: Mon Jan  8 11:21:52 2007

contents = "Text Format Volume Group"
version = 1

description = "Created *before* executing 'lvconvert -m1 testvg/lv'"

creation_host = "tetsuo.lab"	# Linux tetsuo.lab 2.6.18 #1 SMP Wed Jan 3 14:35:29 EST 2007 i686
creation_time = 1168273312	# Mon Jan  8 11:21:52 2007

testvg {
	id = "Dcb2Rj-4N2l-w1A3-Aofl-xVS2-L3Ia-ZCPqGM"
	seqno = 6
	status = ["RESIZEABLE", "READ", "WRITE"]
	extent_size = 8192		# 4 Megabytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "jUH0fP-x6TP-2uJq-nklX-dZ1k-3b8Q-1WtncB"
			device = "/dev/mapper/d1"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv1 {
			id = "fkGSF6-CSv3-37mq-oc4L-moK8-WcHi-NonZ2q"
			device = "/dev/mapper/d2"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv2 {
			id = "FenFQL-gfFl-3hzF-DCZz-D003-F91T-OPqMPt"
			device = "/dev/mapper/d3"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv3 {
			id = "d1zV43-HtSm-6mS0-JwAj-uQG4-ZMN0-omf3xj"
			device = "/dev/mapper/d4"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv4 {
			id = "jYxxAt-lR5O-032z-n7B1-A08M-KbA0-6f4ICk"
			device = "/dev/mapper/d5"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv5 {
			id = "M2TrRN-U873-wJqz-V83P-Z8CA-WLE9-06FQxy"
			device = "/dev/mapper/d6"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv6 {
			id = "hwcep3-Pr3Y-yEVr-Q3Gl-Ddir-tXDE-H9XKel"
			device = "/dev/mapper/d7"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}
	}

	logical_volumes {

		lv {
			id = "zeUbPC-gvyg-xtSR-Fw78-vksc-MZ03-dwxxHu"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 73	# 292 Megabytes

				type = "mirror"
				mirror_count = 2
				region_size = 1024

				mirrors = [
					"lv_mimage_0", 0,
					"lv_mimage_1", 0
				]
			}
		}

		lv_mimage_0 {
			id = "RGdkHe-yXdA-5tCI-QGpw-DnMn-b6yO-4EB4HJ"
			status = ["READ", "WRITE"]
			segment_count = 2

			segment1 {
				start_extent = 0
				extent_count = 49	# 196 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
			segment2 {
				start_extent = 49
				extent_count = 24	# 96 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv2", 0
				]
			}
		}

		lv_mimage_1 {
			id = "vaqnZT-2eKU-Re1N-5NfO-haOI-zVvW-gOnQJG"
			status = ["READ", "WRITE"]
			segment_count = 2

			segment1 {
				start_extent = 0
				extent_count = 49	# 196 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv1", 0
				]
			}
			segment2 {
				start_extent = 49
				extent_count = 24	# 96 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv3", 0
				]
			}
		}
	}
}
# Generated by LVM2: Mon Jan  8 11:26:53 2007

contents = "Text Format Volume Group"
version = 1

description = "Created *before* executing 'lvconvert -m 1 testvg/lv0'"

creation_host = "tetsuo.lab"	# Linux tetsuo.lab 2.6.18 #1 SMP Wed Jan 3 14:35:29 EST 2007 i686
creation_time = 1168273613	# Mon Jan  8 11:26:53 2007

testvg {
	id = "Dcb2Rj-4N2l-w1A3-Aofl-xVS2-L3Ia-ZCPqGM"
	seqno = 25
	status = ["RESIZEABLE", "READ", "WRITE"]
	extent_size = 8192		# 4 Megabytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "jUH0fP-x6TP-2uJq-nklX-dZ1k-3b8Q-1WtncB"
			device = "/dev/mapper/d1"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv1 {
			id = "fkGSF6-CSv3-37mq-oc4L-moK8-WcHi-NonZ2q"
			device = "/dev/mapper/d2"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv2 {
			id = "FenFQL-gfFl-3hzF-DCZz-D003-F91T-OPqMPt"
			device = "/dev/mapper/d3"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv3 {
			id = "d1zV43-HtSm-6mS0-JwAj-uQG4-ZMN0-omf3xj"
			device = "/dev/mapper/d4"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv4 {
			id = "jYxxAt-lR5O-032z-n7B1-A08M-KbA0-6f4ICk"
			device = "/dev/mapper/d5"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv5 {
			id = "M2TrRN-U873-wJqz-V83P-Z8CA-WLE9-06FQxy"
			device = "/dev/mapper/d6"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}

		pv6 {
			id = "hwcep3-Pr3Y-yEVr-Q3Gl-Ddir-tXDE-H9XKel"
			device = "/dev/mapper/d7"	# Hint only

			status = ["ALLOCATABLE"]
			dev_size = 409600	# 200 Megabytes
			pe_start = 384
			pe_count = 49	# 196 Megabytes
		}
	}

	logical_volumes {

		lv0 {
			id = "OztWiN-aCg4-Ws91-7Chz-9IHM-tSFD-O3yvuT"
			status = ["READ", "WRITE", "VISIBLE"]
			segment_count = 2

			segment1 {
				start_extent = 0
				extent_count = 25	# 100 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 24
				]
			}
			segment2 {
				start_extent = 25
				extent_count = 24	# 96 Megabytes

				type = "striped"
				stripe_count = 1	# linear

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

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