1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

3039 Commits

Author SHA1 Message Date
Peter Rajnoha
5649834f7d lvmcmdline: return 0/NULL if cmd->arg_values not set and arg_count/grouped_arg_count/arg_value called
We may call arg_count/grouped_arg_count/arg_value soon enough that
cmd->arg_values is not set yet.

Normally, when running a command, we execute lvm_run_command which in
turn calls _process_command_line to allocate and parse the command line
values and stores them in cmd->arg_values.

However, if we run lvm shell, this one doesn't accept any command line
options and we parse the command line for each command that is executed
within the lvm shell then. If we used any code that tries to access
cmd->arg_values through any of the the arg handling functions too
early, we could end up with a segfault due to uninitialized (NULL)
cmd->arg_values.

This patch just saves extra checks in all the code where arg handling
may be called too early so that the cmd->arg_values is not set up yet.
This does not apply to any of existing code, but subsequent patches
will need that.
2016-08-09 18:24:45 +02:00
Peter Rajnoha
1fde4bf4d0 refactor: move report grouping and log reporting handles from processing_handle to cmd_context
With patches that will follow, this will make it possible to widen log
report coverage when commands are executed from lvm shell so the amount
of messages that may end up in stderr/stdout instead of log report are
minimized.
2016-08-09 18:24:45 +02:00
Peter Rajnoha
ef69934746 shell: also collect last command's return code for subsequent 'lastlog' invocation
Add new log_context=shell and with log_object_type=cmd and
log_object_name=<command_name> for command log report to collect
overall return code from last command (this is reported under
log_type=status).
2016-08-09 18:24:45 +02:00
Peter Rajnoha
06ce9b4e42 log: separate output and make it possible to use given FDs
Currently, the output is separated in 3 parts and each part can go into
a separate and user-defined file descriptor:

  - common output (stdout by default, customizable by LVM_OUT_FD environment variable)
  - error output (stderr by default, customizable by LVM_ERR_FD environment variable)
  - report output (stdout by default, customizable by LVM_REPORT_FD environment variable)

For example, each type of output goes to different output file:

  [0] fedora/~ # export LVM_REPORT_FD=3

  [0] fedora/~ # lvs fedora vg/abc 1>out 2>err 3>report

  [0] fedora/~ # cat out

  [0] fedora/~ # cat err
    Volume group "vg" not found
    Cannot process volume group vg

  [0] fedora/~ # cat report
    LV   VG     Attr       LSize   Layout     Role       CTime
    root fedora -wi-ao----  19.00g linear     public     Wed May 27 2015 08:09:21
    swap fedora -wi-ao---- 500.00m linear     public     Wed May 27 2015 08:09:21

Another example in LVM shell where the report goes to "report" file:

  [0] fedora/~ # export LVM_REPORT_FD=3
  [0] fedora/~ # lvm 3>report

  (in lvm shell)
  lvm> vgs

  (content of "report" file)
  [1] fedora/~ # cat report
    VG     #PV #LV #SN Attr   VSize  VFree
    fedora   1   2   0 wz--n- 19.49g    0

  (in lvm shell)
  lvm> lvs

  (content of "report" file)
  [1] fedora/~ # cat report
    VG     #PV #LV #SN Attr   VSize  VFree
    fedora   1   2   0 wz--n- 19.49g    0
    LV   VG     Attr       LSize   Layout     Role       CTime
    root fedora -wi-ao----  19.00g linear     public     Wed May 27 2015 08:09:21
    swap fedora -wi-ao---- 500.00m linear     public     Wed May 27 2015 08:09:21
