]> sourceware.org Git - lvm2.git/commitdiff
thin: display highest mapped sector
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 30 Mar 2016 09:14:13 +0000 (11:14 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 31 Mar 2016 10:20:43 +0000 (12:20 +0200)
Use  meta%  to expose highest mapped sector in thinLV.
so showing there 100.00% means thinLV maps latest sector.

Currently using a 'trick' with total_numerator to pass-in
device size when  'seg==NULL'

TODO: Improve device status API per target - current 'percentage'
is not really extensible.

WHATS_NEW
lib/activate/dev_manager.c
lib/thin/thin.c

index 3237e0a91a4541f0c5a7712469aa44e9e0d8f53e..2ad2d69d2f5ae399de33e010ec40a2faf90d1109 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.149 - 
 ==================================
+  Report highest mapping for thin volume as Meta%.
   Do not flush thin-pool when checking metadata fullness.
   Remove spurious error about no value in /sys/dev/block/major:minor/dm/uuid.
   Fix device mismatch detection for LV if persistent .cache file is used.
index 2696c5604388418d384e1672f02cfe4519043f36..40e4086d7d9214dd77f263de8a65b211adb3b076 100644 (file)
@@ -938,6 +938,10 @@ static int _percent_run(struct dev_manager *dm, const char *name,
                if (!segtype->ops->target_percent)
                        continue;
 
+               /* For thin volume pass device size via 'total_numerator' */
+               if (!seg && segtype_is_thin_volume(segtype))
+                       total_numerator = length - 1; /* highest mapped is  0 .. (length - 1) */
+
                if (!segtype->ops->target_percent(&dm->target_state,
                                                  &percent, dm->mem,
                                                  dm->cmd, seg, params,
index a85075739532d22ec627885548af555aa7c23990..c07859ae8b43c5bd068f9c0f77569ba1981ee5f6 100644 (file)
@@ -613,7 +613,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
 static int _thin_target_percent(void **target_state __attribute__((unused)),
                                dm_percent_t *percent,
                                struct dm_pool *mem,
-                               struct cmd_context *cmd __attribute__((unused)),
+                               struct cmd_context *cmd,
                                struct lv_segment *seg,
                                char *params,
                                uint64_t *total_numerator,
@@ -643,15 +643,18 @@ static int _thin_target_percent(void **target_state __attribute__((unused)),
 
                *percent = dm_make_percent(s->mapped_sectors, csize);
                *total_denominator += csize;
+               *total_numerator += s->mapped_sectors;
        } else {
-               /* No lv_segment info here */
-               *percent = DM_PERCENT_INVALID;
-               /* FIXME: Using denominator to pass the mapped info upward? */
+               /* Using denominator to pass the mapped info upward? */
+               if (s->highest_mapped_sector > *total_numerator) {
+                       log_warn("WARNING: highest mapped sector %s is above device size.",
+                                display_size(cmd, s->highest_mapped_sector));
+                       s->highest_mapped_sector = *total_numerator;
+               }
+               *percent = dm_make_percent(s->highest_mapped_sector, *total_numerator);
                *total_denominator += s->highest_mapped_sector;
        }
 
-       *total_numerator += s->mapped_sectors;
-
        return 1;
 }
 
This page took 0.05637 seconds and 5 git commands to generate.