1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

1134 Commits

Author SHA1 Message Date
Alasdair G Kergon
7dcbf1dfd0 libdm: Correct typo. 2016-04-07 01:51:09 +01:00
Zdenek Kabelac
261a85ced9 libdm: improve debug message with ioctl
Make the debug message a less difficult to read:
Ioctl shows  [ noopencount flush ] instead of cryptic [NF].
2016-04-06 11:31:02 +02:00
Alasdair G Kergon
a5d53aec83 libdm: Raid status region units are sectors 2016-03-24 17:42:36 +00:00
Alasdair G Kergon
1056894f1f raid: Tidy dm_get_status_raid. [HM] 2016-03-22 21:39:52 +00:00
Alasdair G Kergon
cf39346697 libdm: Move _skip_fields within file. 2016-03-22 19:35:14 +00:00
Alasdair G Kergon
65d2d66d02 libdm: Change _advance_to_next_word to _skip_fields 2016-03-22 19:26:13 +00:00
Zdenek Kabelac
29d1533a49 libdm: parse more info from cache status
Parse Fail/Error/need_check/ro status info from cache.
2016-03-10 18:38:53 +01:00
Peter Rajnoha
9720898c8e libdm: config: fix dm_config_write_node and variants to properly return error on failures
The error was not propagated if _write_config (that is part of
dm_config_write_node and all its variants) was called recursively
for subsections.
2016-03-04 15:51:13 +01:00
Peter Rajnoha
67c5006e12 cleanup: previous patch with libdm config node buffer size 2016-03-04 15:19:09 +01:00
Peter Rajnoha
967a0889a0 libdm: config: remove 4096 char limit due to buffer size if writing dm_config_node 2016-03-04 14:59:22 +01:00
Zdenek Kabelac
36d0dcef38 coverity: eliminate DEADCODE
Coverity notice this cannot be NULL: cur = &dms->regions[*cur_r]
so avoid NULL checking and simplify form.
2016-03-01 14:02:43 +01:00
Zdenek Kabelac
79809d6cdc cleanup: use sizeof instead of macro.
Keep the buffer size defined at a single place and then use
its sizeof.
2016-02-23 21:40:17 +01:00
Zdenek Kabelac
6d6e063a0f libdm: fix string boundary
The test for string 'end' needs to account for ending \0,
which also needs to fit <SIZE.
2016-02-23 21:38:52 +01:00
Zdenek Kabelac
dbc71dc05e gcc: cleanup some sign warnings
When comparing unsigned with int, the comparision is made
as 'unsigned' type, so make it rather explicit which type
is being compared.
2016-02-23 12:25:25 +01:00
Zdenek Kabelac
3178cfc818 cleanup: use char arrays. 2016-02-22 14:27:44 +01:00
Zdenek Kabelac
fba54ae55e cleanup: libdm clang warnings
Add some extra clang pointer validation so we do not try deref NULL.
2016-02-22 14:18:28 +01:00
Zdenek Kabelac
275c9f7e77 libdm: grow with initialized struct content
Coverity noticed struct hist has been copied uninitalized into mempool.
2016-02-22 14:17:32 +01:00
Zdenek Kabelac
0fb3669d49 libdm: thin status update
Fix parsing of 'Fail' status (using capital letter) for thin-pool.
Add also parsing of 'Error' state for thin-pool.
Add needs_check test for thin-pool.

Detect Fail state for thin.
2016-02-18 16:45:42 +01:00
Zdenek Kabelac
0baf66a992 dm: alloc always 8byte aligned
Fixing regression caused by 197b5e6dc7.
So the 'TODO' part now finally know the answer - there is 'sparc64'
architecture which imposes limitation to read 64b words only through
64b aligned address.

Since we never could know how is the user going to use the returned
pointer and the userusually expects it's aligned on the highest CPU
required alignement, preserve it also for char*.

Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809685
Reported-by: Anatoly Pugachev <matorola@gmail.com>
2016-02-11 18:35:05 +01:00
M.H. Tsai
f91622741f dm: fix thin-pool targer params order
Wrong thin-pool feature flag ordering in dm table: It will lead to
unnecessary table reload.