2016-08-09 18:24:45 +02:00
Alasdair G Kergon
e5a5fd3669 lvconvert: Fix repair and replace routing. 2016-08-08 23:13:34 +01:00
Alasdair G Kergon
175e0905d5 test: Drop --mirrorlog when not a mirror. 2016-08-08 18:43:54 +01:00
David Teigland
fc93085c7a lvconvert: separate type raid to mirror
By the current division of unique operations,
converting type raid to type mirror is distinct
from converting type raid to raid.
2016-08-08 10:37:24 -05:00
Alasdair G Kergon
c55134aa48 lvconvert: Limit --corelog and --mirrorlog to mirrors.
It's an error to specify a log when the final result is not of type
mirror.
2016-08-08 14:39:55 +01:00
Heinz Mauelshagen
7d6cf12554 lvcreate: reject '--nosync' option for RAID6 LVs
The MD raid6 personality being used to drive lvm raid6 LVs does
read-modify-write updates to any stripes and thus relies on correct
P and Q Syndromes being written during initial synchronization or
it may fail reconstructing proper user data in case of SubLVs failing.

We may not allow the '--nosync' option on
creation of raid6 LVs for that reason.

Update/fix 'man lvcreate' in that regard.

add lvcreate-raid-nosync.sh test script.

- Resolves rhbz1358532
2016-08-08 13:52:35 +02:00
Peter Rajnoha
57fa5d4329 lvmcmdline: do not refresh whole cmd context if profile dropped after processing LVM cmd
We don't need to refresh whole cmd context if we drop profile after
processing LVM command - just like we don't refresh cmd context when
we're applying the profile. It's because profiles contain only safe
subset of settings which do not require complete cmd context refresh.

This patch calls process_profilable_config instead of
refresh_toolcontext if there was profile applied for the LVM
command only, not --config which requires toolcontext refresh.
The process_profilable_config just sets proper values based on
values of profilable settings, but it does not do complete
reinitialization of various parts (e.g. filters, logging etc.).
2016-08-08 11:57:13 +02:00
Alasdair G Kergon
76ef2d15d8 lvconvert: Support raid0<->raid4 and mirror<->raid1.
Only simple takeover cases so far.
2016-08-07 00:56:08 +01:00
Heinz Mauelshagen
d2c3b23e6d lvchange: Allow device specification when requesting a repair
'lvchange --resync LV' or 'lvchange --syncaction repair LV' request the
RAID layout specific parity blocks in raid4/5/6 to be recreated or the
mirrored blocks to be copied again from the master leg/copy for raid1/10,
thus not allowing a rebuild of a particular PV.

Introduce repeatable option '--[raid]rebuild PV' to allow to request
rebuilds of specific PVs in a RaidLV which are known to contain corrupt
data (e.g. rebuild a raid1 master leg).

Add test lvchange-rebuild-raid.sh to test/shell doing rebuild
variations on raid1/10 and 5; add aux function check_status_chars
to support the new test.

 - Resolves rhbz1064592
