]> sourceware.org Git - lvm2.git/commitdiff
thin: report needs_check and fail state
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 18 Feb 2016 12:19:25 +0000 (13:19 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 18 Feb 2016 15:49:34 +0000 (16:49 +0100)
Fix reporting of Fail thin-pool target status
as attr[8] letter 'F'.

Report  'needs_check' status from thin-pool target via
attr field [4] (letter 'c'/'C'), and also via CheckNeeded field.

TODO: think about better name here?
TODO: lots of prop_not_implemented_set

WHATS_NEW
lib/activate/dev_manager.c
lib/metadata/lv.c
lib/report/columns.h
lib/report/properties.c
lib/report/report.c
lib/report/values.h

index 27bb7e2ada30d5dfa7a2576ecae258c6c6e6732e..8d9294b3f17fcc9d77f481b92c59061b8d89bf40 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.143 -
 =====================================
+  Support reporting CheckNeeded and Fail state for thin-pool and thin LV.
   For failing thin-pool and thin volume correctly report percentage as INVALID.
   Report -1, not 'unkown' for lv_{snapshot_invalid,merge_failed} with --binary.
   Add configure --enable-dbus-service for an LVM D-Bus service.
index 66a301af6c745eb7e29482d099ad10a1c88f101b..2826218e03d4fc1065f88743d514fd80c40452fb 100644 (file)
@@ -130,7 +130,9 @@ static int _get_segment_status_from_target_params(const char *target_name,
         * linear/striped, old snapshots and raids have proper
         * segment selected for status!
         */
-       if (strcmp(target_name, "cache") && strcmp(target_name, "thin-pool"))
+       if (strcmp(target_name, "cache") &&
+           strcmp(target_name, "thin-pool") &&
+           strcmp(target_name, "thin"))
                return 1;
 
        if (!(segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name)))
index 526284eea2a684ce2a7f95ed0c2a267fa6ae4a50..98b1ddbe57ee69945443828a994f053e96708e9e 100644 (file)
@@ -1129,6 +1129,12 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_
                        }
                }
 
+               /* 'c' when thin-pool active with needs_check flag
+                * 'C' for suspend */
+               if (lv_is_thin_pool(lv) &&
+                   lvdm->seg_status.thin_pool->needs_check)
+                       repstr[4] = lvdm->info.suspended ? 'C' : 'c';
+
                /*
                 * 'R' indicates read-only activation of a device that
                 * does not have metadata flagging it as read-only.
@@ -1190,6 +1196,12 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_
                        repstr[8] = 'D';
                else if (lvdm->seg_status.thin_pool->read_only)
                        repstr[8] = 'M';
+       } else if (lv_is_thin_volume(lv) &&
+                  (lvdm->seg_status.type != SEG_STATUS_NONE)) {
+               if (lvdm->seg_status.type == SEG_STATUS_UNKNOWN)
+                       repstr[8] = 'X'; /* Unknown */
+               else if (lvdm->seg_status.thin->fail)
+                       repstr[8] = 'F';
        }
 
        if (lv->status & LV_ACTIVATION_SKIP)
index 7ea7f52529942b53ea62b7fa56303ec624fb68eb..040caf303ce7a7fc0ca2ac60af54c2d7e7ea8eee 100644 (file)
@@ -115,6 +115,7 @@ FIELD(LVSSTATUS, lv, NUM, "CacheWriteMisses", lvid, 16, cache_write_misses, cach
 FIELD(LVSSTATUS, lv, STR_LIST, "KCache Settings", lvid, 18, kernel_cache_settings, kernel_cache_settings, "Cache settings/parameters as set in kernel, including default values (cached segments only).", 0)
 FIELD(LVSSTATUS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0)
 FIELD(LVSSTATUS, lv, STR, "KDiscards", lvid, 8, kdiscards, kernel_discards, "For thin pools, how discards are handled in kernel.", 0)
+FIELD(LVSSTATUS, lv, BIN, "CheckNeeded", lvid, 15, lvcheckneeded, lv_check_needed, "For thin pools, whether metadata check is needed.", 0)
 
 FIELD(LABEL, label, STR, "Fmt", type, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
 FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
index d23e4c9bb0c99c08091270112a5830532971b252..024919ca2f8c9685a36e89f1d5c2b37915699c5b 100644 (file)
@@ -251,6 +251,8 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
 #define _lv_health_status_get prop_not_implemented_get
 #define _lv_skip_activation_set prop_not_implemented_set
 #define _lv_skip_activation_get prop_not_implemented_get
+#define _lv_check_needed_set prop_not_implemented_set
+#define _lv_check_needed_get prop_not_implemented_get
 
 #define _cache_total_blocks_set prop_not_implemented_set
 #define _cache_total_blocks_get prop_not_implemented_get
index 542cbc4c6c0a79f00632f653f45cdd8a37244c0a..b96dcfcdce297f8d580f77e202354629628e2064 100644 (file)
@@ -3311,6 +3311,19 @@ static int _lvhealthstatus_disp(struct dm_report *rh, struct dm_pool *mem,
        return _string_disp(rh, mem, field, &health, private);
 }
 
+static int _lvcheckneeded_disp(struct dm_report *rh, struct dm_pool *mem,
+                              struct dm_report_field *field,
+                              const void *data, void *private)
+{
+       const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
+
+       if (lv_is_thin_pool(lvdm->lv))
+               return _binary_disp(rh, mem, field, lvdm->seg_status.thin_pool->needs_check,
+                                   GET_FIRST_RESERVED_NAME(lv_check_needed_y), private);
+
+       return _binary_undef_disp(rh, mem, field, private);
+}
+
 static int _lvskipactivation_disp(struct dm_report *rh, struct dm_pool *mem,
                                  struct dm_report_field *field,
                                  const void *data, void *private)
index 8a430fc293ae6f852ac6551bd2b02faaf19ff557..43c5abeb6e44f643ef33c991156f0c9d1b26ccf2 100644 (file)
@@ -81,6 +81,7 @@ FIELD_RESERVED_BINARY_VALUE(lv_inactive_table, lv_inactive_table, "", "inactive
 FIELD_RESERVED_BINARY_VALUE(lv_device_open, lv_device_open, "", "open")
 FIELD_RESERVED_BINARY_VALUE(lv_skip_activation, lv_skip_activation, "", "skip activation", "skip")
 FIELD_RESERVED_BINARY_VALUE(zero, zero, "", "zero")
+FIELD_RESERVED_BINARY_VALUE(lv_check_needed, lv_check_needed, "", "check needed", "needed")
 FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_rw, "", "writeable", "writeable", "rw", "read-write")
 FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_r, "", "read-only", "read-only", "r", "ro")
 FIELD_RESERVED_VALUE(NAMED, lv_permissions, lv_permissions_r_override, "", "read-only-override", "read-only-override", "ro-override", "r-override", "R")
This page took 0.063378 seconds and 5 git commands to generate.