]> sourceware.org Git - lvm2.git/commitdiff
report: show proper info for merging origin
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 22 Dec 2016 18:51:35 +0000 (19:51 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 22 Dec 2016 22:37:07 +0000 (23:37 +0100)
When there is 'merging' of an origin in progress, but metadata stil
do provide both origin and snapshot, we should show data from merged
snapshot.  This is important mainly for thin case, where there was
a window, where i.e. 'lvs -o+device_id' would report information
about 'already gone' origin thin LV.

This race window is usually hard to trigger but can be ocasionally hit.
Usually shortly after activation, but before polling process manages
to update metadata after merge.

WHATS_NEW
tools/reporter.c

index dcfd85aca51b629f99bcb3e545bdf09659bc0e10..e5bbfe01da374c0e707ad756cffa5d2d1a24d805 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.169 - 
 =====================================
+  Report thin LV date for merged LV when the merge is in progress.
   Detect if snapshot merge really started before polling for progress.
   Checking LV for merging origin requires also it has merged snapshot.
   Extend validation of metadata processing.
index fc87c06b09e45b21cca3afe289a06b2c815b36de..6c5996b1f24665cc4399f83a3e31ff21cd01e20f 100644 (file)
@@ -113,6 +113,40 @@ static int _do_info_and_status(struct cmd_context *cmd,
        return 1;
 }
 
+/* Check if this is really merging origin.
+ * In such case, origin is gone, and user should see
+ * only data from merged snapshot. Important for thin. */
+static int _check_merging_origin(const struct logical_volume *lv,
+                                struct lv_with_info_and_seg_status *status,
+                                int *merged)
+{
+       uint32_t device_id;
+
+       *merged = 0;
+
+       switch (status->seg_status.type) {
+       case SEG_STATUS_THIN:
+               /* Get 'device_id' from active dm-table */
+               if (!lv_thin_device_id(lv, &device_id))
+                       return_0;
+
+               if (lv->snapshot->device_id != device_id)
+                       return 1;
+               break;
+       case SEG_STATUS_SNAPSHOT:
+               break;
+       default:
+               return 1;
+       }
+
+       /* Origin is gone */
+       log_debug_activation("Merge is progress, reporting merged LV %s.",
+                            display_lvname(lv->snapshot->lv));
+       *merged = 1;
+
+       return 1;
+}
+
 static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
                                               const struct logical_volume *lv,
                                               int do_info, int do_status,
@@ -123,10 +157,22 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
                .seg_status.type = SEG_STATUS_NONE
        };
        int r = ECMD_FAILED;
+       int merged;
+
+       if (lv_is_merging_origin(lv))
+               /* Status is need to know which LV should be shown */
+               do_status = 1;
 
        if (!_do_info_and_status(cmd, first_seg(lv), &status, do_info, do_status))
                goto_out;
 
+       if (lv_is_merging_origin(lv)) {
+               if (!_check_merging_origin(lv, &status, &merged))
+                     goto_out;
+               if (merged)
+                       lv = lv->snapshot->lv;
+       }
+
        if (!report_object(sh ? : handle->custom_handle, sh != NULL,
                           lv->vg, lv, NULL, NULL, NULL, &status, NULL))
                goto out;
@@ -173,10 +219,22 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
                .seg_status.type = SEG_STATUS_NONE
        };
        int r = ECMD_FAILED;
+       int merged;
+
+       if (lv_is_merging_origin(seg->lv))
+               /* Status is need to know which LV should be shown */
+               do_status = 1;
 
        if (!_do_info_and_status(cmd, seg, &status, do_info, do_status))
                goto_out;
 
+       if (lv_is_merging_origin(seg->lv)) {
+               if (!_check_merging_origin(seg->lv, &status, &merged))
+                       goto_out;
+               if (merged)
+                       seg = seg->lv->snapshot;
+       }
+
        if (!report_object(sh ? : handle->custom_handle, sh != NULL,
                           seg->lv->vg, seg->lv, NULL, seg, NULL, &status, NULL))
        goto_out;
This page took 0.043078 seconds and 5 git commands to generate.