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

2362 Commits

Author SHA1 Message Date
Alasdair Kergon
df390f1799 Major pvmove fix to issue ioctls in the correct order when multiple LVs
are affected by the move.  (Currently it's possible for I/O to become
trapped between suspended devices amongst other problems.

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

Some lvconvert scenarios still suffer from related problems.
2011-06-11 00:03:06 +00:00
Milan Broz
4fb39ae074 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
Peter Rajnoha
afc8a3b104 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
Alasdair Kergon
bb056af3c9 missing space in mesg 2011-06-06 12:08:42 +00:00
Alasdair Kergon
0ebd0960b4 Propagate test mode to clvmd to skip activation and changes to held locks. 2011-06-01 21:16:55 +00:00
Alasdair Kergon
3cac20f850 Defer writing PV labels to vg_write.
Store label_sector only in struct physical_volume.
2011-06-01 19:29:31 +00:00
Alasdair Kergon
2aa785c85f Report sector containing label in verbose message. 2011-06-01 19:26:38 +00:00
Alasdair Kergon
453cdee51c Permit --available with lvcreate so non-snapshot LVs need not be activated. 2011-06-01 19:21:03 +00:00
Alasdair Kergon
677ec408bf Report sector containing label in verbose message. 2011-06-01 15:30:36 +00:00
Peter Rajnoha
c08c564e21 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
Alasdair Kergon
564360c195 test 2011-05-24 14:10:55 +00:00
Alasdair Kergon
2d56f030f0 test 2011-05-24 14:09:41 +00:00
Alasdair Kergon
972d37f570 test 2011-05-24 14:00:57 +00:00
Alasdair Kergon
33bd9138fa test 2011-05-24 13:53:26 +00:00
Alasdair Kergon
0b70507434 Add and use dev_open_readonly and variations. 2011-05-24 13:36:57 +00:00
Peter Rajnoha
5fb0c20297 Do not issue an error message when unable to remove .cache on read-only fs. 2011-05-12 12:42:47 +00:00
Petr Rockai
eee66d2a80 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
Petr Rockai
833a287337 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
Alasdair Kergon
5510b4e7d7 test update without WHATS_NEW to check it gives warning now 2011-04-29 19:06:17 +00:00
Alasdair Kergon
4cda44bfb9 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
Alasdair Kergon
919ab56b6d pre-release clean-ups 2011-04-29 00:21:13 +00:00
Alasdair Kergon
9cda028a96 clean up critical section patch 2011-04-28 20:29:59 +00:00
Zdenek Kabelac
96c4abee62 Missing space in debug message 2011-04-28 19:59:17 +00:00
Alasdair Kergon
2c56f60db4 Set pv_min_size to 2048KB to exclude floppy drives.
Previously was 512.
2011-04-28 17:33:34 +00:00
Peter Rajnoha
edcda01a1e 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
Peter Rajnoha
40059f18d9 Move common libudev code to lvm-wrappers.[ch].
...so we can use it throughout.
2011-04-22 11:59:59 +00:00
Zdenek Kabelac
5c246f4876 Skip check for NULL before dm_free
dm_free makes this test itself.
2011-04-21 13:15:26 +00:00
Zdenek Kabelac
b680d5bf7b 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
Mike Snitzer
ffcb1b9c2c 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
Mike Snitzer
727373c176 Use uint32_t rather than uint64_t. 2011-04-12 22:04:04 +00:00
Mike Snitzer
fdc8670327 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
Zdenek Kabelac
96077265c4 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
Petr Rockai
db22d9b978 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
Zdenek Kabelac
c67d2b4dd4 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
Zdenek Kabelac
a1eba521e3 Fix some unmatching sign comparation gcc warnings
Simple replacement for unsigned type - usually in for() loops.
2011-04-08 14:40:18 +00:00
Zdenek Kabelac
2c5827076b 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
Zdenek Kabelac
040cdff1d4 Better const cast logic
(although still gcc gives const violation warning)
2011-04-08 14:14:57 +00:00
Zdenek Kabelac
45109d497c Fix some forgotten -Wold-style-definition gcc warnings 2011-04-08 14:13:08 +00:00
Zdenek Kabelac
e42cb2f892 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
Jonathan Earl Brassow
532e6c8ae3 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
Jonathan Earl Brassow
fe93c99ad9 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
Peter Rajnoha
29684f590c 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
Zdenek Kabelac
3d04380691 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
Zdenek Kabelac
d992bbbaa3 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
Zdenek Kabelac
a66bff47f1 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
Zdenek Kabelac
df336e72d2 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
Zdenek Kabelac
01fb91c615 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
Zdenek Kabelac
142d2e8740 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
Zdenek Kabelac
1bedd3a97b Use id_equal instead of strncmp()
More consistent and easier to read.
2011-03-29 21:57:56 +00:00
Zdenek Kabelac
3aef5ae7fb 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