1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

2572 Commits

Author SHA1 Message Date
Jonathan Earl Brassow
6c0b0e5d9a Revert initial solution to bug 733114 - I/O error message during splitmirror
The original commit comments can be located via this git commit ID:
	7d8e615c0b

There were three possible solutions to the original problem proposed in the
initial check-in.  The one chosen was as follows:
    2) Do like _remove_mirror_images does and suspend the original, then suspend
    the sub-lv (the error target), then resume the sub-lv, and finally resume the
    original LV.  This seems like extra pointless operations to me, but it doesn't
    produce the error message (although, I'm not sure why) and it allows us to
    leave the visible flag in place.
Turns out, the cluster also views the extra suspend/resume operations as
pointless too and ignores them.  So, this solution doesn't work in a cluster.
Further, I've noticed that in addition to the remote cluster nodes still getting
I/O errors from scanning the error target, they also have a different LVM and
DM views of the same LV.  IOW, while the LVM level (gotten from the LVM metadata)
sees the correct name for the newly split LV, device-mapper still maintains the
old names.

Because the original fix failed to completely fix the problem (or work-around it)
and because a better solution must be found to address the additional cluster
issue of device renaming, I am reverting the above mentioned commit.
2011-10-06 14:49:16 +00:00
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
Zdenek Kabelac
151ed8d935 Add more validation to config parser
Do not leave it for vgvalidate().
2011-10-06 11:06:36 +00:00
Zdenek Kabelac
565a4bfc49 Move defines to header
Make limits for thin data_block_size and device_id part of public API.

FIXME: read them possible from some kernel header file in the future ?
But we may need to support different values for different versions ?
2011-10-06 11:05:56 +00:00
Zdenek Kabelac
c0b9c64a77 Use capital letters 2011-10-04 12:39:59 +00:00
Zdenek Kabelac
01ef6510b0 Missed rename pool->thin_pool
Fix compilation
2011-10-03 19:10:52 +00:00
Zdenek Kabelac
04a4715cb8 Add code to activate thin target
Code to zero pool metadata lv when pool is created.
Add code to create thin target via message sending.

(Revert is missing)
2011-10-03 18:43:39 +00:00
Zdenek Kabelac
d35a117e4b Add simple function for lookup of some free device_id
Initial simple implementation for finding some free device_id.
2011-10-03 18:39:17 +00:00
Zdenek Kabelac
a00cb3a6b0 Add lvm functions for sending messages.
Functions are currently only needed for thin provissioning.
2011-10-03 18:37:47 +00:00
Zdenek Kabelac
97bde15a9f Display transaction_id for thin_pool 2011-10-03 18:31:03 +00:00
Zdenek Kabelac
1419bf1c98 Transaction_id is property of thin_pool
Remove Transaction_id from thin target.
Store device_id for thin target.
2011-10-03 18:26:07 +00:00
Zdenek Kabelac
87663d5f88 Add preload support for thin and thin_pool 2011-10-03 18:24:47 +00:00
Zdenek Kabelac
38796c3d47 Fix bad error message for thinp validation 2011-09-29 09:03:36 +00:00
Zdenek Kabelac
aebf2d5cdc Add experimental code for activation of thinp targets
No dm messages yes - just a base functionality in the steps of other targets.
For now usable only for debugging and tracing.
2011-09-29 08:56:38 +00:00
Alasdair Kergon
10d0d9c7c4 Introduce revert_lv for better pvmove cleanup.
(One further fix needed to remove the stray pvmove LVs left behind.)
2011-09-27 22:43:40 +00:00
Alasdair Kergon
1c26860d82 Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely.
Change suspend_lvs to call vg_revert internally.
Change vg_revert to void and remove superfluous calls after failed vg_commit.
2011-09-27 17:09:42 +00:00
Alasdair Kergon
d71fd30e5d typo 2011-09-27 12:34:14 +00:00
Alasdair Kergon
7c67d33dd4 correct thin_pool width 2011-09-27 12:33:36 +00:00
Zdenek Kabelac
1d526c8585 Show some Thin related info in lvdisplay 2011-09-26 13:11:02 +00:00
Peter Rajnoha
c3e5b4976d Add log_error even for general device in use when we can't do the sysfs checks. 2011-09-26 10:17:51 +00:00
Zdenek Kabelac
f1ab501a58 Fix log_error() usage
Cosmetic - skip <bactrace> when error has been just printed in raid segtype.
Add missing log_error if allocation would fail for unknown segtype.
2011-09-24 21:19:30 +00:00
Jonathan Earl Brassow
efa3621a59 Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE.
RAID_META is already handled.
2011-09-23 15:17:54 +00:00
Peter Rajnoha
9fa1d30a1c Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. 2011-09-22 17:39:56 +00:00
Peter Rajnoha
125712bea0 Replace open_count check with holders/mounted_fs check on lvremove path.
Before, we used to display "Can't remove open logical volume" which was
generic. There 3 possibilities of how a device could be opened:
  - used by another device
  - having a filesystem on that device which is mounted
  - opened directly by an application

With the help of sysfs info, we can distinguish the first two situations.
The third one will be subject to "remove retry" logic - if it's opened
quickly (e.g. a parallel scan from within a udev rule run), this will
finish quickly and we can remove it once it has finished. If it's a
legitimate application that keeps the device opened, we'll do our best
to remove the device, but we will fail finally after a few retries.
2011-09-22 17:33:50 +00:00
Jonathan Earl Brassow
40c85cf1d7 When up-converting a RAID1 array, we need to allocate new larger arrays for
seg->areas and seg->meta_areas.  We also need to copy the memory from the
old arrays to the newly allocated arrays.  The amount of memory to copy was
determined by seg->area_count.  However, seg->area_count was being set to the
higher value after copying the 'seg->areas' information, but before copying
the 'seg->meta_areas' information.  This means we were copying more memory
than necessary for 'seg->meta_areas' - something that could lead to a segfault.
2011-09-22 15:33:21 +00:00
Zdenek Kabelac
ce840163c0 Revert patch
Caller of exec must report log_error when rstatus is passed.
2011-09-19 18:38:43 +00:00
Zdenek Kabelac
4eeff46bf2 Use log_error instead of log_verbose when executed command fails 2011-09-19 14:54:23 +00:00
Jonathan Earl Brassow
4026cb6fd1 fix compiler warning.
Compiler says variable may be used uninitialized.  It can't be, but we
initialize the variable to NULL anyway.  Also, remove the double initialization
of another variable.
2011-09-19 14:28:23 +00:00
Zdenek Kabelac
5f3f06db66 Move debug message
so it does not look like we are executing command in the middle of
critical_section in log trace.
2011-09-19 12:48:02 +00:00
Jonathan Earl Brassow
eb607100ef Fix Bug 738832 - core to disk log conversion fails with internal error
This bug showed up when trying to add a log to a mirror whose images are on
multiple devices.  This is an intra-release regression and no WHATS_NEW
entry will be added.  The error was introduce in the following commit:
	2d8a2f35c7

The solution is to recognise in _alloc_init that if there are no mirrors
or stripes specified, then 'new_extents' should be zero.
2011-09-16 18:39:03 +00:00
Jonathan Earl Brassow
a514067448 After suspend/resume following a splitmirror op, call sync_local_dev_names
to settle udev before calling deactivate_lv.

This is an intra-release regression (no WHATS_NEW entry required).  It is
part of the fix for the current WHATS_NEW entry:
  Work around resume_lv causing error LV scanning during splitmirror operation.
2011-09-16 16:41:37 +00:00
Zdenek Kabelac
a6d50bef2f Remove thin volumes before thin pools
When user wants to remove thin pool - check if there are no thin volumes using it.
If so - query before removal (or -ff for no question) and remove them first.
2011-09-16 12:12:51 +00:00
Zdenek Kabelac
4a0c6df8df Reset LV status when unlinking LV from VG
When LV is unlinked, we want to catch problem in vg_validate,
that LV has changed.

i.e. catch LV has been removed and is no long thin_pool while still
being referenced by some thin volume.
2011-09-16 11:59:22 +00:00
Zdenek Kabelac
94147f3f29 Trim spaces on EOL 2011-09-16 11:53:14 +00:00
Petr Rockai
fd7d4adc57 Fix the divisibility check in the allocator for the mirror+stripe case (require
divisibility by stripe count alone, not by (mirror*stripe)).
2011-09-16 09:59:42 +00:00
Milan Broz
c81a322337 Activate virtual snapshot origin exclusively (only on local node in cluster). 2011-09-14 14:20:16 +00:00
Zdenek Kabelac
e24be2abe4 Add suggest parentheses around '&&'
Follow gcc suggestion.
2011-09-14 10:03:15 +00:00
Zdenek Kabelac
886d005616 LVM_WRITE and LVM_READ are 64bit constants
Revert John patch, which fixed only 1 place where ~LVM_WRITE was in use and
convert ommited LVM_READ/WRITE flags to 64bit constants as well.
(Since both 'status' flags for LV and VG are 64bit.)
2011-09-14 09:57:35 +00:00
Zdenek Kabelac
3e25de05a9 Add missing underscores to local static functions 2011-09-14 09:54:21 +00:00
Jonathan Earl Brassow
462579d54e Additional fixes for lv_mirror_count.
Changing lv_mirror_count to only count the AREA_LVs made the function
stop working for PVMOVE mirrors.  A conditional has been added to fix
that problem.  Additionally, when counting the images in a mirror stack,
we don't need to subtract 1 from the count we get back from the
lv_mirror_count call on the temporary mirror layer.  (This is because we
are no falsely counting the top layer of the temporary mirror.)
2011-09-14 04:10:26 +00:00
Jonathan Earl Brassow
9cb27929e9 Fix for bug 734252 - problem up converting striped mirror after image failure
lv_mirror_count was not able to handle mirrors of stripes properly.  When a
failed device is removed, the MIRRORED status flag is removed from the LV
conditionally based on the results of lv_mirror_count.  However, lv_mirror_count
trusted the MIRRORED flag - thinking any such LV must be mirrored.  It would
happily assign first_seg(lv)->area_count as the number of mirrors, but when
a mirrored striped LV was reduced to a simple striped LV area_count would be
the number of /stripes/ not the number of /mirrors/.  A result higher than 1
would be returned from lv_mirror_count, the MIRRORED flag would not be cleared,
and the LV would fail to be up-converted properly in lvconvert_mirrors_aux
because of it.
2011-09-14 02:45:36 +00:00
Jonathan Earl Brassow
46f0efbfce Fix bug 733400 - Mirror down conversion when specifying the secondary leg is broke
The operation of deactivating the residual error target LV after removing a
mirror layer can cause a "device in-use" conflict with udev.  Giving udev a
poke before calling deactivate_lv eliminates the conflict.  The stick used
to poke udev is 'sync_local_dev_names'.
2011-09-13 21:13:33 +00:00
Jonathan Earl Brassow
c94c47abd7 Fix for bug 737200 - Can't create mirrored-log mirror on a VG with small extents
Kernel requires a mirror to be at least 1 region large.  So,
if our mirror log is itself a mirror, it must be at least
1 region large.  This restriction may not be necessary for
non-mirrored logs, but we apply the rule anyway.

(The other option is to make the region size of the log
mirror smaller than the mirror it is acting as a log for,
but that really complicates things.  It's much easier to
keep the region_size the same for both.)
2011-09-13 18:42:57 +00:00
Jonathan Earl Brassow
f5e43f061a Better fix for bug 737125 - unable to create mirror on 1K extent size VG
WHATS_NEW entry:
Fix log size calculation when only a log is being added to a mirror.

The original fix pass the mirror LV to allocate_extents (rather than
passing NULL) so that _alloc_init could correctly determine the necessary
size of the mirror log.  In the previous check-in, I noted:
    In order to get a decent value computed, we need to pass in the 'lv' argument
    to allocate_extents.  This would normally imply a desire for cling/contiguous
    allocation to the given LV, but since we are not allocating any parallel
    extents and only log extents, it works fine.
However, passing in the LV did have unintended consequences on the placement of
the log.  The better solution is to pass in the number of extext that are in
the mirror LV instead of the LV itself.  This will not cause the allocator to
reserve that number of extents, because 'stripes' and 'mirrors' are specified
as 0.  Thus, 'extents' is used to calculate the size of the log, but won't
affect how much is allocated.
2011-09-13 18:11:38 +00:00
Jonathan Earl Brassow
0c89ef513a Changing RAID status flags to 64-bit broke some binary flag operations.
LVM_WRITE is a 32-bit flag.  Now that RAID[_IMAGE|_META] are 64-bit,
and'ing a RAID LV's status against LVM_WRITE can reset the higher order
flags.

A similar thing will affect thinp flags if not careful.
2011-09-13 16:33:21 +00:00
Jonathan Earl Brassow
cc9dc919e6 Fix for bug 737125 - unable to create mirror on 1K extent size VG
_alloc_init calculates the number of necessary log extents via
'mirror_log_extents'.  'mirror_log_extents' takes 3 arguments: region_size,
pe_size, and size of the mirror LV.  Unfortunately, _alloc_init is guessing at
the mirror size by using 'ah->new_extents / ah->area_multiple' - the number of
extents that the mirror images have.  However, this is /always/ wrong when
allocating the log separately.  Further, the log is always allocated separately
unless we are up-converting the mirror at the same time.  It was by luck alone
that a default value of '1' reflects what we want in most cases.

In order to get a decent value computed, we need to pass in the 'lv' argument
to allocate_extents.  This would normally imply a desire for cling/contiguous
allocation to the given LV, but since we are not allocating any parallel
extents and only log extents, it works fine.
2011-09-13 14:37:48 +00:00
Jonathan Earl Brassow
6d0aa801a0 Fix for bug 733114.
When an image is split from a 2-way mirror, the original mirror is converted to
a linear device.  To do this, the top "layer" must be removed.  The segments
are transferred from the sub-lv to the top-level LV and the link is severed.
The former sub-lv - having its segments transferred - now contains a temporary
error target.

When the original LV is resumed, the old sub-lv that now contains an error
segment is activated and scanned.  This is what causes the I/O error messages.
There are three ways to fix this problem:

1) Do not set the sub-lv which contains the error target as "visible" before
suspending the original LV.  This way, when the original is resumed, the sub-lv
device node is not created and it is not scanned - avoiding the error messages.
 The problem with this approach is that if the machine crashes after the
