]> sourceware.org Git - lvm2.git/log
lvm2.git
11 years agoRAID: Make 'vgreduce --removemissing' work with RAID LVs
Jonathan Brassow [Wed, 20 Feb 2013 20:52:46 +0000 (14:52 -0600)]
RAID: Make 'vgreduce --removemissing' work with RAID LVs

Currently it is impossible to remove a failed PV which has a RAID LV
on it.  This patch fixes the issue by replacing the failed PV with an
'error' segment within the affected sub-LVs.  Once there is no longer
a RAID LV using the PV, it can be removed.

Most often, it is better to replace a failed RAID device with a spare.
(You can use 'lvconvert --repair <vg>/<LV>' to accomplish that.)
However, if there are no spares in the volume group and none will be
added, it is useful to be able to removed the failed device.

Following patches address the ability to perform 'lvconvert' operations
on RAID LVs that contain sub-LVs composed of 'error' segments.

11 years agoclean-up: Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'
Jonathan Brassow [Wed, 20 Feb 2013 20:40:17 +0000 (14:40 -0600)]
clean-up:  Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'

We have been using 'mirror_region_size' in lvm.conf as the default region
size for RAID logical volumes as well as mirror logical volumes.  Since,
"raid" is more inclusive and representative than "mirror", I have changed
the name of this setting.  We must still check for the old setting and warn
the user if we are overriding it with the new setting if both happen to be
present.

11 years agofix: 'Couldn't read extent size' --> '... extent start'
Peter Rajnoha [Thu, 21 Feb 2013 12:33:27 +0000 (13:33 +0100)]
fix: 'Couldn't read extent size' --> '... extent start'

11 years agoreport: fix pvs -o pv_free reporting for PVs with 0 PEs
Peter Rajnoha [Thu, 21 Feb 2013 12:28:07 +0000 (13:28 +0100)]
report: fix pvs -o pv_free reporting for PVs with 0 PEs

[0] raw/~ # lsblk -o NAME,SIZE /dev/sda
NAME  SIZE
sda   128M

[0] raw/~ # pvcreate --dataalignment 128m /dev/sda
  Physical volume "/dev/sda" successfully created

[0] raw/~ # vgcreate vg /dev/sda
  Volume group "vg" successfully created

[0] raw/~ # lvcreate -l1 vg
  Volume group "vg" has insufficient free space (0 extents): 1 required.

Before this patch:
[0] raw/~ # pvs -o pv_name,pv_free
  PV         PFree
  /dev/sda   128.00m

After this patch:
[0] raw/~ # pvs -o pv_name,pv_free
  PV         PFree
  /dev/sda      0

11 years agocleanup: old style gcc
Zdenek Kabelac [Tue, 5 Feb 2013 15:48:48 +0000 (16:48 +0100)]
cleanup: old style gcc

11 years agocleanup: preserve signesss and type size on return values
Zdenek Kabelac [Tue, 5 Feb 2013 15:43:16 +0000 (16:43 +0100)]
cleanup: preserve signesss and type size on return values

11 years agothin: update pool_is_active
Zdenek Kabelac [Tue, 5 Feb 2013 15:49:09 +0000 (16:49 +0100)]
thin: update pool_is_active

Change it to take LV and move it to exported header - seems
to be a better fit for usability from tools/ directory.

11 years agothin: properly unmark volume after detach
Zdenek Kabelac [Tue, 5 Feb 2013 10:07:09 +0000 (11:07 +0100)]
thin: properly unmark volume after detach

When the volume is detached form thin pool,
unmask THIN_VOLUME flag and reset related pointers.

11 years agotest: update using exclusive activation
Zdenek Kabelac [Tue, 5 Feb 2013 08:20:17 +0000 (09:20 +0100)]
test: update using exclusive activation

For testing in cluster exclusive activation of origin is needed.

11 years agothin: fix forbidden discards checks
Zdenek Kabelac [Sat, 2 Feb 2013 11:48:52 +0000 (12:48 +0100)]
thin: fix forbidden discards checks

Instead of check for lv_is_active() for thin pool LV,
query the whole pool via new  pool_is_active().

Fixes a problem when we cannot change discards settings
for active pool device where the actual layer for pool
device was inactive, but thin volumes using thin pool
have been active.

11 years agothin: add function pool_is_active
Zdenek Kabelac [Tue, 5 Feb 2013 09:52:39 +0000 (10:52 +0100)]
thin: add function pool_is_active

This internal function check for active pool device.
For cluster it checks every thin volume,
On the non-clustered VG we need to check just
for presence of -tpool device.

11 years agoreport: leave empty report field for 0
Zdenek Kabelac [Tue, 5 Feb 2013 12:59:15 +0000 (13:59 +0100)]
report: leave empty report field for 0

Since we do not support LVs with 0 size, use this value
as 'error' value for devices without origin, and leave this
field blank as in other cases.

11 years agolvconvert: update error path
Zdenek Kabelac [Tue, 5 Feb 2013 10:21:21 +0000 (11:21 +0100)]
lvconvert: update error path

Update the error path after problems with suspend_lv or vg_commit.
It's not exactly well defined what should happen, and this
code seems to appear in many different instancies<F2> in the
whole source code tree - we should probably pick the best version.

11 years agolvconvert: fix accepting second lv name
Zdenek Kabelac [Mon, 4 Feb 2013 12:56:54 +0000 (13:56 +0100)]
lvconvert: fix accepting second lv name