Fix it by placeing feature flags in order they are returned from the
kernel so current 'table line diff' code will not see a difference.
2016-02-11 18:32:24 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Zdenek Kabelac
45781161f4 libdm: add some doc for mirror status
Comment content of struct for mirror status.
2015-12-04 22:10:30 +01:00
Zdenek Kabelac
fa87979004 libdm: introduce dm_get_status_mirror
Add missing function to parse mirror status.
2015-12-01 13:00:43 +01:00
Zdenek Kabelac
d582be43d4 libdm: const raid params and error for unsupported type
Accept const struct with raid params (No API change).
Also add extra error message when raid type is unsupported.
2015-11-26 09:27:04 +01:00
Zdenek Kabelac
6ca5447e0c libdm: enhance thin-pool preload
When preloading thin-pool device node for already
existing/running thin-pool do not resume such thin-pool.

This allows to properly schedule commit point for metadata,
when thin-pool data or metadata volume is resized.
2015-11-23 23:34:46 +01:00
Zdenek Kabelac
ddbf0075b1 libdm: drop extra space from cache target line
Extra space between 'cache' target and metadata device caused
string comparation being not equal and thus always causing
table reload even when uneeded.
2015-11-23 23:33:37 +01:00
Zdenek Kabelac
0614c63579 cleanup: cast resulting value explicitely 2015-11-19 11:59:19 +01:00
Zdenek Kabelac
0b2be60497 cleanup: add stack traces 2015-11-18 22:17:26 +01:00
Peter Rajnoha
0a2cadf6b8 libdm: report: consolidate use of string list selection structures 2015-11-18 10:54:09 +01:00
Zdenek Kabelac
83661c8f7f cleanup: use embeded list
Skip pointer and put list into selection_str_list.
2015-11-17 19:01:25 +01:00
Zdenek Kabelac
121341e52c cleanup: unify NULL custom check
Unify testing of NULL custom pointer.
Resolve 'factor' only in required if() branch.
2015-11-17 19:01:25 +01:00
Zdenek Kabelac
51dfba002b libdm: update error message
Correcting error message.
2015-11-17 19:01:25 +01:00
David Teigland
931fede81b hash: change name of new lookup function 2015-11-17 11:59:44 -06:00
David Teigland
485d2ca945 lvmetad: different style for hash functions
In lookup, return a count of entries with the
same key rather than the value from a second
entry with the same key.

Using some slightly different names.
2015-11-17 10:27:16 -06:00
David Teigland
920a281994 hash: add comment about multiple values 2015-11-16 11:02:25 -06:00
Zdenek Kabelac
b6a45963e3 libdm: fix check of pointer
Ahhh being blind here - wanted to check the pointer before dereference
not a dereferenced one.
2015-11-16 13:10:24 +01:00
Zdenek Kabelac
2a2487f02f libdm: better error reporting from dm_split_lvm_name
Report errors from all error paths correctly.
Validate passed args before dereferencing them.
2015-11-16 13:09:53 +01:00
Zdenek Kabelac
96d73dc6ea libdm: check for passed custom time value
Coverity reports custom should be checked before derefernce.
2015-11-16 01:16:11 +01:00
Zdenek Kabelac
d4288c9bdf libdm: check for null from pool strdup
Unlikely to happen, but Coverity shown we may have possible
derefer NULL pointer.
2015-11-16 01:16:09 +01:00
Zdenek Kabelac
422c7474ca libdm: check if passed return pointer is not NULL
Coverity: before storing return value, check passed space will
not dereference NULL pointer.
2015-11-16 01:15:04 +01:00
David Teigland
d9295410e9 lvmetad: change the new hash to take data len
If the data len is passed into the hash table
and saved there, then the hash table internals
do not need to assume that the data value is
a string at any point.
2015-11-13 16:54:22 -06:00
David Teigland
46193f4a59 lvmetad: handle duplicate VG names
New hash table functions are added that allow for
multiple entries with the same key.  Use of the
vgname_to_vgid hash table is converted to these
new functions since there are multiple entries
in vgname_to_vgid that have the same key (vgname).

