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

176 Commits

Author SHA1 Message Date
Alasdair Kergon
dbb48de507 Add a new 'thin_pool' output field to 'lvs.
A gentle reminder that anyone relying on the output of reporting commands
like lvs in scripts must use -o to guarantee they get the fields they expect.

The default sequence of fields can change from release to release.
Equally, the 'attr' fields can have new values introduced and/or characters
appended to them.
2011-09-09 00:54:49 +00:00
Zdenek Kabelac
586f310618 Remove meaningless const type qualifiers on cast type
Static analyzis noticed we do not really need them - so removing.
2011-08-04 14:30:51 +00:00
Petr Rockai
db22d9b978 This patchset refactors some reporting code and completes the remaining
lvseg properties for lvm2app, 'devices' and 'seg_pe_ranges'.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2011-04-12 12:24:29 +00:00
Zdenek Kabelac
55f6627427 Fix reading of released memory
lvseg_segtype_dup used memory pool vg memory pool for strind duplication.
However this one gets released before reporting happens so the command like:

pvs -o segtype

prints data from already released memory pool. Thanks to the fact there
is not much allocation happing after the VG is released, the memory
stays unmodified and correct result is printed.

Fix adds support for mempool passed parameter (like other similar
query commands) and uses dm_report memory pool for string duplication.
2011-03-05 12:14:00 +00:00
Zdenek Kabelac
aec2115410 Const fixing
Fixing some const warnings - with API change in:

int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,

Change is needed - as lvm2api expects const behaviour here.
So vg_extend() is doing local strdup for unescaping.

skip_dev_dir return const char* from const char* vg_name.

Rest of the patch is cleanup of related warnings.

Also using dm_report_filed_string() API change to simplify
casting in _string_disp and _lvname_disp.
2011-02-18 14:47:28 +00:00
Zdenek Kabelac
1936d75b3c Return PERCENT_INVALID for error case
If the percent value could not be determined return PERCENT_INVALID.
Indent function with tabs.
2011-01-05 12:33:51 +00:00
Petr Rockai
8961b1d503 Add getters for copy_percent and snap_percent to the lvm2app API. 2010-12-14 23:20:58 +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
Petr Rockai
0bc382eae4 All 'size' values of lvm2app properties should be in bytes.
Fix 'seg_size' to return bytes.

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-25 14:39:02 +00:00
Petr Rockai
4543dac58e Add the macro and specific 'get' functions for pvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:11:27 +00:00
Petr Rockai
c1abd569f2 Add the macro and specific 'get' functions for lvsegs.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:08:14 +00:00
Petr Rockai
cbff112651 Make value.string const char *, in properties.h, to fix a warning introduced by
the previous patch set.
2010-11-17 19:50:15 +00:00
Petr Rockai
fd82d8c129 Add generic infrastructure to internal library to 'set' a property.
Similar to 'get' property internal functions.
Add specific 'set' function for vg_mda_copies.

Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 19:15:10 +00:00
Dave Wysochanski
a90221d824 Add 'is_integer' flag into internal lvm_property_type.
Add 'is_integer' flag similar to 'is_string'.
Suggested in review by Petr Rockai.
2010-10-25 14:08:32 +00:00
Dave Wysochanski
12873010e5 Add lv_get_property() internal lvm function. 2010-10-21 18:51:16 +00:00
Dave Wysochanski
60fc088d70 Rename fields in lvm_property_type.
Based on review comments, rename a few fields in lvm_property_type.
In particular, change 'is_writeable' to 'is_settable', which is
more intuitive to the intent of the bitfield (a 'set' function
exists for this field/property).  Also, remove the char array
for 'id' - unnecessary as we can just use the string passed in
to do the strcmp.  Finally rename the union members from n_val
to 'integer' and 's_val' to 'string'.
2010-10-21 14:49:43 +00:00
Dave Wysochanski
d53d92f2e1 Add lv_read_ahead and lv_kernel_read_ahead 'get' functions. 2010-10-21 14:49:31 +00:00
Dave Wysochanski
f1fc310730 Refactor and add code for (lv) 'lv_origin' get function. 2010-10-21 14:49:20 +00:00
Dave Wysochanski
6103254393 Refactor and add code for (lv) 'lv_name' get function. 2010-10-21 14:49:10 +00:00
Dave Wysochanski
2eba846043 Refactor and add code for (lv) 'modules' get function. 2010-10-12 16:13:06 +00:00
Dave Wysochanski
d88090b0ae Refactor and add code for (lv) 'mirror_log' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:50 +00:00
Dave Wysochanski
40c6c80723 Refactor and add code for (lv) 'lv_kernel_{major|minor}' get functions.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:33 +00:00
Dave Wysochanski
e27833fb9c Refactor and add code for (lv) 'convert_lv' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:18 +00:00
Dave Wysochanski
af579eccc3 Refactor and add code for (lv) 'move_pv' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:12:02 +00:00
Dave Wysochanski
29636f38e3 Refactor and add code for (lv) 'origin_size' get function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:11:48 +00:00
Dave Wysochanski
802e252b29 Refactor and add code for (lv) 'lv_path' get function. 2010-10-12 16:11:34 +00:00
Dave Wysochanski
a88a278698 Add some lv 'get' functions that require no refactoring.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
2010-10-12 16:11:20 +00:00
Dave Wysochanski
4df3d5ad25 Add pv_get_property and create generic internal _get_property function.
We need to use a similar function for pv and lv properties, so just make
a generic _get_property() function that contains most of the required
functionality.  Also, add a check to ensure the field name matches the
object passed in by re-using report_type_t enum.  For pv properties,
the report_type might be either PVS or LABEL.

