[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 3/4] Show mirror image sync status in Attr field

Since now we can add mirrors to the existing mirrors,
some mirror images are in-sync while other are out-of-sync.

This patch shows the mirror image sync status in Attr field
as volume type character.
'i' used to mean 'mirror image'.
With this patch, 'i' means 'mirror image in-sync'.
'I' means 'mirror image out-of-sync (syncing)'.

Jun'ichi Nomura, NEC Corporation of America
In the Attr field, 'i' for volume type used to mean a mirror image.

During the synching of added mirror images, pre-existing images can be
in-sync while newly added ones are out-of-sync.

This patch changes the volume type character as followings:
  'i' for mirror image in-sync
  'I' for mirror image out-of-sync (synching)

Index: LVM2.work/lib/report/report.c
--- LVM2.work.orig/lib/report/report.c
+++ LVM2.work/lib/report/report.c
@@ -272,6 +272,24 @@ static int _lvkmin_disp(struct dm_report
 	return dm_report_field_uint64(rh, field, &_minusone);
+static int _lv_mimage_in_sync(struct logical_volume *lv)
+	float percent;
+	struct lv_segment *seg = first_seg(lv);
+	if (!(lv->status & MIRROR_IMAGE) || !seg->mirror_seg)
+		return_0;
+	if (!lv_mirror_percent(lv->vg->cmd, seg->mirror_seg->lv, 0,
+			       &percent, NULL))
+		return_0;
+	if (percent >= 100.0)
+		return 1;
+	return 0;
 static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
 			  struct dm_report_field *field,
 			  const void *data, void *private __attribute((unused)))
@@ -294,7 +312,10 @@ static int _lvstatus_disp(struct dm_repo
 			repstr[0] = 'm';
 	}else if (lv->status & MIRROR_IMAGE)
-		repstr[0] = 'i';
+		if (_lv_mimage_in_sync(lv))
+			repstr[0] = 'i';
+		else
+			repstr[0] = 'I';
 	else if (lv->status & MIRROR_LOG)
 		repstr[0] = 'l';
 	else if (lv->status & VIRTUAL)
Index: LVM2.work/man/lvs.8
--- LVM2.work.orig/man/lvs.8
+++ LVM2.work/man/lvs.8
@@ -47,7 +47,7 @@ The lv_attr bits are: 
 .IP 1 3
 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot, 
-invalid (S)napshot, (v)irtual
+invalid (S)napshot, (v)irtual, mirror (i)mage, mirror (I)mage (out-of-sync or synching)
 .IP 2 3
 Permissions: (w)riteable, (r)ead-only
 .IP 3 3

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]