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

110 Commits

Author SHA1 Message Date
Peter Rajnoha
a7bfc2cbb5 cleanup: tools: "or use -S for selection" --> "or use --select for selection" 2015-03-04 14:40:58 +01:00
Zdenek Kabelac
4c184e9d6b cleanup: drop unused value assign
Dop unused value assignments.

Unknown is detected via other combination
(!linear && !striped).

Also change the log_error() message into a warning,
since the function is not really returning error,
but still keep the INTERNAL_ERROR.

Ret value is always set later.
2015-02-19 14:43:25 +01:00
Peter Rajnoha
969d2bf448 cleanup: remove deallocate_handle_root arg from destroy_procesing_handle fnw 2015-02-13 11:27:09 +01:00
Peter Rajnoha
1a72933143 pvchange: no need to initialize selection handle directly, process_each_pv will do that automatically 2015-02-13 09:29:30 +01:00
Alasdair G Kergon
e4e703ab60 pvchange: Use process_each_pv.
Invalid devices no longer included in the counters printed at the end.
May now need to use --ignoreskippedcluster if relying upon exit status.
If more than one change is requested per-PV, attempt to perform them
all.  Note that different arguments still handle exit status
differently.
2015-02-12 16:37:47 +00:00
Peter Rajnoha
7f2eebf519 select: initialize selection handle for process_each_* fns with initial report type
This is a followup patch for previous patchset that enables selection in
process_each_* fns to fix an issue where field prefixes are not
automatically used for fields in selection criteria.

Use initial report type that matches the intention of each process_each_* functions:
- _process_pvs_in_vg - PVS
- process_each_vg - VGS
- process_each_lv and process_each_lv_in_vg - LVS

This is not normally needed for the selection handle init, BUT we would
miss the field prefix matching, e.g.

lvchange -ay -S 'name=lvol0'

The "name" above would not work if we didn't initialize reporting with
the LVS type at its start. If we pass proper init type, reporting code
can deduce the prefix automatically ("lv_name" in this case).

This report type is then changed further based on what selection criteria we
have. When doing pure selection, not report output, the final report type
is purely based on combination of this initial report type and report types
of the fields used in selection criteria.
2015-02-10 16:10:17 +01:00
Peter Rajnoha
f784c60cd6 tools: allow -S|--select for vgchange, lvchange and pvchange 2015-02-10 16:08:04 +01:00
Peter Rajnoha
d6c8f0de28 pvchange: use processing_handle when processing items for pvchange
pvchange is an exception that does not use toollib yet for iterating
over the list of PVs (process_each_pv) so intialize the
processing_handle and use just like it's used in toollib.
2015-02-10 16:07:01 +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
Peter Rajnoha
5abdb52fdc report: select: refactor: move str_list to libdm
The list of strings is used quite frequently and we'd like to reuse
this simple structure for report selection support too. Make it part
of libdevmapper for general reuse throughout the code.

This also simplifies the LVM code a bit since we don't need to
include and manage lvm-types.h anymore (the string list was the
only structure defined there).
2014-06-17 16:27:20 +02:00
Zdenek Kabelac
a4ac21aded cleanup: make error message more readable 2014-05-21 23:14:41 +02:00
Zdenek Kabelac
88a9705222 pvchange: populate lvmcache for --all
When running pvchange --all  learn about available VGs from lvmetad.
2014-03-28 10:41:58 +01:00
Zdenek Kabelac
80fe100afa pvchange: fix exit code regression
Commit 1a832398a7 moved
some code from _pvchange_single() to main pvchange() and
introduced exit code regression as return codes have not
been properly changed, thus pvchange command exited
with '0' exit code, even though it has reported error.
Also there is a missing vg unlock in error path.

Fix it by counting the total number of expected calls before
checking for pvname and also unlock and relase vg when
pv is not found.
2014-03-27 13:01:51 +01:00
Petr Rockai
f65dd341a5 locking: Make it possible to pass down an LV to activation code.
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.
2013-06-10 17:26:38 +02:00
Peter Rajnoha
32ae07cef1 pv_write: clean up non-orphan format1 PV write
...to not pollute the common and format-independent code in the
abstraction layer above.

The format1 pv_write has common code for writing metadata and
PV header by calling the "write_disks" fn and when rewriting
the header itself only (e.g. just for the purpose of changing
the PV UUID) during the pvchange operation, we had to tweak
this functionality for the format1 case and we had to assign
the PV the orphan state temporarily.

This patch removes the need for this format1 tweak and it calls
the write_disks with appropriate flag indicating whether this is
a PV write call or a VG write call, allowing for metatada update
for the latter one.

