1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
LVM2 mirror repository https://sourceware.org/lvm2/
Go to file
Jonathan Earl Brassow 83c606ae30 This patch fixes issues with improper udev flags on sub-LVs.
The current code does not always assign proper udev flags to sub-LVs (e.g.
mirror images and log LVs).  This shows up especially during a splitmirror
operation in which an image is split off from a mirror to form a new LV.

A mirror with a disk log is actually composed of 4 different LVs: the 2
mirror images, the log, and the top-level LV that "glues" them all together.
When a 2-way mirror is split into two linear LVs, two of those LVs must be
removed.  The segments of the image which is not split off to form the new
LV are transferred to the top-level LV.  This is done so that the original
LV can maintain its major/minor, UUID, and name.  The sub-lv from which the
segments were transferred gets an error segment as a transitory process
before it is eventually removed.  (Note that if the error target was not put
in place, a resume_lv would result in two LVs pointing to the same segment!
If the machine crashes before the eventual removal of the sub-LV, the result
would be a residual LV with the same mapping as the original (now linear) LV.)
So, the two LVs that need to be removed are now the log device and the sub-LV
with the error segment.  If udev_flags are not properly set, a resume will
cause the error LV to come up and be scanned by udev.  This causes I/O errors.
Additionally, when udev scans sub-LVs (or former sub-LVs), it can cause races
when we are trying to remove those LVs.  This is especially bad during failure
conditions.

When the mirror is suspended, the top-level along with its sub-LVs are
suspended.  The changes (now 2 linear devices and the yet-to-be-removed log
and error LV) are committed.  When the resume takes place on the original
LV, there are no longer links to the other sub-lvs through the LVM metadata.
The links are implicitly handled by querying the kernel for a list of
dependencies.  This is done in the '_add_dev' function (which is recursively
called for each dependency found) - called through the following chain:
	_add_dev
	dm_tree_add_dev_with_udev_flags
	<*** DM / LVM divide ***>
	_add_dev_to_dtree
	_add_lv_to_dtree
	_create_partial_dtree
	_tree_action
	dev_manager_activate
	_lv_activate_lv
	_lv_resume
	lv_resume_if_active
When udev flags are calculated by '_get_udev_flags', it is done by referencing
the 'logical_volume' structure.  Those flags are then passed down into
'dm_tree_add_dev_with_udev_flags', which in turn passes them to '_add_dev'.
Unfortunately, when '_add_dev' is finding the dependencies, it has no way to
calculate their proper udev_flags.  This is because it is below the DM/LVM
divide - it doesn't have access to the logical_volume structure.  In fact,
'_add_dev' simply reuses the udev_flags given for the initial device!  This
virtually guarentees the udev_flags are wrong for all the dependencies unless
they are reset by some other mechanism.  The current code provides no such
mechanism.  Even if '_add_new_lv_to_dtree' were called on the sub-devices -
which it isn't - entries already in the tree are simply passed over, failing
to reset any udev_flags.  The solution must retain its implicit nature of
discovering dependencies and be able to go back over the dependencies found
to properly set the udev_flags.

My solution simply calls a new function before leaving '_add_new_lv_to_dtree'
that iterates over the dtree nodes to properly reset the udev_flags of any
children.  It is important that this function occur after the '_add_dev' has
done its job of querying the kernel for a list of dependencies.  It is this
list of children that we use to look up their respective LVs and properly
calculate the udev_flags.

This solution has worked for single machine, cluster, and cluster w/ exclusive
activation.
2011-10-06 14:45:40 +00:00
autoconf Using Fedora 14's autoreconf. 2011-01-07 14:38:34 +00:00
daemons Typo in debug message 2011-09-29 08:57:21 +00:00
doc Clarify multi-name device filter pattern matching explanation in lvm.conf.5. 2011-10-04 20:49:24 +00:00
include Refactor the percent (mirror sync, snapshot usage) handling code to use 2010-11-30 11:53:31 +00:00
lib This patch fixes issues with improper udev flags on sub-LVs. 2011-10-06 14:45:40 +00:00
libdm This patch fixes issues with improper udev flags on sub-LVs. 2011-10-06 14:45:40 +00:00
liblvm Replace free_vg with release_vg 2011-08-10 20:25:29 +00:00
man Clarify multi-name device filter pattern matching explanation in lvm.conf.5. 2011-10-04 20:45:36 +00:00
old-tests Move tests from old-tests/regex to unit-tests/regex. unit-tests will 2010-07-20 15:18:57 +00:00
po INSTALL rules updates 2010-04-09 21:42:48 +00:00
report-generators add copyright notices to new files 2010-07-28 12:20:38 +00:00
reports [REPORT-GENERATORS] cut down stylsheet.css to what we actually use 2010-07-21 10:00:38 +00:00
scripts New handy gdb debugging function, "dm_list_size" 2011-09-28 16:32:22 +00:00
test Fix vgsplit when there are mirrors that have mirrored logs. 2011-10-06 14:17:45 +00:00
tools Fix vgsplit when there are mirrors that have mirrored logs. 2011-10-06 14:17:45 +00:00
udev Update udev rules to skip DM flags decoding for removed devices 2011-08-11 17:55:29 +00:00
unit-tests [MM] Make valgrind aware of the pool allocators 2010-08-09 10:56:01 +00:00
aclocal.m4 Add aclocal.m4 (for pkgconfig). 2011-01-07 16:27:05 +00:00
configure Use Makefile for daemmons/common library. 2011-09-24 20:57:49 +00:00
configure.in Use Makefile for daemmons/common library. 2011-09-24 20:57:49 +00:00
COPYING Outline docs 2001-12-31 16:12:40 +00:00
COPYING.LIB Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1. 2007-08-20 20:55:30 +00:00
INSTALL quick review of docs 2008-11-04 17:49:22 +00:00
make.tmpl.in core removed with clean not distclean 2011-08-12 12:56:38 +00:00
Makefile.in pre-release fixes incl make distclean and configure --with-raid=none/shared 2011-08-11 19:18:17 +00:00
README quick review of docs 2008-11-04 17:49:22 +00:00
VERSION post-release 2011-08-19 19:42:39 +00:00
VERSION_DM post-release 2011-08-19 19:42:39 +00:00
WHATS_NEW This patch fixes issues with improper udev flags on sub-LVs. 2011-10-06 14:45:40 +00:00
WHATS_NEW_DM Update error path tracing for _resume_node 2011-10-03 18:28:25 +00:00

This tree contains the LVM2 and device-mapper tools and libraries.

For more information about LVM2 read the changelog in the WHATS_NEW file.
Installation instructions are in INSTALL.

There is no warranty - see COPYING and COPYING.LIB.

Tarballs are available from:
  ftp://sources.redhat.com/pub/lvm2/

To access the CVS tree use:
  cvs -d :pserver:cvs@sources.redhat.com:/cvs/lvm2 login
  CVS password: cvs
  cvs -d :pserver:cvs@sources.redhat.com:/cvs/lvm2 co LVM2

Mailing list for general discussion related to LVM2:
  linux-lvm@redhat.com
  Subscribe from https://www.redhat.com/mailman/listinfo/linux-lvm

Mailing list for LVM2 development, patches and commits:
  lvm-devel@redhat.com
  Subscribe from https://www.redhat.com/mailman/listinfo/linux-lvm

Mailing list for device-mapper development, including kernel patches
and multipath-tools:
  dm-devel@redhat.com
  Subscribe from https://www.redhat.com/mailman/listinfo/dm-devel