In addition, add 'const' to 'get' functions object parameter, but not
'set' functions.  Add _not_implemented_set() and _not_implemented_get()
functions.
2010-09-30 14:09:45 +00:00
Dave Wysochanski
f9bbf60213 Add pv 'get' functions for all pv properties.
Add 'get' functions for all pv properties.
Multiply by SECTOR_SIZE for pv properties pv_mda_free, pv_mda_size,
pe_start, pv_size, pv_free, pv_used.
2010-09-30 14:09:33 +00:00
Dave Wysochanski
1cd292af8f Add pv_mda_size, pv_mda_free, and pv_used functions, call from 'disp' functions. 2010-09-30 14:09:10 +00:00
Dave Wysochanski
1f4f0d1926 Add 'get' functions for vg fields.
Add 'get' functions based on generic macros for VG, PV, and LV.
Add 'get' functions for vg string fields, vg_name, vg_fmt, vg_sysid,
vg_uuid, vg_attr, and vg_tags, and all numeric fields.
2010-09-30 14:08:58 +00:00
Dave Wysochanski
5d74ec6400 Make generic GET_*_PROPERTY_FN macros and define secondary macro for vg, pv, lv.
Will need similar macros for VG, PV and LV, so define a generic one, and just
pass in the struct name and variable name for the specific macro.
2010-09-30 14:08:46 +00:00
Dave Wysochanski
f15033c0e1 Add tags_format_and_copy() common function and call from _tags_disp.
Add a common function to allocate memory and format a string of
tags.
Call tags_format_and_copy() from _tags_disp().
2010-09-30 14:08:07 +00:00
Dave Wysochanski
f4fd41552d Add id_format_and_copy() common function and call from _uuid_disp.
Add supporting uuid function to allocate memory and call id_write_format.
Call id_format_and_copy from _uuid_disp.
2010-09-30 14:07:33 +00:00
Dave Wysochanski
14663348d0 Add {pv|vg|lv}_attr_dup() functions and refactor 'disp' functions.
Move the creating of the 'attr' strings into a common function so
they can be called from the 'disp' functions as well as the new
'get' property functions.
Add "_dup" suffix to indicate memory is allocated.
Refactor pvstatus_disp to take pv argument and call pv_attr_dup().
2010-09-30 13:52:55 +00:00
Dave Wysochanski
97709450ca Update vg_mda_free 'get' function to multiply by SECTOR_SIZE. 2010-09-09 19:38:03 +00:00
Dave Wysochanski
614469b544 Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' functions. 2010-08-20 13:02:39 +00:00
Dave Wysochanski
cc171eb8ee Add implmentation for simple numeric 'get' property functions.
Add 'get' functions based on the simple macro function definition for a
numeric property.

