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

110 Commits

Author SHA1 Message Date
Peter Rajnoha
c0629c13fe commands: add new NO_METADATA_PROCESSING flag to selected commands
When a command is flagged with NO_METADATA_PROCESSING flag, it means
such command does not process any metadata and hence it doens't require
lvmetad, lvmpolld and it can get away with no locking too. These are
mostly simple commands (like lvmconfig/dumpconfig, version, types,
segtypes and other builtin commands that do not process metadata
in any way).

At first, when lvm command is executed, create toolcontext without
initializing connections (lvmetad,lvmpolld) and without initializing
filters (which depend on connections init). Instead, delay this
initialization until we know we need this. That is, until the
lvm_run_command fn is called in which we know what the actual
command to run is and hence we can avoid any connection, filter
or locking initiliazation for commands that would not make use
of it anyway.

For all the other create_toolcontext calls, we keep the original
behaviour - the filters and connections are initialized together
with the toolcontext.
2015-07-30 13:56:13 +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
Ondrej Kozina
76a0dffe6f polldaemon: refactor polling interfaces
Routines responsible for polling of in-progress pvmove, snapshot merge
or mirror conversion each used custom lookup functions to find vg and
lv involved in polling.

Especially pvmove used pvname to lookup pvmove in-progress. The future
lvmpolld will poll each operation by vg/lv name (internally by lvid).
Also there're plans to make pvmove able to move non-overlaping ranges
of extents instead of single PVs as of now. This would also require
to identify the opertion in different manner.

The poll_operation_id structure together with daemon_parms structure they
identify unambiguously the polling task.
2015-05-05 20:52:07 +02:00
David Teigland
8668a9e81c systemid: silently ignore foreign vgs unless named
A foreign VG should be silently ignored by a reporting/display
command like 'vgs'.  If the reporting/display command specifies
a foreign VG by name on the command line, it should produce an
error message.

Scanning commands pvscan/vgscan/lvscan are always allowed to
read and update caches from all PVs, including those that belong
to foreign VGs.

Other non-report/display/scan commands always ignore a foreign
VG, or report an error if they attempt to use a foreign VG.

vgimport should always invalidate the lvmetad cache because
lvmetad likely holds a pre-vgexported copy of the VG.
(This is unrelated to using foreign VGs; the pre-vgexported
VG may have had no system_id at all.)
2015-02-25 10:53:52 -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
David Teigland
f5d06efbab vgextend: Use process_each_vg.
Tags and --select are not yet supported because new code is needed
to ensure exactly one VG matches before the VG starts to be processed.
2015-02-13 14:58:51 +00:00
Zdenek Kabelac
464f3b8abd lvmcmdline: support size_mb_arg_with_percent
New size_mb_arg_with_percent is able to read  size_mb_arg
but also it's able to read % values.

Percent parsing is share with int_arg_with_sign_and_percent.
2014-10-30 23:58:49 +01:00
Zdenek Kabelac
11ea72cfd8 mirror: extra parsing for mirrorlog arg
Put validation of mirrorlog arg into a separate function.
2014-10-24 16:39:32 +02:00
Zdenek Kabelac
2fc403b0fc toollib: new arg list functions
Check for negative arg list:
arg_from_list_is_negative()

Check for zero arg in list:
arg_from_list_is_zero()
2014-10-24 16:39:31 +02:00
Alasdair G Kergon
f3bb1c018f vgremove: Use process_each_lv_in_vg. 2014-10-07 16:45:45 +01:00
David Teigland
1cdb8766a7 tools: Add ENABLE_ALL_DEVS flag.
The ENABLE_ALL_DEVS flag is added to the command structure
for commands that should process all devs (pvs and non-pvs)
when they call process_each_pv and the command includes the
--all arg.  This will be used in a later process_each_pv patch.
2014-10-01 22:58:23 +01:00
David Teigland
e6ab275aa0 tools: Add ALL_VGS_IS_DEFAULT flag.
The ALL_VGS_IS_DEFAULT flag is added to the command structure
for commands that should process all vgs when they call
process_each_vg or process_each_lv with no args.
This will be used in later patches to process_each functions.
2014-10-01 22:58:00 +01:00
Zdenek Kabelac
89e1190ef0 cleanup: rename func
Update name of function read_and_validate_major_minor
and put it into the right header file toollib.h.

(In release update for f09f85d027)
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
f09f85d027 tools: common handling of --persistent option
Move common code for reading and processing
of --persistent arguments for lvcreate and lvchange
into lvmcmdline.

Reuse validate_major_minor() routine for validation.

Don't blindly activate LVs after change in cluster
and instead only local reactivation is supported.
(we have now many limited targets now).

Dropping 'sigint_caught()' handling, since
prompt() is resolving this case itself.
2014-09-19 15:54:20 +02:00
Zdenek Kabelac
656ba3a744 cleanup: use const for cmd context 2014-09-19 15:51:31 +02:00
Zdenek Kabelac
ab7bcc26f6 tools: switch logic for new arg_ func
Revert logic and rename new arg_ functions to:

