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

268 Commits

Author SHA1 Message Date
David Teigland
c3faa5816d commands: move command def parsing into lvm binary
It was previously done at build time by the ccmd binary.
2017-02-13 08:20:10 -06:00
David Teigland
52c60b7e7b lvchange: make use of command definitions
Reorganize the lvchange code to take advantage of
the command definition, and remove the validation
that is done by the command definintion rules.
2017-02-13 08:20:10 -06:00
David Teigland
9c6c55c314 process_each_lv: add check_single_lv function
The new check_single_lv() function is called prior to the
existing process_single_lv().  If the check function returns 0,
the LV will not be processed.

The check_single_lv function is meant to be a standard method
to validate the combination of specific command + specific LV,
and decide if the combination is allowed.  The check_single
function can be used by anything that calls process_each_lv.

As commands are migrated to take advantage of command
definitions, each command definition gets its own entry
point which calls process_each for itself, passing a
pair of check_single/process_single functions which can
be specific to the narrowly defined command def.
2017-02-13 08:20:10 -06:00
Zdenek Kabelac
1f5dde38a7 cleanup: more use of lvseg_name
Use existing function lvseg_name().
2017-01-03 14:55:16 +01:00
Zdenek Kabelac
0e8449a5b9 thin: fix lvchange of discards and zero flag
Reload of thin-pool origin_only is designed to only post messages
to a thin-pool. It's not intended to be used for reload of thin-pool
table. Fix it by using standard call  'lv_update_and_reload()'.
2016-09-19 14:00:56 +02:00
Brassow Jonathan
5838c41a35 cache: scrubbing for cache origin LV - Bug 1169495
Allow RAID scrubbing on cache origin sub-LV