Add 'get' functions for the following: _vg_extent_count_get,
_vg_free_count_get, _max_lv_get, _max_pv_get, _pv_count_get,
_lv_count_get, _snap_count_get, _vg_seqno_get, _vg_size_get,
_vg_free_get, vg_mda_*.

For size functions, multiply by SECTOR_SIZE to return the value in bytes.
2010-08-20 12:45:09 +00:00
Dave Wysochanski
1af822bff0 Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' functions. 2010-08-20 12:44:58 +00:00
Dave Wysochanski
7bdc15c8bb Remove explicit double quotes from columns.h 'id' entries.
The 'id' entries in columns.h are the report field names.  Since these are
unique, we'd like to use them in generation of 'get' / 'set' functions.
As a step towards using them for this purpose, remove the explicit double
quotes and use the macro '#' character to add the double quotes back when
placing them into the '_fields' array 'id' member.
2010-08-20 12:44:17 +00:00
Dave Wysochanski
d5722ebb21 Add 'flags' field to columns.h and define FIELD_MODIFIABLE.
Add a 'flags' field to columns.h, and set it to 0 by default.
Define FIELD_MODIFIABLE flag to indicate whether a 'set' function exists
to change the field's value.
2010-08-20 12:44:03 +00:00
Dave Wysochanski
69d67dc2ca Add vg_mda_size and vg_mda_free functions.
Add supporting functions to get vg_mda_size and vg_mda_free fields.
Should be no functional change.
2010-08-20 12:43:49 +00:00
Alasdair Kergon
2d6fcbf67d Allow internal suspend and resume of origin without its snapshots. 2010-08-17 16:25:32 +00:00
Dave Wysochanski
81bf06ea38 Clarify help text for vg_mda_count. 2010-07-21 19:44:25 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +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
Dave Wysochanski
3534fb40df Add vg_mda_copies display field to 'vgs' command.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:23 +00:00
Dave Wysochanski
cdbe475fe3 Define new functions and vgs/pvs fields related to mda ignore.
Define a new pvs field, pv_mda_used_count, and a new vgs field,
vg_mda_used_count to match the existing pv_mda_count and vg_mda_count.
These new fields count the number of mdas that have the 'ignored' bit
clear (they are in use on the PV / VG).  Also define various supporting
functions to implement the counting as well as setting the ignored
flag and determining if an mda is ignored.  These high level functions
call into the lower level location independent mda ignore functions
defined by earlier patches.

Note that counting ignored mdas in a vg requires traversing both lists
and checking for the ignored bit on the mda.  The count of 'ignored'
mdas then is defined by having the bit set, not by which list the mda
is on.  The list does determine whether LVM actually does read/write to
the mda, though we must count the bits in order to return accurate numbers
for the various counts.  Also, pv_mda_set_ignored must search both vg
lists for ignored mda.  If the state changes and needs to be committed
to disk, the ignored mda will be on the non-ignored list.

Note also in pv_mda_set_ignored(), we must properly manage the mda lists.
If we change the ignored state of an mda, we must change any mdas on
vg->fid->metadata_areas that correspond to this pv.  Also, we may
need to allocate a copy of the mda, as is done when fid->metadata_areas
is populated from _vg_read(), if we are un-ignoring an ignored mda.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:44 +00:00
Dave Wysochanski
9ccac021a7 Add metadata_areas_ignored list and functions to manage ignored mdas.
Add a second mda list, metadata_areas_ignored to fid, and a couple
functions, fid_add_mda() and fid_add_mdas() to help manage the lists.

These functions are needed to properly count the ignored mdas and
manage the lists attached to the 'fid' and ultimately the 'vg'.

Ensure metadata_areas_ignored is initialized in other formats, even
if the list is never used.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:22 +00:00
Dave Wysochanski
f55a20eb36 Rename fid->metadata_areas to fid->metadata_areas_in_use.
Rename the metadata_areas list to an 'in_use' list to prepare for
future 'ignored' list.
2010-06-28 20:32:44 +00:00