When multiple VGs with the same name exist, commands
that reference only a VG name will fail saying the
VG could not be found (that error message could be
improved.)  Any command that works with the select
option can access one of the VGs with -S vg_uuid=X.
vgrename is a special case that allows the first VG
name arg to be replaced by a uuid, which also works.

(The existing hash table implementation is not well
suited for handling this case, but it works ok with
the new extensions.  Changing lvmetad to use its own
custom hash tables may be preferable at some point.)
2015-11-13 14:56:35 -06:00
Zdenek Kabelac
d74e1291cd libdm: put in secure check
Coverity complains about NULL deref - while this cannot currently
happen, put in secure INTERNAL_ERROR.
2015-11-13 11:17:05 +01:00
Zdenek Kabelac
6d0db97163 libdm: reorder error path
Coverity noticed recent fix of an error path missed to
release 'dmt' - reoder code to ensure 'dmt' is released.
2015-11-10 21:41:47 +01:00
Zdenek Kabelac
fb59847a0f libdm: replace assign with increment
Coverity didn't liked assign with && expression, so use trick.
It does not complain against this prefix incremenent operation.
2015-11-09 22:51:48 +01:00
Zdenek Kabelac
846adadbcc cleanup: use code in place
Pass const strings to printf(),
and use  struct names directly instead of creating unused vars on stack.
2015-11-09 10:22:52 +01:00
Zdenek Kabelac
3cadc1c87e libdm: add test for dm_task_get_message_response()
Coverity notices dm_task_get_message_response() result should be
checked for NULL which should not be passed to dm_pool_strdup().
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
84303dc17a libdm: exlicitly check for NULL
Coverity: another explict check for NULL, where coverity fails to
see it.
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
f6c140e200 libdm: ensure vars are initialized
Coverity found potential error path, where code could
have used some unset variables.
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
b1c4017743 libdm: add missing error path check
Coverity: do not continue with section cloning when root node
would a NULL.
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
428ca9b120 libdm: enable no_flush for driver version > 11
It appears the driver version 11 has troubles with usage of no_flush
So require at least version 12.
2015-10-26 07:37:59 +01:00
Zdenek Kabelac
9ef820a2a5 libdm: dm_tree_node_size_changed recognizes reduction
Add more functionality to size_changed function.
While 'existing' API only detected  0 for
unchanged,  and !0 for changed,
new improved API will also detected if the
size has only went bigger - or there was
size reduction.

Function work for the whole dm-tree - so
no change is size is always 0.
only size extension  1.
and if some size reduction is there - returns -1.

This result can be used for better evaluation
whether we need to flush before suspend.
2015-10-25 21:05:15 +01:00
Zdenek Kabelac
39cffa4e9b cleanup: declare vars before code 2015-10-22 22:46:10 +02:00
Zdenek Kabelac
09a62cca0c libdm: add dm_hold_control_dev
Support hold of control device open.
Useful for daemons so the control device is not frequently reopenned.
2015-10-22 22:27:31 +02:00
Peter Rajnoha
c3bfe07f2a config: add report/compact_output_cols to control which columns to compact in report output
The new report/compact_output_cols setting has exactly the same effect
as report/compact_output setting. The difference is that with the new
setting it's possible to define which cols should be compacted exactly
in contrast to all cols in case of report/compact_output.

In case both compact_output and compact_output_cols is enabled/set,
the compact_output prevails.

For example:

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols=""

$ lvs vg
  LV    VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lvol0 vg   -wi-a----- 4.00m

---

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"

$ lvs vg
  LV    VG   Attr       LSize Log Cpy%Sync Convert
  lvol0 vg   -wi-a----- 4.00m

---

$ lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=1
compact_output_cols="data_percent,metadata_percent,pool_lv,move_pv,origin"

$ lvs vg
  LV    VG   Attr       LSize
  lvol0 vg   -wi-a----- 4.00m