arg_from_list_is_set()
arg_outside_list_is_set()

When err_found is given, log_error message is automaticaly
printed.
2014-07-22 22:38:59 +02:00
Zdenek Kabelac
1931d1e58e tools: arg_is_any_set and arg_is_only_set
Helpful functions to more easily detect conflicting
set of options.
2014-07-11 12:57:45 +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
Alasdair G Kergon
2eed136f0f signals: Move sigint handling out to lvm-signal. 2014-05-01 20:07:17 +01:00
Alasdair G Kergon
80bcdb93ff filters: check for mpath before opening devs
Split out the partitioned device filter that needs to open the device
and move the multipath filter in front of it.

When a device is multipathed, sending I/O to the underlying paths may
cause problems, the most obvious being I/O errors visible to lvm if a
path is down.

Revert the incorrect <backtrace> messages added when a device doesn't
pass a filter.

Log each filter initialisation to show sequence.

Avoid duplicate 'Using $device' debug messages.
2013-08-13 23:26:58 +01:00
Tony Asleson
60c78e6aef lvm2app: Move percent_of_extents to lvm-percent.[h|c]
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:33 -05:00
Zdenek Kabelac
b57b394ebb cmdline: add arg_long_option_name
Add simple function to return long_name string option for given arg.
2013-04-02 15:16:53 +02:00
Peter Rajnoha
34350963d1 dumpconfig: add --type, --atversion and --validate arg
lvm dumpconfig [--type {current|default|missing|new}] [--atversion] [--validate]

This patch adds above-mentioned args to lvm dumpconfig and it maps them
to creation and writing out a configuration tree of a specific type
(see also previous commit):

  - current maps to CFG_TYPE_CURRENT
  - default maps to CFG_TYPE_DEFAULT
  - missing maps to CFG_TYPE_MISSING
  - new maps to CFG_TYPE_NEW

If --type is not defined, dumpconfig defaults to "--type current"
which is the original behaviour of dumpconfig before all these changes.

The --validate option just validates current configuration tree
(lvm.conf/--config) and it writes a simple status message:

  "LVM configuration valid" or "LVM configuration invalid"
2013-03-06 10:46:36 +01:00
Alasdair G Kergon
701b4a8363 thin: use discards as plural rather than singular
Global change from --discard to --discards, as that feels more natural.
2012-08-07 21:24:41 +01:00
Peter Rajnoha
6e55201144 args: increase major:minor limit to 4095:1048575
Remove the limit for major and minor number arguments used while specifying
persistent numbers via -My --major <major> --minor <minor> option which
was set to 255 before. Follow the kernel limit instead which is 12 bits
for major and 20 bits for minor number (kernel >= 2.6 and LVM formats
that does not have FMT_RESTRICTED_LVIDS - so still keep the old limit
of 255 for lvm1 format).
2012-08-06 18:01:01 +02:00
Zdenek Kabelac
ebbf7d8e68 thin: add discard support for thin pool
Add arg support for discard.
Add discard ignore, nopassdown, passdown (=default) support.
Flags could be set per pool.

lvcreate [--discard {ignore|no_passdown|passdown}]  vg/thinlv
2012-07-18 14:36:57 +02:00
Peter Rajnoha
95ced7a7be activate: add autoactivation hooks
Define an 'activation_handler' that gets called automatically on
PV appearance/disappearance while processing the lvmetad_pv_found
and lvmetad_pv_gone functions that are supposed to update the
lvmetad state based on PV availability state. For now, the actual
support is for PV appearance only, leaving room for PV disappearance
support as well (which is a more complex problem to solve as this
needs to count with possible device stack).

Add a new activation change mode - CHANGE_AAY exposed as
'--activate ay/-aay' argument ('activate automatically').

Factor out the vgchange activation functionality for use in other
tools (like pvscan...).
2012-06-28 09:42:47 -04:00
Peter Rajnoha
2729720fd3 args: add --activate synonym for --available arg
We're refererring to 'activation' all over the code and we're talking
about 'LVs being activated' all the time so let's use 'activation/activate'
everywhere for clarity and consistency (still providing the old
'available' keyword as a synonym for backward compatibility with
existing environments).
2012-06-28 09:42:44 -04:00
Petr Rockai
7720ed7037 Fix a regression in handling --major/--minor arguments to lvcreate & lvchange,
by allowing arg_int_value to be used with groupable options.
2012-03-16 10:43:52 +00:00
Alasdair Kergon
b343d75a5a Switch pvscan --cache major:minor to --major --minor. 2012-03-06 02:30:49 +00:00
Petr Rockai
dae0822698 The lvmetad client-side integration. Only active when use_lvmetad = 1 is set in
lvm.conf *and* lvmetad is running.
2012-02-23 13:11:07 +00:00
Zdenek Kabelac
4fbde0143a Support rounding of percentage upward
We want to keep this logic -
when LV is extend - extend the LV by at least given amount,
when LV is reduced - reduce the LV by at most given amount.

