Add lvm vg properties for lvm2app.
cover Add lvm vg properties for lvm2app.
This patchset is a rebase and redo of earlier patchsets posted to implement generic functions to query any value of a field in an lvm report. The patchset extends the reporting infrastructure and then adds a generic lvm2app structure and function to return any vg-based report field.
PATCH 1/11 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.
--- lib/metadata/metadata.c | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/metadata/metadata.h | 4 ++++ lib/report/report.c | 37 ++++--------------------------------- 3 files changed, 50 insertions(+), 33 deletions(-)
lib/metadata/metadata.c +42 -0
@@ -1217,6 +1217,48 @@ int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies)return 1 ; } +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; +} + +uint64_t vg_mda_size (const struct volume_group *vg) +{ +return find_min_mda_size (&vg->fid->metadata_areas_in_use); +} + +uint64_t vg_mda_free (const struct volume_group *vg) +{ +uint64_t freespace =UINT64_MAX , mda_free; +struct metadata_area *mda; + + dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) { +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 vg_set_extent_size (struct volume_group *vg,uint32_t new_size) {uint32_t old_size = vg->extent_size;
lib/metadata/metadata.h +4 -0
@@ -416,4 +416,8 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,int vg_mark_partial_lvs (struct volume_group *vg);int is_mirror_image_removable (struct logical_volume *mimage_lv,void *baton); +uint64_t find_min_mda_size (struct dm_list *mdas); +uint64_t vg_mda_size (const struct volume_group *vg); +uint64_t vg_mda_free (const struct volume_group *vg); +#endif
lib/report/report.c +4 -33
@@ -958,25 +958,6 @@ 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)
@@ -987,7 +968,7 @@ static int _pvmdasize_disp(struct dm_report *rh, struct dm_pool *mem,/* 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 =find_min_mda_size (&info->mdas);return _size64_disp (rh, mem, field, &min_mda_size, private); }
@@ -999,7 +980,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_in_use); + min_mda_size =vg_mda_size (vg);return _size64_disp (rh, mem, field, &min_mda_size, private); }
@@ -1009,19 +990,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_in_use) { -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 =vg_mda_free (vg);return _size64_disp (rh, mem, field, &freespace, private); }
Signature · 1 line
1.7.2.1
PATCH 2/11 Add 'writeable' field to columns.h
In reply to Dave Wysochanski--- lib/report/columns.h | 152 +++++++++++++++++++++++++------------------------- lib/report/report.c | 2 +- 2 files changed, 78 insertions(+), 76 deletions(-)
lib/report/columns.h +77 -75
@@ -52,87 +52,89 @@* struct dm_report_field_type. * 9. Description of field. This is a brief (ideally <= 52 chars) description * of the field used in the reporting commands. +* 10. Writeable field. If the field is writeable, a 'set' function must be +* defined. */ /* *INDENT-OFF* */ -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, "Path", lvid, 4, lvpath, "lv_path", "Full pathname for LV.") -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, "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.") -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, "#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.") -FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.") -FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent", "For mirrors and pvmove, current percentage in-sync.") -FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv", "For pvmove, Source PV of temporary LV created by pvmove.") -FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, "convert_lv", "For lvconvert, Name of temporary LV created by lvconvert.") -FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.") -FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.") -FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.") +FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier.", 0) +FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name", "Name. LVs created for internal use are enclosed in brackets.", 0) +FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, "lv_path", "Full pathname for LV.", 0) +FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr", "Various attributes - see man page.", 0) +FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major", "Persistent major number or -1 if not persistent.", 0) +FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor", "Persistent minor number or -1 if not persistent.", 0) +FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, "lv_read_ahead", "Read ahead setting in current units.", 0) +FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major", "Currently assigned major number or -1 if LV is not active.", 0) +FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, "lv_kernel_minor", "Currently assigned minor number or -1 if LV is not active.", 0) +FIELD(LVS, lv, NUM, "KRahead", lvid, 7, lvkreadahead, "lv_kernel_read_ahead", "Currently-in-use read ahead setting in current units.", 0) +FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size", "Size of LV in current units.", 0) +FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count", "Number of segments in LV.", 0) +FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin", "For snapshots, the origin device of this LV.", 0) +FIELD(LVS, lv, NUM, "OSize", lvid, 5, originsize, "origin_size", "For snapshots, the size of the origin device of this LV.", 0) +FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.", 0) +FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent", "For mirrors and pvmove, current percentage in-sync.", 0) +FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv", "For pvmove, Source PV of temporary LV created by pvmove.", 0) +FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, "convert_lv", "For lvconvert, Name of temporary LV created by lvconvert.", 0) +FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.", 0) +FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.", 0) +FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.", 0) -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", 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.") +FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.", 0) +FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.", 0) +FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, "dev_size", "Size of underlying device in current units.", 0) +FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.", 0) +FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.", 0) +FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.", 0) -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, "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.") -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, 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.") -FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, "pv_mda_used_count", "Number of metadata areas in use on this device.") +FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.", 0) +FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current units.", 0) +FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.", 0) +FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used", "Total amount of allocated space in current units.", 0) +FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes - see man page.", 0) +FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.", 0) +FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.", 0) +FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.", 0) +FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.", 0) +FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, "pv_mda_used_count", "Number of metadata areas in use on this device.", 0) -FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.") -FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.") -FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name", "Name.") -FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - see man page.") -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, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.") -FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, "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, 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 on this VG.") -FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, "vg_mda_used_count", "Number of metadata areas in use on this VG.") -FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata area space for this VG in current units.") -FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, "vg_mda_size", "Size of smallest metadata area for this VG in current units.") -FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, "vg_mda_copies", "Target number of in use metadata areas in the VG.") +FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.", 0) +FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.", 0) +FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name", "Name.", 0) +FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - see man page.", 0) +FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size", "Total size of VG in current units.", 0) +FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free", "Total amount of free space in current units.", 0) +FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid", "System ID indicating when and where it was created.", 0) +FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size", "Size of Physical Extents in current units.", 0) +FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count", "Total number of Physical Extents.", 0) +FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count", "Total number of unallocated Physical Extents.", 0) +FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.", 0) +FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.", 0) +FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.", 0) +FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.", 0) +FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, "snap_count", "Number of snapshots.", 0) +FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.", 0) +FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.", 0) +FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas on this VG.", 0) +FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, "vg_mda_used_count", "Number of metadata areas in use on this VG.", 0) +FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata area space for this VG in current units.", 0) +FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, "vg_mda_size", "Size of smallest metadata area for this VG in current units.", 0) +FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, "vg_mda_copies", "Target number of in use metadata areas in the VG.", 0) -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, "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.") -FIELD(SEGS, seg, NUM, "Start", list, 5, segstartpe, "seg_start_pe", "Offset within the LV to the start of the segment in physical extents.") -FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size", "Size of segment in current units.") -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(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment.", 0) +FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.", 0) +FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize", "For stripes, amount of data placed on one device before switching to the next.", 0) +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.", 0) +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "regionsize", "For mirrors, the unit of data copied when synchronising devices.", 0) +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "region_size", "For mirrors, the unit of data copied when synchronising devices.", 0) +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunksize", "For snapshots, the unit of data used when tracking changes.", 0) +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunk_size", "For snapshots, the unit of data used when tracking changes.", 0) +FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start", "Offset within the LV to the start of the segment in current units.", 0) +FIELD(SEGS, seg, NUM, "Start", list, 5, segstartpe, "seg_start_pe", "Offset within the LV to the start of the segment in physical extents.", 0) +FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size", "Size of segment in current units.", 0) +FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags", "Tags, if any.", 0) +FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, "seg_pe_ranges", "Ranges of Physical Extents of underlying devices in command line format.", 0) +FIELD(SEGS, seg, STR, "Devices", list, 7, devices, "devices", "Underlying devices used with starting extent numbers.", 0) -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", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.", 0) +FIELD (PVSEGS , pvseg,NUM ,"SSize" , len,5 , uint32,"pvseg_size" ,"Number of extents in segment." ,0 )/* *INDENT-ON* */
lib/report/report.c +1 -1
@@ -1195,7 +1195,7 @@ static const struct dm_report_object_type _report_types[] = {#define STR DM_REPORT_FIELD_TYPE_STRING#define NUM DM_REPORT_FIELD_TYPE_NUMBER -#define FIELD (type, strct, sorttype, head, field, width, func, id, desc) \ +#define FIELD (type, strct, sorttype, head, field, width, func, id, desc, writeable) \ {type, sorttype, offsetof(type_ ## strct, field), width, \ id, head, &_ ## func ## _disp, desc},
Signature · 1 line
1.7.2.1
PATCH 2/11 Add 'writeable' field to columns.h
Quoted 2 lines · Dave Wysochanski
+ * 10. Writeable field. If the field is writeable, a 'set' function must be
+ * defined.
Let's do this like we did in args.h with a flags field, to reduce the churn if we decide to add more properties.
10. Flags.
FIELD_MODIFIABLE. A '_set' function exists to change the field's value.
The function name is derived in a similar way to item 7 above.
Alasdair
PATCH 3/11 Remove explicit double quotes from columns.h 'id' entries.
In reply to Dave WysochanskiThe '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.
--- lib/report/columns.h | 150 +++++++++++++++++++++++++------------------------- lib/report/report.c | 2 +- 2 files changed, 76 insertions(+), 76 deletions(-)
lib/report/columns.h +75 -75
@@ -57,84 +57,84 @@*/ /* *INDENT-OFF* */ -FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier.", 0) -FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name", "Name. LVs created for internal use are enclosed in brackets.", 0) -FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, "lv_path", "Full pathname for LV.", 0) -FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr", "Various attributes - see man page.", 0) -FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major", "Persistent major number or -1 if not persistent.", 0) -FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor", "Persistent minor number or -1 if not persistent.", 0) -FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, "lv_read_ahead", "Read ahead setting in current units.", 0) -FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major", "Currently assigned major number or -1 if LV is not active.", 0) -FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, "lv_kernel_minor", "Currently assigned minor number or -1 if LV is not active.", 0) -FIELD(LVS, lv, NUM, "KRahead", lvid, 7, lvkreadahead, "lv_kernel_read_ahead", "Currently-in-use read ahead setting in current units.", 0) -FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size", "Size of LV in current units.", 0) -FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count", "Number of segments in LV.", 0) -FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin", "For snapshots, the origin device of this LV.", 0) -FIELD(LVS, lv, NUM, "OSize", lvid, 5, originsize, "origin_size", "For snapshots, the size of the origin device of this LV.", 0) -FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.", 0) -FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent", "For mirrors and pvmove, current percentage in-sync.", 0) -FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv", "For pvmove, Source PV of temporary LV created by pvmove.", 0) -FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, "convert_lv", "For lvconvert, Name of temporary LV created by lvconvert.", 0) -FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.", 0) -FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.", 0) -FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.", 0) +FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, lv_uuid, "Unique identifier.", 0) +FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name. LVs created for internal use are enclosed in brackets.", 0) +FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV.", 0) +FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0) +FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0) +FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0) +FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0) +FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, lv_kernel_major, "Currently assigned major number or -1 if LV is not active.", 0) +FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, lv_kernel_minor, "Currently assigned minor number or -1 if LV is not active.", 0) +FIELD(LVS, lv, NUM, "KRahead", lvid, 7, lvkreadahead, lv_kernel_read_ahead, "Currently-in-use read ahead setting in current units.", 0) +FIELD(LVS, lv, NUM, "LSize", size, 5, size64, lv_size, "Size of LV in current units.", 0) +FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, seg_count, "Number of segments in LV.", 0) +FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, origin, "For snapshots, the origin device of this LV.", 0) +FIELD(LVS, lv, NUM, "OSize", lvid, 5, originsize, origin_size, "For snapshots, the size of the origin device of this LV.", 0) +FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, snap_percent, "For snapshots, the percentage full if LV is active.", 0) +FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, copy_percent, "For mirrors and pvmove, current percentage in-sync.", 0) +FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, move_pv, "For pvmove, Source PV of temporary LV created by pvmove.", 0) +FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, convert_lv, "For lvconvert, Name of temporary LV created by lvconvert.", 0) +FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0) +FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, mirror_log, "For mirrors, the LV holding the synchronisation log.", 0) +FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, modules, "Kernel device-mapper modules required for this LV.", 0) -FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.", 0) -FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.", 0) -FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, "dev_size", "Size of underlying device in current units.", 0) -FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.", 0) -FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.", 0) -FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.", 0) +FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, pv_fmt, "Type of metadata.", 0) +FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, pv_uuid, "Unique identifier.", 0) +FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, dev_size, "Size of underlying device in current units.", 0) +FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, pv_name, "Name.", 0) +FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, pv_mda_free, "Free metadata area space on this device in current units.", 0) +FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, pv_mda_size, "Size of smallest metadata area on this device in current units.", 0) -FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.", 0) -FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current units.", 0) -FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.", 0) -FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used", "Total amount of allocated space in current units.", 0) -FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes - see man page.", 0) -FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.", 0) -FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.", 0) -FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.", 0) -FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, "pv_mda_count", "Number of metadata areas on this device.", 0) -FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, "pv_mda_used_count", "Number of metadata areas in use on this device.", 0) +FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, pe_start, "Offset to the start of data on the underlying device.", 0) +FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, pv_size, "Size of PV in current units.", 0) +FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, pv_free, "Total amount of unallocated space in current units.", 0) +FIELD(PVS, pv, NUM, "Used", id, 4, pvused, pv_used, "Total amount of allocated space in current units.", 0) +FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, pv_attr, "Various attributes - see man page.", 0) +FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, pv_pe_count, "Total number of Physical Extents.", 0) +FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, pv_pe_alloc_count, "Total number of allocated Physical Extents.", 0) +FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, pv_tags, "Tags, if any.", 0) +FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, pv_mda_count, "Number of metadata areas on this device.", 0) +FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, pv_mda_used_count, "Number of metadata areas in use on this device.", 0) -FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.", 0) -FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.", 0) -FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name", "Name.", 0) -FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - see man page.", 0) -FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size", "Total size of VG in current units.", 0) -FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free", "Total amount of free space in current units.", 0) -FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid", "System ID indicating when and where it was created.", 0) -FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size", "Size of Physical Extents in current units.", 0) -FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count", "Total number of Physical Extents.", 0) -FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count", "Total number of unallocated Physical Extents.", 0) -FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.", 0) -FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.", 0) -FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.", 0) -FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.", 0) -FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, "snap_count", "Number of snapshots.", 0) -FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.", 0) -FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.", 0) -FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, "vg_mda_count", "Number of metadata areas on this VG.", 0) -FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, "vg_mda_used_count", "Number of metadata areas in use on this VG.", 0) -FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, "vg_mda_free", "Free metadata area space for this VG in current units.", 0) -FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, "vg_mda_size", "Size of smallest metadata area for this VG in current units.", 0) -FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, "vg_mda_copies", "Target number of in use metadata areas in the VG.", 0) +FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, vg_fmt, "Type of metadata.", 0) +FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, vg_uuid, "Unique identifier.", 0) +FIELD(VGS, vg, STR, "VG", name, 4, string, vg_name, "Name.", 0) +FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, vg_attr, "Various attributes - see man page.", 0) +FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, vg_size, "Total size of VG in current units.", 0) +FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, vg_free, "Total amount of free space in current units.", 0) +FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, vg_sysid, "System ID indicating when and where it was created.", 0) +FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, vg_extent_size, "Size of Physical Extents in current units.", 0) +FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, vg_extent_count, "Total number of Physical Extents.", 0) +FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, vg_free_count, "Total number of unallocated Physical Extents.", 0) +FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, max_lv, "Maximum number of LVs allowed in VG or 0 if unlimited.", 0) +FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, max_pv, "Maximum number of PVs allowed in VG or 0 if unlimited.", 0) +FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, pv_count, "Number of PVs.", 0) +FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, lv_count, "Number of LVs.", 0) +FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, snap_count, "Number of snapshots.", 0) +FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, vg_seqno, "Revision number of internal metadata. Incremented whenever it changes.", 0) +FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, vg_tags, "Tags, if any.", 0) +FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, vg_mda_count, "Number of metadata areas on this VG.", 0) +FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, vg_mda_used_count, "Number of metadata areas in use on this VG.", 0) +FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, vg_mda_free, "Free metadata area space for this VG in current units.", 0) +FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, vg_mda_size, "Size of smallest metadata area for this VG in current units.", 0) +FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, vg_mda_copies, "Target number of in use metadata areas in the VG.", 0) -FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment.", 0) -FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.", 0) -FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize", "For stripes, amount of data placed on one device before switching to the next.", 0) -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.", 0) -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "regionsize", "For mirrors, the unit of data copied when synchronising devices.", 0) -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "region_size", "For mirrors, the unit of data copied when synchronising devices.", 0) -FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunksize", "For snapshots, the unit of data used when tracking changes.", 0) -FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunk_size", "For snapshots, the unit of data used when tracking changes.", 0) -FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start", "Offset within the LV to the start of the segment in current units.", 0) -FIELD(SEGS, seg, NUM, "Start", list, 5, segstartpe, "seg_start_pe", "Offset within the LV to the start of the segment in physical extents.", 0) -FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size", "Size of segment in current units.", 0) -FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags", "Tags, if any.", 0) -FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, "seg_pe_ranges", "Ranges of Physical Extents of underlying devices in command line format.", 0) -FIELD(SEGS, seg, STR, "Devices", list, 7, devices, "devices", "Underlying devices used with starting extent numbers.", 0) +FIELD(SEGS, seg, STR, "Type", list, 4, segtype, segtype, "Type of LV segment.", 0) +FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, stripes, "Number of stripes or mirror legs.", 0) +FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, stripesize, "For stripes, amount of data placed on one device before switching to the next.", 0) +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.", 0) +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, regionsize, "For mirrors, the unit of data copied when synchronising devices.", 0) +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, region_size, "For mirrors, the unit of data copied when synchronising devices.", 0) +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunksize, "For snapshots, the unit of data used when tracking changes.", 0) +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunk_size, "For snapshots, the unit of data used when tracking changes.", 0) +FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, seg_start, "Offset within the LV to the start of the segment in current units.", 0) +FIELD(SEGS, seg, NUM, "Start", list, 5, segstartpe, seg_start_pe, "Offset within the LV to the start of the segment in physical extents.", 0) +FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, seg_size, "Size of segment in current units.", 0) +FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, seg_tags, "Tags, if any.", 0) +FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, seg_pe_ranges, "Ranges of Physical Extents of underlying devices in command line format.", 0) +FIELD(SEGS, seg, STR, "Devices", list, 7, devices, devices, "Underlying devices used with starting extent numbers.", 0) -FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.", 0) -FIELD (PVSEGS , pvseg,NUM ,"SSize" , len,5 , uint32,"pvseg_size" ,"Number of extents in segment." ,0 ) +FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, pvseg_start, "Physical Extent number of start of segment.", 0) +FIELD (PVSEGS , pvseg,NUM ,"SSize" , len,5 , uint32, pvseg_size,"Number of extents in segment." ,0 )/* *INDENT-ON* */
lib/report/report.c +1 -1
@@ -1197,7 +1197,7 @@ static const struct dm_report_object_type _report_types[] = {#define NUM DM_REPORT_FIELD_TYPE_NUMBER#define FIELD (type, strct, sorttype, head, field, width, func, id, desc, writeable) \ {type, sorttype, offsetof(type_ ## strct, field), width, \ - id, head, &_ ## func ## _disp, desc}, + #id, head, &_ ## func ## _disp, desc},typedef struct physical_volume type_pv ;typedef struct logical_volume type_lv ;
Signature · 1 line
1.7.2.1
PATCH 3/11 Remove explicit double quotes from columns.h 'id' entries.
Quoted 2 lines · Dave Wysochanski
The 'id' entries in
columns.hare the report field names. Since these are unique, we'd like to use them in generation of 'get' / 'set' functions.
OK - as long we avoid namespace pollution as the resulting function names are not a factor in the choice of user-visible field name.
(If the fns are all local to a file it should be fine - otherwise it needs a new standard prefix.)
Alasdair
PATCH 4/11 Add macro definitions to report infrastructure for character arrays.
In reply to Dave WysochanskiRather than hard code the size of the field, use a #define. The #define will be needed in a future patch when we extend the reporting infrastructure to have 'get' and 'set' functions for each field, allowing lvm2app functions which query any report field.
--- libdm/libdevmapper.h | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
libdm/libdevmapper.h +7 -2
@@ -1048,14 +1048,19 @@ struct dm_report_field;#define DM_REPORT_FIELD_TYPE_STRING 0x00000010#define DM_REPORT_FIELD_TYPE_NUMBER 0x00000020 +#define DM_REPORT_FIELD_TYPE_ID_LEN 32 +#define DM_REPORT_FIELD_TYPE_HEADING_LEN 32 +struct dm_report ;struct dm_report_field_type {uint32_t type;/* object type id */ uint32_t flags;/* DM_REPORT_FIELD_* */ uint32_t offset;/* byte offset in the object */ int32_t width;/* default width */ -const char id[32 ];/* string used to specify the field */ -const char heading[32 ];/* string printed in header */ +/* string used to specify the field */ +const char id[DM_REPORT_FIELD_TYPE_ID_LEN ]; +/* string printed in header */ +const char heading[DM_REPORT_FIELD_TYPE_HEADING_LEN ];int (*report_fn)(struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private_data);
Signature · 1 line
1.7.2.1
PATCH 4/11 Add macro definitions to report infrastructure for character arrays.
Quoted 1 line · Dave Wysochanski
Rather than hard code the size of the field, use a #define.
OK, but we cannot change the 32 though without going through a libdevmapper API change.
Alasdair
PATCH 5/11 Add properties.[ch] to lib/report, defined based on columns.h.
In reply to Dave WysochanskiExtend the existing reporting infrastructure definitions and structures to include a 'get' and 'set' function for each field. We will provide a 'get' and 'set' function for each of these fields, which will be utilized by exported lvm2app functions.
Define a default _not_implemented 'get' and 'set' function that just sets an errno and returns 0. Future patches will actually implement the specific 'get' and 'set' functions for each property. For read-only properties, only the 'get' function will be implemented.
Define vg_get_property() function to query a property. We will call this from a lvm2app function.
--- include/.symlinks.in | 1 + lib/Makefile.in | 1 + lib/report/properties.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++ lib/report/properties.h | 37 ++++++++ 4 files changed, 265 insertions(+), 0 deletions(-) create mode 100644 lib/report/properties.c create mode 100644 lib/report/properties.h
include/.symlinks.in +1 -0
@@ -50,6 +50,7 @@ @top_builddir@/lib/misc/lvm-version.h @top_srcdir@/lib/misc/lvm-wrappers.h @top_srcdir@/lib/misc/sharedlib.h + at top_srcdir@/lib/report/properties.h @top_srcdir@/lib/report/report.h @top_srcdir@/lib/uuid/uuid.h @top_srcdir@/libdm/libdevmapper.h
lib/Makefile.in +1 -0
@@ -89,6 +89,7 @@ SOURCES =\ misc/lvm-wrappers.c \ misc/util.c \ mm/memlock.c \ + report/properties.c \ report/report.c \ striped/striped.c \ uuid/uuid.c \
lib/report/properties.c new file +226 -0
226 lines not on this page · raw message
lib/report/properties.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (C) 2010 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_PROPERTIES_H +#define _LVM_PROPERTIES_H + +#include "libdevmapper.h" +#include "lvm-types.h" +#include "metadata.h" + +#define LVM_PROPERTY_NAME_LEN DM_REPORT_FIELD_TYPE_ID_LEN + +struct lvm_property_type { +char id[LVM_PROPERTY_NAME_LEN ]; +unsigned is_writeable; +unsigned is_string; +union { +char *s_val; +uint64_t n_val; + } v; +int (*get) (void *obj,struct lvm_property_type *prop); +int (*set) (void *obj,struct lvm_property_type *prop); +}; + +int vg_get_property (struct volume_group *vg,struct lvm_property_type *prop); + +#endif
Signature · 1 line
1.7.2.1
PATCH 6/11 Add _vg_mda_copies_get and _vg_mda_copies_set.
In reply to Dave WysochanskiAdd the 'get' / 'set' functions for vg_mda_copies property. Since vg_mda_copies is a field that can be changed (see vgchange, etc), we add a 'set' function here and change the '0' to a '1' in the columns.h file.
--- lib/report/columns.h | 2 +- lib/report/properties.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)
lib/report/columns.h +1 -1
@@ -118,7 +118,7 @@ FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, vg_mda_count, "Number of metadata a FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, vg_mda_used_count, "Number of metadata areas in use on this VG.", 0) FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, vg_mda_free, "Free metadata area space for this VG in current units.", 0) FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, vg_mda_size, "Size of smallest metadata area for this VG in current units.", 0) -FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, vg_mda_copies, "Target number of in use metadata areas in the VG.", 0) +FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, vg_mda_copies, "Target number of in use metadata areas in the VG.", 1) FIELD(SEGS, seg, STR, "Type", list, 4, segtype, segtype, "Type of LV segment.", 0)FIELD (SEGS , seg,NUM ,"#Str" , area_count,4 , uint32, stripes,"Number of stripes or mirror legs." ,0 )
lib/report/properties.c +14 -2
@@ -147,8 +147,20 @@ static int _not_implemented(void *obj, struct lvm_property_type *prop)#define _vg_mda_free_set _not_implemented#define _vg_mda_size_get _not_implemented#define _vg_mda_size_set _not_implemented -#define _vg_mda_copies_get _not_implemented -#define _vg_mda_copies_set _not_implemented + +static int _vg_mda_copies_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =vg_mda_copies (vg); +return 1 ; +} + +static int _vg_mda_copies_set (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; +return vg_set_mda_copies (vg, prop->v.n_val); +}/* LVSEG */ #define _segtype_get _not_implemented
Signature · 1 line
1.7.2.1
PATCH 7/11 Add implementation for vg_mda_*_get functions.
In reply to Dave WysochanskiAdd 'get' function implementation for vg_mda_count, vg_mda_used_count, vg_mda_free, vg_mda_size. These are read-only properties so the 'set' functions are defined to the _not_implemented function.
Multiply SECTOR_SIZE to vg_mda_size to return the value in bytes.
--- lib/report/properties.c | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-)
lib/report/properties.c +31 -4
@@ -139,13 +139,40 @@ static int _not_implemented(void *obj, struct lvm_property_type *prop)#define _vg_seqno_set _not_implemented#define _vg_tags_get _not_implemented#define _vg_tags_set _not_implemented -#define _vg_mda_count_get _not_implemented +static int _vg_mda_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =vg_mda_count (vg); +return 1 ; +}#define _vg_mda_count_set _not_implemented -#define _vg_mda_used_count_get _not_implemented + +static int _vg_mda_used_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =vg_mda_used_count (vg); +return 1 ; +}#define _vg_mda_used_count_set _not_implemented -#define _vg_mda_free_get _not_implemented + +static int _vg_mda_free_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =vg_mda_free (vg); +return 1 ; +}#define _vg_mda_free_set _not_implemented -#define _vg_mda_size_get _not_implemented + +static int _vg_mda_size_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =SECTOR_SIZE *vg_mda_size (vg); +return 1 ; +}#define _vg_mda_size_set _not_implementedstatic int _vg_mda_copies_get (void *obj,struct lvm_property_type *prop)
Signature · 1 line
1.7.2.1
PATCH 7/11 Add implementation for vg_mda_*_get functions.
Quoted 3 lines · Dave Wysochanski
Add 'get' function implementation for
vg_mda_count,vg_mda_used_count,vg_mda_free,vg_mda_size. These are read-only properties so the 'set' functions are defined to the_not_implementedfunction.
They look rather similar to each other:)
You might be able to generate some of them from a template.
#define GET_SIMPLE_VG_PROPERTY_FN(...) ...
GET_SIMPLE_PROPERTY_FN(vg_mda_free, vg_mda_free(vg)) GET_SIMPLE_PROPERTY_FN(vg_mda_size, SECTOR_SIZE * vg_mda_size(vg))
Alasdair
PATCH 8/11 Add 'get' functions for various numeric vg fields.
In reply to Dave WysochanskiAdd '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.
Multiply SECTOR_SIZE inside _vg_size_get and _vg_free_get to return bytes instead of sectors.
--- lib/report/properties.c | 80 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 70 insertions(+), 10 deletions(-)
lib/report/properties.c +70 -10
@@ -113,29 +113,89 @@ static int _not_implemented(void *obj, struct lvm_property_type *prop)#define _vg_name_set _not_implemented#define _vg_attr_get _not_implemented#define _vg_attr_set _not_implemented -#define _vg_size_get _not_implemented +static int _vg_size_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =SECTOR_SIZE *vg_size (vg); +return 1 ; +}#define _vg_size_set _not_implemented -#define _vg_free_get _not_implemented +static int _vg_free_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =SECTOR_SIZE *vg_free (vg); +return 1 ; +}#define _vg_free_set _not_implemented#define _vg_sysid_get _not_implemented#define _vg_sysid_set _not_implemented#define _vg_extent_size_get _not_implemented#define _vg_extent_size_set _not_implemented -#define _vg_extent_count_get _not_implemented +static int _vg_extent_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->extent_count; +return 1 ; +}#define _vg_extent_count_set _not_implemented -#define _vg_free_count_get _not_implemented +static int _vg_free_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->free_count; +return 1 ; +}#define _vg_free_count_set _not_implemented -#define _max_lv_get _not_implemented +static int _max_lv_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->max_lv; +return 1 ; +}#define _max_lv_set _not_implemented -#define _max_pv_get _not_implemented +static int _max_pv_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->max_pv; +return 1 ; +}#define _max_pv_set _not_implemented -#define _pv_count_get _not_implemented +static int _pv_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->pv_count; +return 1 ; +}#define _pv_count_set _not_implemented -#define _lv_count_get _not_implemented +static int _lv_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =vg_visible_lvs (vg); +return 1 ; +}#define _lv_count_set _not_implemented -#define _snap_count_get _not_implemented +static int _snap_count_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val =snapshot_count (vg); +return 1 ; +}#define _snap_count_set _not_implemented -#define _vg_seqno_get _not_implemented +static int _vg_seqno_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.n_val = vg->seqno; +return 1 ; +}#define _vg_seqno_set _not_implemented#define _vg_tags_get _not_implemented#define _vg_tags_set _not_implemented
Signature · 1 line
1.7.2.1
PATCH 9/11 Add 'get' functions for a few vg string fields, vg_name and vg_fmt.
In reply to Dave WysochanskiAdd _vg_name_get and _vg_fmt_get functions.
--- lib/report/properties.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-)
lib/report/properties.c +17 -2
@@ -105,11 +105,26 @@ static int _not_implemented(void *obj, struct lvm_property_type *prop)#define _modules_set _not_implemented/* VG */ -#define _vg_fmt_get _not_implemented +static int _vg_fmt_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + +if (!vg->fid || !vg->fid->fmt) + prop->v.s_val =NULL ; +else + prop->v.s_val = (char *)vg->fid->fmt->name; +return 1 ; +}#define _vg_fmt_set _not_implemented#define _vg_uuid_get _not_implemented#define _vg_uuid_set _not_implemented -#define _vg_name_get _not_implemented +static int _vg_name_get (void *obj,struct lvm_property_type *prop) +{ +struct volume_group *vg = (struct volume_group *)obj; + + prop->v.s_val = (char *)vg->name; +return 1 ; +}#define _vg_name_set _not_implemented#define _vg_attr_get _not_implemented#define _vg_attr_set _not_implemented
Signature · 1 line
1.7.2.1
PATCH 10/11 Add lvm_vg_get_property() generic vg property function.
In reply to Dave WysochanskiAdd a generic VG property function to lvm2app. Call the internal library vg_get_property() function. If the property is a string strdup from the vg mempool.
--- liblvm/lvm2app.h | 42 ++++++++++++++++++++++++++++++++++++++++++ liblvm/lvm_vg.c | 19 +++++++++++++++++++ 2 files changed, 61 insertions(+), 0 deletions(-)
liblvm/lvm2app.h +42 -0
@@ -168,6 +168,22 @@ typedef struct lvm_str_list {const char *str; } lvm_str_list_t; +/** +* Property Value +* +* This structure defines a single LVM property value for an LVM object. +* The structures are returned by functions such as +* lvm_vg_get_property() and lvm_vg_set_property(). +*/ +typedef struct lvm_property_value { +unsigned is_writeable; +unsigned is_string; +union { +char *s_val; +uint64_t n_val; + } v; +}lvm_property_value_t ; +/*************************** generic lvm handling ***************************/ /** * Create a LVM handle.
@@ -848,6 +864,32 @@ uint64_t lvm_vg_get_max_lv(const vg_t vg);*/ struct dm_list *lvm_vg_get_tags (const vg_t vg); +/** +* Get the value of a VG property +* +* \memberof vg_t +* +* The memory allocated for a string property value is tied to the vg_t +* handle and will be released when lvm_vg_close() is called. +* +* Example: +* lvm_property_value value; +* +* if (lvm_vg_get_property(vg, "vg_mda_count", &value) < 0) { +* // handle error +* } +* if (value.is_string) +* printf(", value = %s\n", value.u.s_val); +* else +* printf(", value = %"PRIu64"\n", value.u.n_val); +* +* +* \return +* 0 (success) or -1 (failure). +*/ +int lvm_vg_get_property (vg_t vg,const char *name, +struct lvm_property_value *value); +/************************** logical volume handling *************************/ /**
liblvm/lvm_vg.c +19 -0
@@ -20,6 +20,7 @@#include "locking.h" #include "lvmcache.h" #include "lvm_misc.h" +#include "properties.h" int lvm_vg_add_tag (vg_t vg,const char *tag) {
@@ -341,6 +342,24 @@ const char *lvm_vg_get_name(const vg_t vg)return dm_pool_strndup (vg->vgmem, (const char *)vg->name,NAME_LEN +1 ); } + +int lvm_vg_get_property (vg_t vg,const char *name, +struct lvm_property_value *value) +{ +struct lvm_property_type prop; + +strncpy (prop.id, name,LVM_PROPERTY_NAME_LEN ); +if (!vg_get_property (vg, &prop)) +return -1 ; + value->is_writeable = prop.is_writeable; + value->is_string = prop.is_string; +if (value->is_string) + value->v.s_val =dm_pool_strdup (vg->vgmem, prop.v.s_val); +else + value->v.n_val = prop.v.n_val; +return 0 ; +} +struct dm_list *lvm_list_vg_names (lvm_t libh) {return get_vgnames ((struct cmd_context *)libh,0 );
Signature · 1 line
1.7.2.1
PATCH 11/11 Add tests for lvm_vg_get_property().
In reply to Dave Wysochanski--- test/api/test.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-)
test/api/test.c +34 -0
@@ -18,6 +18,7 @@#include <readline/readline.h> #include "lvm2app.h" +#include "libdevmapper.h" #define MAX_ARGS 64
@@ -91,6 +92,8 @@ static void _show_help(void) "Issue a lvm_config_override() with accept device filter\n");printf ("'vg_get_tags vgname': " "List the tags of a VG\n" ); +printf ("'vg_get_property vgname property_name': " +"Display the value of VG property\n" );printf ("'lv_get_tags vgname lvname': " "List the tags of a LV\n" ); printf("'vg_{add|remove}_tag vgname tag': "
@@ -546,6 +549,35 @@ static void _vg_tag(char **argv, int argc, int add) add ? "adding":"removing", argv[2], argv[1]); } +static void _vg_get_property (char **argv,int argc) +{ +vg_t vg; +struct lvm_property_value value; +int rc; + +if (argc <3 ) { +printf ("Please enter vgname, field_id\n" ); +return ; + } +if (!(vg =_lookup_vg_by_name (argv, argc))) +return ; + rc =lvm_vg_get_property (vg, argv[2 ], &value); +if (rc) +printf ("Error " ); +else +printf ("Success " ); +printf ("Obtaining value of property %s in VG %s" , + argv[2 ], argv[1 ]); +if (rc) { +printf ("\n" ); +return ; + } +if (value.is_string) +printf (", value = %s\n" , value.v.s_val); +else +printf (", value = %" PRIu64"\n" , value.v.n_val); +} +static void _lv_get_tags (char **argv,int argc) {lv_t lv;
@@ -796,6 +828,8 @@ static int lvmapi_test_shell(lvm_t libh)_vg_tag (argv, argc,0 ); }else if (!strcmp (argv[0 ],"vg_get_tags" )) {_vg_get_tags (argv, argc); + }else if (!strcmp (argv[0 ],"vg_get_property" )) { +_vg_get_property (argv, argc); }else if (!strcmp (argv[0 ],"lv_add_tag" )) {_lv_tag (argv, argc,1 ); }else if (!strcmp (argv[0 ],"lv_remove_tag" )) {
Signature · 1 line
1.7.2.1