Also, a side effect of the former tweak was that it effectively
invalidated the cache (even for the non-format1 PVs) as we
assigned it the orphan state temporarily just for the format1
PV write to pass.

Also, that tweak made it difficult to directly detect whether
a PV was part of a VG or not because the state was incorrect.

Also, it's not necessary to backup and restore some PV fields
when doing a PV write:

  orig_pe_size = pv_pe_size(pv);
  orig_pe_start = pv_pe_start(pv);
  orig_pe_count = pv_pe_count(pv);
  ...
  pv_write(pv)
  ...
  pv->pe_size = orig_pe_size;
  pv->pe_start = orig_pe_start;
  pv->pe_count = orig_pe_count;

...this is already done by the layer below itself (the _format1_pv_write fn).

So let's have this cleaned up so we don't need to be bothered
about any 'format1 special case for pv_write' anymore.
2013-03-25 15:08:26 +01:00
Zdenek Kabelac
f260f99d57 cleanup: switch log_error to log_warn
Use log_warn to print non-fatal warning messages.

Use of log_error would confuse checker for testing
whether proper error has been reported for some real error.
2012-10-17 15:41:35 +02:00
Alasdair G Kergon
438e0050df config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.

When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]

Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 20:35:48 +01:00
Petr Rockai
e59e2f7c3c Move the core of the lib/config/config.c functionality into libdevmapper,
leaving behind the LVM-specific parts of the code (convenience wrappers that
handle `struct device` and `struct cmd_context`, basically). A number of
functions have been renamed (in addition to getting a dm_ prefix) -- namely,
all of the config interface now has a dm_config_ prefix.
2011-08-30 14:55:15 +00:00
Zdenek Kabelac
077a6755ff Replace free_vg with release_vg
Move the free_vg() to  vg.c  and replace free_vg  with release_vg
and make the _free_vg internal.

Patch is needed for sharing VG in vginfo cache so the release_vg function name
is a better fit here.
2011-08-10 20:25:29 +00:00
Peter Rajnoha
3b97e8d643 Allow non-orphan PVs with two metadata areas to be resized.
We allow writing non-orphan PVs only for resize now. The "orphan PV" assert
in pv_write fn uses the "allow_non_orphan" parameter to control this assert.
However, we should find a more elaborate solution so we can remove this
restriction altogether (pv_write together with vg_write is not atomic, we
need to find a safe mechanism so there's an easy revert possible in case of
an error).
2011-02-28 13:19:02 +00:00
Peter Rajnoha
51aed1992f Add old_uuid field to struct physical_volume so we can still reference a PV
with its old UUID when we're changig it (the cache as well as metadata area
index has the old uuid that we need to use to access the information!)
2011-02-21 12:31:28 +00:00
Peter Rajnoha
17ad2b1115 Change pv_write code to work with the changes in metadata handling interface
and changes in format_instance.
2011-02-21 12:26:27 +00:00
Alasdair Kergon
b51cd542be Add change_tag to toollib.
Allow multiple pvchange command line options to be specified together.
2011-01-24 13:38:31 +00:00
Milan Broz
fadd934150 Fix wrongly paired unlocking of global lock in pvchange. (2.02.66) 2010-12-23 14:23:30 +00:00
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Alasdair Kergon
f8452d8cfd Support repetition of --addtag and --deltag arguments.
Add infrastructure for specific cmdline arguments to be repeated in groups.
Split the_args cmdline arguments and values into arg_props and arg_values.
2010-11-11 17:29:05 +00:00
Peter Rajnoha
bad35c6554 Add escape sequence for ':' and '@' found in device names used as PVs. 2010-09-23 12:02:33 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Dave Wysochanski
69e80c9eee Shorten prompt for pvchange and vgextend. 2010-07-07 21:30:07 +00:00
Dave Wysochanski
96c3c4645f Add --force to pvchange, and allow override of prompt involving metadataignore.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-07 19:14:57 +00:00
Dave Wysochanski
90b96af68f Add prompt if using --metadataignore argument with vgmetadatacopies.
When using vgmetadatacopies value other than "umanaged" (0), prompt
the user if the usage of --metadataignore would change the value of
vgmetadatacopies.  The main 2 cases are:
1) pvchange --metadataignore
2) vgextend --metadataignore

We leave the prompt check in the tools, and do not change anything
if the user says 'n'.

Examples:
vgextend --metadataignore y vgtest /dev/loop0
Setting metadataignore will override preferred number of copies of VG vgtest metadata.
Are you sure? [y/n]: y
  No physical volume label read from /dev/loop0
  Physical volume "/dev/loop0" successfully created
  Volume group "vgtest" successfully extended

