1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-17 09:49:28 +03:00

Compare commits

...

6475 Commits

Author SHA1 Message Date
c615046eec Call built-in blkid conditionaly (udev version >= 176), call standard blkid
with full path otherwise.
2012-02-20 19:38:40 +00:00
a742ee8b37 pre-release 2012-02-20 19:38:19 +00:00
bd746876ee Check whether udev supports built-in blkid.
Built-in blkid is supported since udev v176 - set the UDEV_HAS_BUILTIN_BLKID
variable appropriately so we can use it in the rules to call the built-in
blkid conditionaly.
2012-02-20 19:36:27 +00:00
a2e5d2cb9c Switch to using built-in blkid in 13-dm-disk.rules.
Available in udev since version 176.
2012-02-16 14:39:02 +00:00
b0fe3642c8 Drop the now-redundant pvid_to_status hash. 2012-02-15 17:37:09 +00:00
a0289c969f Update lvmetad: use device major/minor pair to track devices. Keep a pvmeta
config tree per PV which is mostly provided by the client, so it can be used to
keep track of things like label_sector, PV format, mda count / offsets and so
on.
2012-02-15 17:30:07 +00:00
d6463f4890 Initialize dmeventd monitoring for every command
Read lvm.conf setting for monitoring for each command. So we should not
activate monitoring if the default compilation is set to monitor during
lvconvert commnads.

Patch also removes check for  clustered VG and allows to disable monitoring
for clustered VG with the assumption, the problem with monitoring and dmeventd
flag passing for INGNORE is already fixed.
2012-02-15 15:18:43 +00:00
8da4309f07 typo 2012-02-15 15:10:31 +00:00
f71e484598 Add watch rule to 13-dm-disk.rules.
We don't have anything better yet...

The problems the watch rule caused when removing devices should be covered
now with the "retry remove" logic. It's also better to have this maintained
by us, rather than having this rule anywhere else without proper control.
2012-02-15 14:50:33 +00:00
d11718e479 Simplify with dm_strdup 2012-02-15 14:27:53 +00:00
580b0e871d Run tests with lvmetad if we have it. 2012-02-15 14:24:31 +00:00
d7a47a354f Fix segfault in dmsetup when using table specification with --table.
Segfault introduced with the patch that added dm_free(_table) at the
end of dmsetup (in this release).
2012-02-15 14:20:59 +00:00
351c6b96b8 (lvmetad) Remove unused variable. 2012-02-15 14:15:50 +00:00
cc3552f4a8 In lvmetad, also nuke VGs when all their PVs are stolen by another VG (vgmerge
& vgsplit do this).
2012-02-15 14:06:48 +00:00
735a00a152 Detect failing fifo
If the fifo died because of dmeventd restart - do not wait for 20s
in select  - it will not get better and return error immediately.
2012-02-15 13:56:47 +00:00
aaf717039e Deal with slower test processing
If the merge was faster then query - deal with it and pass the test.
2012-02-15 13:51:17 +00:00
397d2bfe89 Initialize monitoring support only for thin pools 2012-02-15 13:49:51 +00:00
eb9e8f8e3d Update cut&paste error message 2012-02-15 13:46:54 +00:00
a872331404 Turn a warning to an error in vgreduce --removemissing, since we exit with a
failure status there.
2012-02-15 12:30:46 +00:00
9fc640ffd9 Add dmsetup manpage entries for mangle command and --manglename option. 2012-02-15 12:25:23 +00:00
c0b2521a82 Add DM_DEFAULT_NAME_MANGLING_MODE env. variable to override configured value.
Just in case of emergency when name mangling code causes any problems so
we can override the default value and switch off the mangling globally.
2012-02-15 12:23:15 +00:00
17696422b6 Replace any '\' char with '\\' in table specification on input.
Device-mapper in kernel uses '\' as escape character so it's better
to double it to avoid any confusion when using existing device names
with '\' in the table specification.

For example:

dmsetup create x --table "0 8 linear /dev/mapper/a\x20b 0"

should pass just fine now without a need to explicitly escape the '\' char
like this:

dmsetup create x --table "0 8 linear /dev/mapper/a\\x20b 0"
2012-02-15 12:17:34 +00:00
7f024cf822 Add mangle command to dmsetup to provide renaming to correct mangled form. 2012-02-15 12:08:57 +00:00
f2e7993792 Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o. 2012-02-15 12:06:17 +00:00
5a923ff8ad Add --manglename option to dmsetup to select the name mangling mode. 2012-02-15 12:02:58 +00:00
9ec1097099 Unamngle dm device name list automatically on ioctl return.
If dm_task_get_name or dm_task_get_names gets called, these will return
unmangled form of the names so the name mangling stays totally transparent
to any libdevmapper user (unless DM_STRING_MANGLING_NONE is used in which
case the name is not touched and it is is returned as it is in kernel).

For example:

dmsetup create "a b" - will create a\x20b device in kernel and so udev will
create /dev/mapper/a\x20b

dm_task_get_name/names will still return "a b"

In AUTO mode, the libdevmapper user can still query the device by using
the mangled ("a\x20b") or unmangled form of the name when calling dm_task_set_name.
If mangled name is provided, it's detected and the name is kept as it is.
If unmangled name is provided, it will be mangled. IOW in AUTO mode it's
totally transparent and it should not require any changes in the code
using libdevmapper.

However, any libdevmapper user must be aware of the fact that the mangled form
of the name appears in /dev/mapper (udev just can't deal with those blacklisted
characters).
2012-02-15 12:01:28 +00:00
4ec2657ac3 lvmetad server-side update:
- rename the hashes to be explicit about the mapping
- add VG/PV listing calls to the protocol
- cache slightly more of the per-PV state
- filter cached metadata
- compare the metadata upon metadata_update
2012-02-15 11:43:06 +00:00
9d5d312d82 Add dm_task_get_name_mangled/unmangled to libdevmapper.
dm_task_get_name_mangled will always return mangled form of the name while
the dm_task_get_name_unmangled will always return unmangled form of the name
irrespective of the global setting (dm_set/get_name_mangling_mode).

This is handy in situations where we need to detect whether the name is already
mangled or not. Also display functions make use of it.
2012-02-15 11:39:38 +00:00
111b6717b6 Add DEV_NAME macro.
Use the DEV_NAME macro to use the mangled form of the name if present,
use normal name otherwise (we store both forms - mangled and unmangled in
struct dm_task). Mangled form should be always preferred over unmangled
with the exception of the situations where we divide one task into several
others (like "create and load") - we need to avoid mangling the name twice
(because of multiple dm_task_set_name calls)!
2012-02-15 11:33:53 +00:00
3ffe9aa27d Mangle device name on dm_task_set_name/newname call if necessary.
If dm_task_set_name/newname is called, the name provided will be
automatically translated to correct encoded form with the hex enconding
so any character not on udev whitelist will be mangled with \xNN
format where NN is hex value of the character used.

By default, the name mangling mode used is the one set during
configure with the '--with-default-name-mangling' option.
2012-02-15 11:27:01 +00:00
8a12e5a359 autoreconf 2012-02-15 11:20:12 +00:00
cd4fce855e Add configure --with-default-name-mangling.
This option configures the default name mangling mode used, one of:
AUTO, NONE and HEX.

The name mangling is primarily used to support udev character whitelist
(0-9, A-Z, a-z, #*-.:=@_) so any character that is not on udev whitelist
will get translated into an encoded form \xNN where NN is the hex value
of the character.
2012-02-15 11:17:57 +00:00
017c0c9e8c Do not forget to initialise the error value in daemon_reply. 2012-02-15 09:14:54 +00:00
d6afd3e0fc Fix pool names of the format1/format_pool orphan VGs. 2012-02-15 01:44:58 +00:00
d05bfd3265 In the test harness, do the back-substitution (@TESTDIR@, @PREFIX@) also on the
live VERBOSE output, not just the post-mortem dumps.
2012-02-15 01:31:10 +00:00
4847399243 Make conversion from a synced 'mirror' to 'raid1' not cause a full resync.
It was not possible to pass down the DM_[FORCE|NO]SYNC flags to
'dm_tree_node_add_raid_target'.  This meant that converting to 'raid1' from
'mirror' would cause a full resync.  (It also meant that '--nosync' was
ineffective when creating a 'raid1' LV.)

I've taken the 'reserved' parameter in 'dm_tree_node_add_raid_target' and
used it for the "flags" parameter.  Now it is possible to pass the sync
flags and any other flags that may come up.
2012-02-13 20:13:39 +00:00
d6f91a013b Change confusing message that is printed when a RAID device fails.
s/Issue/Use/, otherwise it is easy to misread "Issue" as "Issuing" - causing
the user confusion as to whether the action was performed automatically or
whether they need to issue the command.
2012-02-13 18:38:36 +00:00
7daa233e48 Fix possible NULL pointer dereferences when updating mirror log.
'_lv_update_log_type' takes a lvconvert_params argument so that it can pass
down the user's preference of 'region_size' and allocation_policy.  When
'mirror_remove_missing' was introduced (commit ID
95986e42a1) it didn't make sense to pass down
user preferences - so NULL was given instead.  While it may never happen in
practice, static analysis reveals that this argument could be dereferenced.
So, if the user preferences were not passed in, glean the necessary fields
from what is already set in the LV.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

(Not updating WHATSNEW for this simple clean-up.)
2012-02-13 18:36:55 +00:00
9159aec6f1 Fix bug that caused RAID devices to be unable to activate if sub-LV was missing.
Commit 02f6f4902f introduced a bug that caused
RAID devices to fail to activate if the device for a single sub-LV failed.
The special case of LVM mirror was handled, but not LVM RAID.
EXAMPLE:
[root@bp-01 ~]# devices vg
  LV            Copy%  Devices
  lv            100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0]        /dev/sde1(1)
  [lv_rimage_1]        /dev/sdh1(1)
  [lv_rmeta_0]         /dev/sde1(0)
  [lv_rmeta_1]         /dev/sdh1(0)
[root@bp-01 ~]# vgchange -an vg
  0 logical volume(s) in volume group "vg" now active
[root@bp-01 ~]# off.sh sdh
Turning off sdh
[root@bp-01 ~]# vgchange -ay vg --partial
  Partial mode. Incomplete logical volumes will be processed.
  Couldn't find device with uuid fbI0YO-GX7x-firU-Vy5o-vzwx-vAKZ-feRxfF.
  Cannot activate vg/lv_rimage_1: all segments missing.
  0 logical volume(s) in volume group "vg" now active

AFTER this patch:
[root@bp-01 ~]# vgchange -ay vg --partial
  Partial mode. Incomplete logical volumes will be processed.
  Couldn't find device with uuid fbI0YO-GX7x-firU-Vy5o-vzwx-vAKZ-feRxfF.
  1 logical volume(s) in volume group "vg" now active
[root@bp-01 ~]# devices vg
  Couldn't find device with uuid fbI0YO-GX7x-firU-Vy5o-vzwx-vAKZ-feRxfF.
  LV            Copy%  Devices
  lv            100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0]        /dev/sde1(1)
  [lv_rimage_1]        unknown device(1)
  [lv_rmeta_0]         /dev/sde1(0)
  [lv_rmeta_1]         unknown device(0)
[root@bp-01 ~]# dmsetup table vg-lv; dmsetup status vg-lv
0 1024000 raid raid1 3 0 region_size 1024 2 253:2 253:3 - -
0 1024000 raid raid1 2 AD 1024000/1024000

No WHATSNEW update necessary because this is an intrarelease fix.

 brassow
2012-02-13 17:59:21 +00:00
c5d7b90b2a Superfluous '/' in systemd_dir path. 2012-02-13 17:31:14 +00:00
35d3d400ec Fix missing temp_buf init for error path
In previous commit this was missing, also deallocate in reversed order.
2012-02-13 14:39:24 +00:00
0d38ef9273 Add internal error to guard vgname2 NULL dereference 2012-02-13 14:26:15 +00:00
2b62c3ed69 Add some FIXME around allocation code
Remove also unreachable break..
2012-02-13 14:25:14 +00:00
cc05bde071 Never try to test character past given buffer
In case units[0] would be already '\0', do not check units[1].
2012-02-13 14:23:40 +00:00
27d46fc686 Make sure dereferenced words[0] and words[1] are defined 2012-02-13 14:17:04 +00:00
07d54dd4a7 Add configure --with-systemdsystemunitdir. 2012-02-13 13:02:47 +00:00
e975f85035 Handle all succefull values from open() 2012-02-13 12:07:51 +00:00
c868f0ebf0 Ensure allocated device does not leak on error path
For unimplementd canonicalize_file_name set to NULL
2012-02-13 12:06:39 +00:00
5a4638e22b Add internal error for unsupported code paths
Patch mainly helps static analyzers to better work with code paths
lvm code should never trigger.
2012-02-13 11:25:56 +00:00
afed769d42 Check for missing reply_uuid 2012-02-13 11:24:09 +00:00
a140caa666 Check for allocation failure 2012-02-13 11:18:45 +00:00
dab4bb3bdf Add check for allocation failure 2012-02-13 11:16:42 +00:00
2833f81fb3 Add few missing allocation failures tests 2012-02-13 11:13:44 +00:00
bbf912b644 Add check for rimage name allocation failure 2012-02-13 11:10:37 +00:00
05e8ec79e0 Add check for mda_copy failure 2012-02-13 11:09:25 +00:00
78188982d6 Add check for failure 2012-02-13 11:07:55 +00:00
6890aea4ca Add free_orphan_vg
Move commod code to destroy orphan VG into free_orphan_vg() function.
Use orphan vgmem for creation of PV lists.
Remove some free_pv_fid() calls (FIXME: check all of them)
FIXME: Check whether we could merge release_vg back again for all VGs.
2012-02-13 11:03:59 +00:00
b2b5a2268a If the same fid is already same avoid ref_counting 2012-02-13 11:01:34 +00:00
5ca11ba420 Add missing test for failure of lvmcache_foreach_pv 2012-02-13 10:58:20 +00:00
c227ad23cc Clean error paths for format instance
With updated orphan VG code this code needed some updates.
Add missing log_error for allocation failures.
2012-02-13 10:56:31 +00:00
5dc08c01d3 Release_vg instead of plain free in error path 2012-02-13 10:53:31 +00:00
ec6a14f40a Log error reporting for failing _alloc_pv
Drop unneeded zeroing of zalloced memory region.
2012-02-13 10:51:52 +00:00
7cf73cbc1f Do not write to -1 buffer address
In case of zero bytes would be read from sysfs, it would store '\0' on
temp_buf[-1] address.

Simplify some buffer length calculation and use strcpy if we've just
checked string fits in give buffer.

Replace jump label error: with bad: commonly used in libdm.
2012-02-13 10:49:28 +00:00
193c832d12 Remove duplicit test
When it's space it's also not a '\0'.
2012-02-13 10:45:26 +00:00
82e18a35a9 Update autoconf. 2012-02-13 07:30:24 +00:00
69b9a614c7 In the new corosync world, dlm is a standalone service.
Fix clvmd init script to Require dlm service when building for the
new corosync or clvmd will fail to start.
2012-02-13 05:24:57 +00:00
52fdced782 post-release 2012-02-13 00:23:21 +00:00
2a7e2fe2d3 pre-release 2012-02-12 23:02:52 +00:00
3b6c6f1319 FMT_INSTANCE_VG is redundant now 2012-02-12 23:01:19 +00:00
11b3b12336 FMT_INSTANCE_PV is no longer used 2012-02-12 22:37:24 +00:00
b8a4a2b40b use stack consistently if 0 is considered an error 2012-02-12 21:42:43 +00:00
3e15add713 missing error mesg 2012-02-12 21:37:03 +00:00
06eaf8974a remove unused bits after fid changes 2012-02-12 20:19:39 +00:00
4ceec2023f give standard error message if lstat fails unexpectedly 2012-02-12 20:17:12 +00:00
777a797ec3 Fix message check
Check pointer from strchr for NULL instead of crash later.
Badly formated message would have crash dmeventd otherwise.
2012-02-10 15:17:52 +00:00
c559180cca Check for deps pointer before dererence
As _deps() call may return NULL - check for it.
2012-02-10 14:48:28 +00:00
9fde529762 Add validation of name and uuid
Do not accept NULL pointers.
2012-02-10 14:42:28 +00:00
50504ab73e Do not crash for NULL sort_key
Guard against NULL pointer for sort_key and let it behave like an empty
string would have been passed in (i.e. no key).
2012-02-10 14:00:07 +00:00
514976816d Return error for failing allocation
Fix case, where final strdup would have failed and it would miss to return
failure for this case and return success and NULL pointer.
2012-02-10 13:56:19 +00:00
00067fb64a Add test for failing allocation
Avoid memcpy to NULL if realloc fails.
2012-02-10 13:52:05 +00:00
f6aab411f8 Add test for memory allocation failures
Replace asserts with test for failing memory allocation.
Add at least stack traces.
Index counter starts from 1 (0 reserved for error), so replacing fingerprint.
2012-02-10 13:49:29 +00:00
c966f07bbd Remove unreachable code 2012-02-10 13:46:23 +00:00
e8ada4a717 What's new. 2012-02-10 02:56:54 +00:00
14d7b7b4e9 Keep a global (per-format) orphan_vg and keep any and all orphan PVs linked to
it. Avoids the need for FMT_INSTANCE_PV and enables further simplifications. No
functional change, internal refactor only.
2012-02-10 02:53:03 +00:00
395ee036d7 What's new: lvmcache. 2012-02-10 01:29:46 +00:00
1a28df6bb4 Move lvmcache data structures behind an API (making the structures private to
lvmcache.c). No functional change.
2012-02-10 01:28:27 +00:00
2936951d94 Stop processing lvextend if trying to extend a mirror that is being recovered.
Missing correct return value in lv_extend fn.
2012-02-09 15:13:42 +00:00
e98b640d5d Move label_init up in code stack
label_exit() is called destroy_toolcontext() and we are now
using standard dm_list function for destroy, we have to make sure
dm_list gets initialized properly.
2012-02-08 13:44:49 +00:00
6d29fe0f33 Thin add pool_below_threshold
Test both data and metadata percent usage.
2012-02-08 13:05:38 +00:00
5365e4a53f A bit more readable code
Just a minor readability conversion.
2012-02-08 13:03:40 +00:00
70e3728446 Fix test for lv_snapshot_percent
Do not check for PERCENT_MERGE_FAILED if the lv_snapshot_percent() failed.
(test for snap_percent would be testing uninitialized value).
2012-02-08 13:02:07 +00:00
0cb3bdcfce Drop unreachable code 2012-02-08 12:59:45 +00:00
d735798674 Use dm_asprintf to simplify code 2012-02-08 12:59:19 +00:00
74c7c69d34 Some fixmes
'len' calculation is unused ?
Unreachable code could be removed or moved upward ?
2012-02-08 12:57:15 +00:00
7ce534f911 Switch to return void
List delete cannot fail, so there is no reason to test for error.
2012-02-08 12:52:58 +00:00
f03f322f13 Use dm_snprintf and improve error handling
Add standard error reporting with error logging.
Use plain alloc instead of zalloc for string buffer.
Use dm_snprintf with valid test for <0.
2012-02-08 12:50:10 +00:00
c929a0b3c8 Add range test for device number
Check the output of atoi is in valid range.
2012-02-08 12:48:14 +00:00
6bea32ccf2 Remove duplicate test
Tested condition has been already evaluated before
For strlen() code has already excluded <ID_LEN.
For repairing, already tested (!argc && !repairing) before.
2012-02-08 11:41:18 +00:00
84facc4fa5 Replace snprintf with dm_snprintf
snprintf testing for negative is replaced with dm_snprintf where this
test really works.
Add missing test for result of dm_snprintf().
2012-02-08 11:40:02 +00:00
7940545204 Remove unneeded assignments
Variables have (or will have) those values set.
2012-02-08 11:36:18 +00:00
cc525412f1 Keep page_size as signed number
Since it's return value from sysconf and is checked for <0.
2012-02-08 11:34:46 +00:00
962fd76f26 Move done jump lower
Since before 'goto done' is bufused zeroed, it would otherwise write 1
byte in front of buffer.
2012-02-08 11:31:29 +00:00
6e40adde76 Add boundary test for number of mirror devs and logs
As atoi may return negative value - test for both limits.
Test log_args for limits before calling alloca().
Code from dmeventd mirror plugin should probably share same code as
we have in mirrored.c.
2012-02-08 11:29:13 +00:00
fb6a209080 Set all parameters to 0
Since the function dm_get_next_target() returns NULL as 'next' pointer
so it's not a 'real' error - set 0 to all parameters when NULL is
returned because of missing head.

i.e. one of use case::
do {
	next = dm_get_next_target(dmt, next, &start, &length,
				  &target_type, &params);
	size += length;
} while (next);
2012-02-08 11:25:09 +00:00
e6b610e8ed Check that whole locking_dir fits _lock_dir buffer 2012-02-08 11:17:34 +00:00
bb0862fbb4 Move close few lines
Since the function dev_close() has code path, which really could close
file (for unlocked vg) and destroy dev handler, stay on safe side and move
the close few lines later, even our current use case shouldn't trigger
such scenario.
2012-02-08 11:15:38 +00:00
e2d2f6c7b7 Use dm_list_iterate_items_safe
And avoid direct access to list member variables.
Inline _free_li().
2012-02-08 11:12:18 +00:00
e48d39cba0 Fix fd resource leak in error path
Use 'goto bad' to cleanup fd on error path.
2012-02-08 11:07:17 +00:00
4443aa41cc Ensure strncpy() function always ends with '\0'
Since last character needs to be \0 for string,
pass buffer size smaller by 1 byte.
2012-02-08 11:05:04 +00:00
24da0046d5 Set status for error path
Do not leave status unitialized, since in some cases, it's tested,
when the function returns error.
2012-02-08 10:56:17 +00:00
8d9b4b0133 Add missing deps for lvm2api
Hmm, wasted some time because of this missing deps....
2012-02-08 10:52:45 +00:00
328ed80160 Fix resource leaks for failing allocation
In case, something would fail during format initialization,
return allocated memory.
2012-02-08 10:49:36 +00:00
582c94aa21 Release allocated resources in error path
If composite_filter_create() fails, release filters.
2012-02-08 10:46:24 +00:00
38188ff8aa Check result of lstat
If lstat returns errno different from ENOENT, do not use the content of
struct stat 'buf'.
2012-02-08 10:43:42 +00:00
c84c7ee034 What's new. 2012-02-01 20:13:44 +00:00
a3ac5a54d0 Remove a dubious log message ("another thread is handling an event") from LVM
dmeventd plugins. Fixes RHBZ 771419.
2012-02-01 20:11:58 +00:00
b93aa9eac4 post-release 2012-02-01 18:46:57 +00:00
d8e7d0e2bd pre-release 2012-02-01 15:17:04 +00:00
759f5b3349 Adjust comments 2012-02-01 15:05:53 +00:00
433c583cd7 Add synchornization point in mirror log init.
Put extra sync point when mirror log is deactivated and before
it's activated for the second time.
2012-02-01 13:50:36 +00:00
02f6f4902f Disable partial activation for thin LVs and LVs with all missing segments
Count number of error and existing areas and if there is no existing area
for the LV avoid its activation.

Always disable partial activatio for thin volumes.

For mirrors currently put in hack to let it pass with a special name
since current mirror code needs to activate such LV during some operations.
2012-02-01 13:47:27 +00:00
90fd0f5b42 Avoid warning for small pv_min_size
Do not print warning for pv_min_size set in range between 512KB and 2MB.
2012-02-01 13:42:18 +00:00
56f6e9310d Clean up systemd unit ordering and requirements. 2012-02-01 13:08:39 +00:00
8bec4f1a79 Minor consistency update for debugging messages
Use mlock/munlock for debugging lines.
2012-02-01 10:48:22 +00:00
f00a162500 User correct base dir for lcov reports
Fix problem when srcdir != builddir.
2012-02-01 10:46:45 +00:00
1228bcaa0d lost line 2012-02-01 02:11:43 +00:00
b94b757e1e Track unreserved space for all alloc policies and then permit NORMAL to place
log and data on same single PV.
2012-02-01 02:10:45 +00:00
49fd0fef6b lp.pool may be (null) too 2012-02-01 01:54:20 +00:00
8416129244 Automatically detect whether corosync clvmd needs to use confdb or cmap. (fabio) 2012-01-31 21:21:53 +00:00
b329581e8e Fix data% reporting
For reading % of mapped size of thin volume use as origin for
old style snapshot '-real' device needs to be queried.
Fix log_error report given for lvs -a in this case.
2012-01-28 20:12:26 +00:00
0117473049 TARGETS macro has to be defined before inclusion of make.tmpl
Use @TESTING@ check in this case.
2012-01-27 10:55:02 +00:00
09e8d81a53 post-release 2012-01-27 01:23:40 +00:00
317325ed54 Build test run target only for $(TESTING)
Add libraries properly in LDLIBS.
2012-01-26 21:40:36 +00:00
6f9deb5b47 Thin for_each_sub_lv
Adapt to scan thin dependency LVs
2012-01-26 21:39:32 +00:00
21fc2af47e If clvmd is not started, die test instead of skipping it 2012-01-26 18:25:46 +00:00
3d0906496b Oops missed braces in previous commit
This has disabled clvmd for being executed.
(FIXME improve testing part to catch this fault)
2012-01-26 17:55:55 +00:00
f47f37485e pre-release 2012-01-26 14:02:42 +00:00
3876196da4 pre-release 2012-01-26 10:11:30 +00:00
808f1706c2 Cosmetic change use return macro with implicit stack 2012-01-25 22:38:40 +00:00
0f5dc427f6 Set missing header define 2012-01-25 22:37:48 +00:00
28de76ed58 Fix leak of hash table
Minor leak on command initialization.
2012-01-25 22:36:33 +00:00
4e9ef2eea3 Instrument code that pointer are already released
Set pointers to NULL since on the function exit they are no longer valid.
2012-01-25 22:35:36 +00:00
a1f42a8e88 Set to a defined value vars used after error path
Static analyzer noticed this vars are used even when error is reported
back thus their state is undefined - set to 0 for this case.
2012-01-25 22:20:11 +00:00
baffb459d8 Test for uname result
in fail path initialize to 0.
2012-01-25 22:17:57 +00:00
381deeed8f Fix missing dmt destructor
Also always initialize maj,min,patchlevel when success is returned.
2012-01-25 22:16:04 +00:00
6f37aa5e65 Free allocated segment type in error path 2012-01-25 21:54:00 +00:00
4343bc5e86 Limit alignment to 32bit values
to get the same behavior on 32/64 machines.
2012-01-25 21:52:53 +00:00
255e8cb60b Ensure whole info is initialised
Since _create_dm_tree_node is copying whole structure,
make sure all members are initialized.
2012-01-25 21:50:50 +00:00
6bd7f256ae Fix resource leak of file handle
Introduces when added dm_device_get_name.
Close file handle in all error paths.
2012-01-25 21:47:18 +00:00
5d1d269f45 Check for correctness of uint64 value if exists 2012-01-25 21:43:51 +00:00
e152c0b9e6 Add breaks for cases 2012-01-25 21:42:09 +00:00
cd55e7238a Ensure reply struct has all fields defined
Reply is returned by value.
2012-01-25 21:31:59 +00:00
dfac9aef46 Check and print perror for syscalls 2012-01-25 21:30:27 +00:00
1835cb731d & -> && 2012-01-25 17:14:56 +00:00
ab418f0317 Fix compilation with disabled devmapper
During release preparation things has changed, so making sure
we are compilable with --disable-devmapper.
2012-01-25 13:12:59 +00:00
4fb4548a57 Thin read percent info from layered device
Since we only need layered device - check for tpool device presence,
so user doesn't need to activate thin pool explicitely for percent info.
2012-01-25 13:11:52 +00:00
ec2012f736 Rename origin_only to more generic use_layer flag
Since now we have more layered devices i.e. thin volumes - support
selection of layer via flag.
2012-01-25 13:10:26 +00:00
93903e1edf Clean var declarations to the front of the function 2012-01-25 13:06:57 +00:00
500806dda9 Update verbose lvs to print metadata_percent info
Update lvs  -o fields in WHATS_NEW.
2012-01-25 11:32:41 +00:00
7e134dfb8e Thin clear stacked message for thin pool
Before removing thin pool LV always make sure, stacked message
for previous run are cleared - but allow to remove any
device that should have been created
(i.e. creation of snapshot failed - so the message for snapshot creation
may be replaced with delete message within unfinished transaction).

Also commit messages after lv remove - so free space is released in pool.
2012-01-25 11:27:42 +00:00
dee7712483 Make commented out code more obvious 2012-01-25 11:10:06 +00:00
cfd3d9413b Thin skip activation when there are no thin message
If the list with thin messages is empty, do not touch thin pool device.
2012-01-25 09:17:15 +00:00
5feef4f92b Thin correct activation order
When the message is passed only in resume path the order needs
to be corrected.
2012-01-25 09:15:44 +00:00
9644179f39 Thin use suspend/resume_lv_origin
Use origin_only support for thin volume when thin snapshot is created.
2012-01-25 09:14:25 +00:00
9142bc74bb Thin use origin_only for thin pools as well
Extend the usage of origin_only flag to allow resume of thin pool LV
(when it's active) to pass only the messages.

origin_only flag will skip detection of already resumed tree for thin_pool,
so we do not need to suspend the tree and we just send messages.
2012-01-25 09:13:10 +00:00
9518d362ab Thin add support for origin_only suspend of thin volumes
Pass in the origin_only flag also for thin volumes - but curently the flag
is not used to its best.

FIXME: achieve the state where only  thin volume snapshot origin is
suspended without its childrens -  let's explore whether this may
happen automatically inside libdm (might be generic for other targets).
So the code would not need to annotate the node for this.
2012-01-25 09:10:13 +00:00
529267fe5d Thin add messages only for activation tree
Extend lv_activate_opts with bool flag to know for which purpose
dtree is created - and add message only for activation tree
(since that's the only place that may send them).

Extend validation check for thin snapshot creation and test whether
active snapshot origin is suspended before its snapshot is created
(useful in recover scenarios) -  in this case also detect, whether
transaction has been already completed and avoid such suspend check
failure in that case.
2012-01-25 09:06:43 +00:00
c3606d4127 Thin check for lv_thin_pool_percent error status
Check has been missing.
2012-01-25 09:02:35 +00:00
d7a3cf4744 Update lv_info whats_new 2012-01-25 09:00:57 +00:00
fd3e9e102d lv_info using -real layer only for origin_only LV
If the origin_only flag is passed for non lv_is_origin LVs,
the extension is not added.

Thin volumes may also use origin_only flag.
2012-01-25 09:00:18 +00:00
7264da9af1 Thin prevent removal of its data and metadata LVs
LVs cannot be removed while there are linked to thin pool.
(Gives better error message, than validation).
2012-01-25 08:57:25 +00:00
c0f8f6270e Thin fix transaction_id incrementation and code refactoring
Add pool_has_message and use it in attach_pool_message.
Also update header to make more obvious which segment type is
expected as parameter.
Rename  'read_only' to  'no_update' (no auto update transaction_id)
to better fit how it's used.
Fix problem when there was only one stacked message replaced with delete
message that caused unwanted transaction_id increase.
2012-01-25 08:55:19 +00:00
13c67c55af Comment cleanups
Move comment where it applies and remove unused attribe when the var
is actually used.
2012-01-25 08:51:29 +00:00
538e7737d2 Thin dependency scan support
Go through pool_lv and metadata_lv LVs when doing recursive scan.
2012-01-25 08:50:10 +00:00
f72b203392 Thin add lv_thin_pool_transaction_id
Easy function to get transaction_id status value.
2012-01-25 08:48:42 +00:00
ea617ea71c Thin send messages on activation resume code path
Using PRELOAD part would lead to problems when the problem
would happen before vg_write and vg_commit.
Also this change is necessary for snapshot creation sequence.
2012-01-25 08:46:21 +00:00
b05ae8b950 Caller is still entitled to reference an LV that's unlinked, so don't
tamper with struct contents.
2012-01-24 14:53:59 +00:00
cb09dc1274 Use suspend|resume_origin_only when up-converting RAID LVs, as mirrors do.
Failure to do so results in "Performing unsafe table load while X device(s) are
known to be suspended" errors.  While fixing the problem in this way works and
is consistent with the way the mirror segment type does it, it would be nice
to find a solution that uses the generic suspend/resume calls.

Also included in this check-in are additions to the test suite that perform
conversions on RAID LVs under a snapshot.  These tests are disabled for the
time being due to a kernel bug that is yet to be tracked down.
2012-01-24 14:33:38 +00:00
6979dccd79 Properly show LV removal message.
(Fix regression in commit 6e181ba96d)
2012-01-24 14:15:52 +00:00
0942afa35d Use chunk_size consistently for thin_pool within LVM. 2012-01-24 00:55:03 +00:00
fe5199c506 Fix the way RAID meta LVs are added to the dependency tree.
Similar to the "mirror" segment type's log device, _add_dev_to_dtree should
be called and not _add_lv_to_dtree when adding metadata sub-LVs to the deptree.
Since _add_lv_to_dtree was being called, 'origin_only' could be set if a
snapshot sits on top of the RAID device.  This would cause the actual device
that needed to be added to be skipped in favor of the non-existant device,
"<foo>-real".
2012-01-23 20:56:42 +00:00
ea9d0a19ca Fix metad help. 2012-01-23 17:48:18 +00:00
f41e4fba91 add const 2012-01-23 17:47:36 +00:00
7c979db7a9 Reorder fns in libdm-deptree.
Tweak dm_config interface and remove FIXMEs.
2012-01-23 17:46:31 +00:00
efa33f0b49 Add CLVMD_FLAG_REMOTE to skip processing on local node. 2012-01-21 05:31:54 +00:00
5aa7a0ec1c Attempt to improve clustered 'lvchange -aey' behaviour to try local node before
remote nodes and address some existing anomalies.
2012-01-21 05:29:51 +00:00
7281c3ab01 Prompt if request is made to remove a snapshot whose "Merge failed". 2012-01-20 22:04:16 +00:00
27393d999c Allow removal of an invalid snapshot that was to be merged on next activation.
Don't allow a user to merge an invalid snapshot.
2012-01-20 22:03:48 +00:00
2ff68cece1 Use m and M lv_attr to indicate that a snapshot merge failed in lvs.
snapshot (m)erge failed, suspended snapshot (M)erge failed
2012-01-20 22:03:03 +00:00
c25ad6e873 Differentiate between snapshot status of "Invalid" and "Merge failed". 2012-01-20 22:02:04 +00:00
e756b80f56 Lookup snapshot usage percent of origin when a snapshot is merging. 2012-01-20 21:56:01 +00:00
079473f10a Update lvdisplay to show more info about thin LVs
Reformat name and path how the LV is represented with lvm1 compatible option,
to switch to the old way - which had number of  problem - i.e. many links
do not exist - since for private devices we are not creating them.
Add more info about thin pools and volumes.
2012-01-20 16:59:58 +00:00
ba92f67e23 Minor cleanup
Simplier and more readable char pointer math.
2012-01-20 11:01:56 +00:00
e1eeb8e908 Thin until proper vgcfgrestore for thin is implementad, disable restore.
Since it may probably do more harm to leave it enabled - add extra test
for presence of thin volumes in VG, and in this case disable restore.
2012-01-20 11:01:13 +00:00
76b1e2d9b1 Thin forgotten initialisation of pointer to NULL
Since the code may go in error path, set to defined NULL.
2012-01-20 10:59:26 +00:00
8aa66458a3 Tiny cleanup
Just remove double braces from conditions when they are not really needed.
(So it doesn't look like an assignment and comparison).
2012-01-20 10:58:17 +00:00
9abe5853b2 Thin cleanup
Reorder condition so the code is better readable (and shorter).
2012-01-20 10:56:30 +00:00
a563ef56b8 Drop hack in segtype reporting
Since striped name function knows when to report 'linear' instead of
'stripe' type name - drop it from this place.

This fixes problem when reporting segtype e.g. for thin-pool which
is also using area_count=1 to store thin data device reference.

It also returns properly strduped memory instead of badly casted const char*.
2012-01-20 10:55:28 +00:00
3486e8332d Thin extend lvcreate man page about snapshot support 2012-01-20 10:50:39 +00:00
cf22ba1971 . 2012-01-20 03:56:18 +00:00
3e8e48f9d0 improve comment 2012-01-20 03:46:52 +00:00
6bcd3263c2 Preserve exclusive activation of cluster mirror when converting.
This patch to the suspend code - like the similar change for resume -
queries the lock mode of a cluster volume and records whether it is active
exclusively.  This is necessary for suspend due to the possibility of
preloading targets.  Failure to check to exclusivity causes the cluster target
of an exclusively activated mirror to be used when converting - rather than
the single machine target.
2012-01-20 00:27:18 +00:00
f7a26917f2 Drop unimplemented 2012-01-19 16:22:42 +00:00
946166795e Drop unused variable 2012-01-19 15:59:51 +00:00
62fa6a8289 Thin indent update 2012-01-19 15:42:18 +00:00
8aa21348d1 Thin disable snapshot creation when pool is over the threshold.
Since snapshot needs to suspend origin - it might lead to pool userspace
deadlock (as the pool will wait for new space in case it would be overfilled,
but dmeventd would not be able to resize it, as the lvcreate operation would
have kept the VG lock.)
To minimize the risk of such scenario - we prevent to create new snapshot
in case we are over the threshold - but beware, there is still small timewindow,
so keep threshold at some reasonable level!
2012-01-19 15:39:41 +00:00
8d3933945a Thin add new display field for lvs
New field Data% is able to display info about
thin_pool, thin, snapshot and has generic meaning here.

Simple Time/Host field are here to display host and time creation.
2012-01-19 15:34:32 +00:00
06849a0d6a Add support to keep info about creation time and host for each LV
Basic support to keep info when the LV was created.
Host and time is stored into LV mda section.

FIXME: Current version doesn't support configurable string via lvm.conf
and used fixed version strftime "%Y-%m-%d %T %z".
2012-01-19 15:31:45 +00:00
491d106031 Thin add function to read thin volume percent
This value returns percentage of 'mapped' size compared with total LV size.
(Without passed seg pointer it return highest mapped size - but it's
not used yet.)
2012-01-19 15:27:54 +00:00
9fae965546 Thin updated support for thin pool percent
Support to check also for metadata percent
(By checking whether seg pointer is set)
2012-01-19 15:25:37 +00:00
57979a273c Thin rename seg var pool_metadata_lv to metadata_lv
Better fits the code.
2012-01-19 15:23:50 +00:00
4174dad301 Thin handle empty thin volume case
Report both values as 0 in case the volume is unused.
2012-01-19 15:22:32 +00:00
a1224b2da8 Thin use consistentely metadata
Do not shortcut to 'meta' and stay with 'metadata'
Also matches kernel doc for dm API then.
2012-01-19 15:21:23 +00:00
440a4d4c76 Thin rename local static
Use '_' for local const char.
2012-01-19 15:19:18 +00:00
3a55acee5b Rename internal macro to match signess
Since _read_int64 called dm_config_get_uint64, rename it to
less confusing _read_uint64.
2012-01-19 15:17:46 +00:00
dd0fc6d3a8 Update for gcc old-style 2012-01-19 15:16:39 +00:00
5c9bebee8a Add dmsetup 'wipe_table' to replace table with one that uses error target. 2012-01-18 18:52:02 +00:00
de0822a2bf Move dm_task_set_newname from libdm-iface.c to libdm-common.c 2012-01-17 14:36:58 +00:00
693e6e76a9 Beef up the lvmetad code with more functionality and a bunch of bugfixes. There
used to be a few mis-ordered memory accesses (release and access in the next
block). Fix that set_flag could have sometimes corrupted the flags being
modified.

A few issues with metadata tracking are sorted out as well now, and there are
only a few problems remaining before we can integrate lvmetad, mostly on the
client side:

- metadata areas need to be tracked in lvmetad (most likely to be addressed
  through an extension of metadata, meaning no special support in lvmetad would
  be needed)
- non-udev scanning code needs to be taught about telling lvmetad about device
  disappearance (pvscan most importantly)
- this last item also needs to mesh with metadata inconsistencies and
  suddenly-incomplete volume groups (aux disable_dev in tests); udev-based
  scanning should address this separately and more elegantly
2012-01-16 08:25:32 +00:00
5463a05a32 Fix a boundary condition in read_buffer in daemon-shared.c. 2012-01-16 05:09:16 +00:00
e3b4fe6ed2 Fix prototypes for daemon_send_simple (const char). 2012-01-15 15:16:50 +00:00
921de583f4 Unfortunately, blank lines are sometimes produced by config serializer, and
this interferes with their role as message separator in the lvmetad
protocol. Switch to using "##" on an otherwise blank line as a separator.
2012-01-15 11:17:16 +00:00
e31a3a6da6 Fix a couple of resource leaks in daemon-common server code -- filehandles and
unjoined threads were leaked for each connection.
2012-01-15 10:33:41 +00:00
55bdb63f34 Make error message hit when preallocated memlock memory exceeded clearer. 2012-01-12 18:29:07 +00:00
75fe459800 Show read-only activation in display tools. 2012-01-12 16:58:43 +00:00
5bafde0b6f Missing const.
"warning: assignment discards 'const' qualifier..."
2012-01-12 09:08:55 +00:00
57fafd762f Add activation/read_only_volume_list to override LV permission in metadata. 2012-01-12 02:32:09 +00:00
642da16c33 Add activation/read_only_volume_list to override LV permission in metadata. 2012-01-12 01:51:56 +00:00
661f154b66 Give priority to emcpower devices with duplicate PVIDs. 2012-01-11 20:38:42 +00:00
8227bf45d1 Support different device name types on output of dmsetup deps, ls and info -c command.
Add 'blkdevname' and 'blkdevs_used' field to dmsetup info -c -o.
Add 'blkdevname' option to dmsetup ls --tree to see block device names.
Add '-o options' to dmsetup deps and ls to select device name type on output.
2012-01-11 12:46:19 +00:00
ad96b1b460 Add dm_device_get_name to get map name or block device name for given devno.
This is accomplished by reading associated sysfs information. For a dm device,
this is /sys/dev/block/major:minor/dm/name (supported in kernel version >= 2.6.29,
for older kernels, the behaviour is the same as for non-dm devices).

For a non-dm device, this is a readlink on /sys/dev/block/major:minor, e.g.
  /sys/dev/block/253:0 --> ../../devices/virtual/block/dm-0.
The last component of the path is a proper kernel name (block device name).

One can request to read only kernel names by setting the 'prefer_kernel_name'
argument if needed.
2012-01-11 12:34:44 +00:00
ee1e9fcd22 Add dm_uuid_prefix/dm_set_uuid_prefix for non-lvm users to override hard-coded
LVM- prefix.

Try harder not to leave stray empty devices around (locally or remotely) when
reverting changes after failures while there are inactive tables.
2012-01-10 02:03:31 +00:00
7da3845926 Check for error code in _adjust_policy_params
If error is detected in _adjust_policy_params, break further command processing.
2012-01-09 12:31:52 +00:00
8a3960d217 Minor oldstyle warning update 2012-01-09 12:29:15 +00:00
99a1830b46 Improve readahead in dmsetup man page 2012-01-09 12:28:47 +00:00
6cf41f5503 Use sysfs to set/get of read-ahead
If we know major:minor number of device (which is known after resume) we will
try to use  sysfs to set/get read ahead parameters of device.
This avoid potential problem of blocking commands like 'dmsetup info' awaiting
for device being usable for open/close - i.e. overfilled thin pool may block
such command.
2012-01-09 12:26:14 +00:00
51c8cf97af Support rounding of percentage upward
We want to keep this logic -
when LV is extend - extend the LV by at least given amount,
when LV is reduced - reduce the LV by at most given amount.

So for this the rounding needs to be used.
Current logic which seems to satisfy give rule is to round up all
extent values for LV resize upward except for values with '-' sign
that are round downward.

This patch also fixes the problem when  lvextend --use-polices tried
to extend LV the by i.e. 20% - but the resulting 20% were smaller
the extent size thus before this patch no extension happened.
2012-01-05 15:38:18 +00:00
46a75dedb4 Use new dmeventd_lvm2_command function in dmeventd plugins.
For snapshot, prepare whole command in front into private buffer.
Add also some missing '\n' for syslog messages.
For raid and mirror only convert creation of command line string.
This should avoid any unbound growth of mempool for dm_split_names.
2011-12-22 16:37:01 +00:00
f4cb382829 Thin use helper function
Fix some minor outstading issue from thin plugin introduction -
Call dmeventd_lvm2_exit() in failpath for registration.
Add some missing '\n' in syslog messages.
2011-12-22 15:57:29 +00:00
c06fdae782 Add helper function dmeventd_lvm2_command().
Since this code is in all plugins - create a common helper function.
2011-12-22 15:55:21 +00:00
47bc4f5191 Updated documentation for dmeventd.
Update man page style.
Mention raid and thin plugins.
Update help text printed by command to match man page.
2011-12-22 15:50:38 +00:00
52eae5fec2 Thin man page update 2011-12-21 13:58:38 +00:00
d3e0fc4374 Thin update test case
Use thin-pool instead of thin_pool type.
2011-12-21 13:45:42 +00:00
e906e9a160 Exported functions from thin plugin 2011-12-21 13:42:07 +00:00
9e1ccf81c7 Drop extra stat before open of device
Since the !(dev->flags & DEV_REGULAR) code path just called
dev_name_confirmed() which has just called 'stat()' inside,
remove duplicate second stat() call here.
2011-12-21 13:24:24 +00:00
88f8cbbb2e Do not lstat common path prefix
When both path have identical prefix i.e. /dev/disk/by-id
skip  2 x lstat() for /dev  /dev/disk /dev/disk/by-id
and directly lstat() only different part of the path.

Reduces amount of lstat calls on system with lots of devices.
2011-12-21 13:21:09 +00:00
235028bf0f Add common initialization code for struct device
Avoid duplicate code and add _dev_init() where all common
member values are initialized.
2011-12-21 13:17:54 +00:00
93bb35fd2b Always zalloc device structure
Since there is zalloc behind the macro, put 'z' into the name.
Make the 'use_malloc' code path also using zalloc() call,
so it also give zeroed area.
2011-12-21 13:14:54 +00:00
d3923ece3d Thin automatic policy based extension 2011-12-21 13:10:52 +00:00
58044875a8 Thin add lv_thin_pool_percent 2011-12-21 13:10:05 +00:00
88bf72d388 Thin add dev_manager_thin_pool_percent
dev manager function to read percent info from thin pool.
2011-12-21 13:09:33 +00:00
59bcd5a1cf Thin add dmeventd support
This is basic version with still few unresolved issue mainly in case,
when the pool resize is failing.
2011-12-21 13:08:11 +00:00
b0f1e29335 Fix missing thread list manipulation
For manipulation with thread list to avoid race with timeout thread,
take also _timeout_mutex.
2011-12-21 13:03:06 +00:00
1b9a70b6af Check lv pointer for NULL before derefence. 2011-12-21 12:59:22 +00:00
d0b237f46c Thin remove unused code 2011-12-21 12:56:45 +00:00
0857bdba0f Thin move layer suffix into local static const 2011-12-21 12:55:22 +00:00
a1e1561a91 Thin rename internal thin pool segment
Use matching name as kernel target - useful when function like
_percent is using this for validation.
2011-12-21 12:54:19 +00:00
219fa54fd4 Add Thin API for parsing thin status
Add dm_get_status_thin_pool and dm_get_status_thin functions to
parse 'params' argument which is received via dm_get_next_target.

Returns filed structure allocated from given mempool.
2011-12-21 12:52:38 +00:00
2b61011439 Allow empty strings for description and creation_host config fields 2011-12-21 12:49:00 +00:00
6298758992 Add dm_config_find_str_allow_empty
Support empty string values.
2011-12-21 12:47:44 +00:00
14a165bf3f Reinstate support for format1 snapshots, but issue deprecated warning.
I anticipate removing support for snapshots with lvm1-formatted metadata in a
future release.
2011-12-20 00:02:18 +00:00
a9ac026781 Add a unit test for config cascade (overlay). Needs expanding though. 2011-12-18 23:56:36 +00:00
27949793ae Fix up lvmetad for the minor API change in dm_config_create. 2011-12-18 22:31:10 +00:00
e4de6d2ee0 Make a cleaner split between config tree and config file functionality. Move
the latter out of libdm.
2011-12-18 21:56:03 +00:00
dc1d4e2444 Use also normalized output for vgchange command in lvm2-monitor init script. 2011-12-16 11:42:56 +00:00
6b864994f3 Cleanup test compile warning
Add some declaration and cast to cleanup gcc warnings.
Add missing dm_config_destroy() to cleanup pool leak report.
2011-12-13 12:08:42 +00:00
55f7917356 Fix a compiler warning. 2011-12-12 00:08:23 +00:00
2d4b741115 Use a more canonic regex escaping in the default lvm.conf file for testing. 2011-12-12 00:01:12 +00:00
bd7ec82f64 Move dm_config_write out of libdm, back to lib/config, as config_write. 2011-12-11 23:18:20 +00:00
b3d86a26a6 Add a shell test for config parsing and merging (lvm dumpconfig). 2011-12-11 23:14:37 +00:00
cd143dc253 Autoreconf. 2011-12-11 17:24:37 +00:00
b82e7a4fcd Add a unit test for dm_config_clone_node. 2011-12-11 15:45:14 +00:00
7a17af253d Start a rudimentary unit test for the dm_config_* interface. 2011-12-11 15:19:41 +00:00
6d6b259fc0 In the dm_config_*get_* functions, make the actual value retrieval optional
(useful for just checking that a given key is of a given type).
2011-12-11 15:18:32 +00:00
1b068ee26b Use pkg-config to look for CUnit (needed for systems where it's not on the
standard include path).
2011-12-11 15:15:57 +00:00
c3c9864ed0 Nowadays, lvm-version.h is generated from lvm-version.h.in, and lives in the
build directory, not the source one -> fix test/shell/000-basic.sh.
2011-12-10 14:55:31 +00:00
9f2e5eee45 update FIXMEs 2011-12-10 00:47:23 +00:00
042d98b2d2 When dropping the VG metadata from the cache during a VG revert, we must
reset the 'precomitted' flag, just as we'd clear if we next did a 'commit'.
2011-12-08 23:18:00 +00:00
721119a388 Only use built-in stack size in clvmd - ignore lvm.conf. 2011-12-08 21:24:08 +00:00
4403e98eba Test for LCK_CLUSTER_VG directly in args[0].
Drop unused LCK_LOCAL from debug msg.
2011-12-08 18:32:33 +00:00
5495ef8217 Don't pass LCK_LOCAL to clvmd - it's unused.
Pass LCK_CLUSTER_VG in args[0] instead of args[1].
2011-12-08 18:19:05 +00:00
a830fcbc34 Update comments. CLUSTER_VG belongs firmly to args[0]. 2011-12-08 18:09:48 +00:00
58d9230ce2 reinstate !first_time check
(recovery from first_time failure would need different code)
2011-12-08 18:06:33 +00:00
aa8e6be045 tag uninit var 2011-12-08 18:00:03 +00:00
999263f18d Fix lvm2-monitor init script to use normalized output when using vgs. 2011-12-07 12:29:41 +00:00
49d06db518 Add policy based automated repair of RAID logical volumes
The RAID plug-in for dmeventd now calls 'lvconvert --repair' to address failures
of devices in a RAID logical volume.  The action taken can be either to "warn"
or "allocate" a new device from any spares that may be available in the
volume group.  The action is designated by setting 'raid_fault_policy' in
lvm.conf - the default being "warn".
2011-12-06 19:30:15 +00:00
15af345602 Fix FIXME and comment :-) 2011-12-03 11:36:10 +00:00
cbea400d06 Switch locking bits to match RHEL5 version.
FIXME:
There is a problem with overloaded bit 0x80 in locking flag,
the bit flags array must be extended or changed.
2011-12-03 11:34:35 +00:00
8344acfa2d update old comment 2011-12-01 14:57:30 +00:00
80924bc9ff Don't allow two images to be split and tracked from a RAID LV at one time
Also, don't allow a splitmirror operation on a RAID LV that is already tracking
a split, unless the operation is to stop the tracking and complete the split.
Example:
~> lvconvert --splitmirrors 1 --trackchanges vg/lv /dev/sdc1
# Now tracking changes - image can be merged back or split-off for good
~> lvconvert --splitmirrors 1 -n new_name vg/lv /dev/sdc1
# ^ Completes split ^

If a split is performed on a RAID that is tracking an already split image and
PVs are provided, we must ensure that
 1) the already split LV is represented in the PVs
 2) we are careful to split only the tracked image
2011-12-01 00:21:04 +00:00
824ec24322 Don't allow size change of RAID LV that is tracking changes for a split image
Don't allow size change of RAID sub-LVs independently
2011-12-01 00:13:16 +00:00
64b817cbc6 Do not allow users to change the name of RAID sub-LVs or the name of the
RAID LV if it is tracking changes for a split image.
2011-12-01 00:09:34 +00:00
37e5e5e9c2 WHATS_NEW for previous commit. 2011-12-01 00:05:40 +00:00
78b7b7db1a Do not allow users to change permissions on RAID sub-LVs. 2011-12-01 00:04:21 +00:00
b24e58c0ea refer to kernel docs for target info
FIXME thin still missing
2011-11-30 22:32:37 +00:00
8d884c5894 Update comment on LCK_*DMEVENTD*. 2011-11-30 17:02:37 +00:00
7dd63d8ff2 Fix clvmd to respect DMEVENTD_MONITOR_IGNORE. Fixes a bug where dmeventd
actions caused clvmd to turn off monitoring of the volume causing the action.
2011-11-30 17:00:57 +00:00
204aaf2253 The LV_REBUILD flag is not internal - bad comments in metadata-exported.h updated 2011-11-30 02:20:13 +00:00
02941f999c Support the ability to replace specific devices in a RAID array.
RAID is not like traditional LVM mirroring.  LVM mirroring required failed
devices to be removed or the logical volume would simply hang.  RAID arrays can
keep on running with failed devices.  In fact, for RAID types other than RAID1,
removing a device would mean substituting an error target or converting to a
lower level RAID (e.g. RAID6 -> RAID5, or RAID4/5 to RAID0).  Therefore, rather
than removing a failed device unconditionally and potentially allocating a
replacement, RAID allows the user to "replace" a device with a new one.  This
approach is a 1-step solution vs the current 2-step solution.

example> lvconvert --replace <dev_to_remove> vg/lv [possible_replacement_PVs]

'--replace' can be specified more than once.

example> lvconvert --replace /dev/sdb1 --replace /dev/sdc1 vg/lv
2011-11-30 02:02:10 +00:00
bb69784719 Fix last checkin for replicator. 2011-11-29 12:10:38 +00:00
52a9ed70c4 Add activation/use_linear_target enabled by default. (prajnoha)
LVM metadata knows only of striped segments - not linear ones.
The activation code detects segments with a single stripe and switches
them to use the linear target.

If the new lvm.conf setting is set to 0 (e.g. in a test script), this
'optimisation' is turned off.
2011-11-28 20:37:51 +00:00
8ec116a6b8 Try longer sleep
Seems like testing machine could be busy - so 10s might not be enough
for rechecking status.
2011-11-23 15:27:14 +00:00
a9b96bc87a Cleanup files from testing
Cleanup generated files from coverage testing.
Do not skip standard .o compilation for lib/not and lib/harness.
Make a bit longer string in harness to fit new shell/ in.
2011-11-23 14:56:47 +00:00
078b23379e Swap condition order
Swap condtion so the make line does not return 'false'.
Remove cleanup of lvm2api.sh since it is not created anymore.
2011-11-23 13:03:57 +00:00
cde518be8b Put back devmapper-event linkage
Older systems are not able to get this library from lvm2api library and need
this library to be passed to the linker (i.e. Debian Lenny).
2011-11-23 13:02:17 +00:00
57781b3c41 Cleanup test makefiles
Simplify /api makefile and use SUBDIRS target for test dir.
Properly cleanup Makefiles with distclean in /test.
Use symbolic links for shell scripts for non-srcdir compilation.
2011-11-23 12:21:41 +00:00
95abf92593 Split gcc warning options
Use gcc warning options only for .c -> .o compilation
So it makes the output more clear.

Do not use INCLUDES and DEFS for .o -> .so.

Do not use CFLAGS for deps .d generation.
2011-11-23 12:19:23 +00:00
fcc74c44e0 Use 3 digits for chmod
Use same sized chmod params (0 are filled from left on its own)
and we use just 3 digits elsewhere.
2011-11-23 12:18:42 +00:00
f0509623ce Move y/n prompts to stderr and repeat if response has both 'n' and 'y'.
(Note that in a future release we might make this stricter and insist
on exactly 'y' or 'n'.)
2011-11-23 01:34:38 +00:00
4a927fd6db --addtag instead of --tag 2011-11-22 13:54:05 +00:00
2e72b04376 Cleanup gcc warning
bitset_t.c:39: warning: 'last' may be used uninitialized in this function

Compiler is not smart enough to see the code path which avoid using
unitialized 'last'.
2011-11-21 13:15:40 +00:00
d66df1becc Add some cflags to ldflags
Things like gcov needs the compilation flags for linker as well.
TODO: cleanup compilation flags usage
2011-11-21 13:11:03 +00:00
3ab1c64a47 More of WHATS_NEW. 2011-11-21 12:44:38 +00:00
72a4b0eada Update WHATS_NEW. 2011-11-21 12:33:56 +00:00
e0c7b65690 Fix a bug in dmeventd snapshot monitoring code where the monitoring threshold
would grow with subsequent snapshot extensions (RHBZ 754198).
2011-11-21 12:31:18 +00:00
13f9043a35 Fix the last fix (t-XXX -> shell/XXX). 2011-11-21 11:36:53 +00:00
9aa1e40276 Fix the fallout in shell tests from the t-XXX -> shell/XXX move. 2011-11-21 11:25:35 +00:00
0d825ff728 Add CUnit testing support
Regenerate configure for unit test support.
2011-11-21 10:40:21 +00:00
633ef1a00b Tidy the shell tests into their own subdir. We now have:
- test/lib -- infrastructure and helper code
- test/api -- liblvm2app API tests
- test/unit -- C-based unit tests
- test/shell -- shell-based functional tests
2011-11-21 00:15:42 +00:00
6deb7e25cc Fix a syntax error. 2011-11-20 21:55:24 +00:00
e55220e27a Implement a CUnit-based runner for unit tests. Copy and adapt (actual unit)
tests from unit-tests/*/*_t.c (now under test/unit). The valgrind/pool test is
missing, since it's not really a unit test and probably not too valuable
either. Available via "make unit" (and if --enable-testing was passed to
configure, also executed by make check).
2011-11-20 21:43:20 +00:00
60d8256c38 Don't ignore configure --mandir and --infodir. 2011-11-20 20:52:09 +00:00
4c10cc98c7 Drop pool memory allocated in lv_has_target_type
Remove FIXMES - there should not be any pool free call since
the memory pool is from device manager, and pool is detroyed
after the operation, so doing extra free here would not help here.

However lv_has_target_type() is using cmd mempool so here the extra
call for dm_pool_free makes sence.
2011-11-18 19:42:03 +00:00
8b10abd792 Remove constant expression check
"result_independent_of_operands: ((dev->dev & 0xfff00UL) >> 8) ==
18446744073709551615UL /* -1 */ is always false regardless of the values
of its operands (logical operand of if)."

'dev->dev' is set in dev-cache.c _insert() and it's not expectable
st_rdev would have '-1'

This code has been introduced with drbd support commit and code never
worked - so eliminated.
2011-11-18 19:36:10 +00:00
108cfe0b0b Check target type name for DM_MAX_TYPE_NAME length
Avoid creation of target type name when it's longer then
DM_MAX_TYPE_NAME (noticed by static analyzer where the
sp.target_type might be missing '\0' at the end.)

Before patch:

$> dmsetup create long
0 1000 looooooooooooooooooooooooooong
^D
device-mapper: reload ioctl failed: Invalid argument

After patch:

$> dmsetup create xxx
0 1000 looooooooooooooooooooooooooong
Target type name looooooooooooooooooooooooooong is too long.
Command failed
2011-11-18 19:34:02 +00:00
f8484c44cc Replace dynamic buffer allocations for PATH_MAX
Use static buffer instead of stack allocated buffer.
This reduces stack size usage of lvm tool and the
change is very simple.

Since the whole library is not thread safe - it should not
add any new problems - and if there will be some conversion
it's easy to convert this to use some preallocated buffer.
2011-11-18 19:31:09 +00:00
f1f5572fbb Unlock memory for vg_write
For write we do not need to hold memory locked.
This relaxes many conditions and avoid problems when allocating
a lot of memory for writting metadata buffers.
(In case of huge MDA size this would lead to mismatch between
locked and unlocked memory region size).

Add also internal check we are not writing in critical section.
2011-11-18 19:28:00 +00:00
367ae9e86d Query before removing inactive snapshots
Removal of an inactive origin removes also all related snapshots.

When we now support 'old' external snapshots with thin volumes,
removal of pool will not only drop all thin volumes, but as
a consequence also all snapshots - which might be seen a bit
unexpected for the user - so add a query to confirm such action.

lvremove -f will skip the prompt.
2011-11-18 19:25:20 +00:00
a21275e1b2 Allow to activate snapshot
Add extra code to active and deactivate related
snapshots and origin when user specifies snapshot
logical volume as lvchange parameter.

Before patch:

$> lvs -a
  LV    VG   Attr     LSize  Pool Origin Snap%  Move Log Copy%  Convert
  lvol0 mvg  owi-a-s-  1.00k
  lvol1 mvg  swi-a-s- 16.00k      lvol0    0.00
  lvol2 mvg  swi-a-s- 16.00k      lvol0    0.00

$> lvchange -an mvg/lvol2; echo $?
  Can't change snapshot logical volume "lvol2".
5

After patch:

$> lvchange -an mvg/lvol2
Change of snapshot lvol2 will also change its origin lvol0 and 1 other
snapshot(s). Proceed? [y/n]: n
  Logical volume lvol2 not changed.

$> lvchange -y -an mvg/lvol2; echo $?
0

$> lvs -a
  LV    VG   Attr     LSize  Pool Origin Snap%  Move Log Copy%  Convert
  lvol0 mvg  owi---s-  1.00k
  lvol1 mvg  swi---s- 16.00k      lvol0
  lvol2 mvg  swi---s- 16.00k      lvol0
2011-11-18 19:22:49 +00:00
0ae01cf29d Skip non-virtual snapshots for availability
Change the behavior of availability change.
With this patch the lvgchange returns success
when VG is properly changed.

It skips non-virtual origins from being changes when
only 'vg' is specified as lvchange -a parameter.

Before this change we had this:

$> lvs -a
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi-a-s- 128.00k
  lvol1 mvg  owi-a-s- 128.00k
  lvol2 mvg  swi-a-s-   1.25m      lvol0
  lvol3 mvg  swi-a-s-   1.25m      lvol1

$> lvchange -an mvg ; echo $?
  Can't change snapshot logical volume "lvol2".
  Can't change snapshot logical volume "lvol3".
5

$> lvs -a
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi---s- 128.00k
  lvol1 mvg  owi---s- 128.00k
  lvol2 mvg  swi---s-   1.25m      lvol0
  lvol3 mvg  swi---s-   1.25m      lvol1

$> lvchange -ay mvg ; echo $?
  Can't change snapshot logical volume "lvol2".
  Can't change snapshot logical volume "lvol3".
5

$> lvs
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi-a-s- 128.00k
  lvol1 mvg  owi-a-s- 128.00k
  lvol2 mvg  swi-a-s-   1.25m      lvol0
  lvol3 mvg  swi-a-s-   1.25m      lvol1

After commit:

$> lvs -a
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi-a-s- 128.00k
  lvol1 mvg  owi-a-s- 128.00k
  lvol2 mvg  swi-a-s-   1.25m      lvol0
  lvol3 mvg  swi-a-s-   1.25m      lvol1

$> lvchange -an mvg ; echo $?
0

$> lvs -a
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi---s- 128.00k
  lvol1 mvg  owi---s- 128.00k
  lvol2 mvg  swi---s-   1.25m      lvol0
  lvol3 mvg  swi---s-   1.25m      lvol1

$> lvchange -ay mvg ; echo $?
0

$> lvs -a
  LV    VG   Attr     LSize   Pool Origin
  lvol0 mvg  owi-a-s- 128.00k
  lvol1 mvg  owi-a-s- 128.00k
  lvol2 mvg  swi-a-s-   1.25m      lvol0
  lvol3 mvg  swi-a-s-   1.25m      lvol1
2011-11-18 19:19:22 +00:00
986a6d9d85 Adjusted mirror region size only for mirrors and raids
Update region_size only for mirror and raid targets.
This fixes warning messages when vg is using small
extent size like 1KiB and no mirror/raid is created,
but the user still got the message:

$> vgcreate -s 1K vg  <pvs>
$> lvcreate -L10K vg
Using reduced mirror region size of 4 sectors
2011-11-15 17:32:12 +00:00
4c1d56cdcf Thin update prompt message
Enhance message with info about how many thin volumes are going to
be removed with thin pool removal.
2011-11-15 17:29:52 +00:00
a6d0767d3e Reorder AND test condition
Take the easiest condition for checking first since they must
apply all together, check local conditions first before doing
more expensive tests.
2011-11-15 17:27:41 +00:00
7411ce05c6 Thin clean
Reuse seg pointer already set in _add_lv_to_dtree to have the
value of first_seg(lv) (and is used in other parts of this function).
2011-11-15 17:25:05 +00:00
a1c4a54ada Thin supports only thin volumes as snapshot origins
It's currently of the scope to properly solve the snapshoting
of internal thin devs so prevent non-toplevel snapshots here.
2011-11-15 17:23:51 +00:00
96f7c3e2da Simplify iteration
Since nothing is removed in dm_list snapshot_segs during the loop,
there is no reason to use _safe iteration, so switch to simplier
dm_list_iterate().
2011-11-15 17:21:02 +00:00
e60993068c Thin fix tpool layer
Since we support snapshots of thin volumes, we could have more layers,
so we have to check whether tpool layer is going to be inserted.

As the _add_segment_to_dtree() is the only place that adds tpool
segment, we may just check pointer (no strcmp for layer).

Switch to use  seg_is_  function instead of lv_is_.
2011-11-15 17:15:03 +00:00
dddf30e354 Include a copy of kernel DM documentation in doc/kernel 2011-11-15 13:54:20 +00:00
26ab12e69d Avoid 'mda inconsistency' by properly registering UNLABELLED_PV flag (2.02.86).
When a PV label write is deferred to a vg_write call (as introduced by a patch
in 2.02.86), the PV is flagged with the internal UNLABELLED_PV flag. However,
when calling vg_archive before vg_write, we still have the PV labelled with the
UNLABELLED_PV flag which was not recognised as a proper flag while exporting
VG metadata:

  # vgcreate vg /dev/sda
  No physical volume label read from /dev/sda
  Metadata inconsistency: Not all flags successfully exported.
  Metadata inconsistency: Not all flags successfully exported.
  Writing physical volume data to disk "/dev/sda"
  Physical volume "/dev/sda" successfully created
  Volume group "vg" successfully created
2011-11-15 11:54:15 +00:00
dd815a4f7b Make dmsetup.static and lvm.static build when dmeventd is disabled.
udev may also need to be disabled if you didn't build it statically too.

dmeventd.static could be fixed with some more work but I don't really see the
point: without dlopen() it's useless, and if you have dlopen(), why not support
normal shared libraries too?
2011-11-14 21:30:35 +00:00
bc33c1cda4 Incomplete documentation is worse than no documentation.
Any documentation less-detailed than Documentation/device-mapper is
dangerous for the non-trivial ctr lines.  And anyway, this should be in s4
not here.
2011-11-13 01:41:57 +00:00
3d48fc1324 Add missing stack reporting
also remove unneeded {}
2011-11-12 22:53:23 +00:00
b589204e85 Thin use items iterator and stack reporting 2011-11-12 22:52:18 +00:00
8e24709ef2 Missing stack printing 2011-11-12 22:51:20 +00:00
eb668d8981 Update dmsetup man page
Use standard manpage style.
Keep options and commands in alphabetic order.
Added at least a very simply info about some other targets.
TODO: documenting targest needs far more work...
2011-11-12 22:48:44 +00:00
988e809ed4 Thin remove unused define
Remove DM_THIN_ERROR_DEVICE_ID from API.
Remove API warning.
Drop code that was using DM_THIN_ERROR_DEVICE_ID (already commented)
Remove debug message which slipped in through some previous commit.
2011-11-12 22:44:10 +00:00
b5518cb1ea Move gentoo MAKEDEV to /sbin in lvm2create_initrd. (James Le Cuirot) 2011-11-12 17:03:53 +00:00
d2c074bf06 Fix major number filter structure boundary test. 2011-11-11 16:59:30 +00:00
ba89f47b8d Remove unneeded parameter. 2011-11-11 16:41:37 +00:00
0c789c6a9c And now add files for real. 2011-11-11 15:24:48 +00:00
2da3c698fd Fix function name in previous patch. 2011-11-11 15:14:05 +00:00
5584ecf7a2 Do not scan device if it is part of active multipath.
Add filter which tries to check if scanned device is part
of active multipath.

Firstly, only SCSI major number devices are handled in filter.

Then it checks if device has exactly one holder (in sysfs) and
if it is device-mapper device and DM-UUID is prefixed by "MPATH-".

If so, this device is filtered out.

The whole filter can be switched off by setting
mpath_component_detection in lvm.conf.

https://bugzilla.redhat.com/show_bug.cgi?id=597010

Signed-off-by: Milan Broz <mbroz@redhat.com>
2011-11-11 15:11:08 +00:00
c93cfc6a13 Thin send create_snap message
Start creating snapshots for real.
Update test suite to check it happens.
2011-11-10 15:30:59 +00:00
bd2ea128e0 Thin update testing script 2011-11-10 12:44:33 +00:00
1ee4955b70 Add generic function to check for target version
So the test script may use a simple line like i.e.:

aux target_at_least dm-thin-pool 1 0 0 || skip
aux target_at_least snapshot-origin 1 6 || skip
2011-11-10 12:44:00 +00:00
f0c52912f0 Small comment and indent updates 2011-11-10 12:43:05 +00:00
3eb6a4adb6 Thin test min thin_pool size for at least 1 chunk 2011-11-10 12:42:36 +00:00
1b990cc8aa Thin align volume size on chunk boundary size
If the extent_size is smaller then the chunk_size we may try
to find better aligment (wasting less space).

i.e. using  4KB extent_size and  64KB chunk size will
lead to creation of 64KB aligned thin volume.
2011-11-10 12:42:15 +00:00
520afb5a43 Thin lvcreate manpage
Merge thin creation into standard 1st. lvcreate.
Update snapshot for thin support.
2011-11-10 12:41:39 +00:00
69af4ab3ae Thin move _read_activation_params check
Since we finaly recognize thin creation only after
_determine_snapshot_type() - move _read_activation_params()
after it - so we can support  lvcreate -an thin snapshot.
2011-11-10 12:40:29 +00:00
01da72eb3a Thin create normal (old) snapshot when size is specified 2011-11-10 12:39:46 +00:00
815f56fd90 Thin disable pool create without activation 2011-11-10 12:39:01 +00:00
be88d03380 Add missing free() for line that is malloc()'d by getline(). 2011-11-08 19:02:21 +00:00
d25d6d456f Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
Fixes issue reported here: http://lkml.org/lkml/2011/11/8/190
2011-11-08 17:32:10 +00:00
2371f76c73 Thin ensure pool table is update after resize
Always make sure table gets reloaded.
For now activate and deactivate pool volume if it's not active.

FIXME: we could do this only if we are sure some thin volume is alive.
2011-11-08 12:19:53 +00:00
1e6910032e Update lvs man page style. 2011-11-08 12:16:53 +00:00
3b0407ad83 More lvcreate man updates
Use  { Name | Path } consistently like elsewhere.
Move --thin alphabetically before --type.
2011-11-08 12:12:31 +00:00
00c752b931 Correctly handle concurrent read (CR) locks in singlenode clvmd. This means
that we can also test clustered volume groups (vgcreate -c y) in the test
suite. Unfortunately we can't make this the testing default since cluster
mirrors require further infrastructure, and snapshots probably don't work at
all. I'll eventually add a few test cases that create clustered VGs
specifically.
2011-11-07 17:11:23 +00:00
1a7644a0f6 Do not repeat a failed test's output when VERBOSE is in effect. 2011-11-07 17:02:56 +00:00
b3d6e05694 Must not override alloc policy specified by user. 2011-11-07 13:54:54 +00:00
2f6fbed90b Thin add error message for double delete
Add few more internal error messages.
2011-11-07 11:04:45 +00:00
25227bfccb Thin supports snapshots
Full support for thin snapshots.
Create and remove is supported.

TODO: lvconvert support is not yes available.
2011-11-07 11:03:47 +00:00
ae6833c8fa Add missing default LVM_VG_NAME
Add support for exported shell variable LVM_VG_NAME also
for thins and snapshots.
2011-11-07 11:01:53 +00:00
db6bf15fcd Thin lvcreate poolmetadatasize units doc 2011-11-07 10:59:55 +00:00
caa3faa47e Thin reindent code
Drop indention level
Add extra internal error.
2011-11-07 10:59:07 +00:00
56a076fb9e Thin revert code for exclusive pool activation
There are no limits on thin-pool activation now.
Revert code that is no longer needed.
2011-11-07 10:58:13 +00:00
32227d4720 Avoid lvextend to overflow
Add extra check to extent_count overflow.
Use internal define MAX_EXTENT_COUNT instead UINT32_MAX.
2011-11-04 22:49:53 +00:00
4d126a5a80 Thin lvcreate man update
Added poolmetadatasize options
Add an example.
2011-11-04 22:47:17 +00:00
d6ecde875a Thin pool allocation simplified
Support allocation of metadata from the same PV, if the VG
is build only from one PV.

As thinp is not mirror - we do not require 2 PVs
for basic thin usage as user is losing only perfomance.
2011-11-04 22:45:52 +00:00
134641d62d Thin add thin_pool_metadata_require_separate_pvs
Allow to set different policy for pool from mirrors.
2011-11-04 22:44:21 +00:00
d577391181 Thin supports poolmetadatasize setting
Add option to set pool metadatasize.
For passing size parameter reuse region_size.
2011-11-04 22:43:10 +00:00
70a441fcda Thin fix condition check for transation_id
id2 must be checked.
(missed in yesterday commit set).
2011-11-04 12:39:45 +00:00
b316ae6fd1 Add missing lvrename mirrored log recursion in for_each_sub_lv. 2011-11-04 01:31:23 +00:00
7ca380cf6d Thin keep pool device in the same state
Leave the optimalisation to be done differently and preserve
availability state of the pool device.
2011-11-03 15:58:20 +00:00
c4c8553390 Thin no device is created - so nothing to revert here 2011-11-03 15:46:51 +00:00
485734ae74 Thin removing limitation on activation of pool device.
Since activation of pool is now independent on thin activation,
user may do whatever he needs - thought preferable thin should stay alive,
but it it will be found inactivate, update_pool will bring the pool up.
2011-11-03 14:59:20 +00:00
da4dca3881 Thin removing unused detach_pool_messages 2011-11-03 14:57:04 +00:00
19af11c2eb Thin using update_pool_lv
Replace detach_pool_messages with update_pool_lv.
Move creation code from to 'if' condition into 1.
Ensure creation has finished all previous message operations.
2011-11-03 14:56:20 +00:00
6fbce7358c Thin genering update_pool_lv function
Function to trigger pool message passing via resume,
or resize of the pool itself independently on other thins.
2011-11-03 14:53:58 +00:00
9ebfab3a9f Add -tpool layer in activation tree
Let's put the overlay device over real thin pool device.
So we can get the proper locking on cluster.
Overwise the pool LV would be activate once implicitely
and in other case explicitely, confusing locking mechanism.
This patch make the activation of pool LV independent on
activation of thin LV since they will both implicitely use
real -thin pool device.
2011-11-03 14:52:09 +00:00
e8d6ac48a7 Thin api change for passing message into libdm
Avoid exposing another struct to the libdm user and
use only simple dm_tree_node_add_thin_pool_message with
2 overloaded uint64_t values.
2011-11-03 14:45:01 +00:00
a947464d4c Thin api change for dm_tree_node_add_thin_target
A little code shuffling and adding support for
DM_THIN_ERROR_DEVICE_ID which might be eventually be used
for activation of thin which is going to be deleted.
For now we do not need it lvm.
2011-11-03 14:43:21 +00:00
1bab67020c Thin avoids need of having writable VG for activation 2011-11-03 14:41:18 +00:00
264ca9ba32 Thin uses _tdata instead of _tpool for data LV
Switch to different suffix and keep -tpool reserved for overlay device name.
2011-11-03 14:38:36 +00:00
e99a9fec1b Thin clean using delete_id consitently 2011-11-03 14:37:23 +00:00
0e7603ecbb Thin code cleanup
Use iterate_items for list processing.
2011-11-03 14:36:40 +00:00
2d603339f1 Add "ExecReload" to dm-event.service for systemd to reload dmeventd properly.
Normally, restart simply means "stop and start" for systemd. However, if
we're installing new versions of the dmeventd binary/libdevmapper, we need
to restart dmeventd. This fails if we have some devices monitored - we need
to call "dmeventd -R" instead.

The "ExecReload" did not work quite well in some old versions of systemd,
systemd assumed that only the configuration is reloaded on "ExecReload",
not the whole binary itself so it lost track of dmeventd daemon (it lost new
dmeventd PID). This is fixed and seems to be working fine now with recent
versions of dmeventd.
2011-10-31 12:22:49 +00:00
d39f58ac2e Thin fix compile warns
Test for dm_snprintf < 0.
Add header for moved backup.
2011-10-30 22:52:08 +00:00
8ae8b9600c More updates for lvcreate manpage 2011-10-30 22:08:21 +00:00
cdf67ba0d0 Thin creation without activation
All thins are created with the next activation and VG is updated
without messages. Only some basic commands works.
(i.e. lvcreate -an  -V10 -T mvg/pool)
There can be some combination to confuse this system.

This functionality for snapshots is going to be interesting.
2011-10-30 22:07:38 +00:00
03a4d297db Thin segment transaction_id moved
Add a new node flag send_messages that is used to simplify
test when to call _node_send_messages().

Add call to _node_send_messages when pool is deeper in the tree.
2011-10-30 22:04:57 +00:00
4486b3b6a5 Cleanup unsuccessfully created thin LV
If something fails during creation of thin LV remove such LV
and deactivate in case it's been already tried to activate
(i.e. thin kernel driver fails for some reason.)
2011-10-30 22:02:18 +00:00
8ffa1880be Make detach_pool_message visible for tools
Move there also vg_write and vg_commit.
2011-10-30 22:01:39 +00:00
eadb017622 Thin cleanups
Fix/cleanup several error messages.
Remove test for seg_is_thin which could never be true there.
Replace (1<<24) with predefined constant.
2011-10-30 22:00:57 +00:00
9c5039d3e1 Cleanup for lvmetad passing uninit structure
Shown by clang analyzer.
2011-10-30 21:58:59 +00:00
8b7c241b1a Improve valgrind support when compiled with DEBUG_MEM 2011-10-28 20:37:31 +00:00
bb8a42ff56 Continue with lvcreate man page update
Already in WHATS_NEW.
2011-10-28 20:36:05 +00:00
cb961cdc83 Avoid creation of /dev/vg/thinpool 2011-10-28 20:34:45 +00:00
15812aae51 Thin option documentation 2011-10-28 20:33:50 +00:00
f924413d23 Thin support for stripe
Support stripe options to create thin data pool LV.

TODO: combine chunk size and stripe size.
2011-10-28 20:32:54 +00:00
23177b8aad Thin pool resize support for data LV
Support for extension of pool data LV.

TODO: figure out thin volume for suspend/resume in cluster.
2011-10-28 20:31:01 +00:00
22e6256d00 Thin support for lvrename
Rename pool's metadata lv _tmeta together with pool and _tdata.
2011-10-28 20:29:32 +00:00
b9f1afd47c Thin works only with exclusive activation
Enforce exclusive activation with thin targets.
2011-10-28 20:29:06 +00:00
98b5d31edd Thin pool activation change
To ensure we properly handle LV cluster locking - explicitely do
not allow to change the availability of the thin pool that is in use
for some thin LV.

As soon as the thin volume is created the only way to activate pool
is via implicit dependency.

Ignore thinpool open count for lv/vgchange operations.
2011-10-28 20:28:00 +00:00
209bd9887c Thin output data_block_size via outsize
Use outsize to get nice size hint.
2011-10-28 20:25:08 +00:00
82a46ed62c Improve lv_extend stack reporting
and some code cleanup with setting return value.
2011-10-28 20:23:24 +00:00
cde3a58d4e Thin error messages clenaup and some indent 2011-10-28 20:19:26 +00:00
1d5d5e41f7 Remove thin code from mirror/raid lv_extend 2011-10-28 20:18:32 +00:00
20e6a4528a Extend virtual segment instead of adding new one
Before adding a new virtual segment to LV, check first whether
the last segment isn't already of the same type. In this case
extend last segment instead of creating the new one.

Thin volumes should have always only 1 virtual segment, but it
helps also to virtual snapshot or error segtype..
2011-10-28 20:17:55 +00:00
7aa87822f7 Add last_seg
Implement a function to return the last segment in a LV.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2011-10-28 20:12:54 +00:00
69359fcc6a Trying to fix the retry logic
There should be no need for retry for our internal devices - it would be hinding
our own bug in the tree processing.
Update error messages to show also also device name.
No WHATS_NEW - in release fix.
2011-10-28 20:11:21 +00:00
bc69125ef0 Fix core on buggy config file
Since fixed within unreleased version so no WHATS_NEW
2011-10-28 20:07:38 +00:00
f542af20e2 Add find_config_tree_str_allow_empty
Add function to allow read of empty strings as valid arguments.
Add a warning message if string argument has ignored value.
2011-10-28 20:06:49 +00:00
42a14fa876 Update header comment 2011-10-28 20:04:17 +00:00
09f8dcdd7e Update lvconvert man page to describe '--type <segtype>' argument
Man page changes were not included when the ability to convert from
"mirror" -> "raid1" or "linear" -> "raid1" were made.
2011-10-25 13:24:23 +00:00
0fd3c2aa2b Disallow 'mirrored' log for cluster mirrors.
Git commit ID 0864378250 was meant to disallow
'mirrored' logs for cluster mirrors.  However, when add_mirror_log is used
to create the log (as is now the case when using 'lvcreate' or converting only
the log) the check is bypassed.

This patch adds the check to add_mirror_log.
2011-10-25 13:17:04 +00:00
80cdb5240e Don't print char type[8] as a plain string
pvck prints 'extra' character from the label since there is no '\0'
after the struct label entry and just uint64_t follows directly.
So avoid it by limiting 8 chars to be printed.

https://www.redhat.com/archives/lvm-devel/2011-January/msg00109.html

Signed-off-by: Paul Bolle <pebolle tiscali nl>
2011-10-24 10:24:39 +00:00
5ee6718daa Test with -F flag
grep need -F to check what we really want to test.
Add better test for existing device.

Currently this test DOES NOT work with real /dev handle via udev
since our tool does not see such device listet through udev.

FIXME: We might be able to see it at least through dmsetup table and
use for lvm.
2011-10-23 21:24:27 +00:00
13cca48ddc Drop mempool parameter from read functions
Use implicit vgmem pool.
2011-10-23 16:05:45 +00:00
f5aee12510 Always use vg memory pool for allocated lv segment
Remove mem pool parameter from alloc_lv_segment()
Since we should always allocate LV segment from the vg mempool.
2011-10-23 16:02:01 +00:00
7b2a7b7c43 Used device name instead of device path
Udev is tricky here - since with udev the node does not exists until
it resume happens.  So we need to resume devices via its name.
2011-10-23 15:43:10 +00:00
755de5972d Do not make link in the real /dev
Skip trying to make link when real /dev dir is used for test.
2011-10-23 15:40:15 +00:00
25fa1c2783 Expect failure with real /dev dir
As udev is for now incapable to create such devices
turn this test error into warning.
2011-10-23 15:39:08 +00:00
48d03bb158 Fix usage of DEBUG_ENFORCE_POOL_LOCKING with DEBUG_MEM
Since DEBUG_MEM is storing own extra structure within returned memory chunk,
glibc free must be used directly for posix_memaling() allocated block.
2011-10-23 15:38:02 +00:00
3b704b8e5d In t-lvcreate-large, do not create a clustered VG. LV activation/suspend does
not work yet with singlenode clvmd in clustered VGs.
2011-10-23 14:30:51 +00:00
a675bc3d0a Reduce stack size usage in print_log
As the buf2[] and locn[] can't be used at the same time, safe 1 page from
stack memory.
2011-10-22 16:52:00 +00:00
c71178b1ab Remove old thin code from _lv_insert_empty_sublvs
Since thin is not able to use _lv_insert_empty_sublvs,
remove its appearence from this function.

Start to use extend_pool() function for desired functionality
and modify lv_extend() for this.
2011-10-22 16:48:59 +00:00
cf3d037c96 Ensure thin LVs take an exclusive activation 2011-10-22 16:47:23 +00:00
493ea6330b Remove extra empty check
dm_list_splice handles empty list itself, no need to duplicate code.
2011-10-22 16:46:34 +00:00
c7b5b355f7 Consistently use metadata LV as the first in MDA
Cosmetic cleanup.
Mark LV as thin pool before calling attach_pool functions.
2011-10-22 16:45:25 +00:00
1fcd3fc4b5 Recoded way to insert thin pool into vg
Code in _lv_insert_empty_sublvs  was not able to provide proper
initialization order for thin pool LV.

New function extend_pool() first adds metadata segment to pool LV which
is still visible. Such LV is activate and cleared.

Then new meta LV is created and metadata segments are moved there.
Now the preallocated pool data segment is attached to the pool LV
and layer _tpool is created. Finaly segment is marked as thin_pool.
2011-10-22 16:44:23 +00:00
b7bbad9964 Make move_lv_segment non-static
This function could be useful for other _manip source files.

Use dm_list manipulation function for provided functionality,
which make the code more readable and avoid touching list
internal details here.
2011-10-22 16:42:10 +00:00
bd86888d74 Pass exclusive LV locks to all nodes in the cluster.
This was the intended behaviour, as described in the lvchange man page, so you
have complete control through volume_list in lvm.conf, but the code seems to
have been treating -ae as local-only for a very long time.
2011-10-21 15:49:45 +00:00
cd99a84e2b Store transaction_id with created thin lv
So we know the creation history and this should be useful with vgcfgrestore.
2011-10-21 11:38:35 +00:00
9b55b4e08e Remove double-hack for setting metadata size
Drop the second lv_extend and set 128MB directly in the first hack place.
2011-10-21 09:55:50 +00:00
5a6a8f4897 Thin pool now support chunk size as well
Use chunksize option to specify data_block_size for thin pool target.
Drop low_water_mark to zero.
2011-10-21 09:55:07 +00:00
2604d06ec8 Make units for chunksize more obvious 2011-10-21 09:53:16 +00:00
9709a27cb6 Aling structure chunk on default aling size
Since we use 8 bytes by default for the pool allocation,
keep the structure aligned with this size.
(Somehow it was not applied in previous commit.)
2011-10-20 14:43:33 +00:00
04275a672a Mark chunk memory for free as defined again for valgrind
When DEBUG_MEM is used, the memory is trashed with extra pattern before real
free() is called, and as this memory was marked as non accessible when used with
valgrind, make it again usable.
2011-10-20 13:39:57 +00:00
9c1f0f4aef Aling structure chunk on default aling size
Since we use 8 bytes by default for the pool allocation,
keep the structure aligned with this size.
2011-10-20 13:36:13 +00:00
45e1399532 Simplify some pointer operations 2011-10-20 13:33:41 +00:00
ed6d3763da Remove unused file from tree 2011-10-20 13:23:52 +00:00
5c796f3378 Just replace stack, return 0 with return_0 2011-10-20 10:39:07 +00:00
887c9834bb Cleanup backtraces
Make sure stacks are at the right places when something goes wrong here.
2011-10-20 10:38:04 +00:00
e8c577fc2e Add last param 0 for thin-pool
So now the table suppression works for thin-pool.
2011-10-20 10:35:55 +00:00
692d718d9d Ensure right activation order
Couple FIXMEs put into the code for parts of the code which may be
improved later, since we might be able to add 'lazy' device creation later.
For now require exclusive activation.
2011-10-20 10:35:14 +00:00
bc8bfff5ff Adapt to thin kernel target API
Since kernel target uses low_water_mark - use this name in libdm as well.
2011-10-20 10:33:30 +00:00
6e2fdfed67 Reindent code
Avoid 1 indent level and use check for empty list only for
add of transaction_id message.
2011-10-20 10:32:29 +00:00
3f59f7e14f Use const pointers in thin API were appropriate 2011-10-20 10:31:27 +00:00
8bf74e77c0 Print low_water_mark only when it has some value
Do not expose low_water_mark in mda yet, if it has no use.
We do not allow to be set via current lvm tool code.
Usage needs to be clarified first.
2011-10-20 10:30:39 +00:00
79835da163 Add _BLOCK_ to define
Use DM_THIN_MIN_DATA_BLOCK_SIZE and
DM_THIN_MAX_DATA_BLOCK_SIZE to make it more obvious, for which
this define is useful in thin API.
2011-10-20 10:28:41 +00:00
90f6336f85 Improve lvcreate man page
Split syntax for thin-pool since it cannot be fully matched with snapshot.
So to avoid more confusion - take thin support into separate line.

Though still significant updates are needed for thin provisioning.
2011-10-19 16:49:13 +00:00
4f12b7ad6a Add few more protected names 2011-10-19 16:45:35 +00:00
e610f31ca4 Use structure copy
Since the code evolved a bit with current structures we could use C to
copy struct members.
2011-10-19 16:45:02 +00:00
0f220e5858 Update error message
Drop INTERNAL_ERROR from public API functions.
Improve some messages.
2011-10-19 16:42:14 +00:00
7679ee9535 Use generic name for message sending function
Drop _thin_pool prefix for _node_send_message so it could be extended later.
Replace current_id with trans_id name.
2011-10-19 16:40:59 +00:00
a374aed61c Simple validation of messages in mda
Check we do not combine multiple messages for same LV target
and switch to use  'delete_id' to make it clear for what this device_id
is being used.
2011-10-19 16:39:09 +00:00
866b21532a Drop messages referencing deleted LV
lvremove may remove problematic LV for thin target.
2011-10-19 16:37:30 +00:00
fc260f5bcb Just indent changes
Some tabs & spaces.
2011-10-19 16:36:39 +00:00
c239c824f5 Add internal expected_errno dm_tast var
Certain errno codes could be expected in some situations thus
add experimental support for them.

When expected errno is set after ioctl error - function skips error
printing and exits succefully.

Currently only useful for thin pool messages.
2011-10-19 16:36:01 +00:00
d1be6a0c37 Remove test for thin_pool
Since both functions are called during mda read - we don't have full LV info
at this moment.
2011-10-19 16:32:34 +00:00
9f4ef9fda6 Remove a redundant (and in some cases, misleading) message about snapshot
extension, in the snapshot dmeventd plugin. The reporting is done as needed by
the LVM command nowadays.
2011-10-19 14:31:49 +00:00
2a8662ce2e New. 2011-10-19 09:01:03 +00:00
6de64854a8 Keep the LVM-based dmeventd plugins from trying to manipulate the dmeventd
monitoring state of the logical volumes they are currently acting on.

Until now, every time a logical volume has been changed by a dmeventd plugin,
this plugin would have called back to dmeventd through the external FIFO
mechanism. I am fairly sure this was superfluous, inefficient and possibly even
dangerous.
2011-10-19 08:46:26 +00:00
a4ddd21f8e Fix bad lvconvert help output.
The '--merge' option to lvconvert works on snapshots and RAID1.  The man
pages correctly reflect this, but the CLI help output still used the term,
'SnapshotLogicalVolume'.
2011-10-18 16:27:45 +00:00
cd2eab0d10 Use zalloc for malloc,memset 2011-10-17 14:36:06 +00:00
edb7aaf046 Drop messages from lvm app context
(revert)
Thinp target uses activation context.
2011-10-17 14:18:07 +00:00
10c2510aaf Indent debug message 2011-10-17 14:17:30 +00:00
f8690cf8d5 Message support for thin provisiong
lvm part of messaging.

Each message is now stored it's own thin pool section:

message1 {
	create = lv
}

Messages are queued to thin pool dm target when this target
is going to be resumed or used through some dependency.

Currently  'delete' message are purely queued and processed
with next thin pool resume operation (i.e. create_thin).

WARNING - thin provisioning support is developmental code.
2011-10-17 14:17:09 +00:00
49e3017e4a Add thin_pool dm message support
Experimental support for kernel message via resume sequence.
2011-10-17 14:16:25 +00:00
5c5acddf01 Add _thin_validate_device_id 2011-10-17 14:15:26 +00:00
f5dace2cb6 Swap parameters
Use metadata uuid first (match kernel target).
2011-10-17 14:15:01 +00:00
783b4e1068 Drop old check for transaction_id
(revert)
2011-10-17 14:14:33 +00:00
c752c23d33 Fix alignment warning in bitcount calculation for raid segment. 2011-10-17 13:15:35 +00:00
2fd1acc4dd Use a more correct macro for 'seg_is_linear'
It is better to check 'seg->area_count == 1' than '!seg->stripe_size'.
2011-10-14 14:21:32 +00:00
c954b73149 cmirrord now returns log name to kernel in CTR so it can be registered
Version 2 of the userspace log protocol accepts return information during the
DM_ULOG_CTR exchange.  The return information contains the name of the log
device that is being used (if there is one).  The kernel can then register the
device via 'dm_get_device'.  Amoung other things, this allows for userspace to
assemble a correct dependency tree of devices - critical for LVM handling of
suspend/resume calls.

Also, update dm-log-userspace.h to match the kernel header associated with
this protocol change.  (Includes a version inc.)
2011-10-14 14:18:49 +00:00
681ceb16d8 Update stale libdm/misc/dm-log-userspace.h
The upstream kernel version that this file mirrors has changed, here is the
commit message:

commit 86a54a4802df10d23ccd655e2083e812fe990243
Author: Jonathan Brassow <jbrassow@redhat.com>
Date:   Thu Jan 13 19:59:52 2011 +0000

    dm log userspace: add version number to comms

    This patch adds a 'version' field to the 'dm_ulog_request'
    structure.

    The 'version' field is taken from a portion of the unused
    'padding' field in the 'dm_ulog_request' structure.  This
    was done to avoid changing the size of the structure and
    possibly disrupting backwards compatibility.

    The version number will help notify user-space daemons
    when a change has been made to the kernel/userspace
    log API.

    Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2011-10-14 14:04:05 +00:00
54e43fd3de Use pool for dm_tree allocation
Using the same pool allocation strategy as we use for vg,
so dm_tree structure is part of the pool itself.
2011-10-14 13:34:19 +00:00
878960cdba Fix lv_info open_count test
When verify_udev_operations was disable, code for stacking fs operation for
lvm links was completely disable - but this code was also used for collecting
information, that a new node is being created.

Add a new flag which is set when a creation of lv symlinks is requested which
should restore old behaviour of lv_info function, that has called fs_sync()
before quere for open count on device.
2011-10-14 13:23:47 +00:00
1ec22a4f73 Remove unused variables 2011-10-11 10:06:57 +00:00
f4668058b4 Use constant for the repeated dlid size specification 2011-10-11 10:02:28 +00:00
2e36a19e52 Add some fixme locking
Code here is using thread write protected variable without locking.
So add locking, for proper synchronization and a FIXME, since the
code needs closer look.
2011-10-11 09:56:44 +00:00
e65626090b Simplify worker loop
Do not reacquire mutex several times without a real reason.
Code readability is also better.
2011-10-11 09:54:39 +00:00
b39f294d02 Use barrier instead of mutex
Barrier is supposed to be used in situation like this
and replace tricky mutex usage, where mutex has been unlocked
by a different thread than the locking thread.
2011-10-11 09:26:04 +00:00
0372454d07 Add FIXMEs for init_test
Usage of thread unprotected init_test is not correct and needs probably lvm lock
since it part of lvm library. Current implementation may probably fail with
test mode and actually create something unexpectedly (and vice versa).
2011-10-11 09:23:48 +00:00
584a487461 Update 2011-10-11 09:20:17 +00:00
e9bdc318fd Limit thread stack
Since default thread stack size is around 8MB and clvmd creates for now thread
for message, clvmd may easily reach multi GB size of in-memory locked pages
(runs with mlockall()).

This patch significantly reduces memory usage to just tens of MB,
and now different reasons are the cause of server overloading.
Now we are running out of free file descriptors mostly.
2011-10-11 09:18:49 +00:00
d2cd3f4b76 Update whats new 2011-10-11 09:14:51 +00:00
83b15720c0 Reduce preallocated stack size
Go with just 64KiB for stack.

Closer inspection should be made, whether we actually need to play with
settings at all.

Since default stack size is 8MB and gets mapped via page locking thus,
it seems there is no big help with preallocation of stack to some value.
2011-10-11 09:13:39 +00:00
3701873dc9 Check for refresh_filter failure
Properly detect if the filters were refreshed properly.

(May needs few more fixes ??)

Filter refresh may fail because it may be out of free file descriptors
when clvmd gets overloaded.
2011-10-11 09:09:00 +00:00
b105d7e207 Add missing log_error for alloc failure 2011-10-11 09:06:09 +00:00
fea9b4eaa3 Use condition instead of sleep
Replace usleep with pthread condition to increase speed testing
(for simplicity just 1 condition for all locks).

Use thread mutex also for unlock resource (so it wakes up awaiting
threads)

Better check some error states and return error in fail case with
unlocked mutex.
2011-10-11 09:05:20 +00:00
eb050343b9 Use shorter way for if() 2011-10-11 09:03:33 +00:00
4802bbc548 Skip backtrace after log_error 2011-10-11 09:02:20 +00:00
3822c98285 Replace with debug
Since the dm_tree_create already reports reason of error,
use log_debug for this message.
2011-10-11 09:01:38 +00:00
d70b1eea5d Improve backtrace reporting
Add <backtrace> so the function appears logged for the fail path.
2011-10-11 08:59:42 +00:00
0c92ec4d21 Change message severity
Using log_warn to report missing symlinks as warning, since the command
itself returns as successful, we should not produce log_error().
log_warn is better fit here.
2011-10-11 08:57:13 +00:00
fdeda0b438 Skip r assignment
Cosmetic, since r is already 0 for the error path, no need to assign it there,
and r is assigned to 1 after switch command.
Also makes the code more readable.
2011-10-11 08:54:01 +00:00
e7eebbc90f Reindent some thin functions 2011-10-11 08:51:56 +00:00
fcbb8e5c5d Remove test for first_time with FIXME
Workaround for the current code with big FIXME,
since proper solution for pvmove needs to be developed.

Commiting this only for the purpose to get cluster testing covered.
2011-10-11 08:51:02 +00:00
2c80ace622 Add the ability to convert LVs of "mirror" segtype to "raid1" segtype.
Example:
~> lvconvert --type raid1 vg/mirror_lv

Steps to convert "mirror" to "raid1"
1) Allocate a RAID metadata LV for each mirror image from the same PVs
   on which they are located.
2) Clear the metadata LVs.  This involves writing LVM metadata, so we don't
   change any aspects of the mirror LV before this so that the user can easily
   remove LVs from the failed convert attempt while retaining the original
   mirror.
3) Remove the mirror log, if it exists.
4) Add metadata LVs to mirror LV
5) Rename mirror sub-lvs (s/mimage/rimage/)
6) Change flags and segtype from mirror to raid1
2011-10-07 14:56:01 +00:00
50a48b38f5 Add the ability to convert linear LVs to RAID1
Example:
~> lvconvert --type raid1 -m 1 vg/lv

The following steps are performed to convert linear to RAID1:
1) Allocate a metadata device from the same PV as the linear device
   to provide the metadata/data LV pair required for all RAID components.
2) Allocate the required number of metadata/data LV pairs for the
   remaining additional images.
3) Clear the metadata LVs.  This performs a LVM metadata update.
4) Create the top-level RAID LV and add the component devices.

We want to make any failure easy to unwind.  This is why we don't create the
top-level LV and add the components until the last step.  Should anything
happen before that, the user could simply remove the unnecessary images.  Also,
we want to ensure that the metadata LVs are cleared before forming the array to
prevent stale information from polluting the new array.

A new macro 'seg_is_linear' was added to allow us to distinguish linear LVs
from striped LVs.
2011-10-07 14:52:26 +00:00
76ab264200 Allow 'nosync' extension of mirrors.
This patch allows a mirror to be extended without an initial resync of the
extended portion.  It compliments the existing '--nosync' option to lvcreate.
This action can be done implicitly if the mirror was created with the '--nosync'
option, or explicitly if the '--nosync' option is used when extending the device.

Here are the operational criteria:
1) A mirror created with '--nosync' should extend with 'nosync' implicitly
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv ; lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 10.00g                         lv_mlog 100.00

2) The 'M' attribute ('M' signifies a mirror created with '--nosync', while 'm'
signifies a mirror created w/o '--nosync') must be preserved when extending a
mirror created with '--nosync'.  See #1 for example of 'M' attribute.

3) A mirror created without '--nosync' should extend with 'nosync' only when
'--nosync' is explicitly used when extending.
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv; lvs vg
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 20.00m                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 5.02 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 5.02g                         lv_mlog   0.39
vs.
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv --nosync; lvs vg
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 20.00m                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 5.02 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 5.02g                         lv_mlog 100.00

4) The 'm' attribute must change to 'M' when extending a mirror created without
'--nosync' is extended with the '--nosync' option.  (See #3 examples above.)

5) An inactive mirror's sync percent cannot be determined definitively, so it
must not be allowed to skip resync.  Instead, the extend should ask the user if
they want to extend while performing a resync.
[EXAMPLE]# lvchange -an vg/lv
[EXAMPLE]# lvextend -L +5G vg/lv
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  vg/lv is not active.  Unable to get sync percent.
Do full resync of extended portion of vg/lv?  [y/n]: y
  Logical volume lv successfully resized

6) A mirror that is performing recovery (as opposed to an initial sync) - like
after a failure - is not allowed to extend with either an implicit or
explicit nosync option.  [You can simulate this with a 'corelog' mirror because
when it is reactivated, it must be recovered every time.]
[EXAMPLE]# lvcreate -m1 -L 5G -n lv vg --nosync --corelog
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
  Logical volume "lv" created
[EXAMPLE]# lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                             100.00
[EXAMPLE]# lvchange -an vg/lv; lvchange -ay vg/lv; lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                               0.08
[EXAMPLE]# lvextend -L +5G vg/lv
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  vg/lv cannot be extended while it is recovering.

7) If 'no' is selected in #5 or if the condition in #6 is hit, it should not
result in the mirror being resized or the 'm/M' attribute being changed.


NOTE:  A mirror created with '--nosync' behaves differently than one created
without it when performing an extension.  The former cannot be extended when
the mirror is recovering (unless in-active), while the latter can.  This is
a reasonable thing to do since recovery of a mirror doesn't take long (at
least in the case of an on-disk log) and it would cause far more time in
degraded mode if the extension w/o '--nosync' was allowed.  It might be
reasonable to add the ability to force the operation in the future.  This
should /not/ force a nosync extension, but rather force a sync'ed extension.
IOW, the user would be saying, "Yes, yes... I know recovery won't take long
and that I'll be adding significantly to the time spent in degraded mode, but
I need the extra space right now!".
2011-10-06 15:32:26 +00:00
1986e51928 Fix splitmirror in cluster having different DM/LVM views of storage.
This patch also does some clean-up of the splitmirrors code.

I've attempted to clean-up the splitmirrors code to make it easier to
understand with fewer operations.  I've tried to reduce the number of
metadata operations without compromising the intermediate stages which
are necessary for easy clean-up in the even of failure.

These changes now correctly handle cluster situations - including exclusive
cluster mirrors.  Whereas before, a splitmirror operation would result in
remote nodes having LVM commands report the newly split LV with a proper
name while DM commands would report the old (pre-split) names of the device.
IOW, there was a kernel/userspace mismatch.
2011-10-06 14:55:39 +00:00
f7235e7cb4 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
857339758f 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
29044ecb22 Fix vgsplit when there are mirrors that have mirrored logs.
The problem as reported by "ben <benscott@nwlink.com>" on lvm-devel:

vgsplit fails with mirrored mirror log

#lvs --all -o lv_name,lv_attr,devices
LV                       Attr   Devices
MyMirror                 mwi--
[MyMirror_mimage_0]      Iwi--- /dev/sdq(0)
[MyMirror_mimage_1]      Iwi--- /dev/sdo(0)
[MyMirror_mimage_2]      Iwi--- /dev/sdi(0)
[MyMirror_mlog]          mwi---
[MyMirror_mlog_mimage_0] Iwi--- /dev/sds(0)
[MyMirror_mlog_mimage_1] Iwi--- /dev/sde(0)

#vgsplit -v "TestA" "TestB" "/dev/sdq" "/dev/sdo" "/dev/sdi" "/dev/sds"
"/dev/sde"
  Checking for volume group "TestA"
  Checking for new volume group "TestB"
  Archiving volume group "TestA" metadata (seqno 213).
Can't split mirror MyMirror between two Volume Groups

AFTER FIX:

[root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new
  Volume group "new" not found
  Skipping volume group new
  LV                 VG   Devices
  lv                 vg   lv_mimage_0(0),lv_mimage_1(0)
  [lv_mimage_0]      vg   /dev/sdb1(0)
  [lv_mimage_1]      vg   /dev/sdc1(0)
  [lv_mlog]          vg   lv_mlog_mimage_0(0),lv_mlog_mimage_1(0)
  [lv_mlog_mimage_0] vg   /dev/sdh1(0)
  [lv_mlog_mimage_1] vg   /dev/sdi1(0)
[root@bp-01 ~]# vgsplit vg new /dev/sd[bchi]1
  New volume group "new" successfully split from "vg"
[root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new
  LV                 VG   Devices
  lv                 new  lv_mimage_0(0),lv_mimage_1(0)
  [lv_mimage_0]      new  /dev/sdb1(0)
  [lv_mimage_1]      new  /dev/sdc1(0)
  [lv_mlog]          new  lv_mlog_mimage_0(0),lv_mlog_mimage_1(0)
  [lv_mlog_mimage_0] new  /dev/sdh1(0)
  [lv_mlog_mimage_1] new  /dev/sdi1(0)
2011-10-06 14:17:45 +00:00
b47df54d48 Add more validation to config parser
Do not leave it for vgvalidate().
2011-10-06 11:06:36 +00:00
9f9b3e1e28 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
43dce243ab Clarify multi-name device filter pattern matching explanation in lvm.conf.5. 2011-10-04 20:49:24 +00:00
122476adc6 Clarify multi-name device filter pattern matching explanation in lvm.conf.5. 2011-10-04 20:45:36 +00:00
1fef12cd31 Name changes
typo zeroeing->zeroing
add size low_water_mark->low_water_mark_size so it's more obvious its sector
related variable.
2011-10-04 16:22:38 +00:00
f53fb47dd9 Use capital letters 2011-10-04 12:39:59 +00:00
b79f082537 Missed rename pool->thin_pool
Fix compilation
2011-10-03 19:10:52 +00:00
b12ec9b372 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
4121fbb8a4 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
f683063d42 Add lvm functions for sending messages.
Functions are currently only needed for thin provissioning.
2011-10-03 18:37:47 +00:00
c6d777289b Add intial code to check transaction_id
Fix typy in transaction_id.
Add this as node property, so it could be easily checked on resume.

Code is not yet finished.
2011-10-03 18:34:52 +00:00
d75053e74f Display transaction_id for thin_pool 2011-10-03 18:31:03 +00:00
27596fa624 Move priority check in front
Just a minor code mode - make a test for priority before
more complex uuid checks.
2011-10-03 18:29:48 +00:00
f8b4957694 Update error path tracing for _resume_node
dm_task_create & dm_task_set_name produces it's own log_error
Add missing stacks for dm_task_set_cookie, dm_task_run,
dm_task_get_info.
2011-10-03 18:28:25 +00:00
2daddac019 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
a6d73dc760 Add preload support for thin and thin_pool 2011-10-03 18:24:47 +00:00
56fc7c0053 Fix bad error message for thinp validation 2011-09-29 09:03:36 +00:00
4ffb50268a Let the utils to prepare PVs 2011-09-29 08:58:27 +00:00
3473d2f219 Typo in debug message 2011-09-29 08:57:21 +00:00
4a59dda8aa 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
222bbab442 Add supporting function for thinp
New dm_tree_node_add_thin_pool_target() and  dm_tree_node_add_thin_target()
This API is highly experimental and unstable for now.
2011-09-29 08:53:48 +00:00
3589d75998 Just add warning about potential problem exteding dm_segtypes
Since raid target is using now dm_segtypes also for search purpose.
2011-09-29 08:50:54 +00:00
3016856a4c New handy gdb debugging function, "dm_list_size"
Example:
(gdb) dm_list_size &split_images
1 list items
2011-09-28 16:32:22 +00:00
e0948b5825 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
691157a71e Replace incomplete pvmove activation failure recovery code with a message.
As it stands, the recovery code can make things worse sometimes so it's
better to insist on a proper 'pvmove --abort' cleanup.
2011-09-27 17:29:33 +00:00
e63febe5ec 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
88c3d4b61a better -m0 error message, but there's an internal logic error to fix instead 2011-09-27 12:37:07 +00:00
fcdcef33c3 typo 2011-09-27 12:34:14 +00:00
ead841e0a3 correct thin_pool width 2011-09-27 12:33:36 +00:00
26f43649f9 Show some Thin related info in lvdisplay 2011-09-26 13:11:02 +00:00
d1f949465f 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
57f1027a03 Use execvp for clvmd restart
Since execve passed only NULL as environ, we had lost all environment vars on
restart - thus actually running  'different' clvmd then the one at start.

Preserving environ allows to restart clvmd with the same settings
(i.e. LD_LIBRARY_PATH)

Add test for second restart.
2011-09-26 07:51:23 +00:00
7f7e0704f6 Remove test for NULL
Since it's internal function and we always check for NULL value
before call - this is safe.

Just for case add nonnull attribute so analyzer might better
catch error.
2011-09-25 19:45:40 +00:00
ed3d5e9409 Add missing log_error messages 2011-09-25 19:43:43 +00:00
f0633627b4 Add backtrace when allocation fails for _type 2011-09-25 19:42:45 +00:00
1dd5dfed81 Replace test for NULL of root->child with test for NULL l
It's 100% equivalent test - since it always happen for the first iteration.
But the check for 'l' is understandable with analyzers - since analyzer
is not smart enough to deduce connection between  root->child == NULL.
2011-09-25 19:41:27 +00:00
2d2d9ac875 Simplier attribute format
No need to repeat whole declaration for static function.
2011-09-25 19:40:29 +00:00
3416af3f5d Chheck for failing filename strdup 2011-09-25 19:39:38 +00:00
4da6e11c5a Use NULL for pointers 2011-09-25 19:38:59 +00:00
bd085674b2 Restart CLVMD with same cluster manager
Add named cluster_ops to easily learn the name of the active cluster manager,
so we are able to restart singlenode manager in testing.

Add simple test for clvmd -S  (restart) and -R (refresh)
(though it needs some extensions).
2011-09-25 19:37:00 +00:00
71ee4b8d25 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
1fd620a436 Allow overwrite for VERIFY_UDEV
When running tests it might be useful to have an override option when
testing on real /dev  and some broken system (i.e. Debian and its rules).

So one can use:

LVM_TEST_DEVDIR=/dev LVM_VERIFY_UDEV=1 make check
2011-09-24 21:15:13 +00:00
5764014aa3 Avoid sending garbage to terminal in verbose mode.
When read in drain returned <0 value, terminal content has been trashed.
Remove unneeded  memset() and use whole buffer.
Free  readbuf before exit (valgrind).
2011-09-24 21:12:35 +00:00
cc12990b2f Improvements
Simplify RUN_BASE

Put .tests-stamp deps only for check target and fix its cleanup.
Fix abs_top_srcdir.
vgimportclone needs  srcdir.
Clean  api subdir.
2011-09-24 21:10:19 +00:00
a6791e34ba Fix install_ocf
When builddir is different from srcdir install_ocf: has not been able to find
files for installation.
2011-09-24 21:05:03 +00:00
8deff7018a Drop cleanup of .exported_symbols_generated in DISTCLEAN_TARGETS
Makefile cosmetics - since .exported_symbols_generated in cleardir:
target via make.tmpl, there is no need to set them in DISTCLEAN_TARGETS.
2011-09-24 21:00:52 +00:00
48b9cbab24 Use Makefile for daemmons/common library.
Next iteration for better fit of lvmetad compilation.

Move build of libdaemon.a into common subdir Makefile.
libdaemon.a is device-mapper target.

Build and install lvmetad as lvm2 target.
2011-09-24 20:57:49 +00:00
4c71c99934 Detect unusable nodes on fs
Test whether nodes could be used on given filesystem where TMP
dir is being used and skip teardown quicker in fail case.
(makes the problem quickly obvious if you try to such fs).

Skip teardown_dev if we have not created any devs yet.

and do not mkdir /dev/mapper dir  when LVM_TEST_DEVDIR is set.

Drop this test from t-000-basic.sh.
2011-09-24 20:54:35 +00:00
8ed5c47ce5 CLVMD support for LVM_CLVMD_BINARY and LVM_BINARY
Read 2 environmental vars to learn about overide position for
CLVMD and LVM binaries.

We support LVM_BINARY in other script - and this way we could easily
test restart in our test-suite.
2011-09-24 20:50:35 +00:00
9c2095311e CLVMD bugfix support for args -S -E
Bugfix:
Add (most probably unfinished) support for -E arg with list of exclusive
locks.  (During clvmd restart all exclusive locks would have been lost and
in fact, if there would have been an exclusive lock, usage text would be
printed and clvmd exits.)

Instead of parsing list options multiple times every time some lock UUID is
checked - put them straight into the hash table - make the code easier to
understand as well.

Remove  was_ex_lock() function (replaced with dm_hash_lookup()).

Swap return value for get_initial_state() (1 means success).

Update man pages and usage info for -E option.
2011-09-24 20:48:34 +00:00
5d604a99f6 readlink does not append a null byte to the output string! 2011-09-24 11:47:53 +00:00
283094fb67 update man page for new RAID lv_attr characters. 2011-09-23 19:21:53 +00:00
4e8d5bc726 explain why we may now retry 2011-09-23 17:16:28 +00:00
e7bc2978e5 missing Makefile dep 2011-09-23 17:05:44 +00:00
1e32e75ee4 Update the RAID design doc to reflect some of the new options introduce (e.g.
--merge and --trackchanges) and document the coding steps of up/down-conversion,
splitting RAID1 images, and merging RAID1 images.
2011-09-23 17:04:41 +00:00
c6e1353c4d Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE.
RAID_META is already handled.
2011-09-23 15:17:54 +00:00
d00941c9a4 Update dmsetup man page
While dmsetup command properly shows all dmsetup resume supported options,
man page missed to document it.
2011-09-23 09:51:37 +00:00
373b717a5f Build all man pages
When running plain 'make' in man dir - do also those for device-mapper target.
2011-09-23 09:48:21 +00:00
2729ca70bc Initialize 'retryable' variable. 2011-09-22 17:59:58 +00:00
ef2a81b860 Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. 2011-09-22 17:39:56 +00:00
3157f8e8fa Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. 2011-09-22 17:36:50 +00:00
638409a573 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
def057522f 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
1f92ab6e8a 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
2f64783850 Add --retry option for dmsetup remove to retry removal if not successful. 2011-09-22 17:12:28 +00:00
6b1629455a 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
1d251c85da Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg.
If you specify the segment type (e.g. --type mirror) and the mirrors argument
as zero, it would result in a mirrored LV with only one image.  While the device
may be valid in theory, it should not be allowed in practice.  It also makes it
difficult on the conversion tools, since they react badly to single-image
mirrors.
2011-09-22 15:36:21 +00:00
3fa30a939f 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
9cd366bf2b Clvmd restart cleanup
Patch fixes Clang warnings about possible access via lv_name NULL pointer.

Replaces allocation of memory (strdup) with just pointer assignment
(since execve is being called anyway).

Checks for  !*lv_name only when lv_name is defined.
(and as I'm not quite sure what state this really is - putting a FIXME
around - as this rather looks suspicios ??).

Add debug print of passed clvmd args.
2011-09-22 09:47:34 +00:00
d283be0597 Add all exclusive locks to clvmd restart option args
Fix bug when only every even lock has been passed.

Warning: currently -E causes clvmd to exit with usage text being printed.
2011-09-22 09:45:24 +00:00
fb38615cf6 FIXMEs to note problems with some error paths. (Perhaps safer to disable
them until they can be fixed completely?)
2011-09-21 16:36:39 +00:00
c7ea2c24f8 Always sent the whole command header in restart/reload clvmd commands.
(Newly added check catch this as invalid packet.)

(N.B. that code is so fragile that it need full rewrite soon:-)
2011-09-21 13:40:46 +00:00
a456d3c77f Check for failing 'stat' and skip this loop iteration
(since data in statbuf are invalid).

Check whether sysconf managed to find _SC_PAGESIZE.

Report at least debug warning about failing unlink
(logging scheme here seems to be a different then in lvm).

Duplicate terminal FDs and use similar code as is made in clvmd
and cleanup warns about missing open/close tests.
FIXME: Looks like we already have 3 instancies of the same code in lvm repo.
2011-09-21 10:42:53 +00:00
1a82ef4386 Add missing log_error() to lvresize command when fsadm tool fails
Also add test case
2011-09-21 10:39:47 +00:00
8ae350ee06 Unmount works with -y 2011-09-19 19:37:26 +00:00
1c088b0a2b Add support for DM_DEV_DIR
Follow other commands support this directory setting.
Useful for test suite.
2011-09-19 19:36:52 +00:00
dab5a7fad0 Another vgremove for speedup
It seems like test-suite is significantly slowed down on removal phase.

Maybe it should be part of generic teardown - though the reason of slowdown
should be also discovered -  probably related to retry loop ?
2011-09-19 18:40:51 +00:00
cc8b9dd973 Revert patch
Caller of exec must report log_error when rstatus is passed.
2011-09-19 18:38:43 +00:00
a6fd7ce6a5 Ensure fsadm.sh is executable
When the srcdir == builddir we get the link on non-exectable file.
So make always sure fsadm.sh is executable script file.

Add cleanup target for lib/fsadm.
2011-09-19 15:54:15 +00:00
7b3831d001 Use log_error instead of log_verbose when executed command fails 2011-09-19 14:54:23 +00:00
c110bc0154 Add support for non /dev devices
Since test suite is not using /dev - add support for such dirs into fsadm.
2011-09-19 14:52:33 +00:00
e9bafdd2ce 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
7aa34a6a19 Enable t-fsadm test
Now all commands are executed from preffered directory.
2011-09-19 13:52:22 +00:00
304c544ce5 Support different PATH setting
When fsadm is test - it needs to execute lvm and fsadm from non-standard path
setting.   So adding a support in fsadm script when user set LVM_BINARY, then
the lvm command invoced from fsadm will have the same PATH setting as before
entering  fsadm command.

Needed for testing.
2011-09-19 13:51:09 +00:00
9ee3f61aee Surround all executed commands with quotes
In case someone would use filename paths with spaces when changing
this script surround commands with '"'.

With default settings there is no change in behavior.
2011-09-19 13:47:37 +00:00
ff9808505b Fix missing '$' in test 2011-09-19 13:43:50 +00:00
e2749ba847 Add link for fsadm script
Prepare to enabling t-fsadm.sh test
2011-09-19 12:50:17 +00:00
80b6a3a309 Test speed up
Removing vg  reduces time execution of this test.
Teardown has some wait states here...
2011-09-19 12:49:14 +00:00
1207e7a5b1 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
fa6b41848e Few more updates to lvmetad build deps
It seem lvmetad deps must be expressed after the include.
Also adding lvmetad deps to device-mapper target in daemons dir.
2011-09-19 00:29:11 +00:00
48f57c1cf0 Build fixes for lvmetad
Should now be giving better build order and install lvmetad.
2011-09-17 14:50:22 +00:00
6a9d54829f More gcc warnings removed 2011-09-17 14:49:18 +00:00
77bc50144c Fix for gcc compilation warnings
and put _XOPEN_SOURCE so pthread_mutexattr is properly defined.
2011-09-17 13:33:51 +00:00
a94299f451 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
5c11544dc1 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
747060fe19 Fix clvmd processing of invalid request on local socket. (rommer)
Code now detects small packet and wrong arglen and reply with
error intead of infinite loop.

https://bugzilla.redhat.com/show_bug.cgi?id=738484
2011-09-16 14:40:06 +00:00
40f8cf3f7c Disable t-lvcreate-large.sh for now with cluster. 2011-09-16 14:32:47 +00:00
ba230df659 Add inital thin testing
Currently test is skipped by default (since it needs code hack to work)
Check command line options to create & remove thin pools and thin volumes.

Activation code for thin LV support is missing, thus it only works without
driver loaded.
2011-09-16 12:23:59 +00:00
528c26a1ce 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
75394455bc Fix command line option decoding
LVM has huge set of options now - it's approaching 60 short-arg less options
and we get interesting case of misdetection for 'merge' option which has been
put into the middle of options with 'short_arg' - thus certainly past 65. (ASCII 'A').

To avoid confusion of short_arg with long_opt number - add  '128' to all such
non-short-arg options.
2011-09-16 12:10:02 +00:00
b565cb3503 Update 2011-09-16 12:01:48 +00:00
6e181ba96d 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
cd1e29b180 Trim spaces on EOL 2011-09-16 11:53:14 +00:00
b0f8a418b5 Remove vg at the test's end
Speedup this test by removing mirrored vg when it's not longer needed.
teardown() seems to be waiting here for too long.
2011-09-16 11:52:33 +00:00
adc43e35d3 Update WHATS_NEW. 2011-09-16 10:02:14 +00:00
02155338a6 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
396ebcef66 Update WHATS_NEW. 2011-09-15 20:01:21 +00:00
a9f4775dc3 When resizing LVs, always round in the safe direction, regardless of whether we
were called as lvresize or lvreduce.
2011-09-15 18:51:11 +00:00
34d290b424 Fix possible overflow of size if %FREE or %VG is used.
https://bugzilla.redhat.com/show_bug.cgi?id=737087
2011-09-15 15:26:40 +00:00
8d1a933b76 Fix vgchange activation of snapshot with virtual origin. 2011-09-14 18:20:03 +00:00
52301e7c5d 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
d9f3c324e6 Activate virtual snapshot origin exclusively (only on local node in cluster). 2011-09-14 14:20:16 +00:00
719a9e4605 Add suggest parentheses around '&&'
Follow gcc suggestion.
2011-09-14 10:03:15 +00:00
3bb7050e14 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
572d99cacc Add missing underscores to local static functions 2011-09-14 09:54:21 +00:00
f89aa98af5 Keep the old-style function definition 2011-09-14 09:53:32 +00:00
0168b2fe11 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
2c9cf3b73b 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
eb0af241f1 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
39feace42e 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
2d8a2f35c7 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
d954a7f991 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
40a234183c 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
bfd774a20a 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
7d8e615c0b 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
0bab63a818 reorder some status flag printing in gdbinit file. 2011-09-13 13:57:02 +00:00
3f21a5341d Updated testing script
Since attrs were extended by 2 new fields update check functions.
2011-09-09 13:19:19 +00:00
d8487f1f4f Append z to lv_attr if new blocks will be zeroed. 2011-09-09 01:15:18 +00:00
5bd65a2834 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
61b33c0a0a Adjust gdbinit script to new RAID status flag values. 2011-09-08 22:19:45 +00:00
a083187168 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
af71952d7a lvcreate/remove thin_pool and thin volumes (--driverloaded n only) 2011-09-08 16:41:18 +00:00
ad67fb4b73 Terminate pv_attr field correctly. (2.02.86) 2011-09-07 13:42:00 +00:00
e6273046f4 Fix typo 2011-09-07 09:48:49 +00:00
4961eeba52 Check if lp.origin exists
Currently needed for _determine_snapshot_type().
2011-09-07 09:25:51 +00:00
58da345e4e Improve man page style
Only reformat man pages.
2011-09-07 08:50:35 +00:00
8ff2e245ac Support break for vgchange and vgrefresh operation
Allow to break some lengthy vgchange and vgrefresh operation.
2011-09-07 08:41:47 +00:00
83ca5e6d5c Remove unused passed parameters 2011-09-07 08:37:48 +00:00
d05c996d48 Minor change for pv_create api
Switch int to unsigned type.
2011-09-07 08:34:21 +00:00
867e4cfffb Replace char class :space: with explicit chars
Some major distributions are still using 'mawk' and they are not using
the latest version - we end here with hidden dependency on the latest
version of mawk (1.3.4) while i.e. Debian Lenny seems to stay with 1.3.3.
So we end with completely broken  vgimportclone script on such system.

We would need to check for proper support of :space: and abort build if
it doesn't work or simplier replace [:space:] with [ \t] which seems
sufficient to make it work (as can be seen in this patch)

A better fix would be to use command line parameter override - leaving
as FIXME comment.

This patch makes t-vgimportclone.sh test passing on Lenny.
2011-09-07 08:31:16 +00:00
10ab5428df pool attach fns & more field renaming 2011-09-06 22:43:56 +00:00
704cb6b4e9 Convert data->pool 2011-09-06 22:35:44 +00:00
c455c4c1d9 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
d19192b20e 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
054c6c890a Detect sscanf recovering_region input error
Missing check for sscanf found by static analyzer.
2011-09-06 18:24:27 +00:00
ebb39e1041 Fix memory leak of allocated bitmap in error path
Found by static analyzer.
2011-09-06 18:15:43 +00:00
c5120c1a7a Log unlink() error 2011-09-06 18:11:21 +00:00
0de26cd346 else 2011-09-06 15:39:46 +00:00
77729280f6 tdata->tpool 2011-09-06 15:38:44 +00:00
f5a8f2d2ca only thin volumes need converting 2011-09-06 15:35:11 +00:00
e4b64bf719 lvcreate parsing for thin provisioning.
The rest is incomplete so this isn't usable yet.
2011-09-06 00:26:42 +00:00
096dbb58f9 Remove incorrect requirement for -j or -m from lvchange error message. 2011-09-05 12:54:29 +00:00
0b13efd7e5 Hack for build rules of lvmetad
FIXME
2011-09-02 14:49:00 +00:00
d522fa71f0 Add missing 'static' for local function
Avoid missing prototype warning.
2011-09-02 12:38:43 +00:00
ccc01ce94b Compile fix
Reflecting change in dm_config_value  float r -> float f.
2011-09-02 11:04:12 +00:00
0031b78938 temp notes on dealing with cascade 2011-09-02 01:59:07 +00:00
5c216d6eb2 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
c147bbddb3 Comments, FIXMEs, name changes. 2011-09-01 21:04:14 +00:00
985a6a65cb Updates to gdbinit file
1) Add more status flags for printing
2) Fix bug in lv_status_r processing for mirror segment type
2011-09-01 21:01:12 +00:00
9ab111abc0 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
eced331945 Add comments & remove always-included header. 2011-09-01 17:58:27 +00:00
6f6b2cdc52 Only build libdaemon.a when we need it at the moment. 2011-09-01 17:56:53 +00:00
d91c270d1c 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
1f5226d652 Match the prototype old-style declaration 2011-09-01 13:30:11 +00:00
997dabdb9e Keep the old-style prototypes 2011-09-01 13:25:50 +00:00
b90e9912f1 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
fa784f6198 Mark unreleased memory pools as internal error 2011-09-01 10:19:01 +00:00
066465803c Reflect dm_config API update 2011-09-01 10:16:32 +00:00
118fa896b7 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
4c76c264dc Mention --enable-lvmetad in WHATS_NEW. 2011-08-31 12:47:59 +00:00
66fc323292 Do not call prepare_lvmetad just yet in tests. 2011-08-31 12:42:55 +00:00
dbe351860e 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
178675bec5 Fix warnings in daemons/common. 2011-08-31 12:18:40 +00:00
2254b74598 Get rid of the old lvmetad Makefile. 2011-08-31 11:44:27 +00:00
26c828a598 Autoreconf for lvmetad patch 2011-08-31 11:39:32 +00:00
c4d973530f A compromise integration of LVMetaD into the build: I have kept all the
daemon/common code in a single libdaemon.a, which is completely private. This
is currently linked into the lvmetad binary, and will be linked into LVM (the
client part, since static linking only picks up only symbols that are actually
used). I have also added --enable/disable-lvmetad to ./configure; although the
current default is off, I expect this to be flipped to on shortly. There's no
LVM-side support yet, but when there is, even when built, it'll still need to
be enabled by an lvm.conf option.
2011-08-31 11:31:57 +00:00
731c45ff37 Update for resource leak 2011-08-31 08:23:33 +00:00
0b97ce28d6 Fix resource leak when strdup fails
Static analyzer noticed, strdup failing path leaks dmt structure.
2011-08-31 08:23:05 +00:00
51e1300519 Adapt LVMetaD to use the new dm_config interfaces. 2011-08-30 15:44:01 +00:00
5c43b9bda7 Adapt the daemon/common code to use the new dm_config interface. 2011-08-30 15:42:56 +00:00
d60c24dda8 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
4020e6db24 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
38c4b48f33 same for segtype_is_thin 2011-08-26 18:17:05 +00:00
dc2a994176 seg_is_thin includes both thin_pool and thin_volume 2011-08-26 18:15:14 +00:00
93b7108bf7 thin - hide unimplemented dso fn; remove duplicate origin_lv field; add
some lvcreate struct parms
2011-08-26 17:40:53 +00:00
6fb30e2313 Initial code for read/write of thin metadata lv segments 2011-08-26 13:37:47 +00:00
b300359824 Add registration of thin_pool segment
Register thin and thin_pool segment via multiple_segtypes.
2011-08-25 10:00:09 +00:00
fbacf137f2 Fix raid shared lib segtype registration (2.02.87). 2011-08-24 13:41:46 +00:00
750fff3bc7 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
0064f3a9a8 . 2011-08-19 23:01:20 +00:00
8f263acd48 Remove incorrect error message added in 2.02.87. 2011-08-19 22:55:07 +00:00
4c503ee2a6 post-release 2011-08-19 19:42:39 +00:00
13023bf932 clarify comment 2011-08-19 19:35:50 +00:00
8f6b060e7f tweak split/track/merge
How do you discover the value of N?
2011-08-19 17:36:13 +00:00
37086f40a1 spaces->tabs 2011-08-19 17:02:48 +00:00
946f96cda5 revert incomplete inconsistent log message change for now 2011-08-19 16:49:00 +00:00
c6a99b7ccb avoid multi-line calc with incorrect intermediate var contents 2011-08-19 16:41:26 +00:00
ab52d127bb pre-release 2011-08-19 16:31:00 +00:00
6ab3b611c7 restrict dm_tree_node_add_null_area 2011-08-19 16:26:02 +00:00
735254fba4 _ for static fns 2011-08-19 15:59:15 +00:00
29ab9ad5b3 Move RAID convert tests to new file, t-lvconvert-raid.sh
There is duplicate code in t-lvconvert-raid.sh and t-lvcreate-raid.sh.
This should be moved into a common file which is then sourced by these two
files.  I'll wait to move the duplicate code until I can talk to mornfall.
2011-08-18 19:56:17 +00:00
b87604e649 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
4fad401cd2 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
cc00073da7 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
bd1f90fd60 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
7058ed4431 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
4332bb3951 Add -V as short form of --virtualsize in lvcreate. 2011-08-17 15:15:36 +00:00
c5bfcfd65e 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
3bb841dfa1 makefile fixes 2011-08-12 13:03:35 +00:00
571a3ecff0 core removed with clean not distclean 2011-08-12 12:56:38 +00:00
19a05d9764 Do not remove makefile during "make clean". 2011-08-12 07:57:24 +00:00
927e33104a post-release 2011-08-12 02:34:08 +00:00
2955689c71 more pre-release fixes 2011-08-12 02:16:46 +00:00
a35e96114f Drop CCS* variables no longer used. 2011-08-12 01:52:16 +00:00
5fd6065e99 pre-release 2011-08-12 01:34:11 +00:00
0cf914b095 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
787fa3705d 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
a684497b3d 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
18d2cd332b Trivial, add void to ignore dm_snprinf result 2011-08-11 19:21:42 +00:00
9a9dde2d8c pre-release fixes incl make distclean and configure --with-raid=none/shared 2011-08-11 19:18:17 +00:00
470f8b1266 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
219b1d015b Add ability to down-convert RAID1 arrays.
Also, add some simple RAID tests to testsuite.
2011-08-11 18:24:40 +00:00
0e29db4a51 Update udev rules to skip DM flags decoding for removed devices
Skip decoding of DM flags when device is removed.

We currently need DM flags only for add|change events. So forking
dmsetup process for removed devices is a waste of CPU time.

Udev is already quite slow, so make it just a tiny bit faster.
2011-08-11 17:55:29 +00:00
fff1723b6f 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
93cecfbfb6 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
64d62e1ded 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
7ad0d47c3c 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
cc2dcab096 Remove dev name prefix from dmsetup line output if major and minor is used. 2011-08-11 17:06:24 +00:00
25f72cfd07 Fix possible format instance memory leaks and premature releases in _vg_read. 2011-08-11 16:31:40 +00:00
0390acff8c Suppress locking error messages in monitoring init scripts. 2011-08-11 15:27:46 +00:00
86f87f9673 Need 'ifdef' checks around RAID monitoring functions as well to catch the
case where the user does not want dmeventd support compiled in.
2011-08-11 14:00:58 +00:00
f19d62c8b2 Fix build of raid without dmeventd. 2011-08-11 13:30:36 +00:00
48aa36a654 Never ever use uninitialised descriptors if pipe() fails
(because of maximum open count fd exceeded or so).

Better return busy message, so even clients fail in more controlled way.

Without patch,  clvmd crashes with various strange backtraces
if under heavy load of connection requests.

https://bugzilla.redhat.com/show_bug.cgi?id=698393
https://bugzilla.redhat.com/show_bug.cgi?id=697945

(It still can OOM but that's different issue.)
2011-08-11 12:57:10 +00:00
9c3fd6948b Add dmeventd monitoring for RAID devices. 2011-08-11 05:00:20 +00:00
c65ebf3e70 Add RAID metadata devices to considered devices in _add_lv_to_dtree.
_add_lv_to_dtree must also add RAID metadata devices.
2011-08-11 04:18:17 +00:00
430335e24e Fix renaming of RAID logical volumes.
The function 'for_each_sub_lv', which rename uses, was not handling the
RAID metadata areas.  Thus, the metadata LVs were not being renamed.
2011-08-11 03:29:51 +00:00
e56eaf05f9 Just add new lines between header comment 2011-08-10 20:26:41 +00:00
e9bfcd0df0 Replace free_vg with release_vg
Move the free_vg() to  vg.c  and replace free_vg  with release_vg
and make the _free_vg internal.

Patch is needed for sharing VG in vginfo cache so the release_vg function name
is a better fit here.
2011-08-10 20:25:29 +00:00
340f6f334b Remove INCONSISTENT_VG flag
As this flag could not have been set by the current code - removing it.

Note: because of the wrong code logic this call:

lvmcache_update_vg(correct_vg, correct_vg->status & PRECOMMITTED &
			   (inconsistent ? INCONSISTENT_VG : 0));

had always passed '0' - now after flag removal it's passing
PRECOMMITTED flag in - this present functinal change in this patch.

To match the original functionality - 0 had to be always passed.
More testing is needed here.
2011-08-10 20:17:33 +00:00
46e3fe8cf4 Fix compiler warning.
Compiler complaining that meta_lv could be used uninitialized.  (Not true
because it is protected by 'clear_metadata'.)  I switched to using 'lv->vg',
as it makes no difference to vg_[write|commit].
2011-08-10 16:44:17 +00:00
311d319e0a If anything bad happens and unlocking fails
(here clvmd crashed in the middle of operation),
lock is not removed from cache - here is one example:

locking/cluster_locking.c:497       Locking VG V_vg_test UN (VG) (0x6)
locking/cluster_locking.c:113   Error writing data to clvmd: Broken pipe
locking/locking.c:399         <backtrace>
locking/locking.c:461         <backtrace>
  Internal error: Volume Group vg_test was not unlocked

Code should always remove lock info from lvmcache and update counters
on unlock, even if unlock fails.
2011-08-10 16:07:53 +00:00
6447934cff Initialise clvmd locks before lvm context to avoid open descriptor leaks.
(At least /dev/mapper/control is open after lvm context init.)
2011-08-10 11:00:32 +00:00
739cca872a autoreconf 2011-08-09 18:14:48 +00:00
0deb49e2b6 Remove obsoleted GULM clvmd cluster locking support. 2011-08-09 18:11:00 +00:00
bd7f41d83c 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
f9213d84e4 Suppress low-level locking errors and warnings while using --sysinit.
Today, we use "suppress_messages" flag (set internally in init_locking fn based
on 'ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES")'.
This way, we can suppress high level messages like "File-based locking
initialisation failed" or "Internal cluster locking initialisation failed".

However, each locking has its own sequence of initialization steps and these
could log some errors as well. It's quite misleading for the user to see such
errors and warnings if the "--sysinit" is used (and so the ignorelockingfailure
&& LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable). Errors and
warnings from these intermediary steps should be suppressed as well if requested.

This patch propagates the "suppress_messages" flag deeper into locking init
functions. I've also added these flags for other locking types for consistency,
though it's not actually used for no_locking and readonly_locking.
2011-08-09 11:44:57 +00:00
ab42676eff Remove unused 'origin' variable in lv_remove_single function. 2011-08-05 09:21:13 +00:00
67d0232816 Add missing check for allocation failure
Static analyzer discovered missing check.
2011-08-04 17:56:11 +00:00
b43795c364 Remove unused inconsistent_seqno
Last usage was removed in Petr's commit related to VG mda repair fix
where relaxed check starts to ignore inconsistencies coming from
PVs that are marked MISSING - thus removing unused variable.
2011-08-04 15:18:10 +00:00
9f6098f724 Add 'empty' command
Using empty command ';' here makes the code look nicer.
2011-08-04 14:54:48 +00:00
46d6fcc99a 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
63fe43c2f9 Remove self assigment which has no effect
Just a tiny code cleanup found by analyzer.
2011-08-04 14:11:28 +00:00
45e96ab875 Minor memory leak fix
Defer the test of the function return value after the string memory is released.
Otherwise in this error path the string would present memory leak.
(Thought in this case we are already out of memory...)
2011-08-04 12:40:24 +00:00
65073ca838 Add test for fcntl error in singlenode client code.
Static analyzer noticed this check could be handy.
2011-08-04 12:13:50 +00:00
96854e8d35 Remove --force option from lvrename manpage. 2011-08-04 10:14:42 +00:00
ced0c8cbd6 Add missing new line in lvrename help text. 2011-08-04 10:12:44 +00:00
01d49d0e71 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
801a1b1352 Change DEFAULT_UDEV_SYNC to 1 so udev_sync is used even without any config.
This should be set by default! Normally we have "activation/udev_sync = 1"
in lvm.conf (example.conf.in). But if we use lvm2 without any config file
(or without a definition within '--config' option) the DEFAULT_UDEV_SYNC
is used instead. Together with verify_udev_operations=0 (when we rely on
udev fully), this can cause races as the node could be missing when needed.

(See also https://bugzilla.redhat.com/show_bug.cgi?id=723144)
2011-08-02 10:49:57 +00:00
b4c05c8519 Add support for systemd file descriptor handover in dmeventd.
Systemd preloads file descriptors for us and passes them in for
newly spawned daemon when using on-demand fifo (or socket)
based activation.

This patch adds checks for file descriptors preloaded by
systemd and uses them instead of opening the FIFOs again
to properly support on-demand FIFO-based activation.

(We'll change FIFOs to sockets soon - but still this
part of the code will stay almost the same.)
2011-07-28 13:06:50 +00:00
9482fdae35 Add support for new oom killer adjustment interface (oom_score_adj).
The filename to adjust the oom score was changed in 2.6.36.
We should use oom_score_adj instead of oom_adj (which is still
there under /proc, but it's scheduled for removal in August 2012).

New oom_score_adj uses a range from -1000 (OOM_SCORE_ADJ_MIN,
disable oom killing) to 1000 (OOM_SCORE_ADJ_MAX).
2011-07-28 13:03:37 +00:00
63019dc656 autoreconf 2011-07-28 12:59:44 +00:00
c3f5210734 Configure and makefile changes for newly added systemd unit files. 2011-07-28 12:57:26 +00:00
5c4c36b135 Add systemd unit files for dmeventd. 2011-07-28 12:54:28 +00:00
4b20b480b1 lvmetad: Edit the MISSING_PV flags only after making a "reply" copy of the
metadata, which is then serialised and discarded. This fixes a couple of
outstanding TODO items about handling the MISSING flags correctly.
2011-07-25 17:59:50 +00:00
0574adcaa1 lvmetad: Check integrity of multiple metadata copies, i.e. ensure that seqno
equality implies metadata equality. Signal error in response to any update
requests that try to overwrite metadata without providing a higher seqno.
2011-07-25 15:51:51 +00:00
c33c147c9b lvmetad: A couple of TODOs, and fix a few trivial memory leaks. 2011-07-25 15:33:04 +00:00
95dd4eae53 Add simple test for read-only table reload suppression
Just a small test for previous libdm commit.
2011-07-25 08:41:52 +00:00
f2bf7a1cc0 Fix read-only identical table reload supression. 2011-07-24 23:59:03 +00:00
a2146d6548 Compare also file size to detect changed config file
Clvmd detects modifed config file before it takes lv_lock.
If the config file is changed rapidly - the change was ignored within
a seocnd ranged.  This patch adds also compare of file size.
So change like some flag for 0 to 1 would pass unnoticed - but
it's quick fix for failing test suite.

FIXME: Implement inotify solution.
2011-07-21 13:23:48 +00:00
3082fa5d4c lvmetad: Obliterate vg_status by returning the same information from
update_pv_status, saving a dozen lines of code and execution time of one
walkthrough of the PV list.
2011-07-20 21:33:41 +00:00
7d6fed35c0 lvmetad: Fix a possible infinite loop in vg_status. 2011-07-20 21:27:28 +00:00
81535db537 lvmetad: Robustify update_pv_status and remove an useless lookup. 2011-07-20 21:26:18 +00:00
b33c9d313f First stab at making lvmetad-core threadsafe. The current design should allow
very reasonable amount of parallel access, although the hash tables may become
a point of contention under heavy loads. Nevertheless, there should be orders
of magnitude less contention on the hash table locks than we currently have on
block device scanning.
2011-07-20 21:23:43 +00:00
503190e499 lvmetad: Avoid stale PV -> VG mappings on metadata update. 2011-07-20 18:45:32 +00:00
fdbde27ed9 Optimise PV -> VG lookups by using a UUID (hash) map. 2011-07-20 18:34:57 +00:00
54350d68ce Free up allocated memory before exiting, in lvmetad. 2011-07-20 18:24:49 +00:00
f342b6a862 Fix two small (but eventually unbounded) leaks in daemon-server.c. 2011-07-20 18:23:33 +00:00
28b6842556 Can't have a global memory pool in lvmetad (that would constitute an ongoing
memory leak) => remove it (it's been unused anyway).
2011-07-20 16:49:21 +00:00
ecb4ee0b5a Make lvmetad also report VGID in reply when adding a PV without MDAs (this
obviously only works for VGs that already had at least some MDA discovered).
2011-07-20 16:46:40 +00:00
05e87b6b65 Add code to lvmetad's testclient that scans an actual physical device,
effectively emulating a future "pvscan --lvmetad" command.
2011-07-20 15:15:41 +00:00
9f228ea974 Make lvmetad report the VG ID and status (complete, partial) in reply to pv_add
requests.
2011-07-20 15:14:17 +00:00
e36cd89437 Towards MISSING (PV) flag management in lvmetad. 2011-07-19 19:15:22 +00:00
d8f02da1e4 Make it possible to represent type-correct single-item arrays in config trees. 2011-07-19 19:12:38 +00:00
789ed50712 Add an API to config.h for creating values in the config_tree mempool. 2011-07-19 19:11:24 +00:00
df4758d73b Work out some more details in metadata update in lvmetad. 2011-07-19 16:48:13 +00:00
8cccdb25a9 Remove and unneeded parameter from build_parallel_areas_from_lv() 2011-07-19 16:37:42 +00:00
e1154dd09e Fix potential null ptr deref in 'origin_from_cow'
return NULL rather than segfaulting if lv->snapshot is not set
2011-07-19 16:23:52 +00:00
8e5d1c93eb More work on cache maintenance code in lvmetad: keep track of PV status. 2011-07-19 14:13:59 +00:00
f20e649ad1 Start filling in the core LVMetaD functionality and the corresponding
testclient bits.
2011-07-18 14:48:30 +00:00
8e72b3d6d6 Various improvements to the daemon-common code, including automated response
formatting from config trees provided by the daemon implementation.
2011-07-18 14:46:54 +00:00
8970d1b895 Improve format_buffer in daemon-shared.c, adding block formatting in addition
to string/integer (this propagates to the *simple* family of request/response
functionality).
2011-07-18 14:42:44 +00:00
056828e039 Revert the #include changes. Need to fix this at the #include site for now, and
eventually refactor the way we structure #includes in the all of the library.
2011-07-18 14:34:33 +00:00
8e1761a804 Slightly refactor the config code to allow better reuse (no functional change). 2011-07-18 13:26:08 +00:00
4ac59193ee Add a missing libdevmapper.h #include to lvm-types.h (for dm_list). 2011-07-18 13:24:48 +00:00
668f986b05 Add a couple missing #includes in uuid.h. 2011-07-18 13:24:14 +00:00
2d812dea99 Better version of failing 'should' test
where the naming is left completely on lvm.
(Commited code has been different version of test).
So here it should be able to figure out new free name and create a new LV.
2011-07-18 12:12:41 +00:00
e0c9b24a6d Adding test for repair when confusing metadata are found 2011-07-18 12:04:42 +00:00
b546c17105 LVM2 RAID design doc 2011-07-14 17:00:59 +00:00
1c8512eb62 Fix t-vgreduce-usage to stop relying on the persistent cache not seeing a
device that has been brought back from the dead: this sometimes fails with
clvmd (the cache is updated "too soon"). Instead, force a pvscan and rely on an
up-to-date cache as usual.
2011-07-11 12:13:07 +00:00
841a541051 post-release 2011-07-08 19:57:32 +00:00
4c67e55066 remove unnecessary lvconvert.h 2011-07-08 19:42:11 +00:00
136c2e70dc pre-release 2011-07-08 19:19:44 +00:00
f8b6b122ca 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
7a16e1f399 move doc to doc dir 2011-07-08 18:55:28 +00:00
e66cd0dc35 missing ifdef when new fn unused 2011-07-08 17:31:06 +00:00
4ccc44282e Remove dev name prefix from dmsetup line output if exactly one dev requested. 2011-07-08 17:08:19 +00:00
2b069d2ca5 Ignore activation/verify_udev_operations if dm kernel driver vsn < 4.18. 2011-07-08 16:49:04 +00:00
566939185e Fix warning for pvcreate over MD linear.
If MD linear device has set rounding (overload chunk size attribute),
the pvcreate command prints this warning:

  /dev/md0 sysfs attr level not in expected format: linear
2011-07-08 15:53:59 +00:00
1ba4781cb0 Need to snapshot lookup by uuid instead of name in case it's renamed. 2011-07-08 15:35:50 +00:00
2c860451a9 Log cookie values when incrementing/decrementing to give clues about races. 2011-07-08 15:34:47 +00:00
688a4e87ce Move snapshot removal activation logic into lib/activate. 2011-07-08 12:49:50 +00:00
7cd8120de1 Move snapshot deactivation logic into lib/activate, fixing the
teardown sequence.  (Previously the snapshot was deactivated while its
origin was active and before its removal was committed to disk, so
restarting after a crash at the point would leave corruption.)
2011-07-08 12:48:41 +00:00
225d1df8a7 report which dev was not found 2011-07-08 12:35:48 +00:00
459f6c60e6 Increase timeout for udev settle
For some unknown reason (atm) udev settle takes longer time on recent rawhide.
To pass the test - inrease the settle timeout.
2011-07-08 10:05:43 +00:00
1dc49506bc Cope with a PV only discovered missing when creating deptree. 2011-07-06 00:29:44 +00:00
f7b3c167b0 Abort operation if dm_tree_node_add_target_area fails. 2011-07-05 23:10:14 +00:00
9f67b0f0ed Always perform preload logic before suspending - not only in the case when we
have precommitted metadata.  (Necessary to avoid loading tables
while suspend in lvchange --refresh.)
2011-07-05 18:36:37 +00:00
7970cad6de decode cookie flags in debug msgs 2011-07-05 16:17:14 +00:00
84a6c240d5 Snapshots LVs are never loaded in their own right, only along with their
origin.
2011-07-05 01:08:42 +00:00
8f03913e0b Fix conditions using no_merging: only those using lv_is_merging_cow() should
have been converted, not pure lv_is_cow ones.
(Merging has no impact on how the pre-merged cow segment itself is loaded.)
2011-07-05 01:01:19 +00:00
30776aea04 first attempt to fix test 2011-07-04 16:27:27 +00:00
ec000e1dfa reinstate accidentally-removed lines to fix pvmove again 2011-07-04 14:56:58 +00:00
4b22b81391 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
cfafb8a92a RAID updates for gdbinit file 2011-07-01 16:15:25 +00:00
0eee66e257 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
34be5fb50f update pv_attr check for new missing attr 2011-06-30 19:32:51 +00:00
0c6b43a8ef When suspending, automatically preload newly-visible existing LVs
Let's find out if this makes things better or worse overall...
2011-06-30 18:25:18 +00:00
3dd7f795f5 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
3f98a2885d use remove -f 2011-06-30 09:17:49 +00:00
2fcba16688 teardown stray filesystems too 2011-06-30 09:15:53 +00:00
5beb23518d Use -f to remove device
Since some test may leave devices in suspend mode which would require
carefull order of resume operation - use '-f' to replace them with
error targets

For disable_dev  - when  'error' target is used for open count - treat
return code as ok (|| true) to avoid breaking futher test processing.
2011-06-30 09:08:22 +00:00
cf332f746e Try to force remove dm devices in after test fails. 2011-06-30 08:50:10 +00:00
2df71f33ac Try to remove any stray loop devices left behind by earlier aborted tests. 2011-06-30 01:17:37 +00:00
61a821884d test attempt to remove stray loop devs 2011-06-30 00:57:29 +00:00
0952bf42a8 Differentiate the request and response format, in daemon/common. 2011-06-29 22:20:14 +00:00
06577e86d8 Add age filter to dmsetup udevcomplete_all to minimise concurrency problems. 2011-06-29 21:56:46 +00:00
589154d209 make udev teardown conditional on using udev 2011-06-29 18:18:18 +00:00
73c5f313e5 teardown aborts if it hits an error, so better teardown semaphores earlier
as we need them later in the teardown process
2011-06-29 18:14:08 +00:00
637245e9f5 print any loop devs that weren't torn down 2011-06-29 17:37:30 +00:00
e2aa3cf6ae remove any stray semaphores after tearing down devs 2011-06-29 17:33:39 +00:00
08315e3ac4 Reinstate correct permissions when creating mirrors. 2011-06-29 17:05:53 +00:00
e145fa0e83 debug log readonly flag with ioctls 2011-06-29 16:08:33 +00:00
07324d6221 Append 'm' attribute to pv_attr for missing PVs. 2011-06-29 14:56:33 +00:00
ec8423ad76 Add uuids to dmsetup create cmds. 2011-06-29 12:37:51 +00:00
d5b96bdd95 use dmsetup remove -f as a better way of simulating a device "disappearing" 2011-06-29 12:33:18 +00:00
eed2109a93 Remove temporary failures now, but continue to give INTERNAL_ERROR. 2011-06-29 11:36:37 +00:00
283f4a0649 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
fe4a490ff3 Fix error message - the parameter name is '--mirrorlog' not '--log' 2011-06-29 02:06:26 +00:00
20f055bcb4 Remove unnecesary conditional.
The conditional is not just unnecessary, it would have been wrong.  The code
is suppose to be checking if the 'splitmirrors_ARG' is negative, but it
instead is checking 'mirrors_ARG'.  Rather than changing the argument being
checked, I've pulled the check entirely because 'splitmirrors_ARG' is already
guarenteed to not be negative by virtue of the fact that it is a 'int_arg'.
Negative values will be caught in _process_command_line().
2011-06-28 21:28:35 +00:00
daf9efb723 Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd 2011-06-28 13:42:15 +00:00
2e7ab82b92 More readahead tests. 2011-06-28 09:43:28 +00:00
0fac155599 more fixes to readahead etc. 2011-06-28 09:24:13 +00:00
77d16e2e39 Change to still sync with udev (to test waiting for rules) then to verify udev
operations like it used to (which will perform them on systems with
non-std dev dirs where test udev rules aren't installed).
2011-06-28 00:38:26 +00:00
de0e6b4119 Remove enforcement of udev verification when using non-standard /dev location.
If you change the dev dir, it's your responsibility to adjust udev rules
or tell lvm not to use udev too.
2011-06-28 00:23:06 +00:00
1c365783e8 Selectively enable/disable udev rules. 2011-06-28 00:11:46 +00:00
eb81f7ab87 Move _set_lvm_fallback into toolcontext, fix string comparison (/devtest
matched /dev) and note that function should go anyway as it can be
overriding a valid config.
2011-06-27 23:43:04 +00:00
ed04c9d702 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
ea687806b3 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
1a3dab6075 Add int/str lookup routines specific to the reply (in client) and request (in
server) for nicer-looking code (thin wrapping around find_config_{int,str}).
2011-06-27 14:03:58 +00:00
e828044efd Also parse the config_tree on the client end (daemon-client.c). 2011-06-27 13:58:11 +00:00
a084548cce Parse the incoming config tree in daemon-server.c, providing the
daemon-specific handler with a struct config_tree pointer to look things up in.
2011-06-27 13:46:45 +00:00
8d9710bed6 LVMetaD build hack: link to lvm-internal &c. and add a simple test script. 2011-06-27 13:44:33 +00:00
0783429215 Implement daemon_send_simple and use it in the testclient. 2011-06-27 13:15:49 +00:00
0d7965aeca Do not open the socket with SOCK_NONBLOCK in daemon-client, since we have no
use for that behaviour (at least for now).
2011-06-27 13:14:53 +00:00
b5997e5b05 Call daemon_close before exit in the testclient. 2011-06-27 12:27:34 +00:00
fbcc8450b8 Sketch out the actual on-wire format in daemon-client.h documentation, and add
a simplified send interface.
2011-06-27 12:26:54 +00:00
24e1d27e54 remove unused var after recent patch 2011-06-24 23:39:09 +00:00
ec98c72b04 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
4ec4a0c105 Fix to preserve exclusive activation of mirror while up-converting.
When an LVM mirror is up-converted (an additional image added), it creates
a temporary mirror stack.  The lower-level mirror in the stack that is
created was not being activated exclusively - violating the exclusive nature
of the original mirror.  We now check for exclusive activation of a mirror
before converting it, and if found, we ensure that the temporary mirror
is also exclusively activated.
2011-06-23 14:00:58 +00:00
3477dd6c19 Fail allocation if number of extents not divisible by area count
Allocation should fail early if this condition is not met.

Quick fix for https://bugzilla.redhat.com/show_bug.cgi?id=707779
2011-06-23 10:53:24 +00:00
38444f0f13 Fix issue preventing cluster mirror creation.
Mirrors used to be created by first creating a linear device and then adding
the other images plus the log.  Now mirrors are created by creating all the
images in one go and then adding the log separately.  The new way ran into
the condition that cluster mirrors cannot change the log type (in the case
of creation, from core -> disk) while the mirror is not active.  (It isn't
active because it is in the process of being created.)  The reason this
condition is in place is because a remote node may have the mirror active, and
we don't want to alter the log underneath it.

What we really needed was a way of checking if the mirror was active remotely
but not locally, and in that case do not allow a change of the log.  I've added
this check, and cluster mirrors can now be created again.
2011-06-22 21:31:21 +00:00
ffd363ef38 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
c99e816790 Disable udev fallback and add --udevfallback option to dmsetup. 2011-06-17 14:55:51 +00:00
1bc531301e Disable udev fallback by default and add activation/udev_fallback to lvm.conf.
We've used udev fallback code till now to check whether udev
created/removed the entries in /dev correctly and if not,
a repair was done (giving a warning messagea about that).

This patch adds a possibility to enable this additional check
and subsequent fallback only when required (debugging purposes
mostly) and trust udev completely.

So let's disable the fallback code by default and add a new
configuration option "activation/udev_fallback".

(The original code for creating the nodes will still be used
in case the device directory that is set in lvm.conf differs
from the one that udev uses and also when activation/udev_rules
is set to 0 - otherwise we would end up with no nodes/symlinks
at all)
2011-06-17 14:50:53 +00:00
7e6c6e0741 Code move of vg_mark_partial() up in stack
It's useful to keep the partial flag cached - so just move the call
for vg_mark_partil_lvs() into import_vg_from_config_tree() so it gets
evaluated before it goes through the lvmcache.

This patch should not present any functional change.

Note: It is rather temporal solution - proper place is probably inside the
'read' call back - but needs some more discussion.
For now using this minor hack.
2011-06-17 14:39:10 +00:00
9313eb28be Remove unused internal flag ACTIVATE_EXCL from the code 2011-06-17 14:30:58 +00:00
df535c251f Remove test for status flag
As the ACTIVATE_EXCL could be set only in clvmd code - there is no
use for this test in lv_add_mirrors() function only called from
tools context.

FIXME: Add cluster test case for this.
2011-06-17 14:27:34 +00:00
e954b58f29 Add couple FIXMEs around suspicious code 2011-06-17 14:24:18 +00:00
5b1254a741 Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag
Let's hope all conditions has been properly converted.
2011-06-17 14:22:48 +00:00
4626847312 Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. 2011-06-17 14:17:16 +00:00
55a359615f Add lv_activate_opts structure
To avoid modification of 'read-only' volume group structure
add a new structure to pass local data around the code for LV
activation.

As origin_only is one such flag - replace this parameter with new
struct lv_activate_opts.

More parameters might eventually become part of lv_activate_opts.
2011-06-17 14:14:19 +00:00
e5749424a4 What's new. 2011-06-15 17:48:35 +00:00
9ae83a8ea9 Fix RHBZ 651590 (failure to lock LV results in failure to repair mirror after
transient error), stemming from the following sequence of events:

1) devices fail IO, triggering repair
2) dmeventd starts fixing up the mirror
3) during the downconversion, a new metadata version is written

--> the devices come back online here

4) the mirror device suspend/resume is called to update DM tables
5) during the suspend/resume cycle, *pre*-commit metadata is read;
   however, since the failed devices are now back online, we get back
   inconsistent set of precommit metadata and the whole operation fails

The patch relaxes the check that fails in step 5 above, namely by ignoring
inconsistencies coming from PVs that are marked MISSING.
2011-06-15 17:45:02 +00:00
55525d6a92 Add proper udev library context initialization and finalization to liblvm.
This was missing in liblvm and it caused all udev-related operations to
not take effect when using liblvm, e.g. obtaining the list of devices from udev
db instead of scanning the whole /dev which also recreated the .cache as a side
effect. This was also the case with udisks-lvm-pv-export prober which is run
from within udev rules whenever the CHANGE event is fired.
2011-06-15 13:29:48 +00:00
f9ef876aab Fix lvreduce stripe rounding up from previous commit. 2011-06-15 10:56:52 +00:00
691e08ff76 Add a skeleton for lvmetad, a test client, and a temporary Makefile to build
them. These are currently mostly for testing the daemon-common code. LVMetaD
functionality is expected to trickle in soon though.
2011-06-14 02:36:38 +00:00
763e834367 Common daemon code: Implement basic socket-based communication infrastructure
(both client and server side). The server handles each connection in a separate
thread.
2011-06-14 02:34:18 +00:00
359ca22912 Fix last snapshot removal to avoid table reload while a device is suspended. 2011-06-13 22:28:04 +00:00
6094919b5c Fix fields in warning message. 2011-06-13 03:53:02 +00:00
ccadc42707 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
e5d134ff97 Fix 'pvs -o pv_all' to include label fields. (Also removed recursion.) 2011-06-12 19:49:40 +00:00
60578c20cb Disable critical section internal errors until this can be fixed properly
in libdevmapper.
2011-06-12 00:23:50 +00:00
bb7b8d8780 Fix --mirrorlog mirrored. 2011-06-11 12:55:31 +00:00
76564e3168 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
19f592f230 Fix kernel version test (RHEL: 2.6.32-123). 2011-06-09 19:48:26 +00:00
a543712431 Fix mirrored stripe reduction.
Patch adds check for stripe not only in direct
LV segment but also in mirror image segment.

This prevents bugs like:

# lvcreate -i2 -l10 -n lv vg_test
# lvconvert -m1 -i1 vg_test/lv

# lvreduce -f -l1 vg_test/lv
  WARNING: Reducing active logical volume to 4.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Reducing logical volume lv to 4.00 MiB
  Segment extent reduction 9 not divisible by #stripes 2
  Logical volume lv successfully resized

# lvremove -f vg_test
  Segment extent reduction 1 not divisible by #stripes 2
  LV segment lv:0-4294967295 is incorrectly listed as being used by LV lv_mimage_0
  Internal error: LV segments corrupted in lv_mimage_0.
2011-06-09 19:38:56 +00:00
10f5ecdc64 Validate mirror segments size
Currently some operation with striped mirrors lead
to corrupted metadata, this patch just add detection of such
situation.

Example:
# lvcreate -i2 -l10 -n lvs vg_test
# lvconvert -m1 vg_test/lvs

# lvreduce -f -l1 vg_test/lvs
  Reducing logical volume lvs to 4.00 MiB
  Segment extent reduction 9not divisible by #stripes 2
  Logical volume lvs successfully resized

# lvremove vg_test/lvs
  Segment extent reduction 1not divisible by #stripes 2
  LV segment lvs:0-4294967295 is incorrectly listed as being used by LV lvs_mimage_0
  Internal error: LV segments corrupted in lvs_mimage_0.
2011-06-09 19:36:16 +00:00
4964e2d615 Fix extent rounding for striped segments.
We should never remove more extents than requested by user,
so round up to next stripe boundary during lvreduce.

Also this fixes round to zero sized LV bug:

# lvcreate -i2 -I 64k -l10 -n lvs vg_test
# lvreduce -f -l1 vg_test/lvs
  Rounding size (1 extents) down to stripe boundary size for segment (0 extents)
  WARNING: Reducing active logical volume to 0
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Reducing logical volume lvs to 0
  Failed to suspend lvs
2011-06-09 19:34:49 +00:00
4abb15db5f Fix kernel version parsing in tests, use common function. 2011-06-09 18:58:00 +00:00
bb685d4e6c Fix another occurrence of linux kernel version check. 2011-06-09 15:52:59 +00:00
15d64a0899 Accept kernel version 3 (3.0-rc and similar). 2011-06-09 15:07:40 +00:00
81594343d3 Fix topology test.
Kernel version is misparsed in Fedora rawhide, just test sysfs file.

SCSI_DEBUG_DEV is no longer exported, use provided file instead.
2011-06-09 14:26:47 +00:00
fab0de8998 Fix create_temp_name to replace any '/' found in the hostname with '?'.
There's a possibility someone will use the '/' in the hostname. Since we
generate a temporary file name (path) including the hostname, any '/' would
be ambiguous.

We can always set such hostname using 'sethostname' from unistd.h. But the
'hostname' command already includes the check and removes the '/' char.
However, some old versions still allow that.
See: https://bugzilla.redhat.com/show_bug.cgi?id=711445.

Since this is only a temporary name and the possibility of this error is
quite negligible, we don't need any complex escape sequence here, just a
simple char replace.
2011-06-08 08:49:53 +00:00
42a13432d0 missing space in mesg 2011-06-06 12:08:42 +00:00
db40789590 Also check in the pe_start API test that the disks have not been touched. 2011-06-04 21:55:25 +00:00
af8966c42e Add an API test that shows how to find a value of pe_start for a VG without
actually creating the VG on-disk.
2011-06-04 21:46:34 +00:00
e01642db66 Fix a few compile warnings.
clvmd-command.c:84:2: warning: implicit declaration of function ‘init_test’
lvm-functions.c:141:3: warning: too many arguments for format
2011-06-03 09:05:30 +00:00
9e1376e5a1 Use append but except query for dlm locks:-) 2011-06-02 09:08:16 +00:00
28ba223ca9 Always use append to file in lvmdump (selinux policy - no file truncation).
Workaround dmsetup ls --tree (terminal ioctl for width).
(Until isatty() will be allowed by selinux policy.)
2011-06-02 09:02:03 +00:00
970f51c102 Use /var/run/lvm for lvmetad socket. 2011-06-02 08:58:05 +00:00
fe920a6a65 Propagate test mode to clvmd to skip activation and changes to held locks. 2011-06-01 21:16:55 +00:00
0ee514bc81 Defer writing PV labels to vg_write.
Store label_sector only in struct physical_volume.
2011-06-01 19:29:31 +00:00
6f86b62946 Report sector containing label in verbose message. 2011-06-01 19:26:38 +00:00
761b6a2189 Permit --available with lvcreate so non-snapshot LVs need not be activated. 2011-06-01 19:21:03 +00:00
7f77f9d400 Report sector containing label in verbose message. 2011-06-01 15:30:36 +00:00
ce2c219999 Clarify error message when unable to convert an LV into a snapshot of an LV. 2011-06-01 12:24:15 +00:00
5771fee535 Use new dev_open_readonly fn to prevent opening devices for read-write when not necessary.
Before, we used vg_write_lock_held call to determnine the way a device is
opened. Unfortunately, this opened many devices in RW mode when it was not
really necessary. With the OPTIONS+="watch" rule used in the udev rules,
this could fire numerous events while closing such devices (and it caused
useless scans from within udev rules in return).

A common bug we hit with this was with the lvremove command which was unable
to remove the LV since it was being opened from within the udev rules. This
patch should minimize such situations (at least with respect to LVM handling
of devices).

Though there's still a possibility someone will open a device 'outside' in
parallel and fire the event based on the watch rule when closing a device
once opened for RW.
2011-05-28 09:48:14 +00:00
2c8102f7a1 First draft of a document describing how we will automatically and
incrementally assemble (possibly multi-component, like LVM) storage devices.
2011-05-25 21:43:12 +00:00
28714df966 test 2011-05-24 14:12:36 +00:00
7979602398 test 2011-05-24 14:10:55 +00:00
c807c139bf test 2011-05-24 14:10:55 +00:00
72ca3644cb test 2011-05-24 14:09:41 +00:00
329213cc57 test 2011-05-24 14:09:41 +00:00
dbcb996ba2 test 2011-05-24 14:01:32 +00:00
52a85391f6 test 2011-05-24 14:00:57 +00:00
67f4a7cec4 test 2011-05-24 13:59:16 +00:00
a52b5b8b61 test 2011-05-24 13:54:37 +00:00
77d331c2bb test 2011-05-24 13:53:26 +00:00
4834e71812 test 2011-05-24 13:53:26 +00:00
20fdf0231e Add and use dev_open_readonly and variations. 2011-05-24 13:36:57 +00:00
6a7c185e30 Mention code layout in lvmetad DESIGN. 2011-05-23 14:46:48 +00:00
be761afa4c Do not log a superfluous stack message when the lv is properly processed 2011-05-19 13:59:22 +00:00
7d37e830ca More work on the common daemon framework. Make things compile, too. 2011-05-15 11:02:29 +00:00
3777234077 More scavenging of common daemon code, this time the clvmd local socket setup
sequence.
2011-05-13 09:34:12 +00:00
2ca65cc602 Start filling in some of the common daemon (server-side) functionality, taking
dmeventd code as a starting point.
2011-05-13 08:45:46 +00:00
c2ac1bee92 First go at the lvmetad client-side interface. 2011-05-13 08:17:26 +00:00
51fb2c7551 First stab at the prototypes of the daemon-common functionality (to be
eventually shared by dmeventd, lvmetad and clvmd).
2011-05-13 08:07:28 +00:00
b904359bac Initial design document for LVMetaD, building on the draft from June of last
year, incorporating the outcomes of today's and yesterday's discussions.
2011-05-12 17:49:46 +00:00
7c9f1ae834 Do not issue an error message when unable to remove .cache on read-only fs. 2011-05-12 12:42:47 +00:00
37bfb6508d Update WHATS_NEW. 2011-05-07 15:52:50 +00:00
7b64fccba1 Rewrite vgreduce --removemissing --force, using existing primitives:
lv_remove_with_dependencies and mirror_remove_missing (the latter coming from
lvconvert). Remove substantial amount of legacy code.
2011-05-07 15:52:16 +00:00
95986e42a1 Add a new entry point in the mirror lvconvert code, for removing missing mirror
images and/or logs, without attempting any further actions.
2011-05-07 13:56:13 +00:00
d792fc925c When glibc needs buffers for line buffering of input and output buffers, it
allocates these buffers in such way it adds memory page for each such buffer
and size of unlock memory check will mismatch by 1 or 2 pages.

This happens when we print or read lines without '\n' so these buffers are
used. To avoid this extra allocation, use setvbuf to set these bufffers ahead.

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
Reviewed-by: Milan Broz <mbroz@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2011-05-07 13:50:11 +00:00
f9e419bad6 Make vg_mark_partial_lvs also clear existing PARTIAL_LV flags, so it can be
issued repeatedly on the same VG, keeping the PARTIAL_LV flags up to date.
2011-05-07 13:32:05 +00:00
9a3e6e423c test update without WHATS_NEW to check it gives warning now 2011-04-29 19:06:17 +00:00
efe82852a3 test 2011-04-29 19:05:11 +00:00
02dd81f4be test 2011-04-29 19:01:59 +00:00
912c86e526 test 2011-04-29 19:01:59 +00:00
0285bb3312 test 2011-04-29 18:57:09 +00:00
935e65c9ae test 2011-04-29 18:56:35 +00:00
39235f0894 test 2011-04-29 18:48:50 +00:00
781242009d test 2011-04-29 18:43:31 +00:00
d9b479b3c1 test 2011-04-29 18:41:46 +00:00
a5543b5345 test 2011-04-29 18:40:55 +00:00
f3342c7f89 test 2011-04-29 18:40:14 +00:00
6f776305ee post-release 2011-04-29 17:05:20 +00:00
938cc8daa7 wake buildbot 2011-04-29 16:27:09 +00:00
e63f55fcc7 commands/toolcontext.c:578: warning: ‘udev_dir’ may be used uninitialized in this function
commands/toolcontext.c:576: warning: ‘udev_dir_len’ may be used uninitialized in this function

Bogus - suppress them.
2011-04-29 16:23:39 +00:00
24e17116d3 pre-release 2011-04-29 16:12:21 +00:00
d6a05b6fd7 pre-release clean-ups 2011-04-29 00:21:13 +00:00
9139a95616 Add missing cleanup for vgimportclone script 2011-04-28 22:17:06 +00:00
425d920af6 clean up critical section patch 2011-04-28 20:29:59 +00:00
3b2eb14eea Missing space in debug message 2011-04-28 19:59:17 +00:00
7722eea88c Set pv_min_size to 2048KB to exclude floppy drives.
Previously was 512.
2011-04-28 17:33:34 +00:00
c52cf64cea Add missing pkg_config_init check with --enable-udev_sync. 2011-04-28 16:54:32 +00:00
d1ca1d9cb0 Adjust pvmove man page wording.
Add missing --alloc anywhere to example and mention that snapshots and
mirrors can't be moved.
2011-04-28 16:22:47 +00:00
ed244de069 Uncomment obtain_device_list_from_udev setting in lvm.conf.
Just for consistency with other settings we already have in lvm.conf.
2011-04-26 09:09:24 +00:00
2b78acd736 autoreconf 2011-04-22 12:13:05 +00:00
0967b9504b Use common udev_get_dev_dir() to get current device directory managed by udev. 2011-04-22 12:07:35 +00:00
79bed56a52 Obtain device list from udev by default if LVM2 is compiled with udev support.
Also, add a new 'obtain_device_list_from_udev' setting to lvm.conf with which
we can turn this feature on or off if needed.

If set, the cache of block device nodes with all associated symlinks
will be constructed out of the existing udev database content.
This avoids using and opening any inapplicable non-block devices or
subdirectories found in the device directory. This setting is applied
to udev-managed device directory only, other directories will be scanned
fully. LVM2 needs to be compiled with udev support for this setting to
take effect. N.B. Any device node or symlink not managed by udev in
udev directory will be ignored with this setting on.
2011-04-22 12:05:32 +00:00
87edad13ea Move common libudev code to lvm-wrappers.[ch].
...so we can use it throughout.
2011-04-22 11:59:59 +00:00
b7c85c8aa6 Require libudev >= 143 when compiling with udev support.
Old versions of libudev < 143 were experimental and unstable. Require recent
and stable versions only (version 143 is old enough anyway).
2011-04-22 11:56:41 +00:00
207060d03c Disable nightly test for vgimportclone until proper fix is made.
This fails on lenny buildslave for some reason.
For now disable the vgimportclone part of the test until proper fix.

Let the first part of the test still run though, which shows pvs working
with duplicate pvs.
2011-04-21 19:06:00 +00:00
b641164ece Add vgimportclone symlink for nightly test. 2011-04-21 17:42:58 +00:00
8a997e48fb Add nightly test for vgimportclone and querying of vgnames with duplicate pvs.
Related to rhbz 697959.

This test fails prior to these two commits:
commit af112eb2c9
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Thu Apr 21 13:15:26 2011 +0000

    Skip check for NULL before dm_free

    dm_free makes this test itself.

commit 91419c3e86
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Thu Apr 21 13:13:40 2011 +0000

    Fix use of released vgname and vgid
2011-04-21 17:03:38 +00:00
af112eb2c9 Skip check for NULL before dm_free
dm_free makes this test itself.
2011-04-21 13:15:26 +00:00
91419c3e86 Fix use of released vgname and vgid
Avoid using of already released memory when duplicated MDA is found.

As get_pv_from_vg_by_id() may call lvmcache_label_scan() use the local copy
of the vgname and vgid on the stack as vginfo may dissapear and code was
then accessing garbage in memory.

i.e.  pvs  /dev/loop0
(when /dev/loop0 and /dev/loop1 has same MDA content)

Invalid read of size 1
   at 0x523C986: dm_hash_lookup (hash.c:325)
   by 0x440C8C: vginfo_from_vgname (lvmcache.c:399)
   by 0x4605C0: _create_vg_text_instance (format-text.c:1882)
   by 0x46140D: _text_create_text_instance (format-text.c:2243)
   by 0x47EB49: _vg_read (metadata.c:2887)
   by 0x47FBD8: vg_read_internal (metadata.c:3231)
   by 0x477594: get_pv_from_vg_by_id (metadata.c:344)
   by 0x45F07A: _get_pv_if_in_vg (format-text.c:1400)
   by 0x45F0B9: _populate_pv_fields (format-text.c:1414)
   by 0x45F40F: _text_pv_read (format-text.c:1493)
   by 0x480431: _pv_read (metadata.c:3500)
   by 0x4802B2: pv_read (metadata.c:3462)
 Address 0x652ab80 is 0 bytes inside a block of size 4 free'd
   at 0x4C2756E: free (vg_replace_malloc.c:366)
   by 0x442277: _free_vginfo (lvmcache.c:963)
   by 0x44235E: _drop_vginfo (lvmcache.c:992)
   by 0x442B23: _lvmcache_update_vgname (lvmcache.c:1165)
   by 0x443449: lvmcache_update_vgname_and_id (lvmcache.c:1358)
   by 0x443C07: lvmcache_add (lvmcache.c:1492)
   by 0x46588C: _text_read (text_label.c:271)
   by 0x466A65: label_read (label.c:289)
   by 0x4413FC: lvmcache_label_scan (lvmcache.c:635)
   by 0x4605AD: _create_vg_text_instance (format-text.c:1881)
   by 0x46140D: _text_create_text_instance (format-text.c:2243)
   by 0x47EB49: _vg_read (metadata.c:2887)

Add testing script
2011-04-21 13:13:40 +00:00
35c174671b Always copy all tests to builddir regardless of T/S, since subsequent runs
(possibly with different T or S) skip that step.
2011-04-19 15:28:17 +00:00
5a2322eb7d Improve the discard documentation. Also improve discard code in
pv_manip.c to properly account for case when pe_start=0 and the first
physical extent is to be released (currently skip the first extent to
avoid discarding the PV label).
2011-04-13 18:26:39 +00:00
63b91e514e Use uint32_t rather than uint64_t. 2011-04-12 22:04:04 +00:00
e65d6e4a11 Add "devices/issue_discards" to lvm.conf.
Issue discards on lvremove if enabled and both storage and kernel have support.
2011-04-12 21:59:01 +00:00
77392833f4 fix s/then/than/ typo in lvm.conf.5.in 2011-04-12 21:21:08 +00:00
5828e7e584 fix s/then/than/ typos in 'pv_min_size' section and fold floppy example
into documentation preamble.
2011-04-12 20:44:41 +00:00
efc5d04ec7 Replace dm_snprintf with strncpy
My previous patch fixed incorrect error check for dm_snprintf.
However in this particular case - dm_snprintf has been used differently -
just like strncpy + setting last char with '\0' - so the code had to return
error - because the buffer was to short for whole string.

Patch replaces it with real strncpy.
Also test for alloca() failure is removed - as the program behaviour
is rather undefined in this case - it never returns NULL.
2011-04-12 14:13:17 +00:00
ba7d6c9dd0 Make the mirror log checks in t-lvconvert-repair-policy a bit more strict
(i.e. accurate).
2011-04-12 12:39:24 +00:00
81095cc6ea This patchset refactors some reporting code and completes the remaining
lvseg properties for lvm2app, 'devices' and 'seg_pe_ranges'.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2011-04-12 12:24:29 +00:00
103b5a7538 Fix incorrect tests for dm_snprintf() failure
As the memory is preallocated based on arg size in these cases,
the error would be quite hard to trigger here anyway.
2011-04-09 19:05:23 +00:00
1f7f7cb701 Fix some unmatching sign comparation gcc warnings
Simple replacement for unsigned type - usually in for() loops.
2011-04-08 14:40:18 +00:00
83a0836f31 Add missing printf attributes
These attributes were missing in previous patch, that was adding
instrumentation for printf formating string parameter.
2011-04-08 14:21:34 +00:00
7e3042b541 Use dm_snprintf
and fix differently signed comparation.
2011-04-08 14:18:40 +00:00
7e27d8f4db Better const cast logic
(although still gcc gives const violation warning)
2011-04-08 14:14:57 +00:00
34b60db59f Fix some forgotten -Wold-style-definition gcc warnings 2011-04-08 14:13:08 +00:00
42f177b3e2 Newer gcc doesn't need this trick
In fact it now generates an opposite warning about using undefined variable.
2011-04-08 14:11:40 +00:00
9f8c06b31c Thanks to Zdenek Kabelac (kabi) for pointing out that I was using
dm_pool_free incorrectly.  This check-in fixes that incorrect usage.

I've also added a WHATS_NEW line to reflect the changes I made to allow
lv_extend to operate on 0 length intrinsically layered LVs (i.e mirrors
and RAID).  I forgot that in the last commit.
2011-04-07 21:49:29 +00:00
98ac36c049 This patch adds the ability to extend 0 length layered LVs. This
allows us to allocate all images of a mirror (or RAID array) at one
time during create.

The current mirror implementation still requires a separate allocation
for the log, however.
2011-04-06 21:32:20 +00:00
69dda2cfa0 Add rudimentary versioning to the dmevend protocol, allowing us to detect the
(protocol) version of the running dmeventd on the client side.

Right now this is only used in dmeventd -R.
2011-04-04 16:11:09 +00:00
251265821f Cleanup fid finalization code in free_vg and allow exactly the same fid to be set again for a PV/VG.
Actually, we can call vg_set_fid(vg, NULL) instead of calling
destroy_instance for all PV structs and a VG struct - it's the same
code we already have in the vg_set_fid.

Also, allow exactly the same fid to be set again for the same PV/VG
Before, this could end up with the fid destroyed because we destroyed
existing fid first and then we used the new one and we didn't care
whether existing one == new one by chance.
2011-04-01 14:54:20 +00:00
64f51a3797 Finalize PV format instances properly in lvm_vg_write fn.
lvm_vg_write fn reinitializes the vg->removed_pvs list. We have to finalize
all PV format instances attached to PVs found in the original list.
2011-04-01 13:44:51 +00:00
3b0651049b Fix free_vg order
As now the FID management is more complex, the code inside free_vg needs
to access some parts of memory pools which were not needed before.

For this - makes the order of unlock_and_free_vg() unconditional.
Keek using unlock_and_free_vg() API function.

For properly working VG locking mechanism only the alphabeting locking
orderer needs to be preserved.

TODO: there could be few more code parts simplified when we 'officially'
support of referencies between different memory pools.
2011-03-30 14:35:00 +00:00
f00b069236 Testing: remove -q from grep
to avoid any problems with pipe breaking.
2011-03-30 13:39:24 +00:00
a754694221 Use created hash tables for quick check of LV, PV.
Instead of searching linear list of all LVs, PVs - use created hash tables
also for quick mapping between LV.

(Note - for small number of PVs or LVs the overhead of the hash is bigger).

TODO: Use hash tables in volume_group structure directly.
2011-03-30 13:35:51 +00:00
954464e5aa Keep the cache content when the exported vg buffer is matching
Instead of regenerating config tree and parsing same data again,
check whether export_vg_to_buffer does not produce same string as
the one already cached - in this case keep it, otherwise throw cached
content away.

For the code simplicity calling _free_cached_vgmetadata() with
vgmetadata == NULL as the function handles this itself.

Note: sometimes export_vg_to_buffer() generates almost the same data
with just different time stamp, but for the patch simplicity,
data are reparsed in this case.

This patch currently helps for vgrefresh.
2011-03-30 13:14:34 +00:00
57f9272a6a Few more files filtered from memory locking
Code located in these files should not be used in critical section.
2011-03-30 13:06:13 +00:00
649d3a0fdf Word alignment for strings
Align strdup char* allocation just on 2 bytes.
It looks like wasting space to align strings on 8 bytes.
(Could be even 1byte - but for hashing it might eventually get better
perfomance - but probably hardly measurable).

TODO: check on various architectures it's not making any problems.
2011-03-30 12:57:03 +00:00
b74ae69aad Optimise error message write to _lvm_errmsg
Isn't usually perfomance critical - but log_error is used i.e.for debuging,
this code noticable slows down the processing.

Added 512KB limit to avoid memory exhastions in case of some endless loop.

TODO: use _lvm_errmsg buffer only when lvm2api needs it.
2011-03-30 12:53:04 +00:00
d951cb0e68 Keep noreturn attribute for lvm_thread_fn
Even thought my gcc seems to not need it, as it's deduced from pthread_exit(),
keep it here for older compiler to avoid getting warnings.
2011-03-30 12:48:16 +00:00
1fa8125125 Valgrind updates
Avoid locking sum testing with valgrind compilation.

Make memory unaccessible in the valgrind for dm_pool_abadon_object.

Valgrind hinting should not be needed in _free_chunk for dm_free.
2011-03-30 12:43:32 +00:00
f251589b6b Better shutdown for clvmd
'a small step' towards cleaner shutdown sequence.
Normally clvmd doens't care about unreleased memory on exit -
but for valgrind testing it's better to have them cleaned all.

So - few things are left on exit path - this patch starts to remove
just some of them.

1. lvm_thread_fs is made as a thread which could be joined on exit()
2. memory allocated to local_clien_head list is released.
   (this part is somewhat more complex if the proper reaction is
   needed - and as it requires some heavier code moving - it will
   be resolved later.
2011-03-30 12:36:19 +00:00
305e8a8a5c Fix reading of unitialized memory
Could be reached via few of our lvm2 test cases:

==11501== Invalid read of size 8
==11501==    at 0x49B2E0: _area_length (import-extents.c:204)
==11501==    by 0x49B40C: _read_linear (import-extents.c:222)
==11501==    by 0x49B952: _build_segments (import-extents.c:323)
==11501==    by 0x49B9A0: _build_all_segments (import-extents.c:334)
==11501==    by 0x49BB4C: import_extents (import-extents.c:364)
==11501==    by 0x497655: _format1_vg_read (format1.c:217)
==11501==    by 0x47E43E: _vg_read (metadata.c:2901)

cut from t-vgcvgbackup-usage.sh
--
pvcreate -M1 $(cat DEVICES)
vgcreate -M1 -c n $vg $(cat DEVICES)
lvcreate -l1 -n $lv1 $vg $dev1
--

Idea of the fix is rather defensive - to allocate one extra element
to 'map' array which is then used in _area_length() - where the
loop checks, whether next map entry is continuous.

By placing there always one extra zero entry -
we fix the read of unallocated memory, and we make sure the data would
not make a continous block.

FIXME: there could be a problem if some special broken lvm1 data would be imported.
As the format1 is currently not really used - leave it for future fix
and use this small hotfix for now.
2011-03-30 12:30:39 +00:00
2ebc24197a Simplify pool debug initialization
zalloc pool structure and skip zeroing members.
2011-03-30 12:16:15 +00:00
db6446aa2f Fix 2 signess warnings reported by gcc
Replace int with unsigned counter.
Replace snprintf with dm_snprintf.
2011-03-30 12:14:36 +00:00
9458a9da09 Use id_equal instead of strncmp()
More consistent and easier to read.
2011-03-29 21:57:56 +00:00
8207745583 Add attribute printf 2011-03-29 21:56:53 +00:00
b29742d2fa Add attribute printf
gcc suggested to add these attributes to instrumentat
printf arguments. Adding it for internal functions as well.
2011-03-29 21:53:46 +00:00
c2759c3644 Const warning fixes
With recent update of dm_report_field_string() API call to accept
completely const objects - we no longer need loose constness here
and keep it forwarding.
2011-03-29 21:49:18 +00:00
a26bc49296 Fix access to released memory
Invalid primary_vginfo was supposed to move all its lvmcache_infos to
orphan_vginfo - however it has called _drop_vginfo() inside the loop
that released primary_vginfo itself - thus made the loop using released
memory.

Use _vginfo_detach_info() instead and call _drop_vginfo after
th loop is finished.

Valgrind trace it should fix:

Invalid read of size 8
   at 0x41E960: _lvmcache_update_vgname (lvmcache.c:1229)
   by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
   by 0x441393: _text_read (text_label.c:329)
   by 0x442221: label_read (label.c:289)
   by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
   by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
   by 0x45B4A6: lv_from_lvid (metadata.c:3381)
   by 0x41B555: lv_activation_filter (activate.c:1346)
   by 0x415868: do_activate_lv (lvm-functions.c:343)
   by 0x415E8C: do_lock_lv (lvm-functions.c:532)
   by 0x40FD5F: do_command (clvmd-command.c:120)
   by 0x413D7B: process_local_command (clvmd.c:1686)
 Address 0x63eba10 is 16 bytes inside a block of size 160 free'd
   at 0x4C2756E: free (vg_replace_malloc.c:366)
   by 0x41DE70: _free_vginfo (lvmcache.c:980)
   by 0x41DEDA: _drop_vginfo (lvmcache.c:998)
   by 0x41E854: _lvmcache_update_vgname (lvmcache.c:1238)
   by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
   by 0x441393: _text_read (text_label.c:329)
   by 0x442221: label_read (label.c:289)
   by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
   by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
   by 0x45B4A6: lv_from_lvid (metadata.c:3381)
   by 0x41B555: lv_activation_filter (activate.c:1346)
   by 0x415868: do_activate_lv (lvm-functions.c:343)

problematic line:
dm_list_iterate_items_safe(info2, info3, &primary_vginfo->infos)
2011-03-29 21:34:18 +00:00
999238d4fa Fix sending uninitilised bytes in cluster messages
Fix 2 more functions sending cluster messages to avoid passing uninitilised bytes
and compensate 1 extra byte attached to the message from the clvm_header.args[1]
member variable.
2011-03-29 21:05:39 +00:00
9e1eeffe6f Fix -Wold-style-definition gcc warnings 2011-03-29 20:30:05 +00:00
fb5983fb8f Remove double braces
Clang gives notice about possible confusion as commonly double bracces are
used when some assignment is done inside them.
2011-03-29 20:19:03 +00:00
4497409a31 gdbinit update
When doing lv_status_r on a sub_lv, do not climb the tree up past the
starting point.
2011-03-29 12:53:13 +00:00
01b265e08d s/MIRROR_NOTSYNCED/LV_NOTSYNCED/ - Flag will may refer to more than just mirrors 2011-03-29 12:51:57 +00:00
012b164bae Reduce amount of vgremove and vgchange calls
A bit noticable time defference when whole test-suite is run through valgrind.
2011-03-28 11:35:20 +00:00
2b6028fd13 Rename _check_version 2011-03-27 13:44:08 +00:00
8420ee864d Use hard-coded /dev/mapper/control details for 2.6.36+ kernels and simplify
associated code.  (Some obscure configurations that happened to work before
are no longer supported.)
2011-03-25 23:50:35 +00:00
d010b440a3 Fix unhandled condition in _move_lv_segments
If _move_lv_segments is passed a 'lv_from' that does not yet
have any segments, it will screw things up because the code
that does the segment copy assumes there is at least one
segment.  See copy code here:
        lv_to->segments = lv_from->segments;
        lv_to->segments.n->p = &lv_to->segments;
        lv_to->segments.p->n = &lv_to->segments;

If 'segments' is an empty list, the first statement copies over
the values, but the next two reset those values to point to the
other LV's list structure.  'lv_to' now appears to have one
segment, but it is really an ill-set pointer.
2011-03-25 22:02:27 +00:00
e720e51548 Replace malloc with zalloc when creating segment_type's 2011-03-25 21:59:42 +00:00
6bc394736e cosmetic change - swapping one macro for another
When I see 'seg_is_mirrored', I expect the argument to be an lv_segment.
In this case, it is lvcreate_params.  Both structures, have a 'segtype'
entry which the macro dereferences.  However, it just seems easier to
understand if we do 'segtype_is_mirrored' instead.
2011-03-25 21:56:28 +00:00
be59769771 What's new. 2011-03-24 16:03:32 +00:00
07834012c5 In some cases, we could end up with a mirrored LV without a MIRRORED flag. In
other cases, the code could wind up removing wrong number of mirrors. In yet
other cases, we could remove the right number of mirrors, but fail to respect
the removal preferences (i.e. keep an image that was requested to be removed
while removing an image that was requested to be kept). Under some
circumstances, remove_mirror_images could also get stuck in an infinite loop.

This patch should fix all of the above undesirable behaviours.

Signed-off-by: Petr Rockai <prockai@redhat.com>
Reviewed-by: Jonathan Brassow <jbrassow@redhat.com>
2011-03-24 12:28:02 +00:00
123c9b8de5 Release allocated memory on closedown
Release allocated buffers before exit() in debug singlenode - so it's not
poping out in valgrind as memory leak.
2011-03-24 10:45:00 +00:00
1d250e8cb3 Fix last checkin - added error message text wrong. 2011-03-20 02:00:52 +00:00
7c626d5c9a Improve debug stack trace
dm_check_version reports log_error() - so use return_NULL.
2011-03-18 13:21:02 +00:00
a2222288b5 Mitigate some warnings if running as non-root user.
LVM doesn't behave correctly if running as non-root user,
there is warning when it detects it.

Despite this, it produces many error messages, saying nothing.
See https://bugzilla.redhat.com/show_bug.cgi?id=620571

This patch fixes two things:
1) Removes eror message from device_is_usable() which has no
information value anyway (real warning is printed inside it).

2) it fixes device-mapper initialization, if we support
core dm module autoload and device node is present, it should
fail early and not try recreate existing and correct node.
(non-root == permission denied here)

N.B. In future code should support user roles, some more
drastic checks in code are probably contraproductive now.
2011-03-18 12:17:57 +00:00
cb385da467 Watch out for collisions in GDB global namespace.
Better 'lv_status_r' printing.
2011-03-14 18:05:56 +00:00
0084e7b633 Add missing \0 for grown debug object
Attach \0 for proper char* display - otherwise somewhat random message could
be displayed in debug more and read of unpredictable read of uninitilized
memory values could happen.
2011-03-14 17:00:57 +00:00
e8dd7c08fe Revert this commit
This buffer allocation must have been problem somewhere else.
(as sizeof() already has the 'extra' '\0' included).
For now reverting this commit.
2011-03-13 23:18:30 +00:00
1847de3d68 Fix allocation of system_id
As code uses strncpy(system_id, NAME_LEN) and doesn't set '\0'
Fix it by always allocating NAME_LEN + 1 buffer size and with zalloc
we always get '\0' as the last byte.

This bug may trigger some unexpected behavior of the string operation
code - depends on the pool allocator.

FIXME: refactor this code to alloc_vg.
2011-03-13 23:05:48 +00:00
d8d824c6c5 Use proper size of strncpy
Avoid reading extra character if we expect to have there '\0'.
2011-03-13 23:01:08 +00:00
77e3ec4e28 Fix buffer allocation size for uuid string
We have 3 components and traling '\0' so allocate proper room for all of them.
Problem was nicely hidden by allocation from pool and allocation aligment
offset - so to trigger real problem with this one is actually hard.
2011-03-13 22:57:51 +00:00
0e88dec738 Fix usage of readlink
Return value of readlink limits valid string size.
Characters after returned size present some garbage to printf.
Fix it by placing '\0' on the return size value.
2011-03-13 22:52:16 +00:00
4d86ffec2e Remove compile warning for lock_id.
%llx --> PRIx64
2011-03-13 18:08:26 +00:00
4366379b3d lv_status_r now prints out status of attached log LVs
(Print layout could be nicer... :(
2011-03-11 22:25:36 +00:00
876d50dbe2 lv_status_r has been fixed-up so that it supports infinite LV stacking
(It does not yet follow 'log_lv' or 'origin' links.)
2011-03-11 22:16:38 +00:00
eae4a9eb03 detect RAID* LV and segment flags. 2011-03-11 18:22:39 +00:00
3a609bcd5d Use format instance mempool where possible and adequate. 2011-03-11 15:10:16 +00:00
4428aa0fdf Various cleanups for fid mem and ref_count changes.
Missing free_vg on error_path in lvmcache_get_vg fn. Call destroy_instance
only if the fid is not part of the vg in backup_read_vg fn (otherwise it's
part of the VG we're returning and we definitely don't want to destroy it!).
2011-03-11 15:08:31 +00:00
fef82df095 Call destroy_instance for any PVs found in VG structure during vg_free call.
This is necessary for proper format instance ref_count support. We iterate
over vg->pvs and vg->removed_pvs list and the ref_count is decremented and
then it is destroyed if not referenced anymore.
2011-03-11 15:06:13 +00:00
359d2505d3 Add new free_pv_fid fn and use it throughout to free all attached fids.
Since format instances will use own memory pool, it's necessary to properly
deallocate it. For now, only fid is deallocated. The PV structure itself
still uses cmd mempool mostly, but anytime we'd like to add a mempool
in the struct physical_volume, we can just rename this fn to free_pv and
add the code (like we have free_vg fn for VGs).
2011-03-11 14:56:56 +00:00
d3d6337ecf Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
This is essential for proper format instance ref_count support. We must
use these functions to set the fid everywhere from now on, even the NULL
value!
2011-03-11 14:50:13 +00:00
aa7198a530 Make create_text_context fn static and move it inside create_instance fn.
We'd like to use the fid mempool for text_context that is stored
in the instance (we used cmd mempool before, so the order of
initialisation was not a matter, but now it is since we need to
create the fid mempool first which happens in create_instance fn).

The text_context initialisation is not needed anywhere outside the
create_instance fn so move it there.
2011-03-11 14:45:17 +00:00
9e125c5708 Add mem and ref_count fields to struct format_instance for own mempool use.
Format instances can be created anytime on demand and it contains
metadata area information mostly (at least for now, but in the future,
we may store more things here to update/edit in a PV/VG). In case we
have lots of metadata areas, memory consumption will rise. Using cmd
context mempool is not quite optimal here because it is destroyed too
late. So let's use a separate mempool for format instances.

Reference counting is used because fids could be shared, e.g. each PV
has either a PV-based fid or VG-based fid. If it's VG-based, each PV has
a shared fid with the VG - a reference to VG's fid.
2011-03-11 14:38:38 +00:00
2b62190d4b Use new alloc_fid fn for common format instance initialisation. 2011-03-11 14:30:27 +00:00
466c7e43b4 Missed merge fix in vg_validate patch 2011-03-10 22:39:36 +00:00
41d9b8a647 Document pv_min_size in lvm.conf manpage 2011-03-10 15:20:10 +00:00
685e54f4dd Optimise _eat_space and _get_token
Makes the code more readable and has a smaller number of memory
accesses thus it's small optimisation as well.

For _get_token() optimize number parsing. Check for '.' char only
if it's not a digit. Move pointer incrementation into one place.

For _eat_space() check only p->te for '\0' in skipping of comment line.
Avoid check for '\0' when we know it is space. Also master while loop
doesn't need checking p->tb for '\0'. We just need to check p->tb
isn't already at the end of buffer. This could give 'extra' loop cycle
if we are already there - but safes memory access in every other case.
2011-03-10 14:51:35 +00:00
f84700a182 Keep pool name also for pool-fast
It's cheap to keep this name - and it is useful for 'non pool debug code'
compilation.
2011-03-10 14:49:01 +00:00
46e72765b6 Indent spaces to tabs 2011-03-10 14:47:22 +00:00
20d6bb2d9c Refactor code for _lv_postoder
Add _lv_postorder_vg() - for calling _lv_postorder() for every LV from VG.
We use this in 2 places -  vg_mark_partial_lvs() and vg_validate()
so make it as a one function.

Benefit here is - to use only one cleanup code and avoid
potentially duplicate scans of same LVs.
2011-03-10 14:40:32 +00:00
51d61a76da gdbinit - A GDB init file to help while debugging LVM.
Copy this file as '.gdbinit' to your home directory or your working
directory.  It adds the following commands to gdb:
 - first_seg
 - lv_status
 - lv_status_r
 - lv_is_mirrored
 - seg_item
 - seg_status
 - segs_using_this_lv

You can get a list of these user-defined commands by typing:
(gdb) help user-defined

You can get more information on each command by typing:
(gdb) help <command>
2011-03-10 13:45:12 +00:00
8fb9f86271 Use hash tables for validating names
Accelerate validation loop by using lvname, lvid, pvid hash tables.
Also merge pvl loop into one cycle now - no need to scan the list twice.
List scan is stopped when dm_hash_insert fails.

The error message with loop_counter1 is no longer provided - however
the message has been misleading anyway.
2011-03-10 13:11:59 +00:00
0c586a7359 Fix dmsetup man page typo (John Bradshaw) 2011-03-10 13:11:45 +00:00
938ebb30bf Use void pointer instead of char for binary key
dm_hash binary functions takes void* key - so there is no need to cast
pointers to char* (also the hash key does not have trailing '\0').

This is slight API change, but presents no change for the API user side
it just allows to write code easier as the casting could be removed.
2011-03-10 12:48:40 +00:00
b5d7757c3d Refactor vg allocation code
Create new function alloc_vg() to allocate VG structure.

It takes pool_name (for easier debugging).
and also take vg_name to futher simplify code.

Move remainder of _build_vg_from_pds  to _pool_vg_read
and use vg memory pool for import functions.
(it's been using smem -> fid mempool -> cmd mempool)
(FIXME: remove mempool parameter for import functions and use vg).

Move remainder of the _build_vg to _format1_vg_read
2011-03-10 12:43:29 +00:00
d8601fd4b6 Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name. 2011-03-10 03:03:03 +00:00
38c3277bf6 Use empty string instead of /dev// for LV path when there's no VG.
Don't allocate unused VG mempool in _pvsegs_sub_single.
2011-03-09 12:44:42 +00:00
20c6ce9e13 Do not send random bytes in message
Fixing few issues:

struct clvm_header  contains  'char args[1]' - so adding '+ 1' here
for message length calculation is 1 byte off.
Message with last byte uninitialized is then passed to write function.
Update also related arglen.

Initialise xid and clintid to 0.

Memory allocation is checked for NULL
2011-03-08 22:48:50 +00:00
d9785ae4f1 Fix reading byte from char params[-1] position
When the ->params string is empty - memory access is made on the byte
before allocated buffer (catched by valgrind) - in the case it would
constain 0x20 - it would even overwrite this buffer.
So fix by checking len > 0 before doing such access.
Also slightly optimise this loop from repeated strlen call.
2011-03-08 22:43:19 +00:00
b118538f94 Fix clvmd return code for bad options.
We should return exit code 2 for unknown option.

Patch also adds standard --help option instead.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=666991
2011-03-08 13:27:39 +00:00
c2501a7747 Fix test for 8k page (fails on Sparc architecture). 2011-03-06 18:28:09 +00:00
f19572f894 Use lvm_getpagesize wrapper 2011-03-06 17:52:07 +00:00
03a1410b12 Fix hardcoded page size, fixing test fails with 8k page and new kernel. 2011-03-06 16:47:43 +00:00
40c79aba89 Move secure flag warning to verbose level.
This feature is not yet upstream and becuase cryptsetup in next version
uses this flag, it will cause a lot of noise on old kernels.
2011-03-05 21:17:19 +00:00
68a58ad799 Fix reading of released memory
lvseg_segtype_dup used memory pool vg memory pool for strind duplication.
However this one gets released before reporting happens so the command like:

pvs -o segtype

prints data from already released memory pool. Thanks to the fact there
is not much allocation happing after the VG is released, the memory
stays unmodified and correct result is printed.

Fix adds support for mempool passed parameter (like other similar
query commands) and uses dm_report memory pool for string duplication.
2011-03-05 12:14:00 +00:00
ddb128b039 Make the lock test a little bit better... 2011-03-04 15:04:08 +00:00
3e881b9726 Wait until dmeventd properly starts in test. 2011-03-04 14:19:18 +00:00
7b0f2031c4 Leave some time to scheduler
Looks like scheduler prefers running task before exiting tasks.
So leave some time to finish running flock process.
2011-03-03 16:04:53 +00:00
786d8aa089 Avoid using pipes on lv commands
Failure on pipe kills lv command and produces memory stacktrace.
Add 'true' for empty grep/sed to avoid generating stacktrace.

This should help with long time (7min) for this test on Lenny testing maching
(mimage was filler with stacktrace and each word was used as LV name).
2011-03-03 15:46:05 +00:00
263c008cf5 Fix test, "echo n" is not needed when -y is specified. 2011-03-03 14:16:08 +00:00
7fdd43860e Lower severity of selabel_lookup and matchpathcon failure to log_debug. 2011-03-03 13:05:40 +00:00
06f8f76ca3 Do not echo y to lvconvert
This lvconvert is now able to complete operation automatically without question.
So remove  'echo y |'  - it's breaking pipe on some bash versions.

i.e.:
+ echo y
./t-lvconvert-mirror-basic.sh: line 104: echo: write error: Broken pipe

while command has completed this operation succesfully
2011-03-03 12:30:33 +00:00
79770354fe Fix syslog initialisation in clvmd to respect lvm.conf setting. 2011-03-02 23:38:22 +00:00
e717fa3bef Increase check timeout again.
It fails on my s390x Hercules emulator otherwise. :)
2011-03-02 20:14:39 +00:00
227457e20d PE size overflows, on most architectures it is catch by "PE cannot be 0"
but s390x unfortunately return something usable.

Always use unit64 in inital parameter check.
2011-03-02 20:00:09 +00:00
9c2c45f192 Use 64bit unsigned value for maximum stripe size test.
While STRIPE_SIZE_LIMIT * 2 is basically UINT_MAX, 32bit integer
value can already overflow durin arg size parsing.

(This really happens in test where --stripesize 4294967291 is used,
in s390x uint overflow and this test is ineffective.)
2011-03-02 16:56:06 +00:00
fd30a1c96e Do not run past the end of an array in dmeventd's _handle_request when faced
with an unknown command ID.
2011-03-02 14:20:48 +00:00
c537579e61 Fix test to use explicit /dev/mapper/ node, /proc/mounts should not change this...
(failed on RHEL5)
2011-03-02 13:49:29 +00:00
45ba9f9c2f As requested in BZ 454618:
- dmeventd -R will continue to start up even if no dmeventd is currently
  running + a test for this behaviour
- add -R to dmeventd manpage
2011-03-02 12:49:13 +00:00
67f411afc0 Use a copy if moving an mda from pv fid to vg fid.
We'll destroy the pv fid (with all mdas in it) after merging all pv mdas to
a vg in _text_pv_setup fn, hence we need to use a copy here!
2011-03-02 10:23:29 +00:00
38d96413d0 Make add_metadata_area_to_pv/remove_metadata_area_from_pv static.
No need to put these in format-text.h, it's not used anywhere else actually.
2011-03-02 10:19:14 +00:00
7d5f270516 Indent case part properly 2011-03-02 08:41:55 +00:00
5c9b44a61e Add missing return 2011-03-02 08:40:28 +00:00
fa61ff55de Accept multiple mapped device names on many dmsetup command lines. 2011-03-02 02:44:56 +00:00
9a45e3dbbb Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
Include an implicit dm_task_update_nodes() within dm_udev_wait().
2011-03-02 00:29:57 +00:00
5993dc5b48 Rather return success if skipping udev wait. 2011-03-01 23:44:07 +00:00
c9aeaebd1a Invert condition for READLINE check 2011-03-01 23:29:14 +00:00
c588dfbdfa Fix _create_and_load_v4 not to lose the --addnodeoncreate setting (1.02.62). 2011-03-01 23:27:06 +00:00
bc7397105c Build test.c also without readline library
Allow bulding of this testing tool also without readline library.
Outputs message about build without readline library then.
2011-03-01 23:18:40 +00:00
6795c361c1 Fix tests if udevadm missing (old udev). 2011-03-01 22:28:27 +00:00
81957c524b Quick fix to compile lvm2api tests when possible
Do not build lvm2api tests when lvm2api lib is not enabled.
2011-03-01 21:30:43 +00:00
070787d579 Fix some compile warnings on RHEL5
- returned char not needed to be explicitly const
- warn if pipe() fails in clvmd (more fixes here needed for error paths...)
- assign (and ignore) read() output in drain buffer
2011-03-01 20:17:56 +00:00
75029c2d42 Rephrase backup message. 2011-02-28 20:50:01 +00:00
dcb8c448d3 Fix void pointer arithmetic warning in pool debug code 2011-02-28 19:54:30 +00:00
d55b658e6c Add fall through comments
Add comments to switch case construct.
2011-02-28 19:53:03 +00:00
bb9b9c6514 Remove dead code
Remove code which is no longer used.
Code which has been using msg_malloced was removed in 2007.
2011-02-28 19:50:15 +00:00
2163383728 Test result of dm_task_set_uuid 2011-02-28 19:47:22 +00:00
23b5c9b9e5 Use backward compatible configuration for test
Currently the test are not properly working with new code.
Use settings for the previous behaviour.

FIXME: update tests to properly test new allocation policies.
2011-02-28 19:44:21 +00:00
179139735c mention vgreduce in pvremove man page 2011-02-28 19:40:04 +00:00
9938f0c674 Improve pvremove error message when PV belongs to a VG. 2011-02-28 19:35:09 +00:00
0de865f20b Add a hint for manual revert if there's an error in pv_write, vg_write, vg_commit for pvresize. 2011-02-28 17:08:09 +00:00
fc04cb0266 Use pv->vg_name directly instead of pv->vg->name in _text_pv_write.
This also prevents a possible segfault during an automatic repair
when the PV does not belong to a VG anymore and we call pv_write_orphan.
2011-02-28 17:05:48 +00:00
7f250ab142 Allow non-orphan PVs with two metadata areas to be resized.
We allow writing non-orphan PVs only for resize now. The "orphan PV" assert
in pv_write fn uses the "allow_non_orphan" parameter to control this assert.
However, we should find a more elaborate solution so we can remove this
restriction altogether (pv_write together with vg_write is not atomic, we
need to find a safe mechanism so there's an easy revert possible in case of
an error).
2011-02-28 13:19:02 +00:00
eb9b172ec0 Fix check for log-only allocation in new alloc normal loop. 2011-02-27 01:16:52 +00:00
a499caabfb Various changes to the allocation algorithms: Expect some fallout.
There is a lot to test.

Two new config settings added that are intended to make the code behave
closely to the way it did before - worth a try if you find problems.
2011-02-27 00:38:31 +00:00
c4dbd497b2 vgconvert is fixed now to work with the changes in metadata area handling - enable the tests.
Add a small fix that preserves pe_start for lvm1 PVs when being converted.

(this fix needs to be replaced with something more clever, but let's have this working now)
2011-02-25 14:12:14 +00:00
ed08b81e18 Allow only orphan PVs to be resized even with two metadata areas. 2011-02-25 14:08:54 +00:00
8a7a401cae Revert the patch for vgconvert to work with recent changes in metadata area handling.
This should work now with the help of the patch from previous commit.
2011-02-25 14:02:53 +00:00
cb38146acb Read PV metadata information from cache if pv_setup called with pv->fid == vg->fid.
If the PV is already part of the VG (so the pv->fid == vg->fid), it makes no
sense to attach the mdas information from PV to a VG. Instead, we read new
PV metadata information from cache and attach it to the VG fid.
2011-02-25 13:59:47 +00:00
1d96b805e1 Fix a bug in metadata location calculation, cleanup pv_add_metadata_area fn.
This bug (a missing line) caused the 2nd MDA area location to be calculated
incorrectly and it didn't fit the disk size properly.

(https://www.redhat.com/archives/lvm-devel/2011-February/msg00127.html)
2011-02-25 13:50:02 +00:00
65a3e6454b Remove a few size_t type warnings. 2011-02-22 10:01:11 +00:00
96171b0c03 Add inactive table query support for kernel driver >= 4.11.6 (RHEL 5.7). 2011-02-21 16:26:23 +00:00
4dd4e14fd8 %ld -> PRIu64 2011-02-21 13:09:27 +00:00
01a0facd7e WHATS_NEW 2011-02-21 12:40:46 +00:00
7ef77b52a8 Temporarily disable 'convert a VG from lvm2 to lvm1 format' test until a known issue is resolved.
Otherwise we get an error:

  PV segment VG free_count mismatch: 32 != 33
  PV segment VG extent_count mismatch: 32 != 33
2011-02-21 12:37:33 +00:00
249d85882f Fix metadata balance code to work with recent changes in metadata handling
interface (with the changes in format_instance).
2011-02-21 12:33:16 +00:00
5261cc0402 Add old_uuid field to struct physical_volume so we can still reference a PV
with its old UUID when we're changig it (the cache as well as metadata area
index has the old uuid that we need to use to access the information!)
2011-02-21 12:31:28 +00:00
5cbb49ed94 Fix vgconvert code to work with changes in metadata area handling and changes
in format_instance. Add new 'vg_convert' function.
2011-02-21 12:29:21 +00:00
c7c59e41cd Change pvresize code to work with new metadata handling interface and allow
resizing a PV with two metadata areas.
2011-02-21 12:27:26 +00:00
771b5db044 Change pv_write code to work with the changes in metadata handling interface
and changes in format_instance.
2011-02-21 12:26:27 +00:00
d0ffde9114 Remove unused _mda_setup fn. This functionality is covered by new pv_add_metadata_area fn. 2011-02-21 12:25:16 +00:00
12353bda0a Change the code throughout to use new pv_initialise and modified pv_setup fn.
Change pv_create code to work with these changes together with using new
pv_add_metadata_area fn to add metadata areas for a PV being created.
2011-02-21 12:24:15 +00:00
e1b1f2f961 Separate new pv_initialise function out of the original pv_setup code.
pv_initiliase initialises a new PV
pv_setup sets up an existing PV with a VG
2011-02-21 12:20:18 +00:00
d58036bc42 Add new pv_remove_metadata_area interface function. 2011-02-21 12:17:54 +00:00
83f5538979 Add new pv_add_metadata_area interface function. 2011-02-21 12:17:26 +00:00
cdc08fcc63 Remove useless mdas parameter for pv_read (from now on, we store mdas in a
format instance)
2011-02-21 12:15:59 +00:00
ec441b4c5b Add format instance support for pv_read code. 2011-02-21 12:13:40 +00:00
f78aec2b52 Initialise a new PV-based format instance for a PV that is being created. 2011-02-21 12:12:32 +00:00
afc29a3d69 Add vg_set_fid function to change VG format instance.
This function also sets a reference to a new VG format instance for all PVs
that are part of the VG so the PV-VG interconnection is consistent after the
change.
2011-02-21 12:10:58 +00:00
251029609d Change the code throughout for recent changes in format_instance handling. 2011-02-21 12:07:03 +00:00
3a760ad8cd Change create_instance to create PV-based as well as VG-based format instances.
Add supporting functions to work with the format instance and metadata area
structures stored within the format instance. Add support for simple indexing
of metadata areas using PV id and mda order (for on-disk PV only for now, we
can extend the indexing even for other mdas if needed - we only need to define
a proper key for the index).
2011-02-21 12:05:49 +00:00
37c5724db2 Change and generalise struct format_instance for PV and VG use. 2011-02-21 12:01:22 +00:00
1ebe15e7ce Handle decimal digits with --units instead of ignoring them silently.
Fix remaining warnings and compile with -Wpointer-arith.
2011-02-18 23:09:55 +00:00
aed211833d Fix gcc warnings for unused variables
Put dead assigment code into comment.
2011-02-18 16:17:56 +00:00
e382b2b990 Add debug message for open_count failure
Report  open_count problem as debug.

Function using _node_has_closed_parents decides whether
it's error or could be ignored.
2011-02-18 16:13:56 +00:00
2045501076 Use return_0 to get bactrace 2011-02-18 15:05:40 +00:00
f43f5f7004 Add some backtraces for error paths in process_each_lv 2011-02-18 15:02:25 +00:00
16aa248a35 Memory unlock allows 1 page difference
As the kernel seems to be doing weird things during
mlock -> munlock -  allow 1 page locking difference without
warning - and log just debug message for a 1 page difference.

Allocation happens outside critical section probably during
log_warn printing.

Should make tests passing for now.
2011-02-18 14:51:04 +00:00
e50d9e2c57 Const fixing
Fixing some const warnings - with API change in:

int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,

Change is needed - as lvm2api expects const behaviour here.
So vg_extend() is doing local strdup for unescaping.

skip_dev_dir return const char* from const char* vg_name.

Rest of the patch is cleanup of related warnings.

Also using dm_report_filed_string() API change to simplify
casting in _string_disp and _lvname_disp.
2011-02-18 14:47:28 +00:00
dad7e11288 API change - support more const arg
As dm_report_field_string() doesn't modify content of data pointer,
it can be marked as const.

It's slight API change - but doesn't require any change on the user side
and supports wider range of arguments without const casting.
(i.e. we may use as paramater const lv struct this way:  &lv->name)
2011-02-18 14:38:47 +00:00
f09295a4bd Void* arithmetic replaced with char* 2011-02-18 14:34:41 +00:00
c0a8ab7699 Fix !DEVMAPPER_SUPPORT build
Fix build when devmapper is disabled.
2011-02-18 14:29:39 +00:00
b11dd1f7b3 Remove fs_unlock after failed suspend
Explicit fs_unlock() after failed suspend is not need -
as it will happen automatically with nearest lv_info()
or vg_unlock().
2011-02-18 14:26:31 +00:00
6bea349da8 Critical section
New strategy for memory locking to decrease the number of call to
to un/lock memory when processing critical lvm functions.

Introducing functions for critical section.

Inside the critical section - memory is always locked.
When leaving the critical section, the memory stays locked
until memlock_unlock() is called - this happens with
sync_local_dev_names() and sync_dev_names() function call.

memlock_reset() is needed to reset locking numbers after fork
(polldaemon).

The patch itself is mostly rename:

memlock_inc  -> critical_section_inc
memlock_dec  -> critical_section_dec
memlock      -> critical_section

Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec
(mlockall()) thus they will never release or relock memory they've
already locked memory.

Macros sync_local_dev_names() and sync_dev_names() are functions.
It's better for debugging - and also we do not need to add memlock.h
to locking.h header (for memlock_unlock() prototyp).
2011-02-18 14:16:11 +00:00
02c2036731 Replace PV_MIN_SIZE with function pv_min_size()
Add configurable option to define minimal size of
of block device usable as a PV.

pv_min_size() is added to lvm-globals and it's being
initialized through _process_config.

Macro PV_MIN_SIZE is unused and removed.

New define DEFAULT_PV_MIN_SIZE_KB is added to lvm-global
and unlike PV_MIN_SIZE it uses KB units.

Should help users with various slow devices attached to the system,
which cannot be easily filtered out (like FDD on /dev/sdX):
https://bugzilla.redhat.com/show_bug.cgi?id=644578
2011-02-18 14:11:22 +00:00
42ebbfa703 Support 64bit ints in config 2011-02-18 14:08:22 +00:00
8f1cc91a84 Fix for bug 677739: removing final exclusive cmirror snapshot,
results in clvmd deadlock

When a logical volume is activated exclusively in a cluster, the
local (non-cluster-aware) target is used.  However, when creating
a snapshot on the exclusive LV, the resulting suspend/resume fails
to load the appropriate device-mapper table - instead loading the
cluster-aware target.

This patch adds an 'exclusive' parameter to the pertinent resume
functions to allow for the right target type to be loaded.
2011-02-18 00:36:04 +00:00
9c1b192442 Fix an lv_postorder bug where it failed to clear temporary flags, making it
impossible to use twice with the same LV(s). Discovered by Milan.
2011-02-14 19:27:05 +00:00
b6791ca6e4 Avoid flooding syslog with redundant messages when a snapshot is invalidated
(reported by Corey).
2011-02-14 14:26:36 +00:00
b352da1cc7 bug 659264: more examples for pvmove 2011-02-09 22:24:55 +00:00
e8c5b0512d Allow overriding the DM_DEV_DIR used by the test suite (fixes BZ 672796). Use
like this:

# LVM_TEST_DEVDIR=/tmp/dev make check
2011-02-09 17:57:14 +00:00
a06a7a618c Fix a typo in pvmove.8 (fixes BZ 673618, spotted by John Bradshaw). 2011-02-09 17:42:15 +00:00
252d74032a post-release 2011-02-09 12:11:21 +00:00
6d194f2014 pre-release 2011-02-09 12:04:39 +00:00
5ff5555418 orginal WHATS_NEW entry was changed to be less in-line with change it
was associated with.  Update entry to be clearer than both.
2011-02-08 22:35:11 +00:00
8329e7dc19 Revert DEBUG_MEM cleanup commit
As functions compiled within this define are apparently stil part of the public API,
(though lvm2 code is never using them unless this define is used for compilation),
keep functions available in the code for now -> revert.
2011-02-08 15:52:00 +00:00
3a62b826ce Fix CRC32 calculation on big endian CPU
Fix regresion from 2.02.75 speedup - so currently crc32 is a little bit
more complicated on big-endian CPU as the uint32_t needs to be shifted
on here.
2011-02-08 12:41:08 +00:00
d09c912b81 post-release 2011-02-04 22:46:18 +00:00
60963d276e pre-release 2011-02-04 22:35:29 +00:00
b44de841ff Add configure option --with-device-nodes-on
Make configurable default behaviour how to deal with device node creates.
With udev system natural options should be  'resume'.
For older systems where user expect there is node in /dev/mapper immediately
after  dmsetup create --notable  -  use 'create'

FIXME:
Code needs fixing passing this flag through udev cookie.
2011-02-04 22:17:54 +00:00
c45e064975 pre-release 2011-02-04 22:07:43 +00:00
559d2923a7 Warn if secure data flag requested but not supported by kernel. 2011-02-04 21:26:33 +00:00
a683b0c993 Place back some common options
Until man pages are generated keep some common options with all commands.
2011-02-04 21:19:03 +00:00
1ce9f8621b Allow snapshots in a cluster as long as they are exclusively
activated.

In order to achieve this, we need to be able to query whether
the origin is active exclusively (a condition of being able to
add an exclusive snapshot).

Once we are able to query the exclusive activation of an LV, we
can safely create/activate the snapshot.

A change to 'hold_lock' was also made so that a request to aquire
a WRITE lock did not replace an EX lock, which is already a form
of write lock.
2011-02-04 20:30:17 +00:00
84f191ce5a Add --addnodeonresume, --addnodeoncreate
Add new function dm_task_set_add_node() to select between 2 types
of node creation in device directory.

DM_ADD_NODE_ON_RESUME is now default and ensures node is created on
resume. Old original behavior is accessible with DM_ADD_NODE_ON_CREATE.
In this case node would be created during dmsetup create --notable.

For the user 2 new options for dmsetup create are added:
[{--addnodeonresume | --addnodeoncreate }]

Properly working node creation on resume is needed for proper operation
stacking and ability to correctly check in which state the device should
after whole udev transation.
2011-02-04 19:33:53 +00:00
577c542adc Remove extra sync calls.
Remove temporaly added fs_unlock() calls to fix clmvd usablity.
Now when the message passing is properly working - they are no longer needed.
Simplify no_locking  check for VG unlock - as message is always send
for all targets - clustered & non-clustered.
2011-02-04 19:21:47 +00:00
a0866f0990 Use cluster-wide message to request device name sync
Thanks to CLVMD_CMD_SYNC_NAMES propagation fix the message passing started
to work. So starts to send a message before the VG is unlocked.
Removing also implicit sync in VG unlock from clmvd as now the message
is delievered and processed in do_command().
Also add support for this new message into external locking
and mask this event from further processing.
2011-02-04 19:18:16 +00:00
29c9aced14 Fix operation node stacking for consecutive dm ops
With the ability to stack many operations in one udev transaction -
in same cases we are adding and removing same device at the same time
(i.e. deactivate followed by activate).

This leads to a problem of checking stacked operations:
i.e. remove /dev/node1 followed by create /dev/node1

If the node creation is handled with udev - there is a problem as
stacked operation gives warning about existing node1 and will try to
remove it - while next operation needs to recreate it.

Current code removes all previous stacked operation if the fs op is
FS_DEL - patch adds similar behavior for FS_ADD - it will try to
remove any 'delete' operation if udev is in use.

For FS_RENAME operation it seems to be more complex. But as we
are always stacking FS_READ_AHEAD after FS_ADD operation -
should be safe to remove all previous operation on the node
when udev is running.

Code does same checking for stacking libdm and liblvm operations.

As a very simple optimization counters were added for each stacked ops
type to avoid unneeded list scans if some operation does not exists in
the list.

Enable skipping of fs_unlock() (udev sync) if only DEL operations are staked.
as we do not use lv_info for already deleted nodes.
2011-02-04 19:14:39 +00:00
c154d18b11 Suport DM_SECURE_DATA_FLAG.
It will be user for cryptsetup to ensure buffers are properly
wiped when sending sensitive data (key).
2011-02-04 16:08:11 +00:00
6ed7b4d790 Increase hash table size to 1024 lv names and 64 pv uuids 2011-02-03 16:03:13 +00:00
73300f8977 Remove fs_unlock from lv_resume path
Keep it within clvmd until message for SYNC starts to work.
2011-02-03 01:58:20 +00:00
fc585fc2fb Fix wipe size when seting up mda. 2011-02-03 01:41:03 +00:00
713b630c66 Do not check for open_count when not needed.
Disable open_count checking in lv_info it it's not used.

Fix previous commit (comment out unsable code for now).
2011-02-03 01:24:46 +00:00
3d3f093b8c Synchronize with udev for lv_info
In case the open_count is requested via lv_info - check if there
are any udev operations in-progress - and wait for them
before checking for lv_info
2011-02-03 01:16:35 +00:00
9e12eb1cf5 a few more comments 2011-02-02 23:57:48 +00:00
5c3949eac3 Allow CLVMD_CMD_SYNC_NAMES to be propagated around the cluster if requested. 2011-02-02 23:39:39 +00:00
d4fd789d78 Better fix for no-locking udev sync and clvmd
This is better way how to fix clustered synchronization with udev.
As the code for message passing needs fixed - put currently
fs_unlock() after every active/deactive command in clvmd to
ensure nodes are properly created in time.
2011-02-02 20:04:39 +00:00
197d68a4d0 Revert wrong fix for nolock locking missing fs_unlock
Patch was wrond and introduced recursive lock_vol
Reverting it.
2011-02-02 13:34:00 +00:00
4ae7c94196 Update WHATS_NEW for lvmdump change. 2011-02-01 21:41:31 +00:00
248426e1ee Add "dmsetup ls --tree" output to lvmdump.
It would be most useful to add "dmsetup ls --tree" to the commands run.
This command helps in answering the question "which devices are actually
underneath a given LV?"

Although the info is available with other existing dmsetup commands,
adding this command gives a much clearer summary of complex setups.

Here's an example of an LVM mirror, with mirror images on partitions
created on top of multipath devices.  The multipath devices are on
simple block devices.  As you can see, it is easy to see the stacking
from the "dmsetup ls --tree" output:

vgmpathtest-lvmpathmir (253:14)
 ├─vgmpathtest-lvmpathmir_mimage_1 (253:13)
 │  └─mpath5p1 (253:5)
 │     └─mpath5 (253:2)
 │        ├─ (8:16)
 │        └─ (8:0)
 ├─vgmpathtest-lvmpathmir_mimage_0 (253:12)
 │  └─mpath6p1 (253:6)
 │     └─mpath6 (253:3)
 │        ├─ (8:48)
 │        └─ (8:32)
 └─vgmpathtest-lvmpathmir_mlog (253:11)
    └─mpath7 (253:4)
       ├─ (8:80)
       └─ (8:64)
VolGroup00-LogVol01 (253:1)
 └─ (202:2)
vgtest-lvmir (253:10)
 ├─vgtest-lvmir_mimage_1 (253:9)
 │  └─ (7:1)
 ├─vgtest-lvmir_mimage_0 (253:8)
 │  └─ (7:0)
 └─vgtest-lvmir_mlog (253:7)
    └─ (7:3)
VolGroup00-LogVol00 (253:0)
 └─ (202:2)

But it is much harder to see the stacking with only the commands today
("dmsetup info", "dmsetup status", and "dmsetup table").  We could
piece together the stacking from "dmsetup table" but it requires
further processing (take output from "dmsetup info to get
map name to major/minor, then parse "dmsetup table", etc).
2011-02-01 21:39:15 +00:00
b9d4336960 fix bad 'strcmp's in 'decode_lock_type' - missing !'s
There was no effect from having this wrong yet, because the
tree of callers only ever cared about the answer to the first
condition (!response), which determines whether a lock is
held or not.  Correct responses, however, are needed soon.
2011-02-01 17:31:40 +00:00
c60ff20842 Skip sysinit test for cluster
Add #bin/bash to utils.sh
and update fsadm test to current version of aux script
2011-01-31 22:05:30 +00:00
e4b7c72b3a Fix udev synchronization for no-locking mode
Instead of implicitly syncing udev operation in clustered and
file locking code -  call synchronization directly in lock_vol() when
the operation unlocks VG

The problem is missing implicit fs_unlock() in the no_locking code.
This is used with --sysinit on read-only filesystem locking dir.
In this case vgchange -ay could exit before all udev nodes are properly
synchronised and may cause problems with accessing such node right after
vgchange --sysinint command is finished.

Add test case for vgchange --sysinit.
2011-01-31 19:52:40 +00:00
6cbcd683ba Add a debug message when uevent is not generated and we call udev_complete internally. 2011-01-31 11:54:55 +00:00
e50edb8410 Lower device size of pvmove test
Lower the size of devices in this test for speedup.
And check only once that  LVs are prepared properly.
2011-01-28 16:15:08 +00:00
5b8845974c Lower disk space usage of inconsistent mda test
Smaller size of devices speedups this test.
2011-01-28 16:13:39 +00:00
2169ecd063 Replacei sleep wait with udev settle
Use new udev_wait command instead of unpredictable sleep waiting.
As with more devices in the system, udev processing is slower.
2011-01-28 16:12:45 +00:00
74c10192aa Query only test related vg name 2011-01-28 16:11:14 +00:00
cb3031b7fe Add command to wait for udevadm settle 2011-01-28 16:10:21 +00:00
61e665d65b Do not break pipes
As the option 'set -e -o pipefail' is very sensite on pipe breaking
stop using '-q' for grep commands.

Otherwise this command (with large enough table) would fail:

 dmsetup table | egrep -q

with exit code 141 (128 + SIGPIPE)

As Peter suggested, he prefers to keep '-o pipefail' - so make sure all
piped commands will read the whole output and will not exit too early.
2011-01-28 16:08:39 +00:00
2d8c68d097 Accelerate mirror tests
Instead of recreation of whole device set for each test round,
just cleanup created LVs to empty VG.
Lower the size of PV devices to 16MB
2011-01-28 16:07:04 +00:00
9bcd306c02 Display duration of tests when it passed.
Enhance output with info about the test duration.
Cleanup few declarations in the code.
2011-01-28 16:05:38 +00:00
4fa5445562 Updating man pages 2011-01-28 16:03:38 +00:00
76b030d82e Compile code for memory debuging only with DEBUG_MEM
When it's not in use - do not compile this code.
Improves lcov code coverage results for this code a lot :)
2011-01-28 16:01:32 +00:00
2fef22fa85 Set DM_UDEV_DISABLE_OTHER_RULES_FLAG for suspended DM devices in udev rules.
This is to avoid any scanning and processing of DM devices while they are in
suspended state (e.g. a rename while the device is suspended - a CHANGE event
is generated!). Otherwise, any scanning in the rules could end up with locking
the calling process until the device is resumed and so we don't receive a
notification about udev rules completion until then (and that effectively
locks out the process awaiting the notification!).

However, we still keep 'disk' and any 'subsystem' related udev rules running.
We trust these and these should check themselves whether a device is suspended
or not, not trying to run any scanning if it is.
2011-01-28 11:41:51 +00:00
8440981845 Use memcpy and add error message
strncpy (which check each byte for \0) is not need as we always copy
the length size - so using memcpy is a bit cheaper.

Add missing log_error message for failed allocation.
2011-01-28 10:19:00 +00:00
5ba08f195a Skip NULL check before dm_free
dm_free checks for NULL itself.
2011-01-28 10:16:04 +00:00
342e9fee4a Avoid rebuilding of uuid validation table
Small CPU relax...
2011-01-28 10:14:08 +00:00
0db2d39105 Improve lvcreate "insufficient extents" errors to "insufficient free space". 2011-01-28 02:58:00 +00:00
27e49620ec Use O_DIRECT when reading block devices. 2011-01-27 00:21:37 +00:00
f2439f2096 Add missing lvm_quit in test
Fix occasional confusing memory leak report in testing.
2011-01-26 21:21:56 +00:00
3289982950 Initialize pool object for each row
Fix assert abort of dmsetup (when compiled with pool debug)
dmsetup splitname --nameprefixes --noheadings --rows gvg-a2

Move pool begin in the inner loop - otherwise it would using
already 'ended' pool object.
2011-01-25 21:51:30 +00:00
f18ec47d42 post-release 2011-01-24 23:34:46 +00:00
37f5c45dd5 pre-release 2011-01-24 23:24:06 +00:00
fdd24fd4e5 Bring lvscan man page up-to-date. 2011-01-24 20:02:07 +00:00
66a6d5c073 Fix lvchange --test to exit cleanly. 2011-01-24 14:19:05 +00:00
73b81bcd35 Add change_tag to toollib.
Allow multiple pvchange command line options to be specified together.
2011-01-24 13:38:31 +00:00
4dff097f66 If other process finishes (or aborts) pvmove operation and
polling function cannot find any lv with PVMOVE flag, return
success and do not print  "aborting" message.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=602389
2011-01-19 23:11:39 +00:00
ea0c01a2dd In some versions (RHEL6) dlm_create_lockspace() always
return lockspace reference (even if lockspace already exists)
and thus increases DLM lockspace count. It means that after
clvmd restart the lockspace is still in use.

(The only way to clean environment to enable clean cluster
shutdown is call "dlm_tool leave clvmd" several times.)

Because only one clvmd can run in time, we can use simpler logic,
try to open lockspace with dlm_open_lockspace() and only if it fails
try to create new one. This way the lockspace reference doesn not
increase.

Very easily reproducible with  "clvmd -S" command.

Patch also fixes return code when clvmd_restart fails and fixes
double free if debug option was specified during restart.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=612862
2011-01-19 23:09:31 +00:00
e1ad66800a Remove duplicate statement (pasted twice by patch at some point?) 2011-01-19 19:24:07 +00:00
f0306e63b2 Add test to make sure that a log device is retained when a
mirror image fails and the policies are set to:
 mirror_image_fault_policy = "replace"
 mirror_log_fault_policy = "remove"
2011-01-19 19:22:07 +00:00
4dca082776 Remove DEBUGLOG from dmeventd. 2011-01-17 23:14:05 +00:00
4efa0617b9 Add -f (don't fork) option to clvmd and fix clvmd -d<num> description. 2011-01-17 23:13:14 +00:00
3216fba3ca remove unused definitions 2011-01-17 19:02:44 +00:00
e954736299 post-release 2011-01-17 18:16:18 +00:00
c7e561d33d pre-release 2011-01-17 16:46:50 +00:00
ce94c7ea73 Remove -f from list of targets for cleanup
rm -f is already in used for this cleanup.
2011-01-17 15:18:10 +00:00
6789424259 Do not scan devices unnecessarily for reseting error counter
For reseting error counter use directly btree cached elements and do not
create whole dev_iterator.
2011-01-17 15:16:55 +00:00
7a18ae6da4 Set default value to counter_last
Missed in previous commit and could be using some random stack value.
2011-01-13 15:03:28 +00:00
5f2829b0a0 Do not log backtrace for correctly processed command 2011-01-13 15:00:29 +00:00
49376579bf Include default make.tmpl
Use default clean targets for this Makefile
Use also same build flags for compiling testing tools like harness.
2011-01-13 14:58:59 +00:00
8a3e1de5c8 Enable monitoring for cluster tests 2011-01-13 14:57:18 +00:00
6470c383b2 Skip unnecessary lock_vol() call after volume deactivation
Improve condition within lock_vol so we are not calling extra unlock
if the volume just has been deactivated.

Patch uses lck_type and replaces negative 'and' condition to more
readable 'or' condition.
Few missing strace traces added.
2011-01-13 14:56:17 +00:00
cbfb6504a8 Add exec_cmd paramater sync_needed
As sync_local_dev_names() cannot be called within activation context,
add new parametr which allows to select if the sync call is needed
before executing new command.
2011-01-13 14:51:32 +00:00
a4cdc80836 Check for file with clvmd pid
Instead of checking  $LOCAL_CLVMD set during some 'aux' execution which
doesn't seem to be propagated to this shell - check for existance of pid
file of clvmd process - so this test is skipped in singlenode cluster test.
2011-01-13 11:05:27 +00:00
b598e9482d Hotfix to stop harness busylooping
Harness seems to be able to busyloop in while cycle and not moving forward
for certain buffer - so check whethere there was some progress.
This fix allows to continue after failed cluster test.

Fix gcc warning for hiding global variable 's' -> sig.
2011-01-13 11:02:55 +00:00
0c83d60688 Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)
Introduce sync_local_dev_names and CLVMD_CMD_SYNC_NAMES to issue fs_unlock.
2011-01-12 20:42:50 +00:00
d2a3f3afa1 Kill clvmd properly after locking_type 3 tests (using clvmd/singlenode). 2011-01-12 16:07:55 +00:00
f1e5f9d8d5 add fio 2011-01-12 15:28:33 +00:00
92c39fea53 s/log_verbose/log_error/ - Increase log level on error message. 2011-01-11 17:21:01 +00:00
d67ac7ed5c Add disk to mirrored log type conversion. 2011-01-11 17:05:08 +00:00
9e397d92f5 post-release 2011-01-10 21:12:54 +00:00
f40795a119 reissue 2.02.80 2011-01-10 21:12:18 +00:00
8d4f93634f Fix missing declaration for fs_unlock 2011-01-10 19:49:42 +00:00
c141fe1c44 Avoid cookie sharing between forked processes
Before fork, ensure cookie is reset so it's not shared between processes.
2011-01-10 19:31:02 +00:00
2e776f6b50 post-release 2011-01-10 14:51:33 +00:00
437dac07eb pre-release 2011-01-10 14:28:17 +00:00
77e3610e1a Speedup consequent activation calls
Stop calling fs_unlock() from lv_de/activate().
Start using internal lvm fs cookie for dm_tree.
Stop directly calling dm_udev_wait() and
dm_tree_set/get_cookie() from activate code -
it's now called through fs_unlock() function.

Add lvm_do_fs_unlock()

Call fs_unlock() when unlocking vg where implicit unlock solves the
problem also for cluster - thus no extra command for clustering
environment is required - only lvm_do_fs_unlock() function is added
to call lvm's fs_unlock() while holding lvm_lock mutex in clvmd.

Add fs_unlock() also to set_lv() so the command waits until devices
are ready for regular open (i.e. wiping its begining).

Move fs_unlock() prototype to activation.h to keep fs.h private
in lib/activate dir and not expose other functions from this header.
2011-01-10 14:02:30 +00:00
a23f91ad2f Add internal fs cookie
Add functions for handling internal lvm cookie used for
all dm_tree operations until fs_unlock is called.
2011-01-10 13:44:39 +00:00
4fef104bf1 Define DM_COOKIE_AUTO_CREATE
TODO: Use it also for already written code.
2011-01-10 13:42:31 +00:00
57f8bc3081 Use strndup as GNU extension
strndup needs _GNU_SOURCE defined as it's GNU extension.
Remove duplicate string.h header added in previous harness commit.
2011-01-10 13:25:22 +00:00
40fbdb71bd Cache config_tree
Start to use config_tree for cache just like vgmetadata.
When vgmetadata are erased destroy its cached config tree.
2011-01-10 13:15:57 +00:00
7cbf6fa3a6 Change import_vg_from_buffer to use config_tree
Change function import_vg_from_buffer() to import_vg_from_config_tree().
Instead of creating config tree inside the function allow config tree to
be passed as parameter - usable later for caching.
2011-01-10 13:13:42 +00:00
019423f769 Add default error path for get_property
Set invalid property value for error path when NULL handler is passed.
Fixes use of uninitialized prop structure as we return 'v' by value.
---
2011-01-10 13:07:58 +00:00
4114ac5d22 Improve OCF dir support
Add --with-ocfdir configurable option.
Fix superfluous /usr in ocf_scriptdir instalation path.
2011-01-10 13:00:53 +00:00
1a2e58b067 Add aclocal.m4 (for pkgconfig). 2011-01-07 16:27:05 +00:00
9ce215ed01 Skip the api/percent test on kernels <= 2.6.32. 2011-01-07 15:04:52 +00:00
ad7bccb8ea Add a test for the interaction of snapshots of mirrors and lvconvert --repair. 2011-01-07 14:56:52 +00:00
3621b75306 Add a test for the interaction of transient errors and dmeventd mirror repair. 2011-01-07 14:56:10 +00:00
14908e3a3b Fix a typo in the new relaxed mirror check (test/lib/check.sh). 2011-01-07 14:42:35 +00:00
7ce032b99d Using Fedora 14's autoreconf. 2011-01-07 14:38:34 +00:00
dcaf6313af Remove *.t in test/api's make clean target. 2011-01-07 13:07:10 +00:00
b74d30d55a Disable activation/monitoring in testing lvm.conf by default. 2011-01-07 13:04:17 +00:00
9c705ce71e Relax the mirror test in test/lib/check.sh. 2011-01-07 13:03:46 +00:00
16af1b083b In aux, exit 200 no longer works as skip -- replace with real skip call. 2011-01-07 13:03:04 +00:00
f4d63e9e58 Fix up the make clean target in test/. 2011-01-07 12:26:02 +00:00
cae4882865 Fix memory leak in filter creation error path
If some allocation for peristent filter fails its memory reference
was lost, fix it by calling filter's destructor.

Fix log_error messages for failing allocation.
2011-01-06 15:29:24 +00:00
9d4bb244e3 Intentionaly ignore result from get_config_uint32 2011-01-06 15:25:07 +00:00
41b1b9487c Remove dead assignment of 'ret' value
Variable 'ret' assigned from _do_event() was actually not used and replaced with next
assignment without any read of the returned value.

Code is reformated - so the error path is put in the if() branch and normal
code is put after the 'if' together with FIXME comment.


FIXME lowprio: logging needs to be fixed in this code,
 - multiple log_errors are printed, stacks are missing...
2011-01-06 10:45:41 +00:00
6c1db4a7d6 Remove unneeded stack prints after log_error 2011-01-06 09:45:05 +00:00
7b0c0103a9 Reverting recent commit to disallow adding/removing mirror log while
removing/adding mirror images... There was already code in there to
do the job - I just didn't find it in WHATS_NEW (or in the code right
away).
2011-01-05 23:18:46 +00:00
ef6ec3f737 Prevent the user from simultaneously adding a mirror log while removing
a mirror image (or removing a log while adding a mirror).  Advise the
user to use two separate commands instead.

This issue become especially problematic when PVs are specified, as they
tend to mean different things when adding vs removing.  In a command that
mixes adding and removing, it is impossible to decern exactly what the
user wants.

This change prevents bug 603912.
2011-01-05 20:02:45 +00:00
78269c2110 Check result of dm_snprintf for error 2011-01-05 15:10:30 +00:00
eb91c54467 Add sys_debug loging for unlink
This unlink intentionally silently ignores any errors.
It's still worth to trace its error status in debug mode.
2011-01-05 15:06:10 +00:00
56b6c12e8a Fix gcc warnings for missing headers and prototypes
Add missing header  string.h (strcmp, strndup).
Add 'static' to fix missing prototypes gcc warning.
Remove unused variables verbose_off, TESTDIR, PREFIX.
2011-01-05 15:03:43 +00:00
6507ce98df Remove obsolete bits of support code from test/. 2011-01-05 14:15:26 +00:00
2fbadde558 Re-enable t-lvconvert-repair-transient, avoiding the deadlock by running mkfs
asynchronously.
2011-01-05 14:15:01 +00:00
5a363d74f2 Add missing error path tests 2011-01-05 14:03:36 +00:00
b2817688ac Fail deamonization if lvmcache_init fail
FIXME Add proper cleanup
2011-01-05 12:59:46 +00:00
659b348a44 Return PERCENT_INVALID for error case
If the percent value could not be determined return PERCENT_INVALID.
Indent function with tabs.
2011-01-05 12:33:51 +00:00
6990a8c942 Remove unused variable mirr_state and its assignment 2011-01-05 12:27:56 +00:00
98b4ee635d Remove dead assignment to thisfd
Value of 'thisfd' is not read again after its assigment
2011-01-05 12:17:19 +00:00
7d048d52f6 Fix another bug in t-pvcreate-operation-md (should pass now). 2011-01-05 01:04:47 +00:00
41fb54489f Add a test for RHBZ 640621 (metadata/dirs + no PV MDAs broken). 2011-01-05 01:00:34 +00:00
3be9ec308a Fix typo in t-pvcreate-operation-md.sh. 2011-01-05 00:38:41 +00:00
f120a17b1d Move the mkdtemp functionality into test/lib/utils.sh. 2011-01-05 00:26:19 +00:00
fc7054c150 Fix a couple of bugs in the new (test/lib/)aux.sh. 2011-01-05 00:25:07 +00:00
cde70f94db Substantial rework of the functional test support code. Some new features:
- somewhat neater, more consistent and more readable output
- possible to set any lvm.conf value: aux lvmconf "section/key = value"
- LVM_TEST_NODEBUG to suppress the (lengthy) "## DEBUG" output
- back-substitution on test output ($TESTDIR/$PREFIX -> @TESTDIR@/@PREFIX@)
- support code moved from test/ to test/lib/ --> less clutter
2011-01-05 00:16:18 +00:00
8f0f328dbf Fix bug 635949: lvconvert man page clarification 2011-01-04 21:41:35 +00:00
10e3bdcce3 Change to correct cmirrord return code is user visible - update WHATS_NEW
file.
2011-01-04 21:33:06 +00:00
bc036c01cb Fix bug 632681: cmirrord shouldn't fail 'start' if already started
Return 0 from the cmirrord init script if the daemon is already
running.

http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
2011-01-04 21:16:54 +00:00
c14f565d18 Export DM_CONTROL_NODE_UMASK and use it while creating /dev/mapper/control. 2011-01-04 14:43:53 +00:00
f56007d95f Use system assert in test/api/percent.c, for now. 2011-01-03 15:07:39 +00:00
65599cfb58 Fix wrongly paired unlocking of global lock in pvchange. (2.02.66) 2010-12-23 14:23:30 +00:00
39b2b95477 Remove check for existance of vg pointer
Checking for vg being != NULL in this place is not needed.
Pointer vg is already dereferced in this function above this code line.
Also this internal function _read_pv is always called with valid 'vg' pointer.
2010-12-22 15:44:09 +00:00
e65561feae Add backtraces for backup and backup_remove fail paths 2010-12-22 15:36:41 +00:00
2a2170efc0 Hide unused code into if 0
Make it obvious for lcov coverage and static analyzis we
are not interested in this piece of code.
2010-12-22 15:32:15 +00:00
adb5fb90b1 Detect errors from dm_task_set calls
Check for errors in dm_task_set calls.
Use  goto_bad macro with stack trace.
Replace  label  failed: with bad:.
2010-12-22 15:28:44 +00:00
ad9e16c198 Fix last pthread_join fix commit
Call for pthread_join() does not set errno value even though return values
looks like that. For now assign errno from return value and still use
strerror() to print some error message as this seems to be commonly used.

Add also log_sys_error() message for error close of local pipe.
2010-12-22 14:00:28 +00:00
96a20ae9d4 Add backtraces for archive and backup_locally
If archive or back_locally fails - add stack trace.
2010-12-22 13:45:33 +00:00
0cadf7ba66 Fix memory leak in debug mode of restart_clvmd() error path 2010-12-22 12:14:11 +00:00
bb5ccf8869 Log error state from pthread_join operation
Value jstat is unused - so replace it with logging via log_sys_error().
2010-12-22 12:10:56 +00:00
57d19b3f1b Remove dead assignment of lv_total and lv_capasity_total
Variables 'lv_total' and 'lv_capasity_total' are unused.
2010-12-22 12:06:54 +00:00
e45d947322 post-release 2010-12-21 21:08:51 +00:00
b44cdfc143 Copyright notices for new files. 2010-12-21 01:14:34 +00:00
385933819e pre-release 2010-12-21 01:08:29 +00:00
58e3ba19a2 Add missing test for reallocation error. 2010-12-20 14:38:22 +00:00
0f3ab63a24 Remove dead assignment
Variable 'r' is never read so remove it and just cast result from
_error_device function to (void).
2010-12-20 14:36:12 +00:00
2697eddcba Verbose log old_umask value
Use old_umask value and print its content through verbose log.
2010-12-20 14:34:49 +00:00
90ba925a19 Add internal error if pointer is uninitialized
Add simple check for existance of 'pl' and printer internal error message
if device is missing instead of plain crash.
2010-12-20 14:20:52 +00:00
b5d23f1591 Add check for unlink errors 2010-12-20 14:08:46 +00:00
e6f0290d9f Remove unused variable label
Variable 'label' is unused in _format1_pv_write().
2010-12-20 14:06:33 +00:00
23a3de988f Remove unused variable dev_dir_provided 2010-12-20 14:05:31 +00:00
c4fc6c2381 Remove dead assignment of segh
Variable 'segh' is never read again after this assignment.
2010-12-20 14:04:43 +00:00
9bc24aea56 Remove dead store in lvm_run_command
Variable 'ret' is not read before its next assignment.
2010-12-20 13:59:52 +00:00
8392d2853e Removed unused pointer
Pointer 'duplicate' is unused.
2010-12-20 13:58:38 +00:00
28708849a9 Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
Use dm_zalloc to obtain zeroed memory block.
Use dm_free for dm_ allocated memory blocks.
Test close() for error.
2010-12-20 13:57:19 +00:00
9f1538687a Add checks for allocation errors in config node clonning.
Add checks for clonning allocation a fail-out when something is
not allocated correctly.

Also move var declaration to the begining of the function
and fix log_error messages.
2010-12-20 13:53:10 +00:00
0ae26564ce Replace multiple fprintf calls with one large string parameter 2010-12-20 13:48:28 +00:00
9c146b8a6f Fix error path if regex engine cannot be created in _build_matcher().
Fix only 'stack' printing with full function error exit.
2010-12-20 13:45:39 +00:00
2913ac8b4e Use const char * for name and old_name in vg
Switch to use const char pointers to avoid changes of these structure
members and having better control over, were these members could
be modified.
2010-12-20 13:40:46 +00:00
6556fcc3fc Use const char* for offset calculation
As 'const' types are also passed to macro dm_list_struct_base -
keep offset calculation with const char pointers.
Fixes several gcc constness warnings.
2010-12-20 13:39:12 +00:00
1c6b3062bf Switch void* to char* arithmetic 2010-12-20 13:37:26 +00:00
b00600c247 Remove const usage from destroy callbacks
As const segment_type or const format_type are never released
use their non-const version and remove const downcast from dm_free calls.
This change fixes many gcc warnings we were getting from them.
2010-12-20 13:32:49 +00:00
97d680c924 Fix wrong cast to char*
As cmd->cmd_line is already const char pointer it's not needed to cast already
const char pointer to char pointer.
2010-12-20 13:28:04 +00:00
8f606cf0f6 Use const char* const * for dm_regex_create()
Change API interface to accept even completely const array patterns.

This should present no change for libdm users and allows to pass
pattern arrays without cast to const char **.
2010-12-20 13:23:11 +00:00
c05aa13dcf Some const cleanups
Minor const warning fixes and internal API updates.
2010-12-20 13:19:13 +00:00
12389f2089 update 2010-12-20 13:17:56 +00:00
b3cb194c03 Test return value from read() and close() for an error. 2010-12-20 13:16:30 +00:00
1ea4c6d449 Add more strict const pointers around config tree
To have better control were the config tree could be modified use more
const pointers and very carefully downcast them back to non-const
(for config tree merge).
2010-12-20 13:12:55 +00:00
e5526cb27e Move var declarations to function begining
As assert macro jumps to 'bad:' label - we need vg initialized.
2010-12-20 12:29:39 +00:00
8a8a182679 Fix NULL pointer check for *buf
As ternary operator has lower priority then add operation, this check
was not doing what seemed to be expected.

So enclose the test in braces and check for NULL in *buf.
2010-12-17 12:37:49 +00:00
2f19cff4df Fix device.c #include to ensure 64-bit fopen64 use. (2.02.51) (robbat2) 2010-12-15 12:49:55 +00:00
0bceef8c78 Fix sed substitution in copying tests to builddir (test/Makefile.in). 2010-12-14 23:23:45 +00:00
40eee88b06 Add getters for copy_percent and snap_percent to the lvm2app API. 2010-12-14 23:20:58 +00:00
0c79543cfe Add further consistency checking to vg_validate, ensuring that all segment
areas point to LVs or PVs that are listed in the respective VG.
2010-12-14 17:51:09 +00:00
6ea66f6925 Hack up the RUN_BASE computation in the test Makefile.in a bit more (so that it
actually works... sometimes).
2010-12-14 17:38:42 +00:00
8891680304 Add a validation step for pvmoveN internal LVs to vg_validate. 2010-12-14 17:07:35 +00:00
1f80f8f371 HAVE_SELINUX again 2010-12-13 12:44:09 +00:00
d2fefb2e80 #ifdef HAVE_SELINUX and #ifdef HAVE_SELINUX_LABEL_H 2010-12-13 12:30:04 +00:00
b3032f918e Missing #elif HAVE_SELINUX 2010-12-13 12:18:38 +00:00
bb37f26bbf Update configure. 2010-12-13 11:03:10 +00:00
e805bfb103 Create /var/run/lvm directory during clvmd initialisation if missing.
We need to be sure that /var/run and /var/lock is always there.
(E.g. these two directories could be using tmpfs which then loose
all the content after reboot.)
2010-12-13 10:49:02 +00:00
a1cbc61c34 Add new dm_prepare_selinux_context fn to libdevmapper and use it throughout.
Detect existence of new SELinux selabel interface during configure.
Use new dm_prepare_selinux_context instead of dm_set_selinux_context.

We should set the SELinux context before the actual file system object creation.
The new dm_prepare_selinux_context function sets this using the selabel_lookup
fn in conjuction with the setfscreatecon fn. If selinux/label.h interface
(that should be a part of the selinux library) is not found during configure,
we fallback to the original matchpathcon function instead.
2010-12-13 10:43:56 +00:00
e3deef3baa Remove a redundant %.o: %.c rule from test/api/Makefile.in. 2010-12-12 22:26:47 +00:00
4b81bb549d Fix the sed expression to get "base" names of tests. 2010-12-12 21:17:25 +00:00
c0274f4018 Only build the required bits under api/ on make check. 2010-12-12 21:08:00 +00:00
46ac061fb3 Do not build vgtest (superseded by vgtest.t). Fix the build line for .t files. 2010-12-12 20:49:38 +00:00
5e4a1476b3 First go at a somewhat more comprehensive mechanism to run "unit" tests for the
lvm2app API. Further factoring of the support code needed. RHBZ 654445
2010-12-12 20:36:38 +00:00
3415f08149 Fix scanning of VGs without in-PV mdas.
Set cmd->independent_metadata_areas if metadata/dirs or disk_areas in use.
- Identify and record this state.

Don't skip full scan when independent mdas are present even if memlock is set.
- Clusters and OOM aren't supported, so no problem doing the proper scans.

Avoid revalidating the label cache immediately after scanning.
- A simple optimisation.

Support scanning for a single VG in independent mdas.
- Not used by the fix but I left it in anyway as later patches might use it.
2010-12-10 22:39:52 +00:00
c384ad4074 Try to detect fail in clvmd startup in tests. 2010-12-09 11:19:21 +00:00
8a9dbd13e7 . 2010-12-09 00:10:24 +00:00
1e2f3763cb . 2010-12-08 23:09:45 +00:00
bc9b386f80 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
b4940ed53c Cope better with an undefined target_percent operation in _percent_run. 2010-12-08 19:26:35 +00:00
1e9221af45 Remove reset of vg->vgmem pointer as it is access of already release memory
This reset of vgmem pointer causes access of already released memory.
(_vg_make_handle allocates vg from vgmem pool itself - which is a bit tricky)

Interestingly this memory fault was missed by our test suite.
2010-12-08 10:45:37 +00:00
200675b506 post-release 2010-12-06 22:13:10 +00:00
6424bd9e6d pre-release 2010-12-06 17:57:14 +00:00
7ce425114e Fix debug logging of derived flag LCK_CACHE in clvmd. 2010-12-06 17:37:09 +00:00
b0e9ba5f4b Check str_list_add() success
Report error if str_list_add fails.
2010-12-01 13:05:06 +00:00
7837f37e21 Check lv_info() success
Add log_error message for lv_info failure and exit from futher
processing.

Replace 'leg' occurence in debug message with 'image' which
is used in other messages.
2010-12-01 13:01:36 +00:00
966bfcef27 Add backtraces for errors
Add stack;  backtraces when error is reported from dev_set() or
dev_close_immediate().
2010-12-01 12:56:39 +00:00
70ebb39097 Log error from unlink failure 2010-12-01 12:41:49 +00:00
60d340b387 Test lv_name is not NULL
Patch adds extra check for lv_name not being NULL.
Test avoids unneeded strlen call for this case.
Otherwise there is no functional change as test would fail on
size_t comparation even for NULL lv_name (thus there is no risk
of NULL dereference when taking 'true' if branch.
2010-12-01 12:22:49 +00:00
22812bc83c Add logging for pipe write() and close() error
Check values from write() and close() system calls.

FIXME: Missing wrapper around 'write()'.
2010-12-01 10:46:20 +00:00
83c37777f1 Check result of vginfo_from_vgname
Check for some potential internal error.
2010-12-01 10:39:28 +00:00
a200f50bbe Optimize second call to strchr with same parameters
Small optimalization - reusing already known strchr result.
2010-12-01 10:36:25 +00:00
a2f563f84f Fallback to full rescan for missing device
Fix bug when NULL could have been passsed as 'data'
to _add_pv_to_list() if 'dev' is NULL.

Now it fallbacks to complete scan.
2010-12-01 10:33:55 +00:00
d5c94a08a7 What's new. 2010-11-30 23:03:35 +00:00
9fc47d67df Remove unneeded test for NULL
Remove check for system_id (it is defined as int8_t[], so cannot be NULL).
2010-11-30 22:57:35 +00:00
c697497923 Test uuid for NULL
Add test for NULL before passing uuid as src argument to memcpy.
As memcpy function is declared as function not accepting NULL.
Though we pass NULL only with zero length so this patch presents
no functional change to the code.
2010-11-30 22:53:37 +00:00
b13837c2c0 Add stack trace for error path
If dm_task_set_cookie() fails print stack trace, but keep going on.
2010-11-30 22:40:19 +00:00
5eb6300c77 Add error path stack traces
Check for errors from dm_task_set_name() and dm_task_run().
Add stack traces for error paths.
Return 0 if some error is found.
2010-11-30 22:32:44 +00:00
a1b86401a5 Remove check for lv is NULL
'lv' is deferenced in the begining of the function so any check
later is not helpful.

Parameters for dev_manager_transien() are marked as nonnull.
2010-11-30 22:28:06 +00:00
5dcb17df67 Add missing test for failed pool allocation
Add test for NULL from dm_poll_create.
Reorder dm_pool_destroy() before file close and add label out:.
Avoid leaking file descriptor if the allocation fails.
2010-11-30 22:23:35 +00:00
5b94a87589 Replace snprintf with dm_snprintf
Use dm_snprintf with known error case return code (-1).
2010-11-30 22:16:25 +00:00
3698ce35b1 Check reallocated buffer for NULL before use
As *buf is reallocated in case CLVMD_CMD_TEST: test for NULL is needed
before printing status.
(realloc() == NULL and status != 0)
2010-11-30 22:11:26 +00:00
e6ce16ae13 Refactor the percent (mirror sync, snapshot usage) handling code to use
fixed-point values instead of a combination of a float value and an enum.
2010-11-30 11:53:31 +00:00
7e8110ec50 Fix a failing test (it used a combination of lvconvert parameters that is no
longer permitted.)
2010-11-30 11:35:32 +00:00
482cef7121 Avoid the automatic MISSING_PV recovery path in commands with special
MISSING_PV handling (cmd->handles_missing_pvs is set).
2010-11-30 11:15:54 +00:00
3c3e95a5a8 Fix memory leak when VG allocation policy in metadata is invalid.
Ignore unrecognised allocation policy found in metadata instead of aborting.
Fix another missing vg_release() in _vg_read_by_vgid.
2010-11-29 18:35:37 +00:00
e0a4b67e11 Optimize lookup table read
Reread lookup table only when needed.
2010-11-29 14:25:13 +00:00
56c7200837 Remove dead assignment in wait_for_child
'pid' is not used anywhere - remove it.
2010-11-29 12:44:52 +00:00
0381e82b54 Remove dead assignment in _step_matcher
'ns' is not used after this assignment and it is reassigned with the following
code, so dropping this assignment.
2010-11-29 12:43:49 +00:00
28b075f78d Remove dead assignment in _mirror_emit_segment_line
Remove unused 'r' assignment.
2010-11-29 12:42:10 +00:00
4f4c217659 Fix memory leak in error path
Nicely hidden memory leak in outf macro error path.
This macro is using out_text() and does automagical return_0.
That would leak tag_buffer allocated memory.

As there was same code for tags output - create _out_tags() function.
2010-11-29 12:19:58 +00:00
55d9104463 Use one fprintf call for usage print
Replace multiple fprintf calls with multiline one.
2010-11-29 12:15:41 +00:00
be2679a691 Remove dead assignment in dm_tree_node_add_mirror_target_log
'seg' is never used - remove it.
2010-11-29 11:26:00 +00:00
69281c1eab Remove dead assignment in 'main'
'ret' is never read anywhere - remove it.
2010-11-29 11:23:14 +00:00
ea249ebca7 Remove unused 'i' in _pv_analyze_mda_raw
'i' is unused in the function - remove it.
2010-11-29 11:16:58 +00:00
e60fe35e6b Remove dead assignment in lvm2_main
'alias' is not read again in this code path.
Also 'alias' is already equal to 0 in this place.
2010-11-29 11:14:33 +00:00
a1945b9f12 Remove dead assignment in _lock_for_cluster
'saved_errno' is not read from this initialization and before its
usage is assigned again before _cluster_free_request() call.
2010-11-29 11:13:12 +00:00
d41c8aed57 Reset vg pointer after release
Set vg to NULL after releasing it as the following memlock() test may
lead to goto for the second call of vg_release() with the already
released vg pointer.
2010-11-29 11:08:14 +00:00
fbf215ade2 Remove printing of LCK_CACHE
LCK_CACHE is defined as 0x100 so it cannot be passed through
unsigned char parameter - remove it from the sprintf code.

If the LCK_CLUSTER should be printed here - lot of code need
to be reworked - so adding FIXME comment.
2010-11-29 11:05:15 +00:00
5b679c060d Fix check for empty system_dir
Fixing check for zero length system_dir string.
2010-11-29 10:58:32 +00:00
acb88b5339 Cleanup remove test for NULL
dm_free is testing NULL itself
2010-11-29 10:11:50 +00:00
c3d7df946e Fix "it's" typo to be "its" in lvconvert error message. 2010-11-28 18:37:33 +00:00
1dea3b9fab Update WHATS_NEW. 2010-11-25 17:16:41 +00:00
3801cb524c Disallow certain lvconvert operations that need to both allocate and free
extents, while physical volumes are specified. Fixes BZ 640051.
2010-11-25 17:15:46 +00:00
001b2c264b All 'size' values of lvm2app properties should be in bytes.
Fix 'seg_size' to return bytes.

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-25 14:39:02 +00:00
f1e5a95d89 Add interactive tests for functions to lookup a pv|lv by name|uuid.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-25 14:35:46 +00:00
8779301c8d This patch adds helpers to allow users to lookup a lv or pv handle by
uuid (given a vg_t of course).

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-25 14:34:51 +00:00
2ac0e8f989 This patch adds helpers to allow users to lookup a lv or pv handle by
name (given a vg_t of course).

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-25 14:33:44 +00:00
f912e2c887 Add missing destrustion of cmd_context
Lvm1 fallback code missed to destroy cmd_context in error path.
2010-11-24 09:53:31 +00:00
732528e1c0 Fix memory leak in error path
Release allocated path buffer in error path.
2010-11-24 09:43:18 +00:00
90222d0232 Fix resource leak of dlopened pointer
Add missing dlclose in _init_formats() error path.
Use return_0 to print stack trace from the call.
2010-11-24 09:34:34 +00:00
85933f336c Add missing fclose
Fixing resource leak in _umount().

CHECKME: mountpoints with spaces need to be checked
2010-11-23 21:19:45 +00:00
dc60e49a4d Move arg_vgnames from local scope
As gcc puts probably all vars on stack this bug was not noticed in runtime.
Patch fixes referencing local scope list variable.
2010-11-23 20:39:13 +00:00
d1626c2433 Do not call dm_task_destroy with NULL 2010-11-23 18:29:06 +00:00
2b3e80e233 Add missing closedir() - fixes resource leak 2010-11-23 15:28:54 +00:00
0eb26e4582 Move va_end() so it is also used before error path return 2010-11-23 15:08:57 +00:00
79a9cb910a Move va_end(ap) so we do not leave with return -1 without calling it.
Remove unneeded ';'
2010-11-23 15:00:52 +00:00
5b958643be Suppress 'No PV label' message when removing several PVs without mdas. 2010-11-23 01:55:53 +00:00
6e17f8809d Fix default /etc/lvm permissions to be 0755. (2.02.66) 2010-11-22 21:39:47 +00:00
75ab0236a9 post-release 2010-11-22 18:37:56 +00:00
4928dded55 pre-release 2010-11-22 14:25:22 +00:00
61325c32b0 Fix _output_field crash from field_id free with DEBUG_MEM. (Phillip Susi) 2010-11-19 13:17:27 +00:00
4f2136c654 The _free_vg that is created as a placeholder when reporting segments in pvs
was lacking the (vgmem) pool. We now create that pool. There is at least one
more such VG (_dummy_vg) which is pool-less. I am not sure what is the right
way to go about this, but this is currently necessary to fix a segfault
introduced by using vgmem in the reporter in Dave's lvseg lvm2app patches.

Signed-off-by: Petr Rockai <prockai@redhat.com>
2010-11-17 22:26:42 +00:00
9489a09e01 Update interactive tests for lvm2app lvseg and pvseg apis.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:13:51 +00:00
b55eb45e6a Add lvm2app function to query pvseg properties.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:12:39 +00:00
294097601d Add the macro and specific 'get' functions for pvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:11:27 +00:00
92afd60d92 Add a new type and function to lvm2app to enumerate pvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:10:42 +00:00
6bb64bc0b7 Add lvm2app function to query lvseg properties.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:09:42 +00:00
16138ebca3 Add the macro and specific 'get' functions for lvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:08:14 +00:00
bcf4cf83e4 Add a new type and function to lvm2app to enumerate lvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:07:01 +00:00
5d3834485e Make value.string const char *, in properties.h, to fix a warning introduced by
the previous patch set.
2010-11-17 19:50:15 +00:00
4bd06a929d Add vg_set_property to the interactive lvm2app test program.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 19:17:07 +00:00
9f8d31c4a2 Implement lvm_vg_set_property() by calling internal 'set' property function.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 19:16:05 +00:00
e01d8e9702 Add generic infrastructure to internal library to 'set' a property.
Similar to 'get' property internal functions.
Add specific 'set' function for vg_mda_copies.

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 19:15:10 +00:00
212f7e0409 Remove tag length restriction and allow / = ! : # & characters. 2010-11-17 10:19:29 +00:00
676492a634 WHATS_NEW FIXME 2010-11-12 16:04:52 +00:00
39311f404e Support repetition of --addtag and --deltag arguments.
Add infrastructure for specific cmdline arguments to be repeated in groups.
Split the_args cmdline arguments and values into arg_props and arg_values.
2010-11-11 17:29:05 +00:00
60b5c7dab1 Preserve const for char pointer
Keep char pointers 'const'  (introduced with cling commit).
2010-11-11 12:32:33 +00:00
fe80296ff0 Add date configurable variable DATE
Follow the rule to run every command through variable dereference.
Add a runtime check of translated date to seconds.
2010-11-11 12:17:15 +00:00
e945819706 fsadm fix for downsize of unmounted fs
Fix for the last commit as $MOUNTED is not only used as bool flag,
but also store mounted location for remount - so parsing output
from mount differently then from /proc/mounts.

Prefix calls of 'tunefs' tools with LANG=C to be sure we always do get
some nonlocalized strings.

Avoid using forced 'resize2fs' for cleanly unmounted filesystems and
run regular fsck -f for this case as required by resize2fs.

'fsadm check' uses date difference for extX filesystems between
the last mount and last check of 'fsck -f' execution and if the mount
was later run 'fsck' with -f so resize2fs is happy and user does not
need to pass '-f' flag.
2010-11-10 16:14:02 +00:00
caad1b4ff9 Update fsadm regresion 2010-11-10 10:05:27 +00:00
2286995abd Scan also 'mount' output for mounted filesystem.
As util-linux package seems to give all the time different names,
try harder to figure out, where is the given lv possible mounted
and scan /proc/mounts and if not found there, test also 'mount' output.

/dev/dm-xxx
/dev/mapper/vg-lv
/dev/vg/lv

All of them could be used different combination in /proc/mount and mount output.

Patch fixes regression for older systems where new detection code failed to
find valid combination.
2010-11-10 10:03:07 +00:00
3548ba3827 Extend cling allocation policy to recognise PV tags (cling_by_tags).
Add allocation/cling_tag_list to lvm.conf.
2010-11-09 12:34:40 +00:00
de2c6ce36e Regenerate configure with 'autoreconf' for --enable-ocf. (2.02.76) 2010-11-09 11:15:34 +00:00
af1144cac0 forgotten to regenerate last time configure.in was updated 2010-11-09 11:14:06 +00:00
4894259eca post-release 2010-11-09 02:58:06 +00:00
ab3b542a18 pre-release 2010-11-08 19:37:40 +00:00
262ff6e9d3 Fix include commit and switch to use DISTCLEAN_TARGETS
Fixing warning introduced by 'include make.tmpl' commit.
Produced this warning:

Makefile:29: warning: overriding commands for target `distclean'
../make.tmpl:366: warning: ignoring old commands for target `distclean'
2010-11-08 14:19:48 +00:00
968c382706 Clarify error messages when activation fails due to activation filter use. 2010-11-05 18:18:11 +00:00
d99a0313a7 Add OCF support
Updated patch from Florian Haas from Linux-HA project.

User needs to 'configure --enable-ocf' to get file installed
by 'make install' target by default.
User can also use 'make install_ocf' to get only ocf files installed.
With disabled (default) ocf support - no ocf files are installed.

FIXME: ocf installation path needs to be kept in sync with pacemaker.
find better way and possible also better location.
2010-11-05 16:18:38 +00:00
ad2a90ccc6 Add given user prefix to make target install_initscripts
Avoid files to be written into the live system if lvm was
configured with different --prefix.

Use initdir for install target path.
2010-11-05 16:13:18 +00:00
64013278fb Use include make.tmpl
Makes easier to use recursive targets and simplifies Makefile.
2010-11-05 16:10:08 +00:00
86a974c3c3 lost line 2010-11-02 20:10:35 +00:00
f56361e29f Fix regex optimiser not to ignore RHS of OR nodes in _find_leftmost_common. 2010-11-02 19:56:33 +00:00
b53badf298 Use new status code from fsadm check
Patch updates exec_cmd() and adds 3rd parameter with pointer for
status value, so caller might examine returned status code.
If the passed pointer is NULL, behavior is unmodified.

Patch allows to confinue with lvresize if the failure from fsadm check is
caused by mounted filesystem as many of filesystem resize tools do support
online filesystem resize. (originally user had to use flag '-n' to bypass
this filesystem check)
2010-11-01 14:17:35 +00:00
93bd371b57 Add DIAGNOSTICS section to fsadm man page. 2010-11-01 14:10:46 +00:00
3bb9c8e43e Return different status code for fsadm check of mounted filesystem
Return status code 3 for fsadm check of mounted filesystem - used later with
lvresize update patch to better support online filesystem resize.

Also makes a more consistent user interruption and returns status code 2
in this case.
2010-11-01 14:08:51 +00:00
09c6b90d76 Use dm_strdup/dm_free instead of strdup/free. 2010-11-01 13:50:51 +00:00
032a206a83 Allocate buffer for reporting functions dynamically to support long outputs.
Fix memory leak of field_id in _output_field function.

There's been a patch added recently to use dynamic allocation for metadata
tags buffer to remove the 4k limit (for writing metadata out). However, when
using reporting commands like vgs and lvs, we still need to fix libdm reporting
functions themselves to support such long outputs. So the buffer used in those
reporting functions is dynamic now.

The patch also includes a fix for field_id memory leak which was found in
the _output_field function.
2010-11-01 13:31:55 +00:00
735d51276c Update VG metadata only once in vgchange when making multiple changes.
Allow independent vgchange arguments to be used together.
(Still more inconsistencies to iron out here.)
2010-10-29 21:15:23 +00:00
bc91078978 Update WHATS_NEW. 2010-10-29 16:44:47 +00:00
8179a2dc9c Add code to the dmeventd snapshot plugin to automatically unmount snapshots
that have been invalidated.
2010-10-29 16:43:51 +00:00
ab98a1c5dc Alasdair correctly pointed out that if the two closes are concurrent (I haven't
checked, so they *might*), there is still a race possibility with the last
fix. This patch fixes that.
2010-10-27 11:40:14 +00:00
d9f958852c Add a missed test for dmeventd -R. 2010-10-27 09:16:31 +00:00
27b0895f6d Update WHATS_NEW. 2010-10-27 09:15:48 +00:00
fec4084b90 Fix a double close in clvmd.
The management threads (main_loop, the socket thread) could close a single fd
twice in a row sometimes. At least one other thread can be running at the same
time as the threads doing the double close. That one running thread also
happens to do some IO (namely, open /proc/devices, read from it, close it). If
there was enough "demand" for the local socket, this could happen:

- a connection to clvmd is about to finish, let's say the fd is 13 (it often
  happens to be in my test script, don't ask why)
- the local_sock thread calls close(13)
- the lvm thread calls open("/proc/devices"...) and gets 13
- the main_loop thread calls close(13) [OOPS!]
- new connection arrives, and is accept'd by a (new) local_sock thread
- the accept gives an fd of 13 (since it's the lowest free fd at this point)
- the lvm thread gets around to read from it's /proc/devices handle... 13,
  again
- the lvm thread hangs forever trying to read from the socket instead of
  /proc/devices

Signed-off-by: Petr Rockai <prockai@redhat.com>
Reviewed-by: Milan Broz <mbroz@redhat.com>
2010-10-27 09:13:37 +00:00
9a9d7c1c55 Use a more generous timeout for dmeventd in t-lvconvert-repair-dmeventd. 2010-10-26 12:53:07 +00:00
0f287ed3dd Let's rely on the exit code and do not test for empty output. 2010-10-26 12:52:25 +00:00
cf048beade Add missing return for NULL passed buffer
Function pull_stateo() checks for NULL 'buf' - but return for this error
path was missing.  cmirror code never calls this function with NULL 'buf',
so this fix has no effect on current code base, but makes clang happier.
2010-10-26 10:14:41 +00:00
558c22a454 Macro uninitialized_var gives warnings in static analysis
Deactivate uninitialized_var() macro for clang static analysis.
2010-10-26 10:04:34 +00:00
683f33139e Hotfix usage of __builtin_unreachable()
It's quite new feature which is not supported by older compilers.
So until some better macros are introduced into LVM code - hotfix current
compilation problems and compile this code only for __clang__ defining compilers.
2010-10-26 09:57:03 +00:00
810abed9ea Fix NULL pointer dereference for too large MDA error path
Replace dereference of NULL vg with passed vgname to the function
_vg_read_raw_area() in the error path for too large MDA.
2010-10-26 09:13:13 +00:00
9bd893bbc7 Instrument compiler about code unreachability
Clang needs some instrumentation help for static code analysis.
It helps gcc and human reader as well.
2010-10-26 09:01:47 +00:00
abf79b3678 Use static indentifier for internal functions
Functions _align_chunk() and  _new_chunk() are used only internally inside
pool-fast.c - so keep them static inside this object file.
2010-10-26 08:59:05 +00:00
290d1d8c3f Update C declaration () -> (void) 2010-10-26 08:54:37 +00:00
f1ec47e131 Remove bufused for calculation
As bufused is assigned 0 in preceding source line
clang Idempotent operation
2010-10-26 08:53:25 +00:00
0e36229da2 Fix vgchange to process -a, --refresh, --monitor and --poll like lvchange.
Simultaneous -a and --refresh is not valid.
poll+monitor are valid together with or without -ay* (but not with -an*)

No longer print polling results summary if no LVs in the VG were polled.
2010-10-26 01:37:59 +00:00
5d5d6e4d4a Explicitly have grep print the matching filenames (needed to
successfully determine scsi_debug device).
2010-10-26 01:25:46 +00:00
543f8e8cca Update WHATS_NEW for lvm2app property functions 2010-10-25 17:33:51 +00:00
d5f5a46b33 post-release 2010-10-25 16:38:20 +00:00
ac146fc759 Add interactive tests for lvm_{pv|vg|lv}_get_property(). 2010-10-25 14:09:19 +00:00
5b5c981c13 Add lvm_lv_get_property() generic function to obtain value of any lv propert
Add a generic LV property function to lvm2app, similar to VG function.
Return lvm_property_value and require caller to check 'is_valid' flag
and lvm_errno() for API error.
2010-10-25 14:09:08 +00:00
fbe2b85f22 Add lvm_pv_get_property() generic function to obtain value of any pv property.
Add a generic PV property function to lvm2app, similar to VG function.
Return lvm_property_value and require caller to check 'is_valid' flag
before using the value.  If 'is_valid' is not set, then lvm_errno()
should be used to obtain the specific error.
2010-10-25 14:08:55 +00:00
377a39fcaf Add lvm_vg_get_property() generic vg property function.
Add a generic VG property function to lvm2app.  Call the internal library
vg_get_property() function.  Strings are dup'd internally.
Rework lvm_vg_get_property to return lvm_property_value and require caller
to check 'is_valid' flag.  If !is_valid, the caller can check lvm_errno()
for the specific error.

Create a 'get_property' function, local to lvm2app, that factors out
most of the common code that copies the components of lvm_property_type
into lvm_property_value.  This allows for a 1-line function for each
of the generic property functions exported by lvm2app.
2010-10-25 14:08:43 +00:00
6674b9a66f Add 'is_integer' flag into internal lvm_property_type.
Add 'is_integer' flag similar to 'is_string'.
Suggested in review by Petr Rockai.
2010-10-25 14:08:32 +00:00
73ac1ba150 pre-release 2010-10-25 13:54:29 +00:00
fa3bfb017b Use const config node 2010-10-25 13:38:11 +00:00
c755772a23 Fix constness warning
Fix usage of const 'data' pointer and also assign void* directly without
uneeded cast for C.
2010-10-25 13:36:57 +00:00
441a1d7ee2 Fix constness warning
Keep using const pointers.
2010-10-25 13:36:09 +00:00
f6318121f4 Fix constness warning for _vg_read_by_vgid() uuid usage 2010-10-25 13:35:13 +00:00
88943533dd Fix constness warnings
After update of device_from_pvid() API fix constness warnings
Also fix info_from_pvid() constness warning for char* usage.
2010-10-25 13:33:42 +00:00
fba05d7ba1 Use const pointer for return value of dm_basename
Fix return pointer to const as it is created from passed input const pointer.
2010-10-25 13:13:53 +00:00
d302389b9f ok this seems to be never ending story... 2010-10-25 13:10:13 +00:00
14ccfd53b5 rom -> from 2010-10-25 13:04:23 +00:00
e0256ba49a Use 'const' struct id *pvid for device_from_pvid()
Update interface for device_from_pvid and use const pointer.
2010-10-25 13:02:26 +00:00
22f922671e Switch to char* arithmetic from void* 2010-10-25 13:00:35 +00:00
589f03e91a Fix missing initilisation to 0
Add missing init value for variable 'found' which is later tested and may
have contained some garbage value.
2010-10-25 12:59:24 +00:00
759241e905 Fix potential NULL pointer dereference
Makes clang happier as it covers all code paths and avoids NULL pointer
dereference through the 'com' pointer (which is NULL by default static
initialisation).
2010-10-25 12:57:00 +00:00
b68cb6026e Reuse result of previous strchr
Reported by clang as: Argument with 'nonnull' attribute passed null

Reuse the result of the last strchr() call - make sure, 'st' point is not
null for the next strchr() call.
2010-10-25 12:08:15 +00:00
b1b18e183c Ensure we always have origin defined
Reported by clang as: Logic error Dereference of null pointer
Make sure the code path could not use NULL origin because of some internal
code error.
2010-10-25 12:05:46 +00:00
64cdefc540 fix header #defines 2010-10-25 12:01:59 +00:00
52aa8cabe3 Print vg_name and do not to access vg->name
Reported by clang as: Logic error Dereference of null pointer
Replace pointer dereference with vg_name.
2010-10-25 12:01:38 +00:00
e420410f9a Fix clang warning for ntohl(*((uint32_t *)buf))
We cast (char*) to (uint32_t*) that changes alignment requierements.
For our case the code has been correct as alloca() returns properly
aligned buffer, however this patch make it cleaner and more readable
and avoids warning generation.
2010-10-25 11:57:06 +00:00
45f69c7d5f Use a more-generic name for the new kernel flag so list_devices can share it. 2010-10-25 11:44:20 +00:00
612b90ba52 Add global/metadata_read_only to use unrepaired metadata in read-only cmds. 2010-10-25 11:20:54 +00:00
ae0ac24fdd Don't take write lock in vgchange --refresh, --poll or --monitor. 2010-10-25 10:40:13 +00:00
4e51f802a0 restrict last checkin to devs consisting entirely of error target 2010-10-25 10:37:34 +00:00
e4c3b136f5 Never scan a device which is using the error target
A merged snapshot's DM device is made to use the "error" target as part
of lvm's transaction to merge a snapshot.  This snapshot merge use-case
aside, any device using the error target shouldn't be scanned.
2010-10-24 17:36:58 +00:00
f1329d4511 Add lv_get_property() internal lvm function. 2010-10-21 18:51:16 +00:00
ee5f8f12bf Rename fields in lvm_property_type.
Based on review comments, rename a few fields in lvm_property_type.
In particular, change 'is_writeable' to 'is_settable', which is
more intuitive to the intent of the bitfield (a 'set' function
exists for this field/property).  Also, remove the char array
for 'id' - unnecessary as we can just use the string passed in
to do the strcmp.  Finally rename the union members from n_val
to 'integer' and 's_val' to 'string'.
2010-10-21 14:49:43 +00:00
cb41445647 Add lv_read_ahead and lv_kernel_read_ahead 'get' functions. 2010-10-21 14:49:31 +00:00
6d518948a9 Refactor and add code for (lv) 'lv_origin' get function. 2010-10-21 14:49:20 +00:00
45628f9813 Refactor and add code for (lv) 'lv_name' get function. 2010-10-21 14:49:10 +00:00
affe488e93 Reduce a (huge) timeout in t-mirror-names. 2010-10-20 15:35:00 +00:00
c294dbb4c8 Add a test for BZ 509182 (vgchange --monitor y breaks with max_lv). 2010-10-20 15:32:15 +00:00
a60e991ee7 Add coverage test for partition table scanning 2010-10-20 15:14:13 +00:00
3cfab15e8a Implement dmeventd -R, allowing dmeventd to be restarted without losing
monitoring state.
2010-10-20 15:12:12 +00:00
eb8af4be25 Fix strict-aliasing compile warning in partition table scanning 2010-10-20 15:07:30 +00:00
014546ad62 Revert some debug statements that slipped in with last checkin. 2010-10-20 14:51:18 +00:00
e2240edafc Fix a deadlock in clvmd.
The signalling code (pthread_cond_signal/pthread_cond_wait) in the
pre_and_post_thread was using the wait mutex (see man pthread_cond_wait)
incorrectly, and this could cause clvmd to deadlock when timing was
right. Detailed explanation of the problem follows.

There is a single mutex around (L for Lock, U for Unlock), a signal (S) and a
wait (W). C for pthread_create. Time flows from left to right, each arrow is a
thread.

So first the "naive" scenario, with no mutex (PPT = pre_and_post_thread, MCT =
main clvmd thread; well actually the thread that does read_from_local_sock). I
will also use X, for a moment when MCT actually waits for something to happen
that PPT was supposed to do.


MCT -----C ------S--X-----S----X----------------------S------XXXXXXXXX
         |                everything OK up to this --> <-- point...
PPT       -----WWW-----WWWW------------------------------WWWWWWWWWWWWW

Ok, so pthread API actually does not let you use W/S like that. It goes out of
its way to tell you that you need a mutex to protect the W so that the above
cannot happen. *But* if you are creative and just lock around the W's and S's,
this happens:

MCT ----C-----LSU----X-----LSU----X------------LSU------XXXXXXX
        |
PPT      ---LWWWU-------LWWWWU-----------------------LWWWWWWWWW

Ooops. Nothing changed (the above is what actually was done by clvmd before
this satch). So let's do it differently, holding L locked *all* the time in
PPT, unless we are actually in W (this is something that the pthread API does
itself, see the man page).

MCT ----C-----LSU------X---LSU---X-----LLLLLLLSU----X----
        |                             (and they live happily ever after)
PPT     L---WWWWW---------WWWW----------------W----------

So W actually ensures that L is unlocked *atomically* together with entering
the wait. That means that unless PPT is actually waiting, it cannot be
signalled by MCT. So if MCT happens to signal it too soon (it wasn't waiting
yet), it (MCT) will be blocked on the mutex (L), until PPT is actually ready to
do something.
2010-10-20 14:46:45 +00:00
e4d6cfc013 Avoid an extraneous orphans unlock in vgextend --restoremissing. 2010-10-18 17:27:10 +00:00
79e3827207 Update WHATS_NEW. 2010-10-15 17:04:02 +00:00
ba29d593b9 Implement automatic snapshot extension with dmeventd, and add two new options
to lvm.conf in the activation section: 'snapshot_autoextend_threshold' and
'snapshot_autoextend_percent', that define how to handle automatic snapshot
extension. The former defines when the snapshot should be extended: when its
space usage exceeds this many percent. The latter defines how much extra space
should be allocated for the snapshot, in percent of its current size.
2010-10-15 16:28:14 +00:00
b53f7f9993 Fixes for the devices/disable_after_error_count documentation. 2010-10-15 16:24:00 +00:00
e6e871afbe Update 2010-10-15 09:55:37 +00:00
45edc2ae3f Speedup memory un/locking
Move the call of find_config_tree_node() from inner loop to outer
section of maps scanning.
2010-10-15 09:48:23 +00:00
d54db5013b Fix linking order for liblvm2cmd
Reorder linked libraries so we better support --as-needed linker flag used
by some distributions (i.e. Gentoo).

Patch suggested by Diego Elio Pettenò <flameeyes <at> gmail.com>
2010-10-15 09:41:21 +00:00
5426e85284 Add --setuuid to dmsetup rename.
Add dm_task_set_newuuid to set uuid of mapped device post-creation. (pjones)
2010-10-15 01:10:27 +00:00
81631b1986 Fix for bug 637936: killing both redundant logs causes deadlock
Problem:
When both legs of a mirrored log fail, neither the log nor the parent
mirror can proceed.  The repair code must be careful to replace the
log with an error target before operating on the parent - otherwise,
the parent can get stuck trying to suspend because it can't push through
any writes.  The steps to replace the log device with an error target
were incomplete and resulted in the replacement not happening at all!

The code originally had all the necessary logic to complete the
replacement task, but was pulled out in a effort to clean-up that
section of code, while fixing another bug:
<offending commit msg>
In addition, I added following three changes.

- Removed tmp_orphan_lvs handling procedure
  It seems that _delete_lv() can handle detached_log_lv properly
  without adding mirror legs in mirrored log to tmp_orphan_lvs.
  Therefore, I removed the procedure.

- Removed vg_write()/vg_commit()
  Metadata is saved by vg_write()/vg_commit() just after detached_log_lv
  is handled. Therefore, I removed vg_write()/vg_commit().
</offending commit msg>

http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c?cvsroot=lvm2&f=h#rev1.130

I've reverted the "clean-up" changes associated with that fix, but not what
that commit was actually fixing.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-10-14 20:03:12 +00:00
df1b244fda Add a VERBOSE option to make check (make check VERBOSE=1). 2010-10-14 14:36:26 +00:00
004cda1b64 Convey need for snapshot-merge target in lvconvert error message and man
page.

Add ->target_name to segtype_handler to allow a more specific target
name to be returned based on the state of the segment.

Result of trying to merge a snapshot using a kernel that doesn't have
the snapshot-merge target:

Before:
# lvconvert --merge vg/snap
  Can't expand LV lv: snapshot target support missing from kernel?
  Failed to suspend origin lv

After:
# lvconvert --merge vg/snap
  Can't process LV lv: snapshot-merge target support missing from kernel?
  Failed to suspend origin lv
  Unable to merge LV "snap" into it's origin.
2010-10-13 21:26:37 +00:00
97c6592073 Tweak WHATS_NEW for devices/disable_after_error_count. 2010-10-13 15:50:34 +00:00
949b8c519b Tweak the lvm.conf comment about devices/disable_after_error_count. 2010-10-13 15:45:18 +00:00
e59624d6e9 Update WHATS_NEW. 2010-10-13 15:41:52 +00:00
74b228ee94 Limit repeated accesses to broken devices.
Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-10-13 15:40:38 +00:00
1565532bc7 Update WHATS_NEW. 2010-10-13 13:53:25 +00:00
21a17f291c Give correct error message when creating a too-small snapshot (BZ 587063) 2010-10-13 13:52:53 +00:00
919568a223 Don't use floor() in _bitset_with_random_bits
Use _even_rand() function instead of floor() in _bitset_with_random_bits().
floor() function is missing in dietlibc (on architectures other than x86).
Moreover using floor() to clip rand results does not assure even result
distribution. _even_rand() uses integer arithmetic only and is designed to
return evenly distributed results.

> Looks OK to me. It took a while to decipher what is the exact meaning of
> the loop in _even_rand (to a non-pseudorandomness-expert) but I am
> fairly comfortable with it now. If I understand this correctly, it
> rejects numbers that come from an "incomplete" slice of the RAND_MAX
> space (considering the number space [0, RAND_MAX] is divided into some
> "max"-sized slices and at most a single smaller slice, between [n*max,
> RAND_MAX] for suitable n -- numbers from this last slice are discarded
> because they could distort the distribution in favour of smaller
> numbers).

Signed-off-by: Przemyslaw Iskra <sparky <at> pld-linux.org>
Reviewed-by: Petr Rockai <prockai <at> redhat.com>
2010-10-13 12:18:53 +00:00
ec81f7151d Update WHATS_NEW. 2010-10-13 10:37:27 +00:00
46eae0cdd8 Add a test for vgextend --restoremissing. 2010-10-13 10:36:26 +00:00
e5ecec8140 Implement vgextend --restoremissing (BZ 537913), which makes it possible to
re-add a physical volume that has gone missing previously, due to a transient
device failure, without re-initialising it.

Signed-off-by: Petr Rockai <prockai@redhat.com>
Reviewed-by: Alasdair Kergon <agk@redhat.com>
2010-10-13 10:34:31 +00:00
401f9e0eaf Skip fsadm testing until proper installation rules are commited in.
For now testing of fsadm is broken - as it's executing fsadm from system
and not from the package thus we get wrong results.
2010-10-13 09:44:52 +00:00
06769c9ccd Fix lv_modules_dup segfault. 2010-10-12 17:09:23 +00:00
009e7950bf Make lvconvert respect --yes/--force in the inactive log conversion
prompt. Fixes BZs 642055, 621281. Patch by Taka.

Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-10-12 16:41:17 +00:00
66ad893ca4 update WHATS_NEW 2010-10-12 16:17:50 +00:00
15f4b08f94 Add an option to skip some tests in make check (regex based, like T=): eg.
$ sudo make check S='mirror-basic|fsadm'
2010-10-12 16:17:25 +00:00
9b4b94edc0 test-utils: Fix a slight bug in the dmeventd-already-running error message. 2010-10-12 16:13:43 +00:00
476099efc1 Refactor and add code for (lv) 'modules' get function. 2010-10-12 16:13:06 +00:00
cab4c903d0 Refactor and add code for (lv) 'mirror_log' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:50 +00:00
d9da96c8ad Refactor and add code for (lv) 'lv_kernel_{major|minor}' get functions.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:33 +00:00
d9ea736248 Refactor and add code for (lv) 'convert_lv' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:18 +00:00
b4dc68ba50 Refactor and add code for (lv) 'move_pv' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:02 +00:00
786f8576e3 Refactor and add code for (lv) 'origin_size' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:11:48 +00:00
ec739277a1 Refactor and add code for (lv) 'lv_path' get function. 2010-10-12 16:11:34 +00:00
8376fd198f Add some lv 'get' functions that require no refactoring.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:11:20 +00:00
39429d3905 Update script for fsadm testing 2010-10-08 15:03:21 +00:00
4fb84eedfe Add support for noninterctive shell execution
Try to distinguish between the case of  using interactive shell and non
interactive running - different combinations of  '-y' and '-p' option
needs to be used for fsck.
2010-10-08 15:02:05 +00:00
1a64b3c812 Fix usage of --yes flag for ReiserFS resize
Put 'dry' before resize command - using dry for echo had no use.
2010-10-08 15:00:06 +00:00
66c590c89c Fix detection of mounted filesystem.
Update the way how fsadm detects mounted filesystem.
With udev /dev/dm-XXX paths are now returned - but mount or /proc/mounts
prints names in form of /dev/mapper/vg-lv - so the match was not found.
Fixex RHBZ #638050.

Current solution uses same trick as mount and detects vg-lv name through
/sys where available - this should be reasonable safe.

Instead of calling mount without parameter to get actual mount table,
switch to use /proc/mounts directly.
2010-10-08 14:55:19 +00:00
821c266f1d Fix assignment of default LVM variable
Fix a typo which does not work in case LVM_BINARY is empty string.
Using proper :-  syntax.
2010-10-08 14:49:25 +00:00
4e63287d75 Support for passing --yes flag recursively. 2010-10-08 13:49:20 +00:00
7f5ac28c78 Correctly respect --dry-run option for fsadm
Fix missing 'dry' execution of lvresize - fixing problem where resize
command were 'dry-run' executed - but lvresize has been executed for real.

Also adapt code slightly to support better recursive execution of fsadm
through lvresize call.
2010-10-08 13:47:10 +00:00
52cd4a5893 Fix a serious bug in the behavior of fasdm tool when breaked.
Under certain conditions it was possible to break (^C) fsadm before actually
resizing filesystem, but lvresize which executed fsadm will think resize
was succesful and shrinks partitions with unresized filesystem on it.

Fix by returning error (1) for this case - this stops lvresize from futher
proceding in resize operation.
2010-10-08 12:35:56 +00:00
04c5af2130 Replace "can not" with "cannot" 2010-10-08 11:18:29 +00:00
52893778f8 Allow CC to be overridden at build time (for 'scan-build make'). 2010-10-07 16:33:34 +00:00
600e67b17a Rename 'flags' to 'status' for struct metadata_area.
In other LVM memory structures such as volume_group, the field
used to store flags is called "status", and on-disk fields are called
'flags', so rename the one inside metadata_area to be consistent.
Not only is it more consistent with existing code but is cleaner
to say "the status of this mda is ignored".

Background for this patch - prajnoha pinged me on IRC this morning
about a fix he was working on related to metadataignore when
metadata/dirs was set.  I was reviewing my patches from this year
and realized the 'flags' field was probably not the best choice
when I originally did the metadataignore patches.
2010-10-05 17:34:05 +00:00
2da49b93bd Restrict lvm1 partial mode.
Current lvm1 allocation code seems to not properly
map segments on missing PVs.

For now disable this functionality.
(It never worked and previous commit just introduced segfault here.)

So the partial mode in lvm1 can only process missing PVs
with no LV segments only.

Also do not use random PV UUID for missing part but use fixed
string derived from VG UUID (to not confuse clvmd tests).
2010-10-04 18:59:01 +00:00
a65df0e598 Add dm_zalloc and use it and dm_pool_zalloc throughout. 2010-09-30 21:06:50 +00:00
54d4416ef8 Fix copyright dates on new files lib/metadata/{lv|vg|pv}.[ch]. 2010-09-30 20:47:18 +00:00
42a7af1632 Update WHATS_NEW for commits related to generic property functions 2010-09-30 14:26:48 +00:00
cfbbf34d6a Fix memory leak of vg_read while using live copies of metadata in directories. 2010-09-30 14:12:14 +00:00
5b35bbdf1b Add pv_get_property and create generic internal _get_property function.
We need to use a similar function for pv and lv properties, so just make
a generic _get_property() function that contains most of the required
functionality.  Also, add a check to ensure the field name matches the
object passed in by re-using report_type_t enum.  For pv properties,
the report_type might be either PVS or LABEL.

In addition, add 'const' to 'get' functions object parameter, but not
'set' functions.  Add _not_implemented_set() and _not_implemented_get()
functions.
2010-09-30 14:09:45 +00:00
0c46d48e40 Add pv 'get' functions for all pv properties.
Add 'get' functions for all pv properties.
Multiply by SECTOR_SIZE for pv properties pv_mda_free, pv_mda_size,
pe_start, pv_size, pv_free, pv_used.
2010-09-30 14:09:33 +00:00
e78ad5f175 Add pv_name_dup() and pv_fmt_dup() helper functions. 2010-09-30 14:09:22 +00:00
09c2296a9a Add pv_mda_size, pv_mda_free, and pv_used functions, call from 'disp' functions. 2010-09-30 14:09:10 +00:00
55a3cf7ecd Add 'get' functions for vg fields.
Add 'get' functions based on generic macros for VG, PV, and LV.
Add 'get' functions for vg string fields, vg_name, vg_fmt, vg_sysid,
vg_uuid, vg_attr, and vg_tags, and all numeric fields.
2010-09-30 14:08:58 +00:00
180705e9eb Make generic GET_*_PROPERTY_FN macros and define secondary macro for vg, pv, lv.
Will need similar macros for VG, PV and LV, so define a generic one, and just
pass in the struct name and variable name for the specific macro.
2010-09-30 14:08:46 +00:00
f5cf560a3c Add supporting functions vg_name_dup, vg_fmt_dup, vg_system_id_dup.
Add supporting functions for vg_name, vg_fmt, vg_system_id.
Append "_dup" to end of supporting functions to make clear the strings
are dup'd and to avoid namespace conflict with vg_name.
2010-09-30 14:08:33 +00:00
1e11b5dd7c Add pv_tags_dup, vg_tags_dup, lv_tags_dup functions that call tags_format_and_copy. 2010-09-30 14:08:19 +00:00
f201c75a24 Add tags_format_and_copy() common function and call from _tags_disp.
Add a common function to allocate memory and format a string of
tags.
Call tags_format_and_copy() from _tags_disp().
2010-09-30 14:08:07 +00:00
41219737ad Add pv_uuid_dup, vg_uuid_dup, and lv_uuid_dup, and call id_format_and_copy.
Add supporting functions for pv_uuid, vg_uuid, and lv_uuid.
Call new function id_format_and_copy.  Use 'const' where appropriate.
Add "_dup" suffix to indicate memory is being allocated.
Call {pv|vg|lv}_uuid_dup from lvm2app uuid functions.
2010-09-30 14:07:47 +00:00
35d1b6665c Add id_format_and_copy() common function and call from _uuid_disp.
Add supporting uuid function to allocate memory and call id_write_format.
Call id_format_and_copy from _uuid_disp.
2010-09-30 14:07:33 +00:00
0543201db1 Simplify logic to create 'attr' strings.
This patch addresses code review request to simplify creation of 'attr'
strings.  The simplification is done in this separate patch to more
easily review and ensure the simplification is done without error.
2010-09-30 14:07:19 +00:00
8e4da1d397 Add {pv|vg|lv}_attr_dup() functions and refactor 'disp' functions.
Move the creating of the 'attr' strings into a common function so
they can be called from the 'disp' functions as well as the new
'get' property functions.
Add "_dup" suffix to indicate memory is allocated.
Refactor pvstatus_disp to take pv argument and call pv_attr_dup().
2010-09-30 13:52:55 +00:00
2977bfa721 Add lib/metadata/vg.[ch] and lib/metadata/lv.[ch].
These got missed when git cvsexportcommit was used.
2010-09-30 13:16:55 +00:00
5fa92bf619 Add lib/metadata/pv.[ch] new files.
Apparently git cvsexportcommit does not properly add new files
from a git commit.
2010-09-30 13:15:42 +00:00
3e37822415 Refactor metadata.[ch] into lv.[ch] for lv functions.
This patch is similar to the other patches for pv and vg
functionality, and separates lv functionality into separate
files, concentrating on reporting fields and simple functions.
2010-09-30 13:05:45 +00:00
4d65f59824 Refactor metadata.[ch] into pv.[ch] for pv functions.
The metadata.[ch] files are very large.  This patch makes a first
attempt at separating out pv functions and data, particularly
related to the reporting fields calculations.

More code could be moved here but for now I'm stopping at reporting
functions 'get' / 'set' functions.
2010-09-30 13:05:20 +00:00
cd5829fc42 Refactor metadata.[ch] into vg.[ch] for vg functions.
The metadata.[ch] files are very large.  This patch makes a first
attempt at separating out vg functions and data, particularly
related to the reporting fields calculations.
2010-09-30 13:04:55 +00:00
86b056872d Fix memory leak of config_tree
Adding missing destroy_config_tree() for cft_override if it has been allocated.
2010-09-30 11:44:54 +00:00
b1007b02c0 Fix leaked pool report
Swap pool destruction order in dmeventd_lvm2_exit() to fix leak report.
2010-09-30 11:40:14 +00:00
d3126d15cf Maps fix
Read complete content of /proc/self/maps into one buffer without
realocation in the middle of reading and before doing any m/unlock
operation with these lines - as some of them gets change.
With previous implementation we've read some mappings twice ([stack])
2010-09-30 11:32:40 +00:00
d61ed147ac Add missing cleanup rule for generated .exported_symbols_generated 2010-09-30 10:08:58 +00:00
b1f3aa2920 Speed up unquoting of quoted double quotes and backslashes. 2010-09-28 01:29:06 +00:00
8ad3bb1462 drop an unnecessary 'stack' 2010-09-27 19:15:13 +00:00
b91a077d23 was renamed 2010-09-27 19:10:46 +00:00
3df29c1667 Speed up CRC32 calculations by using a larger lookup table.
Use -DDEBUG_CRC32 to revert to old function and check new one gives same result.
2010-09-27 19:09:34 +00:00
abf6c8eb4d pre-release 2010-09-24 16:24:57 +00:00
cffd634681 Add escape sequence for ':' and '@' found in device names used as PVs. 2010-09-23 12:02:33 +00:00
e72e8cc71f Replace alloca with dm_malloc in _aligned_io.
(This section of code dates from 2.4 and could be written more efficiently nowadays.)
2010-09-22 22:31:45 +00:00
8eaef39b33 Fix handling of partial VG for lvm1 format metadata
If some lvm1 device is missing, lvm fails on all operations
# vgcfgbackup -f bck -P vg_test
  Partial mode. Incomplete volume groups will be activated read-only.
  3 PV(s) found for VG vg_test: expected 4
  PV segment VG free_count mismatch: 152599 != 228909
  PV segment VG extent_count mismatch: 152600 != 228910
  Internal error: PV segments corrupted in vg_test.
  Volume group "vg_test" not found

Allow loading of lvm1 partial VG by allocating "new" missing PV,
which covers lost space. Also this fake mising PV inform code
that it is partial VG.

https://bugzilla.redhat.com/show_bug.cgi?id=501390
2010-09-22 13:45:21 +00:00
1588334093 Fix name in msg in last checkin.
(The problem the last checkin addressed was a segfault in 'pvs -a' if .cache
didn't contain every PV in a VG.)
2010-09-22 01:50:38 +00:00
6f4fb574ec Track recursive filter iteration to avoid refreshing while in use. (2.02.56) 2010-09-22 01:36:13 +00:00
64cc7834a8 "goto_bad" should be used in alloc_printed_tags function, not "goto bad". 2010-09-21 10:42:02 +00:00
11e2edcf5f Revert to old glibc behaviour for vsnprintf used in emit_to_buffer function.
Revert to old glibc behaviour for vsnprintf used in emit_to_buffer fn.
Otherwise, the check that follows would be wrong for new glibc versions.
This caused the rh bug #633033 to be undetected and pass throught the check,
corrupting the metadata!
2010-09-20 14:25:27 +00:00
f900ddb544 Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit). 2010-09-20 14:23:20 +00:00
4f60a6ea02 Update vg_mda_free 'get' function to multiply by SECTOR_SIZE. 2010-09-09 19:38:03 +00:00
dc1bc980d0 Add random suffix to archive file names to prevent races when being created.
In certain configurations, we're not under a VG rw lock while trying to write
a new archive file with VG metadata. A common example is using "vgs" while
having the content of backup and archive directories empty. The code scans the
content of these directories and tries to determine the final index that should
be used in archive name. Since we're not under a lock, we can get into a race
while choosing the index which could end up showing errors about not being able
to rename to final archive name. Let's add random number suffix to these archive
file names so we can avoid the race.
2010-09-09 13:13:12 +00:00
3d3ae02e62 Reinitialize archive and backup handling on toolcontext refresh.
For example, when using '--config "backup { ... }"' line, the values from
lvm.conf (or default values) should be overridden. This patch adds
reinitialisation of archive and backup handling on toolcontext refresh
which makes these settings to be applied.
2010-09-09 13:07:13 +00:00
a70a110f31 This patch fixes an issue where cluster mirror write I/O
can be opprobriously slow if created with '--nosync'.

One of the ways cluster mirrors coordinate I/O and recovery
amoung the different machines is by the use of the log
function 'is_remote_recovering()' which lets nodes know if
a region they wish to perform a write on is currently being
recovered on another node.  If the region is being recovered,
the I/O is delayed.

The 'is_remote_recovering' routine has been optimized to
avoid the deluge of requests that would be issued to the
userspace log server by maintaining a marker of how far
the recovery has gotten.  It can then immediately return
'not recovering' if the region being inquired about is
less than this mark.  Additionally, if the region of
concern is greater than the mark, the function will
limit the number of transmissions to userspace by assuming
the region /is/ being recovered when skipping the
transmission.  This limits the amount of processing
and updates the mark in 1/4 sec time steps.

This patch fixes a problem where 'the mark' is not being
updated because of faulty logic in the userspace log
daemon.  When '--nosync' is used to create a cluster
mirror, the userspace log daemon never has a chance
to update the mark in the normal way.  The fix is to set
the mark to "complete" if the mirror was created with
the --nosync flag.
2010-08-30 18:37:42 +00:00
05d3869acf Do not run singlenode clvmd tests if support for singlenode not compiled in. 2010-08-27 08:52:54 +00:00
72489fb458 Currently tests require SI units enabled and data alignment to 1MiB.
For now force it in lvm.conf (otherwise it fails on older systems like RHEL5
where are these options disabled by default).

FIXME: it should test and detect both versions.
2010-08-27 07:59:40 +00:00
fe8b1db933 This patch fixes a problem where the mirror polling process
may never complete.

If you convert from a linear to a mirror and then convert that
mirror back to linear /while/ the previous (up)convert is
taking place, the mirror polling process will never complete.
This is because the function that polls the mirror for
completion doesn't check if it is still polling a mirror and
the copy_percent that it gets back from the linear device is
certainly never 100%.

The fix is simply to check if the daemon is still looking at
a mirror device - if not, return PROGRESS_CHECK_FAILED.

The user sees the following output from the first (up)convert
if someone else sneaks in and does a down-convert shortly
after their convert:
[root@bp-01 ~]# lvconvert -m1 vg/lv
  vg/lv: Converted: 43.4%
  ABORTING: Mirror percentage check failed.
2010-08-26 16:29:12 +00:00
8fdd90eb40 This patch fixes a potential for I/O to hang and LVM commands
to block when a mirror under a snapshot suffers a failure.

The problem has to do with label scanning.  When a mirror suffers
a failure, the kernel blocks I/O to prevent corruption.  When
LVM attempts to repair the mirror, it scans the devices on the
system for LVM labels.  While mirrors are skipped during this
scanning process, snapshot-origins are not.  When the origin is
scanned, it kicks up I/O to the mirror (which is blocked)
underneath - causing the label scan (an thus the repair operation)
to hang.

This patch simply bypasses snapshot-origin devices when doing
labels scans (while ignore_suspended_devices() is set).  This
fixes the issue.
2010-08-26 14:21:50 +00:00
564a356f09 Fix previous const removal. 2010-08-26 12:22:05 +00:00
3927137203 Fix return type qualifier to avoid compiler warning.
introduced in commit b16b4d92a7
"Improve various log messages."

fixes a lot of
../include/metadata.h:148: warning: type qualifiers ignored on function return type
2010-08-26 12:08:19 +00:00
f826ad5c89 Make example.conf description for 'default_data_alignment' more generic. 2010-08-25 13:06:03 +00:00
517ee7f6c3 Fix timestamp.
Not only in Wonderland time can run backwards.
2010-08-25 11:25:02 +00:00
99cc41356c Update configure after last change. 2010-08-23 13:44:31 +00:00
e76736cf55 Based on auto-detection or user requested cluster managers for clvmd,
set appropriate Required-Start and Required-Stop at configure time.

Reorder the checks for user selected cluster managers to match auto
detected ones, to be consistent in the output.

Add special case for qdiskd that´s started after cman/lock_gulmd for
RHEL-4/RHEL-5.
2010-08-23 11:37:02 +00:00
2a7bbc7e46 Fix pvmove --abort <dev> return code
It prints error code even if abort operation succeeds:

pvmove --abort /dev/sdb
  Command failed with status code 5.
2010-08-23 11:34:40 +00:00
bda6449118 Fix pvmove --abort to work even for empty pvmove LV
If pvmove crashed and metadata contains pvmove LV
but without miorrored segments, pvmove --abort
will not repair the situation (and finish wth success!).

Fix it by allowing metadata update if aborting
(thus removing pvmove LV) even if no moved LVs detected.

(Tested on real metadata provided by an lvm user:-)
2010-08-23 11:34:10 +00:00
e6166e4498 Verify that pvcreate --dataalignment really does override the topology
detected alignment.

NOTE: lvm2 doesn't detect MD 1.2 metadata (now the default on RHEL6) so
for now I'm forcing 1.0 metadata.  This was needed to be able to reuse
the existing loop devices but recreate the md device with different
raid0 striping.
2010-08-21 15:43:45 +00:00
80a878ade5 . 2010-08-21 00:18:05 +00:00
bbf2fcf17a autoreconf also updates configure.h.in 2010-08-21 00:16:37 +00:00
c1d266bd9a Update configure for snitm changes 2010-08-20 22:32:18 +00:00
7a7f3f2f5b Switch to using configure --with-default-data-alignment=<NUM> to
establish DEFAULT_DATA_ALIGNMENT.  Again, 0=64KiB, 1=1MiB, 2=2MiB

Default is 1.
2010-08-20 22:24:58 +00:00
0371941707 Update heuristic used for default and detected data alignment.
Add "devices/default_data_alignment" to lvm.conf to control the internal
default that LVM2 uses: 0==64k, 1==1MB, 2==2MB, etc.

If --dataalignment (or lvm.conf's "devices/data_alignment") is specified
then it is always used to align the start of the data area.  This means
the md_chunk_alignment and data_alignment_detection are disabled if set.

(Same now applies to pvcreate --dataalignmentoffset, the specified value
will be used instead of the result from data_alignment_offset_detection)

set_pe_align() still looks to use the determined default alignment
(based on lvm.conf's default_data_alignment) if the default is a
multiple of the MD or topology detected values.
2010-08-20 20:59:05 +00:00
6f449e65a4 Update WHATS_NEW 2010-08-20 20:35:55 +00:00
5491f09bab Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' functions. 2010-08-20 13:02:39 +00:00
6949ec443e Add implmentation for simple numeric 'get' property functions.
Add 'get' functions based on the simple macro function definition for a
numeric property.

Add 'get' functions for the following: _vg_extent_count_get,
_vg_free_count_get, _max_lv_get, _max_pv_get, _pv_count_get,
_lv_count_get, _snap_count_get, _vg_seqno_get, _vg_size_get,
_vg_free_get, vg_mda_*.

For size functions, multiply by SECTOR_SIZE to return the value in bytes.
2010-08-20 12:45:09 +00:00
47ca8f9c12 Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' functions. 2010-08-20 12:44:58 +00:00
ba303a615b Add properties.[ch] to lib/report, defined based on columns.h.
Extend the existing reporting infrastructure definitions and structures
to include a 'get' and 'set' function for each field.  We will provide
a 'get' and 'set' function for each of these fields, which will be utilized
by exported lvm2app functions.

Define a default _not_implemented 'get' and 'set' function that just sets
an errno and returns 0.  Future patches will actually implement the
specific 'get' and 'set' functions for each property.  For read-only
properties, only the 'get' function will be implemented.

Define vg_get_property() function to query a property.  We will call
this from a lvm2app function.
2010-08-20 12:44:47 +00:00
350582bc7b Add macro definitions to report infrastructure for character array length.
Rather than hard code the size of the field, use a #define, so we can re-use.
The #define will be needed in a future patch when we extend the reporting
infrastructure to have 'get' and 'set' functions for each field, allowing
lvm2app functions which query any report field.  In order to provide a
generic lookup based on the field id, we will define a type containing this
field id, and thus, we will need to re-use the length of this string as
it's defined inside libdevmapper.h.
2010-08-20 12:44:30 +00:00
b9836e714a Remove explicit double quotes from columns.h 'id' entries.
The 'id' entries in columns.h are the report field names.  Since these are
unique, we'd like to use them in generation of 'get' / 'set' functions.
As a step towards using them for this purpose, remove the explicit double
quotes and use the macro '#' character to add the double quotes back when
placing them into the '_fields' array 'id' member.
2010-08-20 12:44:17 +00:00
aae30e6db5 Add 'flags' field to columns.h and define FIELD_MODIFIABLE.
Add a 'flags' field to columns.h, and set it to 0 by default.
Define FIELD_MODIFIABLE flag to indicate whether a 'set' function exists
to change the field's value.
2010-08-20 12:44:03 +00:00
86e46f17de Add vg_mda_size and vg_mda_free functions.
Add supporting functions to get vg_mda_size and vg_mda_free fields.
Should be no functional change.
2010-08-20 12:43:49 +00:00
fbc263659b Fix wrong use of LCK_WRITE
In all top vg read functions only LCK_VG_READ/WRITE can be used.
All other vg lock definitions are low-level backend machinery.

Moreover, LCK_WRITE cannot be tested through bitmask.
This patch fixes these mistakes.

For _recover_vg() we do not need lock_flags, it can be only
two of above and we always upgrading to LCK_VG_WRITE lock there.
(N.B. that code is racy)

There is no functional change in code (despite wrong masking
it produces correct bits:-)
2010-08-19 23:26:31 +00:00
8c8a7cbba4 Detect LUKS signature in pvcreate
One shiny day we should use libblkid here. But now using LUKS is
very common together with LVM and pvcreate destroys LUKS completely.

So for user's convenience, try to detect LUKS signature and allow abort.
2010-08-19 23:08:18 +00:00
f5e3cd0dbf Fix file descriptor leak in swap signature detection 2010-08-19 23:05:45 +00:00
24c1a0954b Remove assumption that --yes must be used only in --force mode
This is not only undocumented but is is also in violation with --help
documentation.

Using --yes without --force is useful in pvcreate when it detects
old signature.
2010-08-19 23:04:37 +00:00
f05cf23b89 Change the pvcreate swap/md logic
pvcreate detects MD and swap signature.

The logic hidden there is not only documented but it is also
user unfriendly. Who invented this logic should run pvcreate
on its own critical MD device to see why;-)

This patch
 - creates one function instead of duplication code
 - asks if user want to overwrite signature
 - allows aborting (!)
 (Please note that writing LVM signatute without wiping old
 is wrong, it confuses blkid, MD will not work anyway and
 swap and LUKS is broken too.)
2010-08-19 23:03:34 +00:00
90c883c201 post-release 2010-08-19 22:33:14 +00:00
2d0b95cd49 pre-release 2010-08-18 20:57:10 +00:00
e2bc7a277e Fix dm-mod autoloading logic to not assume control node is set correctly.
We can't rely on the fact that udev should prepare the node with right major
and minor number to trigger the module autoloading. We have to take into
account that the node could be missing or it could exist with improper
major and minor number assigned (e.g. from previous kernel versions in
an environment with static nodes and without udev). Make any corrections
if needed!
2010-08-18 13:11:56 +00:00
adbd3e478b Fix for bug 596453: multiple mirror image failures cause lvm repair...
The lvm repair issues I believe are the superficial symptoms of this
bug - there are worse issues that are not as clearly seen.  From my
inline comments:
* If the mirror was successfully recovered, we want to always
* force every machine to write to all devices - otherwise,
* corruption will occur.  Here's how:
*    Node1 suffers a failure and marks a region out-of-sync
*    Node2 attempts a write, gets by is_remote_recovering,
*          and queries the sync status of the region - finding
*          it out-of-sync.
*    Node2 thinks the write should be a nosync write, but it
*          hasn't suffered the drive failure that Node1 has yet.
*          It then issues a generic_make_request directly to
*          the primary image only - which is exactly the device
*          that has suffered the failure.
*    Node2 suffers a lost write - which completely bypasses the
*          mirror layer because it had gone through generic_m_r.
*    The file system will likely explode at this point due to
*    I/O errors.  If it wasn't the primary that failed, it is
*    easily possible in this case to issue writes to just one
*    of the remaining images - also leaving the mirror inconsistent.
*
* We let in_sync() return 1 in a cluster regardless of what is
* in the bitmap once recovery has successfully completed on a
* mirror.  This ensures the mirroring code will continue to
* attempt to write to all mirror images.  The worst that can
* happen for reads is that additional read attempts may be
* taken.
2010-08-17 23:56:23 +00:00
7b0804c22f Attempt to fix buildbot failure in t-lvconvert-mirror.sh due to failing to
wait for mirror to get into sync before running subsequent command.
2010-08-17 22:01:41 +00:00
47dfe904ab Use 'SINGLENODE' instead of 'dead' in clvmd singlenode messages.
Ignore snapshots when performing mirror recovery beneath an origin.
Pass LCK_ORIGIN_ONLY flag around cluster.
Add suspend_lv_origin and resume_lv_origin using LCK_ORIGIN_ONLY.
2010-08-17 19:25:05 +00:00
7f5b44b423 Allow internal suspend and resume of origin without its snapshots. 2010-08-17 16:25:32 +00:00
c16ca69070 Fix dev_manager_transient to access -real device not snapshot-origin. (brassow)
Another reminder why cloning functions impedes maintenance.
2010-08-17 01:51:12 +00:00
394c628931 Monitor origin -real device below snapshot instead of overlay device. (brassow) 2010-08-17 01:16:41 +00:00
43695024af Don't really change monitoring status when in test mode. 2010-08-16 23:29:09 +00:00
1678de7f51 Add some v1 to v2 metadata upgrade testing. 2010-08-16 23:21:20 +00:00
063436c82b Various small cleanups and fixes related to monitoring. 2010-08-16 22:54:35 +00:00
59585550a7 Remove superfluous NULL pointer tests before dm_free from dmeventd. 2010-08-16 18:19:46 +00:00
51e294c501 Fix for bug 612291: dm devices of split off mirror images are not removed
DM devices were not handled properly on nodes in a cluster that were not
where the splitmirrors command was issued.  This was happening because
suspend_lv/resume_lv were being used in a place where activate_lv should
have been used.

When the suspend/resume are issued on (effectively) new LVs, their
'resource' (UUID) is not located in the lv_hash.  Thus, both operations
turn into no-ops.  You can see this from the output of clvmd from one
of the remote nodes:
<snip>
do_suspend_lv, lock not already held
<snip>
do_resume_lv, lock not already held

'activate_lv' enjoins the other nodes in the cluster to process the lock
and activate the new LV.  clvmd output from remote node as follows:
do_lock_lv: resource 'zMseY7CBuO3Ty09vXlplPAHzD0Y0CovjrTdv0R1VcwggMwPdYhutHErRcwm5Nd2S', cmd = 0x19 LCK_LV_ACTIVATE (READ|LV|NONBLOCK), flags = 0x84 (DMEVENTD_MONITOR ), memlock = 1
sync_lock: 'zMseY7CBuO3Ty09vXlplPAHzD0Y0CovjrTdv0R1VcwggMwPdYhutHErRcwm5Nd2S' mode:1 flags=1
sync_lock: returning lkid 27b0001

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-08-16 18:02:14 +00:00
22ffec640d set DEFAULT_RUN_DIR (missed from earlier checkin?) 2010-08-16 17:49:26 +00:00
7ab3c4c091 WHATS_NEW_DM 2010-08-16 11:22:08 +00:00
19934a59b2 dm-mod autoloading support is in kernel 2.6.36 actually. 2010-08-16 11:13:18 +00:00
f3645e3f4b Fix udev rules to support udev database content generated by older rules.
This can happen with older rules (without support for synthesized events)
that are still part of initrd while using new udev rules in the system itself.

The consequence was that new udev rules incorrectly assumed that not having
DM_UDEV_PRIMARY_SOURCE_FLAG set always means the uevent is synthesized and
inappropriate (device is still not properly activated) and so it should be
ignored. However, initrd is not updated automatically while updating the
libdevmapper/udev rules in the system and so we end up with the rules not
detecting and setting crucial parts in the initrd environment and the rules
in the system that rely on the information that should have been stored in
udev db (which is incorrect in this configuration, of course).

The overall consequence is that the update of libdevmapper/lvm2 without
regenerating the initrd could end up with a boot failure! Ignoring the event
means removing any existing symlinks in /dev!

To fix this, increase udev rules version to make a difference. So from now on,
mark rules without proper support for synthesized events as
DM_UDEV_RULES_VSN="1" and 2 (or higher) if that support is included.
2010-08-12 13:41:18 +00:00
d818035d3a Reinstate detection of inappropriate uevent with DISK_RO set and suppress it.
We still need to detect this one! We're not so strict with CHANGE events as
with the ADD events while applying filters in the rules so this one would
pass and it would process the rules prematurely (because it appears *before*
the actual CHANGE event used when resuming a DM device while setting read-only
state at the same time).
2010-08-12 13:07:08 +00:00
0cce8cfbaa Fix clvmd init script return code when executed as non-root user.
clvmd daemon itself does the right thing when invoked as non-root, by
returning 4.

The patch removes the use daemon function from
/etc/rc.d/init.d/functions that´s unnecessary and has th bad habit to
mask the return codes from the real daemon.

Add a simple and generic check to see if clvmd is executed by root or not.

Our stop/reload/restart paths in the init script are complex and not all
the tools involved in the process are guaranteed to return 4 if executed
by non-root against a process that´s running as root (for example kill
-TERM will return -1 and parsing the output to catch the error is
suboptimal at best).

https://bugzilla.redhat.com/show_bug.cgi?id=553381
2010-08-12 09:14:59 +00:00
3e132d71f5 fix t-pvcreate-operation-md.sh to require kernel.org Linux >= 2.6.33 for
the final alignment_offset check.  In the future, might look to check
for the RHEL6 kernel too.
2010-08-12 04:56:05 +00:00
2b3a4adff8 Change default alignment of pe_start to 1MB.
The new standard in the storage industry is to default alignment of data
areas to 1MB.  fdisk, parted, and mdadm have all been updated to this
default.

Update LVM to align the PV's data area start (pe_start) to 1MB.  This
provides a more useful default than the previous default of 64K (which
generally ended up being a 192K pe_start once the first metadata area
was created).

Before this patch:
# pvs -o name,vg_mda_size,pe_start
  PV         VMdaSize  1st PE
  /dev/sdd     188.00k 192.00k

After this patch:
# pvs -o name,vg_mda_size,pe_start
  PV         VMdaSize  1st PE
  /dev/sdd    1020.00k   1.00m

The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment
  then just use the default.
- Otherwise, use the detected value.

In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds
  1MB
- or the specified/detected value is not a power-of-2
2010-08-12 04:11:48 +00:00
de49d45568 Require --restorefile when using pvcreate --uuid.
Introduce --norestorefile to allow user to override the new requirement.

This can also be overridden with "devices/require_restorefile_with_uuid"
in lvm.conf -- however the default is 1.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-08-12 04:08:59 +00:00
de5337b187 WHATS_NEW_DM 2010-08-11 13:12:31 +00:00
f0e82e4473 Recognise and give preference to md device partitions (blkext major).
We can already detect MD devices internally. But when using MD partitions,
these have "block extended major" (blkext) assigned (259). Blkext major
is also used in general, so we need to check whether the original device
is an MD device actually.
2010-08-11 12:14:23 +00:00
5a00c29f8a Update WHATS_NEW. 2010-08-09 14:06:03 +00:00
dd5d9aa6bc Never scan internal LVM devices. 2010-08-09 14:05:16 +00:00
40f03c4c2c [REGEX] fix a long standing off-by-one error (found by valgrind-pool) 2010-08-09 10:58:27 +00:00
1aaf8d589f [MM] Make valgrind aware of the pool allocators
./configure with --enable-valgrind-pool to enable this.
2010-08-09 10:56:01 +00:00
1b87c6ade7 [REGEX] fix bug in matcher that was causing segfault with chars of 0x80 and over. 2010-08-09 10:30:52 +00:00
d52e9c7704 [REGEX] Parse regexes that contain chars with value > 0x80
This is a long standing issue.  Fixed by casting a char value to
unsigned char before using it as an index into a bitset.
2010-08-09 10:29:42 +00:00
9c7425eee4 [REGEX] add a unit test for regexes containing chars with value over x80 2010-08-09 10:27:31 +00:00
7cd8b4410e [REGEX] matcher_t unit test now takes a flag to turn on fingerprinting 2010-08-09 10:23:54 +00:00
c63e78714a Fix for bug 619221 - log device splitting regression
An incorrect fix on July 13, 2010 for an annoyance has caused a regression.
The offending check-in was part of the 2.02.71 release of LVM.  That
check-in caused any PVs specified on the command line to be ignored when
performing a mirror split.

This patch reverses the aforementioned check-in (solving the regressions)
and posits a new solution to the list reversal problem.  The original
problem was that we would always take the lowest mimage LVs from a mirror
when performing a split, but what we really want is to take the highest
mimage LVs.  This patch accomplishes that by working through the list in
reverse order - choosing the higher numbered mimages first.  (This also
reduces the amount of processing necessary.)

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Reviewed-by: Takahiro Yasui <takahiro.yasui@hds.com>
2010-08-06 15:38:32 +00:00
2b34836c61 A misunderstanding of the return value of 'dm_bit' has been causing a data
corruption bug in cmirror.  'dm_bit' is only ever used as a boolean operation
within LVM, but it can return a range of values.  If the bit is set, a power of
2 is returned.  If the bit is unset, 0 is returned.

'log_test_bit' (a function in the cluster mirror log daemon code) has switched
to using the dm bit operations in rhel6.  There are two places in the daemon
code where 'log_test_bit' is not used merely as a boolean, but rather the
return value is used as the return value for the log functions 'is_clean' and
'in_sync' - having assumed that 'dm_bit' was returning 0 or 1 only.

One place the 'in_sync' function is utilized is in 'dm_rh_get_state' - a
function that informs the mirroring code how to treat I/O and which devices to
read/write from.  'dm_rh_get_state' was checking if the return value of
'in_sync' was 1 to determine if the region was DM_RH_CLEAN.  Since 'dm_bit'
(and by extension 'log_test_bit' and 'in_sync') was returning powers of 2,
DM_RH_CLEAN was rarely being reported as it should have been.  Thinking the
region was out-of-sync, the mirroring code would write only to the primary
device.  When the primary device was failed, all of those writes were lost -
leaving the entire mirror corrupted.
2010-08-04 18:18:18 +00:00
32d1d7b23f Reduce severity of the "mirror transient status" log message (this was never
intended to be a log_error).
2010-08-04 15:55:03 +00:00
e7773faa8d Require logical volume(s) to be explicitly named for lvconvert --merge. 2010-08-03 20:22:31 +00:00
b7c2a2b709 Avoid changing aligned pe_start as a side-effect of very verbose logging. 2010-08-03 18:19:42 +00:00
67ef389a69 Use built-in rules for device aliases: block/ < dm- < disk/ < mapper/ < other. 2010-08-03 13:39:27 +00:00
7c1903a0c3 Fix 'void*' arithmetic warnings in dbg_malloc.c.
Use more readable char[idx] access instead of *char+idx access.
2010-08-03 13:24:07 +00:00
c8563cac0a Fix 'void*' arithmetic warning in some functions from libdm-iface.c. 2010-08-03 13:16:21 +00:00
42c4a7757d Fix const warning in dev_manager_info() and _dev_manager_lv_rmnodes(). 2010-08-03 13:13:01 +00:00
8b007b358e Fix constness warning in archive_file structure from archive.c. 2010-08-03 13:09:21 +00:00
5cd2cfc203 Use void parameter for function definition. 2010-08-03 13:06:35 +00:00
a7ca42cb22 Wait for node creation before displaying debug info in dmsetup.
Readahead check needs to see created node - so wait till udev gets in sync.
2010-08-03 13:04:32 +00:00
f562bcedef Clean generated files .exported_symbols_generated, example.conf for distclean. 2010-08-03 13:00:45 +00:00
a8dc5260b7 Fix return status 0 for "dmsetup info -c -o help".
Solution returns success for _report_init when help is passed,
and caller needs to check for _report existance.
2010-08-03 12:56:00 +00:00
d33d0b01bf Add check for kernel semaphore support and disable udev_sync if not available.
udev_sync feature requires semaphores (part of System V IPC) to be configured
in kernel (CONFIG_SYSVIPC). Check whether it is supported and if not, give
a warning message and disable udev synchronisation code automatically to
avoid any further error states and associated problems.

One should use the kernel with System V IPC support enabled or libdevmapper
with udev_sync feature disabled.
2010-08-03 07:56:03 +00:00
4a5195c38a Taka's fix for handling failure of all mirrored log devices and
all but one mirror leg.

<patch header>
To handle a double failure of a mirrored log, Jon's two patches are
commited, however, lvconvert command can't still handle an error
when mirror leg and mirrored log got failure at the same time.

  [Patch]: Handle both devices of a mirrored log failing (bug 607347)
  posted: https://www.redhat.com/archives/lvm-devel/2010-July/msg00009.html
  commit: https://www.redhat.com/archives/lvm-devel/2010-July/msg00027.html

  [Patch]: Handle both devices of a mirrored log failing (bug 607347) -
           additional fix
  posted: https://www.redhat.com/archives/lvm-devel/2010-July/msg00093.html
  commit: https://www.redhat.com/archives/lvm-devel/2010-July/msg00101.html

In the second patch, the target type of mirrored log is replaced with
error target when remove_log is set to 1, but this procedure should be
also used in other cases such as the number of mirror leg is 1. This
patch relocates the procedure to the main path.

In addition, I added following three changes.

- Removed tmp_orphan_lvs handling procedure
  It seems that _delete_lv() can handle detached_log_lv properly
  without adding mirror legs in mirrored log to tmp_orphan_lvs.
  Therefore, I removed the procedure.

- Removed vg_write()/vg_commit()
  Metadata is saved by vg_write()/vg_commit() just after detached_log_lv
  is handled. Therefore, I removed vg_write()/vg_commit().

- With Jon's second patch, we think that we don't have to call
  remove_mirror_log() in _lv_update_mirrored_log() because will be
  handled remove_mirror_images() in _lvconvert_mirrors_repaire().
</patch header>

Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-08-02 21:07:40 +00:00
0864378250 Disallow mirrored logs in cluster mirrors.
The cluster log daemon (cmirrord) is not multi-threaded and
can handle only one request at a time.  When a log is stacked
on top of a mirror (which itself contains a 'core' log), it
creates a situation that cannot be solved without threading.

When the top level mirror issues a "resume", the log daemon
attempts to read from the log device to retrieve the log
state.  However, the log is a mirror which, before issuing
the read, attempts to determine the 'sync' status of the
region of the mirror which is to be read.  This sync status
request cannot be completed by the daemon because it is
blocked on a read I/O to the very mirror requesting the
sync status.
2010-08-02 19:03:45 +00:00
855e4aac41 Fix lib.device-mapper to wait for include too 2010-08-02 13:56:34 +00:00
5f8a3896dc Minor speedup of lock test -
Instead of waiting for flock process finish kill the flock process.
2010-08-02 13:23:01 +00:00
903bfcaf4b Add shell function to trim spaces.
Test values as "$val" to avoid weird results when spaces are in output.
2010-08-02 13:20:50 +00:00
fcf46a9a42 Using count=0 is sufficient for creation of zeroed files. 2010-08-02 13:18:42 +00:00
1d1db98a2e Visually better align lines which are executed as a result of true
or false result of previous command.
2010-08-02 13:18:01 +00:00
51c8e01575 Do not use VPATH in include/Makefile 2010-08-02 13:17:03 +00:00
b87c774102 revert the 'Base' change - that wasn't the cause of the problem 2010-08-02 12:57:04 +00:00
6aa05bdc37 Fix exported_symbols generation to use standard compiler arguments. 2010-08-02 12:44:21 +00:00
4abee1da76 Use #include <> not "" in lvm2app.h which gets installed on the system. 2010-08-02 12:23:01 +00:00
2106e8f031 Make liblvm.device-mapper wait for include file generation. 2010-08-02 12:10:35 +00:00
4befd355b3 Drop explicit 'Base' version from exported symbols. 2010-07-31 14:13:59 +00:00
a544f403a2 Fix configure to supply DEFAULT_RUN_DIR to Makefiles. 2010-07-31 00:43:41 +00:00
8f1afa1766 Fix wrong number of mirror log at allocate policy
With mirror_log_fault_policy of 'remove' and mirror_image_fault_policy
of 'allocate', the log type of the mirror volume is converted from
'disk' or 'mirrored' to 'core' when all mirror legs but one in a mirror
volume broke.

Keep new_log_count as a number of valid log devices by using log_count
variable for a temporary usage in the first phase of error recovery
in _lvconvert_mirrors_repair().

Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-07-30 17:50:15 +00:00
c0789ae1b4 Remove irrelevant comments relating to vg_mda_copies. 2010-07-30 16:47:27 +00:00
9934a167a2 post-release 2010-07-28 21:58:08 +00:00
798ffad9a9 Never use clvmd singlenode unless explicitly requested with -Isinglenode. 2010-07-28 14:01:40 +00:00
fb3b7f2274 Change clvmd to communicate with lvm via a socket in /var/run/lvm. (mbroz)
https://bugzilla.redhat.com/show_bug.cgi?id=614248 [CVE-2010-2526]
2010-07-28 13:55:42 +00:00
23dd62ec54 add copyright notices to new files 2010-07-28 12:20:38 +00:00
a1affa1dc3 day+1 2010-07-28 11:49:42 +00:00
23633cf632 . 2010-07-28 10:44:29 +00:00
472bd55757 Revert unsuccessful table load preparation in combined "create, load and resume" scenario.
There was missing "revert" call in _create_and_load_v4 fn while the preparation
for table load ends up with failure in create/load/resume sequence. Otherwise
we could end up with a device being created, but not table-loaded nor resumed.

Even though the table is not loaded and the device is not resumed at this
stage, we still need to synchronize with udev when calling the revert
"remove" ioctl - there's still a remove uevent generated! The "revert"
code does exactly that.
2010-07-28 10:30:28 +00:00
2de4f65474 pre-release 2010-07-27 22:52:19 +00:00
38befc5ded . 2010-07-27 21:57:37 +00:00
5f9d855d3e Fix dm_create_lockfile error paths - incorrectly unlinked in-use lockfile.
(Jan Friesse)
2010-07-27 21:56:14 +00:00
3c5d941945 Do not create a clustered volume group in t-nomda-missing. 2010-07-27 21:08:32 +00:00
2f54dbd28c Make vgck warn about missing PVs. 2010-07-27 20:05:29 +00:00
b2b6c18db3 Initial import of document describing LVM's policies
surrounding device faults/failures.
2010-07-26 20:31:53 +00:00
33e7126ba5 Remove unneeded "active" variable in vgchange_monitoring(). 2010-07-26 19:03:29 +00:00
2ab98aa919 Clarify help text for vg_mda_count. 2010-07-21 19:44:25 +00:00
9ba875e502 Building without the '--enable-cmirrord' option means that
CMIRRORD_PIDFILE is not defined.  This makes the build fail.
Therefore, we need to conditionalize the check for cmirrord
based on if CMIRRORD_PIDFILE is defined.
2010-07-21 15:21:24 +00:00
2dcdb807f8 Don't fail t-pvcreate-operation-md if mdadm is broken. 2010-07-21 14:12:47 +00:00
56fe3c6176 It's not enough to check for the kernel module in the case of cluster
mirrors, we must also check that the log daemon (cmirrord) is running.
The log module can be auto-loaded, but the daemon cannot be
"auto-started".  Failing to check for the daemon produces cryptic
messages that customers have a hard time deciphering.  (The system
messages do report that the log daemon is not running, but people
don't seem to find this message easily.)

Here are examples of what is printed when the module is available,
but the log daemon has not been started.

[root@bp-01 LVM2]# lvcreate -m1 -l1 -n lv vg
  Shared cluster mirrors are not available.

[root@bp-01 LVM2]# lvcreate -m1 -l1 -n lv vg -v
    Setting logging type to disk
    Finding volume group "vg"
    Archiving volume group "vg" metadata (seqno 3).
    Creating logical volume lv
    Executing: /sbin/modprobe dm-log-userspace
    Cluster mirror log daemon is not running
  Shared cluster mirrors are not available.
    Creating volume group backup "/etc/lvm/backup/vg" (seqno 4).
2010-07-21 13:40:21 +00:00
321b26f3d4 update configure 2010-07-21 12:54:21 +00:00
ad37ab272a [REGEX] calculate dfa states on demand 2010-07-21 12:09:12 +00:00
d5feddb0a0 [REGEX] remove the state_queue structure.
Instead we just have a 'next' field in the dfa_state.
2010-07-21 12:02:51 +00:00
88ae26178c [REGEX] factor _calc_state() out of _calc_states() 2010-07-21 12:00:53 +00:00
e06357084e [REGEX] reduce the number of charset nodes that are produced 2010-07-21 11:58:49 +00:00
2e52c46165 [REGEX] another matcher_t test with a larger set of regexes, only interested in the fingerprint 2010-07-21 11:52:46 +00:00
a82cf6080e [REPORT-GENERATORS] cut down stylsheet.css to what we actually use 2010-07-21 10:00:38 +00:00
78f321b32c [REGEX] add a fingerprinting facility to allow test code to compare dfas 2010-07-20 15:32:07 +00:00
3113200309 [UNIT-TEST] test for recent dm_bit_and() function 2010-07-20 15:28:22 +00:00
4a854b2927 [UNIT-TESTS] add test for the recent dm_bitset_equal() function 2010-07-20 15:26:43 +00:00
a5e61545e4 Add a unit test for the recent changes to dm_bit_get_next() 2010-07-20 15:25:39 +00:00
17a259e894 Wire the regex tests up to the reports 2010-07-20 15:21:32 +00:00
f5fb224254 Move tests from old-tests/regex to unit-tests/regex. unit-tests will
contain tests that currently work.
2010-07-20 15:18:57 +00:00
fe07d17374 Report generators for unit tests and memory checks. Configure with
--enable-testing.
2010-07-20 14:38:44 +00:00
8d983d6f2d Fix for bug 614164: No check for existing name when splitting mirror
The user could use the same name as an existing LV when specifying a
name for an LV split off from a mirror.  This causes all sorts of
issues.
2010-07-13 22:24:39 +00:00
2c028990b4 Fix reversal of LV list before performing a split mirror.
When splitting off mirror images from a mirror, we always take
LVs from the end of a list.  For example, if the mirror sub-devices
are lv_mimage_[012], we should select lv_mimage_2 if splitting off
one image.  However, lv_mimage_0 was being selected instead.

The problem came from calling '_move_removable_mimages_to_end'
when it was unnecessary to do so.  When the user /does/ specify
specific devices to be removed, this function properly moved the
appropriate LVs to the end of the list for extraction.  However,
if the user /doesn't/ give any specific PVs, the function should
do nothing.  '_move_removable_mimages_to_end' was keying off of
whether 'removable_pvs' was NULL or not and this value was
improperly being populated with the set of all available PVs.
This was causing '_move_removable_mimages_to_end' to completely
reverse the list, which in turn caused us to extract the
hithertofore front-of-the-list LVs.
2010-07-13 22:04:36 +00:00
35af86cef2 Fix for bug 612311: Split of linear provides no error msg
An unhandled condition allowed the command to terminate
cleanly without a warning.  Added a check for the
'--splitmirrors' argument to allow execution to the lower
level function that has the check to see if the user is
trying to split a linear device.  You should now see a
message if you try to use --splitmirrors on a linear device.
2010-07-13 21:53:07 +00:00
659f47f76a Fix for bugs: 612248 & 612291 Split mirror issues
The main problem with these bugs was that the newly split
off LV was not being suspended properly.  This meant that
the memlock count was not being balanced, the DM devices
were not being renamed, and some DM devices which should
have been removed were not.

I've also renamed some of the variables and added comments
to make things clearer as to what is going on.  (I can break
this patch in two if it means easier review.)
2010-07-13 21:48:16 +00:00
b489acb578 Minor man page updates related to metadataignore and vgmetadatacopies.
pvchange: Add --metadataignore description
vgchange: Fix minor formatting
pvcreate: Update metadataignore description to refer to pvchange
lvm.conf: Refer to pvcreate and pvchange for metadata options.
2010-07-13 15:04:23 +00:00
e34342c1f3 Add dm_create_lockfile to libdm to handle pidfiles for all daemons.
Switch dmeventd to use dm_create_lockfile and drop duplicate code.
Allow clvmd pidfile to be configurable.
Switch cmirrord and clvmd to use dm_create_lockfile.
2010-07-13 13:51:01 +00:00
1f6952ba81 More comment updates in lvm2app.h. 2010-07-12 18:29:31 +00:00
d2f48d07bb Update comments about memory handling in lvm2app.h. 2010-07-12 18:12:23 +00:00
e9306bead5 Addendum for previous patch - show VG/LV name everywhere so the messages
are consistent.
2010-07-12 12:38:35 +00:00
a3bdff883b Add more verbose messages while checking volume_list and hosttags settings.
This should bring less confusion when there are some settings left and
people just forgot about it and then they run into problems. These messages
should give them a hint of what's really going on.
2010-07-12 11:37:49 +00:00
ddedf42d21 Failed to test for the case where a log was requested to be removed
even though there was no log.  A simple run through the in-tree test
suite would have caught this.  :(

-               if (lv_is_mirrored(detached_log_lv) &&
+               if (detached_log_lv && lv_is_mirrored(detached_log_lv) &&

Also, made some cosmetic changes suggested by kabi after my last check-in
(e.g. s/return 0/return_0/ and adding an error message).
2010-07-09 17:57:51 +00:00
b3e684d1fe Update WHATS_NEW 2010-07-09 17:01:11 +00:00
b3a13b17cb Add log_error when strdup fails in {vg|lv}_change_tag().
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-09 16:57:44 +00:00
90b4fce199 Remove unnecessary list of includes in liblvm files.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-09 16:57:34 +00:00
2d3164a59f Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
37ee12b2eb Fix redundant declarations and always compile with -Wredundant-decls. 2010-07-09 15:26:41 +00:00
d8d4a1d694 Remove superfluous fn prototypes. 2010-07-09 15:21:10 +00:00
0b18937cbe Finish fix for bug 607347: failing both redundant mirror log legs...
A previous check-in added logic to handle the case where both images
of a mirrored log failed.  It solved the problem by simply removing
the log entirely - leaving the parent mirror with a 'core' log.  This
worked for most cases.  However, if there was a small delay between
the failures of the two mirrored log devices, the mirror would hang,
LVM would hang, and no additional LVM commands could be issued.

When the first leg of the log fails, it signals the need for repair.
Before 'lvconvert --repair' is run by dmeventd, the second leg fails.
'lvconvert' would see both devices as failed and try to remove the
log entirely.  When it came time to suspend the parent mirror to
update the configuration, the suspend would hang because it couldn't
get any I/O through the mirrored log, which was plugged waiting for
corrective action.  The solution is to replace the log with an error
target to clear any pending writes before removing it.  This allows
the parent mirror to suspend and make the proper changes.
2010-07-09 15:08:12 +00:00
264091a239 Pass metadataignore to pv_create, pv_setup, _mda_setup, and add_mda.
Pass metadataignore through PV creation / setup paths.
As a result of this cleanup, we can remove the unnecessary setting
of mda_ignore bits inside pvcreate_single(), after call to pv_create.
For now, just set metadataignore to '0' in some places.  This is
equivalent to the prior functionality, although the 0 is given
by the caller not hardcoded in _mda_setup() call.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-08 18:24:29 +00:00
d324fd94df Init mda->list in mda_copy.
This patch should be no functional change as all callers initialize
mda->list.
2010-07-08 17:41:46 +00:00
15352cd86e Fix format string from patch apply mistake 2010-07-08 14:47:46 +00:00
69ca87abad Revert previous commit as it would return also for incorrect syntax. 2010-07-08 14:29:26 +00:00
e0c8e7c740 Update for dmsetup 2010-07-08 13:35:55 +00:00
8a9f96b21c Set return value 0 for 'dmsetup -c -o help' 2010-07-08 13:31:03 +00:00
bfb05107e3 Small update of memlock debug messages.
Gives slightly better alligned lines for reading.
2010-07-08 13:05:27 +00:00
1e699db631 Do not log backtrace in valid _lv_resume() code path 2010-07-08 12:24:04 +00:00
f3953f9a15 Minor optimalization of _test_word.
Skip ffs() if  (test >> bit) is 0.
2010-07-08 12:16:16 +00:00
7c7f889b1e Cleanups for configure:
Indent updates.
 Use AC_HELP_STRING for help string.
 Start help string with lower letter.
 Add [] around some default values i.e. [TYPE=internal].
 Skip some "" around shell assigment when not needed.
 Fix typo --with-device-gid=UID string.
2010-07-08 12:02:48 +00:00
f437c92b00 Shorten prompt for pvchange and vgextend. 2010-07-07 21:30:07 +00:00
44dd5c38e2 Add --force to pvchange, and allow override of prompt involving metadataignore.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-07 19:14:57 +00:00
e0132ef4cb Add prompt if using --metadataignore argument with vgmetadatacopies.
When using vgmetadatacopies value other than "umanaged" (0), prompt
the user if the usage of --metadataignore would change the value of
vgmetadatacopies.  The main 2 cases are:
1) pvchange --metadataignore
2) vgextend --metadataignore

We leave the prompt check in the tools, and do not change anything
if the user says 'n'.

Examples:
vgextend --metadataignore y vgtest /dev/loop0
Setting metadataignore will override preferred number of copies of VG vgtest metadata.
Are you sure? [y/n]: y
  No physical volume label read from /dev/loop0
  Physical volume "/dev/loop0" successfully created
  Volume group "vgtest" successfully extended

pvchange --metadataignore y /dev/loop3
Setting metadataignore on /dev/loop3 will override preferred number of copies of VG vgtest metadata.
Are you sure? [y/n]: y
  WARNING: Changing preferred number of copies of VG vgtest metadata from 3 to 2
  Physical volume "/dev/loop3" changed
  1 physical volume changed / 0 physical volumes not changed

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-07 19:02:50 +00:00
94cb2db723 Add warning to vgextend and pvchange if metadataignore given on cmdline.
Warn the user then change the value of vg_mda_copies.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-07 18:59:45 +00:00
52cf11338e Test failed commit of mda on new pv - failed vgextend.
Test the auto-repair capability when we fail committing to an mda
on a new pv adding to a vg.  This test should fail until we fix
the auto-repair in this case.
2010-07-07 14:43:57 +00:00
c4cce91dce Use "nowatch" udev rule for known inappropriate devices.
For now, this is just a precaution. Normally, all the other (non-dm) rules
should check DM_UDEV_DISABLE_OTHER_RULES_FLAG and therefore avoid setting
any inotify watches as well. But let's make sure.

Support for final assignment of the "nowatch" rule (the use of ":=") will
appear in next udev release, v160. This should also work in previous udev
versions but the setting won't be sealed so any further OPTIONS="watch" will
always prevail there.

We may want to add more specific "nowatch" rules later if needed.
2010-07-07 11:22:46 +00:00
23aa1c6524 Adjust auto-metadata repair and caching logic to try to cope with empty mdas.
- If a PV contained empty mdas, the auto-recovery code was not kicking in.
- The 'inconsistent' state was getting lost when metadata was cached so
  recovery didn't kick in.  But leave the behaviour alone when using
  precommitted metadata because of a warning in a confusing FIXME.

In my testing, pvs and vgs didn't repair inconsistent metadata like they
used to do.  (How many other tools fail similarly now?)

And there should be no need to cache inconsistent metadata because it is
supposed to get repaired under the protection of a write lock immediately it is
discovered.

This code is in need of a redesign based on first principles.
I still see bugs in this code and this commit is risky.
2010-07-07 02:53:16 +00:00
9de129d5b2 post-release 2010-07-07 02:37:28 +00:00
9d4cb8e97a . 2010-07-07 02:24:05 +00:00
c1589415f0 fix code in 2nd mda unignore loop to match 1st loop 2010-07-06 20:09:38 +00:00
389cbc3686 s/flags/mda/ 2010-07-06 17:29:50 +00:00
2508b4000b shorten mesg 2010-07-06 17:27:32 +00:00
e5164acc9c fix jumbled args in 'Adjusting' message 2010-07-06 17:26:08 +00:00
71ee58b6bb Fix for bug 607347: failing both redundant mirror log legs...
Rather than attempting to remove all the images of a mirrored
log volume via remove_mirror_images, simply remove the log
if all its devices have failed.

Taka was the first to report that there is still an outstanding
issue with handling this case.  I've managed to reproduce it
only very rarely, and am still working on identifying the problem.
Failing to handle the problem rarely is better than not handling
the scenario at all, so I'm checking this in.
2010-07-06 17:02:03 +00:00
3512a6ad0b pre-release 2010-07-06 16:49:38 +00:00
b02de599a0 Fix dmlosetup snprintf %llu compiler warning. 2010-07-05 22:56:31 +00:00
38c6e8faf6 Randomly select which mdas to use or ignore.
Add some missing standard configure.in checks.
2010-07-05 22:23:15 +00:00
431ca070a4 Add parentheses to some libdevmapper.h macro arguments. 2010-07-05 22:22:43 +00:00
ed2630dce5 Add printf format attributes to yes_no_prompt & dm_{sn,as}printf and fix a calle 2010-07-02 21:16:50 +00:00
5a2c9c9cee . 2010-07-02 17:44:17 +00:00
a7184430f1 Minor changes to man pages for --metadataignore.
Move the definition from pvchange to pvcreate - the location of
other metadata options.
2010-07-02 17:05:22 +00:00
2e83fee74c remove unneeded header 2010-07-02 10:25:16 +00:00
bbe29582cb Always pass unsuspended dm devices through persistent filter to other filters.
Move test for suspended dm devices ahead of other filters.
2010-07-02 02:09:57 +00:00
76470d9608 Fix another segfault in clvmd -R if no response from daemon received.
Missed the same problem in another function...
2010-07-01 21:46:09 +00:00
715c4ca4cd Remove superfluous suspended device counter from clvmd.
Moreover, in current mirror handling, when it calls activate
on removed but suspended detached log this counter drops below zero
and confuses debug log.
2010-07-01 21:23:47 +00:00
c097423d77 Fix lvm shell crash when input is entirely whitespace. (Xinwei Hu) 2010-07-01 11:04:58 +00:00
54637fa44d Move dmeventd man page from install_lvm2 to install_device-mapper. (1.02.50) 2010-07-01 10:57:03 +00:00
c192e88bcd Restore the "removemissing" behaviour of lvconvert --repair --use-policies. 2010-07-01 10:10:52 +00:00
19a12b28bc Update metadata-balance test for --vgmetadatacopies 0.
Should be equivalent to "unmanaged".
2010-06-30 22:22:00 +00:00
d55a7f18b0 . 2010-06-30 21:58:13 +00:00
4008a5fbf9 Maintain memlock balance in clvmd.
When a mirror is being downconverted in a cluster, a series of suspends and
resumes is executed.

With the change to using UUIDs in dev_manager instead of names, the behaviour
has changed with regards to including an _mlog in the deptree of a logical
volume. In the old (pre-UUID-enabled) code, the _mlog would appear in a deptree
of any volume purely based on a name match: a linear volume foo would include
foo_mlog in its dependencies if that happened to exist. This behaviour was
fixed and the mlog is now only included for mirrors.

By a coincidence, this mlog bug had been hiding a different bug in clvmd. When
a mirror is being dismantled (and converted to a linear volume), it is first
suspended as a whole, then later resumed in parts. Nevertheless, the overall
memlock balance is maintained in this operation. The problem kicks in, because
even though the mirror log was suspended as part of the mirror, when the
dismantled mirror is resumed again, it is no longer a mirror and therefore the
mirror log stays suspended. This would not be a problem in itself, since
_delete_lv (from metadata/mirror.c) is called on it subsequently, which does an
activate/deactivate cycle and removes the LV. The activate/deactivate cycle
correctly prompts clvmd to resume the device: however, in doing this, it will
issue an unpaired resume operation (the suspend that caused the mirror log to
be suspended is paired with resuming the dismantled mirror later). We have
concluded that the path in clvmd should never affect memlock_count, since there
should never be an unmatched explicit suspend preceding this resume.
2010-06-30 21:40:27 +00:00
e260f729da Fix --[vg]metadatacopies arg processing 2010-06-30 20:21:03 +00:00
17cffe2bf9 improve vgmetadatacopies unmanaged message 2010-06-30 20:03:52 +00:00
d1b068a68a Check for missing_pv in vg_remove loop.
If a pv is missing, we should just skip it rather than checking the
device size and failing the vgremove.
2010-06-30 19:55:43 +00:00
a5053f6ada more mda ignore cleanups 2010-06-30 19:28:35 +00:00
261a3e7e78 Refactor vg_remove_check to place pv removal into separate function. 2010-06-30 18:03:52 +00:00
36e28d4b4b more metadataignore message/code cleanup 2010-06-30 17:13:05 +00:00
cbc562a636 Update partial mode warning message. 2010-06-30 16:43:09 +00:00
51c4e1ea4b revert that 2010-06-30 14:54:29 +00:00
c8f03c38fe suppress useless compiler warning 2010-06-30 14:52:29 +00:00
4107d4d24d post-release 2010-06-30 14:50:32 +00:00
f0c79d95f5 Only attempt to guarantee 1 mda ignored if there's at least one mda in the vg. 2010-06-30 14:48:07 +00:00
d13b495217 Only attempt to guarantee 1 mda ignored if there's at least one mda in the vg. 2010-06-30 14:27:40 +00:00
549e1dfb0d pre-release 2010-06-30 14:04:15 +00:00
e260ecef0b Fix vgremove to allow removal of VG with missing PVs. (2.02.52) 2010-06-30 14:01:39 +00:00
b16b4d92a7 Improve various log messages. 2010-06-30 13:51:11 +00:00
c2584edbdb Update nightly tests for vgextend --metadataignore. 2010-06-30 13:11:12 +00:00
aa00196b6f Update nightly tests for vgextend --metadataignore. 2010-06-30 13:04:59 +00:00
75e3996d36 Add --metadataignore to vgextend and man pages. 2010-06-30 13:03:48 +00:00
d50f13b90d Add pvmetadatacopies to lvm.conf and pvcreate man pages. 2010-06-30 12:49:28 +00:00
652e9c00c5 Update pvcreate tests for --metadataignore. 2010-06-30 12:17:55 +00:00
fdcf749779 Add --metadataignore to pvcreate.
Allow metadataignore flag to be passed in to pvcreate.
Ideally, more refactoring of the mda allocation / initialization
is warranted, but for now, we just add another parameter to 'add_mda'
to take an existing mda ignored flag.  We need to do this or pv_write
loses the state of the mda 'ignored' flag before copying and writing
to disk.
2010-06-30 12:17:24 +00:00
ed38f47f23 Improve logging for setting --vgmetadatacopies.
Example of logging:
metadata/metadata.c:1127     Setting mda_copies = 3 on vg vgtest
metadata/pv_manip.c:296         /dev/loop2 0:      0     25: NULL(0:0)
metadata/pv_manip.c:296         /dev/loop3 0:      0     25: NULL(0:0)
metadata/pv_manip.c:296         /dev/loop4 0:      0     25: NULL(0:0)
metadata/metadata.c:1072     Adjusting ignored mdas on vg vgtest, vg_mda_used_count=5, vg_mda_copies=3
metadata/metadata.c:1015     Setting ignore flag for 2 mdas on vg vgtest
metadata/metadata.c:4151     Setting mda ignored flag for metadata_locn /dev/loop2.
metadata/metadata.c:4151     Setting mda ignored flag for metadata_locn /dev/loop3.
2010-06-29 22:41:28 +00:00
3b0585be3b Improve logging for metadata ignore by printing device name.
Print device name when setting or clearing metadata ignore bit.
Example:
label/label.c:160       /dev/loop2: lvm2 label detected
cache/lvmcache.c:1136         lvmcache: /dev/loop2: now in VG #orphans_lvm2 (#orphans_lvm2)
metadata/metadata.c:4142     Setting mda ignored flag for metadata_locn /dev/loop2.
format_text/text_label.c:318     Skipping mda with ignored flag on device /dev/loop2 at offset 4096
2010-06-29 22:37:32 +00:00
ebe1a8080c Add some log_verbose debug statements related to metadataignore.
Logging isn't ideal, especially for mda_set_ignore.  Ideally we'd
like to display the device name and offset in this case but this
requires a bit more work and a per-format 'mda_description' function
pointer definition (we don't have access to mda_context in
metadata.c).
2010-06-29 22:25:58 +00:00
593bb6470b Move code into pv_change_metadataignore library function.
In preparation to call this from both pvcreate as well as pvchange,
move the guts of metadataignore into a library function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-29 21:32:44 +00:00
6ce45042ef Add error message if backup_to_file fails because of empty in_use mdas list. 2010-06-29 15:03:59 +00:00
f615e84381 Add more initializations of 'mda->flags' field.
Mda allocation needs refactored into a single function but as an
interim step, ensure mda->flags is initialized properly.
2010-06-29 14:52:56 +00:00
bfaf1a4ecc Attempt to fix intermittent failure with non-debug configured vgcfgbackup.
There's an intermittent failure with vgcfgbackup that seems to have been
introduced with the metadataignore / vgmetadatacopies patchset.
Intermittent failures are often the result of uninitialized data,
so this patch calls zalloc in a few places it might matter.
2010-06-29 13:29:53 +00:00
bc1a30f542 Update WHATS_NEW for --metadataignore and --vgmetadatacopies changes. 2010-06-29 12:06:14 +00:00
28e0d5dd64 Update t-covercmd pvck to take proper device argument. 2010-06-28 21:49:31 +00:00
ffdd12841e Fix compile warning in vgchange.c regarding mda_copies initialization. 2010-06-28 21:35:00 +00:00
4b660a89d9 Update tests to handle phase 2 (vg based) metadata balance.
Test vgcreate/vgchange --vgmetadatacopies, vgextend, vgreduce,
vgsplit, vgmerge.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:40:27 +00:00
48386caec5 Update example.conf.in to describe vgmetadatacopies.
Update example.conf to describe vgmetadatacopies.  Provide an
explanation for the '0' ("unmanaged") value.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:40:15 +00:00
996360df6b Allow 'all' and 'unmanaged' values for --vgmetadatacopies.
Allowing an 'all' and 'unmanaged' value is more intuitive, and
provides a simple way for users to get back to original LVM behavior
of metadata written to all PVs in the volume group.

If the user requests "--vgmetadatacopies unmanaged", this instructs
LVM not to manage the ignore bits to achieve a specific number of
metadata copies in the volume group.  The user is free to use
"pvchange --metadataignore" to control the mdas on a per-PV basis.
If the user requests "--vgmetadatacopies all", this instructs LVM
to do 2 things: 1) clear all ignore bits, and 2) set the "unmanaged"
policy going forward.

Internally, we use the special MAX_UINT32 value to indicate 'all'.
This 'just' works since it's the largest value possible for the
field and so all 'ignore' bits on all mdas in the VG will get
cleared inside _vg_metadata_balance().  However, after we've
called the _vg_metadata_balance function, we check for the special
'all' value, and if set, we write the "unmanaged" value into the
metadata.  As such, the 'all' value is never written to disk.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:40:01 +00:00
fe260a26ed Ensure --metadatacopies parameter gets interpreted based on command.
Now that we have both --pvmetadatacopies and --vgmetadatacopies,
we need to make sure --metadatacopies gets interpreted correctly.

For pv commands, --metadatacopies should imply --pvmetadatacopies,
and for vg commands, --vgmetadatacopies.

Note: this will change the behavior of vgcreate with --metadatacopies
to be a synonym for --vgmetadatacopies.  Previously, --metadatacopies
would apply to any PVs given with vgcreate that needed an implicit
pvcreate.  As a result, one small change is needed to one of the nightly
tests - t-vgcreate-usage.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:39 +00:00
457bc4fb63 Add --vgmetadatacopies to vgsplit man page and command.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:24 +00:00
eeb7ce60ae Update _vgmerge_single() to move fid->metadata_areas_ignored.
When vgmerge is called we move the mdas from the source to the
destination.  With metadata balancing we now have another mda
list, fid->metadata_areas_ignored, so move the mdas on this list
as well.

This patch should not matter as the code is written today.  However
we include it for completeness in the case that _vgmerge_single()
is refactored and/or moved into a library function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:08 +00:00
e52586db1c Update check in vg_split_mdas to account for ignored mdas list.
The check in vg_split_mdas will trigger an error if the 'from' vg
list is empty.  However, this might be ok in some instances now
that we have ignored mdas.  Relax this check so an error is triggered
only in the case where there's truly no more mdas in the 'from'
vg.

One example of where this makes a difference is with vgreduce.
If we try to vgreduce a PV with un-ignored mdas, this should trigger
the balancing function to un-ignore mdas on another PV in the VG.
However, we don't get to vg_write() before we fail because this
list size check fails, and we see an error message indicating:
"Cannot remove final metadata area ..."

Another example is with vgsplit into a new VG, where the PVs
being moved contain all ignored mdas.  We must move the mdas on
fid->metadata_areas_ignored from 'vg_from' to 'vg_to'.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:56 +00:00
6cb9642200 Ensure fid mda lists are populated correctly during vgextend.
The vgextend path calls add_pv_to_vg().  Inside add_pv_to_vg(),
we must ensure we pass the correct mdas list into pv_setup(), as
copies of mdas are placed on the vg->fid list.  If we don't place
the mdas on the correct vg->fid list, the various counts may be
incorrect and the metadata balance algorithm will not work when
called from vg_write() path.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:39 +00:00
7ebd46ee53 Add --vgmetadatacopies to vgcreate man page, command, and lvm.conf.
Allow parsing of --vgmetadatacopies for vgcreate.  Accept
--metadatacopies as a synonym for --vgmetadatacopies.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:23 +00:00
d575dfe440 Set vg_mda_copies when pvchange --metadataignore is given.
When a user explicitly sets a new mda ignore value for a PV, we
should update vg_mda_copies accordingly.  When the VG is written
out, the user would not want the new ignore state to get lost as
a result of the vg_mda_copies value and logic in the vg_write
path.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:06 +00:00
074c1880ff Implement _vg_adjust_ignored_mdas and call from vg_write() path.
Compare the value of the newly added vg_mda_copies field
(--vgmetadatacopies parameter) with the current count of
in-use mdas and ignoring or unignoring mdas as necessary to
get to the target count.  Also, as a safety check before
returning, ensure we have at least one mda enabled.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:54 +00:00
b53c1011fc Update vgchange tool to accept --vgmetadatacopies.
Update logic in vgchange to handle --vgmetadatacopies, allow
--metadatacopies as a synonym to --vgmetadatacopies,
and add these parameters to args.h and commands.h
Forbit both --vgmetadatacopies and --metadatacopies as only
one allowed.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:37 +00:00
11f35d31d9 Add vg_mda_copies display field to 'vgs' command.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:23 +00:00
36d07a5cea Make vg->mda_copies persistent in on disk vg metadata.
This patch adds the ability to read/write the vg->mda_copies values
from/to the vg metadata.

If we read the VG metadata and this field does not exist, we set
mda_copies to the default value of 0.  Later in the code, we use
this special '0' value to indicate a disable of metadata balancing.
This should preserve existing LVM behavior and ensure metadata balancing
can be turned off should the need arise.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:10 +00:00
12910a5a29 Add vg get/set methods for VG metadata copies.
This patch adds the get and partially implemented set function.
The 'set' function should probably ignore or un-ignore metadata areas
based on new values.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:56 +00:00
eb93c134a7 Add mda_copies to VG structures and initialization.
Add a field to struct volume_group to later implement metadata
balancing:
- mda_copies: target # of non-ignored mdas in the VG; default 0 (do
not control pv 'ignore mdas' bit.

This patch just adds the parameter to the structures with the default
values but does not modify any commands.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:37 +00:00
493ad74331 Define vgmetadatacopies in vgchange man page.
This patch adds a vgmetadatacopies parameter for metadata balancing.
This parameter provides a simple way for users to create a policy for
placing metadata on PVs automatically by LVM.  The behavior is implemented
inside LVM by managing the 'ignore' mda bits.  We chose the name
'vgmetadatacopies' as this is a natural extension to the existing parameter
'pvmetadatacopies' / 'metadatacopies' in pvcreate.

This is a first step at VG parameter based metadata balancing.  Most users
will probably want to state that they want a certain number of PVs to contain
metadata, and they may be less concerned about a specific number of metadata
copies in the volume group.  However, for default values (pvmetadatacopies
is 1 by default), the number of metadatacopies in the volume group, and the
number of PVs with metadata are the same.  In the future we could add
vgmetadatacopiespvs to define more specifically the number of pvs in the
VG that contain metadata, but for now we start with this parameter.

Another possible future extension would be to define a specific pv tag
to mark the set of PVs that should be used for metadata balancing.  This
tag based approach could be used in conjunction with 'vgmetadatacopies'.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:18 +00:00
a563816d3a Add tests for phase 1 of metadata balance - manage per-PV ignore bit.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:06 +00:00
43526902ae Before committing each mda, arrange mdas so ignored mdas get committed first.
Arrange mdas so mdas that are to be ignored come first.  This is an
optimization that ensures consistency on disk for the longest period of time.
This was noted by agk in review of the v4 patchset of pvchange-based mda
balance.

Note the following example for an explanation of the background:
Assume the initial state on disk is as follows:
PV0 (v1, non-ignored)
PV1 (v1, non-ignored)
PV2 (v1, non-ignored)
PV3 (v1, non-ignored)

If we did not sort the list, we would have a commit sequence something like
this:
PV0 (v2, non-ignored)
PV1 (v2, ignored)
PV2 (v2, ignored)
PV3 (v2, non-ignored)

After the commit of PV0's mdas, we'd have an on-disk state like this:
PV0 (v2, non-ignored)
PV1 (v1, non-ignored)
PV2 (v1, non-ignored)
PV3 (v1, non-ignored)

This is an inconsistent state of the disk. If the machine fails, the next
time it was brought back up, the auto-correct mechanism in vg_read would
update the metadata on PV1-PV3.  However, if possible we try to avoid
inconsistent on-disk states.  Clearly, because we did not sort, we have
a greater chance of on-disk inconsistency - from the time the commit of
PV0 is complete until the time PV3 is complete.

We could improve the amount of time the on-disk state is consistent by simply
sorting the commit order as follows:
PV1 (v2, ignored)
PV2 (v2, ignored)
PV0 (v2, non-ignored)
PV3 (v2, non-ignored)

Thus, after the first PV is committed (in this case PV1), on-disk we would
have:
PV0 (v1, non-ignored)
PV1 (v2, ignored)
PV2 (v1, non-ignored)
PV3 (v1, non-ignored)

This is clearly a consistent state.  PV1 will be read but the mda will be
ignored.  All other PVs contain v1 metadata, and no auto-correct will be
required.  In fact, if we commit all PVs with ignored mdas first, we'll
only have an inconsistent state when we start writing non-ignored PVs,
and thus the chances we'll get an inconsistent state on disk is much
less with the sorted method.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:35:49 +00:00
b6ec0f9b92 Refactor vg_commit() to add _vg_commit_mdas().
Factor out calling mda->ops->vg_commit() for each mda.
No functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:35:33 +00:00
4e7f1a3a9d Update _vg_read and _text_create_text_instance to use fid_add_mda[s].
When we are constructing the vg, we may need to adjust the list of
metadata_areas if there are ignored mdas.  At label read time, we
do not read the metadata of ignored mdas, and as a result, they do
not get placed on vg->fid->metadata_areas inside _text_create_text_instance
since lvmcache does not have these areas attached to vginfo->infos.
However, when we're checking the pvids inside _vg_read, after having
read another metadata area from another PV, we do have the opportunity
to update the metadata_area and metadata_areas_ignored lists based
on the read metadata_area.  We need accurate mda lists for the reporting
functions that count the ignored mdas, as well as general correctness
of mda balancing.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:35:17 +00:00
50e879ef56 Use mdas_empty_or_ignored() in place of checks for empty mda list.
With the addition of ignored mdas, we replace all checks for an empty
mda list with a new function to look for either an empty mda list or
ignored mdas.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:34:58 +00:00
06468b9049 Add mdas_empty_or_ignored() helper function.
Add a helper function to consolidate checking for an empty mdas list
or ignored mdas.  Ignored mdas should behave almost identically to
an empty mda list - the metadata areas should not be read or written
to.  This function will make it easier to implement metadata balancing
and easier to track pvs with an empty mda list or ignored mdas.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:34:40 +00:00
2bdbceca91 Implement ignore of mda if bit set by skipping r/w of metadata.
We implement ignore of an mda at label_read time by checking for
the ignore bit, and then skipping the reading of the vgname and
other information in the metadata.  This will have an effect similar
to a PV found with no mdas.  Thus, it will look like an orphan in the
cache until we scan the rest of the system and find a PV with
metadata, and the mda will not be on the vg->fid->metadata_areas
list so no read/writes will be done to the metadata area.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:34:24 +00:00
d34d85efdd Update pvchange, pvs and vgs man pages for metadata ignore.
Explain --metadataignore argument to pvchange, add new fields to pvs / vgs.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:34:12 +00:00
7e3278ae8f Add --metadataignore to pvchange, allowing for ignoring of metadata areas.
This patch just modifies pvchange to call the underlying ignore
functions for mdas.  Ensure special cases do not reflect changes
in metadata (PVs with 0 mdas, setting ignored when already ignored,
clearing ignored when not ignored).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:58 +00:00
bca7c09e6c Define new functions and vgs/pvs fields related to mda ignore.
Define a new pvs field, pv_mda_used_count, and a new vgs field,
vg_mda_used_count to match the existing pv_mda_count and vg_mda_count.
These new fields count the number of mdas that have the 'ignored' bit
clear (they are in use on the PV / VG).  Also define various supporting
functions to implement the counting as well as setting the ignored
flag and determining if an mda is ignored.  These high level functions
call into the lower level location independent mda ignore functions
defined by earlier patches.

Note that counting ignored mdas in a vg requires traversing both lists
and checking for the ignored bit on the mda.  The count of 'ignored'
mdas then is defined by having the bit set, not by which list the mda
is on.  The list does determine whether LVM actually does read/write to
the mda, though we must count the bits in order to return accurate numbers
for the various counts.  Also, pv_mda_set_ignored must search both vg
lists for ignored mda.  If the state changes and needs to be committed
to disk, the ignored mda will be on the non-ignored list.

Note also in pv_mda_set_ignored(), we must properly manage the mda lists.
If we change the ignored state of an mda, we must change any mdas on
vg->fid->metadata_areas that correspond to this pv.  Also, we may
need to allocate a copy of the mda, as is done when fid->metadata_areas
is populated from _vg_read(), if we are un-ignoring an ignored mda.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:44 +00:00
2e163858fc Add metadata_areas_ignored list and functions to manage ignored mdas.
Add a second mda list, metadata_areas_ignored to fid, and a couple
functions, fid_add_mda() and fid_add_mdas() to help manage the lists.

These functions are needed to properly count the ignored mdas and
manage the lists attached to the 'fid' and ultimately the 'vg'.

Ensure metadata_areas_ignored is initialized in other formats, even
if the list is never used.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:22 +00:00
0ad2a4c72f Rename fid->metadata_areas to fid->metadata_areas_in_use.
Rename the metadata_areas list to an 'in_use' list to prepare for
future 'ignored' list.
2010-06-28 20:32:44 +00:00
b69ca133af Use vg_mda_count() in vgdisplay.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:32:21 +00:00
d4f0f090c0 Add mda location specific mda_copy constructor.
Because of the way mdas are handled internally, where a PV in a VG
has mdas on both info->mdas and vg->fid->metadata_areas list, we
need a location independent copy constructor for struct
metadata_area.  Break up the existing format-text specific copy
constructor into a format independent piece and a format dependent
piece.

This function is necessary to properly implement pv_set_mda_ignored().

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
2010-06-28 20:31:59 +00:00
e56f421490 Add mda_locns_match() internal library function for mapping pv/device to VG mda.
A metadata_area is defined independent of the location.  One downside
is that there is no obvious mapping from a pv to an mda.  For a PV in
a VG, we need a way to start with a PV and end up with an MDA, if we
are to manage mdas starting with a device/pv.  This function provides
us a way to go down the list of PVs on a VG, and identify which ones
match a particular PV.

I'm not entirely happy with this approach, but it does fit into the
existing structures in a reasonable way.

An alternative solution might be to refactor the VG - PV interface such
that mdas are a list tied to a PV.  However, this seemed a bit tricky since
a PV does not come into existence until after the list of mdas is
constructed (see _vg_read() - we create a 'fid' and attach mdas to it,
then we go through them and attach pvs).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
2010-06-28 20:31:38 +00:00
c9b93bf65a Ensure in-memory state matches on-disk state of mda ignore bit.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:31:18 +00:00
9b8ce15725 Allow raw_read_mda_header to be called from text_label.c.
We'd like to pass in mda_header to vgname_from_mda().  In order to
do this, we need to call raw_read_mda_header() from text_label.c,
_text_read(), which gets called from the label_read() path, and
peers into the metadata and update vginfo cache.  We should check
the disable bit here, and if set, not peer into the vg metadata,
thus reducing the I/O to disk.

In the process, move vgname_from_mda() to layout.h, since the fn
only gets called from format_text code, and we need the mda_header
definition from the private layout.h.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:31:01 +00:00
014e7daa36 Move dev_open/dev_close outside vgname_from_mda().
Refactor vgname_from_mda() so caller must open/close the device.
Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:30:46 +00:00
306e3b86f1 Move dev_open / dev_close outside _vg_read_raw_area().
This refactoring moves the device open/close up one level to the caller of
_vg_read_raw_area().  Should be no functional change and facilitate future
changes related to metadata balancing.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:30:30 +00:00
ce7cf5f46b Add location independent flag and functions to ignore mdas.
First we add a 'flags' field to the location independent
metadata_area structure, and a MDA_IGNORE flag.  The
mda_is_ignored and mda_set_ignored functions are added to
manage the flag.  Adding the flag and functions gives a
library interface to ignore metadata areas independent of
the underlying location (disk, file, etc).  The location
specific read/write functions must then handle the specifics
of what this flag means to the location.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Alasdair G Kergon <agk@redhat.com>
2010-06-28 20:30:14 +00:00
3c3b5e0dbf Add text format specific 'rlocn' ignore flag and access functions.
Adding a flag to the 'rlocn' structure in the mda header of the
text format allows us to flip a bit to ignore an area on disk that
stores the metadata via the text format specific mda_header.
This patch defines the flag and access functions to manage the flag.
Other patches will manage the ignore on a format-independent basis,
by using a flag in the metadata_area structure.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:29:57 +00:00
0fc136fcc7 Change 'filler' to 'flags' in on-disk 'raw_locn' structure.
Future patches will make use of a specific flag in the on-disk 'raw_locn'
structure to enable/disable metadata areas, and facilitate metadata
balancing.

Note that 'filler' is always set to '0' (see add_mda() - memset),
so use of this area as a non-zero flags field is a safe way to
provide future code features.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:29:42 +00:00
80328439be Minor shell style cleanup. 2010-06-28 19:13:33 +00:00
3c649de483 Refactor the handles_missing_pv logic in lvchange. 2010-06-28 19:10:16 +00:00
184ca578a0 Fix for bz608048 from Taka...
The same region size is used for both mirror volume and mirrored
log volume, but when the physical extent size is bigger than region size,
the size of mirror leg for mirrored log is smaller than the region size
and lvcreate command fails.

This patch adjusts a region size of mirrored log to a smaller value of
region size or physical extent size.

[This patch ensures that the region_size of the mirrored log does not
exceed the size of the mirrored log itself, which would violate the
kernel constraint: (region_size <= ti->len).]

Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-06-28 14:19:41 +00:00
3643acadac generate liblvm2cmd exported symbols too 2010-06-25 18:23:10 +00:00
1c78aa19ff Generate liblvm2app and libdevmapper exported symbols from header files.
Detection is simply by prefix - dm_ or lvm_ - and any additional symbols needed
but not detected this way are placed in .exported_symbols.
2010-06-25 18:17:38 +00:00
a64fec0722 actually, let's keep these in same order as in header 2010-06-25 12:21:47 +00:00
962811198f Update liblvm2app exported symbols.
Add Makefile target to generate current list of lvm2app.h functions.
2010-06-25 12:19:52 +00:00
378c3b1641 Fix typo reported in Debian bugzilla #586043 2010-06-24 08:36:57 +00:00
34c937510d Preload libc locale messages.
Preload libc.mo file for localized lvm before taking memory lock - this way
we prevent disk access for some error paths in libdm, that prints localized
errno messages while they are still in memory locked state.
2010-06-24 08:29:30 +00:00
e924e9cfb2 Add few missing information about what is this script doing.
(based upon Debian bugzilla suggestion)
2010-06-24 08:18:54 +00:00
8f0fa65379 Add a test of wait_for_locks behaviour (adapted from an original by Dave). 2010-06-24 07:57:54 +00:00
00268c1b82 update WHATS_NEW file with entry for simultaneous mirror image and
mirrored log image fault-handling fix.
2010-06-23 21:01:42 +00:00
7ab37c0ffc Committing Taka's patch... He found a problem during
the failure of a device that contained both a image of
a mirror and an image of the mirrored log.  The order
of the handling of those faults was important (and
wrong), this patch corrects that.

Patch-From: Takahiro Yasui <tyasui@redhat.com>
2010-06-23 20:32:29 +00:00
4cae37c340 post-release 2010-06-23 19:35:11 +00:00
63f8ad01b2 pre-release 2010-06-23 17:48:41 +00:00
1a6159aca5 In some C++ standards, typeof is not reserved. 2010-06-23 17:03:14 +00:00
60e9c014a2 Fix udev rules to handle spurious events properly.
We can use DM_UDEV_PRIMARY_SOURCE_FLAG to identify the spurious events
and use it as an indication that the device has already been activated before
(and hence we can find this property in udev database).

WARNING: This change requires udev startup script to preserve udev database
from initrd. All the information stored there during activation of devices
is important for the initial "udevadm trigger --action=add" call that is
used in udev startup script. If not done this way, udev startup script needs
to define DM_UDEV_PRIMARY_SOURCE_FLAG=1 property for any ADD events it uses.
2010-06-23 17:00:32 +00:00
8f3295456d Fix clvmd init script status
- s/Active clustred VG/clustered VG/ (only LV can be active)

- print only active LVs (not all) in status command
(In the lvdisplay form /dev/vg/lv.)

For now, still use awk (already used in clustered_vgs).

https://bugzilla.redhat.com/show_bug.cgi?id=598495
2010-06-23 16:24:13 +00:00
78df2efac2 Use more standard naming for PVs and VG in vgimportclone example. 2010-06-23 16:12:30 +00:00
546357eaeb Cleanup sentences of the example provided in the vgimportclone man page
(motivated by a patch that Debian was carrying).
2010-06-23 14:15:55 +00:00
50552f3fd5 The function that runs to compress a stacked mirror after
converting from 2-way to 3-way mirror (collapse_mirrored_lv)
was calling '_remove_mirror_images' with the 'remove_log'
parameter set.  When the code was put in to fix 599898 to
honor log parameters during conversion, this argument was
suddenly being honored.  Thus, when someone would convert from
a 2-way to 3-way mirror, the log would get removed.

'collapse_mirrored_lv' should not be calling '_remove_mirror_images'
with 'remove_log' set.
2010-06-23 13:57:26 +00:00
7d62ac4b34 Fix typo: "INTERNAL ERROR" -> "INTERNAL_ERROR"
Author: Xinwei Hu
        xwhu at novell dot com
2010-06-23 12:54:46 +00:00
beb14c3fa7 Add lv_path to reports to offer full /dev pathname. 2010-06-23 12:32:08 +00:00
a15d3d8dcc Fix typo: premitted -> permitted
Signed-off-by: Takahiro Yasui<tyasui@redhat.com>
2010-06-23 10:22:59 +00:00
9c7755c862 Better WHATS_NEW message - as we still have not fixed 'make exec_prefix' build 2010-06-23 10:21:00 +00:00
866553e76f Fix "allocated" warning typo. 2010-06-22 21:10:53 +00:00
f8f2be527f Add device name to output of error messages in raw_read_mda_header().
It would be helpful if we had the device name when something like
a mda_header checksum error occurs.

Before:
./tools/lvm pvs -opv_name,vg_name,uuid,mda_count,pv_mda_count_ignored,vg_mda_count,vg_mda_count_ignored,vg_mda_copies
  Incorrect metadata area header checksum
  PV         VG      PV UUID                                #PMda #PMdaIgn #VMda #VMdaIgn #VMdaCps
  /dev/loop0 vgtest2 sVv26t-gjpb-Rcau-uBDO-Cx04-GbRR-6Ssq7e     2        0     4        0        4
  /dev/loop1 vgtest2 zXWStT-qE8F-mbkc-RfgH-aytv-mptF-Y5Ce09     2        0     4        0        4
  /dev/loop2         riCpK9-9G8r-LlIp-i2oh-mb3N-CUzk-u5YpuR     1        0     0        0        0
  /dev/loop3 vgtest  tQCUjm-rmyd-i92d-4eeE-UYBW-v1vQ-kRaA17     2        0     4        2        0
  /dev/loop4 vgtest  ZRvpeI-p8F1-ccVW-BBac-xhl1-aGXU-CbP0oo     2        2     4        2        0

After:
./tools/lvm pvs -opv_name,vg_name,uuid,mda_count,pv_mda_count_ignored,vg_mda_count,vg_mda_count_ignored,vg_mda_copies
  Incorrect metadata area header checksum on /dev/loop2 at offset 4096
  PV         VG      PV UUID                                #PMda #PMdaIgn #VMda #VMdaIgn #VMdaCps
  /dev/loop0 vgtest2 sVv26t-gjpb-Rcau-uBDO-Cx04-GbRR-6Ssq7e     2        0     4        0        4
  /dev/loop1 vgtest2 zXWStT-qE8F-mbkc-RfgH-aytv-mptF-Y5Ce09     2        0     4        0        4
  /dev/loop2         riCpK9-9G8r-LlIp-i2oh-mb3N-CUzk-u5YpuR     1        0     0        0        0
  /dev/loop3 vgtest  tQCUjm-rmyd-i92d-4eeE-UYBW-v1vQ-kRaA17     2        0     4        2        0
  /dev/loop4 vgtest  ZRvpeI-p8F1-ccVW-BBac-xhl1-aGXU-CbP0oo     2        2     4        2        0
2010-06-22 19:18:27 +00:00
88880e1f89 Use flexible data[] in cmirrord request to prevent abort in runtime size checks. 2010-06-22 13:11:29 +00:00
3cce4419c2 Adding section number for lvm.conf manpages. 2010-06-22 07:34:34 +00:00
bc59859a59 Mirrors can be layered - as in the case of an converting 2-way
to 3-way mirror.  When conversion operations are performed on
these types of mirrors, log options can be confused/ignored.

In the case of a converting 3-way mirror, we have a top-level
2-way corelog mirror whose legs are 1) a 2-way disk-log mirror
and 2) a linear device.  If we wish to convert this 3-way mirror
to a 2-way mirror, the linear device is removed and the extra
top layer is eliminated.  If we also wished to convert the disk
log to a core log in the same step, ambiguity creeps in.  It is
somewhat obvious what the user wants - a 2-way mirror with a
corelog.  However, looking at the top level mirror before
compression, it seems that the mirror already has a core log.
This is why the operation seemed to fail.

This patch simply re-evaluates what mirrored_seg points to after
a compression and then considers the log argument.

This is a fix for bug 599898.
2010-06-21 16:12:33 +00:00
ecf06d3a49 Add error checking for calls to sprintf - it can fail for more
reasons than just 'out-of-space'.
2010-06-21 16:07:06 +00:00
d48af1520d Various cleanups following recent commits. 2010-06-21 15:56:57 +00:00
aa9797fa3c Let running clvmd process time to reexec.
Because execve stops the command loop,
we never receive response (only socket close) for clvmd -S,
so waiting for response here makes no sense.

But if the calling process (clvmd -S)  exits too early, connection
is closed from client side, clvmd takes this as an error and
never run restart code.

Ugly hack(TM).
2010-06-21 10:45:15 +00:00
44a82780b9 Use early udev synchronisation and update of dev nodes for clustered mirrors.
When using clustered mirrors, we need device nodes to be created during
processing of device tree, not at its end like we normally do (we need to
access the nodes in cmirror prematurely). Therefore we use a new flag called
"immediate_dev_node" stored in deptree's load_properties struct to instruct the
device tree processing code to immediately synchronize with udev and flush all
stacked node operations so the nodes are prepared for use.

For now, the immediate_dev_node is used for clustered mirrors during
processing the dm_tree_preload_children code only. We can add more later if
needed.
2010-06-21 08:54:32 +00:00
c76681596e daemons/cmirrord/functions.c (part of cmirrord) was referencing
linux/kdev_t.h even though it wasn't needed.  Strangely, it seems
to be causing problems on various architectures (i686) in the
function daemons/cmirrord/functions.c:disk_status_info()->sprintf.

I'm not sure why this is a problem since none of the macros in
kdev_t.h are used in that code, but it certainly doesn't hurt to
pull an unnecessary header and it seems to fix the problem.
2010-06-18 20:58:04 +00:00
3ce8520c5e Add man pages for lvmconf and unsupported lvmsadc and lvmsar tools. 2010-06-18 10:19:29 +00:00
01f5823ee4 Fix exit code when requesting help using documented -o help option.
IOW fix lvs -o help
...
  Command failed with status code 5.
2010-06-17 13:15:51 +00:00
c7ec3c65f4 Clean up cluster lock mode and flags definition.
Code is mixing up internal DLM and LVM definitions of lock
modes and flags.

OpenAIS and singlenode locking do not depend on DLM but
code currently cannot be compiled without libdlm.h!

LCK_* flags is LVM abstraction, used through all the code.
Only low-level backend (clvmd-cman etc) should use DLM definitions,
also this code should do all needed conversions.

Because there are two DLM flags used in generic code
(NOQUEUE, CONVERT) we define it similar way like lock modes.
(So all needed binary-compatible flags are on one place in locking.h)

(Further code cleaning still needed, though:-)
2010-06-17 12:48:54 +00:00
d01b8d03db Add man page for dmeventd
(inspired by patch from Danny Rawlins, monster.romster at gmail dot com)
2010-06-17 12:14:43 +00:00
41ff900c99 Update lvresize/extend/reduce manpages with --nofsck, --resizefs options 2010-06-17 11:25:43 +00:00
9ca07f4298 Fix lvm2cmd example in documentation. 2010-06-16 13:03:48 +00:00
0e93522190 Remove C++ private keyword from headers.
Add extern C definition for libdevmapper, lvm2app and lvm2cmd.
2010-06-16 13:01:25 +00:00
ebd1d49150 Use "" instead of <> for configure.h and libdevmapper.h
Move configure.h as the first header for clvmd source files.
2010-06-15 11:00:44 +00:00
057462c4e6 Update WHATS_NEW for last commit 2010-06-07 14:39:18 +00:00
b5e36cb96b Fix wrong usage of exec_prefix from previous patch introducing LVM_PATH define
Introduce lvm_exec_prefix with resolved exec_prefix.
(using same ac_default_prefix as for CLVMD_PATH)
Use lvm_exec_prefix instead of dmeventd_prefix (fixes missing ac_default_prefix)

Note: This patch is rather hot-fix as currently generate code
does not create correct code for make exec_prefix=
2010-06-07 14:31:59 +00:00
f58ca71942 Fix segfault in clvmd -R if no response from daemon received. 2010-06-07 13:52:52 +00:00
262a39dfd0 post-release 2010-06-07 10:25:43 +00:00
d531d56dbb pre-release 2010-06-04 17:23:49 +00:00
8b78a832fa Fix restart of clvmd using -S switch
- allocate environment dynamically (still missing some limit?)
 - try to recover, if destroy failed (do not destroy lvm here) and free memory
 - check strdup() return codes
 - report failure to log
 - do not print NULL in exclusive lock loop
2010-06-04 12:59:30 +00:00
8c19b52bda Fix clvmd initscript restart command to start clvmd if not yet running. 2010-06-03 21:03:53 +00:00
a7237281ea Use INSTALL_DIR to create directories 2010-06-03 13:52:21 +00:00
0b6ee2252c Use absolute paths in commands
clvmd restart does not work at all if clvmd binary is not in current
dir.
2010-06-03 13:50:26 +00:00
a9ffbb0803 Require partial option in lvchange --refresh for partials LVs.
We must not refresh LV if some PVs are missing and partial activation
was not requested.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=598886
2010-06-03 12:45:05 +00:00
224457fb0f Revert _init_rand() to reset errno - restores original init behavior. 2010-06-01 21:47:57 +00:00
cacbf14d8e Do not fail lvm_init() if init_logging() generates an errno.
Revert to original behavior of lvm commands if init_logging() generated an
errno.  Fixes rhbz 592967.
2010-06-01 21:46:29 +00:00
b00dc7153a Don't merge unchanged persistent cache file before dumping if tool scanned. 2010-06-01 19:02:12 +00:00
9dbad2f74d Add support for dm-mod module autoload.
A kernel patch is on its way for 2.6.35 adding support for dm-mod module
autoload. Udev v155 and higher is able to read static node information given
in modules.devname (extracted by depmod before) and will create such nodes
at its start. The first access to such node will load the module automatically
(directly in kernel) before the actual read/write operation is processed.
2010-06-01 16:08:13 +00:00
97617cfc76 Fix incorrect memory pool deallocation while using vg_read for files.
We create a separate pool "lvm2 vg_read" for vg_read and we don't use
cmd->mem anymore.
2010-06-01 12:08:50 +00:00
735cac19f2 Add --type parameter description to the lvcreate man page. 2010-05-28 03:50:15 +00:00
3755951091 Document 'clear' in dmsetup man page. 2010-05-27 19:00:14 +00:00
60af6fb0a2 Use expected union semun for arguments in selected semaphore operations.
This is standard and expected use. It also prevents errors related with
misalignment of the arguments for semaphore operations on some architectures.
2010-05-27 15:02:56 +00:00
333cf73ceb Fix copy&paste detection of kernel release version.
Add log_error to avoid return_0 without log_error.
2010-05-25 08:40:36 +00:00
bc653452a7 Replace strncmp kernel version number checks with proper ones 2010-05-24 23:11:34 +00:00
ca92b9a5f0 Avoid selecting names under /dev/block if there is an alternative. 2010-05-24 22:53:48 +00:00
afe102c0fe Fix topology test after last changes to not leak loop devices. 2010-05-24 19:27:38 +00:00
fa7fa300e3 Choose between clustered log versions based on kernel version.
Add fixmes for broken strcmp.
2010-05-24 17:46:47 +00:00
3c2b019578 Use mv -f for replace config in test. 2010-05-24 17:19:50 +00:00
87003ba5b1 Replace lvm.conf instead of truncating it. 2010-05-24 17:18:05 +00:00
bf7d3d2208 t-lvconvert-repair-transient hangs on .33 and on RHEL6 kernel -> disable 2010-05-24 16:33:21 +00:00
4e553333d9 Update clustered log kernel module name to log-userspace. 2010-05-24 16:30:15 +00:00
954df8f3d7 Account for mirror transient status when doing lvconvert --repair. 2010-05-24 15:32:20 +00:00
078573dc2c Skip t-pvcreate-operation-md if mdadm fails to create the required device. 2010-05-24 15:28:45 +00:00
c4655582e6 Update Copyright date for resently modifed files 2010-05-24 09:04:27 +00:00
360f97c31d Replicator: update activate code for vgchange
Activate only the first replicator-dev LV, that activates all other
related LVs from Replicator. In case of error during this activation,
it will not retry again for other heads (less confusing error log).
2010-05-24 09:03:39 +00:00
f20300cc8b Replicator: add replicator to dtree
Adding all replicator related LVs to dtree.
Start of one replicator_dev initiate start of all other related.
2010-05-24 09:01:05 +00:00
f687bd63b8 Replicator: VG with cmd_missing_vgs does not generate output
Do not print message if missing VG is found.
2010-05-24 08:59:29 +00:00
b68340f6d9 Fix scripts/relpath.awk to work with mawk
length(array) is specific to GNU awk and doesn't work in mawk.
Use a return value of "split" function to indicate array size, this is
supported in both gawk and mawk.

This patch fixes the following errors during "make install" when mawk is
installed as a default awk.

mawk: scripts/relpath.awk: line 25: illegal reference to array from
mawk: scripts/relpath.awk: line 25: illegal reference to array to
mawk: scripts/relpath.awk: line 27: illegal reference to array from
mawk: scripts/relpath.awk: line 32: illegal reference to array to

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2010-05-21 15:28:16 +00:00
c5eb266a80 Replicator: update _create_partial_dtree()
Adding function _add_partial_replicator_to_dtree() to create
partial tree for Replicator target.

Using dm_tree_node_set_presuspend_node() for Replicator.
2010-05-21 14:47:58 +00:00
04f3cea84a Replicator: activate checks for missing vgs
Activation needs to have all remote VGs locked to pass for replicator.
So if activated LV is replicator-dev LV - read all remote VGs.
2010-05-21 14:34:01 +00:00
c1fe5092c3 Replicator: lock_lv_vol() finds missing VGs
Find and check for all needed VGs before calling lock_vol().
2010-05-21 14:29:49 +00:00
5257248ed9 Replicator: use cmd_vg for process_each_lv_in_vg()
As for _process_one_vg() we need similar retry loop for
process_each_lv_in_vg(). This patch retries to process
failed LVs with reopened VGs.

Patch does not add any extra repeated invocations if there is not
found any missing VG during LV processing.
2010-05-21 14:15:39 +00:00
780010a268 Replicator: use cmd_vg list for _process_one_vg()
Patch modifes behavior of _process_one_vg().

In the first pass vg_read() collectis for replicator sorted list of
additional VGs during lock_vol().
If any other VG is needed by the replicator and it is not yet opened
then next iteration loop is taken with all collected VGs.

Flag vg->cmd_missing_vgs detects missing VGs.
2010-05-21 14:11:13 +00:00
8571d54f61 Replicator: add read and release VGs for rsites
Add functions to read and release remote VGs for replicator sites
in activation context.
2010-05-21 14:07:16 +00:00
13fed1e445 Add toolcontext.h header file. 2010-05-21 13:34:09 +00:00
2179ff624c Remove files from wrong directory 2010-05-21 13:18:25 +00:00
8b3434061e Right directory name for replicator files.
My local CVS was placing file in slightly different directory by using
obsolete files.
2010-05-21 13:17:20 +00:00
68a6a348b5 Hmm - fixing cvs import mistake 2010-05-21 13:14:02 +00:00
d8659175cd Replicator: add find_replicator_vgs
Adding find_replicator_vgs() function to find all needed
VGs for replicator-dev LV.

This function is later called before taking lock_vol().
2010-05-21 12:55:25 +00:00
1431ddad9c Replicator: add sorted cmd_vg list
Introduce struct cmd_vg to store information about needed
volume group name, vgid, flags and the pointer to opened VG.

Keep VGs list in alphabetical order for locking order.

Introduce functions:
cmd_vg_add() add new cmd_vg entry.
cmd_vg_lookup() search cmd_vgs for vg_name.
cmd_vg_read() open VGs in cmd_vgs list.
cmd_vg_release() close VGs in reversed order.
2010-05-21 12:52:01 +00:00
5f860775c8 Replicator: extend volume_group with list of VGs and flag
Add pointer to linked list of opened VGs. List temporarily keeps
the information about needed or locked and opened VGs for replicator target.

Also add cmd_missing_vgs flag information for quick check and
also for possible continuos process_each_lv() usage where we need
to detect whether failure has been caused by missing VG or
some other reason.
2010-05-21 12:47:46 +00:00
65f5ed533f Replicator: extend _lv_each_dependency() with dependencies for Replicator devices 2010-05-21 12:45:18 +00:00
c4276aad11 Replicator: check replicator segment
Check for possible problems within replicator structures.
Used also by vg_validate.
2010-05-21 12:43:02 +00:00
d4ae0dedf2 Replicator: new files for Replicator target 2010-05-21 12:40:05 +00:00
312a15d24e Replicator: base lvm2 support
Adding configure.in support for Replicators.
Adding basic lib lvm support for Replicators.
Adding flags REPLICATOR and REPLICATOR_LOG.
Adding segments SEG_REPLICATOR and SEG_REPLICATOR_DEV.
Adding basic methods for handling replicator metadata.
2010-05-21 12:36:30 +00:00
bc1024812a Replicator: check open_count for parents of presuspend_node
For deactivation of Replicator check in advance that all heads
have open_count == 0. For this presuspend_node is used as all
head nodes are linking this control node.
2010-05-21 12:30:35 +00:00
451be927a8 Replicator: support deactivate of replicator-dev nodes
Introducing dm_tree_node_set_presuspend_node() for presuspending child
node (i.e. replicator control target) before deactivation of parent node
(i.e. replicator-dev target).

This patch presents no functional change to current dtree - only
replicator target currently sets presuspend node for dev nodes.
2010-05-21 12:27:02 +00:00
4839e5d913 Replicator: libdm support
Introducing new API calls:
dm_tree_node_add_replicator_target()
dm_tree_node_add_replicator_dev_target().

Define new typedef dm_replicator_mode_t.
2010-05-21 12:24:15 +00:00
874d697f4c API change for args of process_each_lv_in_vg()
Patch adds failed_lvnames to the list of parameters for process_each_lv_in_vg().
If the list is not NULL it will be filled with LV names of failing LVs
during function execution.

Application could later reiterate only on failed LVs.
2010-05-21 12:21:51 +00:00
f80cbe8c33 Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv() 2010-05-21 12:19:22 +00:00
154a7af5ee post-release 2010-05-20 23:21:53 +00:00
cea69ab9d0 Fix $(INSTALL_SCRIPT) 2010-05-20 22:54:58 +00:00
6b3f81e647 backup->cache 2010-05-20 22:32:44 +00:00
fbee662499 pre-release 2010-05-20 22:27:26 +00:00
eedf87f891 If unable to obtain snapshot percentage leave value blank on reports. 2010-05-20 22:24:33 +00:00
89cb3a410a Add make install_initscripts 2010-05-20 14:45:14 +00:00
ae1ec1b418 Add install_system_dirs makefile target.
Add configure options for system and locking directories.
2010-05-20 13:47:21 +00:00
c357c91b7d Generate example.conf so default lvm.conf contents can be configured. 2010-05-20 11:45:56 +00:00
b3f073c48c Install lvmconf script by default.
Remove unnecessary versioned dmeventd plugin symlinks.
2010-05-20 11:20:35 +00:00
cd8ffd8725 Remove another pvchange hack involving orphan VG names.
Unnecessary as a result of recent changes.
2010-05-19 15:34:10 +00:00
bbe4a85be1 Remove hack in pvchange to unlock orphan VG.
With agk's recent changes, the lock/unlock APIs can properly handle
orphan VG names.
2010-05-19 13:21:09 +00:00
7e6f58c0a9 Fix warnings with conversion of uuid.
More cleanup of uuid casting / structures is needed but for now just
cast like the rest of the code.
2010-05-19 12:12:47 +00:00
275654210d Update WHATS_NEW 2010-05-19 11:57:05 +00:00
f649252de9 Test lvm_vgname_from_{pvid|device}. 2010-05-19 11:53:30 +00:00
d3ce80e544 Add lvm2app interfaces to lookup a vgname from a pvid and pvname.
lvm2app forces applications to start with a volume group name,
open the volume group, then operate on individual pvs.  In some
cases the application may want to start with a device name rather
than the volume group name.  Today, if an application wants to
do this, it must iterate through all the volume groups to find
the volume group that the specific device is attached to.
These new interfaces allow the application to avoid such overhead.
Bump the lvm2app version number to 3.
2010-05-19 11:53:12 +00:00
ea956b4f6c Update pvchange to always obtain a vg handle for each pv to process.
Earlier patches added some infrastructure to lookup a vgname from
a pvname.  We now can cleanup some of the pvchange and other code
by requiring callers that want to modify some pv property:
1) lookup the vgname by the pvname
2) use the vgname to obtain a vg handle
3) get the pv handle from the vg handle

This should work going forward and be a much cleaner interface,
as we move away from pvs as standalone objects.
2010-05-19 11:53:00 +00:00
ada4c61860 Add find_vgname_from_{pvname|pvid} functions.
Some commands start with a pvname, but we'd like to force users to
start with a vg handle to obtain a pv handle.  Our best option seems
to be providing a way to look up the vgname from the pvname, and then
require them to use vg_read/vg_open.

In addition to the pvname lookup function, this patch also provides a
lookup by pvid.  The lookup by pvid can be used in conjunction with
lvmcache_get_pvids to process all pvs in the system.

The pvid find function first calls lvmcache_vgname_from_pvid, which may
cause the label to be read if it is not in the cache.  If the vgname is
returned is an orphan, we then check to see if there are metadata areas,
and if not, we scan every PV on the system by calling scan_vgs_for_pvs().
In most cases we should not need to do this, and by using the info->mdas
count, we avoid calling pv_read() as prior code did.  So this patch is a
bit cleaner and should allow us to refactor more of the pv code.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-05-19 11:52:37 +00:00
9bcaa94756 Add lvmcache_vgname_from_pvid().
Add lvmcache function to lookup a vgname from a pvid.
2010-05-19 11:52:21 +00:00
49a81e190e Add pvid_from_devname() lvmcache function.
Add supporting function for mappings from devname -> pvid -> vgname.
2010-05-19 11:52:07 +00:00
5303eca8fa Add is_global_vg and split out from is_orphan_vg. 2010-05-19 02:36:33 +00:00
1b37183e74 Validate orphan and VG_GLOBAL lock order too. 2010-05-19 02:08:50 +00:00
09f17bf72d Note that orphan lock is always obtained last 2010-05-19 01:49:08 +00:00
449ffc7b05 Accept orphan VG names as parameters to lock_vol() and related functions. 2010-05-19 01:16:40 +00:00
bea9cf6725 Use is_orphan_vg in place of hard-coded prefix tests. 2010-05-19 00:52:55 +00:00
a0c7ead88f post-release 2010-05-17 20:18:13 +00:00
3eb97ffa25 pre-release 2010-05-17 18:39:01 +00:00
48d651f492 Fix clvmd init script stop function to not deactive non-clustered volume groups.
https://bugzilla.redhat.com/show_bug.cgi?id=592362
2010-05-17 03:18:27 +00:00
0d272a6964 Disallow toggling the cluster attribute of a volume group if there
are active mirrors or snapshots.

We don't have the mechanisms in place to change the device-mapper
tables for those targets that have behavioral differences between
cluster and single machine instances.  Allowing users to change
the attribute but not changing the target's behavior can lead to
data corruption.

The following bugs are fixed/avoided by this patch:
235123 - vgchange -c [ny] do not change target types when necessary
289331 - RFE: switching from cluster domain to local domain needs to deactivate volume somehow
289541 - when changing from local to cluster, volumes can not appear to be deactivated
2010-05-14 15:19:42 +00:00
578c4098e6 Use -d to control level of messages sent to syslog by dmeventd.
Change -d to -f to run dmeventd in foreground.
(mornfall)
2010-05-14 14:56:39 +00:00
c34cb6adcf Fix static build. 2010-05-14 13:36:56 +00:00
cb5d05fd34 For lcov target there is no need to include source file dependencies 2010-05-14 13:32:36 +00:00
5899d9b442 Another one internal device layer fix... 2010-05-14 12:39:52 +00:00
40026b0762 Fix empty layer detection is scan devices. 2010-05-14 12:30:43 +00:00
83b4f8366a Fix device_is_usable to properly detect only internal LV names. 2010-05-14 12:03:32 +00:00
8e50c4e4bb Use /bin/bash for scripts with bashisms 2010-05-14 11:33:20 +00:00
2b129732b0 Skip also special lvm devices in scan (if ignore suspended is used).
This should avoid various races between dmeventd on multiple nodes
in cluster where one node already repairing device and another
run full scan and locks the device.
2010-05-13 18:38:38 +00:00
8cf86745c2 Do not print encryption key in message debug output. 2010-05-13 13:31:30 +00:00
5ee39f1a1d Currently if clvmd is running and user issues vgscan,
the device cache file is dumped both in vgscan and clvmd process.

Unfortunately, clvmd calls lvmcache_label_scan,
it properly destroys persistent filter, but during
persistent_filter_dump it merges old cache content back!

This causes that change in filters is not properly propagated
into device cache after vgscan on cluster.
(Only new devices are added.)

https://bugzilla.redhat.com/show_bug.cgi?id=591861
2010-05-13 13:04:03 +00:00
8c998ebbed Chop up the big t-lvconvert-mirror-basic loop across 4 separate test scripts
(and use sourcing to avoid code duplication).
2010-05-12 13:15:38 +00:00
e2eb9b24b7 Run tests in alphabetical (and thus stable across machines) order. 2010-05-12 11:59:46 +00:00
374e3502fe Bump the debug.log level from 4 to 9 (the numbering is different from verbose). 2010-05-12 11:58:51 +00:00
1ad6e72ade Revert the "repeat failed tests with -vvvv" feature. Instead, dump debug logs
to a file using log/file, with log/overwrite set and dump this file in
STACKTRACE. The overall effect is that only the command that ran last before
the failure has been triggered will get its debug output logged. This is
similar to how we treat coredumps.
2010-05-12 11:23:16 +00:00
d7eaafe9c1 A fairly extensive refactor of the mirror testing code. The exhaustive
lvconvert testing is now in its own test, t-lvconvert-mirror-basic ... it
doesn't do anything fancy but it does run lvconvert through a lot of
combinations.

I have also merged the remaining t-mirror-lvconvert tests into
t-lvconvert-mirror and abolished the former. The latter will be split again
later into more thematic divisions. (The previous split was rather arbitrary,
may I even say random...)
2010-05-12 10:08:35 +00:00
2400150734 Revert the huge device creation in t-lvconvert-mirror and downgrade the
race-induced failure to a warning, until we have a better fix for this.
2010-05-12 06:09:22 +00:00
8ad2a270f4 Add a test for activation in presence of missing devices. This partially covers
the robustness requirements for system startup that we have.
2010-05-12 06:02:28 +00:00
73a006403f Rename t-partial-activate to t-activate-partial (more activation tests coming). 2010-05-12 05:59:24 +00:00
a3513577f0 The "should" testing utility should actually only give a warning when the
command fails.
2010-05-12 05:55:42 +00:00
29ad12df51 Improve the "check" testing utility: slightly refactor and provide
active/inactive checks.
2010-05-12 05:55:08 +00:00
e0dd25f92b If we are checking if '--nosync' was called with the mirror argument,
then let's also check if '--mirrorlog' was called with the mirror
argument.
2010-05-11 21:40:11 +00:00
81c155b465 Add pkgconfigdir for placement of .pc files
Use easily overideable make install pkgconfigdir variable.
2010-05-11 08:57:02 +00:00
ae11cc6731 Switch to use Requires.private for devmapper.pc and lvm2app.pc
Use Requires.private: instead of Libs.private:
Use UDEV_PC and SELINUX_PC for Require.private:

It looks like usage of Requires.private is prefered from Libs.private.
However pkg-config documentation is really poor here. But here is
short outcome:

There is a difference in Libs.private: and Requires.private: where
we specify libselinux instead of  -lselinux -lsepol.

We leave resolving of query like 'pkg-config --libs --static devmapper'
on taking proper selinux and udev libs to their .pc files instead of
hardcoding them into our .pc file which is might give incorrect answer.
- i.e. dependency of libselinux package might change and we may return
wrong list of linked libraries.

http://bugs.freedesktop.org/show_bug.cgi?id=4738
http://err.no/personal/blog/tech/2008-03-25-18-07_pkg-config,_sonames_and_Requires.private
2010-05-11 08:54:11 +00:00
b0b0c853c7 Add UDEV_PC and SELINUX_PC substituted variables 2010-05-11 08:48:43 +00:00
8701c4f50c Use Require.private: field for devmapper-event.pc
Move devmapper to Require.private: field and remove unneeded libs
from Libs.private: as they are dependencies of devmapper library.
2010-05-11 08:47:02 +00:00
627d5adc63 Skip unneeded 'cat' command execution. 2010-05-11 08:43:18 +00:00
7a5a31888a Plugins do not use pthread or lvm2cmd directly.
Plugins are using pthread and lvm2cmd libraries indirectly
through devmapper-event-lvm2, so link only with libraries used by them.
2010-05-11 08:41:58 +00:00
3d64743851 Link libdevmapper-event.so with libdevmapper.so.
For now using $(LIBS) for a list of linked libraries to $(LIB_SHARED) library.
2010-05-11 08:38:10 +00:00
16d704877d Link liblvm2cmd.so with devmapper-event and devmapper libs.
and remove generic %.so: %.a target.
2010-05-11 08:34:38 +00:00
3e320285a1 Headerfile <pthread.h> is no longer needed here 2010-05-11 08:32:22 +00:00
3215d89e97 Fix truncated total size displayed by pvscan. 2010-05-07 15:24:17 +00:00
b7983d4fe2 Add a basic test for dmeventd triggering lvconvert --repair. Needs improvement. 2010-05-06 19:01:26 +00:00
6120f4c507 Add some basic provisions for automated testing of dmeventd. 2010-05-06 18:54:51 +00:00
ac24748b47 Add new --sysinit option for vgchange and lvchange.
A shortcut for --ignorelockingfailure, --ignoremonitoring, --poll n options
and LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable used all at
once in initialisation scripts (e.g. rc.sysinit or initrd).
2010-05-06 11:15:55 +00:00
4c449886f6 Add dm_list_splice() to join two lists. 2010-05-06 10:10:15 +00:00
cd3475a8cb Install plugins to subdirs
Target install_dm_plugin installs files to libdir/device-mapper.
Target install_lvm2_plugin installs files to libdir/lvm2.

Both targets creates relative links to libdir to keep the code
compatible with current dlopen handling.

Once we will be able to read plugins from subdir, links
could be removed.
2010-05-06 10:07:46 +00:00
03c5c5fbe7 What's new. 2010-05-05 22:38:31 +00:00
9d3faa4753 Suppress duplicate error messages about read failures and missing devices. 2010-05-05 22:37:52 +00:00
20399b50d6 Specify exactly which ioctl doesn't have a cookie set (for better debugging). 2010-05-03 22:08:38 +00:00
93c1312901 Synchronize "remove" dm task while reverting unsuccessful "create" dm task
(with table provided).

This remove ioctl generates udev events like any other hence it needs to be
synchronized properly as well. Also, add dm task type in debug log when
setting a cookie (for better debugging).
2010-05-03 21:06:53 +00:00
4bde7fc926 post-release 2010-04-30 15:48:38 +00:00
68086fdde4 typo 2010-04-30 14:51:58 +00:00
005ad96068 pre-release 2010-04-30 14:49:42 +00:00
6c1beb94dc Add a "should" alongside "not" to the test utilities. When a "should" command
fails, the test will carry on but will issue a warning. The harness detects
such warnings from tests and marks tests that passed with warnings with a
special status.
2010-04-30 14:33:39 +00:00
fa0ec772d5 change awk path 2010-04-30 13:58:08 +00:00
661e73d9a6 And be consistent with return code as well (previous commit). 2010-04-30 13:47:11 +00:00
db85b2ddc7 Don't run any complex initialisation for the "version" lvm2 command.
We can use it even in read-only environment where a try to initialise
file-based locking fails (not to mention other processing related with
lvm2 init). Simply, we want to output the version only, nothing else.
And this should always work.
2010-04-30 13:28:44 +00:00
4f732b1989 Initialise _vginfos list staticaly so there is no problem with using uninitialised
variables in case, lvmcache_destory() is called without lvmcache_init().
2010-04-30 12:54:31 +00:00
78b8276111 Release pools for regex if there is error during processing
(fixes error messages about unreleased pools).
2010-04-30 12:37:04 +00:00
6ef6b6af40 Show string with invalid pattern
and start error message with capital letter.
2010-04-30 12:31:32 +00:00
f45bbeb497 . 2010-04-29 01:48:19 +00:00
4eb71369ed . 2010-04-29 01:45:30 +00:00
bc11c3a1d7 Remove no-longer-used arg_ptr_value.
Fix -M and --type to use strings not pointers that change on config refresh.
2010-04-29 01:38:12 +00:00
dd8ac54678 Test all combinations of mirror conversion, both while the LV
is active and while it is in-active.

+for i in $(seq 0 4); do
+       for j in $(seq 0 4); do
+               for k in core disk mirrored; do
+                       for l in core disk mirrored; do

The testing code still needs some improvement.  I'd like to add
the ability to test specifying the PVs to be added/removed during
a convert.  It will also be important to test partial PV
specification during down converts (i.e. request to remove more
mirror images than we have provided PVs for).
2010-04-28 17:46:34 +00:00
15d7886699 Don't attempt to convert the log type of an LV if the LV
is not a mirror.
2010-04-28 17:41:30 +00:00
68c7b86df1 Add support for new IMPORT{db} udev rule.
This rule appeared in udev v152 and it helps us to support spurious events
where we didn't have any flags set (events originated in udevadm trigger
or the watch rule). These flags are important to direct the rule application.
Now, with the help of this rule, we can regenerate old udev db content.
To implement this correctly, we need to flag all proper DM udev events with
DM_UDEV_PRIMARY_SOURCE_FLAG. That happens automatically for all ioctls
generating events originated in libdevmapper.
2010-04-28 13:37:36 +00:00
6c8454e4e2 Small indent change 2010-04-28 12:23:11 +00:00
a249779692 Fix comment from last commit. Additionally, there is no need
to put a comment into the WHATS_NEW file if it is a regression
that was created and fixed inside the same release window.
2010-04-27 15:26:58 +00:00
876b6416ab Patch to fix bug 586021 and mantain historical behavior of
being able to remove more images from a mirror than the
number of PVs directly specified for removal.

The effort to fix bug 581611 corrected a bug that was unnoticed
at the time.  The loop in _remove_mirror_images that looks over
the specified PVs was allowing devices that were previously
counted and moved to the end of the list to be double-counted.
This resulted in the number of devices needed for removal always
being satisfied - even if the user did not specify enough PVs
for removal to satisfy the request.  When 581611 was fixed, this
double-counting no longer took place and the result was to remove
only the minimum of the number of PVs specified or the number
that was asked to be removed.

By simply always setting 'new_area_count' (as used to be done
only in the else statement), we return to the previous behavior.
Indeed, this is exactly what the double-counting was allowing
to happen before the fix of 581611.
2010-04-27 14:57:49 +00:00
1e5d79dce1 Mention how to get PV to LV mappings. 2010-04-27 13:34:56 +00:00
bd8eec0a1e Fix lvconvert error message when existing mirrored LV is not found. 2010-04-26 18:31:58 +00:00
e7075c4366 add comments 2010-04-26 18:12:40 +00:00
532834cbc2 Also include udev libs in libdevmapper.pc when udev_sync is enabled. 2010-04-26 09:05:50 +00:00
d5857e6d48 Disallow the direct removal of a merging snapshot.
Allow lv_remove_with_dependencies() to know the top-level LV that was
requested to be removed (otherwise it recurses and we lose context).

A merging snapshot cannot be removed directly but the associated origin
can be.  Disallow removal of a merging snapshot unless the associated
origin is also being removed.
2010-04-23 19:27:10 +00:00
b004ea2d7f Remove redundant check in _lvs_single now that the caller
(process_each_lv_in_vg) provides it.

Also, removing this check from _lvs_single now allows displaying hidden
LVs that are specifically named on the command line.
2010-04-23 19:10:20 +00:00
205ca4f8a7 Set appropriate udev flags for reserved LVs.
There's no need for foreign udev rules to touch LVM reserved devices
(snapshot, pvmove, _mlog, _mimage, _vorigin) even if they happen to
be visible. The same applies for /dev/disk content - no need to create
any content for these devices (and so no need to run any "blkid" etc.).
This also prevents setting any inotify "watch" from udev rules on such
devices that is a source of race conditions (the rules need to honor
DM_UDEV_DISABLE_OTHER_RULES_FLAG for this to work though).
2010-04-23 14:16:32 +00:00
4a76f5c764 When removing a snapshot avoid preloading the origin if the
snapshot-merge target is not active.
2010-04-23 02:57:39 +00:00
a32e8441d0 don't optimise anything with TARGET_TRANS to avoid intefering with the matcher's counting 2010-04-22 23:09:18 +00:00
4d6089c042 Cache bitset locations to speed up _calc_states. (kabi) 2010-04-22 20:35:24 +00:00
7929929979 avoid ORs rightmost 2010-04-22 20:15:00 +00:00
9ba50046cf Move regex printing code from test to main tree (may use in debug messages).
Yet another optimiser fix attempt.
2010-04-22 17:42:38 +00:00
aa3bdb1911 The following tests in the testsuite have race conditions:
1) Test that the primary mirror image cannot be removed while
   the mirror set is sync'ing.
2) Test that you cannot start a second mirror up-convert while
   one is already in progress.

The trouble is that if the sync/conversion finishes before the
tests occur, the tests will fail by why of success where there
should have been failure.  This means the sync/conversion must
happen very quickly, but this is possible because the test
mirrors we are creating are so small.

In order to decrease the likelyhood of these test failing (or
more correctly, failing to test the right thing), I've increase
the size of the mirrors.  It will still be remotely possible that
the tests will fail (by way of failing to test the right thing).
If this continues to happen, more involved mechanisms will need
to be put in place.  (Perhaps these will still be created, but
this change should be a remedy until that time.)
2010-04-22 15:39:40 +00:00
5ce8c9ae77 Don't walk rightmost through NULL pointers. 2010-04-22 14:33:14 +00:00
9d8d6b1d18 Fix rightmost rotation, and use LEFT and RIGHT to make symmetry more obvious. 2010-04-22 13:42:34 +00:00
52b8978a47 fix leftmost rotation 2010-04-22 13:18:27 +00:00
442fd05339 isprint 2010-04-22 03:42:00 +00:00
4c952f0af4 Still not satisfactory... 2010-04-22 03:24:24 +00:00
cf90b03ce4 add -r to print out closer to original regex format 2010-04-22 03:12:01 +00:00
d4de2a7aa4 Disallow the addition of mirror images while a mirror up-convert
is already occurring.  The addition of new legs can be retried
once the current conversion is complete.
2010-04-21 14:04:24 +00:00
e37b173f13 Disallow the primary mirror image from being removed when the
mirror is not in-sync.  This restriction is not extended to
repair operations (i.e. it will not limit what 'lvconvert --repair'
can do).
2010-04-21 13:55:08 +00:00
b5d88e683f Make matcher_t and parse_t compilable
These two old-test/regex utils are usable for testing output of regex
processing at core level. For getting them usable configure need to create
Makefile. This is currently disable by default.
2010-04-21 08:01:51 +00:00
23dd4773d4 Add a regex optimisation pass for shared character prefixes. 2010-04-20 22:31:22 +00:00
b7af7c9c43 Re-enable t-topology-support.sh
Reintroduce split teardown (teardown() calls teardown_devs()) because
t-topology-support.sh only needs the teardown_devs() subset of the full
teardown() between each iteration of the topology tests -- in particular
the $TESTDIR must not get removed between each topology test iteration.

prepare_loop() must return if prepare_scsi_debug_dev() already
established $LOOP.

Also fix (and simplify) the unsafe scsi-debug device discovery in
prepare_scsi_debug_dev().
2010-04-20 18:18:59 +00:00
9d3955daf2 Remove -n argument from vgcfgrestore.
This is old lvm1 syntax, because arguments changed
from PVs to VGs compatibility is broken already.

name_ARG is not used in code.
2010-04-20 18:17:56 +00:00
063083a203 Add device creation to basic nightly test.
Ensure we can create devices for use in tests before running the real
tests.  This may in various cases, and may involve machine configuration
rather than a failure in some specific test.
For example, if a test is run with LVM_TEST_DIR=/tmp, selinux is enabled,
and the default security context is set to "<<none>>" for /tmp, all the
tests will fail, unable to create devices, since dmsetup will fail, a
result of machpathcon() returning an error code.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-20 15:19:36 +00:00
46886164dd Add -S command to clvmd, so it can restart itself and still
preserve exlusive LV locks.
2010-04-20 14:07:37 +00:00
ea04c0775c Add dm_bitset_equal to libdevmapper. 2010-04-20 13:58:22 +00:00
d29aa4764e typo in comment 2010-04-20 12:18:31 +00:00
203d1d8371 Move function up file 2010-04-20 12:14:28 +00:00
2eb4099563 missed files from last commit 2010-04-20 10:58:18 +00:00
7cd66377ef Add additional test to start the snapshot merge (which had just failed
because an FS was mounted -- origin was still open).
2010-04-19 22:44:42 +00:00
1f9d50fa3f Add dm_bit_and. (ejt) 2010-04-19 21:23:01 +00:00
be29e5ab62 fix last commit 2010-04-19 21:10:20 +00:00
24d8818933 Simplify dm_bitset_create. (ejt) 2010-04-19 21:08:32 +00:00
803380c203 Speed up dm_bit_get_next with ffs(). 2010-04-19 17:17:55 +00:00
1569059b2b Change lvm2app version number from 1 to 2.
This version number change reflects the memory handling change
for string-based pv/vg/lv string based attributes.
In addition, when adding support for tags, I forgot to increase
the version number.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-19 15:24:00 +00:00
8fb6bd930b Use vg->vgmem to allocate vg/lv/pv string properties instead of dm_malloc/fr
Everywhere else in the API the caller can rely on lvm2app taking care of
memory allocation and free, so make the 'name' and 'uuid' properties of a
vg/lv/pv use the vg handle to allocate memory.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-19 15:22:24 +00:00
c7cc4b7ac2 Change daemon lock filename from lvm2_monitor to lvm2-monitor for consistency. 2010-04-15 19:15:03 +00:00
201d0e940b Install symbolic .so links with relative paths between usrlibdir and libdir. 2010-04-15 15:12:20 +00:00
3fcd56034a Fix double DESTDIR usage for infodir and mandir. 2010-04-15 15:09:35 +00:00
51d222469c Added awk script relpath.awk to calculate relative paths. 2010-04-15 15:06:26 +00:00
742d1e9424 post-release 2010-04-14 21:47:48 +00:00
a04f401227 touch file 2010-04-14 20:03:46 +00:00
62699dc3fd fix broken 'make install' for lvm_dump.sh 2010-04-14 20:03:15 +00:00
01645a7eae pre-release 2010-04-14 18:54:37 +00:00
b17939f74e pre-release 2010-04-14 18:53:04 +00:00
aa60387ecc . 2010-04-14 18:10:30 +00:00
4b801e21e3 pre-release 2010-04-14 17:50:49 +00:00
c198ca0285 Add missing readline linkage to lvm2app test. 2010-04-14 16:13:34 +00:00
a312fc8eb9 What's new. 2010-04-14 13:52:20 +00:00
10b62fb0e8 Allow incomplete mirror restore in lvconvert --repair upon insufficient space. 2010-04-14 13:51:58 +00:00
2c12325d63 Do not reset position in metadata ring buffer on vgrename and vgcfgrestore.
We should write metadata into next position in the ring buffer while calling
vgrename and vgcfgrestore. At this code level (_vg_write_raw), we were not able
to determine if this is a rename or not. If yes, then accompanying VG structure
passed here has a new name set, not the old one.

When looking for a location where to put metadata next, we were given a NULL
value because of failed VG name comparison (in _find_vg_rlocn) between the
name in existing metadata and metadata we're just about to write.

This resets the position in the ring buffer, overwriting any existing metadata
(and also incorrectly updates the cache to "orphan" afterwards).

This patch just adds old_name item in struct volume_group that we can check and use
if necessary and detect renames at lower layers as well.

The same applies for vgcfgrestore, but here we're using a special value of
old_name, an empty string, to disable the check with existing metadata totally.
2010-04-14 13:09:16 +00:00
2d8b9935a1 Allow VGs with active LVs to be renamed. 2010-04-14 13:03:06 +00:00
647d948562 Use UUIDs instead of names while processing event handlers.
Internally, we used DM names instead of UUIDs while processing event
handlers. This caused problems while trying to vgrename a VG with active LVs
where the names are being changed and so the devices were not found then.
The patch also contains a little bit of refactoring, moving "build_dlid" code
found in dev_manager.c to "build_dm_uuid", now in lvm-string.c (so we have
build_dm_uuid and build_dm_name at one place).
2010-04-14 13:01:38 +00:00
73d1626ddc SIGTERM testing clvmd before SIGKILL-ing it. 2010-04-14 12:04:23 +00:00
b7445913cc Only pass visible LVs to tools in cmdline VG name/tag expansions without -a 2010-04-14 02:19:49 +00:00
6f7ca25c9b Use typedefs for toollib process_each functions. 2010-04-13 23:57:41 +00:00
4487c42de2 Fix teardown in t-pvcreate-operation-md.sh nightly test. 2010-04-13 21:42:44 +00:00
bfbad87685 Add error diagnostic for setenv failure. 2010-04-13 20:54:57 +00:00
65f0ca65f1 Use C locales and use_mlockall for clvmd.
Use same steps for clvmd as for dmeventd - using C locales to avoid reading
large mmaps and use mlockall() for threaded version.
2010-04-13 19:54:16 +00:00
d0720d5638 Update WHATS_NEW 2010-04-13 18:18:54 +00:00
5d7fd71373 Add pv->vg to solidify link between a pv and a vg.
lvm2app needs a link back to the vg in order to use the vg handle for
memory allocations as well as other things.  This patch adds the field
to struct physical_volume, and sets pv->vg when reading a vg from disk or
extending a vg by using the helper function previously added,
add_pvl_to_vgs().  Moves and renames are handled with separate code
inside move_pv() and vgmerge().  Add pv->vg check to vg_validate().

A NULL value in pv->vg signifies membership in the orphan VG.
Note though in the case of pv_read() on a device with metadatacopies == 0,
more devices may need to be read for an authoritative answer.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:26:36 +00:00
efe3e72ed0 Use del_pvl_from_vgs() in vgreduce paths.
Somehow these got missed in earlier patches.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:26:20 +00:00
85f56aef97 Call add_pvl_to_vgs() and del_pvl_from_vgs() from more places.
Now that we have library functions to add/delete a pv from the vg->pvs
list, call them from everywhere.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:26:03 +00:00
5ac0fdd924 Add del_pvl_from_vgs() and move prototypes into metadata-exported.h
Add a delete function to manage the vg->pvs list.

NOTE: It may be possible to do further cleanup to these add/del functions
by passing a 'pv' as input instead of 'pv_list'.  The pv_list is used for
functions which do allocations (lvcreate) while other places in the code
just manage a list of 'pv' (e.g. import functions, vgextend, etc).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:25:44 +00:00
b33c7a4597 Move increment of vg->pv_count from import_pool_vg() to import_pool_pvs().
Move the increment of vg->pv_count next to the place where we add to
vg->pvs.  It looks safe to do this since the only caller of import_pool_vg()
calls import_pool_pvs() immediately afterward, and there is no way
import_pool_vg() can fail (always returns 1).  However, if there's a
memory allocation failure inside import_pool_pvs(), we will end up with
a different count in vg->pv_count that with the original code.  In any
case, vg->pv_count should be as close to dm_list_size(&vg->pvs) as
possible, as is the case everywhere else in the code.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:25:26 +00:00
788b9bfdc7 Remove unnecessary parameter from import_pool_pvs().
The dm_list * parameter is unnecessary since we are passing in 'vg'
and the only caller of import_pool_pvs() passes '&vg->pvs' in the
dm_list * parameter.  Just use vg->pvs directly in the function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:25:13 +00:00
41cc3b216d Arguments to the --mirrorlog option are described in the synopsis as
{core|disk|mirrored}.  However, under the options section they are
described as {core|disk} - even though the 'mirrored' argument is
described.

s/'{core|disk}'/'{core|disk|mirrored}'/
2010-04-13 16:13:08 +00:00
dcb7878842 Mask LCK_HOLD flag in cluster VG locks for compatibility reasons. 2010-04-13 14:36:24 +00:00
b5e83471bc Add check_cluster and check_local targets in addition to just "check". 2010-04-13 13:28:52 +00:00
bfdc05ec71 Process all core dumps that exist upon a test failure (this would hopefully
include eg. clvmd cores, apart from the usual lvm ones).
2010-04-13 08:01:53 +00:00
1d7ecbe9a0 Fix a reversed exit status from test harness. 2010-04-13 07:34:19 +00:00
9e30a829d5 Optionally disable the verbose repeat of a failed test (export
LVM_TEST_NOVERBOSE=1).
2010-04-13 07:33:34 +00:00
698dfbf953 Disable the rather-dangerous prepare_scsi_debug_dev in the testsuite. 2010-04-13 07:02:14 +00:00
83fbb1ec11 Make it easy to run just a subset of tests by saying make check T="regex". 2010-04-13 06:45:53 +00:00
19d0f2b57c Fix t-lvcreate-usage, as lvcreate ... -i1 no longer prints "Redundant stripes
argument: default is 1".
2010-04-13 06:25:08 +00:00
05d40b3142 For the testsuite, set a default polling interval to 0 in lvm.conf. Cuts down
testing time considerably.
2010-04-13 06:24:20 +00:00
d94fc9ce62 Add --stripes to lvconvert too. 2010-04-13 01:54:32 +00:00
ba9550f473 Add activation/polling_interval to lvm.conf as --interval default. 2010-04-13 01:43:56 +00:00
28e1e7fd07 More testsuite helpers for check.sh. 2010-04-12 19:33:58 +00:00
904e38837e Absorb t-mirror-lvconvert-usage into t-lvconvert-mirror. 2010-04-12 19:32:58 +00:00
697c5de267 Explode t-mirror-basic into a number of smaller tests. 2010-04-12 19:16:24 +00:00
bfa9c7bcfb Add a new helper script for the testsuite, that makes checking for various
(lvm) properties easier and produces nicer output.
2010-04-12 19:02:59 +00:00
2f81a05ce5 Do not pollute /tmp with testing byproducts. 2010-04-12 19:00:23 +00:00
7b994976e3 Don't ignore error if resuming any LV fails in resume_lvs.
Skip closing persistent filter cache file if open failed.
2010-04-12 11:52:53 +00:00
662d1021e6 Update install rules for udev.
Fix unwanted modification of $(top_builddir)/make.tmpl.

Using dependency rules to install rules for udev.
There is minor problem, with concurent usage of builddir
and srcdir could lead to missuse of 10-dm.rules which
could be found in VPATH from different builddir.
However current solution uses intermediate target so
the generated 10-dm.rules exists only for short period of time
during make install execution.
2010-04-09 21:44:28 +00:00
2db34bd266 INSTALL rules updates
Patch is inspired by Debian's extra patch.

- removes OWNER & GROUP make vars they are parts of INSTALL command.
- adds INSTALL_PROGRAM for executable, uses $(INSTALL)
- adds INSTALL_DATA for non-executable data, uses ($INSTALL)
- adds INSTALL_WDATA for writable non-executable data, uses ($INSTALL)
- adds configure option --enable-write_install - to support
  installatin of writable files used by distribution
- replaces usage of ifeq @LIB_SUFFIX@ with $(LIB_SUFFIX)
- installs .a files from static builds without executable flag
- installs .a files to $(usrlibdir) instead of $(libdir)
- installs all static binaries to $(staticdir)
- create .so links for devel package in $(usrlibdir) instead of
  $(libdir)
- makes .so and .so.LIB_VERSION files within builddir
- removes VERSIONED_SHLIB and created versioned LIB_SHARED automagicaly
- install LIB_SHARED via install_lib_shared target
- install plugins via install_lib_shared_plugin target
- prints whole 'install' command during installation instead of less
  informative "Installing  $(something) $(somewhere)"
- install multiple man pages with one INSTALL command
- use DISTCLEAN_TARGETS instead of creating multiple distclean targets
2010-04-09 21:42:48 +00:00
f3491d93a0 Use vpath instead of VPATH.
Usage of VPATH makes troubles when used within $(builddir).
Not only source files are being found through VPATH,
but targets as well. (make --debug=v)

Thus if user builds the code in $(srcdir) and also in some $(builddir)
he gets mangled results as some generated files (i.e. .export.sym)
are 'reused' from $(srcdir) instead of $(builddir).

This patch switches to use vpath were we could explicitly name
suffixes that should be looked via vpath - we must take care,
we do not generate files with these suffixes:
.c, .in, .po, .exported_symbols
2010-04-09 21:34:25 +00:00
337abee8f8 Permit mimage LVs to be striped in lvcreate and lvresize. 2010-04-09 01:00:10 +00:00
34573cf6a5 Check for duplicate paths (pvids) on the commandline of vgcreate.
A user specifying duplicate paths on the cmdline of vgcreate will
get a message similar to the following:
vgcreate vgtest2 /dev/loop3 /dev/loop5
  Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop5 not /dev/loop3
  Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop3 not /dev/loop5
  Internal error: Duplicate PV id jk1lXs-Kzwy-OKlX-q6bh-aFFK-MQQ0-6oPgu8 detected for /dev/loop3 in vgtest2.

This is caught by vg_validate(), but it would be good to find
this condition earlier in the vgcreate code.  add_pv_to_vg()
currently checks by pvname, but does not look for duplcate pvids.
This patch adds the check for duplicate pvids and results in new
error output as follows:
vgcreate vgtest2 /dev/loop3 /dev/loop5
  Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop5 not /dev/loop3
  Found duplicate PV jk1lXsKzwyOKlXq6bhaFFKMQQ06oPgu8: using /dev/loop3 not /dev/loop5
  Physical volume '/dev/loop5 (jk1lXs-Kzwy-OKlX-q6bh-aFFK-MQQ0-6oPgu8)' listed more than once.
  Unable to add physical volume '/dev/loop5' to volume group 'vgtest2'.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-08 15:18:35 +00:00
491ef790c2 Add cleandir target.
Using non-recursive cleandir target for resursive distclean and clean.
Avoids duplicated clean invocation during distclean.
Indent $(RM) parameters.
2010-04-08 09:15:37 +00:00
2e9ae681c5 And another test that should have been failing - normal allocation policy
does not put stripes on the same disk as each other!
2010-04-08 01:58:06 +00:00
a02f7ab0cb another incorrect test that should have been failing before 2010-04-08 01:43:46 +00:00
e0b190c111 missing ?: 2010-04-08 00:56:26 +00:00
56fa3ac1b0 suppress bogus compiler warning 2010-04-08 00:52:41 +00:00
5bcbeca8e7 Fix pvmove allocation to take existing parallel stripes into account.
When moving parts of striped LVs, pvmove wouldn't care about leaving you with
two stripes on the same disk.  Now --alloc anywhere is needed for that.
(Tried and gave up on two alternative approaches before the one committed here.)
2010-04-08 00:28:57 +00:00
adc1729212 Only fail if the top-level LV fails to be deactivated - allow deactivation
of its dependencies to fail.
2010-04-07 23:51:34 +00:00
fd7ae0cdf4 Don't forget to cd into $TESTDIR in test-utils.sh / prepare_testdir. 2010-04-07 21:38:01 +00:00
fdef9679b6 Issue a message if the new type of deactivation failure happens.
If this can happen during 'normal' operations, I need to know.
2010-04-07 21:25:09 +00:00
dcecda51d8 Fix a mis-override of $PWD in test-utils.sh. 2010-04-07 21:19:20 +00:00
687603a144 Fix incorrect removal of symlinks after LV deactivation fails. 2010-04-07 20:04:41 +00:00
acb04c003e Set ulimit -c to unlimited to allow coredumps to be collected and analysed in
the testsuite.
2010-04-07 16:04:22 +00:00
86b10089aa Avoid spurious skips in the testsuite due to obsoleted
dmsetup_has_dm_devdir_support_.
2010-04-07 16:00:19 +00:00
7b030379ec Wipe dm-ioctl parameters in memory after use. 2010-04-07 15:57:20 +00:00
5e8c230d1f Refactor the test utilities, dropping the legacy test-lib.sh and curtailing
lvm-utils.sh. Clears up lots of unused code, should have little observable
impact (it does change test directory layout slightly).
2010-04-07 14:46:26 +00:00
8c2890cf1d In test harness, use fwrite(3) in place of write(2) to avoid mixing fd-level
and FILE-level IO on stdout.
2010-04-07 09:48:11 +00:00
8e9da71c32 Keep the testsuite stats correct in spite of failed-test repetition. 2010-04-07 09:41:33 +00:00
13deb51d3e Move a fragile testcase toward the end of t-mirror-lvconvert.sh. 2010-04-06 23:04:45 +00:00
2c9ffffdca Put back the `lvconvert -m+1 --mirrorlog disk' test in t-lvconvert-mirror.sh. 2010-04-06 22:22:26 +00:00
13a9bce647 disable another broken check in a test 2010-04-06 18:13:43 +00:00
dbb3cfe05e Fix is_partitioned_dev not to attempt to reopen device. 2010-04-06 17:36:41 +00:00
674baa8143 Disable broken test. 2010-04-06 16:30:53 +00:00
db482f3e1c Fix a thread race in clvmd that could cause lockups on very busy systems 2010-04-06 15:29:30 +00:00
6a5a0222d7 Display PVs created during tests 2010-04-06 14:25:07 +00:00
4512267bf1 Using 'not' if the test 'should' fail. 2010-04-06 14:24:13 +00:00
54555a6fab Update WHATS_NEW 2010-04-06 14:07:11 +00:00
ae2353caf8 Add add_pvl_to_vgs() - helper function to add a pv to a vg list.
Small refactor of main places in the code where a pv is added to a
vg into a small function which adds the pv to the list and updates
the vg counts.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-06 14:04:54 +00:00
4eae19ed75 Refactor format1 vg->pvs list add and vg->pv_count.
Refactor adding to the vg->pvs list and incrementing the count, which
will allow further refactoring.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-06 14:04:20 +00:00
e6ec837203 Refactor _read_pv() code that updates vg->extent_count and vg->free_count.
Simple refactor to mov code that updates the vg extent counts from a
single pv's counts close to the code that adds a pv to vg->pvs and
updates vg->pv_count.  No functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-06 14:04:03 +00:00
b37f7c4b7b Add pv to vg->pvs after check for maximum value of vg->extent_count.
In add_pv_to_vg(), we should only add the pv to vg->pvs after all
internal checks have passed.  The check for vg->extent_count exeeding
maximum was after we added the pv to the list, so this function could
return a state of vg->pvs that did not reflect other parameters such
as vg->pv_count.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-06 14:03:43 +00:00
4b8340327c As lcov module is not installed with GD.pm dependency we need
to check for presence of this module and avoid using --frames
option for genhtml in this case.

Fix arg list for AC_PATH_PROG for lcov and genhtml.
(detecting empty LCOV and GENHTML string in Makefiles).
2010-04-06 11:53:53 +00:00
92e4442d4a Distcleanup config files only in toplevel directory.
Do not execute 'rm -r' with empty $(DISTCLEAN_DIRS).
lvm-version.h is already cleaned with subtarget distcleaning.
Always distcleanup lcov_reports*.
2010-04-06 09:54:11 +00:00
2517f9adf2 Fix lcov target
Patch fixes generation of coverage files for dmeventd and adds support for clvmd.
Path names are stripped, so the the html looks better.
Frames 'previews' is enabled for generated pages.
Using top_srcdir was wrong here - though we still can't easily use builddir.
Requiers using shell variables before execution of binaries build outside
of srcdir.
2010-04-06 09:50:07 +00:00
9bad64ff72 remove compiler warning 2010-04-02 01:35:34 +00:00
d1b147e2bb A few more log_error to log_warn changes for mirrors. 2010-04-01 14:54:37 +00:00
1b7730c76a Better debug message for Un/Locked memory size. 2010-04-01 14:53:47 +00:00
28801f7470 temporarily downgrade the 'open while suspended' error till we fix it properly 2010-04-01 14:30:51 +00:00
f4c43c11c9 Try to fix tracking of whether or not log extents need allocating. 2010-04-01 13:58:13 +00:00
fde4a8e1b5 Set ret value to success initially. 2010-04-01 13:43:12 +00:00
abb193533c Avoid endless loop if lv->segments list is corrupted 2010-04-01 13:08:06 +00:00
775fac97d3 initialise log_allocated to 0 2010-04-01 12:29:07 +00:00
3963c01760 Limit number of error messages when checking LV segments. 2010-04-01 12:14:20 +00:00
1e01a63685 Improve vg_validate to detect some loops in lists. 2010-04-01 11:45:36 +00:00
235ca704b1 Improve vg_validate to detect some loops in lists. 2010-04-01 11:43:24 +00:00
5685ba7918 Change most remaining log_error WARNING messages to log_warn. 2010-04-01 10:34:09 +00:00
f0d1c085b9 Do not pass NULL to setenv in the test harness. 2010-03-31 23:11:12 +00:00
45490081c7 Missed to convert T -> SCRIPTS 2010-03-31 23:05:20 +00:00
a3503d13e5 Re-run failing tests with log/verbose=4 (-vvvv) to help with debugging. 2010-03-31 22:18:17 +00:00
3ed4d07d3a remove unused var 2010-03-31 20:39:51 +00:00
06e0023c2c Attempt to fix non-ALLOC_ANYWHERE allocation code after recent changes broke
The preference given to the PVs with the largest free areas.
2010-03-31 20:26:04 +00:00
b22e0a3ecb Always use blocking lock for VGs and orphan locks.
Because we have now strong rule for lock ordering:
 - VG locks must be taken in alphabetical order
 - ORPHAN locks must be the last
vgs_locked() is now not needed.

This fixes problem with orphan locking, e.g.
vgremove VG1    |    vgremove VG2
lock(VG1)       |    lock(VG2)
lock(ORPHAN)    |    lock(ORPHAN) -> fail, non-blocking

https://bugzilla.redhat.com/show_bug.cgi?id=578413

(More similar places in code.)
2010-03-31 17:23:56 +00:00
0802006ea7 Fix all segments memory is allocated from vg private mempool.
Physical segments were still allocated from global
command context mempool.

This leads to very high memory usage when
activating large VG (vgchange).
(Memory usage was about 2G when >3000LVs).

Fix it by properly using vg->vgmem private pool,
so all the memory is released early.

New memory pool parameter is needed here for pv_split_segment
function.

Also fix the same problem in some minor allocations
(vg description, lv segment split).
2010-03-31 17:23:18 +00:00
29a21d1627 Do not traverse PV segment list twice.
In addition to previous patch, we really do not need
to search for segment which was just allocated in
split request.

Make pv_split_segment function return newly allocated
(split) segment also.

(So after this patch, there is only one user
of slow find_peg_by_pe).
2010-03-31 17:22:26 +00:00
a0074aa07e Optimise PV segments search.
The function find_peg_by_pe is incredibly inefficient
for Pvs with many segments.

In shiny future there should be binary (or interval) tree
instead of sorted linked list (volunteers?).

Anyway, for now, we can use dirty trick here to optimise this case:

 - Allocations are usually applied from the beginning
 of PV (we have no alloocation policy which allocates areas
 "backwards")

 - The only user of find_peg_by_pe is pv_split_segment()
 call. In *most* cases it need to split *last* PV segment.

So if we search sorted pv segment list backwards, we
hit the requested segment immediatelly.

This patch applies this tiny change.
(and saves >30% of processing time when >3000LVs segments are on one PV!)

To discourage using this inefficient function from other code,
it is moved to pv_manip.c and used static for now:-)
2010-03-31 17:21:40 +00:00
4e8859d851 Remove vg_validate call when parsing cached metadata.
vg_validate call is an adept to optimisation, it is very
ineeficient and slow.

Anyway, we should call it only before writing data to disk.

The call in lvmcache was just temporary validation,
we realy do not need to revalidate cached metadata
every time.
(Actually, I added that there just to prove that cache works
properly and forgot to remove it.)

Patch removes it from lvmcache completely, this can hit only
internal bug in export function (and this bug must
be detected in any vg_write call anyway before).
2010-03-31 17:20:44 +00:00
562ae607d2 Use hash table for quick lv reference when reading metadata.
The _read_vg uses already hash for PVs to optimise
reading of large VGs and avoiding repeated PV list traversing.

Use the same aproach to speed up parsing VG with many LVs.
2010-03-31 17:20:02 +00:00
2426656b07 A missing space in the error message.
Add missing parentheses to an error message

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2010-03-31 12:06:30 +00:00
898d3c655d Don't kill the parent if debugging.
If dmeventd runs with -d flag, it doesn't fork into backgroud.
The command kill(getppid(), SIGTERM) attempts to kill the parent dmeventd
process, however, if there is no parent, it kills whatever process spawned
dmeventd. In case of debugging with gdb, the parent is gdb, thus
kill(getppid(), SIGTERM) kills the debugger.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2010-03-31 12:01:49 +00:00
855e554051 Update for make install. 2010-03-31 07:43:41 +00:00
4aac2c543b Install generated 10-dm.rules from builddir.
Patch just check whether file is generated in builddir otherwise srcdir file
is used.
2010-03-31 07:40:20 +00:00
78024e7be6 Use .commands created in builddir for symlink installation. 2010-03-31 07:37:16 +00:00
18f0009a41 We only need one extent for the mirror log. So, when specifying
the devices on which to place the individual mirror parts, we can
specify the log devices as $dev:x instead of $dev:x-y.
2010-03-31 03:56:25 +00:00
1cf64de2bf For the mirror repair tests, we should use --ignoremonitoring because
we are running the repair manually.  If we don't ignore, then dmeventd
and the manually run repair can collide.  (We should still get clean
results in such a case, but it makes it harder to validate the test
results.)
2010-03-31 02:36:03 +00:00
b1d6be8ec6 Update for dmeventd changes. 2010-03-30 14:44:57 +00:00
137a25906d Count only readable size for memlock stats.
As we mlock() only readable pages, makes statistics only
for readable bytes.
2010-03-30 14:41:58 +00:00
2b298cbb32 Update memlock
Code moves initilization of stats values to _memlock_maps().
For dmeventd we need to use mlockall() - so avoid reading config value
and go with _use_mlockall code path.

Patch assumes dmeventd uses C locales!
Patch needs the call or memlock_inc_daemon() before memlock_inc()
(which is our common use case).

Some minor code cleanup patch for _un/_lock_mem_if_needed().
2010-03-30 14:41:23 +00:00
5361b5de37 Force C locale
As we need to use mlockall() enforce "C" locales for dmeventd.
2010-03-30 14:40:30 +00:00
f1fee292e4 Updated syslog messages
Use our common '.' end format for syslog messages.
2010-03-30 14:39:55 +00:00
9c9b1f5bc8 Release pool in the same reversed order
and with lowered priority after _memlock_dec.
2010-03-30 14:38:56 +00:00
7e64d04db1 Fix resouce leak in error path
If the error path of _register_for_event() calls _free_thread_status()
_lib_put() call is missing.
To make thing simpler move this _lib_put() into common error path code.
2010-03-30 14:37:28 +00:00
2355f677fb Remove mlockall() form dmeventd
As the header file <sys/mman.h> was not included in dmeventd.c
thus missed definition of MCL_CURRENT so this patch only makes
it obvious we were not locking memory here.

This patch has no functional change.
Later part of this patch set handles mlockall() via memlock_inc_daemon().
2010-03-30 14:35:40 +00:00
e42bb91382 Fix --alloc contiguous policy only to allocate one set of parallel areas. 2010-03-29 17:59:46 +00:00
28aa06675f Work around a problem in t-mirror-lvconvert: different PV order on the
commandline of lvconvert can lead to allocation failures even if enough space
is available. A separate testcase demonstrating the problem will follow.
2010-03-29 16:50:27 +00:00
6e86d0bb03 Enforce distinct-PV allocation of snapshot/origin pairs in vgsplit test. 2010-03-29 16:40:51 +00:00
4342431e39 Do not allow {vg|lv}change --ignoremonitoring if on clustered VG.
clvmd does not propagate DMEVENTD_MONITOR_IGNORE.

Update get_activation_monitoring_mode() to check if the VG that the
LV is being activated in is clustered.  If so, skip it.

Any get_activation_monitoring_mode() error will cause the associated LV
(or VG) to be skipped during activation.  Both vgchange_single() and
lvchange_single(), which call get_activation_monitoring_mode(), are
called by their respective process_each_..() method.
2010-03-29 16:09:40 +00:00
7452298131 Fix also error code from clean:
And fix previous commit which missed test.
2010-03-29 15:53:11 +00:00
e4be66b1ac Oops, avoid returning errors from shell to makefile for builddir == srcdir 2010-03-29 15:39:25 +00:00
f829547a13 Avoid modification of .in files outside man directory.
(i.e. this rule actually tried to change ../make.tmpl in some cases and
left this file completely broken)
2010-03-29 14:22:00 +00:00
ea64fe3b51 Split long line in Makefile and keep $abs_top_buildir as shell variable
within init.sh.
2010-03-29 14:19:42 +00:00
f293d0b951 Fixing another set of distclean problems where we left some generated files
in clvmd, dmevend, man, tests.

Don't include dependency files for clow and cscope.out targets

Improve dependency tracking for dmeventd and liblvm2cmd sources.
2010-03-29 14:17:59 +00:00
1967fd2429 Update cflow file generation - support build dir and use $(top_srcdir)
to obtain sources. Create make.tmpl target for
simplier generation of cflow files with the help of
CFLOW_LIST, CFLOW_LIST_TARGET, CFLOW_TARGET.
Still cflow usage is not perfect.
2010-03-29 14:11:17 +00:00
0fec0340c2 distclean fixes
Move daemons/ and lib/ subtargets to their Makefiles so we don't get
double cleanup error during execution of distclean target.
Instead of duplicating clean target inside distclean target,
just use it as a subtarget and avoid add duplicating code.
2010-03-29 14:09:25 +00:00
bed67320b1 Use $(top_srcdir) for sources and add cscope.out to distclean targets. 2010-03-29 14:07:56 +00:00
8544e24770 Add $(LIB_STATIC) to TARGETS so it's cleaned in the same way
as other libraries in project.
Add dmeventd.gcda dmeventd.gcno to CLEAN_TARGETS.
2010-03-29 14:07:01 +00:00
727b7b7e8c Avoid hard sed replacement - i.e. quick test change in make.tmpl
could avoid recofiguration steps in same debug cases.
2010-03-29 14:06:06 +00:00
bd39789144 Fixing compilation warning: implicit declaration of function ‘umask’ 2010-03-29 14:05:17 +00:00
eb10fc962b When a scsi_debug modprobe fails, skip the test instead of failing it. 2010-03-28 15:52:04 +00:00
3318c41356 Add ability to create mirrored logs for mirror LVs.
This check-in enables the 'mirrored' log type.  It can be specified
by using the '--mirrorlog' option as follows:
#> lvcreate -m1 --mirrorlog mirrored -L 5G -n lv vg

I've also included a couple updates to the testsuite.  These updates
include tests for the new log type, and some fixes to some of the
*lvconvert* tests.
2010-03-26 22:15:43 +00:00
dc2c0b1d51 Use a real socket for singlenode clvmd to fix clvmd's high cpu load. 2010-03-26 15:45:36 +00:00
1de8da23f5 Fix clvmd cluster propagation of dmeventd monitoring mode.
clvmd's do_lock_lv() already properly controls dmeventd monitoring based
on LCK_DMEVENTD_MONITOR_MODE in lock_flags -- though one small fix was
needed for this to work: _lock_for_cluster() must treat
dmeventd_monitor_mode()'s return as a tri-state value.

Also cleanup do_lock_lv() to:
- explicitly init_dmeventd_monitor() based on LCK_DMEVENTD_MONITOR_MODE
- no longer reset init_dmeventd_monitor() to default at the end of
  do_lock_lv() -- it is unnecessary
2010-03-26 15:40:13 +00:00
340fa684af Updates .so links for plugins 2010-03-26 13:21:28 +00:00
34f06fa400 Allow ALLOC_ANYWHERE to split contiguous areas. 2010-03-25 21:19:26 +00:00
5b5337e4af . 2010-03-25 18:22:39 +00:00
d01de820d7 Use INTERNAL_ERROR definition consistently in internal error messages. 2010-03-25 18:22:04 +00:00
5aeea69c01 Add some assertions to allocation code. 2010-03-25 18:16:54 +00:00
8f6c0b24d8 more diagnostics 2010-03-25 12:16:17 +00:00
b8eddf1bdc more diagnostics 2010-03-25 12:14:14 +00:00
1469dc216a add debug mesg 2010-03-25 11:57:16 +00:00
3306ae2f42 . 2010-03-25 11:48:54 +00:00
a89db8e69c add debug mesgs and attempt to control which device is used for log as perhaps intended 2010-03-25 11:47:00 +00:00
8c6f06eb34 add debug output and attempt to control which device gets log as intended perhaps 2010-03-25 11:42:17 +00:00
fe3ed2b871 improve a few comments in last check-in 2010-03-25 02:40:09 +00:00
71cb3fc201 Introduce pv_area_used into allocation algorithm and add debug messages.
This is the next preparatory step towards better --alloc anywhere
support and is not intended to break anything that currently works so
please report any problems - segfaults, bogus data in the new debug
messages, or if the code now chooses bizarre allocation layouts.
2010-03-25 02:31:48 +00:00
f9554c7d27 Revert having clvmd consult the lvm.conf "activation/monitoring".
Correctly implementing the intent of this change requires more
analysis.
2010-03-24 22:25:11 +00:00
384f2fc38b Move declaration of struct dm_info info to declaration block. 2010-03-24 11:36:48 +00:00
cd50107ae1 Improve activation monitoring option processing
. Add "monitoring" option to "activation" section of lvm.conf
. Have clvmd consult the lvm.conf "activation/monitoring" too.
. Introduce toollib.c:get_activation_monitoring_mode().
. Error out when both --monitor and --ignoremonitoring are provided.
. Add --monitor and --ignoremonitoring support to lvcreate.  Update
  lvcreate man page accordingly.
. Clarify that '--monitor' controls the start and stop of monitoring in
  the {vg,lv}change man pages.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-03-23 22:30:18 +00:00
94466645ee Also honour abort_on_internal_errors when log_fn is set. 2010-03-23 18:18:49 +00:00
1acb442f60 UDEV_SYNC_SUPPORT, not UDEV_SYNC! 2010-03-23 15:13:03 +00:00
cff0a562fd Allow dynamic extension of array of areas selected as allocation candidates. 2010-03-23 15:07:55 +00:00
299db29482 Export and use only valid cookie value in test suite. 2010-03-23 14:47:35 +00:00
cc5045d8ca Autoreconf.
(Strictly require libudev if udev_sync is used)
2010-03-23 14:44:42 +00:00
940c32c5dd Strictly require libudev if udev_sync is used.
This prevents some confusion when libudev was not found so udev_sync was disabled
automatically. Configure was successful though giving only a tiny warning.

Also, if "dmsetup udevcreatecookie" is used, never return 0x000000 as a result if
udev is not running and keep the output blank.
2010-03-23 14:43:18 +00:00
14ad41a065 Add support for ioctl's DM_UEVENT_GENERATED_FLAG.
We need to know whether we should wait for any uevent or not when
using udev_sync. A kernel patch was posted recently that changed the
way uevents are sent on dm device resume - it is sent only if the
device has been suspended before. There's also a new DM_UEVENT_GENERATED_FLAG
in the ioctl to notify userspace whether the event was generated.

If the uevent was not generated (e.g. the situation where the device is
*not* suspended and we call a resume), we just call dm_udev_complete
explicitly from within libdevmapper itself to prevent infinite waiting
while trying to synchronise with udev processing.
2010-03-23 14:38:37 +00:00
7eaf1f294d Avoid duplicate definitions. 2010-03-23 14:35:08 +00:00
eb7692743f Remove const modifier for struct volume_group* from process_each_lv_in_vg().
Content of this pointer is not const during this function.
2010-03-23 14:24:04 +00:00
7aa470c8d0 Don't allow resizing of internal logical volumes.
Prevent lvresize from being able to resize internal LVs: mirror legs
(*_mimage_*), mirror log (*_mlog), snapshot placeholder LVs (snapshot*)
and others.  Resizing these would leads to unexpected metadata and
sometimes crashes (in case of growing snapshot*).
2010-03-20 03:44:04 +00:00
4237ca85f5 Fix libdevmapper-event pkgconfig version string to match libdevmapper. 2010-03-19 18:33:55 +00:00
99cdfa1e71 Update WHATS_NEW for last checkin. 2010-03-18 17:32:25 +00:00
39f92f3cfd Avoid scanning all pvs in the system if operating on a device with mdas.
When we pv_read() a device that has an orphan vgname, we might need to scan
the system to be sure this is true.  However, if the PV has mdas, there's
no way possible for it to have an orphan vgname unless it is a true orphan.
Some areas of the code were optimized to take advantage of this fact, while
others were not (we would still do the expensive scan if a device had mdas
but had an orphan VG).

This patch unifies the code so that every place we are operating on such
a PV, we skip the expensive scan if there are mdas.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Petr Rockai <prockai@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2010-03-18 17:29:12 +00:00
9cc29191d4 autoreconf & add missing WHATS_NEW entry 2010-03-18 13:24:35 +00:00
de33332491 Run both locking_type 1 and 3 tests (forgot to uncomment locking_type 1 before
last checkin).
2010-03-18 09:28:42 +00:00
f9ddafdc21 Skip locking_type 3 tests instead of failing when system-wide clvmd is running. 2010-03-18 09:27:39 +00:00
fdefd5eff9 Add infrastructure for running the functional testsuite with locking_type set
to 3, using a local (singlenode) clvmd.
2010-03-18 09:19:30 +00:00
e9e5dbb628 Add pvchange -u --all to testsuite.
This can be an interesting test case when using PVs with --metadatacopies 0.
2010-03-17 17:02:01 +00:00
0e57141bb5 testsuite: get stacktrace if test drops core
Requires lvm be built with debugging (-g).
Also requires 'ulimit -c' be non-zero (to drop core file).
2010-03-17 14:55:28 +00:00
842a3664f0 Disable long living process flag in lvm2app.
This option should be configurable, but for now
do not set it at all.

(lvm2app is used in udisks probers and there
cac cause several nasty races when trying to update
lvmcache during rescan.)
2010-03-17 14:45:28 +00:00
6cf89391b6 Fix pvcreate device check.
If user try to vgcreate or vgextend non-existent VG,
these messages appears:

# vgcreate xxx /dev/xxx
  Internal error: Volume Group xxx was not unlocked
  Device /dev/xxx not found (or ignored by filtering).
  Unable to add physical volume '/dev/xxx' to volume group 'xxx'.
  Internal error: Attempt to unlock unlocked VG xxx.

(the same with existing VG and non-existing PV & vgextend)
# vgextend vg_test /dev/xxx
...

It is caused because code tries to "refresh" cache if
md filter is switched on using cache destroy.

But we can change filters and rescan even without this
machinery now, just use refresh_filters
(and reset md filter afterwards).

(Patch also  discovers cache alias bug in vgsplit test,
fix it by using better filter line.)
2010-03-17 14:44:18 +00:00
ca5fd21509 Suppress repeated errors about the same missing PV uuids.
Bypass full device scans when using internally-cached VG metadata.
2010-03-17 02:11:18 +00:00
d14471e44d fix last checkin 2010-03-16 19:06:57 +00:00
5197fd72c4 Only do one full device scan during each read of text format metadata. 2010-03-16 17:30:00 +00:00
c17ac96509 Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls. 2010-03-16 16:57:03 +00:00
4acb30c464 replace existing_pv with existing_pvl 2010-03-16 15:48:27 +00:00
d61f611adc Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
Make find_pv_in_vg_by_uuid() return same type as related functions.
2010-03-16 15:30:48 +00:00
b19719801b Introduce is_missing_pv(). 2010-03-16 14:37:38 +00:00
83a2bc8ec4 Fix clvmd Makefile to not overwrite LIBS from template definition 2010-03-16 08:47:46 +00:00
aab6f07d14 post-release 2010-03-09 14:01:47 +00:00
db8748cefd pre-release cleanups 2010-03-09 13:42:28 +00:00
23b3f55bfb pre-release 2010-03-09 13:13:07 +00:00
e6573a9bed some missing debug messages 2010-03-09 12:31:51 +00:00
d6a19426c7 Update comments for selecting maps
Use dm_snprintf and check result whether we create correct /proc path name
2010-03-09 10:25:50 +00:00
9426d45cde . 2010-03-09 03:20:12 +00:00
48d0cd3564 Misc cleanups in the new mlock code, incl. improving some variable names
& messages; using more statics (for now) to avoid redundant
recalculation; validating config file just once on loading; keeping maps
file open.
2010-03-09 03:16:11 +00:00
89f61acf2c Use mlock() only on 'r' memory maps 2010-03-08 17:14:21 +00:00
985d87b5eb Add --help dmsetup option as the synonym for help command. 2010-03-08 16:05:07 +00:00
0be2dfefdb Add --showkeys parameter description into dmsetup man page.
Also fix minor warning (-c is parameter) in man page formatting.
2010-03-08 16:04:32 +00:00
89f30d2df7 Unconditionaly ignore also Virtual Dynamically-linked Shared Object
(VDSO on 32bit is VSyscall on 64bit)
It seems it could be locked on 64bit kernels running 32bit binaries,
but it makes troubles on real 32bit machines where mlock() returns
error when trying to lock such map area. (0xffffe000)
Behavior of mlockall() seems to be similar.
2010-03-08 15:55:52 +00:00
0b648ce87b Use '_' prefix for local static variable. 2010-03-05 15:14:03 +00:00
0c897ecefd mlockall() -> mlock()
This patch adds a new implementation of locking function instead
of mlockall() that may lock way too much memory (>100MB).
New function instead uses mlock() system call and selectively locks
memory areas from /proc/self/maps trying to avoid locking areas
unused during lock-ed state.

Patch also adds struct cmd_context to all memlock() calls to have
access to configuration.

For backward compatibility functionality of mlockall()
is preserved with "activation/use_mlockall" flag.

As a simple check, locking and unlocking counts the amount of memory
and compares whether values are matching.
2010-03-05 14:48:33 +00:00
f2a6d937a6 Use UDEV_LIBS, and link -ludev only when needed. 2010-03-04 12:12:34 +00:00
76f4498303 Use DL_LIBS, remove -ldl from global LIBS and link -ldl only when needed. 2010-03-04 12:10:40 +00:00
5451f79f55 This patch add SELINUX_LIBS and STATIC_LIBS variables.
For static builds dependency for SELinux libs is not handled by 'ar'.
Till better solution is found, for static builds STATIC_LIBS is used.

Patch updates SELinux detection to use 3rd & 4th parameter for Success/Fail.
Also removes detection of pthread from this check as we know which
version of libdevmapper we are going to link with lvm after merge.

SELinux header check moved to the SELinux test code.
2010-03-04 12:08:26 +00:00
4e69ed9c98 Removes -rdynamic from linking of lvm.static and dmeventd.static. 2010-03-04 12:03:54 +00:00
75f55c758c Pthread linking change
Create new substituted variable PTHREAD_LIBS and link this library
only with tools/libs which really needs it - i.e. dmeventd.

Check for libpthread only for builds with clvmd or dmeventd.

Remove variable LIB_PTHREAD
2010-03-04 11:21:05 +00:00
f9d1b67e86 Readline linking update
Modify linking of readline library. Create new  substituted varible
READLINE_LIBS - readline library is linked ONLY with tools that really use
it - i.e. lvm. (Static lvm does not use readlin).
Previous behaviour put this library into the variable LIBS and thus
linked it with all created object files of lvm project (i.e. plugins...).

READLINE detection is simplified.

Termcap library is linked in only if readline library doesn't have its own
dependency (i.e. old distributions).
2010-03-04 11:19:15 +00:00
04ecf25522 Introduce LVMINTERNAL_LIBS
Keep dependency libraries for liblvm-internal in one place.
2010-03-04 11:12:39 +00:00
52b51b70eb As fsadm is installed by default - it's a common practice to rather
print help text in '--disable' form for such case.
2010-03-04 11:09:08 +00:00
3fdc1390fe This patch moves inclusion of the make.tmpl before DEFS modification,
so it goes in the same order on the compilation line.
(i.e. HAVE_CONFIG_H goes first)
2010-03-04 09:56:56 +00:00
f309bd12c7 Use consistently $() instead of ${} for all Makefile variables,
thought both usage forms are correct.
2010-03-04 09:56:01 +00:00
d388f94c7f Replace CFLOW_CMD only in make.tmpl and use it as variable elsewhere. 2010-03-04 09:53:08 +00:00
0f878a226d Use $(top_builddir) for inclusion of make.tmpl in Makefiles. 2010-03-04 09:51:37 +00:00
a38f899d7e Use datarootdir and fix warning during configure process:
config.status: WARNING:  'make.tmpl.in' seems to ignore the --datarootdir setting.
2010-03-04 09:48:19 +00:00
6c09d7b60c Usage of AC_PROG_SED and AC_PROG_MKDIR_P requires autoconf version 2.61. 2010-03-04 09:46:38 +00:00
8cb8f65010 Handle a misaligned device that reports a -1 alignment_offset.
The kernel's blk_stack_limits() function may flag a device as
'misaligned'.  If it does the alignment_offset will be -1.

Update set_pe_align_offset() to accommodate this corner case.
2010-03-02 21:56:14 +00:00
49437d9a07 Extend core allocation code in preparation for mirrored log areas. 2010-03-01 20:00:20 +00:00
69962eae7c - fix whitespaces all over (tabs/spaces)
- increase timeout to 30 secs (on Chrissie request)
- source both cluster and clvmd for options (like all the other cluster
  init scripts)
- add clustered_vgs and _lvs commodity fns
- move rh_status* fns at the top, so they can be reused
- heavily cleanup start and stop fns from redundant code and unnecessary
  loops
- improve output from different operations
- make the init script lsb compliant
- don´t force kill of the daemon, send only a TERM signal and then wait
for it to exit
- Resolves rhbz#533247
2010-02-26 13:07:43 +00:00
c440f39874 Remove lvs_in_vg_activated_by_uuid_only call.
There is no difference from lvs_in_vg_activated now,
convert all users to this call.
2010-02-24 20:01:40 +00:00
40090be220 Always query device by uuid only.
lvm2 devices have always UUID set even if imported from lvm1 metadata.

Patch removes name argument from dev_manager_info call and converts
all activation related calls to use query by UUID.

Also it simplifies mknode call (which is the only user on mknodes parameter).
2010-02-24 20:00:56 +00:00
281a92bf74 Update WHATS_NEW. 2010-02-24 18:21:15 +00:00
bbacb7fff0 Add Doxygen file for lvm2app to generate documentation from lvm2app.h.
A simple Doxygen file for lvm2app documentation.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:54 +00:00
cccdc3eea0 Update doxygen comments for lvm2app.h.
Fix add/remove tag function headers.
Fix a lot of little problems with doxygen comments.
Clarify the basic objects and their handles, and place functions with their
appropriate handles/objects.
All this cleanup moves automatic documentation of lvm2app much closer to being
useful as official documentation.  In the future I will add some examples
and plan to build the examples as part of the unit tests.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:44 +00:00
aa9c970f97 Update lvm2app interactive unit test for vg/lv tags.
Simple test of vg/lv tag addition/deletion.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:35 +00:00
4f81adb3c9 Add lvm_lv_get_tags(), lvm_lv_add_tag(), and lvm_lv_remove_tag().
Add lvm2app functions to manage LV tags.
For lvm_lv_get_tags(), we return a list of tags, similar to other
functions that return lists.  An empty list is returned if there
are no tags.  NULL is returned if there is a problem obtaining
the list of tags.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:26 +00:00
b8f75d74ae Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag().
Add lvm2app functions to manage VG tags.
For lvm_vg_get_tags(), we return a list of tags, similar to other
functions that return lists.  An empty list is returned if there
are no VG tags.  NULL is returned if there is a problem obtaining
the list of tags.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:18 +00:00
befffd65bf Add tag_list_copy() supporting function inside lvm2app.
Add a supporting function to copy a list of internal tags to lvm2app list.
We need to put this here because of the lvm_str_list_t type which we export
in lvm2app.h.  If we didn't export this type, we could put this in the
internal library and use struct str_list.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:10 +00:00
610cd1a531 Add dm_pool_strdup to allocate memory and copy a tag in {lv|vg}_change_tag()
We need to allocate memory for the tag and copy the tag value before we
add it to the list of tags.  We could put this inside lvm2app since the
tools keep their memory around until vg_write/vg_commit is called, but
we put it inside the internal library to minimize code in lvm2app.
We need to copy the tag passed in by the caller to ensure the lifetime of
the memory until the {vg|lv} handle is released.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:57 +00:00
08d06030dc Refactor lvchange_tag() to call lv_change_tag() library function.
Similar refactoring to vgchange - pull out common parts and put into
library function for reuse.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:49 +00:00
083687d0fd Refactor vgcreate to call new vg_change_tag() function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:40 +00:00
f874581701 Refactor _vgchange_tag() to vg_change_tag() library function.
Pull out common code to be called from tools as well as lvm2app.
Leave archive() at tool level so we can use from vgcreate
as well as vgchange.  Should be no functional change.
- add stack macro in vgchange

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:05 +00:00
e66d76ac5a Add _mlog devices to dependency trees using UUID, not name, in activation. 2010-02-23 15:49:52 +00:00
5d7ad8ae75 Relax a check on blkid exit value, which seems to be different in different
versions. Fixes a spurious test failure introduced with -o pipefail.
2010-02-22 14:47:55 +00:00
99ab428344 Do not reload origin again in lv_remove_single() if it had a merging
snapshot.  vg_remove_snapshot() will have already performed the required
reload.
2010-02-17 23:36:45 +00:00
eaef92b02f Refactor snapshot-merge deptree and device removal to support info-by-uuid
Add a merging snapshot to the deptree, using the "error" target, rather
than avoid adding it entirely.  This allows proper cleanup of the -cow
device without having to rename the -cow to use the origin's name as a
prefix.

Move the preloading of the origin LV, after a merge, from
lv_remove_single() to vg_remove_snapshot().  Having vg_remove_snapshot()
preload the origin allows the -cow device to be released so that it can
be removed via deactivate_lv().  lv_remove_single()'s deactivate_lv()
reliably removes the -cow device because the associated snapshot LV,
that is to be removed when a snapshot-merge completes, is always added
to the deptree (and kernel -- via "error" target).

Now when the snapshot LV is removed both the -cow and -real devices
get removed using uuid rather than device name.  This paves the way
for us to switch over to info-by-uuid queries.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-17 22:59:46 +00:00
4982eabe07 In testsuite, catch also failures that happen in the middle of a pipeline. 2010-02-17 15:41:28 +00:00
c66ce519f4 Add nightly test to cover vg/lv tags add/delete.
Simple nightly test coverage for adding / deleting lv/vg tags via
create and change functions.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-16 17:49:18 +00:00
e74208778d Add get_{pv|vg|lv}_field() nightly test helper functions.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-16 17:48:46 +00:00
67a0635e75 use lvm2app to refer to library now 2010-02-16 01:14:34 +00:00
def0511361 post-release 2010-02-16 00:27:01 +00:00
29b8138482 pre-release 2010-02-15 23:53:15 +00:00
c6ee487cfc Update 2010-02-15 20:32:27 +00:00
1a6df48bd0 Use dm_report_field_int32 instead of dm_report_field_uint64 for printing '-1' 2010-02-15 20:27:33 +00:00
6cdf300933 Update lvm2app.h comments to remove hidden VG comment list vgnames/vgids.
Peter recently fixed lvm_list_vg_names() and lvm_list_vg_uuids() so they
no longer return hidden names.  Remove the comment in lvm2app.h.
2010-02-15 19:55:49 +00:00
5365974d6c * update for last 3 commits 2010-02-15 18:42:51 +00:00
f1acefd241 Fix dm_report_field_uint64 to really use 64bit.
(function is currently not in use)
2010-02-15 18:36:48 +00:00
079fec6c5a Cleanup float arithmetic gcc warning. 2010-02-15 18:35:06 +00:00
14258c93de * add more 'const' - fixes gcc constness warning 2010-02-15 18:34:00 +00:00
03315d77f1 Add LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable to suppress error
and warning mesages while --ignorelockingfailure is used.
2010-02-15 16:46:56 +00:00
34843e7d6c Remove hard-coded rule to skip _mimage devices in 11-dm-lvm.rules.
There's a tiny period of time when the _mimage device is visible during
downconversion from mirror to linear. Since it is visible, we need to
create the symlinks, otherwise warning messages will be issued about udev
not creating those symlinks. We have to rely on udev flags completely.
2010-02-15 16:38:22 +00:00
4efa67c4ec Update man page for dmsetup: --udevcookie, udevcreatecookie and udevreleasecookie. 2010-02-15 16:32:24 +00:00
2419c1c540 Use udev transactions in testsuite. 2010-02-15 16:30:13 +00:00
34055f40ac Don't use LVM_UDEV_DISABLE_CHECKING environment variable anymore.
Set the state automatically based on udev and libdevmapper dev path comparison.
If these paths differ, disable udev checking.
2010-02-15 16:26:48 +00:00
276d32973f Several changes in dmsetup and libdevmapper:
- add DM_UDEV_DISABLE_LIBRARY_FALLBACK udev flag to rely on udev only

 - export dm_udev_create_cookie function to create new cookies on demand

 - add --udevcookie, udevcreatecookie and udevreleasecookie for dmsetup
   (to support "udev transactions" where one cookie value can be used for
    several dmsetup calls)

 - don't use DM_UDEV_DISABLE_CHECKING env. var. anymore and set the state
   automatically (based on udev and libdevmapper dev path comparison)
2010-02-15 16:21:33 +00:00
f3c51a049d Rename "stat" to "status" in dmeventd_snapshot.c.
Otherwise "warning: declaration of ‘stat’ shadows a global declaration"
will appear because it shadows "stat" from stat.h.
2010-02-15 12:55:20 +00:00
21573cd4f0 Update simple lvm2app unit test for new size apis.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-14 03:23:07 +00:00
f25325f4bb Export lvm_pv_get_size(), lvm_pv_get_free(), lvm_pv_get_dev_size in lvm2app.
We add these exports to show the pv_size and pv_free and dev_size
fields.
Fixes rhbz561423.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-14 03:21:37 +00:00
5b12edfb34 Fix off by 512 sizes for lvm2app.
Internally we store sizes in sectors, but lvm2app exports sizes
in bytes.  We could get fancier and allow units configuration but
this fix should do for now.

Fixes rhbz561422.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-14 03:21:06 +00:00
4697026132 Add 'fail_if_percent_unsupported' arg to _percent() and _percent_run(). 2010-02-10 15:56:20 +00:00
6c39b8f4f0 Add 'fail_if_percent_unsupported' arg to _percent() and _percent_run().
We unfortunately don't yet _know_, in dev_manager_snapshot_percent(), if
a snapshot-merge target is active (activation is deferred if dev is
open); so we can't short-circuit origin devices based purely on existing
LVM LV attributes.

Set 'fail_if_percent_unsupported' in dev_manager_snapshot_percent() for
a merging origin LV, otherwise passing unsupported LV types to _percent
will lead to a default successful return with percent_range as
PERCENT_100.

For a merging origin, PERCENT_100 will result in a polldaemon that runs
infinitely (because completion is PERCENT_0).
2010-02-10 14:38:24 +00:00
4a9af35527 Remove false "failed to find tree node for <lv>" error from _cached_info().
When activating a merging origin it is valid, and expected, to not have
a node in the deptree for both the origin and its merging snapshot.  The
_cached_info() caller is only concerned with whether a device is open.
If there isn't a node in the tree the associated device is definitely
not open.
2010-02-08 23:28:06 +00:00
881056af0b Make lvconvert --repair --use-policies exit with success when no action is needed. 2010-02-06 07:44:16 +00:00
e5df490d5e Add multiple snapshot lv 'lvconvert --merge @tag' support via process_each_lv(). 2010-02-05 22:50:56 +00:00
7c0d6057c5 Switch lvconvert_single() over to using get_vg_lock_and_logical_volume()
This change was deferred to help ease the review of previous refactoring
related to using process_each_lv() for lvconvert's merge support.  Not
that doing so _really_ helped but...

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-05 22:47:22 +00:00
3e5a54a791 lvconvert --merge @tag support
Switch lvconvert's --merge code over to using process_each_lv().  Doing
so adds support for a single 'lvconvert --merge' to start merging
multiple LVs (which includes @tag expansion).

Add 'lvconvert --merge @tag' testing to test/t-snapshot-merge.sh

Adjust man/lvconvert.8.in to reflect these expanded capabilities.

The lvconvert.c implementation requires rereading the VG each iteration
of process_each_lv().  Otherwise a stale VG instance associated with
the LV passed to lvconvert_single_merge() would result in stale VG
metadata being written back out to disk.  This overwrote new metadata
that was written when a previous snapshot LV finished merging (via
lvconvert_poll).  This is only an issue when merging multiple LVs that
share the same VG (a single VG is typical for most LVM configurations on
system disks).

In the end this new support is very useful for performing a "system
rollback" that requires multiple snapshot LVs be merged to their
respective origin LV.

The yum-utils 'fs-snapshot' plugin tags all snapshot LVs that it creates
with a common 'snapshot_tag' that is unique to the yum transaction.
Rolling back a yum transaction, that created LVM snapshots with the tag
'yum_20100129133223', is as simple as:
  lvconvert --merge @yum_20100129133223

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-05 22:44:37 +00:00
dbfd6e0d12 Prepare for _get_lvconvert_vg() reuse as part of a larger lvconvert.c
refactoring.

Document the need to cleanup the "name" args passed around polldaemon,
lvconvert and pvmove.  It is quite a mess.

Annotate the unused nature of the existing poll_fns->get_copy_vg
methods' 'uuid' arg.
2010-02-05 22:40:49 +00:00
f607a0a0a6 Adding a new mimage (leg/copy) to a mirror behaves differently
depending on if the mirror has a 'core' or 'disk' log.  When there
is a disk log, the new leg is added by stacking a new mirror on
top of the old (one leg is the old mirror and the other leg is the newly
added device).  When the log is a 'core' log, the new leg is simply added
to the existing mirror and all the devices are re-synced.

The logic that handles collapsing the stacked 'disk' log mirror was
having the effect of causing 'core' logged mirrors to begin resync'ing
for a second time.  I have used the 'CONVERTING' flag to indicate that
a mirror is converting by way of stacking.  This is no longer set for
up-converting core logs.  The final 'collapse' logic can safely be skipped
for 'core' log mirrors - getting rid of the second resync.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-02-05 21:49:16 +00:00
b15ada28ed This is related to liblvm and its lvm_list_vg_names() and lvm_list_vg_uuids() functions
where we should not expose internal VG names/uuids (the ones with "#" prefix )through the
interface. Otherwise, we could end up with library users opening internal VGs which will
initiate locking mechanism that won't be cleaned up properly.

"#orphans_{lvm1, lvm2, pool}" names are treated in a special way, they are truncated first
to "orphans" and this is used as a part of the lock name then (e.g. while calling lvm_vg_open()).
When library user calls lvm_vg_close(), the original name "orphans_{lvm1, lvm2, pool}"
is used directly and therefore no unlock occurs.

We should exclude internal VG names and uuids in the lists provided by lvmcache:
lvmcache_get_vgids() and lvmcache_get_vgnames().
2010-02-03 14:08:39 +00:00
6610f9bdbc Add %ORIGIN support to lv{create,extend,reduce,resize} --extents option
Allow the number of logical extents to be expressed (for a snapshot) as
a percentage of the total space in the Origin Logical Volume with the
suffix %ORIGIN.

Update the relevant man pages accordingly.  Eliminate inconsistencies
between the man pages and tools/commands.h

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-03 03:58:08 +00:00
5f87626377 move WHATS_NEW entries whose changes were made after 2.02.60 to 2.02.61 2010-02-02 17:48:30 +00:00
54834a1761 Add copy constructor for struct metadata_area.
Clean up cut&paste code with proper copy constructor.
2010-02-02 16:26:34 +00:00
adf7081163 Remove pointless versioned symlinks to dmeventd plugin libraries. 2010-02-02 14:09:17 +00:00
a50b7c55d3 Fix dmeventd snapshot plugin build dependency. 2010-02-02 14:03:50 +00:00
f4f171e04d Make clvmd -V return zero status rather than 1. 2010-02-02 08:54:29 +00:00
d5ea20a6eb Remove unnecessary "dmsetup resume" after "dmsetup create".
It is not necessary to resume after a create since the create will
create the table and make it active.
2010-02-01 19:43:22 +00:00
5584f2ae46 Was using dm_list_iterate_items when I should have been using
*_safe.  This had the effect of segfaulting the log daemon when
converting a mirror from one log type to another.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-27 22:28:05 +00:00
b79d8b1ff0 Fix pvmove abort when temporary mirror fails to be cluster-aware.
When activation of pvmove mirror fails on cluster, some nodes
still possibly succeeded in activation.

 - Explicitly deactivate that mirror to be sure
 - properly pair suspend/resume calls to not cause memory lock problems in clvmd

Code cannot simply call _finish_pvmove on cluster in this situation, because
changed LVs are suspended twice (causing memory inbalance) and also temporary
mirror is activated when it is not expected (and we know that it failed already).

Patch prepares special function which remove temporary mirror references from
metadata and then resumes changed LVs.
2010-01-27 13:29:11 +00:00
1c33c0027f Always query device by using uuid only and not name in clvmd.
Otherwise confusion with the device of the same name
(but different UUID, e.g. non-lvm device) can happen.
2010-01-27 13:23:57 +00:00
aef0a98840 Add some missing vg_revrts calls when pvmove aborts. 2010-01-26 08:01:18 +00:00
9d23a04c0e Unlock shared lock if activation calls failed.
Clvmd should unlock new lock if activation in device-mapper fails.
2010-01-26 08:00:02 +00:00
453bab220b Fix return code of info callbacks.
In dev_manager_info 0 means error and 1 info is returned,
not that device exists (that value is part of info struct).

Fix query by uuid only (no name) which returns 0 when device
does not exist.
2010-01-26 07:58:23 +00:00
448f8c4240 pre-release 2010-01-23 02:14:30 +00:00
5a414c6ad1 Default to checking LV's progress before waiting in _wait_for_single_lv.
Support "wait before testing" using '+' in pvmove and lvconvert
interval.  Doing so overrides the new default of sleeping after checking
the LV's progress.

Sleeping before checking progress can lead to extraneous polldaemons
being left running.  These polldaemons would have otherwise exited had
they checked before sleeping.  Checking progress before sleeping helps
workaround the subtly unreliable nature of "finished" state checking
in _percent_run.

Update test/t-mirror-names.sh to use '+' when providing its lvconvert
interval.
2010-01-22 21:59:42 +00:00
65a942f01f a little more information for the cmirrord man page 2010-01-22 21:48:17 +00:00
6df32fed62 Fix syntax error in cmirror init script
- break cannot be used here
 - remove CLVMDOPTS
 - add echo to stop call
2010-01-22 16:19:38 +00:00
1199b48cd7 Eliminate extra ioctls just to check open_count in _add_new_lv_to_dtree.
DM >= 4.7.0 always returns open_count so just use the associated nodes'
existing info.

Introduce _cached_info() to get an LV's cached info.
2010-01-22 15:40:31 +00:00
c493f56e1b Document undocumented commits which fixed some bugs.
Go WHATS_NEW!
2010-01-22 14:33:33 +00:00
2e65b8ce5f Removed inactive_table check from _lv_has_target_type. This check
doesn't offer any benefit (that I can recall) and testing validates
that.
2010-01-22 13:28:54 +00:00
42a6d954d3 Switch memory debugging off for now if compiled with dmeventd,
functions are not thread-safe in debug mode.
2010-01-22 13:20:32 +00:00
8f73b4c3ae Fix syslog prefix in the first message (dmeventd->lvm). 2010-01-22 12:48:58 +00:00
adcd06fccb Fix exported symbols for lvm2 dmeventd wrapper. 2010-01-22 12:38:16 +00:00
c40380f72a Move error message to locking constructor and print
more descriptive message if locking fails instead of
"Locking type -1 initialisation failed."

Use read-only locking instead of misleading ignorelocking option
in message.
2010-01-22 09:45:29 +00:00
8e44e884a2 post-release 2010-01-22 01:09:09 +00:00
e2368be912 missing header 2010-01-22 00:43:28 +00:00
7986fd4db7 fix lib include 2010-01-22 00:18:37 +00:00
6107f4a02a pre-release 2010-01-21 23:55:17 +00:00
2ce63814e9 Add libdevmapper-event-lvm2.so to serialise dmeventd plugin liblvm2cmd use. 2010-01-21 22:15:45 +00:00
8ba508f8f7 Call _alloc_pv() inside _pv_read() and clean up error paths.
We should be consistent with pv constructors so call _alloc_pv()
here as we do from pv_create().
2010-01-21 21:09:23 +00:00
2100490424 Remove useless memory allocation for pv->vg_name in _alloc_pv().
All this seems to do is provide a memory leak so remove it.
The only caller of _alloc_pv() later explicitly sets
pv->vg_name = fmt->orphan_vg_name so clearly this allocation
should be removed.  I also saw no where in the code where
strncpy was used to assign pv->vg_name - only direct assignments
and strdup's.
2010-01-21 21:04:44 +00:00
7e7639e39a Correct 'void *' usage in pvcreate_single.
Remove needless cast.
2010-01-21 21:04:20 +00:00
3555d0ecd5 Log entry for the last lvmcmdline.c commit 2010-01-21 17:14:18 +00:00
ecb9a01cfa Reset released pointer and counters.
DSO is currently not dl_close-ing pluing during it is unregister handling,
so clear structure and related counter, so there are no memory problems.
Futher fixes are needed.
2010-01-21 13:41:39 +00:00
ca352ebfba Preload the origin prior to suspend IFF snapshot(s) still exist after a
merge completes.  This narrows the scope of this "hack" (which still
needs a proper fix within the deptree).

This stops dmeventd from trying to access snapshot devices that were
already removed.
2010-01-20 21:53:10 +00:00
29c73eb67b Fill in a little more on the man page for cmirrord 2010-01-20 15:17:25 +00:00
2a598ff24d Deal with a few more compiler warnings. 2010-01-20 02:43:19 +00:00
f6d5837e5e Add t-topology-support.sh and t-snapshot-merge.sh tests. 2010-01-19 23:02:04 +00:00
dac8cee72c add test/t-snapshot-merge.sh to provide coverage of snapshot-merge support 2010-01-19 22:55:00 +00:00
e01a2f8324 Remove mknod() and add FIXMEs.
In the udev-world, this function should work differently.
2010-01-19 18:21:03 +00:00
a092ccb82b remove more compiler warnings
add FIXMEs for incomplete write()s
2010-01-19 17:24:29 +00:00
e894d07b92 test/t-topology-support.sh requires scsi_debug from >= 2.6.31 2010-01-19 17:06:50 +00:00
befef6eb00 remove no-longer-used header 2010-01-19 17:04:05 +00:00
162224979d remove no-longer-used files 2010-01-19 17:01:17 +00:00
a90f6e2dda Add a common way to establish a scsi_debug-based 4K drive for use by an
LVM2 test (rather than using the traditional loop device).

prepare_scsi_debug_dev currently assumes exclussive access to the
scsi_debug module.  Any script that tries to use prepare_scsi_debug_dev
when scsi_debug is unavailable or already loaded into the kernel will be
skipped.

t-topology-support.sh shows how prepare_scsi_debug_dev function can be
used repeatedly (within a script) to test LVM2 ontop of a ramdisk-based
SCSI device w/ arbitrary scsi_debug features.
2010-01-19 16:44:57 +00:00
e449bfd741 update test/t-pvcreate-operation-md.sh attempt loading raid0.ko if raid0
isn't already available (in /proc/mdstat).

switch to requiring 2.6.33 for the alignment_offset tests; 2.6.{31,32}
alignment_offset values aren't reliable.  2.6.33 _should_ have mkp's
alignment_offset fixes but so far it doesn't (as of 2.6.33-rc4).
2010-01-19 15:59:34 +00:00
8ecc1eb99d Signal handling FIXMEs.
A few integer type changes.
2010-01-19 15:58:45 +00:00
1fb910411e Never scan suspended devices in clvmd.
For mirror repair (and similar tasks) it can happen that full
device rescan is issued from clvmd.

Because code can be in the middle of repair (calling suspend)
clvmd should never try to scan suspended devices
(otherwise it causes deadlock).

Also code must not change ignore_suspended_device flag when
doing refresh_filters (called from lvmcache scan code).
2010-01-19 13:25:00 +00:00
3141b86d01 And more fixes for cmirror build. 2010-01-19 02:04:33 +00:00
f8ff64c87e more build fixes 2010-01-19 01:10:46 +00:00
c71b834aad Clean up include files. 2010-01-18 21:07:24 +00:00
a78e7d0287 Fix some compiler warnings. 2010-01-18 20:58:50 +00:00
09cf0fe6b9 Misc compilation clean-ups. 2010-01-18 20:08:44 +00:00
13713bc147 Change dev_manager_mirror_percent()'s 'struct logical_volume *' to be
'const'.  Be consistent with its use (and dev_manager_snapshot_percent()).

Pass 'lv' from dev_manager_snapshot_percent() to _percent() to
_percent_run().  _percent_run() always dereferenced 'lv' (when
initializing segh) even though it may have been NULL (as was the case
until now for dev_manager_snapshot_percent()).

If a "snapshot-origin" LV (snapshot-merge whose merge was deferred
becuase it was open) was passed to _percent_run() it would always return
100%.

Update _percent_run() to NOT return PERCENT_100 et. al. if
->target_percent() wasn't ever called and supplied 'lv' is a merging
origin.  A default return of 100% does not work for snapshot-merge.

Also tweak a related lvconvert log_error() to include "Aborting merge."
2010-01-15 22:58:25 +00:00
9c17cf4edf Use tabs, not spaces. 2010-01-15 21:48:03 +00:00
938b25b986 Initial version of the cmirrord init script
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 20:47:52 +00:00
040b76f1e6 initial cmirrord man page
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 20:24:04 +00:00
66226207ce Make the intermachine communication structures architecture independant
to allow for mixed architecture clusters.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 19:49:35 +00:00
999b4168c1 When moving the cluster log server into the LVM tree, the in memory
bitmap tracking was switched from the e2fsprogs implementation to
the device-mapper implementation (dm_bitset_t).  The latter has a
leading uin32_t field designed to hold the number of bits that are
being tracked.  The code was not properly handling this change in
all places.  Specifically, when getting the bitmap to/from disk.

Endian adjustments will likely need to be made on the accounting
field as well, since bitmaps are passed between machines on
start-up.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 18:48:24 +00:00
9bfc452487 Detect case of both merging_store and cow_store supplied in
_snap_text_import().
2010-01-15 17:46:08 +00:00
df675ed9fb Improve target type compatibility checking in _percent_run().
Add 'target_status_compatible' method to 'struct segtype_handler'.
2010-01-15 16:35:26 +00:00
4a13ae4c95 udpate WHATS_NEW* 2010-01-15 16:18:14 +00:00
5287c71d68 At some point "clustered_[core|disk]" was changed to "clustered-[core|disk]".
This patch makes the log server recognise the new format.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 16:03:19 +00:00
827f1a3d30 Off-by-one count was causing not all the mirror table parameters
that were necessary to be passed on to userspace.

The cluster mirror table (log portion only) used to look like this:
        clustered-disk <parm_count> <disk> <region_size> <uuid> \
                        [[no]sync] [block_on_error]
Now it looks like this:
        userspace <parm_count> <uuid> clustered-disk <disk> <region_size> \
                        [[no]sync]

So, there is one extra argument in the latter case - this was
unaccounted for.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-15 16:00:23 +00:00
f6d95e19c4 post-release 2010-01-14 14:42:06 +00:00
3eb93f161f Note some problems still to be addressed. 2010-01-14 14:39:57 +00:00
801eff0c52 pre-release 2010-01-14 14:02:34 +00:00
c1993e76c2 Update entry for few previous gcc cleanup commits. 2010-01-14 10:19:43 +00:00
c23f56b9cb Cleanup const compiler warning 2010-01-14 10:17:12 +00:00
44e17e2aa9 Cleanup gcc warning: cast discards qualifiers from pointer target type
API of the library should remain the same as the 'const' is not
mangled into the function name in C.
2010-01-14 10:15:23 +00:00
84758667c1 Cleanup gcc warning: cast from function call of type 'struct dm_list *'
to non-matching type 'long unsigned int'

Casting pointer to long and back to pointer could be easily
handled with just pointer arithmetic.
2010-01-14 10:12:44 +00:00
8c71113cd6 Cleanup gcc warning: null argument where non-null required (arg.2)
As the const declaration of execvp is a bit weird, using local
dmeventdpath string.
2010-01-14 10:11:26 +00:00
79ba99811c Move initialization of the 'cmd' member of the struct alloc_handle
before the first potentional return.
2010-01-14 10:09:42 +00:00
55a664d6fd lvol%d is generated for NULL name in lv_create_empty().
So just avoid code duplication.
2010-01-14 10:08:03 +00:00
b4affd607d update WHATS_NEW and WHATS_NEW_DM to include snapshot-merge changes 2010-01-13 21:48:39 +00:00
c7007c98d7 Fix clvmd automatic target module loading crash. 2010-01-13 17:40:17 +00:00
fa684a97da Rename segment and lv status flag from SNAPSHOT_MERGE to MERGING.
Eliminate 'merging_snapshot' from 'struct logical_volume' and just use
'snapshot' for origin lv's reference to the merging snapshot; also set
MERGING in the origin lv's status.
2010-01-13 01:56:18 +00:00
cad03afc54 Add snapshot merge wrappers to abstract the associations and flags used
to represent merging origin and snapshot volumes.
2010-01-13 01:55:43 +00:00
fe6d782751 Update lvconvert manpage for snapshot --merge 2010-01-13 01:55:05 +00:00
dfe517cfbe Merge on activate support.
If either the origin or snapshot that is to be merged is open the merge
will not start; only the merge metadata will be written.  The merge will
start on the next activation of the origin (or via lvchange --refresh)
IFF both the origin and snapshot are closed.

Merge on activate is particularly important if we want to merge over a
mounted filesystem that cannot be unmounted (until next boot) --- for
example root.
2010-01-13 01:54:34 +00:00
46ab95f24c When turning merging origin into non-merging origin, there is bad sequence:
snapshots are suspended, new origin is created, snapshots are resumed, new
origin is resumed.  So it allocates memory while suspended.

To fix it, move vg_commit after suspend_lv, so that the suspend code will
treat it as precommitted vg and will preload new origin prior to suspend.

NOTE: agk doesn't like this "hack"; need to revisit and fix
2010-01-13 01:52:58 +00:00
9a57ea4c4a Reload origin if merging has stopped. 2010-01-13 01:51:45 +00:00
5fc98ffa69 Start background polling of merging stores on:
- lvchange -ay or vgchange -ay.
- lvchange --refresh or vgchange --refresh.
2010-01-13 01:50:34 +00:00
814eb397e1 Background poll for lvconvert --merge command.
The merging snapshot is removed when the merge finishes.
2010-01-13 01:49:52 +00:00
77f030956c When there is merging snapshot, report percentage on the origin LV.
Because the snapshot LV will be hidden this is needed so the user can
see merging progress with "lvs" command.
2010-01-13 01:49:22 +00:00
ab7ad3451d Report merging snapshot as 'S' instead of 's':
This is useful for when the snapshot is still active and merging hasn't
started yet; it shows a merge is pending.  Once merging starts the
merging snapshot will be hidden but can still be displayed with 'lvs -a'

Report snapshot origin with merging snapshot as 'O' instead of 'o':
Before merge starts this shows that a merge is pending.  While merging
the snapshot will be hidden, 'O' enables a user to see that there is a
snapshot merging.
2010-01-13 01:48:38 +00:00
1107f82824 Do not allow merging over mounted logical volumes.
When preserving origin, check that the snapshot is not mounted.
2010-01-13 01:47:18 +00:00
2bc2378033 Add --merge support to lvconvert to start merging a snapshot into its
origin, example usage:  lvconvert --merge vg/snaplv
2010-01-13 01:45:15 +00:00
676e214f34 Merging device is loaded with "-cow" suffix and with base name of the
origin.  This is needed so that "-cow" device can be found and removed
when lvremove is performed.
2010-01-13 01:44:37 +00:00
7df1ccbf91 Conditionally push down either the "snapshot-origin" or
"snapshot-merge" target based on whether the LV is a merging snapshot.

When activating a snapshot-merge target do not attempt to monitor the
LV for events; the polldaemon will monitor the snapshot as it is
merged.

Allow "snapshot-merge" target's usage to be parsed via standard
"snapshot" methods.

NOTE: follow on fixes to the _percent_run change are still needed
2010-01-13 01:43:32 +00:00
82d3ee5454 Add support for "snapshot-merge" target.
Introduces new libdevmapper function dm_tree_node_add_snapshot_merge_target

Verifies that the kernel (dm-snapshot) provides the 'snapshot-merge'
target.

Activate origin LV as snapshot-merge target.  Using snapshot-origin
target would be pointless because the origin contains volatile data
while a merge is in progress.

Because snapshot-merge target is activated in place of the
snapshot-origin target it must be resumed after all other snapshots
(just like snapshot-origin does) --- otherwise small window for data
corruption would exist.

Ideally the merging snapshot would not be activated at all but if it is
to be activated (because snapshot was already active) it _must_ be done
after the snapshot-merge.  This insures that DM's snapshot-merge target
will perform exception handover in the proper order (new->resume before
old->resume).  DM's snapshot-merge does support handover if the reverse
sequence is used (old->resume before new->resume) but DM will fail to
resume the old snapshot; leaving it suspended.

To insure the proper activation sequence dm_tree_activate_children() was
updated to accommodate an additional 'activation_priority' level.  All
regular snapshots are 0, snapshot-merge is 1, and merging snapshot is 2.
2010-01-13 01:39:44 +00:00
fcb6fb00e0 Add 'SNAPSHOT_MERGE' lv_segment 'status' flag.
Make 'merging_snapshot' pointer that points from the origin to the
segment that represents the merging snapshot.

Import/export 'merging_store' metadata.

Do not allow creating snapshots while another snapshot is merging.
Snapshot created in this state would certainly contain invalid data.

NOTE: patches at the end of this series will remove 'merging_snapshot'
and will introduce helpful wrappers and cleanups.
2010-01-13 01:35:49 +00:00
4e09e6ca10 Fix allocation code not to stop at the first area of a PV that fits.
This spurious 'break' has been here since this code was first committed
in June 2005 and stopped the algorithm behaving as described in the
comment above it and rendered the variable 'already_found_one' useless.
2010-01-12 20:53:20 +00:00
af6dd44048 post-release 2010-01-12 14:46:59 +00:00
d30ec9fd1e pre-release 2010-01-12 14:39:07 +00:00
16ee54ad23 disable 'redundant' tests 2010-01-12 14:19:46 +00:00
627409ec38 Revert so-called "redundant" log until after next release. 2010-01-12 14:00:51 +00:00
4ead572462 . 2010-01-11 21:44:36 +00:00
42783a54db Add missing items to WHATS_NEW files.
Continue to use 'field' to describe reporting elements.
2010-01-11 21:28:04 +00:00
84763527c5 Add new test cases for mirrors that are under snapshots. 2010-01-11 21:27:49 +00:00
1744c1c2ba Testsuite updates and fixes for recently added features.
1. Found bug in 'redundant log' implementation that caused
   problems when converting a linear that spanned multiple
   devices to a mirror (wasn't checking for NULL value of
   provided parameter in _alloc_parallel_area)

2. Testsuite was failing to perform tests when 'not' modifier
   was used.  This allowed a couple issues to slip through.
   Added a 'not_sh' modifier that negates tests performed by
   functions defined in the shell source file.

3. Was initializing a variable to far down, which cause
   previously set value to be overridden.  (This was the
   result of the collision of the "redundant log" and
   lvconvert fix patches.)
2010-01-11 21:20:19 +00:00
7ef5fbdbe6 Use _LOG_FATAL when aborting on an internal error. 2010-01-11 20:41:39 +00:00
b1482c52b7 Internal errors triggering abort cannot be suppressed. (kabi) 2010-01-11 20:30:32 +00:00
7b0d61b96d Only allow one return from poll_daemon(). If a child polldaemon was
successfully created it must _exit() once it completes.

Update _become_daemon() to differentiate between a failed fork() and a
successful fork().

Added lvm_return_code() to lvmcmdline.[ch]
2010-01-11 19:19:17 +00:00
951b974c4d remove errant comment fragment 2010-01-11 19:12:25 +00:00
975b3c3428 Reset _vgs_locked in lvmcache_init()
Upon successful fork(), _become_daemon() must assert that the locks that
are currently held belong to the parent, not the child.  All of the
child's internal state saying 'this process holds a lock' has to be
reset.

A proper lvmcache_locking_reset() should follow later.
2010-01-11 19:08:18 +00:00
f0420012e6 Found 2 problems with my previous check-in:
date: 2010/01/07 20:42:55;  author: jbrassow;  state: Exp;  lines: +11 -0
 The patch fixes some lvconvert issues (WRT mirror <-> mirror).

1) 'exisiting_mirrors' and 'lp->mirrors' where taken to be in 'n-1'
   notation (i.e a 2-way mirror is '1' and a linear is '0'), but the
   variables were in 'n' notation.
2) After adding the redundant mirror log support, I was calculating
   log_count by looking at the mirror log LV, but didn't take into
   account the fact that there could be no mirror log!

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-11 17:13:45 +00:00
30e5413e2b Substitute UDEV_SYNC value for use in the other files and show a warning message when libudev not found and using udev_sync. 2010-01-11 15:59:54 +00:00
5077a1bb83 Show a warning message when libudev not found and we're using --enable-udev_sync.
Just to emphasize what one can expect - we won't be able to get udev state
and we will consider that udev is not running at all.
2010-01-11 15:51:44 +00:00
a8ed16de33 Define {DM, LVM}_UDEV_DISABLE_CHECKING=1 env. variables for tests.
We need to disable udev checking for our tests since they use their own
location for device nodes and symlinks.
2010-01-11 15:48:49 +00:00
ee0a4914d5 Enable udev_sync and udev_rules in lvm.conf by default while running tests. 2010-01-11 15:43:19 +00:00
8b70a0d0b7 Add support to disable udev checking: LVM_UDEV_DISABLE_CHECKING=1 env. var.
LVM_UDEV_DISABLE_CHECKING=1 applies for /dev/<vgname> content only.
We still need to define DM_UDEV_DISABLE_CHECKING=1 for /dev/mapper content.
2010-01-11 15:40:03 +00:00
8e7c6b60fb Add support to disable udev checking: DM_UDEV_DISABLE_CHECKING=1 env. variable.
Sometimes it is really needed to switch off udev checking and the warnings we show when
we detect that udev has not done its job right - the messages like "Udev should have done
this and that. Falling back to direct node creation/removal. " etc.

This would be especially handy while setting DM_DEV_DIR env var that could be set to a
different location than standard /dev (udev can't create nodes/symlinks out of that one
directory that is configured into udevd). The exact same situation happens while we're
running our tests.
2010-01-11 15:36:24 +00:00
fbb0bb63e7 remove unused variable 'i' that was recently introduced in lv_add_segment 2010-01-10 20:44:09 +00:00
46dc1b6e99 update comment 2010-01-08 23:06:36 +00:00
82b34e06f2 Add the new mirror log type "redundant". The options are now:
--mirrorlog core: in-memory log
--mirrorlog disk: persistent log
--mirrorlog redundant: redundant persistent log

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-08 22:32:35 +00:00
bc178df8f0 udpate WHATS_NEW file for --splitmirror checkin 2010-01-08 22:28:54 +00:00
d5a3de5a97 This patch adds the capability to split off a mirror legs.
It is pretty much the same as reducing the number of
mirror legs, but we just don't delete them afterwards.

The following command line interface is enforced:
  prompt> lvconvert --splitmirror <n> -n <name> <VG>/<LV>
where 'n' is the number of images to split off, and
where 'name' is the name of the newly split off logical volume.

If more than one leg is split off, a new mirror will be the
result.  The newly split off mirror will have a 'core' log.
Example:
[root@bp-01 LVM2]# !lvs
lvs -a -o name,copy_percent,devices
  LV            Copy%  Devices
  lv            100.00 lv_mimage_0(0),lv_mimage_1(0),lv_mimage_2(0),lv_mimage_3(0)
  [lv_mimage_0]        /dev/sdb1(0)
  [lv_mimage_1]        /dev/sdc1(0)
  [lv_mimage_2]        /dev/sdd1(0)
  [lv_mimage_3]        /dev/sde1(0)
  [lv_mlog]            /dev/sdi1(0)
[root@bp-01 LVM2]# lvconvert --splitmirrors 2 --name split vg/lv /dev/sd[ce]1
  Logical volume lv converted.
[root@bp-01 LVM2]# !lvs
lvs -a -o name,copy_percent,devices
  LV               Copy%  Devices
  lv               100.00 lv_mimage_0(0),lv_mimage_2(0)
  [lv_mimage_0]           /dev/sdb1(0)
  [lv_mimage_2]           /dev/sdd1(0)
  [lv_mlog]               /dev/sdi1(0)
  split            100.00 split_mimage_0(0),split_mimage_1(0)
  [split_mimage_0]        /dev/sde1(0)
  [split_mimage_1]        /dev/sdc1(0)

It can be seen that '--splitmirror <n>' is exactly the same
as '--mirrors -<n>' (note the minus sign), except there is the
additional notion to keep the image being detached from the
mirror instead of just throwing it away.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-08 22:00:31 +00:00
b8774d7aac Change background polldaemon's process name to "(lvm2)".
Made .update_metadata optional in 'struct poll_functions' definitions;
eliminated _update_lvconvert_mirror() stub.

Tweak a mirror-specific error message in the generic polldaemon code.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-08 21:53:07 +00:00
891246562f Allow vgremove of a VG with PVs missing. 2010-01-08 14:03:54 +00:00
e53a955115 In lvconvert --repair --use-policies, for the allocate policies, return success
even if allocation fails, as long as the downconversion or corelog conversion
succeeded.
2010-01-08 13:04:10 +00:00
1ec6812246 orig_status preserves 64bit status. 2010-01-08 10:50:11 +00:00
e896691b0f - forgot to update WHATS_NEW along with bug fix for keeping
log type consistent when using lvconvert to change the
  number of mirror images.
2010-01-07 20:55:01 +00:00
fbe92a13c0 The patch fixes some lvconvert issues (WRT mirror <-> mirror).
The default log option for a mirror is 'disk'.  If the log
type is not explicitly stated on the command line when
converting from an X-way mirror to a Y-way mirror, 'disk'
is chosen.  So, if you have a 'core' log mirror and you
convert, your result will contain a 'disk' log.

This patch remembers what the old log type was.  If the
user is merely trying to switch the number of mirror
images, the log type is now kept the same.

There is one historical behaviour I left in place...
If you have a 2-way, core-log mirror and you use lvconvert to
specify you want a 2-way mirror - without specifying the
log type - you will get a 2-way, disk-log mirror.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Informal-IRC-ACK-by: agk
2010-01-07 20:42:55 +00:00
94a434e9e7 Always set environment variables for an LVM2 device in 11-dm-lvm.rules.
This way we can still use DM_LV_NAME, DM_VG_NAME and DM_LV_LAYER in all
the other rules.
2010-01-07 20:01:55 +00:00
e829c626da Add activation/udev_rules config option in lvm.conf.
Add dm_tree_add_dev_with_udev_flags to provide wider support for udev flags.
2010-01-07 19:54:21 +00:00
837adeea7f Add --noudevrules option for dmsetup to disable /dev node management by udev. 2010-01-07 19:45:12 +00:00
65d6350d36 Add few const modifiers. 2010-01-07 14:47:57 +00:00
ba99186951 Use macro outsize() with check for error return value. 2010-01-07 14:46:51 +00:00
b3975f5098 Export function out_text_with_comment() and add outfc() macro that checks
for error.
2010-01-07 14:45:28 +00:00
b90f909289 Add macros outsize() for out_size() and outhint() for out_hint() that check
for errors in a similar way as outf() for out_text().
2010-01-07 14:40:46 +00:00
d098e4def6 Use offsetof() macro and avoid defining dummy static union for FIELD() macro.
Makes it compilable by clang compiler.
2010-01-07 14:37:11 +00:00
835b0d9f62 Error message prints unrecognized key. 2010-01-07 14:32:44 +00:00
9fea2798e3 Show all fields for 'dmsetup info -c -o all'. 2010-01-07 14:30:47 +00:00
394cae5d21 Just add '.' at the end of error message. 2010-01-07 14:29:53 +00:00
7996aae5e9 Fix typo fsdam -> fsadm (closes bug 552721) 2010-01-07 09:42:51 +00:00
9788b9d7a9 . update documentation for --poll in the vgchange and lvchange man pages
. add high-level --poll FIXMEs to vgchange.c and lvchange.c
2010-01-06 19:08:58 +00:00
6f5e1c3d73 Rename mirror_device_fault_policy to mirror_image_fault policy 2010-01-06 13:27:06 +00:00
d4421b12ba Remove empty "repaired" devices if empty in lvconvert.
The logic was that lvconvert repair volumes, marking
PV as MISSING and following vgreduce --removemissing
removes these missing devices.

Previously dmeventd mirror DSO removed all LV and PV
from VG by simply relying on
vgreduce --removemissing --force.

Now, there are two subsequent calls:
lvconvert --repair --use-policies
vgreduce --removemissing

So the VG is locked twice, opening space for all races
between other running lvm processes. If the PV reappears
with old metadata on it (so the winner performs autorepair,
if locking VG for update) the situation is even worse.


Patch simply adds removemissing PV functionality into
lvconcert BUT ONLY if running with --repair and --use-policies
and removing only these empty missing PVs which are
involved in repair.
(This combination is expected to run only from dmeventd.)
2010-01-06 13:26:21 +00:00
099b03f038 Use fixed buffer to prevent stack overflow in persistent filter dump. 2010-01-06 13:25:36 +00:00
f84d2eeec9 update WHATS_NEW and WHATS_NEW_DM with previous commits' changes 2010-01-05 21:32:59 +00:00
f02531802c Use snapshot metadata usage to determine if snapshot is empty
Version >= 1.8.0 of the DM snapshot target appends metadata sectors used
to a snapshot's status.  This patch allows LVM2 to accurately determine
if the snapshot store is empty.  Knowing when a snapshot store is empty
is important in the context of snapshot-merge (means merge is complete).

Also update LVM2 to be aware of the possibility for "Merge failed" in
the snapshot-merge target's status.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:14:04 +00:00
375cb5c31d Add missing 'stack;' for all activate_lv and deactivate_lv callers.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:08:34 +00:00
8f2ba4ec3c Add missing 'stack;' for all suspend_lv and resume_lv callers.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:07:31 +00:00
9935d1183a Return error to dm_tree_deactivate_children() callers.
Otherwise deactivate_lv can fail silently.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:06:26 +00:00
aff8e77bec Return error to dm_tree_suspend_children() callers.
Otherwise suspend_lv and its variants can fail silently.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:05:40 +00:00
c9fd743c65 Return error to dm_tree_preload_children() and
dm_tree_activate_children() callers.

Otherwise resume_lv and its variants can fail silently.

Catching these failures is especially important now that dm targets like
crypt and snapshot-merge can fail in .preresume

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:04:37 +00:00
7a4fa925fc Add a [--poll {y|n}] flag to vgchange and lvchange to control whether
the background polldaemon is allowed to start.  It can be used
standalone or in conjunction with --refresh or --available y.

Control over when the background polldaemon starts will be particularly
important for snapshot-merge of a root filesystem.

Dracut will be updated to activate all LVs with: --poll n

The lvm2-monitor initscript will start polling with: --poll y

NOTE: Because we currently have no way of knowing if a background
polldaemon is active for a given LV the following limitations exist and
have been deemed acceptable:
1) it is not possible to stop an active polldaemon; so the lvm2-monitor
   initscript doesn't stop running polldaemon(s)
2) redundant polldaemon instances will be started for all specified LVs
   if vgchange or lvchange are repeatedly used with '--poll y'

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 20:56:51 +00:00
ff442c1e28 Propagate commit and revert metadata event to other nodes in cluster.
This patch tries to correctly track changes in lvmcache related to commit/revert.

For vg_commit: if there is cached precommitted metadata, after successfull commit
these metadata must be tracked as committed.

For vg_revert: remote nodes must drop precommitted metadata and its flag in lvmcache.

(N.B. Patch do not touch LV locks here in any way.)

All this machinery is needed to properly solve remote node cache invalidaton which
cause several problems recently observed.
2010-01-05 16:09:33 +00:00
5cedaa972a Proper mask lock mode for vg lock.
Lock mode is int masked by LCK_TYPE_MASK, always.

Patch also remove uneccessary masking lock flag on sender side,
if masking is needed, it is don on client side already.
2010-01-05 16:07:56 +00:00
2c8f647e0c Add possibility to handle precommitted metadata in lvmcache.
- Add drop_precommitted flag to force drop precommitted metadata
 - add lvmcache_commit_metadata() which upgrades precommitted metadata in cache

No functional change in this patch - just preparation for following change.
2010-01-05 16:06:42 +00:00
3be5edae0e Move processing of VG locks to separate function (similar to LV locks).
And print some debugging info.

No functional change in this patch.
2010-01-05 16:05:12 +00:00
1078f24d5a Properly decode flags even for VG locks.
And decode flags in humar readable form in client.
And clean some trailing whitespaces.

No functional change in this patch (only debugging messages changed).
2010-01-05 16:03:37 +00:00
c02cc5321a Do not set precommitted flag in cache when precommitted metadata does not exist.
The use_precommitted flag indicates, that we want to use precommitted metadata
(used in suspend call to preload table with precommitted data).

But if there are no such data, committed metadata are read but the cache
still contains that precommitted flag.

(The problem is that later possible drop_metadata call will not invalidate
device in cache.)

The wrong precommitted state is stored in on remote nodes during normal
suspend/resume cycle _without_ vg_write/commit.

Use the PRECOMMITTED status flag here instead (which is always set if using
precommited metadata here).
2010-01-05 16:01:22 +00:00
e60a7ff1d0 Resume volumes in reverse order to preserve memlock pairing.
If renaming snapshot with virtual origin, the origin is renamed too.
But the code must resume LVs in reverse order to properly
pair memlock (in cluster locking).

(The resume of snapshot resumes origin too and later resume
is ignored otherwise.)
2010-01-05 15:58:11 +00:00
91de7311d7 Fix previous vgcreate commit to not call unpaired unlock. 2009-12-28 18:34:45 +00:00
e357c9fc0c Explicitly use non-clustered vgcreate in test.
(So the tests can run under cluster locking and do not require
cluster mirror or snapshots.)

Add vgscan before block device readahead change
(flush long running process - clvmd - dev cache.)
2009-12-28 18:33:04 +00:00
ec4daa5936 Drop metadata cache after device was autorepaired and removed from VG.
All long running processes must reload metadata when some
device becomes orphan after repair.
2009-12-18 12:45:41 +00:00
2743fb9771 Remove missing flag if PV reappeared and is empty.
When PV device reappears with old metadata, it is
always updated to new version byt atutomatic metadata
repair.

Remove missing flag if device is empty.

If device contains allocated extents, issue warning that
user must remove volumes and re-add this PV before
manipulating with this volume.

This partially solves bug 547842 when one PV (log) is failed,
dmeventd removes that device and later this device reappears and
is wrongly added into VG marked missing.
2009-12-18 12:44:20 +00:00
88c4802bdc Revert another unintended change that snuck in. 2009-12-17 15:59:53 +00:00
a47e422715 Fix removal of multiple devices from a mirror (+ regression test). 2009-12-17 15:38:29 +00:00
3a9ab631e5 Also clean up MISSING devices in --removemissing --force in vgreduce. 2009-12-17 13:54:46 +00:00
9ca5118a68 Revert unintended change that slipped in with last checkin. 2009-12-16 19:26:20 +00:00
d6053080f8 #define an INTERNAL_ERROR macro and use it throughout LVM. 2009-12-16 19:22:11 +00:00
b1f8076da0 Cleanup returns for void functions. 2009-12-11 13:16:37 +00:00
abc760c8e4 Destroy allocated mempool in _vg_read_orphans() error path. 2009-12-11 13:14:44 +00:00
0331a34d58 Fix unlocking vg in some pvresize and toollib error paths. 2009-12-11 13:11:56 +00:00
98af0ba143 Fix coredump and memory leak for 'dmsetup help -c' 2009-12-11 13:04:30 +00:00
157810ea3d s/=/==/ Typo was causing sub test to always return success. 2009-12-10 22:06:15 +00:00
448e4251f8 Call explicitly suspend for temporary mirror layer.
The memlock_inc() fix is wrong, memlock count is not
propagated to long living process (clvmd) and just
it underflow there.
Also suspend is needed to pre-load precommited metadata
on other nodes (remapping to error taget in this case).

With explicit suspend we generate lock request and code
can update memlock count.

(Infinitely "locked" memory caused that fs_unlock() was not
called properly and on cluster nodes remains
old links in /dev/mapper for not active devices.)

(N.B. failing of suspend call here is not handled as fatal
error - the LV is going to be removed later anyway.)
2009-12-09 19:53:39 +00:00
81ce20d616 Use more descriptive variable name for temporary layer lv. 2009-12-09 19:43:39 +00:00
3e9ab41e76 Fix missing include. 2009-12-09 19:30:56 +00:00
a3c8fbc6b6 Allow manipulation with precommited metadata even when a PV is missing.
The new recovery code first tries to repair LV and then removes failed PV
from VG. It means that during operation there can be VG with PV missing,
and vg_read code handles it like not consistent VG.

We already allows returning "inconsistent" commited metadata,
for mirror repair we need this for precommited too.
(The suspend call prepares precommited metadata to inactive table on
other cluster nodes.)

"Inconsistent" here means - correct metadata, just with some metadata areas
not found (obviously on missing or failed PVs).
2009-12-09 19:29:04 +00:00
e9dc6880af Add memlock information to do_lock_lv debug output.
This helps a lot to detect that something strange happened.
2009-12-09 19:01:27 +00:00
25fb2c4fb6 Never ever use distributed lock for LV in non-clustered VG.
The LV locks make sense only for clustered LVs.

Properly check cluster flag and never issue cluster lock here.

There are several places in code, where it is already checked, this
patch add this check to all needed calls.

In previous code the lock behaviour was inconsistent,
for example, the pre/post callback can take lock even for local volume,
but deactivate call do not released this lock and it remains held forever.

The local LV lock request now just let run the underlying activation code
on local node, the same process like in local locking.

(Again, this is important for new mirror repair calls, here for local
mirrors but with cluster locking enabled.)
2009-12-09 19:00:16 +00:00
97d28ae4d7 Allow implicit lock conversion for pre/post callbacks.
This is unnoticed regression from commit 31672ff60e

The pre/post callback need to convert lock always, local node
is going to modify metadata in this case, it it fails conversion,
the call is ignored.

Also it fixes bug when the lock is not yet held, we cannot set LKF_CONVERT
in this case, it will fail because this lock do not exist.

Note that the automatic conversion is still disabled in activate
call, so the original fix (reactivation of exlusive LV) should
be still in place.
2009-12-09 18:55:53 +00:00
b5bad15dae Allow implicit "convert" to the same lock mode.
(Code already not fail if unlocking not locked resource.)

This is needed in pre/post lock_lv call, where we can
request the same lock on local node becuase of suspend call.
2009-12-09 18:45:12 +00:00
3098ef4a6e Get rid of magic masks in cluster locking code - clvmd part.
- do_command and lock_vg expect flags (no change here)

Bug fixes:
- lock_vg should check for NONBLOCK on lock_cmd, flags have this bit masked-out

- do_pre/post_command expect do not mask flag at all, this causes that
the code inside is never run! (see following patches, these functions
expect plain command without flags)
2009-12-09 18:42:02 +00:00
e354b1210e Get rid of magic masks in cluster locking code.
Patch should not cause any problems, only real change is
removing LCK_LOCAL bit from lock type flag, it is never used there.
(LCK_LOCAL is part arg[1] bits anyway.)
2009-12-09 18:28:27 +00:00
895b6ff719 Get rid of hardcoded 0xffdf cluster lock flag.
There is hidded change - the upper flags (0xffff0000)
and now not cleared, but there are unused anyway.
2009-12-09 18:16:38 +00:00
0a22655ff3 Remove newly created log volume if initial deactivation fails.
If there is problem deactivate LV and
_init_mirror_log is called with remove_on_failure = 1,
remove the newly created log LV from metadata.

(This can happen if there is active device with the same name
but different UUID.)

The main reason for this "workaround" patch is to
 - do not keep _mlog volume in metadata, so user can repeat the action
 - print better error message describing the real problem

# lvcreate -m 2 -n lv1 -l 1 --nosync vg_bar
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
  /dev/vg_bar/lv1_mlog: not found: device not cleared
  Aborting. Failed to wipe mirror log.
  Error locking on node bar-01: Input/output error
  Unable to deactivate mirror log LV. Manual intervention required.
  Failed to create mirror log.

# lvcreate -m 2 -n lv1 -l 1 --nosync vg_bar
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
  Aborting. Unable to deactivate mirror log.
  Failed to initialise mirror log.
2009-12-09 18:09:52 +00:00
8def378b5e Fix activated/deactivated log_verbose message
I see "Deactivated" message when I activate and "Activated" message when
I deactivate.  The code uses "activate" as boolean but it can be any one
of the enum values from CHANGE_AY, CHANGE_AN, CHANGE_AE, etc.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-12-07 19:32:28 +00:00
7ab8b44b6c Disable udev rules on change event with DISK_RO=1.
There's a new change udev event generated since kernel 2.6.32 that
notifies userspace about a change in read-only attribute for block
devices (with DISK_RO=1 environment variable set).

We need to detect this and disable the rule application so the
meaning of this change event is not interchanged with the regular
change event used while resuming/renaming DM devices.

If there's anybody awaiting this notification in foreign rules,
he can still check for this env var and do the appropriate actions
separately.
2009-12-07 12:03:47 +00:00
335fe09d70 Update a few more uint64_t's related to the 64-bit status change.
At this point they probably do not matter but going forward they
may - depends on future patches for replicator, etc.  I think
these probably got missed because they were 'flags' so I changed
the name to 'status' to be consistent.  So the on-disk
things 'flags' and the in structure 'status' (bits).
NOTE: WHATS_NEW already has entry for this in current release.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
2009-12-04 17:48:32 +00:00
523a7ed7d3 WHATS_NEW for previous commit. 2009-12-04 14:26:22 +00:00
f69e8e3606 Give better message for pvmove when all data on source PV is skipped. 2009-12-04 14:03:18 +00:00
3516797b49 Fix memory lock imbalance in lv_suspend if already suspended.
pvmove suspends all moved LVs + pvmoveX mirrored LV itself.

This suspends even underlying pvmoveX and following explicit
suspend call is just noop.

But in resume the pvmoveX volume is no longer underlying
device for moved LVs, so it performs full resume with memlock
decrease.

Code must call memlock_inc() if suspend is requested, volume
is already suspended and error is not requested.
2009-12-03 19:23:40 +00:00
1683e94f0c Fix pvmove test mode to not fail and do not poll.
Test mode should not fail nor try to poll non-existent devices.
2009-12-03 19:22:24 +00:00
1d249195a4 Print error if VG already exist.
This test have to be moved because of new vg read error handling.
2009-12-03 19:20:48 +00:00
2f7ee08288 Fix tools to report error when stopped by user.
(And do not produce internal error message.)
2009-12-03 19:18:33 +00:00
e0772fb301 minor indent change 2009-12-03 10:01:30 +00:00
78bdbce2fd skip cast from (void*) 2009-12-03 09:59:54 +00:00
5a5fed28fa minor whitespace indentation 2009-12-03 09:58:30 +00:00
5818b6efb8 Add tests to check for readahead value in lvcreate. 2009-12-03 01:48:05 +00:00
53a66492e8 Fix setting of readahead in lvcreate.
The default comes from the configuration settings, with possible
commandline override.
2009-12-03 01:47:33 +00:00
b17ddc26c0 Fix memory leak in lv_info_by_lvid
The lv_from_lvid calls internally vg_read(),
we must release vg structure afterwards.

Code is called only from clvmd.
2009-12-01 19:10:23 +00:00
b7e19d2fe3 If aborting due to an internal error, always print the message causing this. 2009-12-01 13:54:27 +00:00
d8130a99b4 Optionally abort on internal errors (and leverage this option in the
testsuite). (This is showing a problem in the pvmove test for me, so I expect
the tests to start failing -- this needs to be fixed separately though.)
2009-11-30 17:17:11 +00:00
8c654aeebe The sourcedir instances of the test scripts are not PHONY. 2009-11-30 16:58:53 +00:00
bad318d451 Don't fail in the builddir == srcdir case, though. (testsuite) 2009-11-30 16:56:42 +00:00
11d2997e44 Fix test/api to work with srcdir != builddir. 2009-11-30 15:12:34 +00:00
2d75d2e76e More fixes for the testsuite in the $(builddir) != $(srcdir) situation. 2009-11-30 14:59:26 +00:00
6074f58641 Do not allow creating mirrors of more than 8 images.
This is kernel limitation in all kernel versions,
so better detect this early.
2009-11-27 14:35:38 +00:00
48de09c279 Use locking_type 3 (compiled in cluster locking) in lvmconf. 2009-11-27 14:32:16 +00:00
032c2cb462 Remove unnecessary / duplicate dm_list macros and functions.
These are no longer used by anyone.  The dm_list defines are all in
libdevmapper.h and libdm/datastruct/list.c contains any function definitions.
There is some code in "old-tests" that still use this but this code is not
being maintained.

Thanks to Zdenek for spotting this.
2009-11-25 20:44:07 +00:00
2008367883 Log failure type and recognise type 'F' (flush) in dmeventd mirror plugin. 2009-11-25 15:59:07 +00:00
165d88cfd8 Switch status from 32-bit to 64-bit
The physical_volume, volume_group, logical_volume and lv_segment
structures' 'status' member is now uint64_t.

The alignment of these structures was also audited to remove holes.  The
movement of some members in 'volume_group' and 'lv_segment' eliminates
holes.  The 'physical_volume' structure still has one 4-byte hole after
'pe_size'; the other structures no longer have any holes.  Each
structures' size has not changed.
2009-11-24 22:55:55 +00:00
0c0e1fbbeb Post-release.
Fingers crossed this one's more successful that the last one!
2009-11-24 19:04:23 +00:00
3559e20dab . 2009-11-24 18:54:23 +00:00
e400f6eab9 pre-release 2009-11-24 18:26:08 +00:00
cffffe0c2e Add missing vg_release to pvs and pvdisplay to fix memory leak. 2009-11-24 17:07:09 +00:00
70fcdb495a Do not try to unlock VG which is not locked.
If the vg_read() returned error, no lock was taken,
so always call vg_release().

Otherwise this can happen because of missing FAILED_*:

# vgchange -a y x --ignorelockingfailure
  Volume group "x" not found
  Internal error: Attempt to unlock unlocked VG x
2009-11-24 16:13:02 +00:00
c1b2049df9 Move persistent filter dump to more appropriate place.
After context_refresh is cache empty, the cache flush
does nothing.

Call it after lvmcache full rescan if running from
log lived process.
2009-11-24 16:11:37 +00:00
f6cabc78c0 Refresh device filters before full device rescan in lvmcache.
The sysfs filter initialise hash of available devices using
scan of /sys/block. We need to refresh even this hash
when performing full scan otherwise the newly appeared
device could be rejected, because there is no entry
in sysfs filter.

This easily could happen when attaching new device
to cluster node. (Only force refresh of context
in clvmd -R works here now).

Unfortunately consequences of this are much worse,
missing device part on that node is replaced with missing segment
(even when no partial arg is selected) and this directly
lead to data corruption.

See https://bugzilla.redhat.com/show_bug.cgi?id=538515

Simply fix it by refreshing device filters in lvmcache
before performing the full device scan.
2009-11-24 16:10:25 +00:00
b8526452b5 Return error status if vgchange fails to activate some volume.
(on one node a storage connection failed):

# vgchange -a y vg_bar ; echo $?
  Error locking on node bar-02: Refusing activation of partial LV lv1. Use --partial to override.
    1 logical volume(s) in volume group "vg_bar" now active
    0

So activation fails on one node, error is correctly printed but
status code is wrong.

This patch fixes the top level (vgchange) to return proper code
(and print # of activated LVs).

(lvchange returns error properly here.)
2009-11-24 16:08:49 +00:00
a1cefb3e17 Fix memory lock imbalance in locking code.
(This affects only cluster locking because only cluster
locking module set LCK_PRE_MEMLOCK.)

With currect code you get
# vgchange -a n
  Internal error: _memlock_count has dropped below 0.
when using cluster locking.

It is caused by _unlock_memory calls here

  if ((flags & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME)
     memlock_dec();

Unfortunately it is also (wrongly) called in immediate unlock
(when LCK_HOLD is not set) from lock_vol
(LCK_UNLOCK is misinterpreted as LCK_LV_RESUME).

Avoid this by comparing original flags and provide memlock
code type of operation (suspend/resume).
2009-11-23 10:55:14 +00:00
def0f38f3d Revert vg_read_internal change, clvmd cannot use vg_read now. (2.02.55) 2009-11-23 10:44:50 +00:00
58a8b00086 post-release 2009-11-19 19:53:58 +00:00
50a27398b0 . 2009-11-19 19:42:57 +00:00
eab7cba1f3 pre-release 2009-11-19 19:00:34 +00:00
83774ba6ae Add a basic test for snapshots of mirrors, thanks to Jon Brassow. 2009-11-19 13:55:40 +00:00
ab700b4ea3 In case we refuse to continue due to missing PVs, print a hint about using
vgreduce --removemissing to remedy the situation.
2009-11-19 13:44:37 +00:00
bf7936d494 The double resume in remove_mirror_images does not happen *always*. Only call
memlock_inc() when it actually does happen.
2009-11-19 13:42:38 +00:00
14f627329d Un-export vg_read_internal. 2009-11-19 12:13:37 +00:00
829c996611 Add a missing #include (fix compiler warning). 2009-11-19 12:09:53 +00:00
dff2e8ecb4 Fix the dmeventd LD_LIBRARY_PATH in the testsuite. 2009-11-19 12:01:39 +00:00
7c79b1c7c5 What's new. 2009-11-19 01:17:01 +00:00
a390fac356 Fix another bug in memlock handling, this time the "global" dmeventd memlock
was preventing device scans in lvconvert --repair running from inside dmeventd.
2009-11-19 01:11:57 +00:00
9a43e67347 Add an extra memlock_inc() to _remove_mirror_images to properly balance
reference counting (see code comment for details).
2009-11-18 18:23:46 +00:00
b0d08c572a Issue an Internal error message whenever _memlock_count drops below 0. 2009-11-18 18:22:32 +00:00
ee4eb0aa6f Never activate hidden volumes directly in vgchange.
All hidden (not visible) volumes should be activated through
other visible volumes.

(There are already exceptions like snapshot, mirror log and image,
which should be cleaned one day...)

This solves problems for future types of hidden volumes,
which can have special meaning and must not be activated implicitly
(e.g. key store volume).
2009-11-18 17:20:18 +00:00
07e27cac02 Fix pvmove region_size overflow for very large PVs.
Fixes problem reported in
https://www.redhat.com/archives/dm-devel/2009-November/msg00104.html

The region size multiplication can overflow when using 32bit integer.
2009-11-18 16:48:10 +00:00
cdc905cc16 Fix install_device-mapper Makefile target to not build dmeventd plugins. 2009-11-13 12:48:01 +00:00
88b0c82a0d Support udev flags even when udev_sync is disabled or not compiled in.
This provides better support for environments where udev rules are installed
but udev_sync is not compiled in (however, using udev_sync is highly
recommended). It also provides consistent and expected functionality even
when '--noudevsync' option is used.

There is still requirement for kernel >= 2.6.31 for the flags to work though
(it uses DM cookies to pass the flags into the kernel and set them in udev
event environment that we can read in udev rules).
2009-11-13 12:43:21 +00:00
01d3349587 Remove 'last_rule' from udev rules.
'last_rule' option has been removed from udev (version >= 147).

From now on, we require foreign rules to check and honor
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG} instead. Foreign
rules should be skipped totally when this flag is set.
2009-11-13 12:33:27 +00:00
cf7f096db7 . 2009-11-06 01:40:59 +00:00
21ed352ac5 Add support for querying a device's inactive table.
Currently this data is invisible to userspace.
Requires dm >= 4.16 (likely to be in linux 2.6.33).
2009-11-06 00:43:08 +00:00
f8a4f79277 Fix compilation warning:
activate/dev_manager.c:362: warning: combined_percent_range may be used uninitialized in this function
2009-11-04 14:56:35 +00:00
16d385ac6a Fix lvcreate processing of %PVS argument.
- fix missing unlocking of VG
lvcreate -l 100%PVS -n lv1 vg_test
  Please specify physical volume(s) with %PVS
  Internal error: Volume Group vg_test was not unlocked

- if no PVS specified, use all available

Fix segfault if %PVS in lvresize without PVs list.
2009-11-04 14:47:27 +00:00
3dc1945b44 minor code comment update 2009-11-04 12:39:56 +00:00
3c7db9e986 Remove old, and now incorrect, vgextend man page description of pvcreate options. 2009-11-03 15:58:02 +00:00
44e1f095d1 Tidy some uses of arg_count and introduce arg_is_set. 2009-11-03 15:50:42 +00:00
90c39b8371 Update for outnl and indent functions 2009-11-03 11:17:46 +00:00
17b7944ac2 Export functions out_inc_indent(), out_dec_indent() for creating
indented metadata lines.

Macro outnl() is using exported out_newline() instead of direct
call f->fn(), that required the visibility of the internal
struct formatter.
2009-11-03 11:00:46 +00:00
bbf486f890 Add fflush for the case the log is redirected to the buffered file.
Without this patch it have not been obvious, why the application
waits on the stdin as the prompt might be still buffered in memory.
2009-11-03 10:50:57 +00:00
20faa956a8 Fix hash lookup segfault when keys compared are different lengths. 2009-11-03 00:45:35 +00:00
74a4e04185 Rudimentary support for running testsuite in a builddir != srcdir situation. 2009-11-02 15:16:21 +00:00
b102455b57 Rename validate_vg_create_params to vgcreate_params_validate. 2009-11-01 20:05:17 +00:00
c2235a0baa Rename fill_vg_create_params to vgcreate_params_set_from_args.
Rename fill_vg_create_params to vgcreate_params_set_from_args and remove
vg_name parameter from function (caller must set before calling function).
2009-11-01 20:03:24 +00:00
c36d2b02a3 Add vgcreate_params_set_defaults().
Add function to set default vgcreate parameters based on existing VG or
internal defaults.  Should be no functional change.
2009-11-01 20:02:32 +00:00
4eb8d86346 Rename pvcreate_params processing functions to better match <object><action>.
Rename fill_default_pvcreate_params to pvcreate_params_set_defaults.
Rename pvcreate_validate_restore_params to pvcreate_restore_params_validate.
Rename pvcreate_validate_params to pvcreate_params_validate.
2009-11-01 19:51:54 +00:00
1b33fbf98b More cleanup in udev rules:
- add copyright notice for 10-dm.rules.in,

 - set DM_UDEV_DISABLE_{DISK, OTHER}_RULES_FLAG in 11-dm-lvm.rules directly
   for inappropriate and non-top-level subdevices in case we use older kernels
   where DM_COOKIE is not used (and therefore there are no flags passed from
   the LVM process itself). This applies for older kernels (version < 2.6.31),

 - remove unnecessary filters in 95-dm-notify.rules - the DM_COOKIE env var
   itself is set for change/remove udev events and for DM devices only so
   there's no need to double-check this.
2009-11-01 18:01:31 +00:00
3f74391b87 Update vgsplit to call vg_set_clustered(). 2009-10-31 17:43:57 +00:00
93c954dae1 Update vgcreate to call vg_set_clustered(). 2009-10-31 17:39:22 +00:00
f736563a7a Add vg_set_clustered() - move logic from vgchange.
Similar to other vg_set_* functions, we create a vg_set_clustered() function
which does a few checks and sets a flag.  This is where we check for
any limitations of clusters.
2009-10-31 17:30:52 +00:00
0350c4f0f6 Add vg_mda_count library function. 2009-10-31 17:26:13 +00:00
0c0caf0272 Add to vgcreate and vgextend nightly tests. 2009-10-31 16:43:07 +00:00
9abd966a80 Insert some missing stack macros into activation code. 2009-10-30 13:07:49 +00:00
a1dbd7156c Recognise DRBD device part and handle it similar to MD devices.
The DRBD uses underlying device so code should prefer top
device if duplicate is found.

Patch also introduce
        dev_subsystem_part_major and dev_subsytem_name
functions to easily handle all these replication susbystems
and not hardcode md_major call.

See https://bugzilla.redhat.com/show_bug.cgi?id=530881
for full problem description.
2009-10-27 17:00:44 +00:00
b74e5b870c post-release 2009-10-27 01:13:20 +00:00
bcb021296f . 2009-10-27 00:52:45 +00:00
dcf907f36d add copyright lines 2009-10-26 22:42:07 +00:00
972b11e39e pre-release 2009-10-26 21:56:23 +00:00
10fffe842b Cleanup of previous commit with latest changes in udev support code. 2009-10-26 21:38:35 +00:00
963cf98df1 Document --all option in man pages, cleanup {pv|vg|lv}{s|display} man pages.
Option --all is only partially documented currently, so document in all
commands.  Also make {pv|vg|lv}{display|s} man pages consistent with help
output.  Remove ununsed 'disk_ARG' parameter.  Leave --trustcache out of
the man page output.  Update --units argument to show all possible units.
2009-10-26 14:37:09 +00:00
0f64ddf2fb Several changes to udev support code:
- we have these levels when the udev rules are processed:
   10-dm.rules --> [11-dm-<subsystem>.rules] --> [12-dm-permissions.rules] -->
   13-dm-disk.rules --> [...all the other foreign rules...] --> 95-dm-notify.rules

 - each level can be disabled now by
   DM_UDEV_DISABLE_{DM, SUBSYSTEM, DISK, OTHER}_RULES_FLAG

 - add DM_UDEV_DISABLE_DM_RULES_FLAG to disable 10-dm.rules

 - add DM_UDEV_DISABLE_OTHER_RULES_FLAG to disable all the other (non-dm) rules.
   We cutoff these rules by using the 'last_rule', so this one should really be
   used with great care and in well-founded situations. We use this for lvm's
   hidden and layer devices now.

 - add a parameter for add_dev_node, rm_dev_node and rename_dev_node so it's
   possible to switch on/off udev checks

 - use DM_UDEV_DISABLE_DM_RULES_FLAG and DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG
   if there's no cookie set and we have resume, remove and rename ioctl.
   This could happen when someone uses the libdevmapper that is compiled with
   udev_sync but the software does not make use of it. This way we can switch
   off the rules and fallback to libdevmapper node creation so there's no
   udev/libdevmapper race.
2009-10-26 14:29:33 +00:00
3fa82818b9 Rename 11-lvm.rules to 11-dm-lvm.rules and 12-dm-disk.rules to 13-dm-disk.rules. 2009-10-26 14:04:31 +00:00
c48ba4464c Update lvcreate/lvconvert man pages to explain PhysicalVolume parameter.
Addresses rhbz 500177.
2009-10-26 13:41:13 +00:00
2d1118a26f Permit snapshots of mirrors. (brassow) 2009-10-26 10:01:56 +00:00
53560b8e0b Minor fix to vgcreate/vgextend man pages for PHYSICAL DEVICE OPTIONS. 2009-10-26 02:36:29 +00:00
3f647cdf32 Cleanup mimagetmp LV if allocation fails for new lvconvert mimage. 2009-10-23 01:24:17 +00:00
9a0dc6d522 Fix clvmd segfault when refresh_toolcontext fails. (brassow, bz 506986) 2009-10-22 17:45:23 +00:00
c819525e81 Remember to clear 'global lock held during cache refresh' state after use. 2009-10-22 17:33:09 +00:00
4024ad5eb2 Add manpage entry for dmsetup udevflags. 2009-10-22 13:12:20 +00:00
2c0df9552f Use udev flags in the rules and cleanup the rules:
- remove default permissions set in 95-dm-notify.rules (and add a hint in 12-dm-permissions.rules to set it by the user directly)
 - add multipath DM_ACTION=="PATH_FAILED" filter
 - remove unnecessary filters in the headers of the rules (we can simply use DM_UDEV_RULES_VSN instead)
 - fix symlink priorities in /dev/disk/ (snapshot volumes have low priority for FS UUID symlinks so it will not overwrite symlinks for the origin)
2009-10-22 13:11:33 +00:00
9359586fde Use udev flags support in LVM and provide dm_tree_add_new_dev_with_udev_flags wrapper for dm_tree_add_new_dev. 2009-10-22 13:00:07 +00:00
68069c70e1 Add udev flags support in libdevmapper and provide 'dmsetup udevflags' command to decode them. 2009-10-22 12:55:47 +00:00
6a00ceeb66 . 2009-10-22 11:25:46 +00:00
8143f55488 Only announce mirror monitoring to syslog after initialisation succeeds. 2009-10-22 10:40:41 +00:00
03e03fb7a1 Fix the "const discarded" warnings introduced in the unknown segment patch. 2009-10-22 10:38:07 +00:00
b13b8c1882 Clarify message:
"  Mirror status: 1/2 images failed."

Half of an image?  Half of the images?  No, 1 of 2 images.
2009-10-21 22:19:39 +00:00
02a2afb64f Handle metadata with unknown segment types more gracefully. 2009-10-16 17:41:49 +00:00
ae8e907d72 I saw this in a bug report:
[root@xxxx-01 ~]# lvconvert -m 1 --corelog VG/cmirror
  Unable to convert the log of inactive cluster mirror cmirror

I've tried to clean-up the message a little more, so the name
of the mirror stands out more while preserving the sense that
it's not a problem with the specific device, but the fact that
it is inactive that is causing the problem.

New msg:
  Unable to convert the log of an inactive cluster mirror, cmirror
2009-10-14 14:55:44 +00:00
f042834068 configure.in: don't set default file owner and group
Per discussion on lvm-devel mailing list and part of debian patch set,
don't set defaults for owner and group, since nobody seems to use them, and
still allow override.
2009-10-14 04:10:41 +00:00
63130374b9 Attempt to build dmeventd.static. 2009-10-13 02:35:26 +00:00
ac01d56747 More build cleanups (linker parameter ordering). 2009-10-13 01:31:10 +00:00
6f751afae4 Disable realtime support by default.
This code is used only in a under development feature and it's not used
anywhere in the tree.

Allow to build it conditionally.
2009-10-12 16:59:20 +00:00
8fd85fb6e6 Make clvmd return 0 on success rather than 1. 2009-10-12 08:33:30 +00:00
1dbfe1e856 Merge Debian patch 05 debian: keep libdm-abi consistent.
This appears to be the only user visible feature that can change libdm ABI
at build time.

Thanks to Bastian Blank for the patch.
2009-10-12 04:06:42 +00:00
d3fd4c0381 Extra libs must be appended, not defined first. 2009-10-09 16:04:54 +00:00
0e20e05795 linking parms missing from o->so conversion. 2009-10-09 15:55:31 +00:00
3bb0dc03af Cleanup comment and some whitespace. 2009-10-06 16:00:38 +00:00
4257485ff2 Add --pvmetadatacopies as a synonym for --metadatacopies in various commands.
Going forward, we would like to allow users to specify the total
number of metadatacopies in a VG rather than on a per-PV basis.  In
order to facilitate that, introduce --pvmetadatacopes to replace
--metadatacopies everywhere.  We still allow --metadatacopies for
pv commands, but require --pvmetadatacopies for vg commands.
Eventually we will introduce --vgmetadatacopies.  Once we do that,
we should either deprecate --metadatacopies or make it a synonym based
on the command (pvmetadatacopies for pv commands, and vgmetadatacopies
for vg commands).  The latter option would likely just require a simple
'strncpy' check against cmd->command->name to qualify the merge_synonym
call.

Update nightly tests to cover the pvmetadatacopies synonym.

Note that this patch is the result of an eariler review comment for
the implicit pvcreate patches.  Should apply cleanly on top of the
implicit pvcreate patches (I applied after patch 10/10 in that series).

NOTE: This patch will require --pvmetadatacopies for vgconvert as
--metadatacopies is no longer accepted.
2009-10-05 20:55:56 +00:00
f69b7a58f2 Add --pvmetadatacopies as a synonym for --metadatacopies in various commands.
Going forward, we would like to allow users to specify the total
number of metadatacopies in a VG rather than on a per-PV basis.  In
order to facilitate that, introduce --pvmetadatacopes to replace
--metadatacopies everywhere.  We still allow --metadatacopies for
pv commands, but require --pvmetadatacopies for vg commands.
Eventually we will introduce --vgmetadatacopies.  Once we do that,
we should either deprecate --metadatacopies or make it a synonym based
on the command (pvmetadatacopies for pv commands, and vgmetadatacopies
for vg commands).  The latter option would likely just require a simple
'strncpy' check against cmd->command->name to qualify the merge_synonym
call.

Update nightly tests to cover the pvmetadatacopies synonym.

Note that this patch is the result of an eariler review comment for
the implicit pvcreate patches.  Should apply cleanly on top of the
implicit pvcreate patches (I applied after patch 10/10 in that series).

NOTE: This patch will require --pvmetadatacopies for vgconvert as
--metadatacopies is no longer accepted.
2009-10-05 20:53:41 +00:00
fd4fe42013 Update help messages for vgextend / vgcreate to mention PHYSICAL DEVICE OPTIONS. 2009-10-05 20:22:58 +00:00
930820b738 Add implicit tests for implicit pvcreate during vgcreate and vgextend.
Update tests and WHATS_NEW for implicit pvcreate support.
2009-10-05 20:04:40 +00:00
06cc081ca2 Update vgcreate and vgextend man pages to clarify implicit pvcreate.
vgcreate and vgextend now implicitly call pvcreate on devices not
currently initialized for LVM use.  Previously these commands would
fail with an error, so clarify the new behavior in the man page.
2009-10-05 20:04:21 +00:00
ee9bf16d1a Add implicit pvcreate support to vgcreate and vgextend.
Adds implicit pvcreate support when calling vgcreate or vgextend with
device paths that are not yet PVs.  This changes the behavior of vgcreate
and vgextend from failing with an error message to implicitly pvcreating.
2009-10-05 20:04:08 +00:00
f08e65fd04 Move pvcreate_validate_params into toollib to allow calling from mutiple tools.
For implicit pvcreate support, we need to call this from vgcreate and vgextend,
so move it into toollib.
2009-10-05 20:03:54 +00:00
877de45d6e Refactor vgcreate/vgextend validation of vgname/pvname(s).
Decrement argc and increment argv in a consistent way to allow for later
code-sharing.  Should be no functional change.
2009-10-05 20:03:37 +00:00
5a4813d336 Refactor pvcreate - split pvcreate_validate_params into recovery/non-recovery.
Split pvcreate_validate_params into recovery and non-recovery parameters.
This is necessary so we can call the non-recovery validate function from
vgextend / vgcreate.  Note in the pvcreate tool case, we must call the
recovery validation function first (see treatment of pe_start and --zero),
and that we add a call to fill_default_pvcreate_params before the validation
functions.
2009-10-05 20:03:25 +00:00
6dc818deb1 Allow calling fill_default_pvcreate_params from tools.
We need defaults for pvcreate_params at a higher level - this will
allow us to use a common function from the tools to take defaults,
then fill in any non-defaults from the commandline.

Future patches will refactor vgcreate/vgextend to call this function
if one or more pvcreate parameters are given on the commandline.
2009-10-05 20:03:08 +00:00
4b2bf06873 Add pvcreate_params to vg_extend.
Another refactoring for implicit pvcreate support.  We need to get
the pvcreate parameters somehow to the vg_extend routine.  Options
seemed to be:
1. Attach the parameters to struct volume_group.  I personally
did not like this idea in most cases, though one could make an
agrument why it might be ok at least for some of the parameters
(e.g. metadatacopies).
2. Pass them in to the extend routine.  This second route seemed
to be the best approach given the constraints.

Future patches will parse the command line and fill in the actual
values for the pvcreate_single call.
Should be no functional change.
2009-10-05 20:02:48 +00:00
839af3e90e Add pvcreate_params to vg_extend_single_pv.
Should be no functional change.  If this parameter is set to NULL, just fail
the extend if the device is not already a PV.  If non-NULL, try pvcreate_single
before failing.  Note that pvcreate_single() handles the log_error in case
of failure so we just return 0 if pvcreate_single() fails.
2009-10-05 20:02:30 +00:00
c059cdd0f2 Refactor vg_extend - add vg_extend_single_pv.
Simple refactor to setup future changes related to implicit pvcreates.
Should be no functional change.
2009-10-05 20:02:04 +00:00
0ba837e163 More makefile cleaning up and fixing. (gentoo) 2009-10-05 13:46:00 +00:00
1ddcf370a7 Correct example.conf to indicate that lvm2 not lvm1 is the default format.
Remove an unused stray LVM1_SUPPORT ifdef.
2009-10-05 12:44:20 +00:00
e0559e4fda Only include selinux libs in libdevmapper.pc when selinux build enabled. 2009-10-05 12:11:30 +00:00
eeefbfd38d Allow for a build directory separate from the source. 2009-10-02 19:10:31 +00:00
60ba4943ec Update distclean target for rename clogd to cmirrord. (2.02.52) 2009-10-02 11:41:54 +00:00
ba4ac17425 Remove daemons/clogd from distclean dirs (replaced with cmirrord) 2009-10-02 11:35:25 +00:00
3965d3ba83 Run distclean also for daemons/cmirrord 2009-10-02 09:47:11 +00:00
3435f24770 Add LCK_CONVERT flag I missed on the last checkin. 2009-10-01 14:15:34 +00:00
31672ff60e Stop clvmd from automatically doing lock conversions. Now, if a lock
is granted at one mode and an attempt to convert it wthout the LCK_CONVERT
flag set then it will return errno=EBUSY.

This fixes a pretty bad bug in which an LV could be activated exclusively on
one node and lvchange -ay on another would convert it to shared!

It might break some things in other areas, but I doubt it.
2009-10-01 14:14:17 +00:00
6e619f8927 Add percent_range to copy_percent too. 2009-10-01 01:04:27 +00:00
2ccdb165e3 Introduce percent_range_t and centralise snapshot full/mirror in-sync checks. 2009-10-01 00:35:29 +00:00
db8eab04e3 Make poll_mirror_progress a function that can be replaced. 2009-09-30 18:15:06 +00:00
4e2e8954dc Factor out poll_mirror_progress and introduce progress_t. 2009-09-30 17:43:51 +00:00
a25fe81b9e Update nightly tests to deal with unit changes.
Now uppercase letters imply Si units, so use lowercase everywhere.
We could stay with uppercase, but then we'd have to deal with rounding, etc.
Also, some output / error messages change slightly (instead of "GB" we're
now saying "GiB").
One test enhancement might be to add some new tests for the units changes
but for now let's just get the test back to passing.
2009-09-30 16:13:53 +00:00
bce3ac2c73 Distinguish between powers of 1000 and powers of 1024 in unit suffixes. 2009-09-30 14:19:00 +00:00
52b70fbbfa Just a cleanup from previous commit. We don't need pvname local var in _activate_lvs_in_vg anymore... 2009-09-30 12:05:25 +00:00
08b540dd78 look up pvmove by pvmove LV when PVMOVE flag is set 2009-09-29 20:33:49 +00:00
22e91979bb Don't attempt to restart pvmoves when deactivating LVs in vgchange.
Restart lvconverts in vgchange by sharing lv_spawn_background_polling.
2009-09-29 20:22:35 +00:00
e3730ecfc3 Generalise polldaemon code by changing mirror-specific variable names. 2009-09-29 19:35:26 +00:00
9cfc9b3ee2 Don't attempt to deactivate an LV if any of its snapshots are in use. 2009-09-29 18:50:28 +00:00
c0ff3805c8 Return fail if lv_deactivate did not removed device from kernel.
lv_deactivate now returns always success, because tree deactivation
functions (see dm_tree_deactivate_children) always returns success.

Because code should return failure in lv_deactivate at least,
fix it by checking for device existence after real deactivation call.

(After discussion this was prefered solution to dm tree function rewrite
which affects snapshots and mirrors.)
2009-09-29 15:17:54 +00:00
49ebd19ab1 Trivial cleanup to lvcreate man page - use virtualsize in example.
virtualsize replaced virtualoriginsize but the example was never updated.
2009-09-29 15:11:06 +00:00
79bcc98e9b Provide alternative implementation of obsolete siginterrupt(). 2009-09-28 21:23:02 +00:00
a58980fe82 Consolidate LV allocation into alloc_lv(). 2009-09-28 17:46:15 +00:00
fe67a86a5f Treat input units of both 's' and 'S' as 512-byte sectors. (2.02.49)
's' and 'S' are special suffixes representing sectors and are always 512 bytes,
regardless of whether you're using powers of 1000 or 1024.
2009-09-28 16:36:03 +00:00
4d85bb13d1 Add global/si_unit_consistency to enable cleaned-up use of units in output.
Add configure --enable-units-compat to set si_unit_consistency off by default.

Use standard output units for 'PE Size' and 'Stripe size' in pv/lvdisplay.
2009-09-28 16:23:44 +00:00
0501c06745 post-release 2009-09-26 00:42:47 +00:00
abb2e6ea9b Fix log fn prototype. 2009-09-26 00:29:13 +00:00
a99a30d720 missing dm_snprintf 2009-09-25 19:06:05 +00:00
0670c8f60f pre-release 2009-09-25 18:30:27 +00:00
dfdcb92f3d pre-release 2009-09-25 18:30:26 +00:00
bc9b5706e9 ensure dm_strdup succeeds 2009-09-25 18:19:09 +00:00
64c37a20d1 remove unused var & rename fn 2009-09-25 18:13:17 +00:00
6d2d4f72ac Handle any path supplied to dm_task_set_name() by looking up in /dev/mapper. 2009-09-25 18:08:04 +00:00
4c151970e6 Use the same default umask for /dev dirs (DM_DEV_DIR_UMASK). 2009-09-25 11:58:00 +00:00
e65e815aae Add more hints in 12-dm-permissions.rules. Add 'dmsetup splitname' and 'y|--yes' to dmsetup manpage. 2009-09-23 12:52:52 +00:00
db3fb23de4 '_emit_areas_line' returns 1 for success and 0 for failure. This always
confuses me, so I've added a comment at the top of the function to
remind me of this.

I also found that 'mirror_emit_segment_line' was returning 0 (return_0)
on failure /and/ success.  It now returns 1 for success and 0 for failure -
just like '_emit_areas_line' and its calling function, '_emit_segment_line'.
2009-09-22 16:26:59 +00:00
5c9adc4052 Minor replace of of ${top_srcdir} with $(top_srcdir) for lcov target 2009-09-22 13:32:39 +00:00
b8c8c29ee4 Add some advisory comments for users in 12-dm-permissions.rules. 2009-09-22 12:03:32 +00:00
47c0c71e19 Fix dmeventd _temporary_log_fn parameters. (2.02.50) 2009-09-17 10:37:23 +00:00
7d26a86071 Enable dmeventd monitoring section of config file by default. 2009-09-16 23:48:41 +00:00
556d880951 drop -ing suffix 2009-09-16 23:40:19 +00:00
4ee50ed6de Update lvm2_monitoring script. 2009-09-16 23:22:40 +00:00
b1b5a9d8fa Fix lvm2app test to run under test/api subdirectory only when configured. 2009-09-15 19:59:04 +00:00
62d8848bee Add vg_is_resizeable() and cleanup references.
Clean up VG_RESIZEABLE flag by creating vg_is_resizeable().
Update comment - we no longer have ALLOW_RESIZEABLE.
Also use vg_is_exported() in one place missed by earlier patch.
Should be no functional change.
2009-09-15 18:35:13 +00:00
c63b16cf75 Remove test/api which should only be under 'make test'. 2009-09-15 15:37:12 +00:00
d32a6f15bf post-release 2009-09-15 13:54:28 +00:00
918abadb6c pre-release cleanup 2009-09-15 13:49:10 +00:00
7f5adb135d missing (C) reminders 2009-09-15 12:51:28 +00:00
b1ce301520 dm release cleanup 2009-09-15 11:41:38 +00:00
cd93201e46 pre-release 2009-09-15 10:57:16 +00:00
c9aaf5fb24 Fix process_each_vg / _process_one_vg when vg_read() returns FAILED_LOCKING.
Remove the checks for vg_read_error() in most of the tools callback
functions and instead make the check in _process_one_vg() more general.

In all but vgcfgbackup, we do not want to proceed if we get any error
from vg_read().  In vgcfgbackup's case, we may proceed if the backup
is to proceed with inconsistent VGs.  This is a special case though,
and we mark it with the READ_ALLOW_INCONSISTENT flag passed to
process_each_vg (and subsequently to _process_one_vg).

NOTE: More cleanup is needed in the vg_read_error() path cases.
This patch is a start.
2009-09-15 01:38:59 +00:00
fdf1e32962 More cmirror makefile fixes from Fabio. 2009-09-14 22:57:46 +00:00
36d336618e Fix build failure when enabling dmeventd and applib.
This patch fixes a build with options similar to the following:
./configure --enable-debug --enable-applib --enable-dmeventd --enable-cmdlib
2009-09-14 22:56:27 +00:00
013f27e3e6 Add lots of missing stack debug messages to tools.
Make readonly locking available as locking type 4.
Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
2009-09-14 22:47:49 +00:00
1b3f8a4c18 Use vg_is_exported(vg) macro everywhere.
This patch is all just cleanup and no other patch depends on it.
Replace explicit dereference and check with vg_is_exported().
Update a few copyrights and remove unnecessary whitespace.
Should be no functional change.
2009-09-14 19:44:15 +00:00
dd8ef51fa1 Add most relevant vg_attr fields as lvm2app 'get' functions.
Of the vgs field vg_attr, a few of the most likely to be used attributes
are clustered, exported, and partial.  This patch adds the following 3
functions:
uint64_t lvm_vg_is_clustered(const vg_t vg)
uint64_t lvm_vg_is_exported(const vg_t vg)
uint64_t lvm_vg_is_partial(const vg_t vg)
2009-09-14 19:43:11 +00:00
11e8d26606 Update lvm and vgs man pages to clarify 'partial' is a VG missing PVs. 2009-09-14 19:42:13 +00:00
1e954bc8ef Add max_pv and max_lv vg 'get' lvm2app exports. 2009-09-14 15:45:23 +00:00
720eb0e91c Do not run mdadm tests if MD module is not loaded. 2009-09-13 19:28:00 +00:00
106763ef9a Move dm_cookie_supported check into dm_udev_get_sync_supprt function.
We don't have to call dm_cookie_supported with dm_udev_get_sync_support
this way. Also, it's necessary for the current code to work properly on
systems without cookie support (older kernels).
2009-09-11 16:11:25 +00:00
10019a9d96 Add manpage entry for dmsetup's udevcomplete_all and udevcookies commands. 2009-09-11 16:06:31 +00:00
4515bcf289 Several changes in udev rules:
- add DM_UDEV_RULES_VSN to provide a variable to be checked for in the other
  rules (e.g. to check that DM rules are actually installed, we can alternate
  functionality in the other rules based on this information, also we have
  versioning support for the rules)
- set proper sbin path for dmsetup and blkid, /sbin first, then /usr/sbin.
  This is necessary for anaconda to work properly.
- add 'last_rule' for cryptsetup's temporary devices (symlinks in /dev/mapper
  only)
2009-09-11 16:05:20 +00:00
aa8728a2ab Add one define that is necessary for older (experimental) libudev to work. 2009-09-11 15:57:51 +00:00
f2d3b3661b Check that udev is running and set internal state appropriately. 2009-09-11 15:56:06 +00:00
24b598b1be Add libudev configuration check. 2009-09-11 15:55:07 +00:00
0d98ee8916 Add y|--yes option for dmsetup to provide a default 'YES' answer to questions. 2009-09-11 15:53:57 +00:00
3eca5ad9a1 Fix Makefile to take into account dmsetup's reconfiguration. 2009-09-11 15:52:22 +00:00
ed2465fd30 Update lvm2app unit test vgtest - fix remove bug.
We now must commit to disk after lvm_vg_remove().
2009-09-04 19:17:46 +00:00
6d21e61889 Fix path to test/api/vgtest in nightly testsuite. 2009-09-04 14:26:16 +00:00
983312d14d Remove 'test' interative api unit tests from 'TARGET' line.
The test/api directory TARGET line will be reserved for non-interactive
unit tests.  Building the interactive test can still be done with "make test"
from the test/api dir.
2009-09-04 13:49:02 +00:00
2e1271fe36 Add lvm2app.sh to nightly testsuite.
More tests to come but for now just call into vgtest.
Fix warning in vgtest.c
2009-09-04 12:54:23 +00:00
15e53c9839 Restore umask when device node creation fails.
Author: Florian Zumbiehl <florz@florz.de>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-09-03 21:51:26 +00:00
115d48497e Add daemons/cmirrord files to git - somehow got messed up with cvs rename.
When clogd was renamed to cmirrord, somehow git got the remove of the old
files but not the add of the new files.  This patch adds the new files.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-09-04 20:44:58 +02:00
a31948f3b7 Fix path to test/api/vgtest in nightly testsuite. 2009-09-04 14:26:16 +00:00
a12106eb52 Remove 'test' interative api unit tests from 'TARGET' line.
The test/api directory TARGET line will be reserved for non-interactive
unit tests.  Building the interactive test can still be done with "make test"
from the test/api dir.
2009-09-04 13:49:02 +00:00
dd9f42172f Add lvm2app.sh to nightly testsuite.
More tests to come but for now just call into vgtest.
Fix warning in vgtest.c
2009-09-04 12:54:23 +00:00
3d8e149668 Restore umask when device node creation fails.
Author: Florian Zumbiehl <florz@florz.de>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-09-03 21:51:26 +00:00
f557647525 Do not override the distclean target in liblvm's Makefile, it annoys make and
the make.tmpl-included distclean should work better anyway.
2009-09-03 18:19:07 +00:00
1efaf2cde0 Update lvm2app vgtest to take vgname and devices as parameters. 2009-09-03 17:13:46 +00:00
202aea4dda Update lvm_vg_write() to handle the deferred commit of lvm_vg_write().
Now that we've refactored the internal library functions that do the
vg_remove, we can handle the deferred commit of a lvm_vg_remove() inside
lvm_vg_write().  This makes the VG create/remove API more consistent in
terms of disk commits - they now both require an lvm_vg_write() to commit
the create or remove to disk.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:40:10 +00:00
eaefa1ac5d Update vg_remove_single_* functions to use the removed_pvs list.
Now that we've split vg_remove_single into two routines, in the first routine
that only manipulates memory, we move the PVs from the vg->pvs list to the
vg->removed_pvs list.  Then later, we iterate through this list to write the
removed PVs to disk, which removes them from the volume group and places them
into the internal ORPHAN VG.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:49 +00:00
fd49174b1a Split vg_remove_single into 2 functions - the second part commits to disk.
Split vg_remove_single into vg_remove_check (mandatory checks before
vgremove) and vg_remove (do actual remove by committing to disk).

In liblvm, we'd like to provide an consistent API that allows multiple
changes in memory, then let lvm_vg_write() control the commit to disk.  In
some cases (for example, lvresize calls fsadm) this may not be possible.
However, since we are using an object model and dividing things into small
operations, the most logical model seems to be the lvm_vg_write model, and
handling the special cases as they arrive.  So as best as possible
we move towards this end.

A possible optimization would be to consolidate vg_remove (committing)
code with vgreduce code.  A second possible optimization is making vgreduce
of the last device equivalent to vgremove.  Today, lvm_vg_reduce fails if
vgreduce is called with the last device, but from an object model perspective
we could view this as equivalent to vgremove and allow it.  My gut feel is
we do not want to do this though.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:29 +00:00
342605bb44 Rename internal library function vg_remove to vg_remove_mdas.
Later patches should consolidate the vgremove / vgreduce functions but for
now let's clarify what vg_remove actually does by changing the name.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:07 +00:00
a9851f5e95 Enforce an alphabetical lock ordering for vgname locks.
Add a new constraint that vgname locks must be obtained in
alphabetical order.  At this point, we have test coverage for
the 3 commands affected - vgsplit, vgmerge, and vgrename.
Tests have been updated to cover these commands.
Going forward any command or library call that must obtain
more than one vgname lock must do so in alphabetical order.
Future patches will update lvm2app to enforce this ordering.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:34:11 +00:00
848b39b5a0 Update vgrename to take into account vgname lock ordering.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:29:40 +00:00
de372ce095 Refactor vgrename into vg_rename_old and vg_rename_new.
Should be no functional change.
Will allow us to reorder lock obtaining if needed.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:29:23 +00:00
8bbae4b10b Change vgmerge behavior to open/lock first vg based on alphabetical ordering.
This enforces our alphabetical lock ordering rules for vgmerge.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:43 +00:00
cff2eda198 Refactor vgmerge - combine _vgmerge_to and _vgmerge_from into _vgmerge_vg_read.
These functions are identical so should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:27 +00:00
7a75b47da6 Refactor vgmerge - create _vgmerge_from and _vgmerge_to.
These functions are really identical but for clarity I made them separate
functions in this patch.

Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:10 +00:00
79430340e5 Refactor vgmerge - introduce lock_vg_from_first flag.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:55 +00:00
4494c25df7 Change vgsplit behavior to open/lock first vg based on alphabetical ordering.
If the destination vgname comes before the source vgname, we must open the
destination first because of the locking rules.  Thus, do a strcmp and set
the flag based on the comparison.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:39 +00:00
763d659ee2 Refactor vgsplit - reorder _vgsplit_from and _vgsplit_to based on flag.
Slight functional change.  If we open the destination first, we cannot
know the 'fmt'.  In this case we use the default metadata type unless
the user has specified -M on the cmdline.  If not, in most cases this
is fine since we use the LVM2 default metadata type.  However, if the
user is specifying a non-default metadata type (e.g. lvm1) and the order
of the names is such that we have to open the destination (vg_to) first,
we have a problem.  So in this case, we require the use of -M and vgsplit
will fail with an error if not.  I've updated the man page to recommend
the usage of -M in this case.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:22 +00:00
54086f86d2 Refactor vgsplit: _vgsplit_from or _vgsplit_to failure cleanup depends on order.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:05 +00:00
9195a23c95 Refactor vgsplit - create _vgsplit_from function to open source vg.
Should be no functional change and allows future reorder of source and dest
vgs.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:50 +00:00
739ba0fbcc Refactor vgsplit - create _vgsplit_to function which creates or opens dest vg.
Move the creating/opening of the destination vg into its own function so later
we can reorder the source / destination vg opening based on the alphabetical
lock order rule.

Should be no functional change but code is a bit tricky.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:34 +00:00
93ac41e917 Refactor vgsplit - add 'lock_vg_from_first' flag.
Introduce 'lock_vg_from_first' flag to retain which vg was locked first.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:18 +00:00
1928af2a42 Refactor vgsplit - remove bad2 label.
No functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:01 +00:00
45e6585e77 Refactor vgsplit to move existing_vg logic in a separate 'if' statement.
This will aid in future refactorings and allow for us to reorder the source
and destination vg based on alphabetical names.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:25:44 +00:00
8d6fbe1a89 Fix vgsplit test to require -M on ordering of vgnames. 2009-09-02 19:38:53 +00:00
375b420c35 clogd->cmirrord 2009-09-02 19:32:37 +00:00
887b48bd1d Add alphabetical vgname ordering tests for vgsplit, vgmerge, vgrename. 2009-09-02 18:31:11 +00:00
0794a2e526 rename clogd dir to cmirrord 2009-09-02 17:36:46 +00:00
a859e44630 Implement write lock prioritisation for file locking and make it default. 2009-09-02 14:47:39 +00:00
1c1a248277 Fix cmirrod build directory while we wait to do a proper rename of the
directory and move files.
2009-09-02 11:49:03 +00:00
e0e2165c8e Drop clogd Makefile from CVS since it's always autogenerated from Makefile.in
at configure time.
2009-09-01 19:13:38 +00:00
957f8315e3 Fix --with-clvmd=all to deal with the case where no cluster managers are available.
Also simplify the check by removing an unnecessary variable and update
configure messages.
2009-09-01 19:11:45 +00:00
d279ed7dd6 Remove unwanted Makefiles and don't purge lvm2.po that's
under RCS.
2009-09-01 18:11:14 +00:00
827480b9d6 Add some code to clvmd to look in the corosync confdb to see what cluster
interface it should be using, it can still be overriden with -I.

If corosync isn't running or there is no information then the usual
checking will happen.

This code only builds if corosync is available.
2009-09-01 09:48:01 +00:00
1a0af097a6 change clogd to cmirrord
make pidfile locn configurable
2009-08-28 20:51:40 +00:00
d408fc2864 Rewrite clvmd configuration code. 2009-08-28 19:22:05 +00:00
bba03eef2f cluster log daemon (clogd): Adjust for kernel CTR arg reordering
We have moved the internally generated mirror-device-size
parameter from the end of the CTR string to the begining.
This change adjusts for that.
2009-08-28 05:27:09 +00:00
352f7d7f2b Fix global locking in PV reporting commands (2.02.49). 2009-08-24 11:37:20 +00:00
0f07768d6b Fix uuid warning in pvcreate to use terminated (and dash formatted) UUID string.
# pvcreate -u udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi /dev/sdc
   uuid udwxr7BoKYEeKMr033xK6o4og7F13sGi|��� already in use on "/dev/sdb1"
 is now
# pvcreate -u udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi /dev/sdc
   uuid udwxr7-BoKY-EeKM-r033-xK6o-4og7-F13sGi already in use on "/dev/sdb1"
2009-08-20 07:03:02 +00:00
a6a2be6e37 Fix pvcreate on a partition (regressed in 2.02.51).
Eliminate busy loop during pvcreate of a "normal" partition.
_md_sysfs_attribute_snprintf() would busy loop if the device it was
given was not a blkext-based MD partition.

Rather than being cute with a busy-loop prone 'goto check_md_major' in
_md_sysfs_attribute_snprintf(): explicitly check if the provided device
is a blkext-based partition (blkext_major()); and then check that the
get_primary_dev() determined parent is an MD device (md_major()).
2009-08-19 15:34:33 +00:00
e840cc8b91 Use new blkid instead of vol_id in udev rules.
Thanks to Daniel Mierswa for reminding us.
2009-08-14 14:37:46 +00:00
ff17105386 Cluster log server (clogd): Add new build files.
Might be a good idea to add the new files to the repository.  :(
2009-08-13 20:51:41 +00:00
d82f7b9205 configure script: A couple unwanted changes snuck in.
Previously while messing around with 'configure.in' and autoconf,
I changed a couple lines that I didn't want in the final check-in.
2009-08-13 20:23:01 +00:00
01b09aab43 mirror table generating code: Properly handle 'block_on_errors' and 'cluster' features
The device-mapper mirror CTR table has been changing over time.  This has
now been corrected to handle the old and new methods for invoking the
'block_on_errors' and 'cluster' features.  (The code that does this was
accidentally committed in the previous check-in.  This check-in finishes
the job.)
2009-08-13 19:36:04 +00:00
f0153d801e Fix error paths for vgcfgrestore when locking fails. 2009-08-13 17:16:38 +00:00
319b2d8f32 update WHATS_NEW 2009-08-13 16:36:49 +00:00
419675cd2b cluster log daemon (clogd): Add to LVM build system
This check-in includes the touch-ups, make file changes, copyrights,
and other necessities to include the cluster log daemon into the
build system.

[autoconf still needs to be run to generate the 'configure' and
'Makefile' files.]
2009-08-13 16:34:07 +00:00
9dd273626a Cluster log daemon (clogd): use LVM bitops in place of ext2 bitops
Eliminate dependency on outside library, since the same functionality
exists in our tree.

[It is important that the bitops work in the same way, as the bitmaps
must remain backwards compatible.  I haven't tested every architecture,
but the x86* archs work.  My test involved using the old ext2fsprogs
bitops, memcpy'ing the bits over to the LVM bitset array and ensuring
that only the bits set via the old methods were set.]
2009-08-13 16:31:01 +00:00
2997acf9dc Make lvchange --refresh only take a read lock on volume group. 2009-08-13 14:27:32 +00:00
1ee9677b8a Refactor file locking, lifting the flock wrapper code into separate
functions. Also fixes a bug, where a nonblocking lock could, in certain race
situations, succeed without actually obtaining the lock.
2009-08-13 13:23:51 +00:00
9c14c897f5 Update WHATS_NEW 2009-08-13 12:19:30 +00:00
dc3e37956b Make lvm2app pv_t handle definition consistent with lvm_t.
This patch update pv_t handle to be consistent with lvm_t - define as a pointer
to internal struct physical_volume.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:18:15 +00:00
eb283dcbc6 Make lvm2app lv_t handle definition consistent with lvm_t.
This patch update lv_t handle to be consistent with lvm_t - define as a pointer
to internal struct logical_volume.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:17:32 +00:00
fec2b39df3 Make lvm2app vg_t handle definition consistent with lvm_t.
This patch update vg_t handle to be consistent with lvm_t - define as a pointer
to internal struct volume_group.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:16:45 +00:00
1e1b8cc2d5 Update WHATS_NEW for recent checkins. 2009-08-13 12:04:01 +00:00
8a902d7e58 Fix vgextend error path - if ORPHAN lock fails, unlock and release vg.
Full changes
- Fix vgextend error path when lock_vol(VG_ORPHANS) fails
- Move lock_vol(VG_ORPHANS) before archive(vg) - safe & simpler error paths
- Remove legacy comment/code that no longer applies

Found in review - Milan Broz <mbroz@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:03:46 +00:00
1a0d994305 Fix compilation warning in clvmd.c 2009-08-13 10:39:41 +00:00
597986b711 Update man pages to clarify usage of PE ranges.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-10 17:23:04 +00:00
ba0a843482 Remove useless _pv_write wrapper. 2009-08-10 17:15:01 +00:00
0ad0f9e094 Update test/api/test.c to call lvm_vg_create and lvm_vg_remove.
Also fix a couple bugs.
2009-08-07 21:22:37 +00:00
f93a548fe2 post-release 2009-08-06 19:32:26 +00:00
84b0920fe0 pre-release 2009-08-06 17:08:01 +00:00
a3d7f70d45 pre-release 2009-08-06 16:30:34 +00:00
99b7ce7bf5 Fix semaphore includes in dmsetup for udev sync. 2009-08-06 15:56:50 +00:00
819e3b9661 Remove 11-dm-permissions.rules (is now in 12-dm-permissions.rules). 2009-08-06 15:28:05 +00:00
cac468586a Rename template rule file 11-dm-permissions.rules to 12-dm-permissions.rules. 2009-08-06 15:10:58 +00:00
afc8c05f7f Add 'udevcookies' command for dmsetup. 2009-08-06 15:05:10 +00:00
886e528490 Add 'udevcomplete_all' command for dmsetup. Export DM_COOKIE_MAGIC in libdevmapper.h. 2009-08-06 15:04:30 +00:00
06691a0794 Fix failure situations in dm_task_run for udev sync. 2009-08-06 15:02:01 +00:00
c61da238e1 Detect udev problems in _rename_dev_node. 2009-08-06 15:00:25 +00:00
e07419b4ba Additional logging 2009-08-05 19:50:08 +00:00
cecc0e9dc8 Fix locking in clvmd
The changes to remove LCK_NONBLOCK from the LVM locks broke clvmd because the
code was clearly wrong but working anyway! The constant was being masked rather
than the variable that was supposed to match against it.
2009-08-05 14:18:35 +00:00
4d4d7c1fb3 Forgotten '%s' in one of _mk_link warning messages. 2009-08-05 09:12:44 +00:00
e50e7ee119 detect udev mk_link problems 2009-08-04 21:44:20 +00:00
0d15d01b45 Added basic pvcreate --dataalignmentoffset testing to t-pvcreate-usage.sh
Added topology testing via new test/t-pvcreate-operation-md.sh
- requires mdadm and rawhide kernel for full test coverage
2009-08-04 16:02:39 +00:00
7972728e7c Add --noudevsync option for relevant LVM tools. 2009-08-04 15:55:43 +00:00
d4d430ee80 Add --noudevsync option for relevant LVM tools. 2009-08-04 15:53:04 +00:00
b2155fde1a Add activation/udev_sync to lvm.conf. 2009-08-04 15:36:13 +00:00
0033b9eeb5 '--noudevsync' -- update relevant man pages 2009-08-04 08:09:52 +00:00
3d25b06fbc Fix a typo in udev rule (splitname, NOT namesplit) 2009-08-04 08:05:06 +00:00
32752bc3dd Add default udev rules.
Update dm-ioctl.h comments.
2009-08-03 18:44:54 +00:00
f1fd43b61c Add udev checks. 2009-08-03 18:33:08 +00:00
38fda754a1 Add warnings to check udev did what it was meant to. 2009-08-03 18:31:53 +00:00
dc4e40a2f6 Only create LV symlinks on ACTIVATE not PRELOAD.
(This is the udev behaviour - but does this change break anything?)
2009-08-03 18:09:25 +00:00
9abda62c5b Manage without dm_udev_cleanup? 2009-08-03 18:01:45 +00:00
cd5c37fe1c Move FIXME from user visible lvm2app.h to lvm_vg.c
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-03 12:11:45 +00:00
bce8cac1f4 cleanup some ignored return values & 'stack's 2009-08-03 11:20:15 +00:00
4171d0c301 deal with error-related FIXMEs 2009-08-03 11:01:26 +00:00
2edd956853 lvchange --noudevsync 2009-08-03 10:58:40 +00:00
d77b03d6c9 Make lvconvert honour log mirror options combined with downconversion.
(RHBZ 463272)
2009-08-02 21:59:21 +00:00
4d5a88661f Slightly refactor mirror log conversions in lvconvert. 2009-08-02 21:56:29 +00:00
0b9b1ccd0b Add test for RHBZ 481793 (passing, thanks to vg_read changes checked in
previously).
2009-08-02 21:45:45 +00:00
d5ef8e037d Allow LV suspend while --ignorelockingfailure is in force. 2009-08-02 21:03:09 +00:00
fd09a32d5e Update synopsis in lvconvert manpage to mention --repair. 2009-08-02 21:01:51 +00:00
afc5de69d4 Fix error handling of device-related stat() calls to be ENOENT aware.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:14:52 +00:00
2adec6ef66 Retrieve MD sysfs attributes for MD partitions
Rename private _primary_dev() to a public get_primary_dev() and reuse it
to allow retrieval of the MD sysfs attributes (raid level, etc) for MD
partitions.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:11:02 +00:00
5829d87313 Improve ability to lookup primary device associated with a partition
Improve lib/device/device.c:_primary_dev()'s ability to look up the
primary device associated with all partitions; including blkext
(e.g. partitions directly on MD).  The same will also work for obscure
sysfs paths; e.g.: paths with mangled names like the HP cciss driver
uses: /sys/block/cciss!c0d0/cciss!c0d0p1/

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:09:48 +00:00
4422423315 Add devices/data_alignment_detection to lvm.conf.
Adds 'data_alignment_detection' config option to the devices section of
lvm.conf.  If your kernel provides topology information in sysfs (linux
>= 2.6.31) for the Physical Volume, the start of data area will be
aligned on a multiple of the ’minimum_io_size’ or ’optimal_io_size’
exposed in sysfs.

minimum_io_size is used if optimal_io_size is undefined (0).  If both
md_chunk_alignment and data_alignment_detection are enabled the result
of data_alignment_detection is used.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:08:43 +00:00
6c88b6c660 Add devices/data_alignment_offset_detection to lvm.conf.
If the pvcreate --dataalignmentoffset option is not specified the start
of a PV's aligned data area will be shifted by the associated
'alignment_offset' exposed in sysfs (unless
devices/data_alignment_offset_detection is disabled in lvm.conf).

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:07:36 +00:00
ccca1401ae dummy makefile for now to keep builds happy 2009-07-31 18:41:19 +00:00
39270f9647 Set cookies in activation code and wait for udev to complete processing. 2009-07-31 18:30:31 +00:00
3b6a147653 Add udevcomplete and --noudevwait to dmsetup. 2009-07-31 17:51:45 +00:00
fd69075a8b another fixme 2009-07-31 16:57:06 +00:00
dfed228991 Add libdevmapper functions to support synchronisation with udev. 2009-07-31 15:53:11 +00:00
5403c6122c Fix compile warnings from recently added log_very_verbose() in _text_pv_write() 2009-07-31 14:23:06 +00:00
ec76533493 configure --udevdir 2009-07-31 13:31:53 +00:00
fbdc356b7c add not-yet-working udev options 2009-07-31 11:51:23 +00:00
709e1afd31 Prepare for udev synchronisation code. (options don't work yet) 2009-07-31 11:49:53 +00:00
217bbd0dcb Disable the "new pe_start policy"
Documented which use-cases force the reinstatement of the nuanced
handling of pe_start.  As soon as orphan PVs are eliminated much of this
will no longer be a concern ('preserve_pe_start' can be reenabled in
.pv_setup).

Added defensive 'if (pv->pe_align)' check in _text_pv_write()'s pe_start
loop.
2009-07-30 21:15:17 +00:00
e32f9edc3d Revert 'preserve_pe_start' related code in _text_pv_setup
If pv_setup was given a non-zero pe_start it would short-circuit
establishing a default pv->pe_align.  pv->pe_align=0 would result
in a divide by zero in _mda_setup().  'vgconvert -M2 $vgname' hit this.

.pv_write still properly preserves pe_start if it was supplied.
2009-07-30 18:40:22 +00:00
282029eb45 Add --dataalignmentoffset to pvcreate to shift start of aligned data area
Adds pe_align_offset to 'struct physical_volume'; is initialized with
set_pe_align_offset().  After pe_start is established pe_align_offset is
added to it.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:45:28 +00:00
0ae88174b8 Preserve pe_start in .pv_setup and .pv_write if pe_start was supplied.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:42:33 +00:00
42fdc445d0 Remove legacy support for preserving pe_start if a PV already has data
areas.

This preserved pe_start would quickly be readjusted to follow the first
mda anyway.  An example use-case that hit this code path is: running
pvcreate on an already existing PV _without_ a preceeding pvremove.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:41:01 +00:00
48416fcdc1 Fix _mda_setup() to not check first mda's size before pe_align rounding.
Without this fix rounding the end of the first mda to a pe_align
boundary could silently exceed the disk_size.

Final 'if (start1 + mda_size1 > disk_size)' block serves as a safety
net.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:19:31 +00:00
5dab79f1c7 Formalize pe_start policy as split between .pv_setup and .pv_write.
Document existing pe_start policy.
Fix issue in _text_pv_setup() where existing pe_start case could have
the pv->pe_start set to pv->pe_align even though pe_start shouldn't ever
change.

vgconvert and pvcreate have a facility to preserve the existing start
of the on-disk data extents, known as pe_start.
They indicate this by passing the existing value to the pvsetup function
which must preserve it.

This patch avoids one particular case where the value could get
changed incorrectly now that the alignment settings are configurable.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:18:03 +00:00
cfe2d71862 Document the -I option to clvmd 2009-07-30 13:32:38 +00:00
db03ac1596 corosync not cman... 2009-07-30 12:31:45 +00:00
36a1405360 Fix configure script to handle multiple clvmd selections. 2009-07-30 12:25:42 +00:00
85d1fe36e1 Fix lvm2app.pc installation filename. 2009-07-29 19:24:11 +00:00
0148ff5ea2 Don't include lvm-version.h in exported liblvm file!
Move include of lvm-version.h into lvm_base.c where it belongs.
2009-07-29 18:38:27 +00:00
89f096d68e Remove unneeded struct on return from lvm_lv_create_linear.
Results in compile warning.
2009-07-29 16:47:53 +00:00
db9a15e2fa renamed include files 2009-07-29 14:06:31 +00:00
84ae15e8d1 Remove pv_t, vg_t & lv_t handles from lib. Only liblvm uses them.
Rename lvm.h to lvm2app.h for now.
2009-07-29 13:26:01 +00:00
f69451140f Remove old custom list macros and replace with libdevmapper list
macros.
2009-07-28 21:14:12 +00:00
ca897d8d15 post-release 2009-07-28 20:47:40 +00:00
4cacc0ee7d \n 2009-07-28 20:41:41 +00:00
93148f9334 clean up a bit for release 2009-07-28 19:32:26 +00:00
9ae2f02842 pre-release 2009-07-28 17:22:07 +00:00
bc63df367d pre-release 2009-07-28 17:07:48 +00:00
3f76b672f2 Making adjustments to go along with the changes to the kernel.
A patch to the kernel, adding the 'luid' field to dm_ulog_request,
will allow us to properly identify log instances.  We will now
be able to definitively identify which logs are to be removed/
suspended/resumed.  This replaces the old faulty behavior of
assuming the logs were the same if they had the same UUID and
incrementing/decrementing a reference count.
2009-07-28 15:55:50 +00:00
c79f1d5f37 Add doxygen mainpage tag to lvm.h 2009-07-28 15:33:59 +00:00
db023c4448 Add an open_mode to the vg struct for liblvm - enforce read / write semantics.
For now, a simple way to enforce the read/write semantics is to just save the
open mode of the VG.  If the caller uses lvm_vg_create, the mode is write.
The caller using lvm_vg_open can use either read or write to open the VG.
Once we have this, we enforce the permissions on each API call and don't allow
a caller to modify a VG that has not been opened properly.

This may be better combined with the locking mode, but I view that as future
cleanup, past this initial release.  The intial release should enforce the
basic object semantics though, as described in the lvm.h file.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-28 15:14:56 +00:00
48f66c5cb4 Update interactive unit test - fix silly vg_close error. 2009-07-28 14:12:29 +00:00
f54cd61ba6 Update interactive unit test for liblvm - add vg_write, general cleanup. 2009-07-28 13:49:28 +00:00
011ec46dae Add lvm_vg_get_seqno, updating lvm.h and unit test.
Adding the ability to get the seqno is important for an application to
determine if something has changed in a VG.  Otherwise, the only way to
know is to open the VG with write permission and hold the handle.
2009-07-28 13:17:04 +00:00
6c91562aa9 Update lvm.h - remove remaining FIXMEs, note limitations of a few functions.
Almost done...
2009-07-28 13:16:40 +00:00
a3ce036dc0 Fix lvm.h formatting. 2009-07-28 12:19:58 +00:00
c82ecd6656 Add lvm_library_get_version() and update unit tests to display version. 2009-07-28 11:03:28 +00:00
7ce37c9842 Use dm_malloc and dm_free in liblvm instead of malloc/free. 2009-07-28 09:56:48 +00:00
6e4baa664d Rename lvm_create to lvm_init and lvm_destroy to lvm_quit. 2009-07-28 09:16:18 +00:00
59ffb010c4 Update lvm.h to address feeback.
This addresses a a large amount of Alasdair's review.  Subsequent patches
will address remaining issues.
Addressed:
// FIXME Mention that's also required on error.
// FIXME Be consistent in terminology.  It's called "system_dir" then last sentence says "system directory setting".  Is it referring to "system_dir" there or something else?
// FIXME Mention it frees all resources and cannot be used subsequently?
// FIXME What does "any system configuration" mean?
// FIXME Expand on that explanation a bit, now that we know what the other fns look like.
// FIXME Not sure about that - it needs to scan sometimes.  "will not" or "might not" ?
// FIXME: That's a FIXME in the code!!!
// FIXME What does "copied" mean in this context???
// FIXME Say what struct the returned struct dm_list is a list of...
// FIXME "This API" ?  This function creates an object in memory?
// FIXME This function commits the Volume Group object referenced by the VG handle to disk?
// FIXME Where is "Name" defined?  Absolute pathname?

Outstanding:
// FIXME Version function first?  No structs or handles needed for that.
// FIXME Sort out this alignment.  "Set an" directly below "system_dir" looks awful.  Indent differently?  More blank lines?
// FIXME Check how doxygen processes this.  E.g. "return: LVM handle.  You must use lvm_error() to check there were no errors and confirm that the handle is valid for passing to other functions."
// FIXME Find a better name.  lvm_init.
// FIXME Consider renaming according to the new name for lvm_create.
// FIXME Please can we use dm_malloc throughout?
2009-07-28 00:36:58 +00:00
2edb216b24 Add warning to lvm.h stating API development in progress. 2009-07-27 21:13:54 +00:00
7835e2a762 Update WHATS_NEW for latest liblvm changes 2009-07-27 21:10:30 +00:00
f8c9d0c018 Remove unnecessary \n's from log_error in liblvm. 2009-07-27 21:03:15 +00:00
2965b52563 Add config_reload and config_override to test.c, change prompt.
PV         PV UUID                                VG
  /dev/loop1 A95EvV-iqmb-ZFuJ-u8MV-Npwn-wlc2-Ul1Mnn vg1
  /dev/loop0 R16FDG-OmoS-HNGt-LSZY-OAlC-7qeU-t2gztp vg1
lvm> config_override loop0
Success overriding LVM configuration
lvm> config_reload
Success reloading LVM configuration
lvm> vg_open vg1
Couldn't find device with uuid 'A95EvV-iqmb-ZFuJ-u8MV-Npwn-wlc2-Ul1Mnn'.
Success opening vg vg1
lvm> vg_close vg1
lvm> quit

Maybe a bug in lvm_vg_open for missing pvs but the filter seems to work.

Change prompt from "lvm>" to "liblvm>".

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:02:51 +00:00
05762487ff Update return code for lvm_config_reload. 2009-07-27 21:02:35 +00:00
b2380fcc48 Add lvm_config_override - allow caller to override config, similar to --config.
Allowing the caller to override the LVM configuration with an API will
enable them to use things such as device filters.
While very flexible, there is some danger to this API in that it will
make it harder to debug setups that have a changing config and deduce
what might have happened.  At some point we may want to limit the scope
of this API but for now it is as open as the --config option to lvm commands.

Update exported symbols.  When I renamed lvm_reload_config to lvm_config_reload
I forgot to rename so I renamed that one here.

This I believe is the last liblvm API for now.  ;-)

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:02:17 +00:00
40ec4f631c Rename _override_settings into override_config_tree_from_string and move.
Move _override_settings from tools/lvmcmdline.c into lib/config/config.c
and export so we can re-use in liblvm.
2009-07-27 21:01:56 +00:00
f9238f838c Refactor _override_settings to take the new config string as input.
We will re-use this function from liblvm.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:01:36 +00:00
3dd756c2c1 Add skeletons of lvm_lv_resize and lvm_pv_resize - not yet implemented.
These lower-priority interfaces are not currently implemented in liblvm
but are on the TODO list in the near term.

Author: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:00:50 +00:00
a92bdc094d Update test/api/test.c to include lvm_vg_reduce and lvm_vg_extend.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:45:21 +00:00
9b367aa0a1 Update test/api/vgtest.c to include lvm_vg_reduce.
Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:44:58 +00:00
2201a47d95 Add lvm_vg_reduce to liblvm2app
Extend lvm_vg_write to remove pvs removed in lvm_vg_reduce. The lvm
volume_group internal structure removed_pvs is used for that. The list is
empty afterwards.

Add new test for vg->pvs emptyness to lvm_vg_write to prevent to write empty
vgs. This is needed because of lvm_vg_reduce and lv_vg_create, which creates
empty vgs.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:44:29 +00:00
bdb578fda2 Add vg_reduce to metadata.c and metadata-exported.h
This function behaves a little bit different than vg_reduce_single, because
it allowes to remove even the latest pv. This has been done to be consistent
to lvm_vg_create, which creates an empty vg.

removed_pvs has been added to the volume_group struct. vg_reduce adds remove
pvs to this list to be able to commit the changes for the pvs in lvm_vg_comm
in liblvm2app.

Initialize removed_pvs list in format-specific volume_group constructors.
Ideally, we should have a base constructor here that initializes the general
non-format specific members of struct volume_group.  But until then, there
are multiple places to initialize these members.  Maybe a better patch would
be a base constructor patch for struct volume_group.  That is more work
though.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Thomas Woerner <twoerner@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:43:39 +00:00
6765f24184 Update error return and comments for lvm_list_vg_names/uuids.
The two liblvm functions that return a list of vgnames and vguuids use
cmd->mem to allocate the list.  Make it clear to the caller that this
memory will be freed when the LVM handle is freed.

Clean up and clarify the return value of the functions.  In the
case of a memory allocation error, add a couple log_errnos to the internal
code, and make it clear that memory allocation returns a NULL pointer.
If there are no VGs in the system, the list returned is an empty list.

Make a note of the fact that currently we return hidden VG names, how
these can be detected (always start with "#"), and that they should
not be used.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 11:00:17 +00:00
5ec0df6fe1 Rename lvm_reload_config to lvm_config_reload.
The general naming scheme for most liblvm APIs is:
lvm_<object>_<action>

As there are likely to be other things to do on the lvm 'config' object
(i.e. lvm_config_set_device_filter), we should use consistent naming.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 10:18:51 +00:00
594fbed146 Update display.c to use vg_free(vg) instead of duplicating the calculation.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 10:18:31 +00:00
20e2e324e1 More liblvm header file cleanups.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 08:28:13 +00:00
f33e774f4b Update WHATS_NEW for latest liblvm changes 2009-07-26 22:19:14 +00:00
dbdce70a8e Update test/api/test.c to display lvm_lv_is_active and lvm_lv_is_suspended.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:59:02 +00:00
b41f609fe4 Update test/api/test.c to call lv_deactivate and lv_activate.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:58:38 +00:00
424f396e42 Add lvm_lv_is_active and lvm_lv_is_suspended.
Return whether an LV is active in the kernel (live table) or suspended
(table suspend).


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:58:11 +00:00
b1c01d2ac9 Implement lvm_lv_activate and lvm_lv_deactivate liblvm calls.
Limited implementation but other types of activation should probably have
separate calls.  We also currently do not handle pvmoves or lvconverts.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:57:37 +00:00
fed21338fc Update test/api/*.c to use consistent liblvm error returns.
For now, liblvm will return -1 (fail) / 0 (success) or
NULL (fail) / non-NULL (success).  Upon failure, lvm_errno and
lvm_errmsg should be used to determine the precise error.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:29:56 +00:00
987fe8b638 Update a few liblvm calls with log_errno.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:29:28 +00:00
535c4372ca Update liblvm status return codes to be consistent.
For now, we use the following scheme.
For APIs that return an int, success is 0, fail is -1.
APIs that return handles, success is non-NULL, fail is NULL.
At this early stage, liblvm error handling mechanism is subject to change,
but for now we go with this simple scheme consistent with system
programming.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:28:59 +00:00
ac1f36ae76 A few more lvm.h updates that got missed.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:49:52 +00:00
b1442a1a97 Rename lvm_scan_vgs to lvm_scan.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:44:05 +00:00
6628e7769e Update lvm.h - comments describing function behavior, divide into sections.
Hard to divide into smaller patches because of the moving around and
commenting, so just put in the new file diffs.  We will review and can
update as necessary.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:35:57 +00:00
5fadbc7f97 Update lvm.h handle and handle list comments.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:11:58 +00:00
095026b459 Rename lvm_vg_get_free to lvm_vg_get_free_size.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:46 +00:00
496c8d01fa Rename lvm_list_vg_ids to lvm_list_vg_uuids.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:21 +00:00
63574298ce Rename lvm_vg_get_free_count to lvm_vg_get_free_extent_count.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:05:49 +00:00
8c1a5f033e Update test/api/test.c to call lvm_lv_remove.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 14:37:15 +00:00
7e3141512a Add lvm_vg_remove_lv liblvm function.
Add a very simple version of lvm_vg_remove_lv.
Since we currently can only create linear LVs, this simple remove function
is adequate.  We must refactor lvremove_single a bit.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 14:36:52 +00:00
c4510327d4 Update test/api/test.c - correct list_vg_names and list_vg_ids.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 13:08:00 +00:00
88fc2bb3e1 Update test/api/test.c for liblvm 'get' functions.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 13:07:41 +00:00
75a6913f4e Add most all liblvm 'get' functions needed for anaconda.
Add the most straightforward 'get' functions required for anaconda.
These are the ones that return simple uint64_t values.
The other more complex ones involve the lv_attr bits.  These will
come in a separate patch series since each lv_attr bit will be returned
in a separate API instred of returning the string and requiring the
user to parse it.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 13:06:59 +00:00
97472070c3 Use vg_size in vg_set_extent_size.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 12:41:36 +00:00
5d4fd6055e Refactor a few report field calculations into separate functions.
For liblvm 'get' functions, we should share code with the reporting functions.
This means we need common code to return the values for the fields.
In this patch we refactor a few of the fields needed in liblvm.
Unfortunately, for the simple fields that do derefernces of structure
members (for example, vg_extent_count), we cannot call the common function
from the reporting infrastructure without more refactoring.  The reason is
that the dereference of the simple fields is done deep inside the reporting
code (to get the generic "data" pointer), and the display function is a
generic 'size32' function.  We can fix these issues later with more
refactoring.

Should be no functional change and the testsuite should cover any possible
regressions.  The only fields in the report affected by this patch are:
vg_size, vg_free, and pv_mda_count.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 12:41:09 +00:00
83f4e5b457 Rename vg_size to vgsize to avoid naming conflicts.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 12:40:27 +00:00
1523a4953f Update WHATS_NEW for recent checkins 2009-07-26 11:21:32 +00:00
429139be78 Update test/api/test.c to call lvm_vg_create_lv_linear.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:35:47 +00:00
0307c0366a Update test/api/test.c to handle read/write open modes.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:35:19 +00:00
f698db8346 Add lvm_vg_create_lv_linear liblvm function.
Create a default linear logical volume from a volume group.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:34:36 +00:00
b690ccfc20 Move extents_from_size from lvcreate into internal library so we can reuse.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:34:09 +00:00
86e97d9f87 Move _lvcreate into the internal library and rename to lv_create_single.
After some refactorings, we can now move the bulk of _lvcreate into the
internal library, and we can call from liblvm.  In the future, we should
refactor lv_create_single further, probably by segtype, to reduce the
size of struct lvcreate_params.  For now this is a reasonable refactor
and allows us to re-use the function from liblvm.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:33:35 +00:00
4a7a570953 Move pvs and pv_count fields from lvcreate_params to lvcreate_cmdline_params.
No functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:50 +00:00
0b1ce57fd1 Comment lvcreate_params struct.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:26 +00:00
eb39bfad81 Move 'size' from lvcreate_params into lvcreate_cmdline_params.
The main _lvcreate function should deal with extents - the 'size' parameter
is just an intermediate step.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:00 +00:00
77533a2090 Move percent_t from struct lvcreate_params to struct lvcreate_cmdline_params.
Create a new structure, lvcreate_cmdline_params, to store parameters only
relevant for the cmdline, not the library call to lvcreate.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:31:41 +00:00
414bc9cc44 Refactor extents calculations / updates in _lvcreate.
Move extents calculation adjustments into their own local functions
right after we read the vg.  This calculation really is not part of
the LV create function but is rather an adjustment to the parameters
based on what is given on the cmdline.  So we move it outside the main
_lvcreate.

Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:31:18 +00:00
180d55d135 Refactor _lvcreate - move *_ARG into _lvcreate_params and get 'cmd' from 'vg'.
A couple simple refactorings of _lvcreate - should be no functional change.
Move tags_ARG parsing into _lvcreate_params.  Also use lp->voriginsize
instread of arg_count().  These refactorings make it easier to move the
bulk of _lvcreate into the library.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:30:57 +00:00
458baea830 Remove use of void * from pvcreate_single.
We should use struct pvcreate_params to utilize compiler typechecking.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:02:22 +00:00
aaeec65415 Update lvm_vg_extend to do an implicit pvcreate on the device.
Although the tools do not currently do this, we update lvm_vg_extend
to do an implicit pvcreate on an uninitialized device.  The tools will
soon be refactored to do this as well, but more work is needed in the
tools.  For now we update lvm_vg_extend since this is the behavior
required by liblvm.
With this change, the simple liblvm unit test, test/api/vgtest.c
should pass whether or not the device is initialized.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:54:40 +00:00
3a821c040e Move ORPHAN_VG lock outside pvcreate_single.
The implicit pvcreate require either moving the ORPHAN_VG lock outside
pvcreate_single or somehow having the function know or detect whether
the ORPHAN_VG lock is already held.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:54:20 +00:00
31fdb438bb Change pvcreate_single to return pv_t and update function description.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:53:57 +00:00
8db00f063d Allow pvcreate_single to be called with NULL for default pvcreate params.
Passing NULL for pvcreate parameters gives you default parameters for
pvcreate_single.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:53:30 +00:00
8cca58b800 Move bulk of pvcreate logic into library.
In preparation for implicit pvcreate during vgcreate / vgextend,
move bulk of pvcreate logic inside library.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:53:09 +00:00
9f2e60598d Remove unneeded pv_create wrapper function.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:52:19 +00:00
78af10f81b Add global/wait_for_locks to lvm.conf so blocking on locks can be disabled. 2009-07-24 23:28:55 +00:00
025ac59005 remove no-longer-needed NONBLOCK 2009-07-24 18:26:42 +00:00
2b9605e8f5 All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros. 2009-07-24 18:15:06 +00:00
333091a0d3 Eliminate compile warning introduced by previous commit. 2009-07-24 15:15:26 +00:00
012ff9982c Update lvm_vg_extend() to obtain VG_ORPHAN.
vg_extend() no longer obtains VG_OPHAN so we must do so in liblvm function.
We still have the race in liblvm but we will address this problem later.
2009-07-24 15:12:50 +00:00
887e1d5d61 Revert previous patch that moved VG_ORPHAN lock inside vg_extend.
We must hold the VG_ORPHAN lock until we commit to disk.  Otherwise,
we risk a race condition on vgcreate / vgextend.  Reverts the following
commit:

commit 72a41480ba
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Fri Jul 10 20:09:21 2009 +0000

    Move orphan lock obtain/release inside vg_extend().

    With this change we now have vgcreate/vgextend liblvm functions.
    Note that this changes the lock order of the following functions as the
    orphan lock is now obtained first.  With our policy of non-blocking
    second locks, this should not be a problem.

    Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 15:01:43 +00:00
3aca463e7e Add tests for lvm_vg_name_list, lvm_vg_id_list and lvm_scan_vgs.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:51:32 +00:00
b7255dac54 Add lvm_scan_vgs liblvm fn to scan the system for LVM metadata.
The lvm_list_vg_{names|ids} functions do not do a scan so we provide
a liblvm function that does a scan.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:48:21 +00:00
a3158f498f Add lvm_list_vg_names and lvm_list_vg_ids liblvm functions.
These functions provide the capability of enumerating all vgnames and
vgids in the system.  They do not do a scan of the system.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:47:15 +00:00
95ff997d1d Remove redundant validate_name in vgreduce.
This check is now done in vg_read_for_update, thanks to mornfall.
Should be no functional change.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 11:13:36 +00:00
80520d4ed7 Update test/api/test.c to not segfault if null lists of pvs/lvs returned.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 04:15:30 +00:00
1fbf5728e1 Update WHATS_NEW for liblvm commits 2009-07-23 23:55:01 +00:00
216b6b3efd Update test/api/test.c for simple tests involving pv/vg/lv name/uuid attributes.
Tests the following APIs:
- lvm_{pv|vg|lv}_get_{name|uuid}()
- lvm_{lvs|pvs}_in_vg()

Example:
lvm> vg_open VolGroup00
Success opening vg VolGroup00
lvm> vg_list_lvs VolGroup00
LVs in VG VolGroup00:
VolGroup00/LogVol00 (bFO4EU-UaDu-iuMm-N6BA-xcZc-nm3u-J5K5lu)
VolGroup00/LogVol01 (BHGsPK-PwzY-kye0-MEWa-a67z-BiYE-03ZjwM)
lvm> vg_list_pvs VolGroup00
PVs in VG VolGroup00:
/dev/sda2 (Be91pt-CqT0-4YJE-nGI6-Oisz-hy0N-l9CHgn)

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:40:50 +00:00
557f287005 Add lvm_{pv|vg|lv}_get_{uuid|name}.
Caller must free the memory of the uuid / name returned.
This may not be the best memory management policy since it may lead to
memory leaks if the caller has code like this:
if (!lvm_vg_get_name(vg))

Maybe we don't care - if we do we can use pools tied to handles later
or some other scheme.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:40:05 +00:00
7548112578 Add lvm_vg_list_{pvs|lvs} - return lists of pv/lv handles for a vg.
- Use vgmem pool to allocate a list of lvm_*_list structs
- Allocate a new list each call (list may have changed since last call)
- Add to liblvm's exported symbols

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:39:02 +00:00
323685d4c9 Add list structure definitions for liblvm objects.
- pv_t, vg_t, lv_t
- include libdevmapper.h: needed for struct dm_list

These list structures will be needed in later APIs to return a list of
handles to one object, given another object.  For example, lvm_vg_list_lvs()
will return a list of LV handles (lv_t's) given a VG handle (vg_t).  We
need a structure to do this so we define the LV structure, as well as the
other structures at this point.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-23 23:37:24 +00:00
4900b15a65 Remove lvseg_t and pvseg_t typedefs from liblvm/lvm.h.
We do not need lvseg and pvseg for now.  If we need we will add back
later.
2009-07-23 23:36:20 +00:00
adc02e52ad check in the correct pkgconfig file 2009-07-23 01:41:53 +00:00
4bc79321a7 Update lvm_vg_create to use NULL / non-NULL return for the time being.
Some of the error interface is still TBD.  Rather than exporting a lot
of codes, etc, just use a simple pass / fail.  The allows our unit test
to not segfault if trying to create a VG that already exists.
2009-07-23 01:20:22 +00:00
c0d270947f Add a couple lvm_vg_open() calls to vgtest.c. 2009-07-22 22:25:30 +00:00
8b4677dca3 Add lvm_vg_open() to open an existing VG for reading or writing.
lvm_vg_open() calls internal vg_read() function which is the entry point
for reading an existing VG.  In addition to the mode, we include a 'flags'
parameter for future extensions.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 22:24:16 +00:00
44482a809e Add liblvm2app Makefile installation targets.
Add liblvm pkgconfig file.
2009-07-22 21:09:13 +00:00
90d8fab02e fix dir in generated file list for cflow 2009-07-22 20:29:56 +00:00
337d248c5d Use newly-independent LVM_LIBAPI in liblvm soname. E.g. liblvm2app.so.2.1. 2009-07-22 20:12:14 +00:00
62a636c887 Add an API version number, LVM_LIBAPI, to the VERSION string. 2009-07-22 20:01:28 +00:00
bbd12ca7aa Update api/test/vgtest.c error handling.
Reverts some of my 'cleanup' from last night.  For now we will use pass/fail
on API calls (either 'int' return or NULL/non-NULL handle), then use
lvm_errno() to get more specific errors.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 16:49:54 +00:00
02f858e5c9 Update test/api/vgtest.c to use lvm_errno and lvm_errmsg.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 03:13:57 +00:00
536a126886 Fix lvm_vg_close() when locking fails.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 03:13:35 +00:00
2a42fdea85 Export lvm_errno and lvm_errmsg in liblvm.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 03:13:13 +00:00
eb77e55fe6 Pass struct cmd_context as a first argument to init_multiple_segtypes.
Remove redundant assignment seglib.cmd = cmd (done already at the beginning
of the function).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2009-07-21 20:00:02 +00:00
edd643b226 After rebasing the cluster logging code, adjustments need to be
made to compensate for the changes in the kernel-side component
that recently went upstream.  (Things like: renamed structures,
removal of structure fields, and changes to arguments passed
between userspace and kernel.)
2009-07-21 15:34:53 +00:00
4f7f3b5a50 Rebasing the cluster log daemon code from the most current
sources in the 'cluster' tree.  There have been a number of
bug fixes and I don't want to loose them.
2009-07-21 15:32:13 +00:00
1b611e7cd8 Fix build environment of test/api: Make it usable for more than one test case.
Author: Thomas Woerner <twoerner@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-07-21 13:51:05 +00:00
5454ec8f9b Return EINVALID_CMD_LINE not success when invalid VG name format is used. 2009-07-21 11:10:49 +00:00
d2d528d214 Rename test/api/vgcreate.c to vgtest.c to reduce filename conflicts in tree.
Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-21 10:46:45 +00:00
a00d4b7845 Fix compile warnings in vgcreate liblvm api unit test case.
Use const and PRIu64.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Thomas Woerner <twoerner@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-07-21 10:41:47 +00:00
0eeefc4c0d Cast MINOR() in _md_sysfs_attribute_snprintf()'s dm_snprintf() call. 2009-07-20 18:44:13 +00:00
0d8600ed6d Cast MAJOR() and MINOR() to int when used with "%d" in dm_snprintf() call.
Fixes SEGV in _md_sysfs_attribute_snprintf() on 32-bit systems.
2009-07-20 18:33:16 +00:00
35cf511d45 Remove 'is already' message from vg_set_* functions.
These messages are unnecessary in the set functions.  We check for this
condition and print a message in the vgchange tool but not the library
functions.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-16 20:18:16 +00:00
b88fe43808 Fix so only log_error and log_fatal set EUNCLASSIFIED. 2009-07-16 13:13:33 +00:00
9c72fc1d2b Remove extraneous messages for extent_size and alloc_policy upon vgcreate.
When converting to the new liblvm functions, the vgcreate code path
changed to create a new vg, then set values.  As a result of this
change, and the fact that we give a user a message if they try to
set the same value of a VG attribute (extent_size, alloc_policy, etc),
you'll see these 2 extraneous "is already" messages with vgcreate:
tools/lvm vgcreate vg2 /dev/loop2
  Physical extent size of VG vg2 is already 4.00 MB
  Volume group allocation policy is already normal
  Volume group "vg2" successfully created

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-16 03:25:26 +00:00
e176789891 Change default errno value to 0 (no error) and add prototypes in lvm.h
Since we are using errno values, we should use '0' as a default value
which indicates a non-error, rather than defining some made-up default
value that is not defined in errno.  If we need to deviate from errno
values, this will most likely indicate a flaw in our design.

Add prototypes for lvm_errno and lvm_errmsg inside lvm.h and provide
a basic description of their function.  This fixes a couple compile
warnings.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-16 03:07:45 +00:00
5e3369aba3 Add log_errno to set a specific errno and replace log_error in due course. 2009-07-16 00:52:06 +00:00
7b0fcd79a0 Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
Change create_toolcontext to still return an object if it fails part-way.
Add EUNCLASSIFIED (-1) as the default LVM errno code.
2009-07-16 00:36:59 +00:00
0ed40c04c7 Store any errno and error messages issued while processing each command.
(Enabled by default while we test it, but in due course we'll only store
the error messages when we need to.)
2009-07-15 23:57:54 +00:00
7da36611dc Use log_error macro consistently throughout in place of log_err. 2009-07-15 20:02:46 +00:00
49aeee3017 Revert broken commit:
2009-07-15 06:10:51  Un-export vg_read_internal.

lvm-functions.c:774: warning: implicit declaration of function 'vg_read_internal'
2009-07-15 17:26:26 +00:00
571cd5a94f post-release 2009-07-15 15:38:41 +00:00
a044570365 pre-release 2009-07-15 15:16:48 +00:00
c18595ce31 pre-release clarification 2009-07-15 14:59:14 +00:00
a06d6839e1 New LOG_MESG macro to fix file/line number logging for memory leaks after
LOG_LINENO macro was added.
2009-07-15 14:18:38 +00:00
22ba3c7b41 pre-release 2009-07-15 13:20:06 +00:00
e84ecd9e42 Fix memory leak in process_each_pv path.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-15 12:22:59 +00:00
db5e7962c9 Fix memory leak in _process_one_vg error path.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-15 12:15:36 +00:00
4782f379e2 Fix warning. 2009-07-15 06:11:25 +00:00
8762b5aad4 Un-export vg_read_internal. 2009-07-15 06:10:51 +00:00
147d76d2aa Fix bad prototype from previous checkin. 2009-07-15 05:57:11 +00:00
a5aedfee75 Port process_each_pv to new vg_read. 2009-07-15 05:50:22 +00:00
2a4c743edd Remove lockingfailed().
We provide a lock type that behaves like no_locking, but is not
  clustered. Moreover, it also forbids any write locks. This magically (and
  consistently) prevents use of clustered VGs, or changing local VGs with
  --ignorelockingfailure. As a bonus, we can remove the special hacks in a few
  places. Of course, people looking for trouble can always set their locking_type
  to 0 to override.
2009-07-15 05:49:47 +00:00
a9d820ed2f Take just a read lock when activating in lvchange. 2009-07-15 05:48:36 +00:00
fa059a59a8 Refuse to open VG with MISSING_PVs for update unless handles_missing_pvs is set. 2009-07-15 05:47:55 +00:00
dc8f5ef279 Check for certain vg_read errors in _process_one_vg iterator.
In _process_one_vg, we should never proceed if the VG read fails with certain
conditions.  If we cannot allocate or construct the volume_group structure,
we should not proceed - this is true regardless of the tool calling the
iterator.  In other cases, when the volume group structure is constructed but
there is some error (PVs missing, metadata corrupted, etc), some tools may
want to process the VG while others may not.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-15 05:23:19 +00:00
e5e30dc73d Fix FAILED_INCONSISTENT case in vg_backup_single - typeo on 'if' condition.
In vg_backup_single, we should error out if we vg_read_error(vg) and the
error code we received was anything other than FAILED_INCONSISTENT.
Original code contained an error because C operator precedence.
Note - this was part of the vg_read() so no WHATS_NEW entry neceesary.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-15 03:30:04 +00:00
ae94917e76 Fix pvremove test breakage.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-14 19:59:41 +00:00
fedb3704f3 Fix vgck and vgremove segfault if non-existent vg given.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-14 19:37:18 +00:00
ea18f8e19b Add a few negative tests which should fail cleanly if pv, vg, lvs don't exist.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-14 19:35:35 +00:00
cd93b0470b Enable use of new multi-segment registration for static registration too.
so it allows this use:

#ifdef MYNEWSEG_INTERNAL
        if (!init_mynewseg_segtypes(&seglib))
                        return 0;
#endif
2009-07-14 12:17:14 +00:00
4665b5aecf Exclude VG_GLOBAL from vg_write_lock_held so scans open devs read-only again. (mbroz) 2009-07-14 11:01:26 +00:00
1f9b9c6235 Add liblvm test case for creating of a vg.
liblvm unit test case uses the following APIs:
- lvm_create, lvm_destroy
- lvm_vg_create, lvm_vg_extend, lvm_vg_set_extent_size, lvm_vg_write,
lvm_vg_remove, lvm_vg_close

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:08:56 +00:00
3f4c43456f Add VG APIs to liblvm/.exported_symbols.
Add the following VG APIs to liblvm/.exported_symbols:
-lvm_reload_config
-lvm_vg_create
-lvm_vg_extend
-lvm_vg_set_extent_size
-lvm_vg_write
-lvm_vg_close
-lvm_vg_remove

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:02:44 +00:00
10a3ba33a5 Add lvm_vg_* APIs to create and modify VGs.
Add some liblvm APIs for VGs.  Most of these APIs simply call into the internal
liblvm library.  Ideally we should call the liblvm functions directly from
the tools.  However, until we convert more of the code to liblvm functions,
things like the cmd_context will get in the way.  For now just implement the
liblvm functions as wrappers around the internal functions, with a little
error checking and return code handling.  We put all these vg APIs into a
new file, lvm_vg.c

The following APIs are implemented:
lvm_vg_create, lvm_vg_extend, lvm_vg_set_extent_size, lvm_vg_write,
lvm_vg_remove, lvm_vg_close.

Still TODO:
- cleanup error handling by using lvm_errno() and related APIs
- cleanup naming / clarify which functions commit to disk vs not
- implement more 'set' functions
- decide on 'set' / 'change' nomenclature

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:02:14 +00:00
db0beacf02 Add default cmd->cmd_line initialization for liblvm lvm_create().
This needs initialized to non-NULL before using the archive() call.
Normally this is set to the cmdline string when lvm is called from a tool.
We could think about using it in another way, as a potential audit trail
of liblvm calls, or just leave it set to the default "liblvm", similar to
what clvmd does.  For now, just set it to "liblvm".

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:01:18 +00:00
a07023d613 Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg.
Define the 5 main liblvm objects to be the pv, vg, lv, lvseg, and pvseg.
We need handles defined to all these objects in order for liblvm to be
equivalent to the reporting commands pvs, vgs, and lvs.

- move vg_t, lv_t, and pv_t from metadata-exported.h into lvm.h
- move lv_segment and pv_segment forward declarations into lvm.h
- add lvseg_t and pvseg_t to lvm.h

NOTE: We currently have an inconsistency in handle definitions.
lvm_t is defined as a pointer, while these other handles are just
structures.  We should pick one scheme and be consistent - perhaps
define all handles as pointers (this is what I've seen elsewhere).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:00:30 +00:00
900c634af1 Remove READ_REQUIRE_RESIZEABLE flag from vg_read() interface - no users.
The checks for RESIZEABLE_VG should now be inside the various functions that
have to do such operations.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 02:19:19 +00:00
48d9b570b9 Remove READ_REQUIRE_RESIZEABLE flag from vgsplit.
Remove READ_REQUIRE_RESIZEABLE flag from vgsplit similar to the removal from
vgextend.  Move the check inside the functions that actually move pvs from
one vg structure to another.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 02:16:05 +00:00
207ddca859 Refactor vgsplit - move move_pvs_used_by_lv and move_pv inside library.
In the future we may export these functions or something like them in liblvm
For now this helps in cleaning up the checks for RESIZEABLE since we can
use the internal library function vg_bad_status_bits.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 02:15:21 +00:00
823b00705e Remove READ_REQUIRE_RESIZEABLE from vgextend by moving check inside vg_extend.
Move the check for the RESIZEABLE flag inside the vg_extend function.
When we consolidated the vg locking, reading, and status flag checking,
we tied the check for the RESIZEABLE flag to the vg_read() call.  The problem
with this is you cannot know what other APIs the application my or may not
call after a vg_read() call.  Thus the READ_REQUIRE_RESIZEABLE flag is not
really ideal - ideally we should be checking for this flag on a specific
operation, not inside the vg_read() call.  This patch moves one check inside
the library.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 02:14:04 +00:00
4fb0ddedc7 WHATS_NEW 2009-07-13 23:16:17 +00:00
31b3571d31 Change exit() to _exit() in the child process. exit flushes stdio file buffers,
_exit doesn't. If there were some open files, an error in exec and subsequent
exit() would cause the buffers to be flushed twice.

Example:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

int main()
{
	printf("buu");
	if (!fork()) {
		execl("/bin/true-not-exists", "/bin/true", NULL);
		exit(1);
	}
	wait(NULL);
	return 0;
}

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com

---
 daemons/dmeventd/libdevmapper-event.c |    2 +-
 lib/misc/lvm-exec.c                   |    2 +-
 test/harness.c                        |    3 ++-
 tools/dmsetup.c                       |    2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)
2009-07-13 21:26:41 +00:00
ee373a2721 Suppress warning on 64-bit big-endian computers (Sparc 64).
xlate64 produces unsigned long long type, but PRIu64 is defined
to accept argument unsigned long type (on 64-bit machines).

On existing machines, both types have the same size, so it works,
but it is still wrong and produces a warning.

Fix it by using a cast to uint64_t --- according to the standard,
PRIu64 argument matches type uint64_t.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2009-07-13 21:23:48 +00:00
685bc7ae83 Make cmd->cmd_line const. 2009-07-13 19:49:48 +00:00
bc6772282f Get rid of the mdadm presence check in t-000-basic: no actual test uses
it. When we need mdadm in the tests, we can easily do 'which mdadm || exit 200'
to skip the test.
2009-07-13 12:42:26 +00:00
d0d0c1e5e5 Fix dev name mismatch in vgcreate man page example. 2009-07-13 11:25:35 +00:00
1ed598ada6 Remove unused code vg_lock_and_read() and related flags.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 21:19:37 +00:00
b003ae7270 Update WHATS_NEW for vgremove and ORPAHN_LOCK refactoring 2009-07-10 20:16:15 +00:00
18a4a3e21c Change lock ordering of vgcfgrestore to be consistent with other tools.
Orphan lock is now obtained second and released first, and all tools
are consistent in this regard.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 20:10:18 +00:00
72a41480ba Move orphan lock obtain/release inside vg_extend().
With this change we now have vgcreate/vgextend liblvm functions.
Note that this changes the lock order of the following functions as the
orphan lock is now obtained first.  With our policy of non-blocking
second locks, this should not be a problem.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 20:09:21 +00:00
6e221abda6 Move orphan lock inside vg_remove_single.
Move the vg orphan lock inside vg_remove_single, now a complete liblvm
function.  Note that this changes the order of the locks - originally
VG_ORPHAN was obtained first, then the vgname lock.  With the current
policy of non-blocking second locks, this could mean we get a failure
obtaining the orphan lock.  In the case of a vg with lvs being removed,
this could result in the lvs being removed but not the vg.  Such a
scenario could have happened prior though with a different failure.
Other tools were examined for side-effects, and no major problems
were noted.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 20:08:37 +00:00
e7d8b84581 Remove force parameter from vg_remove_single, now the liblvm function.
Move check for active LVs outside of library function.  The vgremove
liblvm function function will fail if there are active LVs.  It will
be the application's responsibility to check this condition and remove
the LVs individually before calling vgremove.  Note also that we've
duplicated the EXPORTED_VG check in vgremove_single (tools) and
vg_remove_single (library).  Duplication seemed the only option here
since we don't want to do the automatic removal of LVs (in the tools)
if the vg is exported, and we still need to protect the library call
from removal if the vg is exported.

We still need to deal with the ORPHAN lock but vg_remove_single is now
very close to our liblvm function.

TODO: Refactor lvremove in a similar way.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 20:07:02 +00:00
7a84430e84 Remove unnecessary parameters from vg_remove_single().
Use vg_t instead of struct volume_group.
Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-10 20:05:29 +00:00
7e7274b002 Add dm_log_with_errno and dm_log_with_errno_init, deprecating the old
Change plog to use dm_log_with_errno unless deprecated dm_log_init was used.
Rename plog macro to LOG_LINE and use in dm_dump_memory_debug.
2009-07-10 09:59:37 +00:00
e27183d54f Check MD devices for a partition table during device scan. 2009-07-09 22:50:45 +00:00
f49c31ddb2 Add extended device (blkext) and MD partition (mdp) types to filters.
Both types were added with a 'max_partitions' of 1 because these devices
are _not_ partitionable (they are the partitions).
2009-07-09 22:34:02 +00:00
ac959238aa Fix and precise metadata read errors for segment areas. 2009-07-09 11:29:41 +00:00
563b6561a5 Fix confusing metadata syntax error messages.
If there is syntax error in metadata, it now prints messages
like:
  Couldn't read 'start_extent' for segment 'extent_count'.
  Couldn't read all logical volumes for volume group vg_test.

The segment specification is wrong and confusing.

Patch fixes it by introducing "parent" member in config_node which
points to parent section and config_parent_name function, which
provides pointer to node section name.

Also it adds several LV references where possible.
2009-07-09 11:29:00 +00:00
bc26690cbf Fix segment import functions to print segment name and logical volume name. 2009-07-09 11:28:09 +00:00
4f56896f60 Update WHATS_NEW for recent vgcreate changes 2009-07-09 10:19:07 +00:00
5158d34c2d Change vg_create() to take only minimal parameters and obtain a lock.
vg_t *vg_create(struct cmd_context *cmd, const char *vg_name);
This is the first step towards the API called to create a VG.
Call vg_lock_newname() inside this function.  Use _vg_make_handle()
where possible.
Now we have 2 ways to construct a volume group:
1) vg_read: Used when constructing an existing VG from disks
2) vg_create: Used when constructing a new VG
Both of these interfaces obtain a lock, and return a vg_t *.
The usage of _vg_make_handle() inside vg_create() doesn't fit
perfectly but it's ok for now.  Needs some cleanup though and I've
noted "FIXME" in the code.

Add the new vg_create() plus vg 'set' functions for non-default
VG parameters in the following tools:
- vgcreate: Fairly straightforward refactoring.  We just moved
vg_lock_newname inside vg_create so we check the return via
vg_read_error.
- vgsplit: The refactoring here is a bit more tricky.  Originally
we called vg_lock_newname and depending on the error code, we either
read the existing vg or created the new one.  Now vg_create()
calls vg_lock_newname, so we first try to create the VG.  If this
fails with FAILED_EXIST, we can then do the vg_read.  If the
create succeeds, we check the input parameters and set any new
values on the VG.

TODO in future patches:
1. The VG_ORPHAN lock needs some thought.  We may want to treat
this as any other VG, and require the application to obtain a handle
and pass it to other API calls (for example, vg_extend).  Or,
we may find that hiding the VG_ORPHAN lock inside other APIs is
the way to go.  I thought of placing the VG_ORPHAN lock inside
vg_create() and tying it to the vg handle, but was not certain
this was the right approach.
2. Cleanup error paths. Integrate vg_read_error() with vg_create and
vg_read* error codes and/or the new error APIs.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:09:33 +00:00
5c63f0b7e3 Add vg_set_alloc_policy() liblvm function and move vgchange logic inside.
NOTE: vg_set_alloc_policy() returns success if you try to set a value that
is already stored.  The behavior of vgchange is the same though - it fails.
There is a fixme noted in the code about this inconsistency, which should
be resolved if possible.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:08:54 +00:00
1b3fa825f3 Add vg_set_max_pv() liblvm function and move vgchange logic inside.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:07:47 +00:00
ef182f4b64 Add vg_set_max_lv() liblvm function and move vgchange logic inside.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:06:00 +00:00
b706479c9b Rename vg_change_pesize to vg_set_extent_size and use vg_t.
In liblvm, we will reserve the word 'change' to mean an API that
both sets one or more values, and commits to disk.  This will be
consistent with the LVM commandline.  The existing vg_change_pesize()
function does not commit to disk, but just changes the extent_size
and ensures all internal structures are updated.  This logic should
be contained in a function that sets the value.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:04:52 +00:00
751c4fe7ef Remove unused 'cmd' from vg_change_pesize().
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:03:37 +00:00
d09baef532 Update vg_change_pesize() to contain all validity checks.
It would be nice to have one function that does all the validation
and setting of the VG's pesize.  However, currently some checks
are in the higher-level function _vgchange_pesize(), and some
checks are in the lower function vg_change_pesize().
This patch moves most of the higher-level checks inside
vg_change_pesize.  In one case a failure return code is
changed from ECMD_FAILED to EINVALID_CMD_LINE.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 10:02:15 +00:00
778244e436 Add defines for default vgcreate parameters. 2009-07-09 10:00:36 +00:00
f6cf83aebf Update t-vgcreate-usage.sh to check for default vg properties. 2009-07-09 08:50:55 +00:00
e6901382a6 Fix memory leak in vgsplit when re-reading the VG.
Call vg_release() before re-reading the vg.
Remove vgsplit whitespace and update copyright.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-09 05:40:59 +00:00
75c22b585e . 2009-07-08 22:22:12 +00:00
5018d3b5cb Make exit paths more robust when some init function fails.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 22:18:32 +00:00
9eeacf2cfc Refactor a couple log_error() statements in prep for larger log_error() patch.
Part of twoerner's log_error() patches.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 18:15:51 +00:00
9c25d59b82 Add t-lvm-init.sh - test lvm init routines and error paths. 2009-07-08 18:14:47 +00:00
4550133c81 Fix segfault in persistent_filter_dump() if lvm init fails.
Just return_0 in persistent_filter_dump() if passed a NULL filter;
2009-07-08 18:13:32 +00:00
8a5921e4bc Make destroy_toolcontext() better able to handle NULL pointers.
Part of twoerner's log_error() patches.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 18:12:08 +00:00
470aa36c91 Update WHATS_NEW for vgread cleanup 2009-07-08 14:41:00 +00:00
1fbcff5fcc Remove unneeded LOCK_NONBLOCKING from vg_read() API.
Remove unneeded LOCK_NONBLOCKING from vg_read() API and tools that
use it.  We no longer need this flag anywhere since we now automatically
set LCK_NONBLOCK inside lock_vol() if vgs_locked().
For further details, see:
commit d52b3fd3fe
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Wed May 13 13:02:52 2009 +0000

    Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.

    As a simplification to the tools and further liblvm, this patch pushes
    the setting of NON_BLOCKING lock flag inside the lock_vol() call.
    The policy we set is if any existing VGs are currently locked, we
    set the NON_BLOCKING flag.

At some point it may make sense to add this flag back if we get an
RFE from a liblvm user, but for now let's keep it as simple as
possible.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 14:33:17 +00:00
6fb06af9ff Remove READ_CHECK_EXISTENCE and vg_might_exist().
Remove READ_CHECK_EXISTENCE and vg_might_exist().
This flag and API is no longer used now that we have a separate
API to check for existence.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 14:31:17 +00:00
62941d65a9 Remove unneeded LOCK_KEEP from vg_read() interface.
Remove unneeded LOCK_KEEP from vg_read() interface.
Update comment to clarify cases where _vg_lock_and_read() may return
with an error but the lock held.  Would be nice to make the vg_read()
interface consistent with regards to lock held and error behavior.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 14:28:30 +00:00
18fe170698 Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.
Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.
These flags are no longer necessary.  We now check for existence
in a differnet function, and it is not necessary to keep the lock.
Removing these flags simplifies the new vg_read() interface.
After this patch, we can fully remove LOCK_KEEP.
READ_CHECK_EXISTENCE needs a bit more work before full removal.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 14:27:37 +00:00
c2cd4d5d15 Permit several segment types to be registered by a single shared object. 2009-07-08 12:36:01 +00:00
69da2ac0c7 Continue to make --units and --size consistent (in code and man pages):
Update units_to_bytes() to support (S)ectors: 500 bytes.
- 500 byte (S)ectors is of questionable value but it adds to consistency
  if a user happens to use --units S.  This seems better than an error.

Updated test/t-covercmd.sh to test --units [hS]

Document the units that can be displayed via --units uniformly.
- (p)etabytes and (e)xabytes were missing in pvs, vgs and lvs man pages.

Made lvreduce man page "... in units of megabytes." consistent (with the
lvextend and lvresize man pages).
2009-07-07 19:28:57 +00:00
e08e69719d . 2009-07-07 17:19:38 +00:00
5628024d45 Fix whitespace in linear target line to fix identical table line detection.
(only tested with linear so far)
2009-07-07 16:36:05 +00:00
9d46d25d03 Fix compile warning in lvmcmdline.c - use C99 PRIu64 for uint64_t.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-07 01:51:00 +00:00
836326f31e Fix vg_read() error paths to properly release upon vg_read_error().
Fix vg_read() error paths to properly release upon vg_read_error().
Note that in the iterator paths (process_each_*()), we release
inside the iterator so no individual cleanup is needed.  However there
are a number of other places we missed the cleanup.  Proper cleanup
when vg_read_error() is true should be calling vg_release(vg), since
there should be no locks held if we get an error (except in certain
special cases, which IMO we should work to remove from the code).

Unfortunately the testsuite is unable to detect these types of memory
leaks.  Most of them can be easily seen if you try an operation
(e.g. lvcreate) with a volume group that does not exist.  Error
message looks like this:
  Volume group "vg2" not found
  You have a memory leak (not released memory pool):
   [0x1975eb8]
  You have a memory leak (not released memory pool):
   [0x1975eb8]


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-07 01:18:35 +00:00
34fe80f9d9 Reword the WHATS_NEW commandline sizes update. 2009-07-06 19:17:15 +00:00
15ae133662 Allow commandline sizes to be specified in terms of bytes and sectors.
Update the man pages to document size units uniformly.
2009-07-06 19:13:26 +00:00
c405a5d5b3 Use the MD device's stripe-width, instead of chunk_size, to align the
data blocks of a Physical Volume that is placed directly upon an MD
device.
2009-07-06 19:04:24 +00:00
7acff3b938 Add device number to more log messages during activation. 2009-07-03 12:45:55 +00:00
7099be8f44 clarification 2009-07-03 11:04:06 +00:00
86e8c36a75 Update WHATS_NEW for vg_read commits 2009-07-01 17:23:10 +00:00
bc6fe86faa Fix t-inconsistent-metadata.sh.
Sun May  3 13:25:10 CEST 2009  Petr Rockai <me@mornfall.net>
  * All tools now handle inconsistent metadata the same way.

Rebase 6/26/09
2009-07-01 17:06:04 +00:00
3bcab11310 Add lvmcache_init() to polldaemon initialization.
Signed-off-by: Petr Rockai <me@mornfall.net>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-01 17:05:12 +00:00
3c8b92675f Convert vgsplit to use vg_read_for_update.
Sun May  3 13:12:28 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert vgsplit to use vg_read_for_update.


Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-07-01 17:04:21 +00:00
0f19d74cb1 Don't segfault in vg_release when vg->cmd is NULL.
Sun May  3 13:06:14 CEST 2009  Petr Rockai <me@mornfall.net>
  * Don't segfault in vg_release when vg->cmd is NULL.


Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-07-01 17:03:38 +00:00
d796a2a768 Convert vgrename to vg_read_for_update.
Sun May  3 12:54:28 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert vgrename to vg_read_for_update.

Rebased 6/26/2009 - Dave W.

Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-07-01 17:02:18 +00:00
f962adbb52 Convert vgreduce to use vg_read_for_update.
Sun May  3 12:50:58 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert vgreduce to use vg_read_for_update.

Rebased 6/26/2009 - Dave W.
2009-07-01 17:01:46 +00:00
3479d0ee30 Rework the toollib interface (process_each_*) on top of new vg_read.
Sun May  3 12:32:30 CEST 2009  Petr Rockai <me@mornfall.net>
  * Rework the toollib interface (process_each_*) on top of new vg_read.

Rebased 6/26/09 by Dave W.
- Add skipping message to process_each_lv
- Remove inconsistent_t.
2009-07-01 17:00:50 +00:00
70a0590ece Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).

Rebased 6/26/09 by Dave W.
2009-07-01 16:59:37 +00:00
8414c57026 post-release 2009-07-01 09:31:46 +00:00
ae2e7f0603 update date 2009-06-30 18:41:47 +00:00
7177c3b393 pre-release tidy up 2009-06-30 18:39:31 +00:00
11f40ba93b Fix incomplete revert for lvconvert. 2009-06-26 11:29:06 +00:00
273511037a pre-release 2009-06-26 10:57:30 +00:00
56d64f23bf revert last patch - let's do a release first 2009-06-26 10:55:57 +00:00
cfbeca5e65 Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).


Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-06-26 09:47:36 +00:00
aaf9b56084 Abort if automatic metadata correction fails when reading VG to update it. 2009-06-26 09:19:13 +00:00
e0a953e27e Abort operation if automatic metadata correction in lvconvert fails. 2009-06-26 09:03:59 +00:00
f7c1e5f60d Fix backward compatibility for major:minor query.
Is an application uses query and set major:minor
to device, it should not fallback to default major by default.

Add new function whoich allows that (and use it in lvm2).
2009-06-17 20:55:24 +00:00
84bf81ac31 Properly destroy toolcontext.
(fixes previous commit)
2009-06-17 20:54:20 +00:00
6a67a8c574 Various vgimportclone fixes:
- validate the specified device is a PV and that it is in a VG
- automatically enable DEBUG (-d) if >= 4 -v instances were supplied
- preserve TMP_LVM_SYSTEM_DIR if it contains an lvm.conf and -d was
  specified
- fix handling of special-case where PV is listed as "unknown device"
- more descriptive error when a PV is missing ("unknown device")
- unset LVM_SYSTEM_DIR if it was not originally set
- skip final vgscan if no changes were made
2009-06-17 15:47:01 +00:00
0fad9eaee4 Cleanup pvs, vgs, and lvs "-o" section in man pages (rhbz 500861).
http://bugzilla.redhat.com/show_bug.cgi?id=500861
- Update list of fields/columns for each command (a few missing).
- Update list order to match "-o help" output (easier to verify field list)
- Add "{pv|vg|lv}_all" description.
- Move "-o help" sentence above column/field list.

New sample man page for lvs (pvs and vgs are similar):
       -o, --options
              Comma-separated ordered list of columns.  Precede the list  with  ’+’  to  append  to  the
              default selection of columns instead of replacing it.

              Use  -o  lv_all to select all logical volume columns, and -o seg_all to select all logical
              segment columns.

              Use -o help to view the full list of columns available.

              Column names  include:  lv_uuid,  lv_name,  lv_attr,  lv_major,  lv_minor,  lv_read_ahead,
              lv_kernel_major,  lv_kernel_minor,  lv_kernel_read_ahead, lv_size, seg_count, origin, ori-
              gin_size, snap_percent, copy_percent, move_pv, convert_lv, lv_tags,  mirror_log,  modules,
              segtype,  stripes,  stripesize,  regionsize, chunksize, seg_start, seg_start_pe, seg_size,
              seg_tags, seg_pe_ranges, devices.

              With --segments, any "seg_" prefixes  are  optional;  otherwise  any  "lv_"  prefixes  are
              optional.  Columns mentioned in vgs (8) can also be chosen.

              The lv_attr bits are:
2009-06-15 17:09:32 +00:00
d64d33ed07 Add WHATS_NEW items. 2009-06-15 15:09:02 +00:00
0e8fdf49d0 - Ignore suspended devices during repair (Milan).
- Call vgreduce --removemissing (without --force) automatically to clean up bad
  PVs (Milan).
2009-06-15 14:47:39 +00:00
f147256697 Suggest use lvchange --resync when up converting not yet synced mirror. 2009-06-15 13:43:15 +00:00
dbe275ce72 Do not fork daemon when dmeventd cannot be found. 2009-06-15 12:29:41 +00:00
649cd608c1 Destroy toolcontext on exit in clvmd (fixes memory pool leaks). 2009-06-15 12:15:23 +00:00
87c63e995b Fix lvconvert to not poll mirror if no conversion in progress. 2009-06-15 12:08:59 +00:00
cd49c5bf66 Fix memory leaks in toolcontext error path.
E.g.
 # vgscan
  Parse error at byte 2360 (line 54): expected a value
  Failed to load config file /etc/lvm/lvm.conf
You have a memory leak (not released memory pool):
 [0x818c788] library (12 bytes)

...
2009-06-15 11:56:31 +00:00
c3ca9468d1 Fix WHATS_NEW - Allow metadata correction even when PVs are missing. 2009-06-12 08:34:15 +00:00
89576aa2c1 Re-instate partial activation support in clustered mode. (mornfall) 2009-06-12 08:30:19 +00:00
630dbab749 Allow metadata correction even when PVs are missing. 2009-06-10 20:17:32 +00:00
8e95a2a603 In the new _vg_read_for_update(), we always do the check for CLUSTERED vg
status flag after reading the volume group.  Thus, no need to set the flag
in vg_read() or clear it later before calling _vg_bad_status_bits().

Also, add back in the !lockingfailed() as part of the CLUSTERED flag check.
It's unclear why it was removed when the check was moved from
_vg_bad_status_bits() to inside _vg_lock_and_read().
There was an open question about the last check in the 'if' stmt for
lockingfailed() with a previous patch submitted.  However, I would
defer that right now as it is a separate item and this patch should
be no functional change by including the !lockingfailed().

Petr acked this patch on 5/26 I just forgot to check it in.

Acked-by: Petr Rockai <prockai@redhat.com>
2009-06-10 16:14:40 +00:00
6a1c94d48d Complain when lvconvert --repair is used on non-mirror LV. 2009-06-10 15:27:57 +00:00
578a9a3332 Fix compiler warning. 2009-06-10 11:21:10 +00:00
122fe8a20d Unlock VG in recover_vg if metadata read failed. 2009-06-10 11:15:29 +00:00
d32f607aba Unlock vg when requested automatic update failed.
(fixes previous commit)
2009-06-10 10:15:28 +00:00
25d9591416 Support crypt segment in libdevmapper tree.
- it can support multiple segments, but note that
to work properly, correct IV (initialization vector)
offset parameter must be set properly.

Because most usage of IV start offset is when we join
several crypto segments together (so iv_offset is the segment
start offset), DM_CRYPT_IV_DEFAULT is defined to simplify
the process.

Function accepts the string in cipher agrument (already
including chainmode and iv type; chainmode and iv parameters are NULL
in this case) or user can provide split parameters which will
join into dm-crypt cipher specification "cipher-chainmode-iv".

All these parameters must be supplied in correct dm-crypt format.
2009-06-09 16:10:20 +00:00
33f41cc68b Use 'lvm lvresize' instead of 'lvresize' in fsadm.
Do not use '-n' realine option in fsadm for busybox compatiblity.
2009-06-09 15:31:36 +00:00
d8bee53822 Update WHATS_NEW 2009-06-09 14:43:59 +00:00
0866f47904 Update vgsplit to use new vg_reserve_newname() function. 2009-06-09 14:31:20 +00:00
d230325569 Update vgcreate to use new vg_lock_newname(). 2009-06-09 14:30:44 +00:00
8e7930a604 Update vgrename to use vg_lock_newname. 2009-06-09 14:30:16 +00:00
1dde89db69 Add vg_lock_newname() library function.
Various tools need to check for existence of a VG before doing something
(vgsplit, vgrename, vgcreate).  Currently we don't have an interface to
check for existence, but the existence check is part of the vg_read* call(s).
This patch is an attempt to pull out some of that functionality into a
separate function, and hopefully simplify our vg_read interface, and
move those patches along.

vg_lock_newname() is only concerned about checking whether a vg exists in
the system.  Unfortunately, we cannot just scan the system, but we must first
obtain a lock.  Since we are reserving a vgname, we take a WRITE lock on
the vgname.  Once obtained, we scan the system to ensure the name does
not exist.  The return codes and behavior is in the function header.
You might think of this function as similar to an open() call with
O_CREAT and O_EXCL flags (returns failure with -EEXIST if file already
exists).

NOTE: I think including the word "lock" in the function name is important,
as it clearly states the function obtains a lock and makes the code more
readable, especially when it comes to cleanup / unlocking.  The ultimate
function name is somewhat open for debate though so later we may rename.
2009-06-09 14:29:10 +00:00
350d0a6495 Fix the same readahead rounding in lvcreate.
(fixes previous commit)
2009-06-06 22:06:54 +00:00
42e922d587 Round readahead more inteligently and print warning.
Round readahead at least to one page up.
Print warning instead of verbose message.
2009-06-06 22:00:20 +00:00
57c002f324 Fix various problems in tests
- PPC uses 64k page, some caculations are wrong in tests
- file utility is buggy on PPC and cannot detect swap, use blkid instead
- read ahead is quietly rounded down according to page size
(for now use some common divisor value in test)
2009-06-06 16:40:39 +00:00
e5fb684ac1 Suspend virtual origin before real snapshot.
Because preload of table for snapshot can produce snapshot
metadata (in kernel cow header) read.

Code should suspend origin first to avoid possible deadlock
when preloading (thus calling snapshot in-kernel constructor)
for origin with suspended cow device.

(fixes previous commit)
2009-06-06 16:37:15 +00:00
84abdc7b2d Fix double releasing of vg when repairing of vg is requested.
Several commands calls process_each_vg() and in provided
callback it explicitly recovers VG if inconsistent.
(vgchange, vgconvert, vgscan)

It means that old VG is released and reread  but the function
above (process_one_vg) tries to unlock and release old VG.

Patch moves the repair logic into _process_one_vg() function.

It always tries to read vg (even inconsistent) and then decides
what to do according new defined parameter.

Also patch unifies inconsistent error messages.

The only slight change if for vgremove command, where
it now tries to repair VG before it removes if force arg is given.
(It works similar way before, just the order of operation changed).
2009-06-05 20:00:52 +00:00
db79a4a14b Add vgrename test to check for existence of new vg. 2009-06-05 10:42:22 +00:00
f1b30c5aff test commit 2009-06-04 13:23:10 +00:00
4db2593801 test commit 2009-06-04 13:16:49 +00:00
ad685d2153 test commit 2009-06-04 13:11:58 +00:00
cf9dd7cf5e Use lvconvert --repair instead of vgreduce in mirror dmeventd DSO (mornfall)
Introduce lvconvert --use_policies (mornfall)
2009-06-04 12:01:15 +00:00
f10d82dc30 Add splitname. 2009-06-03 20:44:42 +00:00
5ec942fb2a Add subsystem, vg_name, lv_name, lv_layer fields to dmsetup reports. 2009-06-03 18:35:39 +00:00
2897cfb556 Fix clvmd-corosync to match the new corosync API. 2009-06-03 13:42:02 +00:00
5484869af9 WHATS_NEW! 2009-06-03 11:49:05 +00:00
90cc3a0f05 Make mempool optional in dm_split_lvm_name() 2009-06-03 11:40:23 +00:00
99e45f71c2 Build shared parts with 'make' command (mpatocka)
When some parts of lvm are built as shared libraries (for example with
--with-snapshots=shared), the 'make' command does not build these parts.
The shared parts are built with 'make install' command.

This bug can be seen if you go to 'lib' subdirectory and type 'make'.
If you type 'make', the shared libraries are not built, if you type
'make all', the shared libraries are built.

The reason for the bug is the line $(SUBDIRS): $(LIB_STATIC)
If make is executed without any arguments, it makes the first target
in the Makefile. If the first target is '$(SUBDIRS): $(LIB_STATIC)',
it only builds static libraries.

This patch moves '$(SUBDIRS): $(LIB_STATIC)' after
include $(top_srcdir)/make.tmpl. make.tmpl contains the 'all' target
as its first target, so 'make' will be equivalent to 'make all' and
shared libraries will be build with 'make' command.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2009-06-03 11:31:06 +00:00
488d246ada Fix rename of active snapshot with virtual origin.
Code must suspend/resume virtual origin too when renaming
snaphsot otherwise in kernel old name remains.
2009-06-01 15:55:06 +00:00
8189910b5a Fix convert polling to ignore LV with different UUID.
When mirror convert polling is started (mainly as backgound process,
in lvchange -a y or in lvconvert itself) it tries to read VG
and LV identified by its name.

Unfortunatelly, the VG can have already different LV under the same name,
and various more or less funny things can happen (note that
_finish_lvconvert_mirror suspends the volume for example).

(the typical example is our testing script which continuously recreates
LVs under the same name in the same VG.)

This patch adds optional uuid parameter which helps to properly
select the monitoring object. For lvconvert polling it is set to LV UUID
and both _get_lvconvert_vg and _get_lvconvert_lv uses it to read proper VG/LV.

(In the pvmove case it is NULL, here we poll for physical volume name).
2009-06-01 14:43:27 +00:00
de317b8e01 Fix log allocation segfault (fix previous commits).
If there is no free area for log, code should break the loop.
(Otherwise it uses uninitializes areas later.)

Easily reproducible using lvconvert --repair
 - kill device with log
 - run lvconvert --repair vg/lv (with no PV usable for log)
2009-06-01 14:23:38 +00:00
436cf94595 Fix readahead calculation problems.
During vgreduce is failed mirror image replaced with error segment,
this segmant type has always area_count == 0.
Current code expects that there is at least one area with device,
patch fixes it by additional check (fixes segfault during vgreduce).

Also do not calculate readahead in every lv_info call, we only need
to cache PV readahead before activation calls which locks memory.
2009-06-01 12:43:31 +00:00
145c999762 Remove verbose 'visited' messages. 2009-05-30 01:54:29 +00:00
c82b46032a Handle multi-extent mirror log allocation when smallest PV has only 1 extent. 2009-05-30 00:09:27 +00:00
cf9fa94eaa Fix 'service-default-enabled' rpmlint in clvmd initscript 2009-05-29 18:54:48 +00:00
d5139fef22 Fix rpmlint in clvmd initscript
Added missing LSB stanza lines.
Added reload capability.
Remaining warning (incoherent-init-script-name) is not relevant.
2009-05-29 18:34:10 +00:00
f8964db41c When creating new LV, double-check that name is not already in use. 2009-05-28 01:59:37 +00:00
052169695c Remove /dev/vgname/lvname symlink automatically if LV is no longer visible. 2009-05-28 01:11:29 +00:00
f9a8a94fd1 Rename internal vorigin LV to match visible LV. 2009-05-28 00:29:14 +00:00
880d9bb33f Suppress 'removed' messages displayed when internal LVs are removed.
Fix lvchange -a and -p for sparse LVs.
Fix lvcreate --virtualsize to activate the new device immediately.
2009-05-27 18:19:21 +00:00
68aa3eb1b9 Make --snapshot optional with lvcreate --virtualsize.
Generalise --virtualoriginsize to --virtualsize.
2009-05-27 16:30:29 +00:00
39dbb9dad8 Skip virtual origins in process_each_lv_in_vg(). (mbroz) 2009-05-27 13:23:41 +00:00
ac7acf2441 Fix counting of virtual origin LVs in vg_validate. (mbroz) 2009-05-27 13:19:34 +00:00
87ce5770b7 0->NULL (mbroz) 2009-05-27 13:07:37 +00:00
24f3c8c29e Attempt to load dm-zero module if zero target needed but not present. (mbroz) 2009-05-27 13:05:53 +00:00
cf578d50ec post-release 2009-05-22 15:23:10 +00:00
6c2e4110ad Temporary disable one of lvconvert tests. 2009-05-22 14:56:17 +00:00
01280bbd06 Rename liblvm.so to liblvm2app.so and use configure --enable-applib. 2009-05-22 14:44:59 +00:00
0f1b7a527b Reinstate version in liblvm2cmd.so soname. (2.02.44) 2009-05-21 11:11:29 +00:00
965c7e1200 Pre-release cleanups. 2009-05-21 03:04:52 +00:00
abea4f481c Missing entries. 2009-05-20 22:44:10 +00:00
71191eae5c Revert:
Use lvconvert --repair in dmeventd mirror DSO.
for now.

It replaces bad behaviour in one set of circumstances with bad behaviour
in a different set.  We think the behaviour needs to be more configurable.
2009-05-20 22:24:48 +00:00
03d4efc5c0 Fix locking query compatibility with old external locking libraries. 2009-05-20 12:58:03 +00:00
22c38019b2 Fix readahead test. 2009-05-20 11:27:14 +00:00
7cd8194c99 Use readahead of underlying device and not default (smaller) one.
When we are stacking LV over device, which has for some reason
increased read_ahead (e.g. MD RAID), the read_ahead hint
for libdevmapper is wrong (it is zero).

If the calculated read_ahead hint is zero, patch uses read_ahead of underlying device
(if first segment is PV) when setting DM_READ_AHEAD_MINIMUM_FLAG.

Because we are using dev-cache, it also store this value to cache for future use
(if several LVs are over one PV, BLKRAGET is called only once for underlying device.)

This should fix all the reamining problems with readahead mismatch reported
for DM over MD configurations (and similar cases).
2009-05-20 11:09:49 +00:00
b4747ad67f Use lock query instead of activate_lv_excl
- switch lvremove to not force activate volume when removing
 - ditto for force resync

 - fix some wrong return codes in lvchange_resync()
2009-05-20 09:55:33 +00:00
bb6db55686 Use suspend with flush when device size was changed during table preload.
This allows online mirror resize, also removes condition to preventing
code to do this.
2009-05-20 09:52:37 +00:00
244cd8f94f Add test - lvconvert from linear (on multiple PVs) to mirror. 2009-05-19 15:47:50 +00:00
ba856910e0 Add infrastructure for queriying for remote locks.
Current code, when need to ensure that volume is not
active on remote node, it need to try to exclusive
activate volume.

Patch adds simple clvmd command which queries all nodes
for lock for given resource.

The lock type is returned in reply in text.

(But code currently uses CR and EX modes only.)
2009-05-19 10:38:58 +00:00
d00e023894 Fix lvconvert check for multiple-segment mirrors (mornfall) 2009-05-19 10:27:47 +00:00
86b4b128a9 Use lvconvert --repair in dmeventd DSO (mornfall)
This means two things:

1) Non-mirrored LVs will be no longer affected by mirror monitoring. (Before,
if you had a LV that went partially missing on a VG where a mirror leg failed,
this LV would be removed automatically by dmeventd... Probably not an
unrecoverable dataloss bug, but still quite unpleasant.)

2) If enough parallel PV space is available at the time of the mirror failure,
the failed devices will be automatically replaced using this spare space. Which
(and whether) free space may be used is still not configurable, but is a
planned feature. Since it is relatively easy to undo the action by converting
the mirror manually, I don't consider this to be a showstopper. In fact, I
think the compromise is much better than what we have now.
2009-05-19 10:25:16 +00:00
35bd06a9a0 Fix compilation warning. 2009-05-19 10:12:41 +00:00
bdc7574fd5 If pvmove fails activating mirror volume, try restore to previous state.
pvmove now keep suspended devices if temporary mirror creation fails.

We can try to restore previous state if it is first attempt to activate
pvmove (code basically run the same code as --abort automatically).
2009-05-19 09:51:02 +00:00
a7cac2463c Use PV UUID in hash for device name when exporting metadata.
Currently code uses pv_dev_name() for hash when getting internal
"pvX" name.

This produce corrupted metadata if PVs are missing, pv->dev
is NULL and all these missing devices returns one name
(using "unknown device" for all missing devices as hash key).
2009-05-19 09:48:32 +00:00
474bc8823e vgcfgrestore should not quietly fail when backup file has missing PVs.
(fixes previous commit: Fix segfault for vgcfgrestore on VG with missing PVs.)
2009-05-19 09:45:33 +00:00
95f6b0c06e Add vgimportclone and install it and the man page by default. 2009-05-14 16:46:12 +00:00
dc205333cd Check max_lv on only place and force the check only for new volume.
We can temporarily violate max_lv during mirror conversion etc.

(If the operation fails, orphan mirror images are visible to administrator
for manual remove for example. Not that this should ever happen:-)

Force limit only for lvcreate (and vg merge) command.

Patch also adds simple max_lv tests into testsuite
2009-05-13 21:29:10 +00:00
4de96ea715 Remove unneeded import parameter from lv_create_empty. 2009-05-13 21:28:31 +00:00
c94f02648c Merge lv_is_displayable and lv_is_visible.
Displayable and visible is the same thing.

volumes_count(vg) is now vg_visible_lvs() and always
returns number of LVs from user perspective.
2009-05-13 21:27:43 +00:00
2ba0dd20fb Introduce lv_set_visible & lv_set_invisible and use lv_is_visible always.
The vg->lv_count parameter now includes always number of visible
logical volumes.

Note that virtual snapshot volume (snapshotX) is never visible,
but it is stored in metadata with visible flag.
2009-05-13 21:26:45 +00:00
389dc22856 Fix lv_is_visible to handle virtual origin.
Snapshot is visible if its origin is marked visible,
or if the origin is virtual.
2009-05-13 21:25:45 +00:00
823c8af1ab Introduce link_lv_to_vg and unlink_lv_from_vg functions.
link_lv_to_vg and unlink_lv_from_vg are the only functions
for adding/removing logical volume from volume group.

Only these function should manipulate with vg->lvs list.
2009-05-13 21:25:01 +00:00
286562d202 Tidy format1 import LV function.
Later patch initializes lv->vg after the LV structure is prepared,
so pass through cmd context and do not use vg->cmd here.
Also move LV id calculation (which uses lv->vg too).

Also properly free memory pool if operation fails.
2009-05-13 21:24:12 +00:00
b83a1876ba Remove vg->lv_count and use counter function.
This should not cause problems but simplifies code a lot.

(the volumes_count is merged and renamed with lvs_visible
function by following patch.)
2009-05-13 21:22:57 +00:00
ed2a931ae3 Fix snapshot segment import to not use duplicate segments & replace.
The snapshot segment (snapshotX) is created twice
during the text metadata segment processing.

This can cause temporary violation of max_lv count.

Simplify the code, snapshot segment is properly initialized
in init_snapshot_seg function now and do not need to be replaced
by vg_add_snapshot call.

The vg_add_snapshot() is now usefull only for adding new
snapshot and it shares the same initialization function.

The snapshot name is always generated, name paramater can be
removed from function call.
2009-05-13 21:21:58 +00:00
f77190f477 Update test-utils to cope with ":" in device names and allow configurable names. 2009-05-13 19:18:47 +00:00
2d3335fa48 Do not query nonexistent devices for readahead. 2009-05-13 14:13:54 +00:00
d52b3fd3fe Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.
As a simplification to the tools and further liblvm, this patch pushes
the setting of NON_BLOCKING lock flag inside the lock_vol() call.
The policy we set is if any existing VGs are currently locked, we
set the NON_BLOCKING flag.

Should be no functional change.
2009-05-13 13:02:52 +00:00
5a945afdc6 better variable name for snapshot counting 2009-05-13 01:48:18 +00:00
8b65ad0237 Remove snapshot_count from VG and use function instead. 2009-05-12 19:12:09 +00:00
6d74246c91 Fix first_seg() call for empty segment list.
The seg variable is temporary variable for list iterator,
code cannot expect that after iteration it remains NULL
(it contains non-NULL pointer here id list is empty).

Patch fixes first_seg function so it now correctly returns NULL
for empty segment list.
2009-05-12 19:09:21 +00:00
9d81c953c3 Update t-read-ahead.sh to validate lv_read_ahead and lv_kernel_read_ahead.
- check default values
- check active/inactive values
2009-05-11 16:17:12 +00:00
97e41de23f Fix previous commit (scripts/Makefile targets order) 2009-05-11 10:35:00 +00:00
d57543b220 Introduce lvm2_install target.
Buildsystem support device-mapper only install,
but generic install tagret includes both dm+lvm2.

For distribution which uses separate install_device-mapper,
there is no way how to install lvm2 only
(so after installing lvm2 for packaging purposes
built system must remove installed device-mapper files).

Fix it by allowing lvm2_install target, similarily like
install_cluster for clvmd.

(install = install_device-mapper + install_lvm2)
2009-05-11 10:28:45 +00:00
13cd91bffb Fix device-mapper static build targets.
dmsetup.static is not built and cleaned properly
if running only device-mapper install/build.
2009-05-11 10:13:28 +00:00
2d170dfed8 Do not use generic install if running install_device-mapper.
It propagates into subdirs which includes DSOs which requires
lvm2 build (only install_device-mapper should propagate there).
2009-05-11 10:12:35 +00:00
744ac0eb81 Add test for seg_start, seg_count, seg_start_pe 2009-05-11 03:37:34 +00:00
057983ce3e Update WHATS_NEW wrt a recent patch. 2009-05-09 13:47:03 +00:00
aadc34ab4d Update tests for region_size. 2009-05-08 21:50:20 +00:00
d9c4af46ed Add tests to check pv_mda_size and vg_mda_size. 2009-05-08 06:10:45 +00:00
cdd0024bad Add tests to check vgcreate --physicalextentsize and field vg_extent_size. 2009-05-08 05:15:52 +00:00
6e331c523f Validate chunksize and originsize for snapshots. 2009-05-08 04:24:52 +00:00
f7712c77b8 Fix PV datalign when for values starting prior to MDA area.
The dataalign value must always be aligned according
to MDA area.
The currect code checks if calculated value collides with
MDA area but not if the value is so small that it is
located before MDA starts.

Unfortunatelly there can be also MDA in the end of the device.

The patch adds simple check to avoid this miscalculation.
Patch expects that first MDA always starts on <= pagesize boundary
(this is true for all allowed label sector parameters).
2009-05-07 12:11:50 +00:00
fd436c316a Use zalloc in initialization of device manager (to zero pvmove mirror count). 2009-05-07 12:01:21 +00:00
7120f7df54 Update columns.h comment. 2009-05-06 15:25:23 +00:00
1d30bf8af4 Fixup whitespace. 2009-04-29 20:14:21 +00:00
40c70e12dd Fixup whitespace. 2009-04-29 20:11:46 +00:00
31b6eb916f Use liblvm.so instead of .a 2009-04-28 19:08:25 +00:00
09e7a582de Fix error path in vg_make_handle().
Enter the error condition if either of the allocations fail, and
don't use dm_pool_zalloc if dm_pool_create fails.
2009-04-28 17:46:47 +00:00
b8aec00dee Fix wrong arg in lv_is_virtual_origin call while creating snapshots. 2009-04-26 08:12:12 +00:00
174f5a3a49 Add sparse devices: lvcreate -s --virtualoriginsize (hidden zero origin).
Add lvs origin_size field.
Fix linux configure --enable-debug to exclude -O2.

Still a few rough edges, but hopefully usable now:
  lvcreate -s vg1 -L 100M --virtualoriginsize 1T
2009-04-25 01:17:59 +00:00
758d469679 Fix linux configure --enable-debug to exclude -O2. 2009-04-24 21:44:15 +00:00
542bdaa740 Fix pool leak in lvmcache_read_vg error path.
(Introduced in previous patches.)
2009-04-24 12:03:55 +00:00
14bd66805e Fix segfault when using -U, -G and -M options in dmsetup. 2009-04-24 11:30:49 +00:00
01c2d76c54 Avoid scanning non-PV devices in functional tests, otherwise lvconvert --repair
breaks for some reason -- possibly needs investagation, but this should fix it
in the meantime.
2009-04-24 08:00:48 +00:00
40cd0b1dd2 Implement, test and document (first iteration of) lvconvert --repair. 2009-04-23 16:56:21 +00:00
5dad791818 Refuse adding missing PVs in create_pv_list in toollib when allocatable_only is
requested.
2009-04-23 16:45:30 +00:00
3743a6858b A more thorough PV equality test (that also copes better with MISSING_PVs) in
_is_mirror_image_removable.
2009-04-23 16:43:01 +00:00
409a8d3678 Do not include MISSING_PVs in allocation maps. 2009-04-23 16:41:27 +00:00
94084178d9 Update columns.h comment to describe macro args. 2009-04-23 16:27:58 +00:00
3c80245275 fix typo reported by "A. Costa" <agcosta@gis.net> 2009-04-23 12:20:15 +00:00
16c4b2a572 Fix vgreduce --removemissing failure exit code. 2009-04-22 17:00:28 +00:00
0cf1e72ed1 Remove some trailing whitespace so git won't complain. 2009-04-22 12:46:25 +00:00
029346d322 Clean a lot of extra extra whitespaces. 2009-04-22 10:38:16 +00:00
9e959f9bdd Fix remote metadata backup for clvmd
Run backup of metadata on remote nodes in the
same place like local node - when calling backup().

Introduce backup_locally() which calls only
local backup if needed.

Remote backup is now trigerred by LCK_VG_BACKUP flag
combination (special VG lock).

This lock type will call check_current_backup()
(including backup_locally() call) and updates
metadata on all nodes.

(Patch fixes non-functional remote backup,
current call during VG lock never triggers.)
2009-04-22 09:39:45 +00:00
3ec8c63e28 Alloc PV internal structure from VG mempool if possible. 2009-04-22 09:31:30 +00:00
ceeb1eca9d - Updating cluster log with latest code changes/bug fixes before
altering to new kernel structures.
2009-04-21 19:16:22 +00:00
5800560602 Move metadata backup call after vg_commit.
The backup() call store metadata from memory.

But in cluster backup() call performs
remote nodes metadata backup and it reads data from disk.

For metadata backup consistency,
patch moves all backup() calls after vg_commit.

(Moreover, some tools already do that this way.)
2009-04-21 14:31:57 +00:00
a840a56e02 Tidy lv_hash[_lock] use inside clvmd.
- Rename unlock_all to destroy_lvhash,
this function is called in cluster shutdown
unlocks everything and clean up allocated info space.

 - Tidy lv_hash_lock use
.
Except adding free(lvi) in lv_has destructror
there is no functional change.
2009-04-21 13:11:28 +00:00
8704f4e24e Fix pvseg report for orphan PVs and other devices.
If user requests report attribute from PVSEG type
and PV is orphan (or all devices is set), the report
is empty.

Try for example (when only orphan PV are present)
 #pvs
 #pvs -o +devices
# pvs /dev/sdb1
  PV         VG   Fmt  Attr PSize  PFree
    /dev/sdb1       lvm2 --   46.58G 46.58G
# pvs -o +devices /dev/sdb1
(no output)

The problem is caused by empty pv->segments list.

Fix it by providing fake segment here (similar to fake structures
in _pvsegs_sub_single() calls.
2009-04-21 12:59:18 +00:00
459a5a5b1f Fix pvs -a for segmented output
# pvs -a -o devices
   Volume group name (null) has invalid characters
   Skipping volume group (null)

...
_pvsegs_sub_single creates fake vg, we need to check
that pv is real here.
2009-04-21 12:57:31 +00:00
afc28c54ac Add libdevmapper to test/api building. 2009-04-20 20:46:06 +00:00
6772b45ea6 Add MMC device type to filters. 2009-04-16 10:16:14 +00:00
7defd4dab0 Fix dmsetup.static build. 2009-04-15 14:42:27 +00:00
db326a14b3 Properly release VG memory pool in all CLI tools. 2009-04-10 10:01:38 +00:00
0abf2e237e Properly release VG memory pool in metadata manipulation code. 2009-04-10 10:01:08 +00:00
d3a2b52363 Properly release VG memory pool in archiver code. 2009-04-10 10:00:37 +00:00
de81594179 Properly release VG memory pool in activation code and clvmd. 2009-04-10 10:00:04 +00:00
06bdf8b461 Introduce memory pool per volume group.
Since now, all code reading volume group is responsible for releasing
the memory allocated by calling vg_release(vg).
(For simplicity of use, vg_releae can be called for vg == NULL,
the same logic like free(NULL)).

Also providing simple macro for unlocking & releasing in one step,
tools usualy uses this approach.

The global memory pool (cmd->mem) should be used only for global
physical volume operations.

This patch have to be applied with all subsequent patches to complete
memory pool per vg logic.

Using separate memory pool has quite bit memory saving impact when
using large VGs, this is mainly needed when we have to use
preallocated and locked memory (and should not overflow from that
memory space).
2009-04-10 09:59:18 +00:00
d784303591 Helper function to catch memory pool leaks. 2009-04-10 09:56:58 +00:00
52d2c31427 Properly copy the whole pv structure for later use.
The all_pvs list, used in vg_read, should make its own private
copy of pv structures, otherwise (when vg will use its own pool)
it will point to released memory pool.
The same applies for get_pvs() call.

Patch adds pv_list copy helper and adds explicit memory pool
parameter into _copy_pv.

(Please note that all these helper functions cannot guarantee that
vg related fields are valid - proper vg read & lock must be used
if it is requested.)
2009-04-10 09:56:00 +00:00
9bc8e56458 Always return exit error status when locking of volume group fails. 2009-04-10 09:54:36 +00:00
489c728793 Fix mirror log convert validation question. 2009-04-10 09:53:42 +00:00
01eaadfa53 Avoid referencing files from DESTDIR during build process 2009-04-08 14:08:05 +00:00
dddd2f9202 Do not create some dm and lvm static librarie when they are not requested
by configure option
Add dependency for static dmeventd library
2009-04-08 14:04:35 +00:00
31709134c9 Enable use of cached metadata for pvs & pvdisplay.
Currently PV commands, which performs full device scan, repeatly
re-reads PVs and scans for all devices.

This behaviour can lead to OOM for large VG.

This patch allows using internal metadata cache for pvs & pvdisplay,
so the commands scan the PVs only once.
(We have to use VG_GLOBAL otherwise cache is invalidated on every
VG unlock in process_single PV call.)
2009-04-08 12:53:20 +00:00
456efad714 Add missing 'device-mapper' internal subdir build dependency. 2009-04-07 22:53:48 +00:00
2112fc571a Use pv from newly read_vg to avoid possible use of not initialized memory.
If the vg in process_each_segment_in_pv is NULL, the pv struct
can be incomplete (for example lv_segs are not copied in get_pvs()
call).

We need use the new pv from just read-in volume group.

(The same code is in pvdisplay already.)
2009-04-07 10:22:14 +00:00
0c4379ff0f Fix memory pool leak.
Call the alloc_destory call always after finishing operation
with handle otherwise it will leak a memory pool.

Also fix return code in lv_extend.
2009-04-07 10:20:28 +00:00
a690b36478 Fix whitespace in t-mdata-strings.sh
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-04-03 14:23:17 +00:00
6f5ed95f71 Save and restore the previous logging level when log level is changed. 2009-04-02 21:34:41 +00:00
251ee5f5a2 Fix error message when archive initialization fails. 2009-04-02 20:46:11 +00:00
9ab1d88a91 Fix debug pool grow object to properly support delta=0
(It prints garbage for some reports)
2009-04-02 15:02:18 +00:00
5d3d9f57fe Allocate new pv->vg_name from pool, it can be destroyed later.
(The mempool rename will be used later by vg private mempools)
2009-04-02 15:01:11 +00:00
0889882255 Do not use pointer from released memory pool (cmd->cmd_line). 2009-04-02 14:59:48 +00:00
2a1f78f95a Make sure clvmd-corosync releases the lockspace when it exits.
patch from Xinwei Hu
2009-04-01 07:51:05 +00:00
6faaa1a0cc Add some more special chars for device name test. 2009-03-31 17:30:47 +00:00
77dd12a028 fix some issues when compiling with -D DEBUG_POOL
- fix compilation issues
- fix wrong pool object maipulation (lvm dumpconfig triggers assert)
- second iteration in loop _log_parallel_areas operates on non-existing object
2009-03-26 09:25:18 +00:00
6a954445f1 Fix segfault for vgcfgrestore on VG with missing PVs. 2009-03-24 13:16:34 +00:00
9500e898c6 Block SIGINT & SIGTERM in clvmd subthreads so they don't delay shutdown.
Patch from Xinwei Hu, Thanks
2009-03-24 11:49:15 +00:00
c5989d4350 Restore log_suppress state when metadata backup file is up-to-date.
Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-23 22:57:27 +00:00
8f782be41d Remove old metadata backup file after renaming vg.
Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-23 22:29:06 +00:00
afcc447a64 Fix size and error message of memory allocation at backup initialization.
Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-23 21:56:32 +00:00
8cfcba83ae Fix error message when adding metadata directory to internal list fails.
Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-23 21:13:37 +00:00
a8315726ce Missed file from previous checkin. 2009-03-17 14:40:00 +00:00
da668c80b2 Some extra (paranoid) checks on dev_is_{md,swap} result. 2009-03-17 14:00:58 +00:00
55455ac21f Detect and wipe swap signatures in pvcreate. 2009-03-17 13:59:56 +00:00
74adacf96a Fix some clean rules, fix previous distclean checkin.
In libdm/Makefile.in, we need to cleanup the symlink properly.
Adding to CLEAN_TARGETS seemed like the simplest way to do this
in the current build framework.  We could redo dependencies for
VERSIONED_SHLIB, but for now just add to CLEAN_TARGETS.

For scripts/Makefile.in, we should be adding to DISTCLEAN_TARGETS.
The generic rule in make.tmpl.in takes care of the cleanup.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-16 20:00:10 +00:00
a384b41308 Fix some distclean rules.
By gnu coding stds, 'distclean' should remove all files generated
by ./configure in addition to what 'clean' does.

Author: Takahiro Yasui <tyasui@redhat.com>
2009-03-16 18:28:04 +00:00
048a329afc Fix warning in previous commit. 2009-03-16 15:19:29 +00:00
3c3d16e794 Fix lv_count when manipulating with snapshots and max_lv is set.
Patch fixes these problems:
 - during the snapshot creation process, it needs create 2 LVs,
   one is cow, second becomes snapshot.
   If the code fails in vg_add_snapshot, code lvcreate will not remove
   LV cow volume.

 - if max_lv is set and VG contains snapshot, it can happen that
   during the activation lv_count is temporarily increased over the limit
   and VG metadata are not properly processed
   see https://bugzilla.redhat.com/show_bug.cgi?id=490298

 - vgcfgrestore alows restore with max_lv set to lower valuer that actual
   LV count. This later leads to situation that max_lv is completely ignored.

 - vgck doesn't call vg_validate(). It should at least try:-)

Signed-off-by: Milan Broz <mbroz@redhat.com>
2009-03-16 14:34:57 +00:00
d95b544dfd Remove unnecessary includes in lvm_base.c.
We would like to declare our handles pv_t, vg_t, and lv_t in
the external library header lvm.h.  However, these are already
defined in metadata-exported.h for the use of some of the
in-progress liblvm APIs.  Thus, we cannot both define
them in lvm.h and include metadata-exported.h in the external
library C files.  We could use preprocessor tricks (#ifndef)
but for now we just avoid the include.
2009-03-10 15:38:46 +00:00
5d9ea7b91b Fix clvmd build after liblvm commit. 2009-03-10 12:10:12 +00:00
500289229a Fix error messages when PV uuid or pe_start reading fails.
Author: Takahiro Yasui <tyasui@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-03-09 15:42:10 +00:00
21d62387ae Add missing liblvm/.exported_symbols 2009-03-08 18:58:53 +00:00
3bbfb30dcb Fix liblvm version symlink. 2009-03-08 18:10:39 +00:00
819fbc6ed5 Remove unnecessary linker flags for liblvm. 2009-03-08 17:29:26 +00:00
53e7c8fa34 Add DSO generation for new LVM application library.
Fix test/api/test build.
2009-03-08 17:06:55 +00:00
35d13cad96 Move lvm.h from lib to liblvm. 2009-03-06 22:49:48 +00:00
c190fc702e Add new liblvm build directory and move lvm_base.c.
The original liblvm.a has been moved to liblvm-internal.a.
We now use liblvm.a for the new application library and build
it inside liblvm directory.

Change dependencies so tools depend on liblvm application library,
and application library depends on liblvm internal.
2009-03-06 16:19:52 +00:00
cd0ed7b509 Rename liblvm to liblvm-internal.
Make preparation for using liblvm for new application library.
2009-03-06 16:17:28 +00:00
24af685db1 Fix unlocks in clvmd-corosync.
The DLM unlock returns EUNLOCK in the lksb on success, not 0
2009-03-06 11:29:38 +00:00
d7553ded6c Fix possible increasing in memory allocation if refreshing_context
(for example when CLVMD_CMD_LOCK_VG for is called during vgscan).

If clvmd calls LV lock, it calls
    /* clean the pool for another command */
	dm_pool_empty(cmd->mem);
to clean up memory pool after command.

Unfortunately, do_refresh_cache() do not call this
and because during it operation it allocates some memory,
the pool increases.

Also do_refresh_cache should use lvm_lock
(it manipulates with lvm internal data).

The same applies for lvm_backup command.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2009-03-05 16:25:35 +00:00
884d5a7fc8 post-release 2009-03-03 18:25:05 +00:00
a920074468 vgname_from_mda now tries to parse for vgname even
if rlocn not defined (there is no metadata area).

In most cases it fails in validate_name(),
unfortunately there are situatuions, when
validate_name is ok and later code fails with
checksum error.

Reproducer:

# dd if=/dev/zero of=/dev/loop0

# pvcreate --metadatasize 637k /dev/loop0
  Physical volume "/dev/loop0" successfully created

# pvs /dev/loop0
  /dev/loop0: Checksum error
      PV         VG   Fmt  Attr PSize PFree
        /dev/loop0      lvm2 --   1.00M 1.00M

Signed-off-by: Milan Broz <mbroz@redhat.com>

-
2009-03-03 16:35:32 +00:00
5ab342e298 pre-release 2009-03-03 13:03:03 +00:00
c99f525821 Fix last check-ins: seg can be NULL. 2009-02-28 20:04:24 +00:00
dff004d695 . 2009-02-28 19:43:42 +00:00
6f53e4b536 Attempt cleanup in child before execing new binary in exec_cmd() 2009-02-28 00:54:06 +00:00
9d3fe84135 . 2009-02-27 23:55:15 +00:00
e5f7ae3878 fsadm cleanups & release prep 2009-02-27 23:40:11 +00:00
97162d9a53 autoreconf (using fedora 10 for this now) 2009-02-25 23:33:30 +00:00
d0b99cb260 pe_start can be overwritten in VG metadata, so it is not PV label-only field. 2009-02-25 23:31:06 +00:00
fa22cc2e20 Try to avoid full rescan if label scan is enough. 2009-02-25 23:29:06 +00:00
9904255490 Use pkgconfig to obtain corosync library details during configuration. (kabi) 2009-02-25 22:41:12 +00:00
f75c15b477 Fix error returns in clvmd-corosync interface to DLM.
Thanks to Xinwei Hu for spotting this.
2009-02-25 14:33:00 +00:00
9404dcab69 Update vgchange and vgmknodes man pages to include --refresh.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-02-25 13:17:40 +00:00
c4d4403955 Fixed bug where lvresize option -t was not properly passed to fsadm.
Using argv[] list in exec_cmd() to allow more params for external commands.
Fsadm does not allow checking mounted filesystem.
Fsadm no longer accepts 'any other key' as 'no' answer to y/n.
Fsadm improved handling of command line options.
2009-02-24 15:48:00 +00:00
a0bb2dc907 Fix include/.symlinks for lvm2.h to lvm.h renaming
Author: Thomas Woerner <twoerner@redhat.com>
2009-02-24 13:13:56 +00:00
ed774a5691 Added files lib/lvm.h and lib/lvm_base.c:
New structure lvm (used as an alias to cmd_context), new type definition lvm_t
for the lvm handle. Added functions lvm_create, lvm_destroy and
lvm_reload_config using the new handle.

Modified test/api/test.c:
Use new lvm.h header file and lvm_t handle.

Removed lib/lvm2.h


Author: Thomas Woerner <twoerner@redhat.com>
2009-02-24 13:03:45 +00:00
78cedddbde Fix validation of dataalignment value introduced in previous commit. 2009-02-23 16:53:42 +00:00
3640dc2fa3 Move tools/version.h to lib/misc/lvm-version.h.
Split LVM_VERSION into MAJOR, MINOR, PATCHLEVEL, RELEASE and RELEASE_DATE.
2009-02-22 22:11:58 +00:00
d3c619e3d3 Add system_dir parameter to create_toolcontext() and call it system_dir
everywhere for consistency.
2009-02-22 21:14:37 +00:00
c158759c11 Comment out pvcreate pagesize alignment test for now. 2009-02-22 19:32:28 +00:00
b49362420c Add --dataalignment to pvcreate to specify alignment of data area. (mbroz)
This patch is not fully tested and leaves some related bugs unfixed.

Intended behaviour of the code now:

  pe_start in the lvm2 format PV label header is set only by pvcreate (or
vgconvert -M2) and then preserved in *all* operations thereafter.

  In some specialist cases, after the PV is added to a VG, the pe_start
field in the VG metadata may hold a different value and if so, it
overrides the other one for as long as the PV is in such a VG.

  Currently, the field storing the size of the data area in the PV label
header always holds 0.  As it only has meaning in the context of a
volume group, it is calculated whenever the PV is added to a VG (and can
be derived from extent_size and pe_count in the VG metadata).
2009-02-22 19:00:26 +00:00
aab76646ee Fix interrupt unblocking after vgcreate, for example: drop_cached_metadata()
previously left _vg_lock_count incremented.
Other locks are always held during drop_cached_metadata() so there's no
need to increment+decrement it.
2009-02-22 16:13:57 +00:00
259245d412 Provide da and mda locations in debug message when writing text format label. 2009-02-20 23:19:28 +00:00
717180a8eb Mention the restriction on file descriptors at invocation on the lvm man page. 2009-02-20 01:47:02 +00:00
12811483be In testsuite's not.c, print a notice when program dies of a fatal signal. 2009-02-17 19:37:28 +00:00
822aa2a352 Fix test output collection in harness.c. 2009-02-17 19:36:16 +00:00
9d788d4d9c Index cached vgmetadata by vgid not vgname to cope with duplicate vgnames. (dwyso) 2009-02-17 18:56:41 +00:00
d405cb8dd9 Fix lvm.static build dependence (to properly propagate changes in libdevmapper). 2009-02-17 11:07:59 +00:00
5d3e57094a Only fail when tests have failed, but not when they have been just skipped. 2009-02-16 16:49:21 +00:00
e28d3f8cbd If kernel supports only one dm major number, use in place of any supplied.
No longer require kernel and metadata major numbers to match.
2009-02-12 20:42:07 +00:00
182494a5b7 Re-implement the test harness in C. This lets us pass through signals and
trigger proper test teardown upon harness interrupt or termination. I also
tweaked the output somewhat while I was at it...
2009-02-12 19:54:45 +00:00
9487820c32 Add a fully-functional get_cluster_name() to clvmd corosync interface. 2009-02-11 10:13:20 +00:00
03d00c16f8 Remove duplicate cpg_initialize from clvmd startup. 2009-02-10 13:22:18 +00:00
57a38a00d9 Add option to /etc/sysconfig/cluster to select cluster type for clvmd. 2009-02-10 11:53:33 +00:00
779b8679fd Allow clvmd to start up if its lockspace already exists. 2009-02-10 11:52:40 +00:00
d0143d6f3e Separate PV label attributes which do not need parse metadata when reporting.
When reporting explicitly label attributes (pv_uuid for example), we do not
need to read metadata.

This patch separate the label fileds and removes scan_vgs_for_pvs
in process_each_pv() if not needed.

(There should be no user visible change in output.)
2009-02-09 09:45:49 +00:00
7917c3fc15 Remove external dependency on the 'cut' command in fsadm 2009-02-06 14:28:06 +00:00
81de913b77 Fix pvs segfault when pv mda attributes requested for not available PV. 2009-02-06 12:41:51 +00:00
0e3798cadb add support for ext4 resize in fsadm 2009-02-04 12:47:05 +00:00
7447482608 Move locking_type reading inside init_locking().
No functional change.
2009-02-03 16:23:19 +00:00
f9b185caa5 Rename get_vgs() to get_vgnames() and clarify related error messages.
get_vgs() really returns a list of vgnames.  In the future we will use
get_vgs() to return a list of vg structures, similar to get_pvs().
2009-02-03 16:19:25 +00:00
4761ce4b45 Allow clvmd to be built with all cluster managers & select one on cmdline. 2009-02-02 14:34:24 +00:00
9f31af4c20 Mention --with-clvmd=corosync in ./configure 2009-01-29 15:23:15 +00:00
ab448cdb57 Add as-yet-unused vg_read_error() and vg_might_exist(). (mornfall) 2009-01-27 01:48:47 +00:00
22c4076818 Introduce as-yet-unused replacement vg_read() and vg_read_for_update()
functions.  (mornfall)
2009-01-27 00:40:44 +00:00
6e8bd97709 Replace internal vg_check_status() implementation. (mornfall) 2009-01-26 22:42:59 +00:00
7dd128a1a8 Properly enforce cluster locking in as-yet-unused _vg_lock_and_read. (mornfall) 2009-01-26 22:22:07 +00:00
dfd422a386 Introduce as-yet-unused _vg_lock_and_read() and associated header file
definitions.
2009-01-26 22:13:22 +00:00
6f434cd94a Rename vg_read() to vg_read_internal(). (mornfall) 2009-01-26 19:01:32 +00:00
a82f2fec18 post-release 2009-01-26 14:46:08 +00:00
234115f384 and another one missing 2009-01-26 14:40:06 +00:00
c522618a4b Add stuff people missed. 2009-01-26 13:34:07 +00:00
1c65c56970 pre-release 2009-01-26 13:14:22 +00:00
c6cff13038 Add a corosync/DLM cluster service to clvmd.
It's not integrated in the configure system yet though.
2009-01-22 10:21:12 +00:00
f25b101161 Use tools.h in for lvm-static. 2009-01-20 20:37:41 +00:00
6a866e208f Add --unquoted to pvs, vgs, lvs man pages. 2009-01-20 17:39:07 +00:00
11b1e5abd7 Add missing --segments to pvs man pg. 2009-01-20 17:27:11 +00:00
f44c387988 Add --nameprefixes to pvs, vgs, lvs man pages. 2009-01-20 17:10:44 +00:00
b6629080ee Fix problems with static build
- compiler warning (missing header)

 - configure should set static flag early to be able
   use STATIC_LINK flag during configure script
2009-01-20 17:07:53 +00:00
4022dd564b Add --rows option to pvs, vgs, lvs man pages. 2009-01-20 16:55:24 +00:00
c848ce66c5 Rename _parse_options() to _parse_fields() for naming consistency.
In libdm, we only ever use 'fields', while the tools use 'options' and
'fields' interchangeably.

Ideally it would be good to use 'fields' consistently everywhere.
However, 'options' most likely comes from the tool commandline '-o' and
'--options' which cannot be changed.
2009-01-19 20:53:35 +00:00
26b4c34778 Add skeleton of fsadm nightly test but skip (doesn't work yet). 2009-01-15 17:14:38 +00:00
7eff83d689 Fix fsadm lvresize for filesystem block sizes != 1024.
Fixes rhbz 480022.
2009-01-15 14:44:48 +00:00
125fb7fbdb A C implementation of "not" that handles fatal signals rather more
intelligently than the shell implementation. C code by Jaroslav Stava.

I have done a rudimentary review and checked that tests still pass.
2009-01-12 18:45:44 +00:00
01be5511e5 ...and a few more uninitialised dummy fields. 2009-01-10 17:21:17 +00:00
4b45c6e35a More fields can cause segfaults with orphans.
Fix these by populating the dummy VG struct more completely.
2009-01-10 17:09:40 +00:00
7f831c1f4d Fix pvs segfault when run with orphan PV and vg_mda_size or vg_mda_free fields
We display '0' for these fields now in this case.  Ideally these values are
undefined for an orphan PV but today there is no way to specify undefined
with display functions such as _size64_disp().
2009-01-10 15:04:28 +00:00
d6778847c9 Fix some checks in lvm-utils.sh. Note that "$(test ...)" is always empty, since
"test" never prints anything. Therefore, "return $(test ...)" is equivalent to
just "return;" which means success in sh (same as return 0). We can however,
thanks to set -e, use "test foo = bar" as an assertion.

PS: test a == b is invalid syntax. It is either = or -eq: = is textual and -eq
is numeric comparison.
2009-01-10 12:19:41 +00:00
9a96645b53 Add <report_type>_all to help text. 2009-01-10 03:14:24 +00:00
ffa1b19e26 Add an "all" field which expands to all fields of the report type.
For example in LVM2, "pv_all" gives all PV fields.
"seg_all" gives all LV segment fields.

"all" gives all fields of the final report type.  I think this is more
useful than just adding the current prefix.

So "lvs -o seg_all" gives all the LV segment fields, whilst
"lvs --segments -o all" adds in LV and VG fields too.

"lvs -o all -O vg_name" has report type LVS+VGS so includes all LV and all
VG fields.
2009-01-10 03:01:35 +00:00
6f98b140a8 Display a 'dev_size' of zero for missing devices in reports. 2009-01-10 02:43:51 +00:00
e83d1a26e6 Add pv_mda_size to pvs and vg_mda_size to vgs. 2009-01-09 22:48:22 +00:00
b237d68c47 Add pv_mda_size to 'pvs' and vg_mda_size to 'vgs'.
Reports the size of the smallest metadata area in a PV or a VG.
Useful to confirm pvcreate --metadatasize or pvmetadatasize setting in
/etc/lvm/lvm.conf file.

NOTE: Actual value in these fields will most always differ from that
given in pvcreate options due to rounding and alignment effects.
2009-01-09 22:44:33 +00:00
1027762816 Document current state of inconsistent metadata behaviour of a few commands in
a test. Should make changes to the !consistent bits of code easier. To be
expanded.
2009-01-09 10:16:57 +00:00
42893fc3bd Initial import of the cluster log daemon from the 'cluster' repository.
There is a rudimentary make file in place so people can build by hand
from 'LVM2/daemons/clogd'.  It is not hooked into the main build system
yet.  I am checking this in to provide people better access to the
source code.

There is still work to be done to make better use of existing code in
the LVM repository.  (list.h could be removed in favor of existing list
implementations, for example.  Logging might also be removed in favor
of what is already in the tree.)

I will probably defer updating WHATS_NEW_DM until this code is linked
into the main build system (unless otherwise instructed).
2009-01-08 17:12:33 +00:00
a479761be5 Add checks for device names in dmsetup and show proper error messages.
Checks added for DM device names to allow only names < DM_NAME_LEN,
otherwise a part of lengthy name would be silently ignored and could
cause confusion while using dmsetup. Also, the name should not contain
'/' character, if it is used in context of creating a new device
or renaming the existing one (because we do not consider full path
to devices, they do not exist in filesystem yet) and appropriate error
messages are shown.
2009-01-07 12:17:40 +00:00
6d7265d966 Fix lvmdump /sys listing to include virtual devices directory. 2009-01-06 18:02:57 +00:00
32048b7658 Fix "Calculate mirror log size" commit, the le_count should be always set. 2009-01-06 17:24:21 +00:00
08f79c6b93 Add "--refresh" functionality to vgchange and vgmknodes. 2008-12-22 09:04:35 +00:00
699a2268d6 Add "--refresh" functionality to vgchange and vgmknodes. 2008-12-22 09:00:51 +00:00
410f9c485e lvm2cmdline.h:31: warning: declaration of `is_static' shadows a global declaration 2008-12-19 18:51:02 +00:00
8561e5e38e Do not issue write behind lv size.
pvcreate $DEV
vgcreate -s 1k vg_test $DEV
lvcreate -l 1 -n lv1 vg_test
..
/dev/vg_test/lv1: write failed after 1024 of 4096 at 0: No space left on device

Just check for maximum write size in set_lv.
2008-12-19 15:26:01 +00:00
17617fe839 Calculate mirror log size instead of hardcoding 1 extent size.
It fails for 1k PE now.

Patch adds log_region_size into allocation habdle struct
and use it in _alloc_parallel_area() for proper log size calculation
instead of hardcoded 1 extent - which can fail.

Reproducer for incorrect log size calculation:
        DEV=/dev/sd[bcd]

        pvcreate $DEV
        vgcreate -s 1k vg_test $DEV
        lvcreate -m1 -L 12M -n mirr vg_test

https://bugzilla.redhat.com/show_bug.cgi?id=477040

The log size calculation is mostly copied from kernel code.
2008-12-19 15:24:52 +00:00
7f4173ab22 Fail add tree node when requested major/minor is used.
Check for major/minor collision is added in _add_dev_to_dtree()
where we already read info by uuid,
so in the case of requesting major/minor it queries device-mapper
by major/minor for device availability.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=204992
2008-12-19 15:23:03 +00:00
84236edaf8 Fix incorrect return value in help function. 2008-12-19 14:43:02 +00:00
370dc2d727 Fix vgrename using UUID in case there are VGs with the same name. 2008-12-19 14:22:48 +00:00
211b07a2e2 Create global is_static() to eliminate from the library init function.
Very simple / crude method of removing 'is_static' from initialization.
Why should we require an application tell us whether it is linked
statically or dynamically to libLVM?  If the application is linked
statically, but libraries exist and dlopen() calls succeed, why
do we care if it's statically linked?
2008-12-18 05:27:17 +00:00
9f67ba6a38 Remove struct arg * from struct cmd_context and create_toolcontext().
This allows us to remove one argument from create_toolcontext() and
moves it closer to a generic library init function.

In the arg_*() functions, we just use _the_args() directly.
For now we leave the first parameter to these
arg_*() functions (struct cmd_context *) because
of the number of files involved in removing the
parameter.
2008-12-17 16:46:45 +00:00
03798fd604 Move arg_* functions from toollib.c to lvmcmdline.c.
In preparation for removing cmd->args.
IMO, it makes more sense to put these accessor functions
in the same location as the static array _the_args.
Next patch will update arg_* functions to use _the_args[]
directly and remove cmd->args.
2008-12-17 16:45:32 +00:00
7bb4897b9f Remove status=noxfer from test, not all dd versions support this (RHEL4 for example). 2008-12-16 20:02:52 +00:00
4b0e97e666 Rename 'cmd' to 'clvmd_cmd' to remove ambiguity.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: James Cameron <james.cameron@hp.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2008-12-16 12:30:39 +00:00
5b655dd4cd Fix segfault when invalid field given in reporting commands.
Problem is dm_report_init() may return NULL and subsequent call to
dm_report_set_output_field_name_prefix() doesn't handle NULL value.

Example:
	pvs --nameprefixes --rows --unquoted --noheadings -opv_name,fred
  Logical Volume Fields
  ---------------------
    lv_uuid              - Unique identifier
    lv_name              - Name.  LVs created for internal use are enclosed in brackets.
 ...

  Physical Volume Segment Fields
  ------------------------------
    pvseg_start          - Physical Extent number of start of segment.
    pvseg_size           - Number of extents in segment.

  Unrecognised field: fred
Segmentation fault
2008-12-15 13:30:45 +00:00
023a61c0e5 Use dm_snprintf to avoid duplicating the snprintf compatibility code. 2008-12-12 18:45:58 +00:00
38cc6383b7 Create _init_globals() and call from bottom of create_toolcontext().
Move init_full_scan_done(0) and init_mirror_in_sync(0) from init_lvm()
after call to create_toolcontext() to _init_globals(), called from bottom
of create_toolcontext().  No functional change.

Author: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: James Cameron <james.cameron@hp.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2008-12-12 03:30:41 +00:00
77ac863bb8 Replace _dm_snprintf with EMIT_PARAMS macro for creating target lines 2008-12-11 16:25:51 +00:00
fdab219755 *** empty log message *** 2008-12-11 13:45:28 +00:00
f31e8d08cd Move initialization of cmd->fmt into init_formats().
init_formats() sets up the command formats, and currently sets cmd->fmt_backup
but does not set cmd->fmt to a default value.  This seems incorrect so we
set it to cmd->default_settings.fmt before returning.

The call we remove here may set cmd->fmt based on a command line setting.
But it is safe to remove this, because the only caller of init_lvm() that
cares about the cmdline override is the cmdline tools (clvmd does not care),
called from lvm2_main().  After lvm2_main() calls init_lvm(), it later calls
lvm_run_command().  In lvm_run_command(), we have a call to _apply_settings(),
which has the identical assignment of cmd->fmt that this patch removes.
2008-12-11 03:36:16 +00:00
224c8ec0fa Remove redundant init_msg_prefix() and init_cmd_name().
This is very obvious - _init_logging() makes the identical init_msg_prefix()
and init_cmd_name() calls with cmd->default_settings so these calls are
clearly redundant after calling create_toolcontext().
2008-12-11 03:34:43 +00:00
309c19ef63 Remove redundant set_activation() call after create_toolcontext() calls.
Very similar argument to removal of init_debug() and other calls.

create_toolcontext() calls _process_config() which sets
cmd->default_settings.activation, then calls
set_activation(cmd->default_settings.activation).  Later, create_toolcontext()
sets cmd->current_settings = cmd->default_settings.  So these calls
set_activation(cmd->current_settings.activation) are redundant.
2008-12-11 03:34:12 +00:00
13aad7e8b4 Remove backup_enable() calls after create_toolcontext() calls.
Identical argument to previous patch which removed archive_enable() calls.
We add a new parameter to backup_init() which sets the enable value based
on the cmd->default_settings.backup value.  This value was used to set
cmd->current_settings.backup, used in the removed backup_enable() call.
2008-12-11 03:33:35 +00:00
6f36d0d06c Remove archive_enable() calls after create_toolcontext() calls.
_init_backup() calls archive_init(), which originally set 'enabled' to
a hardcoded '1' value.  This seems incorrect based on my read of other
areas of the code so here we add a 'enabled' paramter to archive_init().
We pass in cmd->default_settings.archive, which is obtained from the
config tree.  Later in create_toolcontext, cmd->current_settings is
set to cmd->default_settings.  The archive_enable() call we remove
here was using cmd->current_settings to set the 'archive' enable
value.  The final value of cmd->archive_params->enabled should thus
be equivalent to the original code.
2008-12-11 03:32:56 +00:00
76d734a4bd Move init_test() from _apply_settings into _init_logging().
This one we actually need to move.  _init_logging() is called from
    create_toolcontext(), which makes this call:
        /* Test mode */
        cmd->default_settings.test =
            find_config_tree_int(cmd, "global/test", 0);

But it does not call init_test().  So we need an init_test() somewhere.
The most logical place is to put it inside _init_logging(), since this
is where the config value is read and default_settings are set.  Placing
the init_test() call here matches what is done with other variables and
seems to make sense.
2008-12-11 03:31:47 +00:00
b14f29b5b7 Remove handles_missing_pvs assignment after call to create_toolcontext().
This variable is set at the top of create_toolcontext() to 0.
Nothing later in create_toolcontext() changes the value.
In init_lvm(), nothing between create_toolcontext() call and this assignment
changes the value.  Thus, the assignment is redundant.
2008-12-11 03:31:10 +00:00
c57b30e342 Remove init_verbose() calls immediately after create_toolcontext() calls.
The rationale for removing init_verbose() call is very similar to removing
init_debug() call.  create_toolcontext() calls _init_logging() which
makes these calls:
        /* Verbose level for tty output */
        cmd->default_settings.verbose =
            find_config_tree_int(cmd, "log/verbose", DEFAULT_VERBOSE);
        init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);

And being that create_toolcontext() copies default_settings into
current_settings at the bottom, the init_verbose() call we are removing:
        init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);

is redundant.
2008-12-11 03:30:19 +00:00
f6023a7c76 Remove init_debug() calls immediately after create_toolcontext() call.
We can safely remove because create_toolcontext() calls _init_logging(),
which makes these calls:
        /* Debug level for log file output */
        cmd->default_settings.debug =
            find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
        init_debug(cmd->default_settings.debug);

Then at the bottom of create_toolcontext() we do this:
        cmd->current_settings = cmd->default_settings;

So the call we are removing from init_lvm() functions (clvmd and lvmcmdline):
        init_debug(cmd->current_settings.debug);

Just sets the value of debug based on 'cmd->current_settings.debug'.
Since cmd->current_settings is equivalent to cmd->default_settings, and
init_debug() was called with cmd->default_settings, the call we remove is
redundant.
2008-12-11 03:29:37 +00:00
6357a2d9b8 Replace _apply_settings() after create_toolcontext() with equivalent inline.
Subsequent patches will refactor / remove each of these lines, as many of
them are redundant when called immediately after create_toolcontext().
2008-12-11 03:28:54 +00:00
7e3a1a8b18 operate on test subdirectory instead on main /dev 2008-12-10 16:16:53 +00:00
5f1b8f71f3 add simple test for dev node usability (detect devices mounted with nodev) 2008-12-10 16:15:41 +00:00
cca8bb9092 Add liblvm interactive test infrastructure to build. 2008-12-07 19:37:07 +00:00
647314d3cc Make _init_rand() thread safe - use rand_r() instead of rand().
Use good entropy for seed value if possible.
2008-12-07 04:27:56 +00:00
30e6773617 Add generic function to read /dev/urandom, used in uuid calculation. 2008-12-07 04:23:37 +00:00
08774dc558 Fix test-utils.h for rhel4 backward compatability.
for losetup, break out of the loop when successful setup of loop device,
and only look at 7 loop devices (default loop module setting)
for blockdev, use old option if new one is not available
2008-12-05 05:03:23 +00:00
481618826d Added displayable_lvs_in_vg and lv_is_displayable functions to deal with
the counts of visible LVs from user's perspective consistently throughout
the code.
2008-12-04 15:54:26 +00:00
befcada36a Fix vgcreate race which could allow two parallel vgcreates to succeed,
with the second vgcreate overwriting the first.

Obtain lock before calling vg_create(), which checks for existence of vgname
and fails if it already exists.
2008-12-01 20:14:33 +00:00
b71bf9332c Fix uninitialised lv_count in vgdisplay -c 2008-12-01 17:38:35 +00:00
1303c93139 Suppress 'duplicate PV' message when it's only a cache update not a real
duplicate.
2008-11-28 15:51:40 +00:00
29c8c75492 Don't skip updating pvid hash when lvmcache_info struct got swapped. 2008-11-27 18:13:50 +00:00
862d83c691 Add tinfo to termcap search path for pld-linux. 2008-11-24 13:33:16 +00:00
f18eeb4da8 Fix a starup race in clvmd that could result in huge waits for the first command to be processed. 2008-11-21 13:48:00 +00:00
d40fed016f generate init script 2008-11-19 20:14:24 +00:00
76dc3ddf56 regenerate 2008-11-19 19:34:32 +00:00
d80d9a4c4e Generate clvmd init script at configuration time for Red Hat-based distros. 2008-11-19 19:33:25 +00:00
281ee1c2bf post-release (retrospective) 2008-11-19 14:14:51 +00:00
65e976198e daemons depends on liblvm2cmd - fixes parallel builds 2008-11-18 13:16:03 +00:00
a0d668e850 fix missing const char* 2008-11-18 10:13:23 +00:00
f7d624e684 Fix "lvremove -f vgname" when vgname contains snapshots.
Prior to this patch, "lvremove -f vgname" would fail if vgname contained
one or more snapshot LVs.  Now this passes, but has a side-effect.
If you issue "lvremove vgname" where vgname contains one or more snaps,
you will get an extra "y/n" prompt to remove the same snapshot.
Example:
$ lvs
  LV     VG     Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lvsnap vgtest swi-a- 16.00M lvtest   0.05
  lvtest vgtest owi-a- 64.00M
$ lvremove vgtest
Do you really want to remove active logical volume "lvsnap"? [y/n]: n
  Logical volume "lvsnap" not removed
Do you really want to remove active logical volume "lvsnap"? [y/n]: n
  Logical volume "lvsnap" not removed
  Command failed with status code 5.

Fixing this will most likely require modification of the iterator
function, process_each_lvs_in_vg() to iterate over snaps in some
cases (e.g. lvs, vgdisplay -v) but not in others (lvremove).
2008-11-17 18:20:13 +00:00
f5c395adb2 some makefile fixes for liblvm2cmd & remove some hardcoded .so 2008-11-14 20:59:56 +00:00
09192b4d6e More man page cleanup - convert "+/-" to "+|-" 2008-11-12 15:16:58 +00:00
74ec3783e7 Make man pages consistent with either-or options (use "|" everywhere). 2008-11-12 15:01:35 +00:00
1c38ce8245 cleaner const char* usage for last_path_component() 2008-11-12 09:53:33 +00:00
702cfe15be minor compiler warning fix for function declaration prototype 2008-11-12 09:49:06 +00:00
54d790828f removed redundant redeclaration of init_indent() and init_msg_prefix() from lvm-logging.h 2008-11-12 09:41:44 +00:00
aff35fea29 * minor compilator warning fix for improper function declaration. 2008-11-12 09:30:52 +00:00
25a82bcbe3 Add a bunch of sub-tests aimed at testing various bugzillas, by jstava. 2008-11-11 15:46:15 +00:00
cb58100587 Import a bunch of new tests by jstava. Mostly everything pass, they however
tend to expose the lvremove -ff vg ordering bug.
2008-11-11 15:29:24 +00:00
9fbe96fd7c clarify 2008-11-10 21:26:06 +00:00
98cd400443 no need for libdevmapper.h on system any more 2008-11-10 21:25:45 +00:00
873e699f6d Include libdm in lcov reports. 2008-11-10 14:04:12 +00:00
9a8f6c824f Fix t-pool-labels to pass again after the vgdisplay error return fix from
last Friday.
2008-11-10 13:44:01 +00:00
a98888ad07 Fix lvm2.static build. 2008-11-10 13:41:43 +00:00
db98500b72 Minor code and documentation cleanups and changes by jstava. 2008-11-10 12:43:35 +00:00
3feee09cfe add bz264241 check
remove lvconvert progress notifications (-i100)
(by jstava)
2008-11-10 12:41:52 +00:00
4a1cd0d391 First test release of the merged code base. 2008-11-10 12:39:50 +00:00
edb5071d3b bz429342 lvcreate --nosync
bz192865 lvconvert logtype of an inactive mirror lv
(both by jstava)
2008-11-10 12:37:53 +00:00
e9509aa5e6 Add bz186013 check -- lvcreate rejects an invalid regionsize (jstava). 2008-11-10 12:37:03 +00:00
5e6ca1b72d Use separate locking directory for each of the tests, as they never share a
volume group, or physical devices for that matter. Hopefully fixes occasional
test errors due to locking failures. Patch by jstava.
2008-11-10 12:36:23 +00:00
543bf2ffbd Explicitly check after lvremove -ff vg that it did its job. By jstava. 2008-11-10 12:32:00 +00:00
15a7a4c38b Fix lvhange and lvcreate man pages to properly describe permissions option.
James Youngman <jay@gnu.org>
2008-11-07 19:23:52 +00:00
640d07bf35 Fix vgdisplay return code and exit status. 2008-11-07 19:02:47 +00:00
e5ecc2b942 Set LD_LIBRARY_PATH in init.sh, as it is required to run dmsetup now as well,
which otherwise picks up the system version of libdevmapper, which is a pretty
bad idea.
2008-11-07 01:30:03 +00:00
cfd8fe40f4 quick review of docs
Note that we'll continue to use WHATS_NEW_DM for device-mapper changes
until we can switch to unified version numbering.
2008-11-04 17:49:22 +00:00
abba6e0642 make install_device-mapper 2008-11-04 17:25:32 +00:00
ec94fb89a2 clvmd 2008-11-04 16:41:47 +00:00
bb167efa7b dmeventd 2008-11-04 15:55:27 +00:00
2a550ef96d more fixes 2008-11-04 15:07:45 +00:00
03ed7d73fc more missing bits 2008-11-04 14:57:06 +00:00
446852db3b Fix typo. 2008-11-04 14:38:53 +00:00
7c90b57e87 Also report the tests that have been skipped, at the end of harness.sh. 2008-11-04 14:37:51 +00:00
6339e2588b Use $(abs_top_builddir) instead of @DMDIR@ and update paths appropriately. 2008-11-04 14:37:10 +00:00
af6687405b more tweaks for dmeventd - not finished yet 2008-11-03 23:01:21 +00:00
a2bfad1c29 Right, a simple build (without options) is working again. 2008-11-03 22:14:30 +00:00
645aa55abc add list fns 2008-11-03 20:03:00 +00:00
05329c885a more tweaking to get things to compile - dmlib.h for log fns, list.h 2008-11-03 18:59:59 +00:00
b3fed93a74 Rename a couple of variables that matched function names. 2008-11-03 16:26:27 +00:00
2c6fad0ea7 autoreconf 2008-11-01 20:48:50 +00:00
57854c2231 Use simple x.y.z library version in libdevmapper.pc 2008-11-01 20:48:09 +00:00
a8cf4293e0 autoreconf 2008-11-01 02:20:06 +00:00
ba70dce803 further progress 2008-11-01 02:19:19 +00:00
5b4c3ace56 export DM_LIB_VERSION 2008-11-01 01:43:31 +00:00
2ade7a15e2 add libdevmapper-event.h 2008-10-31 22:41:51 +00:00
e83f71d678 autoreconf 2008-10-31 22:34:42 +00:00
412c91cb6b no DMDIR 2008-10-31 22:33:55 +00:00
aa44167319 dm+lvm2 macros 2008-10-31 22:32:54 +00:00
dd5700e8b3 dmeventd plugins move 2008-10-31 22:29:44 +00:00
ef7fc430d7 drop configure --with-dmdir 2008-10-31 22:22:04 +00:00
f1bcb6c634 autoreconf 2008-10-31 22:12:55 +00:00
4a4eb17d08 first attempt at merging configure 2008-10-31 22:06:09 +00:00
8afc267c68 libdevmapper version - will change once the merger's settled in 2008-10-31 21:55:40 +00:00
6457ab31b6 remove ancient debian dir 2008-10-31 12:25:54 +00:00
306dfa2043 Add dm-logging.h ready for libdevmapper. 2008-10-30 17:54:12 +00:00
424bdade0b drop explicit libdevmapper.h 2008-10-30 17:52:06 +00:00
10857e3321 separate lvm-globals 2008-10-30 17:40:00 +00:00
85a4e47879 Separate out globals from the logging code. 2008-10-30 17:39:00 +00:00
759e49f025 Split out lvm-logging.h from log.h. 2008-10-30 17:27:28 +00:00
43924e31b8 Split out dm-logging.h from log.h 2008-10-30 17:24:04 +00:00
3b34fcf59f Add libdm subdir to begin merging the device-mapper tree. 2008-10-30 15:31:33 +00:00
ba7253eaf7 Use lvm-types.h 2008-10-30 15:11:16 +00:00
be23682a30 post-release 2008-10-26 10:40:50 +00:00
3a5dce4c92 pre-release 2008-10-26 10:33:34 +00:00
22d7e60d0e Accept locking fallback_to_* options in the global section as documented. 2008-10-24 01:16:16 +00:00
5752156c9e Fix temp table activation in mirror conversions not to happen in other cmds.
Fix temp table in mirror conversions to use always-present error not zero.
2008-10-23 11:21:04 +00:00
a30215a530 post-release 2008-10-17 17:48:10 +00:00
f9c8c1b964 pre-release 2008-10-17 17:42:08 +00:00
5650f67ef5 Use temp table to set device size when converting mirrors.
(Avoids having same mirror table loaded twice concurrently by first
using a 'zero' table to set the size of the device so when mirror
table is preloaded it doesn't have to be activated immediately.)
2008-10-17 10:57:15 +00:00
5ec25dfb94 In resume_mirror_images replace activate_lv with resume_lv as workaround.
(The resume has the side-effect of resuming all of the original
mirror's sub-lvs in addition to the new 'error' target middle layer.)
2008-10-17 10:50:14 +00:00
ef16682725 Avoid overwriting in-use on-disk text metadata by forgetting MDA_HEADER_SIZE. (Edward Allcutt) 2008-10-17 00:55:46 +00:00
883486cc67 Re-indent test-utils.sh consistently, using tabs. 2008-10-14 19:48:01 +00:00
f367f9b747 Conversion of last 2 tests to use test-utils.sh, by jstava. 2008-10-14 19:41:12 +00:00
a3d987fa73 Fix snapshot monitoring library to not cancel monitoring invalid snapshot.
snapshot DSO unregistered itself when snapshot changed state to invalid.

This can cause a race (and several timeouts), when for example another snapshot
is added and in the middle of operation (suspend/resume) the monitoring thread
unregister itself.

Fix it by keeping the snapshot monitored after invalidation - just reset
threshold to not really print any messages to syslog.
2008-10-13 12:06:30 +00:00
2d48685673 . 2008-10-09 10:47:37 +00:00
9b21ace1e9 Generate man pages from templates and include version. (romster) 2008-10-08 12:50:13 +00:00
be2c03fa96 Add usrlibdir & usrsbindir to configure. 2008-10-07 19:11:59 +00:00
f5585e9252 Add usrsbindir to configure. 2008-10-07 19:08:46 +00:00
4d534dd7e4 Add a workaround for missing losetup -s by jstava, and a print a stacktrace
on errors (also by jstava). Currently requires bash, a fix for that may come
later -- explicitly using bash to run tests in the meantime.
2008-10-06 16:55:30 +00:00
c8584e1cce More test conversions by jstava. Make check still passes. 2008-10-06 16:47:07 +00:00
84a1de464c Fix conversion of md chunk size into sectors. 2008-10-03 14:22:18 +00:00
3966f3d319 device->devices 2008-10-01 22:48:26 +00:00
e6166cf711 Make harness.sh exit with non-zero status when tests fail. 2008-09-30 21:45:42 +00:00
2285712834 Cosmetic: get rid of trailing garbage on comments in t-vgslpit-usage.sh. 2008-09-30 21:43:55 +00:00
53cb6128e8 Improve harness.sh output: also mention failing test's name near the end of its
output. Avoids the need to scroll back just to see which failing test you are
looking at.
2008-09-30 21:43:16 +00:00
8c317baf19 Free text metadata buffer after a failure writing it. 2008-09-30 20:37:52 +00:00
8cac933c71 Fix [ a = b ] usage in t-vgsplit-operation: string comparison is '=', not '=='. 2008-09-30 18:29:10 +00:00
03e61a4bf8 Conversion of t-vgsplit-operation.sh by jstava. 2008-09-30 17:56:54 +00:00
71446a76b2 Fix a syntax error in one of the scripts, introduced by last commit. 2008-09-30 17:50:56 +00:00
28db8d6c7c More test conversions, all of these are by jstava. 2008-09-30 17:47:34 +00:00
786e33d7d5 Port over t-vgreduce-usage. Should fix testsuite hangs where pvremove -ff would
have waited for input on certain test failures.
2008-09-30 17:17:04 +00:00
b140d6c50e Convert t-vgsplit-usage.sh to use the new test-utils.sh. Original conversion by
jstava. Lvm1 testing restored by mornfall.
2008-09-30 15:20:09 +00:00
64a95abdee Convert t-pvremove-usage to use the new test-utils.sh. 2008-09-30 13:19:56 +00:00
57f926be17 Update test/Makefile.in to use the new harness for calling tests. 2008-09-29 16:07:02 +00:00
4933b67959 Add a test for reappearing lost PVs causing endless metadata correction
updates. (A problem Milan fixed recently.)
2008-09-29 16:06:10 +00:00
370b4f1b9e Add a simple test for partial activation. 2008-09-29 16:04:57 +00:00
f3b7baa84e Update a bunch of tests to use functionality from test-utils.sh. 2008-09-29 16:02:50 +00:00
eafdb2c807 Export testlib_cleanup_ from test-lib.sh, which is needed for test-utils.sh to
be able to call proper EXIT traps.
2008-09-29 16:00:53 +00:00
a91fa821ab Import new test utilities and a test harness. 2008-09-29 15:59:19 +00:00
37ef162cda Fix misleading error message when there is no allocatable extents in VG. 2008-09-29 09:59:10 +00:00
770928acfc Fix handling of PVs which reappeared with old metadata version. 2008-09-25 15:59:10 +00:00
d0f3570219 Try to fix possible infinite loop in dependency tree walking (by mornfall). 2008-09-25 15:57:02 +00:00
3d07c2605f Fix mirror DSO to call vgreduce with proper parameters. 2008-09-25 15:52:29 +00:00
c350798528 Fix validation of --minor and --major in lvcreate to require -My always. 2008-09-24 16:32:51 +00:00
6bc3cc0bec . 2008-09-19 18:31:20 +00:00
2e3e5fcc81 suppress warning if old value found for now 2008-09-19 18:26:41 +00:00
dfdb10f6de Add more vgreduce tests. (Jaroslav Stava) 2008-09-19 16:12:25 +00:00
5cbe5909eb Fix vgreduce test, now requires --force flag. (Jaroslav Stava) 2008-09-19 16:10:46 +00:00
04d52b450b fix last release 2008-09-19 15:44:03 +00:00
a586a89547 . 2008-09-19 07:18:03 +00:00
1905eacf15 rename var 2008-09-19 07:12:45 +00:00
858ec0d740 revert unexplained removal of a '<backtrace>' message 2008-09-19 07:03:23 +00:00
76cfd406ca pre-release 2008-09-19 06:48:48 +00:00
9dbaad859d . 2008-09-19 06:44:54 +00:00
95d43e17b3 Improve the way VGs with PVs missing are handled so manual intervention
is required in fewer circumstances.  (mornfall)
2008-09-19 06:42:00 +00:00
09a2dff8de Add device/md_chunk_alignment to lvm.conf 2008-09-19 05:33:37 +00:00
57208f879a adjust pe_align for md chunk size 2008-09-19 05:19:09 +00:00
149638431d remove unsed var 2008-09-19 04:30:02 +00:00
30d2940c67 Pass struct physical_volume to pe_align. 2008-09-19 04:28:58 +00:00
5ee86fc5d0 remove unused var 2008-09-19 03:45:34 +00:00
a03d0e2c3f Store sysfs location in struct cmd_context. 2008-09-19 03:42:37 +00:00
8bd367d58d fix last patch return code 2008-09-19 00:20:39 +00:00
bc633e03aa Fix last checkin - tested wrong dnode. 2008-09-18 22:55:33 +00:00
797d0f1ef1 post-release 2008-09-18 20:09:51 +00:00
1be3e86aa0 Avoid shuffling remaining mirror images when removing one, retaining primary. 2008-09-18 19:56:50 +00:00
e56dd38021 Add missing LV error target activation in _remove_mirror_images. 2008-09-18 19:09:47 +00:00
410904bef1 Prevent resizing an LV while lvconvert is using it. 2008-09-18 18:51:58 +00:00
026cc120e7 Only resume devices in dm_tree_preload_children if size changes. 2008-09-18 18:34:53 +00:00
ef2fda05cf Avoid repeatedly wiping cache while VG_GLOBAL is held in vgscan & pvscan. 2008-09-16 18:05:11 +00:00
92277e3ae2 revert unnecessary 'stack's 2008-09-15 17:06:55 +00:00
fbc34d70b0 Fix pvresize to not allow resize if PV has two metadata areas.
If the PV has two metadata areas, second one is located at the end of the device.

Do not allow resize of PV or second metadata area can be overwritten.
(The check was active only for orphan PVs.)
2008-09-12 15:26:45 +00:00
91dcddbdf7 Do not scan for lvm1 entries in /proc if not running 2.4 kernel.
(LVM1 is only present in 2.4 kernel.)
2008-09-10 10:14:59 +00:00
874f42ad6c Extend deptree buffers so the largest possible device numbers fit. 2008-09-02 12:16:07 +00:00
1989ef4ebc Fix setting of volume limit count if converting to lvm1 format.
Fixes problem when after downconvert to lvm1 VG is broken:

# lvcreate -n lv1 -l 4 vg_test
  Invalid LV in extent map (PV /dev/sdb1, PE 0, LV 0, LE 0)
  ...
2008-08-29 13:41:21 +00:00
4f4c72c065 Add ctype.h header file to silence compile warning on 'isdigit'.
uuid/uuid.c:86: warning: implicit declaration of function 'isdigit'
2008-08-29 00:49:46 +00:00
666cc72661 Fix vgconvert logical volume id metadata validation.
If volume group is downconverted to lvm1 format,
check if lvid has supported format for conversion to lv_num in lvm1.
2008-08-28 18:41:51 +00:00
4524e8f5c9 format1: Not detecing label on disc is not error, remove <backtrace> from debug log
(happens when you explicitly use -M 1)
2008-08-28 13:41:46 +00:00
bd07a29886 Not detecing label on disc is not error, remove <backtrace> from debug log
and report it only if device cannot be read.
2008-08-28 13:28:13 +00:00
a0d865492e fix vgreduce tests to detect partial command failure (Jaroslav Stava) 2008-08-28 11:20:49 +00:00
de27790de8 add vgcreate rejects repeated invocation test
add vgcreate fails when the only pv has --metadatacopies 0 test
(by Jaroslav Stava)
2008-08-28 11:09:58 +00:00
9c910b7be2 add vgrename by uuid test (Jaroslav Stava)
fix vgsplit rejects last mda copy test (Jaroslav Stava)
2008-08-28 10:59:10 +00:00
7f23ab94e2 Fix lvmdump metadata gather option (-m) to work correctly. (Jaroslav Stava) 2008-08-28 10:40:44 +00:00
77dc036c8f Add pvremove usage test (Jaroslav Stava) 2008-08-28 10:24:55 +00:00
aa6e8d82ce - fix environment variable prefix to LVM (this is not GIT:-)
- add lvcreate rejects repeated invocation test
- fix pvs metadata test for partial failure test
- add pvchange reject --addtag to lvm1 pv test

(All fixes by Jaroslav Stava)
2008-08-28 10:07:34 +00:00
3010285bb3 Fix symbolic link creation in test infrastructure.
Original code would create "*.so" symbolic links if there were no actual
files ending in "so".  The second iteration would then cause an error
in the test logs.
2008-08-21 14:33:48 +00:00
aaad3252f8 fail testcase for failed commands inside the for loop 2008-08-20 13:34:33 +00:00
9065f534d8 Fix allocation bug in text metadata format write error path.
Function _text_pv_write doesn't use memory pool but static buffer,
call dm_pool_free in error path in _raw_write_mda_header is wrong.

Move pool free only to path where is the memory pool used.
2008-08-16 09:46:55 +00:00
52361c94e5 valid parameter for lvchange -p is 'rw' 2008-08-13 14:28:17 +00:00
798be60fef added test for coverage improvement
added test for metadata type 1
2008-08-13 13:49:07 +00:00
6294154b15 get lv_list properly from vg->lst and fix compiler warning 2008-08-13 13:42:35 +00:00
6594fe077d Fix vgcfgbackup to properly check filename if template is used. 2008-08-13 12:44:24 +00:00
582706cde6 add tests for pvchange and vgreduce usage (Jaroslav Stava) 2008-08-12 10:04:31 +00:00
6537cbdc17 test vgsplit: reject to give away pv with the last mda copy (Jaroslav Stava) 2008-08-12 10:01:56 +00:00
53959459bb * more strict const 2008-08-07 14:02:32 +00:00
22d6121099 added const modifiers
switched const char* to  const char[] elements to save few relocation entries
2008-08-07 14:01:17 +00:00
48d7f6f2f4 added const and saved relocation entry 2008-08-07 13:59:49 +00:00
9fd4ddc490 configure aborts if lcov or genhtml are missing with --enable-profiling 2008-08-05 14:29:38 +00:00
a4d2fddbb2 add test for pool labels gfs
add test for metadatacopies0 and snapshot manipulation
2008-08-05 12:33:41 +00:00
c54a3f2721 put dmeventd into the LD_LIBRARY_PATH for lvm-wrapper 2008-08-05 12:32:08 +00:00
04c0dba697 vgremove tries to remove lv snapshot first.
Added function lv_remove_with_dependencies().
2008-08-05 12:05:26 +00:00
5406e3b7c5 avoid endless option parsing loop
add support for lvm verbose operation -vvvv
add dlsym path to the test config file
2008-08-05 11:39:54 +00:00
6b624b7d00 * parse error output for 'auto' keyword 2008-08-04 09:15:15 +00:00
2d364d4d80 Improve file descriptor leak detection to display likely culprit and filename. 2008-08-01 19:51:27 +00:00
1f27bf3774 disable mdadm test-case until a better solution is found 2008-08-01 15:44:53 +00:00
d30a2653b5 remove now-redundant slash-stripping 2008-07-31 15:38:52 +00:00
3086822cd2 Change clustered mirror kernel module name from cmirror to dm-log-clustered. 2008-07-31 14:43:39 +00:00
2c08336490 Avoid looping forever in _pv_analyze_mda_raw used by pvck. 2008-07-31 13:07:01 +00:00
5936ac58c2 Change lvchange exit status to indicate if any part of the operation failed. 2008-07-31 13:03:01 +00:00
ded77e3f5c remove unused mdas variable 2008-07-31 12:40:52 +00:00
8a29df0a6c fix pvremove for pvs without mdas 2008-07-31 12:38:31 +00:00
9db22babaf Fix pvchange to handle PVs without mdas. 2008-07-31 12:28:51 +00:00
c318c5ed61 Refactor _text_pv_read and always return mda list if requested. 2008-07-31 10:50:18 +00:00
61243c65cd Add pvcreate tests to verify failure on md array detection. 2008-07-29 21:05:20 +00:00
4a5d5cb462 Fix trivial typo in pvcreate man page. 2008-07-29 18:35:00 +00:00
cbf1447ebd Refactor pvcreate - simplify return codes. 2008-07-25 14:59:51 +00:00
30104441bf Refactor pvcreate - --yes argument 2008-07-25 14:45:24 +00:00
b4a70804f0 Refactor pvcreate - --force parameter. 2008-07-25 14:36:55 +00:00
74f6707bde Refactor pvcreate - use '0' for no --uuid or --restorefile options. 2008-07-25 14:12:29 +00:00
223eb8c84d configure: regenerate 2008-07-25 08:00:40 +00:00
107d000606 Avoid compiler warnings (provoked by new configure.in bug) on RHEL5.
Do not override the default action of AC_CHECK_LIB([readline],...
(i.e., leave the ACTION-IF-FOUND parameter blank) so that the
subsequent check for rl_completion_matches can use -lreadline.

Also, replace AC_CHECK_FUNC+AC_DEFINE with an equivalent AC_CHECK_FUNCS call.
2008-07-25 08:00:18 +00:00
43e05607af Refactor pvcreate - move uuid and restorefile options. 2008-07-25 00:30:57 +00:00
55793452d5 Add pvcreate tests for uuid and restorefile. 2008-07-24 17:33:40 +00:00
686ba37255 . 2008-07-24 15:39:47 +00:00
03ed19dad5 reinstate lost FIXME
- only if kernel gives the info, not to be worked out in userspace
- with lvm.conf option to enable/disable the check
2008-07-24 15:25:09 +00:00
ad2b6e5de1 configure: regenerate 2008-07-24 14:54:26 +00:00
767676d6ff Don't make configure fail when readline library is not available. 2008-07-24 14:54:06 +00:00
bc7a54c615 Remove dead code, is_lvm_partition() - no functional change.
This code does nothing.  The function is #defined to 1 which ensures the only
two if statements referencing it will never be true.
2008-07-23 19:46:33 +00:00
1bda393678 Refactor pvcreate - move labelsector parameter parsing & validation. 2008-07-23 19:29:58 +00:00
bb5495c6bd Refactor pvcreate - divide parameter parsing & validation from create logic.
Move size (setphysicalvolumesize option), metadatacopies and metadatasize
validation.
2008-07-21 19:27:22 +00:00
484f905749 Refactor pvcreate to divide parameter parsing & validation from create logic. 2008-07-21 19:26:33 +00:00
e0d61a4336 Add more pvcreate tests to validate writing lvm2 label using --labelsector. 2008-07-21 18:50:10 +00:00
e643a16ba5 Refactor _lvcreate() - no functional change. 2008-07-17 15:19:42 +00:00
98fadec2b6 Only use lvm2 metadata for now. 2008-07-17 04:03:04 +00:00
14f464ecb0 Update pvcreate and vgsplit tests.
Add more pvcreate tests.
Start handling lvm1 and lvm2 metadata and metadatacopies=0,1.
2008-07-17 03:17:01 +00:00
2ecdaf9bd4 Add pvcreate sanity tests, check for label_write() failure in _text_pv_write().
Failure to check for label_write() return code caused the following test
to indicate it passed when it really failed:
pvcreate rejects labelsector > 1000000000000
2008-07-16 21:32:38 +00:00
707c898f66 Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. 2008-07-16 10:46:12 +00:00
69e4400774 Cease recognising snapshot-in-use percentages returned by early development kernels. 2008-07-15 00:25:52 +00:00
695efde68d Fix gcc warnings. 2008-07-11 09:19:54 +00:00
0c4b769011 Add "flags" metadata field (akin to "status") for backward-compatible flags.
The "status" field is treated as it ever has been, unknown flags there are
treated as fatal metadata errors. However, in the "flags" field, any unknown
flags will be ignored and silently dropped. This improves
backward-compatibility possibilities. (Any versions without support for this
new "flag" field will drop the field altogether, which is same as ignoring all
the flags there.)
2008-07-10 11:30:57 +00:00
e53eff0634 . 2008-07-10 09:50:23 +00:00
6c75243a06 Add #include <signal.h> to dmeventd.c, fixes compilation on NetBSD. 2008-07-09 13:26:07 +00:00
efde37880b Fix dmeventd regression where mirror and snapshot monitoring libraries
failed to link against liblvm2cmd.

Dmeventd DSOs *require* lvm2cmd to be linked in.

For the future:
1) AC_SUBST does not create Makefile variables, only @foo@-style substitutions
2) When using `test', whitespace around `=' is essential:
    test a=b is true, as is test a=a
2008-07-09 09:59:42 +00:00
7d8f6381be post-release 2008-06-27 22:35:22 +00:00
3c361e3393 pre-release 2008-06-27 21:56:35 +00:00
8440ecef5e Enable readline by default if available. 2008-06-27 19:57:27 +00:00
6401f1b1c9 tweak lcov configuration/makefiles 2008-06-27 19:24:17 +00:00
7487a7c988 Added generation of the versioned libdevmapper-event.so for LVM's test 2008-06-27 15:36:51 +00:00
f44584fa10 extended configure with --enable-profiling for compiling code with gcov info
extended Makefile with targets:
  cov-reset - reset counters
  cov       - generete report to covhtml subdirectory
  covd      - generate report to covhtml-DATE-TIME subdirectory
2008-06-27 15:35:09 +00:00
7b32165614 Fix up cache for PVs without mdas after consistent VG metadata is processed. 2008-06-27 15:18:31 +00:00
b0dc94d187 Update validation of safe mirror log type conversions in lvconvert. (brassow) 2008-06-26 23:05:11 +00:00
0383c4e1d8 Fix lvconvert to disallow snapshot and mirror combinations. (mpatocka) 2008-06-26 21:38:58 +00:00
a8c5758222 Underline longer report help text headings. 2008-06-25 19:52:52 +00:00
a7fabfd8cb Fix reporting of LV fields alongside unallocated PV segments. 2008-06-25 16:52:27 +00:00
5d5b575d16 Test script cleanup. 2008-06-25 16:51:26 +00:00
ac1373653c post-release 2008-06-25 14:44:00 +00:00
b097aa787b pre-commit 2008-06-25 14:24:17 +00:00
723be0fe69 Align struct memblock in dbg_malloc for sparc. 2008-06-25 14:10:33 +00:00
f0597a03de Cope with missing field values. 2008-06-25 00:10:36 +00:00
65f0656f54 Add --rows to dmsetup. 2008-06-24 22:53:48 +00:00
507ece15a5 Add --rows to reports. 2008-06-24 22:48:53 +00:00
30be4d1613 Add --unquoted to reporting tools. 2008-06-24 21:21:04 +00:00
366e89bda0 dmsetup --unquoted 2008-06-24 20:16:47 +00:00
f159c3f768 Refactor pv_create() to take cmd_context - no functional change. 2008-06-24 20:10:32 +00:00
8506d1d567 Suppress invalid 'sb_offset' compiler warning (FC8) with uninitialized_var().
device/dev-md.c:61: warning: ‘sb_offset’ may be used uninitialized in this function
2008-06-23 19:26:21 +00:00
111829da46 Add uninitialized_var macro to suppress invalid compiler warnings.
One such warning is seen on fedora9 gcc compiler:
/metadata.c:1923: warning: 'results' may be used uninitialized in this function
2008-06-23 19:04:34 +00:00
605798073e Suppress 'sb_offset' compiler warning by using enum for md superblock versions.
The warning is bogus and is only seen on certain versions of gcc.
However using the enum does seem to clarify the intent of the code - only
3 possible md minor superblock versions.

Related compiler warning:
device/dev-md.c:53: warning: 'sb_offset' may be used uninitialized in this function
2008-06-23 14:54:50 +00:00
8320f2b094 lvm2_run: don't return uninitialized for _memlock_inc or _memlock_dec
* tools/lvmcmdlib.c: Initialize "ret".  Also avoid useless string
comparison.
2008-06-23 09:27:45 +00:00
df0d8d809b configure: regenerate 2008-06-23 09:25:57 +00:00
062886df64 avoid link failure when configuring without --enable-cmdlib
* configure.in (LVM2CMD_LIB): Define if --enable-cmdlib.
* dmeventd/mirror/Makefile.in (CLDFLAGS): Use $(LVM2CMD_LIB) rather
than hard-coding -llvm2cmd.
* dmeventd/snapshot/Makefile.in (CLDFLAGS): Likewise.
2008-06-23 09:25:08 +00:00
148ea3aaa8 avoid link failure when configuring without --enable-readline
* configure.in: Define READLINE_SUPPORT not when processing
--enable-readline or --disable-readline, but rather only after
determining that readline support is desired and the readline
library is available/usable.
2008-06-23 09:23:48 +00:00
ab5f66c13a Make clvmd return immediately if other nodes are down in an openais cluster. 2008-06-20 12:46:21 +00:00
e65ffb8e68 Make clvmd return immediately if other nodes are down in a gulm cluster.
bz#447799
2008-06-20 10:58:28 +00:00
949c1ab517 Improve/Fix read ahead 'auto' calculation for stripe_size
Fix lvchange output for -r auto setting if auto is already set
Add testcase for read ahead
2008-06-18 11:32:14 +00:00
946d8ee046 avoid compiler warning about cast in OFFSET_OF macro
* dmsetup/dmsetup.c (OFFSET_OF): Use an equivalent definition
that does not cast a pointer value to a narrower type.
2008-06-18 10:19:25 +00:00
c54a8a2e10 Fix identifier 'error_message_produced' used ambiguously.
Related compiler warning:
log/log.c:242: warning: declaration of 'error_message_produced' shadows a global declaration
../include/log.h:98: warning: shadowed declaration is here
2008-06-17 14:14:00 +00:00
31177e4f85 Trivial fix to lvcreate man page for --mirrorlog option. 2008-06-16 14:16:02 +00:00
750f81b4b5 Begin syncing configure.in for merge/unification with device-mapper. 2008-06-13 14:37:18 +00:00
987ff02a45 Don't deref uninitialized log_lv upon failed mirror addition.
* mirror.c (add_mirror_images): Ensure that log_lv is initialized.
2008-06-13 12:15:55 +00:00
f5adaf813c Don't call openlog for every invocation of debuglog.
Patch from Masatake YAMATO
2008-06-13 07:44:14 +00:00
78ff7dc7f0 Add --force to lvextend and lvresize. 2008-06-12 13:24:02 +00:00
d1fced3324 Fix vgchange to not activate mirror leg and log volumes directly. 2008-06-12 11:49:46 +00:00
e7df9c289b Makefile.in: correct distclean rule
* Makefile.in (SUBDIRS): Remove long-unused test/* names.
(SUBDIRS) [distclean]: Append "test".
Discovered with Zdeněk Kabeláč.
2008-06-12 09:48:45 +00:00
a78d7231a9 break (rather than return) so we have only one point of return
* tools/toollib.c (process_each_segment_in_lv): Upon sigint_caught,
break rather than returning ret_max.  No semantic change.
2008-06-11 15:02:52 +00:00
ba7ae0002e copy vgid only when volume group is present in import_pool_pv 2008-06-11 13:14:41 +00:00
a090f7b839 post-release 2008-06-11 12:14:41 +00:00
34ed15a987 pre-release 2008-06-11 12:08:19 +00:00
cacec4c910 Fix tracking of validity of PVs with no mdas in lvmcache. 2008-06-11 11:02:05 +00:00
3e47d4e65b Fix return values for reporting commands when run with no PVs, LVs, or VGs.
The new error checking code caught some commands that were returning '0' as
an exit status for success.  This is incorrect and resulted in a benign error
message displayed (see below).  As of today, all commands should return a
value defined in lib/commands/errors.h (1-5).  This results in an exit code of
0 on success, or > 0 on failure (as stated in the lvm.8 man page).

Before change:
1. Make sure no PVs are on the system
2. Run 'pvs'
  Command failed with status code 0.

After change:
<no output>
2008-06-10 20:07:04 +00:00
8b42fa150b Add ommitted unlock_vg() call when sigint_caught() during vg processing.
Specific test case:
1. pvcreate /dev/loop1; vgcreate vg1 /dev/loop1; lvcreate -L 64M -n lv1 vg1
2. vgremove vg1 (will prompt user)
3. CTRL-C
Code will exit with:
Do you really want to remove volume group "vg2" containing 2 logical volumes? [y/n]:
  Volume group "vg2" not removed
  Command failed with status code 5.
  Internal error: Volume Group vg2 was not unlocked
  Device '/dev/loop1' has been left open.

After change:
Do you really want to remove volume group "vg2" containing 2 logical volumes? [y/n]:
  Volume group "vg2" not removed
  Command failed with status code 5.
2008-06-10 15:25:38 +00:00
60e660b9c7 Fix wrong free_count on imported volume group from pool device
Fix segfault when calling pvcreate on the pool device
2008-06-10 14:55:14 +00:00
fe74f013e3 Fix inverted no_flush debug message. (mpatocka) 2008-06-10 11:19:19 +00:00
24c0c70f90 Fix segfault after _free_vginfo by remembering to remove vginfo from list. 2008-06-09 16:22:33 +00:00
757f91ca89 Add simple test case to repro pvs segfault with duplicate vgnames. 2008-06-09 15:31:58 +00:00
5c34f7847e bring list.h into line with lvm2 2008-06-08 14:53:51 +00:00
de456f014e Tweak detection of invalid fid after changes to PVs in VG in _vg_read. 2008-06-08 14:18:44 +00:00
d29565066d Revert assuming precommitted metadata is live when activating (unnecessary). 2008-06-08 11:33:15 +00:00
4d52c9233b . 2008-06-06 20:45:41 +00:00
6da1ca0cb9 rename some config vars 2008-06-06 20:44:35 +00:00
2f02f1518a Bring configure.in into line with the lvm2 version. 2008-06-06 20:33:13 +00:00
e8863707de Drop cached metadata for disappearing VG in vgmerge. 2008-06-06 19:32:35 +00:00
6a336dfc69 post-release 2008-06-06 19:28:35 +00:00
35dec1b9e4 pre-release 2008-06-06 19:09:19 +00:00
f148280c99 switch to single quotes rather than double for nameprefixes 2008-06-06 19:07:47 +00:00
599fe39749 nameprefixes 2008-06-06 18:53:26 +00:00
44f3fcb238 change --prefixes to --nameprefixes 2008-06-06 18:53:08 +00:00
af40fdb285 back out unnecessary changes for this release 2008-06-06 17:36:19 +00:00
9daf8b825c pre-release 2008-06-06 17:24:28 +00:00
ef5d8ce367 cleaner LCK_LV decoding 2008-06-06 16:37:51 +00:00
4a199ab23b cache dropping needs to use old name not new
rename variable to reduce confusion
2008-06-06 16:13:35 +00:00
6f0f5a569d * lvm-utils.sh (init_root_dir_): Correct a diagnostic.
Author: Jim Meyering <meyering@redhat.com>
2008-06-06 13:48:57 +00:00
3172fbfde6 Drop cached metadata when renaming a VG. 2008-06-06 13:04:44 +00:00
e97a07a505 fix _free_vginfo not to remove a ref to a *different* vginfo from the vgid cache 2008-06-06 12:43:40 +00:00
6579ad92da cope with volatile vginfo in vg_read 2008-06-06 11:12:50 +00:00
ec2fad0cfa Allow for vginfo changing during _vg_read. 2008-06-06 09:48:04 +00:00
6196ac7995 Initialise params buffer to empty string in _emit_segment. 2008-06-05 19:10:35 +00:00
095a861018 Decode numbers in clvmd debugging output. 2008-06-05 14:24:28 +00:00
2449ed7765 Add missing deactivation after activation failure in lvcreate -Zy. 2008-06-05 13:38:30 +00:00
117a0408d6 When activating, if precommitted metadata is still cached, assume it's live. 2008-06-05 13:06:39 +00:00
a54b0223a3 When removing LV symlinks, skip any where the VG name is not determined. 2008-06-05 12:45:55 +00:00
44ee708ba5 Drop metadata cache if update fails in vg_revert or vg_commit. 2008-06-03 17:56:54 +00:00
58a20d0fb6 Correct config file line numbers in messages when parsing comments. (kabi) 2008-06-03 17:51:04 +00:00
063078a02d suppress warning on silent failure with ECMD_PROCESSED 2008-06-03 17:48:13 +00:00
01402fea50 Trivial fix to lvchange man pg for consistency. 2008-06-02 15:54:32 +00:00
b7fc2d1147 In script-processing mode, stop if any command fails.
Warn if command exits with non-zero status code without a prior log_error.
2008-05-30 15:27:44 +00:00
43eeb7011c fix setpriority int error 2008-05-28 23:12:45 +00:00
d7901a4220 Avoid spurious duplicate VG messages referring to VGs that are gone.
(untested)
2008-05-28 22:27:47 +00:00
0c6271dabc Skip add_dev_node when ioctls disabled.
Make dm_hash_iter safe against deletion.
Accept a NULL pointer to dm_free silently.
2008-05-21 16:14:46 +00:00
2d4cf0c9f5 Temporarily disable dmeventd mirror monitoring during lvchange --resync. 2008-05-21 14:10:11 +00:00
0646d0dd91 revert accidental checkin 2008-05-19 20:06:34 +00:00
83e54b45a5 Refactor some vginfo manipulation code. 2008-05-19 19:49:56 +00:00
5cd87d3d27 more cleanup 2008-05-09 19:26:58 +00:00
689d8a80b5 More P_ and V_ lock cleanup. 2008-05-09 18:45:15 +00:00
b1d82a92e7 Add missing mutex around clvmd lvmcache_drop_metadata library call. 2008-05-09 15:13:20 +00:00
4d65627a50 Fix uninitialised mutex in clvmd if all daemons are not running at startup.
Thanks to Mark Hlawatschek for pointing this out.
2008-05-09 09:59:39 +00:00
ce3a68d817 Make clvmd-cman use a hash rather than an array for node updown info.
This will allow it to cope with very large nodeids such as those
generated by clusters using cman_tool join -X
2008-05-09 07:20:04 +00:00
409725be24 Avoid unnecessary unlock attempts with LCK_CACHE pseudo-locks. 2008-05-08 18:35:58 +00:00
b74f74a0d7 When asked to drop cached committed VG metadata, invalidate cached PV labels. 2008-05-08 18:28:27 +00:00
719d554430 Drop metadata cache before writing precommitted metadata instead of after. 2008-05-08 18:06:58 +00:00
13f54f4521 remove unused lvmcache_drop_vg prototype 2008-05-08 18:00:47 +00:00
57dfc9cf42 Don't touch /dev in vgrename if activation is disabled. 2008-04-30 14:34:02 +00:00
57244a6823 post-release - reinstate incomplete enhancements 2008-04-29 16:11:28 +00:00
8bdde01bef pre-release (bug fixes only - enhancements excluded) 2008-04-29 15:58:25 +00:00
09bbd5a472 fixing fsadm usage with older blockdev,blkid,readline tools
fixing lvresize extension code path where size was not set for fsadm
2008-04-29 15:25:28 +00:00
9154a74400 . remove_lock_wait.diff remove the definition of "struct lock_wait",
which is not used since the switch away from async version saLck
. num_nodes should equal to member_list_entries, i.e.
joined_list_entires is 0 when a node leaves the group.

Thanks to Xinwei Hu for the patch.
2008-04-29 08:55:20 +00:00
1399b84b32 The attached patch is a try to make clvmd work correctly on openais stack.
It does 2 things.

1. The cpg_deliver_callback make a compare between target_nodeid and our_nodeid.
It turns out openais set target_nodeid to 0 sometimes. for broadcasting ? I change the behavior so that lvm will process_remote also on target_nodeid == 0

2. The joined_list passed to cpg_confchg_callback doesn't include the already exist nodes in the group, which leads to an incomplete node_hash. I simply add all other nodes in member_list to node_hash also.

Thanks to Xinwei Hu for this patch.
2008-04-28 08:57:11 +00:00
2ddbb3a8fa Exclude VG_GLOBAL from internal concurrent VG lock counter.
(Avoids 'device left open' warning messages from vgscan etc.)
2008-04-24 02:22:07 +00:00
e46a6d1cc1 Add test for rhbz440405 - lvconvert -m0 fails incorrectly if all PEs allocated. 2008-04-23 18:27:59 +00:00
b698ab9011 Fix vgsplit internal counting of snapshot LVs. 2008-04-23 14:33:06 +00:00
0a2572a5eb Update test function _check_{vg|lv|pv}_field to aid in test debug.
Author: Dave Wysochanski <dwysocha@redhat.com>
2008-04-23 13:02:03 +00:00
77d049cc3d Fix internal snapshot_count when vgmerge with snapshots in source VG. 2008-04-23 12:53:10 +00:00
7b8f053be2 Simplify locking code by using saLckResourceLock rather than
saLckResourceLockAsync.

Thanks to Xinwei Hu for the patch.
2008-04-23 09:53:49 +00:00
2c850d5293 Check lv_count in vg_validate.
Fix internal LV counter when a snapshot is removed.
2008-04-22 12:54:33 +00:00
4056bbf10b Fix metadata corruption writing lvm1-formatted metadata with snapshots. 2008-04-22 11:47:22 +00:00
896b04a846 Use 'active' for !suspended as the code already uses that. 2008-04-21 16:57:11 +00:00
93cda8b6ec Add 3 new reporting colums: tables_loaded, readonly, suspended. 2008-04-21 13:16:30 +00:00
bb5e930684 Add --prefixes to dmsetup
E.g. dmsetup info -c --prefixes

Again, might change the name of this option.
2008-04-21 11:59:22 +00:00
43761fed2a Add --prefixes to reporting tools for field name prefix output format.
E.g. lvs --prefixes --noheadings --unbuffered --units m --nosuffix

(Used '--prefixes' for now, but I'm looking for a better name.)
2008-04-20 00:15:08 +00:00
a636299680 Add field name prefix option to reporting functions. 2008-04-20 00:11:08 +00:00
08e5bd5b72 Calculate string size within dm_pool_grow_object. 2008-04-19 15:50:18 +00:00
2f057bef5e Fix lvconvert -m0 allocatable space check. 2008-04-18 12:50:24 +00:00
5ab4f21444 post-release 2008-04-15 15:01:18 +00:00
9ec26ed481 missing stack 2008-04-15 14:57:12 +00:00
29c9df1389 pre-release 2008-04-15 14:49:17 +00:00
867e9c51d4 Drop cached VG metadata before and after committing changes to it. 2008-04-15 14:46:19 +00:00
0170f7b42a rename P_global to P_#global 2008-04-15 11:36:46 +00:00
74bb6ead95 Don't attempt remote metadata backups of non-clustered VGs. (2.02.29) 2008-04-14 19:49:12 +00:00
303388e5cb Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) 2008-04-14 19:24:16 +00:00
8388779937 Fix vgsplit and vgmerge tests for updated lv counting. 2008-04-11 14:06:16 +00:00
fc7dfca452 Update vgsplit test to verify loosening of active LV restriction.
This and prior 2 commits resolve Red Hat bz 252041:
Ability to vgsplit an active Volume Group where the split involves only inactive LVs
2008-04-10 21:38:52 +00:00
e5a1db2392 Update vgsplit to only restrict split with active LVs involved in split.
Existing code will reject a vgsplit if any LVs in the source VG are active.
This patch updates vgsplit to only check LVs involved in the split.
2008-04-10 21:34:53 +00:00
6790656af6 Add lv_is_active() to determine whether an lv is active.
Handles non-clustered as well as clustered.  For clustered,
the best we can do is try exclusive local activation.  If this
succeeds, we know it is not active elsewhere in the cluster.
Otherwise, we assume it is active elsewhere.
2008-04-10 21:34:18 +00:00
b7477bdc15 post-release 2008-04-10 20:07:19 +00:00
ffc61f31de . 2008-04-10 20:02:04 +00:00
e612871ea7 more pre-release cleanup 2008-04-10 19:59:43 +00:00
7f40f09f10 fix 3rd copy 2008-04-10 19:16:35 +00:00
456e42257c make list_move consistent with other list fns 2008-04-10 19:14:27 +00:00
8618c271cf Update vgsplit tests that count LVs for adjusted LV counting. 2008-04-10 18:55:40 +00:00
72ca1ccc23 . 2008-04-10 18:53:36 +00:00
075b4bef3f pre-release 2008-04-10 18:19:49 +00:00
b59fce4393 post-release 2008-04-10 18:04:31 +00:00
8674a25eb8 pre-release 2008-04-10 18:00:45 +00:00
10bf8fd2cd Fix vgdisplay 'Cur LV' field to match lvdisplay output.
Fix lv_count report field to exclude hidden LVs.
2008-04-10 17:19:02 +00:00
57cb22ff3c Add vg_is_clustered() helper function.
Should be no functional change.
2008-04-10 17:09:32 +00:00
0162abdcae Minor vgsplit cleanups. 2008-04-10 02:15:56 +00:00
5801171518 Add _move_one_lv() helper function for vgsplit. 2008-04-10 01:30:22 +00:00
bf1edbd1e2 Fix lvm tool exit code display in some tests. 2008-04-10 01:06:48 +00:00
a8484d987d Add vgsplit tests to verify mirror is not moved unnecessarily. 2008-04-09 21:10:13 +00:00
9b2147f608 Fix vgsplit to only move hidden 'snapshotN' LVs when necessary.
This bug has been around for a long time as far as I can tell.
Without this fix, a vgsplit would unconditionally move the
'hidden/internal' snapshot LVs, and result in corrupted metadata
in the following case:
vg1: contains lv1, lv1snap, both on pvset1
vg1: contains lv2, on pvset2

"vgsplit vg1 vg2 pvset2"
would result in "snapshot0" hidden LV being moved to vg2, and
the origin and cow being left in vg1.  The tools detect the
corruption in vg2, but not in vg1.
2008-04-09 20:56:06 +00:00
32530b378e Update vgsplit tests for lvnames on the cmdline. 2008-04-09 14:47:34 +00:00
a42905efa6 Update vgsplit man page to reflect lvnames on cmdline. 2008-04-09 14:39:55 +00:00
c59745f9dd Update vgsplit to take "-n LogicalVolumeName" on the commandline. 2008-04-09 13:47:13 +00:00
b4ad9a5d08 Use clustered mirror log with pvmove in clustered VGs, if available. 2008-04-09 12:56:34 +00:00
3ead7a38b1 Fix some pvmove error status codes. 2008-04-09 12:45:32 +00:00
bf90435200 *** empty log message *** 2008-04-08 22:02:16 +00:00
9c181fa3d3 Fix vgsplit error display - fully remove log_suppress.
Author: Dave Wysochanski <dwysocha@redhat.com>
2008-04-08 21:47:54 +00:00
3af0b1eb90 Fix vgsplit error paths to release vg_to lock. 2008-04-08 21:38:09 +00:00
7110c318ee Indicate whether or not VG is clustered in vgcreate log message.
Mention default --clustered setting in vgcreate man page.
2008-04-08 14:22:13 +00:00
49a552ccdc Add config file overrides to clvmd when it reads the LVs list so that
config items 'command_names' and 'prefix' don't prevent it working.
2008-04-08 13:03:13 +00:00
57685f17a9 Fix vgreduce to use vg_split_mdas to check sufficient mdas remain.
Add (empty) orphan VGs to lvmcache during initialisation.
Fix orphan VG name used for format_pool.
2008-04-08 12:49:21 +00:00
a1c09a463f create fids for internal orphan VGs 2008-04-07 22:12:37 +00:00
194121760a Update lvmcache VG lock state for all locking types now. 2008-04-07 19:17:29 +00:00
6a987d46bf Fix output if overriding command_names on cmdline. 2008-04-07 13:53:26 +00:00
e3db0b39b9 Add detection of clustered mirror log capability.
Currently only check for kernel module presence.
2008-04-07 10:23:47 +00:00
4d4f0ee188 Add check to vg_commit() to ensure lock is held before writing new VG metadata. 2008-04-04 15:41:20 +00:00
ac7334c167 Add validation of LV name to pvmove -n. 2008-04-04 11:59:31 +00:00
e7bdd69af0 If lvm.conf was touched, clvmd attempted to update the toolcontext
but only did half of the job. It now shares the do_refresh_cache()
function that vgscan invokes.
2008-04-04 08:53:47 +00:00
fefc655969 Add some basic internal VG lock validation. 2008-04-03 18:56:40 +00:00
4dceaef60e . 2008-04-03 14:40:34 +00:00
6fc10dd3ae . 2008-04-03 14:32:31 +00:00
1ecd05a584 fix vd->virtblk 2008-04-03 10:29:00 +00:00
976acaca31 enable vg metadata cache by default 2008-04-02 21:31:14 +00:00
b4e5131d59 Add per-command flags to control which commands use the VG metadata cache. 2008-04-02 21:23:39 +00:00
49f7cfefd7 Fix vgsplit locking and remove unneeded error messages when split into new VG.
When vg_lock_and_read() calls were added, they were done so incorrectly for
the destination VG (vg_to).  This resulted in the VG lock not obtained when
a new VG was the destination (vg_lock_and_read() would fail in the vg_read()
clause, which would then release the lock before returning NULL), and could
result in corrupted destination VG.

The fix was to put back the original lock_vol() and vg_read() calls for 'vg_to'.
The failure of vg_read() indicates "vg does not exist", and we key off that
to determine whether we are dealing with a new or existing VG as the
destination.

The first two error messages were also the result of the incorrect
vg_lock_and_read() calls:
  Volume group "new" not found
  cluster request failed: Invalid argument
  New volume group "new" successfully split from "vg"

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=438249
2008-04-02 19:30:12 +00:00
fc365092f6 Suppress "Volume group not found" message when vgsplit of new VG. 2008-04-02 13:08:49 +00:00
7f26240442 Fix lvresize to dump stack if vg_lock_and_read() fails.
Necessary because vg_lock_and_read() may fail silently if the vg_check_status() call fails.

Also add lvresize tests.
2008-04-02 12:17:30 +00:00
db559bb20a Cache VG metadata internally while VG lock is held. 2008-04-01 22:40:13 +00:00
52850faa15 Fix redundant lvresize message if vg doesn't exist.
BEFORE:
tools/lvm lvresize -l +4 vg22/lv1linear
  Volume group "vg22" not found
  Volume group vg22 doesn't exist

AFTER:
tools/lvm lvresize -l +4 vg22/lv1linear
  Volume group "vg22" not found
2008-04-01 22:15:16 +00:00
57d9a6c836 Fix another allocation bug with clvmd and large node IDs.` 2008-04-01 15:01:30 +00:00
752c880bfc Add find_lv_in_lv_list() and find_pv_in_pv_list().
Update _add_pvs() to call find_pv_in_pv_list().
2008-03-28 19:08:23 +00:00
d83a354781 Enhance test debugging by updating verbose mode of check_*_field_ functions.
Author: Dave Wysochanski <dwysocha@redhat.com>
2008-03-28 18:02:22 +00:00
17dd81336d Fix a couple of uninitialised variables. The newfd one could cause
some obscure hangs.
2008-03-28 12:58:09 +00:00
eaa46a2575 Add vgmerge tests. 2008-03-26 18:03:35 +00:00
fc0ec1e71e Use list_move() in applicable places. 2008-03-26 17:26:32 +00:00
fb2f92df1d Add pvseg_is_allocated() for identifying a PV segment allocated to a LV. 2008-03-26 16:48:10 +00:00
74adbb77b7 Add list_move() support function for list manipulation. 2008-03-26 16:20:54 +00:00
788e544e1d Add 'is_reserved_lvname()' helper function.
Very similar to apply_lvname_restrictions but without the error messages.
2008-03-25 15:24:59 +00:00
368a0d4d2d Correct command name in lvmdiskscan man page. 2008-03-25 12:37:48 +00:00
962b7222d0 When reallocating the node IDs array, make it bigger rather than smaller! 2008-03-25 10:41:59 +00:00
17c1f54369 Add vgsplit tests to verfy attributes of new VG match source VG.
Author: Dave Wysochanski <dwysocha@redhat.com>
2008-03-23 15:40:35 +00:00
33ae38e71b Fixup vgsplit tests in preparation for vgsplit changes. 2008-03-21 22:00:29 +00:00
ef58af4bf1 Update vgsplit tests to execute twice (existing and new VG as destination). 2008-03-21 21:14:38 +00:00
3fad2db2f8 Add LV and VG name restrictions to the lvm man page.
Original patch by: Gerrard Geldenhuis <Gerrard.Geldenhuis@datacash.com>
2008-03-20 18:34:29 +00:00
9feaeb28ca preparation for vg cache 2008-03-17 16:51:31 +00:00
0075364715 Fix potential thread deadlock.
Also make local sockets non-blocking.
2008-03-17 09:37:47 +00:00
99c5da5da5 Const cleanups in find_* functions. 2008-03-13 22:51:24 +00:00
22c957bc20 Refactor text format initialisation into _init_text_import. 2008-03-13 12:33:22 +00:00
3316d59910 Add metadata test for escaping double quotes in device names (bz431474). 2008-03-12 17:34:58 +00:00
a109ce1eca Escape double quotes and backslashes in external metadata and config data.
Add functions for escaping double quotes in strings.
Rename count_chars_len to count_chars.
2008-03-12 16:03:22 +00:00
e581a78d65 Use return_0 in a couple more places.
Correct a function name typo in _line_append error message.
2008-03-10 18:51:27 +00:00
3c78f9900c Include limits.h so it compiles with newer headers. 2008-03-06 08:41:05 +00:00
bd606943e6 add vd to filters 2008-03-05 18:15:04 +00:00
6381666df4 Update vgsplit tests.
- Add validation on pv_count, lv_count, and snap_count after split
NOTE: Some of these counts are misleading.  If you compare "lvs" output
with these counts you will be left scratching your head what a "logical volume"
really is.  ;-)
2008-03-04 22:49:00 +00:00
736f1aa301 Update vgsplit tests.
- Divide into 'usage' and 'operation' tests.
- Add operation tests for specific LV types.
2008-03-04 19:48:32 +00:00
b1a4eac7a8 Refactor _move_pv() in vgsplit.
Should be no functional change.
2008-02-29 00:13:48 +00:00
8226a5276b Add vgsplit test to check failure when PV not in source volume group. 2008-02-29 00:09:21 +00:00
77ad0bb12e Fix t-vgsplit-operation.sh lv2-3 definitions to include test signature. 2008-02-28 17:39:47 +00:00
9412b42206 Fix t-vgsplit-operation.sh lv1 definition to include test signature. 2008-02-28 16:48:09 +00:00
2a91d87074 Fix resetting of MIRROR_IMAGE and VISIBLE_LV after removal of LV. 2008-02-22 13:28:29 +00:00
4a23617d79 Fix remove_layer_from_lv to empty the LV before removing it. (2.02.30) 2008-02-22 13:22:44 +00:00
0e2ceed74d Add missing no-longer-used segs_using_this_lv test to check_lv_segments. 2008-02-22 13:22:21 +00:00
ed56aed8eb Remove redundant if-before-free tests. 2008-02-15 14:14:58 +00:00
8d909cbdc0 Remove redundant if-before-free tests in clvmd.c. 2008-02-15 14:12:32 +00:00
bf98943cbb is_orphan: make parameter "const" to avoid compiler warning 2008-02-13 20:01:48 +00:00
6ff4552be2 Fix lvconvert detection of mirror conversion in progress. 2008-02-12 13:29:08 +00:00
1c7eb79370 Avoid automatic lvconvert polldaemon invocation when -R specified. 2008-02-12 13:26:53 +00:00
f095a75f1e Reflect actual default setting of preferred_names in example.conf and
update comments.
2008-02-11 16:57:40 +00:00
f70af6018c Fix 'pvs -a' to detect VGs of PVs without metadata areas. 2008-02-06 16:09:51 +00:00
71b3b1ff4c split orphan VG by format type 2008-02-06 15:47:28 +00:00
d9fefa0c6c Fix lvresize to support /dev/mapper prefix in the lvname
Fix unfilled paramater passed to fsadm from lvresize
  Update fsadm to call lvresize if the partition size differs (with option -l)
  Fix fsadm to support vg/lv name (like the rest of lv-tools)
2008-02-06 12:45:32 +00:00
3bfe922381 Update usage message for clvmd.
Fix clvmd man page printing <br>, clarified debug options.
2008-02-05 09:38:04 +00:00
a85cf17bf1 Fix default preferred_names filter to use /dev/mapper/mpath devices.
If these devices exist, we should be using them for multipath rather than any
underlying device names.
Reference: http://kbase.redhat.com/faq/FAQ_96_11196.shtma
bz195685
2008-02-04 20:26:14 +00:00
dbb5a09918 post-release 2008-01-31 12:41:13 +00:00
93e5097f20 pre-release 2008-01-31 12:36:58 +00:00
dd53f2dc83 a couple more compiler warnings 2008-01-31 12:35:31 +00:00
2b83c80593 Fix mirror log name construction during lvconvert. (2.02.30)
Make monitor_dev_for_events recurse through the stack of LVs.
Clean up some more compiler warnings.
Add mirror names test script.
2008-01-31 12:19:36 +00:00
6930f60c06 only read labels once between each lock event 2008-01-30 16:18:37 +00:00
376b76e75c undo a few 'stack' moves 2008-01-30 14:17:29 +00:00
1ddd4509dc Some whitespace tidy-ups. 2008-01-30 14:00:02 +00:00
6af3f4f4cf Use stack return macros throughout. 2008-01-30 13:19:47 +00:00
6726c5f958 Rely upon internally-cached PV labels while corresponding VG lock is held. 2008-01-29 23:45:48 +00:00
d5a9c43cb2 post-release 2008-01-29 12:02:04 +00:00
19a5a6a4eb pre-release 2008-01-29 11:48:11 +00:00
617a599ee9 Fix two check_lv_segments error messages to show whole segment. 2008-01-26 00:30:28 +00:00
25e2d4da44 . 2008-01-26 00:25:45 +00:00
ad2e7218cb Refactor mirror log attachment code. 2008-01-26 00:25:04 +00:00
917637fa9b Fix internal metadata corruption in lvchange --resync. 2008-01-26 00:13:45 +00:00
b595ee1c0b suppress compiler warning 2008-01-22 16:02:26 +00:00
c8260a4a56 update 2008-01-22 15:58:31 +00:00
d2eaff3204 Fix vgsplit test mode 2008-01-22 03:49:39 +00:00
b65f5a844f Fix vgsplit tests 12-13 2008-01-22 03:30:14 +00:00
95a69f99ba Fix vgsplit - print different message on successful split of existing / new vg
Fix vgsplit - fix a couple error paths that forgot to call unlock_vg
Update vgsplit test cases
2008-01-22 03:25:45 +00:00
71d609895a Fix vgsplit - print error if vgcreate option given w/existing vg destination
Fix vgsplit - reject split if metadata types or clustered attributes differ
Fix vgsplit - remove physicalextentsize option
Add vgsplit test cases
2008-01-22 02:48:53 +00:00
9229630447 Remove redundant cnxman-socket.h file. 2008-01-21 14:07:46 +00:00
eb18a0b7dc Fix pvs, vgs, lvs error exit status on some error paths.
(note -o help is now considered error)
2008-01-20 01:23:46 +00:00
05ed5c0d74 Use log_warn for reporting field help text instead of log_print. 2008-01-20 01:14:38 +00:00
41330ecc5e clarify 2008-01-19 12:36:37 +00:00
16fbcc6e36 post-release 2008-01-19 12:30:55 +00:00
d87da9c7de Pre-release 2008-01-19 12:28:03 +00:00
94563b6017 Fix lvcreate --nosync not to wait for non-happening sync. 2008-01-18 22:02:37 +00:00
34d22f7047 add lvconvert messages 2008-01-18 22:00:46 +00:00
e24d996fbe Fix lvcreate -M1 readahead. 2008-01-18 21:56:39 +00:00
9b52617919 Add a test case for 'vgreduce --removemissing' on stacked mirror 2008-01-17 18:29:36 +00:00
efc1d46c89 More test script fixes. 2008-01-17 18:05:57 +00:00
9397833ceb pre-release review cleanups 2008-01-17 17:17:09 +00:00
e9433e83cd Minor test fix 2008-01-17 15:56:53 +00:00
f3c58100a0 fix default stripesize 2008-01-17 15:53:01 +00:00
8900231d99 fix default extent_size 2008-01-17 15:31:18 +00:00
c7a63b8a2b pre-release 2008-01-17 15:02:59 +00:00
90e90672a4 rename lv_remap_error 2008-01-17 13:54:05 +00:00
fa51e5c762 mirror log stuff 2008-01-17 13:37:51 +00:00
911f55d005 lvconvert/vgreduce fixes 2008-01-17 13:13:54 +00:00
d30eb4e570 Fixup vgsplit man page 2008-01-17 03:18:18 +00:00
67bcfb6947 Fix descriptions in the newly added test cases 2008-01-17 02:20:48 +00:00
3915a61b1e another lvconvert fix 2008-01-16 22:54:49 +00:00
c170d321e8 fix a _get_vgs return 2008-01-16 22:52:46 +00:00
2802c476ee Fix 'make check' runnable with recent versions of dmsetup.
Fix 'make check' to use DMDIR to check DM_DEV_DIR support in dmsetup.
Add basic test cases for mirrored LV.
Add basic test cases for lvconvert mirror.
Add basic test cases for pvmove.
	Jun'ichi Nomura <j-nomura@ce.jp.nec.com>

Add new vgsplit and vgmerge tests.
	Dave Wysochanski <dwysocha@redhat.com>
2008-01-16 21:21:22 +00:00
1050cebf7f additional safety check on new segment list 2008-01-16 20:00:01 +00:00
dad73465fc Create vgs_are_compatible() fn to check whether vgs are compatible for merging.
Add new vgmerge and vgsplit tests to check rejection of incompatible vgs.
Cleanup comments.
Bugzilla: bz251992

---
 lib/metadata/metadata-exported.h |    3 +
 lib/metadata/metadata.c          |   89 +++++++++++++++++++++++++++++++++-
 test/t-vgmerge-usage.sh          |  101 +++++++++++++++++++++++++++++++++++++++
 test/t-vgsplit-operation.sh      |   20 +++++++
 tools/vgmerge.c                  |   69 --------------------------
 tools/vgsplit.c                  |    5 -
 6 files changed, 215 insertions(+), 72 deletions(-)
2008-01-16 19:54:39 +00:00
8e2ac98fe2 adjust mirror log error message 2008-01-16 19:50:23 +00:00
9aaf0c36d5 fix to earlier checkin 2008-01-16 19:40:42 +00:00
1cb07e9cfd cope with stacked LVs as well as PVs when deciding which bits of mirrors to remove 2008-01-16 19:38:39 +00:00
f1ccdf25b1 allow a mirror to contain only one mimage 2008-01-16 19:18:51 +00:00
6dca497b27 fix mirror log manipulation during lv convert 2008-01-16 19:16:48 +00:00
42a83262a1 export find_temporary_mirror() 2008-01-16 19:13:51 +00:00
63ee9cbee6 move removable_pvs checking 2008-01-16 19:11:39 +00:00
3862f8ca7c reorder funcs 2008-01-16 19:09:35 +00:00
4ada7cffd0 Maintain lists of stacked LV segments using each LV. 2008-01-16 19:00:59 +00:00
a664ce4298 use scan_vgs_for_pvs to detect non-orphans without MDAs 2008-01-16 18:15:26 +00:00
8d7b6c6905 Remove unused 'list' param from vgsplit - conflict with maxlogicalvolumes param.
Initialize lvm command getopt buffer to zero before building options string.
Bugzilla: bz251992

---
 man/vgsplit.8      |    3 +--
 tools/commands.h   |    3 +--
 tools/lvmcmdline.c |    1 +
 3 files changed, 3 insertions(+), 4 deletions(-)
2008-01-16 17:14:56 +00:00
16d22d404a revert temp change 2008-01-16 15:26:40 +00:00
ccb24d5779 reword 2008-01-16 15:25:10 +00:00
8795b45cb4 Don't use block_on_error with mirror targets above version 1.12. 2008-01-16 15:24:25 +00:00
628d3bff45 Move more parameter validation into the library.
Update vgrename to call validate_vg_rename_params().
Fix vgcreate and vgsplit default arguments by adding defaults parameter to
fill_vg_create_params().
Add t-vgrename-usage.sh test.
Bugzilla: bz251992
---
 tools/toollib.c  |   32 ++++++++------------------------
 tools/toollib.h  |    5 ++---
 tools/vgcreate.c |   35 +++++++++++++++++++++--------------
 tools/vgrename.c |   35 ++++++-----------------------------
 tools/vgsplit.c  |   21 ++++++++++++++-------
 5 files changed, 51 insertions(+), 77 deletions(-)
2008-01-15 22:56:30 +00:00
0336bc9de9 - The automatic log module loading patch proposed for the upstream kernel
works on '-'s, not '_'s.  This is due to the preference to have log
  module file names that do not mix '_'s and '-'s.
2008-01-15 22:48:11 +00:00
033cb21797 Update WHATS_NEW for vgsplit changes 2008-01-15 20:37:49 +00:00
09b98a45df lvconvert waits for initial completion by default 2008-01-14 21:11:47 +00:00
38857ba29e Allow vgcreate options as input to vgsplit when new vg is split destination. 2008-01-14 21:07:58 +00:00
1c7520ec8f Allow vgsplit into existing vg.
Add vgsplit tests to validate operation for new and existing vg destinations.
2008-01-11 21:43:16 +00:00
362b9769b2 Fixup lvm man pg 2008-01-11 20:24:25 +00:00
b2d68bd3d2 Refactor vgsplit for accepting existing vg as destination 2008-01-11 20:17:18 +00:00
0dc7e635d4 Update lvm man page to enumerate lvm tools. 2008-01-11 19:24:25 +00:00
80e070a857 Fix warning on conditional compile, unused variable 2008-01-11 17:44:26 +00:00
cc203245e4 Refactor vgcreate for parameter validation and add tests 2008-01-11 07:02:35 +00:00
2f9a65fc93 convert_lv 2008-01-10 22:21:44 +00:00
62738e8001 correct field name 2008-01-10 22:21:25 +00:00
5ecacf0c7f Add lv_convert field to default lvs output. 2008-01-10 19:25:07 +00:00
06b103c8d4 Various lvconvert/polldaemon-related fixes from NEC. See lvm-devel
for original patches & explanations.
2008-01-10 18:35:51 +00:00
d473b7bca8 Print warning when lvm tools are running as non-root. 2008-01-09 15:55:44 +00:00
50a1e81ba7 Amend previous commit. * does not match .files... 2008-01-09 15:33:25 +00:00
d9885b1b64 Add snapshot dmeventd library (enables dmeventd snapshot monitoring). 2008-01-09 15:32:19 +00:00
0a9c8cada2 install conditionally fsadm.8 manpage 2008-01-09 14:17:58 +00:00
60f55f8461 Prevent pvcreate from overwriting MDA-less PVs belonging to active VGs. 2008-01-09 00:18:36 +00:00
7bedaea38f added manpage 2008-01-08 17:01:42 +00:00
9e4b87e798 readahead at least twice the strip size (same as raid0 driver does) 2008-01-08 16:47:10 +00:00
95bf59095c added more safety checks
fixed error reporting commands
extended with Exa and Peta support
2008-01-08 16:45:43 +00:00
e0f34a9720 Fix a segfault if using pvs with --all argument. (2.02.29) 2008-01-07 20:42:57 +00:00
f3797c2a8e Update --uuid argument description in man pages. 2008-01-04 11:48:40 +00:00
30cbcccc80 Fix vgreduce PV list processing not to process every PV in the VG. 2008-01-03 19:03:32 +00:00
f49c0d696f typo 2007-12-28 15:13:38 +00:00
71f564ee5b lvconvert uses polldaemon now 2007-12-22 12:13:29 +00:00
4b0950aba5 a few more changes/fixes to recent code 2007-12-22 02:13:00 +00:00
8c3af822ec auto-collapse layers 2007-12-21 01:08:18 +00:00
878a207d19 more fixes 2007-12-20 23:12:27 +00:00
0537ad860a various cleanups in recent patches 2007-12-20 22:37:42 +00:00
2cdbbb1aea stacked mirror support (incomplete) 2007-12-20 18:55:46 +00:00
7af977d36b avoid some compiler warnings 2007-12-20 16:49:37 +00:00
9afff4cf30 Major restructuring of pvmove and lvconvert layer manipulation code 2007-12-20 15:42:55 +00:00
48ba9734aa post-release 2007-12-20 15:16:14 +00:00
897fc59f72 pre-release 2007-12-20 15:12:57 +00:00
947e44ae67 tweak usage text 2007-12-17 14:47:22 +00:00
e44843beba replace fsadm.c with fsadm.sh 2007-12-17 12:31:50 +00:00
147482ea69 Build changes to replace fsadm C program with shell script. 2007-12-17 12:23:24 +00:00
09091c5cf8 Append fields to report/pvsegs_cols_verbose.
Permit LV segment fields with PV segment reports.
  Add seg_start_pe and seg_pe_ranges to reports.
2007-12-14 21:53:02 +00:00
50827a5f69 more readahead node fixes/debug messages 2007-12-14 19:49:27 +00:00
2d6444c924 Fix deptree to pass new name to _resume_node after a rename. 2007-12-14 17:57:04 +00:00
1d2675d9aa Add node operation stack debug messages. 2007-12-14 17:26:09 +00:00
ad98990a8e Report error when empty device name passed to readahead functions. 2007-12-13 02:25:45 +00:00
8e58c143f2 post-release 2007-12-05 22:48:06 +00:00
556a4a2395 clarify 2007-12-05 22:45:56 +00:00
5be987b40f pre-release
N.B. This is a big release and some regressions are inevitable.
2007-12-05 22:19:24 +00:00
066bc35e69 export can_split parameter until rest of pvmove allocation restructuring gets done 2007-12-05 22:11:20 +00:00
403779437c round readahead to multiple of page size in tools 2007-12-05 19:24:32 +00:00
fb806f61d4 Fix minimum readahead debug message. 2007-12-05 18:57:34 +00:00
6ce306661c post-release 2007-12-05 17:14:30 +00:00
3c08ff94d4 pre-release 2007-12-05 17:05:04 +00:00
a6afae2356 clarify when read_ahead may be set 2007-12-05 16:28:19 +00:00
0eea7070a7 work out device name to use for read ahead request 2007-12-05 16:24:41 +00:00
105c2b1eea read_ahead in report with underscore to match lvm2 field 2007-12-05 14:42:10 +00:00
82bb0e8dda fix ioctls to use long not int
update dm-ioctl.h after compat tidy-up
2007-12-05 14:11:26 +00:00
8c01179075 Tidy the clvmd backup code.
Move the backups inside the protection of the VG lock,
Don't backup if we have a suspended LV
Correct the vg_read() call
2007-12-05 13:17:18 +00:00
c9d9a96630 Avoid spurious test failure when compiled with readline support.
* test/t-000-basic.sh: Invoke initial test of lvm with its "version"
argument, so that the behavior of the tool doesn't depend on whether
readline was enabled at configure time.


Author: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Committer: Jim Meyering <meyering@redhat.com>
2007-12-05 09:49:08 +00:00
8f21c9a920 When we unlock a VG tell the clvmds to see if a backup of the metadata needs
to be done.
2007-12-04 15:39:26 +00:00
0ba7d05ea7 fixme 2007-12-03 22:53:04 +00:00
5a4c5b4155 fixes 2007-12-03 22:48:36 +00:00
55323fb497 fix changed parms 2007-12-03 18:00:38 +00:00
7c082d2471 missing #include 2007-12-03 17:56:36 +00:00
f3cafcf983 fix 2007-11-30 16:44:42 +00:00
75073e4aa6 readahead support completed - untested 2007-11-30 16:42:26 +00:00
a3c23f650c read_ahead node ops 2007-11-30 14:59:57 +00:00
0545cd5879 uncomment libdevmapper readahead calls 2007-11-29 15:04:12 +00:00
c96506f22c refine specification of dmsetup readahead 2007-11-29 14:44:28 +00:00
49b2006824 add read_ahead functions to library and dmsetup --readahead
(Not live yet.)
2007-11-27 20:57:05 +00:00
8c6f96faab Fix a possible double-free in libdevmapper-event. 2007-11-27 12:26:06 +00:00
a0e648abfd drop mirrored_pv/mirrored_pe from alloc handle 2007-11-22 14:54:35 +00:00
6350cd12fc Start refactoring pvmove allocation code. 2007-11-22 13:57:21 +00:00
f2fab0677b FIXMEs for case where dm itself has device open 2007-11-22 01:25:06 +00:00
edffc52927 note pvmove breakage 2007-11-19 18:24:08 +00:00
d6e5e3d103 Decode cluster locking state in log message. (untested)
Change file locking state messages from debug to very verbose.
2007-11-16 21:16:20 +00:00
5be7a0ebf7 move pvresize_single back under tools 2007-11-15 22:11:18 +00:00
7f722fe7d3 Fix --addtag to drop @ prefix from name 2007-11-15 21:59:11 +00:00
a01732ee9b more vg_read lock fixes 2007-11-15 21:30:52 +00:00
85ac11b69b If the pre_command fails then go back and wait patiently for the next
pre function rather than retrying it until we get stuck!
2007-11-15 10:16:14 +00:00
590cfb77a5 define LCK_NONE for cases when vg_lock_and_read already holds lock
(temporary - library will use internal ref counting instead)
2007-11-15 02:55:22 +00:00
f01dd16a27 another vg_lock_and_read 2007-11-15 02:53:49 +00:00
df49287e5f Convert some vg_reads into vg_lock_and_reads 2007-11-15 02:20:03 +00:00
c8ec8391ee Avoid nested vg_reads when processing PVs in VGs and fix associated locking. 2007-11-14 18:41:05 +00:00
3499e48064 Make it compile with new lv_info_by_lvid() prototype 2007-11-14 13:37:51 +00:00
2e379cb8a5 Accept sizes with --readahead argument.
Store size arguments as sectors internally.
2007-11-14 00:08:25 +00:00
f8ee3c2369 fix precedence 2007-11-12 21:50:21 +00:00
c74fa11518 readahead activation code (but no dm support yet) 2007-11-12 20:51:54 +00:00
ceec4455df Add DM_READ_AHEAD_MINIMUM_FLAG 2007-11-12 20:47:18 +00:00
17c9975c0b Fix compile warnings / minor errors introduced recently. 2007-11-12 20:02:55 +00:00
6c1cdff912 Remove new mirror logs when creation fails. 2007-11-12 14:36:57 +00:00
79f53f569d Attempt to remove incomplete LVs with lvcreate zeroing/activation problems. 2007-11-12 13:34:14 +00:00
ccb85cc719 Define DM_READ_AHEAD_AUTO and DM_READ_AHEAD_NONE. 2007-11-09 16:52:36 +00:00
c0eff8a07f Enhance the management of readahead settings. 2007-11-09 16:51:54 +00:00
954626f157 Prevent lvconvert -s from using same LV as origin and snapshot. 2007-11-07 16:33:12 +00:00
17e7dfa4bd Add pv_mda_free and vg_mda_free fields to reports for raw text format. 2007-11-05 17:17:55 +00:00
971f233fb7 attempt to fix human-readable unit output when number of sectors is odd 2007-11-05 17:13:54 +00:00
b12bc692af fix inverted orphan test 2007-11-05 17:12:50 +00:00
730301b34d adjust sizes for metadata 2007-11-05 02:10:39 +00:00
c443bcf43c Show 'not usable' space when PV is too large for device in pvdisplay.
Ignore and fix up any excessive device size found in metadata.
2007-11-05 01:47:49 +00:00
b77e7eeddc Add LVM2 version to 'Generated by' comment in metadata. 2007-11-04 19:16:34 +00:00
031b7b57a1 fix new lvremove checks - mustn't fail when activation is disabled 2007-11-04 16:28:57 +00:00
5123fab525 Fix error message when fixing up PV size in lvm2 metadata (2.02.11). 2007-11-04 15:43:50 +00:00
705b96c6f9 Fix orphan-related locking in pvdisplay and pvs.
Fix missing VG unlocks in some pvchange error paths.
Add some missing validation of VG names.
Rename validate_vg_name() to validate_new_vg_name().
Change orphan lock to VG_ORPHANS.
Change format1 to use ORPHAN as orphan VG name.
2007-11-02 20:40:05 +00:00
9ec582002b Convert pvchange, pvdisplay, pvscan to use is_orphan() 2007-11-02 14:54:40 +00:00
ee79277774 Add is_orphan_vg() and change all hardcoded checks to use it. 2007-11-02 13:06:42 +00:00
db02dc218e explanation of md superblock location & avoid compilation warnings 2007-10-24 11:24:24 +00:00
b66ce1089e Detect md superblocks version 1.0, 1.1 and 1.2. 2007-10-24 00:51:05 +00:00
ec0e70b599 refactor dev-md.c, separating out the magic number detection 2007-10-24 00:30:30 +00:00
a273482f9d Remove comment about allocation of pv->vg_name. 2007-10-12 21:08:38 +00:00
76cf8c4cf7 Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
Modified original patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
2007-10-12 18:37:19 +00:00
9691ecc839 Add pv_dev_name() to access PV device name.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
2007-10-12 14:29:32 +00:00
59b2a86359 Accessor functions for PV will not modify the given PV.
So we can add 'const' to it.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
2007-10-12 14:08:10 +00:00
fe7cd72cff Non-functional change - refactor lv_create_empty().
Remove struct format_instance param - we can safely obtain
this from vg->fid inside the function.
2007-10-11 19:20:38 +00:00
f0761fc570 Non-functional change - refactor vg_add_snapshot fid parameter. 2007-10-11 18:51:21 +00:00
90990aa19d Handle new sysfs subsystem/block/devices directory structure. 2007-10-10 11:31:21 +00:00
a3d3ce82e4 Fix configure --with-dmeventd-path substitution. 2007-10-10 00:02:03 +00:00
b8e48113a3 Run tests with LVM_SYSTEM_DIR pointing to private root and /dev dirs.
This makes the tests more reproducible and helps isolate
them from any existing LVM set-up.
* test/Makefile.in (abs_builddir): Define.
(init.sh): Emit definition of abs_builddir.
* test/lvm-utils.sh (unsafe_losetup_): Keep only the portable,
iterative approach.
(dmsetup_has_dm_devdir_support_): New function.
(init_root_dir_): New function.
Invoke init_root_dir_ for all but the first test.
* test/test-lib.sh (this_test_): Adapt to test-name change.
Invoke lvm-utils.sh much later (after tmpdir creation), and
only if the current test is not being skipped.
Remove useless abs_top_srcdir definition.
Rename t0->test_dir_rand_.
* test/t-lvcreate-pvtags.sh: Skip this test if the available
version of dmsetup is not new enough.
Use global, $G_dev_, rather than hard-coded "/dev".
* test/t-lvcreate-usage.sh: Make --verbose output more useful.


Author: Jim Meyering <jim@meyering.net>
Committer: Jim Meyering <meyering@redhat.com>
2007-10-09 13:13:06 +00:00
d4b1003a97 Allow $DM_DEV_DIR envvar to override default of "/dev".
* dmsetup/dmsetup.c (DEV_PATH): Remove definition.
(parse_loop_device_name): Add parameter: dev_dir.
Declare the "dev" parameter to be "const".
Use dev_dir, not DEV_PATH.  Handle the case in which dev_dir
does not end in a "/".
(_get_abspath): Declare "path" parameter "const", to match.
(_process_losetup_switches): Add parameter: dev_dir.
Pass dev_dir to parse_loop_device_name.
(_process_switches): Add parameter: dev_dir.
Pass dev_dir to _process_losetup_switches.
(main): Set dev_dir from the DM_DEV_DIR envvar, else to "/dev".
Call dm_set_dev_dir.
* lib/libdm-common.c (dm_set_dev_dir): Rewrite to be careful
about boundary conditions, now that dev_dir may be tainted.
* man/dmsetup.8: Mention $DM_DEV_DIR.


Author: Jim Meyering <meyering@redhat.com>
2007-10-09 12:14:48 +00:00
efd83567c9 Fix the fsadm build failure without using -llvm.
* lib/misc/util.c (last_path_component): Move definition to ...
* lib/misc/last-path-component.h (last_path_component): ...here.
New file.  Make the function "static inline".
* include/.symlinks: Add last-path-component.h.
* lib/misc/util.h (last_path_component): Remove declaration.
* tools/fsadm/fsadm.c: Include "last-path-component.h".
* tools/lvmcmdline.c: Likewise.

Author: Jim Meyering <meyering@redhat.com>
2007-10-03 16:10:04 +00:00
5563f373f7 Revert last change. fsadm must not depend on -llvm.
Author: Jim Meyering <meyering@redhat.com>
2007-10-03 16:08:18 +00:00
15a36619fe a) use dmsetup version to check for dmsetup, but if it fails, set
DMSETUP=: to disable dmsetup checks (but let the script run
nevertheless); warn the user if this is the case
b) put the non-root and dmsetup warnings both at start and end of
output
2007-10-03 15:00:51 +00:00
38e54b626e Arrange for "make clean" to remove the symlink, too.
* make.tmpl.in ($(VERSIONED_SHLIB)): Move rule to...
* lib/Makefile.in ($(VERSIONED_SHLIB)): ...here, removing the
$(interface)/ prefix.
Reported by Milan Broz.

Author: Jim Meyering <meyering@redhat.com>
2007-10-03 10:48:27 +00:00
8aa30fb56a Avoid link failure when building fsadm.
* tools/fsadm/Makefile.in (LVMLIBS): Define.
(fsadm): Link with $(LVMLIBS).

Author: Nix <nix@esperi.org.uk>
2007-10-03 09:46:57 +00:00
b764becd1b Fix underquotations in lvm_dump.sh. 2007-10-02 16:09:46 +00:00
219370932e Fix a bug in lvm_dump.sh checks for lvm/dmsetup binaries quote the
invocations a bit more (although i'm fairly sure there are still
quotes missing somewhere due to the eval in log).
2007-10-02 15:48:58 +00:00
90afae186c Remove unused pargc parameter 2007-10-01 15:01:26 +00:00
84e49a809d doc/testing.txt: Fix typo: s/this/thing/.
Author: Jim Meyering <jim@meyering.net>
2007-09-25 08:28:57 +00:00
1cfb9ff46a Some const fixups for previous checkins 2007-09-24 21:30:00 +00:00
f35026c74f Avoid over-quoting in shell scripts.
Do not use "..." around the RHS of VAR= assignment,
nor on the argument of "case ... in ...".


Author: Jim Meyering <jim@meyering.net>
2007-09-24 19:19:18 +00:00
5f2d3da8c5 Refactor lvcreate mirror parameter validation. 2007-09-24 13:29:49 +00:00
4e61f32a28 Refactor lvcreate stripe parameter validation. 2007-09-24 13:25:31 +00:00
d7814c7011 add tests to validate lvextend %PVS 2007-09-21 21:14:25 +00:00
aa40668e84 Don't emit a trailing newline to stderr.
* tools/lvmcmdline.c (_short_usage): Remove trailing "\n".
Spotted by Alasdair G. Kergon.


Author: Jim Meyering <jim@meyering.net>
2007-09-21 18:43:55 +00:00
3767e6e96f Print --help output to stdout, not stderr.
* tools/lvmcmdline.c (_usage): Use log_print, not log_error.


Author: Jim Meyering <jim@meyering.net>
2007-09-21 18:06:56 +00:00
44976cef6c After a diagnostic, suggest --help, rather than printing all --help output.
Print just one line:
Use `COMMAND --help' for more information.
after "real" diagnostic(s), rather than all of the usage lines.
Otherwise, the 30-40+ lines of --help output could obscure the real diagnostic.


Author: Jim Meyering <jim@meyering.net>
2007-09-21 18:06:33 +00:00
eba4417947 Rename test scripts not to include the 4-digit number.
Author: Jim Meyering <jim@meyering.net>
2007-09-21 17:12:13 +00:00
c99204d370 Correct typo in comments: s/is part of the LVM2/is part of LVM2/.
Signed-off-by: Jim Meyering <jim@meyering.net>


Author: Jim Meyering <jim@meyering.net>
2007-09-21 10:16:45 +00:00
1bfc4335bb Add %PVS extents option to lvresize, lvextend, and lvcreate. 2007-09-20 21:39:08 +00:00
6b9c7485f1 test/t3000-lvcreate-pvtags.sh: Use better test names.
Author: Jim Meyering <jim@meyering.net>
2007-09-18 21:07:21 +00:00
737f3d78f2 * configure.in (AC_CONFIG_FILES): Remove the test/*/Makefile names
corresponding to the recently-removed directories.
* configure: Regenerate.
Reported by Dave Wysochanski.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 18:26:32 +00:00
b1d5e1b5e3 test/Makefile.in (lvm-wrapper): Use $(DMDIR)/lib/, not $(DMDIR)/lib/ioctl/.
Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:29:06 +00:00
8d92a5cc14 Clean-up and wording changes; add copyright notices.
* test/Makefile.in (srcdir, top_srcdir): Use @srcdir@, etc.
(top_builddir, abs_srcdir, abs_top_builddir, abs_top_srcdir): Likewise.
(so_name): Remove definition.
(.bin-dir-stamp): No longer create symlink in $(DMDIR) tree.
Prompted by suggestions from Alasdair Kergon.
* test/t1000-lvcreate-usage.sh (cleanup_): Redirect to a file,
rather than to /dev/null.
Change wording of some test titles.
Suggestions from Alasdair Kergon.

* test/Makefile.in: Add a copyright notice.
* test/lvm-utils.sh: Likewise.
* test/mkdtemp: Likewise.
* test/t0000-basic.sh: Likewise.
* test/t1000-lvcreate-usage.sh: Likewise.
* test/t3000-lvcreate-pvtags.sh: Likewise.
* test/t4000-pv-range-overflow.sh: Likewise.
* test/test-lib.sh: Likewise.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:02:22 +00:00
fc455df92c Test how lvcreate handles its command-line options.
* test/t1000-lvcreate-usage.sh: New tests.
* test/Makefile.in (T): Add it.
Derived from test cases by Dave Wysochanski.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:01:46 +00:00
c0076ebfa1 Clean up shared-lib support in test/.
* test/Makefile.in (so_name): Use @DMDIR@.
(.bin-dir-stamp): Create symlink only if @DMDIR@ is nonempty.
(lvm-wrapper): Emit LD_LIBRARY_PATH setting only if @DMDIR@ is nonempty.
Based on a patch from Jun'ichi Nomura.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:01:24 +00:00
5d607aa3cd Allow relative dir name in: --with-dmdir=../device-mapper
* configure.in: Convert a relative dmdir directory name to the required
absolute form, e.g. in ./configure --with-dmdir=../device-mapper
Suggestion from Jun'ichi Nomura.
* configure: Regenerate.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:01:08 +00:00
fa1b9a4098 Add testing framework, along with first few tests.
* Makefile.in (check): New target.
* configure.in (AC_CONFIG_FILES): Add test/Makefile.
* configure: Regenerate.
* test/.gitignore: New file.
* test/Makefile.in: New file.
* test/lvm-utils.sh: New script.
* test/mkdtemp (die, rand_bytes, mkdtemp): New script.
* test/t0000-basic.sh: New tests.
* test/t3000-lvcreate-pvtags.sh: New, failing test.
Derived from a script by Jun'ichi Nomura.
* test/t4000-pv-range-overflow.sh: New test.
* test/test-lib.sh: Testing framework, based on the one from git.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 14:00:42 +00:00
c8c4dbb409 Create a symlink, e.g., libdevmapper.so.1.02, in the build dir,
alongside the .so file.  This helps build dynamically linked LVM.

* lib/Makefile.in (VERSIONED_SHLIB): Define.
* make.tmpl.in (TARGETS): Append $(VERSIONED_SHLIB).
($(VERSIONED_SHLIB)): New rule.


Author: Jim Meyering <jim@meyering.net>
2007-09-18 13:02:58 +00:00
16628e6cea Moved the obsolete test subdirectory to old-tests.
If you're using the CVS repository you'll need to remove it and check
it out again when we repopulate it.
2007-09-17 19:51:02 +00:00
7067c12991 Remove no-longer-correct restrictions on PV arg count with stripes/mirrors.
[E.g. They fail if tags or --alloc anywhere used.]
2007-09-17 17:18:37 +00:00
7b47e241e0 clarification 2007-09-17 17:06:31 +00:00
d1e46207a5 Fix strdup memory leak in str_list_dup(). 2007-09-17 16:02:46 +00:00
2a04b97cbd configure: regenerate, to remove vestige of an upcoming patch 2007-09-12 18:23:02 +00:00
e6c8ef59e0 Avoid static link failure with some SELinux libraries.
Author: Jim Meyering <jim@meyering.net>
2007-09-12 16:54:23 +00:00
d3380f41de Diagnose invalid PE values given on the pvmove command line (64-bit systems).
* tools/toollib.c (xstrtouint32): New function.
(_parse_pes): Use xstrtouint32; don't cast strtoul's unsigned
long to uint32_t.  Detect overflow.


Author: Jim Meyering <jim@meyering.net>
2007-09-11 20:12:54 +00:00
4ef1633969 Undo previous checkin - output format not good, info already available in other form(s) 2007-09-11 13:49:52 +00:00
57e593aab2 Add pvseg_free field to 'pvs' output 2007-09-10 20:05:29 +00:00
6461caacbb Include strerror string in dev_open_flags' stat failure message.
* lib/device/dev-io.c (dev_open_flags):
Use log_sys_error after failed stat to report strerror(errno).
Use a slightly different diagnostic to report mismatched device number.
2007-09-07 11:24:19 +00:00
e5531e2a93 Fix last checkin 2007-09-06 22:35:01 +00:00
329402a614 Fixup _lvresize error return codes and modularize function 2007-09-06 21:08:16 +00:00
4656ed462e prepare to move guts of vgrename into library function 2007-08-31 19:09:49 +00:00
96ddad91a9 move guts of pvresize into library 2007-08-30 20:30:41 +00:00
5eb40588d2 prepare to move guts of pvresize into library 2007-08-30 20:16:01 +00:00
58def149aa Avoid error when --corelog is provided without --mirrorlog. (2.02.28)
Correct --mirrorlog argument name in man pages (not --log).
2007-08-30 19:34:19 +00:00
0ee5743d75 - I neglected to update this file on last check-in, which fixed
the MIRROR_NOTSYNCED flag being passed on to a linear lv when
  converting from a mirror.
2007-08-30 18:53:32 +00:00
7c266f3e81 When mirrors are created with the --nosync option, a status flag
(MIRROR_NOTSYNCED) is added to the LVM metadata.  This flag is
not cleared when converting to linear.  Subsequently, if you
up-convert the linear to a mirror, the flag remains - even though
an up-convert will always force a complete resync.
2007-08-29 20:19:11 +00:00
d7ce981cd1 Modify lvremove to prompt for removal if LV active on other cluster nodes.
Add '-f' to vgremove to force removal of VG even if LVs exist.
Update vgremove man page for '-f'.
2007-08-28 16:14:49 +00:00
eadadf6299 post-release 2007-08-24 21:05:15 +00:00
8ac9fabd07 pre-release 2007-08-24 21:01:52 +00:00
44c2b4b281 Fix clvmd logging so you can get lvm-level debugging out of it. 2007-08-24 08:29:39 +00:00
4cd97611e5 Locking P_global causes a cache refresh. 2007-08-23 15:43:20 +00:00
da27380ab5 Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R. 2007-08-23 15:02:26 +00:00
756e539661 Force a device scan after init_full_scan_done() per agk. 2007-08-23 12:44:09 +00:00
cde44e3172 Call init_full_scan_done() when refreshing the cache. This should fix clvmd -R. 2007-08-23 12:19:13 +00:00
e79a4b34b0 Change lvconvert_mirrors to use mirror segtype not striped. 2007-08-22 20:03:46 +00:00
e9f0bdd72c Fix lvconvert_mirrors detection of number of existing mirrors. 2007-08-22 19:32:39 +00:00
d080291150 Clean up numerous compiler warnings that crept in recently.
Remove several unused parameters from _allocate().
2007-08-22 14:38:18 +00:00
06c69c56ba Avoid static link failure with some SELinux libraries. 2007-08-21 20:32:29 +00:00
d79710ba9d Fix (C) ! 2007-08-21 19:56:18 +00:00
c9bc7dd0b6 Clean up mirrorlog argument processing.
Only permit --force, --verbose and --debug arguments to be repeated.
2007-08-21 19:46:36 +00:00
ebc26c7421 Remove obsolete dmfs code from tree and update INSTALL. 2007-08-21 18:41:58 +00:00
3769425f6b Move guts of vgremove into lvm library.
Include archiver.h in metadata.c as a result of prior move.
2007-08-21 17:38:20 +00:00
a50957443e post-release 2007-08-21 17:03:07 +00:00
63fa007af0 Prepare to move guts of vgremove into lvm library.
Fixup force_t.
2007-08-21 16:40:33 +00:00
a6a52a128b pre-release 2007-08-21 16:33:18 +00:00
1ad58e1121 Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1. 2007-08-21 16:26:07 +00:00
3f507a26fb Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1. 2007-08-20 20:55:30 +00:00
bfc368764a Update WHATS_NEW for last checkin 2007-08-20 17:05:49 +00:00
53fbce932b Move lv_remove_single() into library (lv_manip.c, metadata-exported.h).
Move yes_no_prompt() into library (display.c, display.h).
Fixup includes as a result of movement of prior two functions.
Fixup force_t enum to be more descriptive.
2007-08-20 17:04:53 +00:00
a94195c6cd Prepare to move guts of lvremove into lvm library 2007-08-20 16:16:54 +00:00
626c6d1124 factor out some duplication -- mostly I/O redirection 2007-08-20 12:06:35 +00:00
471ab92bbb Allow clvmd debug to be turned on in a running daemon using clvmd -d
You can do with cluster-wide too, by adding -C
2007-08-17 11:51:23 +00:00
fbccd12924 Update to use autoconf 2.61, while still supporting 2.57. 2007-08-14 19:11:31 +00:00
e5928bbaea Remove unneeded WHATS_NEW entry 2007-08-10 14:24:43 +00:00
3c1597bc67 Fix "lvconvert -s" from always failing with argument error message.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>.
2007-08-10 13:33:49 +00:00
295019815e - change new log_ARG variable to more explicit mirrorlog_ARG. 2007-08-09 21:25:08 +00:00
654a391250 minor updates to the lvcreate/lvconvert man pages.
- put back reference to '--corelog'.  It now says that it
is the same as '--log core'.
- other minor touches
2007-08-09 20:43:29 +00:00
9ee1465d3c Add more cluster/clvmd information to lvmdump 2007-08-09 09:53:33 +00:00
52197cf4d2 Remove extra checks for sub LV renaming.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>.
2007-08-08 18:00:36 +00:00
cfbb2afac5 A few more cleanups for lvrename of mirrors checkin:
* add struct lv_names for old/new names
* replace lv->status & MIRROR checks with lv_is_visible()
2007-08-07 18:55:38 +00:00
8f154f65f9 Some simple fixups for last checkin:
* remove "_" from "return_0"
* improve some naming and terminology
* add 'const'
2007-08-07 16:57:09 +00:00
7454664997 Add "const" attributes where possible: first cut. 2007-08-07 09:06:05 +00:00
3393b7aedd Update a few comments 2007-08-06 21:11:27 +00:00
133ccc95b5 Add entry for last checkin of lvrename mirror support 2007-08-06 20:38:41 +00:00
c392ff1cd3 Add support for renaming mirrored LVs.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
2007-08-06 20:35:48 +00:00
30a0f831a5 For consistency, rename local variable: s/newname/new_name/g. 2007-08-06 14:57:48 +00:00
541ea4dc63 improve changelog 2007-08-06 13:09:46 +00:00
afc5e0e3e5 Make lv_rename's interface "const correct".
* lib/metadata/lv_manip.c (lv_rename): Make char* param "const".
* lib/metadata/metadata-exported.h: Update prototype, too.
2007-08-06 09:04:21 +00:00
bcb31df10d Use NULL not 0.
Remove worthless comment.
2007-08-05 00:13:02 +00:00
2192c4e269 Factor out core of lvrename to lv_rename library function.
Patch by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
2007-08-03 21:22:10 +00:00
eec17858c4 Fix a possible segfault in libdevmapper-event. Thanks to Brian J. Wood
for noticing this.
2007-08-02 22:31:59 +00:00
6d696706be This patch changes the arguments that specify the mirror
log type.  Previously, we had a '--corelog' argument that
would change the default type from 'disk' to 'core'.  I
think that creates too much confusion - especially when
doing conversions on mirrors.

The new argument '--log' takes either "disk" or "core"
as a parameter.  This could be expanded in the future
for additional logging types as well.

Examples:
# Creating a 2-way mirror
$> lvcreate -m1 ... # implicitly use default disk logging
$> lvcreate -m1 --log disk ... # explicit disk logging
$> lvcreate -m1 --log core ... # specify core logging
$> lvcreate -m1 --corelog ... # old way still works

# Conversion examples
$> lvconvert --log core ... # convert to core logging
$> lvconvert --log disk ... # convert to disk logging
$> lvconvert -mX --corelog ... # old way still works
$> lvconvert -mX ... # old way of converting to disk logging still works

Changes are reflected in the man pages.
2007-08-01 21:01:06 +00:00
8cd88b6051 - cleanup excessive indentation in tools/lvconvert.c:lvconvert_mirrors 2007-08-01 20:54:28 +00:00
9dbf53fdb9 lib/activate/activate.c:_lv_activate tries to monitor a device
regardless of whether it was successfully activated.  Now fixed
to only monitor if it was successfully activated.
2007-08-01 20:29:07 +00:00
38b6963c8b Don't leak a file descriptor in fcntl_lock_file(), when fcntl fails. 2007-07-28 15:20:36 +00:00
7b6248983d Remove create_dir function; use now-equivalent dm_create_dir instead.
* lib/misc/lvm-file.c (_create_dir_recursive, create_dir): Remove functions.
* lib/misc/lvm-file.h (create_dir): Remove declaration.
* lib/commands/toolcontext.c (create_toolcontext): s/create_dir/dm_create_dir/
* lib/format_text/archiver.c (archive, backup): Likewise.
* lib/format_text/format-text.c (_add_dir): Likewise.
* lib/locking/file_locking.c (init_file_locking): Likewise.
Patch by Jun'ichi Nomura.
2007-07-28 12:26:21 +00:00
4d418dee0e Export dm_create_dir (was create_dir) to help fix LVM2 link error
* lib/libdm-file.c (dm_create_dir): Rename from create_dir.
* lib/libdevmapper.h (dm_create_dir): Declare.
* lib/.exported_symbols: Add dm_create_dir.
* lib/ioctl/libdm-iface.c (_create_control): Update sole use.
Patch by Jun'ichi Nomura.  Details in
http://www.redhat.com/archives/lvm-devel/2007-July/msg00040.html
2007-07-28 10:48:36 +00:00
06fe319347 Make the libdevmapper version of create_dir equivalent to the LVM2 one.
(_create_dir_recursive): Refrain from logging a mkdir failure due to EROFS.
Patch by Jun'ichi Nomura.
2007-07-28 10:27:34 +00:00
9dd7e3fb24 Introduce log_sys_* macros from LVM2.
Convert existing "<string>: <function> failed: <strerror>" type messages
to use this macro.  Patch by Jun'ichi Nomura.
2007-07-28 10:23:02 +00:00
d5a46396b0 Add ps3disk devices. 2007-07-26 13:28:32 +00:00
5e84cb560d Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose
* lib/misc/lvm-file.c (lvm_fclose): New function.
* lib/misc/lvm-file.h (lvm_fclose): Declare it.
* lib/config/config.c (write_config_file): Use the new function to detect
and diagnose unlikely write failure.
* lib/filters/filter-persistent.c (persistent_filter_dump): Likewise.
* lib/format_text/archive.c (archive_vg): Likewise.
* lib/format_text/format-text.c (_vg_write_file): Likewise.
* lib/log/log.c (fin_log): Similar, but use dm_fclose directly.
Include "\n" at end of each fprintf format string.
2007-07-24 17:48:08 +00:00
756c6f8560 Fix clvmd if compiled with gulm support. (2.02.26) 2007-07-24 15:35:11 +00:00
6fa6ce35da libdevmapper, dmeventd: be paranoid about detecting write failure
* dmeventd/dmeventd.c (_set_oom_adj): When writing to /proc/self/oom_adj,
detect failure even if it's hidden behind ferror.  [Using dm_fclose's
extra ferror test here is probably not needed, since the amount written
is nowhere near BUFSIZ, but use it regardless, for consistency. ]
* lib/fs/libdevmapper.c (do_suspend): Detect fclose failure when
writing to suspend.
2007-07-24 14:16:48 +00:00
b14b97599d dm_fclose: new function
* lib/libdevmapper.h: Declare it.
* lib/libdm-file.c (dm_fclose): Define it.
* lib/.exported_symbols: Add dm_fclose.
2007-07-24 14:15:45 +00:00
db6f60d6fc Trivial fix to lvdisplay man pg to recommend lvs 2007-07-24 11:29:55 +00:00
25c348d7c8 Trivial fix to lvdisplay man pg to correct volume size units 2007-07-24 10:58:01 +00:00
2e4bf8b034 Update lvconvert and lvrename to use vg_lock_and_read 2007-07-23 22:20:42 +00:00
c1490e2f7b Fix error introduced with previous checkin 2007-07-23 21:10:36 +00:00
b004fe9556 Add CORRECT_INCONSISTENT and FAIL_INCONSISTENT flags to vg_lock_and_read 2007-07-23 21:03:42 +00:00
67142ad046 Add vg_lock_and_read() external library function. 2007-07-23 17:27:55 +00:00
3c3ec06b12 Fix loading of persistent cache if cache_dir is used. (2.02.23)
Move lstat warning in _compare_paths to verbose output only.
2007-07-23 10:45:49 +00:00
5b5caa8a16 Fix compilation warning in util.c. 2007-07-23 10:41:19 +00:00
b2cba098bb Eliminate uses of strdup+basename. Use last_path_component instead.
* lib/misc/util.c, lib/misc/util.h (last_path_component): New files.
* lib/Makefile.in (SOURCES): Add misc/util.c.
* lib/misc/lib.h: Include "util.h".
* tools/fsadm/fsadm.c: Include "util.h". (_usage): Use last_path_component,
not basename.
* tools/lvmcmdline.c (_find_command, lvm2_main): Likewise.
* include/.symlinks: Add lib/misc/util.h.
2007-07-20 15:48:39 +00:00
1ec0d47f10 Use gcc's printf attribute wherever possible.
* daemons/clvmd/clvmd.h (debuglog): Add __attribute__((printf)).
* lib/config/config.c (_line_append): Likewise.
* lib/misc/lvm-string.h (emit_to_buffer): Likewise.
2007-07-20 15:38:19 +00:00
f232606ec7 In _line_append, use "sizeof buf - 1" rather than equivalent "4095"
* lib/config/config.c:
2007-07-20 15:26:39 +00:00
fa28cea152 Introduce is_same_inode macro, now including a comparison of st_dev.
* lib/misc/lvm-file.h (is_same_inode): Define.
* lib/filters/filter-persistent.c (persistent_filter_dump): Use is_same_inode
in place of a direct st_ino-only comparison.
* lib/locking/file_locking.c (_release_lock, _lock_file): Likewise.
2007-07-20 15:22:46 +00:00
c8da1647a1 Don't leak a file descriptor in _lock_file when flock fails.
* lib/locking/file_locking.c (_lock_file): Close fd upon flock failure.
2007-07-20 12:12:52 +00:00
505a0a8718 Add SUN's LDOM virtual block device to filters
Thanks to Fabio Massimo Di Nitto
2007-07-19 07:06:47 +00:00
10d3496a17 Split metadata-external.h out from metadata.h for the tools to use. 2007-07-18 15:38:58 +00:00
a13c755370 post-release 2007-07-17 20:53:51 +00:00
62f9996fd7 pre-release 2007-07-17 20:45:17 +00:00
edbcd8a1b2 Fix snapshot cow area deactivation if origin is not active. (2.02.13) 2007-07-17 16:13:12 +00:00
a5308d1689 Fix configure libdevmapper.h check when --with-dmdir is used. 2007-07-13 17:08:00 +00:00
cbfe6e8fcc post-release 2007-07-13 16:10:24 +00:00
5571ff35d8 pre-release 2007-07-13 16:07:30 +00:00
2a4819f3c8 Change pv_read_path to pv_by_path 2007-07-12 15:38:53 +00:00
7121866b13 Turn _add_pv_to_vg() into external library function add_pv_to_vg() 2007-07-12 05:04:42 +00:00
d6e05ad9e2 Refactor vg_extend error path. 2007-07-12 04:12:04 +00:00
993e30a7de Add pv_read_path, a proposed external LVM library function to take a device path and return a PV handle 2007-07-11 23:33:12 +00:00
49cae61254 Tidy bits of clvmd-openais and improve an error report. 2007-07-11 12:07:39 +00:00
1ea4b2ea91 Cope with find_seg_by_le() failure in check_lv_segments(). 2007-07-10 18:50:03 +00:00
bc1d6e1f90 tidy 2007-07-10 18:20:00 +00:00
9ec6e68d0c Fix pv_mda_count to cope with missing PV.
[vgcreate vg1 pv1 pv2; pvremove -ff pv1; pvs -P -o+pv_mda_count =>segfault]
2007-07-10 18:18:33 +00:00
341bdc93e2 Call dev_iter_destroy() if _process_all_devs() is interrupted by sigint. 2007-07-10 17:51:26 +00:00
6fb3e1aa15 Add vg_mda_count and pv_mda_count columns to reports. 2007-07-09 15:40:43 +00:00
f1f92eb2e2 Fix dumpconfig to use log_print instead of stdout directly. 2007-07-08 22:51:20 +00:00
8c2369d40f Fix WHATS_NEW for last checkin until further patches for LVM library are ready. 2007-07-03 13:10:14 +00:00
a6d9fc58eb Convert _add_pv_to_vg to usable LVM library function. 2007-07-02 21:48:30 +00:00
f7cd471548 Add kernel and device-mapper targets versions report to lvmdump. 2007-07-02 20:18:38 +00:00
5f951faf32 Don't use index and rindex functions marked by SUSv3 as legacy - Jakub Bogusz <qboosh@pld-linux.org> 2007-07-02 11:17:21 +00:00
b228dfaf2c Fix vgsplit if splitting all PVs from VG. 2007-06-28 17:59:34 +00:00
764858fa12 Make warnings go to stderr. Change log_warn to that effect, log_print
continues to send messages to stdout.
2007-06-28 17:33:44 +00:00
5ee976d276 Make warnings go to stderr. Adds log_warn macro for that purpose,
log_print continues to print to stdout.
2007-06-28 17:27:02 +00:00
8b28b6f2d3 Fix lvmdiskscan volume reporting when run in the lvm shell 2007-06-25 13:19:37 +00:00
fe16df2e6f Use cpg_local_get() rather then Clm to get the local nodeid. 2007-06-25 09:02:37 +00:00
779047f8c9 revert accidental change 2007-06-19 16:50:38 +00:00
094e9fb45d Fix dmsetup -o devno string termination. (1.02.20) 2007-06-19 15:47:20 +00:00
1458bd0e74 Fix missing lvm_shell symbol in lvm2cmd library. (2.02.23) 2007-06-19 10:51:51 +00:00
d2cb05988d Convert vg->status checks to use vg_check_status function.\nRename status_flags to status in vg_check_status. 2007-06-19 04:36:12 +00:00
6e056767b4 Add vg_status function and clean up vg->status in tools directory 2007-06-19 04:23:32 +00:00
a10afb1b98 Make vg_extend() format_instance * parameter internal to vg_extend() 2007-06-19 00:33:43 +00:00
bb6d3b6cfd Add --ignoremonitoring to disable all dmeventd interaction. 2007-06-18 14:14:33 +00:00
c75d4af4bc Remove get_ prefix from get_pv_* functions 2007-06-15 22:16:55 +00:00
972dc39d00 post-release 2007-06-15 20:49:30 +00:00
9daac5c178 pre-release 2007-06-15 20:46:04 +00:00
dd2a3f40e1 pre-release 2007-06-15 19:05:02 +00:00
78f76c1690 Fix default dmsetup report buffering and add --unbuffered.
Add tree-based and dependency fields to dmsetup reports.
2007-06-15 18:20:28 +00:00
4788066a5f Update vgcfgrestore man pg 2007-06-15 16:05:57 +00:00
10e4254e7d Allow keyboard interrupts in yes_no_prompt(). Add code to toollib.c
loops and to pvcreate.c, lvchange.c and lvresize.c to handle
interrupted prompts.
2007-06-15 10:11:14 +00:00
0106e4df9d Fix inverted logic on last checkin for pvremove 2007-06-14 15:51:36 +00:00
8ac718a3a2 convert pv->vg_name[0] to \!is_orphan(pv) 2007-06-14 15:48:05 +00:00
46d45273a1 Convert pv->vg_name to get_pv_vg_name 2007-06-14 15:25:36 +00:00
8da9ec3599 Remove system-lv.[ch] 2007-06-14 10:17:12 +00:00
01fdf84d69 Remove system LV code from clvmd. It's never been used and never should be
used! It's removal tidies a number of code paths inside clvmd.
2007-06-14 10:16:35 +00:00
cc78386e75 Update WHATS_NEW for get_pv* conversions 2007-06-13 23:57:15 +00:00
3755157c61 Convert pv->vg_name to get_pv_vg_name 2007-06-13 23:53:38 +00:00
80f8436f0a Convert pv->status to get_pv_status 2007-06-13 23:33:45 +00:00
f88a4b7760 Convert pv->dev to get_pv_dev 2007-06-13 23:29:33 +00:00
de229b8ab0 Convert pv->size to get_pv_size 2007-06-13 23:02:51 +00:00
a3ba37e45e Convert existing_pv dereferences to get_pv_* 2007-06-13 22:58:32 +00:00
50c779b3c6 Convert pv->pe_size to get_pv_pe_size 2007-06-13 22:30:26 +00:00
192372e1c3 Convert pv->pe_start to get_pv_pe_start 2007-06-13 22:16:27 +00:00
f88fd88c38 Convert pv->pe_count to get_pv_pe_count 2007-06-13 22:11:29 +00:00
6e15145af1 Convert pv->pe_alloc_count to get_pv_pe_alloc_count 2007-06-13 22:04:45 +00:00
4b5fad4e48 Remove casts in pv_create and find_pv_in_vg_by_uuid 2007-06-13 21:14:07 +00:00
7a13e71c80 Convert pv_handle_t to pv_t * and tidy up whitespace 2007-06-13 20:55:56 +00:00
3c10943900 Add typedef pv_handle_t 2007-06-13 19:52:48 +00:00
696b8811c2 Fix a couple benign warnings by adding variable initializations. 2007-06-13 15:11:19 +00:00
9fd2c8602a Convert find_pv_in_vg_by_uuid and pv_create to use PV handles 2007-06-12 22:41:27 +00:00
a3636a5af4 Change PV_HANDLE_DEREF to pv_field and add paren's 2007-06-12 21:39:49 +00:00
f2e5f07718 Add get_pv_* functions to return PV fields in prep for external LVM library 2007-06-12 21:20:20 +00:00
16c6fdde60 Add wrappers to functions related to pv commands in preparation for exported LVM lib 2007-06-11 18:29:30 +00:00
2155c93426 Add capability for tree-based fields to dmsetup reports. 2007-06-11 13:20:29 +00:00
c394631e4c Allow vgcfgrestore to list metadata backup files using -f 2007-06-08 22:38:48 +00:00
8b370b7cc1 Add vg_check_status to consolidate vg status flags checks and error messages. 2007-06-06 19:40:28 +00:00
607db9971c make code consistent with pvresize code - good candidate for common code cleanup 2007-06-05 18:23:17 +00:00
6768f64e2f Fix pvdisplay --maps to not display segment header for orphan PVs. 2007-05-31 20:26:11 +00:00
f1813b1cc6 Fix redundant segment display when PV is given to 'pvdisplay --maps' cmdline. 2007-05-31 20:10:25 +00:00
fb665bd0dd Remove 'Type' from pvdisplay --maps as there is no 'Type' of a physical segment, only logical segments 2007-05-31 15:18:44 +00:00
65dda2ef3d Small fixes to pvdisplay --maps: 1) rename struct pv_segment vars from 'seg' to 'pvseg', 2) Change heading 2007-05-31 14:19:57 +00:00
b162b992af Add --maps to pvdisplay.
Modified original patch from David Robinson <zxvdr.au@gmail.com>.
2007-05-30 20:43:09 +00:00
67a3a3d130 Fix vgcfgrestore man pg to show mandatory VG name and remove LVM1 options. 2007-05-22 02:52:57 +00:00
92cd9bf7d2 Fix vgrename man page to include UUID and be more consistent with lvrename. 2007-05-22 02:51:33 +00:00
bf97034485 Add *Experimental* OpenAIS support to clvmd. 2007-05-21 10:52:01 +00:00
1ded1fc509 Remove symlinks if parent volume is deactivated. 2007-05-15 14:42:01 +00:00
e0592c58b3 Fix and clarify vgsplit error messages. 2007-05-15 13:01:41 +00:00
5ead2706b4 Fix a segfault if a device has no target (no table) 2007-05-14 11:27:34 +00:00
52ada4853c Misc clvmd cleanups from Jim Meyering 2007-05-02 12:22:40 +00:00
c2b27a8298 Add some more debuglogs to clvmd startup. 2007-05-02 08:23:36 +00:00
3934c1d437 post-release 2007-04-27 20:58:45 +00:00
e366b68ad3 pre-release 2007-04-27 20:47:14 +00:00
fb94fb980a Fix get_config_uint64() to read a 64-bit value not a 32-bit one. 2007-04-27 20:41:50 +00:00
b10cc18f53 Add -Wformat-security and change one fprintf() to fputs(). 2007-04-27 19:26:57 +00:00
a249de3b72 Standardise protective include file #defines. 2007-04-27 19:07:43 +00:00
d04e972d65 Move regex functions into libdevmapper. 2007-04-27 18:52:05 +00:00
b9f5a18a76 Add regex functions to library. 2007-04-27 18:40:23 +00:00
d3f157f08a configure.h isn't a system header 2007-04-27 18:01:45 +00:00
2294fdb496 Change some #include lines to search only standard system directories. 2007-04-27 17:46:16 +00:00
d7ba0e01a5 Avoid trailing separator in reports when there are hidden sort fields. 2007-04-27 15:22:27 +00:00
b6172b53fd Fix segfault in 'dmsetup status' without --showkeys against crypt target. [nec] 2007-04-27 15:12:26 +00:00
477ec611d5 Deal with some more compiler warnings. Hope this doesn't break anything... 2007-04-27 14:52:41 +00:00
b6194edd67 add preferred_names to man page. 2007-04-26 17:14:57 +00:00
dcdbbb3ecb Add devices/preferred_names config regex list for displayed device names.
Free a temporary dir string in fcntl_lock_file() after use.
Fix a dm_pool_destroy() in matcher_create().
Introduce goto_bad macro.
2007-04-26 16:44:59 +00:00
7ef99ee4e6 Fix warnings on x86_64 involving ptrdiff_t:
config/config.c:493: warning: format '%d' expects type 'int', but argument 5 has type 'long int'

Modified original patch from Jim Meyering <jim@meyering.net>
2007-04-26 16:40:46 +00:00
1ac1418286 Update pvck to include text metadata area and record detection.
--
2007-04-25 21:10:55 +00:00
8fc854f38e Add support functions for analysis of config sections,
and hence, on-disk LVM2 metadata.

--
2007-04-25 20:38:39 +00:00
1c2360b335 Update pvck to read labels on disk, with flexible --labelsector
parameter.

--
2007-04-25 20:03:16 +00:00
dd4477406b Add count_chars and count_chars_len functions, two
generic string utility functions.

--
2007-04-25 18:24:19 +00:00
9d67bbb104 Make lvm_dump.sh capture a listing of /sys/block entries. 2007-04-25 14:49:27 +00:00
d6c8e1df61 Fix thread race in clvmd. 2007-04-24 15:13:13 +00:00
5ec7c8fece Fix the regression introduced by dmeventd leak fixes. 2007-04-24 13:29:02 +00:00
86b21eaf83 Add 'scan_sector' parameter to label_read and _find_labeller to add
flexibility in searching for disk labels.
2007-04-23 18:21:01 +00:00
228486a971 Fix some memory leaks in dmeventd. 2007-04-23 15:06:03 +00:00
88c0caab26 Make clvmd cope with quorum devices in RHEL5
bz#237386
2007-04-23 14:55:28 +00:00
5cd4679419 re-commit lvm_dump.sh change 2007-04-19 23:06:05 +00:00
eeed5e0d19 Make lvm_dump.sh list /dev recursively to aid identifying devices. 2007-04-19 22:56:16 +00:00
369ab1e0b2 Introduce _add_field() and _is_same_field() to libdm-report.c. 2007-04-19 20:24:00 +00:00
2e21519a10 Fix libdevmapper-event memory leaks 2007-04-19 19:10:19 +00:00
ecc001ed08 Add dev_read_circular, read 2 regions on same device. 2007-04-19 02:10:42 +00:00
cd96852696 Add stub for pvck, a command to check physical volume consistency. 2007-03-30 21:00:26 +00:00
b9f7f30158 Add some extra error checking & robustness.
Thanks to the Crosswalk engineering team:
    Leonard Maiorani
    Henry Harris
    Scott Cannata
2007-03-29 13:59:33 +00:00
ca5e423331 Update lists of attribute characters in man pages.
Change cling alloc policy attribute character from 'C' to l'.
2007-03-27 13:35:33 +00:00
fa9407089c Fix creation and conversion of mirrors with tags. 2007-03-26 16:10:10 +00:00
66f28e193a Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
Split metadata areas in vgsplit properly.
2007-03-23 12:43:17 +00:00
0d93f89f5c post-release 2007-03-19 21:16:49 +00:00
154e9a2c47 pre-release 2007-03-19 21:12:54 +00:00
84574a1257 Fix processing of exit status in init scripts 2007-03-16 17:15:36 +00:00
bf83527b64 Remove unnecessary memset() return value checks. [Jim Meyering] 2007-03-16 14:36:14 +00:00
12c53622a0 Fix vgremove to require at least one vg argument. 2007-03-15 14:00:30 +00:00
d8f54cf891 Try to fix reading in of lvm1 striped LVs.
There are two fixes other than improving variable names and updating code
layout etc.
The loop counter is incremented by area_len instead of area_len * stripes;
the 3rd _check_stripe parameter is no longer multiplied by number of stripes.
2007-03-15 13:38:28 +00:00
625a671189 Flag nolocking as a clustered locking module as we need to be able
to look at clustered LVs at clvmd startup
2007-03-13 14:59:21 +00:00
6ebdad3102 Add a few missing pieces of vgname command line validation. 2007-03-09 21:25:33 +00:00
9a8f21aa03 Support the /dev/mapper prefix on most command lines. 2007-03-09 20:47:41 +00:00
291dd8edc2 post-release 2007-03-08 21:37:48 +00:00
de4c1daf29 pre-release 2007-03-08 21:28:13 +00:00
0b55d7d0d8 Fix vgrename active LV check to ignore differing vgids. 2007-03-08 21:08:25 +00:00
5d86fd8fdb Remove no-longer-used uuid_out parameter from activation info functions. 2007-03-08 19:58:04 +00:00
1b76eb1f59 Fix two more segfaults if an empty config file section encountered. 2007-03-08 19:22:52 +00:00
b05678d8bf Move .cache file into a new /etc/lvm/cache directory by default.
Add devices/cache_dir & devices/cache_file_prefix, deprecating devices/cache.
Create directory in fcntl_lock_file() if required.
2007-02-28 18:27:13 +00:00
781f4971c6 Exclude readline support from lvm.static 2007-02-14 16:51:48 +00:00
d02ac7b99a Fix a leak in a reporting error path. 2007-02-14 15:18:31 +00:00
b1b6c97f7c Fix a few leaks in reporting error paths. 2007-02-14 15:12:16 +00:00
baee28ab5c post-release 2007-02-13 16:16:15 +00:00
83edf68ff9 pre-release 2007-02-13 16:12:24 +00:00
c7588f91dd Correct -b and -P on a couple of man pages.
Add global/units to example.conf.
2007-02-13 16:04:01 +00:00
30b432adc5 Fix loading of segment_libraries. [gentoo] 2007-02-08 17:31:02 +00:00
7c9733eb5d If a PV reappears after it was removed from its VG, make it an orphan. 2007-02-07 13:29:52 +00:00
a223c3fea3 Improve dmeventd messaging protocol: drain pipe and tag messages. 2007-02-02 17:08:51 +00:00
d5250f4901 Fix some &->&& vgreduce cmdline validation. [Andre Noll] 2007-01-31 16:26:23 +00:00
25f29f4712 post-release 2007-01-30 21:37:18 +00:00
382af5563d pre-release 2007-01-30 18:08:17 +00:00
8cf3d165d3 Add warning to lvm2_monitoring_init_rhel4 if attempting to stop monitoring. 2007-01-30 18:02:15 +00:00
0fd6ce546f Fix vgsplit to handle mirrors.
Reorder fields in reporting field definitions.
2007-01-29 23:01:18 +00:00
b881c372bc post-release 2007-01-29 20:25:19 +00:00
94c5e7deb0 pre-release 2007-01-29 19:57:24 +00:00
c344766f3c Add recent reporting options to dmsetup man page.
Revise some report fields names.
2007-01-29 19:35:24 +00:00
67895de0bc help on help 2007-01-29 18:45:08 +00:00
ff00cb6990 help unused attr 2007-01-29 18:43:27 +00:00
2cc75c11ed add help -c for field list 2007-01-29 18:37:57 +00:00
cd79e58eda Add dmsetup 'help' command and update usage text. 2007-01-29 18:18:41 +00:00
6fa801f3d8 reorder report field definitions 2007-01-29 17:45:32 +00:00
684eecba1d Use fixed-size fields in report interface. 2007-01-29 17:23:54 +00:00
da9cf7e5de fix pvsegs report too 2007-01-27 02:32:31 +00:00
f57e7445fd Fix vgs to treat args as VGs even when PV fields are displayed. 2007-01-27 02:09:06 +00:00
fba1388719 Fix md signature check to handle both endiannesses. 2007-01-26 17:15:16 +00:00
80ed029c17 post-release 2007-01-25 23:40:33 +00:00
34a74e81e3 pre-release 2007-01-25 23:36:59 +00:00
cb120ddb15 dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors. 2007-01-25 23:32:29 +00:00
f9ee4395b0 also ignore mirrors 2007-01-25 23:03:48 +00:00
71f06d51ed Add devices/ignore_suspended_devices to ignore suspended dm devices. 2007-01-25 21:22:30 +00:00
217f70952f don't remove libdm-common.h any more 2007-01-25 15:45:10 +00:00
f813d41a76 Add some missing close() and fclose() return code checks.
Fix exit statuses of reporting tools (2.02.19).
2007-01-25 14:37:48 +00:00
d851289d8a Add some missing close() and fclose() return value checks. 2007-01-25 14:16:20 +00:00
b115b8a2ea Add init script for dmeventd monitoring. 2007-01-24 23:44:43 +00:00
d0f7067471 lvm.static no longer interacts with dmeventd unless explicitly asked to. 2007-01-24 23:43:27 +00:00
be5b4c38a7 fix earlier checkin 2007-01-24 22:06:11 +00:00
d6d597e3dd Migrate dmsetup column-based output over to new libdevmapper report framework. 2007-01-24 18:09:07 +00:00
84e348fade Add field definitions to report help text.
Remove unnecessary cmd arg from target_*monitor_events().
2007-01-24 16:51:24 +00:00
910054657e Adjust report field help description layout. 2007-01-24 16:41:33 +00:00
8357a11249 fix earlier checkin 2007-01-23 23:58:55 +00:00
9b021ba057 Add descriptions to reporting field definitions. 2007-01-23 19:18:52 +00:00
317e588efd Add private variable to dmeventd shared library interface. 2007-01-23 17:40:40 +00:00
b1d32a03c7 add a dso-private variable to dmeventd interface
more inline docn
2007-01-23 17:38:39 +00:00
ee6e6529ee Long-lived processes write out persistent dev cache in refresh_toolcontext(). 2007-01-23 16:03:54 +00:00
9d944d6cf9 Fix refresh_toolcontext() always to wipe persistent device filter cache.
Add is_long_lived to toolcontext.
2007-01-23 15:58:06 +00:00
13635d281a Add --clustered to man pages. 2007-01-23 13:08:34 +00:00
2493c46970 Streamline dm_report_field_* interface. 2007-01-22 15:07:21 +00:00
63e4217271 Add dm_event_handler_[gs]et_timeout functions.
Streamline dm_report_field_* interface.
2007-01-22 15:03:57 +00:00
f4bd12e8e9 register->monitor etc. 2007-01-19 22:21:45 +00:00
df15f46900 var dev_name->device_name (lvm2 has dev_name()) 2007-01-19 20:42:09 +00:00
fb3a732361 fix exit status; always print message on child failure 2007-01-19 18:08:36 +00:00
2d74110feb Add cmdline debug & version options to dmeventd.
Fix oom_adj handling.
2007-01-19 17:22:17 +00:00
19d102082d Add DM_LIB_VERSION definition to configure.h. 2007-01-19 15:53:01 +00:00
d2af2c9487 Update reporting man pages. 2007-01-18 22:33:24 +00:00
82980149fa Suppress 'Unrecognised field' error if report field is 'help'. 2007-01-18 22:15:04 +00:00
a19bb7b909 fix last checkin 2007-01-18 21:59:02 +00:00
9d98c3278d No longer necessary to specify alignment for report fields. 2007-01-18 17:48:29 +00:00
26376ac1c9 Some internal renaming.
Add --separator and --sort to dmsetup (unused as yet).
Make alignment flag optional when specifying report fields.
2007-01-18 17:47:58 +00:00
8459f99341 post-release 2007-01-17 17:56:15 +00:00
e5bdb0e0b5 pre-release 2007-01-17 17:51:51 +00:00
1106b7775a Fix a segfault if an empty config file section encountered. 2007-01-17 16:22:59 +00:00
ae2852156d merge _target_*register_events
introduce _create_dm_event_handler()
2007-01-17 15:00:57 +00:00
44c6c36c43 stat oom_adj and stay silent if it doesn't exist
dm_event_handler now keeps private copies of strings
2007-01-17 14:45:10 +00:00
a81926503d use updated dm_event_get_registered_device interface 2007-01-16 23:05:13 +00:00
af13ccddda more fixes 2007-01-16 23:03:13 +00:00
392e1bc2e8 more little fixes 2007-01-16 21:13:07 +00:00
9268d92c70 clean up global mutex usage and fix a race in thread finalisation code
properly clean up thread status when thread terminates from within
2007-01-16 20:27:07 +00:00
bb3366c07d dmeventd oom_adj + reduce thread stack size 2007-01-16 20:13:04 +00:00
d24d563ebc Move basic reporting functions into libdevmapper. 2007-01-16 18:06:12 +00:00
954bd9257b Add basic reporting functions to libdevmapper. 2007-01-16 18:04:15 +00:00
5d51a56c02 reduce some if/else complexity 2007-01-15 22:37:40 +00:00
f48648552e Fix a malloc error path in dmsetup message. 2007-01-15 22:05:50 +00:00
edb9c3cc9f Fix partition table processing after sparc changes (introduced in 2.02.16).
Fix cmdline PE range processing segfault (introduced in 2.02.13).
2007-01-15 21:55:11 +00:00
01dc83b936 fix recent checkins 2007-01-15 19:47:49 +00:00
3a8dff3a62 fail registration if timeout thread cannot be started 2007-01-15 19:19:31 +00:00
13b234ccba use DMEVENTD_PATH 2007-01-15 19:11:58 +00:00
e451e93664 static naming 2007-01-15 18:58:40 +00:00
b4f9531475 Some libdevmapper-event interface changes. 2007-01-15 18:22:02 +00:00
3184ff75c4 More libdevmapper-event interface changes and fixes.
Rename dm_saprintf() to dm_asprintf().
2007-01-15 18:21:01 +00:00
43243f4d30 Report error if NULL pointer supplied to dm_strdup_aux(). 2007-01-15 14:39:12 +00:00
c975a100b1 Report dmeventd mirror monitoring status. 2007-01-12 20:38:30 +00:00
02bf389425 Reinstate dm_event_get_registered_device 2007-01-12 20:22:11 +00:00
bcb9a3dd04 post-release 2007-01-11 23:19:08 +00:00
cce3baa275 pre-release 2007-01-11 22:49:43 +00:00
2b48fad426 updated dmeventd interface 2007-01-11 22:24:32 +00:00
d554b2bc94 Lots of dmeventd-related changes. 2007-01-11 21:54:53 +00:00
f66943de43 fail if status args are missing 2007-01-11 20:11:19 +00:00
9d1e9bc2fb Remove dmeventd mirror status line word limit 2007-01-11 19:52:06 +00:00
2d6a014920 Use CFLAGS when linking so mixed sparc builds can supply -m64 2007-01-11 17:12:27 +00:00
c1952bf257 Use CFLAGS when linking so mixed sparc builds can supply -m64. 2007-01-11 16:23:22 +00:00
a10227eb03 Prevent permission changes on active mirrors. 2007-01-10 19:56:39 +00:00
475ae29b85 Print warning instead of error message if cannot zero volume
Update lvconvert man page (snapshot option)
2007-01-10 14:13:46 +00:00
0b9cfc278b dumpconfig accepts a list of configuration variables to display.
Change dumpconfig to use --file to redirect output to a file.
2007-01-09 23:22:31 +00:00
b57b6b4fba Avoid vgreduce error when mirror code removes the log LV. 2007-01-09 23:14:35 +00:00
7d948f7bc5 Remove 3 redundant AC_MSG_RESULTs from configure.in. 2007-01-09 22:07:20 +00:00
459023d171 Free memory in _raw_read_mda_header() error paths.
Fix ambiguous vgsplit error message for split LV.
Fix lvextend man page typo.
2007-01-09 21:12:41 +00:00
fd6570720a Add configure --with-dmdir to compile against a device-mapper source tree.
Use no flush suspending for mirrors.
2007-01-09 20:31:08 +00:00
7831665417 Add dm_tree_use_no_flush_suspend(). 2007-01-09 19:44:07 +00:00
7c9920d982 fix last checkin 2007-01-08 15:35:08 +00:00
cbdccf0a9c Lots of dmevent changes.
Export dm_basename().
Cope with a trailing space when comparing tables prior to possible reload.
2007-01-08 15:18:52 +00:00
64fa83ec3f Add dmeventd_mirror register_mutex, tidy initialisation & add memlock. 2007-01-08 14:24:20 +00:00
faff865cfd Fix create mirror with name longer than 22 chars. 2007-01-05 15:53:40 +00:00
742ab55a9a Fix some activate.c prototypes when compiled without devmapper. 2006-12-20 16:19:01 +00:00
66e623fb2a Fix dmeventd mirror to cope if monitored device disappears. 2006-12-20 14:35:02 +00:00
4ab17ee965 post-release 2006-12-14 22:21:32 +00:00
7f48ca5132 pre-release 2006-12-14 20:05:08 +00:00
da983848b4 Add missing pvremove error message when device doesn't exist. 2006-12-13 18:40:23 +00:00
bc03f7bad3 When lvconvert allocates a mirror log, respect parallel area constraints.
Use loop to iterate through the now-ordered policy list in _allocate().
Check for failure to allocate just the mirror log.
Introduce calc_area_multiple().
Support mirror log allocation when there is only one PV: area_count now 0.

(See lvm-devel list archives for further details.)
2006-12-13 03:39:58 +00:00
a1c8bd3846 Fix detection of smallest area in _alloc_parallel_area() for cling policy. 2006-12-12 19:30:10 +00:00
404bc284e0 Add manpage reference for clvmd -T that got missed out when I
checked the code in (sorry).
2006-12-11 14:06:25 +00:00
9dee30ff0e Fix gulm operation of clvmd. including a hang when attempting to
exclusively lock an LV that is already locked no another node.
2006-12-11 14:00:26 +00:00
f91aadbea8 Fix hang in clvmd if a pre-command failed. The pre/post thread was getting
out of sync in this instance and would not quit.
2006-12-11 13:48:41 +00:00
aa15a10c91 post-release 2006-12-01 23:29:54 +00:00
5b03e36351 pre release 2006-12-01 23:15:59 +00:00
b9ba9ffad2 clvmd ia64 alignment fixes etc. (pjc) 2006-12-01 23:10:26 +00:00
642be5d16c Fix VG clustered read locks to use PR not CR.
VG metadata reads were not being locked out during metadata updates.
2006-12-01 22:48:47 +00:00
ee68d715bf Adjust some alignments for ia64 and sparc.
(Some of the changes are probably unnecessary.)
2006-11-30 23:11:42 +00:00
224084f056 Fix mirror segment removal to use temporary error segment. 2006-11-30 17:52:47 +00:00
1cd8c849b8 Always compile debug logging into clvmd as it's too useful to
restrict to just developers.
-d will switch it on and run the daemon in the foreground
2006-11-30 13:19:42 +00:00
169f68bfcd Add timeout to RHEL4 clvmd init script.
With the previous clvmd checkin this should address bz#187812
2006-11-30 10:16:48 +00:00
d2b7cfa2d1 Add -T (startup timeout) switch to clvmd 2006-11-30 09:44:07 +00:00
a40c7dff5d post-release 2006-11-28 22:51:01 +00:00
e8e00630d3 pre-release 2006-11-28 22:49:58 +00:00
e33720c854 Update dmsetup man page (setgeometry & message) 2006-11-23 20:34:16 +00:00
bd8a4e0d17 mention new env vars on man page 2006-11-23 17:44:15 +00:00
586a2aef76 Improve lvm_dump.sh robustness. 2006-11-23 17:23:14 +00:00
ce1d8f6754 Update lvm2create_initrd to support gentoo. 2006-11-21 22:41:56 +00:00
7b0f401065 . 2006-11-21 17:46:11 +00:00
8387016eef Fix clvmd_init_rhel4 line truncation (2.02.14). 2006-11-21 17:44:46 +00:00
4e1342b641 fix _find_config_node: null parameter is permitted 2006-11-21 15:13:36 +00:00
e45a184d90 post-release 2006-11-20 23:30:45 +00:00
979e1012d2 Install lvmdump by default. 2006-11-20 20:03:26 +00:00
fe10a50e23 pre-release 2006-11-20 19:33:03 +00:00
8ab6d72519 Fix check for snapshot module when activating snapshot. 2006-11-20 16:45:45 +00:00
3aada6dd1d Fix pvremove error path for case when PV is in use. 2006-11-17 02:45:51 +00:00
0933036366 Warn if certain duplicate config file entries are seen.
(not thoroughly tested)
2006-11-16 17:36:00 +00:00
05f5abdc06 Enhance lvm_dump.sh for sysreport integration and add man page. 2006-11-16 16:44:48 +00:00
fb875e0709 Fix --autobackup argument which could never disable backups. 2006-11-14 15:28:50 +00:00
9acdc2f6bf Fix a label_verify error path. 2006-11-14 15:03:07 +00:00
028ce4bff6 post-release 2006-11-10 21:27:51 +00:00
3f245ad6db pre-release 2006-11-10 21:22:34 +00:00
23115f4116 fix cast 2006-11-10 20:15:10 +00:00
cf5f48e6cc Fix adjusted_mirror_region_size() for 64-bit size. 2006-11-10 19:35:03 +00:00
997fa756ad Add some missing bounds checks on 32 bit extent counters.
Add Petabyte and Exabyte support.
Fix lvcreate error message when 0 extents requested.
2006-11-10 18:24:11 +00:00
e23f75b1cc Add note to lvremove man page: volumes must be inactive on
all cluster nodes before being removed.
2006-11-06 14:11:40 +00:00
6531e88761 Protect .cache manipulations with fcntl locking.
Change .cache timestamp comparisons to use ctime.
2006-11-04 03:34:10 +00:00
e76a9c2618 fix shift 2006-11-03 21:23:06 +00:00
45be8a836b fix last check-in: lv->size is in sectors 2006-11-03 21:07:15 +00:00
954b6032e7 Fix mirror log LV writing to set all bits in whole LV. 2006-11-02 23:33:20 +00:00
bd95416f27 Fix clustered VG detection and default runlevels in clvmd_init_rhel4. 2006-11-01 18:25:26 +00:00
df2577ace2 Fix high-level free space check for partial allocations. 2006-10-30 16:10:55 +00:00
720e6558c9 post-release 2006-10-27 15:37:02 +00:00
c239f15d8a pre-release 2006-10-27 15:21:07 +00:00
dfa1f80a57 dd couple of missing files to tools/Makefile CLEAN_TARGETS. 2006-10-26 20:37:13 +00:00
15dfb93b17 When adding snapshot leave cow LV mapped device active after zeroing. 2006-10-26 18:22:10 +00:00
0ec8488c2b . 2006-10-24 19:07:32 +00:00
94b2e29cb1 - likely cut and paste error. Fix wrong function name in debug
output.
2006-10-24 18:49:31 +00:00
fefa8e9b4d Add dev_flush() to set_lv() 2006-10-24 18:25:30 +00:00
32c4c44812 resync alphabetical order 2006-10-24 17:19:48 +00:00
05195e2b1d try forcesync -> resync 2006-10-24 17:18:25 +00:00
4c2ff675b8 reword --resync desc a bit 2006-10-24 17:09:40 +00:00
e5692a4721 fix forcesync local active detection 2006-10-24 15:30:33 +00:00
312e6a0d31 Add lvchange --forcesync. 2006-10-23 23:03:55 +00:00
5bb8efa41f Perform high-level free space check before each allocation attempt. 2006-10-23 15:54:51 +00:00
949a835f4a Don't allow a node to remove an LV that's exclusively active on anther node. 2006-10-23 11:46:16 +00:00
85e6042941 Cope if same PV is included more than once in cmdline PE range list. 2006-10-21 23:18:43 +00:00
3cd2f28975 getline debug free 2006-10-19 16:50:05 +00:00
2179a72c3a Suppress encryption key in 'dmsetup table' output unless --showkeys supplied. 2006-10-19 15:34:50 +00:00
a5f282f156 Set PV size to current device size if it is found to be zero. 2006-10-19 12:53:47 +00:00
40e8631f63 Add segment parameter to target_present functions. 2006-10-18 18:01:53 +00:00
9ded05bb97 post-release 2006-10-16 17:18:08 +00:00
ec8efa35a1 revert 2006-10-16 16:47:56 +00:00
f72bf20482 pre-release 2006-10-16 16:44:28 +00:00
ebde2002e8 Fix pvdisplay to use vg_read() for non-orphans 2006-10-16 16:29:40 +00:00
352a66f46f Fall back to internal locking if external locking lib is missing or fails. 2006-10-14 16:37:54 +00:00
d84c5391f7 Retain activation state after changing LV minor number with --force. 2006-10-13 21:33:31 +00:00
f4c582472b post-release.
Note that I've dropped the 2.4 kernel files from the release tarballs now.
2006-10-13 19:01:30 +00:00
1485586f7e pre-release 2006-10-13 18:43:53 +00:00
d5c9024335 Avoid deptree attempting to suspend a device that's already suspended. 2006-10-13 14:03:35 +00:00
860cf80703 Propagate clustered flag in vgsplit and require resizeable flag. 2006-10-13 13:22:44 +00:00
897ff3161f post-release 2006-10-12 18:20:45 +00:00
b356b2e501 fix realtime msg alignment 2006-10-12 18:17:09 +00:00
1d2733c893 pre-release 2006-10-12 18:13:33 +00:00
32d9126094 . 2006-10-12 17:42:40 +00:00
db43314e50 missing mesg 2006-10-12 17:41:21 +00:00
68d2baeb65 pre-release 2006-10-12 17:37:42 +00:00
1fd5f562d3 noflush code fixes: missing debug log; non-standard variable name 2006-10-12 17:29:05 +00:00
48e02f2086 remove unused variable 2006-10-12 17:18:40 +00:00
eab7b2b581 fix dmsetup usage display (missing \n and --noflush wrong place) 2006-10-12 17:09:09 +00:00
45abade7fc Add suspend noflush support.
Add basic dmsetup loop support.
2006-10-12 15:42:25 +00:00
5372fc4b43 Test message to lvm-devel list. 2006-10-10 17:20:40 +00:00
4e2f240c98 Add clvmd call to return the cluster name. 2006-10-09 14:11:57 +00:00
bb3605518d add cling allocation policy 2006-10-08 12:01:13 +00:00
3ef6d37f27 . 2006-10-07 23:42:03 +00:00
88e9f2f7f4 check_contiguous to use for_each_pv 2006-10-07 23:40:36 +00:00
704a447df9 More work towards pv->size always holding the same value in internal metadata.
Store it in external text metadata as dev_size, and estimate it if not
present when metadata is read back in.
2006-10-07 23:17:17 +00:00
a5fcb26a33 rely on pv_setup functions to fix up pe_count 2006-10-07 23:06:18 +00:00
2491a61481 Accept regionsize with lvconvert. 2006-10-07 23:04:36 +00:00
91831d51ed more refactoring 2006-10-07 16:00:28 +00:00
174f0c19f7 Extend _for_each_pv() to allow termination without error. 2006-10-07 12:41:06 +00:00
de6fadfb4f abstract _is_contiguous() 2006-10-07 11:34:53 +00:00
f946db3e00 move _for_each_pv() 2006-10-07 11:23:22 +00:00
8d05e5bc31 Remove duplicated pv arg from _check_contiguous(). 2006-10-07 11:00:09 +00:00
cfb46820e4 Accept regionsize with lvconvert 2006-10-07 10:47:05 +00:00
081f1cbcc2 Correct regionsize default on lvcreate man page (MB). 2006-10-07 10:43:40 +00:00
7bc6da326f Add report columns with underscore before field names ending 'size'. 2006-10-07 10:42:27 +00:00
cd95a0df7b Use strncpy rather than strcpy 2006-10-06 10:06:37 +00:00
82fa497c16 Fix clvmd bug that could cause it to die when a node with a long name crashed. 2006-10-06 10:06:10 +00:00
44fd345206 Fix format_text mda_setup pv->size and pv_setup pe_count calculations.
(This area of the code needs a lot more work.)
2006-10-05 22:02:52 +00:00
088e1c9db4 Fix _for_each_pv() for mirror with core log. 2006-10-05 21:24:48 +00:00
d4f16e666e Add lvm_dump.sh script to create a tarball of debugging info from a system. 2006-10-05 18:42:33 +00:00
8233cfd371 Vastly improve the errors returned to the user from clvmd.
It now captures the error messages that are generated and returns them
in the reply packet rather than just telling the user to check syslog.
2006-10-05 13:55:50 +00:00
ff05e2e30d Remove unused #defines from filter-md.c. 2006-10-04 16:03:17 +00:00
a8ea7dd3fb Make clvmd restart init script wait until clvmd has died before starting it. 2006-10-04 08:42:14 +00:00
96f70a5303 Update man page for clvmd -R 2006-10-04 08:28:17 +00:00
f1604c3e69 Add -R switch to clvmd.
This option will instruct all the clvmd daemons in the cluster to reload their device cache
2006-10-04 08:22:16 +00:00
c42c8c5192 Test. Future commit messages should now also go to the dm-devel list
(450 subscribers) for discussion as well as the read-only dm-cvs list
(just 15 subscribers).
2006-10-03 21:51:28 +00:00
5facb53a41 exclude targets that are always built-in 2006-10-03 18:02:06 +00:00
d039ce89af Add LV column to reports listing kernel modules needed for activation. 2006-10-03 17:55:20 +00:00
bc7605103f Show available fields if report given invalid field. (e.g. lvs -o list) 2006-10-02 16:46:27 +00:00
d305d655d4 Fix compiler warnings in percent arg. [pjc] 2006-10-02 16:15:03 +00:00
4ef1220b16 Add timestamp functions with --disable-realtime configure option. [AJ] 2006-09-30 20:02:02 +00:00
a4fef143cd Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.
e.g. lvcreate -l 100%FREE to create an LV using all available space.
     lvextend -l 50%LV to increase an LV by 50% of its existing size.
     lvcreate -l 20%VG to create an LV using 20% of the total VG size.
2006-09-26 09:35:43 +00:00
74ecb724a9 Fix two potential NULL pointer derefs in error cases in vg_read(). 2006-09-21 20:25:54 +00:00
af235897ab Separate --enable-cluster from locking lib options in lvmconf.sh. 2006-09-20 17:36:47 +00:00
5ec4e458b5 Supply missing comma. [via Debian] 2006-09-19 20:20:40 +00:00
2dae63ce21 post-release 2006-09-19 19:36:59 +00:00
be748fe33b pre-release 2006-09-19 19:15:10 +00:00
7408340b6a Fix lvconvert mirror change case detection logic.
Fix mirror log detachment so it correctly becomes a standalone LV.
2006-09-19 19:13:41 +00:00
29eb92446e post-release 2006-09-19 17:50:58 +00:00
ae6918742e pre-release 2006-09-19 17:43:03 +00:00
863484bb65 Reorder mm bounds_check code to reduce window for a dmeventd race. (dm_free_aux) 2006-09-19 17:30:04 +00:00
1cd7ebce4c Extend _check_contiguous() to detect single-area LVs.
Include mirror log (untested) in _for_each_pv() processing.
Use MIRROR_LOG_SIZE constant.
Remove struct seg_pvs from _for_each_pv() for generalisation.
Avoid adding duplicates to list of parallel PVs to avoid.
2006-09-11 21:14:56 +00:00
eef8c7862e Fix several incorrect comparisons in parallel area avoidance code.
Fix segment lengths when flattening existing parallel areas.
Log existing parallel areas prior to allocation.
Fix mirror log creation when activation disabled.
2006-09-11 14:24:58 +00:00
b52375d446 fix vgreduce clustered check 2006-09-07 23:23:45 +00:00
6e2babc2ce When using local file locking, skip clustered VGs.
Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
2006-09-02 01:18:17 +00:00
08e253bed1 lvm.static uses built-in cluster locking instead of external locking.
Don't attempt to load shared libraries if built statically.
2006-08-31 22:21:00 +00:00
c6661477a2 Change default locking_lib to liblvm2clusterlock.so. 2006-08-31 20:56:33 +00:00
415cfd99a0 Add skip_dev_dir() to process command line VGs. 2006-08-25 23:02:33 +00:00
8c2e37381a Stop clvmd complaining about nodes that have left the cluster 2006-08-24 12:45:05 +00:00
45df79feba stub.h shouldn't be here 2006-08-22 15:56:06 +00:00
5824f992b7 Add needed new parameter to create_toolcontext(). 2006-08-22 09:49:20 +00:00
b0b60fafd5 Move lvm_snprintf into libdevmapper. 2006-08-21 12:54:53 +00:00
8d98b02ba2 Add dm_snprintf 2006-08-21 12:52:39 +00:00
a93fe79bc4 Add dm_split_words() and dm_split_lvm_name() to libdevmapper. 2006-08-21 12:07:03 +00:00
4aebd7be37 fix lvm.conf (5) refs 2006-08-18 22:35:59 +00:00
3170a5db32 mirror man page tweaks 2006-08-18 22:27:01 +00:00
3605b9eef6 Add mirroring into man pages 2006-08-18 21:49:19 +00:00
a945f1fde2 reorder bounds check code 2006-08-18 21:38:58 +00:00
461a997b5b Prevent mirror renames. 2006-08-18 21:19:54 +00:00
a80afd7b4e Move CMDLIB code into separate file and record whether static build. 2006-08-18 21:17:18 +00:00
aad2b51d85 post 2006-08-17 20:04:38 +00:00
36a9a81ff1 wrappers files 2006-08-17 19:56:28 +00:00
42c88546ae pre-release 2006-08-17 19:55:50 +00:00
0f0e86ef9b Fix PE_ALIGN for pagesize over 32KB. 2006-08-17 19:53:36 +00:00
98efd9a857 wrap PE_ALIGN 2006-08-17 19:30:59 +00:00
a0c27d95b7 Separate out LVM1_PE_ALIGN. 2006-08-17 19:15:27 +00:00
984651d99d Add lvm_getpagesize wrapper. 2006-08-17 18:23:44 +00:00
c6f7370b30 Add --maxphysicalvolumes to vgchange. 2006-08-16 14:41:42 +00:00
3e4b8e8985 post-release 2006-08-15 19:13:06 +00:00
73f08b98d2 pre-release 2006-08-15 19:06:09 +00:00
8607a74206 post-release 2006-08-15 17:43:10 +00:00
8339f3ceb3 pre-release 2006-08-15 17:38:38 +00:00
c0c9f3cc19 fix getopt_long error check 2006-08-10 20:53:21 +00:00
81f4813c29 Add --table argument to dmsetup for a one-line table.
Abort if errors are found during cmdline option processing.
2006-08-10 14:11:03 +00:00
94f57745b9 Add checks for duplicate LV name, lvid and PV id before writing metadata.
Report all sanity check failures, not just the first.
2006-08-09 19:33:25 +00:00
54fb2ebbe0 Add lockfs indicator to debug output. 2006-08-08 21:22:31 +00:00
02d122b65b Fix missing lockfs on first snapshot creation. 2006-08-08 21:20:00 +00:00
df0a5561a1 Add --trustcache option to reporting commands in preparation for supporting
event-driven model.  Without changes to the way the cache gets updated, the
option is currently unreliable without a global lock to prevent any lvm2
commands from running concurrently.
2006-08-01 14:56:33 +00:00
f7c55da7d0 Fix locking for mimage removal. 2006-07-20 20:37:10 +00:00
b385f701ce Fix clvmd_init_rhel4 'status' exit code. 2006-07-19 18:55:58 +00:00
05dd42f443 post-release 2006-07-17 14:39:54 +00:00
36d816d5cb pre-release 2006-07-17 14:32:00 +00:00
92a6746e70 Fix activation logic in lvchange --persistent. 2006-07-10 19:39:14 +00:00
1728848a39 Don't ignore persistent minor numbers when activating. 2006-07-10 19:17:40 +00:00
f9eb4e7487 test 2006-07-05 21:07:35 +00:00
d0b9f33aeb test 2006-07-05 21:03:15 +00:00
718583b241 Append full patch to checkin emails. 2006-07-05 21:01:06 +00:00
6737127e9a Avoid duplicate dmeventd subdir with 'make distclean'. 2006-07-05 17:29:12 +00:00
19a7b4479b add dlerror to another error path 2006-07-05 17:26:36 +00:00
c340647502 Differentiate between the two 'log device failed' cases in vgreduce. 2006-07-04 19:52:47 +00:00
0f987d2982 Use RTLD_GLOBAL when loading shared libraries. 2006-07-04 19:40:27 +00:00
52bcaed169 Add some forgotten memlock checks to _vg_read to protect against full scans. 2006-07-04 19:36:49 +00:00
177bd565ac Add mutex to dmeventd_mirror to avoid concurrent execution. 2006-07-04 18:57:27 +00:00
c801c32fc5 If VG is already consistent with --removemissing, return success not failure. 2006-07-04 18:51:59 +00:00
d090cf3058 force remove fixes 2006-06-18 11:51:46 +00:00
1e4b82cc94 Add --force to dmsetup remove* to load error target. [Untested.]
Update dmsetup man page.
2006-06-18 11:35:04 +00:00
3426f31184 dmsetup remove_all also performs mknodes. 2006-06-17 16:12:41 +00:00
b4fb7af1df Don't suppress identical table reloads if permission changes. 2006-06-14 22:00:03 +00:00
b36647598b Fix return code if VG specified on command line is not found. 2006-06-14 20:27:15 +00:00
fd6b94f20e Fix PV tools to include orphaned PVs in default output again. 2006-06-14 20:11:22 +00:00
296dc0ed8a test checkin 2006-06-12 17:34:20 +00:00
4f869e14d6 test checkin 2006-06-12 17:32:43 +00:00
5704270e9d test checkin 2006-06-12 17:30:29 +00:00
505b381e85 checkin test 2006-06-12 17:18:31 +00:00
da6cb15393 Fix "Unaligned access" when using clvm
bz#194626
2006-06-12 09:46:35 +00:00
16843f6cc8 Fix an extra dev_close in a label_read error path. 2006-06-08 22:15:49 +00:00
64f3ad1fd4 change two files in different directories 2006-06-06 17:44:11 +00:00
ff4c4f99b3 test 2006-06-06 17:42:20 +00:00
f5d2e09569 test one change 2006-06-06 17:41:30 +00:00
f2bdbe0d4d Fix target_register_events args. 2006-05-25 13:32:26 +00:00
c51a13caa6 Prevent snapshots of mirrors. 2006-05-24 13:58:14 +00:00
7840c78a23 Add DISTCLEAN_TARGETS to make template for configure.h.
More fixes to error paths.
2006-05-16 20:53:13 +00:00
c706f3246b fix error path 2006-05-16 20:42:01 +00:00
608eedf88d Fix lvcreate corelog validation.
Add --config for overriding most config file settings from cmdline.
  Quote arguments when printing command line.
  Remove linefeed from 'initialising logging' message.
  Add 'Completed' debug message.
  Don't attempt library exit after reloading config files.
  Always compile with libdevmapper, even if device-mapper is disabled.
2006-05-16 16:48:31 +00:00
a564ca82be Fix corelog segment line.
Suppress some compiler warnings.
2006-05-16 16:20:29 +00:00
c868b1fee2 Add needed include. 2006-05-15 12:32:08 +00:00
22374f718f fix compile 2006-05-15 11:56:15 +00:00
abe3cfcf41 post-release 2006-05-12 20:32:39 +00:00
59db4b50cd fix dev->device 2006-05-12 19:47:40 +00:00
bdae38765d not reqd 2006-05-12 19:44:42 +00:00
66d3ceeb61 pre-release 2006-05-12 19:41:43 +00:00
445dd17db3 Add --monitor to vgcreate and lvcreate to control dmeventd registration.
Propagate --monitor around cluster.
Filter LCK_NONBLOCK in clvmd lock_vg.
2006-05-12 19:16:48 +00:00
cff78a2577 fix compile 2006-05-12 13:33:22 +00:00
6a09e64195 Pre-release. 2006-05-11 20:24:07 +00:00
22eabe5eab M for unsynced mirror 2006-05-11 20:17:17 +00:00
b69ba36c2d Add --nosync to lvcreate with LV flag NOTSYNCED. 2006-05-11 20:03:40 +00:00
5240aad22b Use mirror's uuid for a core log. 2006-05-11 19:47:53 +00:00
2897eb3cb3 Add mirror log fault-handling policy. 2006-05-11 19:45:53 +00:00
d3f2f00c25 Add DM_CORELOG flag to dm_tree_node_add_mirror_target(). 2006-05-11 19:10:55 +00:00
bacfb913a0 Avoid a dmeventd compiler warning. 2006-05-11 19:08:02 +00:00
c99d0236a0 Propagate nosync flag around cluster. 2006-05-11 19:05:21 +00:00
aac2b655f7 Allow vgreduce to handle mirror log failures. 2006-05-11 19:01:11 +00:00
126c41e73a Check in-sync status before changing disk log. 2006-05-11 18:56:55 +00:00
359ee54f0d Add --corelog to lvcreate and lvconvert. 2006-05-11 18:54:04 +00:00
28ab560907 Create a log header for replacement in-sync mirror log.
Use set_lv() and dev_set() to wipe sections of devices.
Add mirror_in_sync() flag to avoid unnecessary resync on activation.
2006-05-11 18:39:24 +00:00
ead252fee4 Add mirror_library description to example.conf.
More compile-time cleanup.
2006-05-11 17:58:58 +00:00
abf67914c4 post-release 2006-05-10 20:46:28 +00:00
127884e9dd pre-release 2006-05-10 20:14:15 +00:00
654f5049eb Move DEFS into configure.h.
Remove dmsetup line buffer limitation.
2006-05-10 19:38:25 +00:00
979ca34259 fix last commit 2006-05-10 17:51:02 +00:00
4dd1086805 more coverity fixes 2006-05-10 17:49:25 +00:00
3503d4b72c Fix uuid_from_num() buffer overrun. 2006-05-10 16:42:03 +00:00
b8d32a0d33 coverity fixes 2006-05-10 16:23:41 +00:00
45dca55fc8 Make SIZE_SHORT the default for display_size().
Fix some memory leaks in error paths found by coverity.
Use C99 struct initialisers.
Move DEFS into configure.h.
Clean-ups to remove miscellaneous compiler warnings.
2006-05-09 21:23:51 +00:00
445d8ecd9f sign fix 2006-05-04 09:33:42 +00:00
c980add503 fix stripesize const 2006-05-02 07:14:43 +00:00
133842392a Improve stripe size validation.
Increase maximum stripe size limit to physical extent size for lvm2 metadata.
2006-04-29 22:08:43 +00:00
8baf2ef155 missing { 2006-04-28 21:07:19 +00:00
20b71340bc validate region size against page size 2006-04-28 17:25:54 +00:00
61d8baf8b1 Fix activation code to check for pre-existing mirror logs. 2006-04-28 17:01:07 +00:00
56a9645aa5 Tighten region size validation. 2006-04-28 15:01:39 +00:00
85877000a6 tweak .so loading messages; extra device_exists() sanity check 2006-04-28 14:08:04 +00:00
2f7d2477b6 _register_dev_for_events to return error on failure 2006-04-28 14:06:06 +00:00
21ea3f05f4 Ignore empty strings in config files. 2006-04-28 13:30:59 +00:00
79d3492e90 Require non-zero regionsize and document parameter on lvcreate man page. 2006-04-28 13:11:05 +00:00
5972777abe remove redundant list_init 2006-04-27 17:58:48 +00:00
8e373ff868 Invalidate cache if composition of VG changed externally. 2006-04-21 19:12:41 +00:00
a4db92da3a terminate vgid in debug mesg 2006-04-21 15:37:08 +00:00
9b777eb281 pre-release 2006-04-21 15:27:38 +00:00
bd3c652184 Fix vgid string termination in recent cache code. 2006-04-21 14:44:33 +00:00
800f747570 Increase dmsetup line buffer to 4k. 2006-04-19 20:43:30 +00:00
2b8423437e post-release 2006-04-19 20:15:11 +00:00
8b4b6945f8 remove inlines 2006-04-19 18:12:33 +00:00
e5ecfec5c4 pre-release 2006-04-19 18:06:56 +00:00
f95dbff71f fix makefile 2006-04-19 17:32:05 +00:00
098f6830a6 fix makefile 2006-04-19 17:24:00 +00:00
d1ecebdb52 post-release 2006-04-19 17:21:39 +00:00
590b654251 fix makefile 2006-04-19 17:15:08 +00:00
3bf190c8ab update version 2006-04-19 16:41:03 +00:00
dcca7638e0 make pkgconfig installation step optional, and clean up generated files 2006-04-19 16:38:56 +00:00
70e45ad37b Check for libsepol.
Add some cflow & scope support.
Separate out DEFS from CFLAGS.
Remove inlines and use unique function names.
2006-04-19 15:33:07 +00:00
db88210289 configure/makefile tidying + pkg-config support. 2006-04-19 15:23:10 +00:00
d2e0d96cc3 post-release 2006-04-14 21:39:32 +00:00
3feba82ccc pre-release 2006-04-14 21:11:38 +00:00
db924da231 vgrename accepts vgid and exported VG. 2006-04-13 21:08:29 +00:00
fc55ae7e6d Add --partial to pvs. 2006-04-13 17:51:40 +00:00
86e757a6ad When choosing between identically-named VGs, also consider creation_host. 2006-04-13 17:32:24 +00:00
4790715cd3 Fix vgexport/vgimport to set/reset PV exported flag so pv_attr is correct.
Add vgid to struct physical_volume and pass with vg_name to some functions.
2006-04-12 21:23:04 +00:00
e7e9c60042 If two or more VGs are found with the same name, use one that is not exported. 2006-04-12 17:54:11 +00:00
1c3bc52cc4 tidy 2006-04-11 19:09:55 +00:00
5227dff0e1 When scanning, also record whether or not VG is exported. 2006-04-11 17:42:15 +00:00
33f0b5b7c2 Use lvmcache_update_vgname_and_id throughout. 2006-04-11 16:00:26 +00:00
0a02968303 Whenever vgname is captured, also capture vgid. 2006-04-11 13:55:59 +00:00
f7bf658c07 Capture vgid in more places. 2006-04-10 22:09:00 +00:00
8d16a0abad lv_is_visible() 2006-04-07 17:41:56 +00:00
c974b97ca3 missing vg_name initialisation 2006-04-07 14:14:31 +00:00
b8025bfebd Update extent size information in vgchange and vgcreate man pages 2006-04-06 21:15:14 +00:00
30323b253f Bring dmsetup man page up-to-date. 2006-04-06 16:20:40 +00:00
535c3ede96 more snapshot code tidying 2006-04-06 14:06:27 +00:00
89fed8ca33 Introduce origin_from_cow() 2006-04-06 13:39:16 +00:00
f43c77aaed pvremove without -f now fails if there's no PV label. 2006-04-05 22:24:16 +00:00
96c676b371 Support lvconvert -s. 2006-04-05 20:43:23 +00:00
113047e1a2 Suppress locking library load failure message if --ignorelockingfailure. 2006-04-03 18:43:55 +00:00
abed57cb53 Use name-based device refs if kernel doesn't support device number refs.
Fix memory leak (struct dm_ioctl) when struct dm_task is reused.
2006-04-03 15:56:02 +00:00
c01a800a6b If _create_and_load_v4 fails part way through, revert the creation. 2006-03-30 15:15:47 +00:00
d648832a2d allow new cman to shutdown on request. 2006-03-21 10:31:08 +00:00
f06833fbd2 Make sure it compiles if gulm is NOT selected AND using an old libcman.h 2006-03-15 08:36:11 +00:00
c561addc94 Get clvmd to use libcman rather than cman ioctl calls. This makes
it forward-compatible with the new userland CMAN in cluster head.

To build it you will need the libcman header & library installed.
2006-03-14 14:18:34 +00:00
702f5f1f4c Remove an incorrect unlock_vg() from process_each_lv(). 2006-03-10 15:41:04 +00:00
1273f179e8 Propagate partial mode around cluster. 2006-03-09 22:34:13 +00:00
5d02f60bde dmeventd thread/fifo fixes. 2006-03-09 21:33:59 +00:00
4cf7a108e8 Fix archive file expiration. 2006-03-07 15:43:05 +00:00
42635c3938 Add file & line to dm_strdup_aux(). 2006-02-23 19:11:51 +00:00
ed43dc842b A setgeometry implementation. [untested] 2006-02-20 23:55:58 +00:00
49d4db6cd2 post-release 2006-02-08 23:24:02 +00:00
ea80ab2cae post-release
fix dmeventd build
2006-02-08 23:23:19 +00:00
382e808b8d fix mirror log parm count 2006-02-08 14:14:13 +00:00
846befa7e0 release 2006-02-07 16:33:48 +00:00
74dd29f843 add clustered log uuid 2006-02-06 20:18:10 +00:00
b0473bffcb remove a dmeventd_mirror syslog message 2006-02-06 19:34:45 +00:00
24dd9ab1a7 Change prefix for clustered log from "clustered " to "clustered_" 2006-02-06 19:32:18 +00:00
49d3037e87 fix tabs 2006-02-03 21:34:11 +00:00
37ad2bd4e8 tweak clvmd makefile 2006-02-03 21:31:00 +00:00
7d7b332b02 Temporary device_exists() fixes. 2006-02-03 19:44:59 +00:00
ac033b8612 Use supplied full dso name. 2006-02-03 19:41:34 +00:00
a7b98dfe25 suspend using existing LV metadata; vgreduce then needs partial flag 2006-02-03 19:36:20 +00:00
7fb7c86c46 fix libdevmapper-event-mirror liblvm2cmd link search path 2006-02-03 14:48:38 +00:00
ed036598a9 Add exported functions to set uid, gid and mode. [Bastian Blank] 2006-02-03 14:23:22 +00:00
160bb70cdf Add %.so: %.a make template rule. 2006-02-02 19:16:47 +00:00
c2e61f3c21 autoconf LIB_SUFFIX 2006-02-02 18:39:23 +00:00
18218467f3 remove unnecessary 0 in format string 2006-02-02 17:23:04 +00:00
17e298ad2a Only do lockfs filesystem sync when suspending snapshots.
Switchover library building to use LIB_SUFFIX.
2006-01-31 14:52:30 +00:00
d031a374f9 Rename _log to dm_log and export.
Fix misc compile-time warnings.
2006-01-31 14:50:38 +00:00
55f69c98cb Add dm_tree_skip_lockfs. 2006-01-30 23:36:04 +00:00
71f2e4306d Tidy some comments/messages. 2006-01-27 20:52:21 +00:00
f8af23a025 Fix renamed dso. 2006-01-27 20:51:36 +00:00
4ef55a6cd3 dmeventd thread termination fix 2006-01-27 20:50:01 +00:00
312f866723 some init_client cleanup 2006-01-27 20:49:13 +00:00
0ebe1f6dec More dmeventd mirror cleanups. 2006-01-27 20:48:19 +00:00
2ad92e0e6e Remove avoidable dmeventd mirror forking. 2006-01-27 20:47:20 +00:00
ac8823cdcf Fix libdevmapper event daemon_running status. 2006-01-27 20:46:06 +00:00
77565f7ee4 Replace deprecated signal functions. 2006-01-27 20:45:17 +00:00
d656d90fa8 Use split_dm_name in dmeventd mirror code. 2006-01-27 20:43:52 +00:00
175b3b0834 When suspending, dmeventd deregistration needs to use existing details
not precommitted ones.
2006-01-27 20:39:37 +00:00
7477e6b714 Fix dmeventd sharedlib path & start tidying registration code. 2006-01-27 20:13:12 +00:00
cd6568db69 fix dmevent registration return codes 2006-01-27 20:01:45 +00:00
6aff325fb2 Add config file setting: dmeventd/mirror_library 2006-01-27 19:05:05 +00:00
0d603cfe9c Rename register_dev; fix missing initialisation; reduce number of ifdefs. 2006-01-27 18:38:14 +00:00
34a1f14a17 Fix dm_strdup debug definition. 2006-01-11 15:40:54 +00:00
efe1c8a070 Fix dm_strdup debug definition. 2006-01-10 22:19:41 +00:00
1575844344 Fix hash function to avoid using a negative array offset. 2006-01-09 20:35:24 +00:00
221ac1c208 vgreduce remove mirror images
adjust block_on_error version no detection for RHEL4U3
2006-01-04 18:09:52 +00:00
57442db759 Don't inline _find in hash.c and tidy signed/unsigned etc. 2006-01-04 16:07:27 +00:00
5fdb3e7cd6 Fix libdevmapper.h #endif 2006-01-04 16:05:44 +00:00
96f259726c Fix dmsetup version driver version 2006-01-03 20:53:57 +00:00
4936efba5e Always print warning if activation is disabled. 2005-12-22 16:13:38 +00:00
d5a3559a2f Add --mirrorsonly arg to vgreduce. (Doesn't handle mirrors yet.) 2005-12-21 21:21:45 +00:00
114a1c7f52 some fixes 2005-12-21 20:24:22 +00:00
ce5265c203 fix libdevmapper-event include 2005-12-21 19:45:16 +00:00
1a575d926f vgreduce replaces active LVs with error segment before removing them. 2005-12-21 18:51:50 +00:00
85c818a39e read/write loop fixes 2005-12-19 22:56:47 +00:00
4ffa2defe4 fixme 2005-12-19 22:36:04 +00:00
8825157fbb Change dm_tree_node_add_mirror_target_log parm order 2005-12-19 21:03:17 +00:00
966d608dc5 Set block_on_error parameter if available.
Add target_version.
2005-12-19 21:01:39 +00:00
b808c89471 Add details to format1 'Invalid LV in extent map' error message. 2005-12-19 16:28:35 +00:00
75d4e6490f ability to pass log flags to libdevmapper 2005-12-13 15:57:32 +00:00
a82775f544 Add sync, nosync and block_on_error mirror log parameters.
Add hweight32.
2005-12-13 15:49:27 +00:00
6a22ad0171 comments 2005-12-13 13:34:31 +00:00
c854e88186 comment 2005-12-13 13:32:19 +00:00
d02203060c Fix lvscan snapshot full display.
dmeventd fixes
2005-12-08 17:49:34 +00:00
cf703b0433 Fix dmeventd build. 2005-12-05 11:16:48 +00:00
c0197a72d3 fix exports 2005-12-02 21:00:33 +00:00
e5a543e283 More dmeventd support. 2005-12-02 20:35:07 +00:00
b8b029b7d3 Add mirror dmeventd library 2005-12-02 19:52:06 +00:00
370f368b1a post-release 2005-12-02 17:24:06 +00:00
8288b45b4f 1.02.02 2005-12-02 15:44:18 +00:00
fe529faf8e dmeventd 2005-12-02 15:41:14 +00:00
ab931b177d dmeventd updates 2005-12-02 15:39:16 +00:00
9aa3465513 Export dm_task_update_nodes.
Use names instead of numbers in messages when ioctls fail.
2005-12-01 23:11:41 +00:00
6c70fc1a6c Add some FIXMEs to libdm-event. 2005-11-30 18:35:03 +00:00
1ccc39962a more lvconvert mirror code 2005-11-29 18:20:23 +00:00
99c941fc85 Allow signed mirrors arguments.
Move create_mirror_log() into toollib.
2005-11-28 21:00:37 +00:00
19729fdcc2 Determine parallel PVs to avoid with ALLOC_NORMAL allocation. (untested) 2005-11-28 20:01:00 +00:00
02e17998ce alloc avoids parallel pvs when supplied 2005-11-24 21:23:55 +00:00
459e00c67a preparation for parallel_areas changes to allocation code 2005-11-24 20:58:44 +00:00
292f665650 Fix lv_empty. 2005-11-24 18:46:51 +00:00
93bbb79569 _find_parallel_space -> _find_segment_space 2005-11-24 18:00:47 +00:00
273e724f2b post_release 2005-11-23 18:45:30 +00:00
5d2615c56f post-release 2005-11-23 18:44:59 +00:00
bfaaf21330 2.02.01 2005-11-23 18:42:45 +00:00
dcb8415b7a 1.02.01 2005-11-23 18:36:33 +00:00
699e1c75ce Fix lvdisplay cmdline to accept snapshots. 2005-11-23 16:16:39 +00:00
465b6e613e Fix open RO->RW promotions. 2005-11-23 16:07:40 +00:00
05fa105855 Resume snapshot-origins last. 2005-11-22 20:00:35 +00:00
d7a0cdebe5 Remove a resolved FIXME. 2005-11-22 19:37:14 +00:00
b049ab31eb Suppress unnecessary resumes. 2005-11-22 19:31:20 +00:00
6db4dcff7a Drop leading zeros from dm_format_dev.
Suppress attempt to reload identical table.
2005-11-22 18:43:12 +00:00
3eeaef00ec Additional LVM- prefix matching for transitional period. 2005-11-12 22:46:48 +00:00
8bf4c38a00 lvcreate vg_revert 2005-11-12 22:42:08 +00:00
3a32b09ad1 A missing vg_revert in an error path. 2005-11-12 22:00:50 +00:00
6315982752 more debug fixes 2005-11-11 16:16:37 +00:00
374a171e82 Fix selinux compile. 2005-11-10 18:31:17 +00:00
fc5d801f91 fix debug linking 2005-11-10 16:33:04 +00:00
5146641848 post-release 2005-11-10 16:06:29 +00:00
cdd0ac42cf pre-release 2005-11-10 15:27:19 +00:00
e5895500a2 remove a debugging line 2005-11-10 15:17:54 +00:00
9cb4dde3fa Extend allocation areas to avoid overflow with contiguous with other PVs.
Another pvmove fix.
2005-11-10 14:45:39 +00:00
3c2a4370a5 Make it compile with debug enabled. 2005-11-10 08:49:29 +00:00
e7a360dd6f revert - alternative pvmove fix, disabling preloading completely for now 2005-11-09 23:57:40 +00:00
c814c2fd35 workaround for pvmove with new activation code 2005-11-09 23:56:36 +00:00
fefa7fe262 more mirror fixing 2005-11-09 18:13:10 +00:00
26f01a29d1 some fixes for mirrors 2005-11-09 17:32:31 +00:00
169d4090ab fix last checkin 2005-11-09 15:41:42 +00:00
0b43754d60 rename deptree 2005-11-09 14:10:50 +00:00
8b3b26b813 rename deptree 2005-11-09 13:08:41 +00:00
5426af4f81 rename deptree 2005-11-09 13:05:17 +00:00
4e2c3a579d xen xvd 2005-11-09 12:47:16 +00:00
5ae2693241 Use hash functions in libdevmapper. 2005-11-09 09:24:10 +00:00
41c86b0d19 Replacement activation code. [Don't use this yet!] 2005-11-08 22:52:26 +00:00
40788e8c3d New activation code. [Not ready to be used yet.] 2005-11-08 22:50:11 +00:00
0d29120033 precommitted flag 2005-10-31 20:18:50 +00:00
4be598f865 Clear up precommitted metadata better on disk after use.
[Some activation-related features will stop working for a while now.
Some types of activation are getting split into two steps, with the
first step using the precommitted metadata.]
2005-10-31 20:15:28 +00:00
558a6d509e pvresize man 2005-10-31 15:49:07 +00:00
75cd02aad2 revert unfinished change 2005-10-31 15:46:29 +00:00
e4c4451482 missing vg_revert 2005-10-31 15:43:11 +00:00
0671632477 A pvresize implementation (Zak Kipling). 2005-10-31 02:37:29 +00:00
54c230c264 reorder commit 2005-10-28 14:38:20 +00:00
64ba878eda more mirror library functions 2005-10-28 12:48:50 +00:00
01acd6dd76 Fix contiguous allocation when there are no preceding segments. 2005-10-27 22:21:10 +00:00
9d819b52d3 Fix contiguous allocation without preceding segments. 2005-10-27 22:20:33 +00:00
37bac5cdc9 Fix new mirror_seg pointer. 2005-10-27 21:51:28 +00:00
78c718c591 Add mirror_seg pointer to lv_segment struct. (incomplete & untested) 2005-10-27 19:58:22 +00:00
284b8bf6ca Only keep a device open if it's known to belong to a locked VG. 2005-10-27 17:45:34 +00:00
5a5084b837 Only keep devices open if known to belong to a locked VG now. 2005-10-27 17:44:55 +00:00
3b8058e1f1 Export vgname_is_locked 2005-10-27 17:41:41 +00:00
2a3168e0d6 remove unused suspend code path 2005-10-26 19:50:00 +00:00
a8ac6e4a15 fix strncmps 2005-10-26 18:33:47 +00:00
6172cf9fba Fix incorrect checkin 2005-10-26 18:32:57 +00:00
b728ec3909 Fix strncmps. 2005-10-26 18:17:36 +00:00
61a53bbcff suppress status err mesg when LVM- uuid prefix is missing 2005-10-26 17:56:31 +00:00
17d13dd084 Also suppress error if device doesn't exist with DM_DEVICE_STATUS. 2005-10-26 17:51:10 +00:00
edcb28d591 also suppress error if device doesn't exist with STATUS 2005-10-26 17:50:15 +00:00
ad101119a7 remove remaining hard-coded prefix lengths 2005-10-26 17:31:12 +00:00
bc36676d31 Fix lvdisplay to show all mirror destinations. 2005-10-26 16:12:36 +00:00
d76fe120ab a missing lvid/dlid conversion 2005-10-26 15:54:50 +00:00
2e95949b80 attempt to cope with uuid transition 2005-10-26 15:21:13 +00:00
ae14d85e24 Attempt to cope with LVM- prefix transition. 2005-10-26 15:00:51 +00:00
fad6304c60 new suspend code 2005-10-26 14:14:30 +00:00
a4dd3c8ce9 switch in new suspend code (untested) 2005-10-26 14:13:52 +00:00
6d1a5d45e2 check parents suspended 2005-10-26 14:08:24 +00:00
a6c7043e03 unfinished suspend functions 2005-10-25 19:09:41 +00:00
bcc400dafa Use dm_is_dm_major instead of local copy.
Allow mapped devices to be used as PVs safely.
2005-10-25 19:08:21 +00:00
8fbedf3441 Add DEFS 2005-10-25 19:03:59 +00:00
2e8a9c9874 Export dm_set_selinux_context. 2005-10-25 17:30:00 +00:00
44fc41b3e5 Move set_selinux_context into libdevmapper 2005-10-25 17:28:46 +00:00
7212c20a1b Fix automatic text metadata buffer expansion (using macro). [stdarg usage bug]
Cache formatted text metadata buffer between metadata area writes.
  [improves write performance when lots of metadata area clones]
2005-10-23 00:14:48 +00:00
7ff142de1c Add pe_start to pvs. 2005-10-20 22:24:46 +00:00
e67efb199d Fix LVM2- prefix changes; export build_dlid. 2005-10-20 21:07:57 +00:00
20128bd04b zero suppress 2005-10-20 20:38:18 +00:00
c0fefdde28 fix dev no printf 2005-10-20 20:29:58 +00:00
f6ee160e66 Add 'LVM-' prefix to uuids. 2005-10-19 13:59:18 +00:00
06acc2004f cope with null uuid_prefix 2005-10-18 13:57:11 +00:00
43ac2ce4c8 use seg_type macro 2005-10-18 13:45:25 +00:00
b32bf72b5f Split lv_segment_area from lv_segment to permit extension. 2005-10-18 13:43:40 +00:00
c6880c957e Tidy some log mesgs. 2005-10-18 13:07:41 +00:00
095b71ed96 Move deactivation code into libdevmapper. 2005-10-18 12:39:20 +00:00
9160e496bc Add deactivation functions 2005-10-18 12:37:53 +00:00
2a7ac78f02 some deactivation fixes 2005-10-17 19:06:20 +00:00
64efa4627d Replacement deactivation code - untested. 2005-10-17 18:21:57 +00:00
f7e35569ce Only one dump_memory. 2005-10-17 18:21:05 +00:00
e8af32ec2b dm_driver_version 2005-10-17 18:05:39 +00:00
e092ce51f6 Attempt to load missing targets using modprobe.
Simplify dev_manager_info().
2005-10-17 18:00:02 +00:00
7b78edb1b7 Attempt to load missing targets using modprobe. 2005-10-17 17:56:27 +00:00
b332e7090e lvscan -a 2005-10-17 16:41:38 +00:00
67eb7723d6 Use hash, bitset, malloc, pool from libdevmapper. 2005-10-16 23:03:59 +00:00
251d138474 export bitset, pool, hash, malloc 2005-10-16 22:57:20 +00:00
1170dfac05 post-release 2005-10-16 20:09:42 +00:00
4157f141c7 pre-release 2005-10-16 20:06:54 +00:00
f569abd28a Code to build and display device dependency tree. 2005-10-16 14:33:22 +00:00
088f9687c0 Add dmsetup --nolockfs support for suspend/reload.
Requires kernel patches to have any effect.
Library version incremented.
2005-10-04 20:12:32 +00:00
e23df1f07a Refuse to run pvcreate/pvremove on devices we can't open exclusively. 2005-10-03 21:10:41 +00:00
c818540dfd Use ORPHAN lock definition throughout. 2005-10-03 18:16:44 +00:00
21365cbe1a Validate chunksize in lvcreate. 2005-09-30 22:21:01 +00:00
5471a80a96 Impose chunk size limitation. 2005-09-30 22:20:14 +00:00
d7b6fa9cd0 Reduce chunksize limit to 512k. 2005-09-29 15:50:51 +00:00
dfdc2e02ef post-release 2005-09-26 20:52:00 +00:00
893ec9a302 1.01.05 2005-09-26 20:44:12 +00:00
05f65c38e6 Fix chunksize field in reports. 2005-09-23 17:06:01 +00:00
2e9d062ec0 Don't hide snapshots from default 'lvs' output. 2005-09-23 16:22:17 +00:00
6b0b394e61 Resync list.h with LVM2. 2005-09-22 12:06:34 +00:00
25621396c9 Remember increased buffer size and use for subsequent calls. 2005-09-20 18:04:28 +00:00
82aa0271f3 Explicitly initialise no_open_count 2005-09-20 16:39:12 +00:00
653cab13f8 On 'buffer full' condition, double buffer size and repeat ioctl. [Untested] 2005-09-19 14:29:17 +00:00
b526f86b49 Add is_dm_major() for use in duplicate device detection in lvmcache_add(). 2005-09-16 18:53:01 +00:00
53c0f00888 Really switch device number in lvmcache when it says it is doing so. 2005-09-16 18:44:52 +00:00
f0c4d9de40 Option for bitset memory allocation using malloc as well as pool. 2005-09-16 18:40:53 +00:00
03ef8cec83 Don't assume exactly two mirrors when parsing mirror status 2005-09-02 16:59:46 +00:00
85f2a2e8c2 Suppress fsync() error message on filesystems that don't support it. 2005-09-01 18:37:22 +00:00
584b3e6642 Fix yes_no_prompt() error handling. 2005-08-31 19:32:10 +00:00
39b7ef841d add comments to example conf file to warn about common filter line mistakes 2005-08-31 15:05:47 +00:00
aa16a9098d Fix termination of getopt_long() option array. 2005-08-18 19:40:19 +00:00
7b8c2707bc lvmconf.sh 2005-08-16 20:42:28 +00:00
60e26a31a7 Add copyright notice to lvmconf.sh and use unique exit codes. 2005-08-16 20:38:33 +00:00
3473c25c14 Add format1 dev_write debug messages. 2005-08-16 19:00:55 +00:00
e52f022026 clvmd no longer takes out locks for non-clusteed LVs,
and non-clustered LVs are only activated on the local node.
2005-08-16 08:25:09 +00:00
b1a7df8e43 Add clustered VG attribute to report. 2005-08-15 23:34:11 +00:00
0fd2479b7c Move lvconvert parameters into struct lvconvert_params. 2005-08-15 14:10:28 +00:00
273857f914 Add clustered VG flag to LV lock requests. 2005-08-15 13:24:46 +00:00
a08b85dbc8 Change LV locking macros to take lv instead of lvid. 2005-08-15 12:00:04 +00:00
a0aedf299a Prepare tools to support clustered mirrors. 2005-08-14 23:18:28 +00:00
3c61426844 Factor out generate_log_name_format(). 2005-08-12 20:02:21 +00:00
786f228076 Factor out adjusted_mirror_region_size() 2005-08-12 19:23:08 +00:00
004da28792 Move compose_log_line() into mirror directory. 2005-08-10 17:19:46 +00:00
6e2be6efb6 Don't kill idling clvmd threads. 2005-08-09 17:29:04 +00:00
a994dfcfbc Factor out _get_library_path(). 2005-08-09 17:24:21 +00:00
7a8ea2ac93 Don't send a signal to kill threads that are idling nicely as it upsets them.
This seems to cure bz#159727 on SMP systems.

Alasdair, can you include this patch in the lvm2-cluster package please ?
2005-08-09 10:39:57 +00:00
0da3965d19 Report 'buffer full' condition with v4 ioctl as well as with v1. 2005-08-08 18:40:17 +00:00
885fd7bb46 aoe 2005-08-08 17:55:35 +00:00
08771f9c89 Recognise aoe devices. 2005-08-08 17:54:23 +00:00
8be48195a5 post-release 2005-08-04 02:07:34 +00:00
98ce2d650e update po 2005-08-04 02:02:37 +00:00
3af327116a Fix lvconvert PV parameter in help string. 2005-08-04 01:50:17 +00:00
b75434db93 fix last checkin 2005-08-04 01:29:18 +00:00
04e912aacd Prevent snapshots getting activated in a clustered VG. 2005-08-04 01:27:25 +00:00
d7be352f87 Separate out _build_dev_string. 2005-08-04 01:15:30 +00:00
96be3ec22c Move zero_lv to toollib. 2005-08-04 01:14:36 +00:00
32e7e0d790 post-release 2005-08-02 21:46:49 +00:00
becc320e62 update vsn 2005-08-02 18:00:32 +00:00
7666ed57d1 Fix dmsetup ls -j and status --target with empty table. 2005-07-29 16:11:23 +00:00
5e61d0955e fix pool format handler to work with pvseg code 2005-07-26 21:48:18 +00:00
e8a4662ae7 post-release 2005-07-13 19:28:09 +00:00
a48da3bd3b update po 2005-07-13 19:23:48 +00:00
5f1a5d7b99 2.01.13 2005-07-13 19:15:09 +00:00
3e28a9db8f Fix pvmove segment splitting.
Abstract vg_validate.
2005-07-12 19:40:59 +00:00
ebf6071d77 Only make one attempt at contiguous allocation. 2005-07-12 14:50:45 +00:00
47a35fb9fb Fix lvm1 format metadata read. 2005-06-22 15:31:29 +00:00
48e88aba44 fix lvm1 non-mirror lvcreate 2005-06-22 14:56:14 +00:00
b85f99c140 Fixing some makesfiles, so that the correct things link against pthreads.
Also changed dmevent so that in no longer links against pthreads, and
dynamically loads libdmevent.so.  Everything seems to work just fine like this.
2005-06-14 19:06:26 +00:00
0a5e0e1f71 preset pl to NULL 2005-06-14 18:29:12 +00:00
85dc22ebb7 missing fn defs 2005-06-14 18:22:31 +00:00
5c21526009 post-release 2005-06-14 18:22:22 +00:00
14dff1cefc 2.01.12 2005-06-14 17:59:57 +00:00
39fbb844f9 Various allocation-related pvmove fixes. 2005-06-14 17:54:48 +00:00
ca4e0c973a Log an error if clvmd can't resolve a host name got from CCS
Fix potential spin loop in clvmd
2005-06-14 10:35:02 +00:00
ecb42bee80 post-release 2005-06-13 14:53:07 +00:00
674ed2a9f3 2.01.11 2005-06-13 14:43:28 +00:00
252daf9717 Use matchpathcon mode parameter. 2005-06-13 13:13:15 +00:00
196b8eaad3 Use matchpathcon mode parameter 2005-06-13 13:11:48 +00:00
8e526ba1bf Don't defer closing of FDs in clvmd as it can cause trouble. 2005-06-13 10:16:21 +00:00
19225828d9 update version 2005-06-10 22:00:44 +00:00
7e594126be fix configure script to reenable selinux 2005-06-10 21:57:49 +00:00
d2529e6334 o print the context along with the path when setting selinux context 2005-06-10 21:30:21 +00:00
97344f18e2 o set umask and make tempfiles a bit nicer to deal with 2005-06-10 19:10:45 +00:00
33934db629 o script to adjust items in lvm.conf file - currently only handles turning
cluster lvm on and off
2005-06-10 17:11:48 +00:00
6c6165c9f5 Be a bit smarter about reading stuff from the sockets 2005-06-10 09:11:01 +00:00
853460b20d Timeout event implementation:
The daemon side of this is mostly the same as the patch I sent out.  To select
a timeout period different than the default and to get the timeout period,
I added two library calls, dm_set_event_timeout() and dm_get_event_timeout().
If people are against them, the other option is to tack extra arguments onto
dm_regiser_for_event() and dm_get_registered_device().  I also added a
-t option to dmevent, so people can try out timeouts.
2005-06-09 18:40:49 +00:00
cc4d9676c5 Remove hard-coded 64k text metadata writing restriction. 2005-06-07 11:00:07 +00:00
1cf1b819f4 Make VG name restrictions consistent. 2005-06-06 18:16:33 +00:00
f916c66d2b Introduce lvconvert. So far only removes mirror images. 2005-06-06 17:12:08 +00:00
550aa86b45 prevent active mirror resize for now 2005-06-03 22:26:09 +00:00
014e764758 Allow mirror images to be resized. 2005-06-03 19:48:19 +00:00
d1fc28432b Allow mirror images to have more than one segment. 2005-06-03 18:07:13 +00:00
879576f0a2 lvremove mirror images 2005-06-03 15:44:12 +00:00
69098210be Always insert an intermediate layer for mirrors.
Suppress hidden LVs from reports unless --all is given.
Use square brackets for hidden LVs in reports.
Centralise restrictions on LV names.
2005-06-03 14:49:51 +00:00
99df4f892d Basic support for mirrors. 2005-06-01 16:51:55 +00:00
7bc04fbad3 Change the multilog code to toggle between async and sync writes for all
log types.  This means the threaded_syslog type is no longer valid.  A new
fxn multilog_async is available to toggle between the two modes.  If an
app is compiled without pthreads and tries to use async logging, no logging
will occur while async is enabled.

dmeventd has been modified to use the new code

I'm not positive I like the way the async_logger code calls the log fxn,
but it works for now.  Suggestions for other ways to do it would be helpful
2005-05-25 21:08:36 +00:00
8a74ce578d Fix non-orphan pvchange -u. 2005-05-24 17:38:26 +00:00
0805e4e5de Fix mem allocs after archiver code move. 2005-05-24 17:37:39 +00:00
f1060fc88e Exit after last unregister_for_event() 2005-05-20 13:53:26 +00:00
7d3d3d0a3a Fix vgmerge to handle duplicate LVIDs. 2005-05-19 16:48:51 +00:00
40377032e3 1.01.02 2005-05-17 15:50:25 +00:00
b2971edd7d Start merging cloned allocation functions. 2005-05-17 13:49:45 +00:00
c37d723692 Move archiver code from tools into library. 2005-05-17 13:46:38 +00:00
30f9026e1d vgscan/change/display/vgs automatically create metadata backup if out-of-date or missing. 2005-05-17 13:44:02 +00:00
332286072e Add dmsetup ls --exec. 2005-05-16 20:46:46 +00:00
d6da172a2a Add --target to dmsetup ls. 2005-05-16 16:04:34 +00:00
ebfe584afc Call dm_lib_exit() and dm_lib_release() automatically now. 2005-05-16 15:15:34 +00:00
6250023583 Add --target <target_type> filter to dmsetup table/status.
Fix dmsetup getopt_long usage.
2005-05-16 14:53:23 +00:00
6b4f3d63b8 Fix contiguous allocations with linear. 2005-05-11 16:46:59 +00:00
56db773a09 more clvmd rhel4 initscript cleanup
- don't echo after an 'action' call - action does the echo itself
 - use vgdisplay/vgs to determine which VGs are marked clustered and only
   deactivate those VGs (unless the LVM_VGS var is set in
   /etc/sysconfig/cluster)
2005-05-11 15:21:44 +00:00
fc6c472401 Cope with missing format1 PVs again. 2005-05-11 15:04:06 +00:00
2cd42a6866 Remove lists of free PV segments.
Simplify pv_maps code and remove slow bitset algorithm.
2005-05-11 15:02:49 +00:00
36a90c345c updated to reflect clvmd rhel4 initscript being redhatified 2005-05-10 20:15:39 +00:00
ef1e82c72c Fixes bz#155478
Redhatify the rhel4 initscript (use /etc/init.d/functions)
2005-05-10 20:14:33 +00:00
88f9534685 o Changed the multilog API a bit (I warned you)
- multilog_add_type, multilog_del_type, multilog_custom, and
     multilog_init_verbose all have different arguments.
   - Primary change is that caller only passes in config info, and the
     lib keeps track of state internally.  No more exporting of
     'struct log_data'.
   - Custom callers now only get the custom data pointer passed into their
     log fxn (that is set with multilog_custom)
   - Added basic README that describes libmultilog
2005-05-09 18:44:35 +00:00
68254a052a %Zu->zu 2005-05-09 17:45:06 +00:00
2425b3a166 fix compiler warnings 2005-05-09 17:41:36 +00:00
5524ed753b Fix loopfiles mem alloc. 2005-05-09 17:02:52 +00:00
89711723da Un-inline dbg_strdup. 2005-05-09 17:01:06 +00:00
bed2740ffd lv_reduce tidying.
Remove some unnecessary parameters.
Introduce seg_is macros.
2005-05-09 16:59:01 +00:00
751d633c3d post-release 2005-05-09 16:41:48 +00:00
45952cbdf2 oops. Those are char **'s not char *'s 2005-05-04 19:24:03 +00:00
b355dd7b23 fixed dmevent so that it doesn't do a double free when you run
# dmevent -l

Also, changed the behaviour of dm_get_registered_device(), so that it doesn't
change the pointer you passed in without freeing the memory on a non-next call,
and doesn't free your pointer without setting it to NULL on a failed next call.
2005-05-04 18:53:28 +00:00
48a186f172 o libmultilog needs introducing of list locking in order to stand
multilog_add_type()/multilog_del_type cycles correctly.
o fixed segfault in multilog_add_type()
o fixed test-multilog.c
o cleaned up libmultilog (list macros, indentation, braces, comments)
2005-05-04 11:52:07 +00:00
39dc7ec2ab - make noop use multilog
- add event_nr to thread_status struct and set appropriately so that the
  thread actually waits for an event
- essentially make error_detected return true.  Let the DSOs determine
  how to interpret the status info
2005-05-04 01:57:31 +00:00
2fedabd3b9 o stick multilog into the dm-event lib and dmeventd code again
o more tweaks to libmultilog calls - the api isn't set in stone yet, so
   don't get too comfortable.
 o not sure the dmeventd in device-mapper/dmeventd works - i've been using
   the one in lib/event/
 o currently both daemons are set to log only to syslog
2005-05-03 21:29:13 +00:00
6d719e9480 2.01.10 2005-05-03 17:43:47 +00:00
05e278afda Don't create backup and archive dirs till needed. 2005-05-03 17:31:56 +00:00
87dbf462cb Reinstate full PV size when removing from VG.
Support loopfiles for testing.
Complete the pv_segment support.
2005-05-03 17:28:23 +00:00
40e896bc5b working dm_get_registered_device(). dmevent.c update to use it. 2005-05-03 16:15:20 +00:00
3e940f80c7 more dm_get_registered_device() code 2005-05-03 13:50:42 +00:00
dbf2888d43 dmeventd was looking for dsos with libdmeventd<name>.so
The Makefile turned noop.c into    libdmeventnoop.so
The Makefile now turns noop.c into libdmeventdnoop.so
2005-05-02 19:34:25 +00:00
d412355324 stopped printing a string after we erased the pointer to it. 2005-05-02 18:43:23 +00:00
178732217f removed the -lmultilog for now. 2005-05-02 18:42:07 +00:00
de17b95c3d get the makefile to clean up the .o's 2005-05-02 17:41:54 +00:00
d14e774525 Introduce exit() in main() and cleanup signal settings for parent/child 2005-05-02 11:02:19 +00:00
ca5402a7fa more variable initialization. 2005-04-29 22:12:09 +00:00
7a6fa7c5b4 changed client_path and sever_path from 'char *' to 'const char *' to stop
compiler warning messages.
2005-04-29 21:52:46 +00:00
da36c286a6 o checking in instrumented code for AJ to follow up on comms and logging
o changed

  int dm_get_next_registered_device(char **dso_name, char **device,
                                    enum event_type *events);

  to

  int dm_get_registered_device(char **dso_name, char **device,
                               enum event_type *events, int next)

  so that the daemon is able to retrive the next one of the list without
  running into locking issues.

o changed dmevent.c to use dm_get_registered_device()

o couldn't test this yet because of the comms issues
  (daemon exits in do_process_request())
2005-04-29 14:56:35 +00:00
d3901bcf2e first changes to get comms back to work after flock changes 2005-04-29 13:41:25 +00:00
94c8d4fdfb minor cleanup 2005-04-29 10:58:34 +00:00
ab8bdc18bb o Build dmeventd against multilog 2005-04-28 22:47:52 +00:00
c9dcd7442a build libdmeventnoop.so for testing 2005-04-28 17:32:27 +00:00
34c8f13346 test.c->dmevent.c 2005-04-28 14:49:41 +00:00
7a8ccda95c o adds dm_get_next_registered_device() (not functional yet)
to retrieve which devices got registered with the daemon;
  needs locking changes as well
2005-04-28 14:02:30 +00:00
44a1448542 Prototype for a device-mapper event-handling daemon. 2005-04-27 22:32:00 +00:00
c87d89ffaf extend alloc_lv_segment 2005-04-22 15:44:00 +00:00
0868749d42 set_lv_segment_area_pv/lv 2005-04-22 15:43:02 +00:00
1d40ee23f0 Initial pv_segment code. 2005-04-19 20:58:25 +00:00
8893f32603 initial pv_segment defns 2005-04-19 20:52:35 +00:00
adcf7e8dc3 _copy_pv -> int 2005-04-19 20:44:21 +00:00
901f7c5c36 Tidy clvmd's SIGHUP handler so it doesn't do all that work. 2005-04-19 10:36:42 +00:00
775bb413b3 vgchange --physicalextentsize (but only if it's an exact fit - may need to
use pvmove first)
2005-04-18 14:56:42 +00:00
64cd5b5a46 extract compose_log_line 2005-04-17 23:59:04 +00:00
ae356609b1 get_pv_from_vg_by_id 2005-04-17 23:57:44 +00:00
6102a5d2b0 Make clvmd work around some "limitations" in gulm's node state notifications.
Also make clvmd debuglog timestamps a little more helpful.
2005-04-13 13:50:07 +00:00
f8782ee2d7 Internal snapshot code restructuring. 2005-04-07 12:39:44 +00:00
6181ec4c77 add lvid to lv_create_empty 2005-04-07 12:29:46 +00:00
e0e7a685ef Remove unused internal non-persistent snapshot option. 2005-04-07 12:27:57 +00:00
ae1f8cdad2 fix unused o_direct label 2005-04-07 12:25:33 +00:00
a4cf792e6d store snapshot id as lvid internally 2005-04-07 12:24:48 +00:00
89109ded53 Allow offline extension of snapshot volumes.
NB Requires kernel patch that is not upstream.
2005-04-07 12:17:46 +00:00
e20e52a4b2 Move from 2-step to 3-step on-disk metadata commit. 2005-04-06 18:59:55 +00:00
20c4b1cbec Add ramdisk. 2005-04-06 16:43:59 +00:00
5238b0241d _vg_posn -> _find_vg_rlocn 2005-04-06 16:35:33 +00:00
9cdf6c203d more refinements 2005-04-06 15:21:28 +00:00
839335cae6 Annotate, tidy and extend list.h. 2005-04-06 14:50:37 +00:00
a99b2ce167 Alignment tidying. 2005-04-06 13:47:41 +00:00
b695141d87 post-release 2005-04-04 15:46:14 +00:00
92d5c9f866 2.01.09 2005-04-04 15:41:51 +00:00
7f18a1ffe0 Add --ignorelockingfailure to vgmknodes. 2005-04-04 14:44:49 +00:00
8c3fdaaa62 set SO_KEEPALIVE on sockets 2005-04-01 16:03:00 +00:00
5ac1c69710 Don't allow user operations to start until the lvm thread is fully up.
Hopefully finally nails bz#146056
2005-04-01 13:01:01 +00:00
de2d5fba63 post-release 2005-03-29 18:10:57 +00:00
33d516748f 1.01.01 2005-03-29 14:47:39 +00:00
de17f6f0fd Update dmsetup man page. 2005-03-29 14:46:30 +00:00
756731fc02 Drop-in devmap_name replacement. 2005-03-27 11:37:46 +00:00
e46be0415f post-release 2005-03-22 16:50:17 +00:00
aa02fb50bf update pofile 2005-03-22 15:13:48 +00:00
8b6cd9c772 2.01.08 2005-03-22 15:12:37 +00:00
cdd0d3351a Add clustered attribute so vgchange can identify clustered VGs w/o locking. 2005-03-21 22:55:12 +00:00
8b6d584529 Improve detection of external changes affecting internal cache. 2005-03-21 22:40:35 +00:00
f49fdd4141 Add 'already in device cache' debug message. 2005-03-21 14:51:49 +00:00
b26e1be81a Add -a to pvdisplay -C. 2005-03-21 14:47:36 +00:00
bacab38d7f Avoid rmdir opendir error messsages when dir was already removed. 2005-03-21 14:43:02 +00:00
701c05ce96 Tighten signal handlers. 2005-03-21 14:16:16 +00:00
438c452585 Fix WHATS_NEW. 2005-03-10 23:04:42 +00:00
0a7a1eff3f Avoid some compiler warnings. 2005-03-10 22:34:17 +00:00
87e743e381 Additional rename failure error message. 2005-03-10 22:31:10 +00:00
a03f1b3d55 read/write may be macros 2005-03-10 20:23:36 +00:00
2d8dc3d243 post-release 2005-03-10 20:22:40 +00:00
b982232cc5 Don't take out the lvm_thread_lock at startup - it only protects the jobs list.
DEBUGLOG() message now print threadid rather than PID which is more useful.
2005-03-09 14:08:11 +00:00
61c8d728ac update pofile 2005-03-08 13:48:13 +00:00
851a2bf855 Cope with new devices appearing by rescanning /dev if a uuid can't be found. 2005-03-08 13:46:17 +00:00
e0bdde3630 Remove DESTDIR from LVM_SHARED_PATH. 2005-03-08 13:39:39 +00:00
6a0dcd7f0e make clvmd FDs close-on-exec, to avoid warnings when running lvm via popen.
clvmd-gulm unlocks VG & orphan locks at startup in case they are stale.
clvmd-gulm now unlocks VG & orphan locks if client dies.
2005-03-07 17:03:44 +00:00
75f0b4c879 post-release 2005-03-03 22:31:01 +00:00
db536a9504 2.01.06 2005-03-03 22:26:34 +00:00
0fb114dede Option to suppress warnings of file descriptors left open. 2005-03-03 22:09:20 +00:00
e703342179 Suppress 'open failed' error messages during scanning. 2005-03-03 21:54:35 +00:00
35c8f4a611 Fix default value of metadatacopies in documentation (2->1). 2005-03-03 21:52:58 +00:00
7c89ae44a9 Fix clvmd-gulm node up/down code so it actually works.
clvmd-gulm now releases locks when shut down.
2005-02-22 16:26:21 +00:00
84fe06da22 ./configure --enable-debug now enables debugging code in clvmd 2005-02-21 15:58:06 +00:00
806318c8b3 Always manipulate both locks in sync_lock() otherwise they get left
hanging around and cause trouble.
2005-02-21 14:36:09 +00:00
3aac2e1822 post-release 2005-02-18 19:06:16 +00:00
168baef433 Static binary invokes dynamic binary if appropriate. 2005-02-18 18:58:31 +00:00
6dba6cd78d Cope with more than one message arriving at the TCP socket, also
fix some instances where the length in the message was wrong (cman
code didn't notice this because it is packet-based comms anyway)
2005-02-18 15:31:32 +00:00
502250d08f Fix gulm->errno error number conversion. 2005-02-17 12:56:19 +00:00
7395f0e680 Make config check a little more tolerant of library names. 2005-02-14 09:07:14 +00:00
494d3fdaca post-release 2005-02-09 18:26:38 +00:00
7b86a157de Add fixed offset to imported pool minor numbers. 2005-02-09 17:49:36 +00:00
0988c41785 o cluster lvm requires that /usr/sbin/$TOOL is used instead of
/sbin/lvm.static $TOOL

o made variables LVDISPLAY, VGSCAN and VGCHANGE configurable in
  /etc/sysconfig/cluster
2005-02-08 17:20:24 +00:00
522db1bf01 Fix thread shutdown race which could cause clvmd to hang in pthread_join. 2005-02-08 09:05:58 +00:00
06f066f90d Revert last clvmd patch. More testing reveals that this just doesn't
work yet.
2005-02-07 14:45:38 +00:00
f37b20677b Make clvmd use the command library rather than popen() to
preload the lock state.
2005-02-07 10:04:27 +00:00
cd2eac1032 lvm2cmd.so should skip the check for open fds. 2005-02-03 16:34:53 +00:00
8ac38d58d7 Remove unused -f from pvmove 2005-02-02 14:31:48 +00:00
4c80cc313a Make clvmd do a quick sanity check on the clustering bits of lvm.conf 2005-02-02 11:42:29 +00:00
1c65fee9b4 Get rid of "connection refused" message because Corey doesn't like it. 2005-02-02 09:17:56 +00:00
90dda7edc1 post-release 2005-02-01 16:40:16 +00:00
da054fae20 pofile 2005-02-01 16:33:45 +00:00
bdb6611e30 2.01.03 2005-02-01 16:29:22 +00:00
9284f973f1 More 64-bit display/report fixes. 2005-02-01 16:19:48 +00:00
2bfd64c3c9 Add option to compile without ioctl for testing. 2005-01-27 16:16:54 +00:00
939d24cce5 Fix DM_LIB_VERSION sed 2005-01-27 15:53:28 +00:00
27b0183c46 More informative startup mesg if can't create /etc/lvm. 2005-01-27 15:50:34 +00:00
d14efacac7 Fix snapshot device size bug (since 2.01.01). 2005-01-27 15:48:49 +00:00
150a002c40 Don't print CMAN error if initial probe fails - we could be running with GULM. 2005-01-26 09:30:52 +00:00
ce0def3bd8 Remove superflous &
Gulm clvmd no longer hangs trying to talk to a rebooted node.
2005-01-25 16:46:29 +00:00
ee20fa97c2 Make clvmd announce it's startup and cluster connection in syslog. 2005-01-24 15:31:13 +00:00
7403b7d700 postrelease 2005-01-21 19:03:48 +00:00
87ef173e0a update pofile 2005-01-21 18:51:48 +00:00
52a3fb6bc7 pre-release 2005-01-21 18:49:06 +00:00
92e2a257a6 Get rid of libclvm as it's out-of-date and not used at all. 2005-01-21 11:56:30 +00:00
32e175752c Fix clvmd startup bug introduced in cman/gulm amalgamation. bz#145729
Improve reporting of node-specific locking errors so you'll get
somthing a little more helpfiul than "host is down" - it will now tell
you /which/ host it thinks is down.
2005-01-21 11:35:24 +00:00
d43f7180dc Update clvmd_init_rhel4: use lvm.static and don't load dlm. 2005-01-20 22:16:55 +00:00
0129c2b0fc Fix some size_t printing. 2005-01-20 18:14:04 +00:00
4ed1990001 Fix 64 bit xlate consts. 2005-01-20 18:13:17 +00:00
5bd6ab27ae Split out pool sptype_names to avoid unused const. 2005-01-20 18:12:41 +00:00
f3593b89fa Always fail if random id generation fails. 2005-01-20 18:11:53 +00:00
23d84b2310 Recognise gnbd. 2005-01-19 18:56:01 +00:00
fdc49402ec fix clvmd lv_info_by_lvid open_count 2005-01-19 18:10:09 +00:00
5457c133e1 Add some comments. 2005-01-19 17:31:51 +00:00
292e588ee3 move recover_vg 2005-01-19 17:30:50 +00:00
243494c25e Store snapshot and origin sizes separately. 2005-01-19 17:19:39 +00:00
e4365f3706 Update vgcreate man page. 2005-01-19 17:01:18 +00:00
310f3038d3 Post-2.01.00 2005-01-17 20:45:05 +00:00
4e6033273d update po 2005-01-17 20:16:37 +00:00
73718586d3 2.01.00 2005-01-17 20:13:01 +00:00
011abe61e8 post-1.01.00 2005-01-17 20:12:12 +00:00
fe3a37f89d 1.01.00 2005-01-17 20:00:28 +00:00
8aea44e77b Fix vgscan metadata auto-correction. 2005-01-17 18:24:28 +00:00
5529aec0d6 You can now build clvmd with cman & gulm support in the same binary.
./configure --with-clvmd
wil do this by default. Or you can choose which you want with
./configure --with-clvmd=gulm    or
./configure --with-clvmd=cman

When clvmd with both included is run, it will automatically detect the cluster
manager in use.
2005-01-13 13:24:02 +00:00
369549d23f Only ask libdevmapper for open_count when we need it. 2005-01-12 22:58:21 +00:00
181ea9a381 Add dm_task_no_open_count() to skip getting open_count. 2005-01-12 22:10:14 +00:00
76b8f2854e Adjust RHEL4 clvmd init script priority. 2005-01-11 22:00:36 +00:00
320e5198f9 post-2.00.33 2005-01-07 20:06:49 +00:00
e522539e2d 2.00.33 2005-01-07 19:50:54 +00:00
7c996b83d2 post-1.00.21 2005-01-07 17:10:16 +00:00
3dd354d7aa 1.00.21 2005-01-07 15:53:37 +00:00
f4ad6e2157 Fix /proc/devices parsing. 2005-01-07 15:39:53 +00:00
8b170dc2bf Fix off-by-one error in cluster_locking that could case read hangs. 2005-01-07 14:22:49 +00:00
dcb9d779bf post-1.00.20 2005-01-06 18:41:38 +00:00
80f736d670 1.00.20 2005-01-06 18:30:17 +00:00
8502c6da3c Attempt to fix /dev/mapper/control transparently if it's wrong. 2005-01-06 18:22:44 +00:00
b131449422 Some more gulm fixes from "Mr gulm" himself. 2005-01-06 11:48:25 +00:00
6eebc4a620 Configuration-time option for setting uid/gid/mode for /dev/mapper nodes. 2005-01-05 22:00:40 +00:00
4661ab1179 pvcreate wipes first 4 sectors unless given --zero n. 2005-01-05 17:25:25 +00:00
86046445ed Improve clvmd failure message if it's already running.
Allow user to kill clvmd during initialisation.
2005-01-05 14:41:54 +00:00
baea9bf944 Typo in "for" caused first node in ccs to be ignored. 2005-01-04 15:11:34 +00:00
0951ee9e63 Use new CCS key names for nodes in the GULM version of clvmd.
based on a patch from Mike Tilstra
2005-01-04 11:48:10 +00:00
5492528287 post-2.00.32 2004-12-22 22:04:03 +00:00
14dbd220c2 update pofile 2004-12-22 21:58:26 +00:00
babc890c59 Drop static/dl config restriction for now. 2004-12-22 21:55:36 +00:00
6f7b47ff40 update version 2004-12-22 21:47:50 +00:00
3991f03202 Fix an error fprintf. 2004-12-22 21:47:31 +00:00
27271d5da7 Fix vgdisplay -s. Breaks (undocumented) lvs/pvs/vgs -s instead for now. 2004-12-21 21:40:36 +00:00
627312e1de Fix device reference counting on re-opens. 2004-12-21 20:23:16 +00:00
bfc9550e4e Ignore sysfs symlinks when DT_UNKNOWN. 2004-12-21 18:29:46 +00:00
2b9c21268b Add RHEL4 clvmd init script. 2004-12-21 18:07:15 +00:00
3dce4ed6f1 Skip devices that are too small to be PVs. 2004-12-21 17:54:52 +00:00
0f16c2ea87 Add CONTRIBUTORS file. 2004-12-21 16:24:19 +00:00
9a635f0686 Fix pvchange -x segfault with lvm2-format orphan. 2004-12-21 16:12:02 +00:00
6a0d4b2baa Cope with empty msdos partition tables. 2004-12-21 16:10:25 +00:00
ac017098ad post-2.00.31 2004-12-12 21:55:46 +00:00
98fef2640d update pofile 2004-12-12 21:51:59 +00:00
8bb66e133a 2.00.31 2004-12-12 21:47:55 +00:00
68a582901d Reopen RO file descriptor RW if necessary. 2004-12-12 21:47:14 +00:00
c094f4c06e post-2.00.30 2004-12-10 18:01:49 +00:00
f7ca545544 update pofile 2004-12-10 16:07:37 +00:00
69b4716894 2.00.30 2004-12-10 16:02:35 +00:00
7e44dcc5bf Additional device-handling debug messages.
Additional verbosity level -vvvv includes line numbers and backtraces.
Verbose messages now go to stderr not stdout.
Close any stray file descriptors before starting.
Refine partitionable checks for certain device types.
Allow devices/types to override built-ins.
2004-12-10 16:01:35 +00:00
ab9843e183 Fix lvreduce man page .i->.I 2004-12-09 16:59:18 +00:00
01af706ade Fix vgsplit man page title. 2004-12-09 16:58:31 +00:00
9ebdb08e99 Fix clvmd man makefile. 2004-12-09 16:57:37 +00:00
a74ffe25d9 Extend dev_open logging. 2004-12-09 16:56:51 +00:00
7f95e27707 Make clvmd_fix_conf.sh UNDOable 2004-12-01 14:47:31 +00:00
1facf5bba3 post-29 2004-11-27 22:56:58 +00:00
03d77009eb xlate compilation fix 2004-11-27 22:07:41 +00:00
8afd6812b5 update version 2004-11-27 21:38:34 +00:00
ec9ad78fcf Endian fix to signature detection. 2004-11-27 21:37:54 +00:00
6f4e93dc90 Configure/makefile tidy. 2004-11-26 18:07:17 +00:00
a38e43862d fix partition table signature size 2004-11-26 14:40:34 +00:00
39294bb037 update pofile 2004-11-24 21:39:30 +00:00
edc5e59b78 Trap large memory allocation requests. 2004-11-24 21:34:56 +00:00
c00fd9fd37 Fix to partition table detection code. 2004-11-24 20:38:05 +00:00
b3e621dd9f Improve filter debug msgs. 2004-11-24 20:36:52 +00:00
6e8c49b978 post-release 2004-11-23 18:36:01 +00:00
398d57133d update po 2004-11-23 18:27:57 +00:00
16521a6feb pool debugging 2004-11-23 18:23:23 +00:00
3ca0b37a3e 2.00.26 2004-11-23 17:47:19 +00:00
cf2ec1229d fix a md filter log mesg 2004-11-23 17:45:48 +00:00
fe9b1e5f9b update pofile 2004-11-23 17:44:10 +00:00
f5b96ddf01 Detect partition table signature. 2004-11-23 11:44:04 +00:00
2fe076fb27 Only wipe signature bytes when destroying md superblock, so process
is reversible.
2004-11-19 19:32:09 +00:00
99249cff04 pvcreate wipes md superblocks. (With --uuid or --restorefile it prompts.) 2004-11-19 19:25:07 +00:00
0cdf7b0613 Separate out md superblock detection code. 2004-11-18 20:02:21 +00:00
90bcf4f157 Prevent snapshot origin resizing. 2004-11-18 19:49:48 +00:00
03c3ec4e12 Improve a vgremove error message. 2004-11-18 19:45:53 +00:00
ca9bb20d64 More tagging documentation, with some cluster examples. 2004-11-17 18:34:49 +00:00
c6bc078fd9 More lvm.conf and tagging documentation. 2004-11-17 17:49:32 +00:00
2f4bd6e52c More man page updates. 2004-11-16 18:09:32 +00:00
2affe53727 Tidy the socket callbacks so that all the work is done outside the
main loop.
2004-11-16 10:55:01 +00:00
09654d7dd8 update WHATS_NEW 2004-11-12 16:02:08 +00:00
90a4e37815 Update some man pages. 2004-11-12 15:59:09 +00:00
60889c0c79 Also accept y/n with -ae. 2004-11-12 15:58:26 +00:00
20f3408d96 Report detailed errors in cluster initialisation to syslog, and point the user
at syslog if clvmd fails to intialise.
2004-11-11 14:51:23 +00:00
e9d86789db Can now build a gulm version of clvmd instead of a cman one. use
./configure --with-clvmd=gulm

The default is still cman, and you can't have both - sorry.
2004-11-03 10:45:07 +00:00
5152b7c66c update 2004-10-15 17:31:37 +00:00
c494c4e12c Fixes to lvcreate vgname processing. 2004-10-15 15:53:18 +00:00
54d58ccb7e Add --noheadings option to dmsetup -c for colon-separated output. 2004-10-12 16:42:40 +00:00
714a77bfbe Fix size of dm_name string. 2004-10-11 15:59:23 +00:00
d48f8bf5cc Make clvmd -V display the lvm version number too rather than just
the protocol version (which is not that useful and doesn't change very often).
2004-10-06 12:36:47 +00:00
99d97754a6 Revert the fork back to where it was as it seems to confuse pthreads.
Instead, the parent now waits for the daemon to signal that it has
completed successfully (or not) so it can return status to the user.
2004-10-06 10:12:34 +00:00
b9d437de2a Change some perror() calls to log_error() so they'll appear in
syslog when we're a daemon.
2004-10-06 10:02:25 +00:00
11403f2019 Check the UUID length when readingthe output of the "lvs" command at startup.
This way we should not get quite so confused by any debugging output
that may come our way.
2004-10-04 09:23:52 +00:00
1ca102d639 Support device referencing by uuid or major/minor. 2004-10-01 19:11:37 +00:00
339ba55111 printf->fprintf 2004-10-01 19:07:41 +00:00
14ae59885a Make clvmd cope with large gaps in nodeIDs 2004-09-30 14:18:29 +00:00
e3ef54f99b Fork a little later in the startup sequence so that we can return
an error code if the cluster infrastructure isn't there.
2004-09-30 14:16:28 +00:00
001901f9a9 post-2.00.25 2004-09-29 15:25:43 +00:00
6a98f60e2e 2.00.25 2004-09-29 15:08:20 +00:00
6f2e24c47d Use macro in vgremove locking fix. 2004-09-27 10:32:36 +00:00
aafa368923 Hold VG lock while doing vgremove.
agk - you may want to check this.
2004-09-24 12:48:43 +00:00
eb783cab4c Remove spurious trailing dot in man page. 2004-09-24 10:34:53 +00:00
6533aa865a Keep client locks (VG locks usually) in their own hash table so
we can actually have more then one of them per client.
2004-09-24 09:39:57 +00:00
f1a1e1bc07 Update WHATS_NEW with latest clvmd change 2004-09-23 13:12:09 +00:00
953f4838dd Make the thread handling a little less cavalier. In particular, calling
pthread_exit in a signal handler was a /really/ bad idea.
2004-09-23 12:51:56 +00:00
130b892d34 Don't use hold_lock for VG locks as that doesn't stop processes contending
on the same node, only across the cluster.
2004-09-23 12:29:35 +00:00
6ad525c77e Fix return code from rm_link for vgmknodes. 2004-09-22 13:38:37 +00:00
d0ca74ad27 Put some locking round the LV hash table as it could be accessed by
different threads concurrently.
2004-09-22 12:10:34 +00:00
9806f69b4d post-2.00.24 2004-09-16 21:48:26 +00:00
34d9b5e3d7 2.00.24 2004-09-16 20:56:18 +00:00
3bf5189d86 Fix pool_empty so it really does empty the memory pool. 2004-09-16 20:09:55 +00:00
12e5b0681b Rename old segtypes files to segtype. 2004-09-16 18:40:56 +00:00
8c0285d608 Some fixes to memory debugging code.
Exclude internal commands formats & segtypes from install.
2004-09-16 16:53:39 +00:00
36558fa3b8 post-2.00.23 2004-09-15 15:59:19 +00:00
235f940cde 2.00.23 2004-09-15 15:32:21 +00:00
803d61fcbc Add formats & segtypes files. 2004-09-15 15:27:26 +00:00
ffbd7d8de4 Export dm name build & split functions. 2004-09-15 15:02:36 +00:00
4ed924d7c7 Use O_NOATIME on devices if available. 2004-09-14 22:23:23 +00:00
798dc9948b Write log message when each segtype/format gets initialised. 2004-09-14 17:37:51 +00:00
13515f7ee4 New commands 'segtypes' and 'formats'. 2004-09-14 16:42:46 +00:00
ef80824c26 Suppress pvmove abort message in test mode. 2004-09-14 15:23:42 +00:00
c8503fd65e Improve pvcreate/remove device not found error message. 2004-09-14 14:54:58 +00:00
b3c454fb1c Allow pvmove to move data within the same PV. 2004-09-14 13:59:17 +00:00
1d7723e873 Describe how pvmove works on man page. 2004-09-14 13:58:11 +00:00
77100b2365 Test for incompatible format/segtype combinations in lv_extend. 2004-09-14 13:56:18 +00:00
259a788134 Fix man page for lvchange. The example seems to have been lifted from pvchange. 2004-09-13 08:01:54 +00:00
39511455cb post 2.00.22 2004-09-03 19:18:23 +00:00
b04c16178e 2.00.22 2004-09-03 19:08:50 +00:00
49a959c06e Fix /dev/vgname mkdir perms. 2004-09-02 14:38:46 +00:00
096a8932b4 clvmd man page tweaks 2004-09-02 14:16:54 +00:00
e39e66df93 Restructure xlate.h 2004-09-02 13:53:25 +00:00
513633f49a clvmd man page. 2004-08-23 08:42:53 +00:00
eb3740daaf post-2.4.21 2004-08-19 17:13:49 +00:00
f7947b148a 2.00.21 2004-08-19 16:10:15 +00:00
9a2a702f3f Recognise iseries/vd devices. 2004-08-18 19:13:01 +00:00
c65d95bf29 Cluster-extension-only installation. 2004-08-18 18:57:40 +00:00
753a5edc4f Cope with DT_UNKNOWN in sysfs. 2004-08-18 18:50:21 +00:00
0b3f853c2d Update pvmove prototype. 2004-08-18 18:49:29 +00:00
3527fcf1d5 Updated file from cman. 2004-08-18 16:04:35 +00:00
4544a89c7a Support for PE ranges in pvmove source PV. 2004-08-17 22:09:02 +00:00
ffeae9005e Remove duplicate line in pvremove help text. 2004-08-17 22:06:06 +00:00
47217bcfb7 Change alloc_areas to pe_ranges and allow suppression of availability checks. 2004-08-17 21:55:23 +00:00
80ff58b57a Add a const. 2004-08-11 13:15:35 +00:00
d15dd368f1 Add dev_size column to pvs. 2004-08-11 13:15:05 +00:00
8a2ec32bd8 Add report columns for in-kernel device number. 2004-07-03 22:07:52 +00:00
410496ed52 update version 2004-07-03 18:29:48 +00:00
b7b07552e5 Misc autoconf fixes 2004-07-03 18:21:13 +00:00
44486e80d9 Fix ftp urls 2004-07-03 18:20:25 +00:00
7890c527d8 misc autoconf fixes 2004-07-03 18:17:32 +00:00
2c82ab79a7 fix a newline 2004-07-03 18:15:14 +00:00
e3ebe5fc53 set_selinux_context() return code fix 2004-07-03 18:14:12 +00:00
0ac430892e Fix device number handling for 2.6 kernels. 2004-07-01 15:14:29 +00:00
a7739c942c update version 2004-06-29 13:46:44 +00:00
24581482d0 make -O2 optimisation flag configurable. 2004-06-29 13:29:25 +00:00
0571c3b453 Reduce severity of setlocale failure message (ie suppress during boot). 2004-06-29 13:28:57 +00:00
73e7f5a0b0 Add initrd-lvm to list of recognised argv[0]s. [pld-linux] 2004-06-29 13:27:19 +00:00
20c0adb961 Fix LD_FLAGS->LDFLAGS. LD_DEPS->LDDEPS.
Update configure script: add --disable-selinux & some missing messages.
2004-06-28 14:01:24 +00:00
a01e03562f Make sure errors reach syslog(). 2004-06-28 10:26:42 +00:00
d184ed0130 update version 2004-06-25 10:31:04 +00:00
089e1c2aee Fix vgchange (de)activation of (open) LVs. 2004-06-24 14:48:01 +00:00
ebab0e91ee Missing .exported_symbols 2004-06-24 08:16:09 +00:00
858a2b1b88 Add cluster support. 2004-06-24 08:02:38 +00:00
02bd59827c Remove pv segments line from backport. 2004-06-20 15:14:31 +00:00
4991428510 Fix targets string size calc in driver.
Fix a uuid free in libdm-iface. [Eric Taylor]
Update version.
2004-06-20 13:50:42 +00:00
3b245f5dc1 fsadm configurable (default disabled as untested)
version update
2004-06-20 13:38:54 +00:00
c9c81da901 Display all filtered devices, not just PVs, with pvs -a. 2004-06-19 19:27:00 +00:00
4919cdc3fb Fix sync_dir() when no / in filename. 2004-06-19 19:24:33 +00:00
e90e1f577d vgcfgbackup -f accepts template with %s for VG name. 2004-06-19 18:55:29 +00:00
afd4284403 Extend hash functions to handle non-null-terminated data. 2004-06-18 15:08:22 +00:00
150b350d31 Add local activation support. 2004-06-16 17:13:41 +00:00
2818520bd1 Add dmsetup -C for column-based output. 2004-06-16 16:44:12 +00:00
2819952292 fsadm 2004-06-15 17:29:20 +00:00
5af71af51c tidy relative paths in makefile includes 2004-06-15 17:25:07 +00:00
07a55b51df lvresize + fsadm support - needs testing 2004-06-15 17:23:49 +00:00
66dd68b49d Clear message buffer before use. 2004-06-10 16:14:16 +00:00
9812657777 Support new target message ioctl. 2004-06-08 20:34:40 +00:00
0b09312fc6 mark pool support read-only; fix makefile typo 2004-06-07 19:26:13 +00:00
d0a7ac6b74 Add read-only GFS pool support. 2004-06-07 19:10:21 +00:00
ff9a238fbd lvm2create_initrd submitted by Jeff Layton <jtlayton@poochiereds.net>
sourced from http://poochiereds.net/svn/lvm2/
2004-06-07 16:20:05 +00:00
359fffa5f1 Fix rounding of large displayed sizes. 2004-06-07 15:22:43 +00:00
5bf92ced1a i2o_block 2004-06-01 18:33:50 +00:00
340bcc7b45 Suppress decimal point when using units of sectors/bytes. 2004-05-28 12:47:57 +00:00
ef03742bd4 Additional kernel target checks before pvmove & snapshot creation. 2004-05-24 20:51:56 +00:00
20431ec16d v2.00.16 2004-05-24 19:20:57 +00:00
becba8157b Set area_count within alloc_lv_segment 2004-05-24 17:30:00 +00:00
51fd3bb0eb Remove error labels. 2004-05-24 15:58:50 +00:00
4bbd3acb4e Fix a pvs error path. 2004-05-24 14:14:10 +00:00
3bc930ea7b xxchange -ae to activation exclusively 2004-05-24 13:44:10 +00:00
d1b26f8e86 Don't return non-zero status if there aren't any volume groups 2004-05-20 16:18:58 +00:00
fdf15caaff Rename allocation policies; add --alloc to cmdline; LV inherits from VG. 2004-05-18 22:12:53 +00:00
c7b4a53c0b Add reset_fn to external_locking. 2004-05-18 21:57:24 +00:00
af78dc0308 indent 2004-05-18 21:55:55 +00:00
5ad39493c4 Ensure presence of virtual targets before attempting activation. 2004-05-12 20:43:34 +00:00
61f597b408 Attempt to fix resizing of snapshot origins. 2004-05-12 20:40:34 +00:00
2162825240 Restructure lvresize, bringing it closer to lvcreate. 2004-05-11 18:47:40 +00:00
2b780e70d1 indent 2004-05-11 18:45:11 +00:00
a3823f818e update comment 2004-05-11 18:18:14 +00:00
1f7c47bcaf A quick sanity check on vg_disk struct when read in. More checks needed. 2004-05-11 17:18:42 +00:00
ec53c365a2 Only include visible LVs in active/open counts. 2004-05-11 17:09:09 +00:00
793ad1f2d4 Add --type to lvcreate/resize.
Add virtual segment types, zero and error.

A large sparse device can be constructed as a writeable snapshot of a large
zero device.
2004-05-11 16:01:58 +00:00
9bc733b76c Push lv_create & alloc policy up to tool level. 2004-05-05 18:49:21 +00:00
21b28f0217 fix return code 2004-05-05 18:39:30 +00:00
d3e23caa52 comments 2004-05-05 18:35:04 +00:00
9e7518de67 Skip mirror LV. Comments. 2004-05-05 18:33:01 +00:00
679f0047aa Detect invalid LV names in arg lists. 2004-05-05 18:31:38 +00:00
d77d5ce14b stray space 2004-05-05 18:27:56 +00:00
33ec22a2af Reporting uses line-at-a-time output. 2004-05-05 18:23:11 +00:00
353053225f lvm2 format sets unlimited_vols format flag. 2004-05-05 18:17:48 +00:00
b7f3d6f7f7 Internal-only metadata flag support. 2004-05-05 18:15:47 +00:00
e34577499d Some basic checking for presence of device-mapper targets. 2004-05-05 18:11:43 +00:00
4cf8960c0c Separate out polldaemon. 2004-05-05 17:56:20 +00:00
1f93ea0675 Revise internal locking semantics. 2004-05-05 12:03:07 +00:00
25b705c3a8 move find_pv_by_name to lib 2004-05-05 11:04:28 +00:00
0725588731 Add devices to segments report; some move->copy renaming. 2004-05-05 10:58:44 +00:00
fc5c61cc8b Begin to separate out segment types. 2004-05-04 21:25:57 +00:00
ac282e63c6 Compress any (obsolete) long LVM1 pvids encountered. 2004-05-04 18:38:11 +00:00
c3941941ce Support tagged config files. 2004-05-04 18:28:15 +00:00
46cdd53323 Don't abort operations if selinux is present but disabled. 2004-05-04 15:29:26 +00:00
3ff3e302c3 Missing $ => HAVE_LIBDL unset 2004-05-04 12:14:20 +00:00
f2ceecf95c fix selinux library linking 2004-04-19 14:01:23 +00:00
9314c7c881 config option to avoid using install -o -g 2004-04-19 13:10:06 +00:00
54abb2c572 Use 64-bit file functions. 2004-04-16 18:43:29 +00:00
8fa3bdd025 Set devices/md_component_detection = 1 to ignore devices containing md
superblocks. [Luca Berra]
2004-04-16 16:12:04 +00:00
5e7a308528 Ignore error setting selinux file context if fs doesn't support it. 2004-04-16 12:24:46 +00:00
7952177786 2.00.12 2004-04-14 20:09:25 +00:00
9afbe49c84 update 2004-04-14 18:31:35 +00:00
9f06ba2db3 fix selinux error mesg 2004-04-14 18:10:10 +00:00
fe55bfddcf lvm.static can be installed in different dir from rest of tools 2004-04-14 18:00:23 +00:00
c0842e6444 Install example config file by default if there isn't one already. 2004-04-14 17:39:55 +00:00
3fed20d06a Add power2 2004-04-14 17:33:51 +00:00
5e8f2e2c04 Fix lvs_in_vg_opened counting. 2004-04-14 17:33:04 +00:00
e4df99ea84 fix patch that misapplied 2004-04-08 17:21:01 +00:00
b3276f5f11 Update version 2004-04-08 17:14:00 +00:00
32667ca256 Option for auto-fallback to LVM1 tools if running 2.4 without device-mapper. 2004-04-08 15:23:23 +00:00
bed122a170 update for 2.00.10 2004-04-07 18:12:51 +00:00
14adc9b875 Basic selinux support 2004-04-07 14:08:22 +00:00
a8778bbc5a Fix status overflow check in kernel patches. 2004-04-07 12:39:59 +00:00
a54e641f44 fix static selinux build 2004-04-06 20:32:02 +00:00
5c99efe87a 1.00.13 2004-04-06 18:57:13 +00:00
7da1d731ff add some selinux support 2004-04-06 18:54:00 +00:00
af9828e819 Fix sysfs filter to check fs type. 2004-04-06 16:47:59 +00:00
7a27136142 Update to 2.00.10 2004-04-06 15:17:53 +00:00
012ad2d423 More build fixes 2004-04-06 15:14:23 +00:00
ef3bdbf4da Fix dmsetup.static install. 2004-04-06 12:06:55 +00:00
b3bb698f7b Version 1.00.11 2004-04-05 20:51:42 +00:00
1ed5d1e4c1 Combine static/dynamic build. 2004-04-05 20:48:14 +00:00
bdee01a03d Fix shared format1 build. 2004-04-05 16:29:37 +00:00
458f7376d7 accept argv[0] lvm.static 2004-04-05 16:24:17 +00:00
cb3a00e027 Move library targets definition into template. 2004-04-05 16:20:50 +00:00
482eb1f3fb update for 1.00.10 2004-04-02 16:47:43 +00:00
6e0f638f5e Build process fixes/tidy-ups. 2004-04-02 15:18:38 +00:00
bab349047d updates for release 2004-03-31 20:14:02 +00:00
28ea6b8de8 update text for release 2004-03-31 20:09:56 +00:00
9d51bbdae8 Update VERSION 2004-03-31 19:12:17 +00:00
d622f79533 Add 2.4 support for DM_LIST_VERSIONS (dmsetup targets).
Rebaseline patches to 2.4.26-rc1.
2004-03-31 18:54:17 +00:00
04c8515ad1 Missing dev_close_all()s 2004-03-31 18:41:39 +00:00
53bc4251d1 Update changelog. 2004-03-30 20:33:26 +00:00
a5a751f02f Example cmdlib program. 2004-03-30 19:54:59 +00:00
66ed5f82c4 Update copyright notices. 2004-03-30 19:35:44 +00:00
c802a9e6aa Update changelog. 2004-03-30 19:12:42 +00:00
880f210946 Update copyright messages. 2004-03-30 19:08:57 +00:00
4f9f7eb6a6 Fix vgmknodes to remove dud /dev/mapper entries 2004-03-30 14:40:03 +00:00
f910c4a8e7 Rename dev_manager_mknodes -> dev_manager_lv_mknodes etc. 2004-03-30 14:38:57 +00:00
529686d965 spelling corrections 2004-03-30 14:36:50 +00:00
84dfd1536f vgdisplay_colons 2004-03-30 14:35:40 +00:00
85dedc324c Move full mknodes functionality from dmsetup into libdevmapper. 2004-03-30 14:31:58 +00:00
d639237411 and another typo 2004-03-26 21:49:57 +00:00
449aaf75f1 typo 2004-03-26 21:47:43 +00:00
b1fda66caa missing definition 2004-03-26 21:46:01 +00:00
66a8e90fd9 lvchange --refresh 2004-03-26 21:24:03 +00:00
37b487d191 tweak memlock includes 2004-03-26 21:11:34 +00:00
6c59fe3577 Add string display to mem leak dump. 2004-03-26 21:09:44 +00:00
1cbb70c992 indent 2004-03-26 21:07:30 +00:00
e06b39f882 move lock_lvs; add lock memlock code 2004-03-26 20:49:35 +00:00
2602b1493e LV allocation variable renaming 2004-03-26 20:35:14 +00:00
989d14502d Add locking flags + memlock option. 2004-03-26 20:17:11 +00:00
f78a550282 makefile spacing 2004-03-26 20:03:58 +00:00
54a1abb284 Add list_versions to library 2004-03-26 19:52:09 +00:00
97b492a8e2 Ignore open hidden LVs when checking if deactivation is OK. 2004-03-26 19:13:39 +00:00
0873bd14a9 Suppress move percentage when inactive 2004-03-26 19:10:48 +00:00
eff6ba429a Tidy sysfs includes 2004-03-26 18:54:55 +00:00
8c18064be4 indent 2004-03-26 15:46:37 +00:00
44a1ac0cf3 lv_info_by_lvid 2004-03-26 15:35:01 +00:00
28dc8d88dd cmdlib prototypes 2004-03-26 14:56:41 +00:00
2c0c2b64ba .export.sym generation 2004-03-26 14:51:23 +00:00
bd3e0f5248 cmdlib logging function 2004-03-26 14:47:14 +00:00
cd52d98938 update configure for cmdlib 2004-03-26 14:17:14 +00:00
894c70e7f8 Update makefiles (incl. cmdlib). 2004-03-26 13:21:12 +00:00
51d70c2edd Rename some files to avoid duplicate filenames in tree. 2004-03-26 12:25:15 +00:00
7d4b355240 Add cmdlib code. 2004-03-26 12:21:24 +00:00
3b56193b98 Add --nolocking option for read operations if locking is failing/unavailable. 2004-03-26 12:09:33 +00:00
b16045b57d Move main() into separate file. 2004-03-26 12:00:24 +00:00
9e8b0fca5b Indent; _init -> _init_lvm 2004-03-26 11:49:07 +00:00
35cf1b3b5b Rebaseline internal verbose level. 2004-03-26 11:45:01 +00:00
83f788af57 Document metadata tagging. 2004-03-22 15:08:50 +00:00
2ffe378d3f Only print warning message once when compiled without libdevmapper. 2004-03-19 16:26:46 +00:00
38b33a4a5e Fix lvreduce pv extents calculations. 2004-03-19 16:19:41 +00:00
60bf9ed0a0 Avoid sscanf %as for uClibc 2004-03-19 15:52:22 +00:00
16adf4de1b Fix DESTDIR with configure path overrides. 2004-03-17 19:37:44 +00:00
80de983023 additional activation functions 2004-03-08 18:54:13 +00:00
8703ca623f rename config file vars & always use / as separator 2004-03-08 18:28:45 +00:00
286253a73f host tags 2004-03-08 18:13:22 +00:00
bd806a41df move hostname into global 2004-03-08 17:25:59 +00:00
b89c4e9002 tagging 2004-03-08 17:19:15 +00:00
6dbf31c0c3 More str_list fns. 2004-03-08 15:23:01 +00:00
060c45d8a1 Fix (rare) bug in recognition of long argument forms. 2004-03-08 13:54:45 +00:00
33d3e82e4d Detailed changelog. 2004-02-27 22:36:13 +00:00
4bb074514d Update man page incl. 'targets', event_nr. 2004-02-27 19:36:49 +00:00
e3f8892003 more syncing with lvm2 build process 2004-02-24 19:23:28 +00:00
9d00ad5f18 Extract log.h and tweak funcs to be like lvm2 ones. 2004-02-24 18:50:09 +00:00
dae4344850 more makefile syncing 2004-02-24 18:46:20 +00:00
aa7f3fabe2 File missed from last checkin. 2004-02-18 13:06:21 +00:00
f93434a8ce Basic internationalisation support. 2004-02-13 22:56:45 +00:00
25dee56be9 Don't recurse symlinked dirs such as /dev/fd on 2.6. 2004-02-13 18:55:43 +00:00
ce9a3f3797 Update autoconf files 2004-02-13 16:00:22 +00:00
11e384920a don't inline pool_zalloc(); lift duplicated pool_str(n)dup to pool.c 2004-02-13 15:38:54 +00:00
a0a1f1e536 Don't inline hash _find 2004-02-13 15:36:58 +00:00
3b3d0ea9eb Sysfs block device filtering option for 2.6. 2004-02-13 14:46:04 +00:00
2f4d78286d split_words() 2004-02-13 14:43:35 +00:00
677dc6f985 Update CVS info for move to sources.redhat.com. 2004-02-10 15:26:51 +00:00
d52057e732 Static build too. 2004-01-28 03:40:31 +00:00
fa2a1cb1fb Define BLKGETSIZE64 on systems with out-of-date header files. 2004-01-27 20:53:57 +00:00
19a0fb04ad Userspace support for LIST_VERSIONS ioctl. 2004-01-23 14:37:47 +00:00
947352f2fe Add event number arg to dmsetup wait. 2004-01-23 14:09:33 +00:00
adcbedb686 Document that sector size is always 512 bytes. [AJ] 2004-01-23 14:08:09 +00:00
7732f92acd pv/vgchange --uuid to change (non-random) UUIDs to random values 2004-01-13 18:42:05 +00:00
ad8a001688 If PV/VG uuids are missing, generate them from the pv/vg numbers.
[This situation could occur if the uuids were oritinally created by
LVM1 on a system without /dev/urandom.]
2004-01-09 19:18:20 +00:00
9121eada08 Log full details when "VG data differs between PVs" error message occurs. 2004-01-02 14:04:44 +00:00
49bd4d25a2 Option to revert to default logging function after using a custom one. 2003-12-21 16:08:20 +00:00
d80b4129c6 Change pvscan to show total of usable device size (instead of free data space). 2003-12-09 22:32:47 +00:00
7edb4172d5 Remove undocumented -m abbreviation. 2003-12-09 22:17:17 +00:00
c3a4677990 Relax restriction on pe_start location when re-writing LVM1 metadata. 2003-12-09 17:51:39 +00:00
5cbb893a3b Fix support for PVs on read only devices. [Still must set LVs read only] 2003-11-21 19:54:40 +00:00
f28a2a432b dumpconfig 2003-11-21 19:53:05 +00:00
03b75a2d27 Don't remove mirror LV until after other LVs reloaded. 2003-11-20 16:22:04 +00:00
859fe69083 Update dmsetup man. 2003-11-17 14:24:22 +00:00
f6f2205ddb Ready for another release. 2003-11-14 23:46:49 +00:00
0f9a03ef61 lvcreate should close the initialised snapshot device immediately. 2003-11-14 17:55:39 +00:00
9aa417c084 Add/update some man pages. 2003-11-14 16:17:55 +00:00
7b70952f5d vgscan --mknodes 2003-11-14 14:03:48 +00:00
edd3d07b49 Fix dev_zero() offset. 2003-11-13 23:55:03 +00:00
5293d0a4ec Immediate error on big memory allocations when --enable-debug. 2003-11-13 23:54:02 +00:00
3c8c7beae1 Missing include. 2003-11-13 18:47:22 +00:00
9c3ba9fdcd vgmknodes also creates necessary nodes in /dev/mapper 2003-11-13 14:11:41 +00:00
fb1748fb0f dmsetup mknodes 2003-11-13 13:14:28 +00:00
0a109fbd03 The LVM2 part of vgmknodes [still to do the non-devfs device-mapper bit]. 2003-11-12 19:16:48 +00:00
5cf64db74e Accept tables from stdin with dmsetup.
Update autoconf.
2003-11-12 17:30:32 +00:00
488cc94f36 Exclude v1 compatibility code when configured with --disable-compat
[Use this with 2.6 kernels + device-mapper V4 interface]
CVS ----------------------------------------------------------------------
2003-11-10 21:06:16 +00:00
e15846bf79 Default to unlimited number of LVs/PVs in lvm2 format. 2003-11-06 20:33:34 +00:00
752bd00674 Prevent PV allocation bit getting changed for format_text orphans. 2003-11-06 20:15:13 +00:00
7fadfcbe32 Fix vgremove 'all OK' check 2003-11-06 17:16:22 +00:00
41141e75bb Configuration-time O_DIRECT setting. 2003-11-06 17:14:06 +00:00
50f641e627 Add drbd. 2003-11-06 17:10:35 +00:00
c7883fd093 Fit locking bits into 1 byte. 2003-11-06 17:08:18 +00:00
4fcb24b2b1 Ban vgcreate -s 0 2003-11-06 17:07:19 +00:00
5003557935 Fix pvchange segfault with orphans. 2003-11-06 17:06:06 +00:00
bdf1ba84da Don't trigger error if changing PV allocation to the state it already is. 2003-11-06 17:04:35 +00:00
b0b4def983 Cope better with LVM1 minor numbers & LV numbers. 2003-11-06 16:58:38 +00:00
cc184bbe9e Fix exported format1 VG recognition. 2003-10-21 22:21:41 +00:00
ad30c830aa More consistent error code usage. 2003-10-21 22:06:07 +00:00
1d791a8af4 Check no fs mounted before deactivating. 2003-10-21 22:00:36 +00:00
e63c51cd97 Inherit CFLAGS at make time 2003-10-21 21:59:42 +00:00
f202e32908 Dump active configuration 2003-10-15 20:19:43 +00:00
26e1a08e82 dumpconfig to dump active configuration 2003-10-15 20:17:19 +00:00
4d5119d435 relax a scanning restriction 2003-10-15 20:10:11 +00:00
75e34ea62e Fix >32bit lvcreate size calculation. 2003-10-15 20:07:55 +00:00
0a183d6274 Prevent creation of MDA bigger than disk. 2003-10-15 20:06:37 +00:00
21d8060aea Don't forget to set 64-bit arg values too. 2003-10-15 20:05:30 +00:00
9cbe906f60 more str_list fns 2003-10-15 20:04:29 +00:00
8ce4137399 macro changes 2003-10-15 20:02:46 +00:00
5f8a139347 str_list_del 2003-10-15 20:01:12 +00:00
9bb009a3fe Extract some common functions. 2003-09-17 20:35:57 +00:00
726d65923f Update to incorporate most of version 4 interface changes. 2003-09-17 13:23:49 +00:00
8a6be4cb2d Remove incorrect comments. 2003-09-16 16:23:21 +00:00
10b06beb8e out-of-date 2003-09-16 16:18:50 +00:00
81318c7968 Update 2003-09-16 16:15:07 +00:00
47a2c1c6e5 Fix read-only snapshot creation. 2003-09-16 16:08:05 +00:00
39cee65c6b Make dev_name optional to show details for all devices.
e.g. 'dmsetup info', 'dmsetup status -v', 'dmsetup table'
2003-09-16 14:13:51 +00:00
8582ec724e Improve segment merge/split code. 2003-09-15 18:22:50 +00:00
b0139682e8 Don't install the pvdata stub; update built-in mesg. 2003-09-15 15:05:23 +00:00
d39c475a6d Ensure more args aren't negative. 2003-09-15 15:04:39 +00:00
48f38354c6 Missing vg_commit() 2003-09-15 15:03:54 +00:00
cd5a920ed5 vgcfgrestore -l lists backup file too 2003-09-15 15:03:22 +00:00
71bc1f378d Prevent cmdline flags that take args getting repeated. 2003-09-15 15:02:24 +00:00
0ee6c31cff Missing ] in pvmove usage display 2003-09-15 15:01:36 +00:00
af89a9971e Generalise 'invalid chars' error mesg to just say 'invalid' 2003-09-15 15:01:00 +00:00
c718a8ef72 Correct order of consistency/exists checks. 2003-09-15 15:00:01 +00:00
8c8ad0faf0 Don't use !# in randomly-generated uuids. 2003-09-15 14:58:43 +00:00
314d5bbb7f Fix makefile install mesg displayed for man5 2003-09-15 14:57:15 +00:00
102255757a Additional validation of LV segments read from metadata. [HM] 2003-09-01 19:55:16 +00:00
914067a0d0 Fix unsafe list iteration in segment merge code. [HM] 2003-08-27 15:30:39 +00:00
06e3ae2536 Remove unnecessary file. 2003-08-26 21:12:45 +00:00
7f9b252556 Cope better when format functions are missing. 2003-08-26 21:12:06 +00:00
3d700e243f Log each command & args. 2003-08-26 21:00:05 +00:00
bcfc78ce11 Update. 2003-08-20 15:48:46 +00:00
09241765d5 Some tidyups and minor fixes. 2003-08-20 15:48:27 +00:00
671c83c265 Remove small hard-coded activation target line parameter limit. 2003-08-20 12:53:57 +00:00
772d28b766 Also allow pvmove --abort when pvmove mirror not active (e.g. after a reboot). 2003-08-18 17:21:51 +00:00
c26fcea58d Missing check for inconsistent VG in pvmove. 2003-08-18 13:52:43 +00:00
1e5e26dbff update 2003-07-18 00:41:04 +00:00
742fc54864 Accept signed numbers in config file. 2003-07-15 16:32:20 +00:00
49738f43c0 update 2003-07-15 01:30:18 +00:00
9f85f61010 Fix vgimport fix to work outside debug mode. 2003-07-15 01:26:24 +00:00
239f422039 update 2003-07-13 11:07:50 +00:00
67af3c37be Fix detection of exported LVM1 volume groups. 2003-07-13 11:07:25 +00:00
a9442385c4 vsn 2.00.02 (rc3) 2003-07-12 12:02:12 +00:00
8c9cd10b8b Restrict active lvchange -My with -f 2003-07-11 17:10:19 +00:00
72542059dd Fix inactive snapshot display. 2003-07-11 17:09:21 +00:00
a843fc6d40 update 2003-07-05 23:27:17 +00:00
4beed60c08 Driver version 1 compatibility fix for snapshots. 2003-07-05 23:24:10 +00:00
4049c1e480 Backwards compatibility fix for version1 suspend/resume. 2003-07-05 23:20:43 +00:00
8449314da2 Another sync point - numerous fixes & clean ups. 2003-07-04 22:34:56 +00:00
63ad057028 Synchronise repository / 2.4.21 support 2003-07-04 19:38:49 +00:00
e720464330 Support for v4 interface 2003-07-01 21:20:58 +00:00
24036afef9 move functions 2003-05-06 12:22:24 +00:00
c78fa1a1bc remove global pvmove lock & poll for completion 2003-05-06 12:20:11 +00:00
faa8b9022c Check for locked LVs/pvmoves. 2003-05-06 12:14:36 +00:00
729bafef7a unsigned 2003-05-06 12:13:19 +00:00
590b028632 Prevent renaming active VGs for now. 2003-05-06 12:11:46 +00:00
8150d00f36 Don't process locked LVs 2003-05-06 12:10:18 +00:00
060065926f Store argv 2003-05-06 12:09:28 +00:00
70babe8a28 --abort --background 2003-05-06 12:08:58 +00:00
c36e09664f move fields 2003-05-06 12:06:02 +00:00
a9672246f3 reset_locking() 2003-05-06 12:03:13 +00:00
ff571884e9 Move fields. 2003-05-06 12:02:36 +00:00
475138bceb list_next 2003-05-06 12:01:13 +00:00
4a8af199c2 Add argv 2003-05-06 12:00:51 +00:00
bdabf5db72 Distinguish between visible & top level devices. 2003-05-06 12:00:29 +00:00
6a5f21b34e Missing 'make install' dependency. 2003-05-06 11:58:55 +00:00
d608be103c Update 2003-04-30 16:49:27 +00:00
374bb5d18a Don't move snapshots 2003-04-30 15:58:09 +00:00
031d6c25ff Add pvmove 2003-04-30 15:28:17 +00:00
223fb7b075 add region size & interval 2003-04-30 15:27:48 +00:00
a746741971 configurable region size 2003-04-30 15:26:54 +00:00
120faf2a58 pvmove support 2003-04-30 15:26:25 +00:00
990bca0dc6 use pvmove flag 2003-04-30 15:25:34 +00:00
3406472db7 Add mirror.c 2003-04-30 15:24:49 +00:00
1bd733c9f6 Outline pvmove man page 2003-04-30 15:24:08 +00:00
238c7f982e basic pvmove support 2003-04-30 15:23:43 +00:00
fcb81147cb pvmove flag 2003-04-30 15:22:52 +00:00
1915b73783 mirror type 2003-04-30 15:22:36 +00:00
ee79e621fb mirror display type 2003-04-30 15:21:43 +00:00
d203275a3b Add comment 2003-04-30 15:21:10 +00:00
9e8a996222 Up interface to major version number 4. 2003-04-30 13:48:53 +00:00
0126b0b3ed Up interface to major version number 4. 2003-04-29 22:52:11 +00:00
458928612c Display event number. 2003-04-29 11:34:40 +00:00
e33f88e28d Event number support. 2003-04-29 11:34:23 +00:00
be570bbf9e Try alternative syncs if BLKFLSBUF fails. 2003-04-28 16:20:39 +00:00
f59b4be110 Extra metadata-reading debug message. 2003-04-28 12:18:53 +00:00
37336e41be Revert to data_start 2003-04-28 11:55:58 +00:00
d24a1a3f0a Version 1.95.17 (new <PV>:<PE range list> allocation restriction feature). 2003-04-24 22:52:14 +00:00
f7258955bd Update segment area length when merging consecutive segments. 2003-04-24 22:46:47 +00:00
2a1eae5d6f o Metadata area struct change.
o Support physical extent restrictions on PV lists for allocations
    e.g. lvcreate -l 200 vg1 /dev/sda1:100-199:300-399
2003-04-24 22:23:24 +00:00
50ee0a4adb Stop more gracefully when in test mode. 2003-04-24 22:13:48 +00:00
955a26584e stripe filler parameter 2003-04-24 22:10:56 +00:00
1d3e407c8f o Rejig activation code device dependencies to make things a bit more robust
and further reduce the number of ioctl calls made.
o Metadata area struct change.
o Make config file accessible to activation functions & get stripe_filler
  from it.
o Allow kernel to return snapshot status as a fraction or a percentage.
2003-04-24 22:09:13 +00:00
cb809c4596 indent 2003-04-24 22:00:29 +00:00
53bbe2888e fix optind after last change to it 2003-04-24 21:59:42 +00:00
7246f476a5 Add pool_strndup 2003-04-24 21:58:34 +00:00
0785d1c390 DM_EXISTS_FLAG replaced by ENXIO 2003-04-24 16:08:18 +00:00
85d2c49d14 Some ioctl code tidying: removing duplicate internal buffers; making bounds
checks clearer (incl. variable renaming); using a flag to indicate when
output data doesn't fit into supplied buffer instead of returning an error etc.
2003-04-22 21:22:04 +00:00
8b77d62b7f Improve message for pvcreate of empty device. 2003-04-22 16:09:11 +00:00
373058a32a Improve build robustness. 2003-04-15 13:24:42 +00:00
e6293c2c8c Abort if any filter creation fails. 2003-04-15 13:22:43 +00:00
eff181c959 Cope with intentionally missing /proc. 2003-04-15 13:21:38 +00:00
54752c2305 Support snapshot status fraction. 2003-04-15 13:20:16 +00:00
b4753c044f Display read-only state. 2003-04-15 12:30:44 +00:00
26493424ae alignment fixes 2003-04-08 21:20:31 +00:00
0282fd1332 Add major arg 2003-04-04 13:22:58 +00:00
b9a019a08b Allow for specification of major number as well as minor. 2003-04-02 19:14:43 +00:00
66f6a0e687 size_t tidying 2003-04-02 19:11:23 +00:00
2dd1b9f97d Allow device major to be set too. 2003-04-02 19:03:00 +00:00
89615f3045 Reinstate lost vg_write() in lvchange --permission. 2003-04-02 13:01:04 +00:00
7e46192f67 Proposed changes to the ioctl interface to fix alignment issues on some
architectures and specify an explicit width for every numeric field.
2003-03-28 18:58:59 +00:00
e78d985cdf Avoid report segfault with non-partial inconsistent VG. 2003-03-24 18:22:48 +00:00
e8c4bf56fe Tidy various pre-processing incl. making libdl optional. 2003-03-24 18:08:53 +00:00
e6aa7d323d Fix incomplete munmap. (pjc) 2003-03-20 14:29:28 +00:00
fca8e25929 Fix typo. 2003-03-03 12:57:27 +00:00
8e8ac286b4 HAT_CHAR and DOLLAR_CHAR were defined to the same value ! 2003-02-20 14:53:56 +00:00
7d9770b9a2 Fix table output bug in last commit. 2003-02-20 13:30:03 +00:00
1996230460 Update packages. 2003-02-16 22:12:28 +00:00
de7897a864 LV name validation 2003-02-03 20:09:58 +00:00
e2884dcdb7 Identifiers may now start with digits etc. 2003-02-03 20:08:45 +00:00
544a53a42b Allow strings in single quotes too 2003-01-28 17:20:11 +00:00
2e4787bfc8 Treat 'section{' as equivalent to 'section {' 2003-01-28 16:07:04 +00:00
1829eeb171 merge back accidentally overwritten r1.2 change 2003-01-25 13:34:35 +00:00
c7488e3c4a Prepare for ioctl version number change. 2003-01-21 21:27:36 +00:00
3bf9606383 Allow optional verbose logging. 2003-01-21 21:25:51 +00:00
4f43f18f0a Allow optional verbose logging 2003-01-21 21:25:11 +00:00
5b7f197397 Add --enable-debug --disable-compat 2003-01-21 21:22:55 +00:00
018141c97f Indicate full (dropped) snapshot. 2003-01-21 18:50:50 +00:00
4d7813e57c vgreduce --removemissing to remove missing PVs & deps & make VG consistent 2003-01-17 21:04:26 +00:00
605c60208f Add success message; validate given VG name. 2003-01-17 21:02:04 +00:00
884fafcc30 Activation commands now return success in test mode. 2003-01-17 20:16:23 +00:00
56baa90320 Update 2003-01-10 22:51:18 +00:00
6bb20ee09e Fix (rare) cache bug on machines with large /dev directories. 2003-01-10 19:14:01 +00:00
541356430c Fix segfault in uuid display (substitution missed during bulk change) 2003-01-09 19:35:17 +00:00
2f4d91fd69 configure --disable-devmapper if you don't have libdevmapper 2003-01-08 22:44:07 +00:00
f58c5e6b30 o Additional device/filter-level debugging messages + duplicate alias fix
o 32/64-bit size_t fix (pjc)
2003-01-08 16:41:22 +00:00
0311d0132c Update date. 2003-01-07 17:06:58 +00:00
c946c97402 Detect duplicate PV uuids - select the one on an md device if appropriate. 2003-01-06 21:10:43 +00:00
84a6f51318 Ignore filter cache at startup if config file is newer than cache. 2003-01-06 21:09:04 +00:00
24a1501b0d More docn for filter changes. 2003-01-06 21:07:27 +00:00
383b6f5fcc Correct error message for non-snapshot activation failure. 2003-01-06 21:06:43 +00:00
633dd7ff9b When there are device name aliases, choose the "nicest" to display. 2003-01-03 21:11:23 +00:00
580624fad6 Also lock memory during LV updates. 2003-01-03 21:10:28 +00:00
a8190f7efa When activating an LV, remove any stray LVM1 /dev nodes and group file. 2003-01-03 13:50:47 +00:00
dd2157534b Default stripesize 64k & config file setting for it;
Clear many compiler warnings (i386) & associated bugs - hopefully without
introducing too many new bugs:-)  (Same exercise required for other archs.)
Default compilation has optimisation - or else use ./configure --enable-debug
2002-12-19 23:25:55 +00:00
38a90e7669 New column-based reporting tools: lvs, pvs & vgs. 2002-12-12 20:55:49 +00:00
6bfc526dcd close another bug 2002-12-09 08:59:34 +00:00
aadb8a7405 it's about that time again 2002-12-09 08:37:58 +00:00
27082bf77e Use sync_dir(). 2002-12-05 22:56:22 +00:00
a2903c80cd Add sync_dir() 2002-12-05 22:51:15 +00:00
9a77c5369c Fix display alignment of zero. 2002-12-05 22:42:31 +00:00
3c30741a19 Remove an unused .h file. 2002-12-05 22:37:36 +00:00
7028ad4ec0 Fix long arg processing. 2002-12-05 22:35:15 +00:00
8de750c6aa Maintain snapshot_count correctly. 2002-12-05 22:30:39 +00:00
04f98de9ee Keep certain versions of ld happy. 2002-12-05 22:28:18 +00:00
a1a019784b Keep some ld versions happy. 2002-12-05 22:27:43 +00:00
4aeeae77bd New devices/types config file entry to add new types of block devices. 2002-12-03 16:20:38 +00:00
651cfc2b78 tidy 2002-12-03 13:27:23 +00:00
2ef8af25e2 Show PV uuid; single stripe is 'linear'; suppress snapshot fields for origin. 2002-12-03 13:26:17 +00:00
0b13852a5b More restore hints. 2002-12-03 13:25:09 +00:00
13427578c9 Default size unit normally MB not KB. 2002-12-03 13:24:38 +00:00
d89ca2087e Suppress a (normally) unnecessary warning. 2002-12-03 13:23:50 +00:00
8b0ea9fba6 Further help text tidying & support for -?. 2002-11-29 15:02:57 +00:00
9f0b653d5a tiny tidying 2002-11-28 15:27:59 +00:00
659a339233 Corrected lvcreate synopsis.
Added --ignorelockingflag to synopsis where missing.
2002-11-28 15:27:29 +00:00
4c29f177a0 Show stripesize in KB. 2002-11-26 21:56:57 +00:00
d664e63d55 Skip config file reload attempt if no config file location. 2002-11-26 12:14:37 +00:00
2493509dbe Fix snapshot lvcreate activation check. 2002-11-22 14:19:56 +00:00
1c8b27f554 Remove 2 TB LV size restriction message. 2002-11-18 16:21:00 +00:00
68297b7186 Missing sector->k conversion in "logical volumes cannot be larger than" mesg. 2002-11-18 16:08:45 +00:00
34dd8d0a91 Some new features. 2002-11-18 14:04:08 +00:00
81c44790d5 Refactoring. 2002-11-18 14:01:16 +00:00
d557b335cf A new cache. 2002-11-18 13:53:58 +00:00
e2adc28cff Only functions listed in libdevmapper.h should get exported. 2002-11-14 19:26:28 +00:00
0fef6a6ecc Fix includes after DM_DIR definition move. 2002-11-14 14:44:42 +00:00
f2fd4b8a1f Don't let LVM2 access a VG if the original LVM driver appears to be using it. 2002-11-01 19:57:25 +00:00
95bd5605a8 Improve missing-kernel-driver error message. 2002-11-01 16:16:42 +00:00
497cca7eca agk, I recall you saying you had a massive commit pending; if you need me
to back this out so you can do that commit, let me know.  Also, if there's
an issue with the error message that's displayed, just change it in tools.h.

This causes a "device-mapper driver/module not loaded?" error message to
be displayed for the commands that require dm-mod, if the tools can't get
the driver version.  It's not done for commands that don't require dm-mod.
This should clear up some problems people have had attempting to use lvm2
without rtfm'ing.
2002-10-27 21:04:03 +00:00
54f78feedd synch w/ debian 2002-10-27 18:40:35 +00:00
76408e53ae Wow, learn something new every day. Apparently, the signed-ness of char is
implementation-dependent; some archs (s390, arm, and ppc) default to
an unsigned char.
2002-10-08 20:16:44 +00:00
be19e74d30 Support alternative lvrename syntax. 2002-09-05 12:49:23 +00:00
dac578a775 update, synch w/ debian 2002-09-01 23:08:17 +00:00
04732ce74b o inline _step_matcher 2002-08-29 15:05:16 +00:00
a6c95a2374 o Give an example filter that uses anchors. 2002-08-29 14:47:06 +00:00
f68622abe9 o Anchor support for the regex engine. 2002-08-29 14:46:30 +00:00
83a9a7bdb2 o This resolves bug #79
o added -D_REENTRANT to the CFLAGS so clvmd works properly with liblvm
   (I saw this problem with Redhat 7.3)
2002-08-15 15:31:33 +00:00
6500afc0ca Remove O_DIRECT as it causes problems with some systems.
Harumph.
2002-08-14 14:58:00 +00:00
c69b7ecc96 o Remove e2fsadm to stop people waiting expectantly for something that isn't going
to arrive.
2002-08-08 07:54:57 +00:00
615ef1e2d2 o Make sure the status parsing code can deal with an empty array. 2002-08-01 12:51:48 +00:00
cf69a0cd7f o Added new value type CFG_EMPTY_ARRAY, to indicate '[]', useful since we use
the arrays to hold a symbolic set of flags.
2002-08-01 12:46:52 +00:00
06e892fb33 o 0 was used rather than NULL in a couple of places.
o  Indent output with tabs rather than single spaces.
2002-08-01 08:22:09 +00:00
e6c5dd6865 o Test program for the config unit. Just reads a config and then writes it
out again.
2002-08-01 08:18:54 +00:00
247efdebdb Rename lock_resource to file_lock_resource to avoid name clashes 2002-07-25 09:04:30 +00:00
76f3792287 Use O_DIRECT for writing to devices.
Doesn't work on HPPA due to a kernel bug but other archs shuld be OK.
2002-07-22 08:10:54 +00:00
64d8e2c727 Remove hard-coded extent_size from snapshot target (field no longer used). 2002-07-17 17:00:54 +00:00
ead0bd9cb0 Improved snapshot-related arg validation 2002-07-17 16:04:05 +00:00
66fc13b2ec i) Add the VISIBLE flag to the text format. (Other changes are pending
for lib/activate.)
2002-07-11 15:28:49 +00:00
f3af4128b0 i) Added a little macro to aid defining the status flags. 2002-07-11 14:36:45 +00:00
0e43107c87 i) There's now a seperate field in struct logical_volume that stores the
allocation policy.  This can currently take one of three values:

   typedef enum {
        ALLOC_NEXT_FREE,
        ALLOC_STRICT,
        ALLOC_CONTIGUOUS
   } alloc_policy_t;

    Notice that 'SIMPLE' has turned into the slightly more meaningful NEXT_FREE.

ii) Put code into display.[hc] for converting one of these enums to a
    text representation and back again.

ii) Updated the text format so this also has the alloc_policy field.
2002-07-11 14:21:49 +00:00
1ee3e7997e tidy 2002-07-11 14:09:26 +00:00
50fd61d91f Add get_config_str 2002-07-11 14:07:43 +00:00
e4cdc051a9 Don't log an error if we can't write the cache file because the FS is read-only.
Gets rid of that annoying error at shutdown.
2002-07-11 09:23:29 +00:00
778e846e96 Add --ignorelockingfailure 2002-07-10 20:43:32 +00:00
a27759b647 Merge adjacent "Missing" segments. 2002-07-10 13:54:17 +00:00
b75eceab41 o Add version number to text format. 2002-07-02 18:47:43 +00:00
e748a5d5f4 Tidy up for another release: updated documentation; removed old files;
module build fix.
2002-06-26 21:50:53 +00:00
99c5a3ae46 Flush on open as well as close. 2002-06-25 14:02:28 +00:00
51da710f5a o Long-awaited ioctl interface clean-up. *** Not backwardly compatible ***
o Various other kernel side tidy-ups.
o Version number changes so we have the option of adding new ioctl commands
  in future without affecting the use of existing ones should you later
  revert to an older kernel but not revert the userspace library/tools.
o Better separation of kernel/userspace elements in the build process to
  prepare for independent distribution of the kernel driver.
2002-06-19 13:07:05 +00:00
569d69b3d2 o Knock the version check out of the makefile, Alasdair will no doubt put it back :)
o  Change to new ioctl names.
2002-06-17 15:50:17 +00:00
059a6b1d90 Get rid of compile warnings on 64bit platforms. 2002-06-07 08:37:07 +00:00
990af7548a Increment version. 2002-05-31 19:33:30 +00:00
a38aefdfc8 Add vgsplit. 2002-05-31 19:30:51 +00:00
3bcb12e7d1 Tidy/fix segment rounding. 2002-05-31 19:29:43 +00:00
7904ecb462 Tidy 2002-05-31 19:28:37 +00:00
9ba4d45109 Remember to update VG free_count when reducing size of an LV. 2002-05-30 16:08:19 +00:00
56b8afe19d Fix vgcfgrestore segfault (wrong variable used). 2002-05-30 16:03:26 +00:00
f7aed9a94c update 2002-05-27 13:00:18 +00:00
e12a7e881d o fix changed function names 2002-05-23 14:13:21 +00:00
5afb65325d Fix LVM1 backwards compatibility issue when LV with a low LV number is deleted. 2002-05-23 11:37:51 +00:00
135f520f32 o Remove ext3 incompatibility bug
o	Mention 2.4.18 VM problem
2002-05-23 08:20:44 +00:00
bc251f4ff6 update for .08 2002-05-23 07:49:25 +00:00
b8769751f6 Rename; add some FIXMEs. 2002-05-22 14:03:45 +00:00
eff96d839e Revert to standard linux macros (for correct behaviour on rare architectures). 2002-05-21 12:37:07 +00:00
aa34c23807 Update version. 2002-05-21 12:14:05 +00:00
195acdac8c ack, missing include 2002-05-19 04:11:34 +00:00
903e03c56c update create_dir() comment 2002-05-19 03:52:38 +00:00
0892767b8a support recursive mkdir in create_dir() 2002-05-19 03:46:34 +00:00
83ebfa772c synch w/ -3 "oh shit" release 2002-05-14 03:56:40 +00:00
1583641322 Drop the default chunk size for snapshots down to 8k 2002-05-13 15:14:21 +00:00
9510e2c256 Rewrite missing/corrupt metadata in more cases. 2002-05-13 12:38:54 +00:00
a9dbabe07e o the _status fxns now take more arguments - this way i don't get the
preparsed status info, shove it all into a string, and then parse it
   again to get the info back out (which is what i was doing before)
 o basically that's it...i like this *much* better than the previous
   method and i think it makes the _status fxn more flexible if we need
   to use it to get other info out.
2002-05-10 16:06:06 +00:00
12884008fa Import snapshot status & persistence + indent etc. 2002-05-10 15:25:38 +00:00
02543bad1c o Actually read snapshot percentage from the kernel - what a pain! :)
o Not sure if the code in dev_manager is really optimal, but it works..
   will look at adjusting it a bit now.
 o I *think* it works right when one snapshot if full but others aren't,
   but I haven't really been able to test it because the full snapshot
   somehow resets itself and weird things start happening to the system...
2002-05-09 21:17:57 +00:00
a8c56a5251 Remove a no-op. 2002-05-09 12:03:55 +00:00
4e5a855f3f o header should only be printed once... 2002-05-08 17:58:52 +00:00
7e497a951e o Added function find_snapshots to snapshot_manip.c that returns a list
of snapshots whose origin is the lv passed in.
 o Used this new function to make lvdisplay properly display all snapshots
   attached to a origin.
2002-05-08 16:57:46 +00:00
cd08eabbfa i) Put back chunksize_ARG for lvcreate. 2002-05-08 14:36:10 +00:00
f7e62d9f81 Always call init_log() to initialise logging defaults. 2002-05-08 12:26:45 +00:00
9a3761e86e implement our own swabbing functions, instead of relying on the kernel's. 2002-05-07 15:28:59 +00:00
3619a68693 log/{prefix,command_names} use defaults.h & reset between shell cmds 2002-05-07 13:00:01 +00:00
efaf3c3bf9 Default values for some display output settings 2002-05-07 12:50:01 +00:00
0e4e6a6f67 Tweaks 2002-05-07 12:47:11 +00:00
42458e6278 updated. 2002-05-07 06:13:03 +00:00
41ec995377 Make lvm2 compile on big endian archs; use the kernel/glibc's endian
conversion stuff, instead of implementing our own.  Tested on a little
endian system (x86); I'll let the debian handle big endian testing.  :)
2002-05-07 05:54:14 +00:00
4f37599326 o Will now correctly remove expired achive files from the system when
archive_vg is called.
 o Added a #define to the top of the file - not sure if this is the
   appropriate place for it though
2002-05-03 19:28:07 +00:00
4144520e5c Add features to get table/status & wait for next event. 2002-05-03 11:55:58 +00:00
6c4800546c forgot to add Conflicts against lvm1 packages 2002-05-03 04:57:49 +00:00
733733c8a7 updated for 0.95.05-2. 2002-05-03 04:43:46 +00:00
2aa67cc946 ditto 2002-05-03 04:43:24 +00:00
9385981a9d dh_installinit makes a perfectly find postrm script.. 2002-05-03 04:13:02 +00:00
fff780035d Update. 2002-04-30 17:13:43 +00:00
46127e673d Some partial VG support with format_text. 2002-04-30 17:12:37 +00:00
70df59b224 get_vgs must check for text format VGs when no lvm1 format VGs present 2002-04-30 12:27:13 +00:00
0fdbaa803f o Updated *display output for LVM1 compatibility
o There is still a bit missing
   + all are missing the {PV,VG,LV} # - that is not applicable in LVM2
   + pvdisplay doesn't show how many LVs are contained on it
   + much of the snapshot information isn't available for lvdisplay
 o Look at the code for other potiential FIXMEs  :)
2002-04-29 21:43:14 +00:00
6af1830eff Changed DEFAULT_PV and DEFAULT_LV to 256 (has been fixed in LVM1 before) 2002-04-25 10:53:58 +00:00
6f860e2bd5 Updated for new release 2002-04-25 06:12:07 +00:00
20a492f7ee Update example config 2002-04-24 18:41:02 +00:00
63875e7591 Merge with text format branch.
Lots of changes/very little testing so far => there'll be bugs!

Use 'vgcreate -M text' to create a volume group with its metadata stored
in text files.  Text format metadata changes should be reasonably atomic,
with a (basic) automatic recovery mechanism if the system crashes while a
change is in progress.

Add a metadata section to lvm.conf to specify multiple directories if
you want (recommended) to keep multiple copies of the metadata (eg on
different filesystems).

e.g. metadata {
        dirs = ["/etc/lvm/metadata1","/usr/local/lvm/metadata2"]
}

Plenty of refinements still in the pipeline.
2002-04-24 18:20:51 +00:00
0ad98cabde add setlocale() call so that localisation of things like number entry
and display will work correctly.
2002-04-24 10:42:09 +00:00
668879d2e1 o Stop printing errors if flushing fails (could be an unconfigured device). 2002-04-24 08:37:34 +00:00
2e09783302 Prepare for another beta release. 2002-04-23 22:13:04 +00:00
49734114b3 Commit snapshot-related changes preparing for the next beta release. 2002-04-23 21:47:50 +00:00
950d9d6ee7 Missing seg->lv gives segfault when activating from text format. 2002-04-16 19:41:54 +00:00
f7974aee2e Allow deactivation of final snapshot. 2002-04-16 14:42:20 +00:00
c870a82621 o Added support for chunk_size to lvcreate. 2002-04-15 18:49:20 +00:00
984929a001 Missing VG lock when iterating through all LVs. 2002-04-15 16:27:39 +00:00
7f9e2c1db8 More memory leak plugging. 2002-04-15 13:24:14 +00:00
324e8389dc o Drop the default chunk size for snapshots down to 16k. 2002-04-15 08:41:00 +00:00
6f448c5a38 Implement a no_locking module that *does* attempt activation. 2002-04-11 14:10:32 +00:00
ec43efbb20 Rename device node during a DM_RENAME command. 2002-04-11 12:45:18 +00:00
3ed065de37 Return status from _lv_activate and friends.
Alasdair, I think this is right (and I need it) but you may like to check.
2002-04-11 09:14:04 +00:00
8152f0d72c Remove \n from log messages. 2002-04-10 15:49:47 +00:00
f8047f4736 o Perform a BLKFLSBUF ioctl whenever a block device is closed.
Patrick, can you see if this fixes your cluster syncing problem please ?
If so I'll make it so it only syncs if you have actually written to the
device.
2002-04-08 18:59:50 +00:00
b93c66dc2d Implement an external locking interface. 2002-04-08 16:04:50 +00:00
ac877b3065 Fix prototype. 2002-04-08 13:35:09 +00:00
dee8abfdde Fix lv_setup() not to generate a new lvid each time if asked to setup the
same LV more than once - subsequent times validate only.
2002-04-05 14:32:22 +00:00
cef3841d73 Make lock type numbers match the DLM numbers in use, and move UNLOCK out
of the way.
2002-04-04 13:31:21 +00:00
3cd5e8a041 Rename LCK_NONE to LCK_UNLOCK 2002-04-04 11:18:45 +00:00
515b5f866e Tidying. 2002-04-03 12:17:55 +00:00
321f62bf92 Cope with creation of additional snapshots while active.
(More work on suspension dependencies still needed.)
2002-03-27 18:17:43 +00:00
f94fa47b52 Snapshots are now attached to their origin device for locking purposes
so lock the origin instead of the snapshot itself when creating one.
2002-03-26 15:01:57 +00:00
c502f8a722 New-style persistent minor support. 2002-03-26 13:41:37 +00:00
59b4868ac3 o read-only device support
o name/uuid disambiguation
2002-03-25 18:54:59 +00:00
3634e12cce Fix typo. 2002-03-25 18:50:37 +00:00
6d45445391 all people to actually uninstall lvm2 (*grin*) 2002-03-23 08:23:15 +00:00
4f47e268cc Improve log messages. 2002-03-20 14:34:15 +00:00
0035b31cdb Better support for LVs with hyphens in names. 2002-03-19 16:41:44 +00:00
f2565aee03 Support device queries by uuid as well as by name. (Used by lvrename.) 2002-03-18 23:39:42 +00:00
5bd85668dd lvrename works on snapshots now 2002-03-18 23:25:50 +00:00
20f990b6ce Tie all snapshot (de)activation requests to (de)activation of origin device. 2002-03-18 13:09:27 +00:00
6821379586 s/Removing/Unloading/ in messages to reduce confusion 2002-03-15 23:01:59 +00:00
73b040eb49 Cut the number of device-mapper calls. 2002-03-15 22:59:12 +00:00
49aa4b2e1e New function to enable suppression of messages to stdout/stderr. 2002-03-15 22:54:04 +00:00
972241c74c Review locking: block signals instead of ignoring them and restore state
afterwards; avoid race condition with unlink; add LCK_HOLD to process_each_vg.
2002-03-15 16:07:38 +00:00
680750e3c2 Reduce the number of dm info calls. 2002-03-14 21:17:30 +00:00
5e7d4d9d15 distclean also to remove libdm-common.h 2002-03-14 16:56:02 +00:00
1e57e60613 Integrate suspend. 2002-03-14 15:36:07 +00:00
3ac7ce605a Suppress verbose/debug messages from libdevmapper. 2002-03-14 13:39:33 +00:00
b720dea9f0 o dev_manager_suspend, untested. 2002-03-14 10:56:09 +00:00
c80722aefe A missing free() found by Valgrind. ( http://developer.kde.org/~sewardj/ ) 2002-03-13 23:19:20 +00:00
a84fa69f28 dmsetup display uuid 2002-03-13 16:19:17 +00:00
e33781e59f Set LV uuid. 2002-03-13 15:11:29 +00:00
8824bc7ece o Mention that vgscan needs to be run after changing the filter var. 2002-03-13 14:25:53 +00:00
c2e3b0e448 Fix _align so it works on 64-bit machines. 2002-03-12 15:27:51 +00:00
f61a38e85a Let dmsetup store the uuid on device creation. 2002-03-11 22:44:36 +00:00
d23e948216 Move is_empty_dir to lvm-file 2002-03-11 22:23:24 +00:00
58bdaa31f0 o Actually check that the vg directory is empty rather than speculatively
rmdiring it.  Work around for devfs bug.
2002-03-11 20:43:58 +00:00
b6491d88a6 o This should complete the dev_manager alg. Please could people now
report any activation oddities they see.
2002-03-11 20:36:04 +00:00
f6061ba62e lv_info replaces lv_active etc. 2002-03-11 19:02:28 +00:00
427899ddce o activate/reactivate merge
o unlocking macro
2002-03-11 15:08:39 +00:00
c4ab7d2dbd o dm->active_list now filled in, ATM this is based on the layer name rather
than the uuid.
2002-03-11 11:27:48 +00:00
0fd2ba033f o Comment out some new code that was preventing pjc activating
snapshots.  This will go back in when the active_list is working.
2002-03-11 10:38:16 +00:00
ed38939a93 o knock out the offset for origin targets. 2002-03-08 10:45:01 +00:00
c7ee26ce5a o Add active_list to dev_manager
o  Origin layer is only added to snapshots if a snapshot is in the
   active_list.
2002-03-08 10:41:48 +00:00
909b8cb303 heh, whoops. s/device-mapper/LVM2/g. 2002-03-08 02:39:08 +00:00
b0277370cf o dm_destroy_all() called on exit - but doesn't touch suspended devices yet.
o 'dmsetup remove_all' calls dm_destroy_all() to provide a quick way to
  prepare for unloading the module
o Ran through indent again.
2002-03-07 20:56:10 +00:00
2ec8656bea o First cut at dev scanning.
o  Split up _expand_lv
2002-03-07 17:37:38 +00:00
b2ef256910 o Add comment describing what we're aiming for with dev_manager.
o  Remove dev_manager_reactivate, since it'll be the same as activate.

o  Merge the mark, visible and dirty fields into the same flags field.
2002-03-07 16:48:46 +00:00
63d6ce95db o Top level device is now just called <vg>-<lv> (there's no 'top'
layer appended).

o  Got rid of the unused layer->type field and enum.
2002-03-07 15:29:31 +00:00
a9532b189c Kernel functionality that returns device dependencies (ejt). 2002-03-06 19:42:23 +00:00
844545411f o Rename dmsetup dependencies -> dmsetup deps 2002-03-06 14:47:13 +00:00
4e23a2b9b8 o Add support for getting dependencies for a device.
o  dmsetup dependencies <dev>
2002-03-06 14:38:25 +00:00
5deba027eb convert from debian native package 2002-03-06 05:43:54 +00:00
fc8b7efc6f o Use new LCK_HOLD flag to indicate whether lock should be held on return
from lock_vol() - otherwise it now attempts to acquire the lock and then
  immediately releases it.
o Extend the id field in struct logical_volume to hold VG uuid + LV uuid
  for format1. This unique lvid can be used directly when calling lock_vol().
o Add the VG uuid to vgcache to make VG uuid lookups possible.  (Another
  step towards using them instead of VG names internally.)
2002-03-05 20:03:09 +00:00
a1c2d9c0f3 Fix activation for VG with more than one LV. 2002-03-04 18:50:34 +00:00
4ca49a0501 snapshot/zero logic 2002-03-04 15:25:52 +00:00
493c53d090 o Add a line to lvdisplay to say if the volume is a snapshot. 2002-03-04 15:12:30 +00:00
b27e956d35 o Bad dependency, meant the origin was always getting activated. 2002-03-04 15:10:30 +00:00
35ebed75c6 Remove unused fns. 2002-03-04 14:27:25 +00:00
7bfdb5f77f o I was tearing down device bottom-up instead of top down. Which
is why lvremove of snapshots wasn't working.
2002-03-04 14:26:43 +00:00
8d8c02317f o Break creating a snapshot down into:
i)   create cow
   ii)  activate cow
   iii) zero cow
   iv)  deactivate
   v)   add snapshot info
   vi)  reactivate
2002-03-04 13:46:37 +00:00
a34482feab proper /etc/lvm/lvm.conf now 2002-03-04 11:13:47 +00:00
cbdc8fd4a6 fix various issues 2002-03-04 11:12:57 +00:00
8d3afaa53c More use of LV locking. 2002-03-01 19:08:11 +00:00
7ced9ef3df o point snapshots at origin:real rather than origin:top, and *ping*
snapshots work.
2002-03-01 09:07:00 +00:00
e8a9ae7e80 Fix unlock parameter. 2002-02-27 14:48:42 +00:00
73a88ab3d3 o Lock mechanism for LV activation
o #defines for common lock flag combinations
o Try out hyphens instead of colons in device-mapper names - does this
  make messages containing filenames easier to read?
2002-02-27 12:26:41 +00:00
aaed82738a Running out of filehandles? Close /dev/device-mapper/control then. 2002-02-26 18:30:02 +00:00
de7f7b96db o Format1 wasn't recording the snapshot chunk size properly
o  Activation of snapshots now works - though the resulting device
   doesn't (pjc ?)

o  text format wasn't setting vg->cmd.
2002-02-26 16:48:52 +00:00
1a669b3e68 Clearer link pathname display. 2002-02-26 16:08:22 +00:00
333af9b13a o _build_name was allocating 1 byte too few, which meant the
terminating zero was falling off at some later point.

o Don't try and iterate from a deleted node in _prune_unmarked.
2002-02-26 14:44:13 +00:00
a5bca5e240 o Removed old files
o  rewrote activate.c to use dev-manager, I'm sure these two will merge
   at some point.

o  Rename is broken ATM

o  dev-manager puts the calls through to fs.c for layers that have the
   'visible' flag set.
2002-02-26 11:49:17 +00:00
c885633e02 o More dev_manager fns. 2002-02-25 16:53:12 +00:00
ca7e20b7ca pvresize command 2002-02-25 15:32:58 +00:00
545e11a3d7 o In go the populate functions. 2002-02-25 15:19:53 +00:00
44f5287664 o More dev_manager work. 2002-02-25 14:46:57 +00:00
cf510897f1 Begin conversion so LV id is passed to activation unit instead of
struct logical_volume.
2002-02-25 12:56:16 +00:00
1d171345f8 o Sync with cvs, dev_manager still needs to be wired into activate.c 2002-02-25 12:02:33 +00:00
4fa7e1cd49 o Remove the vg argument from find_cow 2002-02-25 11:55:39 +00:00
acd008298e o hash_iterate -> hash_iter 2002-02-25 11:54:15 +00:00
83a8021515 o Added a macro called hash_iterate, that is similar to list_iterate
o Renamed hash_iterate function, hash_iter.
2002-02-25 11:52:58 +00:00
cf88dfb1db indent 2002-02-24 22:31:55 +00:00
8937c4b481 lvmdiskscan 2002-02-22 13:17:46 +00:00
cc6af10a4d Fill in format_text functions.
Sort of seems to work.
2002-02-22 11:44:56 +00:00
6d94578955 o Convert lv->id back to lv_number when writing back to disk
o Use first unused lv_number when creating new LV
o Use lv_number for refs to snapshots
o Update persistent minor logic after the lvcreate restructure
o Reset all parameters before use in lvcreate.
2002-02-21 19:04:37 +00:00
08442ab71e Avoid ambigous volume_group argument in vg_add_snapshot() 2002-02-21 18:31:48 +00:00
10d91d213f Generate LV uuid from lv_number when reading in LVs. 2002-02-21 15:26:44 +00:00
b7a3b06994 Removed wrong 'lv->vg' argument from lv_is_cow() call. Is used in lv_is_cow internally. 2002-02-21 14:00:45 +00:00
5f12c37f23 o typo 2002-02-21 10:17:01 +00:00
585edebccd o add find_cow function. 2002-02-21 10:16:33 +00:00
9921c62234 o misc little fixes. 2002-02-21 10:15:54 +00:00
1ac76d2e16 ah, it was that "set -e" that was the culprit.. 2002-02-21 08:52:36 +00:00
6e983bf400 stop init script from returning w/ non-zero if not really an error 2002-02-21 08:30:14 +00:00
6a8fd4fa6e Try out using LV locking for reactivation. 2002-02-20 21:30:27 +00:00
3698eaa2d2 Remove lv_update_write_access: use lv_reactivate directly now instead. 2002-02-20 21:28:22 +00:00
8d97ca433c Suppress meaningless <backtrace> msg on screen (no prog/line number given) 2002-02-20 21:26:40 +00:00
23cc65e537 lvd->lv_access & LV_SNAPSHOT not lvd->lv_status 2002-02-20 21:24:45 +00:00
2f5a3c2bbe Remove VG arg from lv_is_cow() and lv_is_origin() - use lv->vg instead. 2002-02-20 19:04:55 +00:00
f6485616cd o Use 'pvcreate --setphysicalvolumesize' with no short form (instead of -s)
and add severe warning if it's used to make a device seem bigger than
  it really is.  This is not an option people should be using as it
  breaks metadata integrity.
o Use uint64_t throughout (rather than unsigned long long)
o Convert a few messages that contain pathnames into the more common form:
  pathname: message
2002-02-20 18:29:30 +00:00
6544fb43d9 initial lvm2 debian packages; still missing some manpages, but otherwise lintian passes
E: lvm2: binary-without-manpage e2fsadm
E: lvm2: binary-without-manpage lvmdiskscan
E: lvm2: binary-without-manpage lvmsadc
E: lvm2: binary-without-manpage lvmsar
E: lvm2: binary-without-manpage lvresize
E: lvm2: binary-without-manpage pvdata
E: lvm2: binary-without-manpage pvmove
E: lvm2: binary-without-manpage version
E: lvm2: binary-without-manpage vgcfgrestore
E: lvm2: binary-without-manpage vgexport
E: lvm2: binary-without-manpage vgimport
E: lvm2: binary-without-manpage vgmknodes
E: lvm2: binary-without-manpage vgsplit
2002-02-20 10:28:49 +00:00
a954b32dcc install all the manpages (another make-lintian-happy exercise) 2002-02-20 10:22:02 +00:00
426dc7836c o Removed the -z (suspend) option from the tools
o  New function: int lv_setup_cow_store(struct logical_volume *lv)
   This zeroes the start of the cow device.

o  Made lvcreate call above fn.
2002-02-18 15:52:48 +00:00
ff941ffc16 o small bug in the format1 export code for snapshots.
o  tidied newlines in the snapshot section of format text.
2002-02-18 11:25:43 +00:00
a063c201df o Add support for the -s and -c flags to lvcreate. 2002-02-18 10:59:51 +00:00
e2be3fa0aa Second path on "pvcreate -s" 2002-02-15 14:33:59 +00:00
609da6fb50 o split lvcreate into seperate functions for parsing the command line,
and creating the lv.  A lot of changes in here so be on the lookout
   for bugs.
2002-02-15 11:53:22 +00:00
fc9f3ccec3 Forgot to remove test printf :-) 2002-02-15 09:37:23 +00:00
f7baa67a0a First cut on "pvcreate -s" 2002-02-15 01:26:16 +00:00
e8d78c2cdb o Initialise the snapshot list properly in vgcreate. 2002-02-14 15:06:24 +00:00
9d33366092 o Define _read_uint32 2002-02-14 14:52:21 +00:00
f5d61515c2 test printf removed 2002-02-13 21:30:51 +00:00
711a04a972 LV maximum size limit of 2TB ensured in _lv_setup() 2002-02-13 21:28:56 +00:00
e5b470a3f1 spaces 2002-02-13 21:28:15 +00:00
31820e1e22 > 2TB numbers in vgdisplay_full 2002-02-13 20:21:13 +00:00
4849e8cd6d o snapshot support for the text format.
The logical_volumes, and snapshots sections of the text format are now
optional.
2002-02-13 13:29:16 +00:00
77e3b460aa o First pass at format1 snapshot support. 2002-02-13 11:43:29 +00:00
b5321001f8 o First changes to add snapshot support.
I'm taking a different route from LVM1 here in that snapshots are a
seperate entity from the logical volumes, I think of them as an
application of an LV (or two lvs rather).  As such there is a list of
snapshots held against the vg, and there is *not* a SNAPSHOT, or
SHAPSHOT_ORG flag in lv->status.
2002-02-12 16:31:31 +00:00
38eba9f5ea use portable <inttypes.h> macros for printing. 2002-02-12 14:12:13 +00:00
ea6f399454 o Turn the device_create_* functions into device_populate_*, they only
fill in an already created dm_task.  This allows common code, such
  as minor number selection, and read_only to be lifted.
2002-02-12 11:15:45 +00:00
f8bf2d7b7d Run through indent - no (intentional) changes to any code. 2002-02-11 21:00:35 +00:00
c4856caebb Preparation for an LVM2 liblvm - pass cmd_context into each tool and
link some globals that the tools need into that structure.
2002-02-11 20:50:53 +00:00
fc1030bb22 Now that most of the usage of 'stack' only occurs when there's an error,
don't suppress it from the screen output any longer.
2002-02-11 18:25:18 +00:00
9eb6cad8dc dbg_free(tc->desc) 2002-02-11 18:21:54 +00:00
0fa2a78dce Document return codes. 2002-02-11 17:42:02 +00:00
a56fa1558b o Split activate.c into a high level (remaining in activate.c) and low level (ll-activate.[hc]) API.
o  Creation of a device from an lv now lives in activate-lv.c
2002-02-11 15:48:34 +00:00
261c73a997 o Support locking with local lock files
o Disable control-c during updates (except if blocked waiting for a lock)
2002-02-11 15:42:34 +00:00
929c1333ca o Little recipe for testing LVM2 with loopback devices. 2002-02-11 12:01:59 +00:00
286a79d94d o Added functions to display what's in the archive.
o  For now vgcfgrestore -l <vg> displays this list.

A bit hacky, but it'll get better.
2002-02-11 11:43:17 +00:00
8b951f99da Locking prototypes. 2002-02-08 14:30:37 +00:00
abb449bca0 move defaults.h 2002-02-08 14:28:52 +00:00
bd084028d1 Move defaults.h 2002-02-08 14:28:14 +00:00
138a27570b o I decided that the archive_format shouldn't really be a format at
all since it only supports vg_write.  It has been replaced with:

int archive_vg(struct volume_group *vg,
	       const char *dir,
	       const char *desc,
	       uint32_t retain_days,
	       uint32_t min_archive);

which is now called directly by tools/archive.c
2002-02-08 11:58:18 +00:00
c2ed40a74f o Add cmd_line field to struct cmd_context
o  Text format now has a description and time field at the top level.

o  archiving and backup set the description appropriately. eg,

   for an archive:

     description = "Created *before* executing 'lvextend test_vg/lvol0 -l +1'."
     creation_time = 1013166332

   for a backup:

     description = "Created *after* executing 'lvextend test_vg/lvol0 -l +1'."
     creation_time = 1013166332

This is preparing the way for a simple vgcfgundo command.
2002-02-08 11:13:47 +00:00
a7e7a00cab Poor mans lvmdiskscan 2002-02-05 14:31:57 +00:00
64a31ab3cd Another release (includes some fixes from last week; persistent minors,
partial activation etc.)
2002-02-04 13:30:21 +00:00
71958bc0f1 lv->minor >= 0 (ejt) 2002-02-04 13:08:31 +00:00
366ec35612 Basic support for persistent minor numbers;
slightly different from the current LVM1 method.

  lvcreate --persistent y  --minor 10   (to specify when created)
  lvchange --persistent n  (to turn off)
  lvchange --persistent y  --minor 11   (to change)

--persistent uses a new LV status flag stored on disk
minor number is stored on disk the same way as LVM1 does
(but major number stored is 0; any LVM1 major/minor setting gets lost)

  lvchange -ay --minor 12 (to activate using minor 12, regardless of the
                           on-disk setting, which doesn't get changed)

--minor == -m
--persistent == -M
2002-02-01 17:54:39 +00:00
3738f6e8ae Failure signalled by -1 not 0; MAX_DEVICES 256 (was 64); change a '>' to '>='. 2002-02-01 17:39:20 +00:00
051a8e2af1 Display error when running unimplemented functions. 2002-01-31 20:37:26 +00:00
2f43f28d5e Remove gcc -D to support as different gcc versions handle it differently. 2002-01-31 20:15:26 +00:00
b64769754b "exit" means "quit" (lamer) 2002-01-31 20:08:52 +00:00
a97daa18d1 o Remove redundant dbg_free. 2002-01-31 15:28:30 +00:00
b6556dce8b Remove stray comma. 2002-01-30 17:25:51 +00:00
aa8d8bc8b5 Propagate volume group read-only setting down to its logical volumes.
(Might sometimes be safe to relax this restriction.)
2002-01-30 17:12:14 +00:00
0800dcfdc4 Basic support for (read-only) partial activation if any PVs are
missing from a VG.  (Linear targets use the device-mapper 'error' target
which returns ioerror; striped targets use '/dev/ioerror' for now - which must
already exist e.g. as a sufficiently large block device version of /dev/zero).
2002-01-30 15:33:12 +00:00
12b0101e94 quotes around names in output 2002-01-30 15:04:48 +00:00
021b391a02 Allocate fixed space for vg->system_id when vg is created, instead of
dynamically.
2002-01-30 12:47:29 +00:00
d11e2b6057 Correct statement order for case when 'stripes' parameter is not supplied. 2002-01-30 12:17:40 +00:00
264d90e7e5 add vgimport 2002-01-29 19:23:46 +00:00
f9f3da9e78 o A vgimport implementation
o Require -a or <list of vgs> parameters with vgexport/vgimport
o Allow pvcreate -ff to destroy exported/partial VGs
2002-01-29 19:19:37 +00:00
6435b49153 o Basic support for exporting (but importing not completed yet).
o When volume group does not have write flag set, prevent changes to it.
o Preparation for partial activation (not completed yet).
2002-01-29 17:23:33 +00:00
f9aa2941cf Display 'exported' status. 2002-01-29 16:30:18 +00:00
5a933d4bee Add list_iterate that's safe with deletions. 2002-01-29 16:28:52 +00:00
5536aea0df Date changed 2002-01-29 15:54:49 +00:00
976666d216 Zero gap after PV structure on write to disk in order to make non LVM tools happier (AED's idea and patch for LVM1) 2002-01-29 15:52:11 +00:00
9a5bcd4392 fixed div bug in calculation of end in calculate_extent_count 2002-01-29 15:43:04 +00:00
812060a118 Check that vgname doesn't already exits in dev_dir 2002-01-28 16:30:42 +00:00
089b5052e6 o There were some alignment problems with pool-debug which I've resolved
by allocating the data block with an additional dbg_malloc.

o  Added an assertion to check that no one is requesting alternate
   alignment for memory allocated from pool.  I can't see us needing this
   for LVM2.
2002-01-28 09:16:09 +00:00
874e5d72f4 *** empty log message *** 2002-01-27 21:48:05 +00:00
6b11de1329 Tweak some error message levels. 2002-01-27 21:30:47 +00:00
2245a7ad8d If lv isn't active, skip reactivation. 2002-01-25 22:58:01 +00:00
ee5ec1b870 Prevent lvextend from adding segments with different stripe characteristics
at the moment because the old LVM format doesn't support this.
2002-01-25 21:14:43 +00:00
74ccfe851b The latest attempt at making extended striped LVs work portably with LVM1. 2002-01-25 20:24:14 +00:00
e1c24bd5a2 Set pv->pe_size when reading in text-file backup.
Otherwise LVM1 decides the PV structure is corrupt.
But do we need to keep both pv->pe_size and vg->extent_size
in internal metadata or can we generate pvd->pe_size when writing out
a PV that belongs to a VG?
2002-01-25 20:21:13 +00:00
1349b79728 Only remove symbolic links when deactivating.
(if this code didn't create it, don't delete it)
2002-01-25 20:17:44 +00:00
d294d7604c o Tidy 2002-01-25 13:41:13 +00:00
01df2cf464 Have a pe_total check using theoretically big number instead of the
unnecessarily small limit LVM1 imposes in vgcreate (but not vgextend)
2002-01-24 23:35:56 +00:00
45b7322488 Don't bother to write out an empty cache. 2002-01-24 23:17:16 +00:00
b3055e992f Fix the device cache to cope reasonably safely with device name changes.
This should be a rare occurrence so the aim is to recover if it's
straightforward to do so, otherwise just to abort the operation.
If people *knowingly* change device names, they should always run vgscan
afterwards.

A few bytes of memory gets leaked inside a pool each time an alias
has to be discarded - it's not worth restructuring the code to reuse it.

More of LVM2 needs updating to pass device objects (or uuids) about
instead of pathnames so that resolution of pathname->object only happens
once per operation.

dev_cache_get() should now always return the *current* device at the path given

dev_name_confirmed() replaces dev_name() whenever it's important to
know that name for the device is still current (ie when opening it).
If the cache doesn't know a current name, the function fails.

dev_open() guarantees that the file descriptor returned is for the dev_t
of the device structure it was passed.
2002-01-24 23:16:19 +00:00
3da548565c Clear a FIXME about checking for identical devices by comparing dev_t
instead of name.
2002-01-24 22:37:24 +00:00
a975e85548 removed ~64limit for PEs per PV agk introduced 2002-01-24 19:20:35 +00:00
c4b5ade752 o Limit for number of extents should be 65534. 2002-01-24 17:32:56 +00:00
a4b61b0794 Improve allocation error messages when PVs in a VG have the allocatable
flag unset.
2002-01-24 17:26:00 +00:00
f6011184b8 Impose max PE limit for each PV. 2002-01-24 17:24:32 +00:00
74de118c6e o Add check for > 65k extents in a single lv. 2002-01-24 17:16:36 +00:00
9c25e77c17 o Add extra parameter to lv_manip fns 2002-01-24 17:15:49 +00:00
440113e67e o extra fid parameter to lv_manip fns 2002-01-24 17:15:24 +00:00
a11b60c445 o Remove pointless calculation. 2002-01-24 14:15:42 +00:00
a6052681ad Ignore all except one PV found with the same UUID. Use one which
has the md major number if there is such.
2002-01-24 13:36:33 +00:00
482d50536a Fix dev_close arg. 2002-01-24 13:31:18 +00:00
25c79a4fcd Remove any core files on distclean. 2002-01-24 13:30:40 +00:00
02946144ac o typo 2002-01-24 09:54:09 +00:00
71a360e9a3 o Cut and paste description of how pvmove works that I was mailing someone. 2002-01-24 09:26:13 +00:00
f7912d88b1 o Remove redundant symlink-handling code.
o When opening device, return error if its cached name is incorrect (eg if
  it's changed since the cache was generated).  This prevents use until
  the cache is rebuilt (eg with vgscan).  Doesn't catch every case.
2002-01-23 18:55:01 +00:00
975101d7d2 Avoid using VG metadata on PVs that are not in VGs. 2002-01-23 15:50:34 +00:00
ef58c5ff55 *** empty log message *** 2002-01-23 12:25:30 +00:00
e10221804a Silently remove any existing symlink before creating a new one. 2002-01-22 19:58:37 +00:00
284ed9ee0e Update with info on how to configure command output to look like LVM1 2002-01-22 19:20:46 +00:00
5d7b961997 Reviewed interaction with lib/activate now that the interface has settled down. 2002-01-22 19:11:12 +00:00
c699a5c4b4 New config options to customise message output. 2002-01-22 15:33:57 +00:00
1f4ceb89cf Customisable message output prefix / indentation. 2002-01-22 15:33:40 +00:00
0934ca0040 o added BUGS file. 2002-01-22 14:40:38 +00:00
4738f892c2 o Fix inverted logic in list_empty test. 2002-01-22 14:16:27 +00:00
33004fcf33 old file 2002-01-22 13:29:34 +00:00
34d214c166 Update. Ready to release? 2002-01-22 13:11:01 +00:00
a56cd92a1e No need for file output to default to stderr now that log file can be
specified in config file.
2002-01-21 19:05:00 +00:00
7251348507 Insert a missing hash_remove. 2002-01-21 19:04:13 +00:00
01cd5c84d6 o Allow fractional parts for size args. eg, lvcreate -L 34.4M
o  Fix a couple of bugs related to the earlier lv_list change
2002-01-21 17:43:10 +00:00
e210599fa6 o Similar changes for lv_list. 2002-01-21 16:49:32 +00:00
dbe7cee7e9 o fail if create_pv_list would produce an empty list. 2002-01-21 16:15:25 +00:00
7370d88ceb o Typo in comment 2002-01-21 16:10:36 +00:00
34458e0c57 o Changed
struct pv_list {
	struct list list;
	struct physical_volume pv;
   };

   to

   struct pv_list {
	struct list list;
	struct physical_volume *pv;
   };


o  New function in toollib 'create_pv_list', which creates a list of pv's
   from a given command line array of pv's.

o  Changed lvcreate/extend to use this (fixes lvextend [pv list] bug).
2002-01-21 16:05:23 +00:00
05c8c3abf2 Is this sufficient to fix make -j? 2002-01-21 16:02:55 +00:00
e9d464b4d3 Fixx OB1 error in max LV and max PV numbers 2002-01-21 14:53:47 +00:00
6968c3ab9b o Changed find_pv_in_vg, and find_lv_in_vg to return a struct pv_list * and
struct lv_list * respectively.
2002-01-21 14:28:12 +00:00
131a8a9650 o names.[hc] 2002-01-21 13:11:03 +00:00
379ecbf9a9 o lvdisplay now gives a segment map for the -m option. 2002-01-21 12:05:39 +00:00
7b9dfa9a28 o removed display_uuid
o use id_write_format from lib/uuid/uuid.h instead
2002-01-21 11:29:06 +00:00
fbd0f5eed2 o move the path building functions to lib/activate/names.c
o  Update activate.c and fs.c to use them

o  device names are now of the form <vg>:<lv>
2002-01-21 11:06:32 +00:00
5970f904ae Allow syslog facility to be set, or turned off, from the config file. 2002-01-18 21:26:37 +00:00
8cbcb2868d Display something in the "hypothetical" unknown log level case. 2002-01-18 19:38:19 +00:00
8ff2a4b026 Use same log levels as LVM2. 2002-01-18 19:37:26 +00:00
ae14d205a5 Allow compilation against a device-mapper that was installed into $DESTDIR
Always check for negative (error) return code from lv_active()
2002-01-18 16:43:19 +00:00
ec5d560ec5 More updates. 2002-01-18 13:45:12 +00:00
fb543b53c0 added before 2.1 item 2002-01-18 11:07:26 +00:00
39c16422e2 beta1-pre1 tagged, but there's still some documentation to update/write. 2002-01-17 18:48:08 +00:00
4d5b273ebe Support --version argument and 'version' shell command. 2002-01-17 16:39:24 +00:00
ed6a860fad Add function that returns the library version. 2002-01-17 14:13:25 +00:00
423e579292 Add another level of symlink to library name (like LVM1) so people who find
themselves running multiple incompatible kernel versions will just need
to swap symlinks at boot.
2002-01-17 13:37:09 +00:00
ee11aa9e75 Use additional version numbers.
Kernel driver has a version number (stored in kernel/VERSION).
  The first two components of this (0.94) give the version number of the
  ioctl interface.  This number must be changed whenever a change is
  made to the ioctl interface that breaks backwards compatibility.

  The library has a version number (stored in VERSION) which is
  used for linking.
  The first and/or second component of this must be changed whenever
  a change is made to the library API that breaks backwards
  compatibility.
2002-01-17 13:19:55 +00:00
c46d20fa92 o pvcreate --uuid to specify the uuid (required before using vgcfgrestore
onto a new device).  uuid specified must not already exist on the system.
o More message tidying.
o When checking for label, only read PV metadata.
o Add ataraid.  [Needs moving into config/defaults files.]
2002-01-16 18:10:08 +00:00
dc8d17574c o save before committing 2002-01-16 15:53:42 +00:00
5c17cd04c8 o lvm.conf file that contains the same settings that would be assumed if it
wasn't there.  A good starting point for tweaking.
2002-01-16 15:52:53 +00:00
67ada02076 Move test flag from log to global section of config file. 2002-01-16 15:20:51 +00:00
32d94c2eaf o Don't update vgcache when (not really) writing in test mode.
o Don't continue iterating through a possibly-deleted list.
2002-01-16 14:43:27 +00:00
687b39a12a Remove a duplicate disk read (can_handle). 2002-01-16 13:09:26 +00:00
705af407bf #include <string.h> 2002-01-16 12:02:06 +00:00
080052da2e o Set the segment counter back to 1, for a new LV. 2002-01-16 11:34:29 +00:00
ef735fd92a o Add pvmove to the stub file. 2002-01-16 11:27:19 +00:00
17c16dcafc o Knock out the "'%s' is not a block device" debug message. 2002-01-16 09:23:28 +00:00
a89b3018fb Reduce 'no label found' message severity to debug level. 2002-01-16 00:01:36 +00:00
851e2ebd32 Fix function typecasts. 2002-01-15 23:47:56 +00:00
1225ce7fe8 o More comprehensive config parameter debugging messages.
o Make /proc configurable.
 o Review hard-coded "/dev"s - made 2 more of them configurable.
2002-01-15 23:34:13 +00:00
7e77a31b96 o missing labeller free
o updated vgcfgrestore args
o change _check_for_open_devices only to check devices present in the hash
  table instead of using dev_iter which triggers a full scan even when only
  displaying command line help
2002-01-15 21:28:04 +00:00
d146b9002f o Actually check in vgcfgrestore. 2002-01-15 18:17:57 +00:00
1f9d567b23 o vgcfgrestore works ! (with the couple of examples I tried). 2002-01-15 17:37:23 +00:00
ed1b3a023c Another ioctl interface update:
Supply offset to start of variable data area (so struct size can change
without breaking backward compatibility)
  Add command that just returns the driver version
2002-01-15 15:21:57 +00:00
1ca18f501a o split the uuid -> device map out from vgcache
o  roll vgcache back to agk's implementation, we'll revisit this as part
   of the cluster integration.

o  change the extra_info field in a label to be a void *
2002-01-15 10:24:48 +00:00
49588ccd98 Some ioctl interface changes. (Do we want these?)
- use status bits (so we can add flags without changing the struct size)
  - use dev_t
2002-01-14 23:07:32 +00:00
098dedc092 o Non-caching implementation of new vgcache interface. 2002-01-14 11:43:52 +00:00
b06f6b9545 o LVM1 labeller. 2002-01-14 10:00:56 +00:00
ba3cb94999 o Reformat comment and correct typo. 2002-01-14 09:59:12 +00:00
74c67fbf4b o Add rename support to dmsetup.
o Add support to use specified minor number to library and dmsetup.
2002-01-11 12:12:46 +00:00
32b46e4910 Couple of typos fixed. 2002-01-11 11:34:53 +00:00
ecf5539ed2 o Put in the pv_hash which stores the pv section name -> pv struct mapping. 2002-01-11 11:09:12 +00:00
ac9db4e4d5 o label.c now compiles. 2002-01-11 10:43:32 +00:00
0eb96094b0 Change lvm2_label to use Joe's new label switch system. 2002-01-11 10:39:56 +00:00
30b3ac7dc5 Support the renaming of active mapped devices (ioctl interface only). 2002-01-10 23:29:16 +00:00
0092790c7d o ACTIVE is no longer a status flag - lv_active() used to check if an LV
is active in the device-mapper.
o Many operations can be carried out regardless of whether the VG is
  active or not.
o vgscan does not activate anything - use vgchange.
o Change lvrename to support renaming of active LVs.
o Remove '//' appearing in some pathnames.
o Dummy lv_check_segments() for compilation.
2002-01-10 23:21:07 +00:00
28909d8a51 o _read_id function for import.c 2002-01-10 18:12:26 +00:00
b20cfbb7b6 More steps towards successful compilation. 2002-01-10 16:48:28 +00:00
97639bd0a8 Add 'get' functions. 2002-01-10 16:47:58 +00:00
161ec73c96 More detail in error msgs. 2002-01-10 16:47:25 +00:00
957d6bea15 Separate constant fields from variable ones. 2002-01-10 16:47:04 +00:00
f8b6e5b414 Clarify terminology:
VG is resizeable  - PVs can be added or removed
  PV is allocatable - free extents on it may be allocated to LVs
2002-01-10 15:09:51 +00:00
1ab450870e o Moved the current label.[hc] sideways to lvm2_label.[hc]
o  First pass at low level labelling switch.  This allows us to
   register different label types (eg, lvm1, lvm2).
2002-01-10 15:01:58 +00:00
de45f4884c Allow for multiple spellings / backwards compatibility of renamed
command line options.
      vgchange --resizeable y
      pvchange --allocatable y
But --allocation is still allowed for both (as LVM1) and --resizable is OK.
2002-01-10 14:46:50 +00:00
5da1f3e7c8 o vgcfgrestore. 2002-01-10 14:27:47 +00:00
983014952b Temporary file creation & renaming. 2002-01-10 12:22:17 +00:00
55298019a3 o First pass at import.c. Still waiting for label code for the uuid->pv
mapping.
2002-01-10 11:18:08 +00:00
a1ffc3f271 o Put in the 'out of memory' log_err for pool. 2002-01-10 09:35:55 +00:00
2fb60aa997 Renamed to archive.c 2002-01-09 19:17:11 +00:00
f5ec76537a o Rename many occurrences of 'backup' to 'archive' to reduce confusion.
o Extract file creation/renaming code into a library and change backup code
  to use it too.
o Support umask.
o Bring lvm.conf man page up-to-date.
2002-01-09 19:16:48 +00:00
728491fd2b Accept octal values for numbers (such as umask). 2002-01-09 18:53:07 +00:00
d9d3f2b9e4 o Let the comment wars begin. 2002-01-09 14:14:07 +00:00
3fe4864f65 o new function backup_remove(const char *vg_name), to be called from vgremove. 2002-01-09 14:07:49 +00:00
0b156f22a4 o Reformat comments. 2002-01-09 13:56:11 +00:00
35b1d93813 Add archiving. 2002-01-09 13:17:14 +00:00
d770851ac0 o Try to improve NFS-safety for temporary file creation (unique name; O_APPEND
+ fcntl lock) and rename (using hard link), avoiding any "real" archive
  files ever being zero length.
o Fix filename parsing & ordered list handling.
2002-01-09 13:16:19 +00:00
989e7b1033 Explicitly close (=>flush) files. 2002-01-09 13:07:03 +00:00
c4e0eb7b49 Allow pool_begin_object in empty pool. 2002-01-09 13:06:02 +00:00
71f5d0dac7 Another attempt to support both readline versions. 2002-01-08 19:17:08 +00:00
561b0c4381 call archive_exit() & backup_exit() on exit 2002-01-08 18:14:04 +00:00
995fbc7330 o Remove anomalous punctuation. 2002-01-08 10:51:13 +00:00
10ab8949c4 o Introduction to pool for those without psychic powers. 2002-01-08 10:47:17 +00:00
c441202fea fixes for compilation 2002-01-07 23:28:25 +00:00
ca261b0bee Sync. 2002-01-07 23:04:48 +00:00
52f3709f67 Sync tidy. 2002-01-07 22:49:04 +00:00
c2ca6187fe If a device somehow became suspended, lvchange -ay now reactivates it. 2002-01-07 22:36:12 +00:00
671a13d295 Support for read-only. 2002-01-07 22:28:36 +00:00
14c3e2eccf Missing close() in error case. 2002-01-07 22:25:57 +00:00
08e5b852c2 tidying 2002-01-07 22:01:50 +00:00
1c9606c824 o vgcreate wasn't setting vg->cmd 2002-01-07 15:27:55 +00:00
3cd47b5c9b o New function 'merge_segments'
o  Call said function at end of lv_extend
2002-01-07 15:08:28 +00:00
aedc729087 o tidy up renaming of archive files. 2002-01-07 14:21:33 +00:00
5f7cfa3fa9 o sync tool changes for backup stuff. 2002-01-07 11:12:11 +00:00
0083f30af5 o Added find_config_bool 2002-01-07 10:23:52 +00:00
4a06f05ef5 o Get format-text.c compiling. 2002-01-07 09:16:20 +00:00
8f37cadce8 o sync laptop to test machine. 2002-01-07 09:05:31 +00:00
a11603ca6c Imported man pages from LVM1 with some quick LVM2 updates. 2002-01-04 20:35:19 +00:00
86274842e9 The start of an lvm man page. 2002-01-04 18:56:56 +00:00
cf9c955a44 Document remaining configuration file parameters. 2002-01-04 17:49:38 +00:00
55d828c35f o Revert to the 6-4-4-4-4-4-6 format for uuid's
o  When reading a uuid all -'s are stripped, wherever they are.
2002-01-04 16:55:14 +00:00
cdff28aca6 Put device name in quotes. 2002-01-03 17:47:48 +00:00
b9da39274f o High level archiving and backup functions.
I've split the old autobackup function into two seperate areas:

'archiving' is performed *before* a vg configuration is changed.  This
produces a numbered backup in /etc/lvm/archive.

A 'backup' is performed *after* a vg change.  So the directory /etc/lvm/backup
will hold the  a copy of the current configuration.
2002-01-03 15:46:48 +00:00
c379aa5782 stub for read-only functions with fs interface 2002-01-03 15:12:02 +00:00
9dcabac9dd Fix final comma in arrays. 2002-01-03 12:43:01 +00:00
794f3a2b9f *** empty log message *** 2002-01-03 12:39:04 +00:00
2066121b7c o Added -r, --read-only switch to dmsetup for use with create and reload. 2002-01-03 10:39:21 +00:00
0c4067f143 o Allow the definition of read-only devices (ioctl interface only) (Joe)
o Add version number to ioctl structure with error on kernel/library mismatch
2002-01-02 19:01:09 +00:00
8aa69243b7 o Added section on the syntax of the config file, with an informal grammar. 2002-01-02 17:54:57 +00:00
8697263bde Fix $DESTDIR support 2002-01-02 14:23:10 +00:00
ea25c4f65c Tidy makefiles - $DESTDIR & shared library version (like LVM1) 2002-01-02 13:40:49 +00:00
82ac3ebd7e Add test mode parm. 2001-12-31 22:12:03 +00:00
13cb94909c o Add autobackup support to tools (follows most vg_write calls).
o Skip autobackup when in test mode.
o Set test mode from config file.
o Create system/backup dirs if not present (unless LVM_SYSTEM_DIR holds "").
2001-12-31 21:27:39 +00:00
b57ca2a763 vgcache.h inclusion (avoid compiler warning) 2001-12-31 19:18:44 +00:00
83c49e9745 o Use lvm_snprintf wherever return value is used
o Add parameters to set retention limits for backups
2001-12-31 19:09:51 +00:00
e15771d78d Remove some old files. 2001-12-31 17:34:51 +00:00
6edc4920ba Redundant. 2001-12-31 17:26:42 +00:00
302bb1bd93 Document lvm.conf fields 2001-12-31 17:20:22 +00:00
529b1bceee Outline docs 2001-12-31 16:12:40 +00:00
42cd47d32e o Allow more default values to be overridden from config file.
o Cope with both the readline versions used around here.
2001-12-31 15:20:18 +00:00
711d884c2e Fix C99 error case handling (snprintf ret value >= buffer size). 2001-12-31 15:17:34 +00:00
183d1c4674 Fixes for compilation. 2001-12-31 15:14:44 +00:00
faed63a0bb Remove unused --with_kernel_dir
Current version of LVM2 instead relies on /usr/include/libdevmapper.h
which gets installed by the device mapper package.
(Should this location now be configurable?)
2001-12-31 15:13:42 +00:00
53bff262f8 Revised ioctl/dmfs merge with fixes for bugs found in tests. 2001-12-20 20:32:14 +00:00
3251a708e4 o Added a quick vgcfgbackup, needs parameters as yet. 2001-12-20 16:05:14 +00:00
b5dbdbf7b2 o Debug version of the pool_grow stuff. 2001-12-20 12:27:41 +00:00
a9649e92c9 o sync backup changes 2001-12-20 11:52:54 +00:00
b561f1fa8b Wipe the first label if writing the second one failed. 2001-12-18 14:39:32 +00:00
cecd7491b5 o sync the backup stuff 2001-12-17 19:46:10 +00:00
55a66322b5 o history is now saved in ~/.lvm_history 2001-12-17 17:59:58 +00:00
155c31a2d7 o Shuffled completion functions around so we dont have to declare them
at the top of the file.

o Changed completion_matches -> rl_completion_matches, and added some consts.

This will probably break things on pre readline 4.2 systems.
2001-12-17 17:18:47 +00:00
a89ce91089 o Changed the macro name in args.h from 'xx' to 'arg'
o  There is now a _default_debug, and _default_verbose level, when
   using lvm interactively -vv and -dd switches just effect the current
   command.

o  Added a --quiet switch which sets both verbose and debug to zero.
2001-12-17 16:58:17 +00:00
b897fe6700 o Use lvm_snprintf 2001-12-17 14:05:43 +00:00
548a351b06 o Add symlink for lvm-string.h 2001-12-17 14:04:33 +00:00
4b1da57ca1 o lvm_snprintf
Could everyone please use this from now on.
2001-12-17 14:04:10 +00:00
529aec7f25 o Remove LVM_CONFIG_FILE environment variable.
o  Introduced the LVM_SYSTEM_DIR variable.

This makes more sense because the persistent cache, and backup directories
are config specific.

eg, I use /etc/lvm for running my real LV's

    but I have another directory /dev/lvm_loops that contains a config
    that allows only loopback devices, I use this for testing.
2001-12-17 12:01:09 +00:00
1661e545cb Typos in error messages 2001-12-17 11:07:33 +00:00
ec71d08878 I had another look at the argument processing code:
o You must list long args with no short option (eg. --version) at the
  front of the args.h file.

o If an argument has no short option, set the short option in args.h to '\0'

o The index into the 'the_args' var is now stored as the option value
  for getopt, iff there is no short opt.
2001-12-17 10:08:27 +00:00
ac258b7dd7 o Include dmsetup man page in build
o Allow pathname in dmsetup device arg
o Generated patches for 0.90.02
2001-12-14 13:30:04 +00:00
0f57876233 Write the location of both labels in the labels so we can check them. I don't do
much with this ATM (apart from check that they all match up).
Use a different CRC routine.
2001-12-14 13:15:15 +00:00
1d25a3693d o I figure if I can't remember how to use my code, then I should add
a comment.  It's quite cool, wish I remember writing it.
2001-12-13 16:09:06 +00:00
45fa428bf1 Handle orphan PVs too, so hints remain valid after vgreduce. 2001-12-13 15:08:58 +00:00
177fa80f1a o Man page for dmsetup 2001-12-13 13:46:21 +00:00
3261261bfe made the hard-coded 512 into BLOCK_SIZE just for neatness sake.
log_error() if writing the label fails so someone knows which was in error.
2001-12-13 08:40:47 +00:00
d4de7934f8 Add internal cache holding a 'hint' list of the PVs belonging to each VG.
A substantial speed-up - particularly in readline mode.
If the hints turn out to be wrong, the relevant parts get thrown away.
vgscan destroys it totally.  In both cases it then rebuilds itself as
required.
2001-12-13 00:07:29 +00:00
c3475af809 fix for clean compilation 2001-12-12 16:25:53 +00:00
b12f707812 o silly bugs 2001-12-12 16:22:38 +00:00
22c0c34d60 o pool-debug version of end_object wasn't returning the object. 2001-12-12 16:05:52 +00:00
a60b66f230 o Add error checking in _new_chunk 2001-12-12 14:54:24 +00:00
83f6e93628 o pool-debug versions of begin_object, grow_object etc. 2001-12-12 14:25:20 +00:00
222b5f0229 Build label code into the library 2001-12-12 09:09:04 +00:00
30aa383e26 Use a proper CRC calculation. 2001-12-12 09:05:44 +00:00
676b401294 - Change label format to include a string disk_type and a version number.
- The iterator can find labels by string and also appropriate version number (==,
  <= or any) if you want.
- Add labels_match() call that compares the two labels and returns an error if
  they do not match.
- Write labels in sector 1 & last rather than 2 & last as per Joe.
2001-12-11 16:49:40 +00:00
ebf57159de Apply make distclean to test subdirs too. 2001-12-11 16:26:34 +00:00
199d2aafec Fix label filter. 2001-12-11 14:17:10 +00:00
81952f56fd o Add output_date 2001-12-11 12:29:25 +00:00
c5bac82b43 o flags.c reads and writes a status bitset 2001-12-11 12:18:56 +00:00
081b86109c o Split import-export.c into two files. 2001-12-11 12:16:58 +00:00
8ac2028a75 o Update sample to a format that supports multiple vg's per file. 2001-12-11 12:15:08 +00:00
264fed1c9f Label reading/writing code.
Not tested the filter yet.
2001-12-11 11:42:30 +00:00
dd59f7b2c7 o Pretty print and read for uuid's 2001-12-11 11:40:34 +00:00
9245a760db Add a dev_get_sectsize call. 2001-12-11 10:18:49 +00:00
b61b32bbc3 Fixes for allocation of striped volumes. 2001-12-07 21:17:12 +00:00
09b3914f5d Fixes for library compilation. 2001-12-07 21:15:33 +00:00
fe644e4c9e Moved across to device-mapper repository. 2001-12-06 14:20:38 +00:00
7b09bf2156 o Updated projects.txt to remove the earlier error which turned out to be
a build error.
2001-12-05 18:04:55 +00:00
987d0aae66 Various fixes & restructure to extract common code. 2001-12-05 16:41:52 +00:00
9cbcbc1c22 o Removed unused MOD_INC/DEC_USE_COUNT 2001-12-05 12:00:01 +00:00
cfc4e2bc60 o Added a few more projects 2001-12-05 11:58:43 +00:00
a03405fa81 o Initial merge attempt
There are still a few odd things going on, so more debugging remains to be
done.
2001-12-05 11:28:41 +00:00
d5c9ccbe6e Correct activation message. 2001-12-05 00:04:18 +00:00
e52772d65f Added more log messages. 2001-12-04 23:20:27 +00:00
1e3259e728 o sync 2001-12-04 14:14:07 +00:00
e905a20a60 Tweaks for make install. -m args replaces verbose to display maps. 2001-12-03 20:23:53 +00:00
88e2be7a33 More striping support & fixes. 2001-12-03 16:27:16 +00:00
8939131600 o Comparison function was sorting things in ascending rather than
descending order.

o free off the sort array when finished with it.
2001-11-30 09:19:46 +00:00
ba37ebff8b o Striped allocator
o  Changed pv_map.c to maintain the list of free areas in size order, which
   is more helpful to the allocators.  If you want to allocate a bit of an
   area call consume_area(area, size), this will adjust the area if there's
   some space left and shuffle it to the correct place in the list.


Not tested.
2001-11-29 18:45:35 +00:00
28f4cb7e07 o I was reading striped volumes incorrectly. 2001-11-29 14:13:43 +00:00
db1e7102cd o Confusingly, dmfs-tdir isn't gone, its now called dmfs-lv.c and its the
old dmfs-lv.c thats gone.
 o Dropped out support for multiple tables in line with ioctl interface
 o Some reordering to better support the userland library
 o Updated to 2.4.16

I'm fairly happy with the way that this is working now, so the next job is
to start the integration with the ioctl interface so there is a single
common dm.[ch] and selectable interfaces (fs or ioctl).

Further improvements can be made even now, but I hope to wait until we've
got this going and integrated and the libdm parts working as well before
investigating other avenues.
2001-11-29 14:00:04 +00:00
07eb7a5830 New patches for 2.4.16 2001-11-29 13:44:46 +00:00
b7c6c685fa configure --with-interface=ioctl (default) or =fs to choose kernel interface 2001-11-28 21:03:50 +00:00
212134df70 Add autoconf & makefile structure like LVM2. 2001-11-28 20:08:11 +00:00
6eeb5528f5 Add -t or --test arg to all tools that update metadata to avoid
committing metadata changes or (de)activating.
2001-11-28 18:03:11 +00:00
54fad845c9 o Output the correct format for the stripe target 2001-11-28 17:52:27 +00:00
d6c0de6fc7 Fix single stripe resizing. 2001-11-28 16:16:44 +00:00
649c8649f7 Make source files depend on makefiles. 2001-11-28 15:00:49 +00:00
da2f53d1b1 o pool_free was leaving one block hanging around. 2001-11-28 14:58:33 +00:00
405139e3b8 o Tool support for segments.
o vgmerge working.
2001-11-28 13:45:50 +00:00
4f8d347171 Use CFLAGS during make rule generation. 2001-11-28 12:28:03 +00:00
bf0db4876c o pool-debug.c contains an alternative implementation of pool that gets
a seperate chunk of memory from dbg_malloc for each pool_alloc.  This
   will allow the bounds checking code in dbg_malloc to do it's stuff.

o  The normal implementation moved to pool-fast.c

o  pool.c now just contains a #ifdef and includes the appropriate .c file.

Alasdair, could you make sure that gcc -MM get's passed all the
CFLAGS please, otherwise the dependencies get calculated incorrectly.
2001-11-28 09:13:00 +00:00
47a14884d6 o Turn on pool debugging by default (-DDEBUG_POOL) 2001-11-28 09:07:53 +00:00
3a7bbc8b08 Fix a memory smash. 2001-11-27 23:12:06 +00:00
1b1d65372c o extra error checking 2001-11-27 20:03:45 +00:00
fd2faaa16e o These now compile. 2001-11-27 17:39:15 +00:00
0609cdb9ea o Get format1 building. 2001-11-27 17:29:56 +00:00
d3bb140f89 vgmerge first cut 2001-11-27 17:02:24 +00:00
b31dc66628 o Sync up todays work on converting to the segmented representation of
logical volumes.  It includes:

   format1 changes.

   metadata.h changes.

   lv_manip.c changed (striped allocation still not done though).

   activate.c changes.

Nothing has been near a compiler as yet.

Alasdair can you look at changing display.c to use to output the mappings
in a more segment oriented format please ?

I haven't put the span list into struct physical_volume to represent allocated
extents.  I think the burden of maintaining it for things like lv_extend may
out weigh it's uses.
2001-11-27 16:37:33 +00:00
09476171a6 Tool support for multiple (striped) segments (incomplete). 2001-11-27 13:42:37 +00:00
33dee813b5 o change chunk_size to stripe_size 2001-11-26 16:30:43 +00:00
bb4e73c40b o More metadata changes. 2001-11-26 16:18:48 +00:00
b1f23ffa94 LV create/extend prototype changes for striping 2001-11-26 15:31:46 +00:00
b0e8cec1e7 o make it obvious that stripe_segment is variable sized. 2001-11-26 13:15:22 +00:00
5077ae19bc o segments will have to be held as an array of pointers since they're now
variable sized.
2001-11-26 13:03:36 +00:00
0d8447bf59 o sync the new in core rep. for Alasdair.
This will break everything !  Hopefully things will be working again by
   this evening.
2001-11-26 12:49:29 +00:00
c6cf08a274 additional patch required 2001-11-23 12:35:31 +00:00
dc49ae519e o Revised seq_file usage after discussions on linux-fsdevel 2001-11-22 15:14:20 +00:00
904539476a o Make sure that every switch has a short option, even if it's
non-displayable so we can remove the pointer mangling that was
   breaking 64bit arch.s
2001-11-22 14:37:07 +00:00
3fbf02dc82 o activation & active status tests
o lvdisplay fields from kernel
o update lv->size on resize
2001-11-21 19:32:35 +00:00
c9392a840d dmdir path 2001-11-21 19:20:41 +00:00
d164e8ab72 o Remove an old debug statement 2001-11-21 18:24:22 +00:00
6dc62c9fb6 o Display major number 2001-11-21 18:12:41 +00:00
87a9684d66 o use the major number returned from dm_ioctl. 2001-11-21 17:57:57 +00:00
94525e2f44 o There's no need to prefix dm_dir() with /dev/ anymore 2001-11-21 17:20:49 +00:00
b408b1b3b9 o You can now specify the dev directory for libdm
o  dm_dir() returns the full path to the device-mapper dir (eg, /dev/device-mapper).

o  put stat in on _rm_node
2001-11-21 17:08:37 +00:00
27c2f09e32 o Removed _check_devfs
o  We now do a stat to see if the device node is there
2001-11-21 16:47:10 +00:00
19bc4d3349 o Remove hard coded path to /dev/device-mapper/control 2001-11-21 15:49:45 +00:00
f2b6c424d6 Tidy makefiles 2001-11-21 15:41:14 +00:00
a49d4453e9 o Change name of libdm.h 2001-11-21 15:15:37 +00:00
65e50087b9 o Use MKDEV to build the dev_t for mknod 2001-11-21 15:14:35 +00:00
2d90f759d9 o Don't use dmt->dmi until it has been initialised. 2001-11-21 14:52:16 +00:00
4230ac7674 o Migration of device-mapper from LVM_WORK to it's own (public) repository.
Please use this one from now on.
2001-11-21 12:47:42 +00:00
d96e9182e9 o Oops, I thought this was checked in ages ago. 2001-11-21 09:21:31 +00:00
68c87b9616 o Sync. only 2001-11-21 09:20:05 +00:00
7f8e9a0b6d o _emit_target wasn't spotting contiguous targets properly. 2001-11-19 15:44:06 +00:00
81a229f2a5 o Use new info interface to dm. 2001-11-19 15:38:39 +00:00
8be7ae2733 vgdisplay 2001-11-19 15:20:50 +00:00
846bca4cb1 file cmgr.h was initially added on branch CLUSTER_TAG. 2001-11-19 14:40:32 +00:00
f36f353789 file cmgr.c was initially added on branch CLUSTER_TAG. 2001-11-19 14:40:32 +00:00
939a2731ed file clvm.h was initially added on branch CLUSTER_TAG. 2001-11-19 14:40:32 +00:00
835dab97ff Zero first 4k of new LVs. 2001-11-16 15:38:52 +00:00
fa904b53be Don't need EXTRA_LIBS as autoconf fills in LIBS for us with all that is needed.
BTW if there are any *real* autoconf experts out there please feel free to flame
me.
2001-11-16 11:39:13 +00:00
0ec52dddce size_ts aren't really pointers but there are no format specifiers for them,
so this will just have to do.
2001-11-16 11:37:45 +00:00
c289355a3a Fix format characters for printing size_ts 2001-11-16 10:56:11 +00:00
02a13a5a18 Do substitution on LIBS so that those platforms that need -lncurses as well as
lreadline will work.
2001-11-16 10:40:16 +00:00
6cf2a0281b lvrename (without reactivation) 2001-11-15 17:27:45 +00:00
120d35f9af Use POSIX defined PRIu64 for formatting 64 bit unsigned integer types 2001-11-15 15:18:53 +00:00
2b15d5e7b3 Use FMT_64 to format 64bit types 2001-11-15 14:27:51 +00:00
fc167bd3f0 define FMT_64 to be the right format string for 64-bit types a la GFS 2001-11-15 14:27:34 +00:00
91b04abf05 Use inttypes.h 2001-11-15 14:14:03 +00:00
77faac8740 #include <string.h> for memset 2001-11-15 11:46:00 +00:00
43b3d54855 More LV-related tidying. lvdisplay without args now shows all LVs. 2001-11-14 18:38:07 +00:00
69e9b85700 Avoid generating duplicate lv names 2001-11-14 14:12:01 +00:00
0b6d132759 Miscellaneous tidying 2001-11-14 13:52:38 +00:00
7c233c6c0c o lvcreate no longer needs the explicit -n flag
o  disabled zeroing of lv until bug's worked out
2001-11-14 12:07:37 +00:00
c35b290fa4 o Prefix static var with '_' 2001-11-14 10:44:14 +00:00
3d95cfb367 o Added dev_open and dev_close functions
o  Changed disk-rep to use these

o  if NDEBUG is not defined the dev_cache will check for open devices on
   teardown.

I was hoping this would speed things up.  But I'm still getting:

reti:/home/joe/sistina/LVM2/tools# time ./lvm vgchange -a n
  Volume group vg0 successfully changed

real    0m5.751s
user    0m0.060s
sys     0m0.070s

even though I have only 1 device with the vg on it passing the filters.
2001-11-14 10:01:52 +00:00
b90fc3a56e o Deal with sparse lv arrays (on disk)
o  new fn. dev_zero which zero's an area of a device
2001-11-13 18:52:52 +00:00
1ef3fdccf5 o lvdisplay now shows LE / PV map
o fix LE allocation when first PV is full
o reduce VG free_count when removing PVs from VG
2001-11-13 17:53:06 +00:00
02b7f77bd8 o Put underscore between vg and lv name. 2001-11-13 16:14:54 +00:00
0ac7ead922 Merge lvreduce & lvextend into lvresize. 2001-11-13 14:17:50 +00:00
da9d0e03ce o Stuff 2001-11-12 19:28:50 +00:00
120f65f672 o Add ALLOC_SIMPLE 2001-11-12 17:55:05 +00:00
200a14caa4 Remove hard-coding and create device-mapper directory if required 2001-11-12 17:21:25 +00:00
35bf6da8e2 o if any pattern rejects a device, and there were no accepts then reject ! 2001-11-12 17:06:33 +00:00
f08f70276c o check result of an allocation 2001-11-12 16:00:52 +00:00
1ae50fd95b iospace restructured 2001-11-12 15:10:01 +00:00
40512beb47 o add fs.c to the Makefile 2001-11-12 13:02:06 +00:00
0d7f9b2c94 o add uplink from vg to cmd_context 2001-11-12 12:23:10 +00:00
52f42140a7 o Plug in fs_(add|del)_lv 2001-11-12 12:20:58 +00:00
3f6c50297f o Split struct io_space into:
struct format_handler - format methods
   struct format_instance - links instance data, methods, and cmd
   struct cmd_context - dev_dir, memory allocator, device filter
2001-11-12 12:16:57 +00:00
f72d80afc5 o Compile errors 2001-11-12 11:48:31 +00:00
7c5cb13b22 o Ready for testing 2001-11-12 11:42:29 +00:00
d728750eb2 o Fix module ref counts so that you can actually unload dm-mod
N.B. This means that you have to take very great care in the event that
   you want to access the dcache tree from in kernel

 o Added extra field to allow out of memory conditions to result in the
   correct error code. (This hasn't received a lot of testing...)

I've ditched the final project (which would have cleared my whole list)
since its got other complications which I don't have time to fix right
now. Still as Meatloaf says, two out of three ain't bad!
2001-11-10 17:11:36 +00:00
02a70e5667 o Added lvextend
o Full signed arguments to lvreduce/lvextend
o Consistent lv_number/pe map use
o Populate pv->pe_allocated
o Fixes for allocation/writing of multiple LVs
2001-11-09 22:01:04 +00:00
44e51ea5fa sync only, not ready yet 2001-11-09 08:48:22 +00:00
87e201460a lvdisplay & lvreduce 2001-11-08 16:15:58 +00:00
039bd945e2 more todo 2001-11-08 08:19:06 +00:00
e9e52d2b4b o Always set LVM_READ.
o Avoid duplicate deallocation.
2001-11-07 22:47:43 +00:00
2bf92e7399 Oops. Forgot to check this in earlier. Changes as per previous check in
comments.
2001-11-07 19:27:17 +00:00
5b0df241f0 o more todo 2001-11-07 17:38:25 +00:00
76f5b05eff o Lot's to do 2001-11-07 17:25:17 +00:00
40fb6c998f o Added lvs_in_vgs_opened 2001-11-07 15:02:07 +00:00
33f50a342d o pool_empty was very wrong 2001-11-07 14:11:20 +00:00
81523ab68a Tidy and changes to make code smaller.
o Created dmfs.h as a private header for the filesystem code
 o Using seq_file.[ch] written by Al Viro as a generic mechanism for /proc
   style files which have one record per line. We use a slight modification
   here, so if you are using a recent -ac kernel you'll need to replace the
   existing seq_file.[ch] with  the ones here and do a bit of editing to make
   it work. I'll submit the changes to Al Viro shortly as they are very
   small and I think make sense generally.
 o Using fail_writepage()
 o Init code for filesystem now all in dmfs-super.c
 o Some common code reduction amoung the dmfs-*.c files
 o Auto allocation of major device number (default). You can specify a
   particular major by using a module argument. If built in then you don't
   get this option at the moment but it could be added if required.
 o Hotplug support
 o General tidying
 o Updated projects.txt file
 o Patches updated to 2.4.14
2001-11-07 12:12:56 +00:00
2bf8cc62cf o Another pass at the activation code 2001-11-07 11:51:42 +00:00
1ae8247af3 Added GPL disclaimer 2001-11-07 08:50:07 +00:00
5ef32227ec lvcreate 2001-11-06 19:02:26 +00:00
6456e773bd o lv_extend 2001-11-06 12:01:46 +00:00
234fe53ca3 o Factor _allocate out for use by lv_extend 2001-11-06 11:31:29 +00:00
7c93e7a7b3 o lv_reduce
o  pv_maps wasn't taking a list of acceptable pvs
2001-11-06 11:19:33 +00:00
8afc6c7f4b o Contiguous allocation 2001-11-06 10:55:01 +00:00
4609d0fa3a o lv_manip.c will contain the code for lv_create, lv_extend and lv_reduce. 2001-11-06 10:29:56 +00:00
d452c035c6 Reinstate size of lv 2001-11-05 18:07:44 +00:00
45113c8f5a o code for building free area lists on a pv. Compiles but not run. 2001-11-05 16:41:38 +00:00
0acdd3c62b o adjacent extents are now merged into a single target when activating. 2001-11-05 13:37:13 +00:00
96d7d0a33e lvcreate prototype 2001-11-05 13:06:03 +00:00
b6b280267b o build lv name from <vg>_<lv> 2001-11-02 16:45:44 +00:00
6e6d253b1a Link in the activation library. 2001-11-02 16:28:04 +00:00
d92c105db2 o First pass at activation 2001-11-02 13:45:05 +00:00
906db728d6 o Changes to activation interface
o Add pointer lv->vg
o Some naming tweaks to improve clarity
2001-10-31 17:59:52 +00:00
c4b7411565 o LGPL list implementation 2001-10-31 12:47:01 +00:00
de06396046 o random little fixes 2001-10-30 17:53:21 +00:00
ee6bfeb8e3 lvchange 2001-10-30 14:32:48 +00:00
058347321f basic lvscan 2001-10-29 18:23:35 +00:00
feefe49324 o Add read_ahead and stripes to struct logical_volume 2001-10-29 15:34:56 +00:00
187381a9a2 prefix & vgname in lvname 2001-10-29 15:28:00 +00:00
993dfa4368 lvremove 2001-10-29 13:52:23 +00:00
7e35a16440 o Added two items which ought to be done when we update to 2.4.14-pre3 or
above.
2001-10-29 11:06:46 +00:00
e4eeb15926 o Added a file containing a TODO list.
Please add to/edit this file as you think of new ideas or discover bugs. The
items in it are in no particular order. They are also only ideas and hence may
never get implemented depending on whether they turn out to be good ideas or
not.
2001-10-29 10:03:05 +00:00
634e0db26d o rfilter was no longer accepting by default 2001-10-25 18:12:44 +00:00
56855c23e1 o log/overwrite=1 in config file to overwrite instead of append to log 2001-10-25 17:25:48 +00:00
0b00f742e3 o was freeing memory from the wrong pool 2001-10-25 15:24:35 +00:00
b7ab3f673c o fopen error message
o debug options in makefile
2001-10-25 15:07:26 +00:00
be04ea1e35 o pfilter stores results for all aliases. 2001-10-25 14:51:51 +00:00
1f8e695802 o It's a bit of a hack, but the regex filter now makes sure a device path
that passed the filter is at the front of the aliases list.
2001-10-25 14:41:28 +00:00
2d82b2c64f o rfilter now checks all aliases for a match 2001-10-25 14:19:39 +00:00
d076caf473 o use dev_name(dev) to get the name of a device, this operation is cheap
since it just get's the first alias.
2001-10-25 14:04:18 +00:00
c7abdefa31 o Remove a couple of warnings, and one bug in ttree. Spotted by the optimiser 2001-10-25 13:08:29 +00:00
ba772c0bca o Shuffle the keys to stop degeneracy. 2001-10-25 12:38:18 +00:00
5bad234119 o Trivial binary tree 2001-10-25 11:38:19 +00:00
c7e7baaf23 o added aliases list to struct device. 2001-10-25 11:34:55 +00:00
36658a671b o Correction in logic for write access to tables 2001-10-25 11:05:29 +00:00
045f2e10ba o Fix typos from yesterday 2001-10-25 10:37:05 +00:00
fb5a7db66d o Merged common code between hash_destroy and hash_wipe. 2001-10-25 08:31:43 +00:00
ba7d33982e persistent cache fully incorporated. Goodbye to scanning /dev/cdrom :-) 2001-10-24 17:53:50 +00:00
c62279a755 o Updated 00_makefile
o 00_bh-async-3 has been merge with vanilla
2001-10-24 10:52:10 +00:00
17fa1a7ffb o Error list handling now part of fs rather than part of table. 2001-10-24 08:26:10 +00:00
e89ceac351 o Fix bug in dmfs-error.c where it could return too many bytes under some
circumstances.
 o Use sscanf() in dmfs-table.c
 o Use do_generic_file_read() instead of original hand made loop in dmfs-table.c
2001-10-24 07:51:42 +00:00
0b8c30c109 persistent filter & some log message changes 2001-10-23 18:20:27 +00:00
9ab0f463cc o removed old files 2001-10-23 14:17:07 +00:00
6433dda7b8 o forgot to use the path passed into _read_array. 2001-10-23 13:12:05 +00:00
fa7a2f4be4 o test program for the new persistent filter. 2001-10-23 13:11:28 +00:00
ba90e16505 deallocations 2001-10-23 12:33:57 +00:00
008f710203 o rethink of the persistent filter 2001-10-23 12:24:55 +00:00
df2740f126 filter integration into tools 2001-10-23 11:50:49 +00:00
2db89d143e o forgot to retry on EINTR or EAGAIN, doh ! 2001-10-23 11:16:30 +00:00
0525d49da3 o forgot 'static' 2001-10-22 14:40:31 +00:00
e2b0745882 o composite filter that allows us to merge filters. Think of it as &&'ing
filters in order.

eg,

	f = composite_filter_create(2, regex_filter, persistent_filter);

  ownership of the filters passes, they will be destroyed when f's
  destroy method is called.
2001-10-22 14:39:12 +00:00
92e804fc50 o Filter which caches valid devices in a file. Pass in init == 1 to the
constructor if you want it to ignore the existing cache and check every
  device again (eg, vgscan, pvscan).
2001-10-22 14:14:00 +00:00
67abf45576 reinstate a removed line 2001-10-22 13:44:09 +00:00
d2c9c814e7 o removed 00_latest since it never is. 2001-10-22 10:03:05 +00:00
22f8881a64 o tidying 2001-10-21 10:24:10 +00:00
4ab20322fe o Filter for the dev cache that takes values from config file:
devices {

        # first match is final, eg.  /dev/ide/cdrom
		        # get's rejected due to the first pattern

					filter=["r/cdrom/",         # don't touch the music !
							"a/hd[a-d][0-9]+/",
							"a/ide/",
							"a/sd/",
							"a/md/",
							"a|loop/[0-9]+|", # accept devfs style loop back
							"r/loop/",        # and reject old style
							"a/dasd/",
							"a/dac960/",
							"a/nbd/",
							"a/ida/",
							"a/cciss/",
							"a/ubd/",
							"r/.*/"] # reject all others
}


Alasdair this is ready to roll into the tools now.
2001-10-19 18:20:37 +00:00
5370eeecea o First pass at the regex code. lib/regex/matcher takes an array of regex's
and builds a *very* efficient engine that will tell you which regex a string
  matches with only a single pass through the string.  To be used in the config
  file when specifying devices.

o Anchor's aren't supported yet (^ and $) but that won't take long.

o Also when we get some realistic config files we may want to consider adding an
  extra level of indirection to the dfa state in order to compress the table.
  It all depends on how large typical tables get.
2001-10-19 14:36:57 +00:00
ba71cb5dd7 pvdisplay 2001-10-18 16:55:19 +00:00
9aad6c2c52 o Remove unused variable. 2001-10-18 15:59:25 +00:00
4d9627f20c pvchange 2001-10-17 15:29:31 +00:00
c142492e91 o Fix crash that Patrick reported 2001-10-17 15:03:00 +00:00
6bf8d9e207 o Fix a typo. This should fix devfs support. 2001-10-17 14:34:53 +00:00
4f9a6168c1 o Patches to go with earlier check in 2001-10-17 13:13:25 +00:00
38397f99aa Ok. this is the big one.... the change to the new fs interface.
Things to note:

 o Changes to the dm-*.c files have been kept as small as possible during
   the development of the new fs interface and there are a few places where
   the new code does odd things to give the original code what it wants. These
   places will gradually go away during the next few days once we are sure the
   new code is sound.
 o I've spent most of my testing time looking at the parser since thats where
   a lot of the changes are, I've not checked the actual I/O very much, but
   then that code hasn't changed at all.
 o The print operation in the target type operations is there to help in
   debugging and will go away eventually
 o There are some other printk's which will also go away once we are sure that
   things are working correctly.
 o I've tagged the old code with PRE_DMFS if you want to use that until this is
   stable.
 o There are no kernel patches for this yet (will fix after lunch... :-)
      o Makefile needs some changes
      o need to EXPORT_SYMBOL(deny_write_access); in ksyms.c

How to use the new interface ?

 mount -t dmfs dmfs /mnt/dm
 cd /mnt/dm
 mkdir fish fish/tank
 cd fish/tank
 cat ~/my.table > table
 cd ..
 ln -s tank ACTIVE

Creates a logical volume called fish and activates a table called tank, if
there is a problem doing the link, look in /mnt/dm/fish/tank/errors to see
what is wrong.

If you see any odd things happening, let me know right away as I'm sure there'll
be one or two things that slipped through my testing.
2001-10-17 11:34:50 +00:00
f8686d0e75 o Update to parser
o Extra checks in symlink routines
2001-10-17 11:09:43 +00:00
549e3c8f9d pvscan 2001-10-16 18:07:54 +00:00
bb56225b95 o Fixed infinite loop in parser
o Fixed error handling whilst creating volumes
 o General tidy up
2001-10-16 17:09:27 +00:00
f00be261ba vgchange 2001-10-16 16:25:28 +00:00
9cd94f26d0 o Get file size correct for table
o Make parser look at the right object
2001-10-16 12:17:54 +00:00
4d8f5c80a7 o Fixes to parsing code 2001-10-16 11:56:55 +00:00
24a23acc3d o Tidy up, removing debugging printk's no longer needed 2001-10-16 10:38:13 +00:00
ca8703cfd8 o More bug fixes 2001-10-15 22:39:14 +00:00
6dcbb5b2f8 vgextend 2001-10-15 22:04:27 +00:00
a84fdddb2a vgcreate basic extent size validation 2001-10-15 20:29:15 +00:00
38bb2f8ceb More vgcreate error trapping 2001-10-15 18:39:40 +00:00
23f5ef4345 o More fixes 2001-10-15 16:40:17 +00:00
ef8a2a9054 o lvm readline error-case tidy-up
o more vgcreate error cases
2001-10-15 12:49:58 +00:00
96103d0e36 o Some bug fixes
o Added symlink ops
 o Some extra sanity checks
2001-10-15 11:31:00 +00:00
ff5f6748df o vgcreate 2001-10-12 14:25:53 +00:00
1c1fd6c366 vgcreate 2001-10-12 12:21:43 +00:00
32d37d00cb o make ios the first argument to pv_create 2001-10-12 10:52:32 +00:00
82f6cda966 o lift call to check out of pvcreate_single 2001-10-12 10:45:04 +00:00
f1ff8ff0d0 o rename _single pvcreate_signle 2001-10-12 10:43:36 +00:00
756c72902f o made _single static 2001-10-12 10:42:31 +00:00
73f8f0bbd0 o pvcreate
o added uuid unit

o stubbed partition stuff
2001-10-12 10:32:06 +00:00
18ed528f5d o Further tidyups and fixes. 2001-10-12 10:06:40 +00:00
8fd2f136bc sync 2001-10-12 09:52:30 +00:00
0524b1bf67 vgreduce, vgremove, vgrename & vgscan 2001-10-11 21:35:55 +00:00
15716f65ce Some more sync ups
o Error file routines (initial idea)
 o Various fixes for bugs
 o Tidy a few things
 o Added a bit of debugging code ready for when this gets tested
 o get_exclusive_write_access() function which will get moved into namei.c
   I hope (and rewritten accordingly), should this become the final version
   used.

Still a few more areas need thinking about, but in general much closer now I
think. Last area to sort out before testing is the symlink code which is
pretty close now... just a few more checks needed and the actual calls to
the core code.
2001-10-11 20:29:00 +00:00
d46bdba332 o try incrementing pv_number from 1 2001-10-11 16:31:09 +00:00
760728110a o if contained &= instad of & 2001-10-11 15:09:31 +00:00
12d0a194ca o initalise list_heads, initialise list_heads, initi .. 2001-10-11 14:21:38 +00:00
4104543508 o a very quick hack to get vg_number right 2001-10-11 14:10:18 +00:00
5c211db015 o set PV_ALLOCATABLE flag correctly 2001-10-11 13:34:17 +00:00
2dc6180f8d o pv->system_id 2001-10-11 13:22:51 +00:00
e222a34b69 o vg->pv_act 2001-10-11 13:05:55 +00:00
ef17d95063 o calculate pv_numbers and lv_numbers for LVM1 support 2001-10-11 10:55:19 +00:00
853502e5d7 o pe_start wasn't being set properly when exporting to disk
o added a check for lv's with null lv_name

o setup pv->lv_cur correctly

o test program for vg_write
2001-10-11 10:08:44 +00:00
c18e297e77 o Everybody needs dm.h
o Fixed to work with highmem
 o Added dmfs private inode struct for lv and table directories
 o Fixed a number of errors/typos
 o Status file read returns 0 so we can leave this until we've actually got
   something to report in this now.
 o New locking on tables.... still some issues to be worked out here but
   closer now I think.
 o Now use mapping of table directory to hold pages rather than mapping of
   table file inode. Need to write a note to myself to fix issues with the
   file length at the same time....

Well thats enough for tonight I think. The error file will be part of
tomorrows work.
2001-10-10 21:49:21 +00:00
c5a49599ba o sync 2001-10-10 17:11:31 +00:00
df9da9edf5 standardise some log messages 2001-10-10 16:36:32 +00:00
e2200fd050 o builds a very sub-optimal table 2001-10-10 15:30:31 +00:00
c6207f5d9c o allocate and zero the extents before exporting the lv's 2001-10-10 14:56:53 +00:00
4302b7ff6b o zero all of uuid 2001-10-10 13:33:20 +00:00
50a7923438 o uuid_list->id should be NAME_LEN wide 2001-10-10 13:30:58 +00:00
ab416445c8 o sizeof(NAME_LEN), don't do that 2001-10-10 13:24:16 +00:00
a54698d43c o forgot to init a list head 2001-10-10 13:09:40 +00:00
c5a77cc1c0 o dev_write 2001-10-10 13:03:10 +00:00
a9ffa811fc Tidy metadata diagnostic messages. 2001-10-10 12:45:20 +00:00
080a2608e0 o return data not 1 in read_ov 2001-10-10 12:42:03 +00:00
57f2e83d6a o check for orphaned pv's when reading 2001-10-10 12:28:10 +00:00
5b030139d3 o pv_setup for format1, this is the last one ! 2001-10-10 10:55:55 +00:00
0da1ff42d1 o AC_INIT was pointing to an old file 2001-10-10 10:11:25 +00:00
2c599b7baa o metadata.h was in here twice 2001-10-10 10:09:12 +00:00
5c8af8d21a o pv_write for orphan pv's 2001-10-10 10:05:29 +00:00
026f3cfde2 o add munging for format1 and 2 2001-10-10 09:36:29 +00:00
f6349180e8 o Code to calculate the metadata layout. 2001-10-10 09:25:04 +00:00
aa6421921c o stub pv_write to stop tools crashing 2001-10-09 17:44:58 +00:00
7d41d2dab2 o fix seg fault while reading extents 2001-10-09 17:36:48 +00:00
f0b4d18f93 o remove another spurious error message 2001-10-09 17:30:20 +00:00
6750f06e10 o vgremove.
o filter devices by major.
2001-10-09 17:20:02 +00:00
b2bd38fa9e o spot empty list in build_vg 2001-10-09 17:09:46 +00:00
3482a01e22 o proposed interface to the kernel driver 2001-10-09 16:44:30 +00:00
6335467552 o dev-mgr disappears 2001-10-09 16:13:12 +00:00
4a39e65b62 o change pv_read to take a name rather than a device 2001-10-09 16:05:34 +00:00
c50a23e918 o remove spurious log message 2001-10-09 14:42:58 +00:00
1e76b72b98 o hack, hack, hack 2001-10-09 14:26:45 +00:00
b94cf39eef o vg_write compiles 2001-10-09 10:47:52 +00:00
fef254ffff o get_vgs works 2001-10-09 09:22:50 +00:00
e5495863a2 o pv_Read works 2001-10-09 08:58:52 +00:00
3b4df2abf0 o get_pvs now works for format 1 2001-10-09 08:11:52 +00:00
aef2aee6a4 vgrename & vgck 2001-10-08 18:44:22 +00:00
d0d9519149 o test program for get_pvs 2001-10-08 18:09:31 +00:00
685df1d2c5 o get_pvs for format 1
o fix vg_read if vg doesn't exist
2001-10-08 17:53:43 +00:00
08e6b6f2e7 o added pretty printing to read_vg_t, run this on your system
to see what vg's you've got

S: ----------------------------------------------------------------------
2001-10-08 17:28:49 +00:00
66c887d0f3 o read_vg works (or so it claims) 2001-10-08 16:08:16 +00:00
22e9960697 o dev_cache_t program works 2001-10-08 13:58:52 +00:00
64aa6e1f2d o sync 2001-10-08 12:11:33 +00:00
7a93ed9d04 o we were stuill building dev-mgr files 2001-10-08 10:35:59 +00:00
a905e922e9 o read_vg_t compiles 2001-10-08 10:20:25 +00:00
f9f08fc720 o makefile for read_vg_t 2001-10-08 09:50:00 +00:00
8d402d76d0 o get things compiling 2001-10-08 09:45:16 +00:00
46fda6281c o test program for reading a vg 2001-10-08 08:47:27 +00:00
a14dbe1ea6 Sync include file changes. 2001-10-05 21:39:30 +00:00
18810a4c16 o end of day sync 2001-10-05 16:36:53 +00:00
147bc80dba o replace {stack; return 0;}'s with a macro (just for this file). 2001-10-05 15:48:05 +00:00
c7a484195a o low level write path 2001-10-05 15:20:40 +00:00
4968eb6503 o finished writing extent reading code 2001-10-05 13:59:44 +00:00
a6f2d698a9 revised flags and comments 2001-10-05 13:03:03 +00:00
ea5ed93ea5 Just a small sync of pending changes before I start looking at this again
more seriously.

 o Odds and ends
2001-10-05 10:00:13 +00:00
e1140134c6 metadata status flags regrouping & comments; misc tool changes 2001-10-04 22:53:37 +00:00
5ed11e012e o vg_read for format1 2001-10-04 17:48:55 +00:00
5380bd39ca makefile support for tests 2001-10-04 12:07:29 +00:00
2ee2685688 o define the uintN_t types 2001-10-04 11:40:13 +00:00
782002245b o forgot to add this before 2001-10-04 10:25:34 +00:00
7fc0905843 o got dbg_malloc_t working, Alasdair could you look at the Makefile.in it
seems to be having trouble with the dependencies.

o removed some files from the lib makefile that don't compile yet.
2001-10-04 10:13:07 +00:00
72ecb99e54 o Use the __alignof__ extension to set DEFAULT_ALIGNMENT to that required
for a 'double'.
2001-10-04 09:10:11 +00:00
c863507d08 vgcreate & lvmchange outlines 2001-10-03 20:38:07 +00:00
cff86c9093 vgrename & pvchange outlines 2001-10-03 17:03:25 +00:00
0479dfcc54 o added dev-cache.c, dev-io and sorted source files alphabetically 2001-10-03 12:46:17 +00:00
68dd67f21c o moved dev-cache to device dir 2001-10-03 12:43:29 +00:00
540f6858b5 o I've moved the dev-cache and dev-io into here since this directory has a
better name.  dev-mgr will be removed at some point.
2001-10-03 12:41:29 +00:00
b61e791a4f lvremove outline 2001-10-03 12:34:08 +00:00
d0986f9482 o code sync for dev-cache.c
o made copyright headers the same

o added __attribute ((format ... to print_log so we'll get better compile errors

o added iterator to the hash table
2001-10-03 11:06:31 +00:00
112cb0dc28 pvscan framework 2001-10-02 17:09:05 +00:00
0d3d7fdcf2 o test program for the device cache 2001-10-02 13:44:44 +00:00
5d6b89ef3b o test program for the hash table. 2001-10-02 12:46:04 +00:00
ed0b26c09e o Test program for dbg_malloc unit.
I'm postfixing test programs with _t, and benchmarks with _b
2001-10-02 12:27:55 +00:00
ae292bd920 Another step towards consistency & compilation. 2001-10-01 22:12:10 +00:00
6c85a90723 Misc structural changes. 2001-10-01 19:36:06 +00:00
852592066c Misc structural changes. 2001-10-01 19:29:52 +00:00
96e1bc9b44 o changed dev-manager to a dev_filter 2001-10-01 16:21:21 +00:00
b41d81ed31 o get block size moved to dev-io.c 2001-10-01 16:07:29 +00:00
e241ec2244 merge partition code 2001-10-01 15:59:40 +00:00
16e1f1a94c Tidy includes 2001-10-01 15:53:21 +00:00
7a68c42b26 o drop the reference counting in the devices. 2001-10-01 15:43:51 +00:00
37ccc2e118 Merge fixes 2001-10-01 15:29:39 +00:00
4192fe1ab2 o missing * 2001-10-01 15:28:28 +00:00
d5c743d7bb o added filter type. 2001-10-01 15:27:16 +00:00
11814d63e8 Tidy include files 2001-10-01 15:14:39 +00:00
b753656d50 Create symlinks to .h files in an include directory 2001-10-01 13:36:54 +00:00
f7e87611fc o I'm splitting dev-manager in two. dev-cache is the bottom layer that
handles devices.  Dev-manager will sit on this filtering the view.
2001-09-28 15:42:25 +00:00
1fb0e1900e o list.h from kernel for userland tools to use. 2001-09-28 13:19:17 +00:00
954a9731e0 o logical data structures 2001-09-28 13:15:30 +00:00
65c3364ad8 o generic hash table to store void *'s, not efficient, but adequate for LVM. 2001-09-28 13:08:44 +00:00
3d72b7dccc o rewrite of dm_user_bmap, not tested though. 2001-09-27 10:15:02 +00:00
13ee569f06 Fix prototype for malloc_aux 2001-09-27 10:01:17 +00:00
d79ef23a75 Don't include asm/* files 2001-09-27 10:00:47 +00:00
5d0797d4ba o Kill write funcs for error/status files
o Redo write logic for table file
 o Relax rules for symlink content by removing the rewriting function

Well I probably won't get a chance to work on this tomorrow, so this is my
changeset to date.
2001-09-26 20:24:39 +00:00
47a8d7475f o table creation works again. 2001-09-26 19:48:20 +00:00
4939053121 o It should build now 2001-09-26 17:32:57 +00:00
b525bf554e o typos 2001-09-26 17:07:10 +00:00
f00285d2b2 o remove steve's insane ramblings from my code. 2001-09-26 14:32:07 +00:00
040f8d6eda o Lunchtime. 2001-09-26 11:47:02 +00:00
66d905325c o More updates 2001-09-26 09:26:10 +00:00
8b0cd95e73 o Beginnings of new interface. 2001-09-26 08:06:46 +00:00
d867cca6d9 fix memory leak 2001-09-25 16:26:38 +00:00
a28f736369 o quick tidy up 2001-09-25 15:23:20 +00:00
5c3a71cc59 lvactivate checkpoint commit 2001-09-25 12:49:28 +00:00
cef6dadb08 Another missing dependency. 2001-09-24 22:44:06 +00:00
36be817a3e o Check in case of setting up volumes before root is mounted. 2001-09-24 15:18:45 +00:00
02f571f081 Well when things start looking so complicated that future direction becomes
non-obvious, its time to simplify :-)

 o Moving towards a simpler and more obviously correct interface
 o Removed some fs operations in directories representing volumes
 o Changed some file names
 o Made things cleaner

more changes to follow...
2001-09-24 15:10:33 +00:00
157159e487 Fix dependencies. 2001-09-24 12:05:04 +00:00
02ada9f800 Makefiles & autoconf. 2001-09-21 12:37:43 +00:00
6fcf9a97bb Initialise root node pointer. 2001-09-21 12:32:37 +00:00
17a5d8799f Unused variables. 2001-09-21 12:31:57 +00:00
31f3fe7a22 o Sync up of todays changes .... nothing very important 2001-09-20 22:58:06 +00:00
89e46d3d83 o Bug fix in error path 2001-09-20 20:22:15 +00:00
885795e67d o Use ERR_PTR and PTR_ERR rather than an extra argument. 2001-09-20 19:25:58 +00:00
92bfb53dd4 o Changed to use table->err_msg rather than passing functions around 2001-09-20 18:22:35 +00:00
4cecbeb115 o Some new files (also part of new fs interface) 2001-09-19 21:28:25 +00:00
5971480f55 o Further changes to new file system interface 2001-09-19 21:27:46 +00:00
05bebea511 o Removed the error reporting function from the target constructor function
arguments. Errors are now reported by setting a pointer in the table to
   point to an error message.
2001-09-19 21:27:15 +00:00
76fa6c5cfb hardsect/blksize handling 2001-09-19 17:46:27 +00:00
633b68b518 o Added ref counting to tables
o Further changes to new fs interface
2001-09-19 16:01:27 +00:00
6913d8e995 o Fixed a bug where we were not holding a reference of the block devices
used by the targets correctly.
2001-09-19 14:54:44 +00:00
f3654e6f8d o Change the deallocation of tables to match the vmalloc changes in my
previous commit
2001-09-19 11:02:02 +00:00
d685dbcf22 o Cut down number of vmallocs to increase speed and efficiency 2001-09-19 10:59:10 +00:00
6a57fa079e o More fs fiddling. Another check point commit. 2001-09-19 10:32:51 +00:00
0a91d145ba o Bug fix to LV_BMAP ioctl()
o Account for I/O against tables rather than logical volume devices
2001-09-19 10:32:09 +00:00
c2866e799d Fix allocation & list-handling. 2001-09-18 20:03:00 +00:00
d8cffcaae7 These files are now a bit closer towards what I'm aiming at. Still a lot
more to do though.
2001-09-18 16:54:14 +00:00
30abca7be2 Should have been included in the previous commit. 2001-09-18 16:53:18 +00:00
edce87f3fb o Changed dm_create() to return a struct mapped_device rather than an int
o Changed dm_remove() to accept a struct mapped_device argument rather than
   a name
 o We no longer have to look up devices by name, the dcache handles that
   nicely for us
 o Fixed a bug where we were freeing a structure before we'd finished with
   it.
 o The name field in struct mapped_device is now only used in a very few
   places in dm.c and will be replaced in future with a back reference to
   the dentry rather than keeping the name in two places.
2001-09-18 16:52:50 +00:00
66bac98fc2 o New file dmfs-super.c
o dmfs-dir.c becomes dmfs-lv.c
 o dmfs-file.c becomes dmfs-table.c
 o A few tweeks and updates

The main reason for the slow progress on these files (which are not yet used
by the device mapper) is that we are working out what this interface should
look like as we go along.

Once this has evolved a bit further and in a state where it can be used we'll
announce it on the lists for further comment.
2001-09-18 15:38:54 +00:00
59156de92b Error checking: only allow block devices & test for 'nodev'. 2001-09-17 21:17:30 +00:00
e0d7d10600 o Again, please ignore this for the time being. 2001-09-17 19:05:49 +00:00
daaf862257 o Arbitrary mount path.
o Name length 128.
2001-09-17 16:55:31 +00:00
9de53d4b59 o Work in progress, please ignore these files for a day or two whilst I
get everything going.
2001-09-17 15:42:59 +00:00
f1571e2d46 o Fixed code where return value of vmalloc wasn't checked 2001-09-17 11:23:13 +00:00
bd28d06298 o Use count should be an atomic_t 2001-09-17 09:01:23 +00:00
a24e4655eb o Targets now get rw passed through so they can do COW for example
o Added error handler (not sure that this is the "correct" way to do
   this at the moment, so its a bit exprimental for now)
2001-09-14 16:22:02 +00:00
20a6c8d8e5 o Support /sbin/hotplug 2001-09-14 15:35:06 +00:00
98d264faf4 o Made pending I/O wait uninterruptible 2001-09-14 14:03:02 +00:00
321902a9b5 o New ioctl(): LV_BMAP which is compatible with LVM so that hopefully LILO
will work. I haven't actually tested that, but this support at least will
   be required.
2001-09-14 13:45:40 +00:00
8df5d06f9a Use dmfs_ function name prefix (in line with other file systems). 2001-09-14 13:27:58 +00:00
e69ea529cc lc->in->f_op->read expects its buffer to be in userspace so surround it in
set_fs() etc calls
2001-09-14 12:27:57 +00:00
15405b1119 o As promised earlier, the device registration is now hashed and the
lists are private to dm-blkdev.c
2001-09-14 11:25:51 +00:00
d2f97ce2da Always truncate error file. 2001-09-14 11:15:54 +00:00
543ca631e9 Don't store things in _devs[-1] - it's not nice. 2001-09-14 10:54:08 +00:00
f184886db1 o Forgot to create slab caches for dm-blkdev.c
o Misc code tidy
2001-09-14 10:40:20 +00:00
8432ab4324 o kmalloc error check
o error file mode
The 1st Jan 1970 date I'm seeing in /dev is a devfs issue I think.
2001-09-14 10:06:22 +00:00
6c05b37ca3 Changes to device handling;
o Only one list of block devices for all tables
 o Locking to ensure that block devices only get opened once
 o Block device handling is now in dm-blkdev.c
 o We open block devices when we create the tables and hold them open until
   the table is destroyed (this prevents the module for the device being
   unloaded after table parsing and before the table is used)
 o We compute the hardsect size when the table is created rather than when
   someone requests it.

Still to fix/change:

 o Probably want to hash the device lists in dm-blkdev.c and also remove refs
   to struct dm_bdev outside this file.
 o Need to ensure that hardsect_size doesn't change when new tables are
   swapped in (maybe this ought to be a per volume parameter and the tables
   will only parse if they match the value for the volume?).

Things are changing fast here, so if you want a stable version of thic code
try checking out yesterdays.
2001-09-14 09:45:35 +00:00
35f4beeb47 o New code for handling block device registration. Not yet used but checked
in for backup purposes.
2001-09-14 08:06:02 +00:00
cbad7caa68 is_identifier characters 2001-09-13 21:50:38 +00:00
b0388a4012 o Two fixes which Alasdair pointed out. 2001-09-13 20:10:14 +00:00
df3fab4d55 o Tidy in dm-fs.c
o Magic number is really magic
 o Check on directory names
2001-09-13 19:41:46 +00:00
da49f88a03 o Forgot to add ref to module. 2001-09-13 19:36:40 +00:00
e28feceb06 Add dm-parse to makefile 2001-09-13 19:09:23 +00:00
50496a164d o Now we handle target modules correctly
o Moved the linear target into its own module (not really because it needs to
   be there, but because its useful to have a simple example so people can see
   what we are doing)

Btw, this needs testing properly.
2001-09-13 18:30:05 +00:00
6f1dce1572 o Remove hard-coded mount point
o Fix macro for compilation
2001-09-13 16:52:50 +00:00
6847776ae7 o Some structures change size with different configs, so always include
<linux/config.h> first.
2001-09-13 14:03:42 +00:00
67bd53bdd8 o Some ioctl() commands. 2001-09-13 14:01:13 +00:00
e735abfdfd Fix includes so that string functions get prototyped 2001-09-13 12:38:31 +00:00
1de93a2d6d Fix includes so that string functions get prototyped.
Fix cast - repeat after me Joe: "I must not cast pointers to ints"!
2001-09-13 12:38:08 +00:00
36f9e7c742 o I'm afraid that wu and wl etc. is just too confusing.... I've changed it
to up_write() and down_write() etc so that you can see what kind of a lock
   it is (otherwise it could be anything.. semaphore, spinlock, spinlock_bh,
   spinlock_irq, br_lock, etc.)
2001-09-13 11:29:38 +00:00
9462763bbb o Use kmem_cache_destroy() to remove slab cache. 2001-09-13 11:07:08 +00:00
4ae0880ea6 Set DEFAULT_ALIGNMENT to 8 for Alpha.
If you think this is wasteful on other arches then stick some ifdefs in.
2001-09-13 09:03:42 +00:00
6ae2b6c835 Add dm-parse 2001-09-12 13:50:26 +00:00
a0f180fd48 o first sattab at custom fs. Very rough ATM.
Mount the dm-fs filesystem on /device-mapper (will fix later).  mkdir
to create a device, inside that directory every file you create is a table
file.  If there are errors <table>.err will appear automagically.  Mv a table
file to ACTIVE to activeate the device.  I'm not happy with mv being the
binding command, symlink would be better.
2001-09-07 11:34:46 +00:00
bf1cf89914 o more tidy ups from Clausen. 2001-09-05 07:48:11 +00:00
297a047fb4 o Added two new functions get_child [Andrew Clausen] and get_node. I think
this makes 'high()' a bit more understandable.
2001-09-04 10:17:28 +00:00
52ffc15ffc o added new constant CHILD_PER_NODE to make things clearer 2001-09-03 08:36:41 +00:00
e478c9c693 o Various tidy ups [Andrew Clausen] 2001-09-02 10:49:20 +00:00
d004f28074 o added global dm_table_lookup_device(path)
o changed linear target to : <device_path> <start>
2001-08-31 18:26:27 +00:00
bc68ed8b1d o added reference counting to the destination devices, make sure that the
destructor for any targets you write call dm_table_remove_device.
2001-08-31 16:36:56 +00:00
04555ae650 o split struct mapped_device into mapped_device and dm_table
o seperated loading of a table from binding a table to the device

These should allow multiple tables to be managed by dm-fs
2001-08-31 15:13:33 +00:00
e8f62085be o tidy ups 2001-08-31 12:49:31 +00:00
f430bffe2a o allocate io_hooks from a slab 2001-08-31 10:25:32 +00:00
1f0520634f o stray return -ENXIO in reuqest [Jens Axboe] 2001-08-31 09:43:35 +00:00
902d4c31fb o rebuilt 00_latest 2001-08-31 09:14:55 +00:00
17364ac09f o split uml part out 2001-08-29 14:23:40 +00:00
0b889f8f81 o various little tidy ups 2001-08-29 13:58:48 +00:00
40e349ff35 o change format of table line to <start> <len> <target> ... 2001-08-28 14:56:47 +00:00
c943b1b1df o Enable building dm modules (called dm-mod)
o split the patches into config and makefile specific.
2001-08-28 14:11:55 +00:00
912bc1d4e1 o more deferred io stuff 2001-08-28 14:05:22 +00:00
cacb1533a3 o added proper suspend/resume support, it now waits for all 'in flight' io's
to complete.

  
  moved comment to dm.h
2001-08-28 13:04:44 +00:00
f0feaca9d7 o ACtual source code patch 2001-08-24 09:50:16 +00:00
b6656f171b o a couple of patches we'll need for deviec-mapper 2001-08-24 09:39:32 +00:00
6206ab3931 o you can now load maps repeatedly without hanging
o tested multiple target map

Driver is now useable
2001-08-23 17:10:05 +00:00
c35fc58b1f o dm_add_target was returning 0 an error when it shouldn't
o reference count was being checked badly
2001-08-23 16:45:43 +00:00
deed8abed7 o map loads ok now
o request function appears to work, but something is segfaulting when i
  mke2fs
2001-08-23 12:35:02 +00:00
7151ad23f0 Tweak permissions - currently root-only. (no support for non-root ownership
in procfs except for PIDs)
2001-08-22 20:10:06 +00:00
0166d938af o chagngesd alloc to return 0 on success 2001-08-22 15:59:56 +00:00
6194aeddb0 o fs_add and fs_remove actually create/remove the device now 2001-08-22 15:33:08 +00:00
903dbf2c30 o added brackets to make t->name = (char *) (t + 1) more explicit 2001-08-22 15:12:31 +00:00
9380f9ff57 Return 0 on success now. 2001-08-22 15:02:55 +00:00
259ed95486 o wu macro was doing a read unlock
o added dm_fs_add/remveove
2001-08-22 15:01:09 +00:00
2ebc92681e o _tok_cpy was broken 2001-08-22 14:30:30 +00:00
195a1ffe13 o fix get_word
o capy name in when registering targets

o change _line_splitter so it expects the process functions to return zero
  on success
2001-08-22 14:13:26 +00:00
a8c2978185 o _get_workd was always returning the end on iput 2001-08-22 13:52:26 +00:00
140f97a457 o Initialisation tweaks.
o Use different major number so it can co-exist with LVM 1.
2001-08-22 13:46:58 +00:00
7f94445a1e o set permissions on /proc/device-mapper/control to -w-w-w 2001-08-22 13:45:28 +00:00
82a89aec65 o call dm_init_fs 2001-08-22 13:41:00 +00:00
7e95110232 o Ok, this seems to be a much better method for caching valid
devices based on /proc/devices
   + The dev_mgr structure now has a 256 element char array that is
     initially all 0s
   + When a match is found, the array element corresponding to the major
     number of the match is set to a non-zero value
   + to check for a match, all one has to do is check that the array
     element at the major number in question is non-zero.
 o I'm wondering if we should do this with bitwise operators instead?  Does
   anyone expect the major numbers to grow larger than 8-bits?
2001-08-21 20:40:37 +00:00
ec4aaaad89 o Quick and dirty *UGLY* hack of a /proc/devices cache using a linked list
o I don't like it, but I'm committing it so I can go back and laugh at
   myself later
 o I have a (hopefully) better idea that i'll try to commit yet today.
2001-08-21 19:51:04 +00:00
1b790fde24 o Quick and dirty hack to get lvm_check_dev code into the dev-manager
o I'm working on caching the /proc/devices entries now, and should have
   that in by the end of today or early tomorrow.
 o There will be much cleanup involved with that...
2001-08-21 18:20:14 +00:00
aaccea731e o quick hack to get the proc entry registering 2001-08-21 15:31:50 +00:00
29e31d7610 o dm-fs compiles, I've forgotten to register the device in /proc though 2001-08-21 15:24:02 +00:00
aa51f4a98f o Added a basic makefile to build liblvm.a again
o Modified source files so that this works
2001-08-21 15:23:45 +00:00
e6ccd12f00 o Brought hash table code over from experimental 2001-08-21 15:22:59 +00:00
b134315df1 o wasn't including dm-fs.o in the build 2001-08-21 14:52:54 +00:00
7f34dffa13 o dm-target compiles 2001-08-21 14:51:41 +00:00
fa239e78c9 o dm-table compiles 2001-08-21 14:47:42 +00:00
707a6c4d6a o Added _basic_ config file support to the device manager 2001-08-21 14:44:18 +00:00
e5da303b43 o make dm.c compile 2001-08-21 14:28:00 +00:00
84ccd66331 o 2.4.9 support
o new uml-lvm patch
2001-08-21 13:45:16 +00:00
ad8cc2baea o Populating with stuff from experimental 2001-08-21 13:22:16 +00:00
7c4cf70309 o Populating with stuff from experimental 2001-08-21 12:56:08 +00:00
c3211e9b4f o dm_activate/dm_close 2001-08-20 16:12:22 +00:00
268d94c983 dec use count on close. corrects a typo.
Really the use counts on these modules should be handled at a higher level,
otherwise there are races I think.
2001-08-20 15:59:22 +00:00
0bcacbba58 o implemeted dm_start_table/dm_add_entry/dm_complete_table as used by
the /proc interface.
2001-08-20 15:22:44 +00:00
8cdc26add9 o changed _dev_lock to a rw_semaphore 2001-08-20 14:06:25 +00:00
e0b2238886 o proc interface is getting there. 2001-08-20 13:45:43 +00:00
369a2e4029 o missed one 2001-08-20 08:05:51 +00:00
c4089e3b51 Just syncing with the office.
o device-mapper.c has split
2001-08-20 08:03:02 +00:00
9e2e9bc5b8 o added a description 2001-08-16 15:14:07 +00:00
a9e44426ed o checked in the new driver, and the uml dir 2001-08-16 08:26:13 +00:00
660 changed files with 173495 additions and 861 deletions

340
COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

504
COPYING.LIB Normal file
View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

31
INSTALL Normal file
View File

@ -0,0 +1,31 @@
Installation
============
1) Generate custom makefiles.
Run the 'configure' script from the top directory.
If you don't want to include the LVM1 backwards-compatibility code use:
./configure --with-lvm1=none
To separate the LVM1 support into a shared library loaded by lvm.conf use:
./configure --with-lvm1=shared
Use ./configure --help to see other options.
2) Build and install.
Run 'make' from the top directory to build everything you configured.
Run 'make install' to build and install everything you configured.
If you only want the device-mapper libraries and tools use
'make device-mapper' or 'make install_device-mapper'.
3) If using LVM2, create a configuration file.
The tools will work fine without a configuration file being
present, but you ought to review the example file in doc/example.conf.
Please also refer to the WHATS_NEW file and the manual pages for the
individual commands.

162
Makefile.in Normal file
View File

@ -0,0 +1,162 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SUBDIRS = doc include man scripts
ifeq ("@UDEV_RULES@", "yes")
SUBDIRS += udev
endif
ifeq ("@INTL@", "yes")
SUBDIRS += po
endif
SUBDIRS += lib tools daemons libdm
ifeq ("@APPLIB@", "yes")
SUBDIRS += liblvm
endif
# FIXME Should use intermediate Makefiles here!
ifeq ($(MAKECMDGOALS),distclean)
SUBDIRS = doc include man scripts \
lib tools daemons libdm \
udev po liblvm test \
unit-tests/datastruct unit-tests/mm unit-tests/regex
endif
DISTCLEAN_DIRS += lcov_reports*
DISTCLEAN_TARGETS += config.cache config.log config.status make.tmpl
include make.tmpl
libdm: include
lib: libdm
liblvm: lib
daemons: lib tools
tools: lib device-mapper
po: tools daemons
lib.device-mapper: include.device-mapper
libdm.device-mapper: include.device-mapper
liblvm.device-mapper: include.device-mapper
daemons.device-mapper: libdm.device-mapper
tools.device-mapper: libdm.device-mapper
device-mapper: tools.device-mapper daemons.device-mapper man.device-mapper
ifeq ("@INTL@", "yes")
lib.pofile: include.pofile
tools.pofile: lib.pofile
daemons.pofile: lib.pofile
po.pofile: tools.pofile daemons.pofile
pofile: po.pofile
endif
ifneq ("$(CFLOW_CMD)", "")
tools.cflow: libdm.cflow lib.cflow
daemons.cflow: tools.cflow
cflow: include.cflow
endif
ifneq ("@CSCOPE_CMD@", "")
cscope.out:
@CSCOPE_CMD@ -b -R -s$(top_srcdir)
all: cscope.out
endif
DISTCLEAN_TARGETS += cscope.out
check check_cluster check_local unit: all
$(MAKE) -C test $(@)
install_system_dirs:
$(INSTALL_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR)
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR)
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR)
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_LOCK_DIR)
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_RUN_DIR)
$(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache
install_initscripts:
$(MAKE) -C scripts install_initscripts
install_systemd_units:
$(MAKE) -C scripts install_systemd_units
LCOV_TRACES = libdm.info lib.info tools.info \
daemons/dmeventd.info daemons/clvmd.info
CLEAN_TARGETS += $(LCOV_TRACES)
ifneq ("$(LCOV)", "")
.PHONY: lcov-reset lcov lcov-dated $(LCOV_TRACES)
ifeq ($(MAKECMDGOALS),lcov-dated)
LCOV_REPORTS_DIR := lcov_reports-$(shell date +%Y%m%d%k%M%S)
lcov-dated: lcov
else
LCOV_REPORTS_DIR := lcov_reports
endif
lcov-reset:
$(LCOV) --zerocounters $(addprefix -d , $(basename $(LCOV_TRACES)))
# maybe use subdirs processing to create tracefiles...
$(LCOV_TRACES):
$(LCOV) -b $(basename $@) \
-d $(basename $@) -c -o - | $(SED) \
-e "s/\(dmeventd_lvm.[ch]\)/plugins\/lvm2\/\1/" \
-e "s/\(dmeventd_mirror.c\)/plugins\/mirror\/\1/" \
-e "s/\(dmeventd_snapshot.c\)/plugins\/snapshot\/\1/" \
>$@
ifneq ("$(GENHTML)", "")
lcov: $(LCOV_TRACES)
$(RM) -r $(LCOV_REPORTS_DIR)
$(MKDIR_P) $(LCOV_REPORTS_DIR)
for i in $(LCOV_TRACES); do \
test -s $$i && lc="$$lc $$i"; \
done; \
test -z "$$lc" || $(GENHTML) -p @abs_top_builddir@ \
-o $(LCOV_REPORTS_DIR) $$lc
endif
endif
ifeq ("$(TESTING)", "yes")
# testing and report generation
RUBY=ruby1.9 -Ireport-generators/lib -Ireport-generators/test
.PHONEY: unit-test ruby-test test-programs
# FIXME: put dependencies on libdm and liblvm
# FIXME: Should be handled by Makefiles in subdirs, not here at top level.
test-programs:
cd unit-tests/regex && $(MAKE)
cd unit-tests/datastruct && $(MAKE)
cd unit-tests/mm && $(MAKE)
unit-test: test-programs
$(RUBY) report-generators/unit_test.rb $(shell find . -name TESTS)
$(RUBY) report-generators/title_page.rb
memcheck: test-programs
$(RUBY) report-generators/memcheck.rb $(shell find . -name TESTS)
$(RUBY) report-generators/title_page.rb
ruby-test:
$(RUBY) report-generators/test/ts.rb
endif

29
README
View File

@ -1,2 +1,27 @@
This is pretty much empty so far...if you can't see subdirectories,
try 'cvs -f update'
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

1
VERSION Normal file
View File

@ -0,0 +1 @@
2.02.92(2)-cvs (2012-02-20)

1
VERSION_DM Normal file
View File

@ -0,0 +1 @@
1.02.71-cvs (2012-02-20)

2871
WHATS_NEW Normal file

File diff suppressed because it is too large Load Diff

757
WHATS_NEW_DM Normal file
View File

@ -0,0 +1,757 @@
Version 1.02.71 - 20th February 2012
====================================
Switch to using built-in blkid in 13-dm-disk.rules.
Add "watch" rule to 13-dm-disk.rules.
Detect failing fifo and skip 20s retry communication period.
Add DM_DEFAULT_NAME_MANGLING_MODE environment variable as an override.
Add dm_lib_init to automatically initialise device-mapper library on load.
Replace any '\' char with '\\' in table specification on input.
Add mangle command to dmsetup to provide renaming to correct mangled form.
Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
Add --manglename option to dmsetup to select the name mangling mode.
Add dm_task_get_name_mangled/unmangled to libdevmapper.
Mangle device name on dm_task_set_name/newname call if necessary.
Add dm_set/get_name_mangling_mode to set/get name mangling in libdevmapper.
Add configure --with-default-name-mangling for udev-friendly dev name charset.
Test for parsed words in _umount() dmeventd snapshot plugin.
Fix memory leak in fail path of parse_loop_device_name() in dmsetup.
Check for missing reply_uuid in dm_event_get_registered_device().
Check for allocation failure in dmeventd restart().
Add few missing allocation failures tests in dmsetup.
Fix potential risk of writing in front of buffer in _sysfs_get_dm_name().
Version 1.02.70 - 12th February 2012
====================================
Fix dm_event_get_version() check.
Add pointer test for dependency check in _add_dev().
Validate name and uuid params of dm_tree_add_new_dev_with_udev_flags().
Do not crash for dm_report_init() sort_key == NULL and behave like "".
Return error for failing allocation in dm_asprintf().
Add missing test for failing allocation in dm_realloc() code.
Add test for memory allocation failures in regex matcher code.
Simplify dm_task_set_geometry() and use dm_asprintf().
Set all parameters to 0 for dm_get_next_target() for NULL return.
Fix fd resource leak in error path for _udev_notify_sem_create().
Leave space for '\0' for readline() call in _sysfs_get_kernel_name().
Version 1.02.69 - 1st February 2012
===================================
Clean up dmeventd systemd unit ordering and requirements.
Version 1.02.68 - 26th January 2012
===================================
Reset all members of info struct in dm_tree_add_new_dev_with_udev_flags.
Add dmsetup wipe_table to replace table with one that uses error target.
Add 'blkdevname' and 'blkdevs_used' fields to dmsetup info -c -o.
Add 'blkdevname' option to dmsetup ls --tree to see block device names.
Add -o devno/blkdevname/devname to dmsetup deps and ls.
Add dm_device_get_name to get map name or block device name for given devno.
Remove empty devices when clearing left-over inactive tables in deptree.
Add dm_uuid_prefix/dm_set_uuid_prefix to override hard-coded LVM- prefix.
Improve dmsetup man page description of readahead parameter.
Use sysfs to set/get readahead if possible.
Fix lvm2-monitor init script to use normalized output when using vgs.
Add test for max length (DM_MAX_TYPE_NAME) of target type name.
Include a copy of kernel DM documentation in doc/kernel.
Improve man page style for dmsetup and mention more targets.
Fix _get_proc_number to be tolerant of malformed /proc/misc entries.
Fix missing thread list manipulation protection in dmeventd.
Add ExecReload to dm-event.service for systemd to reload dmeventd properly.
Add dm_config_tree_find_str_allow_empty and dm_config_find_str_allow_empty.
Fix compile-time pool memory locking with DEBUG_MEM.
Fix valgrind error reports in free of pool chunks with DEBUG_MEM.
Align size of structure chunk for fast pool allocator to 8 bytes.
Simplify some pointer operations in dm_free_aux() debug code.
Remove unused dbg_malloc.h file from source tree.
Cleanup backtraces for _create_and_load_v4().
Fix alignment warning in bitcount calculation for raid segment.
Allocate dm_tree structure from dm_tree pool.
Update debug logging for _resume_node.
Add functions to support thin provisioning target.
Improve libdm-config error path reporting.
Update dmsetup resume man with --addnodeonresume/create options.
Add dependency for dm man pages to man subdirectory make all target.
Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree.
Add dm_device_has_mounted_fs fn to check mounted filesystem on a device.
Add dm_device_has_holders fn to to check use of the device by another device.
Add dm_sysfs_dir to libdevmapper to retrieve sysfs location set.
Add dm_set_sysfs_dir to libdevmapper to set sysfs location.
Add --retry option for dmsetup remove to retry removal if not successful.
Add dm_task_retry_remove fn to use retry logic for device removal.
Remove unused passed parameters for _mirror_emit_segment_line().
Add dm_config and string character escaping functions to libdevmapper.
Mark unreleased memory pools as internal error.
Version 1.02.67 - 19th August 2011
==================================
Add dm_tree_node_add_null_area for temporarily-missing raid devs tracked.
Version 1.02.66 - 12th August 2011
==================================
Release geometry buffer in dm_task_destroy.
Update udev rules to skip DM flags decoding for removed devices.
Add compile-time pool memory locking options (to debug shared VG structs).
Remove device name prefix from dmsetup line output if -j & -m or -u supplied.
Remove support for the original version 1 dm ioctls.
Add missing check for allocation failure _create_dir_recursive().
Add support for systemd file descriptor handover in dmeventd.
Fix memory leak in dmsetup _message() memory allocation error path.
Use new oom killer adjustment interface (oom_score_adj) when available.
Add systemd unit files for dmeventd.
Fix read-only identical table reload supression.
Version 1.02.65 - 8th July 2011
===============================
Remove dev name prefix from dmsetup line output if exactly one dev requested.
Report internal error if suspending a device using an already-suspended dev.
Report error if a table load requiring target parameters has none supplied.
Add dmsetup --checks and dm_task_enable_checks framework to validate ioctls.
Add age_in_minutes parameter to dmsetup udevcomplete_all.
Return immediately from dm_lib_exit() if called more than once.
Disable udev fallback by default and add --verifyudev option to dmsetup.
Report internal error if any table is loaded while any dev is known suspended.
Add dm_get_suspended_counter() for number of devs in suspended state by lib.
Fix "all" report field prefix matching to include label fields with pv_all.
Delay resuming new preloaded mirror devices with core logs in deptree code.
Accept new kernel version 3 uname formats in initialisation.
Version 1.02.64 - 29th April 2011
==================================
Require libudev >= 143 when compiling with udev support.
Use word alignment for dm_pool_strdup() and dm_pool_strndup().
Use dm_snprintf() to fix signedness warning in dm_set_dev_dir().
Use unsigned loop counter to fix signedness warning in _other_node_ops().
Fix const cast in dmsetup calls of dm_report_field_string().
Streamline /dev/mapper/control node code for common cases.
Use hard-coded dm control node device number for 2.6.36 kernels and above.
Improve stack debug reporting in dm_task_create().
Fallback to control node creation only if node doesn't exist yet.
Change dm_hash binary functions to take void *key instead of char *.
Fix uninitialised memory use with empty params in _reload_with_suppression_v4.
Lower severity of selabel_lookup and matchpathcon failure to log_debug.
Add test for failed allocation from dm_task_set_uuid() in dmeventd.
Add dm_event_get_version to dmeventd for use with -R.
Avoid dmeventd core dumps when handling request with unknown command ID.
Have dmeventd -R start up even when no existing copy is running.
Accept multiple mapped device names on many dmsetup command lines.
Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
Include an implicit dm_task_update_nodes() within dm_udev_wait().
Fix _create_and_load_v4 not to lose the --addnodeoncreate setting (1.02.62).
Add inactive table query support for kernel driver >= 4.11.6 (RHEL 5.7).
Log debug open_count in _node_has_closed_parents().
Add a const to dm_report_field_string() data parameter.
Version 1.02.63 - 9th February 2011
===================================
Reinstate DEBUG_MEM as it's part of the API. (1.02.62)
Version 1.02.62 - 4th February 2011
===================================
Add configure --with-device-nodes-on=create for previous behaviour.
Move creation of device nodes from 'create' to 'resume'.
Add --addnodeonresume and --addnodeoncreate options to dmsetup.
Add dm_task_set_add_node to libdevmapper to control dev node creation time.
Add dm_task_secure_data to libdevmapper to wipe ioctl buffers in kernel.
Log debug message when expected uevent is not generated.
Only compile memory debugging code when DEBUG_MEM is set.
Set DM_UDEV_DISABLE_OTHER_RULES_FLAG for suspended DM devices in udev rules.
Begin a new pool object for each row in _output_as_rows() correctly.
Version 1.02.61 - 10th January 2011
===================================
Add DM_COOKIE_AUTO_CREATE to libdevmapper.h.
Export DM_CONTROL_NODE_UMASK and use it while creating /dev/mapper/control.
Version 1.02.60 - 20th December 2010
====================================
Check for unlink failure in remove_lockfile() in dmeventd.
Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr in cmirrord.
Use char* arithmetic in _process_all() & _targets() in dmsetup.
Change dm_regex_create() API to accept const char * const *patterns.
Add new dm_prepare_selinux_context fn to libdevmapper and use it throughout.
Detect existence of new SELinux selabel interface during configure.
Version 1.02.59 - 6th December 2010
===================================
Add backtraces to _process_mapper_dir and _create_and_load_v4 error paths.
Remove superfluous checks for NULL before calling dm_free.
Version 1.02.58 - 22nd November 2010
====================================
Fix _output_field crash from field_id free with DEBUG_MEM. (1.02.57)
Version 1.02.57 - 8th November 2010
===================================
Fix regex optimiser not to ignore RHS of OR nodes in _find_leftmost_common.
Add dmeventd -R to restart dmeventd without losing monitoring state. (1.02.56)
Fix memory leak of field_id in _output_field function.
Allocate buffer for reporting functions dynamically to support long outputs.
Version 1.02.56 - 25th October 2010
===================================
Return const pointer from dm_basename() in libdevmapper.
Implement dmeventd -R to restart without state loss.
Add dm_zalloc and use it and dm_pool_zalloc throughout.
Add --setuuid to dmsetup rename.
Add dm_task_set_newuuid to set uuid of mapped device post-creation.
Version 1.02.55 - 24th September 2010
=====================================
Fix the way regions are marked complete to avoid slow --nosync cmirror I/O.
Add DM_REPORT_FIELD_TYPE_ID_LEN to libdevmapper.h.
Version 1.02.54 - 18th August 2010
==================================
Fix dm-mod autoloading logic to not assume control node is set correctly.
Add dmeventd/executable to lvm.conf to test alternative dmeventd.
Export dm_event_handler_set_dmeventd_path to override built-in dmeventd path.
Generate libdevmapper-event exported symbols.
Remove superfluous NULL pointer tests before dm_free from dmeventd.
Assume dm-mod autoloading support is in kernel 2.6.36 and higher, not 2.6.35.
Fix udev rules to support udev database content generated by older rules.
Reinstate detection of inappropriate uevent with DISK_RO set and suppress it.
Fix regex ttree off-by-one error.
Add --enable-valgrind-pool to configure.
Fix segfault in regex matcher with characters of ordinal value > 127.
Fix 'void*' arithmetic warnings in dbg_malloc.c and libdm-iface.c.
Wait for node creation before displaying debug info in dmsetup.
Fix return status 0 for "dmsetup info -c -o help".
Add check for kernel semaphore support and disable udev_sync if not available.
Version 1.02.53 - 28th July 2010
================================
Revert failed table load preparation after "create, load and resume".
Switch dmeventd to use dm_create_lockfile and drop duplicate code.
Add dm_create_lockfile to libdm to handle pidfiles for all daemons.
Replace lookup with next in struct dfa_state & calculate states on demand.
Improve the regex matcher, reducing the number of charset nodes used.
Add dm_regex_fingerprint to facilitate regex testing.
Skip ffs(0) in _test_word in bitset functions.
Use "nowatch" udev rule for inappropriate devices.
Version 1.02.52 - 6th July 2010
===============================
Fix dmlosetup snprintf %llu compiler warning.
Add parentheses to some libdevmapper.h macro arguments.
Add printf format attributes to dm_{sn,as}printf and fix a caller.
Move dmeventd man page from install_lvm2 to install_device-mapper. (1.02.50)
Version 1.02.51 - 30th June 2010
================================
Generate libdevmapper exported symbols from header file.
Version 1.02.50 - 23rd June 2010
================================
Fix INTERNAL_ERROR typo in ioctl iface unknown task message.
Fix udev rules to handle spurious events properly.
Use C99 [] not [0] in dm_ulog_request struct to avoid abort when fortified.
Allow use of devmapper header file in C++ mode (extern "C" and __typeof__).
Add dmeventd man page.
Version 1.02.49 - 4th June 2010
===============================
Support autoloading of dm-mod module for kernels from 2.6.35.
Document 'clear' in dmsetup man page.
Fix semctl parameter (union) to avoid misaligned parameter on some arches.
Add dm_tree_node_set_presuspend_node() to presuspend child when deactivating.
Initial support for replicator target.
Version 1.02.48 - 17th May 2010
================================
Use -d to control level of messages sent to syslog by dmeventd.
Change -d to -f to run dmeventd in foreground.
Do not print encryption key in message debug output (cryptsetup luksResume).
Fix dmeventd static build library dependencies.
Fix udev flags on remove in create_and_load error path.
Version 1.02.47 - 30th April 2010
=================================
Add support for new IMPORT{db} udev rule.
Add DM_UDEV_PRIMARY_SOURCE_FLAG udev flag to recognize proper DM events.
Also include udev libs in libdevmapper.pc when udev_sync is enabled.
Cache bitset locations to speed up _calc_states.
Add a regex optimisation pass for shared prefixes and suffixes.
Add dm_bit_and and dm_bitset_equal to libdevmapper.
Simplify dm_bitset_create.
Speed up dm_bit_get_next with ffs().
Version 1.02.46 - 14th April 2010
=================================
Change dm_tree_deactivate_children to fail if device is open.
Wipe memory buffers for dm-ioctl parameters before releasing.
Strictly require libudev if udev_sync is used.
Add support for ioctl's DM_UEVENT_GENERATED_FLAG.
Version 1.02.45 - 9th March 2010
================================
Add --showkeys parameter description to dmsetup man page.
Add --help option as synonym for help command.
Version 1.02.44 - 15th February 2010
====================================
Add DM_UDEV_DISABLE_LIBRARY_FALLBACK udev flag to rely on udev only.
Export dm_udev_create_cookie function to create new cookies on demand.
Add --udevcookie, udevcreatecookie and udevreleasecookie to dmsetup.
Set udev state automatically instead of using DM_UDEV_DISABLE_CHECKING.
Version 1.02.43 - 21st January 2010
===================================
Remove bitset, hash and pool headers superceded by libdevmapper.h.
Fix off-by-one error causing bad cluster mirror table construction.
Version 1.02.42 - 14th January 2010
===================================
Add support for the "snapshot-merge" kernel target (2.6.33-rc1).
Introduce a third activation_priority level in dm_tree_activate_children.
Version 1.02.41 - 12th January 2010
===================================
If DM_UDEV_DISABLE_CHECKING is set in environment, disable udev warnings.
Add dm_tree_add_dev_with_udev_flags to provide wider support for udev flags.
Add --noudevrules option for dmsetup to disable /dev node management by udev.
Fix 'dmsetup info -c -o all' to show all fields.
Return errors if dm_tree_*_children functions fail.
Fix coredump and memory leak for 'dmsetup help -c'.
Disable udev rules for change events with DISK_RO set.
Version 1.02.40 - 19th November 2009
====================================
Fix install_device-mapper Makefile target to not build dmeventd plugins.
Support udev flags even when udev_sync is disabled or not compiled in.
Remove 'last_rule' from udev rules: honour DM_UDEV_DISABLE_OTHER_RULES_FLAG.
Add dmsetup --inactive support.
Add dm_task_query_inactive_table to libdevmapper for kernel driver >= 4.16.
Fix hash lookup segfault when keys compared are different lengths.
Version 1.02.39 - 26th October 2009
===================================
Remove strict default permissions for DM devices from 95-dm-notify.rules.
Add dmsetup udevflags command to decode udev flags in given cookie value.
Support udev flags in libdevmapper incl. dm_tree_add_new_dev_with_udev_flags.
Make libdm ABI consistent when built with/without selinux support.
Version 1.02.38 - 25th September 2009
=====================================
Export DM_DEV_DIR_UMASK, the default umask for /dev directories created.
Handle any path supplied to dm_task_set_name by looking up in /dev/mapper.
Add several examples to 12-dm-permissions.rules.
Add splitname and --yes to dmsetup man page.
Fix _mirror_emit_segment_line return code.
Fix dmeventd _temporary_log_fn parameters. (2.02.50)
Version 1.02.37 - 15th September 2009
=====================================
Add dmsetup manpage entries for udevcomplete_all and udevcookies.
Check udev is running when processing cookies and retain state internally.
Add y|--yes option to dmsetup for default 'yes' answer to prompts.
Fix tools Makefile to process dmsetup sources separately.
Restore umask when device node creation fails.
Check kernel vsn to use 'block_on_error' or 'handle_errors' in mirror table.
Add dm-log-userspace.h to tree for cmirrord builds.
Version 1.02.36 - 6th August 2009
=================================
Add udevcookies, udevcomplete, udevcomplete_all and --noudevwait to dmsetup.
Add libdevmapper functions to support synchronisation with udev.
Version 1.02.35 - 28th July 2009
================================
Add LOG_LINE_WITH_ERRNO macro.
Use log_error macro consistently throughout in place of log_err.
Version 1.02.34 - 15th July 2009
================================
Use _exit() not exit() after forking to avoid flushing libc buffers twice.
Rename plog macro to LOG_LINE & add LOG_MESG variant for dm_dump_memory_debug.
Change plog to use dm_log_with_errno unless deprecated dm_log_init was used.
Add dm_log_with_errno and dm_log_with_errno_init, deprecating the old fns.
Fix whitespace in linear target line to fix identical table line detection.
Add device number to more log messages during activation.
Version 1.02.33 - 30th June 2009
================================
Don't fallback to default major number: use dm_task_set_major_minor. (1.02.31)
Do not fork daemon when dmeventd cannot be found.
Add crypt target handling to libdevmapper tree nodes.
Add splitname command to dmsetup.
Add subsystem, vg_name, lv_name, lv_layer fields to dmsetup reports.
Make mempool optional in dm_split_lvm_name().
Version 1.02.32 - 21st May 2009
===============================
Only generate libdevmapper.a when configured to link statically.
Export dm_tree_node_size_changed() from libdevmapper.
Propagate the table size_changed property up the dm device tree.
Detect failure to free memory pools when releasing the library.
Fix segfault when getopt processes dmsetup -U, -G and -M options.
Version 1.02.31 - 3rd March 2009
================================
If kernel supports only one dm major number, use in place of any supplied.
Version 1.02.30 - 26th January 2009
====================================
Add "all" field to reports expanding to all fields of report type.
Enforce device name length and character limitations in libdm.
Replace _dm_snprintf with EMIT_PARAMS macro for creating target lines.
Version 1.02.29 - 10th November 2008
====================================
Merge device-mapper into the LVM2 tree.
Split out dm-logging.h from log.h.
Use lvm-types.h.
Add usrsbindir to configure.
Version 1.02.28 - 18th September 2008
=====================================
Only resume devices in dm_tree_preload_children if size changes.
Extend deptree buffers so the largest possible device numbers fit.
Generate versioned libdevmapper-event.so.
Underline longer report help text headings.
Version 1.02.27 - 25th June 2008
================================
Align struct memblock in dbg_malloc for sparc.
Add --unquoted and --rows to dmsetup.
Avoid compiler warning about cast in dmsetup.c's OFFSET_OF macro.
Fix inverted no_flush debug message.
Remove --enable-jobs from configure. (Set at runtime instead.)
Bring configure.in and list.h into line with the lvm2 versions.
Version 1.02.26 - 6th June 2008
===============================
Initialise params buffer to empty string in _emit_segment.
Skip add_dev_node when ioctls disabled.
Make dm_hash_iter safe against deletion.
Accept a NULL pointer to dm_free silently.
Add tables_loaded, readonly and suspended columns to reports.
Add --nameprefixes to dmsetup.
Add field name prefix option to reporting functions.
Calculate string size within dm_pool_grow_object.
Version 1.02.25 - 10th April 2008
=================================
Remove redundant if-before-free tests.
Use log_warn for reporting field help text instead of log_print.
Change cluster mirror log type name (s/clustered_/clustered-/)
Version 1.02.24 - 20th December 2007
====================================
Fix deptree to pass new name to _resume_node after a rename.
Suppress other node operations if node is deleted.
Add node operation stack debug messages.
Report error when empty device name passed to readahead functions.
Fix minimum readahead debug message.
Version 1.02.23 - 5th December 2007
===================================
Update dm-ioctl.h after removal of compat code.
Add readahead support to libdevmapper and dmsetup.
Fix double free in a libdevmapper-event error path.
Fix configure --with-dmeventd-path substitution.
Allow a DM_DEV_DIR environment variable to override /dev in dmsetup.
Create a libdevmapper.so.$LIB_VERSION symlink within the build tree.
Avoid static link failure with some SELinux libraries that require libpthread.
Remove obsolete dmfs code from tree and update INSTALL.
Version 1.02.22 - 21st August 2007
==================================
Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.
Update to use autoconf 2.61, while still supporting 2.57.
Avoid repeated dm_task free on some dm_event_get_registered_device errors.
Introduce log_sys_* macros from LVM2.
Export dm_fclose and dm_create_dir; remove libdm-file.h.
Don't log EROFS mkdir failures in _create_dir_recursive (for LVM2).
Add fclose wrapper dm_fclose that catches write failures (using ferror).
Version 1.02.21 - 13th July 2007
================================
Introduce _LOG_STDERR to send log_warn() messages to stderr not stdout.
Fix dmsetup -o devno string termination. (1.02.20)
Version 1.02.20 - 15th June 2007
================================
Fix default dmsetup report buffering and add --unbuffered.
Add tree-based and dependency fields to dmsetup reports.
Version 1.02.19 - 27th April 2007
=================================
Standardise protective include file #defines.
Add regex functions to library.
Avoid trailing separator in reports when there are hidden sort fields.
Fix segfault in 'dmsetup status' without --showkeys against crypt target.
Deal with some more compiler warnings.
Introduce _add_field() and _is_same_field() to libdm-report.c.
Fix some libdevmapper-event and dmeventd memory leaks.
Remove unnecessary memset() return value checks.
Fix a few leaks in reporting error paths. [1.02.15+]
Version 1.02.18 - 13th February 2007
====================================
Improve dmeventd messaging protocol: drain pipe and tag messages.
Version 1.02.17 - 29th January 2007
===================================
Add recent reporting options to dmsetup man page.
Revise some report fields names.
Add dmsetup 'help' command and update usage text.
Use fixed-size fields in report interface and reorder.
Version 1.02.16 - 25th January 2007
===================================
Add some missing close() and fclose() return value checks.
Migrate dmsetup column-based output over to new libdevmapper report framework.
Add descriptions to reporting field definitions.
Add a dso-private variable to dmeventd dso interface.
Add dm_event_handler_[gs]et_timeout functions.
Streamline dm_report_field_* interface.
Add cmdline debug & version options to dmeventd.
Add DM_LIB_VERSION definition to configure.h.
Suppress 'Unrecognised field' error if report field is 'help'.
Add --separator and --sort to dmsetup (unused).
Make alignment flag optional when specifying report fields.
Version 1.02.15 - 17th January 2007
===================================
Add basic reporting functions to libdevmapper.
Fix a malloc error path in dmsetup message.
More libdevmapper-event interface changes and fixes.
Rename dm_saprintf() to dm_asprintf().
Report error if NULL pointer is supplied to dm_strdup_aux().
Reinstate dm_event_get_registered_device.
Version 1.02.14 - 11th January 2007
===================================
Add dm_saprintf().
Use CFLAGS when linking so mixed sparc builds can supply -m64.
Add dm_tree_use_no_flush_suspend().
Lots of dmevent changes including revised interface.
Export dm_basename().
Cope with a trailing space when comparing tables prior to possible reload.
Fix dmeventd to cope if monitored device disappears.
Version 1.02.13 - 28 Nov 2006
=============================
Update dmsetup man page (setgeometry & message).
Fix dmsetup free after getline with debug.
Suppress encryption key in 'dmsetup table' output unless --showkeys supplied.
Version 1.02.12 - 13 Oct 2006
=============================
Avoid deptree attempting to suspend a device that's already suspended.
Version 1.02.11 - 12 Oct 2006
==============================
Add suspend noflush support.
Add basic dmsetup loop support.
Switch dmsetup to use dm_malloc and dm_free.
Version 1.02.10 - 19 Sep 2006
=============================
Add dm_snprintf(), dm_split_words() and dm_split_lvm_name() to libdevmapper.
Reorder mm bounds_check code to reduce window for a dmeventd race.
Version 1.02.09 - 15 Aug 2006
=============================
Add --table argument to dmsetup for a one-line table.
Abort if errors are found during cmdline option processing.
Add lockfs indicator to debug output.
Version 1.02.08 - 17 July 2006
==============================
Append full patch to check in emails.
Avoid duplicate dmeventd subdir with 'make distclean'.
Update dmsetup man page.
Add --force to dmsetup remove* to load error target.
dmsetup remove_all also performs mknodes.
Don't suppress identical table reloads if permission changes.
Fix corelog segment line.
Suppress some compiler warnings.
Version 1.02.07 - 11 May 2006
=============================
Add DM_CORELOG flag to dm_tree_node_add_mirror_target().
Avoid a dmeventd compiler warning.
Version 1.02.06 - 10 May 2006
=============================
Move DEFS into configure.h.
Fix leaks in error paths found by coverity.
Remove dmsetup line buffer limitation.
Version 1.02.05 - 19 Apr 2006
=============================
Separate install_include target in makefiles.
Separate out DEFS from CFLAGS.
Support pkg-config.
Check for libsepol.
Version 1.02.04 - 14 Apr 2006
=============================
Bring dmsetup man page up-to-date.
Use name-based device refs if kernel doesn't support device number refs.
Fix memory leak (struct dm_ioctl) when struct dm_task is reused.
If _create_and_load_v4 fails part way through, revert the creation.
dmeventd thread/fifo fixes.
Add file & line to dm_strdup_aux().
Add setgeometry.
Version 1.02.03 - 7 Feb 2006
============================
Add exported functions to set uid, gid and mode.
Rename _log to dm_log and export.
Add dm_tree_skip_lockfs.
Fix dm_strdup debug definition.
Fix hash function to avoid using a negative array offset.
Don't inline _find in hash.c and tidy signed/unsigned etc.
Fix libdevmapper.h #endif.
Fix dmsetup version driver version.
Add sync, nosync and block_on_error mirror log parameters.
Add hweight32.
Fix dmeventd build.
Version 1.02.02 - 2 Dec 2005
============================
dmeventd added.
Export dm_task_update_nodes.
Use names instead of numbers in messages when ioctls fail.
Version 1.02.01 - 23 Nov 2005
=============================
Resume snapshot-origins last.
Drop leading zeros from dm_format_dev.
Suppress attempt to reload identical table.
Additional LVM- prefix matching for transitional period.
Version 1.02.00 - 10 Nov 2005
=============================
Added activation functions to library.
Added return macros.
Also suppress error if device doesn't exist with DM_DEVICE_STATUS.
Export dm_set_selinux_context().
Add dm_driver_version().
Added dependency tree functions to library.
Added hash, bitset, pool, dbg_malloc to library.
Added ls --tree to dmsetup.
Added dmsetup --nolockfs support for suspend/reload.
Version 1.01.05 - 26 Sep 2005
=============================
Resync list.h with LVM2.
Remember increased buffer size and use for subsequent calls.
On 'buffer full' condition, double buffer size and repeat ioctl.
Fix termination of getopt_long() option array.
Report 'buffer full' condition with v4 ioctl as well as with v1.
Version 1.01.04 - 2 Aug 2005
============================
Fix dmsetup ls -j and status --target with empty table.
Version 1.01.03 - 13 Jun 2005
=============================
Use matchpathcon mode parameter.
Fix configure script to re-enable selinux.
Version 1.01.02 - 17 May 2005
=============================
Call dm_lib_exit() and dm_lib_release() automatically now.
Add --target <target_type> filter to dmsetup table/status/ls.
Add --exec <command> to dmsetup ls.
Fix dmsetup getopt_long usage.
Version 1.01.01 - 29 Mar 2005
=============================
Update dmsetup man page.
Drop-in devmap_name replacement.
Add option to compile without ioctl for testing.
Fix DM_LIB_VERSION sed.
Version 1.01.00 - 17 Jan 2005
=============================
Add dm_task_no_open_count() to skip getting open_count.
Version 1.00.21 - 7 Jan 2005
============================
Fix /proc/devices parsing.
Version 1.00.20 - 6 Jan 2005
============================
Attempt to fix /dev/mapper/control transparently if it's wrong.
Configuration-time option for setting uid/gid/mode for /dev/mapper nodes.
Update kernel patches for 2.4.27/2.4.28-pre-4 (includes minor fixes).
Add --noheadings columns option for colon-separated dmsetup output.
Support device referencing by uuid or major/minor.
Warn if kernel data didn't fit in buffer.
Fix a printf.
Version 1.00.19 - 3 July 2004
=============================
More autoconf fixes.
Fix a dmsetup newline.
Fix device number handling for 2.6 kernels.
Version 1.00.18 - 20 Jun 2004
=============================
Fix a uuid free in libdm-iface.
Fix a targets string size calc in driver.
Add -c to dmsetup for column-based output.
Add target message-passing ioctl.
Version 1.00.17 - 17 Apr 2004
=============================
configure --with-owner= --with-group= to avoid -o and -g args to 'install'
Fix library selinux linking.
Version 1.00.16 - 16 Apr 2004
=============================
Ignore error setting selinux file context if fs doesn't support it.
Version 1.00.15 - 7 Apr 2004
============================
Fix status overflow check in kernel patches.
Version 1.00.14 - 6 Apr 2004
============================
Fix static selinux build.
Version 1.00.13 - 6 Apr 2004
============================
Add some basic selinux support.
Version 1.00.12 - 6 Apr 2004
============================
Fix dmsetup.static install.
Version 1.00.11 - 5 Apr 2004
============================
configure --enable-static_link does static build in addition to dynamic.
Moved Makefile library targets definition into template.
Version 1.00.10 - 2 Apr 2004
============================
Fix DESTDIR handling.
Static build installs to dmsetup.static.
Basic support for internationalisation.
Minor Makefile tidy-ups/fixes.
Version 1.00.09 - 31 Mar 2004
=============================
Update copyright notices to Red Hat.
Move full mknodes functionality from dmsetup into libdevmapper.
Avoid sscanf %as for uClibc compatibility.
Cope if DM_LIST_VERSIONS is not defined.
Add DM_LIST_VERSIONS functionality to kernel patches.
Generate new kernel patches for 2.4.26-rc1.
Version 1.00.08 - 27 Feb 2004
=============================
Added 'dmsetup targets'.
Added event_nr support to 'dmsetup wait'.
Updated dmsetup man page.
Allow logging function to be reset to use internal one.
Bring log macros in line with LVM2 ones.
Added 'make install_static_lib' which installs libdevmapper.a.
Made configure/makefiles closer to LVM2 versions.
Fixed DESTDIR for make install/install_static_lib.
Updated README/INSTALL to reflect move to sources.redhat.com.
Updated autoconf files to 2003-06-17.

171
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,171 @@
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 1 (pkg-config-0.24)
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
# only at the first occurence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])# PKG_CHECK_MODULES

1463
autoconf/config.guess vendored

File diff suppressed because it is too large Load Diff

777
autoconf/config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,62 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
scriptversion=2006-10-14.15
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright 1991 by the Massachusetts Institute of Technology
# Copyright (C) 1994 X Consortium
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# put in absolute paths if you don't have them in your path; or use env. vars.
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
@ -41,211 +67,441 @@ stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
posix_glob=
posix_mkdir=
# Desired mode of installed file.
mode=0755
chmodcmd=$chmodprog
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
src=
dst=
dir_arg=
dstarg=
no_target_directory=
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
-d) dir_arg=true
shift
continue;;
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
while test $# -ne 0; do
case $1 in
-c) shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
--help) echo "$usage"; exit $?;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
-m) mode=$2
shift
shift
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
continue;;
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
-s) stripcmd=$stripprog
shift
continue;;
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
-t) dstarg=$2
shift
shift
continue;;
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
-T) no_target_directory=true
shift
continue;;
pathcomp="${pathcomp}/"
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
done
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
# If we're going to rename the final executable, determine the name now.
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
mkdir_mode=
fi
# don't allow the sed command to completely eliminate the filename
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix=/ ;;
-*) prefix=./ ;;
*) prefix= ;;
esac
case $posix_glob in
'')
if (set -f) 2>/dev/null; then
posix_glob=true
else
posix_glob=false
fi ;;
esac
oIFS=$IFS
IFS=/
$posix_glob && set -f
set fnord $dstdir
shift
$posix_glob && set +f
IFS=$oIFS
prefixes=
for d
do
test -z "$d" && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
true
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
# Make a temp file name in the proper directory.
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
dsttmp=$dstdir/#inst.$$#
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Move or copy the file name to the temp name
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
$doit $instcmd $src $dsttmp &&
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap "rm -f ${dsttmp}" 0 &&
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dst"; then
$doit $rmcmd -f "$dst" 2>/dev/null \
|| { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
&& { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
|| {
echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
} || exit 1
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
trap '' 0
fi
done
fi &&
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

11745
configure vendored Executable file

File diff suppressed because it is too large Load Diff

1542
configure.in Normal file

File diff suppressed because it is too large Load Diff

52
daemons/Makefile.in Normal file
View File

@ -0,0 +1,52 @@
#
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
ifeq ("@BUILD_LVMETAD@", "yes")
SUBDIRS += common lvmetad
endif
.PHONY: dmeventd clvmd common cmirrord lvmetad
ifneq ("@CLVMD@", "none")
SUBDIRS += clvmd
endif
ifeq ("@BUILD_CMIRRORD@", "yes")
SUBDIRS += cmirrord
endif
ifeq ("@BUILD_DMEVENTD@", "yes")
SUBDIRS += dmeventd
ifneq ("$(CFLOW_CMD)", "")
daemons.cflow: dmeventd.cflow
endif
endif
ifeq ($(MAKECMDGOALS),distclean)
SUBDIRS = clvmd cmirrord common dmeventd lvmetad
endif
include $(top_builddir)/make.tmpl
ifeq ("@BUILD_DMEVENTD@", "yes")
device-mapper: dmeventd.device-mapper
endif
ifeq ("@BUILD_LVMETAD@", "yes")
lvmetad: common.device-mapper
endif

107
daemons/clvmd/Makefile.in Normal file
View File

@ -0,0 +1,107 @@
#
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CMAN_LIBS = @CMAN_LIBS@
CMAN_CFLAGS = @CMAN_CFLAGS@
CMAP_LIBS = @CMAP_LIBS@
CMAP_CFLAGS = @CMAP_CFLAGS@
CONFDB_LIBS = @CONFDB_LIBS@
CONFDB_CFLAGS = @CONFDB_CFLAGS@
CPG_LIBS = @CPG_LIBS@
CPG_CFLAGS = @CPG_CFLAGS@
DLM_LIBS = @DLM_LIBS@
DLM_CFLAGS = @DLM_CFLAGS@
QUORUM_LIBS = @QUORUM_LIBS@
QUORUM_CFLAGS = @QUORUM_CFLAGS@
SALCK_LIBS = @SALCK_LIBS@
SALCK_CFLAGS = @SALCK_CFLAGS@
SOURCES = \
clvmd-command.c \
clvmd.c \
lvm-functions.c \
refresh_clvmd.c
ifeq ("@DEBUG@", "yes")
DEFS += -DDEBUG
endif
ifneq (,$(findstring cman,, "@CLVMD@,"))
SOURCES += clvmd-cman.c
LMLIBS += $(CMAN_LIBS) $(CONFDB_LIBS) $(DLM_LIBS)
CFLAGS += $(CMAN_CFLAGS) $(CONFDB_CFLAGS) $(DLM_CFLAGS)
DEFS += -DUSE_CMAN
endif
ifneq (,$(findstring openais,, "@CLVMD@,"))
SOURCES += clvmd-openais.c
LMLIBS += $(CONFDB_LIBS) $(CPG_LIBS) $(SALCK_LIBS)
CFLAGS += $(CONFDB_CFLAGS) $(CPG_CFLAGS) $(SALCK_CFLAGS)
DEFS += -DUSE_OPENAIS
endif
ifneq (,$(findstring corosync,, "@CLVMD@,"))
SOURCES += clvmd-corosync.c
LMLIBS += $(CMAP_LIBS) $(CONFDB_LIBS) $(CPG_LIBS) $(DLM_LIBS) $(QUORUM_LIBS)
CFLAGS += $(CMAP_CFLAGS) $(CONFDB_CFLAGS) $(CPG_CFLAGS) $(DLM_CFLAGS) $(QUORUM_CFLAGS)
DEFS += -DUSE_COROSYNC
endif
ifneq (,$(findstring singlenode,, &quot;@CLVMD@,&quot;))
SOURCES += clvmd-singlenode.c
DEFS += -DUSE_SINGLENODE
endif
ifeq ($(MAKECMDGOALS),distclean)
SOURCES += clvmd-cman.c
SOURCES += clvmd-openais.c
SOURCES += clvmd-corosync.c
SOURCES += clvmd-singlenode.c
endif
TARGETS = \
clvmd
LVMLIBS = $(LVMINTERNAL_LIBS)
ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event
endif
include $(top_builddir)/make.tmpl
LVMLIBS += -ldevmapper
LIBS += $(PTHREAD_LIBS)
DEFS += -D_REENTRANT
CFLAGS += -fno-strict-aliasing
INSTALL_TARGETS = \
install_clvmd
clvmd: $(OBJECTS) $(top_builddir)/lib/liblvm-internal.a
$(CC) $(CFLAGS) $(LDFLAGS) -o clvmd $(OBJECTS) \
$(LVMLIBS) $(LMLIBS) $(LIBS)
.PHONY: install_clvmd
install_clvmd: $(TARGETS)
$(INSTALL_PROGRAM) -D clvmd $(usrsbindir)/clvmd
install: $(INSTALL_TARGETS)
install_cluster: $(INSTALL_TARGETS)

82
daemons/clvmd/clvm.h Normal file
View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Definitions for CLVMD server and clients */
/*
* The protocol spoken over the cluster and across the local socket.
*/
#ifndef _CLVM_H
#define _CLVM_H
#include "configure.h"
struct clvm_header {
uint8_t cmd; /* See below */
uint8_t flags; /* See below */
uint16_t xid; /* Transaction ID */
uint32_t clientid; /* Only used in Daemon->Daemon comms */
int32_t status; /* For replies, whether request succeeded */
uint32_t arglen; /* Length of argument below.
If >1500 then it will be passed
around the cluster in the system LV */
char node[1]; /* Actually a NUL-terminated string, node name.
If this is empty then the command is
forwarded to all cluster nodes unless
FLAG_LOCAL or FLAG_REMOTE is also set. */
char args[1]; /* Arguments for the command follow the
node name, This member is only
valid if the node name is empty */
} __attribute__ ((packed));
/* Flags */
#define CLVMD_FLAG_LOCAL 1 /* Only do this on the local node */
#define CLVMD_FLAG_SYSTEMLV 2 /* Data in system LV under my node name */
#define CLVMD_FLAG_NODEERRS 4 /* Reply has errors in node-specific portion */
#define CLVMD_FLAG_REMOTE 8 /* Do this on all nodes except for the local node */
/* Name of the local socket to communicate between lvm and clvmd */
static const char CLVMD_SOCKNAME[]= DEFAULT_RUN_DIR "/clvmd.sock";
/* Internal commands & replies */
#define CLVMD_CMD_REPLY 1
#define CLVMD_CMD_VERSION 2 /* Send version around cluster when we start */
#define CLVMD_CMD_GOAWAY 3 /* Die if received this - we are running
an incompatible version */
#define CLVMD_CMD_TEST 4 /* Just for mucking about */
#define CLVMD_CMD_LOCK 30
#define CLVMD_CMD_UNLOCK 31
/* Lock/Unlock commands */
#define CLVMD_CMD_LOCK_LV 50
#define CLVMD_CMD_LOCK_VG 51
#define CLVMD_CMD_LOCK_QUERY 52
/* Misc functions */
#define CLVMD_CMD_REFRESH 40
#define CLVMD_CMD_GET_CLUSTERNAME 41
#define CLVMD_CMD_SET_DEBUG 42
#define CLVMD_CMD_VG_BACKUP 43
#define CLVMD_CMD_RESTART 44
#define CLVMD_CMD_SYNC_NAMES 45
/* Used internally by some callers, but not part of the protocol.*/
#define NODE_ALL "*"
#define NODE_LOCAL "."
#define NODE_REMOTE "^"
#endif

506
daemons/clvmd/clvmd-cman.c Normal file
View File

@ -0,0 +1,506 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* CMAN communication layer for clvmd.
*/
#include "clvmd-common.h"
#include <pthread.h>
#include "clvmd-comms.h"
#include "clvm.h"
#include "clvmd.h"
#include "lvm-functions.h"
#include <libdlm.h>
#include <syslog.h>
#define LOCKSPACE_NAME "clvmd"
struct clvmd_node
{
struct cman_node *node;
int clvmd_up;
};
static int num_nodes;
static struct cman_node *nodes = NULL;
static struct cman_node this_node;
static int count_nodes; /* size of allocated nodes array */
static struct dm_hash_table *node_updown_hash;
static dlm_lshandle_t *lockspace;
static cman_handle_t c_handle;
static void count_clvmds_running(void);
static void get_members(void);
static int nodeid_from_csid(const char *csid);
static int name_from_nodeid(int nodeid, char *name);
static void event_callback(cman_handle_t handle, void *private, int reason, int arg);
static void data_callback(cman_handle_t handle, void *private,
char *buf, int len, uint8_t port, int nodeid);
struct lock_wait {
pthread_cond_t cond;
pthread_mutex_t mutex;
struct dlm_lksb lksb;
};
static int _init_cluster(void)
{
node_updown_hash = dm_hash_create(100);
/* Open the cluster communication socket */
c_handle = cman_init(NULL);
if (!c_handle) {
syslog(LOG_ERR, "Can't open cluster manager socket: %m");
return -1;
}
DEBUGLOG("Connected to CMAN\n");
if (cman_start_recv_data(c_handle, data_callback, CLUSTER_PORT_CLVMD)) {
syslog(LOG_ERR, "Can't bind cluster socket: %m");
return -1;
}
if (cman_start_notification(c_handle, event_callback)) {
syslog(LOG_ERR, "Can't start cluster event listening");
return -1;
}
/* Get the cluster members list */
get_members();
count_clvmds_running();
DEBUGLOG("CMAN initialisation complete\n");
/* Create a lockspace for LV & VG locks to live in */
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
if (!lockspace) {
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
if (!lockspace) {
syslog(LOG_ERR, "Unable to create DLM lockspace for CLVM: %m");
return -1;
}
DEBUGLOG("Created DLM lockspace for CLVMD.\n");
} else
DEBUGLOG("Opened existing DLM lockspace for CLVMD.\n");
dlm_ls_pthread_init(lockspace);
DEBUGLOG("DLM initialisation complete\n");
return 0;
}
static void _cluster_init_completed(void)
{
clvmd_cluster_init_completed();
}
static int _get_main_cluster_fd()
{
return cman_get_fd(c_handle);
}
static int _get_num_nodes()
{
int i;
int nnodes = 0;
/* return number of ACTIVE nodes */
for (i=0; i<num_nodes; i++) {
if (nodes[i].cn_member && nodes[i].cn_nodeid)
nnodes++;
}
return nnodes;
}
/* send_message with the fd check removed */
static int _cluster_send_message(const void *buf, int msglen, const char *csid,
const char *errtext)
{
int nodeid = 0;
if (csid)
memcpy(&nodeid, csid, CMAN_MAX_CSID_LEN);
if (cman_send_data(c_handle, buf, msglen, 0, CLUSTER_PORT_CLVMD, nodeid) <= 0)
{
log_error("%s", errtext);
}
return msglen;
}
static void _get_our_csid(char *csid)
{
if (this_node.cn_nodeid == 0) {
cman_get_node(c_handle, 0, &this_node);
}
memcpy(csid, &this_node.cn_nodeid, CMAN_MAX_CSID_LEN);
}
/* Call a callback routine for each node is that known (down means not running a clvmd) */
static int _cluster_do_node_callback(struct local_client *client,
void (*callback) (struct local_client *,
const char *,
int))
{
int i;
int somedown = 0;
for (i = 0; i < _get_num_nodes(); i++) {
if (nodes[i].cn_member && nodes[i].cn_nodeid) {
int up = (int)(long)dm_hash_lookup_binary(node_updown_hash, (char *)&nodes[i].cn_nodeid, sizeof(int));
callback(client, (char *)&nodes[i].cn_nodeid, up);
if (!up)
somedown = -1;
}
}
return somedown;
}
/* Process OOB messages from the cluster socket */
static void event_callback(cman_handle_t handle, void *private, int reason, int arg)
{
char namebuf[MAX_CLUSTER_MEMBER_NAME_LEN];
switch (reason) {
case CMAN_REASON_PORTCLOSED:
name_from_nodeid(arg, namebuf);
log_notice("clvmd on node %s has died\n", namebuf);
DEBUGLOG("Got port closed message, removing node %s\n", namebuf);
dm_hash_insert_binary(node_updown_hash, (char *)&arg, sizeof(int), (void *)0);
break;
case CMAN_REASON_STATECHANGE:
DEBUGLOG("Got state change message, re-reading members list\n");
get_members();
break;
#if defined(LIBCMAN_VERSION) && LIBCMAN_VERSION >= 2
case CMAN_REASON_PORTOPENED:
/* Ignore this, wait for startup message from clvmd itself */
break;
case CMAN_REASON_TRY_SHUTDOWN:
DEBUGLOG("Got try shutdown, sending OK\n");
cman_replyto_shutdown(c_handle, 1);
break;
#endif
default:
/* ERROR */
DEBUGLOG("Got unknown event callback message: %d\n", reason);
break;
}
}
static struct local_client *cman_client;
static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
const char *csid,
struct local_client **new_client)
{
/* Save this for data_callback */
cman_client = fd;
/* We never return a new client */
*new_client = NULL;
return cman_dispatch(c_handle, 0);
}
static void data_callback(cman_handle_t handle, void *private,
char *buf, int len, uint8_t port, int nodeid)
{
/* Ignore looped back messages */
if (nodeid == this_node.cn_nodeid)
return;
process_message(cman_client, buf, len, (char *)&nodeid);
}
static void _add_up_node(const char *csid)
{
/* It's up ! */
int nodeid = nodeid_from_csid(csid);
dm_hash_insert_binary(node_updown_hash, (char *)&nodeid, sizeof(int), (void *)1);
DEBUGLOG("Added new node %d to updown list\n", nodeid);
}
static void _cluster_closedown()
{
destroy_lvhash();
dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
cman_finish(c_handle);
}
static int is_listening(int nodeid)
{
int status;
do {
status = cman_is_listening(c_handle, nodeid, CLUSTER_PORT_CLVMD);
if (status < 0 && errno == EBUSY) { /* Don't busywait */
sleep(1);
errno = EBUSY; /* In case sleep trashes it */
}
}
while (status < 0 && errno == EBUSY);
return status;
}
/* Populate the list of CLVMDs running.
called only at startup time */
static void count_clvmds_running(void)
{
int i;
for (i = 0; i < num_nodes; i++) {
int nodeid = nodes[i].cn_nodeid;
if (is_listening(nodeid) == 1)
dm_hash_insert_binary(node_updown_hash, (void *)&nodeid, sizeof(int), (void*)1);
else
dm_hash_insert_binary(node_updown_hash, (void *)&nodeid, sizeof(int), (void*)0);
}
}
/* Get a list of active cluster members */
static void get_members()
{
int retnodes;
int status;
int i;
int high_nodeid = 0;
num_nodes = cman_get_node_count(c_handle);
if (num_nodes == -1) {
log_error("Unable to get node count");
return;
}
/* Not enough room for new nodes list ? */
if (num_nodes > count_nodes && nodes) {
free(nodes);
nodes = NULL;
}
if (nodes == NULL) {
count_nodes = num_nodes + 10; /* Overallocate a little */
nodes = malloc(count_nodes * sizeof(struct cman_node));
if (!nodes) {
log_error("Unable to allocate nodes array\n");
exit(5);
}
}
status = cman_get_nodes(c_handle, count_nodes, &retnodes, nodes);
if (status < 0) {
log_error("Unable to get node details");
exit(6);
}
/* Get the highest nodeid */
for (i=0; i<retnodes; i++) {
if (nodes[i].cn_nodeid > high_nodeid)
high_nodeid = nodes[i].cn_nodeid;
}
}
/* Convert a node name to a CSID */
static int _csid_from_name(char *csid, const char *name)
{
int i;
for (i = 0; i < num_nodes; i++) {
if (strcmp(name, nodes[i].cn_name) == 0) {
memcpy(csid, &nodes[i].cn_nodeid, CMAN_MAX_CSID_LEN);
return 0;
}
}
return -1;
}
/* Convert a CSID to a node name */
static int _name_from_csid(const char *csid, char *name)
{
int i;
for (i = 0; i < num_nodes; i++) {
if (memcmp(csid, &nodes[i].cn_nodeid, CMAN_MAX_CSID_LEN) == 0) {
strcpy(name, nodes[i].cn_name);
return 0;
}
}
/* Who?? */
strcpy(name, "Unknown");
return -1;
}
/* Convert a node ID to a node name */
static int name_from_nodeid(int nodeid, char *name)
{
int i;
for (i = 0; i < num_nodes; i++) {
if (nodeid == nodes[i].cn_nodeid) {
strcpy(name, nodes[i].cn_name);
return 0;
}
}
/* Who?? */
strcpy(name, "Unknown");
return -1;
}
/* Convert a CSID to a node ID */
static int nodeid_from_csid(const char *csid)
{
int nodeid;
memcpy(&nodeid, csid, CMAN_MAX_CSID_LEN);
return nodeid;
}
static int _is_quorate()
{
return cman_is_quorate(c_handle);
}
static void sync_ast_routine(void *arg)
{
struct lock_wait *lwait = arg;
pthread_mutex_lock(&lwait->mutex);
pthread_cond_signal(&lwait->cond);
pthread_mutex_unlock(&lwait->mutex);
}
static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
{
int status;
struct lock_wait lwait;
if (!lockid) {
errno = EINVAL;
return -1;
}
DEBUGLOG("sync_lock: '%s' mode:%d flags=%d\n", resource,mode,flags);
/* Conversions need the lockid in the LKSB */
if (flags & LKF_CONVERT)
lwait.lksb.sb_lkid = *lockid;
pthread_cond_init(&lwait.cond, NULL);
pthread_mutex_init(&lwait.mutex, NULL);
pthread_mutex_lock(&lwait.mutex);
status = dlm_ls_lock(lockspace,
mode,
&lwait.lksb,
flags,
resource,
strlen(resource),
0, sync_ast_routine, &lwait, NULL, NULL);
if (status)
return status;
/* Wait for it to complete */
pthread_cond_wait(&lwait.cond, &lwait.mutex);
pthread_mutex_unlock(&lwait.mutex);
*lockid = lwait.lksb.sb_lkid;
errno = lwait.lksb.sb_status;
DEBUGLOG("sync_lock: returning lkid %x\n", *lockid);
if (lwait.lksb.sb_status)
return -1;
else
return 0;
}
static int _sync_unlock(const char *resource /* UNUSED */, int lockid)
{
int status;
struct lock_wait lwait;
DEBUGLOG("sync_unlock: '%s' lkid:%x\n", resource, lockid);
pthread_cond_init(&lwait.cond, NULL);
pthread_mutex_init(&lwait.mutex, NULL);
pthread_mutex_lock(&lwait.mutex);
status = dlm_ls_unlock(lockspace, lockid, 0, &lwait.lksb, &lwait);
if (status)
return status;
/* Wait for it to complete */
pthread_cond_wait(&lwait.cond, &lwait.mutex);
pthread_mutex_unlock(&lwait.mutex);
errno = lwait.lksb.sb_status;
if (lwait.lksb.sb_status != EUNLOCK)
return -1;
else
return 0;
}
static int _get_cluster_name(char *buf, int buflen)
{
cman_cluster_t cluster_info;
int status;
status = cman_get_cluster(c_handle, &cluster_info);
if (!status) {
strncpy(buf, cluster_info.ci_name, buflen);
}
return status;
}
static struct cluster_ops _cluster_cman_ops = {
.name = "cman",
.cluster_init_completed = _cluster_init_completed,
.cluster_send_message = _cluster_send_message,
.name_from_csid = _name_from_csid,
.csid_from_name = _csid_from_name,
.get_num_nodes = _get_num_nodes,
.cluster_fd_callback = _cluster_fd_callback,
.get_main_cluster_fd = _get_main_cluster_fd,
.cluster_do_node_callback = _cluster_do_node_callback,
.is_quorate = _is_quorate,
.get_our_csid = _get_our_csid,
.add_up_node = _add_up_node,
.cluster_closedown = _cluster_closedown,
.get_cluster_name = _get_cluster_name,
.sync_lock = _sync_lock,
.sync_unlock = _sync_unlock,
};
struct cluster_ops *init_cman_cluster(void)
{
if (!_init_cluster())
return &_cluster_cman_ops;
else
return NULL;
}

View File

@ -0,0 +1,431 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
CLVMD Cluster LVM daemon command processor.
To add commands to the daemon simply add a processor in do_command and return
and messages back in buf and the length in *retlen. The initial value of
buflen is the maximum size of the buffer. if buf is not large enough then it
may be reallocated by the functions in here to a suitable size bearing in
mind that anything larger than the passed-in size will have to be returned
using the system LV and so performance will suffer.
The status return will be negated and passed back to the originating node.
pre- and post- command routines are called only on the local node. The
purpose is primarily to get and release locks, though the pre- routine should
also do any other local setups required by the command (if any) and can
return a failure code that prevents the command from being distributed around
the cluster
The pre- and post- routines are run in their own thread so can block as long
they like, do_command is run in the main clvmd thread so should not block for
too long. If the pre-command returns an error code (!=0) then the command
will not be propogated around the cluster but the post-command WILL be called
Also note that the pre and post routine are *always* called on the local
node, even if the command to be executed was only requested to run on a
remote node. It may peek inside the client structure to check the status of
the command.
The clients of the daemon must, naturally, understand the return messages and
codes.
Routines in here may only READ the values in the client structure passed in
apart from client->private which they are free to do what they like with.
*/
#include "clvmd-common.h"
#include <pthread.h>
#include "clvmd-comms.h"
#include "clvm.h"
#include "clvmd.h"
#include "lvm-globals.h"
#include "lvm-functions.h"
#include "locking.h"
#include <sys/utsname.h>
extern struct cluster_ops *clops;
static int restart_clvmd(void);
/* This is where all the real work happens:
NOTE: client will be NULL when this is executed on a remote node */
int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
char **buf, int buflen, int *retlen)
{
char *args = msg->node + strlen(msg->node) + 1;
int arglen = msglen - sizeof(struct clvm_header) - strlen(msg->node);
int status = 0;
char *lockname;
const char *locktype;
struct utsname nodeinfo;
unsigned char lock_cmd;
unsigned char lock_flags;
/* Reset test mode before we start */
init_test(0);
/* Do the command */
switch (msg->cmd) {
/* Just a test message */
case CLVMD_CMD_TEST:
if (arglen > buflen) {
char *new_buf;
buflen = arglen + 200;
new_buf = realloc(*buf, buflen);
if (new_buf == NULL) {
status = errno;
free (*buf);
}
*buf = new_buf;
}
if (*buf) {
if (uname(&nodeinfo))
memset(&nodeinfo, 0, sizeof(nodeinfo));
*retlen = 1 + dm_snprintf(*buf, buflen,
"TEST from %s: %s v%s",
nodeinfo.nodename, args,
nodeinfo.release);
}
break;
case CLVMD_CMD_LOCK_VG:
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
/* Check to see if the VG is in use by LVM1 */
status = do_check_lvm1(lockname);
if (lock_flags & LCK_TEST_MODE)
init_test(1);
do_lock_vg(lock_cmd, lock_flags, lockname);
break;
case CLVMD_CMD_LOCK_LV:
/* This is the biggie */
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
if (lock_flags & LCK_TEST_MODE)
init_test(1);
status = do_lock_lv(lock_cmd, lock_flags, lockname);
/* Replace EIO with something less scary */
if (status == EIO) {
*retlen = 1 + dm_snprintf(*buf, buflen, "%s",
get_last_lvm_error());
return EIO;
}
break;
case CLVMD_CMD_LOCK_QUERY:
lockname = &args[2];
if (buflen < 3)
return EIO;
if ((locktype = do_lock_query(lockname)))
*retlen = 1 + dm_snprintf(*buf, buflen, "%s", locktype);
break;
case CLVMD_CMD_REFRESH:
do_refresh_cache();
break;
case CLVMD_CMD_SYNC_NAMES:
lvm_do_fs_unlock();
break;
case CLVMD_CMD_SET_DEBUG:
clvmd_set_debug(args[0]);
break;
case CLVMD_CMD_RESTART:
status = restart_clvmd();
break;
case CLVMD_CMD_GET_CLUSTERNAME:
status = clops->get_cluster_name(*buf, buflen);
if (!status)
*retlen = strlen(*buf)+1;
break;
case CLVMD_CMD_VG_BACKUP:
/*
* Do not run backup on local node, caller should do that.
*/
if (!client)
lvm_do_backup(&args[2]);
break;
default:
/* Won't get here because command is validated in pre_command */
break;
}
/* Check the status of the command and return the error text */
if (status) {
*retlen = 1 + ((*buf) ? dm_snprintf(*buf, buflen, "%s",
strerror(status)) : -1);
}
return status;
}
static int lock_vg(struct local_client *client)
{
struct dm_hash_table *lock_hash;
struct clvm_header *header =
(struct clvm_header *) client->bits.localsock.cmd;
unsigned char lock_cmd;
int lock_mode;
char *args = header->node + strlen(header->node) + 1;
int lkid;
int status = 0;
char *lockname;
/* Keep a track of VG locks in our own hash table. In current
practice there should only ever be more than two VGs locked
if a user tries to merge lots of them at once */
if (client->bits.localsock.private) {
lock_hash = (struct dm_hash_table *)client->bits.localsock.private;
}
else {
lock_hash = dm_hash_create(3);
if (!lock_hash)
return ENOMEM;
client->bits.localsock.private = (void *)lock_hash;
}
lock_cmd = args[0] & (LCK_NONBLOCK | LCK_HOLD | LCK_SCOPE_MASK | LCK_TYPE_MASK);
lock_mode = ((int)lock_cmd & LCK_TYPE_MASK);
/* lock_flags = args[1]; */
lockname = &args[2];
DEBUGLOG("doing PRE command LOCK_VG '%s' at %x (client=%p)\n", lockname, lock_cmd, client);
if (lock_mode == LCK_UNLOCK) {
lkid = (int)(long)dm_hash_lookup(lock_hash, lockname);
if (lkid == 0)
return EINVAL;
status = sync_unlock(lockname, lkid);
if (status)
status = errno;
else
dm_hash_remove(lock_hash, lockname);
}
else {
/* Read locks need to be PR; other modes get passed through */
if (lock_mode == LCK_READ)
lock_mode = LCK_PREAD;
status = sync_lock(lockname, lock_mode, (lock_cmd & LCK_NONBLOCK) ? LCKF_NOQUEUE : 0, &lkid);
if (status)
status = errno;
else
dm_hash_insert(lock_hash, lockname, (void *)(long)lkid);
}
return status;
}
/* Pre-command is a good place to get locks that are needed only for the duration
of the commands around the cluster (don't forget to free them in post-command),
and to sanity check the command arguments */
int do_pre_command(struct local_client *client)
{
struct clvm_header *header =
(struct clvm_header *) client->bits.localsock.cmd;
unsigned char lock_cmd;
unsigned char lock_flags;
char *args = header->node + strlen(header->node) + 1;
int lockid = 0;
int status = 0;
char *lockname;
init_test(0);
switch (header->cmd) {
case CLVMD_CMD_TEST:
status = sync_lock("CLVMD_TEST", LCK_EXCL, 0, &lockid);
client->bits.localsock.private = (void *)(long)lockid;
break;
case CLVMD_CMD_LOCK_VG:
lockname = &args[2];
/* We take out a real lock unless LCK_CACHE was set */
if (!strncmp(lockname, "V_", 2) ||
!strncmp(lockname, "P_#", 3))
status = lock_vg(client);
break;
case CLVMD_CMD_LOCK_LV:
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
if (lock_flags & LCK_TEST_MODE)
init_test(1);
status = pre_lock_lv(lock_cmd, lock_flags, lockname);
break;
case CLVMD_CMD_REFRESH:
case CLVMD_CMD_GET_CLUSTERNAME:
case CLVMD_CMD_SET_DEBUG:
case CLVMD_CMD_VG_BACKUP:
case CLVMD_CMD_SYNC_NAMES:
case CLVMD_CMD_LOCK_QUERY:
case CLVMD_CMD_RESTART:
break;
default:
log_error("Unknown command %d received\n", header->cmd);
status = EINVAL;
}
return status;
}
/* Note that the post-command routine is called even if the pre-command or the real command
failed */
int do_post_command(struct local_client *client)
{
struct clvm_header *header =
(struct clvm_header *) client->bits.localsock.cmd;
int status = 0;
unsigned char lock_cmd;
unsigned char lock_flags;
char *args = header->node + strlen(header->node) + 1;
char *lockname;
init_test(0);
switch (header->cmd) {
case CLVMD_CMD_TEST:
status =
sync_unlock("CLVMD_TEST", (int) (long) client->bits.localsock.private);
client->bits.localsock.private = 0;
break;
case CLVMD_CMD_LOCK_LV:
lock_cmd = args[0];
lock_flags = args[1];
lockname = &args[2];
if (lock_flags & LCK_TEST_MODE)
init_test(1);
status = post_lock_lv(lock_cmd, lock_flags, lockname);
break;
default:
/* Nothing to do here */
break;
}
return status;
}
/* Called when the client is about to be deleted */
void cmd_client_cleanup(struct local_client *client)
{
if (client->bits.localsock.private) {
struct dm_hash_node *v;
struct dm_hash_table *lock_hash =
(struct dm_hash_table *)client->bits.localsock.private;
dm_hash_iterate(v, lock_hash) {
int lkid = (int)(long)dm_hash_get_data(lock_hash, v);
char *lockname = dm_hash_get_key(lock_hash, v);
DEBUGLOG("cleanup: Unlocking lock %s %x\n", lockname, lkid);
sync_unlock(lockname, lkid);
}
dm_hash_destroy(lock_hash);
client->bits.localsock.private = 0;
}
}
static int restart_clvmd(void)
{
const char **argv;
char *lv_name;
int argc = 0, max_locks = 0;
struct dm_hash_node *hn = NULL;
char debug_arg[16];
const char *clvmd = getenv("LVM_CLVMD_BINARY") ? : CLVMD_PATH;
DEBUGLOG("clvmd restart requested\n");
/* Count exclusively-open LVs */
do {
hn = get_next_excl_lock(hn, &lv_name);
if (lv_name) {
max_locks++;
if (!*lv_name)
break; /* FIXME: Is this error ? */
}
} while (hn);
/* clvmd + locks (-E uuid) + debug (-d X) + NULL */
if (!(argv = malloc((max_locks * 2 + 5) * sizeof(*argv))))
goto_out;
/*
* Build the command-line
*/
argv[argc++] = "clvmd";
/* Propogate debug options */
if (clvmd_get_debug()) {
if (dm_snprintf(debug_arg, sizeof(debug_arg), "-d%u", clvmd_get_debug()) < 0)
goto_out;
argv[argc++] = debug_arg;
}
argv[argc++] = "-I";
argv[argc++] = clops->name;
/* Now add the exclusively-open LVs */
hn = NULL;
do {
hn = get_next_excl_lock(hn, &lv_name);
if (lv_name) {
if (!*lv_name)
break; /* FIXME: Is this error ? */
argv[argc++] = "-E";
argv[argc++] = lv_name;
DEBUGLOG("excl lock: %s\n", lv_name);
}
} while (hn);
argv[argc] = NULL;
/* Exec new clvmd */
DEBUGLOG("--- Restarting %s ---\n", clvmd);
for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]);
/* NOTE: This will fail when downgrading! */
execvp(clvmd, (char **)argv);
out:
/* We failed */
DEBUGLOG("Restart of clvmd failed.\n");
free(argv);
return EIO;
}

View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This file must be included first by every clvmd source file.
*/
#ifndef _LVM_CLVMD_COMMON_H
#define _LVM_CLVMD_COMMON_H
#include "configure.h"
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include "libdevmapper.h"
#include "lvm-logging.h"
#include <unistd.h>
#include <sys/stat.h>
#endif

119
daemons/clvmd/clvmd-comms.h Normal file
View File

@ -0,0 +1,119 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Abstraction layer for clvmd cluster communications
*/
#ifndef _CLVMD_COMMS_H
#define _CLVMD_COMMS_H
struct local_client;
struct cluster_ops {
const char *name;
void (*cluster_init_completed) (void);
int (*cluster_send_message) (const void *buf, int msglen,
const char *csid,
const char *errtext);
int (*name_from_csid) (const char *csid, char *name);
int (*csid_from_name) (char *csid, const char *name);
int (*get_num_nodes) (void);
int (*cluster_fd_callback) (struct local_client *fd, char *buf, int len,
const char *csid,
struct local_client **new_client);
int (*get_main_cluster_fd) (void); /* gets accept FD or cman cluster socket */
int (*cluster_do_node_callback) (struct local_client *client,
void (*callback) (struct local_client *,
const char *csid,
int node_up));
int (*is_quorate) (void);
void (*get_our_csid) (char *csid);
void (*add_up_node) (const char *csid);
void (*reread_config) (void);
void (*cluster_closedown) (void);
int (*get_cluster_name)(char *buf, int buflen);
int (*sync_lock) (const char *resource, int mode,
int flags, int *lockid);
int (*sync_unlock) (const char *resource, int lockid);
};
#ifdef USE_CMAN
# include <netinet/in.h>
# include "libcman.h"
# define CMAN_MAX_CSID_LEN 4
# ifndef MAX_CSID_LEN
# define MAX_CSID_LEN CMAN_MAX_CSID_LEN
# endif
# undef MAX_CLUSTER_MEMBER_NAME_LEN
# define MAX_CLUSTER_MEMBER_NAME_LEN CMAN_MAX_NODENAME_LEN
# define CMAN_MAX_CLUSTER_MESSAGE 1500
# define CLUSTER_PORT_CLVMD 11
struct cluster_ops *init_cman_cluster(void);
#endif
#ifdef USE_OPENAIS
# include <openais/saAis.h>
# include <corosync/totem/totem.h>
# define OPENAIS_CSID_LEN (sizeof(int))
# define OPENAIS_MAX_CLUSTER_MESSAGE MESSAGE_SIZE_MAX
# define OPENAIS_MAX_CLUSTER_MEMBER_NAME_LEN SA_MAX_NAME_LENGTH
# ifndef MAX_CLUSTER_MEMBER_NAME_LEN
# define MAX_CLUSTER_MEMBER_NAME_LEN SA_MAX_NAME_LENGTH
# endif
# ifndef CMAN_MAX_CLUSTER_MESSAGE
# define CMAN_MAX_CLUSTER_MESSAGE MESSAGE_SIZE_MAX
# endif
# ifndef MAX_CSID_LEN
# define MAX_CSID_LEN sizeof(int)
# endif
struct cluster_ops *init_openais_cluster(void);
#endif
#ifdef USE_COROSYNC
# include <corosync/corotypes.h>
# define COROSYNC_CSID_LEN (sizeof(int))
# define COROSYNC_MAX_CLUSTER_MESSAGE 65535
# define COROSYNC_MAX_CLUSTER_MEMBER_NAME_LEN CS_MAX_NAME_LENGTH
# ifndef MAX_CLUSTER_MEMBER_NAME_LEN
# define MAX_CLUSTER_MEMBER_NAME_LEN CS_MAX_NAME_LENGTH
# endif
# ifndef CMAN_MAX_CLUSTER_MESSAGE
# define CMAN_MAX_CLUSTER_MESSAGE 65535
# endif
# ifndef MAX_CSID_LEN
# define MAX_CSID_LEN sizeof(int)
# endif
struct cluster_ops *init_corosync_cluster(void);
#endif
#ifdef USE_SINGLENODE
# define SINGLENODE_CSID_LEN (sizeof(int))
# ifndef MAX_CLUSTER_MEMBER_NAME_LEN
# define MAX_CLUSTER_MEMBER_NAME_LEN 64
# endif
# define SINGLENODE_MAX_CLUSTER_MESSAGE 65535
# ifndef MAX_CSID_LEN
# define MAX_CSID_LEN sizeof(int)
# endif
struct cluster_ops *init_singlenode_cluster(void);
#endif
#endif

View File

@ -0,0 +1,684 @@
/*
* Copyright (C) 2009-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This provides the interface between clvmd and corosync/DLM as the cluster
* and lock manager.
*/
#include "clvmd-common.h"
#include <pthread.h>
#include "clvm.h"
#include "clvmd-comms.h"
#include "clvmd.h"
#include "lvm-functions.h"
#include "locking.h"
#include <corosync/cpg.h>
#include <corosync/quorum.h>
#ifdef HAVE_COROSYNC_CONFDB_H
# include <corosync/confdb.h>
#elif defined HAVE_COROSYNC_CMAP_H
# include <corosync/cmap.h>
#else
# error "Either HAVE_COROSYNC_CONFDB_H or HAVE_COROSYNC_CMAP_H must be defined."
#endif
#include <libdlm.h>
#include <syslog.h>
/* Timeout value for several corosync calls */
#define LOCKSPACE_NAME "clvmd"
static void corosync_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
size_t msg_len);
static void corosync_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries);
static void _cluster_closedown(void);
/* Hash list of nodes in the cluster */
static struct dm_hash_table *node_hash;
/* Number of active nodes */
static int num_nodes;
static unsigned int our_nodeid;
static struct local_client *cluster_client;
/* Corosync handles */
static cpg_handle_t cpg_handle;
static quorum_handle_t quorum_handle;
/* DLM Handle */
static dlm_lshandle_t *lockspace;
static struct cpg_name cpg_group_name;
/* Corosync callback structs */
cpg_callbacks_t corosync_cpg_callbacks = {
.cpg_deliver_fn = corosync_cpg_deliver_callback,
.cpg_confchg_fn = corosync_cpg_confchg_callback,
};
quorum_callbacks_t quorum_callbacks = {
.quorum_notify_fn = NULL,
};
struct node_info
{
enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state;
int nodeid;
};
/* Set errno to something approximating the right value and return 0 or -1 */
static int cs_to_errno(cs_error_t err)
{
switch(err)
{
case CS_OK:
return 0;
case CS_ERR_LIBRARY:
errno = EINVAL;
break;
case CS_ERR_VERSION:
errno = EINVAL;
break;
case CS_ERR_INIT:
errno = EINVAL;
break;
case CS_ERR_TIMEOUT:
errno = ETIME;
break;
case CS_ERR_TRY_AGAIN:
errno = EAGAIN;
break;
case CS_ERR_INVALID_PARAM:
errno = EINVAL;
break;
case CS_ERR_NO_MEMORY:
errno = ENOMEM;
break;
case CS_ERR_BAD_HANDLE:
errno = EINVAL;
break;
case CS_ERR_BUSY:
errno = EBUSY;
break;
case CS_ERR_ACCESS:
errno = EPERM;
break;
case CS_ERR_NOT_EXIST:
errno = ENOENT;
break;
case CS_ERR_NAME_TOO_LONG:
errno = ENAMETOOLONG;
break;
case CS_ERR_EXIST:
errno = EEXIST;
break;
case CS_ERR_NO_SPACE:
errno = ENOSPC;
break;
case CS_ERR_INTERRUPT:
errno = EINTR;
break;
case CS_ERR_NAME_NOT_FOUND:
errno = ENOENT;
break;
case CS_ERR_NO_RESOURCES:
errno = ENOMEM;
break;
case CS_ERR_NOT_SUPPORTED:
errno = EOPNOTSUPP;
break;
case CS_ERR_BAD_OPERATION:
errno = EINVAL;
break;
case CS_ERR_FAILED_OPERATION:
errno = EIO;
break;
case CS_ERR_MESSAGE_ERROR:
errno = EIO;
break;
case CS_ERR_QUEUE_FULL:
errno = EXFULL;
break;
case CS_ERR_QUEUE_NOT_AVAILABLE:
errno = EINVAL;
break;
case CS_ERR_BAD_FLAGS:
errno = EINVAL;
break;
case CS_ERR_TOO_BIG:
errno = E2BIG;
break;
case CS_ERR_NO_SECTIONS:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
return -1;
}
static char *print_corosync_csid(const char *csid)
{
static char buf[128];
int id;
memcpy(&id, csid, sizeof(int));
sprintf(buf, "%d", id);
return buf;
}
static void corosync_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
size_t msg_len)
{
int target_nodeid;
memcpy(&target_nodeid, msg, COROSYNC_CSID_LEN);
DEBUGLOG("%u got message from nodeid %d for %d. len %zd\n",
our_nodeid, nodeid, target_nodeid, msg_len-4);
if (nodeid != our_nodeid)
if (target_nodeid == our_nodeid || target_nodeid == 0)
process_message(cluster_client, (char *)msg+COROSYNC_CSID_LEN,
msg_len-COROSYNC_CSID_LEN, (char*)&nodeid);
}
static void corosync_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries)
{
int i;
struct node_info *ninfo;
DEBUGLOG("confchg callback. %zd joined, %zd left, %zd members\n",
joined_list_entries, left_list_entries, member_list_entries);
for (i=0; i<joined_list_entries; i++) {
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&joined_list[i].nodeid,
COROSYNC_CSID_LEN);
if (!ninfo) {
ninfo = malloc(sizeof(struct node_info));
if (!ninfo) {
break;
}
else {
ninfo->nodeid = joined_list[i].nodeid;
dm_hash_insert_binary(node_hash,
(char *)&ninfo->nodeid,
COROSYNC_CSID_LEN, ninfo);
}
}
ninfo->state = NODE_CLVMD;
}
for (i=0; i<left_list_entries; i++) {
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&left_list[i].nodeid,
COROSYNC_CSID_LEN);
if (ninfo)
ninfo->state = NODE_DOWN;
}
for (i=0; i<member_list_entries; i++) {
if (member_list[i].nodeid == 0) continue;
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&member_list[i].nodeid,
COROSYNC_CSID_LEN);
if (!ninfo) {
ninfo = malloc(sizeof(struct node_info));
if (!ninfo) {
break;
}
else {
ninfo->nodeid = member_list[i].nodeid;
dm_hash_insert_binary(node_hash,
(char *)&ninfo->nodeid,
COROSYNC_CSID_LEN, ninfo);
}
}
ninfo->state = NODE_CLVMD;
}
num_nodes = member_list_entries;
}
static int _init_cluster(void)
{
cs_error_t err;
#ifdef QUORUM_SET /* corosync/quorum.h */
uint32_t quorum_type;
#endif
node_hash = dm_hash_create(100);
err = cpg_initialize(&cpg_handle,
&corosync_cpg_callbacks);
if (err != CS_OK) {
syslog(LOG_ERR, "Cannot initialise Corosync CPG service: %d",
err);
DEBUGLOG("Cannot initialise Corosync CPG service: %d", err);
return cs_to_errno(err);
}
#ifdef QUORUM_SET
err = quorum_initialize(&quorum_handle,
&quorum_callbacks,
&quorum_type);
if (quorum_type != QUORUM_SET) {
syslog(LOG_ERR, "Corosync quorum service is not configured");
DEBUGLOG("Corosync quorum service is not configured");
return EINVAL;
}
#else
err = quorum_initialize(&quorum_handle,
&quorum_callbacks);
#endif
if (err != CS_OK) {
syslog(LOG_ERR, "Cannot initialise Corosync quorum service: %d",
err);
DEBUGLOG("Cannot initialise Corosync quorum service: %d", err);
return cs_to_errno(err);
}
/* Create a lockspace for LV & VG locks to live in */
lockspace = dlm_open_lockspace(LOCKSPACE_NAME);
if (!lockspace) {
lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
if (!lockspace) {
syslog(LOG_ERR, "Unable to create DLM lockspace for CLVM: %m");
return -1;
}
DEBUGLOG("Created DLM lockspace for CLVMD.\n");
} else
DEBUGLOG("Opened existing DLM lockspace for CLVMD.\n");
dlm_ls_pthread_init(lockspace);
DEBUGLOG("DLM initialisation complete\n");
/* Connect to the clvmd group */
strcpy((char *)cpg_group_name.value, "clvmd");
cpg_group_name.length = strlen((char *)cpg_group_name.value);
err = cpg_join(cpg_handle, &cpg_group_name);
if (err != CS_OK) {
cpg_finalize(cpg_handle);
quorum_finalize(quorum_handle);
dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
syslog(LOG_ERR, "Cannot join clvmd process group");
DEBUGLOG("Cannot join clvmd process group: %d\n", err);
return cs_to_errno(err);
}
err = cpg_local_get(cpg_handle,
&our_nodeid);
if (err != CS_OK) {
cpg_finalize(cpg_handle);
quorum_finalize(quorum_handle);
dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
syslog(LOG_ERR, "Cannot get local node id\n");
return cs_to_errno(err);
}
DEBUGLOG("Our local node id is %d\n", our_nodeid);
DEBUGLOG("Connected to Corosync\n");
return 0;
}
static void _cluster_closedown(void)
{
DEBUGLOG("cluster_closedown\n");
destroy_lvhash();
dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
cpg_finalize(cpg_handle);
quorum_finalize(quorum_handle);
}
static void _get_our_csid(char *csid)
{
memcpy(csid, &our_nodeid, sizeof(int));
}
/* Corosync doesn't really have nmode names so we
just use the node ID in hex instead */
static int _csid_from_name(char *csid, const char *name)
{
int nodeid;
struct node_info *ninfo;
if (sscanf(name, "%x", &nodeid) == 1) {
ninfo = dm_hash_lookup_binary(node_hash, csid, COROSYNC_CSID_LEN);
if (ninfo)
return nodeid;
}
return -1;
}
static int _name_from_csid(const char *csid, char *name)
{
struct node_info *ninfo;
ninfo = dm_hash_lookup_binary(node_hash, csid, COROSYNC_CSID_LEN);
if (!ninfo)
{
sprintf(name, "UNKNOWN %s", print_corosync_csid(csid));
return -1;
}
sprintf(name, "%x", ninfo->nodeid);
return 0;
}
static int _get_num_nodes()
{
DEBUGLOG("num_nodes = %d\n", num_nodes);
return num_nodes;
}
/* Node is now known to be running a clvmd */
static void _add_up_node(const char *csid)
{
struct node_info *ninfo;
ninfo = dm_hash_lookup_binary(node_hash, csid, COROSYNC_CSID_LEN);
if (!ninfo) {
DEBUGLOG("corosync_add_up_node no node_hash entry for csid %s\n",
print_corosync_csid(csid));
return;
}
DEBUGLOG("corosync_add_up_node %d\n", ninfo->nodeid);
ninfo->state = NODE_CLVMD;
return;
}
/* Call a callback for each node, so the caller knows whether it's up or down */
static int _cluster_do_node_callback(struct local_client *master_client,
void (*callback)(struct local_client *,
const char *csid, int node_up))
{
struct dm_hash_node *hn;
struct node_info *ninfo;
int somedown = 0;
dm_hash_iterate(hn, node_hash)
{
char csid[COROSYNC_CSID_LEN];
ninfo = dm_hash_get_data(node_hash, hn);
memcpy(csid, dm_hash_get_key(node_hash, hn), COROSYNC_CSID_LEN);
DEBUGLOG("down_callback. node %d, state = %d\n", ninfo->nodeid,
ninfo->state);
if (ninfo->state != NODE_DOWN)
callback(master_client, csid, ninfo->state == NODE_CLVMD);
if (ninfo->state != NODE_CLVMD)
somedown = -1;
}
return somedown;
}
/* Real locking */
static int _lock_resource(const char *resource, int mode, int flags, int *lockid)
{
struct dlm_lksb lksb;
int err;
DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
if (flags & LKF_CONVERT)
lksb.sb_lkid = *lockid;
err = dlm_ls_lock_wait(lockspace,
mode,
&lksb,
flags,
resource,
strlen(resource),
0,
NULL, NULL, NULL);
if (err != 0)
{
DEBUGLOG("dlm_ls_lock returned %d\n", errno);
return err;
}
if (lksb.sb_status != 0)
{
DEBUGLOG("dlm_ls_lock returns lksb.sb_status %d\n", lksb.sb_status);
errno = lksb.sb_status;
return -1;
}
DEBUGLOG("lock_resource returning %d, lock_id=%x\n", err, lksb.sb_lkid);
*lockid = lksb.sb_lkid;
return 0;
}
static int _unlock_resource(const char *resource, int lockid)
{
struct dlm_lksb lksb;
int err;
DEBUGLOG("unlock_resource: %s lockid: %x\n", resource, lockid);
lksb.sb_lkid = lockid;
err = dlm_ls_unlock_wait(lockspace,
lockid,
0,
&lksb);
if (err != 0)
{
DEBUGLOG("Unlock returned %d\n", err);
return err;
}
if (lksb.sb_status != EUNLOCK)
{
DEBUGLOG("dlm_ls_unlock_wait returns lksb.sb_status: %d\n", lksb.sb_status);
errno = lksb.sb_status;
return -1;
}
return 0;
}
static int _is_quorate()
{
int quorate;
if (quorum_getquorate(quorum_handle, &quorate) == CS_OK)
return quorate;
else
return 0;
}
static int _get_main_cluster_fd(void)
{
int select_fd;
cpg_fd_get(cpg_handle, &select_fd);
return select_fd;
}
static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
const char *csid,
struct local_client **new_client)
{
cluster_client = fd;
*new_client = NULL;
cpg_dispatch(cpg_handle, CS_DISPATCH_ONE);
return 1;
}
static int _cluster_send_message(const void *buf, int msglen, const char *csid,
const char *errtext)
{
struct iovec iov[2];
cs_error_t err;
int target_node;
if (csid)
memcpy(&target_node, csid, COROSYNC_CSID_LEN);
else
target_node = 0;
iov[0].iov_base = &target_node;
iov[0].iov_len = sizeof(int);
iov[1].iov_base = (char *)buf;
iov[1].iov_len = msglen;
err = cpg_mcast_joined(cpg_handle, CPG_TYPE_AGREED, iov, 2);
return cs_to_errno(err);
}
#ifdef HAVE_COROSYNC_CONFDB_H
/*
* We are not necessarily connected to a Red Hat Cluster system,
* but if we are, this returns the cluster name from cluster.conf.
* I've used confdb rather than ccs to reduce the inter-package
* dependancies as well as to allow people to set a cluster name
* for themselves even if they are not running on RH cluster.
*/
static int _get_cluster_name(char *buf, int buflen)
{
confdb_handle_t handle;
int result;
size_t namelen = buflen;
hdb_handle_t cluster_handle;
confdb_callbacks_t callbacks = {
.confdb_key_change_notify_fn = NULL,
.confdb_object_create_change_notify_fn = NULL,
.confdb_object_delete_change_notify_fn = NULL
};
/* This is a default in case everything else fails */
strncpy(buf, "Corosync", buflen);
/* Look for a cluster name in confdb */
result = confdb_initialize (&handle, &callbacks);
if (result != CS_OK)
return 0;
result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
if (result != CS_OK)
goto out;
result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, (void *)"cluster", strlen("cluster"), &cluster_handle);
if (result != CS_OK)
goto out;
result = confdb_key_get(handle, cluster_handle, (void *)"name", strlen("name"), buf, &namelen);
if (result != CS_OK)
goto out;
buf[namelen] = '\0';
out:
confdb_finalize(handle);
return 0;
}
#elif defined HAVE_COROSYNC_CMAP_H
static int _get_cluster_name(char *buf, int buflen)
{
cmap_handle_t cmap_handle = 0;
int result;
char *name = NULL;
/* This is a default in case everything else fails */
strncpy(buf, "Corosync", buflen);
/* Look for a cluster name in cmap */
result = cmap_initialize(&cmap_handle);
if (result != CS_OK)
return 0;
result = cmap_get_string(cmap_handle, "totem.cluster_name", &name);
if (result != CS_OK)
goto out;
memset(buf, 0, buflen);
strncpy(buf, name, buflen - 1);
out:
if (name)
free(name);
cmap_finalize(cmap_handle);
return 0;
}
#endif
static struct cluster_ops _cluster_corosync_ops = {
.name = "corosync",
.cluster_init_completed = NULL,
.cluster_send_message = _cluster_send_message,
.name_from_csid = _name_from_csid,
.csid_from_name = _csid_from_name,
.get_num_nodes = _get_num_nodes,
.cluster_fd_callback = _cluster_fd_callback,
.get_main_cluster_fd = _get_main_cluster_fd,
.cluster_do_node_callback = _cluster_do_node_callback,
.is_quorate = _is_quorate,
.get_our_csid = _get_our_csid,
.add_up_node = _add_up_node,
.reread_config = NULL,
.cluster_closedown = _cluster_closedown,
.get_cluster_name = _get_cluster_name,
.sync_lock = _lock_resource,
.sync_unlock = _unlock_resource,
};
struct cluster_ops *init_corosync_cluster(void)
{
if (!_init_cluster())
return &_cluster_corosync_ops;
else
return NULL;
}

View File

@ -0,0 +1,695 @@
/*
* Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This provides the interface between clvmd and OpenAIS as the cluster
* and lock manager.
*/
#include "clvmd-common.h"
#include <pthread.h>
#include <fcntl.h>
#include <syslog.h>
#include <openais/saAis.h>
#include <openais/saLck.h>
#include <corosync/corotypes.h>
#include <corosync/cpg.h>
#include "locking.h"
#include "clvm.h"
#include "clvmd-comms.h"
#include "lvm-functions.h"
#include "clvmd.h"
/* Timeout value for several openais calls */
#define TIMEOUT 10
static void openais_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
size_t msg_len);
static void openais_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries);
static void _cluster_closedown(void);
/* Hash list of nodes in the cluster */
static struct dm_hash_table *node_hash;
/* For associating lock IDs & resource handles */
static struct dm_hash_table *lock_hash;
/* Number of active nodes */
static int num_nodes;
static unsigned int our_nodeid;
static struct local_client *cluster_client;
/* OpenAIS handles */
static cpg_handle_t cpg_handle;
static SaLckHandleT lck_handle;
static struct cpg_name cpg_group_name;
/* Openais callback structs */
cpg_callbacks_t openais_cpg_callbacks = {
.cpg_deliver_fn = openais_cpg_deliver_callback,
.cpg_confchg_fn = openais_cpg_confchg_callback,
};
struct node_info
{
enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state;
int nodeid;
};
struct lock_info
{
SaLckResourceHandleT res_handle;
SaLckLockIdT lock_id;
SaNameT lock_name;
};
/* Set errno to something approximating the right value and return 0 or -1 */
static int ais_to_errno(SaAisErrorT err)
{
switch(err)
{
case SA_AIS_OK:
return 0;
case SA_AIS_ERR_LIBRARY:
errno = EINVAL;
break;
case SA_AIS_ERR_VERSION:
errno = EINVAL;
break;
case SA_AIS_ERR_INIT:
errno = EINVAL;
break;
case SA_AIS_ERR_TIMEOUT:
errno = ETIME;
break;
case SA_AIS_ERR_TRY_AGAIN:
errno = EAGAIN;
break;
case SA_AIS_ERR_INVALID_PARAM:
errno = EINVAL;
break;
case SA_AIS_ERR_NO_MEMORY:
errno = ENOMEM;
break;
case SA_AIS_ERR_BAD_HANDLE:
errno = EINVAL;
break;
case SA_AIS_ERR_BUSY:
errno = EBUSY;
break;
case SA_AIS_ERR_ACCESS:
errno = EPERM;
break;
case SA_AIS_ERR_NOT_EXIST:
errno = ENOENT;
break;
case SA_AIS_ERR_NAME_TOO_LONG:
errno = ENAMETOOLONG;
break;
case SA_AIS_ERR_EXIST:
errno = EEXIST;
break;
case SA_AIS_ERR_NO_SPACE:
errno = ENOSPC;
break;
case SA_AIS_ERR_INTERRUPT:
errno = EINTR;
break;
case SA_AIS_ERR_NAME_NOT_FOUND:
errno = ENOENT;
break;
case SA_AIS_ERR_NO_RESOURCES:
errno = ENOMEM;
break;
case SA_AIS_ERR_NOT_SUPPORTED:
errno = EOPNOTSUPP;
break;
case SA_AIS_ERR_BAD_OPERATION:
errno = EINVAL;
break;
case SA_AIS_ERR_FAILED_OPERATION:
errno = EIO;
break;
case SA_AIS_ERR_MESSAGE_ERROR:
errno = EIO;
break;
case SA_AIS_ERR_QUEUE_FULL:
errno = EXFULL;
break;
case SA_AIS_ERR_QUEUE_NOT_AVAILABLE:
errno = EINVAL;
break;
case SA_AIS_ERR_BAD_FLAGS:
errno = EINVAL;
break;
case SA_AIS_ERR_TOO_BIG:
errno = E2BIG;
break;
case SA_AIS_ERR_NO_SECTIONS:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
return -1;
}
static char *print_openais_csid(const char *csid)
{
static char buf[128];
int id;
memcpy(&id, csid, sizeof(int));
sprintf(buf, "%d", id);
return buf;
}
static int add_internal_client(int fd, fd_callback_t callback)
{
struct local_client *client;
DEBUGLOG("Add_internal_client, fd = %d\n", fd);
client = malloc(sizeof(struct local_client));
if (!client)
{
DEBUGLOG("malloc failed\n");
return -1;
}
memset(client, 0, sizeof(struct local_client));
client->fd = fd;
client->type = CLUSTER_INTERNAL;
client->callback = callback;
add_client(client);
/* Set Close-on-exec */
fcntl(fd, F_SETFD, 1);
return 0;
}
static void openais_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
size_t msg_len)
{
int target_nodeid;
memcpy(&target_nodeid, msg, OPENAIS_CSID_LEN);
DEBUGLOG("%u got message from nodeid %d for %d. len %" PRIsize_t "\n",
our_nodeid, nodeid, target_nodeid, msg_len-4);
if (nodeid != our_nodeid)
if (target_nodeid == our_nodeid || target_nodeid == 0)
process_message(cluster_client, (char *)msg+OPENAIS_CSID_LEN,
msg_len-OPENAIS_CSID_LEN, (char*)&nodeid);
}
static void openais_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries)
{
int i;
struct node_info *ninfo;
DEBUGLOG("confchg callback. %" PRIsize_t " joined, "
"%" PRIsize_t " left, %" PRIsize_t " members\n",
joined_list_entries, left_list_entries, member_list_entries);
for (i=0; i<joined_list_entries; i++) {
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&joined_list[i].nodeid,
OPENAIS_CSID_LEN);
if (!ninfo) {
ninfo = malloc(sizeof(struct node_info));
if (!ninfo) {
break;
}
else {
ninfo->nodeid = joined_list[i].nodeid;
dm_hash_insert_binary(node_hash,
(char *)&ninfo->nodeid,
OPENAIS_CSID_LEN, ninfo);
}
}
ninfo->state = NODE_CLVMD;
}
for (i=0; i<left_list_entries; i++) {
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&left_list[i].nodeid,
OPENAIS_CSID_LEN);
if (ninfo)
ninfo->state = NODE_DOWN;
}
for (i=0; i<member_list_entries; i++) {
if (member_list[i].nodeid == 0) continue;
ninfo = dm_hash_lookup_binary(node_hash,
(char *)&member_list[i].nodeid,
OPENAIS_CSID_LEN);
if (!ninfo) {
ninfo = malloc(sizeof(struct node_info));
if (!ninfo) {
break;
}
else {
ninfo->nodeid = member_list[i].nodeid;
dm_hash_insert_binary(node_hash,
(char *)&ninfo->nodeid,
OPENAIS_CSID_LEN, ninfo);
}
}
ninfo->state = NODE_CLVMD;
}
num_nodes = member_list_entries;
}
static int lck_dispatch(struct local_client *client, char *buf, int len,
const char *csid, struct local_client **new_client)
{
*new_client = NULL;
saLckDispatch(lck_handle, SA_DISPATCH_ONE);
return 1;
}
static int _init_cluster(void)
{
SaAisErrorT err;
SaVersionT ver = { 'B', 1, 1 };
int select_fd;
node_hash = dm_hash_create(100);
lock_hash = dm_hash_create(10);
err = cpg_initialize(&cpg_handle,
&openais_cpg_callbacks);
if (err != SA_AIS_OK) {
syslog(LOG_ERR, "Cannot initialise OpenAIS CPG service: %d",
err);
DEBUGLOG("Cannot initialise OpenAIS CPG service: %d", err);
return ais_to_errno(err);
}
err = saLckInitialize(&lck_handle,
NULL,
&ver);
if (err != SA_AIS_OK) {
cpg_initialize(&cpg_handle, &openais_cpg_callbacks);
syslog(LOG_ERR, "Cannot initialise OpenAIS lock service: %d",
err);
DEBUGLOG("Cannot initialise OpenAIS lock service: %d\n\n", err);
return ais_to_errno(err);
}
/* Connect to the clvmd group */
strcpy((char *)cpg_group_name.value, "clvmd");
cpg_group_name.length = strlen((char *)cpg_group_name.value);
err = cpg_join(cpg_handle, &cpg_group_name);
if (err != SA_AIS_OK) {
cpg_finalize(cpg_handle);
saLckFinalize(lck_handle);
syslog(LOG_ERR, "Cannot join clvmd process group");
DEBUGLOG("Cannot join clvmd process group: %d\n", err);
return ais_to_errno(err);
}
err = cpg_local_get(cpg_handle,
&our_nodeid);
if (err != SA_AIS_OK) {
cpg_finalize(cpg_handle);
saLckFinalize(lck_handle);
syslog(LOG_ERR, "Cannot get local node id\n");
return ais_to_errno(err);
}
DEBUGLOG("Our local node id is %d\n", our_nodeid);
saLckSelectionObjectGet(lck_handle, (SaSelectionObjectT *)&select_fd);
add_internal_client(select_fd, lck_dispatch);
DEBUGLOG("Connected to OpenAIS\n");
return 0;
}
static void _cluster_closedown(void)
{
DEBUGLOG("cluster_closedown\n");
destroy_lvhash();
saLckFinalize(lck_handle);
cpg_finalize(cpg_handle);
}
static void _get_our_csid(char *csid)
{
memcpy(csid, &our_nodeid, sizeof(int));
}
/* OpenAIS doesn't really have nmode names so we
just use the node ID in hex instead */
static int _csid_from_name(char *csid, const char *name)
{
int nodeid;
struct node_info *ninfo;
if (sscanf(name, "%x", &nodeid) == 1) {
ninfo = dm_hash_lookup_binary(node_hash, csid, OPENAIS_CSID_LEN);
if (ninfo)
return nodeid;
}
return -1;
}
static int _name_from_csid(const char *csid, char *name)
{
struct node_info *ninfo;
ninfo = dm_hash_lookup_binary(node_hash, csid, OPENAIS_CSID_LEN);
if (!ninfo)
{
sprintf(name, "UNKNOWN %s", print_openais_csid(csid));
return -1;
}
sprintf(name, "%x", ninfo->nodeid);
return 0;
}
static int _get_num_nodes()
{
DEBUGLOG("num_nodes = %d\n", num_nodes);
return num_nodes;
}
/* Node is now known to be running a clvmd */
static void _add_up_node(const char *csid)
{
struct node_info *ninfo;
ninfo = dm_hash_lookup_binary(node_hash, csid, OPENAIS_CSID_LEN);
if (!ninfo) {
DEBUGLOG("openais_add_up_node no node_hash entry for csid %s\n",
print_openais_csid(csid));
return;
}
DEBUGLOG("openais_add_up_node %d\n", ninfo->nodeid);
ninfo->state = NODE_CLVMD;
return;
}
/* Call a callback for each node, so the caller knows whether it's up or down */
static int _cluster_do_node_callback(struct local_client *master_client,
void (*callback)(struct local_client *,
const char *csid, int node_up))
{
struct dm_hash_node *hn;
struct node_info *ninfo;
int somedown = 0;
dm_hash_iterate(hn, node_hash)
{
char csid[OPENAIS_CSID_LEN];
ninfo = dm_hash_get_data(node_hash, hn);
memcpy(csid, dm_hash_get_key(node_hash, hn), OPENAIS_CSID_LEN);
DEBUGLOG("down_callback. node %d, state = %d\n", ninfo->nodeid,
ninfo->state);
if (ninfo->state != NODE_DOWN)
callback(master_client, csid, ninfo->state == NODE_CLVMD);
if (ninfo->state != NODE_CLVMD)
somedown = -1;
}
return somedown;
}
/* Real locking */
static int _lock_resource(char *resource, int mode, int flags, int *lockid)
{
struct lock_info *linfo;
SaLckResourceHandleT res_handle;
SaAisErrorT err;
SaLckLockIdT lock_id;
SaLckLockStatusT lockStatus;
/* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */
if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE;
linfo = malloc(sizeof(struct lock_info));
if (!linfo)
return -1;
DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
linfo->lock_name.length = strlen(resource)+1;
strcpy((char *)linfo->lock_name.value, resource);
err = saLckResourceOpen(lck_handle, &linfo->lock_name,
SA_LCK_RESOURCE_CREATE, TIMEOUT, &res_handle);
if (err != SA_AIS_OK)
{
DEBUGLOG("ResourceOpen returned %d\n", err);
free(linfo);
return ais_to_errno(err);
}
err = saLckResourceLock(
res_handle,
&lock_id,
mode,
flags,
0,
SA_TIME_END,
&lockStatus);
if (err != SA_AIS_OK && lockStatus != SA_LCK_LOCK_GRANTED)
{
free(linfo);
saLckResourceClose(res_handle);
return ais_to_errno(err);
}
/* Wait for it to complete */
DEBUGLOG("lock_resource returning %d, lock_id=%" PRIx64 "\n",
err, lock_id);
linfo->lock_id = lock_id;
linfo->res_handle = res_handle;
dm_hash_insert(lock_hash, resource, linfo);
return ais_to_errno(err);
}
static int _unlock_resource(char *resource, int lockid)
{
SaAisErrorT err;
struct lock_info *linfo;
DEBUGLOG("unlock_resource %s\n", resource);
linfo = dm_hash_lookup(lock_hash, resource);
if (!linfo)
return 0;
DEBUGLOG("unlock_resource: lockid: %" PRIx64 "\n", linfo->lock_id);
err = saLckResourceUnlock(linfo->lock_id, SA_TIME_END);
if (err != SA_AIS_OK)
{
DEBUGLOG("Unlock returned %d\n", err);
return ais_to_errno(err);
}
/* Release the resource */
dm_hash_remove(lock_hash, resource);
saLckResourceClose(linfo->res_handle);
free(linfo);
return ais_to_errno(err);
}
static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
{
int status;
char lock1[strlen(resource)+3];
char lock2[strlen(resource)+3];
snprintf(lock1, sizeof(lock1), "%s-1", resource);
snprintf(lock2, sizeof(lock2), "%s-2", resource);
switch (mode)
{
case LCK_EXCL:
status = _lock_resource(lock1, SA_LCK_EX_LOCK_MODE, flags, lockid);
if (status)
goto out;
/* If we can't get this lock too then bail out */
status = _lock_resource(lock2, SA_LCK_EX_LOCK_MODE, LCK_NONBLOCK,
lockid);
if (status == SA_LCK_LOCK_NOT_QUEUED)
{
_unlock_resource(lock1, *lockid);
status = -1;
errno = EAGAIN;
}
break;
case LCK_PREAD:
case LCK_READ:
status = _lock_resource(lock1, SA_LCK_PR_LOCK_MODE, flags, lockid);
if (status)
goto out;
_unlock_resource(lock2, *lockid);
break;
case LCK_WRITE:
status = _lock_resource(lock2, SA_LCK_EX_LOCK_MODE, flags, lockid);
if (status)
goto out;
_unlock_resource(lock1, *lockid);
break;
default:
status = -1;
errno = EINVAL;
break;
}
out:
*lockid = mode;
return status;
}
static int _sync_unlock(const char *resource, int lockid)
{
int status = 0;
char lock1[strlen(resource)+3];
char lock2[strlen(resource)+3];
snprintf(lock1, sizeof(lock1), "%s-1", resource);
snprintf(lock2, sizeof(lock2), "%s-2", resource);
_unlock_resource(lock1, lockid);
_unlock_resource(lock2, lockid);
return status;
}
/* We are always quorate ! */
static int _is_quorate()
{
return 1;
}
static int _get_main_cluster_fd(void)
{
int select_fd;
cpg_fd_get(cpg_handle, &select_fd);
return select_fd;
}
static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
const char *csid,
struct local_client **new_client)
{
cluster_client = fd;
*new_client = NULL;
cpg_dispatch(cpg_handle, SA_DISPATCH_ONE);
return 1;
}
static int _cluster_send_message(const void *buf, int msglen, const char *csid,
const char *errtext)
{
struct iovec iov[2];
SaAisErrorT err;
int target_node;
if (csid)
memcpy(&target_node, csid, OPENAIS_CSID_LEN);
else
target_node = 0;
iov[0].iov_base = &target_node;
iov[0].iov_len = sizeof(int);
iov[1].iov_base = (char *)buf;
iov[1].iov_len = msglen;
err = cpg_mcast_joined(cpg_handle, CPG_TYPE_AGREED, iov, 2);
return ais_to_errno(err);
}
/* We don't have a cluster name to report here */
static int _get_cluster_name(char *buf, int buflen)
{
strncpy(buf, "OpenAIS", buflen);
return 0;
}
static struct cluster_ops _cluster_openais_ops = {
.name = "openais",
.cluster_init_completed = NULL,
.cluster_send_message = _cluster_send_message,
.name_from_csid = _name_from_csid,
.csid_from_name = _csid_from_name,
.get_num_nodes = _get_num_nodes,
.cluster_fd_callback = _cluster_fd_callback,
.get_main_cluster_fd = _get_main_cluster_fd,
.cluster_do_node_callback = _cluster_do_node_callback,
.is_quorate = _is_quorate,
.get_our_csid = _get_our_csid,
.add_up_node = _add_up_node,
.reread_config = NULL,
.cluster_closedown = _cluster_closedown,
.get_cluster_name = _get_cluster_name,
.sync_lock = _sync_lock,
.sync_unlock = _sync_unlock,
};
struct cluster_ops *init_openais_cluster(void)
{
if (!_init_cluster())
return &_cluster_openais_ops;
else
return NULL;
}

View File

@ -0,0 +1,321 @@
/*
* Copyright (C) 2009 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "clvmd-common.h"
#include <pthread.h>
#include "locking.h"
#include "clvm.h"
#include "clvmd-comms.h"
#include "lvm-functions.h"
#include "clvmd.h"
#include <sys/un.h>
#include <sys/socket.h>
#include <fcntl.h>
static const char SINGLENODE_CLVMD_SOCKNAME[] = DEFAULT_RUN_DIR "/clvmd_singlenode.sock";
static int listen_fd = -1;
static int *_locks = NULL;
static char **_resources = NULL;
static void close_comms(void)
{
if (listen_fd != -1 && close(listen_fd))
stack;
(void)unlink(SINGLENODE_CLVMD_SOCKNAME);
listen_fd = -1;
}
static int init_comms(void)
{
struct sockaddr_un addr;
mode_t old_mask;
close_comms();
(void) dm_prepare_selinux_context(SINGLENODE_CLVMD_SOCKNAME, S_IFSOCK);
old_mask = umask(0077);
listen_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (listen_fd < 0) {
DEBUGLOG("Can't create local socket: %s\n", strerror(errno));
goto error;
}
/* Set Close-on-exec */
if (fcntl(listen_fd, F_SETFD, 1)) {
DEBUGLOG("Setting CLOEXEC on client fd failed: %s\n", strerror(errno));
goto error;
}
memset(&addr, 0, sizeof(addr));
memcpy(addr.sun_path, SINGLENODE_CLVMD_SOCKNAME,
sizeof(SINGLENODE_CLVMD_SOCKNAME));
addr.sun_family = AF_UNIX;
if (bind(listen_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
DEBUGLOG("Can't bind local socket: %s\n", strerror(errno));
goto error;
}
if (listen(listen_fd, 10) < 0) {
DEBUGLOG("Can't listen local socket: %s\n", strerror(errno));
goto error;
}
umask(old_mask);
(void) dm_prepare_selinux_context(NULL, 0);
return 0;
error:
umask(old_mask);
(void) dm_prepare_selinux_context(NULL, 0);
close_comms();
return -1;
}
static int _init_cluster(void)
{
int r;
r = init_comms();
if (r)
return r;
DEBUGLOG("Single-node cluster initialised.\n");
return 0;
}
static void _cluster_closedown(void)
{
close_comms();
DEBUGLOG("cluster_closedown\n");
destroy_lvhash();
dm_free(_locks);
dm_free(_resources);
_locks = NULL;
_resources = NULL;
}
static void _get_our_csid(char *csid)
{
int nodeid = 1;
memcpy(csid, &nodeid, sizeof(int));
}
static int _csid_from_name(char *csid, const char *name)
{
return 1;
}
static int _name_from_csid(const char *csid, char *name)
{
sprintf(name, "SINGLENODE");
return 0;
}
static int _get_num_nodes(void)
{
return 1;
}
/* Node is now known to be running a clvmd */
static void _add_up_node(const char *csid)
{
}
/* Call a callback for each node, so the caller knows whether it's up or down */
static int _cluster_do_node_callback(struct local_client *master_client,
void (*callback)(struct local_client *,
const char *csid, int node_up))
{
return 0;
}
int _lock_file(const char *file, uint32_t flags);
static int _lock_max = 1;
static pthread_mutex_t _lock_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Using one common condition for all locks for simplicity */
static pthread_cond_t _lock_cond = PTHREAD_COND_INITIALIZER;
/* Real locking */
static int _lock_resource(const char *resource, int mode, int flags, int *lockid)
{
int *_locks_1;
char **_resources_1;
int i, j;
if (mode == LCK_READ) { /* only track PREAD, aka PROTECTED READ */
DEBUGLOG("Not tracking CONCURRENT READ lock: %s, flags=%d, mode=%d\n",
resource, flags, mode);
*lockid = -1;
return 0;
}
DEBUGLOG("Locking resource %s, flags=%d, mode=%d\n",
resource, flags, mode);
pthread_mutex_lock(&_lock_mutex);
retry:
/* look for an existing lock for this resource */
for (i = 1; i < _lock_max; ++i) {
if (!_resources[i])
break;
if (!strcmp(_resources[i], resource)) {
if ((_locks[i] & LCK_TYPE_MASK) == LCK_WRITE ||
(_locks[i] & LCK_TYPE_MASK) == LCK_EXCL) {
DEBUGLOG("Resource %s already write/exclusively locked...\n", resource);
goto maybe_retry;
}
if ((mode & LCK_TYPE_MASK) == LCK_WRITE ||
(mode & LCK_TYPE_MASK) == LCK_EXCL) {
DEBUGLOG("Resource %s already locked and WRITE/EXCL lock requested...\n",
resource);
goto maybe_retry;
}
}
}
if (i == _lock_max) { /* out of lock slots, extend */
if (!(_locks_1 = dm_realloc(_locks, 2 * _lock_max * sizeof(int))))
goto_bad;
_locks = _locks_1;
if (!(_resources_1 = dm_realloc(_resources, 2 * _lock_max * sizeof(char *))))
/* _locks may get realloc'd twice, but that should be safe */
goto_bad;
_resources = _resources_1;
/* clear the new resource entries */
for (j = _lock_max; j < 2 * _lock_max; ++j)
_resources[j] = NULL;
_lock_max = 2 * _lock_max;
}
/* resource is not currently locked, grab it */
if (!(_resources[i] = dm_strdup(resource)))
goto_bad;
*lockid = i;
_locks[i] = mode;
DEBUGLOG("Locked resource %s, lockid=%d\n", resource, i);
pthread_mutex_unlock(&_lock_mutex);
return 0;
maybe_retry:
if (!(flags & LCK_NONBLOCK)) {
pthread_cond_wait(&_lock_cond, &_lock_mutex);
goto retry;
}
bad:
DEBUGLOG("Failed to lock resource %s\n", resource);
pthread_mutex_unlock(&_lock_mutex);
return 1; /* fail */
}
static int _unlock_resource(const char *resource, int lockid)
{
if (lockid < 0) {
DEBUGLOG("Not tracking unlock of lockid -1: %s, lockid=%d\n",
resource, lockid);
return 0;
}
DEBUGLOG("Unlocking resource %s, lockid=%d\n", resource, lockid);
pthread_mutex_lock(&_lock_mutex);
if (!_resources[lockid]) {
pthread_mutex_unlock(&_lock_mutex);
DEBUGLOG("Resource %s, lockid=%d is not locked\n", resource, lockid);
return 1;
}
if (strcmp(_resources[lockid], resource)) {
pthread_mutex_unlock(&_lock_mutex);
DEBUGLOG("Resource %d has wrong resource (requested %s, got %s)\n",
lockid, resource, _resources[lockid]);
return 1;
}
dm_free(_resources[lockid]);
_resources[lockid] = 0;
pthread_cond_broadcast(&_lock_cond); /* wakeup waiters */
pthread_mutex_unlock(&_lock_mutex);
return 0;
}
static int _is_quorate(void)
{
return 1;
}
static int _get_main_cluster_fd(void)
{
return listen_fd;
}
static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
const char *csid,
struct local_client **new_client)
{
return 1;
}
static int _cluster_send_message(const void *buf, int msglen,
const char *csid,
const char *errtext)
{
return 0;
}
static int _get_cluster_name(char *buf, int buflen)
{
strncpy(buf, "localcluster", buflen);
buf[buflen - 1] = 0;
return 0;
}
static struct cluster_ops _cluster_singlenode_ops = {
.name = "singlenode",
.cluster_init_completed = NULL,
.cluster_send_message = _cluster_send_message,
.name_from_csid = _name_from_csid,
.csid_from_name = _csid_from_name,
.get_num_nodes = _get_num_nodes,
.cluster_fd_callback = _cluster_fd_callback,
.get_main_cluster_fd = _get_main_cluster_fd,
.cluster_do_node_callback = _cluster_do_node_callback,
.is_quorate = _is_quorate,
.get_our_csid = _get_our_csid,
.add_up_node = _add_up_node,
.reread_config = NULL,
.cluster_closedown = _cluster_closedown,
.get_cluster_name = _get_cluster_name,
.sync_lock = _lock_resource,
.sync_unlock = _unlock_resource,
};
struct cluster_ops *init_singlenode_cluster(void)
{
if (!_init_cluster())
return &_cluster_singlenode_ops;
else
return NULL;
}

2331
daemons/clvmd/clvmd.c Normal file

File diff suppressed because it is too large Load Diff

126
daemons/clvmd/clvmd.h Normal file
View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _CLVMD_H
#define _CLVMD_H
#define CLVMD_MAJOR_VERSION 0
#define CLVMD_MINOR_VERSION 2
#define CLVMD_PATCH_VERSION 1
/* Default time (in seconds) we will wait for all remote commands to execute
before declaring them dead */
#define DEFAULT_CMD_TIMEOUT 60
/* One of these for each reply we get from command execution on a node */
struct node_reply {
char node[MAX_CLUSTER_MEMBER_NAME_LEN];
char *replymsg;
int status;
struct node_reply *next;
};
typedef enum {DEBUG_OFF, DEBUG_STDERR, DEBUG_SYSLOG} debug_t;
/*
* These exist for the use of local sockets only when we are
* collecting responses from all cluster nodes
*/
struct localsock_bits {
struct node_reply *replies;
int num_replies;
int expected_replies;
time_t sent_time; /* So we can check for timeouts */
int in_progress; /* Only execute one cmd at a time per client */
int sent_out; /* Flag to indicate that a command was sent
to remote nodes */
void *private; /* Private area for command processor use */
void *cmd; /* Whole command as passed down local socket */
int cmd_len; /* Length of above */
int pipe; /* Pipe to send PRE completion status down */
int finished; /* Flag to tell subthread to exit */
int all_success; /* Set to 0 if any node (or the pre_command)
failed */
struct local_client *pipe_client;
pthread_t threadid;
enum { PRE_COMMAND, POST_COMMAND, QUIT } state;
pthread_mutex_t mutex; /* Main thread and worker synchronisation */
pthread_cond_t cond;
pthread_mutex_t reply_mutex; /* Protect reply structure */
};
/* Entries for PIPE clients */
struct pipe_bits {
struct local_client *client; /* Actual (localsock) client */
pthread_t threadid; /* Our own copy of the thread id */
};
/* Entries for Network socket clients */
struct netsock_bits {
void *private;
int flags;
};
typedef int (*fd_callback_t) (struct local_client * fd, char *buf, int len,
const char *csid,
struct local_client ** new_client);
/* One of these for each fd we are listening on */
struct local_client {
int fd;
enum { CLUSTER_MAIN_SOCK, CLUSTER_DATA_SOCK, LOCAL_RENDEZVOUS,
LOCAL_SOCK, THREAD_PIPE, CLUSTER_INTERNAL } type;
struct local_client *next;
unsigned short xid;
fd_callback_t callback;
uint8_t removeme;
union {
struct localsock_bits localsock;
struct pipe_bits pipe;
struct netsock_bits net;
} bits;
};
#define DEBUGLOG(fmt, args...) debuglog(fmt, ## args);
#ifndef max
#define max(a,b) ((a)>(b)?(a):(b))
#endif
/* The real command processor is in clvmd-command.c */
extern int do_command(struct local_client *client, struct clvm_header *msg,
int msglen, char **buf, int buflen, int *retlen);
/* Pre and post command routines are called only on the local node */
extern int do_pre_command(struct local_client *client);
extern int do_post_command(struct local_client *client);
extern void cmd_client_cleanup(struct local_client *client);
extern int add_client(struct local_client *new_client);
extern void clvmd_cluster_init_completed(void);
extern void process_message(struct local_client *client, char *buf,
int len, const char *csid);
extern void debuglog(const char *fmt, ... )
__attribute__ ((format(printf, 1, 2)));
void clvmd_set_debug(debug_t new_de);
debug_t clvmd_get_debug(void);
int sync_lock(const char *resource, int mode, int flags, int *lockid);
int sync_unlock(const char *resource, int lockid);
#endif

View File

@ -0,0 +1,917 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "clvmd-common.h"
#include <pthread.h>
#include "lvm-types.h"
#include "clvm.h"
#include "clvmd-comms.h"
#include "clvmd.h"
#include "lvm-functions.h"
/* LVM2 headers */
#include "toolcontext.h"
#include "lvmcache.h"
#include "lvm-globals.h"
#include "activate.h"
#include "archiver.h"
#include "memlock.h"
#include <syslog.h>
static struct cmd_context *cmd = NULL;
static struct dm_hash_table *lv_hash = NULL;
static pthread_mutex_t lv_hash_lock;
static pthread_mutex_t lvm_lock;
static char last_error[1024];
struct lv_info {
int lock_id;
int lock_mode;
};
static const char *decode_full_locking_cmd(uint32_t cmdl)
{
static char buf[128];
const char *type;
const char *scope;
const char *command;
switch (cmdl & LCK_TYPE_MASK) {
case LCK_NULL:
type = "NULL";
break;
case LCK_READ:
type = "READ";
break;
case LCK_PREAD:
type = "PREAD";
break;
case LCK_WRITE:
type = "WRITE";
break;
case LCK_EXCL:
type = "EXCL";
break;
case LCK_UNLOCK:
type = "UNLOCK";
break;
default:
type = "unknown";
break;
}
switch (cmdl & LCK_SCOPE_MASK) {
case LCK_VG:
scope = "VG";
command = "LCK_VG";
break;
case LCK_LV:
scope = "LV";
switch (cmdl & LCK_MASK) {
case LCK_LV_EXCLUSIVE & LCK_MASK:
command = "LCK_LV_EXCLUSIVE";
break;
case LCK_LV_SUSPEND & LCK_MASK:
command = "LCK_LV_SUSPEND";
break;
case LCK_LV_RESUME & LCK_MASK:
command = "LCK_LV_RESUME";
break;
case LCK_LV_ACTIVATE & LCK_MASK:
command = "LCK_LV_ACTIVATE";
break;
case LCK_LV_DEACTIVATE & LCK_MASK:
command = "LCK_LV_DEACTIVATE";
break;
default:
command = "unknown";
break;
}
break;
default:
scope = "unknown";
command = "unknown";
break;
}
sprintf(buf, "0x%x %s (%s|%s%s%s%s%s)", cmdl, command, type, scope,
cmdl & LCK_NONBLOCK ? "|NONBLOCK" : "",
cmdl & LCK_HOLD ? "|HOLD" : "",
cmdl & LCK_CLUSTER_VG ? "|CLUSTER_VG" : "",
cmdl & LCK_CACHE ? "|CACHE" : "");
return buf;
}
/*
* Only processes 8 bits: excludes LCK_CACHE.
*/
static const char *decode_locking_cmd(unsigned char cmdl)
{
return decode_full_locking_cmd((uint32_t) cmdl);
}
static const char *decode_flags(unsigned char flags)
{
static char buf[128];
int len;
len = sprintf(buf, "0x%x ( %s%s%s%s%s%s%s)", flags,
flags & LCK_PARTIAL_MODE ? "PARTIAL_MODE|" : "",
flags & LCK_MIRROR_NOSYNC_MODE ? "MIRROR_NOSYNC|" : "",
flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR|" : "",
flags & LCK_ORIGIN_ONLY_MODE ? "ORIGIN_ONLY|" : "",
flags & LCK_TEST_MODE ? "TEST|" : "",
flags & LCK_CONVERT ? "CONVERT|" : "",
flags & LCK_DMEVENTD_MONITOR_IGNORE ? "DMEVENTD_MONITOR_IGNORE|" : "");
if (len > 1)
buf[len - 2] = ' ';
else
buf[0] = '\0';
return buf;
}
char *get_last_lvm_error(void)
{
return last_error;
}
/*
* Hash lock info helpers
*/
static struct lv_info *lookup_info(const char *resource)
{
struct lv_info *lvi;
pthread_mutex_lock(&lv_hash_lock);
lvi = dm_hash_lookup(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
return lvi;
}
static void insert_info(const char *resource, struct lv_info *lvi)
{
pthread_mutex_lock(&lv_hash_lock);
dm_hash_insert(lv_hash, resource, lvi);
pthread_mutex_unlock(&lv_hash_lock);
}
static void remove_info(const char *resource)
{
pthread_mutex_lock(&lv_hash_lock);
dm_hash_remove(lv_hash, resource);
pthread_mutex_unlock(&lv_hash_lock);
}
/*
* Return the mode a lock is currently held at (or -1 if not held)
*/
static int get_current_lock(char *resource)
{
struct lv_info *lvi;
if ((lvi = lookup_info(resource)))
return lvi->lock_mode;
return -1;
}
void init_lvhash(void)
{
/* Create hash table for keeping LV locks & status */
lv_hash = dm_hash_create(1024);
pthread_mutex_init(&lv_hash_lock, NULL);
pthread_mutex_init(&lvm_lock, NULL);
}
/* Called at shutdown to tidy the lockspace */
void destroy_lvhash(void)
{
struct dm_hash_node *v;
struct lv_info *lvi;
char *resource;
int status;
pthread_mutex_lock(&lv_hash_lock);
dm_hash_iterate(v, lv_hash) {
lvi = dm_hash_get_data(lv_hash, v);
resource = dm_hash_get_key(lv_hash, v);
if ((status = sync_unlock(resource, lvi->lock_id)))
DEBUGLOG("unlock_all. unlock failed(%d): %s\n",
status, strerror(errno));
free(lvi);
}
dm_hash_destroy(lv_hash);
lv_hash = NULL;
pthread_mutex_unlock(&lv_hash_lock);
}
/* Gets a real lock and keeps the info in the hash table */
static int hold_lock(char *resource, int mode, int flags)
{
int status;
int saved_errno;
struct lv_info *lvi;
if (test_mode())
return 0;
/* Mask off invalid options */
flags &= LCKF_NOQUEUE | LCKF_CONVERT;
lvi = lookup_info(resource);
if (lvi) {
if (lvi->lock_mode == mode) {
DEBUGLOG("hold_lock, lock mode %d already held\n",
mode);
return 0;
}
if ((lvi->lock_mode == LCK_EXCL) && (mode == LCK_WRITE)) {
DEBUGLOG("hold_lock, lock already held LCK_EXCL, "
"ignoring LCK_WRITE request");
return 0;
}
}
/* Only allow explicit conversions */
if (lvi && !(flags & LCKF_CONVERT)) {
errno = EBUSY;
return -1;
}
if (lvi) {
/* Already exists - convert it */
status =
sync_lock(resource, mode, flags, &lvi->lock_id);
saved_errno = errno;
if (!status)
lvi->lock_mode = mode;
if (status) {
DEBUGLOG("hold_lock. convert to %d failed: %s\n", mode,
strerror(errno));
}
errno = saved_errno;
} else {
lvi = malloc(sizeof(struct lv_info));
if (!lvi)
return -1;
lvi->lock_mode = mode;
status = sync_lock(resource, mode, flags & ~LCKF_CONVERT, &lvi->lock_id);
saved_errno = errno;
if (status) {
free(lvi);
DEBUGLOG("hold_lock. lock at %d failed: %s\n", mode,
strerror(errno));
} else
insert_info(resource, lvi);
errno = saved_errno;
}
return status;
}
/* Unlock and remove it from the hash table */
static int hold_unlock(char *resource)
{
struct lv_info *lvi;
int status;
int saved_errno;
if (test_mode())
return 0;
if (!(lvi = lookup_info(resource))) {
DEBUGLOG("hold_unlock, lock not already held\n");
return 0;
}
status = sync_unlock(resource, lvi->lock_id);
saved_errno = errno;
if (!status) {
remove_info(resource);
free(lvi);
} else {
DEBUGLOG("hold_unlock. unlock failed(%d): %s\n", status,
strerror(errno));
}
errno = saved_errno;
return status;
}
/* Watch the return codes here.
liblvm API functions return 1(true) for success, 0(false) for failure and don't set errno.
libdlm API functions return 0 for success, -1 for failure and do set errno.
These functions here return 0 for success or >0 for failure (where the retcode is errno)
*/
/* Activate LV exclusive or non-exclusive */
static int do_activate_lv(char *resource, unsigned char command, unsigned char lock_flags, int mode)
{
int oldmode;
int status;
int activate_lv;
int exclusive = 0;
struct lvinfo lvi;
/* Is it already open ? */
oldmode = get_current_lock(resource);
if (oldmode == mode && (command & LCK_CLUSTER_VG)) {
DEBUGLOG("do_activate_lv, lock already held at %d\n", oldmode);
return 0; /* Nothing to do */
}
/* Does the config file want us to activate this LV ? */
if (!lv_activation_filter(cmd, resource, &activate_lv))
return EIO;
if (!activate_lv)
return 0; /* Success, we did nothing! */
/* Do we need to activate exclusively? */
if ((activate_lv == 2) || (mode == LCK_EXCL)) {
exclusive = 1;
mode = LCK_EXCL;
}
/*
* Try to get the lock if it's a clustered volume group.
* Use lock conversion only if requested, to prevent implicit conversion
* of exclusive lock to shared one during activation.
*/
if (command & LCK_CLUSTER_VG) {
status = hold_lock(resource, mode, LCKF_NOQUEUE | (lock_flags & LCK_CONVERT ? LCKF_CONVERT:0));
if (status) {
/* Return an LVM-sensible error for this.
* Forcing EIO makes the upper level return this text
* rather than the strerror text for EAGAIN.
*/
if (errno == EAGAIN) {
sprintf(last_error, "Volume is busy on another node");
errno = EIO;
}
return errno;
}
}
/* If it's suspended then resume it */
if (!lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0))
goto error;
if (lvi.suspended) {
critical_section_inc(cmd, "resuming");
if (!lv_resume(cmd, resource, 0)) {
critical_section_dec(cmd, "resumed");
goto error;
}
}
/* Now activate it */
if (!lv_activate(cmd, resource, exclusive))
goto error;
return 0;
error:
if (oldmode == -1 || oldmode != mode)
(void)hold_unlock(resource);
return EIO;
}
/* Resume the LV if it was active */
static int do_resume_lv(char *resource, unsigned char command, unsigned char lock_flags)
{
int oldmode, origin_only, exclusive, revert;
/* Is it open ? */
oldmode = get_current_lock(resource);
if (oldmode == -1 && (command & LCK_CLUSTER_VG)) {
DEBUGLOG("do_resume_lv, lock not already held\n");
return 0; /* We don't need to do anything */
}
origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
revert = (lock_flags & LCK_REVERT_MODE) ? 1 : 0;
if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert))
return EIO;
return 0;
}
/* Suspend the device if active */
static int do_suspend_lv(char *resource, unsigned char command, unsigned char lock_flags)
{
int oldmode;
struct lvinfo lvi;
unsigned origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
unsigned exclusive;
/* Is it open ? */
oldmode = get_current_lock(resource);
if (oldmode == -1 && (command & LCK_CLUSTER_VG)) {
DEBUGLOG("do_suspend_lv, lock not already held\n");
return 0; /* Not active, so it's OK */
}
exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
/* Only suspend it if it exists */
if (!lv_info_by_lvid(cmd, resource, origin_only, &lvi, 0, 0))
return EIO;
if (lvi.exists &&
!lv_suspend_if_active(cmd, resource, origin_only, exclusive))
return EIO;
return 0;
}
static int do_deactivate_lv(char *resource, unsigned char command, unsigned char lock_flags)
{
int oldmode;
int status;
/* Is it open ? */
oldmode = get_current_lock(resource);
if (oldmode == -1 && (command & LCK_CLUSTER_VG)) {
DEBUGLOG("do_deactivate_lock, lock not already held\n");
return 0; /* We don't need to do anything */
}
if (!lv_deactivate(cmd, resource))
return EIO;
if (command & LCK_CLUSTER_VG) {
status = hold_unlock(resource);
if (status)
return errno;
}
return 0;
}
const char *do_lock_query(char *resource)
{
int mode;
const char *type = NULL;
mode = get_current_lock(resource);
switch (mode) {
case LCK_NULL: type = "NL"; break;
case LCK_READ: type = "CR"; break;
case LCK_PREAD:type = "PR"; break;
case LCK_WRITE:type = "PW"; break;
case LCK_EXCL: type = "EX"; break;
}
DEBUGLOG("do_lock_query: resource '%s', mode %i (%s)\n", resource, mode, type ?: "?");
return type;
}
/* This is the LOCK_LV part that happens on all nodes in the cluster -
it is responsible for the interaction with device-mapper and LVM */
int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
{
int status = 0;
DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s, critical_section = %d\n",
resource, decode_locking_cmd(command), decode_flags(lock_flags), critical_section());
if (!cmd->config_valid || config_files_changed(cmd)) {
/* Reinitialise various settings inc. logging, filters */
if (do_refresh_cache()) {
log_error("Updated config file invalid. Aborting.");
return EINVAL;
}
}
pthread_mutex_lock(&lvm_lock);
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(1);
if (lock_flags & LCK_DMEVENTD_MONITOR_IGNORE)
init_dmeventd_monitor(DMEVENTD_MONITOR_IGNORE);
else {
if (lock_flags & LCK_DMEVENTD_MONITOR_MODE)
init_dmeventd_monitor(1);
else
init_dmeventd_monitor(0);
}
cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
/* clvmd should never try to read suspended device */
init_ignore_suspended_devices(1);
switch (command & LCK_MASK) {
case LCK_LV_EXCLUSIVE:
status = do_activate_lv(resource, command, lock_flags, LCK_EXCL);
break;
case LCK_LV_SUSPEND:
status = do_suspend_lv(resource, command, lock_flags);
break;
case LCK_UNLOCK:
case LCK_LV_RESUME: /* if active */
status = do_resume_lv(resource, command, lock_flags);
break;
case LCK_LV_ACTIVATE:
status = do_activate_lv(resource, command, lock_flags, LCK_READ);
break;
case LCK_LV_DEACTIVATE:
status = do_deactivate_lv(resource, command, lock_flags);
break;
default:
DEBUGLOG("Invalid LV command 0x%x\n", command);
status = EINVAL;
break;
}
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(0);
cmd->partial_activation = 0;
/* clean the pool for another command */
dm_pool_empty(cmd->mem);
pthread_mutex_unlock(&lvm_lock);
DEBUGLOG("Command return is %d, critical_section is %d\n", status, critical_section());
return status;
}
/* Functions to do on the local node only BEFORE the cluster-wide stuff above happens */
int pre_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
{
/* Nearly all the stuff happens cluster-wide. Apart from SUSPEND. Here we get the
lock out on this node (because we are the node modifying the metadata)
before suspending cluster-wide.
LCKF_CONVERT is used always, local node is going to modify metadata
*/
if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND &&
(command & LCK_CLUSTER_VG)) {
DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
resource, decode_locking_cmd(command), decode_flags(lock_flags));
if (hold_lock(resource, LCK_WRITE, LCKF_NOQUEUE | LCKF_CONVERT))
return errno;
}
return 0;
}
/* Functions to do on the local node only AFTER the cluster-wide stuff above happens */
int post_lock_lv(unsigned char command, unsigned char lock_flags,
char *resource)
{
int status;
unsigned origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
/* Opposite of above, done on resume after a metadata update */
if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME &&
(command & LCK_CLUSTER_VG)) {
int oldmode;
DEBUGLOG
("post_lock_lv: resource '%s', cmd = %s, flags = %s\n",
resource, decode_locking_cmd(command), decode_flags(lock_flags));
/* If the lock state is PW then restore it to what it was */
oldmode = get_current_lock(resource);
if (oldmode == LCK_WRITE) {
struct lvinfo lvi;
pthread_mutex_lock(&lvm_lock);
status = lv_info_by_lvid(cmd, resource, origin_only, &lvi, 0, 0);
pthread_mutex_unlock(&lvm_lock);
if (!status)
return EIO;
if (lvi.exists) {
if (hold_lock(resource, LCK_READ, LCKF_CONVERT))
return errno;
} else if (hold_unlock(resource))
return errno;
}
}
return 0;
}
/* Check if a VG is in use by LVM1 so we don't stomp on it */
int do_check_lvm1(const char *vgname)
{
int status;
status = check_lvm1_vg_inactive(cmd, vgname);
return status == 1 ? 0 : EBUSY;
}
int do_refresh_cache(void)
{
DEBUGLOG("Refreshing context\n");
log_notice("Refreshing context");
pthread_mutex_lock(&lvm_lock);
if (!refresh_toolcontext(cmd)) {
pthread_mutex_unlock(&lvm_lock);
return -1;
}
init_full_scan_done(0);
init_ignore_suspended_devices(1);
lvmcache_label_scan(cmd, 2);
dm_pool_empty(cmd->mem);
pthread_mutex_unlock(&lvm_lock);
return 0;
}
/*
* Handle VG lock - drop metadata or update lvmcache state
*/
void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
{
uint32_t lock_cmd = command;
char *vgname = resource + 2;
lock_cmd &= (LCK_SCOPE_MASK | LCK_TYPE_MASK | LCK_HOLD);
/*
* Check if LCK_CACHE should be set. All P_ locks except # are cache related.
*/
if (strncmp(resource, "P_#", 3) && !strncmp(resource, "P_", 2))
lock_cmd |= LCK_CACHE;
DEBUGLOG("do_lock_vg: resource '%s', cmd = %s, flags = %s, critical_section = %d\n",
resource, decode_full_locking_cmd(lock_cmd), decode_flags(lock_flags), critical_section());
/* P_#global causes a full cache refresh */
if (!strcmp(resource, "P_" VG_GLOBAL)) {
do_refresh_cache();
return;
}
pthread_mutex_lock(&lvm_lock);
switch (lock_cmd) {
case LCK_VG_COMMIT:
DEBUGLOG("vg_commit notification for VG %s\n", vgname);
lvmcache_commit_metadata(vgname);
break;
case LCK_VG_REVERT:
DEBUGLOG("vg_revert notification for VG %s\n", vgname);
lvmcache_drop_metadata(vgname, 1);
break;
case LCK_VG_DROP_CACHE:
default:
DEBUGLOG("Invalidating cached metadata for VG %s\n", vgname);
lvmcache_drop_metadata(vgname, 0);
}
pthread_mutex_unlock(&lvm_lock);
}
/*
* Ideally, clvmd should be started before any LVs are active
* but this may not be the case...
* I suppose this also comes in handy if clvmd crashes, not that it would!
*/
static int get_initial_state(struct dm_hash_table *excl_uuid)
{
int lock_mode;
char lv[64], vg[64], flags[25], vg_flags[25];
char uuid[65];
char line[255];
char *lvs_cmd;
const char *lvm_binary = getenv("LVM_BINARY") ? : LVM_PATH;
FILE *lvs;
if (dm_asprintf(&lvs_cmd, "%s lvs --config 'log{command_names=0 prefix=\"\"}' "
"--nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr",
lvm_binary) < 0)
return 0;
/* FIXME: Maybe link and use liblvm2cmd directly instead of fork */
if (!(lvs = popen(lvs_cmd, "r"))) {
dm_free(lvs_cmd);
return 0;
}
while (fgets(line, sizeof(line), lvs)) {
if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) {
/* States: s:suspended a:active S:dropped snapshot I:invalid snapshot */
if (strlen(vg) == 38 && /* is is a valid UUID ? */
(flags[4] == 'a' || flags[4] == 's') && /* is it active or suspended? */
vg_flags[5] == 'c') { /* is it clustered ? */
/* Convert hyphen-separated UUIDs into one */
memcpy(&uuid[0], &vg[0], 6);
memcpy(&uuid[6], &vg[7], 4);
memcpy(&uuid[10], &vg[12], 4);
memcpy(&uuid[14], &vg[17], 4);
memcpy(&uuid[18], &vg[22], 4);
memcpy(&uuid[22], &vg[27], 4);
memcpy(&uuid[26], &vg[32], 6);
memcpy(&uuid[32], &lv[0], 6);
memcpy(&uuid[38], &lv[7], 4);
memcpy(&uuid[42], &lv[12], 4);
memcpy(&uuid[46], &lv[17], 4);
memcpy(&uuid[50], &lv[22], 4);
memcpy(&uuid[54], &lv[27], 4);
memcpy(&uuid[58], &lv[32], 6);
uuid[64] = '\0';
/* Look for this lock in the list of EX locks
we were passed on the command-line */
lock_mode = (dm_hash_lookup(excl_uuid, uuid)) ?
LCK_EXCL : LCK_READ;
DEBUGLOG("getting initial lock for %s\n", uuid);
hold_lock(uuid, lock_mode, LCKF_NOQUEUE);
}
}
}
if (fclose(lvs))
DEBUGLOG("lvs fclose failed: %s\n", strerror(errno));
dm_free(lvs_cmd);
return 1;
}
static void lvm2_log_fn(int level, const char *file, int line, int dm_errno,
const char *message)
{
/* Send messages to the normal LVM2 logging system too,
so we get debug output when it's asked for.
We need to NULL the function ptr otherwise it will just call
back into here! */
init_log_fn(NULL);
print_log(level, file, line, dm_errno, "%s", message);
init_log_fn(lvm2_log_fn);
/*
* Ignore non-error messages, but store the latest one for returning
* to the user.
*/
if (level != _LOG_ERR && level != _LOG_FATAL)
return;
strncpy(last_error, message, sizeof(last_error));
last_error[sizeof(last_error)-1] = '\0';
}
/* This checks some basic cluster-LVM configuration stuff */
static void check_config(void)
{
int locking_type;
locking_type = find_config_tree_int(cmd, "global/locking_type", 1);
if (locking_type == 3) /* compiled-in cluster support */
return;
if (locking_type == 2) { /* External library, check name */
const char *libname;
libname = find_config_tree_str(cmd, "global/locking_library",
"");
if (strstr(libname, "liblvm2clusterlock.so"))
return;
log_error("Incorrect LVM locking library specified in lvm.conf, cluster operations may not work.");
return;
}
log_error("locking_type not set correctly in lvm.conf, cluster operations will not work.");
}
/* Backups up the LVM metadata if it's changed */
void lvm_do_backup(const char *vgname)
{
struct volume_group * vg;
int consistent = 0;
DEBUGLOG("Triggering backup of VG metadata for %s.\n", vgname);
pthread_mutex_lock(&lvm_lock);
vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, 1, &consistent);
if (vg && consistent)
check_current_backup(vg);
else
log_error("Error backing up metadata, can't find VG for group %s", vgname);
release_vg(vg);
dm_pool_empty(cmd->mem);
pthread_mutex_unlock(&lvm_lock);
}
struct dm_hash_node *get_next_excl_lock(struct dm_hash_node *v, char **name)
{
struct lv_info *lvi;
*name = NULL;
if (!v)
v = dm_hash_get_first(lv_hash);
do {
if (v) {
lvi = dm_hash_get_data(lv_hash, v);
DEBUGLOG("Looking for EX locks. found %x mode %d\n", lvi->lock_id, lvi->lock_mode);
if (lvi->lock_mode == LCK_EXCL) {
*name = dm_hash_get_key(lv_hash, v);
}
v = dm_hash_get_next(lv_hash, v);
}
} while (v && !*name);
if (*name)
DEBUGLOG("returning EXclusive UUID %s\n", *name);
return v;
}
void lvm_do_fs_unlock(void)
{
pthread_mutex_lock(&lvm_lock);
DEBUGLOG("Syncing device names\n");
fs_unlock();
pthread_mutex_unlock(&lvm_lock);
}
/* Called to initialise the LVM context of the daemon */
int init_clvm(struct dm_hash_table *excl_uuid)
{
/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
init_syslog(LOG_DAEMON);
openlog("clvmd", LOG_PID, LOG_DAEMON);
/* Initialise already held locks */
if (!get_initial_state(excl_uuid))
log_error("Cannot load initial lock states.");
if (!(cmd = create_toolcontext(1, NULL, 0, 1))) {
log_error("Failed to allocate command context");
return 0;
}
if (stored_errno()) {
destroy_toolcontext(cmd);
return 0;
}
cmd->cmd_line = "clvmd";
/* Check lvm.conf is setup for cluster-LVM */
check_config();
init_ignore_suspended_devices(1);
/* Trap log messages so we can pass them back to the user */
init_log_fn(lvm2_log_fn);
memlock_inc_daemon(cmd);
return 1;
}
void destroy_lvm(void)
{
if (cmd) {
memlock_dec_daemon(cmd);
destroy_toolcontext(cmd);
}
cmd = NULL;
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Functions in lvm-functions.c */
#ifndef _LVM_FUNCTIONS_H
#define _LVM_FUNCTIONS_H
extern int pre_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
char *resource);
extern int do_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
char *resource);
extern const char *do_lock_query(char *resource);
extern int post_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
char *resource);
extern int do_check_lvm1(const char *vgname);
extern int do_refresh_cache(void);
extern int init_clvm(struct dm_hash_table *excl_uuid);
extern void destroy_lvm(void);
extern void init_lvhash(void);
extern void destroy_lvhash(void);
extern void lvm_do_backup(const char *vgname);
extern char *get_last_lvm_error(void);
extern void do_lock_vg(unsigned char command, unsigned char lock_flags,
char *resource);
extern struct dm_hash_node *get_next_excl_lock(struct dm_hash_node *v, char **name);
void lvm_do_fs_unlock(void);
#endif

View File

@ -0,0 +1,385 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* FIXME Remove duplicated functions from this file. */
/*
* Send a command to a running clvmd from the command-line
*/
#include "clvmd-common.h"
#include "clvm.h"
#include "refresh_clvmd.h"
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>
typedef struct lvm_response {
char node[255];
char *response;
int status;
int len;
} lvm_response_t;
/*
* This gets stuck at the start of memory we allocate so we
* can sanity-check it at deallocation time
*/
#define LVM_SIGNATURE 0x434C564D
static int _clvmd_sock = -1;
/* Open connection to the clvm daemon */
static int _open_local_sock(void)
{
int local_socket;
struct sockaddr_un sockaddr;
/* Open local socket */
if ((local_socket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "Local socket creation failed: %s", strerror(errno));
return -1;
}
memset(&sockaddr, 0, sizeof(sockaddr));
memcpy(sockaddr.sun_path, CLVMD_SOCKNAME, sizeof(CLVMD_SOCKNAME));
sockaddr.sun_family = AF_UNIX;
if (connect(local_socket,(struct sockaddr *) &sockaddr,
sizeof(sockaddr))) {
int saved_errno = errno;
fprintf(stderr, "connect() failed on local socket: %s\n",
strerror(errno));
if (close(local_socket))
return -1;
errno = saved_errno;
return -1;
}
return local_socket;
}
/* Send a request and return the status */
static int _send_request(const char *inbuf, int inlen, char **retbuf, int no_response)
{
char outbuf[PIPE_BUF];
struct clvm_header *outheader = (struct clvm_header *) outbuf;
int len;
unsigned off;
int buflen;
int err;
/* Send it to CLVMD */
rewrite:
if ( (err = write(_clvmd_sock, inbuf, inlen)) != inlen) {
if (err == -1 && errno == EINTR)
goto rewrite;
fprintf(stderr, "Error writing data to clvmd: %s", strerror(errno));
return 0;
}
if (no_response)
return 1;
/* Get the response */
reread:
if ((len = read(_clvmd_sock, outbuf, sizeof(struct clvm_header))) < 0) {
if (errno == EINTR)
goto reread;
fprintf(stderr, "Error reading data from clvmd: %s", strerror(errno));
return 0;
}
if (len == 0) {
fprintf(stderr, "EOF reading CLVMD");
errno = ENOTCONN;
return 0;
}
/* Allocate buffer */
buflen = len + outheader->arglen;
*retbuf = dm_malloc(buflen);
if (!*retbuf) {
errno = ENOMEM;
return 0;
}
/* Copy the header */
memcpy(*retbuf, outbuf, len);
outheader = (struct clvm_header *) *retbuf;
/* Read the returned values */
off = 1; /* we've already read the first byte */
while (off <= outheader->arglen && len > 0) {
len = read(_clvmd_sock, outheader->args + off,
buflen - off - offsetof(struct clvm_header, args));
if (len > 0)
off += len;
}
/* Was it an error ? */
if (outheader->status != 0) {
errno = outheader->status;
/* Only return an error here if there are no node-specific
errors present in the message that might have more detail */
if (!(outheader->flags & CLVMD_FLAG_NODEERRS)) {
fprintf(stderr, "cluster request failed: %s\n", strerror(errno));
return 0;
}
}
return 1;
}
/* Build the structure header and parse-out wildcard node names */
static void _build_header(struct clvm_header *head, int cmd, const char *node,
unsigned int len)
{
head->cmd = cmd;
head->status = 0;
head->flags = 0;
head->xid = 0;
head->clientid = 0;
if (len)
/* 1 byte is used from struct clvm_header.args[1], so -> len - 1 */
head->arglen = len - 1;
else {
head->arglen = 0;
*head->args = '\0';
}
/*
* Translate special node names.
*/
if (!node || !strcmp(node, NODE_ALL))
head->node[0] = '\0';
else if (!strcmp(node, NODE_LOCAL)) {
head->node[0] = '\0';
head->flags = CLVMD_FLAG_LOCAL;
} else
strcpy(head->node, node);
}
/*
* Send a message to a(or all) node(s) in the cluster and wait for replies
*/
static int _cluster_request(char cmd, const char *node, void *data, int len,
lvm_response_t ** response, int *num, int no_response)
{
char outbuf[sizeof(struct clvm_header) + len + strlen(node) + 1];
char *inptr;
char *retbuf = NULL;
int status;
int i;
int num_responses = 0;
struct clvm_header *head = (struct clvm_header *) outbuf;
lvm_response_t *rarray;
*num = 0;
if (_clvmd_sock == -1)
_clvmd_sock = _open_local_sock();
if (_clvmd_sock == -1)
return 0;
_build_header(head, cmd, node, len);
if (len)
memcpy(head->node + strlen(head->node) + 1, data, len);
status = _send_request(outbuf, sizeof(struct clvm_header) +
strlen(head->node) + len, &retbuf, no_response);
if (!status || no_response)
goto out;
/* Count the number of responses we got */
head = (struct clvm_header *) retbuf;
inptr = head->args;
while (inptr[0]) {
num_responses++;
inptr += strlen(inptr) + 1;
inptr += sizeof(int);
inptr += strlen(inptr) + 1;
}
/*
* Allocate response array.
* With an extra pair of INTs on the front to sanity
* check the pointer when we are given it back to free
*/
*response = dm_malloc(sizeof(lvm_response_t) * num_responses +
sizeof(int) * 2);
if (!*response) {
errno = ENOMEM;
status = 0;
goto out;
}
rarray = *response;
/* Unpack the response into an lvm_response_t array */
inptr = head->args;
i = 0;
while (inptr[0]) {
strcpy(rarray[i].node, inptr);
inptr += strlen(inptr) + 1;
memcpy(&rarray[i].status, inptr, sizeof(int));
inptr += sizeof(int);
rarray[i].response = dm_malloc(strlen(inptr) + 1);
if (rarray[i].response == NULL) {
/* Free up everything else and return error */
int j;
for (j = 0; j < i; j++)
dm_free(rarray[i].response);
free(*response);
errno = ENOMEM;
status = -1;
goto out;
}
strcpy(rarray[i].response, inptr);
rarray[i].len = strlen(inptr);
inptr += strlen(inptr) + 1;
i++;
}
*num = num_responses;
*response = rarray;
out:
if (retbuf)
dm_free(retbuf);
return status;
}
/* Free reply array */
static int _cluster_free_request(lvm_response_t * response, int num)
{
int i;
for (i = 0; i < num; i++) {
dm_free(response[i].response);
}
dm_free(response);
return 1;
}
int refresh_clvmd(int all_nodes)
{
int num_responses;
char args[1]; // No args really.
lvm_response_t *response = NULL;
int saved_errno;
int status;
int i;
status = _cluster_request(CLVMD_CMD_REFRESH, all_nodes ? NODE_ALL : NODE_LOCAL, args, 0, &response, &num_responses, 0);
/* If any nodes were down then display them and return an error */
for (i = 0; i < num_responses; i++) {
if (response[i].status == EHOSTDOWN) {
fprintf(stderr, "clvmd not running on node %s",
response[i].node);
status = 0;
errno = response[i].status;
} else if (response[i].status) {
fprintf(stderr, "Error resetting node %s: %s",
response[i].node,
response[i].response[0] ?
response[i].response :
strerror(response[i].status));
status = 0;
errno = response[i].status;
}
}
saved_errno = errno;
_cluster_free_request(response, num_responses);
errno = saved_errno;
return status;
}
int restart_clvmd(int all_nodes)
{
int dummy, status;
status = _cluster_request(CLVMD_CMD_RESTART, all_nodes ? NODE_ALL : NODE_LOCAL, NULL, 0, NULL, &dummy, 1);
/*
* FIXME: we cannot receive response, clvmd re-exec before it.
* but also should not close socket too early (the whole rq is dropped then).
* FIXME: This should be handled this way:
* - client waits for RESTART ack (and socket close)
* - server restarts
* - client checks that server is ready again (VERSION command?)
*/
usleep(500000);
return status;
}
int debug_clvmd(int level, int clusterwide)
{
int num_responses;
char args[1];
const char *nodes;
lvm_response_t *response = NULL;
int saved_errno;
int status;
int i;
args[0] = level;
if (clusterwide)
nodes = NODE_ALL;
else
nodes = NODE_LOCAL;
status = _cluster_request(CLVMD_CMD_SET_DEBUG, nodes, args, 1, &response, &num_responses, 0);
/* If any nodes were down then display them and return an error */
for (i = 0; i < num_responses; i++) {
if (response[i].status == EHOSTDOWN) {
fprintf(stderr, "clvmd not running on node %s",
response[i].node);
status = 0;
errno = response[i].status;
} else if (response[i].status) {
fprintf(stderr, "Error setting debug on node %s: %s",
response[i].node,
response[i].response[0] ?
response[i].response :
strerror(response[i].status));
status = 0;
errno = response[i].status;
}
}
saved_errno = errno;
_cluster_free_request(response, num_responses);
errno = saved_errno;
return status;
}

View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2007 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
int refresh_clvmd(int all_nodes);
int restart_clvmd(int all_nodes);
int debug_clvmd(int level, int clusterwide);

View File

@ -0,0 +1,38 @@
#
# Copyright (C) 2009-2010 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPG_LIBS = @CPG_LIBS@
CPG_CFLAGS = @CPG_CFLAGS@
SACKPT_LIBS = @SACKPT_LIBS@
SACKPT_CFLAGS = @SACKPT_CFLAGS@
SOURCES = clogd.c cluster.c compat.c functions.c link_mon.c local.c logging.c
TARGETS = cmirrord
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper
LMLIBS += $(CPG_LIBS) $(SACKPT_LIBS)
CFLAGS += $(CPG_CFLAGS) $(SACKPT_CFLAGS)
cmirrord: $(OBJECTS) $(top_builddir)/lib/liblvm-internal.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
$(LVMLIBS) $(LMLIBS) $(LIBS)
install: $(TARGETS)
$(INSTALL_PROGRAM) -D cmirrord $(usrsbindir)/cmirrord

246
daemons/cmirrord/clogd.c Normal file
View File

@ -0,0 +1,246 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logging.h"
#include "common.h"
#include "functions.h"
#include "link_mon.h"
#include "local.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
static volatile sig_atomic_t exit_now = 0;
/* FIXME Review signal handling. Should be volatile sig_atomic_t */
static sigset_t signal_mask;
static volatile sig_atomic_t signal_received;
static void process_signals(void);
static void daemonize(void);
static void init_all(void);
static void cleanup_all(void);
int main(int argc __attribute__((unused)), char *argv[] __attribute__((unused)))
{
daemonize();
init_all();
/* Parent can now exit, we're ready to handle requests */
kill(getppid(), SIGTERM);
LOG_PRINT("Starting cmirrord:");
LOG_PRINT(" Built: "__DATE__" "__TIME__"\n");
LOG_DBG(" Compiled with debugging.");
while (!exit_now) {
links_monitor();
links_issue_callbacks();
process_signals();
}
exit(EXIT_SUCCESS);
}
/*
* parent_exit_handler: exit the parent
* @sig: the signal
*
*/
static void parent_exit_handler(int sig __attribute__((unused)))
{
exit_now = 1;
}
static void sig_handler(int sig)
{
/* FIXME Races - don't touch signal_mask here. */
sigaddset(&signal_mask, sig);
signal_received = 1;
}
static void process_signal(int sig){
int r = 0;
switch(sig) {
case SIGINT:
case SIGQUIT:
case SIGTERM:
case SIGHUP:
r += log_status();
break;
case SIGUSR1:
case SIGUSR2:
log_debug();
/*local_debug();*/
cluster_debug();
return;
default:
LOG_PRINT("Unknown signal received... ignoring");
return;
}
if (!r) {
LOG_DBG("No current cluster logs... safe to exit.");
cleanup_all();
exit(EXIT_SUCCESS);
}
LOG_ERROR("Cluster logs exist. Refusing to exit.");
}
static void process_signals(void)
{
int x;
if (!signal_received)
return;
signal_received = 0;
for (x = 1; x < _NSIG; x++) {
if (sigismember(&signal_mask, x)) {
sigdelset(&signal_mask, x);
process_signal(x);
}
}
}
static void remove_lockfile(void)
{
if (unlink(CMIRRORD_PIDFILE))
LOG_ERROR("Unable to remove \"" CMIRRORD_PIDFILE "\" %s", strerror(errno));
}
/*
* daemonize
*
* Performs the steps necessary to become a daemon.
*/
static void daemonize(void)
{
int pid;
int status;
int devnull;
if ((devnull = open("/dev/null", O_RDWR)) == -1) {
LOG_ERROR("Can't open /dev/null: %s", strerror(errno));
exit(EXIT_FAILURE);
}
signal(SIGTERM, &parent_exit_handler);
pid = fork();
if (pid < 0) {
LOG_ERROR("Unable to fork()");
exit(EXIT_FAILURE);
}
if (pid) {
/* Parent waits here for child to get going */
while (!waitpid(pid, &status, WNOHANG) && !exit_now);
if (exit_now)
exit(EXIT_SUCCESS);
switch (WEXITSTATUS(status)) {
case EXIT_LOCKFILE:
LOG_ERROR("Failed to create lockfile");
LOG_ERROR("Process already running?");
break;
case EXIT_KERNEL_SOCKET:
LOG_ERROR("Unable to create netlink socket");
break;
case EXIT_KERNEL_BIND:
LOG_ERROR("Unable to bind to netlink socket");
break;
case EXIT_KERNEL_SETSOCKOPT:
LOG_ERROR("Unable to setsockopt on netlink socket");
break;
case EXIT_CLUSTER_CKPT_INIT:
LOG_ERROR("Unable to initialize checkpoint service");
LOG_ERROR("Has the cluster infrastructure been started?");
break;
case EXIT_FAILURE:
LOG_ERROR("Failed to start: Generic error");
break;
default:
LOG_ERROR("Failed to start: Unknown error");
break;
}
exit(EXIT_FAILURE);
}
setsid();
chdir("/");
umask(0);
if (close(0) || close(1) || close(2)) {
LOG_ERROR("Failed to close terminal FDs");
exit(EXIT_FAILURE);
}
if ((dup2(devnull, 0) < 0) || /* reopen stdin */
(dup2(devnull, 1) < 0) || /* reopen stdout */
(dup2(devnull, 2) < 0)) /* reopen stderr */
exit(EXIT_FAILURE);
LOG_OPEN("cmirrord", LOG_PID, LOG_DAEMON);
(void) dm_prepare_selinux_context(CMIRRORD_PIDFILE, S_IFREG);
if (dm_create_lockfile(CMIRRORD_PIDFILE) == 0)
exit(EXIT_LOCKFILE);
(void) dm_prepare_selinux_context(NULL, 0);
atexit(remove_lockfile);
/* FIXME Replace with sigaction. (deprecated) */
signal(SIGINT, &sig_handler);
signal(SIGQUIT, &sig_handler);
signal(SIGTERM, &sig_handler);
signal(SIGHUP, &sig_handler);
signal(SIGPIPE, SIG_IGN);
signal(SIGUSR1, &sig_handler);
signal(SIGUSR2, &sig_handler);
sigemptyset(&signal_mask);
signal_received = 0;
}
/*
* init_all
*
* Initialize modules. Exit on failure.
*/
static void init_all(void)
{
int r;
if ((r = init_local()) ||
(r = init_cluster())) {
exit(r);
}
}
/*
* cleanup_all
*
* Clean up before exiting
*/
static void cleanup_all(void)
{
cleanup_local();
cleanup_cluster();
}

1663
daemons/cmirrord/cluster.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_CLUSTER_H
#define _LVM_CLOG_CLUSTER_H
#include "dm-log-userspace.h"
#include "libdevmapper.h"
#define DM_ULOG_RESPONSE 0x1000U /* in last byte of 32-bit value */
#define DM_ULOG_CHECKPOINT_READY 21
#define DM_ULOG_MEMBER_JOIN 22
/*
* There is other information in addition to what can
* be found in the dm_ulog_request structure that we
* need for processing. 'clog_request' is the wrapping
* structure we use to make the additional fields
* available.
*/
struct clog_request {
/*
* If we don't use a union, the structure size will
* vary between 32-bit and 64-bit machines. So, we
* pack two 64-bit version numbers in there to force
* the size of the structure to be the same.
*
* The two version numbers also help us with endian
* issues. The first is always little endian, while
* the second is in native format of the sending
* machine. If the two are equal, there is no need
* to do endian conversions.
*/
union {
uint64_t version[2]; /* LE version and native version */
struct dm_list list;
} u;
/*
* 'originator' is the machine from which the requests
* was made.
*/
uint32_t originator;
/*
* 'pit_server' is the "point-in-time" server for the
* request. (I.e. The machine that was the server at
* the time the request was issued - only important during
* startup.
*/
uint32_t pit_server;
/*
* The request from the kernel that is being processed
*/
struct dm_ulog_request u_rq;
};
int init_cluster(void);
void cleanup_cluster(void);
void cluster_debug(void);
int create_cluster_cpg(char *uuid, uint64_t luid);
int destroy_cluster_cpg(char *uuid);
int cluster_send(struct clog_request *rq);
#endif /* _LVM_CLOG_CLUSTER_H */

33
daemons/cmirrord/common.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_COMMON_H
#define _LVM_CLOG_COMMON_H
/*
* If there are problems when forking off to become a daemon,
* the child will exist with one of these codes. This allows
* the parent to know the reason for the failure and print it
* to the launching terminal.
*
* #define EXIT_SUCCESS 0 (from stdlib.h)
* #define EXIT_FAILURE 1 (from stdlib.h)
*/
#define EXIT_LOCKFILE 2
#define EXIT_KERNEL_SOCKET 3 /* Failed netlink socket create */
#define EXIT_KERNEL_BIND 4
#define EXIT_KERNEL_SETSOCKOPT 5
#define EXIT_CLUSTER_CKPT_INIT 6 /* Failed to init checkpoint */
#define EXIT_QUEUE_NOMEM 7
#define DM_ULOG_REQUEST_SIZE 1024
#endif /* _LVM_CLOG_COMMON_H */

210
daemons/cmirrord/compat.c Normal file
View File

@ -0,0 +1,210 @@
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*/
#include "logging.h"
#include "cluster.h"
#include "compat.h"
#include "xlate.h"
#include <errno.h>
/*
* Older versions of the log daemon communicate with different
* versions of the inter-machine communication structure, which
* varies in size and fields. The older versions append the
* standard upstream version of the structure to every request.
* COMPAT_OFFSET is where the upstream structure starts.
*/
#define COMPAT_OFFSET 256
static void v5_data_endian_switch(struct clog_request *rq, int to_network __attribute__((unused)))
{
int i, end;
int64_t *pi64;
uint64_t *pu64;
uint32_t rq_type = rq->u_rq.request_type & ~DM_ULOG_RESPONSE;
if (rq->u_rq.request_type & DM_ULOG_RESPONSE) {
switch (rq_type) {
case DM_ULOG_CTR:
case DM_ULOG_DTR:
LOG_ERROR("Invalid response type in endian switch");
exit(EXIT_FAILURE);
case DM_ULOG_PRESUSPEND:
case DM_ULOG_POSTSUSPEND:
case DM_ULOG_RESUME:
case DM_ULOG_FLUSH:
case DM_ULOG_MARK_REGION:
case DM_ULOG_CLEAR_REGION:
case DM_ULOG_SET_REGION_SYNC:
case DM_ULOG_CHECKPOINT_READY:
case DM_ULOG_MEMBER_JOIN:
case DM_ULOG_STATUS_INFO:
case DM_ULOG_STATUS_TABLE:
/* No outbound data */
break;
case DM_ULOG_GET_REGION_SIZE:
case DM_ULOG_GET_SYNC_COUNT:
pu64 = (uint64_t *)rq->u_rq.data;
*pu64 = xlate64(*pu64);
break;
case DM_ULOG_IS_CLEAN:
case DM_ULOG_IN_SYNC:
pi64 = (int64_t *)rq->u_rq.data;
*pi64 = xlate64(*pi64);
break;
case DM_ULOG_GET_RESYNC_WORK:
case DM_ULOG_IS_REMOTE_RECOVERING:
pi64 = (int64_t *)rq->u_rq.data;
pu64 = ((uint64_t *)rq->u_rq.data) + 1;
*pi64 = xlate64(*pi64);
*pu64 = xlate64(*pu64);
break;
default:
LOG_ERROR("Unknown request type, %u", rq_type);
return;
}
} else {
switch (rq_type) {
case DM_ULOG_CTR:
case DM_ULOG_DTR:
LOG_ERROR("Invalid request type in endian switch");
exit(EXIT_FAILURE);
case DM_ULOG_PRESUSPEND:
case DM_ULOG_POSTSUSPEND:
case DM_ULOG_RESUME:
case DM_ULOG_GET_REGION_SIZE:
case DM_ULOG_FLUSH:
case DM_ULOG_GET_RESYNC_WORK:
case DM_ULOG_GET_SYNC_COUNT:
case DM_ULOG_STATUS_INFO:
case DM_ULOG_STATUS_TABLE:
case DM_ULOG_CHECKPOINT_READY:
case DM_ULOG_MEMBER_JOIN:
/* No incoming data */
break;
case DM_ULOG_IS_CLEAN:
case DM_ULOG_IN_SYNC:
case DM_ULOG_IS_REMOTE_RECOVERING:
pu64 = (uint64_t *)rq->u_rq.data;
*pu64 = xlate64(*pu64);
break;
case DM_ULOG_MARK_REGION:
case DM_ULOG_CLEAR_REGION:
end = rq->u_rq.data_size/sizeof(uint64_t);
pu64 = (uint64_t *)rq->u_rq.data;
for (i = 0; i < end; i++)
pu64[i] = xlate64(pu64[i]);
break;
case DM_ULOG_SET_REGION_SYNC:
pu64 = (uint64_t *)rq->u_rq.data;
pi64 = ((int64_t *)rq->u_rq.data) + 1;
*pu64 = xlate64(*pu64);
*pi64 = xlate64(*pi64);
break;
default:
LOG_ERROR("Unknown request type, %u", rq_type);
exit(EXIT_FAILURE);
}
}
}
static int v5_endian_to_network(struct clog_request *rq)
{
int size;
struct dm_ulog_request *u_rq = &rq->u_rq;
size = sizeof(*rq) + u_rq->data_size;
u_rq->error = xlate32(u_rq->error);
u_rq->seq = xlate32(u_rq->seq);
u_rq->request_type = xlate32(u_rq->request_type);
u_rq->data_size = xlate64(u_rq->data_size);
rq->originator = xlate32(rq->originator);
v5_data_endian_switch(rq, 1);
return size;
}
int clog_request_to_network(struct clog_request *rq)
{
int r;
/* FIXME: Remove this safety check */
if (rq->u.version[0] != xlate64(rq->u.version[1])) {
LOG_ERROR("Programmer error: version[0] must be LE");
exit(EXIT_FAILURE);
}
/*
* Are we already running in the endian mode we send
* over the wire?
*/
if (rq->u.version[0] == rq->u.version[1])
return 0;
r = v5_endian_to_network(rq);
if (r < 0)
return r;
return 0;
}
static int v5_endian_from_network(struct clog_request *rq)
{
int size;
struct dm_ulog_request *u_rq = &rq->u_rq;
u_rq->error = xlate32(u_rq->error);
u_rq->seq = xlate32(u_rq->seq);
u_rq->request_type = xlate32(u_rq->request_type);
u_rq->data_size = xlate64(u_rq->data_size);
rq->originator = xlate32(rq->originator);
size = sizeof(*rq) + u_rq->data_size;
v5_data_endian_switch(rq, 0);
return size;
}
int clog_request_from_network(void *data, size_t data_len)
{
uint64_t *vp = data;
uint64_t version = xlate64(vp[0]);
uint64_t unconverted_version = vp[1];
struct clog_request *rq = data;
switch (version) {
case 5: /* Upstream */
if (version == unconverted_version)
return 0;
break;
case 4: /* RHEL 5.[45] */
case 3: /* RHEL 5.3 */
case 2: /* RHEL 5.2 */
/* FIXME: still need to account for payload */
if (data_len < (COMPAT_OFFSET + sizeof(*rq)))
return -ENOSPC;
rq = (struct clog_request *)((char *)data + COMPAT_OFFSET);
break;
default:
LOG_ERROR("Unable to process cluster message: "
"Incompatible version");
return -EINVAL;
}
v5_endian_from_network(rq);
return 0;
}

25
daemons/cmirrord/compat.h Normal file
View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*/
#ifndef _LVM_CLOG_COMPAT_H
#define _LVM_CLOG_COMPAT_H
/*
* The intermachine communication structure version are:
* 0: Unused
* 1: Never in the wild
* 2: RHEL 5.2
* 3: RHEL 5.3
* 4: RHEL 5.4, RHEL 5.5
* 5: RHEL 6, Current Upstream Format
*/
#define CLOG_TFR_VERSION 5
int clog_request_to_network(struct clog_request *rq);
int clog_request_from_network(void *data, size_t data_len);
#endif /* _LVM_CLOG_COMPAT_H */

1954
daemons/cmirrord/functions.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_FUNCTIONS_H
#define _LVM_CLOG_FUNCTIONS_H
#include "dm-log-userspace.h"
#include "cluster.h"
#define LOG_RESUMED 1
#define LOG_SUSPENDED 2
int local_resume(struct dm_ulog_request *rq);
int cluster_postsuspend(char *, uint64_t);
int do_request(struct clog_request *rq, int server);
int push_state(const char *uuid, uint64_t luid,
const char *which, char **buf, uint32_t debug_who);
int pull_state(const char *uuid, uint64_t luid,
const char *which, char *buf, int size);
int log_get_state(struct dm_ulog_request *rq);
int log_status(void);
void log_debug(void);
#endif /* _LVM_CLOG_FUNCTIONS_H */

151
daemons/cmirrord/link_mon.c Normal file
View File

@ -0,0 +1,151 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logging.h"
#include "link_mon.h"
#include <errno.h>
#include <poll.h>
#include <stdlib.h>
struct link_callback {
int fd;
const char *name;
void *data;
int (*callback)(void *data);
struct link_callback *next;
};
static unsigned used_pfds = 0;
static unsigned free_pfds = 0;
static struct pollfd *pfds = NULL;
static struct link_callback *callbacks = NULL;
int links_register(int fd, const char *name, int (*callback)(void *data), void *data)
{
unsigned i;
struct link_callback *lc;
for (i = 0; i < used_pfds; i++) {
if (fd == pfds[i].fd) {
LOG_ERROR("links_register: Duplicate file descriptor");
return -EINVAL;
}
}
lc = malloc(sizeof(*lc));
if (!lc)
return -ENOMEM;
lc->fd = fd;
lc->name = name;
lc->data = data;
lc->callback = callback;
if (!free_pfds) {
struct pollfd *tmp;
tmp = realloc(pfds, sizeof(struct pollfd) * ((used_pfds*2) + 1));
if (!tmp) {
free(lc);
return -ENOMEM;
}
pfds = tmp;
free_pfds = used_pfds + 1;
}
free_pfds--;
pfds[used_pfds].fd = fd;
pfds[used_pfds].events = POLLIN;
pfds[used_pfds].revents = 0;
used_pfds++;
lc->next = callbacks;
callbacks = lc;
LOG_DBG("Adding %s/%d", lc->name, lc->fd);
LOG_DBG(" used_pfds = %u, free_pfds = %u",
used_pfds, free_pfds);
return 0;
}
int links_unregister(int fd)
{
unsigned i;
struct link_callback *p, *c;
for (i = 0; i < used_pfds; i++)
if (fd == pfds[i].fd) {
/* entire struct is copied (overwritten) */
pfds[i] = pfds[used_pfds - 1];
used_pfds--;
free_pfds++;
}
for (p = NULL, c = callbacks; c; p = c, c = c->next)
if (fd == c->fd) {
LOG_DBG("Freeing up %s/%d", c->name, c->fd);
LOG_DBG(" used_pfds = %u, free_pfds = %u",
used_pfds, free_pfds);
if (p)
p->next = c->next;
else
callbacks = c->next;
free(c);
break;
}
return 0;
}
int links_monitor(void)
{
unsigned i;
int r;
for (i = 0; i < used_pfds; i++) {
pfds[i].revents = 0;
}
r = poll(pfds, used_pfds, -1);
if (r <= 0)
return r;
r = 0;
/* FIXME: handle POLLHUP */
for (i = 0; i < used_pfds; i++)
if (pfds[i].revents & POLLIN) {
LOG_DBG("Data ready on %d", pfds[i].fd);
/* FIXME: Add this back return 1;*/
r++;
}
return r;
}
int links_issue_callbacks(void)
{
unsigned i;
struct link_callback *lc;
for (i = 0; i < used_pfds; i++)
if (pfds[i].revents & POLLIN)
for (lc = callbacks; lc; lc = lc->next)
if (pfds[i].fd == lc->fd) {
LOG_DBG("Issuing callback on %s/%d",
lc->name, lc->fd);
lc->callback(lc->data);
break;
}
return 0;
}

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_LINK_MON_H
#define _LVM_CLOG_LINK_MON_H
int links_register(int fd, const char *name, int (*callback)(void *data), void *data);
int links_unregister(int fd);
int links_monitor(void);
int links_issue_callbacks(void);
#endif /* _LVM_CLOG_LINK_MON_H */

416
daemons/cmirrord/local.c Normal file
View File

@ -0,0 +1,416 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logging.h"
#include "common.h"
#include "functions.h"
#include "link_mon.h"
#include "local.h"
#include <errno.h>
#include <sys/socket.h>
#include <linux/connector.h>
#include <linux/netlink.h>
#include <unistd.h>
#ifndef CN_IDX_DM
/* Kernel 2.6.31 is required to run this code */
#define CN_IDX_DM 0x7 /* Device Mapper */
#define CN_VAL_DM_USERSPACE_LOG 0x1
#endif
static int cn_fd; /* Connector (netlink) socket fd */
static char recv_buf[2048];
static char send_buf[2048];
/* FIXME: merge this function with kernel_send_helper */
static int kernel_ack(uint32_t seq, int error)
{
int r;
struct nlmsghdr *nlh = (struct nlmsghdr *)send_buf;
struct cn_msg *msg = NLMSG_DATA(nlh);
if (error < 0) {
LOG_ERROR("Programmer error: error codes must be positive");
return -EINVAL;
}
memset(send_buf, 0, sizeof(send_buf));
nlh->nlmsg_seq = 0;
nlh->nlmsg_pid = getpid();
nlh->nlmsg_type = NLMSG_DONE;
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct cn_msg));
nlh->nlmsg_flags = 0;
msg->len = 0;
msg->id.idx = CN_IDX_DM;
msg->id.val = CN_VAL_DM_USERSPACE_LOG;
msg->seq = seq;
msg->ack = error;
r = send(cn_fd, nlh, NLMSG_LENGTH(sizeof(struct cn_msg)), 0);
/* FIXME: do better error processing */
if (r <= 0)
return -EBADE;
return 0;
}
/*
* kernel_recv
* @rq: the newly allocated request from kernel
*
* Read requests from the kernel and allocate space for the new request.
* If there is no request from the kernel, *rq is NULL.
*
* This function is not thread safe due to returned stack pointer. In fact,
* the returned pointer must not be in-use when this function is called again.
*
* Returns: 0 on success, -EXXX on error
*/
static int kernel_recv(struct clog_request **rq)
{
int r = 0;
ssize_t len;
char *foo;
struct cn_msg *msg;
struct dm_ulog_request *u_rq;
struct nlmsghdr *nlmsg_h;
*rq = NULL;
memset(recv_buf, 0, sizeof(recv_buf));
len = recv(cn_fd, recv_buf, sizeof(recv_buf), 0);
if (len < 0) {
LOG_ERROR("Failed to recv message from kernel");
r = -errno;
goto fail;
}
nlmsg_h = (struct nlmsghdr *)recv_buf;
switch (nlmsg_h->nlmsg_type) {
case NLMSG_ERROR:
LOG_ERROR("Unable to recv message from kernel: NLMSG_ERROR");
r = -EBADE;
goto fail;
case NLMSG_DONE:
msg = (struct cn_msg *)NLMSG_DATA((struct nlmsghdr *)recv_buf);
len -= (ssize_t)sizeof(struct nlmsghdr);
if (len < (ssize_t)sizeof(struct cn_msg)) {
LOG_ERROR("Incomplete request from kernel received");
r = -EBADE;
goto fail;
}
if (msg->len > DM_ULOG_REQUEST_SIZE) {
LOG_ERROR("Not enough space to receive kernel request (%d/%d)",
msg->len, DM_ULOG_REQUEST_SIZE);
r = -EBADE;
goto fail;
}
if (!msg->len)
LOG_ERROR("Zero length message received");
len -= (ssize_t)sizeof(struct cn_msg);
if (len < msg->len)
LOG_ERROR("len = %zd, msg->len = %" PRIu16, len, msg->len);
msg->data[msg->len] = '\0'; /* Cleaner way to ensure this? */
u_rq = (struct dm_ulog_request *)msg->data;
if (!u_rq->request_type) {
LOG_DBG("Bad transmission, requesting resend [%u]",
msg->seq);
r = -EAGAIN;
if (kernel_ack(msg->seq, EAGAIN)) {
LOG_ERROR("Failed to NACK kernel transmission [%u]",
msg->seq);
r = -EBADE;
}
}
/*
* Now we've got sizeof(struct cn_msg) + sizeof(struct nlmsghdr)
* worth of space that precede the request structure from the
* kernel. Since that space isn't going to be used again, we
* can take it for our purposes; rather than allocating a whole
* new structure and doing a memcpy.
*
* We should really make sure 'clog_request' doesn't grow
* beyond what is available to us, but we need only check it
* once... perhaps at compile time?
*/
foo = (char *)u_rq;
foo -= (sizeof(struct clog_request) - sizeof(struct dm_ulog_request));
*rq = (struct clog_request *) foo;
/* Clear the wrapper container fields */
memset(*rq, 0, (size_t)((char *)u_rq - (char *)(*rq)));
break;
default:
LOG_ERROR("Unknown nlmsg_type");
r = -EBADE;
}
fail:
if (r)
*rq = NULL;
return (r == -EAGAIN) ? 0 : r;
}
static int kernel_send_helper(void *data, uint16_t out_size)
{
int r;
struct nlmsghdr *nlh;
struct cn_msg *msg;
memset(send_buf, 0, sizeof(send_buf));
nlh = (struct nlmsghdr *)send_buf;
nlh->nlmsg_seq = 0; /* FIXME: Is this used? */
nlh->nlmsg_pid = getpid();
nlh->nlmsg_type = NLMSG_DONE;
nlh->nlmsg_len = NLMSG_LENGTH(out_size + sizeof(struct cn_msg));
nlh->nlmsg_flags = 0;
msg = NLMSG_DATA(nlh);
memcpy(msg->data, data, out_size);
msg->len = out_size;
msg->id.idx = CN_IDX_DM;
msg->id.val = CN_VAL_DM_USERSPACE_LOG;
msg->seq = 0;
r = send(cn_fd, nlh, NLMSG_LENGTH(out_size + sizeof(struct cn_msg)), 0);
/* FIXME: do better error processing */
if (r <= 0)
return -EBADE;
return 0;
}
/*
* do_local_work
*
* Any processing errors are placed in the 'rq'
* structure to be reported back to the kernel.
* It may be pointless for this function to
* return an int.
*
* Returns: 0 on success, -EXXX on failure
*/
static int do_local_work(void *data __attribute__((unused)))
{
int r;
struct clog_request *rq;
struct dm_ulog_request *u_rq = NULL;
r = kernel_recv(&rq);
if (r)
return r;
if (!rq)
return 0;
u_rq = &rq->u_rq;
LOG_DBG("[%s] Request from kernel received: [%s/%u]",
SHORT_UUID(u_rq->uuid), RQ_TYPE(u_rq->request_type),
u_rq->seq);
switch (u_rq->request_type) {
case DM_ULOG_CTR:
case DM_ULOG_DTR:
case DM_ULOG_GET_REGION_SIZE:
case DM_ULOG_IN_SYNC:
case DM_ULOG_GET_SYNC_COUNT:
case DM_ULOG_STATUS_INFO:
case DM_ULOG_STATUS_TABLE:
case DM_ULOG_PRESUSPEND:
/* We do not specify ourselves as server here */
r = do_request(rq, 0);
if (r)
LOG_DBG("Returning failed request to kernel [%s]",
RQ_TYPE(u_rq->request_type));
r = kernel_send(u_rq);
if (r)
LOG_ERROR("Failed to respond to kernel [%s]",
RQ_TYPE(u_rq->request_type));
break;
case DM_ULOG_RESUME:
/*
* Resume is a special case that requires a local
* component to join the CPG, and a cluster component
* to handle the request.
*/
r = local_resume(u_rq);
if (r) {
LOG_DBG("Returning failed request to kernel [%s]",
RQ_TYPE(u_rq->request_type));
r = kernel_send(u_rq);
if (r)
LOG_ERROR("Failed to respond to kernel [%s]",
RQ_TYPE(u_rq->request_type));
break;
}
/* ELSE, fall through */
case DM_ULOG_IS_CLEAN:
case DM_ULOG_FLUSH:
case DM_ULOG_MARK_REGION:
case DM_ULOG_GET_RESYNC_WORK:
case DM_ULOG_SET_REGION_SYNC:
case DM_ULOG_IS_REMOTE_RECOVERING:
case DM_ULOG_POSTSUSPEND:
r = cluster_send(rq);
if (r) {
u_rq->data_size = 0;
u_rq->error = r;
kernel_send(u_rq);
}
break;
case DM_ULOG_CLEAR_REGION:
r = kernel_ack(u_rq->seq, 0);
r = cluster_send(rq);
if (r) {
/*
* FIXME: store error for delivery on flush
* This would allow us to optimize MARK_REGION
* too.
*/
}
break;
default:
LOG_ERROR("Invalid log request received (%u), ignoring.",
u_rq->request_type);
return 0;
}
if (r && !u_rq->error)
u_rq->error = r;
return r;
}
/*
* kernel_send
* @u_rq: result to pass back to kernel
*
* This function returns the u_rq structure
* (containing the results) to the kernel.
* It then frees the structure.
*
* WARNING: should the structure be freed if
* there is an error? I vote 'yes'. If the
* kernel doesn't get the response, it should
* resend the request.
*
* Returns: 0 on success, -EXXX on failure
*/
int kernel_send(struct dm_ulog_request *u_rq)
{
int r;
uint16_t size;
if (!u_rq)
return -EINVAL;
size = (uint16_t)(sizeof(struct dm_ulog_request) + u_rq->data_size);
if (!u_rq->data_size && !u_rq->error) {
/* An ACK is all that is needed */
/* FIXME: add ACK code */
} else if (size > DM_ULOG_REQUEST_SIZE) {
/*
* If we gotten here, we've already overrun
* our allotted space somewhere.
*
* We must do something, because the kernel
* is waiting for a response.
*/
LOG_ERROR("Not enough space to respond to server");
u_rq->error = -ENOSPC;
size = sizeof(struct dm_ulog_request);
}
r = kernel_send_helper(u_rq, size);
if (r)
LOG_ERROR("Failed to send msg to kernel.");
return r;
}
/*
* init_local
*
* Initialize kernel communication socket (netlink)
*
* Returns: 0 on success, values from common.h on failure
*/
int init_local(void)
{
int r = 0;
unsigned opt;
struct sockaddr_nl addr;
cn_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
if (cn_fd < 0)
return EXIT_KERNEL_SOCKET;
/* memset to fix valgrind complaint */
memset(&addr, 0, sizeof(struct sockaddr_nl));
addr.nl_family = AF_NETLINK;
addr.nl_groups = CN_IDX_DM;
addr.nl_pid = 0;
r = bind(cn_fd, (struct sockaddr *) &addr, sizeof(addr));
if (r < 0) {
close(cn_fd);
return EXIT_KERNEL_BIND;
}
opt = addr.nl_groups;
r = setsockopt(cn_fd, 270, NETLINK_ADD_MEMBERSHIP, &opt, sizeof(opt));
if (r) {
close(cn_fd);
return EXIT_KERNEL_SETSOCKOPT;
}
/*
r = fcntl(cn_fd, F_SETFL, FNDELAY);
*/
links_register(cn_fd, "local", do_local_work, NULL);
return 0;
}
/*
* cleanup_local
*
* Clean up before exiting
*/
void cleanup_local(void)
{
links_unregister(cn_fd);
close(cn_fd);
}

20
daemons/cmirrord/local.h Normal file
View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_LOCAL_H
#define _LVM_CLOG_LOCAL_H
int init_local(void);
void cleanup_local(void);
int kernel_send(struct dm_ulog_request *rq);
#endif /* _LVM_CLOG_LOCAL_H */

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "logging.h"
const char *__rq_types_off_by_one[] = {
"DM_ULOG_CTR",
"DM_ULOG_DTR",
"DM_ULOG_PRESUSPEND",
"DM_ULOG_POSTSUSPEND",
"DM_ULOG_RESUME",
"DM_ULOG_GET_REGION_SIZE",
"DM_ULOG_IS_CLEAN",
"DM_ULOG_IN_SYNC",
"DM_ULOG_FLUSH",
"DM_ULOG_MARK_REGION",
"DM_ULOG_CLEAR_REGION",
"DM_ULOG_GET_RESYNC_WORK",
"DM_ULOG_SET_REGION_SYNC",
"DM_ULOG_GET_SYNC_COUNT",
"DM_ULOG_STATUS_INFO",
"DM_ULOG_STATUS_TABLE",
"DM_ULOG_IS_REMOTE_RECOVERING",
NULL
};
int log_tabbing = 0;
int log_is_open = 0;
/*
* Variables for various conditional logging
*/
#ifdef MEMB
int log_membership_change = 1;
#else
int log_membership_change = 0;
#endif
#ifdef CKPT
int log_checkpoint = 1;
#else
int log_checkpoint = 0;
#endif
#ifdef RESEND
int log_resend_requests = 1;
#else
int log_resend_requests = 0;
#endif

View File

@ -0,0 +1,77 @@
/*
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CLOG_LOGGING_H
#define _LVM_CLOG_LOGGING_H
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include "configure.h"
#include <stdio.h>
#include <stdint.h>
#include <syslog.h>
/* SHORT_UUID - print last 8 chars of a string */
#define SHORT_UUID(x) (strlen(x) > 8) ? ((x) + (strlen(x) - 8)) : (x)
extern const char *__rq_types_off_by_one[];
#define RQ_TYPE(x) __rq_types_off_by_one[(x) - 1]
extern int log_tabbing;
extern int log_is_open;
extern int log_membership_change;
extern int log_checkpoint;
extern int log_resend_requests;
#define LOG_OPEN(ident, option, facility) do { \
openlog(ident, option, facility); \
log_is_open = 1; \
} while (0)
#define LOG_CLOSE(void) do { \
log_is_open = 0; \
closelog(); \
} while (0)
#define LOG_OUTPUT(level, f, arg...) do { \
int __i; \
char __buffer[16]; \
FILE *fp = (level > LOG_NOTICE) ? stderr : stdout; \
if (log_is_open) { \
for (__i = 0; (__i < log_tabbing) && (__i < 15); __i++) \
__buffer[__i] = '\t'; \
__buffer[__i] = '\0'; \
syslog(level, "%s" f "\n", __buffer, ## arg); \
} else { \
for (__i = 0; __i < log_tabbing; __i++) \
fprintf(fp, "\t"); \
fprintf(fp, f "\n", ## arg); \
} \
} while (0)
#ifdef DEBUG
#define LOG_DBG(f, arg...) LOG_OUTPUT(LOG_DEBUG, f, ## arg)
#else /* DEBUG */
#define LOG_DBG(f, arg...)
#endif /* DEBUG */
#define LOG_COND(__X, f, arg...) do {\
if (__X) { \
LOG_OUTPUT(LOG_NOTICE, f, ## arg); \
} \
} while (0)
#define LOG_PRINT(f, arg...) LOG_OUTPUT(LOG_NOTICE, f, ## arg)
#define LOG_ERROR(f, arg...) LOG_OUTPUT(LOG_ERR, f, ## arg)
#endif /* _LVM_CLOG_LOGGING_H */

View File

@ -0,0 +1,22 @@
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of the device-mapper userspace tools.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License v.2.1.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
LIB_STATIC = libdaemon.a
SOURCES = daemon-shared.c daemon-server.c daemon-client.c
include $(top_builddir)/make.tmpl
device-mapper: $(LIB_STATIC)

View File

@ -0,0 +1,81 @@
#include "daemon-client.h"
#include "daemon-shared.h"
#include <sys/un.h>
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h> // ENOMEM
daemon_handle daemon_open(daemon_info i) {
daemon_handle h = { .protocol = 0 };
struct sockaddr_un sockaddr;
if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM /* | SOCK_NONBLOCK */, 0)) < 0) {
perror("socket");
goto error;
}
memset(&sockaddr, 0, sizeof(sockaddr));
fprintf(stderr, "[C] connecting to %s\n", i.socket);
strcpy(sockaddr.sun_path, i.socket);
sockaddr.sun_family = AF_UNIX;
if (connect(h.socket_fd,(struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
perror("connect");
goto error;
}
return h;
error:
if (h.socket_fd >= 0)
close(h.socket_fd);
h.socket_fd = -1;
return h;
}
daemon_reply daemon_send(daemon_handle h, daemon_request rq)
{
daemon_reply reply = { .cft = NULL, .error = 0 };
assert(h.socket_fd >= 0);
if (!rq.buffer) {
/* TODO: build the buffer from rq.cft */
}
assert(rq.buffer);
write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer));
if (read_buffer(h.socket_fd, &reply.buffer)) {
reply.cft = dm_config_from_string(reply.buffer);
} else
reply.error = 1;
return reply;
}
void daemon_reply_destroy(daemon_reply r) {
if (r.cft)
dm_config_destroy(r.cft);
}
daemon_reply daemon_send_simple(daemon_handle h, const char *id, ...)
{
static const daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL };
daemon_request rq = { .cft = NULL };
daemon_reply repl;
va_list ap;
va_start(ap, id);
rq.buffer = format_buffer("request", id, ap);
va_end(ap);
if (!rq.buffer)
return err;
repl = daemon_send(h, rq);
dm_free(rq.buffer);
return repl;
}
void daemon_close(daemon_handle h)
{
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "libdevmapper.h" // for dm_list, needed by config.h
#ifndef _LVM_DAEMON_COMMON_CLIENT_H
#define _LVM_DAEMON_COMMON_CLIENT_H
typedef struct {
int socket_fd; /* the fd we use to talk to the daemon */
int protocol; /* version of the protocol the daemon uses */
} daemon_handle;
typedef struct {
const char *path; /* the binary of the daemon */
const char *socket; /* path to the comms socket */
unsigned autostart:1; /* start the daemon if not running? */
} daemon_info;
typedef struct {
char *buffer;
/*
* The request looks like this:
* request = "id"
* arg_foo = "something"
* arg_bar = 3
* arg_wibble {
* something_special = "here"
* amount = 75
* knobs = [ "twiddle", "tweak" ]
* }
*/
struct dm_config_tree *cft;
} daemon_request;
typedef struct {
int error; /* 0 for success */
char *buffer; /* textual reply */
struct dm_config_tree *cft; /* parsed reply, if available */
} daemon_reply;
/*
* Open the communication channel to the daemon. If the daemon is not running,
* it may be autostarted based on the binary path provided in the info (this
* will only happen if autostart is set to true). If the call fails for any
* reason, daemon_handle_valid(h) for the response will return false. Otherwise,
* the connection is good to start serving requests.
*/
daemon_handle daemon_open(daemon_info i);
/*
* Send a request to the daemon, waiting for the reply. All communication with
* the daemon is synchronous. The function handles the IO details and parses the
* response, handling common error conditions. See "daemon_reply" for details.
*
* In case the request contains a non-NULL buffer pointer, this buffer is sent
* *verbatim* to the server. In this case, the cft pointer may be NULL (but will
* be ignored even if non-NULL). If the buffer is NULL, the cft is required to
* be a valid pointer, and is used to build up the request.
*/
daemon_reply daemon_send(daemon_handle h, daemon_request r);
/*
* A simple interface to daemon_send. This function just takes the command id
* and possibly a list of parameters (of the form "name = %?", "value"). The
* type (string, integer) of the value is indicated by a character substituted
* for ? in %?: d for integer, s for string.
*/
daemon_reply daemon_send_simple(daemon_handle h, const char *id, ...);
void daemon_reply_destroy(daemon_reply r);
static inline int daemon_reply_int(daemon_reply r, const char *path, int def) {
return dm_config_find_int(r.cft->root, path, def);
}
static inline const char *daemon_reply_str(daemon_reply r, const char *path, const char *def) {
return dm_config_find_str(r.cft->root, path, def);
}
/* Shut down the communication to the daemon. Compulsory. */
void daemon_close(daemon_handle h);
#endif

View File

@ -0,0 +1,380 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <unistd.h>
#include <signal.h>
#include <syslog.h>
#include "daemon-server.h"
#include "daemon-shared.h"
#include "libdevmapper.h"
#if 0
/* Create a device monitoring thread. */
static int _pthread_create(pthread_t *t, void *(*fun)(void *), void *arg, int stacksize)
{
pthread_attr_t attr;
pthread_attr_init(&attr);
/*
* We use a smaller stack since it gets preallocated in its entirety
*/
pthread_attr_setstacksize(&attr, stacksize);
return pthread_create(t, &attr, fun, arg);
}
#endif
static volatile sig_atomic_t _shutdown_requested = 0;
static void _exit_handler(int sig __attribute__((unused)))
{
_shutdown_requested = 1;
}
#ifdef linux
# define OOM_ADJ_FILE "/proc/self/oom_adj"
# include <stdio.h>
/* From linux/oom.h */
# define OOM_DISABLE (-17)
# define OOM_ADJUST_MIN (-16)
/*
* Protection against OOM killer if kernel supports it
*/
static int _set_oom_adj(int val)
{
FILE *fp;
struct stat st;
if (stat(OOM_ADJ_FILE, &st) == -1) {
if (errno == ENOENT)
perror(OOM_ADJ_FILE " not found");
else
perror(OOM_ADJ_FILE ": stat failed");
return 1;
}
if (!(fp = fopen(OOM_ADJ_FILE, "w"))) {
perror(OOM_ADJ_FILE ": fopen failed");
return 0;
}
fprintf(fp, "%i", val);
if (fclose(fp))
perror(OOM_ADJ_FILE ": fclose failed");
return 1;
}
#endif
static int _open_socket(daemon_state s)
{
int fd = -1;
struct sockaddr_un sockaddr;
mode_t old_mask;
(void) dm_prepare_selinux_context(s.socket_path, S_IFSOCK);
old_mask = umask(0077);
/* Open local socket */
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("Can't create local socket.");
goto error;
}
/* Set Close-on-exec & non-blocking */
if (fcntl(fd, F_SETFD, 1))
fprintf(stderr, "setting CLOEXEC on socket fd %d failed: %s\n", fd, strerror(errno));
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
fprintf(stderr, "[D] creating %s\n", s.socket_path);
memset(&sockaddr, 0, sizeof(sockaddr));
strcpy(sockaddr.sun_path, s.socket_path);
sockaddr.sun_family = AF_UNIX;
if (bind(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
perror("can't bind local socket.");
goto error;
}
if (listen(fd, 1) != 0) {
perror("listen local");
goto error;
}
out:
umask(old_mask);
(void) dm_prepare_selinux_context(NULL, 0);
return fd;
error:
if (fd >= 0) {
if (close(fd))
perror("close failed");
if (unlink(s.socket_path))
perror("unlink failed");
fd = -1;
}
goto out;
}
static void remove_lockfile(const char *file)
{
if (unlink(file))
perror("unlink failed");
}
static void _daemonise(void)
{
int child_status;
int fd;
pid_t pid;
struct rlimit rlim;
struct timeval tval;
sigset_t my_sigset;
sigemptyset(&my_sigset);
if (sigprocmask(SIG_SETMASK, &my_sigset, NULL) < 0) {
fprintf(stderr, "Unable to restore signals.\n");
exit(EXIT_FAILURE);
}
signal(SIGTERM, &_exit_handler);
switch (pid = fork()) {
case -1:
perror("fork failed:");
exit(EXIT_FAILURE);
case 0: /* Child */
break;
default:
/* Wait for response from child */
while (!waitpid(pid, &child_status, WNOHANG) && !_shutdown_requested) {
tval.tv_sec = 0;
tval.tv_usec = 250000; /* .25 sec */
select(0, NULL, NULL, NULL, &tval);
}
if (_shutdown_requested) /* Child has signaled it is ok - we can exit now */
exit(0);
/* Problem with child. Determine what it is by exit code */
fprintf(stderr, "Child exited with code %d\n", WEXITSTATUS(child_status));
exit(WEXITSTATUS(child_status));
}
if (chdir("/"))
exit(1);
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
fd = 256; /* just have to guess */
else
fd = rlim.rlim_cur;
for (--fd; fd >= 0; fd--)
close(fd);
if ((open("/dev/null", O_RDONLY) < 0) ||
(open("/dev/null", O_WRONLY) < 0) ||
(open("/dev/null", O_WRONLY) < 0))
exit(1);
setsid();
}
response daemon_reply_simple(const char *id, ...)
{
va_list ap;
response res = { .cft = NULL };
va_start(ap, id);
if (!(res.buffer = format_buffer("response", id, ap)))
res.error = ENOMEM;
va_end(ap);
return res;
}
struct thread_baton {
daemon_state s;
client_handle client;
};
static int buffer_rewrite(char **buf, const char *format, const char *string) {
char *old = *buf;
dm_asprintf(buf, format, *buf, string);
dm_free(old);
return 0;
}
static int buffer_line(const char *line, void *baton) {
response *r = baton;
if (r->buffer)
buffer_rewrite(&r->buffer, "%s\n%s", line);
else
dm_asprintf(&r->buffer, "%s\n", line);
return 0;
}
static void *client_thread(void *baton)
{
struct thread_baton *b = baton;
request req;
response res;
while (1) {
if (!read_buffer(b->client.socket_fd, &req.buffer))
goto fail;
req.cft = dm_config_from_string(req.buffer);
if (!req.cft)
fprintf(stderr, "error parsing request:\n %s\n", req.buffer);
res = b->s.handler(b->s, b->client, req);
if (!res.buffer) {
dm_config_write_node(res.cft->root, buffer_line, &res);
buffer_rewrite(&res.buffer, "%s\n\n", NULL);
dm_config_destroy(res.cft);
}
if (req.cft)
dm_config_destroy(req.cft);
dm_free(req.buffer);
write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer));
free(res.buffer);
}
fail:
/* TODO what should we really do here? */
close(b->client.socket_fd);
free(baton);
return NULL;
}
static int handle_connect(daemon_state s)
{
struct thread_baton *baton;
struct sockaddr_un sockaddr;
client_handle client = { .thread_id = 0 };
socklen_t sl = sizeof(sockaddr);
client.socket_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl);
if (client.socket_fd < 0)
return 0;
if (!(baton = malloc(sizeof(struct thread_baton))))
return 0;
baton->s = s;
baton->client = client;
if (pthread_create(&baton->client.thread_id, NULL, client_thread, baton))
return 0;
pthread_detach(baton->client.thread_id);
return 1;
}
void daemon_start(daemon_state s)
{
int failed = 0;
/*
* Switch to C locale to avoid reading large locale-archive file used by
* some glibc (on some distributions it takes over 100MB). Some daemons
* need to use mlockall().
*/
if (setenv("LANG", "C", 1))
perror("Cannot set LANG to C");
if (!s.foreground)
_daemonise();
/* TODO logging interface should be somewhat more elaborate */
openlog(s.name, LOG_PID, LOG_DAEMON);
(void) dm_prepare_selinux_context(s.pidfile, S_IFREG);
/*
* NB. Take care to not keep stale locks around. Best not exit(...)
* after this point.
*/
if (dm_create_lockfile(s.pidfile) == 0)
exit(1);
(void) dm_prepare_selinux_context(NULL, 0);
/* Set normal exit signals to request shutdown instead of dying. */
signal(SIGINT, &_exit_handler);
signal(SIGHUP, &_exit_handler);
signal(SIGQUIT, &_exit_handler);
signal(SIGTERM, &_exit_handler);
signal(SIGALRM, &_exit_handler);
signal(SIGPIPE, SIG_IGN);
#ifdef linux
if (s.avoid_oom && !_set_oom_adj(OOM_DISABLE) && !_set_oom_adj(OOM_ADJUST_MIN))
syslog(LOG_ERR, "Failed to set oom_adj to protect against OOM killer");
#endif
if (s.socket_path) {
s.socket_fd = _open_socket(s);
if (s.socket_fd < 0)
failed = 1;
}
/* Signal parent, letting them know we are ready to go. */
if (!s.foreground)
kill(getppid(), SIGTERM);
if (s.daemon_init)
s.daemon_init(&s);
while (!_shutdown_requested && !failed) {
fd_set in;
FD_ZERO(&in);
FD_SET(s.socket_fd, &in);
if (select(FD_SETSIZE, &in, NULL, NULL, NULL) < 0 && errno != EINTR)
perror("select error");
if (FD_ISSET(s.socket_fd, &in))
if (!handle_connect(s))
syslog(LOG_ERR, "Failed to handle a client connection.");
}
if (s.socket_fd >= 0)
if (unlink(s.socket_path))
perror("unlink error");
if (s.daemon_fini)
s.daemon_fini(&s);
syslog(LOG_NOTICE, "%s shutting down", s.name);
closelog();
remove_lockfile(s.pidfile);
if (failed)
exit(1);
}

View File

@ -0,0 +1,119 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "daemon-client.h"
#ifndef _LVM_DAEMON_COMMON_SERVER_H
#define _LVM_DAEMON_COMMON_SERVER_H
typedef struct {
int socket_fd; /* the fd we use to talk to the client */
pthread_t thread_id;
char *read_buf;
void *private; /* this holds per-client state */
} client_handle;
typedef struct {
struct dm_config_tree *cft;
char *buffer;
} request;
typedef struct {
int error;
struct dm_config_tree *cft;
char *buffer;
} response;
struct daemon_state;
/*
* Craft a simple reply, without the need to construct a config_tree. See
* daemon_send_simple in daemon-client.h for the description of the parameters.
*/
response daemon_reply_simple(const char *id, ...);
static inline int daemon_request_int(request r, const char *path, int def) {
if (!r.cft)
return def;
return dm_config_find_int(r.cft->root, path, def);
}
static inline const char *daemon_request_str(request r, const char *path, const char *def) {
if (!r.cft)
return def;
return dm_config_find_str(r.cft->root, path, def);
}
/*
* The callback. Called once per request issued, in the respective client's
* thread. It is presented by a parsed request (in the form of a config tree).
* The output is a new config tree that is serialised and sent back to the
* client. The client blocks until the request processing is done and reply is
* sent.
*/
typedef response (*handle_request)(struct daemon_state s, client_handle h, request r);
typedef struct daemon_state {
/*
* The maximal stack size for individual daemon threads. This is
* essential for daemons that need to be locked into memory, since
* pthread's default is 10M per thread.
*/
int thread_stack_size;
/* Flags & attributes affecting the behaviour of the daemon. */
unsigned avoid_oom:1;
unsigned foreground:1;
const char *name;
const char *pidfile;
const char *socket_path;
int log_level;
handle_request handler;
int (*daemon_init)(struct daemon_state *st);
int (*daemon_fini)(struct daemon_state *st);
/* Global runtime info maintained by the framework. */
int socket_fd;
void *private; /* the global daemon state */
} daemon_state;
/*
* Start serving the requests. This does all the daemonisation, socket setup
* work and so on. This function takes over the process, and upon failure, it
* will terminate execution. It may be called at most once.
*/
void daemon_start(daemon_state s);
/*
* Take over from an already running daemon. This function handles connecting
* to the running daemon and telling it we are going to take over. The takeover
* request may be customised by passing in a non-NULL request.
*
* The takeover sequence: the old daemon stops accepting new clients, then it
* waits until all current client connections are closed. When that happens, it
* serializes its current state and sends that as a reply, which is then
* returned by this function (therefore, this function won't return until the
* previous instance has shut down).
*
* The daemon, after calling daemon_takeover is expected to set up its
* daemon_state using the reply from this function and call daemon_start as
* usual.
*/
daemon_reply daemon_takeover(daemon_info i, daemon_request r);
/* Call this to request a clean shutdown of the daemon. Async safe. */
void daemon_stop(void);
#endif

View File

@ -0,0 +1,123 @@
#include <errno.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include "daemon-shared.h"
/*
* Read a single message from a (socket) filedescriptor. Messages are delimited
* by blank lines. This call will block until all of a message is received. The
* memory will be allocated from heap. Upon error, all memory is freed and the
* buffer pointer is set to NULL.
*
* See also write_buffer about blocking (read_buffer has identical behaviour).
*/
int read_buffer(int fd, char **buffer) {
int bytes = 0;
int buffersize = 32;
char *new;
*buffer = malloc(buffersize + 1);
while (1) {
int result = read(fd, (*buffer) + bytes, buffersize - bytes);
if (result > 0)
bytes += result;
if (result == 0)
goto fail; /* we should never encounter EOF here */
if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
goto fail;
if ((!strncmp((*buffer) + bytes - 4, "\n##\n", 4))) {
*(*buffer + bytes - 4) = 0;
break; /* success, we have the full message now */
}
if (bytes == buffersize) {
buffersize += 1024;
if (!(new = realloc(*buffer, buffersize + 1)))
goto fail;
*buffer = new;
}
/* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */
}
return 1;
fail:
free(*buffer);
*buffer = NULL;
return 0;
}
/*
* Write a buffer to a filedescriptor. Keep trying. Blocks (even on
* SOCK_NONBLOCK) until all of the write went through.
*
* TODO use select on EWOULDBLOCK/EAGAIN to avoid useless spinning
*/
int write_buffer(int fd, const char *buffer, int length) {
static const char terminate[] = "\n##\n";
int done = 0;
int written = 0;
write:
while (1) {
int result = write(fd, buffer + written, length - written);
if (result > 0)
written += result;
if (result < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
return 0; /* too bad */
if (written == length) {
if (done)
return 1;
else
break; /* done */
}
}
buffer = terminate;
length = 4;
written = 0;
done = 1;
goto write;
}
char *format_buffer(const char *what, const char *id, va_list ap)
{
char *buffer, *old;
char *next;
int keylen;
dm_asprintf(&buffer, "%s = \"%s\"\n", what, id);
if (!buffer) goto fail;
while ((next = va_arg(ap, char *))) {
old = buffer;
assert(strchr(next, '='));
keylen = strchr(next, '=') - next;
if (strstr(next, "%d")) {
int value = va_arg(ap, int);
dm_asprintf(&buffer, "%s%.*s= %d\n", buffer, keylen, next, value);
dm_free(old);
} else if (strstr(next, "%s")) {
char *value = va_arg(ap, char *);
dm_asprintf(&buffer, "%s%.*s= \"%s\"\n", buffer, keylen, next, value);
dm_free(old);
} else if (strstr(next, "%b")) {
char *block = va_arg(ap, char *);
if (!block)
continue;
dm_asprintf(&buffer, "%s%.*s%s", buffer, keylen, next, block);
dm_free(old);
} else {
dm_asprintf(&buffer, "%s%s", buffer, next);
dm_free(old);
}
if (!buffer) goto fail;
}
return buffer;
fail:
dm_free(buffer);
return NULL;
}

View File

@ -0,0 +1,6 @@
#include <stdarg.h>
#include <libdevmapper.h>
int read_buffer(int fd, char **buffer);
int write_buffer(int fd, const char *buffer, int length);
char *format_buffer(const char *what, const char *id, va_list ap);

View File

@ -0,0 +1,4 @@
init_fifos
fini_fifos
daemon_talk
dm_event_get_version

View File

@ -0,0 +1,108 @@
#
# Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of the device-mapper userspace tools.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License v.2.1.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SOURCES = libdevmapper-event.c
SOURCES2 = dmeventd.c
TARGETS = dmeventd
.PHONY: install_lib_dynamic install_lib_static install_include \
install_pkgconfig install_dmeventd_dynamic install_dmeventd_static \
install_lib install_dmeventd
INSTALL_DMEVENTD_TARGETS = install_dmeventd_dynamic
INSTALL_LIB_TARGETS = install_lib_dynamic
LIB_NAME = libdevmapper-event
ifeq ("@STATIC_LINK@", "yes")
LIB_STATIC = $(LIB_NAME).a
TARGETS += $(LIB_STATIC) dmeventd.static
INSTALL_DMEVENTD_TARGETS += install_dmeventd_static
INSTALL_LIB_TARGETS += install_lib_static
endif
LIB_VERSION = $(LIB_VERSION_DM)
LIB_SHARED = $(LIB_NAME).$(LIB_SUFFIX)
CLEAN_TARGETS = dmeventd.static $(LIB_NAME).a
ifneq ($(MAKECMDGOALS),device-mapper)
SUBDIRS+=plugins
endif
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
CFLOW_TARGET = dmeventd
EXPORTED_HEADER = $(srcdir)/libdevmapper-event.h
EXPORTED_FN_PREFIX = dm_event
include $(top_builddir)/make.tmpl
all: device-mapper
device-mapper: $(TARGETS)
LIBS += -ldevmapper
LVMLIBS += -ldevmapper-event $(PTHREAD_LIBS)
dmeventd: $(LIB_SHARED) dmeventd.o
$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) -L. -o $@ dmeventd.o \
$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a
$(CC) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \
dmeventd.o $(DL_LIBS) $(LVMLIBS) $(LIBS) $(STATIC_LIBS)
ifeq ("@PKGCONFIG@", "yes")
INSTALL_LIB_TARGETS += install_pkgconfig
endif
ifneq ("$(CFLOW_CMD)", "")
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
-include $(top_builddir)/libdm/libdevmapper.cflow
-include $(top_builddir)/lib/liblvm-internal.cflow
-include $(top_builddir)/lib/liblvm2cmd.cflow
-include $(top_builddir)/daemons/dmeventd/$(LIB_NAME).cflow
-include $(top_builddir)/daemons/dmeventd/plugins/mirror/$(LIB_NAME)-lvm2mirror.cflow
endif
install_include: $(srcdir)/libdevmapper-event.h
$(INSTALL_DATA) -D $< $(includedir)/$(<F)
install_pkgconfig: libdevmapper-event.pc
$(INSTALL_DATA) -D $< $(pkgconfigdir)/devmapper-event.pc
install_lib_dynamic: install_lib_shared
install_lib_static: $(LIB_STATIC)
$(INSTALL_DATA) -D $< $(usrlibdir)/$(<F)
install_lib: $(INSTALL_LIB_TARGETS)
install_dmeventd_dynamic: dmeventd
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
install_dmeventd_static: dmeventd.static
$(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
install_dmeventd: $(INSTALL_DMEVENTD_TARGETS)
install: install_include install_lib install_dmeventd
install_device-mapper: install_include install_lib install_dmeventd
DISTCLEAN_TARGETS += libdevmapper-event.pc

1997
daemons/dmeventd/dmeventd.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __DMEVENTD_DOT_H__
#define __DMEVENTD_DOT_H__
/* FIXME This stuff must be configurable. */
#define DM_EVENT_FIFO_CLIENT "/var/run/dmeventd-client"
#define DM_EVENT_FIFO_SERVER "/var/run/dmeventd-server"
#define DM_EVENT_DEFAULT_TIMEOUT 10
/* Commands for the daemon passed in the message below. */
enum dm_event_command {
DM_EVENT_CMD_ACTIVE = 1,
DM_EVENT_CMD_REGISTER_FOR_EVENT,
DM_EVENT_CMD_UNREGISTER_FOR_EVENT,
DM_EVENT_CMD_GET_REGISTERED_DEVICE,
DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE,
DM_EVENT_CMD_SET_TIMEOUT,
DM_EVENT_CMD_GET_TIMEOUT,
DM_EVENT_CMD_HELLO,
DM_EVENT_CMD_DIE,
DM_EVENT_CMD_GET_STATUS,
};
/* Message passed between client and daemon. */
struct dm_event_daemon_message {
uint32_t cmd;
uint32_t size;
char *data;
};
/* FIXME Is this meant to be exported? I can't see where the
interface uses it. */
/* Fifos for client/daemon communication. */
struct dm_event_fifos {
int client;
int server;
const char *client_path;
const char *server_path;
};
/* EXIT_SUCCESS 0 -- stdlib.h */
/* EXIT_FAILURE 1 -- stdlib.h */
/* EXIT_LOCKFILE_INUSE 2 -- obsoleted */
#define EXIT_DESC_CLOSE_FAILURE 3
#define EXIT_DESC_OPEN_FAILURE 4
/* EXIT_OPEN_PID_FAILURE 5 -- obsoleted */
#define EXIT_FIFO_FAILURE 6
#define EXIT_CHDIR_FAILURE 7
/* Implemented in libdevmapper-event.c, but not part of public API. */
int daemon_talk(struct dm_event_fifos *fifos,
struct dm_event_daemon_message *msg, int cmd,
const char *dso_name, const char *dev_name,
enum dm_event_mask evmask, uint32_t timeout);
int init_fifos(struct dm_event_fifos *fifos);
void fini_fifos(struct dm_event_fifos *fifos);
int dm_event_get_version(struct dm_event_fifos *fifos, int *version);
#endif /* __DMEVENTD_DOT_H__ */

View File

@ -0,0 +1,878 @@
/*
* Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "dmlib.h"
#include "libdevmapper-event.h"
//#include "libmultilog.h"
#include "dmeventd.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/wait.h>
#include <arpa/inet.h> /* for htonl, ntohl */
static int _sequence_nr = 0;
struct dm_event_handler {
char *dso;
char *dmeventd_path;
char *dev_name;
char *uuid;
int major;
int minor;
uint32_t timeout;
enum dm_event_mask mask;
};
static void _dm_event_handler_clear_dev_info(struct dm_event_handler *dmevh)
{
dm_free(dmevh->dev_name);
dm_free(dmevh->uuid);
dmevh->dev_name = dmevh->uuid = NULL;
dmevh->major = dmevh->minor = 0;
}
struct dm_event_handler *dm_event_handler_create(void)
{
struct dm_event_handler *dmevh = NULL;
if (!(dmevh = dm_malloc(sizeof(*dmevh))))
return NULL;
dmevh->dmeventd_path = NULL;
dmevh->dso = dmevh->dev_name = dmevh->uuid = NULL;
dmevh->major = dmevh->minor = 0;
dmevh->mask = 0;
dmevh->timeout = 0;
return dmevh;
}
void dm_event_handler_destroy(struct dm_event_handler *dmevh)
{
_dm_event_handler_clear_dev_info(dmevh);
dm_free(dmevh->dso);
dm_free(dmevh->dmeventd_path);
dm_free(dmevh);
}
int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const char *dmeventd_path)
{
if (!dmeventd_path) /* noop */
return 0;
dm_free(dmevh->dmeventd_path);
dmevh->dmeventd_path = dm_strdup(dmeventd_path);
if (!dmevh->dmeventd_path)
return -ENOMEM;
return 0;
}
int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path)
{
if (!path) /* noop */
return 0;
dm_free(dmevh->dso);
dmevh->dso = dm_strdup(path);
if (!dmevh->dso)
return -ENOMEM;
return 0;
}
int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *dev_name)
{
if (!dev_name)
return 0;
_dm_event_handler_clear_dev_info(dmevh);
dmevh->dev_name = dm_strdup(dev_name);
if (!dmevh->dev_name)
return -ENOMEM;
return 0;
}
int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid)
{
if (!uuid)
return 0;
_dm_event_handler_clear_dev_info(dmevh);
dmevh->uuid = dm_strdup(uuid);
if (!dmevh->uuid)
return -ENOMEM;
return 0;
}
void dm_event_handler_set_major(struct dm_event_handler *dmevh, int major)
{
int minor = dmevh->minor;
_dm_event_handler_clear_dev_info(dmevh);
dmevh->major = major;
dmevh->minor = minor;
}
void dm_event_handler_set_minor(struct dm_event_handler *dmevh, int minor)
{
int major = dmevh->major;
_dm_event_handler_clear_dev_info(dmevh);
dmevh->major = major;
dmevh->minor = minor;
}
void dm_event_handler_set_event_mask(struct dm_event_handler *dmevh,
enum dm_event_mask evmask)
{
dmevh->mask = evmask;
}
void dm_event_handler_set_timeout(struct dm_event_handler *dmevh, int timeout)
{
dmevh->timeout = timeout;
}
const char *dm_event_handler_get_dso(const struct dm_event_handler *dmevh)
{
return dmevh->dso;
}
const char *dm_event_handler_get_dev_name(const struct dm_event_handler *dmevh)
{
return dmevh->dev_name;
}
const char *dm_event_handler_get_uuid(const struct dm_event_handler *dmevh)
{
return dmevh->uuid;
}
int dm_event_handler_get_major(const struct dm_event_handler *dmevh)
{
return dmevh->major;
}
int dm_event_handler_get_minor(const struct dm_event_handler *dmevh)
{
return dmevh->minor;
}
int dm_event_handler_get_timeout(const struct dm_event_handler *dmevh)
{
return dmevh->timeout;
}
enum dm_event_mask dm_event_handler_get_event_mask(const struct dm_event_handler *dmevh)
{
return dmevh->mask;
}
static int _check_message_id(struct dm_event_daemon_message *msg)
{
int pid, seq_nr;
if ((sscanf(msg->data, "%d:%d", &pid, &seq_nr) != 2) ||
(pid != getpid()) || (seq_nr != _sequence_nr)) {
log_error("Ignoring out-of-sequence reply from dmeventd. "
"Expected %d:%d but received %s", getpid(),
_sequence_nr, msg->data);
return 0;
}
return 1;
}
/*
* daemon_read
* @fifos
* @msg
*
* Read message from daemon.
*
* Returns: 0 on failure, 1 on success
*/
static int _daemon_read(struct dm_event_fifos *fifos,
struct dm_event_daemon_message *msg)
{
unsigned bytes = 0;
int ret, i;
fd_set fds;
struct timeval tval = { 0, 0 };
size_t size = 2 * sizeof(uint32_t); /* status + size */
uint32_t *header = alloca(size);
char *buf = (char *)header;
struct stat fstatbuf;
while (bytes < size) {
for (i = 0, ret = 0; (i < 20) && (ret < 1); i++) {
/* Watch daemon read FIFO for input. */
FD_ZERO(&fds);
FD_SET(fifos->server, &fds);
tval.tv_sec = 1;
ret = select(fifos->server + 1, &fds, NULL, NULL,
&tval);
if (ret < 0 && errno != EINTR) {
log_error("Unable to read from event server");
return 0;
}
/* Check whether fifo is still alive */
if ((ret == 0) &&
fstat(fifos->server + 1, &fstatbuf) &&
(errno == EBADF)) {
log_error("Fifo fd is bad for event server.");
return 0;
}
}
if (ret < 1) {
log_error("Unable to read from event server.");
return 0;
}
ret = read(fifos->server, buf + bytes, size);
if (ret < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
else {
log_error("Unable to read from event server.");
return 0;
}
}
bytes += ret;
if (header && (bytes == 2 * sizeof(uint32_t))) {
msg->cmd = ntohl(header[0]);
msg->size = ntohl(header[1]);
buf = msg->data = dm_malloc(msg->size);
size = msg->size;
bytes = 0;
header = 0;
}
}
if (bytes != size) {
dm_free(msg->data);
msg->data = NULL;
}
return bytes == size;
}
/* Write message to daemon. */
static int _daemon_write(struct dm_event_fifos *fifos,
struct dm_event_daemon_message *msg)
{
unsigned bytes = 0;
int ret = 0;
fd_set fds;
size_t size = 2 * sizeof(uint32_t) + msg->size;
uint32_t *header = alloca(size);
char *buf = (char *)header;
char drainbuf[128];
struct timeval tval = { 0, 0 };
header[0] = htonl(msg->cmd);
header[1] = htonl(msg->size);
memcpy(buf + 2 * sizeof(uint32_t), msg->data, msg->size);
/* drain the answer fifo */
while (1) {
FD_ZERO(&fds);
FD_SET(fifos->server, &fds);
tval.tv_usec = 100;
ret = select(fifos->server + 1, &fds, NULL, NULL, &tval);
if ((ret < 0) && (errno != EINTR)) {
log_error("Unable to talk to event daemon");
return 0;
}
if (ret == 0)
break;
ret = read(fifos->server, drainbuf, 127);
}
while (bytes < size) {
do {
/* Watch daemon write FIFO to be ready for output. */
FD_ZERO(&fds);
FD_SET(fifos->client, &fds);
ret = select(fifos->client + 1, NULL, &fds, NULL, NULL);
if ((ret < 0) && (errno != EINTR)) {
log_error("Unable to talk to event daemon");
return 0;
}
} while (ret < 1);
ret = write(fifos->client, buf + bytes, size - bytes);
if (ret < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
else {
log_error("Unable to talk to event daemon");
return 0;
}
}
bytes += ret;
}
return bytes == size;
}
int daemon_talk(struct dm_event_fifos *fifos,
struct dm_event_daemon_message *msg, int cmd,
const char *dso_name, const char *dev_name,
enum dm_event_mask evmask, uint32_t timeout)
{
const char *dso = dso_name ? dso_name : "-";
const char *dev = dev_name ? dev_name : "-";
const char *fmt = "%d:%d %s %s %u %" PRIu32;
int msg_size;
memset(msg, 0, sizeof(*msg));
/*
* Set command and pack the arguments
* into ASCII message string.
*/
msg->cmd = cmd;
if (cmd == DM_EVENT_CMD_HELLO)
fmt = "%d:%d HELLO";
if ((msg_size = dm_asprintf(&(msg->data), fmt, getpid(), _sequence_nr,
dso, dev, evmask, timeout)) < 0) {
log_error("_daemon_talk: message allocation failed");
return -ENOMEM;
}
msg->size = msg_size;
/*
* Write command and message to and
* read status return code from daemon.
*/
if (!_daemon_write(fifos, msg)) {
stack;
dm_free(msg->data);
msg->data = 0;
return -EIO;
}
do {
dm_free(msg->data);
msg->data = 0;
if (!_daemon_read(fifos, msg)) {
stack;
return -EIO;
}
} while (!_check_message_id(msg));
_sequence_nr++;
return (int32_t) msg->cmd;
}
/*
* start_daemon
*
* This function forks off a process (dmeventd) that will handle
* the events. I am currently test opening one of the fifos to
* ensure that the daemon is running and listening... I thought
* this would be less expensive than fork/exec'ing every time.
* Perhaps there is an even quicker/better way (no, checking the
* lock file is _not_ a better way).
*
* Returns: 1 on success, 0 otherwise
*/
static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
{
int pid, ret = 0;
int status;
struct stat statbuf;
char default_dmeventd_path[] = DMEVENTD_PATH;
char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
if (stat(fifos->client_path, &statbuf))
goto start_server;
if (!S_ISFIFO(statbuf.st_mode)) {
log_error("%s is not a fifo.", fifos->client_path);
return 0;
}
/* Anyone listening? If not, errno will be ENXIO */
fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK);
if (fifos->client >= 0) {
/* server is running and listening */
close(fifos->client);
return 1;
} else if (errno != ENXIO) {
/* problem */
log_error("%s: Can't open client fifo %s: %s",
__func__, fifos->client_path, strerror(errno));
return 0;
}
start_server:
/* server is not running */
if (!strncmp(DMEVENTD_PATH, "/", 1) && stat(DMEVENTD_PATH, &statbuf)) {
log_error("Unable to find dmeventd.");
return 0;
}
pid = fork();
if (pid < 0)
log_error("Unable to fork.");
else if (!pid) {
execvp(args[0], args);
log_error("Unable to exec dmeventd: %s", strerror(errno));
_exit(EXIT_FAILURE);
} else {
if (waitpid(pid, &status, 0) < 0)
log_error("Unable to start dmeventd: %s",
strerror(errno));
else if (WEXITSTATUS(status))
log_error("Unable to start dmeventd.");
else
ret = 1;
}
return ret;
}
int init_fifos(struct dm_event_fifos *fifos)
{
/* FIXME? Is fifo the most suitable method? Why not share
comms/daemon code with something else e.g. multipath? */
/* FIXME Make these either configurable or depend directly on dmeventd_path */
fifos->client_path = DM_EVENT_FIFO_CLIENT;
fifos->server_path = DM_EVENT_FIFO_SERVER;
/* Open the fifo used to read from the daemon. */
if ((fifos->server = open(fifos->server_path, O_RDWR)) < 0) {
log_error("%s: open server fifo %s",
__func__, fifos->server_path);
return 0;
}
/* Lock out anyone else trying to do communication with the daemon. */
if (flock(fifos->server, LOCK_EX) < 0) {
log_error("%s: flock %s", __func__, fifos->server_path);
close(fifos->server);
return 0;
}
/* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/
if ((fifos->client = open(fifos->client_path, O_RDWR | O_NONBLOCK)) < 0) {
log_error("%s: Can't open client fifo %s: %s",
__func__, fifos->client_path, strerror(errno));
close(fifos->server);
return 0;
}
return 1;
}
/* Initialize client. */
static int _init_client(char *dmeventd_path, struct dm_event_fifos *fifos)
{
/* init fifos */
memset(fifos, 0, sizeof(*fifos));
/* FIXME Make these either configurable or depend directly on dmeventd_path */
fifos->client_path = DM_EVENT_FIFO_CLIENT;
fifos->server_path = DM_EVENT_FIFO_SERVER;
if (!_start_daemon(dmeventd_path, fifos))
return_0;
return init_fifos(fifos);
}
void fini_fifos(struct dm_event_fifos *fifos)
{
if (flock(fifos->server, LOCK_UN))
log_error("flock unlock %s", fifos->server_path);
close(fifos->client);
close(fifos->server);
}
/* Get uuid of a device */
static struct dm_task *_get_device_info(const struct dm_event_handler *dmevh)
{
struct dm_task *dmt;
struct dm_info info;
if (!(dmt = dm_task_create(DM_DEVICE_INFO))) {
log_error("_get_device_info: dm_task creation for info failed");
return NULL;
}
if (dmevh->uuid) {
if (!dm_task_set_uuid(dmt, dmevh->uuid))
goto_bad;
} else if (dmevh->dev_name) {
if (!dm_task_set_name(dmt, dmevh->dev_name))
goto_bad;
} else if (dmevh->major && dmevh->minor) {
if (!dm_task_set_major(dmt, dmevh->major) ||
!dm_task_set_minor(dmt, dmevh->minor))
goto_bad;
}
/* FIXME Add name or uuid or devno to messages */
if (!dm_task_run(dmt)) {
log_error("_get_device_info: dm_task_run() failed");
goto bad;
}
if (!dm_task_get_info(dmt, &info)) {
log_error("_get_device_info: failed to get info for device");
goto bad;
}
if (!info.exists) {
log_error("_get_device_info: %s%s%s%.0d%s%.0d%s%s: device not found",
dmevh->uuid ? : "",
(!dmevh->uuid && dmevh->dev_name) ? dmevh->dev_name : "",
(!dmevh->uuid && !dmevh->dev_name && dmevh->major > 0) ? "(" : "",
(!dmevh->uuid && !dmevh->dev_name && dmevh->major > 0) ? dmevh->major : 0,
(!dmevh->uuid && !dmevh->dev_name && dmevh->major > 0) ? ":" : "",
(!dmevh->uuid && !dmevh->dev_name && dmevh->minor > 0) ? dmevh->minor : 0,
(!dmevh->uuid && !dmevh->dev_name && dmevh->major > 0) && dmevh->minor == 0 ? "0" : "",
(!dmevh->uuid && !dmevh->dev_name && dmevh->major > 0) ? ") " : "");
goto bad;
}
return dmt;
bad:
dm_task_destroy(dmt);
return NULL;
}
/* Handle the event (de)registration call and return negative error codes. */
static int _do_event(int cmd, char *dmeventd_path, struct dm_event_daemon_message *msg,
const char *dso_name, const char *dev_name,
enum dm_event_mask evmask, uint32_t timeout)
{
int ret;
struct dm_event_fifos fifos;
if (!_init_client(dmeventd_path, &fifos)) {
stack;
return -ESRCH;
}
ret = daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0);
dm_free(msg->data);
msg->data = 0;
if (!ret)
ret = daemon_talk(&fifos, msg, cmd, dso_name, dev_name, evmask, timeout);
/* what is the opposite of init? */
fini_fifos(&fifos);
return ret;
}
/* External library interface. */
int dm_event_register_handler(const struct dm_event_handler *dmevh)
{
int ret = 1, err;
const char *uuid;
struct dm_task *dmt;
struct dm_event_daemon_message msg = { 0, 0, NULL };
if (!(dmt = _get_device_info(dmevh))) {
stack;
return 0;
}
uuid = dm_task_get_uuid(dmt);
if ((err = _do_event(DM_EVENT_CMD_REGISTER_FOR_EVENT, dmevh->dmeventd_path, &msg,
dmevh->dso, uuid, dmevh->mask, dmevh->timeout)) < 0) {
log_error("%s: event registration failed: %s",
dm_task_get_name(dmt),
msg.data ? msg.data : strerror(-err));
ret = 0;
}
dm_free(msg.data);
dm_task_destroy(dmt);
return ret;
}
int dm_event_unregister_handler(const struct dm_event_handler *dmevh)
{
int ret = 1, err;
const char *uuid;
struct dm_task *dmt;
struct dm_event_daemon_message msg = { 0, 0, NULL };
if (!(dmt = _get_device_info(dmevh))) {
stack;
return 0;
}
uuid = dm_task_get_uuid(dmt);
if ((err = _do_event(DM_EVENT_CMD_UNREGISTER_FOR_EVENT, dmevh->dmeventd_path, &msg,
dmevh->dso, uuid, dmevh->mask, dmevh->timeout)) < 0) {
log_error("%s: event deregistration failed: %s",
dm_task_get_name(dmt),
msg.data ? msg.data : strerror(-err));
ret = 0;
}
dm_free(msg.data);
dm_task_destroy(dmt);
return ret;
}
/* Fetch a string off src and duplicate it into *dest. */
/* FIXME: move to separate module to share with the daemon. */
static char *_fetch_string(char **src, const int delimiter)
{
char *p, *ret;
if ((p = strchr(*src, delimiter)))
*p = 0;
if ((ret = dm_strdup(*src)))
*src += strlen(ret) + 1;
if (p)
*p = delimiter;
return ret;
}
/* Parse a device message from the daemon. */
static int _parse_message(struct dm_event_daemon_message *msg, char **dso_name,
char **uuid, enum dm_event_mask *evmask)
{
char *id = NULL;
char *p = msg->data;
if ((id = _fetch_string(&p, ' ')) &&
(*dso_name = _fetch_string(&p, ' ')) &&
(*uuid = _fetch_string(&p, ' '))) {
*evmask = atoi(p);
dm_free(id);
return 0;
}
if (id)
dm_free(id);
return -ENOMEM;
}
/*
* Returns 0 if handler found; error (-ENOMEM, -ENOENT) otherwise.
*/
int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
{
int ret = 0;
const char *uuid = NULL;
char *reply_dso = NULL, *reply_uuid = NULL;
enum dm_event_mask reply_mask = 0;
struct dm_task *dmt = NULL;
struct dm_event_daemon_message msg = { 0, 0, NULL };
struct dm_info info;
if (!(dmt = _get_device_info(dmevh))) {
stack;
return 0;
}
uuid = dm_task_get_uuid(dmt);
if (_do_event(next ? DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE :
DM_EVENT_CMD_GET_REGISTERED_DEVICE, dmevh->dmeventd_path,
&msg, dmevh->dso, uuid, dmevh->mask, 0)) {
ret = -ENOENT;
stack;
goto fail;
}
/* FIXME this will probably horribly break if we get
ill-formatted reply */
ret = _parse_message(&msg, &reply_dso, &reply_uuid, &reply_mask);
dm_task_destroy(dmt);
dmt = NULL;
dm_free(msg.data);
msg.data = NULL;
_dm_event_handler_clear_dev_info(dmevh);
if (!reply_uuid) {
ret = -ENXIO; /* dmeventd probably gave us bogus uuid back */
goto fail;
}
dmevh->uuid = dm_strdup(reply_uuid);
if (!dmevh->uuid) {
ret = -ENOMEM;
goto fail;
}
if (!(dmt = _get_device_info(dmevh))) {
ret = -ENXIO; /* dmeventd probably gave us bogus uuid back */
goto fail;
}
dm_event_handler_set_dso(dmevh, reply_dso);
dm_event_handler_set_event_mask(dmevh, reply_mask);
dm_free(reply_dso);
reply_dso = NULL;
dm_free(reply_uuid);
reply_uuid = NULL;
dmevh->dev_name = dm_strdup(dm_task_get_name(dmt));
if (!dmevh->dev_name) {
ret = -ENOMEM;
goto fail;
}
if (!dm_task_get_info(dmt, &info)) {
ret = -1;
goto fail;
}
dmevh->major = info.major;
dmevh->minor = info.minor;
dm_task_destroy(dmt);
return ret;
fail:
dm_free(msg.data);
dm_free(reply_dso);
dm_free(reply_uuid);
_dm_event_handler_clear_dev_info(dmevh);
if (dmt)
dm_task_destroy(dmt);
return ret;
}
/*
* You can (and have to) call this at the stage of the protocol where
* daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0)
*
* would be normally sent. This call will parse the version reply from
* dmeventd, in addition to above call. It is not safe to call this at any
* other place in the protocol.
*
* This is an internal function, not exposed in the public API.
*/
int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
char *p;
struct dm_event_daemon_message msg = { 0, 0, NULL };
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0))
return 0;
p = msg.data;
*version = 0;
p = strchr(p, ' '); /* Message ID */
if (!p) return 0;
p = strchr(p + 1, ' '); /* HELLO */
if (!p) return 0;
p = strchr(p + 1, ' '); /* HELLO, once more */
if (p)
*version = atoi(p);
return 1;
}
#if 0 /* left out for now */
static char *_skip_string(char *src, const int delimiter)
{
src = srtchr(src, delimiter);
if (src && *(src + 1))
return src + 1;
return NULL;
}
int dm_event_set_timeout(const char *device_path, uint32_t timeout)
{
struct dm_event_daemon_message msg = { 0, 0, NULL };
if (!device_exists(device_path))
return -ENODEV;
return _do_event(DM_EVENT_CMD_SET_TIMEOUT, &msg,
NULL, device_path, 0, timeout);
}
int dm_event_get_timeout(const char *device_path, uint32_t *timeout)
{
int ret;
struct dm_event_daemon_message msg = { 0, 0, NULL };
if (!device_exists(device_path))
return -ENODEV;
if (!(ret = _do_event(DM_EVENT_CMD_GET_TIMEOUT, &msg, NULL, device_path,
0, 0))) {
char *p = _skip_string(msg.data, ' ');
if (!p) {
log_error("malformed reply from dmeventd '%s'\n",
msg.data);
return -EIO;
}
*timeout = atoi(p);
}
if (msg.data)
dm_free(msg.data);
return ret;
}
#endif

View File

@ -0,0 +1,112 @@
/*
* Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Note that this file is released only as part of a technology preview
* and its contents may change in future updates in ways that do not
* preserve compatibility.
*/
#ifndef LIB_DMEVENT_H
#define LIB_DMEVENT_H
#include <stdint.h>
/*
* Event library interface.
*/
enum dm_event_mask {
DM_EVENT_SETTINGS_MASK = 0x0000FF,
DM_EVENT_SINGLE = 0x000001, /* Report multiple errors just once. */
DM_EVENT_MULTI = 0x000002, /* Report all of them. */
DM_EVENT_ERROR_MASK = 0x00FF00,
DM_EVENT_SECTOR_ERROR = 0x000100, /* Failure on a particular sector. */
DM_EVENT_DEVICE_ERROR = 0x000200, /* Device failure. */
DM_EVENT_PATH_ERROR = 0x000400, /* Failure on an io path. */
DM_EVENT_ADAPTOR_ERROR = 0x000800, /* Failure of a host adaptor. */
DM_EVENT_STATUS_MASK = 0xFF0000,
DM_EVENT_SYNC_STATUS = 0x010000, /* Mirror synchronization completed/failed. */
DM_EVENT_TIMEOUT = 0x020000, /* Timeout has occured */
DM_EVENT_REGISTRATION_PENDING = 0x1000000, /* Monitor thread is setting-up/shutting-down */
};
#define DM_EVENT_ALL_ERRORS DM_EVENT_ERROR_MASK
#define DM_EVENT_PROTOCOL_VERSION 1
struct dm_event_handler;
struct dm_event_handler *dm_event_handler_create(void);
void dm_event_handler_destroy(struct dm_event_handler *dmevh);
/*
* Path of shared library to handle events.
*
* All of dmeventd, dso, device_name and uuid strings are duplicated so
* you do not need to keep the pointers valid after the call succeeds.
* They may return -ENOMEM though.
*/
int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path);
/*
* Path of dmeventd binary.
*/
int dm_event_handler_set_dmeventd_path(struct dm_event_handler *dmevh, const char *dmeventd_path);
/*
* Identify the device to monitor by exactly one of device_name, uuid or
* device number. String arguments are duplicated, see above.
*/
int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *device_name);
int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid);
void dm_event_handler_set_major(struct dm_event_handler *dmevh, int major);
void dm_event_handler_set_minor(struct dm_event_handler *dmevh, int minor);
void dm_event_handler_set_timeout(struct dm_event_handler *dmevh, int timeout);
/*
* Specify mask for events to monitor.
*/
void dm_event_handler_set_event_mask(struct dm_event_handler *dmevh,
enum dm_event_mask evmask);
const char *dm_event_handler_get_dso(const struct dm_event_handler *dmevh);
const char *dm_event_handler_get_dev_name(const struct dm_event_handler *dmevh);
const char *dm_event_handler_get_uuid(const struct dm_event_handler *dmevh);
int dm_event_handler_get_major(const struct dm_event_handler *dmevh);
int dm_event_handler_get_minor(const struct dm_event_handler *dmevh);
int dm_event_handler_get_timeout(const struct dm_event_handler *dmevh);
enum dm_event_mask dm_event_handler_get_event_mask(const struct dm_event_handler *dmevh);
/* FIXME Review interface (what about this next thing?) */
int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next);
/*
* Initiate monitoring using dmeventd.
*/
int dm_event_register_handler(const struct dm_event_handler *dmevh);
int dm_event_unregister_handler(const struct dm_event_handler *dmevh);
/* Prototypes for DSO interface, see dmeventd.c, struct dso_data for
detailed descriptions. */
void process_event(struct dm_task *dmt, enum dm_event_mask evmask, void **user);
int register_device(const char *device_name, const char *uuid, int major, int minor, void **user);
int unregister_device(const char *device_name, const char *uuid, int major,
int minor, void **user);
#endif

View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: devmapper-event
Description: device-mapper event library
Version: @DM_LIB_PATCHLEVEL@
Cflags: -I${includedir}
Libs: -L${libdir} -ldevmapper-event
Requires.private: devmapper

View File

@ -0,0 +1,46 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2005, 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SUBDIRS += lvm2
ifneq ("@MIRRORS@", "none")
SUBDIRS += mirror
endif
ifneq ("@SNAPSHOTS@", "none")
SUBDIRS += snapshot
endif
ifneq ("@RAID@", "none")
SUBDIRS += raid
endif
ifneq ("@THIN@", "none")
SUBDIRS += thin
endif
ifeq ($(MAKECMDGOALS),distclean)
SUBDIRS = lvm2 mirror snapshot raid thin
endif
include $(top_builddir)/make.tmpl
snapshot: lvm2
mirror: lvm2
raid: lvm2
thin: lvm2

View File

@ -0,0 +1,7 @@
dmeventd_lvm2_init
dmeventd_lvm2_exit
dmeventd_lvm2_lock
dmeventd_lvm2_unlock
dmeventd_lvm2_pool
dmeventd_lvm2_run
dmeventd_lvm2_command

View File

@ -0,0 +1,31 @@
#
# Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CLDFLAGS += -L$(top_builddir)/tools
SOURCES = dmeventd_lvm.c
LIB_SHARED = libdevmapper-event-lvm2.$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_LVM)
include $(top_builddir)/make.tmpl
LIBS += @LVM2CMD_LIB@ -ldevmapper $(PTHREAD_LIBS)
install_lvm2: install_lib_shared
install: install_lvm2

View File

@ -0,0 +1,173 @@
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "log.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include <pthread.h>
#include <syslog.h>
extern int dmeventd_debug;
/*
* register_device() is called first and performs initialisation.
* Only one device may be registered or unregistered at a time.
*/
static pthread_mutex_t _register_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
* Number of active registrations.
*/
static int _register_count = 0;
static struct dm_pool *_mem_pool = NULL;
static void *_lvm_handle = NULL;
/*
* Currently only one event can be processed at a time.
*/
static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
* FIXME Do not pass things directly to syslog, rather use the existing logging
* facilities to sort logging ... however that mechanism needs to be somehow
* configurable and we don't have that option yet
*/
static void _temporary_log_fn(int level,
const char *file __attribute__((unused)),
int line __attribute__((unused)),
int dm_errno __attribute__((unused)),
const char *message)
{
level &= ~(_LOG_STDERR | _LOG_ONCE);
switch (level) {
case _LOG_DEBUG:
if (dmeventd_debug >= 3)
syslog(LOG_DEBUG, "%s", message);
break;
case _LOG_INFO:
if (dmeventd_debug >= 2)
syslog(LOG_INFO, "%s", message);
break;
case _LOG_NOTICE:
if (dmeventd_debug >= 1)
syslog(LOG_NOTICE, "%s", message);
break;
case _LOG_WARN:
syslog(LOG_WARNING, "%s", message);
break;
case _LOG_ERR:
syslog(LOG_ERR, "%s", message);
break;
default:
syslog(LOG_CRIT, "%s", message);
}
}
void dmeventd_lvm2_lock(void)
{
pthread_mutex_lock(&_event_mutex);
}
void dmeventd_lvm2_unlock(void)
{
pthread_mutex_unlock(&_event_mutex);
}
int dmeventd_lvm2_init(void)
{
int r = 0;
pthread_mutex_lock(&_register_mutex);
/*
* Need some space for allocations. 1024 should be more
* than enough for what we need (device mapper name splitting)
*/
if (!_mem_pool && !(_mem_pool = dm_pool_create("mirror_dso", 1024)))
goto out;
if (!_lvm_handle) {
lvm2_log_fn(_temporary_log_fn);
if (!(_lvm_handle = lvm2_init())) {
dm_pool_destroy(_mem_pool);
_mem_pool = NULL;
goto out;
}
lvm2_disable_dmeventd_monitoring(_lvm_handle);
/* FIXME Temporary: move to dmeventd core */
lvm2_run(_lvm_handle, "_memlock_inc");
}
_register_count++;
r = 1;
out:
pthread_mutex_unlock(&_register_mutex);
return r;
}
void dmeventd_lvm2_exit(void)
{
pthread_mutex_lock(&_register_mutex);
if (!--_register_count) {
lvm2_run(_lvm_handle, "_memlock_dec");
dm_pool_destroy(_mem_pool);
_mem_pool = NULL;
lvm2_exit(_lvm_handle);
_lvm_handle = NULL;
}
pthread_mutex_unlock(&_register_mutex);
}
struct dm_pool *dmeventd_lvm2_pool(void)
{
return _mem_pool;
}
int dmeventd_lvm2_run(const char *cmdline)
{
return lvm2_run(_lvm_handle, cmdline);
}
int dmeventd_lvm2_command(struct dm_pool *mem, char *buffer, size_t size,
const char *cmd, const char *device)
{
char *vg = NULL, *lv = NULL, *layer;
int r;
if (!dm_split_lvm_name(mem, device, &vg, &lv, &layer)) {
syslog(LOG_ERR, "Unable to determine VG name from %s.\n",
device);
return 0;
}
r = dm_snprintf(buffer, size, "%s %s/%s", cmd, vg, lv);
dm_pool_free(mem, vg);
if (r < 0) {
syslog(LOG_ERR, "Unable to form LVM command. (too long).\n");
return 0;
}
return 1;
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Wrappers around liblvm2cmd functions for dmeventd plug-ins.
*
* liblvm2cmd is not thread-safe so the locking in this library helps dmeventd
* threads to co-operate in sharing a single instance.
*
* FIXME Either support this properly as a generic liblvm2cmd wrapper or make
* liblvm2cmd thread-safe so this can go away.
*/
#include "libdevmapper.h"
#ifndef _DMEVENTD_LVMWRAP_H
#define _DMEVENTD_LVMWRAP_H
int dmeventd_lvm2_init(void);
void dmeventd_lvm2_exit(void);
int dmeventd_lvm2_run(const char *cmdline);
void dmeventd_lvm2_lock(void);
void dmeventd_lvm2_unlock(void);
struct dm_pool *dmeventd_lvm2_pool(void);
int dmeventd_lvm2_command(struct dm_pool *mem, char *buffer, size_t size,
const char *cmd, const char *device);
#endif /* _DMEVENTD_LVMWRAP_H */

View File

@ -0,0 +1,3 @@
process_event
register_device
unregister_device

View File

@ -0,0 +1,37 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2005, 2008-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_mirror.c
LIB_NAME = libdevmapper-event-lvm2mirror
LIB_SHARED = $(LIB_NAME).$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_LVM)
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper-event-lvm2 -ldevmapper
install_lvm2: install_dm_plugin
install: install_lvm2

View File

@ -0,0 +1,235 @@
/*
* Copyright (C) 2005-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include "defaults.h"
#include <syslog.h> /* FIXME Replace syslog with multilog */
/* FIXME Missing openlog? */
/* FIXME Replace most syslogs with log_error() style messages and add complete context. */
/* FIXME Reformat to 80 char lines. */
#define ME_IGNORE 0
#define ME_INSYNC 1
#define ME_FAILURE 2
static int _process_status_code(const char status_code, const char *dev_name,
const char *dev_type, int r)
{
/*
* A => Alive - No failures
* D => Dead - A write failure occurred leaving mirror out-of-sync
* F => Flush failed.
* S => Sync - A sychronization failure occurred, mirror out-of-sync
* R => Read - A read failure occurred, mirror data unaffected
* U => Unclassified failure (bug)
*/
if (status_code == 'F') {
syslog(LOG_ERR, "%s device %s flush failed.",
dev_type, dev_name);
r = ME_FAILURE;
} else if (status_code == 'S')
syslog(LOG_ERR, "%s device %s sync failed.",
dev_type, dev_name);
else if (status_code == 'R')
syslog(LOG_ERR, "%s device %s read failed.",
dev_type, dev_name);
else if (status_code != 'A') {
syslog(LOG_ERR, "%s device %s has failed (%c).",
dev_type, dev_name, status_code);
r = ME_FAILURE;
}
return r;
}
static int _get_mirror_event(char *params)
{
int i, r = ME_INSYNC;
char **args = NULL;
char *dev_status_str;
char *log_status_str;
char *sync_str;
char *p = NULL;
int log_argc, num_devs;
/*
* dm core parms: 0 409600 mirror
* Mirror core parms: 2 253:4 253:5 400/400
* New-style failure params: 1 AA
* New-style log params: 3 cluster 253:3 A
* or 3 disk 253:3 A
* or 1 core
*/
/* number of devices */
if (!dm_split_words(params, 1, 0, &p))
goto out_parse;
if (!(num_devs = atoi(p)) ||
(num_devs > DEFAULT_MIRROR_MAX_IMAGES) || (num_devs < 0))
goto out_parse;
p += strlen(p) + 1;
/* devices names + "400/400" + "1 AA" + 1 or 3 log parms + NULL */
args = dm_malloc((num_devs + 7) * sizeof(char *));
if (!args || dm_split_words(p, num_devs + 7, 0, args) < num_devs + 5)
goto out_parse;
/* FIXME: Code differs from lib/mirror/mirrored.c */
dev_status_str = args[2 + num_devs];
log_argc = atoi(args[3 + num_devs]);
log_status_str = args[3 + num_devs + log_argc];
sync_str = args[num_devs];
/* Check for bad mirror devices */
for (i = 0; i < num_devs; i++)
r = _process_status_code(dev_status_str[i], args[i],
i ? "Secondary mirror" : "Primary mirror", r);
/* Check for bad disk log device */
if (log_argc > 1)
r = _process_status_code(log_status_str[0],
args[2 + num_devs + log_argc],
"Log", r);
if (r == ME_FAILURE)
goto out;
p = strstr(sync_str, "/");
if (p) {
p[0] = '\0';
if (strcmp(sync_str, p+1))
r = ME_IGNORE;
p[0] = '/';
} else
goto out_parse;
out:
dm_free(args);
return r;
out_parse:
dm_free(args);
syslog(LOG_ERR, "Unable to parse mirror status string.");
return ME_IGNORE;
}
static int _remove_failed_devices(const char *device)
{
int r;
#define CMD_SIZE 256 /* FIXME Use system restriction */
char cmd_str[CMD_SIZE];
if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
"lvconvert --config devices{ignore_suspended_devices=1} "
"--repair --use-policies", device))
return -ENAMETOOLONG; /* FIXME Replace with generic error return - reason for failure has already got logged */
r = dmeventd_lvm2_run(cmd_str);
syslog(LOG_INFO, "Repair of mirrored device %s %s.", device,
(r == ECMD_PROCESSED) ? "finished successfully" : "failed");
return (r == ECMD_PROCESSED) ? 0 : -1;
}
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **unused __attribute__((unused)))
{
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
const char *device = dm_task_get_name(dmt);
dmeventd_lvm2_lock();
do {
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, &params);
if (!target_type) {
syslog(LOG_INFO, "%s mapping lost.", device);
continue;
}
if (strcmp(target_type, "mirror")) {
syslog(LOG_INFO, "%s has unmirrored portion.", device);
continue;
}
switch(_get_mirror_event(params)) {
case ME_INSYNC:
/* FIXME: all we really know is that this
_part_ of the device is in sync
Also, this is not an error
*/
syslog(LOG_NOTICE, "%s is now in-sync.", device);
break;
case ME_FAILURE:
syslog(LOG_ERR, "Device failure in %s.", device);
if (_remove_failed_devices(device))
/* FIXME Why are all the error return codes unused? Get rid of them? */
syslog(LOG_ERR, "Failed to remove faulty devices in %s.",
device);
/* Should check before warning user that device is now linear
else
syslog(LOG_NOTICE, "%s is now a linear device.\n",
device);
*/
break;
case ME_IGNORE:
break;
default:
/* FIXME Provide value then! */
syslog(LOG_INFO, "Unknown event received.");
}
} while (next);
dmeventd_lvm2_unlock();
}
int register_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **unused __attribute__((unused)))
{
if (!dmeventd_lvm2_init())
return 0;
syslog(LOG_INFO, "Monitoring mirror device %s for events.", device);
return 1;
}
int unregister_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **unused __attribute__((unused)))
{
syslog(LOG_INFO, "No longer monitoring mirror device %s for events.",
device);
dmeventd_lvm2_exit();
return 1;
}

View File

@ -0,0 +1,3 @@
process_event
register_device
unregister_device

View File

@ -0,0 +1,36 @@
#
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_raid.c
LIB_NAME = libdevmapper-event-lvm2raid
LIB_SHARED = $(LIB_NAME).$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_LVM)
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper-event-lvm2 -ldevmapper
install_lvm2: install_dm_plugin
install: install_lvm2

View File

@ -0,0 +1,172 @@
/*
* Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include <syslog.h> /* FIXME Replace syslog with multilog */
/* FIXME Missing openlog? */
/* FIXME Replace most syslogs with log_error() style messages and add complete context. */
/* FIXME Reformat to 80 char lines. */
/*
* run_repair is a close copy to
* plugins/mirror/dmeventd_mirror.c:_remove_failed_devices()
*/
static int run_repair(const char *device)
{
int r;
#define CMD_SIZE 256 /* FIXME Use system restriction */
char cmd_str[CMD_SIZE];
if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
"lvconvert --config devices{ignore_suspended_devices=1} "
"--repair --use-policies", device))
return -1;
r = dmeventd_lvm2_run(cmd_str);
if (r != ECMD_PROCESSED)
syslog(LOG_INFO, "Repair of RAID device %s failed.", device);
return (r == ECMD_PROCESSED) ? 0 : -1;
}
static int _process_raid_event(char *params, const char *device)
{
int i, n, failure = 0;
char *p, *a[4];
char *raid_type;
char *num_devices;
char *health_chars;
char *resync_ratio;
/*
* RAID parms: <raid_type> <#raid_disks> \
* <health chars> <resync ratio>
*/
if (!dm_split_words(params, 4, 0, a)) {
syslog(LOG_ERR, "Failed to process status line for %s\n",
device);
return -EINVAL;
}
raid_type = a[0];
num_devices = a[1];
health_chars = a[2];
resync_ratio = a[3];
if (!(n = atoi(num_devices))) {
syslog(LOG_ERR, "Failed to parse number of devices for %s: %s",
device, num_devices);
return -EINVAL;
}
for (i = 0; i < n; i++) {
switch (health_chars[i]) {
case 'A':
/* Device is 'A'live and well */
case 'a':
/* Device is 'a'live, but not yet in-sync */
break;
case 'D':
syslog(LOG_ERR,
"Device #%d of %s array, %s, has failed.",
i, raid_type, device);
failure++;
break;
default:
/* Unhandled character returned from kernel */
break;
}
if (failure)
return run_repair(device);
}
p = strstr(resync_ratio, "/");
if (!p) {
syslog(LOG_ERR, "Failed to parse resync_ratio for %s: %s",
device, resync_ratio);
return -EINVAL;
}
p[0] = '\0';
syslog(LOG_INFO, "%s array, %s, is %s in-sync.",
raid_type, device, strcmp(resync_ratio, p+1) ? "not" : "now");
return 0;
}
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **unused __attribute__((unused)))
{
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
const char *device = dm_task_get_name(dmt);
dmeventd_lvm2_lock();
do {
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, &params);
if (!target_type) {
syslog(LOG_INFO, "%s mapping lost.", device);
continue;
}
if (strcmp(target_type, "raid")) {
syslog(LOG_INFO, "%s has non-raid portion.", device);
continue;
}
if (_process_raid_event(params, device))
syslog(LOG_ERR, "Failed to process event for %s",
device);
} while (next);
dmeventd_lvm2_unlock();
}
int register_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **unused __attribute__((unused)))
{
if (!dmeventd_lvm2_init())
return 0;
syslog(LOG_INFO, "Monitoring RAID device %s for events.", device);
return 1;
}
int unregister_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **unused __attribute__((unused)))
{
syslog(LOG_INFO, "No longer monitoring RAID device %s for events.",
device);
dmeventd_lvm2_exit();
return 1;
}

View File

@ -0,0 +1,3 @@
process_event
register_device
unregister_device

View File

@ -0,0 +1,33 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of the LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_snapshot.c
LIB_SHARED = libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_LVM)
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper-event-lvm2 -ldevmapper
install_lvm2: install_dm_plugin
install: install_lvm2

View File

@ -0,0 +1,283 @@
/*
* Copyright (C) 2007-2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include "lvm-string.h"
#include <sys/wait.h>
#include <syslog.h> /* FIXME Replace syslog with multilog */
/* FIXME Missing openlog? */
/* First warning when snapshot is 80% full. */
#define WARNING_THRESH 80
/* Run a check every 5%. */
#define CHECK_STEP 5
/* Do not bother checking snapshots less than 50% full. */
#define CHECK_MINIMUM 50
#define UMOUNT_COMMAND "/bin/umount"
struct snap_status {
int invalid;
int used;
int max;
};
struct dso_state {
int percent_check;
int known_size;
char cmd_str[1024];
};
/* FIXME possibly reconcile this with target_percent when we gain
access to regular LVM library here. */
static void _parse_snapshot_params(char *params, struct snap_status *status)
{
char *p;
/*
* xx/xx -- fractions used/max
* Invalid -- snapshot invalidated
* Unknown -- status unknown
*/
status->used = status->max = 0;
if (!strncmp(params, "Invalid", 7)) {
status->invalid = 1;
return;
}
/*
* When we return without setting non-zero max, the parent is
* responsible for reporting errors.
*/
if (!strncmp(params, "Unknown", 7))
return;
if (!(p = strstr(params, "/")))
return;
*p = '\0';
p++;
status->used = atoi(params);
status->max = atoi(p);
}
static int _run(const char *cmd, ...)
{
va_list ap;
int argc = 1; /* for argv[0], i.e. cmd */
int i = 0;
const char **argv;
pid_t pid = fork();
int status;
if (pid == 0) { /* child */
va_start(ap, cmd);
while (va_arg(ap, const char *))
++ argc;
va_end(ap);
/* + 1 for the terminating NULL */
argv = alloca(sizeof(const char *) * (argc + 1));
argv[0] = cmd;
va_start(ap, cmd);
while ((argv[++i] = va_arg(ap, const char *)));
va_end(ap);
execvp(cmd, (char **)argv);
syslog(LOG_ERR, "Failed to execute %s: %s.\n", cmd, strerror(errno));
exit(127);
}
if (pid > 0) { /* parent */
if (waitpid(pid, &status, 0) != pid)
return 0; /* waitpid failed */
if (!WIFEXITED(status) || WEXITSTATUS(status))
return 0; /* the child failed */
}
if (pid < 0)
return 0; /* fork failed */
return 1; /* all good */
}
static int _extend(const char *cmd)
{
return dmeventd_lvm2_run(cmd) == ECMD_PROCESSED;
}
static void _umount(const char *device, int major, int minor)
{
FILE *mounts;
char buffer[4096];
char *words[3];
struct stat st;
if (!(mounts = fopen("/proc/mounts", "r"))) {
syslog(LOG_ERR, "Could not read /proc/mounts. Not umounting %s.\n", device);
return;
}
while (!feof(mounts)) {
/* read a line of /proc/mounts */
if (!fgets(buffer, sizeof(buffer), mounts))
break; /* eof, likely */
/* words[0] is the mount point and words[1] is the device path */
if (dm_split_words(buffer, 3, 0, words) < 2)
continue;
/* find the major/minor of the device */
if (stat(words[0], &st))
continue; /* can't stat, skip this one */
if (S_ISBLK(st.st_mode) &&
major(st.st_rdev) == major &&
minor(st.st_rdev) == minor) {
syslog(LOG_ERR, "Unmounting invalid snapshot %s from %s.\n", device, words[1]);
if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
syslog(LOG_ERR, "Failed to umount snapshot %s from %s: %s.\n",
device, words[1], strerror(errno));
}
}
if (fclose(mounts))
syslog(LOG_ERR, "Failed to close /proc/mounts.\n");
}
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **private)
{
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
struct snap_status status = { 0 };
const char *device = dm_task_get_name(dmt);
int percent;
struct dso_state *state = *private;
/* No longer monitoring, waiting for remove */
if (!state->percent_check)
return;
dmeventd_lvm2_lock();
dm_get_next_target(dmt, next, &start, &length, &target_type, &params);
if (!target_type)
goto out;
_parse_snapshot_params(params, &status);
if (status.invalid) {
struct dm_info info;
if (dm_task_get_info(dmt, &info)) {
dmeventd_lvm2_unlock();
_umount(device, info.major, info.minor);
return;
} /* else; too bad, but this is best-effort thing... */
}
/* Snapshot size had changed. Clear the threshold. */
if (state->known_size != status.max) {
state->percent_check = CHECK_MINIMUM;
state->known_size = status.max;
}
/*
* If the snapshot has been invalidated or we failed to parse
* the status string. Report the full status string to syslog.
*/
if (status.invalid || !status.max) {
syslog(LOG_ERR, "Snapshot %s changed state to: %s\n", device, params);
state->percent_check = 0;
goto out;
}
percent = 100 * status.used / status.max;
if (percent >= state->percent_check) {
/* Usage has raised more than CHECK_STEP since the last
time. Run actions. */
state->percent_check = (percent / CHECK_STEP) * CHECK_STEP + CHECK_STEP;
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
syslog(LOG_WARNING, "Snapshot %s is now %i%% full.\n", device, percent);
/* Try to extend the snapshot, in accord with user-set policies */
if (!_extend(state->cmd_str))
syslog(LOG_ERR, "Failed to extend snapshot %s.\n", device);
}
out:
dmeventd_lvm2_unlock();
}
int register_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **private)
{
struct dso_state *state;
if (!dmeventd_lvm2_init())
goto out;
if (!(state = dm_zalloc(sizeof(*state))))
goto bad;
if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(),
state->cmd_str, sizeof(state->cmd_str),
"lvextend --use-policies", device))
goto bad;
state->percent_check = CHECK_MINIMUM;
state->known_size = 0;
*private = state;
syslog(LOG_INFO, "Monitoring snapshot %s\n", device);
return 1;
bad:
dm_free(state);
dmeventd_lvm2_exit();
out:
syslog(LOG_ERR, "Failed to monitor snapshot %s.\n", device);
return 0;
}
int unregister_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **private)
{
struct dso_state *state = *private;
syslog(LOG_INFO, "No longer monitoring snapshot %s\n", device);
dm_free(state);
dmeventd_lvm2_exit();
return 1;
}

View File

@ -0,0 +1,3 @@
process_event
register_device
unregister_device

View File

@ -0,0 +1,36 @@
#
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
INCLUDES += -I$(top_srcdir)/tools -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/tools -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_thin.c
LIB_NAME = libdevmapper-event-lvm2thin
LIB_SHARED = $(LIB_NAME).$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_LVM)
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper-event-lvm2 -ldevmapper
install_lvm2: install_dm_plugin
install: install_lvm2

View File

@ -0,0 +1,288 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include "lvm-string.h"
#include <sys/wait.h>
#include <syslog.h> /* FIXME Replace syslog with multilog */
/* FIXME Missing openlog? */
/* First warning when thin is 80% full. */
#define WARNING_THRESH 80
/* Run a check every 5%. */
#define CHECK_STEP 5
/* Do not bother checking thins less than 50% full. */
#define CHECK_MINIMUM 50
#define UMOUNT_COMMAND "/bin/umount"
#define THIN_DEBUG 0
struct dso_state {
struct dm_pool *mem;
int metadata_percent_check;
int data_percent_check;
uint64_t known_metadata_size;
uint64_t known_data_size;
char cmd_str[1024];
};
static int _extend(struct dso_state *state)
{
#if THIN_DEBUG
syslog(LOG_INFO, "dmeventd executes: %s.\n", state->cmd_str);
#endif
return (dmeventd_lvm2_run(state->cmd_str) == ECMD_PROCESSED);
}
#if 0
static int _run(const char *cmd, ...)
{
va_list ap;
int argc = 1; /* for argv[0], i.e. cmd */
int i = 0;
const char **argv;
pid_t pid = fork();
int status;
if (pid == 0) { /* child */
va_start(ap, cmd);
while (va_arg(ap, const char *))
++argc;
va_end(ap);
/* + 1 for the terminating NULL */
argv = alloca(sizeof(const char *) * (argc + 1));
argv[0] = cmd;
va_start(ap, cmd);
while ((argv[++i] = va_arg(ap, const char *)));
va_end(ap);
execvp(cmd, (char **)argv);
syslog(LOG_ERR, "Failed to execute %s: %s.\n", cmd, strerror(errno));
exit(127);
}
if (pid > 0) { /* parent */
if (waitpid(pid, &status, 0) != pid)
return 0; /* waitpid failed */
if (!WIFEXITED(status) || WEXITSTATUS(status))
return 0; /* the child failed */
}
if (pid < 0)
return 0; /* fork failed */
return 1; /* all good */
}
/* FIXME: all thin pool users needs to be here */
static void _umount(const char *device, int major, int minor)
{
FILE *mounts;
char buffer[4096];
char *words[3];
struct stat st;
if (!(mounts = fopen("/proc/mounts", "r"))) {
syslog(LOG_ERR, "Could not read /proc/mounts. Not umounting %s.\n", device);
return;
}
while (!feof(mounts)) {
/* read a line of /proc/mounts */
if (!fgets(buffer, sizeof(buffer), mounts))
break; /* eof, likely */
/* words[0] is the mount point and words[1] is the device path */
dm_split_words(buffer, 3, 0, words);
/* find the major/minor of the device */
if (stat(words[0], &st))
continue; /* can't stat, skip this one */
if (S_ISBLK(st.st_mode) &&
(int) major(st.st_rdev) == major &&
(int) minor(st.st_rdev) == minor) {
syslog(LOG_ERR, "Unmounting invalid thin %s from %s.\n", device, words[1]);
if (!_run(UMOUNT_COMMAND, "-fl", words[1], NULL))
syslog(LOG_ERR, "Failed to umount thin %s from %s: %s.\n",
device, words[1], strerror(errno));
}
}
if (fclose(mounts))
syslog(LOG_ERR, "Failed to close /proc/mounts.\n");
}
#endif
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **private)
{
const char *device = dm_task_get_name(dmt);
int percent;
struct dso_state *state = *private;
struct dm_status_thin_pool *tps = NULL;
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
#if 0
/* No longer monitoring, waiting for remove */
if (!state->meta_percent_check && !state->data_percent_check)
return;
#endif
dmeventd_lvm2_lock();
dm_get_next_target(dmt, next, &start, &length, &target_type, &params);
if (!target_type || (strcmp(target_type, "thin-pool") != 0)) {
syslog(LOG_ERR, "Invalid target type.\n");
goto out;
}
if (!dm_get_status_thin_pool(state->mem, params, &tps)) {
syslog(LOG_ERR, "Failed to parse status.\n");
#if 0
/* FIXME hmm what we should do? */
struct dm_info info;
if (dm_task_get_info(dmt, &info)) {
dmeventd_lvm2_unlock();
_umount(device, info.major, info.minor);
} /* else; too bad, but this is best-effort thing... */
#endif
goto out;
}
#if THIN_DEBUG
syslog(LOG_INFO, "%p: Got status %" PRIu64 " / %" PRIu64
" %" PRIu64 " / %" PRIu64 ".\n", state,
tps->used_meta_blocks, tps->total_meta_blocks,
tps->used_data_blocks, tps->total_data_blocks);
#endif
/* Thin pool size had changed. Clear the threshold. */
if (state->known_metadata_size != tps->total_metadata_blocks) {
state->metadata_percent_check = CHECK_MINIMUM;
state->known_metadata_size = tps->total_metadata_blocks;
}
if (state->known_data_size != tps->total_data_blocks) {
state->data_percent_check = CHECK_MINIMUM;
state->known_data_size = tps->total_data_blocks;
}
percent = 100 * tps->used_metadata_blocks / tps->total_metadata_blocks;
if (percent >= state->metadata_percent_check) {
/*
* Usage has raised more than CHECK_STEP since the last
* time. Run actions.
*/
state->metadata_percent_check = (percent / CHECK_STEP) * CHECK_STEP + CHECK_STEP;
/* FIXME: extension of metadata needs to be written! */
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
syslog(LOG_WARNING, "Thin metadata %s is now %i%% full.\n",
device, percent);
/* Try to extend the metadata, in accord with user-set policies */
if (!_extend(state))
syslog(LOG_ERR, "Failed to extend thin metadata %s.\n",
device);
/* FIXME: hmm READ-ONLY switch should happen in error path */
}
percent = 100 * tps->used_data_blocks / tps->total_data_blocks;
if (percent >= state->data_percent_check) {
/*
* Usage has raised more than CHECK_STEP since
* the last time. Run actions.
*/
state->data_percent_check = (percent / CHECK_STEP) * CHECK_STEP + CHECK_STEP;
if (percent >= WARNING_THRESH) /* Print a warning to syslog. */
syslog(LOG_WARNING, "Thin %s is now %i%% full.\n", device, percent);
/* Try to extend the thin data, in accord with user-set policies */
if (!_extend(state))
syslog(LOG_ERR, "Failed to extend thin %s.\n", device);
/* FIXME: hmm READ-ONLY switch should happen in error path */
}
out:
if (tps)
dm_pool_free(state->mem, tps);
dmeventd_lvm2_unlock();
}
int register_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **private)
{
struct dm_pool *statemem = NULL;
struct dso_state *state;
if (!dmeventd_lvm2_init())
goto bad;
if (!(statemem = dm_pool_create("thin_pool_state", 2048)) ||
!(state = dm_pool_zalloc(statemem, sizeof(*state))) ||
!dmeventd_lvm2_command(statemem, state->cmd_str,
sizeof(state->cmd_str),
"lvextend --use-policies",
device)) {
if (statemem)
dm_pool_destroy(statemem);
dmeventd_lvm2_exit();
goto bad;
}
state->mem = statemem;
state->metadata_percent_check = CHECK_MINIMUM;
state->data_percent_check = CHECK_MINIMUM;
*private = state;
syslog(LOG_INFO, "Monitoring thin %s.\n", device);
return 1;
bad:
syslog(LOG_ERR, "Failed to monitor thin %s.\n", device);
return 0;
}
int unregister_device(const char *device,
const char *uuid __attribute__((unused)),
int major __attribute__((unused)),
int minor __attribute__((unused)),
void **private)
{
struct dso_state *state = *private;
syslog(LOG_INFO, "No longer monitoring thin %s.\n", device);
dm_pool_destroy(state->mem);
dmeventd_lvm2_exit();
return 1;
}

View File

@ -0,0 +1,53 @@
# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
#
# This file is part of the device-mapper userspace tools.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License v.2.1.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SOURCES = lvmetad-core.c
SOURCES2 = testclient.c
TARGETS = lvmetad lvmetad-testclient
.PHONY: install_lvmetad
INCLUDES += -I$(top_srcdir)/daemons/common
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
CFLOW_TARGET = lvmetad
include $(top_builddir)/make.tmpl
LIBS += -ldevmapper -ldaemon $(PTHREAD_LIBS)
lvmetad: lvmetad-core.o
$(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/daemons/common -o $@ lvmetad-core.o \
$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
# TODO: No idea. No idea how to test either.
#ifneq ("$(CFLOW_CMD)", "")
#CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
#-include $(top_builddir)/libdm/libdevmapper.cflow
#-include $(top_builddir)/lib/liblvm-internal.cflow
#-include $(top_builddir)/lib/liblvm2cmd.cflow
#-include $(top_builddir)/daemons/dmeventd/$(LIB_NAME).cflow
#-include $(top_builddir)/daemons/dmeventd/plugins/mirror/$(LIB_NAME)-lvm2mirror.cflow
#endif
install_lvmetad: lvmetad
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
install_lvm2: install_lvmetad
install: install_lvm2

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVMETAD_CLIENT_H
#define _LVM_LVMETAD_CLIENT_H
#include "daemon-client.h"
#include "metadata-exported.h"
/* Different types of replies we may get from lvmetad. */
typedef struct {
daemon_reply r;
const char **uuids; /* NULL terminated array */
} lvmetad_uuidlist;
typedef struct {
daemon_reply r;
struct dm_config_tree *cft;
} lvmetad_vg;
static inline daemon_handle lvmetad_open();
static inline void lvmetad_close(daemon_handle h);
/* Get a list of VG UUIDs that match a given VG name. */
lvmetad_uuidlist lvmetad_lookup_vgname(daemon_handle h, const char *name);
/* Get the metadata of a single VG, identified by UUID. */
lvmetad_vg lvmetad_get_vg(daemon_handle h, const char *uuid);
/*
* Add and remove PVs on demand. Udev-driven systems will use this interface
* instead of scanning.
*/
daemon_reply lvmetad_add_pv(daemon_handle h, const char *pv_uuid, const char *mda_content);
daemon_reply lvmetad_remove_pv(daemon_handle h, const char *pv_uuid);
/* Trigger a full disk scan, throwing away all caches. XXX do we eventually want
* this? Probalby not yet, anyway.
* daemon_reply lvmetad_rescan(daemon_handle h);
*/
/*
* Update the version of metadata of a volume group. The VG has to be locked for
* writing for this, and the VG metadata here has to match whatever has been
* written to the disk (under this lock). This initially avoids the requirement
* for lvmetad to write to disk (in later revisions, lvmetad_supersede_vg may
* also do the writing, or we probably add another function to do that).
*/
daemon_reply lvmetad_supersede_vg(daemon_handle h, struct volume_group *vg);
/* Implementation of inline functions */
static inline daemon_handle lvmetad_open(const char *socket)
{
/* TODO configurable */
daemon_info lvmetad_info = {
.path = "lvmetad",
.socket = socket ?: "/var/run/lvm/lvmetad.socket",
.autostart = 1
};
return daemon_open(lvmetad_info);
}
static inline void lvmetad_close(daemon_handle h)
{
return daemon_close(h);
}
#endif

View File

@ -0,0 +1,984 @@
#define _GNU_SOURCE
#define _XOPEN_SOURCE 500 /* pthread */
#include <assert.h>
#include <pthread.h>
#include <malloc.h>
#include <stdint.h>
#include <unistd.h>
#include "configure.h"
#include "libdevmapper.h"
#include "daemon-server.h"
typedef struct {
struct dm_hash_table *pvid_to_pvmeta;
struct dm_hash_table *device_to_pvid; /* shares locks with above */
struct dm_hash_table *vgid_to_metadata;
struct dm_hash_table *vgid_to_vgname;
struct dm_hash_table *vgname_to_vgid;
struct dm_hash_table *pvid_to_vgid;
struct {
struct dm_hash_table *vg;
pthread_mutex_t pvid_to_pvmeta;
pthread_mutex_t vgid_to_metadata;
pthread_mutex_t pvid_to_vgid;
} lock;
} lvmetad_state;
__attribute__ ((format(printf, 1, 2)))
static void debug(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "[D %lu] ", pthread_self());
vfprintf(stderr, fmt, ap);
va_end(ap);
}
static int debug_cft_line(const char *line, void *baton) {
fprintf(stderr, "| %s\n", line);
return 0;
}
static void debug_cft(const char *id, struct dm_config_node *n) {
debug("%s\n", id);
dm_config_write_node(n, &debug_cft_line, NULL);
}
static void lock_pvid_to_pvmeta(lvmetad_state *s) {
pthread_mutex_lock(&s->lock.pvid_to_pvmeta); }
static void unlock_pvid_to_pvmeta(lvmetad_state *s) {
pthread_mutex_unlock(&s->lock.pvid_to_pvmeta); }
static void lock_vgid_to_metadata(lvmetad_state *s) {
pthread_mutex_lock(&s->lock.vgid_to_metadata); }
static void unlock_vgid_to_metadata(lvmetad_state *s) {
pthread_mutex_unlock(&s->lock.vgid_to_metadata); }
static void lock_pvid_to_vgid(lvmetad_state *s) {
pthread_mutex_lock(&s->lock.pvid_to_vgid); }
static void unlock_pvid_to_vgid(lvmetad_state *s) {
pthread_mutex_unlock(&s->lock.pvid_to_vgid); }
/*
* TODO: It may be beneficial to clean up the vg lock hash from time to time,
* since if we have many "rogue" requests for nonexistent things, we will keep
* allocating memory that we never release. Not good.
*/
static struct dm_config_tree *lock_vg(lvmetad_state *s, const char *id) {
pthread_mutex_t *vg;
struct dm_config_tree *cft;
lock_vgid_to_metadata(s);
vg = dm_hash_lookup(s->lock.vg, id);
if (!vg) {
pthread_mutexattr_t rec;
pthread_mutexattr_init(&rec);
pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP);
vg = malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(vg, &rec);
dm_hash_insert(s->lock.vg, id, vg);
}
// debug("lock VG %s\n", id);
pthread_mutex_lock(vg);
cft = dm_hash_lookup(s->vgid_to_metadata, id);
unlock_vgid_to_metadata(s);
return cft;
}
static void unlock_vg(lvmetad_state *s, const char *id) {
// debug("unlock VG %s\n", id);
lock_vgid_to_metadata(s); /* someone might be changing the s->lock.vg structure right
* now, so avoid stepping on each other's toes */
pthread_mutex_unlock(dm_hash_lookup(s->lock.vg, id));
unlock_vgid_to_metadata(s);
}
static struct dm_config_node *pvs(struct dm_config_node *vg)
{
struct dm_config_node *pv = dm_config_find_node(vg, "metadata/physical_volumes");
if (pv)
pv = pv->child;
return pv;
}
/*
* TODO: This set_flag function is pretty generic and might make sense in a
* library here or there.
*/
static int set_flag(struct dm_config_tree *cft, struct dm_config_node *parent,
const char *field, const char *flag, int want) {
struct dm_config_value *value = NULL, *pred = NULL;
struct dm_config_node *node = dm_config_find_node(parent->child, field);
struct dm_config_value *new;
if (node)
value = node->v;
while (value && value->type != DM_CFG_EMPTY_ARRAY && strcmp(value->v.str, flag)) {
pred = value;
value = value->next;
}
if (value && want)
return 1;
if (!value && !want)
return 1;
if (value && !want) {
if (pred) {
pred->next = value->next;
} else if (value == node->v && value->next) {
node->v = value->next;
} else {
node->v->type = DM_CFG_EMPTY_ARRAY;
}
}
if (!value && want) {
if (!node) {
node = dm_config_create_node(cft, field);
node->sib = parent->child;
node->v = dm_config_create_value(cft);
node->v->type = DM_CFG_EMPTY_ARRAY;
node->parent = parent;
parent->child = node;
}
if (!(new = dm_config_create_value(cft))) {
/* FIXME error reporting */
return 0;
}
new->type = DM_CFG_STRING;
new->v.str = flag;
new->next = node->v;
node->v = new;
}
return 1;
}
static struct dm_config_node *make_config_node(struct dm_config_tree *cft,
const char *key,
struct dm_config_node *parent,
struct dm_config_node *pre_sib)
{
struct dm_config_node *cn = dm_config_create_node(cft, key);
cn->parent = parent;
cn->sib = NULL;
cn->v = NULL;
cn->child = NULL;
if (parent && parent->child && !pre_sib) { /* find the last one */
pre_sib = parent->child;
while (pre_sib && pre_sib->sib) pre_sib = pre_sib->sib;
}
if (parent && !parent->child)
parent->child = cn;
if (pre_sib)
pre_sib->sib = cn;
return cn;
}
static struct dm_config_node *make_text_node(struct dm_config_tree *cft,
const char *key,
const char *value,
struct dm_config_node *parent,
struct dm_config_node *pre_sib)
{
struct dm_config_node *cn = make_config_node(cft, key, parent, pre_sib);
cn->v = dm_config_create_value(cft);
cn->v->type = DM_CFG_STRING;
cn->v->v.str = value;
return cn;
}
static struct dm_config_node *make_int_node(struct dm_config_tree *cft,
const char *key,
int64_t value,
struct dm_config_node *parent,
struct dm_config_node *pre_sib)
{
struct dm_config_node *cn = make_config_node(cft, key, parent, pre_sib);
cn->v = dm_config_create_value(cft);
cn->v->type = DM_CFG_INT;
cn->v->v.i = value;
return cn;
}
static void filter_metadata(struct dm_config_node *vg) {
struct dm_config_node *pv = pvs(vg);
while (pv) {
struct dm_config_node *item = pv->child;
while (item) {
/* Remove the advisory device nodes. */
if (item->sib && !strcmp(item->sib->key, "device"))
item->sib = item->sib->sib;
item = item->sib;
}
pv = pv->sib;
}
vg->sib = NULL; /* Drop any trailing garbage. */
}
/* Either the "big" vgs lock, or a per-vg lock needs to be held before entering
* this function. */
static int update_pv_status(lvmetad_state *s,
struct dm_config_tree *cft,
struct dm_config_node *vg, int act)
{
struct dm_config_node *pv;
int complete = 1;
lock_pvid_to_pvmeta(s);
pv = pvs(vg);
while (pv) {
const char *uuid = dm_config_find_str(pv->child, "id", NULL);
struct dm_config_tree *pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, uuid);
if (act) {
set_flag(cft, pv, "status", "MISSING", !pvmeta);
if (pvmeta) {
// debug_cft("PV META", pvmeta->root);
make_int_node(cft, "device",
dm_config_find_int(pvmeta->root, "pvmeta/device", 0),
pv, NULL);
}
}
if (!pvmeta) {
complete = 0;
if (!act) { /* optimisation */
unlock_pvid_to_pvmeta(s);
return complete;
}
}
pv = pv->sib;
}
unlock_pvid_to_pvmeta(s);
return complete;
}
static struct dm_config_node *make_pv_node(lvmetad_state *s, const char *pvid,
struct dm_config_tree *cft,
struct dm_config_node *parent,
struct dm_config_node *pre_sib)
{
struct dm_config_tree *pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
const char *vgid = dm_hash_lookup(s->pvid_to_vgid, pvid), *vgname = NULL;
if (!pvmeta)
return NULL;
if (vgid) {
lock_vgid_to_metadata(s); // XXX
vgname = dm_hash_lookup(s->vgid_to_vgname, vgid);
unlock_vgid_to_metadata(s);
}
/* Nick the pvmeta config tree. */
struct dm_config_node *pv = dm_config_clone_node(cft, pvmeta->root, 0);
if (pre_sib)
pre_sib->sib = pv;
if (parent && !parent->child)
parent->child = pv;
pv->parent = parent;
/* Add the "variable" bits to it. */
struct dm_config_node *cn = NULL;
if (vgid && strcmp(vgid, "#orphan"))
cn = make_text_node(cft, "vgid", vgid, pv, cn);
if (vgname)
cn = make_text_node(cft, "vgname", vgname, pv, cn);
return pv;
}
static response pv_list(lvmetad_state *s, request r)
{
struct dm_config_node *cn = NULL, *cn_pvs;
response res = { .buffer = NULL };
res.cft = dm_config_create();
/* The response field */
res.cft->root = make_text_node(res.cft, "response", "OK", NULL, NULL);
cn_pvs = make_config_node(res.cft, "physical_volumes", NULL, res.cft->root);
lock_pvid_to_pvmeta(s);
struct dm_hash_node *n = dm_hash_get_first(s->pvid_to_pvmeta);
while (n) {
const char *id = dm_hash_get_key(s->pvid_to_pvmeta, n);
cn = make_pv_node(s, id, res.cft, cn_pvs, cn);
n = dm_hash_get_next(s->pvid_to_pvmeta, n);
}
unlock_pvid_to_pvmeta(s);
// debug_cft("PV LIST", res.cft->root);
return res;
}
static response pv_lookup(lvmetad_state *s, request r)
{
const char *pvid = daemon_request_str(r, "uuid", NULL);
if (!pvid)
return daemon_reply_simple("failed", "reason = %s", "need PVID", NULL);
response res = { .buffer = NULL };
res.cft = dm_config_create();
res.cft->root = make_text_node(res.cft, "response", "OK", NULL, NULL);
struct dm_config_node *pv;
lock_pvid_to_pvmeta(s);
pv = make_pv_node(s, pvid, res.cft, NULL, res.cft->root);
if (!pv) {
unlock_pvid_to_pvmeta(s);
return daemon_reply_simple("failed", "reason = %s", "PV not found", NULL);
}
pv->key = "physical_volume";
unlock_pvid_to_pvmeta(s);
// debug_cft("PV LOOKUP", res.cft->root);
return res;
}
static response vg_list(lvmetad_state *s, request r)
{
struct dm_config_node *cn, *cn_vgs, *cn_last = NULL;
response res = { .buffer = NULL };
res.cft = dm_config_create();
/* The response field */
res.cft->root = cn = dm_config_create_node(res.cft, "response");
cn->parent = res.cft->root;
cn->v = dm_config_create_value(res.cft);
cn->v->type = DM_CFG_STRING;
cn->v->v.str = "OK";
cn_vgs = cn = cn->sib = dm_config_create_node(res.cft, "volume_groups");
cn->parent = res.cft->root;
cn->v = NULL;
cn->child = NULL;
lock_vgid_to_metadata(s);
struct dm_hash_node *n = dm_hash_get_first(s->vgid_to_vgname);
while (n) {
const char *id = dm_hash_get_key(s->vgid_to_vgname, n),
*name = dm_hash_get_data(s->vgid_to_vgname, n);
cn = dm_config_create_node(res.cft, id);
if (cn_last)
cn_last->sib = cn;
cn->parent = cn_vgs;
cn->sib = NULL;
cn->v = NULL;
cn->child = dm_config_create_node(res.cft, "name");
cn->child->parent = cn;
cn->child->sib = 0;
cn->child->v = dm_config_create_value(res.cft);
cn->child->v->type = DM_CFG_STRING;
cn->child->v->v.str = name;
if (!cn_vgs->child)
cn_vgs->child = cn;
cn_last = cn;
n = dm_hash_get_next(s->vgid_to_vgname, n);
}
unlock_vgid_to_metadata(s);
return res;
}
static response vg_lookup(lvmetad_state *s, request r)
{
struct dm_config_tree *cft;
struct dm_config_node *metadata, *n;
response res = { .buffer = NULL };
const char *uuid = daemon_request_str(r, "uuid", NULL),
*name = daemon_request_str(r, "name", NULL);
debug("vg_lookup: uuid = %s, name = %s\n", uuid, name);
if (!uuid || !name) {
lock_vgid_to_metadata(s);
if (name && !uuid)
uuid = dm_hash_lookup(s->vgname_to_vgid, (void *)name);
if (uuid && !name)
name = dm_hash_lookup(s->vgid_to_vgname, (void *)uuid);
unlock_vgid_to_metadata(s);
}
debug("vg_lookup: updated uuid = %s, name = %s\n", uuid, name);
if (!uuid)
return daemon_reply_simple("failed", "reason = %s", "VG not found", NULL);
cft = lock_vg(s, uuid);
if (!cft || !cft->root) {
unlock_vg(s, uuid);
return daemon_reply_simple("failed", "reason = %s", "UUID not found", NULL);
}
metadata = cft->root;
res.cft = dm_config_create();
/* The response field */
res.cft->root = n = dm_config_create_node(res.cft, "response");
n->parent = res.cft->root;
n->v->type = DM_CFG_STRING;
n->v->v.str = "OK";
n = n->sib = dm_config_create_node(res.cft, "name");
n->parent = res.cft->root;
n->v->type = DM_CFG_STRING;
n->v->v.str = name;
/* The metadata section */
n = n->sib = dm_config_clone_node(res.cft, metadata, 1);
n->parent = res.cft->root;
res.error = 0;
unlock_vg(s, uuid);
update_pv_status(s, res.cft, n, 1); /* FIXME report errors */
// debug_cft("METADATA", n);
return res;
}
static int compare_value(struct dm_config_value *a, struct dm_config_value *b)
{
int r = 0;
if (a->type > b->type)
return 1;
if (a->type < b->type)
return -1;
switch (a->type) {
case DM_CFG_STRING: r = strcmp(a->v.str, b->v.str); break;
case DM_CFG_FLOAT: r = (a->v.f == b->v.f) ? 0 : (a->v.f > b->v.f) ? 1 : -1; break;
case DM_CFG_INT: r = (a->v.i == b->v.i) ? 0 : (a->v.i > b->v.i) ? 1 : -1; break;
case DM_CFG_EMPTY_ARRAY: return 0;
}
if (r == 0 && a->next && b->next)
r = compare_value(a->next, b->next);
return r;
}
static int compare_config(struct dm_config_node *a, struct dm_config_node *b)
{
int result = 0;
if (a->v && b->v)
result = compare_value(a->v, b->v);
if (a->v && !b->v)
result = 1;
if (!a->v && b->v)
result = -1;
if (a->child && b->child)
result = compare_config(a->child, b->child);
if (result) {
debug("config inequality at %s / %s\n", a->key, b->key);
return result;
}
if (a->sib && b->sib)
result = compare_config(a->sib, b->sib);
if (a->sib && !b->sib)
result = 1;
if (!a->sib && b->sib)
result = -1;
return result;
}
static int vg_remove_if_missing(lvmetad_state *s, const char *vgid);
/* You need to be holding the pvid_to_vgid lock already to call this. */
static int update_pvid_to_vgid(lvmetad_state *s, struct dm_config_tree *vg,
const char *vgid, int nuke_empty)
{
struct dm_config_node *pv = pvs(vg->root);
struct dm_hash_table *to_check = dm_hash_create(32);
if (!vgid)
return 0;
while (pv) {
const char *pvid = dm_config_find_str(pv->child, "id", NULL);
const char *vgid_old = dm_hash_lookup(s->pvid_to_vgid, pvid);
if (vgid_old && nuke_empty)
dm_hash_insert(to_check, vgid_old, (void*) 1);
dm_hash_insert(s->pvid_to_vgid, pvid, (void *) vgid);
debug("remap PV %s to VG %s\n", pvid, vgid);
pv = pv->sib;
}
struct dm_hash_node *n = dm_hash_get_first(to_check);
while (n) {
const char *check_vgid = dm_hash_get_key(to_check, n);
lock_vg(s, check_vgid);
vg_remove_if_missing(s, check_vgid);
unlock_vg(s, check_vgid);
n = dm_hash_get_next(to_check, n);
}
dm_hash_destroy(to_check);
return 1;
}
/* A pvid map lock needs to be held if update_pvids = 1. */
static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids)
{
struct dm_config_tree *old;
const char *oldname;
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, vgid);
oldname = dm_hash_lookup(s->vgid_to_vgname, vgid);
unlock_vgid_to_metadata(s);
if (!old)
return 0;
if (update_pvids)
update_pvid_to_vgid(s, old, "#orphan", 0);
/* need to update what we have since we found a newer version */
dm_hash_remove(s->vgid_to_metadata, vgid);
dm_hash_remove(s->vgid_to_vgname, vgid);
dm_hash_remove(s->vgname_to_vgid, oldname);
dm_config_destroy(old);
return 1;
}
/* The VG must be locked. */
static int vg_remove_if_missing(lvmetad_state *s, const char *vgid)
{
if (!vgid)
return 0;
struct dm_config_tree *vg = dm_hash_lookup(s->vgid_to_metadata, vgid);
if (!vg)
return 1;
struct dm_config_node *pv = pvs(vg->root);
int missing = 1;
lock_pvid_to_pvmeta(s);
while (pv) {
const char *pvid = dm_config_find_str(pv->child, "id", NULL);
const char *vgid_check = dm_hash_lookup(s->pvid_to_vgid, pvid);
if (dm_hash_lookup(s->pvid_to_pvmeta, pvid) &&
vgid_check && !strcmp(vgid, vgid_check))
missing = 0; /* at least one PV is around */
pv = pv->sib;
}
if (missing) {
debug("nuking VG %s\n", vgid);
remove_metadata(s, vgid, 0);
}
unlock_pvid_to_pvmeta(s);
return 1;
}
/* No locks need to be held. The pointers are never used outside of the scope of
* this function, so they can be safely destroyed after update_metadata returns
* (anything that might have been retained is copied). */
static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid,
struct dm_config_node *metadata)
{
struct dm_config_tree *cft;
struct dm_config_tree *old;
int retval = 0;
int seq;
int haveseq = -1;
const char *oldname = NULL;
const char *vgid;
lock_vgid_to_metadata(s);
old = dm_hash_lookup(s->vgid_to_metadata, _vgid);
lock_vg(s, _vgid);
unlock_vgid_to_metadata(s);
seq = dm_config_find_int(metadata, "metadata/seqno", -1);
if (old) {
haveseq = dm_config_find_int(old->root, "metadata/seqno", -1);
oldname = dm_hash_lookup(s->vgid_to_vgname, _vgid);
assert(oldname);
}
if (seq < 0)
goto out;
filter_metadata(metadata); /* sanitize */
if (seq == haveseq) {
retval = 1;
if (compare_config(metadata, old->root))
retval = 0;
debug("Not updating metadata for %s at %d (%s)\n", _vgid, haveseq,
retval ? "ok" : "MISMATCH");
if (!retval) {
debug_cft("OLD: ", old->root);
debug_cft("NEW: ", metadata);
}
goto out;
}
if (seq < haveseq) {
debug("Refusing to update metadata for %s at %d to %d\n", _vgid, haveseq, seq);
/* TODO: notify the client that their metadata is out of date? */
retval = 1;
goto out;
}
cft = dm_config_create();
cft->root = dm_config_clone_node(cft, metadata, 0);
vgid = dm_config_find_str(cft->root, "metadata/id", NULL);
if (!vgid || !name) {
debug("Name '%s' or uuid '%s' missing!\n", name, vgid);
goto out;
}
lock_pvid_to_vgid(s);
if (haveseq >= 0 && haveseq < seq) {
debug("Updating metadata for %s at %d to %d\n", _vgid, haveseq, seq);
/* temporarily orphan all of our PVs */
remove_metadata(s, vgid, 1);
}
// debug_cft("METADATA", metadata);
lock_vgid_to_metadata(s);
dm_hash_insert(s->vgid_to_metadata, vgid, cft);
debug("Mapping %s to %s\n", vgid, name);
dm_hash_insert(s->vgid_to_vgname, vgid, dm_pool_strdup(dm_config_memory(cft), name));
dm_hash_insert(s->vgname_to_vgid, name, (void *)vgid);
unlock_vgid_to_metadata(s);
update_pvid_to_vgid(s, cft, vgid, 1);
unlock_pvid_to_vgid(s);
retval = 1;
out:
unlock_vg(s, _vgid);
return retval;
}
static response pv_gone(lvmetad_state *s, request r)
{
int found = 0;
const char *pvid = daemon_request_str(r, "uuid", NULL);
int64_t device = daemon_request_int(r, "device", 0);
debug("pv_gone: %s / %lld\n", pvid, device);
debug_cft("PV_GONE", r.cft->root);
lock_pvid_to_pvmeta(s);
if (!pvid && device > 0)
pvid = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
if (!pvid) {
unlock_pvid_to_pvmeta(s);
return daemon_reply_simple("failed", "reason = %s", "device not in cache", NULL);
}
debug("pv_gone (updated): %s / %lld\n", pvid, device);
struct dm_config_tree *pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
dm_hash_remove(s->pvid_to_pvmeta, pvid);
vg_remove_if_missing(s, dm_hash_lookup(s->pvid_to_vgid, pvid));
unlock_pvid_to_pvmeta(s);
if (pvmeta) {
dm_config_destroy(pvmeta);
return daemon_reply_simple("OK", NULL);
} else
return daemon_reply_simple("failed", "reason = %s", "PVID does not exist", NULL);
}
static response pv_found(lvmetad_state *s, request r)
{
struct dm_config_node *metadata = dm_config_find_node(r.cft->root, "metadata");
const char *pvid = daemon_request_str(r, "pvmeta/id", NULL);
const char *vgname = daemon_request_str(r, "vgname", NULL);
const char *vgid = daemon_request_str(r, "metadata/id", NULL);
struct dm_config_node *pvmeta = dm_config_find_node(r.cft->root, "pvmeta");
uint64_t device;
int complete = 0, orphan = 0;
// debug_cft("INCOMING PV", r.cft->root);
if (!pvid)
return daemon_reply_simple("failed", "reason = %s", "need PV UUID", NULL);
if (!pvmeta)
return daemon_reply_simple("failed", "reason = %s", "need PV metadata", NULL);
if (!dm_config_get_uint64(pvmeta, "pvmeta/device", &device))
return daemon_reply_simple("failed", "reason = %s", "need PV device number", NULL);
debug("pv_found %s, vgid = %s, device = %lld\n", pvid, vgid, device);
lock_pvid_to_pvmeta(s);
{
struct dm_config_tree *cft = dm_config_create();
cft->root = dm_config_clone_node(cft, pvmeta, 0);
const char *pvid_dup = dm_config_find_str(cft->root, "pvmeta/id", NULL);
dm_hash_insert(s->pvid_to_pvmeta, pvid, cft);
dm_hash_insert_binary(s->device_to_pvid, &device, sizeof(device), (void*)pvid_dup);
}
unlock_pvid_to_pvmeta(s);
if (metadata) {
if (!vgid)
return daemon_reply_simple("failed", "reason = %s", "need VG UUID", NULL);
debug("obtained vgid = %s, vgname = %s", vgid, vgname);
if (!vgname)
return daemon_reply_simple("failed", "reason = %s", "need VG name", NULL);
if (daemon_request_int(r, "metadata/seqno", -1) < 0)
return daemon_reply_simple("failed", "reason = %s", "need VG seqno", NULL);
if (!update_metadata(s, vgname, vgid, metadata))
return daemon_reply_simple("failed", "reason = %s",
"metadata update failed", NULL);
} else {
lock_pvid_to_vgid(s);
vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
unlock_pvid_to_vgid(s);
}
if (vgid) {
struct dm_config_tree *cft = lock_vg(s, vgid);
if (cft) {
complete = update_pv_status(s, cft, cft->root, 0);
} else if (!strcmp(vgid, "#orphan")) {
orphan = 1;
} else {
unlock_vg(s, vgid);
return daemon_reply_simple("failed", "reason = %s",
"internal treason!", NULL);
}
unlock_vg(s, vgid);
}
return daemon_reply_simple("OK",
"status = %s", orphan ? "orphan" :
(complete ? "complete" : "partial"),
"vgid = %s", vgid ? vgid : "#orphan",
NULL);
}
static response vg_update(lvmetad_state *s, request r)
{
struct dm_config_node *metadata = dm_config_find_node(r.cft->root, "metadata");
const char *vgid = daemon_request_str(r, "metadata/id", NULL);
const char *vgname = daemon_request_str(r, "vgname", NULL);
if (metadata) {
if (!vgid)
return daemon_reply_simple("failed", "reason = %s", "need VG UUID", NULL);
if (!vgname)
return daemon_reply_simple("failed", "reason = %s", "need VG name", NULL);
if (daemon_request_int(r, "metadata/seqno", -1) < 0)
return daemon_reply_simple("failed", "reason = %s", "need VG seqno", NULL);
/* TODO defer metadata update here; add a separate vg_commit
* call; if client does not commit, die */
if (!update_metadata(s, vgname, vgid, metadata))
return daemon_reply_simple("failed", "reason = %s",
"metadata update failed", NULL);
}
return daemon_reply_simple("OK", NULL);
}
static response vg_remove(lvmetad_state *s, request r)
{
const char *vgid = daemon_request_str(r, "uuid", NULL);
if (!vgid)
return daemon_reply_simple("failed", "reason = %s", "need VG UUID", NULL);
fprintf(stderr, "vg_remove: %s\n", vgid);
lock_pvid_to_vgid(s);
remove_metadata(s, vgid, 1);
unlock_pvid_to_vgid(s);
return daemon_reply_simple("OK", NULL);
}
static response handler(daemon_state s, client_handle h, request r)
{
lvmetad_state *state = s.private;
const char *rq = daemon_request_str(r, "request", "NONE");
/*
* TODO Add a stats call, with transaction count/rate, time since last
* update &c.
*/
if (!strcmp(rq, "pv_found"))
return pv_found(state, r);
if (!strcmp(rq, "pv_gone"))
return pv_gone(state, r);
if (!strcmp(rq, "pv_lookup"))
return pv_lookup(state, r);
if (!strcmp(rq, "vg_update"))
return vg_update(state, r);
if (!strcmp(rq, "vg_remove"))
return vg_remove(state, r);
if (!strcmp(rq, "vg_lookup"))
return vg_lookup(state, r);
if (!strcmp(rq, "pv_list")) {
return pv_list(state, r);
}
if (!strcmp(rq, "vg_list"))
return vg_list(state, r);
return daemon_reply_simple("failed", "reason = %s", "no such request", NULL);
}
static int init(daemon_state *s)
{
pthread_mutexattr_t rec;
lvmetad_state *ls = s->private;
ls->pvid_to_pvmeta = dm_hash_create(32);
ls->device_to_pvid = dm_hash_create(32);
ls->vgid_to_metadata = dm_hash_create(32);
ls->vgid_to_vgname = dm_hash_create(32);
ls->pvid_to_vgid = dm_hash_create(32);
ls->vgname_to_vgid = dm_hash_create(32);
ls->lock.vg = dm_hash_create(32);
pthread_mutexattr_init(&rec);
pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&ls->lock.pvid_to_pvmeta, &rec);
pthread_mutex_init(&ls->lock.vgid_to_metadata, &rec);
pthread_mutex_init(&ls->lock.pvid_to_vgid, NULL);
debug("initialised state: vgid_to_metadata = %p\n", ls->vgid_to_metadata);
if (!ls->pvid_to_vgid || !ls->vgid_to_metadata)
return 0;
/* if (ls->initial_registrations)
_process_initial_registrations(ds->initial_registrations); */
return 1;
}
static int fini(daemon_state *s)
{
lvmetad_state *ls = s->private;
struct dm_hash_node *n = dm_hash_get_first(ls->vgid_to_metadata);
debug("fini\n");
while (n) {
dm_config_destroy(dm_hash_get_data(ls->vgid_to_metadata, n));
n = dm_hash_get_next(ls->vgid_to_metadata, n);
}
n = dm_hash_get_first(ls->lock.vg);
while (n) {
pthread_mutex_destroy(dm_hash_get_data(ls->lock.vg, n));
free(dm_hash_get_data(ls->lock.vg, n));
n = dm_hash_get_next(ls->lock.vg, n);
}
dm_hash_destroy(ls->lock.vg);
dm_hash_destroy(ls->pvid_to_pvmeta);
dm_hash_destroy(ls->device_to_pvid);
dm_hash_destroy(ls->vgid_to_metadata);
dm_hash_destroy(ls->pvid_to_vgid);
return 1;
}
static void usage(char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
"%s [-V] [-h] [-d] [-d] [-d] [-f]\n\n"
" -V Show version of lvmetad\n"
" -h Show this help information\n"
" -d Log debug messages to syslog (-d, -dd, -ddd)\n"
" -R Replace a running lvmetad instance, loading its data\n"
" -f Don't fork, run in the foreground\n\n", prog);
}
int main(int argc, char *argv[])
{
signed char opt;
daemon_state s = { .private = NULL };
lvmetad_state ls;
int _restart = 0;
s.name = "lvmetad";
s.private = &ls;
s.daemon_init = init;
s.daemon_fini = fini;
s.handler = handler;
s.socket_path = getenv("LVM_LVMETAD_SOCKET");
if (!s.socket_path)
s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
s.pidfile = DEFAULT_RUN_DIR "/lvmetad.pid";
s.log_level = 0;
// use getopt_long
while ((opt = getopt(argc, argv, "?fhVdRs:")) != EOF) {
switch (opt) {
case 'h':
usage(argv[0], stdout);
exit(0);
case '?':
usage(argv[0], stderr);
exit(0);
case 'R':
_restart++;
break;
case 'f':
s.foreground = 1;
break;
case 'd':
s.log_level++;
break;
case 's': // --socket
s.socket_path = optarg;
break;
case 'V':
printf("lvmetad version 0\n");
exit(1);
}
}
daemon_start(s);
return 0;
}

16
daemons/lvmetad/test.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
export LD_LIBRARY_PATH="$1"
test -n "$2" && {
rm -f /var/run/lvmetad.{socket,pid}
chmod +rx lvmetad
valgrind ./lvmetad -f &
PID=$!
sleep 1
./testclient
kill $PID
exit 0
}
sudo ./test.sh "$1" .

View File

@ -0,0 +1,127 @@
#include "lvmetad-client.h"
#include "label.h"
#include "lvmcache.h"
#include "metadata.h"
const char *uuid1 = "abcd-efgh";
const char *uuid2 = "bbcd-efgh";
const char *vgid = "yada-yada";
const char *uuid3 = "cbcd-efgh";
const char *metadata2 = "{\n"
"id = \"yada-yada\"\n"
"seqno = 15\n"
"status = [\"READ\", \"WRITE\"]\n"
"flags = []\n"
"extent_size = 8192\n"
"physical_volumes {\n"
" pv0 {\n"
" id = \"abcd-efgh\"\n"
" }\n"
" pv1 {\n"
" id = \"bbcd-efgh\"\n"
" }\n"
" pv2 {\n"
" id = \"cbcd-efgh\"\n"
" }\n"
"}\n"
"}\n";
void _handle_reply(daemon_reply reply) {
const char *repl = daemon_reply_str(reply, "response", NULL);
const char *status = daemon_reply_str(reply, "status", NULL);
const char *vgid = daemon_reply_str(reply, "vgid", NULL);
fprintf(stderr, "[C] REPLY: %s\n", repl);
if (!strcmp(repl, "failed"))
fprintf(stderr, "[C] REASON: %s\n", daemon_reply_str(reply, "reason", "unknown"));
if (vgid)
fprintf(stderr, "[C] VGID: %s\n", vgid);
if (status)
fprintf(stderr, "[C] STATUS: %s\n", status);
daemon_reply_destroy(reply);
}
void _pv_add(daemon_handle h, const char *uuid, const char *metadata)
{
daemon_reply reply = daemon_send_simple(h, "pv_add", "uuid = %s", uuid,
"metadata = %b", metadata,
NULL);
_handle_reply(reply);
}
int scan(daemon_handle h, char *fn) {
struct device *dev = dev_cache_get(fn, NULL);
struct label *label;
if (!label_read(dev, &label, 0)) {
fprintf(stderr, "[C] no label found on %s\n", fn);
return;
}
char uuid[64];
id_write_format(dev->pvid, uuid, 64);
fprintf(stderr, "[C] found PV: %s\n", uuid);
struct lvmcache_info *info = (struct lvmcache_info *) label->info;
struct physical_volume pv = { 0, };
if (!(info->fmt->ops->pv_read(info->fmt, dev_name(dev), &pv, 0))) {
fprintf(stderr, "[C] Failed to read PV %s", dev_name(dev));
return;
}
struct format_instance_ctx fic;
struct format_instance *fid = info->fmt->ops->create_instance(info->fmt, &fic);
struct metadata_area *mda;
struct volume_group *vg = NULL;
dm_list_iterate_items(mda, &info->mdas) {
struct volume_group *this = mda->ops->vg_read(fid, "", mda);
if (this && !vg || this->seqno > vg->seqno)
vg = this;
}
if (vg) {
char *buf = NULL;
/* TODO. This is not entirely correct, since export_vg_to_buffer
* adds trailing garbage to the buffer. We may need to use
* export_vg_to_config_tree and format the buffer ourselves. It
* does, however, work for now, since the garbage is well
* formatted and has no conflicting keys with the rest of the
* request. */
export_vg_to_buffer(vg, &buf);
daemon_reply reply =
daemon_send_simple(h, "pv_add", "uuid = %s", uuid,
"metadata = %b", strchr(buf, '{'),
NULL);
_handle_reply(reply);
}
}
void _dump_vg(daemon_handle h, const char *uuid)
{
daemon_reply reply = daemon_send_simple(h, "vg_by_uuid", "uuid = %s", uuid, NULL);
fprintf(stderr, "[C] reply buffer: %s\n", reply.buffer);
daemon_reply_destroy(reply);
}
int main(int argc, char **argv) {
daemon_handle h = lvmetad_open();
if (argc > 1) {
int i;
struct cmd_context *cmd = create_toolcontext(0, NULL, 0, 0);
for (i = 1; i < argc; ++i) {
const char *uuid = NULL;
scan(h, argv[i]);
}
destroy_toolcontext(cmd);
return 0;
}
_pv_add(h, uuid1, NULL);
_pv_add(h, uuid2, metadata2);
_dump_vg(h, vgid);
_pv_add(h, uuid3, NULL);
daemon_close(h);
return 0;
}

31
doc/Makefile.in Normal file
View File

@ -0,0 +1,31 @@
#
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CONFSRC=example.conf
CONFDEST=lvm.conf
include $(top_builddir)/make.tmpl
install_lvm2: $(CONFSRC)
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \
echo "$(INSTALL_WDATA) -D $< $(confdir)/$(CONFDEST)"; \
$(INSTALL_WDATA) -D $< $(confdir)/$(CONFDEST); \
fi
install: install_lvm2
DISTCLEAN_TARGETS += $(CONFSRC)

View File

@ -1 +0,0 @@
Wow! This is really incredible documentation!

753
doc/example.conf.in Normal file
View File

@ -0,0 +1,753 @@
# This is an example configuration file for the LVM2 system.
# It contains the default settings that would be used if there was no
# @DEFAULT_SYS_DIR@/lvm.conf file.
#
# Refer to 'man lvm.conf' for further information including the file layout.
#
# To put this file in a different directory and override @DEFAULT_SYS_DIR@ set
# the environment variable LVM_SYSTEM_DIR before running the tools.
#
# N.B. Take care that each setting only appears once if uncommenting
# example settings in this file.
# This section allows you to configure which block devices should
# be used by the LVM system.
devices {
# Where do you want your volume groups to appear ?
dir = "/dev"
# An array of directories that contain the device nodes you wish
# to use with LVM2.
scan = [ "/dev" ]
# If set, the cache of block device nodes with all associated symlinks
# will be constructed out of the existing udev database content.
# This avoids using and opening any inapplicable non-block devices or
# subdirectories found in the device directory. This setting is applied
# to udev-managed device directory only, other directories will be scanned
# fully. LVM2 needs to be compiled with udev support for this setting to
# take effect. N.B. Any device node or symlink not managed by udev in
# udev directory will be ignored with this setting on.
obtain_device_list_from_udev = 1
# If several entries in the scanned directories correspond to the
# same block device and the tools need to display a name for device,
# all the pathnames are matched against each item in the following
# list of regular expressions in turn and the first match is used.
preferred_names = [ ]
# Try to avoid using undescriptive /dev/dm-N names, if present.
# preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ]
# A filter that tells LVM2 to only use a restricted set of devices.
# The filter consists of an array of regular expressions. These
# expressions can be delimited by a character of your choice, and
# prefixed with either an 'a' (for accept) or 'r' (for reject).
# The first expression found to match a device name determines if
# the device will be accepted or rejected (ignored). Devices that
# don't match any patterns are accepted.
# Be careful if there there are symbolic links or multiple filesystem
# entries for the same device as each name is checked separately against
# the list of patterns. The effect is that if the first pattern in the
# list to match a name is an 'a' pattern for any of the names, the device
# is accepted; otherwise if the first pattern in the list to match a name
# is an 'r' pattern for any of the names it is rejected; otherwise it is
# accepted.
# Don't have more than one filter line active at once: only one gets used.
# Run vgscan after you change this parameter to ensure that
# the cache file gets regenerated (see below).
# If it doesn't do what you expect, check the output of 'vgscan -vvvv'.
# By default we accept every block device:
filter = [ "a/.*/" ]
# Exclude the cdrom drive
# filter = [ "r|/dev/cdrom|" ]
# When testing I like to work with just loopback devices:
# filter = [ "a/loop/", "r/.*/" ]
# Or maybe all loops and ide drives except hdc:
# filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ]
# Use anchors if you want to be really specific
# filter = [ "a|^/dev/hda8$|", "r/.*/" ]
# The results of the filtering are cached on disk to avoid
# rescanning dud devices (which can take a very long time).
# By default this cache is stored in the @DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@ directory
# in a file called '.cache'.
# It is safe to delete the contents: the tools regenerate it.
# (The old setting 'cache' is still respected if neither of
# these new ones is present.)
cache_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@"
cache_file_prefix = ""
# You can turn off writing this cache file by setting this to 0.
write_cache_state = 1
# Advanced settings.
# List of pairs of additional acceptable block device types found
# in /proc/devices with maximum (non-zero) number of partitions.
# types = [ "fd", 16 ]
# If sysfs is mounted (2.6 kernels) restrict device scanning to
# the block devices it believes are valid.
# 1 enables; 0 disables.
sysfs_scan = 1
# By default, LVM2 will ignore devices used as component paths
# of device-mapper multipath devices.
# 1 enables; 0 disables.
multipath_component_detection = 1
# By default, LVM2 will ignore devices used as components of
# software RAID (md) devices by looking for md superblocks.
# 1 enables; 0 disables.
md_component_detection = 1
# By default, if a PV is placed directly upon an md device, LVM2
# will align its data blocks with the md device's stripe-width.
# 1 enables; 0 disables.
md_chunk_alignment = 1
# Default alignment of the start of a data area in MB. If set to 0,
# a value of 64KB will be used. Set to 1 for 1MiB, 2 for 2MiB, etc.
# default_data_alignment = @DEFAULT_DATA_ALIGNMENT@
# By default, the start of a PV's data area will be a multiple of
# the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs.
# - minimum_io_size - the smallest request the device can perform
# w/o incurring a read-modify-write penalty (e.g. MD's chunk size)
# - optimal_io_size - the device's preferred unit of receiving I/O
# (e.g. MD's stripe width)
# minimum_io_size is used if optimal_io_size is undefined (0).
# If md_chunk_alignment is enabled, that detects the optimal_io_size.
# This setting takes precedence over md_chunk_alignment.
# 1 enables; 0 disables.
data_alignment_detection = 1
# Alignment (in KB) of start of data area when creating a new PV.
# md_chunk_alignment and data_alignment_detection are disabled if set.
# Set to 0 for the default alignment (see: data_alignment_default)
# or page size, if larger.
data_alignment = 0
# By default, the start of the PV's aligned data area will be shifted by
# the 'alignment_offset' exposed in sysfs. This offset is often 0 but
# may be non-zero; e.g.: certain 4KB sector drives that compensate for
# windows partitioning will have an alignment_offset of 3584 bytes
# (sector 7 is the lowest aligned logical block, the 4KB sectors start
# at LBA -1, and consequently sector 63 is aligned on a 4KB boundary).
# But note that pvcreate --dataalignmentoffset will skip this detection.
# 1 enables; 0 disables.
data_alignment_offset_detection = 1
# If, while scanning the system for PVs, LVM2 encounters a device-mapper
# device that has its I/O suspended, it waits for it to become accessible.
# Set this to 1 to skip such devices. This should only be needed
# in recovery situations.
ignore_suspended_devices = 0
# During each LVM operation errors received from each device are counted.
# If the counter of a particular device exceeds the limit set here, no
# further I/O is sent to that device for the remainder of the respective
# operation. Setting the parameter to 0 disables the counters altogether.
disable_after_error_count = 0
# Allow use of pvcreate --uuid without requiring --restorefile.
require_restorefile_with_uuid = 1
# Minimum size (in KB) of block devices which can be used as PVs.
# In a clustered environment all nodes must use the same value.
# Any value smaller than 512KB is ignored.
# Ignore devices smaller than 2MB such as floppy drives.
pv_min_size = 2048
# The original built-in setting was 512 up to and including version 2.02.84.
# pv_min_size = 512
# Issue discards to a logical volumes's underlying physical volume(s) when
# the logical volume is no longer using the physical volumes' space (e.g.
# lvremove, lvreduce, etc). Discards inform the storage that a region is
# no longer in use. Storage that supports discards advertise the protocol
# specific way discards should be issued by the kernel (TRIM, UNMAP, or
# WRITE SAME with UNMAP bit set). Not all storage will support or benefit
# from discards but SSDs and thinly provisioned LUNs generally do. If set
# to 1, discards will only be issued if both the storage and kernel provide
# support.
# 1 enables; 0 disables.
issue_discards = 0
}
# This section allows you to configure the way in which LVM selects
# free space for its Logical Volumes.
#allocation {
# When searching for free space to extend an LV, the "cling"
# allocation policy will choose space on the same PVs as the last
# segment of the existing LV. If there is insufficient space and a
# list of tags is defined here, it will check whether any of them are
# attached to the PVs concerned and then seek to match those PV tags
# between existing extents and new extents.
# Use the special tag "@*" as a wildcard to match any PV tag.
#
# Example: LVs are mirrored between two sites within a single VG.
# PVs are tagged with either @site1 or @site2 to indicate where
# they are situated.
#
# cling_tag_list = [ "@site1", "@site2" ]
# cling_tag_list = [ "@*" ]
#
# Changes made in version 2.02.85 extended the reach of the 'cling'
# policies to detect more situations where data can be grouped
# onto the same disks. Set this to 0 to revert to the previous
# algorithm.
#
# maximise_cling = 1
#
# Set to 1 to guarantee that mirror logs will always be placed on
# different PVs from the mirror images. This was the default
# until version 2.02.85.
#
# mirror_logs_require_separate_pvs = 0
#
# Set to 1 to guarantee that thin pool metadata will always
# be placed on different PVs from the pool data.
#
# thin_pool_metadata_require_separate_pvs = 0
#}
# This section that allows you to configure the nature of the
# information that LVM2 reports.
log {
# Controls the messages sent to stdout or stderr.
# There are three levels of verbosity, 3 being the most verbose.
verbose = 0
# Should we send log messages through syslog?
# 1 is yes; 0 is no.
syslog = 1
# Should we log error and debug messages to a file?
# By default there is no log file.
#file = "/var/log/lvm2.log"
# Should we overwrite the log file each time the program is run?
# By default we append.
overwrite = 0
# What level of log messages should we send to the log file and/or syslog?
# There are 6 syslog-like log levels currently in use - 2 to 7 inclusive.
# 7 is the most verbose (LOG_DEBUG).
level = 0
# Format of output messages
# Whether or not (1 or 0) to indent messages according to their severity
indent = 1
# Whether or not (1 or 0) to display the command name on each line output
command_names = 0
# A prefix to use before the message text (but after the command name,
# if selected). Default is two spaces, so you can see/grep the severity
# of each message.
prefix = " "
# To make the messages look similar to the original LVM tools use:
# indent = 0
# command_names = 1
# prefix = " -- "
# Set this if you want log messages during activation.
# Don't use this in low memory situations (can deadlock).
# activation = 0
}
# Configuration of metadata backups and archiving. In LVM2 when we
# talk about a 'backup' we mean making a copy of the metadata for the
# *current* system. The 'archive' contains old metadata configurations.
# Backups are stored in a human readeable text format.
backup {
# Should we maintain a backup of the current metadata configuration ?
# Use 1 for Yes; 0 for No.
# Think very hard before turning this off!
backup = 1
# Where shall we keep it ?
# Remember to back up this directory regularly!
backup_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@"
# Should we maintain an archive of old metadata configurations.
# Use 1 for Yes; 0 for No.
# On by default. Think very hard before turning this off.
archive = 1
# Where should archived files go ?
# Remember to back up this directory regularly!
archive_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@"
# What is the minimum number of archive files you wish to keep ?
retain_min = 10
# What is the minimum time you wish to keep an archive file for ?
retain_days = 30
}
# Settings for the running LVM2 in shell (readline) mode.
shell {
# Number of lines of history to store in ~/.lvm_history
history_size = 100
}
# Miscellaneous global LVM2 settings
global {
# The file creation mask for any files and directories created.
# Interpreted as octal if the first digit is zero.
umask = 077
# Allow other users to read the files
#umask = 022
# Enabling test mode means that no changes to the on disk metadata
# will be made. Equivalent to having the -t option on every
# command. Defaults to off.
test = 0
# Default value for --units argument
units = "h"
# Since version 2.02.54, the tools distinguish between powers of
# 1024 bytes (e.g. KiB, MiB, GiB) and powers of 1000 bytes (e.g.
# KB, MB, GB).
# If you have scripts that depend on the old behaviour, set this to 0
# temporarily until you update them.
si_unit_consistency = 1
# Whether or not to communicate with the kernel device-mapper.
# Set to 0 if you want to use the tools to manipulate LVM metadata
# without activating any logical volumes.
# If the device-mapper kernel driver is not present in your kernel
# setting this to 0 should suppress the error messages.
activation = 1
# If we can't communicate with device-mapper, should we try running
# the LVM1 tools?
# This option only applies to 2.4 kernels and is provided to help you
# switch between device-mapper kernels and LVM1 kernels.
# The LVM1 tools need to be installed with .lvm1 suffices
# e.g. vgscan.lvm1 and they will stop working after you start using
# the new lvm2 on-disk metadata format.
# The default value is set when the tools are built.
# fallback_to_lvm1 = 0
# The default metadata format that commands should use - "lvm1" or "lvm2".
# The command line override is -M1 or -M2.
# Defaults to "lvm2".
# format = "lvm2"
# Location of proc filesystem
proc = "/proc"
# Type of locking to use. Defaults to local file-based locking (1).
# Turn locking off by setting to 0 (dangerous: risks metadata corruption
# if LVM2 commands get run concurrently).
# Type 2 uses the external shared library locking_library.
# Type 3 uses built-in clustered locking.
# Type 4 uses read-only locking which forbids any operations that might
# change metadata.
locking_type = 1
# Set to 0 to fail when a lock request cannot be satisfied immediately.
wait_for_locks = 1
# If using external locking (type 2) and initialisation fails,
# with this set to 1 an attempt will be made to use the built-in
# clustered locking.
# If you are using a customised locking_library you should set this to 0.
fallback_to_clustered_locking = 1
# If an attempt to initialise type 2 or type 3 locking failed, perhaps
# because cluster components such as clvmd are not running, with this set
# to 1 an attempt will be made to use local file-based locking (type 1).
# If this succeeds, only commands against local volume groups will proceed.
# Volume Groups marked as clustered will be ignored.
fallback_to_local_locking = 1
# Local non-LV directory that holds file-based locks while commands are
# in progress. A directory like /tmp that may get wiped on reboot is OK.
locking_dir = "@DEFAULT_LOCK_DIR@"
# Whenever there are competing read-only and read-write access requests for
# a volume group's metadata, instead of always granting the read-only
# requests immediately, delay them to allow the read-write requests to be
# serviced. Without this setting, write access may be stalled by a high
# volume of read-only requests.
# NB. This option only affects locking_type = 1 viz. local file-based
# locking.
prioritise_write_locks = 1
# Other entries can go here to allow you to load shared libraries
# e.g. if support for LVM1 metadata was compiled as a shared library use
# format_libraries = "liblvm2format1.so"
# Full pathnames can be given.
# Search this directory first for shared libraries.
# library_dir = "/lib"
# The external locking library to load if locking_type is set to 2.
# locking_library = "liblvm2clusterlock.so"
# Treat any internal errors as fatal errors, aborting the process that
# encountered the internal error. Please only enable for debugging.
abort_on_internal_errors = 0
# Check whether CRC is matching when parsed VG is used multiple times.
# This is useful to catch unexpected internal cached volume group
# structure modification. Please only enable for debugging.
detect_internal_vg_cache_corruption = 0
# If set to 1, no operations that change on-disk metadata will be permitted.
# Additionally, read-only commands that encounter metadata in need of repair
# will still be allowed to proceed exactly as if the repair had been
# performed (except for the unchanged vg_seqno).
# Inappropriate use could mess up your system, so seek advice first!
metadata_read_only = 0
# 'mirror_segtype_default' defines which segtype will be used when the
# shorthand '-m' option is used for mirroring. The possible options are:
#
# "mirror" - The original RAID1 implementation provided by LVM2/DM. It is
# characterized by a flexible log solution (core, disk, mirrored)
# and by the necessity to block I/O while reconfiguring in the
# event of a failure. Snapshots of this type of RAID1 can be
# problematic.
#
# "raid1" - This implementation leverages MD's RAID1 personality through
# device-mapper. It is characterized by a lack of log options.
# (A log is always allocated for every device and they are placed
# on the same device as the image - no separate devices are
# required.) This mirror implementation does not require I/O
# to be blocked in the kernel in the event of a failure.
#
# Specify the '--type <mirror|raid1>' option to override this default
# setting.
mirror_segtype_default = "mirror"
# The default format for displaying LV names in lvdisplay was changed
# in version 2.02.89 to show the LV name and path separately.
# Previously this was always shown as /dev/vgname/lvname even when that
# was never a valid path in the /dev filesystem.
# Set to 1 to reinstate the previous format.
#
# lvdisplay_shows_full_device_path = 0
}
activation {
# Set to 1 to perform internal checks on the operations issued to
# libdevmapper. Useful for debugging problems with activation.
# Some of the checks may be expensive, so it's best to use this
# only when there seems to be a problem.
checks = 0
# Set to 0 to disable udev synchronisation (if compiled into the binaries).
# Processes will not wait for notification from udev.
# They will continue irrespective of any possible udev processing
# in the background. You should only use this if udev is not running
# or has rules that ignore the devices LVM2 creates.
# The command line argument --nodevsync takes precedence over this setting.
# If set to 1 when udev is not running, and there are LVM2 processes
# waiting for udev, run 'dmsetup udevcomplete_all' manually to wake them up.
udev_sync = 1
# Set to 0 to disable the udev rules installed by LVM2 (if built with
# --enable-udev_rules). LVM2 will then manage the /dev nodes and symlinks
# for active logical volumes directly itself.
# N.B. Manual intervention may be required if this setting is changed
# while any logical volumes are active.
udev_rules = 1
# Set to 1 for LVM2 to verify operations performed by udev. This turns on
# additional checks (and if necessary, repairs) on entries in the device
# directory after udev has completed processing its events.
# Useful for diagnosing problems with LVM2/udev interactions.
verify_udev_operations = 0
# If set to 1 and if deactivation of an LV fails, perhaps because
# a process run from a quick udev rule temporarily opened the device,
# retry the operation for a few seconds before failing.
retry_deactivation = 1
# How to fill in missing stripes if activating an incomplete volume.
# Using "error" will make inaccessible parts of the device return
# I/O errors on access. You can instead use a device path, in which
# case, that device will be used to in place of missing stripes.
# But note that using anything other than "error" with mirrored
# or snapshotted volumes is likely to result in data corruption.
missing_stripe_filler = "error"
# The linear target is an optimised version of the striped target
# that only handles a single stripe. Set this to 0 to disable this
# optimisation and always use the striped target.
use_linear_target = 1
# How much stack (in KB) to reserve for use while devices suspended
# Prior to version 2.02.89 this used to be set to 256KB
reserved_stack = 64
# How much memory (in KB) to reserve for use while devices suspended
reserved_memory = 8192
# Nice value used while devices suspended
process_priority = -18
# If volume_list is defined, each LV is only activated if there is a
# match against the list.
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
#
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
# If read_only_volume_list is defined, each LV that is to be activated
# is checked against the list, and if it matches, it as activated
# in read-only mode. (This overrides '--permission rw' stored in the
# metadata.)
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
#
# read_only_volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
# Size (in KB) of each copy operation when mirroring
mirror_region_size = 512
# Setting to use when there is no readahead value stored in the metadata.
#
# "none" - Disable readahead.
# "auto" - Use default value chosen by kernel.
readahead = "auto"
# 'raid_fault_policy' defines how a device failure in a RAID logical
# volume is handled. This includes logical volumes that have the following
# segment types: raid1, raid4, raid5*, and raid6*.
#
# In the event of a failure, the following policies will determine what
# actions are performed during the automated response to failures (when
# dmeventd is monitoring the RAID logical volume) and when 'lvconvert' is
# called manually with the options '--repair' and '--use-policies'.
#
# "warn" - Use the system log to warn the user that a device in the RAID
# logical volume has failed. It is left to the user to run
# 'lvconvert --repair' manually to remove or replace the failed
# device. As long as the number of failed devices does not
# exceed the redundancy of the logical volume (1 device for
# raid4/5, 2 for raid6, etc) the logical volume will remain
# usable.
#
# "allocate" - Attempt to use any extra physical volumes in the volume
# group as spares and replace faulty devices.
#
raid_fault_policy = "warn"
# 'mirror_image_fault_policy' and 'mirror_log_fault_policy' define
# how a device failure affecting a mirror (of "mirror" segment type) is
# handled. A mirror is composed of mirror images (copies) and a log.
# A disk log ensures that a mirror does not need to be re-synced
# (all copies made the same) every time a machine reboots or crashes.
#
# In the event of a failure, the specified policy will be used to determine
# what happens. This applies to automatic repairs (when the mirror is being
# monitored by dmeventd) and to manual lvconvert --repair when
# --use-policies is given.
#
# "remove" - Simply remove the faulty device and run without it. If
# the log device fails, the mirror would convert to using
# an in-memory log. This means the mirror will not
# remember its sync status across crashes/reboots and
# the entire mirror will be re-synced. If a
# mirror image fails, the mirror will convert to a
# non-mirrored device if there is only one remaining good
# copy.
#
# "allocate" - Remove the faulty device and try to allocate space on
# a new device to be a replacement for the failed device.
# Using this policy for the log is fast and maintains the
# ability to remember sync state through crashes/reboots.
# Using this policy for a mirror device is slow, as it
# requires the mirror to resynchronize the devices, but it
# will preserve the mirror characteristic of the device.
# This policy acts like "remove" if no suitable device and
# space can be allocated for the replacement.
#
# "allocate_anywhere" - Not yet implemented. Useful to place the log device
# temporarily on same physical volume as one of the mirror
# images. This policy is not recommended for mirror devices
# since it would break the redundant nature of the mirror. This
# policy acts like "remove" if no suitable device and space can
# be allocated for the replacement.
mirror_log_fault_policy = "allocate"
mirror_image_fault_policy = "remove"
# 'snapshot_autoextend_threshold' and 'snapshot_autoextend_percent' define
# how to handle automatic snapshot extension. The former defines when the
# snapshot should be extended: when its space usage exceeds this many
# percent. The latter defines how much extra space should be allocated for
# the snapshot, in percent of its current size.
#
# For example, if you set snapshot_autoextend_threshold to 70 and
# snapshot_autoextend_percent to 20, whenever a snapshot exceeds 70% usage,
# it will be extended by another 20%. For a 1G snapshot, using up 700M will
# trigger a resize to 1.2G. When the usage exceeds 840M, the snapshot will
# be extended to 1.44G, and so on.
#
# Setting snapshot_autoextend_threshold to 100 disables automatic
# extensions. The minimum value is 50 (A setting below 50 will be treated
# as 50).
snapshot_autoextend_threshold = 100
snapshot_autoextend_percent = 20
# 'thin_pool_autoextend_threshold' and 'thin_pool_autoextend_percent' define
# how to handle automatic pool extension. The former defines when the
# pool should be extended: when its space usage exceeds this many
# percent. The latter defines how much extra space should be allocated for
# the pool, in percent of its current size.
#
# For example, if you set thin_pool_autoextend_threshold to 70 and
# thin_pool_autoextend_percent to 20, whenever a pool exceeds 70% usage,
# it will be extended by another 20%. For a 1G pool, using up 700M will
# trigger a resize to 1.2G. When the usage exceeds 840M, the pool will
# be extended to 1.44G, and so on.
#
# Setting thin_pool_autoextend_threshold to 100 disables automatic
# extensions. The minimum value is 50 (A setting below 50 will be treated
# as 50).
thin_pool_autoextend_threshold = 100
thin_pool_autoextend_percent = 20
# While activating devices, I/O to devices being (re)configured is
# suspended, and as a precaution against deadlocks, LVM2 needs to pin
# any memory it is using so it is not paged out. Groups of pages that
# are known not to be accessed during activation need not be pinned
# into memory. Each string listed in this setting is compared against
# each line in /proc/self/maps, and the pages corresponding to any
# lines that match are not pinned. On some systems locale-archive was
# found to make up over 80% of the memory used by the process.
# mlock_filter = [ "locale/locale-archive", "gconv/gconv-modules.cache" ]
# Set to 1 to revert to the default behaviour prior to version 2.02.62
# which used mlockall() to pin the whole process's memory while activating
# devices.
use_mlockall = 0
# Monitoring is enabled by default when activating logical volumes.
# Set to 0 to disable monitoring or use the --ignoremonitoring option.
monitoring = 1
# When pvmove or lvconvert must wait for the kernel to finish
# synchronising or merging data, they check and report progress
# at intervals of this number of seconds. The default is 15 seconds.
# If this is set to 0 and there is only one thing to wait for, there
# are no progress reports, but the process is awoken immediately the
# operation is complete.
polling_interval = 15
}
####################
# Advanced section #
####################
# Metadata settings
#
# metadata {
# Default number of copies of metadata to hold on each PV. 0, 1 or 2.
# You might want to override it from the command line with 0
# when running pvcreate on new PVs which are to be added to large VGs.
# pvmetadatacopies = 1
# Default number of copies of metadata to maintain for each VG.
# If set to a non-zero value, LVM automatically chooses which of
# the available metadata areas to use to achieve the requested
# number of copies of the VG metadata. If you set a value larger
# than the the total number of metadata areas available then
# metadata is stored in them all.
# The default value of 0 ("unmanaged") disables this automatic
# management and allows you to control which metadata areas
# are used at the individual PV level using 'pvchange
# --metadataignore y/n'.
# vgmetadatacopies = 0
# Approximate default size of on-disk metadata areas in sectors.
# You should increase this if you have large volume groups or
# you want to retain a large on-disk history of your metadata changes.
# pvmetadatasize = 255
# List of directories holding live copies of text format metadata.
# These directories must not be on logical volumes!
# It's possible to use LVM2 with a couple of directories here,
# preferably on different (non-LV) filesystems, and with no other
# on-disk metadata (pvmetadatacopies = 0). Or this can be in
# addition to on-disk metadata areas.
# The feature was originally added to simplify testing and is not
# supported under low memory situations - the machine could lock up.
#
# Never edit any files in these directories by hand unless you
# you are absolutely sure you know what you are doing! Use
# the supplied toolset to make changes (e.g. vgcfgrestore).
# dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ]
#}
# Event daemon
#
dmeventd {
# mirror_library is the library used when monitoring a mirror device.
#
# "libdevmapper-event-lvm2mirror.so" attempts to recover from
# failures. It removes failed devices from a volume group and
# reconfigures a mirror as necessary. If no mirror library is
# provided, mirrors are not monitored through dmeventd.
mirror_library = "libdevmapper-event-lvm2mirror.so"
# snapshot_library is the library used when monitoring a snapshot device.
#
# "libdevmapper-event-lvm2snapshot.so" monitors the filling of
# snapshots and emits a warning through syslog when the use of
# the snapshot exceeds 80%. The warning is repeated when 85%, 90% and
# 95% of the snapshot is filled.
snapshot_library = "libdevmapper-event-lvm2snapshot.so"
# thin_library is the library used when monitoring a thin device.
#
# "libdevmapper-event-lvm2thin.so" monitors the filling of
# pool and emits a warning through syslog when the use of
# the pool exceeds 80%. The warning is repeated when 85%, 90% and
# 95% of the pool is filled.
thin_library = "libdevmapper-event-lvm2thin.so"
# Full path of the dmeventd binary.
#
# executable = "@DMEVENTD_PATH@"
}

49
doc/example_cmdlib.c Normal file
View File

@ -0,0 +1,49 @@
/*
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lvm2cmd.h"
#include <stdio.h>
/* All output gets passed to this function line-by-line */
void test_log_fn(int level, const char *file, int line,
int dm_errno, const char *format)
{
/* Extract and process output here rather than printing it */
if (level != 4)
return;
printf("%s\n", format);
return;
}
int main(int argc, char **argv)
{
void *handle;
int r;
lvm2_log_fn(test_log_fn);
handle = lvm2_init();
lvm2_log_level(handle, 1);
r = lvm2_run(handle, "vgs --noheadings vg1");
/* More commands here */
lvm2_exit(handle);
return r;
}

76
doc/kernel/crypt.txt Normal file
View File

@ -0,0 +1,76 @@
dm-crypt
=========
Device-Mapper's "crypt" target provides transparent encryption of block devices
using the kernel crypto API.
Parameters: <cipher> <key> <iv_offset> <device path> \
<offset> [<#opt_params> <opt_params>]
<cipher>
Encryption cipher and an optional IV generation mode.
(In format cipher[:keycount]-chainmode-ivopts:ivmode).
Examples:
des
aes-cbc-essiv:sha256
twofish-ecb
/proc/crypto contains supported crypto modes
<key>
Key used for encryption. It is encoded as a hexadecimal number.
You can only use key sizes that are valid for the selected cipher.
<keycount>
Multi-key compatibility mode. You can define <keycount> keys and
then sectors are encrypted according to their offsets (sector 0 uses key0;
sector 1 uses key1 etc.). <keycount> must be a power of two.
<iv_offset>
The IV offset is a sector count that is added to the sector number
before creating the IV.
<device path>
This is the device that is going to be used as backend and contains the
encrypted data. You can specify it as a path like /dev/xxx or a device
number <major>:<minor>.
<offset>
Starting sector within the device where the encrypted data begins.
<#opt_params>
Number of optional parameters. If there are no optional parameters,
the optional paramaters section can be skipped or #opt_params can be zero.
Otherwise #opt_params is the number of following arguments.
Example of optional parameters section:
1 allow_discards
allow_discards
Block discard requests (a.k.a. TRIM) are passed through the crypt device.
The default is to ignore discard requests.
WARNING: Assess the specific security risks carefully before enabling this
option. For example, allowing discards on encrypted devices may lead to
the leak of information about the ciphertext device (filesystem type,
used space etc.) if the discarded blocks can be located easily on the
device later.
Example scripts
===============
LUKS (Linux Unified Key Setup) is now the preferred way to set up disk
encryption with dm-crypt using the 'cryptsetup' utility, see
http://code.google.com/p/cryptsetup/
[[
#!/bin/sh
# Create a crypt device using dmsetup
dmsetup create crypt1 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
]]
[[
#!/bin/sh
# Create a crypt device using cryptsetup and LUKS header with default cipher
cryptsetup luksFormat $1
cryptsetup luksOpen $1 crypt1
]]

26
doc/kernel/delay.txt Normal file
View File

@ -0,0 +1,26 @@
dm-delay
========
Device-Mapper's "delay" target delays reads and/or writes
and maps them to different devices.
Parameters:
<device> <offset> <delay> [<write_device> <write_offset> <write_delay>]
With separate write parameters, the first set is only used for reads.
Delays are specified in milliseconds.
Example scripts
===============
[[
#!/bin/sh
# Create device delaying rw operation for 500ms
echo "0 `blockdev --getsize $1` delay $1 0 500" | dmsetup create delayed
]]
[[
#!/bin/sh
# Create device delaying only write operation for 500ms and
# splitting reads and writes to different devices $1 $2
echo "0 `blockdev --getsize $1` delay $1 0 0 $2 0 500" | dmsetup create delayed
]]

53
doc/kernel/flakey.txt Normal file
View File

@ -0,0 +1,53 @@
dm-flakey
=========
This target is the same as the linear target except that it exhibits
unreliable behaviour periodically. It's been found useful in simulating
failing devices for testing purposes.
Starting from the time the table is loaded, the device is available for
<up interval> seconds, then exhibits unreliable behaviour for <down
interval> seconds, and then this cycle repeats.
Also, consider using this in combination with the dm-delay target too,
which can delay reads and writes and/or send them to different
underlying devices.
Table parameters
----------------
<dev path> <offset> <up interval> <down interval> \
[<num_features> [<feature arguments>]]
Mandatory parameters:
<dev path>: Full pathname to the underlying block-device, or a
"major:minor" device-number.
<offset>: Starting sector within the device.
<up interval>: Number of seconds device is available.
<down interval>: Number of seconds device returns errors.
Optional feature parameters:
If no feature parameters are present, during the periods of
unreliability, all I/O returns errors.
drop_writes:
All write I/O is silently ignored.
Read I/O is handled correctly.
corrupt_bio_byte <Nth_byte> <direction> <value> <flags>:
During <down interval>, replace <Nth_byte> of the data of
each matching bio with <value>.
<Nth_byte>: The offset of the byte to replace.
Counting starts at 1, to replace the first byte.
<direction>: Either 'r' to corrupt reads or 'w' to corrupt writes.
'w' is incompatible with drop_writes.
<value>: The value (from 0-255) to write.
<flags>: Perform the replacement only if bio->bi_rw has all the
selected flags set.
Examples:
corrupt_bio_byte 32 r 1 0
- replaces the 32nd byte of READ bios with the value 1
corrupt_bio_byte 224 w 0 32
- replaces the 224th byte of REQ_META (=32) bios with the value 0

75
doc/kernel/io.txt Normal file
View File

@ -0,0 +1,75 @@
dm-io
=====
Dm-io provides synchronous and asynchronous I/O services. There are three
types of I/O services available, and each type has a sync and an async
version.
The user must set up an io_region structure to describe the desired location
of the I/O. Each io_region indicates a block-device along with the starting
sector and size of the region.
struct io_region {
struct block_device *bdev;
sector_t sector;
sector_t count;
};
Dm-io can read from one io_region or write to one or more io_regions. Writes
to multiple regions are specified by an array of io_region structures.
The first I/O service type takes a list of memory pages as the data buffer for
the I/O, along with an offset into the first page.
struct page_list {
struct page_list *next;
struct page *page;
};
int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw,
struct page_list *pl, unsigned int offset,
unsigned long *error_bits);
int dm_io_async(unsigned int num_regions, struct io_region *where, int rw,
struct page_list *pl, unsigned int offset,
io_notify_fn fn, void *context);
The second I/O service type takes an array of bio vectors as the data buffer
for the I/O. This service can be handy if the caller has a pre-assembled bio,
but wants to direct different portions of the bio to different devices.
int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where,
int rw, struct bio_vec *bvec,
unsigned long *error_bits);
int dm_io_async_bvec(unsigned int num_regions, struct io_region *where,
int rw, struct bio_vec *bvec,
io_notify_fn fn, void *context);
The third I/O service type takes a pointer to a vmalloc'd memory buffer as the
data buffer for the I/O. This service can be handy if the caller needs to do
I/O to a large region but doesn't want to allocate a large number of individual
memory pages.
int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw,
void *data, unsigned long *error_bits);
int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw,
void *data, io_notify_fn fn, void *context);
Callers of the asynchronous I/O services must include the name of a completion
callback routine and a pointer to some context data for the I/O.
typedef void (*io_notify_fn)(unsigned long error, void *context);
The "error" parameter in this callback, as well as the "*error" parameter in
all of the synchronous versions, is a bitset (instead of a simple error value).
In the case of an write-I/O to multiple regions, this bitset allows dm-io to
indicate success or failure on each individual region.
Before using any of the dm-io services, the user should call dm_io_get()
and specify the number of pages they expect to perform I/O on concurrently.
Dm-io will attempt to resize its mempool to make sure enough pages are
always available in order to avoid unnecessary waiting while performing I/O.
When the user is finished using the dm-io services, they should call
dm_io_put() and specify the same number of pages that were given on the
dm_io_get() call.

47
doc/kernel/kcopyd.txt Normal file
View File

@ -0,0 +1,47 @@
kcopyd
======
Kcopyd provides the ability to copy a range of sectors from one block-device
to one or more other block-devices, with an asynchronous completion
notification. It is used by dm-snapshot and dm-mirror.
Users of kcopyd must first create a client and indicate how many memory pages
to set aside for their copy jobs. This is done with a call to
kcopyd_client_create().
int kcopyd_client_create(unsigned int num_pages,
struct kcopyd_client **result);
To start a copy job, the user must set up io_region structures to describe
the source and destinations of the copy. Each io_region indicates a
block-device along with the starting sector and size of the region. The source
of the copy is given as one io_region structure, and the destinations of the
copy are given as an array of io_region structures.
struct io_region {
struct block_device *bdev;
sector_t sector;
sector_t count;
};
To start the copy, the user calls kcopyd_copy(), passing in the client
pointer, pointers to the source and destination io_regions, the name of a
completion callback routine, and a pointer to some context data for the copy.
int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from,
unsigned int num_dests, struct io_region *dests,
unsigned int flags, kcopyd_notify_fn fn, void *context);
typedef void (*kcopyd_notify_fn)(int read_err, unsigned int write_err,
void *context);
When the copy completes, kcopyd will call the user's completion routine,
passing back the user's context pointer. It will also indicate if a read or
write error occurred during the copy.
When a user is done with all their copy jobs, they should call
kcopyd_client_destroy() to delete the kcopyd client, which will release the
associated memory pages.
void kcopyd_client_destroy(struct kcopyd_client *kc);

61
doc/kernel/linear.txt Normal file
View File

@ -0,0 +1,61 @@
dm-linear
=========
Device-Mapper's "linear" target maps a linear range of the Device-Mapper
device onto a linear range of another device. This is the basic building
block of logical volume managers.
Parameters: <dev path> <offset>
<dev path>: Full pathname to the underlying block-device, or a
"major:minor" device-number.
<offset>: Starting sector within the device.
Example scripts
===============
[[
#!/bin/sh
# Create an identity mapping for a device
echo "0 `blockdev --getsize $1` linear $1 0" | dmsetup create identity
]]
[[
#!/bin/sh
# Join 2 devices together
size1=`blockdev --getsize $1`
size2=`blockdev --getsize $2`
echo "0 $size1 linear $1 0
$size1 $size2 linear $2 0" | dmsetup create joined
]]
[[
#!/usr/bin/perl -w
# Split a device into 4M chunks and then join them together in reverse order.
my $name = "reverse";
my $extent_size = 4 * 1024 * 2;
my $dev = $ARGV[0];
my $table = "";
my $count = 0;
if (!defined($dev)) {
die("Please specify a device.\n");
}
my $dev_size = `blockdev --getsize $dev`;
my $extents = int($dev_size / $extent_size) -
(($dev_size % $extent_size) ? 1 : 0);
while ($extents > 0) {
my $this_start = $count * $extent_size;
$extents--;
$count++;
my $this_offset = $extents * $extent_size;
$table .= "$this_start $extent_size linear $dev $this_offset\n";
}
`echo \"$table\" | dmsetup create $name`;
]]

54
doc/kernel/log.txt Normal file
View File

@ -0,0 +1,54 @@
Device-Mapper Logging
=====================
The device-mapper logging code is used by some of the device-mapper
RAID targets to track regions of the disk that are not consistent.
A region (or portion of the address space) of the disk may be
inconsistent because a RAID stripe is currently being operated on or
a machine died while the region was being altered. In the case of
mirrors, a region would be considered dirty/inconsistent while you
are writing to it because the writes need to be replicated for all
the legs of the mirror and may not reach the legs at the same time.
Once all writes are complete, the region is considered clean again.
There is a generic logging interface that the device-mapper RAID
implementations use to perform logging operations (see
dm_dirty_log_type in include/linux/dm-dirty-log.h). Various different
logging implementations are available and provide different
capabilities. The list includes:
Type Files
==== =====
disk drivers/md/dm-log.c
core drivers/md/dm-log.c
userspace drivers/md/dm-log-userspace* include/linux/dm-log-userspace.h
The "disk" log type
-------------------
This log implementation commits the log state to disk. This way, the
logging state survives reboots/crashes.
The "core" log type
-------------------
This log implementation keeps the log state in memory. The log state
will not survive a reboot or crash, but there may be a small boost in
performance. This method can also be used if no storage device is
available for storing log state.
The "userspace" log type
------------------------
This log type simply provides a way to export the log API to userspace,
so log implementations can be done there. This is done by forwarding most
logging requests to userspace, where a daemon receives and processes the
request.
The structure used for communication between kernel and userspace are
located in include/linux/dm-log-userspace.h. Due to the frequency,
diversity, and 2-way communication nature of the exchanges between
kernel and userspace, 'connector' is used as the interface for
communication.
There are currently two userspace log implementations that leverage this
framework - "clustered-disk" and "clustered-core". These implementations
provide a cluster-coherent log for shared-storage. Device-mapper mirroring
can be used in a shared-storage environment when the cluster log implementations
are employed.

View File

@ -0,0 +1,84 @@
Introduction
============
The more-sophisticated device-mapper targets require complex metadata
that is managed in kernel. In late 2010 we were seeing that various
different targets were rolling their own data strutures, for example:
- Mikulas Patocka's multisnap implementation
- Heinz Mauelshagen's thin provisioning target
- Another btree-based caching target posted to dm-devel
- Another multi-snapshot target based on a design of Daniel Phillips
Maintaining these data structures takes a lot of work, so if possible
we'd like to reduce the number.
The persistent-data library is an attempt to provide a re-usable
framework for people who want to store metadata in device-mapper
targets. It's currently used by the thin-provisioning target and an
upcoming hierarchical storage target.
Overview
========
The main documentation is in the header files which can all be found
under drivers/md/persistent-data.
The block manager
-----------------
dm-block-manager.[hc]
This provides access to the data on disk in fixed sized-blocks. There
is a read/write locking interface to prevent concurrent accesses, and
keep data that is being used in the cache.
Clients of persistent-data are unlikely to use this directly.
The transaction manager
-----------------------
dm-transaction-manager.[hc]
This restricts access to blocks and enforces copy-on-write semantics.
The only way you can get hold of a writable block through the
transaction manager is by shadowing an existing block (ie. doing
copy-on-write) or allocating a fresh one. Shadowing is elided within
the same transaction so performance is reasonable. The commit method
ensures that all data is flushed before it writes the superblock.
On power failure your metadata will be as it was when last committed.
The Space Maps
--------------
dm-space-map.h
dm-space-map-metadata.[hc]
dm-space-map-disk.[hc]
On-disk data structures that keep track of reference counts of blocks.
Also acts as the allocator of new blocks. Currently two
implementations: a simpler one for managing blocks on a different
device (eg. thinly-provisioned data blocks); and one for managing
the metadata space. The latter is complicated by the need to store
its own data within the space it's managing.
The data structures
-------------------
dm-btree.[hc]
dm-btree-remove.c
dm-btree-spine.c
dm-btree-internal.h
Currently there is only one data structure, a hierarchical btree.
There are plans to add more. For example, something with an
array-like interface would see a lot of use.
The btree is 'hierarchical' in that you can define it to be composed
of nested btrees, and take multiple keys. For example, the
thin-provisioning target uses a btree with two levels of nesting.
The first maps a device id to a mapping tree, and that in turn maps a
virtual block to a physical block.
Values stored in the btrees can have arbitrary size. Keys are always
64bits, although nesting allows you to use multiple keys.

View File

@ -0,0 +1,39 @@
dm-queue-length
===============
dm-queue-length is a path selector module for device-mapper targets,
which selects a path with the least number of in-flight I/Os.
The path selector name is 'queue-length'.
Table parameters for each path: [<repeat_count>]
<repeat_count>: The number of I/Os to dispatch using the selected
path before switching to the next path.
If not given, internal default is used. To check
the default value, see the activated table.
Status for each path: <status> <fail-count> <in-flight>
<status>: 'A' if the path is active, 'F' if the path is failed.
<fail-count>: The number of path failures.
<in-flight>: The number of in-flight I/Os on the path.
Algorithm
=========
dm-queue-length increments/decrements 'in-flight' when an I/O is
dispatched/completed respectively.
dm-queue-length selects a path with the minimum 'in-flight'.
Examples
========
In case that 2 paths (sda and sdb) are used with repeat_count == 128.
# echo "0 10 multipath 0 0 1 1 queue-length 0 2 1 8:0 128 8:16 128" \
dmsetup create test
#
# dmsetup table
test: 0 10 multipath 0 0 1 1 queue-length 0 2 1 8:0 128 8:16 128
#
# dmsetup status
test: 0 10 multipath 2 0 0 0 1 1 E 0 2 1 8:0 A 0 0 8:16 A 0 0

108
doc/kernel/raid.txt Normal file
View File

@ -0,0 +1,108 @@
dm-raid
-------
The device-mapper RAID (dm-raid) target provides a bridge from DM to MD.
It allows the MD RAID drivers to be accessed using a device-mapper
interface.
The target is named "raid" and it accepts the following parameters:
<raid_type> <#raid_params> <raid_params> \
<#raid_devs> <metadata_dev0> <dev0> [.. <metadata_devN> <devN>]
<raid_type>:
raid1 RAID1 mirroring
raid4 RAID4 dedicated parity disk
raid5_la RAID5 left asymmetric
- rotating parity 0 with data continuation
raid5_ra RAID5 right asymmetric
- rotating parity N with data continuation
raid5_ls RAID5 left symmetric
- rotating parity 0 with data restart
raid5_rs RAID5 right symmetric
- rotating parity N with data restart
raid6_zr RAID6 zero restart
- rotating parity zero (left-to-right) with data restart
raid6_nr RAID6 N restart
- rotating parity N (right-to-left) with data restart
raid6_nc RAID6 N continue
- rotating parity N (right-to-left) with data continuation
Refererence: Chapter 4 of
http://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf
<#raid_params>: The number of parameters that follow.
<raid_params> consists of
Mandatory parameters:
<chunk_size>: Chunk size in sectors. This parameter is often known as
"stripe size". It is the only mandatory parameter and
is placed first.
followed by optional parameters (in any order):
[sync|nosync] Force or prevent RAID initialization.
[rebuild <idx>] Rebuild drive number idx (first drive is 0).
[daemon_sleep <ms>]
Interval between runs of the bitmap daemon that
clear bits. A longer interval means less bitmap I/O but
resyncing after a failure is likely to take longer.
[min_recovery_rate <kB/sec/disk>] Throttle RAID initialization
[max_recovery_rate <kB/sec/disk>] Throttle RAID initialization
[write_mostly <idx>] Drive index is write-mostly
[max_write_behind <sectors>] See '-write-behind=' (man mdadm)
[stripe_cache <sectors>] Stripe cache size (higher RAIDs only)
[region_size <sectors>]
The region_size multiplied by the number of regions is the
logical size of the array. The bitmap records the device
synchronisation state for each region.
<#raid_devs>: The number of devices composing the array.
Each device consists of two entries. The first is the device
containing the metadata (if any); the second is the one containing the
data.
If a drive has failed or is missing at creation time, a '-' can be
given for both the metadata and data drives for a given position.
Example tables
--------------
# RAID4 - 4 data drives, 1 parity (no metadata devices)
# No metadata devices specified to hold superblock/bitmap info
# Chunk size of 1MiB
# (Lines separated for easy reading)
0 1960893648 raid \
raid4 1 2048 \
5 - 8:17 - 8:33 - 8:49 - 8:65 - 8:81
# RAID4 - 4 data drives, 1 parity (with metadata devices)
# Chunk size of 1MiB, force RAID initialization,
# min recovery rate at 20 kiB/sec/disk
0 1960893648 raid \
raid4 4 2048 sync min_recovery_rate 20 \
5 8:17 8:18 8:33 8:34 8:49 8:50 8:65 8:66 8:81 8:82
'dmsetup table' displays the table used to construct the mapping.
The optional parameters are always printed in the order listed
above with "sync" or "nosync" always output ahead of the other
arguments, regardless of the order used when originally loading the table.
Arguments that can be repeated are ordered by value.
'dmsetup status' yields information on the state and health of the
array.
The output is as follows:
1: <s> <l> raid \
2: <raid_type> <#devices> <1 health char for each dev> <resync_ratio>
Line 1 is the standard output produced by device-mapper.
Line 2 is produced by the raid target, and best explained by example:
0 1960893648 raid raid4 5 AAAAA 2/490221568
Here we can see the RAID type is raid4, there are 5 devices - all of
which are 'A'live, and the array is 2/490221568 complete with recovery.
Faulty or missing devices are marked 'D'. Devices that are out-of-sync
are marked 'a'.

View File

@ -0,0 +1,91 @@
dm-service-time
===============
dm-service-time is a path selector module for device-mapper targets,
which selects a path with the shortest estimated service time for
the incoming I/O.
The service time for each path is estimated by dividing the total size
of in-flight I/Os on a path with the performance value of the path.
The performance value is a relative throughput value among all paths
in a path-group, and it can be specified as a table argument.
The path selector name is 'service-time'.
Table parameters for each path: [<repeat_count> [<relative_throughput>]]
<repeat_count>: The number of I/Os to dispatch using the selected
path before switching to the next path.
If not given, internal default is used. To check
the default value, see the activated table.
<relative_throughput>: The relative throughput value of the path
among all paths in the path-group.
The valid range is 0-100.
If not given, minimum value '1' is used.
If '0' is given, the path isn't selected while
other paths having a positive value are available.
Status for each path: <status> <fail-count> <in-flight-size> \
<relative_throughput>
<status>: 'A' if the path is active, 'F' if the path is failed.
<fail-count>: The number of path failures.
<in-flight-size>: The size of in-flight I/Os on the path.
<relative_throughput>: The relative throughput value of the path
among all paths in the path-group.
Algorithm
=========
dm-service-time adds the I/O size to 'in-flight-size' when the I/O is
dispatched and subtracts when completed.
Basically, dm-service-time selects a path having minimum service time
which is calculated by:
('in-flight-size' + 'size-of-incoming-io') / 'relative_throughput'
However, some optimizations below are used to reduce the calculation
as much as possible.
1. If the paths have the same 'relative_throughput', skip
the division and just compare the 'in-flight-size'.
2. If the paths have the same 'in-flight-size', skip the division
and just compare the 'relative_throughput'.
3. If some paths have non-zero 'relative_throughput' and others
have zero 'relative_throughput', ignore those paths with zero
'relative_throughput'.
If such optimizations can't be applied, calculate service time, and
compare service time.
If calculated service time is equal, the path having maximum
'relative_throughput' may be better. So compare 'relative_throughput'
then.
Examples
========
In case that 2 paths (sda and sdb) are used with repeat_count == 128
and sda has an average throughput 1GB/s and sdb has 4GB/s,
'relative_throughput' value may be '1' for sda and '4' for sdb.
# echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4" \
dmsetup create test
#
# dmsetup table
test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4
#
# dmsetup status
test: 0 10 multipath 2 0 0 0 1 1 E 0 2 2 8:0 A 0 0 1 8:16 A 0 0 4
Or '2' for sda and '8' for sdb would be also true.
# echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8" \
dmsetup create test
#
# dmsetup table
test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8
#
# dmsetup status
test: 0 10 multipath 2 0 0 0 1 1 E 0 2 2 8:0 A 0 0 2 8:16 A 0 0 8

168
doc/kernel/snapshot.txt Normal file
View File

@ -0,0 +1,168 @@
Device-mapper snapshot support
==============================
Device-mapper allows you, without massive data copying:
*) To create snapshots of any block device i.e. mountable, saved states of
the block device which are also writable without interfering with the
original content;
*) To create device "forks", i.e. multiple different versions of the
same data stream.
*) To merge a snapshot of a block device back into the snapshot's origin
device.
In the first two cases, dm copies only the chunks of data that get
changed and uses a separate copy-on-write (COW) block device for
storage.
For snapshot merge the contents of the COW storage are merged back into
the origin device.
There are three dm targets available:
snapshot, snapshot-origin, and snapshot-merge.
*) snapshot-origin <origin>
which will normally have one or more snapshots based on it.
Reads will be mapped directly to the backing device. For each write, the
original data will be saved in the <COW device> of each snapshot to keep
its visible content unchanged, at least until the <COW device> fills up.
*) snapshot <origin> <COW device> <persistent?> <chunksize>
A snapshot of the <origin> block device is created. Changed chunks of
<chunksize> sectors will be stored on the <COW device>. Writes will
only go to the <COW device>. Reads will come from the <COW device> or
from <origin> for unchanged data. <COW device> will often be
smaller than the origin and if it fills up the snapshot will become
useless and be disabled, returning errors. So it is important to monitor
the amount of free space and expand the <COW device> before it fills up.
<persistent?> is P (Persistent) or N (Not persistent - will not survive
after reboot).
The difference is that for transient snapshots less metadata must be
saved on disk - they can be kept in memory by the kernel.
* snapshot-merge <origin> <COW device> <persistent> <chunksize>
takes the same table arguments as the snapshot target except it only
works with persistent snapshots. This target assumes the role of the
"snapshot-origin" target and must not be loaded if the "snapshot-origin"
is still present for <origin>.
Creates a merging snapshot that takes control of the changed chunks
stored in the <COW device> of an existing snapshot, through a handover
procedure, and merges these chunks back into the <origin>. Once merging
has started (in the background) the <origin> may be opened and the merge
will continue while I/O is flowing to it. Changes to the <origin> are
deferred until the merging snapshot's corresponding chunk(s) have been
merged. Once merging has started the snapshot device, associated with
the "snapshot" target, will return -EIO when accessed.
How snapshot is used by LVM2
============================
When you create the first LVM2 snapshot of a volume, four dm devices are used:
1) a device containing the original mapping table of the source volume;
2) a device used as the <COW device>;
3) a "snapshot" device, combining #1 and #2, which is the visible snapshot
volume;
4) the "original" volume (which uses the device number used by the original
source volume), whose table is replaced by a "snapshot-origin" mapping
from device #1.
A fixed naming scheme is used, so with the following commands:
lvcreate -L 1G -n base volumeGroup
lvcreate -L 100M --snapshot -n snap volumeGroup/base
we'll have this situation (with volumes in above order):
# dmsetup table|grep volumeGroup
volumeGroup-base-real: 0 2097152 linear 8:19 384
volumeGroup-snap-cow: 0 204800 linear 8:19 2097536
volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16
volumeGroup-base: 0 2097152 snapshot-origin 254:11
# ls -lL /dev/mapper/volumeGroup-*
brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
brw------- 1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
brw------- 1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
brw------- 1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base
How snapshot-merge is used by LVM2
==================================
A merging snapshot assumes the role of the "snapshot-origin" while
merging. As such the "snapshot-origin" is replaced with
"snapshot-merge". The "-real" device is not changed and the "-cow"
device is renamed to <origin name>-cow to aid LVM2's cleanup of the
merging snapshot after it completes. The "snapshot" that hands over its
COW device to the "snapshot-merge" is deactivated (unless using lvchange
--refresh); but if it is left active it will simply return I/O errors.
A snapshot will merge into its origin with the following command:
lvconvert --merge volumeGroup/snap
we'll now have this situation:
# dmsetup table|grep volumeGroup
volumeGroup-base-real: 0 2097152 linear 8:19 384
volumeGroup-base-cow: 0 204800 linear 8:19 2097536
volumeGroup-base: 0 2097152 snapshot-merge 254:11 254:12 P 16
# ls -lL /dev/mapper/volumeGroup-*
brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
brw------- 1 root root 254, 12 29 ago 18:16 /dev/mapper/volumeGroup-base-cow
brw------- 1 root root 254, 10 29 ago 18:16 /dev/mapper/volumeGroup-base
How to determine when a merging is complete
===========================================
The snapshot-merge and snapshot status lines end with:
<sectors_allocated>/<total_sectors> <metadata_sectors>
Both <sectors_allocated> and <total_sectors> include both data and metadata.
During merging, the number of sectors allocated gets smaller and
smaller. Merging has finished when the number of sectors holding data
is zero, in other words <sectors_allocated> == <metadata_sectors>.
Here is a practical example (using a hybrid of lvm and dmsetup commands):
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup owi-a- 4.00g
snap volumeGroup swi-a- 1.00g base 18.97
# dmsetup status volumeGroup-snap
0 8388608 snapshot 397896/2097152 1560
^^^^ metadata sectors
# lvconvert --merge -b volumeGroup/snap
Merging of volume snap started.
# lvs volumeGroup/snap
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup Owi-a- 4.00g 17.23
# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 281688/2097152 1104
# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 180480/2097152 712
# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 16/2097152 16
Merging has finished.
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup owi-a- 4.00g

58
doc/kernel/striped.txt Normal file
View File

@ -0,0 +1,58 @@
dm-stripe
=========
Device-Mapper's "striped" target is used to create a striped (i.e. RAID-0)
device across one or more underlying devices. Data is written in "chunks",
with consecutive chunks rotating among the underlying devices. This can
potentially provide improved I/O throughput by utilizing several physical
devices in parallel.
Parameters: <num devs> <chunk size> [<dev path> <offset>]+
<num devs>: Number of underlying devices.
<chunk size>: Size of each chunk of data. Must be a power-of-2 and at
least as large as the system's PAGE_SIZE.
<dev path>: Full pathname to the underlying block-device, or a
"major:minor" device-number.
<offset>: Starting sector within the device.
One or more underlying devices can be specified. The striped device size must
be a multiple of the chunk size and a multiple of the number of underlying
devices.
Example scripts
===============
[[
#!/usr/bin/perl -w
# Create a striped device across any number of underlying devices. The device
# will be called "stripe_dev" and have a chunk-size of 128k.
my $chunk_size = 128 * 2;
my $dev_name = "stripe_dev";
my $num_devs = @ARGV;
my @devs = @ARGV;
my ($min_dev_size, $stripe_dev_size, $i);
if (!$num_devs) {
die("Specify at least one device\n");
}
$min_dev_size = `blockdev --getsize $devs[0]`;
for ($i = 1; $i < $num_devs; $i++) {
my $this_size = `blockdev --getsize $devs[$i]`;
$min_dev_size = ($min_dev_size < $this_size) ?
$min_dev_size : $this_size;
}
$stripe_dev_size = $min_dev_size * $num_devs;
$stripe_dev_size -= $stripe_dev_size % ($chunk_size * $num_devs);
$table = "0 $stripe_dev_size striped $num_devs $chunk_size";
for ($i = 0; $i < $num_devs; $i++) {
$table .= " $devs[$i] 0";
}
`echo $table | dmsetup create $dev_name`;
]]

View File

@ -0,0 +1,285 @@
Introduction
============
This document descibes a collection of device-mapper targets that
between them implement thin-provisioning and snapshots.
The main highlight of this implementation, compared to the previous
implementation of snapshots, is that it allows many virtual devices to
be stored on the same data volume. This simplifies administration and
allows the sharing of data between volumes, thus reducing disk usage.
Another significant feature is support for an arbitrary depth of
recursive snapshots (snapshots of snapshots of snapshots ...). The
previous implementation of snapshots did this by chaining together
lookup tables, and so performance was O(depth). This new
implementation uses a single data structure to avoid this degradation
with depth. Fragmentation may still be an issue, however, in some
scenarios.
Metadata is stored on a separate device from data, giving the
administrator some freedom, for example to:
- Improve metadata resilience by storing metadata on a mirrored volume
but data on a non-mirrored one.
- Improve performance by storing the metadata on SSD.
Status
======
These targets are very much still in the EXPERIMENTAL state. Please
do not yet rely on them in production. But do experiment and offer us
feedback. Different use cases will have different performance
characteristics, for example due to fragmentation of the data volume.
If you find this software is not performing as expected please mail
dm-devel@redhat.com with details and we'll try our best to improve
things for you.
Userspace tools for checking and repairing the metadata are under
development.
Cookbook
========
This section describes some quick recipes for using thin provisioning.
They use the dmsetup program to control the device-mapper driver
directly. End users will be advised to use a higher-level volume
manager such as LVM2 once support has been added.
Pool device
-----------
The pool device ties together the metadata volume and the data volume.
It maps I/O linearly to the data volume and updates the metadata via
two mechanisms:
- Function calls from the thin targets
- Device-mapper 'messages' from userspace which control the creation of new
virtual devices amongst other things.
Setting up a fresh pool device
------------------------------
Setting up a pool device requires a valid metadata device, and a
data device. If you do not have an existing metadata device you can
make one by zeroing the first 4k to indicate empty metadata.
dd if=/dev/zero of=$metadata_dev bs=4096 count=1
The amount of metadata you need will vary according to how many blocks
are shared between thin devices (i.e. through snapshots). If you have
less sharing than average you'll need a larger-than-average metadata device.
As a guide, we suggest you calculate the number of bytes to use in the
metadata device as 48 * $data_dev_size / $data_block_size but round it up
to 2MB if the answer is smaller. The largest size supported is 16GB.
If you're creating large numbers of snapshots which are recording large
amounts of change, you may need find you need to increase this.
Reloading a pool table
----------------------
You may reload a pool's table, indeed this is how the pool is resized
if it runs out of space. (N.B. While specifying a different metadata
device when reloading is not forbidden at the moment, things will go
wrong if it does not route I/O to exactly the same on-disk location as
previously.)
Using an existing pool device
-----------------------------
dmsetup create pool \
--table "0 20971520 thin-pool $metadata_dev $data_dev \
$data_block_size $low_water_mark"
$data_block_size gives the smallest unit of disk space that can be
allocated at a time expressed in units of 512-byte sectors. People
primarily interested in thin provisioning may want to use a value such
as 1024 (512KB). People doing lots of snapshotting may want a smaller value
such as 128 (64KB). If you are not zeroing newly-allocated data,
a larger $data_block_size in the region of 256000 (128MB) is suggested.
$data_block_size must be the same for the lifetime of the
metadata device.
$low_water_mark is expressed in blocks of size $data_block_size. If
free space on the data device drops below this level then a dm event
will be triggered which a userspace daemon should catch allowing it to
extend the pool device. Only one such event will be sent.
Resuming a device with a new table itself triggers an event so the
userspace daemon can use this to detect a situation where a new table
already exceeds the threshold.
Thin provisioning
-----------------
i) Creating a new thinly-provisioned volume.
To create a new thinly- provisioned volume you must send a message to an
active pool device, /dev/mapper/pool in this example.
dmsetup message /dev/mapper/pool 0 "create_thin 0"
Here '0' is an identifier for the volume, a 24-bit number. It's up
to the caller to allocate and manage these identifiers. If the
identifier is already in use, the message will fail with -EEXIST.
ii) Using a thinly-provisioned volume.
Thinly-provisioned volumes are activated using the 'thin' target:
dmsetup create thin --table "0 2097152 thin /dev/mapper/pool 0"
The last parameter is the identifier for the thinp device.
Internal snapshots
------------------
i) Creating an internal snapshot.
Snapshots are created with another message to the pool.
N.B. If the origin device that you wish to snapshot is active, you
must suspend it before creating the snapshot to avoid corruption.
This is NOT enforced at the moment, so please be careful!
dmsetup suspend /dev/mapper/thin
dmsetup message /dev/mapper/pool 0 "create_snap 1 0"
dmsetup resume /dev/mapper/thin
Here '1' is the identifier for the volume, a 24-bit number. '0' is the
identifier for the origin device.
ii) Using an internal snapshot.
Once created, the user doesn't have to worry about any connection
between the origin and the snapshot. Indeed the snapshot is no
different from any other thinly-provisioned device and can be
snapshotted itself via the same method. It's perfectly legal to
have only one of them active, and there's no ordering requirement on
activating or removing them both. (This differs from conventional
device-mapper snapshots.)
Activate it exactly the same way as any other thinly-provisioned volume:
dmsetup create snap --table "0 2097152 thin /dev/mapper/pool 1"
Deactivation
------------
All devices using a pool must be deactivated before the pool itself
can be.
dmsetup remove thin
dmsetup remove snap
dmsetup remove pool
Reference
=========
'thin-pool' target
------------------
i) Constructor
thin-pool <metadata dev> <data dev> <data block size (sectors)> \
<low water mark (blocks)> [<number of feature args> [<arg>]*]
Optional feature arguments:
- 'skip_block_zeroing': skips the zeroing of newly-provisioned blocks.
Data block size must be between 64KB (128 sectors) and 1GB
(2097152 sectors) inclusive.
ii) Status
<transaction id> <used metadata blocks>/<total metadata blocks>
<used data blocks>/<total data blocks> <held metadata root>
transaction id:
A 64-bit number used by userspace to help synchronise with metadata
from volume managers.
used data blocks / total data blocks
If the number of free blocks drops below the pool's low water mark a
dm event will be sent to userspace. This event is edge-triggered and
it will occur only once after each resume so volume manager writers
should register for the event and then check the target's status.
held metadata root:
The location, in sectors, of the metadata root that has been
'held' for userspace read access. '-' indicates there is no
held root. This feature is not yet implemented so '-' is
always returned.
iii) Messages
create_thin <dev id>
Create a new thinly-provisioned device.
<dev id> is an arbitrary unique 24-bit identifier chosen by
the caller.
create_snap <dev id> <origin id>
Create a new snapshot of another thinly-provisioned device.
<dev id> is an arbitrary unique 24-bit identifier chosen by
the caller.
<origin id> is the identifier of the thinly-provisioned device
of which the new device will be a snapshot.
delete <dev id>
Deletes a thin device. Irreversible.
trim <dev id> <new size in sectors>
Delete mappings from the end of a thin device. Irreversible.
You might want to use this if you're reducing the size of
your thinly-provisioned device. In many cases, due to the
sharing of blocks between devices, it is not possible to
determine in advance how much space 'trim' will release. (In
future a userspace tool might be able to perform this
calculation.)
set_transaction_id <current id> <new id>
Userland volume managers, such as LVM, need a way to
synchronise their external metadata with the internal metadata of the
pool target. The thin-pool target offers to store an
arbitrary 64-bit transaction id and return it on the target's
status line. To avoid races you must provide what you think
the current transaction id is when you change it with this
compare-and-swap message.
'thin' target
-------------
i) Constructor
thin <pool dev> <dev id>
pool dev:
the thin-pool device, e.g. /dev/mapper/my_pool or 253:0
dev id:
the internal device identifier of the device to be
activated.
The pool doesn't store any size against the thin devices. If you
load a thin target that is smaller than you've been using previously,
then you'll have no access to blocks mapped beyond the end. If you
load a target that is bigger than before, then extra blocks will be
provisioned as and when needed.
If you wish to reduce the size of your thin device and potentially
regain some space then send the 'trim' message to the pool.
ii) Status
<nr mapped sectors> <highest mapped sector>

Some files were not shown because too many files have changed in this diff Show More