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

7776 Commits

Author SHA1 Message Date
Zdenek Kabelac
4eb8db26ac cleanup: convert set of strncat into a single printf
Use single snprintf for better control of used bufsize,
and also increased buffer to 128char to ensure all
chars will always fit.
2013-04-21 23:14:05 +02:00
Zdenek Kabelac
4e1ac7faf1 cleanup: add some FIXMEs 2013-04-21 23:14:05 +02:00
Zdenek Kabelac
dfca5dac9c cleanup: explicit check for nonnull pointer
Since execvp requires nonnull args - add explicit check.
2013-04-21 23:14:05 +02:00
Zdenek Kabelac
dd4fdce16c cleanup: drop unused assignment
Assigned values are unused.
2013-04-21 23:14:04 +02:00
Zdenek Kabelac
1951798d72 vgread: fix fid transfer for lvm1 and pool format
Assign fid as the last step before returning VG.
Make the format reader for 'lvm1' and 'pool' equal to 'lvm2' format reader.

It has caused memory corruption to lvmetad as it later calls
destroy_instance() to allocated fid. This patch should fix problems
with crashing test lvmetad-lvm1.sh.
2013-04-21 23:13:57 +02:00
Zdenek Kabelac
5e7eae59da lv_manip: check remove_seg_from_segs_using_this_lv()
Add missing check for result of remove_seg_from_segs_using_this_lv().
Failure is reported as internal error.
2013-04-21 23:10:43 +02:00
Zdenek Kabelac
8f1dd00c36 libdm: improve check in dm_split_lvm_name
We support both type of call - with or without mem pool.
So ensure we will not use NULL vgname also when mem is given.
2013-04-21 23:10:43 +02:00
Zdenek Kabelac
a2b76a6f02 thin: fix resource leak in err path
If the devices list could not have been obtained, FILE* was leaked.
2013-04-21 23:10:30 +02:00
Zdenek Kabelac
17a6915054 thin: explicitly avoid pvmove operation
So far we do not support pvmove for thin volumes
and thin pools.
2013-04-21 23:09:11 +02:00
Zdenek Kabelac
78a42bac15 thin: fix cut&paste bug
Use proper external_lv.
(In release fix)
2013-04-21 23:07:00 +02:00
Zdenek Kabelac
24f8daa13d raid: test for target_pvs
If target_pvs is NULL do not call lv_is_on_pvs()
2013-04-21 23:07:00 +02:00
Zdenek Kabelac
9e24d563c6 raid: read segment only for known LV
Avoid reading first_seg() on unknown LV and find it only when needed.
2013-04-21 23:07:00 +02:00
Zdenek Kabelac
4ca6a4105d thin: lvcreate better support for AAY
Test rather for changes which are deactivating.
2013-04-21 23:06:23 +02:00
Zdenek Kabelac
f787b575b5 lvmetad: fix error paths
Also add missing goto out on error.
Error path missed return NULL leading to double free of enc_value.
2013-04-21 23:04:53 +02:00
Zdenek Kabelac
377e06b0f8 lvmetad: cleanup
Move individual assignments to simplier structure setup.
2013-04-21 23:02:43 +02:00
Zdenek Kabelac
bee3f4b930 dmeventd: cleanup
Drop unneeded reset of data pointer to NULL, since this if() code path
is executed when data is NULL.
2013-04-21 23:02:43 +02:00
Zdenek Kabelac
8184a57c2b dmeventd: prevent double free
Since device.name is relased on more places, mark already
released name with NULL.
2013-04-21 23:02:36 +02:00
Zdenek Kabelac
5ea466673a dmeventd: convert union to struct members
Sharing char* with field has a problem in error path,
when we allocate event, but fail to allocate timeout string.
Instead of creating complicated error paths to resolve
it individually stop using unions, and let the resource
to be released in a simple _free_message().
2013-04-21 23:01:35 +02:00
Zdenek Kabelac
45f396f2a0 dmeventd: check for msg.data nonnull
Ensure we will not use  msg.data as NULL for strchr.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
ba3cee3630 config: check for hash success
Hash insert may fail.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
5070ffbca7 clvmd: avoid logging in signal handler
debuglog in the main thread.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
61d0ae7019 clvmd: use pclose
For popened FILE use pclose.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
0125518d6d clvmd: preserve foreground mode across restart
Keep clvmd in foreground when restarted.
Useful for testing.
2013-04-21 22:56:48 +02:00
Zdenek Kabelac
c9d8d22224 clmvd: fix responce status
Failing status code is expected to be 0.
Also do not return '*response' as pointer which has been already free().
2013-04-21 22:54:42 +02:00
Peter Rajnoha
764195207d udev: also autoactivate on coldplug
Commit 756bcabbfe fixed autoactivation
to not trigger on each uevent for a PV that appeared in the system
most notably the events that are triggered artificially (udevadm
trigger or as the result of the WATCH udev rule being applied that
consequently generates CHANGE uevents). This fixed a situation in
which VGs/LVs were activated when they should not.

