: liblvm object property baseline, take2
cover : liblvm object property baseline, take2
The following 30 patches supercede the previous 8 patch posting and implement a baseline for liblvm objects and their properties. The primary focus/goal of these patches are:
1. Define / clarify the main liblvm objects and their handles
2. Get the numeric object properties for a specific handle
3. Convert reporting commands to call liblvm 'get' functions for 'NUM' fields
Together with the handles, the 'get' functions will provide equivalent functionality to the reporting commands (pvs, vgs, lvs) while keeping with the object model of liblvm.
This set of patches converts most all numeric reporting field 'disp' functions to call into liblvm 'get' property functions. There should be no functional change after this patch, and I believe this patchset, while lengthy, should be relatively easy to review.
The bulk of this patchset involves a couple changes for each field:
1) moves the logic of the field data calculation from the 'disp' function into liblvm 'get' function
2) adds a 'disp' function for fields with simple dereferences (these were originally covered by the same 'disp' function (for example, _uint32_disp())
There are a few areas of particular interest in this patchset. First, the return types for all the 'get' functions are the same at uint64_t. This would allow internal changes to field sizes without making them visible in the API but also obscures the internal type size. I could easily make the internal size match the return type of the 'get' function if this is deemed the better tradeoff, but I thought fixed uint64_t was decided in a previous discussion. Second, a couple numeric fields were ommitted from this patch: snap_percent, and copy_percent. These fields involve a float value and so will be dealt with in a later patchset.
Along with this patchset I've been adding nightly tests to cover some of the numeric reporting fields not yet covered. We are still missing a few fields in the nightly tests and some deserve better coverage but we are getting closer to full coverage.
This set of patches pass the nightly test suite.
They apply cleanly against the following commit:
commit 97e41de23f5a021dfba8fb16692a9e2badec7d56
Author: Milan Broz <[email protected]> Date: Mon May 11 10:35:00 2009 +0000
Fix previous commit (scripts/Makefile targets order)
PATCH 1/30 Define handles to liblvm objects for pv, vg, lv, lvseg, pvseg.
Define the 5 main liblvm objects to be the pv, vg, lv, lvseg, and pvseg. We need handles defined to all these objects in order for liblvm to be equivalent to the reporting commands pvs, vgs, and lvs.
- move vg_t, lv_t, and pv_t from metadata-exported.h into lvm.h
- move lv_segment and pv_segment forward declarations into lvm.h
- add lvseg_t and pvseg_t to lvm.h
NOTE: We currently have an inconsistency in handle definitions. lvm_t is defined as a pointer, while these other handles are just structures. We should pick one scheme and be consistent - perhaps define all handles as pointers (this is what I've seen elsewhere).
--- lib/metadata/metadata-exported.h | 11 +---------- liblvm/lvm.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-)
lib/metadata/metadata-exported.h +1 -10
@@ -22,16 +22,7 @@#define _LVM_METADATA_EXPORTED_H#include "uuid.h" - -struct physical_volume ; -typedef struct physical_volume pv_t ; -struct volume_group ; -typedef struct volume_group vg_t ; - -struct logical_volume ; - -struct lv_segment ; -struct pv_segment ; +#include "lvm.h" #define MAX_STRIPES 128U#define SECTOR_SHIFT 9L
liblvm/lvm.h +15 -0
@@ -18,6 +18,20 @@#include <stdint.h> +/* Internal object structures */ +struct volume_group ; +struct physical_volume ; +struct logical_volume ; +struct lv_segment ; +struct pv_segment ; + +/* liblvm handles to objects pv, vg, lv, pvseg, lvseg */ +typedef struct volume_group vg_t ; +typedef struct physical_volume pv_t ; +typedef struct logical_volume lv_t ; +typedef struct pv_segment pvseg_t ; +typedef struct lv_segment lvseg_t ; +struct lvm ;/* internal data */ /**
@@ -54,4 +68,5 @@ void lvm_destroy(lvm_t libh);*/ int lvm_reload_config (lvm_t libh); +#endif /* _LIB_LVM_H */
Signature · 1 line
1.6.0.6
PATCH 2/30 Add lvm_object_prop.pl to generate liblvm object property functions.
The intent of this perl code, lvm_object_prop.pl, is to help maintain liblvm object property consistency with the reporting commands pvs, vgs, lvs. As new fields get added to columns.h, we should re-run this script on the new FIELD line(s), take the generated code, edit as appropriate, and place into appropriate liblvm code file.
This patch adds the perl file, lvm_object_prop.pl. A later patch will add the files this code generates, namely the liblvm object property function header and C file, lvm_object_prop.[ch].
NOTE: The term 'attribute' is used in some of the reporting fields (for example, vg_attr), so we avoid it here and instead use the term 'properties' or 'prop'.
--- lib/report/lvm_object_prop.pl | 232 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 232 insertions(+), 0 deletions(-) create mode 100644 lib/report/lvm_object_prop.pl
lib/report/lvm_object_prop.pl new file +232 -0
@@ -0,0 +1,232 @@ +#!/usr/bin/perl +# +# Take the colunms.h file as input and produce a header and +# default code for liblvm object property accessor and mutator functions. +# To run: perl lvm_object_prop.pl < columns.h +# +# For maintenance purposes, when adding a new line to columns.h, +# we can pipe the diff to this program to generate the new prototypes +# and C code, then cut/paste into the proper liblvm files. +# + +sub write_code_header; +sub write_code_body; +sub write_code_body_get; +sub write_code_footer; +sub write_include_header; +sub write_include_body; +sub write_include_footer; + +# +# Open the files and write the headers +# +$outfile = "lvm_object_prop"; +open(INCLUDE_FILE, ">./$outfile.h") || die "Cannot open $outfile.h!\n"; +write_include_header(INCLUDE_FILE); +open(CODE_FILE, ">./$outfile.c") || die "Cannot open $outfile.c!\n"; +write_code_header(CODE_FILE); + +# +# Write the include and code body +# +while(<>) { + # Skip if line does not begin w/"FIELD" - not perfect but does the job + if ($_ !~ /^FIELD/) { + next; + } + # Pull out the actual parameters to the FIELD macro + m%FIELD\((.*)\)%; + $_ = $1; + + #FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier") + # NOTE: I tried using Text:CSV but could not make it work. + # Parse using brute force regex + m%(\S+),\s*(\S+),\s*(\S+),\s*(\".*\"),\s*(\S+),\s*(\S+),\s*(\S+),\s*(\".*\"),\s*(\".*\")%; + ($type, $strct, $sorttype, $head, $field, $width, $func, $id, $desc) = + ($1, $2, $3, $4, $5, $6, $7, $8, $9); + + # + # Fixup the id / field name / attribute name + # + + # Unquote 'id' (field name) and description + $id =~ tr/"//d; + $desc =~ tr/"//d; + + # Skip redundant fields + if ($id =~ /^(stripesize|regionsize|chunksize)$/) { + next; + } + + # Map report type to liblvm object name + # - PVS, VGS, LVS reports, the liblvm object is pv/vg/lv + # - PVSEG, the object is pvseg + # - SEG, the object is lvseg + # - LABEL, the object is pv + if ($type =~ /^PVS$/) { + $object = "pv"; + } elsif ($type =~ /^VGS$/) { + $object = "vg"; + } elsif ($type =~ /^LVS$/) { + $object = "lv"; + } elsif ($type =~ /^LABEL$/) { + $object = "pv"; + } elsif ($type =~ /^SEGS$/) { + $object = "lvseg"; + } elsif ($type =~ /^PVSEGS$/) { + $object = "pvseg"; + } else { + print "Skipping type: $type, line: $_\n"; #DEBUG + next; + } + + # lv_kernel_major and lv_kernel_minor are 'STR' but we make them uint64_t here + # as this seems more appropriate and easier to manage. + if ($id =~ /^(lv_kernel_major|lv_kernel_minor)$/) { + $prop_type = "uint64_t "; + } elsif ($sorttype =~ m/STR/) { + $prop_type = "char *"; + } else { + $prop_type = "uint64_t "; + } + + # Some field names/ids contain the struct name, while others don't. + # For consistency, if the field name contains the struct name, remove + # it (we always put the object name in the function name. + # + if ($id =~ /^$strct/) { + $id = substr($id,length($strct)+1,length($id)); + } + + # Write 'get' prototype to header and code to C file. + write_include_body(INCLUDE_FILE, $object, $id, $desc, $prop_type); + write_code_body(CODE_FILE, $object, $id, $desc, $prop_type, $func, $field); +} + +write_include_footer(INCLUDE_FILE); +write_code_footer(CODE_FILE); +close(INCLUDE_FILE); +close(CODE_FILE); + +sub write_include_header +{ + my($file) = @_; + print $file <<END_INCLUDE_HEADER; +/* + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LVM_OBJECT_PROP_H +#define _LVM_OBJECT_PROP_H + +END_INCLUDE_HEADER +} + +sub write_include_body +{ + my($file, $object, $id, $desc, $prop_type) = @_; + # + # Use the description and field name in the comment + # + print $file "/**\n"; + print $file " * "."lvm_"."$object"."_{get|set}_$id\n"; + print $file " * $id - $desc\n"; + print $file " */\n"; + # Write out 'get' method prototype + $fun_name = "lvm_"."$object"."_get_$id"; + $fun_args = "(const $object"."_t *$object)"; + print $file "$prop_type"."$fun_name"."$fun_args".";\n"; + # Write out 'set' method prototype + $fun_name = "lvm_"."$object"."_set_$id"; + $fun_args = "($object"."_t *$object, const $prop_type"."value)"; + print $file "int "."$fun_name"."$fun_args".";\n\n"; +} + +sub write_include_footer +{ + my($file) = @_; + print $file <<END_INCLUDE_FOOTER; +#endif +END_INCLUDE_FOOTER +} + +sub write_code_header +{ + my($file) = @_; + print $file <<END_CODE_HEADER; +/* + * Copyright (C) 2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "lvm.h" +#include "lib.h" +#include "metadata-exported.h" + +END_CODE_HEADER +} + +sub write_code_body_get +{ + my($file, $object, $func, $field, $fun_name, $prop_type, $id) = @_; + + if ($func =~ /^(int32|uint32|size32|size64)$/) { + $code = "\treturn $object->$field;"; + } else { + $code = "\t/* FIXME: implement function body */\n\treturn 0;"; + } + print $file <<END_CODE_GET; +{ +$code +} +END_CODE_GET +} + +sub write_code_body +{ + my($file, $object, $id, $desc, $prop_type, $func, $field) = @_; + print $file "/**\n"; + print $file " * "."lvm_"."$object"."_{get|set}_$id\n"; + print $file " * $id - $desc\n"; + print $file " */\n"; + # Write out 'get' method + $fun_name = "lvm_"."$object"."_get_$id"; + $fun_args = "(const $object"."_t *$object)"; + print $file "$prop_type"."$fun_name"."$fun_args"."\n"; + write_code_body_get($file, $object, $func, $field, $fun_name, $prop_type, $id); + + # Write out 'set' method; all sets require internal logic so no autogeneration + $fun_name = "lvm_"."$object"."_set_$id"; + $fun_args = "($object"."_t *$object, const $prop_type"."value)"; + print $file "int "."$fun_name"."$fun_args"."\n"; + $code = "\t/* FIXME: implement function body */\n\treturn -1;"; + print $file <<END_CODE_SET; +{ +$code +} +END_CODE_SET +} + + +sub write_code_footer +{ +# nothing to do +}
Signature · 1 line
1.6.0.6
PATCH 3/30 Add generated files, lvm_object_prop.[ch], to lib/report directory and build
These files were generated from using the current columns.h file as input into lvm_object_prop.pl. They are a starting point for liblvm object property get/set functions. The 'NUM' fields that are simple dereferences are generated from the perl script. Code implementing the functions for other fields will be added later.
Include lvm_object_prop.h in lvm.h
--- include/.symlinks | 1 + lib/Makefile.in | 1 + lib/report/lvm_object_prop.c | 950 ++++++++++++++++++++++++++++++++++++++++++ lib/report/lvm_object_prop.h | 494 ++++++++++++++++++++++ liblvm/lvm.h | 1 + 5 files changed, 1447 insertions(+), 0 deletions(-) create mode 100644 lib/report/lvm_object_prop.c create mode 100644 lib/report/lvm_object_prop.h
include/.symlinks +1 -0
@@ -51,6 +51,7 @@ ../lib/misc/lvm-wrappers.h ../lib/misc/sharedlib.h ../lib/report/report.h +../lib/report/lvm_object_prop.h ../lib/uuid/uuid.h ../libdm/libdevmapper.h ../libdm/misc/dm-ioctl.h
lib/Makefile.in +1 -0
@@ -85,6 +85,7 @@ SOURCES =\ misc/util.c \ mm/memlock.c \ report/report.c \ + report/lvm_object_prop.c \ striped/striped.c \ uuid/uuid.c \ zero/zero.c
lib/report/lvm_object_prop.c new file +950 -0
950 lines not on this page · raw message
lib/report/lvm_object_prop.h new file +494 -0
494 lines not on this page · raw message
liblvm/lvm.h +1 -0
@@ -68,5 +68,6 @@ void lvm_destroy(lvm_t libh);*/ int lvm_reload_config (lvm_t libh); +#include "lvm_object_prop.h" #endif /* _LIB_LVM_H */
Signature · 1 line
1.6.0.6
PATCH 4/30 Update vg_size 'disp' function to call liblvm 'get' function.
Move 'disp' function logic that calculates vg_size inside liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -561,8 +561,7 @@ int lvm_vg_set_attr(vg_t *vg, const char *value)*/ uint64_t lvm_vg_get_size (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +return (uint64_t ) vg->extent_count * vg->extent_size; }int lvm_vg_set_size (vg_t *vg,const uint64_t value) {
lib/report/report.c +2 -1
@@ -23,6 +23,7 @@#include "segtype.h" #include "str_list.h" #include "lvmcache.h" +#include "lvm_object_prop.h" struct lvm_report_object {struct volume_group *vg;
@@ -672,7 +673,7 @@ static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,const struct volume_group *vg = (const struct volume_group *) data;uint64_t size; - size = (uint64_t ) vg->extent_count * vg->extent_size; + size =lvm_vg_get_size (vg);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 5/30 Modify lv_major and lv_minor fields to call liblvm 'get' functions.
We'd like to call liblvm 'get' functions from the reporting commands in all cases. This allows for nice code re-use, as well as free testing. In the case of simple fields that are dereferences, we must modify the 'disp' function from a generic one (e.g. _int32_disp()) to a specific one. The reason for this is that the generic one relies on the dereference of the base object pointer + field data value, which is done in libdm. If we call the liblvm 'get' functions, the dereference is done in there. So for each field, we remove the generic "int32" disp function and replace it with a specific one. Note that we change the data pointer argument to the FIELD macro to 'lvid', which makes the base + offset calculation in libdm yield the pointer to the object for the value of 'data' pointer being passed into the 'disp' function.
Should be no functional change.
--- lib/report/columns.h | 4 ++-- lib/report/report.c | 32 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-)
lib/report/columns.h +2 -2
@@ -59,8 +59,8 @@ FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier.") FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name", "Name. LVs created for internal use are enclosed in brackets.") FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr", "Various attributes - see man page.") -FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major", "Persistent major number or -1 if not persistent.") -FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor", "Persistent minor number or -1 if not persistent.") +FIELD(LVS, lv, NUM, "Maj", lvid, 3, lvmajor, "lv_major", "Persistent major number or -1 if not persistent.") +FIELD(LVS, lv, NUM, "Min", lvid, 3, lvminor, "lv_minor", "Persistent minor number or -1 if not persistent.") FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, "lv_read_ahead", "Read ahead setting in current units.") FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major", "Currently assigned major number or -1 if LV is not active.")FIELD (LVS , lv,STR ,"KMin" , lvid,4 , lvkmin,"lv_kernel_minor" ,"Currently assigned minor number or -1 if LV is not active." )
lib/report/report.c +25 -7
@@ -247,6 +247,31 @@ static int _pvfmt_disp(struct dm_report *rh, struct dm_pool *mem,return _string_disp (rh, mem, field, &pv->fmt->name, private); } + +static int _lvmajor_disp (struct dm_report *rh,struct dm_pool *mem __attribute((unused)), +struct dm_report_field *field, +const void *data,void *private __attribute((unused))) +{ +const struct logical_volume *lv = (const struct logical_volume *) data; +int32_t value; + + value =lvm_lv_get_major (lv); +return dm_report_field_int32 (rh, field, &value); +} + + +static int _lvminor_disp (struct dm_report *rh,struct dm_pool *mem __attribute((unused)), +struct dm_report_field *field, +const void *data,void *private __attribute((unused))) +{ +const struct logical_volume *lv = (const struct logical_volume *) data; +int32_t value; + + value =lvm_lv_get_minor (lv); +return dm_report_field_int32 (rh, field, &value); +} + +static int _lvkmaj_disp (struct dm_report *rh,struct dm_pool *mem __attribute((unused)),struct dm_report_field *field,const void *data,void *private __attribute((unused)))
@@ -843,13 +868,6 @@ static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem __attribute((ureturn dm_report_field_uint32 (rh, field, data); } -static int _int32_disp (struct dm_report *rh,struct dm_pool *mem __attribute((unused)), -struct dm_report_field *field, -const void *data,void *private __attribute((unused))) -{ -return dm_report_field_int32 (rh, field, data); -} -static int _pvmdas_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 6/30 Update lvreadahead_disp to call liblvm 'get' function.
Should be no functional change. Just move the dereference inside 'get' function and call from 'disp' function.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -89,8 +89,7 @@ int lvm_lv_set_minor(lv_t *lv, const uint64_t value)*/ uint64_t lvm_lv_get_read_ahead (const lv_t *lv) { -/* FIXME: implement function body */ -return 0 ; +return lv->read_ahead; }int lvm_lv_set_read_ahead (lv_t *lv,const uint64_t value) {
lib/report/report.c +4 -2
@@ -668,13 +668,15 @@ static int _lvreadahead_disp(struct dm_report *rh, struct dm_pool *mem, const void *data, void *private __attribute((unused))) {const struct logical_volume *lv = (const struct logical_volume *) data; +uint32_t value; -if (lv->read_ahead ==DM_READ_AHEAD_AUTO ) { + value =lvm_lv_get_read_ahead (lv); +if (value ==DM_READ_AHEAD_AUTO ) {dm_report_field_set_value (field,"auto" , &_minusone);return 1 ; } -return _size32_disp (rh, mem, field, &lv->read_ahead, private); +return _size32_disp (rh, mem, field, &value, private); } static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
Signature · 1 line
1.6.0.6
PATCH 7/30 Update lvkreadhead_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 7 +++++-- lib/report/report.c | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-)
lib/report/lvm_object_prop.c +5 -2
@@ -14,6 +14,7 @@#include "lvm.h" #include "lib.h" #include "metadata-exported.h" +#include "activate.h" /** * lvm_lv_{get|set}_uuid
@@ -130,8 +131,10 @@ int lvm_lv_set_kernel_minor(lv_t *lv, const uint64_t value)*/ uint64_t lvm_lv_get_kernel_read_ahead (const lv_t *lv) { -/* FIXME: implement function body */ -return 0 ; +struct lvinfo info; +if (!lv_info (lv->vg->cmd, lv, &info,0 ,1 ) || !info.exists) +return -1 ; +return info.read_ahead; }int lvm_lv_set_kernel_read_ahead (lv_t *lv,const uint64_t value) {
lib/report/report.c +4 -3
@@ -685,12 +685,13 @@ static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem, void *private) {const struct logical_volume *lv = (const struct logical_volume *) data; -struct lvinfo info; +uint32_t value; -if (!lv_info (lv->vg->cmd, lv, &info,0 ,1 ) || !info.exists) + value =lvm_lv_get_kernel_read_ahead (lv); +if (value ==-1 )return dm_report_field_uint64 (rh, field, &_minusone); -return _size32_disp (rh, mem, field, &info.read_ahead, private); +return _size32_disp (rh, mem, field, &value, private); } static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,
Signature · 1 line
1.6.0.6
PATCH 8/30 Update lv_size field - create lvsize_disp() and call liblvm 'get' function.
Should be no functional change.
--- lib/report/columns.h | 2 +- lib/report/report.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-)
lib/report/columns.h +1 -1
@@ -65,7 +65,7 @@ FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, "lv_read_ahead", "Read ahead FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major", "Currently assigned major number or -1 if LV is not active.") FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, "lv_kernel_minor", "Currently assigned minor number or -1 if LV is not active.") FIELD(LVS, lv, NUM, "KRahead", lvid, 7, lvkreadahead, "lv_kernel_read_ahead", "Currently-in-use read ahead setting in current units.") -FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size", "Size of LV in current units.") +FIELD(LVS, lv, NUM, "LSize", lvid, 5, lvsize, "lv_size", "Size of LV in current units.") FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count", "Number of segments in LV.") FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin", "For snapshots, the origin device of this LV.")FIELD (LVS , lv,NUM ,"OSize" , lvid,5 , originsize,"origin_size" ,"For snapshots, the size of the origin device of this LV." )
lib/report/report.c +12 -0
@@ -706,6 +706,18 @@ static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &size, private); } +static int _lvsize_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct logical_volume *lv = (const struct logical_volume *) data; +uint64_t size; + + size =lvm_lv_get_size (lv); + +return _size64_disp (rh, mem, field, &size, private); +} +static int _segstart_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 9/30 Update lvsegcount_disp() to call liblvm 'get' function.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -160,8 +160,7 @@ int lvm_lv_set_size(lv_t *lv, const uint64_t value)*/ uint64_t lvm_lv_get_seg_count (const lv_t *lv) { -/* FIXME: implement function body */ -return 0 ; +return dm_list_size (&lv->segments); }int lvm_lv_set_seg_count (lv_t *lv,const uint64_t value) {
lib/report/report.c +1 -1
@@ -1020,7 +1020,7 @@ static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem,const struct logical_volume *lv = (const struct logical_volume *) data;uint32_t count; - count =dm_list_size (&lv->segments); + count =lvm_lv_get_seg_count (lv);return _uint32_disp (rh, mem, field, &count, private); }
Signature · 1 line
1.6.0.6
PATCH 10/30 Update originsize_disp() to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 11 +++++++++-- lib/report/report.c | 7 +------ 2 files changed, 10 insertions(+), 8 deletions(-)
lib/report/lvm_object_prop.c +9 -2
@@ -187,8 +187,15 @@ int lvm_lv_set_origin(lv_t *lv, const char *value)*/ uint64_t lvm_lv_get_origin_size (const lv_t *lv) { -/* FIXME: implement function body */ -return 0 ; +uint64_t size; + +if (lv_is_cow (lv)) + size = (uint64_t )find_cow (lv)->len * lv->vg->extent_size; +else if (lv_is_origin (lv)) + size = lv->size; +else + size =UINT64_C (0 ); +return size; }int lvm_lv_set_origin_size (lv_t *lv,const uint64_t value) {
lib/report/report.c +1 -6
@@ -775,12 +775,7 @@ static int _originsize_disp(struct dm_report *rh, struct dm_pool *mem,const struct logical_volume *lv = (const struct logical_volume *) data;uint64_t size; -if (lv_is_cow (lv)) - size = (uint64_t )find_cow (lv)->len * lv->vg->extent_size; -else if (lv_is_origin (lv)) - size = lv->size; -else - size =UINT64_C (0 ); + size =lvm_lv_get_origin_size (lv);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 11/30 Update devsize_disp() to call liblvm 'get' function.
Should be no functional change.
Note again we change the field data pointer from 'dev' to 'id' so that the 'data' pointer value is simply the pointer to the 'pv'. We can then call the liblvm 'get' function to retrieve the value.
--- lib/report/columns.h | 2 +- lib/report/lvm_object_prop.c | 8 ++++++-- lib/report/report.c | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-)
lib/report/columns.h +1 -1
@@ -79,7 +79,7 @@ FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mappe FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.") FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.") -FIELD(LABEL, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.") +FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, "dev_size", "Size of underlying device in current units.") FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.") FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")FIELD (LABEL , pv,NUM ,"PMdaSize" , id,9 , pvmdasize,"pv_mda_size" ,"Size of smallest metadata area on this device in current units." )
lib/report/lvm_object_prop.c +6 -2
@@ -15,6 +15,7 @@#include "lib.h" #include "metadata-exported.h" #include "activate.h" +#include "device.h" /** * lvm_lv_{get|set}_uuid
@@ -334,8 +335,11 @@ int lvm_pv_set_uuid(pv_t *pv, const char *value)*/ uint64_t lvm_pv_get_dev_size (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +uint64_t size; + +if (!dev_get_size (pv->dev, &size)) + size =0 ; +return size; }int lvm_pv_set_dev_size (pv_t *pv,const uint64_t value) {
lib/report/report.c +2 -3
@@ -832,11 +832,10 @@ static int _devsize_disp(struct dm_report *rh, struct dm_pool *mem,struct dm_report_field *field, const void *data, void *private) { - const struct device *dev = *(const struct device **) data; + const struct physical_volume *pv = (const struct physical_volume *) data;uint64_t size; -if (!dev_get_size (dev, &size)) - size =0 ; + size =lvm_pv_get_dev_size (pv);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 12/30 Update pvmdafree_disp() to call liblvm 'get' function.
Move the guts of pvmadfree_disp() inside liblvm 'get' function. As we do this, we must add a few more includes into lvm_object_prop.c as we are now dereferencing internal lvm types to get the field values.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 22 ++++++++++++++++++++-- lib/report/report.c | 18 +++--------------- 2 files changed, 23 insertions(+), 17 deletions(-)
lib/report/lvm_object_prop.c +20 -2
@@ -16,6 +16,9 @@#include "metadata-exported.h" #include "activate.h" #include "device.h" +#include "lvmcache.h" +#include "uuid.h" +#include "metadata.h" /** * lvm_lv_{get|set}_uuid
@@ -366,8 +369,23 @@ int lvm_pv_set_name(pv_t *pv, const char *value)*/ uint64_t lvm_pv_get_mda_free (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +struct lvmcache_info *info; +uint64_t freespace =UINT64_MAX , mda_free; +const char *pvid = (const char *)pv->id.uuid; +struct metadata_area *mda; + +if ((info =info_from_pvid (pvid,0 ))) + dm_list_iterate_items(mda, &info->mdas) { +if (!mda->ops->mda_free_sectors) +continue ; + mda_free = mda->ops->mda_free_sectors (mda); +if (mda_free < freespace) + freespace = mda_free; + } + +if (freespace ==UINT64_MAX ) + freespace =UINT64_C (0 ); +return freespace; }int lvm_pv_set_mda_free (pv_t *pv,const uint64_t value) {
lib/report/report.c +3 -15
@@ -907,22 +907,10 @@ static int _pvmdafree_disp(struct dm_report *rh, struct dm_pool *mem,struct dm_report_field *field, const void *data, void *private) { - struct lvmcache_info *info; -uint64_t freespace =UINT64_MAX , mda_free; -const char *pvid = (const char *)(&((struct id *) data)->uuid); -struct metadata_area *mda; - -if ((info =info_from_pvid (pvid,0 ))) - dm_list_iterate_items(mda, &info->mdas) { -if (!mda->ops->mda_free_sectors) -continue ; - mda_free = mda->ops->mda_free_sectors (mda); -if (mda_free < freespace) - freespace = mda_free; - } + const struct physical_volume *pv = (const struct physical_volume *) data; +uint64_t freespace; -if (freespace ==UINT64_MAX ) - freespace =UINT64_C (0 ); + freespace =lvm_pv_get_mda_free (pv);return _size64_disp (rh, mem, field, &freespace, private); }
Signature · 1 line
1.6.0.6
PATCH 13/30 Update pvmdasize_disp and vgmdasize_disp to call liblvm 'get' function.
Should be no functional change.
We must move both pvmdasize and vgmdasize at the same time since they both use the _find_min_mda_size() code.
--- lib/report/lvm_object_prop.c | 33 +++++++++++++++++++++++++++++---- lib/report/report.c | 30 ++++-------------------------- 2 files changed, 33 insertions(+), 30 deletions(-)
lib/report/lvm_object_prop.c +29 -4
@@ -392,14 +392,40 @@ int lvm_pv_set_mda_free(pv_t *pv, const uint64_t value)/* FIXME: implement function body */ return -1 ; } + +static uint64_t _find_min_mda_size (struct dm_list *mdas) +{ +uint64_t min_mda_size =UINT64_MAX , mda_size; +struct metadata_area *mda; + + dm_list_iterate_items(mda, mdas) { +if (!mda->ops->mda_total_sectors) +continue ; + mda_size = mda->ops->mda_total_sectors (mda); +if (mda_size < min_mda_size) + min_mda_size = mda_size; + } + +if (min_mda_size ==UINT64_MAX ) + min_mda_size =UINT64_C (0 ); + +return min_mda_size; +} +/** * lvm_pv_{get|set}_mda_size * mda_size - Size of smallest metadata area on this device in current units. */ uint64_t lvm_pv_get_mda_size (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +struct lvmcache_info *info; +uint64_t min_mda_size =0 ; +const char *pvid = (const char *)pv->id.uuid; + +/* PVs could have 2 mdas of different sizes (rounding effect) */ +if ((info =info_from_pvid (pvid,0 ))) + min_mda_size =_find_min_mda_size (&info->mdas); +return min_mda_size; }int lvm_pv_set_mda_size (pv_t *pv,const uint64_t value) {
@@ -792,8 +818,7 @@ int lvm_vg_set_mda_free(vg_t *vg, const uint64_t value)*/ uint64_t lvm_vg_get_mda_size (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +return _find_min_mda_size (&vg->fid->metadata_areas);; }int lvm_vg_set_mda_size (vg_t *vg,const uint64_t value) {
lib/report/report.c +4 -26
@@ -915,36 +915,14 @@ static int _pvmdafree_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &freespace, private); } -static uint64_t _find_min_mda_size (struct dm_list *mdas) -{ -uint64_t min_mda_size =UINT64_MAX , mda_size; -struct metadata_area *mda; - - dm_list_iterate_items(mda, mdas) { -if (!mda->ops->mda_total_sectors) -continue ; - mda_size = mda->ops->mda_total_sectors (mda); -if (mda_size < min_mda_size) - min_mda_size = mda_size; - } - -if (min_mda_size ==UINT64_MAX ) - min_mda_size =UINT64_C (0 ); - -return min_mda_size; -} -static int _pvmdasize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private) { -struct lvmcache_info *info; -uint64_t min_mda_size =0 ; -const char *pvid = (const char *)(&((struct id *) data)->uuid); +const struct physical_volume *pv = (const struct physical_volume *) data; +uint64_t min_mda_size; -/* PVs could have 2 mdas of different sizes (rounding effect) */ -if ((info =info_from_pvid (pvid,0 ))) - min_mda_size =_find_min_mda_size (&info->mdas); + min_mda_size =lvm_pv_get_mda_size (pv);return _size64_disp (rh, mem, field, &min_mda_size, private); }
@@ -956,7 +934,7 @@ static int _vgmdasize_disp(struct dm_report *rh, struct dm_pool *mem,const struct volume_group *vg = (const struct volume_group *) data;uint64_t min_mda_size; - min_mda_size =_find_min_mda_size (&vg->fid->metadata_areas); + min_mda_size =lvm_vg_get_mda_size (vg);return _size64_disp (rh, mem, field, &min_mda_size, private); }
Signature · 1 line
1.6.0.6
PATCH 14/30 Update pe_start field - create pestart_disp which calls liblvm 'get' function.
Note that the liblvm 'get' function was one of the autogenerated ones (simple field dereference).
Should be no functional change.
--- lib/report/columns.h | 2 +- lib/report/report.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletions(-)
lib/report/columns.h +1 -1
@@ -84,7 +84,7 @@ FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.") FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.") FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.") -FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.") +FIELD(PVS, pv, NUM, "1st PE", id, 7, pestart, "pe_start", "Offset to the start of data on the underlying device.") FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current units.") FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.")FIELD (PVS , pv,NUM ,"Used" , id,4 , pvused,"pv_used" ,"Total amount of allocated space in current units." )
lib/report/report.c +13 -0
@@ -812,6 +812,19 @@ static int _pvfree_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &freespace, private); } +static int _pestart_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct physical_volume *pv = + (const struct physical_volume *) data; +uint64_t value; + + value =lvm_pv_get_pe_start (pv); + +return _size64_disp (rh, mem, field, &value, private); +} +static int _pvsize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 15/30 Update pvsize_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 9 +++++++-- lib/report/report.c | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +7 -2
@@ -451,8 +451,13 @@ int lvm_pv_set_pe_start(pv_t *pv, const uint64_t value)*/ uint64_t lvm_pv_get_size (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +uint64_t size; + +if (!pv->pe_count) + size = pv->size; +else + size = (uint64_t ) pv->pe_count * pv->pe_size; +return size; }int lvm_pv_set_size (pv_t *pv,const uint64_t value) {
lib/report/report.c +1 -4
@@ -833,10 +833,7 @@ static int _pvsize_disp(struct dm_report *rh, struct dm_pool *mem, (const struct physical_volume *) data;uint64_t size; -if (!pv->pe_count) - size = pv->size; -else - size = (uint64_t ) pv->pe_count * pv->pe_size; + size =lvm_pv_get_size (pv);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 16/30 Update pvfree_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 10 ++++++++-- lib/report/report.c | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +8 -2
@@ -470,8 +470,14 @@ int lvm_pv_set_size(pv_t *pv, const uint64_t value)*/ uint64_t lvm_pv_get_free (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +uint64_t freespace; + +if (!pv->pe_count) + freespace = pv->size; +else + freespace = (uint64_t ) (pv->pe_count - pv->pe_alloc_count) * pv->pe_size; + +return freespace; }int lvm_pv_set_free (pv_t *pv,const uint64_t value) {
lib/report/report.c +1 -4
@@ -804,10 +804,7 @@ static int _pvfree_disp(struct dm_report *rh, struct dm_pool *mem, (const struct physical_volume *) data;uint64_t freespace; -if (!pv->pe_count) - freespace = pv->size; -else - freespace = (uint64_t ) (pv->pe_count - pv->pe_alloc_count) * pv->pe_size; + freespace =lvm_pv_get_free (pv);return _size64_disp (rh, mem, field, &freespace, private); }
Signature · 1 line
1.6.0.6
PATCH 17/30 Update pvused_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 9 +++++++-- lib/report/report.c | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +7 -2
@@ -490,8 +490,13 @@ int lvm_pv_set_free(pv_t *pv, const uint64_t value)*/ uint64_t lvm_pv_get_used (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +uint64_t used; + +if (!pv->pe_count) + used =0LL ; +else + used = (uint64_t ) pv->pe_alloc_count * pv->pe_size; +return used; }int lvm_pv_set_used (pv_t *pv,const uint64_t value) {
lib/report/report.c +1 -4
@@ -788,10 +788,7 @@ static int _pvused_disp(struct dm_report *rh, struct dm_pool *mem, (const struct physical_volume *) data;uint64_t used; -if (!pv->pe_count) - used =0LL ; -else - used = (uint64_t ) pv->pe_alloc_count * pv->pe_size; + used =lvm_pv_get_used (pv);return _size64_disp (rh, mem, field, &used, private); }
Signature · 1 line
1.6.0.6
PATCH 18/30 Update pv_pe_count and pv_pe_alloc_count fields to call liblvm 'get' functions.
Implement specific 'disp' functions for these two fields, and call into already generated liblvm 'get' functions.
Should be no functional change.
--- lib/report/columns.h | 4 ++-- lib/report/report.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-)
lib/report/columns.h +2 -2
@@ -89,8 +89,8 @@ FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current un FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.") FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used", "Total amount of allocated space in current units.") FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes - see man page.") -FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.") -FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.") +FIELD(PVS, pv, NUM, "PE", id, 3, pecount, "pv_pe_count", "Total number of Physical Extents.") +FIELD(PVS, pv, NUM, "Alloc", id, 5, pealloccount, "pv_pe_alloc_count", "Total number of allocated Physical Extents.") FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.")FIELD (PVS , pv,NUM ,"#PMda" , id,5 , pvmdas,"pv_mda_count" ,"Number of metadata areas on this device." )
lib/report/report.c +26 -0
@@ -819,6 +819,32 @@ static int _pestart_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &value, private); } +static int _pecount_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct physical_volume *pv = + (const struct physical_volume *) data; +uint32_t value; + + value =lvm_pv_get_pe_count (pv); + +return _uint32_disp (rh, mem, field, &value, private); +} + +static int _pealloccount_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct physical_volume *pv = + (const struct physical_volume *) data; +uint32_t value; + + value =lvm_pv_get_pe_alloc_count (pv); + +return _uint32_disp (rh, mem, field, &value, private); +} +static int _pvsize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 19/30 Update pvmdas_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 9 +++++++-- lib/report/report.c | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +7 -2
@@ -563,8 +563,13 @@ int lvm_pv_set_tags(pv_t *pv, const char *value)*/ uint64_t lvm_pv_get_mda_count (const pv_t *pv) { -/* FIXME: implement function body */ -return 0 ; +struct lvmcache_info *info; +uint32_t count; +const char *pvid = (const char *)pv->id.uuid; + + info =info_from_pvid (pvid,0 ); + count = info ?dm_list_size (&info->mdas) :0 ; +return count; }int lvm_pv_set_mda_count (pv_t *pv,const uint64_t value) {
lib/report/report.c +2 -4
@@ -911,12 +911,10 @@ static int _pvmdas_disp(struct dm_report *rh, struct dm_pool *mem,struct dm_report_field *field, const void *data, void *private) { - struct lvmcache_info *info; + const struct physical_volume *pv = (const struct physical_volume *) data;uint32_t count; -const char *pvid = (const char *)(&((struct id *) data)->uuid); - info =info_from_pvid (pvid,0 ); - count = info ?dm_list_size (&info->mdas) :0 ; + count =lvm_pv_get_mda_count (pv);return _uint32_disp (rh, mem, field, &count, private); }
Signature · 1 line
1.6.0.6
PATCH 20/30 Update vgfree_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -651,8 +651,7 @@ int lvm_vg_set_size(vg_t *vg, const uint64_t value)*/ uint64_t lvm_vg_get_free (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +return (uint64_t ) vg->free_count * vg->extent_size;; }int lvm_vg_set_free (vg_t *vg,const uint64_t value) {
lib/report/report.c +1 -1
@@ -877,7 +877,7 @@ static int _vgfree_disp(struct dm_report *rh, struct dm_pool *mem,const struct volume_group *vg = (const struct volume_group *) data;uint64_t freespace; - freespace = (uint64_t ) vg->free_count * vg->extent_size; + freespace =lvm_vg_get_free (vg);return _size64_disp (rh, mem, field, &freespace, private); }
Signature · 1 line
1.6.0.6
PATCH 21/30 Update a few simple vg 'NUM' fields to call liblvm 'get' functions.
Add new 'disp' functions for vg fields vg_extent_size, vg_extent_count, vg_free_count, max_lv, max_pv, and pv_count. Call into liblvm 'get' functions to get the value (Note - the liblvm functions were some of the autogenerated ones with simple pointer dereferences).
Move uint32_disp() higher in the report.c file so it can be called from the new 'disp' functions.
Should be no functional change.
--- lib/report/columns.h | 12 +++--- lib/report/report.c | 86 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 13 deletions(-)
lib/report/columns.h +6 -6
@@ -101,12 +101,12 @@ FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - s FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size", "Total size of VG in current units.") FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free", "Total amount of free space in current units.") FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid", "System ID indicating when and where it was created.") -FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size", "Size of Physical Extents in current units.") -FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count", "Total number of Physical Extents.") -FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count", "Total number of unallocated Physical Extents.") -FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.") -FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.") -FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.") +FIELD(VGS, vg, NUM, "Ext", cmd, 3, vgextentsize, "vg_extent_size", "Size of Physical Extents in current units.") +FIELD(VGS, vg, NUM, "#Ext", cmd, 4, vgextentcount, "vg_extent_count", "Total number of Physical Extents.") +FIELD(VGS, vg, NUM, "Free", cmd, 4, vgfreecount, "vg_free_count", "Total number of unallocated Physical Extents.") +FIELD(VGS, vg, NUM, "MaxLV", cmd, 5, vgmaxlv, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.") +FIELD(VGS, vg, NUM, "MaxPV", cmd, 5, vgmaxpv, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.") +FIELD(VGS, vg, NUM, "#PV", cmd, 3, vgpvcount, "pv_count", "Number of PVs.") FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.") FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.")FIELD (VGS , vg,NUM ,"Seq" , seqno,3 , uint32,"vg_seqno" ,"Revision number of internal metadata. Incremented whenever it changes." )
lib/report/report.c +79 -7
104 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 22/30 Update lvcount_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -756,8 +756,7 @@ int lvm_vg_set_pv_count(vg_t *vg, const uint64_t value)*/ uint64_t lvm_vg_get_lv_count (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +return displayable_lvs_in_vg (vg); }int lvm_vg_set_lv_count (vg_t *vg,const uint64_t value) {
lib/report/report.c +1 -1
@@ -1068,7 +1068,7 @@ static int _lvcount_disp(struct dm_report *rh, struct dm_pool *mem,const struct volume_group *vg = (const struct volume_group *) data;uint32_t count; - count =displayable_lvs_in_vg (vg); + count =lvm_vg_get_lv_count (vg);return _uint32_disp (rh, mem, field, &count, private); }
Signature · 1 line
1.6.0.6
PATCH 23/30 Update vg_snap_count and vg_seqno display functions to call liblvm 'get'.
Note that vg_snap_count and vg_seqno field values are obtained from a simple dereference of the vg. The liblvm 'get' functions do not show up in this patch as they were generated by an earlier patch.
Should be no functional change.
--- lib/report/columns.h | 4 ++-- lib/report/report.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-)
lib/report/columns.h +2 -2
@@ -108,8 +108,8 @@ FIELD(VGS, vg, NUM, "MaxLV", cmd, 5, vgmaxlv, "max_lv", "Maximum number of LVs a FIELD(VGS, vg, NUM, "MaxPV", cmd, 5, vgmaxpv, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.") FIELD(VGS, vg, NUM, "#PV", cmd, 3, vgpvcount, "pv_count", "Number of PVs.") FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.") -FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.") -FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.") +FIELD(VGS, vg, NUM, "#SN", cmd, 3, vgsnapcount, "snap_count", "Number of snapshots.") +FIELD(VGS, vg, NUM, "Seq", cmd, 3, vgseqno, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.") FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.") FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas in use by this VG.")FIELD (VGS , vg,NUM ,"VMdaFree" , cmd,9 , vgmdafree,"vg_mda_free" ,"Free metadata area space for this VG in current units." )
lib/report/report.c +24 -0
@@ -949,6 +949,30 @@ static int _vgpvcount_disp(struct dm_report *rh, struct dm_pool *mem,return _uint32_disp (rh, mem, field, &value, private); } +static int _vgsnapcount_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct volume_group *vg = (const struct volume_group *) data; +uint32_t value; + + value =lvm_vg_get_snap_count (vg); + +return _uint32_disp (rh, mem, field, &value, private); +} + +static int _vgseqno_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct volume_group *vg = (const struct volume_group *) data; +uint32_t value; + + value =lvm_vg_get_seqno (vg); + +return _uint32_disp (rh, mem, field, &value, private); +} +static int _vgfree_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 24/30 Update vgmdas_disp to call liblvm 'get' function.
No functional change.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -809,8 +809,7 @@ int lvm_vg_set_tags(vg_t *vg, const char *value)*/ uint64_t lvm_vg_get_mda_count (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +return dm_list_size (&vg->fid->metadata_areas); }int lvm_vg_set_mda_count (vg_t *vg,const uint64_t value) {
lib/report/report.c +1 -1
@@ -1022,7 +1022,7 @@ static int _vgmdas_disp(struct dm_report *rh, struct dm_pool *mem,const struct volume_group *vg = (const struct volume_group *) data;uint32_t count; - count =dm_list_size (&vg->fid->metadata_areas); + count =lvm_vg_get_mda_count (vg);return _uint32_disp (rh, mem, field, &count, private); }
Signature · 1 line
1.6.0.6
PATCH 25/30 Update vgmdafree_disp to call liblvm 'get' function.
--- lib/report/lvm_object_prop.c | 16 ++++++++++++++-- lib/report/report.c | 14 ++------------ 2 files changed, 16 insertions(+), 14 deletions(-)
lib/report/lvm_object_prop.c +14 -2
@@ -822,8 +822,20 @@ int lvm_vg_set_mda_count(vg_t *vg, const uint64_t value)*/ uint64_t lvm_vg_get_mda_free (const vg_t *vg) { -/* FIXME: implement function body */ -return 0 ; +uint64_t freespace =UINT64_MAX , mda_free; +struct metadata_area *mda; + + dm_list_iterate_items(mda, &vg->fid->metadata_areas) { +if (!mda->ops->mda_free_sectors) +continue ; + mda_free = mda->ops->mda_free_sectors (mda); +if (mda_free < freespace) + freespace = mda_free; + } + +if (freespace ==UINT64_MAX ) + freespace =UINT64_C (0 ); +return freespace; }int lvm_vg_set_mda_free (vg_t *vg,const uint64_t value) {
lib/report/report.c +2 -12
@@ -1068,19 +1068,9 @@ static int _vgmdafree_disp(struct dm_report *rh, struct dm_pool *mem, const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; -uint64_t freespace =UINT64_MAX , mda_free; -struct metadata_area *mda; - - dm_list_iterate_items(mda, &vg->fid->metadata_areas) { -if (!mda->ops->mda_free_sectors) -continue ; - mda_free = mda->ops->mda_free_sectors (mda); -if (mda_free < freespace) - freespace = mda_free; - } +uint64_t freespace; -if (freespace ==UINT64_MAX ) - freespace =UINT64_C (0 ); + freespace =lvm_vg_get_mda_free (vg);return _size64_disp (rh, mem, field, &freespace, private); }
Signature · 1 line
1.6.0.6
PATCH 26/30 Update a few lvseg field display functions to call liblvm 'get' functions.
Update stripes, stripe_size, and region_size to call liblvm 'get' functions. These functions are simple dereferences, so we adjust the data pointer arg to the FIELD macro so that we get the lv_segment pointer in the 'data' arg of the 'disp' functions. Note that the liblvm 'get' functions do not show up in this patch - this is because 'get' functions with simple dereferences were autogenerated in an earlier patch.
Should be no functional change.
--- lib/report/columns.h | 10 +++++----- lib/report/report.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-)
lib/report/columns.h +5 -5
@@ -116,11 +116,11 @@ FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, "vg_mda_size", "Size of smallest metadata area for this VG in current units.") FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment.") -FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.") -FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize", "For stripes, amount of data placed on one device before switching to the next.") -FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripe_size", "For stripes, amount of data placed on one device before switching to the next.") -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "regionsize", "For mirrors, the unit of data copied when synchronising devices.") -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "region_size", "For mirrors, the unit of data copied when synchronising devices.") +FIELD(SEGS, seg, NUM, "#Str", list, 4, stripes, "stripes", "Number of stripes or mirror legs.") +FIELD(SEGS, seg, NUM, "Stripe", list, 6, stripesize, "stripesize", "For stripes, amount of data placed on one device before switching to the next.") +FIELD(SEGS, seg, NUM, "Stripe", list, 6, stripesize, "stripe_size", "For stripes, amount of data placed on one device before switching to the next.") +FIELD(SEGS, seg, NUM, "Region", list, 6, regionsize, "regionsize", "For mirrors, the unit of data copied when synchronising devices.") +FIELD(SEGS, seg, NUM, "Region", list, 6, regionsize, "region_size", "For mirrors, the unit of data copied when synchronising devices.") FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunksize", "For snapshots, the unit of data used when tracking changes.") FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunk_size", "For snapshots, the unit of data used when tracking changes.")FIELD (SEGS , seg,NUM ,"Start" , list,5 , segstart,"seg_start" ,"Offset within the LV to the start of the segment in current units." )
lib/report/report.c +36 -0
@@ -760,6 +760,42 @@ static int _segsize_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &size, private); } +static int _stripes_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct lv_segment *seg = (const struct lv_segment *) data; +uint32_t value; + + value =lvm_lvseg_get_stripes (seg); + +return _uint32_disp (rh, mem, field, &value, private); +} + +static int _stripesize_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct lv_segment *seg = (const struct lv_segment *) data; +uint32_t size; + + size =lvm_lvseg_get_stripe_size (seg); + +return _size32_disp (rh, mem, field, &size, private); +} + +static int _regionsize_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct lv_segment *seg = (const struct lv_segment *) data; +uint32_t size; + + size =lvm_lvseg_get_region_size (seg); + +return _size32_disp (rh, mem, field, &size, private); +} +static int _chunksize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
PATCH 27/30 Update chunksize_disp to call liblvm 'get' function.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 8 ++++++-- lib/report/report.c | 5 +---- 2 files changed, 7 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +6 -2
@@ -914,8 +914,12 @@ int lvm_lvseg_set_region_size(lvseg_t *lvseg, const uint64_t value)*/ uint64_t lvm_lvseg_get_chunk_size (const lvseg_t *lvseg) { -/* FIXME: implement function body */ -return 0 ; +uint64_t size; +if (lv_is_cow (lvseg->lv)) + size = (uint64_t )find_cow (lvseg->lv)->chunk_size; +else + size =UINT64_C (0 ); +return size; }int lvm_lvseg_set_chunk_size (lvseg_t *lvseg,const uint64_t value) {
lib/report/report.c +1 -4
@@ -803,10 +803,7 @@ static int _chunksize_disp(struct dm_report *rh, struct dm_pool *mem,const struct lv_segment *seg = (const struct lv_segment *) data;uint64_t size; -if (lv_is_cow (seg->lv)) - size = (uint64_t )find_cow (seg->lv)->chunk_size; -else - size =UINT64_C (0 ); + size =lvm_lvseg_get_chunk_size (seg);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 28/30 Update segstart_disp and segstartpe_disp to call liblvm 'get' functions.
Should be no functional change.
--- lib/report/lvm_object_prop.c | 6 ++---- lib/report/report.c | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-)
lib/report/lvm_object_prop.c +2 -4
@@ -932,8 +932,7 @@ int lvm_lvseg_set_chunk_size(lvseg_t *lvseg, const uint64_t value)*/ uint64_t lvm_lvseg_get_start (const lvseg_t *lvseg) { -/* FIXME: implement function body */ -return 0 ; +return (uint64_t ) lvseg->le * lvseg->lv->vg->extent_size; }int lvm_lvseg_set_start (lvseg_t *lvseg,const uint64_t value) {
@@ -946,8 +945,7 @@ int lvm_lvseg_set_start(lvseg_t *lvseg, const uint64_t value)*/ uint64_t lvm_lvseg_get_start_pe (const lvseg_t *lvseg) { -/* FIXME: implement function body */ -return 0 ; +return lvseg->le; }int lvm_lvseg_set_start_pe (lvseg_t *lvseg,const uint64_t value) {
lib/report/report.c +5 -2
@@ -732,7 +732,7 @@ static int _segstart_disp(struct dm_report *rh, struct dm_pool *mem,const struct lv_segment *seg = (const struct lv_segment *) data;uint64_t start; - start = (uint64_t ) seg->le * seg->lv->vg->extent_size; + start =lvm_lvseg_get_start (seg);return _size64_disp (rh, mem, field, &start, private); }
@@ -744,8 +744,11 @@ static int _segstartpe_disp(struct dm_report *rh, void *private __attribute((unused))) {const struct lv_segment *seg = (const struct lv_segment *) data; +uint32_t start; -return dm_report_field_uint32 (rh, field, &seg->le); + start =lvm_lvseg_get_start_pe (seg); + +return dm_report_field_uint32 (rh, field, &start); } static int _segsize_disp(struct dm_report *rh, struct dm_pool *mem,
Signature · 1 line
1.6.0.6
PATCH 29/30 Update segsize_disp to call liblvm 'get' function.
No functional change.
--- lib/report/lvm_object_prop.c | 3 +-- lib/report/report.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/report/lvm_object_prop.c +1 -2
@@ -958,8 +958,7 @@ int lvm_lvseg_set_start_pe(lvseg_t *lvseg, const uint64_t value)*/ uint64_t lvm_lvseg_get_size (const lvseg_t *lvseg) { -/* FIXME: implement function body */ -return 0 ; +return (uint64_t ) lvseg->len * lvseg->lv->vg->extent_size; }int lvm_lvseg_set_size (lvseg_t *lvseg,const uint64_t value) {
lib/report/report.c +1 -1
@@ -758,7 +758,7 @@ static int _segsize_disp(struct dm_report *rh, struct dm_pool *mem,const struct lv_segment *seg = (const struct lv_segment *) data;uint64_t size; - size = (uint64_t ) seg->len * seg->lv->vg->extent_size; + size =lvm_lvseg_get_size (seg);return _size64_disp (rh, mem, field, &size, private); }
Signature · 1 line
1.6.0.6
PATCH 30/30 Update pvseg_start and pvseg_size fields to have a disp function calling liblvm
Call into liblvm 'get' functions from 'disp' functions.
Note that the 'get' functions were some of the simple ones autogenerated by the perl script in an earlier patch.
Should be no functional change.
--- lib/report/columns.h | 4 ++-- lib/report/report.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-)
lib/report/columns.h +2 -2
@@ -130,6 +130,6 @@ FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags", "Tags, if any.") FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, "seg_pe_ranges", "Ranges of Physical Extents of underlying devices in command line format.") FIELD(SEGS, seg, STR, "Devices", list, 7, devices, "devices", "Underlying devices used with starting extent numbers.") -FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.") -FIELD (PVSEGS , pvseg,NUM ,"SSize" , len,5 , uint32,"pvseg_size" ,"Number of extents in segment." ) +FIELD(PVSEGS, pvseg, NUM, "Start", list, 5, pvsegstart, "pvseg_start", "Physical Extent number of start of segment.") +FIELD (PVSEGS , pvseg,NUM ,"SSize" , list,5 , pvsegsize,"pvseg_size" ,"Number of extents in segment." )/* *INDENT-ON* */
lib/report/report.c +24 -0
@@ -811,6 +811,30 @@ static int _chunksize_disp(struct dm_report *rh, struct dm_pool *mem,return _size64_disp (rh, mem, field, &size, private); } +static int _pvsegstart_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct pv_segment *pvseg = (const struct pv_segment *) data; +uint32_t start; + + start =lvm_pvseg_get_start (pvseg); + +return _uint32_disp (rh, mem, field, &start, private); +} + +static int _pvsegsize_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct pv_segment *pvseg = (const struct pv_segment *) data; +uint32_t value; + + value =lvm_pvseg_get_size (pvseg); + +return _uint32_disp (rh, mem, field, &value, private); +} +static int _originsize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.6.0.6
cover : liblvm object property baseline, take2
In reply to Dave WysochanskiFYI - I have these patches rebased to Milan's latest lv / snapshot counting patches (nice cleanup Milan!). I won't spam the list but if anyone wants them just let me know.
The new patches now apply on:
commit dc205333cd46770e5ca1a390a6b8fef1f584939a
Author: Milan Broz <[email protected]> Date: Wed May 13 21:29:10 2009 +0000
Check max_lv on only place and force the check only for new volume.