resume, it leaves the *hidden* LV in place and the user has a more difficult
time noticing that it needs to be cleaned up.  Thus, this type of processing is
frowned upon.

2) Do like _remove_mirror_images does and suspend the original, then suspend
the sub-lv (the error target), then resume the sub-lv, and finally resume the
original LV.  This seems like extra pointless operations to me, but it does not
produce the error message (although, I'm not sure why) and it allows us to
leave the visible flag in place.

3) Flag the sub-lv (error target) with a "do not scan" flag.  This seems like
the cleanest approach, but I have been unable to find the method for doing
this.  LVs get tagged in such a way by _get_udev_flags, but in this case the
resume of the original LV also resumes the error target LV without running it
through _get_udev_flags (likely because they are no longer linked).  Could
there be something wrong in resume_lv?

Option #2 was chosen to fix this bug, but it seems like more of a workaround
for now.
2011-09-13 13:59:19 +00:00
Alasdair Kergon
5081181b5d Append z to lv_attr if new blocks will be zeroed. 2011-09-09 01:15:18 +00:00
Alasdair Kergon
dbb48de507 Add a new 'thin_pool' output field to 'lvs.
A gentle reminder that anyone relying on the output of reporting commands
like lvs in scripts must use -o to guarantee they get the fields they expect.