BUT we still need to care about the coldplug used at boot to
retrigger the ADD events - the "udevadm trigger --action=add"!

For non-DM-based PVs, this is already covered as for these we
run the autoactivation on ADD event only.

However, for DM-based PVs, we still need to run the
autoactivation even for the artificial ADD event, reusing
the udev DB content from previous proper CHANGE event that
came with the DM device activation.

Simply, this patch fixes a situation in which we run extra
"udevadm trigger --action=add" (or echo add > /sys/block/<dev>/uevent)
for DM-based PVs (cryptsetup devices, multipath devices, any
other DM devices...).

Without this patch, while using lvmetad + autoactivation,
any VG/LV that has a DM-based PV and for which we do not
call the activation directly, the VG/LV is not activated.

For example a VG with an LV with root FS on it which is directly
activated in initrd and then missing activation of the rest
of the LVs in the VG because of unhandled uevent retrigger on
boot after switching to root FS (the "coldplug").

(No WHATS_NEW here as this fixes the commit mentioned
above and which was not released yet.)
2013-04-19 12:43:36 +02:00
Tony Asleson
2ccb9eb861 config_def_check: fix memory leak
There is no need to strdup a key when inserting into
the hash table as the table allocates memory and copies
the string.  This was causing memory to be lost.
2013-04-16 10:45:37 +02:00
Jonathan Brassow
2e0740f7ef RAID: Add writemostly/writebehind support for RAID1
'lvchange' is used to alter a RAID 1 logical volume's write-mostly and
write-behind characteristics.  The '--writemostly' parameter takes a
PV as an argument with an optional trailing character to specify whether
to set ('y'), unset ('n'), or toggle ('t') the value.  If no trailing
character is given, it will set the flag.
Synopsis:
        lvchange [--writemostly <PV>:{t|y|n}] [--writebehind <count>] vg/lv
Example:
        lvchange --writemostly /dev/sdb1:y --writebehind 512 vg/raid1_lv

The last character in the 'lv_attr' field is used to show whether a device
has the WriteMostly flag set.  It is signified with a 'w'.  If the device
has failed, the 'p'artial flag has priority.

Example ("nosync" raid1 with mismatch_cnt and writemostly):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   Rwi---r-m    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-w    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r--    1 linear   4.00m

Example (raid1 with mismatch_cnt, writemostly - but failed drive):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   rwi---r-p    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-p    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r-p    1 linear   4.00m

