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

12640 Commits

Author SHA1 Message Date
Peter Rajnoha
e081203f3e report: recognize list of keys to sort report by (-O|--sort) for each subreport; make -O|--sort groupable 2016-06-20 11:33:42 +02:00
Peter Rajnoha
bd26684d5d report: recognize list of fields to report (-o|--options) for each subreport 2016-06-20 11:33:42 +02:00
Peter Rajnoha
80ffaefb88 report: add _get_report_idx_from_name and _should_process_report_idx helper fns
Prepare for recognition of cmd line options for each subreport within
one command.
2016-06-20 11:33:42 +02:00
Peter Rajnoha
28b4c48e2a args: add --configreport arg 2016-06-20 11:33:42 +02:00
Peter Rajnoha
d23c5b9318 args: add priorities for grouping args
Groupable args (the ones marked with ARG_GROUPABLE flag) start a new
group of args if:
  - this is the first time we hit such a groupable arg,
  - or if non-countable arg is repeated.

However, there may be cases where we want to give priorities when
forming groups and hence force new group creation if we hit an arg
with higher grouping priority.

For example, let's assume (for now) hypothetical sequence of args used:

  lvs -o lv_name --configreport log -o log_type --configreport lv -o +vg_name

Without giving any priorites, we end up with:

  lvs -o lv_name --configreport log -o log_type --configreport lv -o +vg_name
     |                            | |                           | |          |
     \__________GROUP1___________/   \________GROUP2___________/   \_GROUP3_/

This is because we hit "-o" as the first groupable arg. The --configreport,
even though it's groupable too, it falls into the previous "-o" group.

While we may need to give priority to the --configreport arg that should
always start a new group in this scenario instead:

  lvs -o lv_name --configreport log -o log_type --configreport lv -o +vg_name
      |         | |                            | |                           |
      \_GROUP1_/   \_________GROUP2___________/   \_________GROUP3__________/

So here "-o" started a new group but since "--configreport" has higher
priority than "-o", it starts fresh new group now and hence the rest of
the command line's args are grouped by --configreport now.
2016-06-20 11:33:42 +02:00
Peter Rajnoha
9c37b7ed7c conf: add report/{vgs,pvs,lvs,pvsegs,segs}_{cols,sort}_full config settings 2016-06-20 11:33:42 +02:00
Peter Rajnoha
26c43c6ce5 commands: report: add lvm fullreport command
lvm fullreport executes 5 subreports (vg, pv, lv, pvseg, seg) per each VG
(and so taking one VG lock each time) within one command which makes it
easier to produce full report about LVM entities.

Since all 5 subreports for a VG are done under a VG lock, the output is
more consistent mainly in cases where LVM entities may be changed in
parallel.
2016-06-20 11:33:42 +02:00
Peter Rajnoha
f1e7f35bb5 commands: recognize --reportformat option for other commands
Enables --reportformat option for all command using processing_handle
(and process_each_* fn variant), that is: lvchange, lvcreate, lvdisplay,
lvextend, lvreduce, lvremove, lvrename, lvresize, lvscan, pvchange,
pvresize, pvcreate, pvdisplay, pvmove, pvremove, pvscan, vgcfgbackup,
vgchange, vgck, vgconvert, vgcreate, vgdisplay, vgexport, vgextend,
vgimport, vgmknodes, vgreduce, vgremove, vgrename command.
2016-06-20 11:33:42 +02:00
Peter Rajnoha
f8a93763e5 commands: recognize --reportformat option for pvs,vgs,lvs and devtypes command
Enables --reportformat options for pvs, vgs, lvs, devtypes command.
2016-06-20 11:33:41 +02:00
Peter Rajnoha
10a1b9e182 report: add current report to existing group
Add any report (pvs/vgs/lvs) currently processed to current report group
which is part of processing handle and which already contains log
report. This way both log report and pvs/vgs/lvs report will be
reported as a whole within a group, thus having same output format as
selected by --reportformat option.
2016-06-20 11:33:41 +02:00
Peter Rajnoha
f752a95302 toollib: add 'parent' field to processing_handle; init report format only if there's no parent
If there's parent processing handle, we don't need to create completely
new report group and status report - we'll just reuse the one already
initialized for the parent.

Currently, the situation where this matter is when doing internal report
to do the selection for processing commands where we have parent processing
handle for the command itself and processing handle for the selection
part (that is selection for non-reporting tools).
2016-06-20 11:33:41 +02:00
Peter Rajnoha
c099f531fb toollib: add report_group and log_rh to processing_handle and initialize cmd processing log report
Wire up report group creation with log report in struct
processing_handle and call report_format_init during processing handle
initialization (init_processing_handle fn) and destroy it while
destroing processing handle (destroy_processing_handle fn).

