]> sourceware.org Git - lvm2.git/log
lvm2.git
8 years agogcc: cleanup some sign warnings
Zdenek Kabelac [Tue, 23 Feb 2016 11:18:48 +0000 (12:18 +0100)]
gcc: cleanup some sign warnings

When comparing unsigned with int, the comparision is made
as 'unsigned' type, so make it rather explicit which type
is being compared.

8 years agocache: enforce header check
Zdenek Kabelac [Tue, 23 Feb 2016 11:15:42 +0000 (12:15 +0100)]
cache: enforce header check

Currently it's been checked for 'zero' header for thin-pool,
but lets use it always for cache as well - since it's relatively 'cheap'
detection of read 'error' problems as thin/cache tools
currently do not work fast enough in this case.

8 years agothin: fix read size compare
Zdenek Kabelac [Tue, 23 Feb 2016 11:11:15 +0000 (12:11 +0100)]
thin: fix read size compare

Fix the compare with 'unsigned' sizeof() and error read -1 result.
So the read error is correctly recognized.

8 years agolvmdbusd: Initial unit test driver script
Tony Asleson [Mon, 22 Feb 2016 22:05:43 +0000 (16:05 -0600)]
lvmdbusd: Initial unit test driver script

It's disabled until we can fix it up.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agolvmdbusd: Remove unlimited retries
Tony Asleson [Mon, 22 Feb 2016 21:53:31 +0000 (15:53 -0600)]
lvmdbusd: Remove unlimited retries

Change while to for loop to prevent the daemon from getting stuck
when lvm is messed up.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agolvmdbusd: Add env variable to use session bus
Tony Asleson [Mon, 22 Feb 2016 20:28:11 +0000 (14:28 -0600)]
lvmdbusd: Add env variable to use session bus

export LVMDBUSD_SESSION=True to run on the session bus instead
of the system bus so that we can run the unit test without
installing the dbus conf file.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agolvmdbus: Make unit tests work in test env
Tony Asleson [Mon, 22 Feb 2016 20:03:31 +0000 (14:03 -0600)]
lvmdbus: Make unit tests work in test env

Reduced the size of LVs created and use actual PE numbers instead of hard
coding them to allow us to work with the loop back devices.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agolvmdbusd: background.py, fix stdout parse error
Tony Asleson [Mon, 22 Feb 2016 20:00:30 +0000 (14:00 -0600)]
lvmdbusd: background.py, fix stdout parse error

It appears that the output of lvconvert --merge can vary some.  The code
was blowing up as it was trying to parse a line of stdout to retrieve the
% complete, but the line did not have the needed format and an execption
was thrown.  The uncaught exception caused the background thread to exit
without updating the job object, which caused the client to hang forever
waiting.  Added a default exception handler to prevent unhandled execptions
causing hangs and removed the parameter skip_first_line as it's no longer
needed.  The code checks to see if the line can be parsed before doing so.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agolvmdbustest.py: Make executable
Tony Asleson [Fri, 19 Feb 2016 23:02:45 +0000 (17:02 -0600)]
lvmdbustest.py: Make executable

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agotests: fix clean up after lvmlockd tests
David Teigland [Mon, 22 Feb 2016 20:13:30 +0000 (14:13 -0600)]
tests: fix clean up after lvmlockd tests

8 years agolvmdbusd: Fix make install for python >= 3.5
Marian Csontos [Mon, 22 Feb 2016 17:14:23 +0000 (18:14 +0100)]
lvmdbusd: Fix make install for python >= 3.5

python 3.5 renamed .pyo files to .opt-1.pyc.

8 years agospec: Fix 04ab1fa572bb: Remove left-overs
Marian Csontos [Mon, 22 Feb 2016 16:40:12 +0000 (17:40 +0100)]
spec: Fix 04ab1fa572bb: Remove left-overs

8 years agolvmlockd: invalidate name in lockspace struct after remove
David Teigland [Mon, 22 Feb 2016 15:32:39 +0000 (09:32 -0600)]
lvmlockd: invalidate name in lockspace struct after remove

After the lockspace has been successfully removed,
invalidate the name field in the lockspace struct.
The struct remains on the list of lockspaces until
the struct can be freed later.  Until the struct is
freed, its name will prevent another new lockspace
from being created with the same name.

8 years agotest: add make check_lvmlockd_test
David Teigland [Thu, 14 Jan 2016 22:12:46 +0000 (16:12 -0600)]
test: add make check_lvmlockd_test

Which runs lvmlockd in --test mode, without
any lock manager.

Also make some adjustments to the check_lvmlockd
variations using the lock managds.

8 years agotests: skip thin-flags test on 32bit el6 kernel
Zdenek Kabelac [Mon, 22 Feb 2016 13:52:01 +0000 (14:52 +0100)]
tests: skip thin-flags test on 32bit el6 kernel

Until kernel is fixed, stop running test always hitting OOPS there.

