Skip to contentSkip to conversation

master - libdm: report: introduce dm_report_group

PATCH Peter Rajnoha 1 participant 1 message Jun 20, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9c8f912ea79d9b836c814b3d12cc331de634617e
Commit:        9c8f912ea79d9b836c814b3d12cc331de634617e
Parent:        029f51e1a853297ca7246b75ac80cde9de23a2a4
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon May 2 14:21:05 2016 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Mon Jun 20 09:26:51 2016 +0200

libdm: report: introduce dm_report_group

This patch introduces DM report group (represented by dm_report_group structure) that is used to group several reports to make a whole. As a whole, all the reports in the group follow the same settings and/or formatting used on output and it controls that the output is properly ordered (e.g. the output from different reports is not interleaved which would break readability and/or syntax of target output format used for the whole group).

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

Quoted 1 line

From the naming used (dm_report_group_push/pop), it's clear the reports

are pushed onto a stack. The rule then is that only the report on top of the stack can be reported (that means calling dm_report_output). This way we make sure that the output is not interleaved and provides determinism and control over the output.

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

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

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

We can call dm_report_output directly anytime we need (with the only restriction that we can call dm_report_output only for the report that is currently on top of the group's stack). Or we don't need to call dm_report_output explicitly in which case all the reports in a stack are reported on output automatically once we call dm_report_group_destroy.

---
 WHATS_NEW_DM                        |    1 +
 libdm/.exported_symbols.DM_1_02_128 |    4 +
 libdm/libdevmapper.h                |   14 +++
 libdm/libdm-report.c                |  188 ++++++++++++++++++++++++++++++++++-
 4 files changed, 203 insertions(+), 4 deletions(-)
WHATS_NEW_DM +1 -0
index 6fb1745..c16f0c1 100644
@@ -1,5 +1,6 @@
 Version 1.02.128 -
 =================================
+  Add dm_report_group_{create,push,pop,destroy} to support report grouping.
 
 Version 1.02.127 - 11th June 2016
 =================================
libdm/.exported_symbols.DM_1_02_128 new file +4 -0
new file mode 100644
index 0000000..6e365d5
@@ -0,0 +1,4 @@
+dm_report_group_create
+dm_report_group_push
+dm_report_group_pop
+dm_report_group_destroy
libdm/libdevmapper.h +14 -0
index d2f40c9..c99ebe8 100644
@@ -2704,6 +2704,20 @@ void dm_report_field_set_value(struct dm_report_field *field, const void *value,
 			       const void *sortvalue);
 
 /*
+ * Report group support.
+ */
+struct dm_report_group;
+
+typedef enum {
+	DM_REPORT_GROUP_SINGLE,
+} dm_report_group_type_t;
+
+struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
+int dm_report_group_push(struct dm_report_group *group, struct dm_report *report, void *data);
+int dm_report_group_pop(struct dm_report_group *group);
+int dm_report_group_destroy(struct dm_report_group *group);
+
+/*
  * Stats counter access methods
  *
  * Each method returns the corresponding stats counter value from the
libdm/libdm-report.c +184 -4

212 lines not on this page · raw message