Do not allow to accept second LV name on lvconvert --thinpool
command line.

11 years agoheaders: add headers for musl libc
Zdenek Kabelac [Tue, 5 Feb 2013 08:33:30 +0000 (09:33 +0100)]
headers: add headers for musl libc

On glibc, those are erroneously (namespace pollution) pulled in via
other headers. this doesn't work with conformant libcs (musl libc in
this case), we simply need to include all needed headers.

Signed-Off-By: John Spencer <maillist-lvm@barfooze.de>
11 years agocleanup: avoid overflow warning
Zdenek Kabelac [Mon, 4 Feb 2013 19:32:21 +0000 (20:32 +0100)]
cleanup: avoid overflow warning

Even we do not expect to support chunks bigger then 2GB.

11 years agocleanup: remove extra braces
Zdenek Kabelac [Mon, 4 Feb 2013 19:31:56 +0000 (20:31 +0100)]
cleanup: remove extra braces

11 years agocleanup: malloc attributes
Zdenek Kabelac [Mon, 4 Feb 2013 19:29:59 +0000 (20:29 +0100)]
cleanup: malloc attributes

11 years agocleanup: add internal error check
Zdenek Kabelac [Fri, 14 Dec 2012 18:42:28 +0000 (19:42 +0100)]
cleanup: add internal error check

Check if 'is_removable' is defined and report internal error,
if it's missing.

11 years agoclean-up: Another functiont that can use 'lv_layer'
Jonathan Brassow [Mon, 4 Feb 2013 23:10:16 +0000 (17:10 -0600)]
clean-up:  Another functiont that can use 'lv_layer'

lib/activate/dev_manager.c:dev_manager_raid_status() can also use
the new 'lv_layer' function.

11 years agothin: use noflush for obtaining transaction_id
Zdenek Kabelac [Thu, 17 Jan 2013 09:54:41 +0000 (10:54 +0100)]
thin: use noflush for obtaining transaction_id

Do not flush thin pool data, when reading transation_id status.

11 years agocleanup: comment update
Zdenek Kabelac [Fri, 25 Jan 2013 14:29:42 +0000 (15:29 +0100)]
cleanup: comment update

Just update code comment and use single line if().

11 years agocleanup: indent line
Zdenek Kabelac [Sat, 19 Jan 2013 11:04:17 +0000 (12:04 +0100)]
cleanup: indent line

11 years agolibdm: support newer thin pool status parameters
Zdenek Kabelac [Mon, 10 Dec 2012 09:23:17 +0000 (10:23 +0100)]
libdm: support newer thin pool status parameters

Support read_only and discards information.

11 years agotest: regression test for lvmetad error
Zdenek Kabelac [Mon, 7 Jan 2013 09:57:59 +0000 (10:57 +0100)]
test: regression test for lvmetad error

11 years agothin: replace is_active with send_messages
Zdenek Kabelac [Thu, 17 Jan 2013 09:35:27 +0000 (10:35 +0100)]
thin: replace is_active with send_messages

Since is_active is only used for thinp
replace struct member with more meaningful
send_messages flag

11 years agouse lv_layer
Zdenek Kabelac [Fri, 1 Feb 2013 23:16:36 +0000 (00:16 +0100)]
use lv_layer

11 years agoactivate: add lv_layer function
Zdenek Kabelac [Fri, 1 Feb 2013 10:09:34 +0000 (11:09 +0100)]
activate: add lv_layer function

Add function to return layer name for LV.

11 years agolibdm: fix segault for truncated string token.
Zdenek Kabelac [Fri, 1 Feb 2013 10:07:44 +0000 (11:07 +0100)]
libdm: fix segault for truncated string token.

This patch fixes problem reported here:

https://www.redhat.com/archives/dm-devel/2013-January/msg00311.html

Fixing it by separating function for duplicating string token.

---
When /etc/lvm/lvm.conf is truncated at the first '"' of a line, all LVM
utilities crash with a segfault.

The segfault only seems to occur if the last character is the first '"'
(double quote) of a line. If you truncate it at any other point, lvm
detects the error and report parse error

lvm.conf ends like this.

$hexdump -C lvm.conf
....
69 72 20 3d 20 22 2f 64  65 76 22 0a 0a 0a 20 20  |ir = "/dev"...  |
20 20 23 20 41 6e 20 61  72 72 61 79 20 6f 66 20  |  # An array of |
64 69 72 65 63 74 6f 72  69 65 73 20 74 68 61 74  |directories that|
20 63 6f 6e 74 61 69 6e  20 74 68 65 20 64 65 76  | contain the dev|
69 63 65 20 6e 6f 64 65  73 20 79 6f 75 20 77 69  |ice nodes you wi|
73 68 0a 20 20 20 20 23  20 74 6f 20 75 73 65 20  |sh.    # to use |
77 69 74 68 20 4c 56 4d  32 2e 0a 20 20 20 20 73  |with LVM2..    s|
63 61 6e 20 3d 20 5b 20  22 2f 78 22 2c 0a 20 20  |can = [ "/x",.  |
20 20 20 20 20 20 20 20  20 20 20 22              | "|
...

Reported-by: dongmao zhang <dmzhang suse com>
11 years agocleanup: postpone lv_is_thin_volume check
Zdenek Kabelac [Fri, 1 Feb 2013 23:44:07 +0000 (00:44 +0100)]
cleanup: postpone lv_is_thin_volume check

Code move to make it easier to follow and
call _add_dev_to_dtree() in the separate if() branch
for thin volumes.

11 years agoWHATS_NEW: Better description of previous change
Jonathan Brassow [Fri, 1 Feb 2013 17:52:25 +0000 (11:52 -0600)]
WHATS_NEW:  Better description of previous change

11 years agoRAID: Improve 'lvs' attribute reporting of RAID LVs and sub-LVs
Jonathan Brassow [Fri, 1 Feb 2013 17:33:54 +0000 (11:33 -0600)]
RAID:  Improve 'lvs' attribute reporting of RAID LVs and sub-LVs

There are currently a few issues with the reporting done on RAID LVs and
sub-LVs.  The most concerning is that 'lvs' does not always report the
correct failure status of individual RAID sub-LVs (devices).  This can
occur when a device fails and is restored after the failure has been
detected by the kernel.  In this case, 'lvs' would report all devices are
fine because it can read the labels on each device just fine.
Example:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)