A new reportable field has been added for writebehind as well.  If
write-behind has not been set or the LV is not RAID1, the field will
be blank.
Example (writebehind is set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--     512
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--

Example (writebehind is not set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--
2013-04-15 13:59:46 -05:00
Petr Rockai
dce8d06af7 libdaemon: Print a diagnostic when we fail to lock the pidfile. 2013-04-15 16:07:07 +02:00
Alasdair G Kergon
9495a3d807 Revert "cleanup: simplify option matching function"
This reverts commit 0396ade38b.

The original code also handled len==1, which the new code doesn't.
Press <TAB> in the lvm shell to get a list of the possible
flag completions for a single hyphen.
2013-04-13 02:26:37 +01:00
Jonathan Brassow
c363c74a25 CLEAN-UP: Better string checking to avoid substring matches
Commit 9fd7ac7d03 introduced a way a
method of avoiding reading from mirrors with a device failure.  If
a device was found to be dead, the mapping table was checked for
'handle_errors' or 'block_on_error'.  These strings were checked for
in the table string via 'strstr', which could also match on strings
like, 'no_handle_errors' or 'no_block_on_error'.  No such strings
exist, but we don't want to have problems in the future if they do.
So, we check for ' <string>{'\0'|' '}'.
2013-04-12 11:30:04 -05:00
Zdenek Kabelac
58734d2538 dmsetup: check for strncpy
Test whether device name fits into a given buffer.
2013-04-12 11:30:47 +02:00
Zdenek Kabelac
a81a2406f1 tools: add common lv_change_activate
Move common code for changing activation state from
vgchange and lvchange to one function.

Fix the order of checks - so we always implicitelly
activate snapshots and thin volumes in exclusive mode,
and we do not allow local deactivation for them.
2013-04-12 11:30:07 +02:00
Zdenek Kabelac
698137ec38 cleanup: add gcc attribute for printf parameter 2013-04-12 11:26:31 +02:00
Zdenek Kabelac
2e39392daf cleanup: remove unused lvl_idx 2013-04-12 11:26:31 +02:00
Zdenek Kabelac
4cce09dbdb lvmcache: keep sp_count unsigned 2013-04-12 11:26:31 +02:00
Jonathan Brassow
719e908bc0 WHATS_NEW: Add WHATS_NEW entry for previous commit. 2013-04-11 16:03:24 -05:00
Jonathan Brassow
faeea37057 RAID: Revert previous commit that allowed identical table loads.
Revert commit 31c24dd9f2.  This commit
was used to force a RAID device-mapper table to be loaded into the
kernel despite the fact that it was identical to the one already
loaded.  The effect allowed a RAID array with a transiently failed
device to refresh and reintegrate the failed device.  This operation
is better done in the kernel on a 'resume'.  Since,
'lvchange --refresh' already performs a suspend/resume cycle, the
above commit is not needed once the kernel change is made.  Reverting
the commit removes an unnecessary (at least for now) change to the
device-mapper interface.
2013-04-11 15:57:14 -05:00
Jonathan Brassow
ff64e3500f RAID: Add scrubbing support for RAID LVs
New options to 'lvchange' allow users to scrub their RAID LVs.
Synopsis:
	lvchange --syncaction {check|repair} vg/raid_lv

RAID scrubbing is the process of reading all the data and parity blocks in
an array and checking to see whether they are coherent.  'lvchange' can
now initaite the two scrubbing operations: "check" and "repair".  "check"
will go over the array and recored the number of discrepancies but not
repair them.  "repair" will correct the discrepancies as it finds them.

'lvchange --syncaction repair vg/raid_lv' is not to be confused with
'lvconvert --repair vg/raid_lv'.  The former initiates a background
synchronization operation on the array, while the latter is designed to
repair/replace failed devices in a mirror or RAID logical volume.

Additional reporting has been added for 'lvs' to support the new
operations.  Two new printable fields (which are not printed by
default) have been added: "syncaction" and "mismatches".  These
can be accessed using the '-o' option to 'lvs', like:
	lvs -o +syncaction,mismatches vg/lv
"syncaction" will print the current synchronization operation that the
RAID volume is performing.  It can be one of the following:
        - idle:   All sync operations complete (doing nothing)
        - resync: Initializing an array or recovering after a machine failure
        - recover: Replacing a device in the array
        - check: Looking for array inconsistencies
        - repair: Looking for and repairing inconsistencies
The "mismatches" field with print the number of descrepancies found during
a check or repair operation.

The 'Cpy%Sync' field already available to 'lvs' will print the progress
of any of the above syncactions, including check and repair.

Finally, the lv_attr field has changed to accomadate the scrubbing operations
as well.  The role of the 'p'artial character in the lv_attr report field
as expanded.  "Partial" is really an indicator for the health of a
logical volume and it makes sense to extend this include other health
indicators as well, specifically:
        'm'ismatches:  Indicates that there are discrepancies in a RAID
                       LV.  This character is shown after a scrubbing
                       operation has detected that portions of the RAID
                       are not coherent.
        'r'efresh   :  Indicates that a device in a RAID array has suffered
                       a failure and the kernel regards it as failed -
                       even though LVM can read the device label and
                       considers the device to be ok.  The LV should be
                       'r'efreshed to notify the kernel that the device is
                       now available, or the device should be 'r'eplaced
                       if it is suspected of failing.
2013-04-11 15:33:59 -05:00
Peter Rajnoha
e7ccad2ef0 config: remove typo in handling devices/write_cache_state config
...which caused the cmd->dump_filter to be always set irrespective
of the actual devices/write_cache_state setting.
2013-04-11 16:32:10 +02:00
Petr Rockai
91c9771fc3 test: Re-instate exec in lvm-wrapper, catching crashes inside not. 2013-04-11 16:22:35 +02:00
Jonathan Brassow
cbcbb67731 mirror: Fix overly-concerning warning on mirror up-convert failure.
Attempting to up-convert an inactive mirror when there is insufficient
space leads to the following message:
  Unable to allocate extents for mirror(s).
  ABORTING: Failed to remove temporary mirror layer inactive_mimagetmp_3.
  Manual cleanup with vgcfgrestore and dmsetup may be required.
This is caused by a failure to execute the 'deactivate_lv' function in
the error condition.  The deactivate returns an error because the LV is
already inactive.  This patch checks if the LV is activate and calls
deactivate_lv only if it is.  This allows the error cleanup code to work
properly in this condition.

It wasn't that big of a deal anyway, since there was no previous vg_commit
that needed to be reverted.  IOW, no harm was done if the allocation failed.
The message was scary and useless.
2013-04-10 16:47:04 -05:00
Jonathan Brassow
95d28735ea WHATS_NEW: Include entry for RAID status func improvements 2013-04-08 15:17:12 -05:00
Jonathan Brassow
38f8f4a958 RAID: Capture new RAID kernel sync_action status fields
I've updated the dm_status_raid structure and dm_get_status_raid()
function to make it handle the new kernel status fields that will
be coming in dm-raid v1.5.0.  It is backwards compatible with the
old status line - initializing the new fields to '0'.  The new
structure is also more amenable to future changes.  It includes a
'reserved' field that is currently initialized to zero but could
be used to hold flags describing new features.  It also now uses
pointers for the character strings instead of attempting to allocate
their space along with the structure (causing the size of the
structure to be variable).  This allows future fields to be appended.

The new fields that are available are:
 - sync_action : shows what the sync thread in the kernel is doing
                 (idle, frozen, resync, recover, check, repair, or
                 reshape)
 - mismatch_count: shows the number of discrepancies which were
                   found or repaired by a "check" or "repair"
                   process, respectively.
2013-04-08 15:04:08 -05:00
Zdenek Kabelac
c22e925ce4 man: lvceate document external origin snapshot
Document added support for external origin.
2013-04-05 14:15:03 +02:00
Zdenek Kabelac
ddafa0115e man: updates for lvconvert and lvcreate
Cleanup and improvement on man pages.
2013-04-05 14:14:20 +02:00
Zdenek Kabelac
3fd0242a0a libdm: validate params for NULL
Validate passed params and report error
instead of dereferencing NULL passed argument.
2013-04-05 14:13:12 +02:00
Petr Rockai
72921d7922 test: Invalidate .cache after vgimportclone. 2013-04-03 22:08:46 +02:00
Petr Rockai
95372a852b lvmetad: Fix a memory leak introduced in 15fdd5c90d. 2013-04-03 13:46:12 +02:00
Petr Rockai
382fc878d7 lvmetad: Check for reappeared PVs. 2013-04-03 12:48:28 +02:00
Petr Rockai
00ed6759c8 lvmetad: Mark PVs visible to lvmetad but not to us as MISSING. 2013-04-03 11:40:29 +02:00