pvchange --metadataignore y /dev/loop3
Setting metadataignore on /dev/loop3 will override preferred number of copies of VG vgtest metadata.
Are you sure? [y/n]: y
  WARNING: Changing preferred number of copies of VG vgtest metadata from 3 to 2
  Physical volume "/dev/loop3" changed
  1 physical volume changed / 0 physical volumes not changed

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-07 19:02:50 +00:00
Dave Wysochanski
a375ced300 Move code into pv_change_metadataignore library function.
In preparation to call this from both pvcreate as well as pvchange,
move the guts of metadataignore into a library function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-29 21:32:44 +00:00
Dave Wysochanski
60a5f61fc8 Set vg_mda_copies when pvchange --metadataignore is given.
When a user explicitly sets a new mda ignore value for a PV, we
should update vg_mda_copies accordingly.  When the VG is written
out, the user would not want the new ignore state to get lost as
a result of the vg_mda_copies value and logic in the vg_write
path.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:06 +00:00
Dave Wysochanski
88fc1b143e Add --metadataignore to pvchange, allowing for ignoring of metadata areas.
This patch just modifies pvchange to call the underlying ignore
functions for mdas.  Ensure special cases do not reflect changes
in metadata (PVs with 0 mdas, setting ignored when already ignored,
clearing ignored when not ignored).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:58 +00:00
Dave Wysochanski
a5f0b044bf Remove another pvchange hack involving orphan VG names.
Unnecessary as a result of recent changes.
2010-05-19 15:34:10 +00:00
Dave Wysochanski
24a57a0b95 Remove hack in pvchange to unlock orphan VG.
With agk's recent changes, the lock/unlock APIs can properly handle
orphan VG names.
2010-05-19 13:21:09 +00:00
Dave Wysochanski
1a832398a7 Update pvchange to always obtain a vg handle for each pv to process.
Earlier patches added some infrastructure to lookup a vgname from
a pvname.  We now can cleanup some of the pvchange and other code
by requiring callers that want to modify some pv property:
1) lookup the vgname by the pvname
2) use the vgname to obtain a vg handle
3) get the pv handle from the vg handle

This should work going forward and be a much cleaner interface,
as we move away from pvs as standalone objects.
2010-05-19 11:53:00 +00:00
Alasdair Kergon
651ff9b328 Add lots of missing stack debug messages to tools.
Make readonly locking available as locking type 4.
Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
2009-09-14 22:47:49 +00:00
Dave Wysochanski
0f66b7086b Refactor a couple log_error() statements in prep for larger log_error() patch.
Part of twoerner's log_error() patches.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-08 18:15:51 +00:00
Dave Wysochanski
4c611a220a Fix vg_read() error paths to properly release upon vg_read_error().
Fix vg_read() error paths to properly release upon vg_read_error().
Note that in the iterator paths (process_each_*()), we release
inside the iterator so no individual cleanup is needed.  However there
are a number of other places we missed the cleanup.  Proper cleanup
when vg_read_error() is true should be calling vg_release(vg), since
there should be no locks held if we get an error (except in certain
special cases, which IMO we should work to remove from the code).

Unfortunately the testsuite is unable to detect these types of memory
leaks.  Most of them can be easily seen if you try an operation
(e.g. lvcreate) with a volume group that does not exist.  Error
message looks like this:
  Volume group "vg2" not found
  You have a memory leak (not released memory pool):
   [0x1975eb8]
  You have a memory leak (not released memory pool):
   [0x1975eb8]


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-07 01:18:35 +00:00
Dave Wysochanski
b8b3508c59 Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).

Rebased 6/26/09 by Dave W.
2009-07-01 16:59:37 +00:00
Alasdair Kergon
f7c76e3878 revert last patch - let's do a release first 2009-06-26 10:55:57 +00:00
Dave Wysochanski
96d0004d12 Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).


Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-06-26 09:47:36 +00:00
Alasdair Kergon
2f5a1df42c Abort if automatic metadata correction fails when reading VG to update it. 2009-06-26 09:19:13 +00:00
Alasdair Kergon
25a2e7b80e Pre-release cleanups. 2009-05-21 03:04:52 +00:00
Milan Broz
043b13625b Properly release VG memory pool in all CLI tools. 2009-04-10 10:01:38 +00:00
Milan Broz
7b1c853bd9 Try to avoid full rescan if label scan is enough. 2009-02-25 23:29:06 +00:00
Alasdair Kergon
2c44337bd5 Right, a simple build (without options) is working again. 2008-11-03 22:14:30 +00:00
Alasdair Kergon
a6d9d66dcc remove unused mdas variable 2008-07-31 12:40:52 +00:00
Alasdair Kergon
1b8b624661 Fix pvchange to handle PVs without mdas. 2008-07-31 12:28:51 +00:00