2015-10-16 17:05:54 +02:00
Peter Rajnoha
508f0f5a21 libdm: add dm_report_compact_given_fields
dm_report_compact_given_fields is the same as dm_report_compact_fields,
but it processes only given fields, not all the fields in the report
like dm_report_compact_field does.
2015-10-16 17:05:54 +02:00
Zdenek Kabelac
362558cd66 cleanup: typo in comment 2015-10-13 15:22:58 +02:00
Zdenek Kabelac
5695c6aca6 libdm: enforce writethrough mode for cleaner
With "cleaner" policy always use 'writethrough' mode.
2015-10-13 14:35:48 +02:00
Alasdair G Kergon
0173c260d8 libdm: Move status fns from deptree to targets.
libdm-deptree is only for functions working with dm tree nodes.
2015-09-28 20:28:31 +01:00
Heinz Mauelshagen
1945a0f504 libdm: fix bogus macro causing false parameter count 2015-09-24 14:22:52 +02:00
Heinz Mauelshagen
4e60e62444 raid: Fix raid target write_behind parameter.
Now uses correct "max_write_behind" instead of "writebehind".
(Includes some tidying up.)
2015-09-23 15:53:27 +01:00
Heinz Mauelshagen
96a6210198 libdm: Improve raid segment parameter handling. 2015-09-23 15:25:46 +01:00
Zdenek Kabelac
e0d915a873 libdm: parse Overflow string from snapshot status
This is likely to be a new 'info' provided by kernel
snapshot target.
For now just parse this string.
2015-09-18 17:45:45 +02:00
Peter Rajnoha
6c0b4a2769 libdm: file: add proper checks for directory components in dm_create_dir
Also make error messages more consistent:

Before this patch:

(/run/lock exists and is not a directory)
$ pvs
  /run/lock/lvm: mkdir failed: Not a directory
  File-based locking initialisation failed.

(/run/lock/lvm exists and is not a directory)
$ pvs
  Directory "/run/lock/lvm" not found
  File-based locking initialisation failed.

With this patch applied:

(/run/lock exists and is not a directory)
$ pvs
  Existing path /run/lock is not a directory.
  Failed to create directory /run/lock/lvm.
  File-based locking initialisation failed

(/run/lock/lvm exists and is not a directory)
$ pvs
  Existing path /run/lock/lvm is not a directory.
  Failed to create directory /run/lock/lvm.
  File-based locking initialisation failed.
2015-09-17 14:29:51 +02:00
Peter Rajnoha
afdae26c71 libdm: dev_node: use lstat instead of stat while removing and renaming nodes
When using udev, the /dev/mapper entries are symlinks - fix the code
to count with this.

This patch also fixes the dmsetup mknodes and vgmknodes to properly
repair /dev/mapper content if it sees dangling symlink in /dev/mapper.
2015-09-17 13:37:15 +02:00
Peter Rajnoha
b5022102bb libdm: report: make it possible to use blank value as selection for string list report field
$ lvs -o name,tags vg
  LV    LV Tags
  lvol0
  lvol1 mytag

Before this patch:
$ lvs -o name,tags vg -S 'tags=""'
  Failed to parse string list value for selection field lv_tags.
  Selection syntax error at 'tags=""'.
  Use 'help' for selection to get more help.

(and the same for -S 'tags={}' and -S 'tags=[]')

With this patch applied:
$ lvs -o name,tags vg -S 'tags=""'
  LV    LV Tags
  lvol0

(and the same for -S 'tags={}' and -S 'tags=[]')
2015-09-17 10:19:15 +02:00
Alasdair G Kergon
a729b1aa29 pre-release 2015-09-15 13:17:50 +01:00
Zdenek Kabelac
c356991fa8 libdm: no validate for pool without messages
Avoid validation of free space in pool, when no messages are passed.

