master - reporting: Add devtypes command.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aa98f4b97e4d8e5e41b77d43c9f594a0cc2e1d4e Commit: aa98f4b97e4d8e5e41b77d43c9f594a0cc2e1d4e Parent: d1bcb21e02a33a03795c2e35bd4d16ea67107c5d Author: Alasdair G Kergon <[email protected]> AuthorDate: Tue Sep 17 23:55:44 2013 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Tue Sep 17 23:55:44 2013 +0100
reporting: Add devtypes command.
Add internal devtypes reporting command to display built-in recognised block device types. (The output does not include any additional types added by a configuration file.)
Device Types Fields
-------------------
devtype_all - All fields in this section.
devtype_name - Name of Device Type exactly as it appears in /proc/devices.
devtype_max_partitions - Maximum number of partitions. (How many device minor numbers get reserved for each device.)
devtype_description - Description of Device Type.
DevType MaxParts Description
aoe 16 ATA over Ethernet
ataraid 16 ATA Raid
bcache 1 bcache block device cache
blkext 1 Extended device partitions
...
--- WHATS_NEW | 1 + include/.symlinks.in | 1 + lib/config/config_settings.h | 3 ++ lib/config/defaults.h | 3 ++ lib/report/properties.c | 1 - lib/report/report.c | 54 +++++++++++++++++++++++++++++++++++++++++- lib/report/report.h | 14 ++++++---- man/lvm.8.in | 2 + tools/commands.h | 24 ++++++++++++++++++ tools/reporter.c | 26 ++++++++++++++++++++ 10 files changed, 121 insertions(+), 8 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.101 - =================================== + Add devtypes report command to display built-in recognised block device types. Fix CC Makefile override which had reverted to using built-in value. (2.02.75) Recognise bcache block devices in filter (experimental). Run lvm2-activation-net after lvm2-activation service to prevent parallel run.
include/.symlinks.in +1 -0
@@ -16,6 +16,7 @@ @top_srcdir@/lib/device/dev-cache.h @top_srcdir@/lib/device/dev-type.h @top_srcdir@/lib/device/device.h + at top_srcdir@/lib/device/device-types.h @top_srcdir@/lib/display/display.h @top_srcdir@/lib/filters/filter.h @top_srcdir@/lib/format1/format1.h
lib/config/config_settings.h +3 -0
@@ -209,6 +209,9 @@ cfg(report_separator_CFG, "separator", report_CFG_SECTION, 0, CFG_TYPE_STRING, D cfg(report_prefixes_CFG, "prefixes", report_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REP_PREFIXES, vsn(2, 2, 36), NULL) cfg(report_quoted_CFG, "quoted", report_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REP_QUOTED, vsn(2, 2, 39), NULL) cfg(report_colums_as_rows_CFG, "colums_as_rows", report_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_REP_COLUMNS_AS_ROWS, vsn(1, 0, 0), NULL) +cfg(report_devtypes_sort_CFG, "devtypes_sort", report_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DEVTYPES_SORT, vsn(2, 2, 101), NULL) +cfg(report_devtypes_cols_CFG, "devtypes_cols", report_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DEVTYPES_COLS, vsn(2, 2, 101), NULL) +cfg(report_devtypes_cols_verbose_CFG, "devtypes_cols_verbose", report_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DEVTYPES_COLS_VERB, vsn(2, 2, 101), NULL) cfg(report_lvs_sort_CFG, "lvs_sort", report_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_LVS_SORT, vsn(1, 0, 0), NULL) cfg(report_lvs_cols_CFG, "lvs_cols", report_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_LVS_COLS, vsn(1, 0, 0), NULL)cfg (report_lvs_cols_verbose_CFG,"lvs_cols_verbose" , report_CFG_SECTION,0 ,CFG_TYPE_STRING ,DEFAULT_LVS_COLS_VERB ,vsn (1 ,0 ,0 ),NULL )
lib/config/defaults.h +3 -0
@@ -165,18 +165,21 @@#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"#define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size"#define DEFAULT_PVSEGS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pvseg_start,pvseg_size" +#define DEFAULT_DEVTYPES_COLS "devtype_name,devtype_max_partitions,devtype_description"#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,pool_lv,origin,data_percent,metadata_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid,lv_profile"#define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid,vg_profile"#define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,dev_size,pv_uuid"#define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize"#define DEFAULT_PVSEGS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pvseg_start,pvseg_size,lv_name,seg_start_pe,segtype,seg_pe_ranges" +#define DEFAULT_DEVTYPES_COLS_VERB "devtype_name,devtype_max_partitions,devtype_description"#define DEFAULT_LVS_SORT "vg_name,lv_name"#define DEFAULT_VGS_SORT "vg_name"#define DEFAULT_PVS_SORT "pv_name"#define DEFAULT_SEGS_SORT "vg_name,lv_name,seg_start"#define DEFAULT_PVSEGS_SORT "pv_name,pvseg_start" +#define DEFAULT_DEVTYPES_SORT "devtype_name"#define DEFAULT_MIRROR_DEVICE_FAULT_POLICY "remove"#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
lib/report/properties.c +0 -1
@@ -331,7 +331,6 @@ GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe) GET_PVSEG_NUM_PROPERTY_FN(pvseg_size, (SECTOR_SIZE * pvseg->len))#define _pvseg_size_set prop_not_implemented_set -struct lvm_property_type _properties[] = { #include "columns.h" {0 ,"" ,0 ,0 ,0 , { .integer =0 }, prop_not_implemented_get, prop_not_implemented_set },
lib/report/report.c +53 -1
110 lines not on this page · raw message
lib/report/report.h +8 -6
@@ -19,12 +19,13 @@#include "metadata-exported.h" typedef enum { -LVS =1 , -PVS =2 , -VGS =4 , -SEGS =8 , -PVSEGS =16 , -LABEL =32 +LVS =1 , +PVS =2 , +VGS =4 , +SEGS =8 , +PVSEGS =16 , +LABEL =32 , +DEVTYPES =64 }report_type_t ;struct field ;
@@ -41,6 +42,7 @@ void report_free(void *handle);int report_object (void *handle,struct volume_group *vg,struct logical_volume *lv,struct physical_volume *pv,struct lv_segment *seg,struct pv_segment *pvseg); +int report_devtypes (void *handle);int report_output (void *handle);#endif
man/lvm.8.in +2 -0
@@ -46,6 +46,8 @@ being created in the filesystem for them. \fBdumpconfig\fP \(em Display the configuration information after loading \fBlvm.conf\fP(5) and any other configuration files. .TP +\fBdevtypes\fP \(dm Display the recognised built-in block device types. +.TP \fBformats\fP \(em Display recognised metadata formats. .TP \fBhelp\fP \(em Display the help text.
tools/commands.h +24 -0
@@ -28,6 +28,30 @@ xx(e2fsadm,extents_ARG, size_ARG, nofsck_ARG, test_ARG) *********/ +xx (devtypes, +"Display recognised built-in block device types" , +PERMITTED_READ_ONLY , +"devtypes" "\n" +"\t[--aligned]\n" +"\t[-d|--debug]\n" +"\t[-h|--help]\n" +"\t[--nameprefixes]\n" +"\t[--noheadings]\n" +"\t[--nosuffix]\n" +"\t[-o|--options [+]Field[,Field]]\n" +"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" +"\t[--rows]\n" +"\t[--separator Separator]\n" +"\t[--unbuffered]\n" +"\t[--unquoted]\n" +"\t[-v|--verbose]\n" +"\t[--version]" "\n" , + + aligned_ARG, nameprefixes_ARG, + noheadings_ARG, nosuffix_ARG, options_ARG, + rows_ARG, separator_ARG, sort_ARG, + unbuffered_ARG, unquoted_ARG) + xx(dumpconfig, "Dump configuration", PERMITTED_READ_ONLY,
tools/reporter.c +26 -0
@@ -16,6 +16,17 @@#include "tools.h" #include "report.h" +static int _process_each_devtype (struct cmd_context *cmd,int argc,void *handle) +{ +if (argc) +log_warn ("WARNING: devtypes currently ignores command line arguments." ); + +if (!report_devtypes (handle)) + return_ECMD_FAILED; + +return ECMD_PROCESSED ; +} +static int _vgs_single (struct cmd_context *cmd __attribute__((unused)),const char *vg_name,struct volume_group *vg,void *handle)
@@ -235,6 +246,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type == PVSEGS) ? 1 : 0;switch (report_type) { +case DEVTYPES : + keys =find_config_tree_str (cmd, report_devtypes_sort_CFG,NULL ); +if (!arg_count (cmd, verbose_ARG)) + options =find_config_tree_str (cmd, report_devtypes_cols_CFG,NULL ); +else + options =find_config_tree_str (cmd, report_devtypes_cols_verbose_CFG,NULL ); +break ;case LVS : keys =find_config_tree_str (cmd, report_lvs_sort_CFG,NULL );if (!arg_count (cmd, verbose_ARG))
@@ -350,6 +368,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type =LVS ;switch (report_type) { +case DEVTYPES : + r =_process_each_devtype (cmd, argc, report_handle); +break ;case LVS : r =process_each_lv (cmd, argc, argv,0 , report_handle, &_lvs_single);
@@ -418,3 +439,8 @@ int pvs(struct cmd_context *cmd, int argc, char **argv)return _report (cmd, argc, argv, type); } + +int devtypes (struct cmd_context *cmd,int argc,char **argv) +{ +return _report (cmd, argc, argv,DEVTYPES ); +}