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

[lvm-devel] [PATCH mirror 11/13] Add 'lv_mirrors' field to reporting functions



This patch adds 'lv_mirrors' field to reporting commands.
It is the number of mirrors for the LV.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Add [lv_]mirrors field to report command as an accumulated number of
mirror legs (i.e. not only the legs in the top-level LV)

For example, if we have stacked mirrored-LV like this:
# dmsetup ls --tree
testvg-lvol0 (253:12)
 |-testvg-lvol0_mimage_5 (253:16)
 |  `-d5 (253:5)
 `-testvg-lvol0_mimage_4 (253:15)
    |-testvg-lvol0_mimage_3 (253:14)
    |  `-d4 (253:4)
    `-testvg-lvol0_mimage_2 (253:13)
       |-testvg-lvol0_mimage_1 (253:11)
       |  `-d2 (253:2)
       |-testvg-lvol0_mimage_0 (253:10)
       |  `-d1 (253:1)
       `-testvg-lvol0_mlog (253:9)
          `-d3 (253:3)

lvs will shows this: (see the difference between mirrors and stripes)
# lvs -a -oname,mirrors,stripes
  LV               #Mirror #Str
  [lvol0]                4    2
  [lvol0_mimage_0]       1    1
  [lvol0_mimage_1]       1    1
  [lvol0_mimage_2]       2    2
  [lvol0_mimage_3]       1    1
  [lvol0_mimage_4]       3    2
  [lvol0_mimage_5]       1    1
  [lvol0_mlog]           1    1

Index: LVM2.work/lib/report/columns.h
===================================================================
--- LVM2.work.orig/lib/report/columns.h
+++ LVM2.work/lib/report/columns.h
@@ -31,6 +31,7 @@ FIELD(LVS, lv, NUM, "LSize", size, 5, si
 FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count", "Number of segments in LV.")
 FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin", "For snapshots, the origin device of this LV")
 FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.")
+FIELD(LVS, lv, NUM, "#Mirror", lvid, 7, lvmirrors, "mirrors", "For mirrors, the total number of mirror legs of this LV")
 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, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.")
Index: LVM2.work/lib/report/report.c
===================================================================
--- LVM2.work.orig/lib/report/report.c
+++ LVM2.work/lib/report/report.c
@@ -917,6 +917,18 @@ static int _snpercent_disp(struct dm_rep
 	return 1;
 }
 
+static int _lvmirrors_disp(struct dm_report *rh, struct dm_pool *mem,
+			   struct dm_report_field *field,
+			   const void *data, void *private)
+{
+	const struct logical_volume *lv = (const struct logical_volume *) data;
+	uint32_t count;
+
+	count = lv_mirror_count(lv);
+
+	return _uint32_disp(rh, mem, field, &count, private);
+}
+
 static int _copypercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
 			     struct dm_report_field *field,
 			     const void *data, void *private __attribute((unused)))

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