However, 'dmsetup status' on the device tells us a different story:
  [root@bp-01 lvm2]# dmsetup status vg-lv
  0 1024000 raid raid1 2 DA 1024000/1024000

In this case, we must also be sure to check the RAID LVs kernel status
in order to get the proper information.  Here is an example of the correct
output that is displayed after this patch is applied:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r-p   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor-p          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor-p          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)

The other case where 'lvs' gives incomplete or improper output is when a
device is replaced or added to a RAID LV.  It should display that the RAID
LV is in the process of sync'ing and that the new device is the only one
that is not-in-sync - as indicated by a leading 'I' in the Attr column.
(Remember that 'i' indicates an (i)mage that is in-sync and 'I' indicates
an (I)mage that is not in sync.)  Here's an example of the old incorrect
behaviour:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
[root@bp-01 lvm2]# lvconvert -m +1 vg/lv; lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--     0.00 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   Iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   Iwi-aor--          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)                            ** Note that all the images currently are marked as 'I' even though it is
   only the last device that has been added that should be marked.

Here is an example of the correct output after this patch is applied:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
[root@bp-01 lvm2]# lvconvert -m +1 vg/lv; lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--     0.00 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)
** Note only the last image is marked with an 'I'.  This is correct and we can
   tell that it isn't the whole array that is sync'ing, but just the new
   device.

It also works under snapshots...
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   owi-a-r-p    33.47 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   Iwi-aor-p          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor-p          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)
  snap          vg   swi-a-s--          /dev/sda1(51201)

11 years agoRAID: Cache previous results of lv_raid_dev_health for future use
Jonathan Brassow [Fri, 1 Feb 2013 17:32:18 +0000 (11:32 -0600)]
RAID:  Cache previous results of lv_raid_dev_health for future use

We can avoid many dev_manager (ioctl) calls by caching the results of
previous calls to lv_raid_dev_health.  Just considering the case where
'lvs -a' is called to get the attributes of a RAID LV and its sub-lvs,
this function would be called many times.  (It would be called at least
7 times for a 3-way RAID1 - once for the health of each sub-LV and once
for the health of the top-level LV.)  This is a good idea because the
sub-LVs are processed in groups along with their parent RAID LV and in
each case, it is the parent LV whose status will be queried.  Therefore,
there only needs to be one trip through dev_manager for each time the
group is processed.

11 years agoRAID: Add RAID status accessibility functions
Jonathan Brassow [Fri, 1 Feb 2013 17:31:47 +0000 (11:31 -0600)]
RAID:  Add RAID status accessibility functions

Similar to the way thin* accesses its kernel status, we add a method
for RAID to grab the various values in its status output without the
higher levels (LVM) having to understand how to parse the output.
Added functions include:
        - lib/activate/dev_manager.c:dev_manager_raid_status()
          Pulls the status line from the kernel

        - libdm/libdm-deptree.c:dm_get_status_raid()
          Parses status line and puts components into dm_status_raid struct

        - lib/activate/activate.c:lv_raid_dev_health()
          Accesses dm_status_raid to deliver raid dev_health string

The new structure and functions can provide a more unified way to access
status information.  ('lv_raid_percent' could switch to using these
functions, for example.)

11 years agoTest (RAID): Test for RAID10 activations when devices are missing
Jonathan Brassow [Mon, 28 Jan 2013 18:32:33 +0000 (12:32 -0600)]
Test (RAID):  Test for RAID10 activations when devices are missing

Test the fix for bug 889358.  RAID10 had been failing to activate when
there were devices that had failed in more than one mirror set.

11 years agoblkdeactivate: prevent trying to unmount the same mountpoint more times
Peter Rajnoha [Wed, 23 Jan 2013 15:57:44 +0000 (16:57 +0100)]
blkdeactivate: prevent trying to unmount the same mountpoint more times

An addendum to previous commit 1052863a1b35f7488758c78b3a9ebef5c63392bc.

11 years agoblkdeactivate: fix handling of nested mountpoints and mangled mount paths.
Peter Rajnoha [Wed, 23 Jan 2013 13:45:41 +0000 (14:45 +0100)]
blkdeactivate: fix handling of nested mountpoints and mangled mount paths.