So for this the rounding needs to be used.
Current logic which seems to satisfy give rule is to round up all
extent values for LV resize upward except for values with '-' sign
that are round downward.

This patch also fixes the problem when  lvextend --use-polices tried
to extend LV the by i.e. 20% - but the resulting 20% were smaller
the extent size thus before this patch no extension happened.
2012-01-05 15:38:18 +00:00
Milan Broz
b18e1fd50e Fix possible overflow of size if %FREE or %VG is used.
https://bugzilla.redhat.com/show_bug.cgi?id=737087
2011-09-15 15:26:40 +00:00
Alasdair Kergon
6585b5a197 remove unnecessary lvconvert.h 2011-07-08 19:42:11 +00:00
Alasdair Kergon
453cdee51c Permit --available with lvcreate so non-snapshot LVs need not be activated. 2011-06-01 19:21:03 +00:00
Petr Rockai
8191fe4f4a Refactor the percent (mirror sync, snapshot usage) handling code to use
fixed-point values instead of a combination of a float value and an enum.
2010-11-30 11:53:31 +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
Alasdair Kergon
b83af51668 Add global/metadata_read_only to use unrepaired metadata in read-only cmds. 2010-10-25 11:20:54 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Alasdair Kergon
77d308ef77 Fix --[vg]metadatacopies arg processing 2010-06-30 20:21:03 +00:00
Dave Wysochanski
a9d8bf269a Allow 'all' and 'unmanaged' values for --vgmetadatacopies.
Allowing an 'all' and 'unmanaged' value is more intuitive, and
provides a simple way for users to get back to original LVM behavior
of metadata written to all PVs in the volume group.

If the user requests "--vgmetadatacopies unmanaged", this instructs
LVM not to manage the ignore bits to achieve a specific number of
metadata copies in the volume group.  The user is free to use
"pvchange --metadataignore" to control the mdas on a per-PV basis.
If the user requests "--vgmetadatacopies all", this instructs LVM
to do 2 things: 1) clear all ignore bits, and 2) set the "unmanaged"
policy going forward.

Internally, we use the special MAX_UINT32 value to indicate 'all'.
This 'just' works since it's the largest value possible for the
field and so all 'ignore' bits on all mdas in the VG will get
cleared inside _vg_metadata_balance().  However, after we've
called the _vg_metadata_balance function, we check for the special
'all' value, and if set, we write the "unmanaged" value into the
metadata.  As such, the 'all' value is never written to disk.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:40:01 +00:00
Zdenek Kabelac
cee2f123a4 Use "" instead of <> for configure.h and libdevmapper.h
Move configure.h as the first header for clvmd source files.
2010-06-15 11:00:44 +00:00
Alasdair Kergon
54d7741a3e Remove no-longer-used arg_ptr_value.
Fix -M and --type to use strings not pointers that change on config refresh.
2010-04-29 01:38:12 +00:00
Mike Snitzer
5bc2af2688 Add %ORIGIN support to lv{create,extend,reduce,resize} --extents option
Allow the number of logical extents to be expressed (for a snapshot) as
a percentage of the total space in the Origin Logical Volume with the
suffix %ORIGIN.

Update the relevant man pages accordingly.  Eliminate inconsistencies
between the man pages and tools/commands.h

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-03 03:58:08 +00:00
Alasdair Kergon
a8fb89adaf Tidy some uses of arg_count and introduce arg_is_set. 2009-11-03 15:50:42 +00:00
Milan Broz
31f55a07db Fix convert polling to ignore LV with different UUID.
When mirror convert polling is started (mainly as backgound process,
in lvchange -a y or in lvconvert itself) it tries to read VG
and LV identified by its name.

Unfortunatelly, the VG can have already different LV under the same name,
and various more or less funny things can happen (note that
_finish_lvconvert_mirror suspends the volume for example).

(the typical example is our testing script which continuously recreates
LVs under the same name in the same VG.)

This patch adds optional uuid parameter which helps to properly
select the monitoring object. For lvconvert polling it is set to LV UUID
and both _get_lvconvert_vg and _get_lvconvert_lv uses it to read proper VG/LV.

(In the pvmove case it is NULL, here we poll for physical volume name).
2009-06-01 14:43:27 +00:00
Alasdair Kergon
e50d0e97b1 more missing bits 2008-11-04 14:57:06 +00:00
Alasdair Kergon
84b9ec9733 Split out lvm-logging.h from log.h. 2008-10-30 17:27:28 +00:00
Alasdair Kergon
bf7dea978e Add per-command flags to control which commands use the VG metadata cache. 2008-04-02 21:23:39 +00:00