The default sequence of fields can change from release to release.
Equally, the 'attr' fields can have new values introduced and/or characters
appended to them.
2011-09-09 00:54:49 +00:00
Alasdair Kergon
52e3f9dd5e Add 7th lv_attr char to show the related kernel target.
Add thin volume types to lv_attr.
2011-09-08 20:55:39 +00:00
Alasdair Kergon
ef78ebf35a lvcreate/remove thin_pool and thin volumes (--driverloaded n only) 2011-09-08 16:41:18 +00:00
Alasdair Kergon
1abaaab1bc Terminate pv_attr field correctly. (2.02.86) 2011-09-07 13:42:00 +00:00
Zdenek Kabelac
f32b76a193 Minor change for pv_create api
Switch int to unsigned type.
2011-09-07 08:34:21 +00:00
Alasdair Kergon
bb6f9b10db pool attach fns & more field renaming 2011-09-06 22:43:56 +00:00
Zdenek Kabelac
5a7926c7d9 Convert data->pool 2011-09-06 22:35:44 +00:00
Alasdair Kergon
b88362ff95 add thin_manip.c like the other manip files
move basic lv_is_* to macros
data_lv -> pool_lv - we decided to call it 'pool' everywhere now
2011-09-06 19:25:42 +00:00
Alasdair Kergon
2ef5b7cca6 Start using 64-bit status flags - most of the code already handles them.
tdata -> tpool
remove commented out definitions from metadata.h
formatting clean-ups
2011-09-06 18:49:31 +00:00
Alasdair Kergon
dd44cccefe else 2011-09-06 15:39:46 +00:00
Alasdair Kergon
afadb4628e tdata->tpool 2011-09-06 15:38:44 +00:00
Alasdair Kergon
9ac61d2ba2 lvcreate parsing for thin provisioning.
The rest is incomplete so this isn't usable yet.
2011-09-06 00:26:42 +00:00
Zdenek Kabelac
7aa56e8f90 Add missing 'static' for local function
Avoid missing prototype warning.
2011-09-02 12:38:43 +00:00
Alasdair Kergon
c05144b9ec temp notes on dealing with cascade 2011-09-02 01:59:07 +00:00
Alasdair Kergon
c82c2bebed Move cascade inside libdm etc.
Makes dumpconfig whole-section output wrong in a different way from before,
but we should be able to merge cft_cmdline properly into cmd->cft now and
remove cascade.
2011-09-02 01:32:08 +00:00
Alasdair Kergon
fe8f5dbeb7 Comments, FIXMEs, name changes. 2011-09-01 21:04:14 +00:00
Jonathan Earl Brassow
da23255cc9 Fix for bug 732142: Unsafe table load during mirror image split
There was a bad sequence:
*) Make changes to LV layout to split images (e.g. 4-way -> 2-way/2-way)
1) vg_write, suspend_lv(original_mirror), vg_commit
2) activate_lv(newly_split_lv)
3) resume_lv(original_mirror)