8 years agocleanup: use char arrays.
Zdenek Kabelac [Mon, 22 Feb 2016 13:11:02 +0000 (14:11 +0100)]
cleanup: use char arrays.

8 years agocleanup: indent changes
Zdenek Kabelac [Mon, 22 Feb 2016 09:44:46 +0000 (10:44 +0100)]
cleanup: indent changes

Some code indention.
Use dm_strncpy() for simplier code.

TODO: we could possibly use   %32s  for printing pvid...
so maybe adding extra  FMT_PVID....

8 years agocleanup: libdm clang warnings
Zdenek Kabelac [Mon, 22 Feb 2016 09:49:45 +0000 (10:49 +0100)]
cleanup: libdm clang warnings

Add some extra clang pointer validation so we do not try deref NULL.

8 years agolibdm: grow with initialized struct content
Zdenek Kabelac [Mon, 22 Feb 2016 10:14:30 +0000 (11:14 +0100)]
libdm: grow with initialized struct content

Coverity noticed struct hist has been copied uninitalized into mempool.

8 years agolvmetad: fix error path
Zdenek Kabelac [Mon, 22 Feb 2016 09:45:01 +0000 (10:45 +0100)]
lvmetad: fix error path

Coverity noticed the internal error path would  be using uninit struct.
So always make sure reply is initilized.

8 years agopost-release
Alasdair G Kergon [Sun, 21 Feb 2016 23:37:48 +0000 (23:37 +0000)]
post-release

8 years agopre-release v2_02_143
Alasdair G Kergon [Sun, 21 Feb 2016 23:17:24 +0000 (23:17 +0000)]
pre-release

8 years agolvmdbustest.py: resync latest changes
Tony Asleson [Fri, 19 Feb 2016 21:16:05 +0000 (15:16 -0600)]
lvmdbustest.py: resync latest changes

This file update was missed, copied latest file from:
https://github.com/tasleson/lvm-dubstep/blob/master/test/lvmdbustest.py

Signed-off-by: Tony Asleson <tasleson@redhat.com>
8 years agothin: fix update_pool_lv error path
Zdenek Kabelac [Fri, 19 Feb 2016 10:18:41 +0000 (11:18 +0100)]
thin: fix update_pool_lv error path

When update fails in suspend() (sending of messages
fails because metadata space is full) call resume(),
so the locking sequence works properly for clustering.

Also failing deactivation should unlock memory.

8 years agospec: Update python bindings and dbus-service
Marian Csontos [Thu, 18 Feb 2016 13:34:17 +0000 (14:34 +0100)]
spec: Update python bindings and dbus-service

The workaround for python3 is no longer needed.

8 years agotests: needs_check needs version 16
Zdenek Kabelac [Thu, 18 Feb 2016 17:10:31 +0000 (18:10 +0100)]
tests: needs_check needs version 16

Skip part of test when driver is too old.

8 years agothin: fix test for nonexisting status
Zdenek Kabelac [Thu, 18 Feb 2016 17:09:49 +0000 (18:09 +0100)]
thin: fix test for nonexisting status

Check status has right type.

8 years agotests: checking thin flags
Zdenek Kabelac [Thu, 18 Feb 2016 15:44:42 +0000 (16:44 +0100)]
tests: checking thin flags

Test various  (D/M/F) attrs for thin-pool/thin

8 years agoman: lvs updates
Zdenek Kabelac [Thu, 18 Feb 2016 13:13:40 +0000 (14:13 +0100)]
man: lvs updates

8 years agothin: report needs_check and fail state
Zdenek Kabelac [Thu, 18 Feb 2016 12:19:25 +0000 (13:19 +0100)]
thin: report needs_check and fail state

Fix reporting of Fail thin-pool target status
as attr[8] letter 'F'.

Report  'needs_check' status from thin-pool target via
attr field [4] (letter 'c'/'C'), and also via CheckNeeded field.

TODO: think about better name here?
TODO: lots of prop_not_implemented_set

8 years agothin: report PERCENT_INVALID for failed pool
Zdenek Kabelac [Thu, 18 Feb 2016 12:18:18 +0000 (13:18 +0100)]
thin: report PERCENT_INVALID for failed pool

When thin-pool is in failed/error state, we can't
read percentage so report invalid value.

8 years agolibdm: thin status update
Zdenek Kabelac [Mon, 15 Feb 2016 15:33:38 +0000 (16:33 +0100)]
libdm: thin status update

Fix parsing of 'Fail' status (using capital letter) for thin-pool.
Add also parsing of 'Error' state for thin-pool.
Add needs_check test for thin-pool.

Detect Fail state for thin.

8 years agometadata: ask for confirmation before really initializing/removing PV that is marked...
Peter Rajnoha [Thu, 18 Feb 2016 13:30:14 +0000 (14:30 +0100)]
metadata: ask for confirmation before really initializing/removing PV that is marked as belonging to a VG

Ask for confirmation when using pvcreate/pvremove on a PV which is
marked as belonging to a VG, just like we do in case of a PV which
belongs to known VG:

