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

[lvm-devel] [PATCH lvconvert 9/11] Add a new attr field char for the CONVERTING LV



The patch changes the reporting format to show the conversion
structure.

# lvs -o+convert_lv vg
  LV    VG   Attr   LSize Origin Snap%  Move Log Copy%  Convert          
  lvol0 vg   cwi--- 1.00G                               lvol0_mimagetmp_2

'c' in the 'Attr' field means 'LV under conversion'.
'Convert' field points to the temporary LV for the conversion.

Might be better to add a new char for Attr field than
using volume-type char.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Add 'c' for volume type in Attr field for the LV under conversion.
Add 'Convert' (convert_lv) field to show the temporary LV for the conversion.

# lvs -o+convert_lv vg
  LV    VG   Attr   LSize Origin Snap%  Move Log Copy%  Convert          
  lvol0 vg   cwi--- 1.00G                               lvol0_mimagetmp_2
# lvs -a -o+convert_lv vg
  LV                  VG   Attr   LSize Origin Snap%  Move Log        Copy%  Convert          
  lvol0               vg   cwi--- 1.00G                                      lvol0_mimagetmp_2
  [lvol0_mimage_0]    vg   Iwi--- 1.00G                                                       
  [lvol0_mimage_1]    vg   Iwi--- 1.00G                                                       
  [lvol0_mimage_2]    vg   Iwi--- 1.00G                                                       
  [lvol0_mimagetmp_2] vg   mwi--- 1.00G                    lvol0_mlog                         
  [lvol0_mlog]        vg   lwi--- 2.00M                                                       

Index: LVM2.work/lib/report/report.c
===================================================================
--- LVM2.work.orig/lib/report/report.c
+++ LVM2.work/lib/report/report.c
@@ -306,6 +306,8 @@ static int _lvstatus_disp(struct dm_repo
 
 	if (lv->status & PVMOVE)
 		repstr[0] = 'p';
+	else if (lv->status & CONVERTING)
+		repstr[0] = 'c';
 	else if (lv->status & MIRRORED) {
 		if (lv->status & MIRROR_NOTSYNCED)
 			repstr[0] = 'M';
@@ -548,6 +550,32 @@ static int _movepv_disp(struct dm_report
 	return 1;
 }
 
+static int _convertlv_disp(struct dm_report *rh, struct dm_pool *mem __attribute((unused)),
+			   struct dm_report_field *field,
+			   const void *data, void *private __attribute((unused)))
+{
+	const struct logical_volume *lv = (const struct logical_volume *) data;
+	const char *name = NULL;
+	struct lv_segment *seg;
+
+	if (lv->status & CONVERTING) {
+		if (lv->status & MIRRORED) {
+			seg = first_seg(lv);
+
+			/* Temporary mirror is always area_num == 0 */
+			if (seg_type(seg, 0) == AREA_LV &&
+			    is_temporary_mirror_layer(seg_lv(seg, 0)))
+				name = seg_lv(seg, 0)->name;
+		}
+	}
+
+	if (name)
+		return dm_report_field_string(rh, field, &name);
+
+	dm_report_field_set_value(field, "", NULL);
+	return 1;
+}
+
 static int _size32_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
 			struct dm_report_field *field,
 			const void *data, void *private)
Index: LVM2.work/lib/report/columns.h
===================================================================
--- LVM2.work.orig/lib/report/columns.h
+++ LVM2.work/lib/report/columns.h
@@ -33,6 +33,7 @@ FIELD(LVS, lv, STR, "Origin", lvid, 6, o
 FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.")
 FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent", "For mirrors and pvmove, current percentage in-sync.")
 FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv", "For pvmove, Source PV of temporary LV created by pvmove")
+FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, "convert_lv", "For lvconvert, Name of temporary LV created by lvconvert")
 FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.")
 FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.")
 FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.")
Index: LVM2.work/man/lvs.8
===================================================================
--- LVM2.work.orig/man/lvs.8
+++ LVM2.work/man/lvs.8
@@ -47,7 +47,8 @@ The lv_attr bits are: 
 .RS
 .IP 1 3
 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot, 
-invalid (S)napshot, (v)irtual, mirror (i)mage, mirror (I)mage out-of-sync
+invalid (S)napshot, (v)irtual, mirror (i)mage, mirror (I)mage out-of-sync,
+under (c)onversion
 .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]