Patch a3c7e326c3 add new check for
pool overload - but this check should not be made if there are
no messages and transaction_id is still within 'bounds' (bigger by 1).
2015-09-14 20:18:54 +02:00
Bryn M. Reeves
d7f45ebca5 libdm: clean up stats local variable use 2015-09-07 20:14:53 +01:00
Bryn M. Reeves
daa94eb792 libdm: fix display of nsec suffixes in histogram strings 2015-09-07 20:14:53 +01:00
Bryn M. Reeves
5f990473e4 libdm: clean up _build_histogram_arg()
Split up _build_histogram_arg() into separate functions to allocate
and fill the histogram arg string and remove nested local variable
declarations from the parent function.
2015-09-07 19:30:03 +01:00
Bryn M. Reeves
4bc7a86f3a libdm: only free the first histogram explicitly (Coverity)
Coverity flags a user-after-free in _stats_histograms_destroy():

>>>     Calling "dm_pool_free" frees pointer "mem->chunk" which has
>>>     already been freed.

This should not be possible since the histograms are destroyed in
reverse order of allocation:

 203         for (n = _nr_areas_region(region) - 1; n; n--)
 204                 if (region->counters[n].histogram)
 205                         dm_pool_free(mem, region->counters[n].histogram);

It appears that Coverity is unaware that pool->chunk is updated
during the call to dm_pool_free() and valgrind flags no errors in
this function when called with multiple allocated histograms.

Since there is no actual need to free the histograms individually
in this way simplify the code and just free the first allocated
object (which will also free all later allocated histograms in a
single call).
2015-09-07 17:53:56 +01:00
Bryn M. Reeves
ab1b54c3e3 libdm: fix dm_stats leak in dm_stats_create()
The histogram changes adds a new error path to dm_stats_create().
Make sure that the dm_stats handle is properly destroyed if we fail
to create the histogram pool and check for failures setting the
program_id.
2015-09-07 12:08:34 +01:00
Bryn M. Reeves
0f5933ecc1 libdm: handle pool errors in dm_histogram_to_string() 2015-09-07 12:01:20 +01:00
Bryn M. Reeves
e75b4bc2df libdm: check dm_pool_begin_object() return value. 2015-09-07 11:52:54 +01:00
Bryn M. Reeves
36b09fd147 libdm: add missing error handling in _stats_parse_histogram()
Since we are growing an object in the histogram pool the return
value of dm_pool_grow_object() must be checked and error paths need
to abandon the object before returning.
2015-09-07 11:44:53 +01:00
Alasdair G Kergon
fb12308416 style: Standardise some error paths. 2015-09-05 23:56:30 +01:00
Bryn M. Reeves
cdca2782d2 libdm: fix uninitialized variable warnings on older gcc
Older versions of gcc aren't able to track the assignments of
local variables as well as the latest versions leading to spurious
warnings like:

libdm-stats.c:2183: warning: "len" may be used uninitialized in this
function
libdm-stats.c:2177: warning: "minwidth" may be used uninitialized in
this function

Both of these variables are in fact assigned in all possible paths
through the function and later compilers do not produce these
warnings.

There's no reason to not initialize these variables though and
it makes the function slightly easier to follow.

Also fix one use of 'unsigned' for a nr_bins value.
2015-09-04 11:46:48 +01:00
Zdenek Kabelac
0a389691dc cleanup: avoid printing -0.00
Nice trick to not print -0.00 for some percent values.
2015-09-03 23:34:37 +02:00
Zdenek Kabelac
a3c7e326c3 libdm: relocate parsing of thin-pool status
Use single routine for parsing status.

Internally we do not need to allocate pool memory for
passed struct.
2015-09-03 23:34:36 +02:00
Bryn M. Reeves
f09e4f7b10 libdm: allow formatting histogram strings with no whitespace
Allow dm_histogram_to_string() to format histogram strings with
no whitespace by passing a width value less than zero.
2015-09-03 22:04:10 +01:00
Peter Rajnoha
fc35b6988d libdm: pkgconfig: fix devmapper.pc to not reference nonexistent rt.pc file
librt doesn't have a pkgconfig file so use Libs.private: -lrt instead
to declare the dependency directly.