$ pvcreate -ff /dev/sda
Really INITIALIZE physical volume "/dev/sda" that is marked as belonging to a VG [y/n]? n
  /dev/sda: physical volume not initialized

$ pvremove -ff /dev/sda
Really WIPE LABELS from physical volume "/dev/sda" that is marked as belonging to a VG [y/n]? n
  /dev/sda: physical volume label not removed

8 years agolbmdbusd: Support in-tree testing.
Alasdair G Kergon [Thu, 18 Feb 2016 13:26:08 +0000 (13:26 +0000)]
lbmdbusd: Support in-tree testing.

8 years agoFix rpm builds
Marian Csontos [Thu, 18 Feb 2016 11:36:43 +0000 (12:36 +0100)]
Fix rpm builds

8 years agoreport: report -1, not 'unkown' for lv_{snapshot_invalid,merge_failed} with --binary
Peter Rajnoha [Thu, 18 Feb 2016 11:10:00 +0000 (12:10 +0100)]
report: report -1, not 'unkown' for lv_{snapshot_invalid,merge_failed} with --binary

State:
$ lvs -o lv_name,lv_active_locally,lv_snapshot_invalid,lv_merge_failed vg/lvol0
  LV    ActLocal       SnapInvalid     MergeFailed
  lvol0 active locally         unknown         unknown

Now with using --binary switch.

Before this patch (lv_snapshot_invalid and lv_merge_failed not switched into numeric value
where -1 represents 'unknown' value)
$ lvs -o lv_name,lv_active_locally,lv_snapshot_invalid,lv_merge_failed vg/lvol0 --binary
  LV    ActLocal   SnapInvalid     MergeFailed
  lvol0          1         unknown         unknown

With this patch applied:
$ lvs -o lv_name,lv_active_locally,lv_snapshot_invalid,lv_merge_failed vg/lvol0 --binary
  LV    ActLocal   SnapInvalid     MergeFailed
  lvol0          1              -1              -1

8 years agoconfigure: Use python-config if python2-config not found.
Alasdair G Kergon [Thu, 18 Feb 2016 02:10:35 +0000 (02:10 +0000)]
configure: Use python-config if python2-config not found.

Assume that's good enough for older systems.

8 years ago.
Alasdair G Kergon [Thu, 18 Feb 2016 01:50:36 +0000 (01:50 +0000)]
.

8 years agolvmdbusd: Rename module to lvmdbusd
Alasdair G Kergon [Thu, 18 Feb 2016 01:14:56 +0000 (01:14 +0000)]
lvmdbusd: Rename module to lvmdbusd

8 years agoautoconf: Fix py-compile permissions
Alasdair G Kergon [Thu, 18 Feb 2016 01:05:05 +0000 (01:05 +0000)]
autoconf: Fix py-compile permissions

8 years agolvmdbus: resync latest changes with original repo
Alasdair G Kergon [Thu, 18 Feb 2016 00:27:57 +0000 (00:27 +0000)]
lvmdbus: resync latest changes with original repo

8 years agoWHATS_NEW
Alasdair G Kergon [Thu, 18 Feb 2016 00:01:02 +0000 (00:01 +0000)]
WHATS_NEW

8 years agolvmdbus: Add new daemon.
Alasdair G Kergon [Wed, 17 Feb 2016 23:53:35 +0000 (23:53 +0000)]
lvmdbus: Add new daemon.

8 years agoman: fix list of restricted LV name suffixes
Peter Rajnoha [Wed, 17 Feb 2016 14:38:27 +0000 (15:38 +0100)]
man: fix list of restricted LV name suffixes

8 years agometadata: add missing _repair_inconsinstent_vg call during PV ext repair
Peter Rajnoha [Tue, 16 Feb 2016 14:50:32 +0000 (15:50 +0100)]
metadata: add missing _repair_inconsinstent_vg call during PV ext repair

8 years agometadata: do not repair missing PV_EXT_USED flag for PVs belonging to foreign VG
Peter Rajnoha [Tue, 16 Feb 2016 12:55:31 +0000 (13:55 +0100)]
metadata: do not repair missing PV_EXT_USED flag for PVs belonging to foreign VG

The host that owns foreign VGs is responsible for fixing up PV_EXT_USED
flag - the same already applies to repairing any inconsistent VG.

This patch also moves the iteration over vg->pvs inside
_check_or_repair_pv_ext fn - it's cleaner this way.

8 years agorefactor: add common _is_foreign_vg fn
Peter Rajnoha [Tue, 16 Feb 2016 12:44:48 +0000 (13:44 +0100)]
refactor: add common _is_foreign_vg fn

8 years agopv: use pv->fmt to check for fake PVs, not pv->vg
Peter Rajnoha [Mon, 15 Feb 2016 14:50:11 +0000 (15:50 +0100)]
pv: use pv->fmt to check for fake PVs, not pv->vg