Step #2 is not allowed.  However, without it, the resume of the original
mirror will also resume its former sub-LVs - making it impossible to
activate the newly split LV due to the changes in layering, pointers, and
names that had already been made.  Additionally, the resume or the original
brings the sub-lv's online with names that differ from the metadata on disk -
also a no-no.  Thus, the split must be done in stages such that the active LVs
always reflect what is in the committed LVM metadata.

First, alter the original mirror by releasing the images.  The images are made
visible and independent as an intermediate stage.  (This way, we can have
consistency between LVM metadata and active LVs.)  The second stage collects
the recently split LVs, deactivates them, forms them into a mirror if necessary,
and then activates them.  It is a bit of a circuitous method, but it is the only
way to split a mirror from a mirror and obey these general rules:
1) Never [de]activate sub-lvs when the top-level LV is suspended
2) Avoid having active LVs that differ from the description in the LVM metadata

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2011-09-01 19:22:11 +00:00
Zdenek Kabelac
4ea01630ae Match the prototype old-style declaration 2011-09-01 13:30:11 +00:00
Zdenek Kabelac
08a95743a2 Keep the old-style prototypes 2011-09-01 13:25:50 +00:00
Zdenek Kabelac
3caa77f831 Use size_t return type
Since these function returns buffer size - use size_t type for them.
2011-09-01 10:25:22 +00:00
Zdenek Kabelac
466098cd1c Reflect dm_config API update 2011-09-01 10:16:32 +00:00
Petr Rockai
97a4b5165e Replace const usage of dm_config_find_node with more appropriate value-lookup
functionality. A number of bugs (copied and pasted all over the code) should
disappear:

