master - tests: Revert update for new thin pool messaging
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a606966029d411...
Commit: a606966029d411a1336eb5bc2f99a4162e0d97d6
Parent: 79ea81b8a849677489c35717fb571d3d6e67a0a0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 14 11:08:14 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Aug 17 11:25:03 2015 +0200
tests: Revert update for new thin pool messaging
This reverts commit 3dbb9a57ca684271dbbc26300aa2e35da9608aa3.
Original code is back as the code restored previous TID handling.
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 2 +-
test/shell/thin-volume-list.sh | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index 6897072..d7f5ccc 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -77,7 +77,7 @@ grep expected out
check inactive $vg pool_tmeta
# Transaction_id is higher by 1
-fake_metadata_ 10 3 >data
+fake_metadata_ 10 2 >data
"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
lvconvert -y --thinpool $vg/pool --poolmetadata $vg/$lv1
not vgchange -ay $vg 2>&1 | tee out
diff --git a/test/shell/thin-volume-list.sh b/test/shell/thin-volume-list.sh
index 88cae35..c3dab25 100644
--- a/test/shell/thin-volume-list.sh
+++ b/test/shell/thin-volume-list.sh
@@ -29,8 +29,11 @@ lvcreate -T -L8M $vg/pool -V10M -n $lv1
# skip $vg from activation
aux lvmconf "activation/volume_list = [ \"$vg1\" ]"
-# We cannot pass - pool volume cannot be manipulated
-not lvcreate -V10 -n $lv2 -T $vg/pool
+# We still could pass - since pool is still active
+lvcreate -V10 -n $lv2 -T $vg/pool
+
+# but $lv2 is not active
+check inactive $vg $lv2
vgchange -an $vg
8 years, 9 months
master - thin: restore transaction_id handling
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79ea81b8a84967...
Commit: 79ea81b8a849677489c35717fb571d3d6e67a0a0
Parent: d4c024c836aa10be0fe4d55157bac15f5ede62a8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 14 17:41:27 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Aug 17 11:25:03 2015 +0200
thin: restore transaction_id handling
Revert back to already existing behavior which has been slightly
modified by a900d150e4658a5d72c39acdd4fefd069b8f00b8.
At the end however it seem to be equal to change TID right with first
metadata write.
Existing code missed handling for 'unused' thin-pool which would
require to also check empty message list for TID==0.
So with the fix we now again preserve 'active' thin-pool volume
when first thin volume is created - this property was lost and caused
problems in cluster, where the lock was hold, but volume was no longer
active on the node.
Another missing part was the proper support for already increased,
but unfinished TID change.
So going back here with existing logic -
TID is increased with first MDA update.
Code allows start with either same TID or (TID-1).
If there are messages, TID must be lower by 1 for sending,
otherwise messages were already posted.
---
lib/metadata/thin_manip.c | 7 ++++---
lib/thin/thin.c | 10 +++++-----
libdm/libdm-deptree.c | 2 +-
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index d0a5c55..24c68a8 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -63,6 +63,10 @@ int attach_pool_message(struct lv_segment *pool_seg, dm_thin_message_t type,
tmsg->type = type;
+ /* If the 1st message is add in non-read-only mode, modify transaction_id */
+ if (!no_update && dm_list_empty(&pool_seg->thin_messages))
+ pool_seg->transaction_id++;
+
dm_list_add(&pool_seg->thin_messages, &tmsg->list);
log_debug_metadata("Added %s message.",
@@ -476,9 +480,6 @@ int update_pool_lv(struct logical_volume *lv, int activate)
dm_list_init(&(first_seg(lv)->thin_messages));
- /* thin-pool target transaction is finished, increase lvm2 TID */
- first_seg(lv)->transaction_id++;
-
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 4c4636f..c5f04f3 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -295,7 +295,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
}
if (!dm_tree_node_add_thin_pool_target(node, len,
- seg->transaction_id + (laopts->send_messages ? 1 : 0),
+ seg->transaction_id,
metadata_dlid, pool_dlid,
seg->chunk_size, seg->low_water_mark,
seg->zero_new_blocks ? 0 : 1))
@@ -345,7 +345,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
*/
if (!lv_thin_pool_transaction_id(seg->lv, &transaction_id))
return_0; /* Thin pool should exist and work */
- if (transaction_id != seg->transaction_id) {
+ if ((transaction_id + 1) != seg->transaction_id) {
log_error("Can't create snapshot %s as origin %s is not suspended.",
lmsg->u.lv->name, origin->name);
return 0;
@@ -373,11 +373,11 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
if (!dm_list_empty(&seg->thin_messages)) {
/* Messages were passed, modify transaction_id as the last one */
- log_debug_activation("Thin pool set transaction id %" PRIu64 ".", seg->transaction_id + 1);
+ log_debug_activation("Thin pool set transaction id %" PRIu64 ".", seg->transaction_id);
if (!dm_tree_node_add_thin_pool_message(node,
DM_THIN_MESSAGE_SET_TRANSACTION_ID,
- seg->transaction_id,
- seg->transaction_id + 1))
+ seg->transaction_id - 1,
+ seg->transaction_id))
return_0;
}
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index d28f0de..84f1d28 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1586,7 +1586,7 @@ static int _node_send_messages(struct dm_tree_node *dnode,
}
/* Error if there are no stacked messages or id mismatches */
- if (trans_id != (seg->transaction_id - have_messages)) {
+ if ((trans_id + 1) != seg->transaction_id) {
log_error("Thin pool %s transaction_id is %" PRIu64 ", while expected %" PRIu64 ".",
_node_name(dnode), trans_id, seg->transaction_id - have_messages);
return 0;
8 years, 9 months
master - cache: use undefined settings for cache_policy
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4c024c836aa10...
Commit: d4c024c836aa10be0fe4d55157bac15f5ede62a8
Parent: b297d78367c2a9395bcc6abc7484763368979842
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Aug 17 11:19:28 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Aug 17 11:25:03 2015 +0200
cache: use undefined settings for cache_policy
As cache_policy is evaluated in runtime, we no longer should use
CFG_COMMENTED, but have to switch to CFG_UNDEFINED.
So as long as the value is undefined, it's runtime evaluated.
Once it's set - it's always respected (no runtime fallback).
Also fix version of introduced settings to 2.2.128.
---
lib/config/config_settings.h | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index b687c57..f18d173 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -474,13 +474,13 @@ cfg(allocation_cache_mode_CFG, "cache_mode", allocation_CFG_SECTION, CFG_DEFAULT
"writeback - Data blocks are written from the cache back\n"
"to disk after some delay to improve performance.\n")
-cfg_runtime(allocation_cache_policy_CFG, "cache_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, vsn(2, 2, 127), 0, NULL,
+cfg_runtime(allocation_cache_policy_CFG, "cache_policy", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, vsn(2, 2, 128), 0, NULL,
"The default cache policy used for new cache volume.\n"
- "Generally available policies are: mq, smq.\n"
- "mq - Multiqueue policy with 88 bytes per block\n"
- "smq - Stochastic multique with 25 bytes per block (kernel >= 4.2).\n")
+ "For the kernel 4.2 and newer the default policy is smq\n"
+ "(Stochastic multique), otherwise the older mq (Multiqueue),\n"
+ "policy is selected.\n")
-cfg_section(allocation_cache_settings_CFG_SECTION, "cache_settings", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, vsn(2, 2, 127), 0, NULL,
+cfg_section(allocation_cache_settings_CFG_SECTION, "cache_settings", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, vsn(2, 2, 128), 0, NULL,
"Individual settings for policies.\n"
"See the help for individual policies for more info.\n")
8 years, 9 months
master - WHATS_NEW: Update.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b297d78367c2a9...
Commit: b297d78367c2a9395bcc6abc7484763368979842
Parent: 4a6d5e2012cbcf40842b5ef051347694bbf5ca04
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sun Aug 16 01:16:16 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sun Aug 16 01:16:16 2015 +0100
WHATS_NEW: Update.
---
WHATS_NEW | 7 +++----
WHATS_NEW_DM | 6 +++---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1e34e1c..dbb78d6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,10 +1,9 @@
Version 2.02.128 -
===================================
Check for valid cache mode in validation of cache segment.
- Enhance internal API cache_set_mode() and cache_set_policy().
- Enhance toollib's get_cache_params().
- Runtime detect presence of cache smq policy.
- Add demo cache-mq and cache-smq profiles.
+ Change internal interface handling cache mode and policy.
+ When no cache policy specified, prefer smq (if available) over mq.
+ Add demo cache-mq and cache-smq profiles.
Add cmd profilable allocation/cache_policy,cache_settings,cache_mode.
Require cache_check 0.5.4 for use of --clear-needs-check-flag.
Fix lvmetad udev rules to not override SYSTEMD_WANTS, add the service instead.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 8e816a0..870ffb2 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,8 +1,8 @@
Version 1.02.105 -
===================================
- Fix 'stats list -o all' segfault
- Separate statistics fields from region information fields
- Add interval and interval_ns fields to DR_STATS reports.
+ Fix 'dmstats list -o all' segfault.
+ Separate dmstats statistics fields from region information fields.
+ Add interval and interval_ns fields to dmstats reports.
Do not include internal glibc headers in libdm-timestamp.c (1.02.104)
Exit immediately if no device is supplied to dmsetup wipe_table.
Suppress dmsetup report headings when no data is output. (1.02.104)
8 years, 9 months
master - dmstats: fix --length argument
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a6d5e2012cbcf...
Commit: 4a6d5e2012cbcf40842b5ef051347694bbf5ca04
Parent: 9d5cd4ca14a94d83bf7b3c0b73896abc4ff8926c
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sat Aug 15 16:51:31 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sat Aug 15 18:35:10 2015 +0100
dmstats: fix --length argument
Commit f10ad95 introduced a regression causing the size of regions
passed in on the command line to be truncated to zero. Initialise
the 'this_len' variable to the supplied length to correct this.
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index ee1e1fe..097f1fd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4456,7 +4456,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
const char *program_id,
const char *aux_data)
{
- uint64_t this_start = 0, this_len = 0, region_id = UINT64_C(0);
+ uint64_t this_start = 0, this_len = len, region_id = UINT64_C(0);
char *target_type, *params; /* unused */
struct dm_task *dmt;
struct dm_info info;
8 years, 9 months
master - dmstats: fix new area count for 'create --areasize'
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d5cd4ca14a94d...
Commit: 9d5cd4ca14a94d83bf7b3c0b73896abc4ff8926c
Parent: 0b487802a041a0848e927e3dfc3d71618b66ca42
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sat Aug 15 00:32:59 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sat Aug 15 00:42:51 2015 +0100
dmstats: fix new area count for 'create --areasize'
Commit f10ad95 introduced a regression in the calculation of the
number of areas in a region created with the --areasize switch:
vg_hex-lv_home: Created new region with 0 area(s) as region ID 1
vg_hex-lv_swap: Created new region with 0 area(s) as region ID 1
Fis this by using the correct region size when calculating the
value.
---
tools/dmsetup.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 9e72226..ee1e1fe 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4456,7 +4456,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
const char *program_id,
const char *aux_data)
{
- uint64_t this_start, this_len, region_id = UINT64_C(0);
+ uint64_t this_start = 0, this_len = 0, region_id = UINT64_C(0);
char *target_type, *params; /* unused */
struct dm_task *dmt;
struct dm_info info;
@@ -4506,7 +4506,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
* whole-device region).
*/
this_start = (segments) ? segment_start : start;
- this_len = (segments) ? segment_len : len;
+ this_len = (segments) ? segment_len : this_len;
if (!dm_stats_create_region(dms, ®ion_id,
this_start, this_len, step,
program_id, aux_data)) {
8 years, 9 months
master - dmstats: change region fields prefix to 'region_'
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0b487802a041a0...
Commit: 0b487802a041a0848e927e3dfc3d71618b66ca42
Parent: f3891e90e32d0b76dc8c3ef2fb9bddbe09ffb846
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 23:53:42 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 23:53:42 2015 +0100
dmstats: change region fields prefix to 'region_'
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index f90ce3e..9e72226 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3915,7 +3915,7 @@ static const struct dm_report_object_type _report_types[] = {
{ DR_TREE, "Mapped Device Relationship Information", "tree_", _tree_get_obj },
{ DR_NAME, "Mapped Device Name Components", "splitname_", _split_name_get_obj },
{ DR_STATS, "Mapped Device Statistics","stats_", _stats_get_obj },
- { DR_STATS_META, "Mapped Device Statistics Region Information","stats_region_", _stats_get_obj },
+ { DR_STATS_META, "Mapped Device Statistics Region Information","region_", _stats_get_obj },
{ 0, "", "", NULL }
};
8 years, 9 months
master - dmstats: make -v enable per area reports for 'stats list'
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3891e90e32d0b...
Commit: f3891e90e32d0b76dc8c3ef2fb9bddbe09ffb846
Parent: 0f3b81bb2e7de61457ec0f2a72f381b9992421c6
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 20:40:13 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
dmstats: make -v enable per area reports for 'stats list'
When dmstats is run with -v or higher enable a per-area reporting
mode for statistics regions. This will output one row per area
(rather than one row per region) and adds additional fields of use
when viewing areas:
area_id - index within the region assigned by libdm-stats
area_start - the start location of the area in the containing
device.
---
man/dmstats.8.in | 6 ++++++
tools/dmsetup.c | 43 +++++++++++++++++++++++++++++++++----------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/man/dmstats.8.in b/man/dmstats.8.in
index f8d2949..a6b2ff5 100644
--- a/man/dmstats.8.in
+++ b/man/dmstats.8.in
@@ -63,6 +63,8 @@ dmstats \(em device-mapper statistics management
.RB [ \-\-units
.IR units ]
.RB [ \-\-nosuffix ]
+.RB [ \-\-nosuffix ]
+.RB [ \-v | \-\-verbose \ [ \-v | \-\-verbose ]
.br
.B dmstats print
.RI [ device_name ]
@@ -302,11 +304,15 @@ the list of report fields.
.RI [ device_name ]
.RB [ \-\-allprograms ]
.RB [ \-\-programid
+.RB [ \-v | \-\-verbose \ [ \-v | \-\-verbose ]]
.IR id ]
.br
List the statistics regions registered on the device. If the
\fB\-\-allprograms\fP switch is given all regions will be listed
regardless of region program ID values.
+
+If \fB\-v\fP or \fB\-\-verbose\fP is given the report will include
+a row of information for each area contained in each region displayed.
.br
.TP
.B print
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index f69fbe4..f90ce3e 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -256,6 +256,7 @@ static struct dm_timestamp *_initial_timestamp = NULL;
static uint64_t _disp_factor = 512; /* display sizes in sectors */
static char _disp_units = 's';
const char *_program_id = DM_STATS_PROGRAM_ID; /* program_id used for reports. */
+static int _stats_report_by_areas = 1; /* output per-area info for stats reports. */
/* report timekeeping */
static struct dm_timestamp *_cycle_timestamp = NULL;
@@ -859,8 +860,10 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
dm_stats_walk_do(obj.stats) {
if (!dm_report_object(_report, &obj))
goto_out;
- /* report walk is always by area */
- dm_stats_walk_next(obj.stats);
+ if (_stats_report_by_areas)
+ dm_stats_walk_next(obj.stats);
+ else
+ dm_stats_walk_next_region(obj.stats);
} dm_stats_walk_while(obj.stats);
r = 1;
@@ -4024,15 +4027,23 @@ FIELD_F(STATS_META, STR, "AuxDat", 6, dm_stats_aux_data, "aux_data", "Auxiliary
static const char *default_report_options = "name,major,minor,attr,open,segments,events,uuid";
static const char *splitname_report_options = "vg_name,lv_name,lv_layer";
-#define DEV_INFO_STATS "name,region_id"
+/* Stats counters & derived metrics. */
#define RD_COUNTERS "reads,reads_merged,read_sectors,read_nsecs,total_rd_nsecs"
#define WR_COUNTERS "writes,writes_merged,write_sectors,write_nsecs,total_wr_nsecs"
#define IO_COUNTERS "in_progress,io_nsecs,weighted_io_nsecs"
#define METRICS "rrqm,wrqm,rs,ws,rsize_sec,wsize_sec,arqsz,qusz,util,await,r_await,w_await"
#define COUNTERS RD_COUNTERS "," WR_COUNTERS "," IO_COUNTERS
-static const char *_stats_default_report_options = DEV_INFO_STATS ",area_id,area_start,area_len," METRICS;
-static const char *_stats_raw_report_options = DEV_INFO_STATS ",area_id,area_start,area_len," COUNTERS;
-static const char *_stats_list_options = "name,region_id,region_start,region_len,area_len,area_count,program_id";
+
+/* Device, region and area metadata. */
+#define STATS_DEV_INFO "name,region_id"
+#define STATS_AREA_INFO STATS_DEV_INFO ",region_start,region_len,area_count,area_id,area_start,area_len"
+#define STATS_REGION_INFO STATS_DEV_INFO ",region_start,region_len,area_count,area_len"
+
+/* Default stats report options. */
+static const char *_stats_default_report_options = STATS_DEV_INFO ",area_id,area_start,area_len," METRICS;
+static const char *_stats_raw_report_options = STATS_DEV_INFO ",area_id,area_start,area_len," COUNTERS;
+static const char *_stats_list_options = STATS_REGION_INFO ",program_id";
+static const char *_stats_area_list_options = STATS_AREA_INFO ",program_id";
static int _report_init(const struct command *cmd, const char *subcommand)
{
@@ -4055,11 +4066,14 @@ static int _report_init(const struct command *cmd, const char *subcommand)
if (cmd && !strcmp(cmd->name, "stats")) {
_report_type |= DR_STATS_META;
if (!strcmp(subcommand, "list"))
- options = (char *) _stats_list_options;
+ options = (char *) ((_switches[VERBOSE_ARG])
+ ? _stats_area_list_options
+ : _stats_list_options);
else {
- options = (char *) (!_switches[RAW_ARG])
+ options = (char *) ((!_switches[RAW_ARG])
? _stats_default_report_options
- : _stats_raw_report_options;
+ : _stats_raw_report_options);
+
_report_type |= DR_STATS;
}
}
@@ -4772,6 +4786,9 @@ static int _stats_report(CMD_ARGS)
if (_switches[ALL_PROGRAMS_ARG])
_program_id = "";
+ if (!_switches[VERBOSE_ARG] && !strcmp(subcommand, "list"))
+ _stats_report_by_areas = 0;
+
if (names)
name = names->name;
else {
@@ -5067,7 +5084,13 @@ static int _stats(CMD_ARGS)
return 0;
}
- if (!stats_cmd->fn(stats_cmd, NULL, argc, argv, NULL, multiple_devices))
+ /*
+ * Pass the sub-command through to allow a single function to be
+ * used to implement several distinct sub-commands (e.g. 'report'
+ * and 'list' share a single implementation.
+ */
+ if (!stats_cmd->fn(stats_cmd, subcommand, argc, argv, NULL,
+ multiple_devices))
return 0;
return 1;
8 years, 9 months
master - dmstats: add 'area_offset' field to stats reports
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0f3b81bb2e7de6...
Commit: 0f3b81bb2e7de61457ec0f2a72f381b9992421c6
Parent: 00ed52365916753d0bd6eb0de09c46ad782fec2e
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 21:49:40 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
dmstats: add 'area_offset' field to stats reports
---
tools/dmsetup.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 74e7806..f69fbe4 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3319,6 +3319,34 @@ static int _dm_stats_area_start_disp(struct dm_report *rh,
return 1;
}
+static int _dm_stats_area_offset_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 dm_stats *dms = (const struct dm_stats *) data;
+ uint64_t area_offset;
+ const char *repstr;
+ double *sortval;
+ char units = _disp_units;
+ uint64_t factor = _disp_factor;
+
+ if (!dm_stats_get_current_area_offset(dms, &area_offset))
+ return_0;
+
+ if (!(repstr = dm_size_to_string(mem, area_offset, units, 1, factor,
+ _show_units(), DM_SIZE_UNIT)))
+ return_0;
+
+ if (!(sortval = dm_pool_alloc(mem, sizeof(uint64_t))))
+ return_0;
+
+ *sortval = (double) area_offset;
+
+ dm_report_field_set_value(field, repstr, sortval);
+ return 1;
+}
+
static int _dm_stats_area_len_disp(struct dm_report *rh,
struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field, const void *data,
@@ -3976,12 +4004,12 @@ FIELD_F(STATS_META, NUM, "RgID", 5, dm_stats_region_id, "region_id", "Region ID.
FIELD_F(STATS_META, SIZ, "RStart", 5, dm_stats_region_start, "region_start", "Region start.")
FIELD_F(STATS_META, SIZ, "RSize", 5, dm_stats_region_len, "region_len", "Region length.")
FIELD_F(STATS_META, NUM, "ArID", 5, dm_stats_area_id, "area_id", "Area ID.")
-FIELD_F(STATS_META, SIZ, "AStrt", 5, dm_stats_area_start, "area_start", "Area start.")
+FIELD_F(STATS_META, SIZ, "AStart", 5, dm_stats_area_start, "area_start", "Area offset from start of device.")
FIELD_F(STATS_META, SIZ, "ASize", 5, dm_stats_area_len, "area_len", "Area length.")
+FIELD_F(STATS_META, SIZ, "AOff", 5, dm_stats_area_offset, "area_offset", "Area offset from start of region.")
FIELD_F(STATS_META, NUM, "#Areas", 6, dm_stats_area_count, "area_count", "Area count.")
FIELD_F(STATS_META, STR, "ProgID", 6, dm_stats_program_id, "program_id", "Program ID.")
FIELD_F(STATS_META, STR, "AuxDat", 6, dm_stats_aux_data, "aux_data", "Auxiliary data.")
-
{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
8 years, 9 months
master - libdm: add dm_stats_get_{current_}area_offset()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00ed5236591675...
Commit: 00ed52365916753d0bd6eb0de09c46ad782fec2e
Parent: 77fae3d8522ffb1077dcb0e2e9ebfba86cf19daf
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Aug 14 20:30:05 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Fri Aug 14 22:03:37 2015 +0100
libdm: add dm_stats_get_{current_}area_offset()
Add a method to retrieve the offset of an area within the
containing region (rather than the offset within the containing
device returned by dm_stats_get_area_start()).
Although users of the library can calculate this themselves it is
better to provide this through a method call to avoid users making
assumptions about the structure of regions and areas.
---
libdm/.exported_symbols.DM_1_02_105 | 2 ++
libdm/libdevmapper.h | 17 ++++++++++++++---
libdm/libdm-stats.c | 15 +++++++++++++++
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/libdm/.exported_symbols.DM_1_02_105 b/libdm/.exported_symbols.DM_1_02_105
index 9b701f1..4707164 100644
--- a/libdm/.exported_symbols.DM_1_02_105
+++ b/libdm/.exported_symbols.DM_1_02_105
@@ -1 +1,3 @@
dm_report_is_empty
+dm_stats_get_area_offset
+dm_stats_get_current_area_offset
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 303ed67..bfc90da 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -705,19 +705,27 @@ uint64_t dm_stats_get_region_area_len(const struct dm_stats *dms,
uint64_t *area_len, uint64_t region_id);
/*
- * Area properties: start and length.
+ * Area properties: start, offset and length.
*
* The area length is always equal to the area length of the region
* that contains it and is obtained from dm_stats_get_region_area_len().
*
- * The start offset of an area is a function of the area_id and the
- * containing region's start and area length.
+ * The start of an area is a function of the area_id and the containing
+ * region's start and area length: it gives the absolute offset into the
+ * containing device of the beginning of the area.
+ *
+ * The offset expresses the area's relative offset into the current
+ * region. I.e. the area start minus the start offset of the containing
+ * region.
*
* All values are returned in units of 512b sectors.
*/
uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
uint64_t region_id, uint64_t area_id);
+uint64_t dm_stats_get_area_offset(const struct dm_stats *dms, uint64_t *offset,
+ uint64_t region_id, uint64_t area_id);
+
/*
* Retrieve program_id and aux_data for a specific region. Only valid
* following a call to dm_stats_list(). The returned pointer does not
@@ -876,6 +884,9 @@ uint64_t dm_stats_get_current_region_area_len(const struct dm_stats *dms,
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
uint64_t *start);
+uint64_t dm_stats_get_current_area_offset(const struct dm_stats *dms,
+ uint64_t *offset);
+
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
uint64_t *start);
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 51aba79..400b12d 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1335,6 +1335,14 @@ uint64_t dm_stats_get_area_start(const struct dm_stats *dms, uint64_t *start,
return 1;
}
+uint64_t dm_stats_get_area_offset(const struct dm_stats *dms, uint64_t *offset,
+ uint64_t region_id, uint64_t area_id)
+{
+ if (!dms || !dms->regions)
+ return_0;
+ *offset = dms->regions[region_id].step * area_id;
+}
+
uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
uint64_t *start)
{
@@ -1342,6 +1350,13 @@ uint64_t dm_stats_get_current_area_start(const struct dm_stats *dms,
dms->cur_region, dms->cur_area);
}
+uint64_t dm_stats_get_current_area_offset(const struct dm_stats *dms,
+ uint64_t *offset)
+{
+ return dm_stats_get_area_offset(dms, offset,
+ dms->cur_region, dms->cur_area);
+}
+
uint64_t dm_stats_get_current_area_len(const struct dm_stats *dms,
uint64_t *len)
{
8 years, 9 months