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

566 Commits

Author SHA1 Message Date
Peter Rajnoha
787200efd6 Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. 2011-09-22 17:36:50 +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
Peter Rajnoha
14254bd0be Add dm_device_has_holders fn to to check use of the device by another device.
Add dm_device_has_mounted_fs fn to check mounted filesystem on a device.

This requires sysfs directory to be correctly set via dm_set_sysfs_dir
(/sys by default). If sysfs dir is not used or it's set incorrectly,
dm_device_has_{holders,mounted_fs} will return 0!
2011-09-22 17:23:35 +00:00
Peter Rajnoha
07e237d6f4 Add dm_set_sysfs_dir to libdevmapper to set sysfs location.
Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set.
2011-09-22 17:17:07 +00:00
Peter Rajnoha
355b2224b2 Add dm_task_retry_remove fn to use retry logic for device removal.
This call ensures that the dm device removal is retried several
times before failing.
2011-09-22 17:09:48 +00:00
Zdenek Kabelac
6fe315d412 Fix memory overwrite
Transfer of build_dm_uuid() function into libdm made uuid_prefix as parameter,
thus sizeof() was replaced with strlen() and room for '\0' missed.

As it's only fix in current version - no whatsnew.
2011-09-14 16:07:07 +00:00
Peter Rajnoha
8171b93700 Retry DM_DEVICE_REMOVE ioctl if device is busy.
This is a workaround for long-lasting problem with using the WATCH udev
rule. When trying to remove a DM device, this one can still be opened
while processing the event in parallel (generated based on the WATCH
udev rule).

Let's use this until we have a proper solution.
2011-09-13 15:13:41 +00:00
Zdenek Kabelac
beecb1e160 Remove unused passed parameters 2011-09-07 08:37:48 +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
Alasdair Kergon
79b9c65b6b Add comments & remove always-included header. 2011-09-01 17:58:27 +00:00
Zdenek Kabelac
441edcb50a Use const casting when it's needed
Keep the lookup operation const and use const casting at the dm_ function level.
2011-09-01 14:02:05 +00:00
Zdenek Kabelac
2d70959c86 Mark unreleased memory pools as internal error 2011-09-01 10:19:01 +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
e68a6fbf20 Fix warnings and constness handling in lvmetad-core (adjusting the
dm_config_find_node to give non-const node pointer, since that better reflects
the contract of that function).
2011-08-31 12:39:58 +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
Alasdair Kergon
40e5fd8b3a spaces->tabs 2011-08-19 17:02:48 +00:00
Alasdair Kergon
c3d985c3ad revert incomplete inconsistent log message change for now 2011-08-19 16:49:00 +00:00
Alasdair Kergon
415c0690af restrict dm_tree_node_add_null_area 2011-08-19 16:26:02 +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
Zdenek Kabelac
5bedb7a5e0 Fix memleak of geometry buffer
Looks like this function is not used too often - thus leak was discovered
by static analyzis (Coverity).
2011-08-11 20:49:33 +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
Zdenek Kabelac
ed463ccf51 Add memory pool locking functions
Adding debuging functionality to lock and unlock memory pool.

2 ways to debug code:
crc - is default checksum/hash of the locked pool.
      It gets slower when the pool is larger - so the check is only
      made when VG is finaly released and it has been used more then
      once.Thus the result is rather informative.

mprotect - quite fast all the time - but requires more memory and
           currently it is using posix_memalign() - this could be
	   later modified to use dm_malloc() and align internally.
           Tool segfaults when locked memory is modified and core
	   could be examined for faulty code section (backtrace).

Only fast memory pools could use mprotect for now -
so such debug builds cannot be combined with DEBUG_POOL.
2011-08-11 17:29:04 +00:00
Alasdair Kergon
2061c0ec24 Remove support for the original dm ioctl interface version 1.
Leave the basic support for multiple versions in case we have a new version
in future.
2011-08-09 17:56:47 +00:00
Zdenek Kabelac
b23975ee28 Add missing check for allocation failure
Static analyzer discovered missing check.
2011-08-04 17:56:11 +00:00
Zdenek Kabelac
586f310618 Remove meaningless const type qualifiers on cast type
Static analyzis noticed we do not really need them - so removing.
2011-08-04 14:30:51 +00:00
Jonathan Earl Brassow
cac52ca4ce Add basic RAID segment type(s) support.
Implementation described in doc/lvm2-raid.txt.