- most string lookup based on dm_config_find_node would segfault when
  encountering a non-zero integer (the intention there was to print an
  error message instead)
- check for required sections in metadata would have been satisfied by
  values as well (i.e. not sections)
- encountering a section in place of expected flag value would have
  segfaulted (due to assumed but unchecked cn->v != NULL)
2011-08-31 15:19:19 +00:00
Petr Rockai
e59e2f7c3c Move the core of the lib/config/config.c functionality into libdevmapper,
leaving behind the LVM-specific parts of the code (convenience wrappers that
handle `struct device` and `struct cmd_context`, basically). A number of
functions have been renamed (in addition to getting a dm_ prefix) -- namely,
all of the config interface now has a dm_config_ prefix.
2011-08-30 14:55:15 +00:00
Peter Rajnoha
d35188058b Directly allocate buffer memory in a pvck scan instead of using a mempool.
There's a very high memory usage when calling _pv_analyse_mda_raw (e.g. while
executing pvck) that can end up with "out of memory".

_pv_analyse_mda_raw scans for metadata in the MDA, iteratively increasing the
size to scan with SECTOR_SIZE until we find a probable config section or we're
at the edge of the metadata area. However, when using a memory pool, we're also
iteratively chasing for bigger and bigger mempool chunk which can't be found
and so we're always allocating a new one, consuming more and more memory...