If there was a nested mountpoint inside an existing mount path,
blkdeactivate could fail to unmount such a mountpoint as it
needs to deactivate the deepest path first and continue upwards.

For example the simplest reproducer:

[root@rhel6-a ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                           8:0    0    4G  0 disk
|-vg-lvol0 (dm-2)           253:2    0   32M  0 lvm  /mnt/a
`-vg-lvol1 (dm-3)           253:3    0   32M  0 lvm  /mnt/a/b

Before this patch:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a
umount: /mnt/a: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
  UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b
  LVM: deactivating Logical Volume vg/lvol1

(deactivation of vg/lvol0 is skipped as /mnt/a that is on lvol0
can't be unmounted - it still has /mnt/a/b as nested mountpoint!)

With this patch applied:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a
  LVM: deactivating Logical Volume vg/lvol0
  LVM: deactivating Logical Volume vg/lvol1

===

Also, this patch contains a fix for processing mangled mount paths:

[root@rhel6-a ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                           8:0    0    4G  0 disk
`-vg-lvol0 (dm-2)           253:2    0   32M  0 lvm  /mnt/x y z

[root@rhel6-a ~]# lsblk -r
vg-lvol0 253:2 0 32M 0 lvm /mnt/x\x20y\x20z

(the mount path is mangled with \xNN that is visible in raw
lsblk output only and which is used in blkdeactive as well)

Before this patch:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  umount: /mnt/x\x20y\x20z: not found

After this patch applied:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/x\x20y\x20z
  LVM: deactivating Logical Volume vg/lvol0

11 years agolocales: use higher prio LC_ALL variable
Zdenek Kabelac [Tue, 22 Jan 2013 10:25:02 +0000 (11:25 +0100)]
locales: use higher prio LC_ALL variable

For reseting locale environment into significantly less memory
consuming version 'C' - use LC_ALL instead of LANG since it has
higher priority in locale settings.

Otherwise we may observe whole locale-archive which might be
over 100MB on i.e. Fedora systems locked in memory with
some daemons.

11 years agoUpdate WHATS_NEW.
Petr Rockai [Wed, 16 Jan 2013 10:22:08 +0000 (11:22 +0100)]
Update WHATS_NEW.

11 years agolvmetad: Call _lvmetad_handle_reply in lvmetad_vg_lookup.
Petr Rockai [Wed, 16 Jan 2013 10:12:22 +0000 (11:12 +0100)]
lvmetad: Call _lvmetad_handle_reply in lvmetad_vg_lookup.

11 years agolvmetad: Fix a race in metadata update.
Petr Rockai [Wed, 16 Jan 2013 10:09:37 +0000 (11:09 +0100)]
lvmetad: Fix a race in metadata update.

The idea is to avoid a period when an existing VG is not mapped to either the
old or the new name. (Note that the brief "blackout" was present even if the
name did not actually change.) We instead allow a brief overlap of a VG existing
under both names, i.e. a query for a VG might succeed but before a lock is
acquired the VG disappears.

11 years agodmeventd: close dmeventd FIFO FDs on exec (add FD_CLOEXEC).
Peter Rajnoha [Tue, 15 Jan 2013 13:59:54 +0000 (14:59 +0100)]
dmeventd: close dmeventd FIFO FDs on exec (add FD_CLOEXEC).

11 years agowhatsnew
Zdenek Kabelac [Fri, 11 Jan 2013 08:26:51 +0000 (09:26 +0100)]
whatsnew

11 years agofilters: add scm devices
Sebastian Ott [Thu, 10 Jan 2013 19:20:37 +0000 (20:20 +0100)]
filters: add scm devices

Fix this:
pvcreate /dev/scma
  Device /dev/scma not found (or ignored by filtering).

Reported-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
11 years agologging: classify log_debug messages
Alasdair G Kergon [Mon, 7 Jan 2013 22:30:29 +0000 (22:30 +0000)]
logging: classify log_debug messages

Place most log_debug() messages into a class.

11 years agologging: add debug classes
Alasdair G Kergon [Mon, 7 Jan 2013 22:25:19 +0000 (22:25 +0000)]
logging: add debug classes

Add log/debug_classes to lvm.conf to allow debug messages to be
classified and filtered at runtime.

The dm_errno field is only used by log_error(), so I've redefined it
for log_debug() messages to hold the message class.

By default, all existing messages appear, but we can add categories that
generate high volumes of data, such as logging all traffic to/from
lvmetad.

11 years agolvmetad: fix format1 updates
Alasdair G Kergon [Sat, 5 Jan 2013 03:07:43 +0000 (03:07 +0000)]
lvmetad: fix format1 updates

fmt1 doesn't have a separate commit function: updates take effect
immediately vg_write is called, so we must update lvmetad at this
point if we're going to go on and ask lvmetad for the VG metadata
again before calling the commit function (though that's probably an
unsupported and pointless thing to do anyway as the client must
already have that data and it cannot have changed because it's locked
and with devs suspended we shouldn't be communicating with lvmetad;
so when that's fixed properly, this fix here can be reverted).

This problem showed up as an internal error when lvremoving an LVM1
snapshot.

> Internal error: LV snap1 (00000000000000000000000000000001) missing from preload metadata

https://bugzilla.redhat.com/891855

11 years agolvmetad: add basic client-side debug logging
Alasdair G Kergon [Sat, 5 Jan 2013 00:35:50 +0000 (00:35 +0000)]
lvmetad: add basic client-side debug logging

First attempt at showing precisely what use any command is making of
lvmetad in the -vvvv trace information.

11 years agolvmetad: rename device vars and move _token_update
Alasdair G Kergon [Fri, 4 Jan 2013 23:45:22 +0000 (23:45 +0000)]
lvmetad: rename device vars and move _token_update

Move _token_update() to avoid the need for _lvmetad_send prototype.

Use 'dev' consistently for a struct device * variable.
Use 'devno' for a dev_t.

11 years agolibdaemon: add logging to daemon_open
Alasdair G Kergon [Fri, 4 Jan 2013 23:29:59 +0000 (23:29 +0000)]
libdaemon: add logging to daemon_open

Log all conditions encountered in daemon_open().

Only store errno when known to be set.

11 years agolvmetad: improve client logging when connecting
Alasdair G Kergon [Fri, 4 Jan 2013 23:22:30 +0000 (23:22 +0000)]
lvmetad: improve client logging when connecting

Rename lvmetad_warning() to lvmetad_connect_or_warn().

Log all connection attempts on the client side, whether successful or not.

Reduce some nesting and remove a redundant assertion.

11 years agolvmetad: lvm depends on libdaemonclient.a
Alasdair G Kergon [Fri, 4 Jan 2013 23:10:38 +0000 (23:10 +0000)]
lvmetad: lvm depends on libdaemonclient.a

Rebuild lvm binary if libdaemonclient.a changes.

11 years agopvscan: synchronize with udev if pvscan --cache is used.
Peter Rajnoha [Fri, 21 Dec 2012 09:54:31 +0000 (10:54 +0100)]
pvscan: synchronize with udev if pvscan --cache is used.

We need to call sync_local_dev_names directly as pvscan uses
VG_GLOBAL lock and this one *does not* cause the synchronization
(sync_dev_names) to be called on unlock (VG_GLOBAL is not a real VG):

define unlock_vg(cmd, vol)
  do { \
    if (is_real_vg(vol)) \
      sync_dev_names(cmd); \
    (void) lock_vol(cmd, vol, LCK_VG_UNLOCK); \
  } while (0)

Without this fix, we end up without udev synchronization for the
pvscan --cache (mainly for -aay that causes the VGs/LVs to be
autoactivated) and also udev synchronization cookies are then left
in the system since they're not managed properly (code before sets
up udev sync cookies, but we have to call dm_udev_wait at least once
after that to do the wait and cleanup).

11 years agoactivation: fix autoactivation to not trigger on each PV change
Peter Rajnoha [Fri, 21 Dec 2012 09:34:48 +0000 (10:34 +0100)]
activation: fix autoactivation to not trigger on each PV change

Before, the pvscan --cache -aay was called on each ADD and CHANGE
uevent (for a device that is not a device-mapper device) and each CHANGE
event (for a PV that is a device-mapper device).

This causes troubles with autoactivation in some cases as CHANGE event
may originate from using the OPTION+="watch" udev rule that is defined
in 60-persistent-storage.rules (part of the rules provided by udev
directly) and it's used for all block devices
(except fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md* devices). For example, the
following sequence incorrectly activates the rest of LVs in a VG if one
of the LVs in the VG is being removed:

[root@rhel6-a ~]# pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created

[root@rhel6-a ~]# vgcreate vg /dev/sda
  Volume group "vg" successfully created

[root@rhel6-a ~]# lvcreate -l1 vg
  Logical volume "lvol0" created

[root@rhel6-a ~]# lvcreate -l1 vg
  Logical volume "lvol1" created

[root@rhel6-a ~]# vgchange -an vg
  0 logical volume(s) in volume group "vg" now active

[root@rhel6-a ~]# lvs
  LV      VG        Attr      LSize   Pool Origin Data%  Move Log
Cpy%Sync Convert
  lvol0   vg        -wi------   4.00m
  lvol1   vg        -wi------   4.00m

[root@rhel6-a ~]# lvremove -ff vg/lvol1
  Logical volume "lvol1" successfully removed

[root@rhel6-a ~]# lvs
  LV      VG        Attr      LSize   Pool Origin Data%  Move Log
Cpy%Sync Convert
  lvol0   vg        -wi-a----   4.00m

...so the vg was deactivated, then lvol1 removed, and we end up with
lvol1 removed (which is ok) BUT with lvol0 activated (which is wrong)!!!
This is because after lvol1 removal, we need to write metadata to the
underlying device /dev/sda and that causes the CHANGE event to be
generated (because of the WATCH udev rule set on this device) and this
causes the pvscan --cache -aay to be reevaluated.

We have to limit this and call pvscan --cache -aay to autoactivate
VGs/LVs only in these cases:

 --> if the *PV is not a dm device*, scan only after proper device
addition (ADD event) and not with any other changes (CHANGE event)

 --> if the *PV is a dm device*, scan only after proper mapping
activation (CHANGE event + the underlying PV in a state "just
activated")

11 years agoRAID: Limit replacement of devices when array is not in-sync.
Jonathan Brassow [Tue, 18 Dec 2012 20:40:42 +0000 (14:40 -0600)]
RAID:  Limit replacement of devices when array is not in-sync.

If a RAID array is not in-sync, replacing devices should not be allowed
as a general rule.  This is because the contents used to populate the
incoming device may be undefined because the devices being read where
not in-sync.  The kernel enforces this rule unless overridden by not
allowing the creation of an array that is not in-sync and includes a
devices that needs to be rebuilt.

Since we cannot know the sync state of an LV if it is inactive, we must
also enforce the rule that an array must be active to replace devices.

That leaves us with the following conditions:
1) never allow replacement or repair of devices if the LV is in-active
2) never allow replacement if the LV is not in-sync
3) allow repair if the LV is not in-sync, but warn that contents may
   not be recoverable.