This patch adds the ability to perform RAID scrubbing on the cache
origin sub-LV (https://bugzilla.redhat.com/1169495).  Cache origin
operations are restricted to non-clustered RAID LVs until there can
be further testing in a cluster (even for exclusive activation).

User can either specify directly _corig LV
or he can specify cache LV and operation  --syncation is
passed ONLY to   _corig LV.

If users wants to manipulation with cache-pool devices - he
needs to specify this object name.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2016-09-07 16:42:32 +02: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
5af311ddd8 macros: Add lv_is_not_synced. 2016-07-14 14:21:01 +01:00
Heinz Mauelshagen
c77c59f3d9 lvchange: resync attempts on raid0 cause segfaults
Resync attempts on raid0/raid0_meta via 'lvchange --resync ...'
cause segfaults.

'lvchange --syncaction ...' doesn't get rejected either.

Prohibit both on raid0/raid0_meta LVs.

- resolves rhbz1354656
2016-07-12 17:23:05 +02:00
Zdenek Kabelac
3fd4584886 cleanup: lvchange uses display_lvname
Convert messages to report vg/lv name consistently.

Also drop unneeded 'info_obtaned' variable since the
obtained info is not reused in any code path.
2016-07-01 00:44:48 +02:00
Alasdair G Kergon
7e671e5dd0 tools: Use arg_is_set instead of arg_count. 2016-06-21 22:24:52 +01:00
Zdenek Kabelac
04003cf1ff cache: add log_error on error path
Validate and report error when lv_cache_status is called
for inactive LV, or pending delete or unused cache_pool.
2016-05-27 15:47:24 +02:00
David Teigland
2f2b3c9100 lvconvert: use process_each_lv
In the same way that process_each_vg() can be passed
a single VG name to process, also allow process_each_lv()
to be passed a single VG name and LV name to process.
2016-05-25 15:05:49 -05:00
Alasdair G Kergon
b896f7de1e raid0: Standardise meta_areas checks before access. 2016-05-23 22:55:13 +01:00
Zdenek Kabelac
197066c863 lvchange: allow change of cache mode
Add support for active cache LV.
Handle --cachemode args validation during command line processing.
Rework some lvm2 internal to use lvm2 defined  CACHE_MODE  enums
indepently on libdm defines and use enum around the code instead
of passing and comparing strings.
2016-05-19 18:40:14 +02:00
Zdenek Kabelac
e77b6968b6 lvchange: use better arg functions 2016-04-26 23:29:58 +02:00
Zdenek Kabelac
c215e1be5c lvchange: always check for sigint
Check sigint() state during process_each_lv.
2016-04-26 23:29:08 +02:00
Zdenek Kabelac
d8bdc7af37 lvchange: fix return code
We already opened VG for this - so not an invalid cmdline.
2016-04-26 23:28:01 +02:00
Alasdair G Kergon
01181a299e activate: Hide errors when snapshot merge delayed. 2016-04-21 22:14:10 +01:00
David Teigland
5e9e43074a lvmetad: rework command connection setup and checking
The lvmetad connection is created within the
init_connections() path during command startup,
rather than via the old lvmetad_active() check.

The old lvmetad_active() checks are replaced
with lvmetad_used() which is a simple check that
tests if the command is using/connected to lvmetad.

The old lvmetad_set_active(cmd, 0) calls, which
stopped the command from using lvmetad (to revert to
disk scanning), are replaced with lvmetad_make_unused(cmd).
2016-04-19 14:00:02 -05:00
Zdenek Kabelac
dbc71dc05e 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.
2016-02-23 12:25:25 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Alasdair G Kergon
39a97d86f0 segtypes: Add and use new segtype macros.
Includes fixing an inverted raid10 segtype check in _raid_add_target_line.
2015-09-24 14:59:07 +01:00
Zdenek Kabelac
f0c18fceb4 cache: api update
Change logic and naming of some internal API functions.

cache_set_mode() and cache_set_policy() both take segment.

cache mode is now correctly 'masked-in'.

If the passed segment is 'cache' segment - it will automatically
try to find 'defaults' according to profiles if the are NOT
specified on command line or they are NOT already set for cache-pool.

These defaults are never set for cache-pool.
2015-08-12 14:32:24 +02:00
Zdenek Kabelac
969ee25a74 toollib: get_cache_params
Enhance  get_cache_params() to read common cache args.
2015-08-12 14:11:18 +02:00
David Teigland
439a579aa2 vgchange/lvchange: allow deactivation without locking
If locking with lvmlockd has failed, allow LVs to be deactivated.
2015-07-31 14:11:24 -05:00
David Teigland
b4be988732 vgchange/lvchange: enforce the shared VG lock from lvmlockd
The vgchange/lvchange activation commands read the VG, and
don't write it, so they acquire a shared VG lock from lvmlockd.
When other commands fail to acquire a shared VG lock from
lvmlockd, a warning is printed and they continue without it.
(Without it, the VG metadata they display from lvmetad may
not be up to date.)

vgchange/lvchange -a shouldn't continue without the shared
lock for a couple reasons:

. Usually they will just continue on and fail to acquire the
  LV locks for activation, so continuing is pointless.

. More importantly, without the sh VG lock, the VG metadata
  used by the command may be stale, and the LV locks shown
  in the VG metadata may no longer be current.  In the
  case of sanlock, this would result in odd, unpredictable
  errors when lvmlockd doesn't find the expected lock on
  disk.  In the case of dlm, the invalid LV lock could be
  granted for the non-existing LV.

The solution is to not continue after the shared lock fails,
in the same way that a command fails if an exclusive lock fails.
2015-07-17 15:35:34 -05:00
Zdenek Kabelac
e9e35b011e cache: handle policy_name separately
Keep policy name separate from policy settings and avoid
to mangling and demangling this string from same config tree.
Ensure policy_name is always defined.
2015-07-15 13:10:22 +02:00
Alasdair G Kergon
dfe3eb12d0 include: Standardise around new tool.h. 2015-07-06 17:30:18 +01:00
David Teigland
fe70b03de2 Add lvmlockd 2015-07-02 15:42:26 -05:00
Alasdair G Kergon
4c629a5257 locking: Add missing error handling.
Add missing error logging and detection to unlock_vg and callers
of sync_local_dev_names etc.
2015-06-30 18:54:38 +01:00
Ondrej Kozina
c26d81d6e6 toollib: do not spawn polling in lv_change_activate
spawning a background polling from within the lv_change_activate
fn went to two problems:

1) vgchange should not spawn any background polling until after
   the whole activation process for a VG is finished. Otherwise
   it could lead to a duplicite request for spawning background
   polling. This statement was alredy true with one exception of
   mirror up-conversion polling (fixed by this commit).

2) due to current conditions in lv_change_activate lvchange cmd
   couldn't start background polling for pvmove LVs if such LV was
   about to get activated by the command in the same time.

This commit however doesn't alter the lvchange cmd so that it works same as
vgchange with regard to not to spawn duplicate background pollings per
unique LV.
2015-04-13 20:52:22 +02:00
Zdenek Kabelac
a10a11bd54 lvchange: disable persistent minors for pools
There is no reason to support persistent major/minor numbers
for pool volumes - it's only meant to be supported for filesystems
(since i.e. nfs may need to keep volume on a persistent device node.)

