]> sourceware.org Git - lvm2.git/commitdiff
raid: implement transient status check
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 21 Nov 2016 11:43:18 +0000 (12:43 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 23 Nov 2016 16:45:44 +0000 (17:45 +0100)
Take into acount reported state from 'raid' targets.
When raid leg is marked with 'D' - take it as missing leg.

WHATS_NEW
lib/raid/raid.c

index 7f8801ac0b9e6ec8cbee7444f7b596b89c4180a3..9414b03938c6fabc93cba71dec8f158ccbd19795 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.168 - 
 ====================================
+  Implement transient status check for raid volumes.
   Only log msg as debug if lvm2-lvmdbusd unit missing for D-Bus notification.
   Missing stripe filler now could be also 'zero'.
   lvconvert --repair accepts --interval and --background option.
index 92a96a3e992d1b12e09527d03fe76202ff394e57..80af61e068b83268d350d6651fcc2922044499ff 100644 (file)
@@ -349,6 +349,62 @@ static int _raid_target_percent(void **target_state,
        return 1;
 }
 
+static int _raid_transient_status(struct dm_pool *mem,
+                                 struct lv_segment *seg,
+                                 char *params)
+{
+       int failed = 0, r = 0;
+       unsigned i;
+       struct lvinfo info;
+       struct logical_volume *lv;
+       struct dm_status_raid *sr;
+
+       log_debug("Raid transient status %s.", params);
+
+       if (!dm_get_status_raid(mem, params, &sr))
+               return_0;
+
+       if (sr->dev_count != seg->area_count) {
+               log_error("Active raid has a wrong number of raid images!");
+               log_error("Metadata says %u, kernel says %u.",
+                         seg->area_count, sr->dev_count);
+               goto out;
+       }
+
+       if (seg->meta_areas)
+               for (i = 0; i < seg->area_count; ++i) {
+                       lv = seg_metalv(seg, i);
+                       if (!lv_info(lv->vg->cmd, lv, 0, &info, 0, 0)) {
+                               log_error("Check for existence of raid meta %s failed.",
+                                         display_lvname(lv));
+                               goto out;
+                       }
+               }
+
+       for (i = 0; i < seg->area_count; ++i) {
+               lv = seg_lv(seg, i);
+               if (!lv_info(lv->vg->cmd, lv, 0, &info, 0, 0)) {
+                       log_error("Check for existence of raid image %s failed.",
+                                 display_lvname(lv));
+                       goto out;
+               }
+               if (sr->dev_health[i] == 'D') {
+                       lv->status |= PARTIAL_LV;
+                       ++failed;
+               }
+       }
+
+       /* Update PARTIAL_LV flags across the VG */
+       if (failed)
+               vg_mark_partial_lvs(lv->vg, 0);
+
+       r = 1;
+out:
+       dm_pool_free(mem, sr);
+
+       return r;
+}
+
 static int _raid_target_present(struct cmd_context *cmd,
                                const struct lv_segment *seg __attribute__((unused)),
                                unsigned *attributes)
@@ -460,6 +516,7 @@ static struct segtype_handler _raid_ops = {
 #ifdef DEVMAPPER_SUPPORT
        .target_percent = _raid_target_percent,
        .target_present = _raid_target_present,
+       .check_transient_status = _raid_transient_status,
        .modules_needed = _raid_modules_needed,
 #  ifdef DMEVENTD
        .target_monitored = _raid_target_monitored,
This page took 0.044924 seconds and 5 git commands to generate.