This patch just changes the mempool to direct memory allocation in this
problematic part of the code.
2011-08-29 13:37:36 +00:00
Alasdair Kergon
11bfaa1df8 same for segtype_is_thin 2011-08-26 18:17:05 +00:00
Alasdair Kergon
6fbf1c6b56 seg_is_thin includes both thin_pool and thin_volume 2011-08-26 18:15:14 +00:00
Alasdair Kergon
42914557d5 thin - hide unimplemented dso fn; remove duplicate origin_lv field; add
some lvcreate struct parms
2011-08-26 17:40:53 +00:00
Zdenek Kabelac
e82bd6249b Initial code for read/write of thin metadata lv segments 2011-08-26 13:37:47 +00:00
Zdenek Kabelac
9d32170d5c Add registration of thin_pool segment
Register thin and thin_pool segment via multiple_segtypes.
2011-08-25 10:00:09 +00:00
Alasdair Kergon
f9b92564a7 Fix raid shared lib segtype registration (2.02.87). 2011-08-24 13:41:46 +00:00
Zdenek Kabelac
3ba4a19510 Initial code layout for thin provisioning target
Only registers init_thin_segtype

Option --with-thin=internal needed for compilation.
For now useful only for developememt!
2011-08-24 08:27:49 +00:00
Alasdair Kergon
c31d14d786 Remove incorrect error message added in 2.02.87. 2011-08-19 22:55:07 +00:00
Alasdair Kergon
1d64dcfbf7 clarify comment 2011-08-19 19:35:50 +00:00
Alasdair Kergon
ba7df3de88 avoid multi-line calc with incorrect intermediate var contents 2011-08-19 16:41:26 +00:00
Alasdair Kergon
3250b38583 _ for static fns 2011-08-19 15:59:15 +00:00
Jonathan Earl Brassow
a2facf4ad4 Add ability to merge back a RAID1 image that has been split w/ --trackchanges
Argument layout is very similar to the merge command for snapshots.
2011-08-18 19:43:08 +00:00
Jonathan Earl Brassow
f439e65b64 Add support for m-way to n-way up-convert in RAID1 (no linear to n-way yet)
This patch adds the ability to upconvert a raid1 array - say from 2-way to
3-way.  It does not yet support upconverting linear to n-way.

The 'raid' device-mapper target allows for individual components (images) of
an array to be specified for rebuild.  This mechanism is used when adding
new images to the array so that the new images can be resync'ed while the
rest of the images in the array can remain 'in-sync'.  (There is no
mirror-on-mirror layering required.)
2011-08-18 19:41:21 +00:00
Jonathan Earl Brassow
6d04311efa Add the ability to split an image from the mirror and track changes.
~> lvconvert --splitmirrors 1 --trackchanges vg/lv
The '--trackchanges' option allows a user the ability to use an image of
a RAID1 array for the purposes of temporary read-only access.  The image
can be merged back into the array at a later time and only the blocks that
have changed in the array since the split will be resync'ed.  This
operation can be thought of as a partial split.  The image is never completely
extracted from the array, in that the array reserves the position the device
occupied and tracks the differences between the array and the split image via
a bitmap.  The image itself is rendered read-only and the name (<LV>_rimage_*)
cannot be changed.  The user can complete the split (permanently splitting the
image from the array) by re-issuing the 'lvconvert' command without the
'--trackchanges' argument and specifying the '--name' argument.
	~> lvconvert --splitmirrors 1 --name my_split vg/lv
Merging the tracked image back into the array is done with the '--merge'
option (included in a follow-on patch).
	~> lvconvert --merge vg/lv_rimage_<n>

The internal mechanics of this are relatively simple.  The 'raid' device-
mapper target allows for the specification of an empty slot in an array
via '- -'.  This is what will be used if a partial activation of an array
is ever required.  (It would also be possible to use 'error' targets in
place of the '- -'.)  If a RAID image is found to be both read-only and
visible, then it is considered separate from the array and '- -' is used
to hold it's position in the array.  So, all that needs to be done to
temporarily split an image from the array /and/ cause the kernel target's
bitmap to track (aka "mark") changes made is to make the specified image
visible and read-only.  To merge the device back into the array, the image
needs to be returned to the read/write state of the top-level LV and made
invisible.
2011-08-18 19:38:26 +00:00
Jonathan Earl Brassow
a324baf6a1 Add --splitmirrors support for RAID1 (1 image only)
Users already have the ability to split an image from an LV of "mirror"
segtype.  This patch extends that ability to LVs of "raid1" segtype.