This way, all the LVM command processing using processing handle
has access to log report via which the current command log
can be reported as items are processed.
2016-06-20 11:33:41 +02:00
Peter Rajnoha
213434d426 report: separate common report and per-report args
Separating common report and per-report arguments prepares the code for
handling several reports per one command (for example, the command log
report and LVM command report itself).

Each report can have sort keys, options (fields), list of fields to
compact and selection criteria set individually. Hooks for setting these
per report within one command will be a part of subsequent patches, this
patch only separates new struct single_report_args out of existing
struct report_args.
2016-06-20 11:33:41 +02:00
Peter Rajnoha
bd0a0ae36b conf: add log/report_command_log config setting 2016-06-20 11:33:41 +02:00
Peter Rajnoha
a08e02afbf conf: add report/output_format config setting
New report/output_format configuration sets the output format used
for all LVM commands globally. Currently, there are 2 formats
recognized:
   - basic (the classical basic output with columns and rows, used by default)
   - json (output is in json format)
2016-06-20 11:33:41 +02:00
Peter Rajnoha
79a74e9aae toollib: add report_format_init fn to create report group and to create/add log report handle
Add new --reportformat option and new report_format_init function that
checks this option and creates new report group accordingly, also
preparing log report handle and adding it to the report group just
created.
2016-06-20 11:33:41 +02:00
Peter Rajnoha
c36d4632a6 conf: add log/command_log_{sort,cols} config settings 2016-06-20 11:33:40 +02:00
Peter Rajnoha
99c2a2b960 report: add CMDLOG report type
This is a preparation for new CMDLOG report type which is going to be
used for reporting LVM command log.

The new report type introduces several new fields (log_seq_num, log_type,
log_context, log_object_type, log_object_group, log_object_id, object_name,
log_message, log_errno, log_ret_code) as well as new configuration settings
to set this report type (report/command_log_sort and report/command_log_cols
lvm.conf settings).

This patch also introduces internal report_cmdlog helper function
which is a wrapper over dm_report_object to report command log via
CMDLOG report type and which is going to be used throughout the code
to report the log items.
2016-06-20 11:33:08 +02:00
Peter Rajnoha
094fce3776 libdm: report: implement DM_REPORT_GROUP_JSON for JSON report output
This patch introduces DM_REPORT_GROUP_JSON report group type. When using
this group type and when pushing a report to such a group, these flags
are automatically unset:

   DM_REPORT_OUTPUT_ALIGNED
   DM_REPORT_OUTPUT_HEADINGS
   DM_REPORT_OUTPUT_COLUMNS_AS_ROWS

...and this flag is set:

   DM_REPORT_OUTPUT_BUFFERED

The whole group is encapsulated in { } for the outermost JSON object
and then each report is reported on output as array of objects where
each object is the row from report:

  {
     "report_name1": [
         {field1="value", field2="value",...},
         {field1="value", field2="value",...}
         ...
     ],
     "report_name2": [
         {field1="value", field2="value",...},
         {field1="value", field2="value",...}
         ...
     ]
     ...
  }
2016-06-20 10:42:26 +02:00
Peter Rajnoha
230b7ff0f6 libdm: report: implement DM_REPORT_GROUP_BASIC for extended report output
This patch introduces DM_REPORT_GROUP_BASIC report group type. This
type has exactly the classical output format as we know from before
introduction of report groups. However, in addition to that, it allows
to put several reports into a group - this is the very basic grouping
scheme that doesn't change the output format itself:

  Report: report1_name
  Header1  Header2 ...
  value    value   ...
  value    value   ...
  ...      ...     ...

  Report: report2_name
  Header1  Header2 ...
  value    value   ...
  value    value   ...
  ...      ...     ...
2016-06-20 10:42:26 +02:00
Peter Rajnoha
a9fe57db1c libdm: report: implement DM_REPORT_GROUP_SINGLE for a group containing single report only
There's no change in output for this report group type - with this type,
we only make sure there's always only one report in a group at a time,
not more.
2016-06-20 10:42:18 +02:00
Peter Rajnoha
9c8f912ea7 libdm: report: introduce dm_report_group
This patch introduces DM report group (represented by dm_report_group
structure) that is used to group several reports to make a whole. As a
whole, all the reports in the group follow the same settings and/or
formatting used on output and it controls that the output is properly
ordered (e.g. the output from different reports is not interleaved
which would break readability and/or syntax of target output format
used for the whole group).