Basic support includes:
- ability to create RAID 1/4/5/6 arrays
- ability to delete RAID arrays
- ability to display RAID arrays
Notable missing features (not included in this patch):
- ability to clean-up/repair failures
- ability to convert RAID segment types
- ability to monitor RAID segment types
2011-08-02 22:07:20 +00:00
Alasdair Kergon
d3efe22fa2 Fix read-only identical table reload supression. 2011-07-24 23:59:03 +00:00
Alasdair Kergon
b6793963e9 Downgrade error message - it isn't strictly an internal error in the
library, and the known cause within lvm2 got fixed.
2011-07-08 19:13:05 +00:00
Alasdair Kergon
32b7009196 Log cookie values when incrementing/decrementing to give clues about races. 2011-07-08 15:34:47 +00:00
Alasdair Kergon
f92e31558b decode cookie flags in debug msgs 2011-07-05 16:17:14 +00:00
Alasdair Kergon
ba45e1fdee Report internal error if suspending a device using an already-suspended dev.
This catches the recent pvmove problem trapping I/O between layers.
2011-07-02 01:17:09 +00:00
Alasdair Kergon
2243718fae Add framework for validation of ioctls. Doesn't do any checks yet.
dmsetup --checks
libdevmapper: dm_task_enable_checks()
lvm.conf: activation/checks=1
2011-07-01 14:09:19 +00:00
Zdenek Kabelac
812e10ac60 Report internal error when parameters are missing on table load
When some target is passing empty parameters to some dm target,
report this as an internal error to better catch some broken
table construction (some mirror conversions seem to be doing
this for now).
2011-06-30 09:24:58 +00:00
Alasdair Kergon
7cc4a70487 debug log readonly flag with ioctls 2011-06-29 16:08:33 +00:00
Alasdair Kergon
600dc4168c Remove temporary failures now, but continue to give INTERNAL_ERROR. 2011-06-29 11:36:37 +00:00
Alasdair Kergon
9591e7ede1 Temporary conversion to internal error and failure, to see how many
instances of this problem this flushes out.
2011-06-29 08:54:13 +00:00
Alasdair Kergon
7b5e4dcf1f more fixes to readahead etc. 2011-06-28 09:24:13 +00:00
Alasdair Kergon
9032898eb1 Extend debug log messages to distinguish between the 3 states:
trust udev; verify udev; perform dev node operations directly.
2011-06-27 22:38:53 +00:00
Alasdair Kergon
0437bccc3c Move udev_only logic inside stacked node op code.
(We still need to treat add+readhead+del as a no-op.)
Rename udev_fallback to verify_udev_operations.
Rename --udevfallback to --verifyudev
2011-06-27 21:43:58 +00:00
Alasdair Kergon
f4249251cb Return immediately dm_lib_exit() if called more than once.
(Avoiding calling it twice would involve some untangling.)
Decrement the new suspended_counter if removing a suspended device.
2011-06-24 19:33:41 +00:00
Peter Rajnoha
901e7257d1 Add check for library fallback in _deactivate_node.
This fn calls rm_dev_node directly - an exceptional case. It needs to check
the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag directly (it's called in dm_task_run
normally where it's checked already).
2011-06-22 12:56:02 +00:00
Alasdair Kergon
98a0fa72be Fix fields in warning message. 2011-06-13 03:53:02 +00:00
Alasdair Kergon
1840aa0974 Maintain a count of the number of suspended devices in libdevmapper
and use this for the LVM critical section logic.  Also report an error if
code tries to load a table while any device is known to be in the
suspended state.
(If the variety of problems these changes are showing up can't be fixed
before the next release, the error messages can be reduced to debug
level.)
2011-06-13 03:32:45 +00:00
Alasdair Kergon
83e797bc52 Fix 'pvs -o pv_all' to include label fields. (Also removed recursion.) 2011-06-12 19:49:40 +00:00
Alasdair Kergon
0a99713ea4 Fix --mirrorlog mirrored. 2011-06-11 12:55:31 +00:00
Alasdair Kergon
df390f1799 Major pvmove fix to issue ioctls in the correct order when multiple LVs
are affected by the move.  (Currently it's possible for I/O to become
trapped between suspended devices amongst other problems.

The current fix was selected so as to minimise the testing surface.  I
hope eventually to replace it with a cleaner one that extends the
deptree code.

Some lvconvert scenarios still suffer from related problems.
2011-06-11 00:03:06 +00:00
Milan Broz
b39fdcf45b Fix another occurrence of linux kernel version check. 2011-06-09 15:52:59 +00:00