2016-08-05 16:01:46 +02:00
Alasdair G Kergon
91f866f786 raid: Tell lib whether stripesize was specified 2016-08-05 14:28:14 +01:00
David Teigland
d1a25fe597 lvconvert: add FIXME
operations are no longer identified correctly.
2016-08-04 13:01:48 -05:00
Alasdair G Kergon
4a15abe865 striped: Add precise macros for original segtype.
The existing striped macros include raid0 segments.
2016-08-04 01:24:39 +01:00
Alasdair G Kergon
5c3141a8b9 lvconvert: Improve error message when no -m. 2016-08-03 23:43:59 +01:00
Alasdair G Kergon
8b1a368b59 lvconvert: Provide entry point for new functionality.
Prepare for new segment type conversion functionality in cases that
currently fail.  In the short-term, we need to do this while limiting
the changes to the code paths for the conversions that are already
supported.
2016-08-03 03:53:29 +01:00
Alasdair G Kergon
fdc3fcbfce lvconvert: Pass region_size to lv_raid_convert. 2016-08-02 23:51:20 +01:00
Alasdair G Kergon
a234cebbed lvconvert: Preserve mirror region size with --repair. 2016-08-02 19:50:04 +01:00
Alasdair G Kergon
415c5fd5d8 lvconvert: Divide into 12 categories. 2016-08-02 16:44:21 +01:00
Alasdair G Kergon
6361bc4734 lvconvert: Treat --repair as an independent case. 2016-08-02 16:22:12 +01:00
Alasdair G Kergon
804a397643 lvconvert: Forbid stripe parameters with --repair. 2016-08-02 15:59:12 +01:00
Alasdair G Kergon
d0df1ff995 lvconvert: Set lp->segtype in only one place. 2016-07-30 18:20:04 +01:00
Alasdair G Kergon
1ce958bc5e lvconvert: Rely upon lp->thin and lp->cache. 2016-07-30 15:58:09 +01:00
Alasdair G Kergon
48d9c46daa lvconvert: Fix --type thin recognition.
lp->thin already holds the result of the cmdline arg resolution.
2016-07-30 15:08:50 +01:00
Alasdair G Kergon
b3fbcd1ff7 lvconvert: Move stripe validation code later.
Simpler to delay it all until the actual LV being changed is available,
rather than having it split in two parts.
2016-07-30 02:52:06 +01:00
Alasdair G Kergon
4ffe15bf6a tools: Unify stripesize parameter validation.
Move it all into get_stripe_params().
Some code paths missed --stripesize checks.
E.g. lvcreate --type raid4 -i1
2016-07-30 02:05:50 +01:00
Alasdair G Kergon
d01b1b6cc1 lvconvert: Rearrange code that decides segtype. 2016-07-30 00:22:13 +01:00
Alasdair G Kergon
a8e4790810 lvconvert: Only obtain --type parameter once. 2016-07-29 21:45:22 +01:00
Alasdair G Kergon
800c0d3dd6 lvconvert: Remove hard-coded segment names. 2016-07-29 21:11:12 +01:00
Alasdair G Kergon
6f47e79a88 pre-release 2016-07-28 18:36:45 +01:00
Heinz Mauelshagen
a579ba2ac2 vgsplit: ea90a3d622 added an unconditional call to lv_is_on_pvs()
on any thin snap external origin LV which caused a segfault
         when none existed as exposed by the vgsplit-thin.sh test.

         Only call lv_is_on_pvs() if an external origin LV actually
         exists and correct the related splitting logic.
2016-07-28 18:35:33 +02:00
David Teigland
ea90a3d622 vgsplit: restore check for thin pool external origin
Fix a regression from commit 4420d41f, in which the
check was skipped for splitting a thin pool and an
external origin.
2016-07-27 14:00:57 -05:00
Heinz Mauelshagen
c7b2654c25 lvcreate.c: respect DEFAULT_RAID_MAX_IMAGES on creation of any RaidLV 2016-07-27 18:20:48 +02:00
Heinz Mauelshagen
8f62b7bfe5 vg_validate: segment check enhancements for raids to catch bogus metadata
General RAID and RAID segment type specific checks are added
to merge.c. New static _check_raid_seg() is called on each segment
of a RaidLV (which have just one) from check_lv_segments().

New checks caught some unititialized segment members
which are addressed here as well:

- initialize seg->region_size to 0 in lvcreate.c for raid0/raid0_meta

- initialize list seg->origin_list in lv_manip.c
2016-07-27 18:17:29 +02:00
Zdenek Kabelac
eaf7d06a82 lvconvert: support --zero for full cache pool conversion.
Add matching support for -Z option also we doing full conversion
to cache-pool.

Extending coversion message to show which pool type is created
and whether the metadata will be wiped or remain unmodified.
2016-07-27 16:20:57 +02:00
Zdenek Kabelac
3c377f8334 lvconvert: tune cache-pool zeroing
Follow-up to 27a767d5e8.
Tunning behavior in a way we always prompt when option --zero is NOT specified.
Without -Z lvm expects user wants to 'reset' cache-pool metadata
(they could have been splitted from some cached LV)

If user doesn't want to zero metadata he needs to specify -Zn.