To support this feature, there are 4 new functions:
  - dm_report_group_create
  - dm_report_group_push
  - dm_report_group_pop
  - dm_report_group_destroy

From the naming used (dm_report_group_push/pop), it's clear the reports
are pushed onto a stack. The rule then is that only the report on top
of the stack can be reported (that means calling dm_report_output).
This way we make sure that the output is not interleaved and provides
determinism and control over the output.

Different formats may allow or disallow some of the existing report
flags controlling output itself (DM_REPORT_OUTPUT_*) to be set or not so
once the report is pushed to a group, the grouping code makes sure that
all the reports have compatible flags set and then these flags are
restored once each report is popped from the report group stack.

We also allow to push/pop non-report item in which case such an item
creates a structure (e.g. to put several reports together with any
opening and/or closing lines needed on output which pose as extra
formatting structure besides formatting the reports).

The dm_report_group_push function accepts an argument to pass any
format-specific data needed (e.g. handle, name, structures passed
along while working with reports...).

We can call dm_report_output directly anytime we need (with the only
restriction that we can call dm_report_output only for the report that
is currently on top of the group's stack). Or we don't need to call
dm_report_output explicitly in which case all the reports in a stack are
reported on output automatically once we call dm_report_group_destroy.
2016-06-20 09:26:51 +02:00
David Teigland
029f51e1a8 vgreduce: fix location of lvmlockd global lock
The lvmlockd global lock was missing the non-repair case,
which caused the new orphan PV created by vgreduce to
not be seen by other hosts.
2016-06-17 12:22:58 -05:00
David Teigland
899a4ca275 lvmlockd: fix dropping PVs in rescanning VG
This fixes a problem in commit ae0a8740c.  The problem
in that commit was that all existing PVs are initially
dropped from lvmetad.  This works if the VG is updated
at the end, which replaces the dropped PVs, but if the
rescan finds that the VG seqno is unchanged, it leaves
the cached VG in place.  So, we should only drop the
existing PVs in lvmetad when the VG is going to be updated.
2016-06-17 12:21:09 -05:00
Alasdair G Kergon
ab7ade4095 post-release 2016-06-17 14:10:20 +01:00
Alasdair G Kergon
38cc03605c pre-release 2016-06-17 14:10:20 +01:00
Peter Rajnoha
a23655ab3b tools: add missing destroy_processing_handle in pvscan and vgreduce code 2016-06-17 13:29:33 +02:00
David Teigland
f77fe436af pvscan: don't activate LVs when use_lvmetad=0
commit 15da467b was meant to address the case where
use_lvmetad=1 in lvm.conf, and lvmetad is not available,
in which case, pvscan --cache -aay should activate LVs.

But the commit unintentionally also changed the case
where use_lvmetad=0 in lvm.conf, in which case
pvscan --cache -aay should not activate LVs, so fix
that here.
2016-06-16 12:04:05 -05:00
David Teigland
944ae4d2df pvscan: fix lvmlockd global lock
This should have been removed when pvscan was
recently converted to use process_each_pv which
does the lvmlockd locking.
2016-06-15 16:51:36 -05:00
David Teigland
15da467b52 pvscan: do activation when lvmetad is not running
When pvscan --cache -aay fails to connect to lvmetad it will
simply exit and do nothing.  Change this so that it will
skip the lvmetad cache step and do the activation step from
disk.
2016-06-15 14:19:18 -05:00
David Teigland
ae0a8740c5 lvmlockd: fix rescanning VG
Previously, new PVs that were added to the VG were not scanned.
2016-06-15 11:36:30 -05:00
Alasdair G Kergon
49a8d1a85e post-release 2016-06-11 00:14:00 +01:00
Alasdair G Kergon
f2d1f5e927 pre-release 2016-06-11 00:08:08 +01:00
Tony Asleson
2d384954ad lvmdbusd: Remove duplicate test code 2016-06-10 16:05:03 -05:00
Tony Asleson
a1febff857 lvmdbusd: Add test for DataLv & MetaDataLv
Added tests which expose an issue found with these properties.
2016-06-10 16:05:03 -05:00
Tony Asleson
cdf06044e1 lvmdbusd: Create correct LV object type
We were initially looking to see if an LV was hidden and if it was we were
creating an instance of a LvCommon object to represent it.  Thus if we
had a hidden cache pool for example we were missing the methods and
properties for the cache pool.  However, when we create the object path,
any hidden LVs, regardless of type/functionality will be placed in the
hidden path.
2016-06-10 16:05:03 -05:00
Tony Asleson
b81186e535 lvmdbusd: Add method get_object_path_by_lvm_id
The object manager method get_object_by_lvm_id was used in many cases for
the sole reason of getting the object path for the object.  Instead of
retrieving the object and then calling 'dbus_object_path' on the object, we
are adding a method which returns the object path.
2016-06-10 16:04:43 -05:00
Tony Asleson
b717e8fe1d lvmdbusd: Rename get_object_path_by_lvm_id
Renaming to get_object_path_by_uuid_lvm_id, to clarify that both the uuid
and the lvm id are required.
2016-06-10 15:28:42 -05:00
Tony Asleson
41ebed7077 lvmdbusd: Change print statement to py3 syntax 2016-06-10 15:28:42 -05:00
Tony Asleson
b717c5efae lvmdbusd: Bug fix for missing LV properties
When we are processing the LVs we need to build up dbus objects from least
dependent to most dependent, so that we have information available when
constructing.
2016-06-10 15:28:42 -05:00
Tony Asleson
e04705b305 lvmdbusd: Add data_lv and metadata_lv to cache pool interface
See: https://bugzilla.redhat.com/show_bug.cgi?id=1342558
2016-06-10 15:28:42 -05:00
Tony Asleson
3bf43a65fe lvmdbusd: Add roles property to LV common interface
See: https://bugzilla.redhat.com/show_bug.cgi?id=1342559
2016-06-10 15:28:42 -05:00
David Teigland
8a667f5887 WHATS_NEW: add recent changes 2016-06-10 13:39:23 -05:00
Zdenek Kabelac
ad414e5ad6 cleanup: typo in WHATS_NEW_DM 2016-06-10 16:01:22 +02:00
Zdenek Kabelac
35612bd27c display: yes no prompt improvement
Original code missed to catch all apperances of SIGINT.
Also enhance logging when running in shell without tty.
Accept this regex as valid input:
'^[ ^t]*([Yy]([Ee]([Ss]|)|)|[Nn]([Oo]|))[ ^t]*$'
2016-06-10 16:00:31 +02:00
Peter Rajnoha
cfdc87b623 lvmdump: also collect output from lsblk command when running lvmdump -s
lsblk provides nice and quick overview of the storage/sysfs structure
that is useful for debugging - collect its output when running lvmdump -s.
2016-06-09 13:54:15 +02:00
David Teigland
86f9271457 vgcreate, pvcreate, vgextend: don't use a device with duplicates
If duplicate orphan PVs exist, don't allow one of them to be
used for vgcreate/pvcreate/vgextend.
2016-06-07 15:21:07 -05:00
David Teigland
199b7b55c2 lvmcache: fix duplicate handling with multiple scans
Some commands scan labels to populate lvmcache multiple
times, i.e. lvmcache_init, scan labels to fill lvmcache,
lvmcache_destroy, then later repeat

Each time labels are scanned, duplicates are detected,
and preferred devices are chosen.  Each time this is done
within a single command, we want to choose the same
preferred devices.  So, check for existing preferences
when choosing preferred devices.

This also fixes a problem with the list of unused duplicate
devs when run in an lvm shell.  The devs had been allocated
from cmd memory, resulting in invalid list entries between
commands.
2016-06-07 15:15:51 -05:00
David Teigland
01156de6f7 lvmcache: add optional dev arg to lvmcache_info_from_pvid
A number of places are working on a specific dev when they
call lvmcache_info_from_pvid() to look up an info struct
based on a pvid.  In those cases, pass the dev being used
to lvmcache_info_from_pvid().  When a dev is specified,
lvmcache_info_from_pvid() will verify that the cached
info it's using matches the dev being processed before
returning the info.  Calling code will not mistakenly
get info for the wrong dev when duplicate devs exist.

This confusion was happening when scanning labels when
duplicate devs existed.  label_read for the first dev
would add an info struct to lvmcache for that dev/pvid.
label_read for the second dev would see the pvid in
lvmcache from first dev, and mistakenly conclude that
the label_read from the second dev can be skipped
because it's already been done.  By verifying that the
dev for the cached pvid matches the dev being read,
this mismatch is avoided and the label is actually read
from the second duplicate.
2016-06-07 15:15:47 -05:00
David Teigland
ed6ffc7a34 lvmetad: handle update failures
If a command gets stuck during an lvmetad update, lvmetad
will cancel that update after the timeout.  The next command
to check the lvmetad will see that lvmetad needs to be
populated because lvmetad will return token of "none" after
a timed out update (same as when lvmetad is not populated
at all after starting.)

If a command gets an error during an lvmetad update, it
will now just quit and leave its updating token in place.
That update will be cancelled after the timeout.
2016-06-07 10:17:00 -05:00