In the case where a user is performing the repair on the command line via
'lvconvert --repair', the warning is printed before the user is prompted
if they would like to replace the device(s).  If the repair is automated
(i.e. via dmeventd and policy is "allocate"), then the device is replaced
if possible and the warning is printed.

11 years agoWHATS_NEW: changelog for fae1a611d2 and 5294a6f77a
Peter Rajnoha [Tue, 18 Dec 2012 11:12:58 +0000 (12:12 +0100)]
WHATS_NEW: changelog for fae1a611d2 and 5294a6f77a

11 years agolvm2app: No special behavior for 0 for max_snap_size in lvm_lv_snapshot()
Andy Grover [Mon, 17 Dec 2012 22:14:38 +0000 (14:14 -0800)]
lvm2app: No special behavior for 0 for max_snap_size in lvm_lv_snapshot()

It isn't possible to choose a sane default for snapshot size, so just
play it straight and use the passed size instead of adding special
behavior for 0.

Also revert change to Python lib, size parameter must be supplied.

Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agoRevert "lvmetad: simplify pvid memory allocation."
Zdenek Kabelac [Mon, 17 Dec 2012 12:49:19 +0000 (13:49 +0100)]
Revert "lvmetad: simplify pvid memory allocation."

This reverts commit ed23da95b63308e11f8d680b189686a5d2d380d0.