User may also avoid prompting for zeroing by using -Zy for
cache-pool (basically equals using --yes  without -Z being given)
(unlike full convert case, there is no cache-pool being converted,
so there is not 'uncoditional' prompt in this case).
2016-07-27 16:20:57 +02:00
Zdenek Kabelac
5636bfd83d lvconvert: suppress zeroing warning when converting to thin
When volume was lvconvert-ed to a thin-volume with external origin,
then in case thin-pool was in non-zeroing mode
it's been printing WARNING about not zeroing thin volume - but
this is wanted and expected - so nothing to warn about.

So in this particular use case WARNING needs to be suppressed.

Adding parameter support for lvcreate_params.

So now lvconvert creates 'normal thin LV' in read-only mode
(so any read will 'return 0' for a moment)
then deactivate regular thin LV and reacreate in 'final R/RW' mode
thin LV with external origin and activate again.
2016-07-27 16:20:57 +02:00
Alasdair G Kergon
d180bf6311 lvconvert: --trackchanges requires --splitmirrors 1 2016-07-25 21:15:25 +01:00
Alasdair G Kergon
1efb1c2343 lvconvert: --trackchanges requires --splitmirrors 2016-07-25 19:32:10 +01:00
David Teigland
7b1daa248f lvconvert: remove warnings about deprecated split option
A warning seems too severe for this message, so leave it
out until there's a better idea.
2016-07-25 11:01:56 -05:00
David Teigland
70bad99894 lvmlockd: improve message for lock-start
Only print this for shared VGs, and include the
time it may take for sanlock.
2016-07-25 10:43:06 -05:00
David Teigland
2c3b92b550 lvconvert: change error message
for implicit pool conversion since it's also used
when the lv is already a pool
2016-07-22 10:00:24 -05:00
Zdenek Kabelac
27a767d5e8 lvconvert: reusing old cache pool metadata needs -Zn
When cache pool is reused for a new cached volume, there is
normally no need to 'keep' old cache-pool metadata as this
could cause major data lose.

Unlike with 'lvcreate -H -LX --cachepool' conversion, this lvconvert
path left the metadata unzeroed - partly for making easier some
debugging, but this was rather a bug.

So to keep possible reattach of 'unzeroed' metadata, user
now has to use 'lvconvert -Zn' for such conversion. In this case
the prompt will appear about possibe data loss and to proceed,
user has to confirm such operation. Without -Zn metadata are wiped.
2016-07-22 14:40:26 +02:00
Heinz Mauelshagen
259f9dd718 lvcreate: conditionally set stripesize
Stripe size may not be set unconditionally in
_read_mirror_and_raid_params() or creation of
striped LV will fail
2016-07-21 02:33:28 +02:00
David Teigland
b203d5e745 lvconvert: allow implied cache pool convert
Just as with the implied thin pool convert when
given ambiguous command line options.
2016-07-20 10:44:28 -05:00
Heinz Mauelshagen
7eb7909193 lvcreate: raid0 needs default number of stripes
Commit 3928c96a37 introduced
new defaults for raid number of stripes, which may cause
backwards compatibility issues with customer scripts.

Adding configurable option 'raid_stripe_all_devices' defaulting
to '0' (i.e. off = new behaviour) to select the old behaviour
of using all PVs in the VG or those provided on the command line.

In case any scripts rely on the old behaviour, just set
'raid_strip_all_devices = 1'.

- resolves rhbz1354650
2016-07-20 17:20:15 +02:00
Zdenek Kabelac
6dc4d03508 lvconvert: enable work with partial LVs
Fix printed message and enable handling of missing PVs.
2016-07-19 17:39:41 +02:00
Bryn M. Reeves
da49d4d54e dmstats: fix bounds leak in _do_stats_create_regions() (Coverity) 2016-07-18 18:48:34 +01:00
Bryn M. Reeves
d2bf6742f8 dmstats: check uuid, major, and alldevices before argc (Coverity)
The --uuid, --major and --alldevices arguments were incorrectly tested
after confirming argc is > 0, in a branch that only executes if argc
== 0 (i.e. they were unreachable).

Move all device checks before the test for argc and log an appropriate
error before returning.
2016-07-18 18:48:34 +01:00