This patch only allows a single image to be split off, however.  (The
"mirror" segtype allows an arbitrary number of images to be split off.
e.g.  4-way => 3-way/linear, 2-way/2-way, linear,3-way)
2011-08-18 19:34:18 +00:00
Jonathan Earl Brassow
63d32fb6a6 When down-converting RAID1, don't activate sub-lvs between suspend/resume
of top-level LV.

We can't activate sub-lv's that are being removed from a RAID1 LV while it
is suspended.  However, this is what was being used to have them show-up
so we could remove them.  'sync_local_dev_names' is a sufficient and
proper replacement and can be done after the top-level LV is resumed.
2011-08-18 19:31:33 +00:00
Jonathan Earl Brassow
4903b85d23 Compiler warning fixes, better error messaging, and cosmetic changes.
1) add new function 'raid_remove_top_layer' which will be useful
to other conversion functions later (also cleans up code)
2) Add error messages if raid_[extract|add]_images fails
3) Add function prototypes to prevent compiler warnings when
compiling with '--with-raid=shared'
2011-08-13 04:28:34 +00:00
Jonathan Earl Brassow
a22515c87f Various code clean-ups (s/malloc/zalloc/, new msgs, etc)
Fix a couple more issues that kabi found.
- Add some error messages in failure cases
- s/malloc/zalloc/
- use vg->vgmem for lv names instead of vg->cmd->mem
2011-08-11 21:32:18 +00:00
Jonathan Earl Brassow
2100c90dd7 Add missing checks for function return codes.
Some functions were being called without having their return values checked.
2011-08-11 19:38:00 +00:00
Zdenek Kabelac
4afdf187a1 Trivial, add void to ignore dm_snprinf result 2011-08-11 19:21:42 +00:00
Alasdair Kergon
40dbaac892 pre-release fixes incl make distclean and configure --with-raid=none/shared 2011-08-11 19:18:17 +00:00
Jonathan Earl Brassow
b2fa9b43dc Add some log_error msg's and fix potential segfault
Thanks to kabi for spotting these - especially the possibility for
segfault if a loop runs all the way through without finding a match.
2011-08-11 19:17:10 +00:00
Jonathan Earl Brassow
4aebd52c4c Add ability to down-convert RAID1 arrays.
Also, add some simple RAID tests to testsuite.
2011-08-11 18:24:40 +00:00
Zdenek Kabelac
cf98c05082 Add detect_internal_vg_cache_corruption to lvm.conf
Add config option to enable crc checking of VG structures.
Currently it's disabled by default.

For the internal test-suite this check it is enabled.

Note: In the case the internal error is detected, debug build with
compile option DEBUG_ENFORCE_POOL_LOCKING helps to catch the source
of the problem.
2011-08-11 17:46:13 +00:00
Zdenek Kabelac
031c986ea8 Lock memory for shared VG
Use debug pool locking functionality. So the command could check,
whether the memory in the pool has not been modified.

For lv_postoder() instead of unlocking and locking for every changed
struct status member do it once when entering and leaving function.
(mprotect would trap each such memory access).
Currently lv_postoder() does not modify other part of vg structure
then status flags of each LV with flags that are reverted back to
its original state after function exit.
2011-08-11 17:34:30 +00:00
Zdenek Kabelac
bb115a7a6c Cache and share generated VG structs
Extend vginfo cache with cached VG structure. So if the same metadata
are use, skip mda decoding in the case, the same data are in use.
This helps for operations like activation of all LVs in one VG,
where same data were decoded giving the same output result.

Patch adds 1-to-1 connection between volume_group and lvmcache_vginfo.
2011-08-11 17:24:23 +00:00
Peter Rajnoha
47d7f00e16 Fix possible format instance memory leaks and premature releases in _vg_read. 2011-08-11 16:31:40 +00:00
Peter Rajnoha
d183554c72 Suppress locking error messages in monitoring init scripts. 2011-08-11 15:27:46 +00:00