The same applies for -lm which is also used and which hasn't been
defined in the devmapper.pc file yet.
2015-09-03 09:28:42 +02:00
Bryn M. Reeves
a0cf3d47f1 libdm: add latency histogram support
Add support for creating, parsing, and reporting dm-stats latency
histograms on kernels that support precise_timestamps.

Histograms are specified as a series of time values that give the
boundaries of the bins into which I/O counts accumulate (with
implicit lower and upper bounds on the first and last bins).

A new type, struct dm_histogram, is introduced to represent
histogram values and bin boundaries.

The boundary values may be given as either a string of values (with
optional unit suffixes) or as a zero terminated array of uint64_t
values expressing boundary times in nanoseconds.

A new bounds argument is added to dm_stats_create_region() which
accepts a pointer to a struct dm_histogram initialised with bounds
values.

Histogram data associated with a region is parsed during a call to
dm_stats_populate() and used to build a table of histogram values
that are pointed to from the containing area's counter set. The
histogram for a specified area may then be obtained and interogated
for values and properties.

This relies on kernel support to provide the boundary values in
a @stats_list response: this will be present in 4.3 and 4.2-stable. A
check for a minimum driver version of 4.33.0 is implemented to ensure
that this is present (4.32.0 has the necessary precise_timestamps and
histogram features but is unable to report these via @stats_list).

Access methods are provided to retrieve histogram values and bounds
as well as simple string representations of the counts and bin
boundaries.  Methods are also available to return the total count
for a histogram and the relative value (as a dm_percent_t) of a
specified bin.
2015-09-02 20:48:59 +01:00
Bryn M. Reeves
c4f3732c91 libdm: reset report field widths in _destroy_rows()
For repeating reports field widths should be re-calculated for
each report interval. Not doing so will cause a single row with
wide field data to cause all subsequent rows to share the width:

Name                                      RgID ArID R/s     W/s    Histogram                                     Bounds
vg_hex-lv_home                               0    0 4522.00 834.00 0s:   991, 2ms:   152, 4ms:   161, 6ms:  4052 0s, 2ms, 4ms, 6ms
vg_hex-lv_swap                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_root                               0    0 1754.00 683.00 0s:  369, 2ms:   65, 4ms:   90, 6ms: 1913     0s, 2ms, 4ms, 6ms
luks-79733921-3f68-4c92-9eb7-d0aca4c6ba3e    0    0 4522.00 868.00 0s:   985, 2ms:   152, 4ms:   161, 6ms:  4092 0s, 2ms, 4ms, 6ms
vg_hex-lv_images                             0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms

Name                                      RgID ArID R/s     W/s    Histogram                                     Bounds
vg_hex-lv_home                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_swap                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_root                               0    0    0.00   2.00 0s: 1, 2ms: 0, 4ms: 0, 6ms: 1                 0s, 2ms, 4ms, 6ms
luks-79733921-3f68-4c92-9eb7-d0aca4c6ba3e    0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_images                             0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
                                                                                                ^^^^^^^^^^^^^^^^^
This is especially significant for the current histogram fields:
depending on the time since the last clear operation the first
report iteration may contain very large values leading to a very
large minimum field width. Without resetting field widths this
large minimum field width value is used for all subsequent rows.
2015-09-02 20:48:59 +01:00
Alasdair G Kergon
746b1bcf2a libdm: Drop ignored duplicate export designation.
dm_stats_create_region is now assigned to DM_1_02_106 by default:
the DM_1_02_104 .exported_symbols file entry was moved into
libdm-stats.c as:
  DM_EXPORT_SYMBOL(dm_stats_create_region, 1_02_104)
so delete it from .exported_symbols.DM_1_02_104.
2015-08-26 17:30:36 +01:00
Bryn M. Reeves
567189cc76 libdm: add per region precise timestamps property methods 2015-08-24 20:03:21 +01:00
Bryn M. Reeves
f4262026b6 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.
2015-08-24 20:03:21 +01:00
Bryn M. Reeves
82a27a85b5 macros: fix default symbol export control
Fix the version export macros to make it possible to export two
different DM_* versions of a symbol: currently it is only possible for a
DM_* symbol to override a symbol in Base. Attempting to export two
symbols at different DM_* version levels (e.g. DM_1_02_104 and
DM_1_02_106) leads to a linker error due to a duplicate symbol
definition.