Support for pools is now explicitely disabled and documented.
2015-03-18 13:42:13 +01:00
Peter Rajnoha
a7bfc2cbb5 cleanup: tools: "or use -S for selection" --> "or use --select for selection" 2015-03-04 14:40:58 +01:00
David Teigland
2477495922 lvchange, vgchange: fix the system_id check
The check for matching system_id needs to check
that the system_id is not blank.
2015-03-03 16:45:16 -06:00
Alasdair G Kergon
ee4cd2c737 lvchange: Allow -pr to change kernel only. 2015-02-27 13:38:26 +00:00
Alasdair G Kergon
b5394c8f26 lvchange: Allow -prw to change kernel only.
If an LV is already rw but still ro in the kernel, allow -prw to issue a
refresh to try to change the kernel state to rw.

Intended for use after clearing activation/read_only_volume_list in
lvm.conf.
2015-02-26 18:38:26 +00:00
David Teigland
dd6a202831 lvchange: deactivate is always possible in foreign vgs
The only realistic way for a host to have active LVs in a
foreign VG is if the host's system_id (or system_id_source)
is changed while LVs are active.

In this case, the active LVs produce an warning, and access
to the VG is implicitly allowed (without requiring --foreign.)
This allows the active LVs to be deactivated.

In this case, rescanning PVs for the VG offers no benefit.
It is not possible that rescanning would reveal an LV that
is active but wasn't previously in the VG metadata.
2015-02-25 14:58:49 -06:00
Alasdair G Kergon
5793ecd165 systemid: Extend --foreign to reporting commands.
Add --foreign to the remaining reporting and display commands plus
vgcfgbackup.
Add a NEEDS_FOREIGN_VGS flag for vgimport to always set --foreign.
If lvmetad is being used with --foreign, scan foreign VGs (currently
implemented as a full PV scan).
Handle these things centrally in lvmcmdline.c.
Also allow lvchange and vgchange -an/-aln to deactivate any foreign
LVs that happen to be active if something went wrong.
Remember to set the system ID when creating a new VG in vgsplit.
2015-02-23 23:41:38 +00:00
Peter Rajnoha
e1710f34bb lvchange: change msg about required params (LV or selection) to be consistent with msgs used in other tools 2015-02-13 09:04:21 +01:00
Peter Rajnoha
f784c60cd6 tools: allow -S|--select for vgchange, lvchange and pvchange 2015-02-10 16:08:04 +01:00
Peter Rajnoha
51d96a1703 toollib: replace void *handle with struct processing_handle for use in processing functions (process_each_*/process_single_* and related)
This patch replaces "void *handle" with "struct processing_handle *handle"
in process_each_*, process_single_* and related functions.

The struct processing_handle consists of two handles inside now:

  - the "struct selection_handle *selection_handle" used for
    applying selection criteria while processing process_each_*,
    process_single_* and related functions (patches using this
    logic will follow)

  - the "void* custom_handle" (this is actually the original handle
    used before this patch - a pointer to custom data passed into
    process_each_*, process_single_* and related functions).
2015-02-10 16:05:24 +01:00
Zdenek Kabelac
64d8ed502d thin: lvchange support for errorwhenfull
Support lvchange --errorwhenfull y|n for thin pools.
2015-01-20 14:53:03 +01:00
Petr Rockai
4b9b8e1282 toollib: Split --cachesettings from --cachepolicy. 2014-11-20 16:51:07 +01:00
Petr Rockai
c164f59631 lvchange: Accept --cachepolicy. 2014-11-20 16:51:07 +01:00
Zdenek Kabelac
a3a2c792a8 lv: lv_active_change add needs_exclusive flag
Let's use this function for more activations in the code.

'needs_exlusive' will enforce exlusive type for any given LV.

We may want to activate LV in exlusive mode, even when we know
the LV (as is) supports non-exlusive activation as well.

lvcreate -ay   -> exclusive & local
lvcreate -aay  -> exclusive & local
lvcreate -aly  -> exclusive & local
lvcreate -aey  -> exclusive  (might be on any node).
2014-11-05 15:29:43 +01:00
Zdenek Kabelac
0b7335f847 cache: allow deactivation of empty pool
Tool will use internal activation of unused cache pool to
clear metadata area before next use of cache-pool.
So allow to deactivation unused pool in case some error
case happend and we were not able to deactivation pool
right after metadata wipe.
2014-11-03 14:19:33 +01:00
Zdenek Kabelac
237c54802c tools: read yes_no_arg via int_value
yes_no_arg is already parsed so read parsed value as int.
2014-10-24 16:39:31 +02:00
Zdenek Kabelac
9411c19b31 segments: introduce lvseg_name
Instead of segtype->ops->name()  introduce lvseg_name().

This also allows us to leave name() function 'empty' for default
return of segtype->name.

TODO: add functions for rest of ops->
2014-10-24 16:39:30 +02:00
Petr Rockai
22a6b0e40b lvchange: Allow appropriate actions on cache (in addition to thin) pools. 2014-10-13 16:21:41 +02:00