master - man: replace to with for
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1307fafe0f72ce...
Commit: 1307fafe0f72cea9b3f2e7e7fdb70b1b5d0a0670
Parent: 9886fd236e2cf09f299589e0e2b6cb7454b2314a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Aug 24 11:20:29 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 26 11:24:41 2015 +0200
man: replace to with for
Better word.
---
man/lvconvert.8.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index c2ee2b2..4438893 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -326,7 +326,7 @@ operation from its arguments.
Separates \fICacheLogicalVolume\fP from cache pool.
Before the logical volume becomes uncached, cache is flushed.
The cache pool volume is then left unused and
-could be used e.g. to caching another volume.
+could be used e.g. for caching another volume.
See also the option \fB\-\-uncache\fP for uncaching and removing
cache pool with one command.
.TP
8 years, 3 months
master - cache: lvconvert accepts --cachemode for --cache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9886fd236e2cf0...
Commit: 9886fd236e2cf09f299589e0e2b6cb7454b2314a
Parent: a4fdfc098d7a1c28793a8ba6f82277ecef40dfcd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 25 14:48:31 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 26 11:24:41 2015 +0200
cache: lvconvert accepts --cachemode for --cache
All cache args could be specified when caching LV
(means converting LV to cached).
When --cachemode arg is given during cache-pool conversion,
store it in the metadata.
https://bugzilla.redhat.com/show_bug.cgi?id=1255184
---
WHATS_NEW | 1 +
tools/lvconvert.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ac8e1e9..ea50997 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.129 -
===================================
+ Accept --cachemode with lvconvert.
Fix and improve reporting properties of cache-pool.
Enable usage of --cachepolicy and --cachesetting with lvconvert.
Don't allow to reduce size of thin-pool metadata.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 95996b7..07d9f43 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2828,7 +2828,7 @@ static int _lvconvert_pool(struct cmd_context *cmd,
if (!metadata_lv) {
if (arg_from_list_is_set(cmd, "is invalid with existing pool",
- cachemode_ARG, chunksize_ARG, discards_ARG,
+ chunksize_ARG, discards_ARG,
zero_ARG, poolmetadatasize_ARG, -1))
return_0;
@@ -3069,6 +3069,10 @@ mda_write:
seg->discards = lp->discards;
seg->zero_new_blocks = lp->zero ? 1 : 0;
+ if (lp->cache_mode &&
+ !cache_set_mode(seg, lp->cache_mode))
+ return_0;
+
if ((lp->policy_name || lp->policy_settings) &&
!cache_set_policy(seg, lp->policy_name, lp->policy_settings))
return_0;
8 years, 3 months
master - cache: report cache pool attrs also for pools
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a4fdfc098d7a1c...
Commit: a4fdfc098d7a1c28793a8ba6f82277ecef40dfcd
Parent: cbe81ad3932417ffaf89cbd924bd6d1ce1c7f199
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 25 15:07:41 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 26 11:24:41 2015 +0200
cache: report cache pool attrs also for pools
Since cache-pool actualy keeps info about caching,
display this info for cache-pool LV as well
(matches info for cache LV when cache-pool is asociated with it).
---
WHATS_NEW | 1 +
lib/report/report.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4eb852c..ac8e1e9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.129 -
===================================
+ Fix and improve reporting properties of cache-pool.
Enable usage of --cachepolicy and --cachesetting with lvconvert.
Don't allow to reduce size of thin-pool metadata.
Fix debug buffer overflows in cmirrord logging.
diff --git a/lib/report/report.c b/lib/report/report.c
index 1885f45..4fd311a 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1344,7 +1344,7 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
- else {
+ else if (!seg_is_cache_pool(seg)) {
dm_list_init(&dummy_list);
return _field_set_string_list(rh, field, &dummy_list, private, 0);
/* TODO: once we have support for STR_LIST reserved values, replace with:
@@ -1384,7 +1384,7 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
- else
+ else if (!seg_is_cache_pool(seg) || !seg->policy_name)
return _field_set_value(field, GET_FIRST_RESERVED_NAME(cache_policy_undef),
GET_FIELD_RESERVED_VALUE(cache_policy_undef));
8 years, 3 months
master - cache: no report error for cpool without mode
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cbe81ad3932417...
Commit: cbe81ad3932417ffaf89cbd924bd6d1ce1c7f199
Parent: 8c09f12943a8136079360a05bc0afc120cfc7674
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 25 14:47:07 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 26 10:49:23 2015 +0200
cache: no report error for cpool without mode
It's perferctly valid to not have cachemode for
unused cache-pool.
https://bugzilla.redhat.com/show_bug.cgi?id=1255184
---
lib/report/report.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index a17af32..1885f45 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2078,7 +2078,7 @@ static int _cachemode_disp(struct dm_report *rh, struct dm_pool *mem,
if (seg_is_cache(seg))
seg = first_seg(seg->pool_lv);
- if (seg_is_cache_pool(seg)) {
+ if (seg_is_cache_pool(seg) && cache_mode_is_set(seg)) {
if (!(cachemode_str = get_cache_mode_name(seg)))
return_0;
8 years, 3 months
master - makefiles: remove stray ')'
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c09f12943a813...
Commit: 8c09f12943a8136079360a05bc0afc120cfc7674
Parent: 19ef3e0f31f375be72da875a5e6beb5d10af44df
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Tue Aug 25 19:05:45 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Tue Aug 25 19:05:45 2015 +0100
makefiles: remove stray ')'
---
make.tmpl.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index 3e39a3a..dbc839a 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -502,7 +502,7 @@ else
set -e;\
R=$$(sort $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
- for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | sort -rnt_ -k5 )); do\
+ for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | sort -rnt_ -k5 ); do\
echo "$${i##*.} {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" $$i;\
test "$$i" = Base && { echo " local:"; echo " *;"; };\
8 years, 3 months
master - makefiles: fix ld version script generation for older make versions
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=19ef3e0f31f375...
Commit: 19ef3e0f31f375be72da875a5e6beb5d10af44df
Parent: 463f59eca4330300c549b40603065b8640fdb790
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Tue Aug 25 18:18:34 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Tue Aug 25 18:51:57 2015 +0100
makefiles: fix ld version script generation for older make versions
Commit 82a27a8 introduced a change to the symbol versioning macros
that allows a new version of a function to be introduced while
keeping the old behaviour via a versioned symbol export. The new
symbol is listed in the current .exported_symbols.DM_* file and a
default (@@VERSION) binding is created during linking.
This broke the build on RHEL5, RHEL6 and Debian Lenny. This is
because the make version in these distros returns results from the
$(wildcard *) command in a different order to the RHEL7 and F22
versions: this affects the ordering of the generated .export.sym
version script:
RHEL7/F22
for i in ./.exported_symbols.Base ./.exported_symbols.DM_1_02_99
./.exported_symbols.DM_1_02_98 ./.exported_symbols.DM_1_02_97
./.exported_symbols.DM_1_02_106 ./.exported_symbols.DM_1_02_105
./.exported_symbols.DM_1_02_103 ./.exported_symbols.DM_1_02_101
./.exported_symbols.DM_1_02_104 ./.exported_symbols.DM_1_02_100
290: 000000000003d101 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region_v1_02_104
*388: 000000000003cfc7 314 FUNC GLOBAL DEFAULT 12 dm_stats_create_region@@DM_1_02_106
391: 000000000003d101 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region@DM_1_02_104
*552: 000000000003cfc7 314 FUNC GLOBAL DEFAULT 12 dm_stats_create_region
944: 000000000003d101 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region_v1_02_104
992: 000000000003d101 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region@DM_1_02_104
RHEL6:
for i in ./.exported_symbols.Base ./.exported_symbols.DM_1_02_100
./.exported_symbols.DM_1_02_101 ./.exported_symbols.DM_1_02_103
./.exported_symbols.DM_1_02_104 ./.exported_symbols.DM_1_02_105
./.exported_symbols.DM_1_02_106 ./.exported_symbols.DM_1_02_97
./.exported_symbols.DM_1_02_98 ./.exported_symbols.DM_1_02_99; do\
290: 000000000003d0e1 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region_v1_02_104
390: 000000000003d0e1 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region@DM_1_02_104
*479: 000000000003cfa7 314 FUNC LOCAL DEFAULT 12 dm_stats_create_region
944: 000000000003d0e1 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region_v1_02_104
992: 000000000003d0e1 106 FUNC GLOBAL DEFAULT 12 dm_stats_create_region@DM_1_02_104
The F22 build has the correct behaviour (although the sort order is
inconsistent) but on RHEL6 the 1_02_106 symbol file appears after
version 1_02_104 which introduced the original symbol. This causes
the later version of the symbol to lose its version binding and be
reduced to local scope.
If using un-versioned exports of the current version of a symbol
(i.e. exported with the plain symbol name and no macro) and using
the linker script to set the symbol version, the current version
node must appear first in the version script: the un-versioned
symbol will be bound to the first version node found that contains
it.
On RHEL6 and the other older distros the original version of the
dm_stats_create_region() call sorted before the current version
(DM_1_02_104 vs. DM_1_02_106) leading to a subsequent link error for
the later symbol version:
dmsetup.o: In function `_do_stats_create_regions':
/root/src/git/lvm2/tools/dmsetup.c:4658: undefined reference to
`dm_stats_create_region'
Ensure that the ordering of entries in the version script is
consistent to avoid an old implementation shadowing a newer one by
sorting the list of file names before the loop:
$$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | sort -rnt_ -k5 )
This only sorts by patch level but this is sufficient to maintain
the correct order for current version files.
Tested on RHEL5, 6, 7 and F22.
---
make.tmpl.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index e4f8835..3e39a3a 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -502,7 +502,7 @@ else
set -e;\
R=$$(sort $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
- for i in $(EXPORTED_SYMBOLS); do\
+ for i in $$(echo $(EXPORTED_SYMBOLS) | tr ' ' '\n' | sort -rnt_ -k5 )); do\
echo "$${i##*.} {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" $$i;\
test "$$i" = Base && { echo " local:"; echo " *;"; };\
8 years, 3 months
master - dmstats: add 'precise' flag field to stats report
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=463f59eca43303...
Commit: 463f59eca4330300c549b40603065b8640fdb790
Parent: e4145ebc47a833d443a7c8bcec26d9d2ec9e5518
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Aug 17 18:09:43 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 24 20:03:21 2015 +0100
dmstats: add 'precise' flag field to stats report
Add a flag indicating whether or not precise_timestamps are enabled for
a given region or area.
---
WHATS_NEW_DM | 1 +
tools/dmsetup.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 01ceefb..28bc933 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.106 -
===================================
+ Add 'precise' column to statistics reports.
Add --precise switch to 'dmstats create' to request nanosecond counters.
Add precise argument to dm_stats_create_region().
Add support to libdm-stats for precise_timestamps
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index e98bdcd..dcf44de 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3425,6 +3425,17 @@ static int _dm_stats_aux_data_disp(struct dm_report *rh,
return dm_report_field_string(rh, field, (const char * const *) &aux_data);
}
+static int _dm_stats_precise_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;
+ int precise;
+ precise = dm_stats_get_current_region_precise_timestamps(dms);
+ return dm_report_field_int(rh, field, (const int *) &precise);
+}
+
static int _dm_stats_rrqm_disp(struct dm_report *rh,
struct dm_pool *mem __attribute__((unused)),
struct dm_report_field *field, const void *data,
@@ -4021,6 +4032,7 @@ FIELD_F(STATS_META, SIZ, "AOff", 5, dm_stats_area_offset, "area_offset", "Area o
FIELD_F(STATS_META, NUM, "#Areas", 3, 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.")
+FIELD_F(STATS_META, STR, "Precise", 5, dm_stats_precise, "precise", "Set if the nanosecond precision timers are enabled.")
{0, 0, 0, 0, "", "", NULL, NULL},
/* *INDENT-ON* */
};
8 years, 3 months
master - dmstats: add --precise switch to enable nanosecond counters.
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e4145ebc47a833...
Commit: e4145ebc47a833d443a7c8bcec26d9d2ec9e5518
Parent: 567189cc7617a4d239d0f2ea052801fe2573d011
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Tue Aug 18 12:39:34 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 24 20:03:21 2015 +0100
dmstats: add --precise switch to enable nanosecond counters.
---
WHATS_NEW_DM | 1 +
man/dmstats.8.in | 9 +++++++++
tools/dmsetup.c | 16 ++++++++++++++--
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index e083231..01ceefb 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.106 -
===================================
+ Add --precise switch to 'dmstats create' to request nanosecond counters.
Add precise argument to dm_stats_create_region().
Add support to libdm-stats for precise_timestamps
diff --git a/man/dmstats.8.in b/man/dmstats.8.in
index bdcf742..ad5f952 100644
--- a/man/dmstats.8.in
+++ b/man/dmstats.8.in
@@ -32,6 +32,7 @@ dmstats \(em device-mapper statistics management
.IR nr_areas ]
.RB |[ \-\-areasize
.IR area_size ]]
+.RB [ \-\-precise ]
.RB [[ \-\-start
.IR start_sector ]
.RB [ \-\-length
@@ -181,6 +182,10 @@ Specify which report fields to display.
Sort output according to the list of fields given. Precede any
sort_field with - for a reverse sort on that column.
.TP
+.BR \-\-precise
+Attempt to use nanosecond precision counters when creating new
+statistics regions.
+.TP
.B \-\-programid \fIid
Specify a program ID string. When creating new statistics regions this
string is stored with the region. Subsequent operations may supply a
@@ -240,6 +245,7 @@ regions (with the exception of in-flight IO counters).
.IR nr_areas ]
.RB [ \-\-areasize
.IR area_size ]
+.RB [ \-\-precise ]
.RB [[ \-\-start
.IR start_sector ]
.RB [ \-\-length
@@ -259,6 +265,9 @@ at an arbitrary offset into the device. The \fB\-\-segments\fP option
causes a new region to be created for each target in the corresponding
device-mapper device's table.
+If the \fB\-\-precise\fP option is used the command will attempt to
+create a region using nanosecond precision counters.
+
An optional \fBprogram_id\fP or \fBaux_data\fP string may be associated
with the region. A \fBprogram_id\fP may then be used to select regions
for subsequent list, print, and report operations. The \fBaux_data\fP
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index b8376dd..e98bdcd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -190,6 +190,7 @@ enum {
NOUDEVRULES_ARG,
NOUDEVSYNC_ARG,
OPTIONS_ARG,
+ PRECISE_ARG,
PROGRAM_ID_ARG,
RAW_ARG,
READAHEAD_ARG,
@@ -4473,7 +4474,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
struct dm_info info;
void *next = NULL;
const char *devname = NULL;
- int r = 0;
+ int r = 0, precise = _switches[PRECISE_ARG];
if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) {
dm_stats_destroy(dms);
@@ -4520,7 +4521,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
this_len = (segments) ? segment_len : this_len;
if (!dm_stats_create_region(dms, ®ion_id,
this_start, this_len, step,
- -1,
+ precise,
program_id, aux_data)) {
log_error("%s: Could not create statistics region.",
devname);
@@ -4631,6 +4632,14 @@ static int _stats_create(CMD_ARGS)
if (!_bind_stats_device(dms, name))
goto_out;
+ if (_switches[PRECISE_ARG]) {
+ if (!dm_stats_driver_supports_precise()) {
+ log_error("Using --precise requires driver version "
+ "4.32.0 or later.");
+ goto out;
+ }
+ }
+
if (!strlen(program_id))
/* force creation of a region with no id */
dm_stats_set_program_id(dms, 1, NULL);
@@ -5497,6 +5506,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
{"noudevrules", 0, &ind, NOUDEVRULES_ARG},
{"noudevsync", 0, &ind, NOUDEVSYNC_ARG},
{"options", 1, &ind, OPTIONS_ARG},
+ {"precise", 0, &ind, PRECISE_ARG},
{"programid", 1, &ind, PROGRAM_ID_ARG},
{"raw", 0, &ind, RAW_ARG},
{"readahead", 1, &ind, READAHEAD_ARG},
@@ -5648,6 +5658,8 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
_switches[PROGRAM_ID_ARG]++;
_string_args[PROGRAM_ID_ARG] = optarg;
}
+ if (ind == PRECISE_ARG)
+ _switches[PRECISE_ARG]++;
if (ind == RAW_ARG)
_switches[RAW_ARG]++;
if (ind == REGION_ID_ARG) {
8 years, 3 months
master - libdm: add per region precise timestamps property methods
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=567189cc7617a4...
Commit: 567189cc7617a4d239d0f2ea052801fe2573d011
Parent: f4262026b671ac2604ec8143c6fe328e9ab159aa
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Aug 17 18:08:18 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 24 20:03:21 2015 +0100
libdm: add per region precise timestamps property methods
---
libdm/.exported_symbols.DM_1_02_106 | 2 ++
libdm/libdevmapper.h | 16 ++++++++++++++++
libdm/libdm-stats.c | 12 ++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/libdm/.exported_symbols.DM_1_02_106 b/libdm/.exported_symbols.DM_1_02_106
index b664cc6..0bec544 100644
--- a/libdm/.exported_symbols.DM_1_02_106
+++ b/libdm/.exported_symbols.DM_1_02_106
@@ -1,3 +1,5 @@
dm_message_supports_precise_timestamps
dm_stats_create_region
dm_stats_driver_supports_precise
+dm_stats_get_current_region_precise_timestamps
+dm_stats_get_region_precise_timestamps
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 71b8ce4..59eb5e9 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -480,6 +480,22 @@ int dm_message_supports_precise_timestamps(void);
*/
int dm_stats_driver_supports_precise(void);
+/*
+ * Returns 1 if the specified region has the precise_timestamps feature
+ * enabled (i.e. produces nanosecond-precision counter values) or 0 for
+ * a region using the default milisecond precision.
+ */
+int dm_stats_get_region_precise_timestamps(const struct dm_stats *dms,
+ uint64_t region_id);
+
+/*
+ * Returns 1 if the region at the current cursor location has the
+ * precise_timestamps feature enabled (i.e. produces
+ * nanosecond-precision counter values) or 0 for a region using the
+ * default milisecond precision.
+ */
+int dm_stats_get_current_region_precise_timestamps(const struct dm_stats *dms);
+
#define DM_STATS_ALL_PROGRAMS ""
/*
* Parse the response from a @stats_list message. dm_stats_list will
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index b85300f..800bde6 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1489,3 +1489,15 @@ const char *dm_stats_get_current_region_aux_data(const struct dm_stats *dms)
{
return dm_stats_get_region_aux_data(dms, dms->cur_region);
}
+
+int dm_stats_get_region_precise_timestamps(const struct dm_stats *dms,
+ uint64_t region_id)
+{
+ struct dm_stats_region *region = &dms->regions[region_id];
+ return region->timescale == 1;
+}
+
+int dm_stats_get_current_region_precise_timestamps(const struct dm_stats *dms)
+{
+ return dm_stats_get_region_precise_timestamps(dms, dms->cur_region);
+}
8 years, 3 months
master - libdm: add precise timestamps support to libdm-stats
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f4262026b671ac...
Commit: f4262026b671ac2604ec8143c6fe328e9ab159aa
Parent: 82a27a85b54b68277e79de2fa9b4fadb01330497
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Aug 20 11:55:06 2015 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Aug 24 20:03:21 2015 +0100
libdm: add precise timestamps support to libdm-stats
Add support for the kernel precise_timestamps feature. This allows
regions to be created using counters with nanosecond precision.
A new dm_stats method, dm_stats_set_precise_timestamps() causes all
future regions created with this handle to attempt to enable precise
counters.
---
WHATS_NEW_DM | 2 +
libdm/.exported_symbols.DM_1_02_106 | 2 +
libdm/libdevmapper.h | 11 +++
libdm/libdm-stats.c | 155 +++++++++++++++++++++++++++++------
tools/dmsetup.c | 1 +
5 files changed, 144 insertions(+), 27 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 363f7bf..e083231 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,7 @@
Version 1.02.106 -
===================================
+ Add precise argument to dm_stats_create_region().
+ Add support to libdm-stats for precise_timestamps
Version 1.02.105 - 17th August 2015
===================================
diff --git a/libdm/.exported_symbols.DM_1_02_106 b/libdm/.exported_symbols.DM_1_02_106
index 0ce8924..b664cc6 100644
--- a/libdm/.exported_symbols.DM_1_02_106
+++ b/libdm/.exported_symbols.DM_1_02_106
@@ -1 +1,3 @@
dm_message_supports_precise_timestamps
+dm_stats_create_region
+dm_stats_driver_supports_precise
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 2be2ce3..71b8ce4 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -473,6 +473,13 @@ int dm_stats_bind_uuid(struct dm_stats *dms, const char *uuid);
*/
int dm_message_supports_precise_timestamps(void);
+/*
+ * Precise timetamps support.
+ *
+ * Test for the presence of precise_timestamps support.
+ */
+int dm_stats_driver_supports_precise(void);
+
#define DM_STATS_ALL_PROGRAMS ""
/*
* Parse the response from a @stats_list message. dm_stats_list will
@@ -535,6 +542,9 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
*
* dm_stats_create_region(dms, 1024, 1 << 11, -2, p, a);
*
+ * If precise is non-zero attempt to create a region with nanosecond
+ * precision counters using the kernel precise_timestamps feature.
+ *
* program_id is an optional string argument that identifies the
* program creating the region. If program_id is NULL or the empty
* string the default program_id stored in the handle will be used.
@@ -548,6 +558,7 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
*/
int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
uint64_t start, uint64_t len, int64_t step,
+ int precise,
const char *program_id, const char *aux_data);
/*
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 4b4135a..b85300f 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -19,6 +19,8 @@
#define NSEC_PER_MSEC 1000000L
#define NSEC_PER_SEC 1000000000L
+#define PRECISE_ARG "precise_timestamps"
+
/*
* See Documentation/device-mapper/statistics.txt for full descriptions
* of the device-mapper statistics counter fields.
@@ -61,7 +63,8 @@ struct dm_stats {
uint64_t nr_regions; /* total number of present regions */
uint64_t max_region; /* size of the regions table */
uint64_t interval_ns; /* sampling interval in nanoseconds */
- uint64_t timescale; /* sample value multiplier */
+ uint64_t timescale; /* default sample value multiplier */
+ int precise; /* use precise_timestamps when creating regions */
struct dm_stats_region *regions;
/* statistics cursor */
uint64_t cur_region;
@@ -109,8 +112,9 @@ struct dm_stats *dm_stats_create(const char *program_id)
dms->name = NULL;
dms->uuid = NULL;
- /* all regions currently use msec precision */
+ /* by default all regions use msec precision */
dms->timescale = NSEC_PER_MSEC;
+ dms->precise = 0;
dms->nr_regions = DM_STATS_REGION_NOT_PRESENT;
dms->max_region = DM_STATS_REGION_NOT_PRESENT;
@@ -225,6 +229,19 @@ int dm_stats_bind_uuid(struct dm_stats *dms, const char *uuid)
return 1;
}
+static int _stats_check_precise_timestamps(const struct dm_stats *dms)
+{
+ /* Already checked? */
+ if (dms && dms->precise)
+ return 1;
+ return dm_message_supports_precise_timestamps();
+}
+
+int dm_stats_driver_supports_precise(void)
+{
+ return _stats_check_precise_timestamps(NULL);
+}
+
static struct dm_task *_stats_send_message(struct dm_stats *dms, char *msg)
{
struct dm_task *dmt;
@@ -249,24 +266,55 @@ out:
static int _stats_parse_list_region(struct dm_stats_region *region, char *line)
{
- /* FIXME: the kernel imposes no length limit here */
- char program_id[256], aux_data[256];
+ char *p = NULL, string_data[4096]; /* FIXME: add dm_sscanf with %ms? */
+ const char *program_id, *aux_data, *stats_args;
+ const char *empty_string = "";
int r;
- /* line format:
- * <region_id>: <start_sector>+<length> <step> <program_id> <aux_data>
+ memset(string_data, 0, sizeof(string_data));
+
+ /*
+ * Parse fixed fields, line format:
+ *
+ * <region_id>: <start_sector>+<length> <step> <string data>
+ *
+ * Maximum string data size is 4096 - 1 bytes.
*/
- r = sscanf(line, FMTu64 ": " FMTu64 "+" FMTu64 " " FMTu64 "%255s %255s",
- ®ion->region_id, ®ion->start, ®ion->len, ®ion->step,
- program_id, aux_data);
+ r = sscanf(line, FMTu64 ": " FMTu64 "+" FMTu64 " " FMTu64 " %4095c",
+ ®ion->region_id, ®ion->start, ®ion->len,
+ ®ion->step, string_data);
- if (r != 6)
+ if (r != 5)
return_0;
- if (!strcmp(program_id, "-"))
- program_id[0] = '\0';
- if (!strcmp(aux_data, "-"))
- aux_data[0] = '\0';
+ /* program_id is guaranteed to be first. */
+ program_id = string_data;
+
+ /*
+ * FIXME: support embedded '\ ' in string data:
+ * s/strchr/_find_unescaped_space()/
+ */
+ if ((p = strchr(string_data, ' '))) {
+ /* terminate program_id string. */
+ *p = '\0';
+ if (!strcmp(program_id, "-"))
+ program_id = empty_string;
+ aux_data = p + 1;
+ if ((p = strchr(aux_data, ' '))) {
+ /* terminate aux_data string. */
+ *p = '\0';
+ if (!strcmp(aux_data, "-"))
+ aux_data = empty_string;
+ stats_args = p + 1;
+ } else
+ stats_args = empty_string;
+ } else
+ aux_data = stats_args = empty_string;
+
+ if (strstr(stats_args, PRECISE_ARG))
+ region->timescale = 1;
+ else
+ region->timescale = NSEC_PER_MSEC;
if (!(region->program_id = dm_strdup(program_id)))
return_0;
@@ -621,14 +669,17 @@ uint64_t dm_stats_get_nr_areas(const struct dm_stats *dms)
return nr_areas;
}
-int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
- uint64_t start, uint64_t len, int64_t step,
- const char *program_id, const char *aux_data)
+static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
+ uint64_t start, uint64_t len, int64_t step,
+ int precise,
+ const char *program_id, const char *aux_data)
{
struct dm_task *dmt = NULL;
char msg[1024], range[64];
const char *err_fmt = "Could not prepare @stats_create %s.";
- const char *resp;
+ const char *precise_str = PRECISE_ARG;
+ const char *resp, *opt_args = NULL;
+ int nr_opt = 0, r = 0; /* number of optional args. */
if (!_stats_bound(dms))
return_0;
@@ -640,16 +691,35 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
if (!dm_snprintf(range, sizeof(range), FMTu64 "+" FMTu64,
start, len)) {
log_error(err_fmt, "range");
- goto out;
+ return 0;
}
}
- if (!dm_snprintf(msg, sizeof(msg), "@stats_create %s %s" FMTu64 " %s %s",
- (start || len) ? range : "-",
+ if (precise < 0)
+ precise = dms->precise;
+
+ if (precise)
+ nr_opt++;
+ else
+ precise_str = "";
+
+ if (nr_opt) {
+ if ((dm_asprintf((char **)&opt_args, "%d %s", nr_opt,
+ precise_str)) < 0) {
+ log_error(err_fmt, PRECISE_ARG " option.");
+ return 0;
+ }
+ } else
+ opt_args = dm_strdup("");
+
+ if (!dm_snprintf(msg, sizeof(msg), "@stats_create %s %s" FMTu64
+ " %s %s %s", (start || len) ? range : "-",
(step < 0) ? "/" : "",
- (uint64_t)llabs(step), program_id, aux_data)) {
+ (uint64_t)llabs(step),
+ opt_args, program_id, aux_data)) {
log_error(err_fmt, "message");
- goto out;
+ dm_free((void *) opt_args);
+ return 0;
}
if (!(dmt = _stats_send_message(dms, msg)))
@@ -668,14 +738,45 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
goto_out;
}
- dm_task_destroy(dmt);
+ r = 1;
- return 1;
out:
if(dmt)
dm_task_destroy(dmt);
- return 0;
+ dm_free((void *) opt_args);
+ return r;
+}
+
+int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
+ uint64_t start, uint64_t len, int64_t step,
+ int precise,
+ const char *program_id,
+ const char *aux_data)
+{
+ /* Nanosecond counters need precise_timestamps. */
+ if (precise && !_stats_check_precise_timestamps(dms))
+ return 0;
+
+ return _stats_create_region(dms, region_id, start, len, step,
+ precise,
+ program_id, aux_data);
+}
+
+/* Backward compatible dm_stats_create_region() */
+#if defined(__GNUC__)
+int dm_stats_create_region_v1_02_104(struct dm_stats *dms, uint64_t *region_id,
+ uint64_t start, uint64_t len, int64_t step,
+ const char *program_id, const char *aux_data);
+int dm_stats_create_region_v1_02_104(struct dm_stats *dms, uint64_t *region_id,
+ uint64_t start, uint64_t len, int64_t step,
+ const char *program_id, const char *aux_data)
+{
+ return _stats_create_region(dms, region_id, start, len, step,
+ dms->precise,
+ program_id, aux_data);
}
+DM_EXPORT_SYMBOL(dm_stats_create_region, 1_02_104);
+#endif
int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
{
@@ -815,7 +916,7 @@ static int _dm_stats_populate_region(struct dm_stats *dms, uint64_t region_id,
if (!_stats_bound(dms))
return_0;
- if (!_stats_parse_region(dms->mem, resp, region, dms->timescale)) {
+ if (!_stats_parse_region(dms->mem, resp, region, region->timescale)) {
log_error("Could not parse @stats_print message response.");
return 0;
}
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 45d4173..b8376dd 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4520,6 +4520,7 @@ static int _do_stats_create_regions(struct dm_stats *dms,
this_len = (segments) ? segment_len : this_len;
if (!dm_stats_create_region(dms, ®ion_id,
this_start, this_len, step,
+ -1,
program_id, aux_data)) {
log_error("%s: Could not create statistics region.",
devname);
8 years, 3 months