Hash table device_to_pvid  seems to contain references to
already deleted pvids and so revert to the older
behaviour using allocated memory.

11 years agolvmetad: Fix a possible race in remove_metadata.
Petr Rockai [Sun, 16 Dec 2012 23:43:18 +0000 (00:43 +0100)]
lvmetad: Fix a possible race in remove_metadata.

All operations on shared hash tables need to be protected by mutexes. Moreover,
lookup and subsequent key removal need to happen atomically, to avoid races (and
possible double free-ing) between multiple threads trying to manipulate the same
VG.

11 years agolvmetad: Fix a possible deadlock.
Petr Rockai [Sun, 16 Dec 2012 23:39:00 +0000 (00:39 +0100)]
lvmetad: Fix a possible deadlock.

If an update and a query were running in parallel, there was a slim but non-zero
chance of a deadlock due to (unnecessary) mutex nesting.

11 years agolvmetad: simplify pvid memory allocation.
Zdenek Kabelac [Sat, 15 Dec 2012 16:00:35 +0000 (17:00 +0100)]
lvmetad: simplify pvid memory allocation.

Since pvid_dup and cft config appears to be tightly
binded together - reuse it's memory pool for string.
Simplifies release of hashes.

11 years agothin: dmeventd fix memleak on error path
Zdenek Kabelac [Thu, 13 Dec 2012 19:19:38 +0000 (20:19 +0100)]
thin: dmeventd fix memleak on error path

Some error paths on _umount have leaked bitset.

11 years agopv_read: add missing check for valid info
Zdenek Kabelac [Fri, 14 Dec 2012 13:06:33 +0000 (14:06 +0100)]
pv_read: add missing check for valid info

If the lvmcache_info_from_pvid() fails to find valid
info, invoke the lookup by dev, and only in this case
call lvmcache_info_from_pvid() again.

Also check for the result of info and return
error directly, so the NULL is not passed
to lvmcache_get_label().

11 years agolvmetad: add check for failure dm_config_write_node
Zdenek Kabelac [Fri, 14 Dec 2012 20:36:27 +0000 (21:36 +0100)]
lvmetad: add check for failure dm_config_write_node

Detect if dm_config_write_node failed and fail correctly.

11 years agolvmetad: fix socket leak in handle_connect
Zdenek Kabelac [Fri, 14 Dec 2012 20:31:22 +0000 (21:31 +0100)]
lvmetad: fix socket leak in handle_connect

Close socket_fd and report error on malloc failure.

11 years agolvmetad: check id_read_format error status
Zdenek Kabelac [Fri, 14 Dec 2012 15:45:15 +0000 (16:45 +0100)]
lvmetad: check id_read_format error status

Detect error from id_read_format() function.

11 years agolvmetad: fix memleak on pv_found error path
Zdenek Kabelac [Fri, 14 Dec 2012 15:43:42 +0000 (16:43 +0100)]
lvmetad: fix memleak on pv_found error path

Free resources allocated in pv_found when going out
through error path.

11 years agolvmetad: keep returned struct fully initialized
Zdenek Kabelac [Fri, 14 Dec 2012 15:38:07 +0000 (16:38 +0100)]
lvmetad: keep returned struct fully initialized

Always clear the response structure.
Simplify daemon_reply initialization.

11 years agolvmetad: unlock vg on out-of-memory path
Zdenek Kabelac [Fri, 14 Dec 2012 15:35:26 +0000 (16:35 +0100)]
lvmetad: unlock vg on out-of-memory path