This is because the DM_EXPORTED_SYMBOL macro makes each exported symbol
the default (@@VERSION):

       __asm__(".symver " #func "_v" #ver ", " #func "@@DM_" #ver )

Fix the macro to use a single '@' for a symbols exported in multiple
versions and rename the macros to DM_EXPORT_*:

  DM_EXPORT_SYMBOL(func,ver)
  DM_EXPORT_SYMBOL_BASE(func,ver)

For functions that have multiple implementations these macros control
symbol export and versioning.

Function definitions that exist in only one version never need to use
these macros.

Backwards compatible implementations must include a version tag of
the form "_v1_02_104" as a suffix to the function name and use the
macro DM_EXPORT_SYMBOL to export the function and bind it to the
specified version string.

Since versioning is only available when compiling with GCC the entire
compatibility version should be enclosed in '#if defined(__GNUC__)',
for example:

  int dm_foo(int bar)
  {
    return bar;
  }

  #if defined(__GNUC__)
  // Backward compatible dm_foo() version 1.02.104
  int dm_foo_v1_02_104(void);
  int dm_foo_v1_02_104(void)
  {
    return 0;
  }
  DM_EXPORT_SYMBOL(dm_foo,1_02_104)
  #endif

A prototype for the compatibility version is required as these
functions must not be declared static.

The DM_EXPORT_SYMBOL_BASE macro is only used to export the base
versions of library symbols prior to the introduction of symbol
versioning: it must never be used for new symbols.
2015-08-24 20:03:21 +01:00
Bryn M. Reeves
386e91addb libdm: add dm_message_supports_precise_timestamps()
Add a function to test whether the kernel precise_timestamps
feature is available in the current device-mapper driver version.

Presence of precise_timestamps also implies the availability of
latency histograms.
2015-08-20 12:11:23 +01:00
Bryn M. Reeves
c1bd76d6fc configure: check for -lm and log10 function
We already use -lm functions in a couple of places (these are
satisfied by gcc built-ins for most builds): add a configure.in
check and explicitly link to -lm.
2015-08-18 15:25:54 +01:00
Zdenek Kabelac
6e1feb0f73 cleanup: preserve constness of some pointers 2015-08-18 16:05:04 +02:00
Zdenek Kabelac
55a9262bdb cleanup: unused header files (Coverity) 2015-08-18 15:00:08 +02:00
Zdenek Kabelac
ba94d0f144 libdm: simplify dmstats formula.
Since we check for stats for not being 0,
simplify the operation and use a single division.
2015-08-18 15:00:08 +02:00
Bryn M. Reeves
074b5de771 libdm: check for zero in _nr_areas() (Coverity) 2015-08-17 18:37:16 +01:00
Bryn M. Reeves
8967776713 libdm: do not read region before checking dms for NULL (Coverity)
dm_stats_get_area_start() attempts to assign a region pointer from
a stats handle before checking it is non-NULL: move the assignment
after the test.
2015-08-17 18:37:16 +01:00
Alasdair G Kergon
be1db6b6c1 pre-release 2015-08-17 17:20:14 +01:00
Bryn M. Reeves
4227b2ebb4 libdm-stats: only return uint64_t when required
Several interfaced in libdm-stats return a uint64_t when it is
only used to signal success/failure: change all these uses to
return a simple int instead.
2015-08-17 16:59:52 +01:00
Bryn M. Reeves
427d0a5e92 libdm: ensure dm_stats_get_area_offset() returns a value 2015-08-17 14:40:48 +01:00
Zdenek Kabelac
79ea81b8a8 thin: restore transaction_id handling
Revert back to already existing behavior which has been slightly
modified by a900d150e4.

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.
2015-08-17 11:25:03 +02:00
Bryn M. Reeves
00ed523659 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.
2015-08-14 22:03:37 +01:00