Skip to contentSkip to conversation

master - libdm: fix dm_stats_delete_region() backwards compat

PATCH Bryn Reeves 1 participant 1 message Sep 27, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56c90ffa5e7d7c69c5230ac3bbee3ed03e7bae62
Commit:        56c90ffa5e7d7c69c5230ac3bbee3ed03e7bae62
Parent:        6ec8854fdb051b092d5e262dc6c6d4c2ea075cd1
Author:        Bryn M. Reeves <[email protected]>
AuthorDate:    Tue Sep 27 17:46:52 2016 +0100
Committer:     Bryn M. Reeves <[email protected]>
CommitterDate: Tue Sep 27 17:58:05 2016 +0100

libdm: fix dm_stats_delete_region() backwards compat

The dm_stats_delete_region() call removes a region from the bound device, and, if the region is grouped, from the group leader group descriptor stored in aux_data.

To do this requires a listed handle: previous versions of the library do not since no dependencies exist between regions without grouping.

This leads to strange behaviour when a command built against an old version of the library is used with one supporting groups. Deleting a region with dmstats succeeds, but logs errors:

  # dmstats list
  Name             RgID RgSta RgSiz #Areas ArSize ProgID
  vg_hex-root         0     0 1.00g      1  1.00g dmstats
  vg_hex-root         1 1.00g 1.00g      1  1.00g dmstats
  vg_hex-root         2 2.00g 1.00g      1  1.00g dmstats
  # dmstats delete --regionid 2 vg_hex/root
  Region ID 2 does not exist
  Could not delete statistics region.
  Command failed
  # dmstats list
  Name             RgID RgSta RgSiz #Areas ArSize ProgID
  vg_hex-root         0     0 1.00g      1  1.00g dmstats
  vg_hex-root         1 1.00g 1.00g      1  1.00g dmstats

This happens because the call to dm_stats_delete_region() is inside a dm_stats_walk_*() iterator: upon entry to the call, the iterator is at its end conditions and about to terminate. Due to the call to dm_stats_list() inside the function, it returns with an iterator at the beginning of a walk and performs a further iteration before exiting. This final loop makes a further attempt to delete the (already deleted) region, leading to the confusing error messages.

---
 WHATS_NEW_DM        |    1 +
 libdm/libdm-stats.c |   48 +++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 40 insertions(+), 9 deletions(-)
WHATS_NEW_DM +1 -0
index b048f7a..ed07307 100644
@@ -1,5 +1,6 @@
 Version 1.02.136 - 
 ======================================
+  Fix 'dmstats delete' with dmsetup older than v1.02.129
   Fix stats walk segfault with dmsetup older than v1.02.129
 
 Version 1.02.135 - 26th September 2016
libdm/libdm-stats.c +39 -9

94 lines not on this page · raw message