If we fail to get memory for mutex, hash the mutex
or fail somewhere along pthread function calls
return allocated resources back and unlock vg_lock_map mutex.

11 years agolibdaemon: check for strdup result
Zdenek Kabelac [Fri, 14 Dec 2012 00:00:36 +0000 (01:00 +0100)]
libdaemon: check for strdup result

Detect failure of dm_pool_strdup() and print error in fail path.
Save one extra strchr call - since we already know the distance
for the '=' character.

Drop stack trace from return after log_error().

11 years agoformat-text: check for _text_create_text_instance
Zdenek Kabelac [Fri, 14 Dec 2012 20:34:28 +0000 (21:34 +0100)]
format-text: check for _text_create_text_instance

Test if 'fid' creation failed and report stack trace,
break the loop and do not pass NULL fid further.

11 years agolog: move abort past syslog
Zdenek Kabelac [Fri, 14 Dec 2012 12:57:01 +0000 (13:57 +0100)]
log: move abort past syslog

When the abort_on_internal_errors is enabled, we aborted prior
the syslog logging output.

Since such fatal error gets level _LOG_FATAL it should
not be blocked by debug_level() check so lets move it further,
to get abort error logged also via syslog.

11 years agocleanup: use proper const in apply_lvname_restrictions
Zdenek Kabelac [Fri, 14 Dec 2012 13:03:58 +0000 (14:03 +0100)]
cleanup: use proper const in apply_lvname_restrictions

Better constness used for reserved prefixes and strings.
Also simplify a bit validate_name and use direct char
checks isntead of 2 strcmp() calls.

11 years agocleanup: reorder code
Zdenek Kabelac [Fri, 14 Dec 2012 18:43:42 +0000 (19:43 +0100)]
cleanup: reorder code

Swap if() test condition and check for failure
and use traditional 'stack' trace.

11 years agocleanup: skip assignment
Zdenek Kabelac [Fri, 14 Dec 2012 13:18:46 +0000 (14:18 +0100)]
cleanup: skip assignment

env is reassigned without the use, so drop this assign.

11 years agocleanup: simplify option matching function
Zdenek Kabelac [Fri, 14 Dec 2012 15:41:24 +0000 (16:41 +0100)]
cleanup: simplify option matching function

Avoid using sprintf and strncmp call, when
we really want to compare just one character.

11 years agocleanup: singlenode minor change
Zdenek Kabelac [Fri, 14 Dec 2012 13:01:19 +0000 (14:01 +0100)]
cleanup: singlenode minor change

Use strcpy instead of sprintf for plain string.
And use dm_strncpy for safer strncpy.

TODO: Fix API return values for cluster functions.

11 years agocleanup: ignore return values
Zdenek Kabelac [Fri, 14 Dec 2012 17:58:18 +0000 (18:58 +0100)]
cleanup: ignore return values

These dm_snprintfs should not fail, since enough space is reserved.
So return intentionaly ignored.

11 years agocleanup: ignore errors
Zdenek Kabelac [Thu, 13 Dec 2012 18:55:33 +0000 (19:55 +0100)]
cleanup: ignore errors

Since we are doing just dump and function doesn't report
any error, explicitely ignore return values from
dm_config_write_node and dm_asprintf.

Same applies for the logging function.

11 years agocleanup: drop unused header
Zdenek Kabelac [Thu, 13 Dec 2012 19:35:00 +0000 (20:35 +0100)]
cleanup: drop unused header

This header does not resolve any symbols here.

11 years agocleanup: drop test for optarg NULL
Zdenek Kabelac [Thu, 13 Dec 2012 18:54:07 +0000 (19:54 +0100)]
cleanup: drop test for optarg NULL

Since -d takes an argument, we do not need to check for
optarg being NULL here.

11 years agocleanup: convert to 32bit
Zdenek Kabelac [Thu, 13 Dec 2012 19:35:38 +0000 (20:35 +0100)]
cleanup: convert to 32bit

Chunk sizes fits into 4G range, so keep it in 32bit range.

11 years agopython-lvm: Make second lv.snapshot() argument optional
Andy Grover [Fri, 14 Dec 2012 22:10:41 +0000 (14:10 -0800)]
python-lvm: Make second lv.snapshot() argument optional

If no size is given, size defaults to 0, which in lvm_lv_snapshot will
allocate extents equal to the original LV be allocated for the new
snapshot.

Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agopython-lvm: whitespace in python/liblvm.c.
Andy Grover [Fri, 14 Dec 2012 18:32:35 +0000 (10:32 -0800)]
python-lvm: whitespace in python/liblvm.c.

Sorry, it bugged me. Should be perfect now.

Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agopython-lvm: Small fixups to new create_lv_snapshot
Andy Grover [Fri, 14 Dec 2012 18:17:29 +0000 (10:17 -0800)]
python-lvm: Small fixups to new create_lv_snapshot

Tabify

Remove use of asize, unneeded.

Don't initialize lvobj->parent_vgobj to NULL, the object ctor already
zeroed everything on alloc.

Redo call to lvm_lv_snapshot to use the liblvm snapshot implementation
we went with.

Add {}s to silence warning in lv_dealloc.

Rename snapshot function for consistency.