pv->vg is not set yet during pvcreate processing. Use pv->fmt instead to
check for these fake PVs (all normal PVs have format defined, devices
which are not PVs don't have this set).

This fixes commit 0000db7f98a07aa31c5b1cf13938b612e7f2821b.

8 years agocleanup: make the message about marked PVs consistent with the others
Peter Rajnoha [Mon, 15 Feb 2016 14:20:23 +0000 (15:20 +0100)]
cleanup: make the message about marked PVs consistent with the others

8 years agotoollib: skip PV if system ID is used and PV marked as used but metadata missing
Peter Rajnoha [Mon, 15 Feb 2016 14:11:54 +0000 (15:11 +0100)]
toollib: skip PV if system ID is used and PV marked as used but metadata missing

If we know that a PV belongs to some VG and we're missing metadata
(because we have only those PV(s) from VG present in the system that
don't have metadata areas), we should skip such PV when processing
under system ID.

This is because we know that the PV belongs to some VG, but we
really can't decide whether it matches system ID unless the VG
metadata is present again.

8 years ago pv: mark fake PVs as not used
Peter Rajnoha [Mon, 15 Feb 2016 13:46:31 +0000 (14:46 +0100)]
 pv: mark fake PVs as not used

Some of the PVs are not even orphan PVs - they're fake PVs - this can
happen if we're listing all devices with "pvs -a". Such PV must not
be marked as used.

8 years agocleanup: use is_used_pv fn to detect whether PV is in use while reporting pv_free...
Peter Rajnoha [Mon, 15 Feb 2016 12:30:37 +0000 (13:30 +0100)]
cleanup: use is_used_pv fn to detect whether PV is in use while reporting pv_free field

8 years agoWHATS_NEW: PV_EXT_USED flag and related
Peter Rajnoha [Mon, 15 Feb 2016 12:07:35 +0000 (13:07 +0100)]
WHATS_NEW: PV_EXT_USED flag and related

8 years agotests: fix tests checking pv_attr - there's a new bit now
Peter Rajnoha [Fri, 12 Feb 2016 11:05:59 +0000 (12:05 +0100)]
tests: fix tests checking pv_attr - there's a new bit now

8 years agotests: add pv-ext-flags.sh test
Peter Rajnoha [Tue, 7 Apr 2015 11:50:54 +0000 (13:50 +0200)]
tests: add pv-ext-flags.sh test

Testing PV extension flags. Currently, there's only one PV extension
flag present - the PV_EXT_USED flag (marking PV as used in a VG).

8 years agovg: automatically update to newest PV ext version during vg_write
Peter Rajnoha [Fri, 12 Feb 2016 13:22:02 +0000 (14:22 +0100)]
vg: automatically update to newest PV ext version during vg_write

8 years agoformat: format_text: add pv_needs_rewrite to format_handler and implemention for...
Peter Rajnoha [Fri, 12 Feb 2016 12:53:06 +0000 (13:53 +0100)]
format: format_text: add pv_needs_rewrite to format_handler and implemention for format_text

8 years agoreport: identify used PVs in pv_attr field with 'u' char
Peter Rajnoha [Thu, 11 Feb 2016 14:34:05 +0000 (15:34 +0100)]
report: identify used PVs in pv_attr field with 'u' char

8 years agoreport: always display 0 for pv_free field if we don't have any mda and PV is marked...
Peter Rajnoha [Thu, 11 Feb 2016 14:00:43 +0000 (15:00 +0100)]
report: always display 0 for pv_free field if we don't have any mda and PV is marked as used at the same time

8 years agobackup: backup_restore_vg: register PVs that need writing via vg->pvs_to_write list
Peter Rajnoha [Thu, 26 Mar 2015 13:20:46 +0000 (14:20 +0100)]
backup: backup_restore_vg: register PVs that need writing via vg->pvs_to_write list

The backup_restore_vg is used directly for restoring the VG from backup.
It's also used to do the VG conversions from one metadata format to
another which means vgconvert calls backup_restore_vg too.

When restoring VG from backup, we need to rewrite/write PV headers as
PVs may have been orphans before and now they're becoming part of some
VG - we need to write the PV_EXT_USED flag at least.

When using the backup_restore_vg for vgconvert, we need to write
completely new PV header in different format.

Avoid the special "pv_write" call and handling that was used before
this patch in vgconvert (vgconvert_single function to be more precise)
and reuse existing internal interface to register PV header for writing
(or rewriting) via vg->pvs_to_write list instead like we do it elsewhere
in the code.

This patch also resolves a problem in which PV headers with target
format were written in the vgconvert_single fn as orphans and VG
metadata were added later on - this was a tiny hack actually.
We can't do this now - we need to write the PV as belonging
to a VG because otherwise the PV_EXT_USED flag won't be written
properly (if the PV header is written as orphan, the PV_EXT_USED
is set to 0, of course, even though metadata are attached later).
So this patch removes this tiny inconsistency which was passing
just fine before because we didn't have any relation to the VG
in PV header before. Now we have the PV_EXT_USED flag which says
the "PV is used in some VG".

8 years agometadata: _vg_read: check if PV_EXT_USED flag is set correctly for non-orphan PVs...
Peter Rajnoha [Thu, 19 Mar 2015 06:53:22 +0000 (07:53 +0100)]
metadata: _vg_read: check if PV_EXT_USED flag is set correctly for non-orphan PVs and do a repair if needed

The same check as we already do for orphan PVs, just the other way
round now: if the PV is surely part of some VG and any PV the VG
contains does not have the PV_EXT_USED flag set, repair it.

For example - /dev/sda here is in VG vg and it's incorrectly not
marked as used by PV_EXT_USED flag:

pvs --binary -o pv_ext_vsn,pv_in_use
  WARNING: Volume Group vg is not consistent.
  WARNING: Repairing Physical Volume /dev/sda that is in Volume Group vg but not marked as used.
  PV         VG     Fmt  Attr PSize   PFree   ExtVsn PInUse
  /dev/sda   vg     lvm2 a--  124.00m 124.00m      2      1

8 years agoreport: add pv_ext_vsn field to display PV header extension version used
Peter Rajnoha [Tue, 17 Mar 2015 08:49:08 +0000 (09:49 +0100)]
report: add pv_ext_vsn field  to display PV header extension version used

For example:

$ pvs -o pv_name,vg_name,pv_ext_vsn,pv_in_use
  PV         VG     ExtVsn InUse
  /dev/sda               2
  /dev/sdb   vg          2    used
  /dev/vda2  fedora      1    used

8 years agometadata: check for PV extension version before doing any checks on PV extension...
Peter Rajnoha [Mon, 16 Mar 2015 17:23:43 +0000 (18:23 +0100)]
metadata: check for PV extension version before doing any checks on PV extension flags

PV header extension versions:
  0 - the original PV without any extensions
  1 - bootloader area support added
  2 - PV_EXT_USED flag support added

So do the associated checks related to PV_EXT_USED flag only if
PV header extension found is of version 2 and higher.

8 years agometadata: _vg_read: check if PV_EXT_USED flag is set correctly for orphan PVs and...
Peter Rajnoha [Wed, 11 Mar 2015 15:18:42 +0000 (16:18 +0100)]
metadata: _vg_read: check if PV_EXT_USED flag is set correctly for orphan PVs and do a repair if needed

If we know that the PV is orphan, meaning there's at least one MDA on
that PV which does not reference any VG and at the same time there's
PV_EXT_USED flag set, we're certainly in an inconsistent state and we
need to fix this.

For example, such situation can happen during vgremove/vgreduce if we
removed/reduced the VG, but we haven't written PV headers yet because
vgremove stopped abruptly for whatever reason just before writing new
PV headers with updated state, including PV extension flags (and so the
PV_EXT_USED flag).

However, in case the PV has no MDAs at all, we can't double-check
whether the PV_EXT_USED is correct or not - if that PV is marked
as used, it's either:
  - really used (but other disks with MDAs are missing)
  - or the error state as described above is hit

User needs to overwrite the PV header directly if it's really clear
the PV having no MDAs does not belong to any VG and at the same time
it's still marked as being in use (pvcreate -ff <dev_name> will fix this).

For example - /dev/sda here has 1 MDA, orphan and is incorrectly marked
with PV_EXT_USED flag:

$ pvs --binary -o+pv_in_use
  WARNING: Found inconsistent standalone Physical Volumes.
  WARNING: Repairing flag incorrectly marking Physical Volume /dev/sda as used.
  PV         VG     Fmt  Attr PSize   PFree   InUse
  /dev/sda          lvm2 ---  128.00m 128.00m     0

8 years agoreport: add pv_in_use field to display whether PV is in use or not
Peter Rajnoha [Tue, 10 Mar 2015 15:10:16 +0000 (16:10 +0100)]
report: add pv_in_use field to display whether PV is in use or not

For example:

$ pvs -o pv_name,vg_name,pv_in_use
  PV         VG     InUse
  /dev/sda   vg      used
  /dev/sdb
  /dev/sdc           used

(sda is part of vg - it's used
 sdb is not part of vg - it's not used
 sdc is part of vg, but MDAs missing - it's used)

8 years agopv: _pvcreate_write: do label removal and zeroing only if creating a new PV
Peter Rajnoha [Thu, 12 Mar 2015 14:18:52 +0000 (15:18 +0100)]
pv: _pvcreate_write: do label removal and zeroing only if creating a new PV

8 years agopv: issue different message of different type when we're overwriting existing PV...
Peter Rajnoha [Tue, 10 Mar 2015 13:19:20 +0000 (14:19 +0100)]
pv: issue different message of different type when we're overwriting existing PV header instead of creating a new one

Scenario:

$ pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created

We're adding the PV to a VG.

Before this patch:
$ vgcreate vg /dev/sda
  Physical volume "/dev/sda" successfully created
  Volume group "vg" successfully created

With this path applied:
$ vgcreate vg /dev/sda
  Volume group "vg" successfully created

...and verbose log containing: "Physical volume "/dev/sda" successfully written"

8 years agopv: check for the PV_EXT_USED flag and deny pvcreate/pvchange/pvremove/vgcreate on...
Peter Rajnoha [Tue, 10 Mar 2015 10:25:14 +0000 (11:25 +0100)]
pv: check for the PV_EXT_USED flag and deny pvcreate/pvchange/pvremove/vgcreate on such PV (unless forced)

Make sure we won't use a PV that is already marked as used. Normally,
VG metadata would stop us from doing that, but we can run into a
situation where such metadata is missing because PVs with MDAs
are missing and the PVs left are the ones with 0 MDAs.

(/dev/sda in this example has 0 MDAs and it belongs to a VG,
but other PVs with MDA are missing)

$ pvs -o pv_name,pv_mda_count /dev/sda
  PV         #PMda
  /dev/sda       0

$ pvcreate /dev/sda
  PV '/dev/sda' is marked as belonging to a VG but its metadata is missing.
  Can't initialize PV '/dev/sda' without -ff.

$ pvchange -u /dev/sda
  PV '/dev/sda' is marked as belonging to a VG but its metadata is missing.
  Can't change PV '/dev/sda' without -ff.
  Physical volume /dev/sda not changed
  0 physical volumes changed / 1 physical volume not changed

$ pvremove /dev/sda
  PV '/dev/sda' is marked as belonging to a VG but its metadata is missing.
  (If you are certain you need pvremove, then confirm by using --force twice.)

$ vgcreate vg /dev/sda
  Physical volume '/dev/sda' is marked as belonging to a VG but its metadata is missing.
  Unable to add physical volume '/dev/sda' to volume group 'vg'.

8 years agopv: format-text: store PV_EXT_USED flag if PV is used and unset it otherwise
Peter Rajnoha [Fri, 12 Feb 2016 09:59:27 +0000 (10:59 +0100)]
pv: format-text: store PV_EXT_USED flag if PV is used and unset it otherwise

When adding a PV to VG, set the PV_EXT_USED flag in PV header and
vice versa - if the PV is no longer in a VG, unset the flag.

8 years agometadata: schedule PV for header rewrite if adding a PV to VG or restoring VG
Peter Rajnoha [Thu, 12 Mar 2015 13:49:10 +0000 (14:49 +0100)]
metadata: schedule PV for header rewrite if adding a PV to VG or restoring VG

When adding PV to VG, we need to rewrite PV header as there's a flip
in PV_EXT_USED flag. The same applies if we're restoring VG from backup.

8 years agometadata: add_pv_to_vg: add 'new_pv' arg to state if the PV is about to be created
Peter Rajnoha [Thu, 12 Mar 2015 13:37:50 +0000 (14:37 +0100)]
metadata: add_pv_to_vg: add 'new_pv' arg to state if the PV is about to be created

8 years agopv: add is_used_pv fn
Peter Rajnoha [Fri, 12 Feb 2016 09:17:18 +0000 (10:17 +0100)]
pv: add is_used_pv fn

8 years agolvmcache/lvmetad: cache PV extension version
Peter Rajnoha [Thu, 11 Feb 2016 15:25:36 +0000 (16:25 +0100)]
lvmcache/lvmetad: cache PV extension version

Store PV extension version in lvmcache/lvmetad for use throughout the code.

8 years agolvmcache/lvmetad: cache PV extension flags
Peter Rajnoha [Mon, 9 Mar 2015 11:52:07 +0000 (12:52 +0100)]
lvmcache/lvmetad: cache PV extension flags

Store PV extension flags in lvmcache/lvmetad for use throughout the code.

8 years agometadata: introduce PV_EXT_USED flag and bump PV_HEADER_EXTENSION_VSN
Peter Rajnoha [Fri, 12 Feb 2016 12:20:34 +0000 (13:20 +0100)]
metadata: introduce PV_EXT_USED flag and bump PV_HEADER_EXTENSION_VSN

8 years agoformat: add FMT_PV_FLAGS to indicate format supports PV flags
Peter Rajnoha [Fri, 12 Feb 2016 11:58:59 +0000 (12:58 +0100)]
format: add FMT_PV_FLAGS to indicate format supports PV flags

8 years agorefactor: rename struct pv_to_create --> struct pv_to_write
Peter Rajnoha [Mon, 9 Mar 2015 11:29:30 +0000 (12:29 +0100)]
refactor: rename struct pv_to_create --> struct pv_to_write

We'll use this struct in subsequent patches for PVs which should
be rewritten, not just created. So rename struct pv_to_create to
struct pv_to_write for clarity.

8 years agopost-release
Alasdair G Kergon [Mon, 15 Feb 2016 10:48:55 +0000 (10:48 +0000)]
post-release

8 years agopre-release v2_02_142
Alasdair G Kergon [Mon, 15 Feb 2016 10:35:16 +0000 (10:35 +0000)]
pre-release

8 years agoman: pvresize: remove old comment about inability to resize PV with more mdas
Peter Rajnoha [Fri, 12 Feb 2016 15:29:39 +0000 (16:29 +0100)]
man: pvresize: remove old comment about inability to resize PV with more mdas

8 years agotests: indent
Zdenek Kabelac [Fri, 12 Feb 2016 10:59:42 +0000 (11:59 +0100)]
tests: indent

Better bash indention

8 years agopvmove: fix possible memory pool corruption
Ondrej Kozina [Fri, 12 Feb 2016 10:34:26 +0000 (11:34 +0100)]
pvmove: fix possible memory pool corruption

This is a hotfix for a bug introduced in
6d7dc87cb356162f912b13c8a0cd198037c0226b.

The bug description: First we allocate memory for
processing handle (at an address 1) then we
allocate some memory on the same pool for later use
in pvmove_poll function inside the process_each_pv
function (at an address 2). After we jump out of
process_each_pv we called destroy_processing_handle.
As a result of destroying the handle memory pool could
deallocate all memory at address 1 or higher. The
pvmove_poll function tried to copy a memory allocated
at address 2 that could be returned to the system.
If it was so it led to segfault.

We need to rethink proper fix but in the same time
cmd->mem pool is recreated per each lvm command so
this should not cause problems even when we run
multiple commands in lvm shell.

A valgrind snapshot of the corruption:

Invalid read of size 1
    at 0x4C29F92: strlen (mc_replace_strmem.c:403)
    by 0x5495F2E: dm_pool_strdup (pool.c:51)
    by 0x1592A7: _create_id (pvmove.c:774)
    by 0x159409: pvmove_poll (pvmove.c:796)
    by 0x1599E3: pvmove (pvmove.c:931)
    by 0x15105B: lvm_run_command (lvmcmdline.c:1655)
    by 0x1523C3: lvm2_main (lvmcmdline.c:2121)
    by 0x1754F3: main (lvm.c:22)
Address 0xf15df8a is 138 bytes inside a block of size 8,192 free'd
    at 0x4C28430: free (vg_replace_malloc.c:446)
    by 0x5494E73: dm_free_wrapper (dbg_malloc.c:357)
    by 0x5495DE2: _free_chunk (pool-fast.c:318)
    by 0x549561C: dm_pool_free (pool-fast.c:151)
    by 0x164451: destroy_processing_handle (toollib.c:1837)
    by 0x1598C1: pvmove (pvmove.c:903)
    by 0x15105B: lvm_run_command (lvmcmdline.c:1655)
    by 0x1523C3: lvm2_main (lvmcmdline.c:2121)
    by 0x1754F3: main (lvm.c:22)

8 years agotests: update test
Zdenek Kabelac [Fri, 12 Feb 2016 09:21:07 +0000 (10:21 +0100)]
tests: update test

Upgrade test to count with much faster dmeventd work thanks
to low_watter_mark support.

Fix some wrong tests.

8 years agogcc: better code for older compiler
Zdenek Kabelac [Fri, 12 Feb 2016 09:17:39 +0000 (10:17 +0100)]
gcc: better code for older compiler

Address this gcc warning:

metadata/lv.c:243: warning: initialized field overwritten
metadata/lv.c:243: warning: (near initialization for 'status.seg_status')

Present with e.g.: gcc version 4.3.2 (Debian 4.3.2-1.1)

8 years agotests: check for automated dmeventd resize
Zdenek Kabelac [Thu, 11 Feb 2016 17:05:58 +0000 (18:05 +0100)]
tests: check for automated dmeventd resize

Watermark support should handle relatively quickly data LV resizes.
So check if it does what is expected.

8 years agodebug: cut_and_paste type in message
M.H. Tsai [Wed, 27 Jan 2016 11:11:03 +0000 (19:11 +0800)]
debug: cut_and_paste type in message

Typo in debug message.

8 years agocleanup: update messages
Zdenek Kabelac [Mon, 8 Feb 2016 12:08:54 +0000 (13:08 +0100)]
cleanup: update messages

8 years agocleanup: drop unneeded assigns
Zdenek Kabelac [Mon, 8 Feb 2016 12:14:43 +0000 (13:14 +0100)]
cleanup: drop unneeded assigns

8 years agocleanup: relocate function to vg.c
Zdenek Kabelac [Mon, 8 Feb 2016 11:53:54 +0000 (12:53 +0100)]
cleanup: relocate function to vg.c

8 years agocleanup: stripes_extents
Zdenek Kabelac [Fri, 22 Jan 2016 15:11:29 +0000 (16:11 +0100)]
cleanup: stripes_extents

Simplify calculation of extents rounding needed for
segment size.

Segment size has to divisible by 'extent count' needed to contain
whole stripe. LVM currently does not support stripes across segment.

In case the stripe size is bigger then extent size,
require bigger rounding.

8 years agocleanup: rename usepolicies
Zdenek Kabelac [Mon, 8 Feb 2016 12:09:37 +0000 (13:09 +0100)]
cleanup: rename usepolicies

Switch to ARG name without '_' in the middle (like all others args).

8 years agolvresize: check for given parameters
Zdenek Kabelac [Fri, 22 Jan 2016 12:08:13 +0000 (13:08 +0100)]
lvresize: check for given parameters

Check ac_ value as passed args.
Also drop reseting 'computed' values - since they get
assigned values later.

8 years agodm: alloc always 8byte aligned
Zdenek Kabelac [Thu, 11 Feb 2016 11:00:28 +0000 (12:00 +0100)]
dm: alloc always 8byte aligned

Fixing regression caused by 197b5e6dc7dd8ec161ebe43c97fd2ac8384b3433.
So the 'TODO' part now finally know the answer - there is 'sparc64'
architecture which imposes limitation to read 64b words only through
64b aligned address.

Since we never could know how is the user going to use the returned
pointer and the userusually expects it's aligned on the highest CPU
required alignement, preserve it also for char*.

Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809685
Reported-by: Anatoly Pugachev <matorola@gmail.com>
8 years agodm: fix thin-pool targer params order
M.H. Tsai [Wed, 27 Jan 2016 11:11:03 +0000 (19:11 +0800)]
dm: fix thin-pool targer params order

Wrong thin-pool feature flag ordering in dm table: It will lead to
unnecessary table reload.

Fix it by placeing feature flags in order they are returned from the
kernel so current 'table line diff' code will not see a difference.

8 years agolvconvert: enable spare creation during conversion
M.H. Tsai [Wed, 27 Jan 2016 11:11:03 +0000 (19:11 +0800)]
lvconvert: enable spare creation during conversion

Let user control pool metadata spare creation after repair as
the VG might not have enough free space.

8 years agoconfig: fix verbose type to int
M.H. Tsai [Wed, 27 Jan 2016 11:11:03 +0000 (19:11 +0800)]
config: fix verbose type to int

'verbose' was marked as a boolean option while it
takes integer args - so it has limited usage to 0 or 1,
but we supported 0-4 at least.

Fix it by switching to corrent int type.
(Hopefully noone was trying to use this variable as true/yes/false/no
way - as the would be unsupported/undocumented).

8 years agothin: fix low_water_mark threshold calc
Zdenek Kabelac [Thu, 11 Feb 2016 17:05:36 +0000 (18:05 +0100)]
thin: fix low_water_mark threshold calc

Reporter noticed lvm2 incorrectly translated
lvm2 threshold value to  water mark in commit:
99237f0908d87592815f4bdf3c239e8a108e835c

Fix it by properly translating size to number of
blocks in thin-pool and then calc for free blocks
matching configured lvm2 threshold value.

Reported-by: Ming-Hung Tsai <mingnus@gmail.com>
8 years agoconf: use use_blkid_wiping=0 if not defined in lvm.conf and support not compiled in
Peter Rajnoha [Wed, 10 Feb 2016 13:53:10 +0000 (14:53 +0100)]
conf: use use_blkid_wiping=0 if not defined in lvm.conf and support not compiled in

Normally, we generate and provide lvm.conf file where use_blkid_wiping
is set based on whether support for this is compiled in or not. This was
generated properly based on configure.

However, if lvm.conf is not used at all (someone deletes it) or the value
in lvm.conf is commented out (user edited it), we still need to use
proper default value that is based on DEFAULT_USE_BLKID_WIPING taken
from configure script - we used hardcoded value of "1" in this case
by mistake.

8 years agofilter: do not check for suspended devs in filter-usable in lvmetad mode
Peter Rajnoha [Wed, 3 Feb 2016 13:40:52 +0000 (14:40 +0100)]
filter: do not check for suspended devs in filter-usable in lvmetad mode

We already do check for suspended devs within udev rules where
the pvscan is to update lvmetad. So the check for suspended devs
in "pre-lvmetad" chain is not useful here - remove it - it may
be a source of hardly to detect races anyway (if udev rule detects
the device is not suspended and then the pvscan instance sees the
dev as suspended, we may end up not reacting to the event properly).

8 years agometadata: format: also delete bootloader areas from lvmcache when reading lvm1 and...
Peter Rajnoha [Tue, 2 Feb 2016 12:54:19 +0000 (13:54 +0100)]
metadata: format: also delete bootloader areas from lvmcache when reading lvm1 and pool label

lvm1 and pool format do not support bootloader areas and we need to
remove any existing associated bootloader areas when we read lvm1 and
pool labels.

This has its importance if we're converting from one format to another
and we're reusing lvmcache in long-running commands (e.g. clvmd or lvm
shell) and we need to make lvmcache consistent and valid for current format.

This page took 0.076681 seconds and 5 git commands to generate.