Update WHATS_NEW.

Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agopython-lvm: Add snapshot support
James Antill [Fri, 14 Dec 2012 01:39:09 +0000 (17:39 -0800)]
python-lvm: Add snapshot support

Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agolvm2app: Add lv snapshot support
Tony Asleson [Fri, 14 Dec 2012 01:57:38 +0000 (17:57 -0800)]
lvm2app: Add lv snapshot support

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
11 years agolvconvert: also allow --type with --stripes
Peter Rajnoha [Thu, 13 Dec 2012 10:15:37 +0000 (11:15 +0100)]
lvconvert: also allow --type with --stripes

We can also use this for conversion between different mirror segment
types. Each new segment type converter then needs to check itself
whether the --stripes is applicable.

11 years agoUpdate WHATS_NEW.
Petr Rockai [Wed, 12 Dec 2012 14:17:08 +0000 (15:17 +0100)]
Update WHATS_NEW.

11 years agotoollib: Avoid a global lock in process_each_pv if lvmetad is used.
Petr Rockai [Wed, 12 Dec 2012 13:39:52 +0000 (14:39 +0100)]
toollib: Avoid a global lock in process_each_pv if lvmetad is used.

The motivation to grab the global lock is to avoid a scan and metadata parsing
for each PV, but the cost of obtaining metadata is _mostly_ mitigated by having
lvmetad around. Not taking the global lock improves throughput when multiple pvs
or related commands are running in parallel, like in RHEV.

11 years agolvmetad: fix compiler warning and add WHATS_NEW line for previous commit
Peter Rajnoha [Wed, 12 Dec 2012 12:27:25 +0000 (13:27 +0100)]
lvmetad: fix compiler warning and add WHATS_NEW line for previous commit

11 years agolvmetad: Fix autoactivation for MDA-less PVs.
Petr Rockai [Wed, 12 Dec 2012 11:51:28 +0000 (12:51 +0100)]
lvmetad: Fix autoactivation for MDA-less PVs.

Calling pvscan --cache with -aay on a PV without an MDA would spuriously fail
with an internal error, because of an incorrect assumption that a parsed VG
structure was always available. This is not true and the autoactivation handler
needs to call vg_read to obtain metadata in cases where the PV had no MDAs to
parse. Therefore, we pass vgid into the handler instead of the (possibly NULL)
VG coming from the PV's MDA.

11 years agolvconvert: allow lvconvert --stripes/stripesize only with -mirrors/--repair/--thinpool
Peter Rajnoha [Tue, 11 Dec 2012 14:50:25 +0000 (15:50 +0100)]
lvconvert: allow lvconvert --stripes/stripesize only with -mirrors/--repair/--thinpool

Also, update lvconvert man page to reflect this and make clear that
the --stripes/stripesize is applied to newly allocated space only.

11 years agotest: update thin discards testing
Zdenek Kabelac [Mon, 10 Dec 2012 09:51:25 +0000 (10:51 +0100)]
test: update thin discards testing

Reflect fixed disards behavior.

11 years agolvmetad: use dm_config_destroy to free pvmeta
Marian Csontos [Mon, 10 Dec 2012 13:24:55 +0000 (14:24 +0100)]
lvmetad: use dm_config_destroy to free pvmeta

Release pvmeta handler with proper dm_config_destroy() function.
TODO: Fix primary fault for this internal error.

Signed-off-by: mcsontos@redhat.com
11 years agothin: fix test for dicards ignore settings
Zdenek Kabelac [Mon, 10 Dec 2012 09:22:48 +0000 (10:22 +0100)]
thin: fix test for dicards ignore settings

Arghh, this was bad last-minute shortening of if() expression
in the commit 1ef98310187a7.

dm_tree_node_set_thin_pool_discard() must not run in the same
expression as check for non-power-2 discard, otherwise
there are 2 calls for dm_tree_node_set_thin_pool_discard
and whole setting of discards is missinterpretted.

In-relase fix it by using proper parentheses {}.

11 years agothin: remove detection for thin discard support
Zdenek Kabelac [Mon, 10 Dec 2012 09:22:16 +0000 (10:22 +0100)]
thin: remove detection for thin discard support

Remove no longer needed warning for unsuppoted discards
for non-power-2 lvcreate commands.

(Missed from the patch for the same update in lvchange made
by commit dde5a6c52b315d7b)

11 years agomirrors: fix leak in device_is_usable mirror check
Zdenek Kabelac [Thu, 6 Dec 2012 22:37:21 +0000 (23:37 +0100)]
mirrors: fix leak in device_is_usable mirror check

Function _ignore_blocked_mirror_devices was not release
allocated strings images_health and log_health.

In error paths it was also not releasing dm_task structure.

Swaped return code of _ignore_blocked_mirror_devices and
use 1 as success.

In _parse_mirror_status use log_error if memory allocation
fails and few more errors so they are no going unnoticed
as debug messages.

On error path always clear return values and free strings.

For dev_create_file  use cache mem pool to avoid memleak.

11 years agolvconvert: do not ignore -f in lvconvert --repair -y -f
Peter Rajnoha [Tue, 11 Dec 2012 08:52:54 +0000 (09:52 +0100)]
lvconvert: do not ignore -f in lvconvert --repair -y -f

11 years agoFix Py_BuildValue for i386
James Antill [Thu, 6 Dec 2012 00:31:30 +0000 (16:31 -0800)]
Fix Py_BuildValue for i386

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

Signed-off-by: James Antill <james.antill@redhat.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
This page took 0.073567 seconds and 5 git commands to generate.