Skip to contentSkip to conversation

If lv_info fails, don't report snapshot percentage

PATCH New Mikulas Patocka 2 participants 2 messages May 19, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 If lv_info fails, don't report snapshot percentage

If lv_info fails, don't report snapshot percentage

We shouldn't report snapshot percentage if lv_info fails (i.e. returns zero) or if the device is not loaded (info.exists is zero).

Previously, the logic in the code was to not report percentage if lv_info succeeds and info.exists is zero.

This fixes a bug, when dm-mod is not loaded (and the kernel doesn't load it automatically) "lvs" commands reports all snapshots as 100% full.

---
 lib/report/report.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/report/report.c +1 -1
Index: LVM2.2.02.64/lib/report/report.c
===================================================================
@@ -1019,7 +1019,7 @@ static int _snpercent_disp(struct dm_rep
 	}
 
 	if ((!lv_is_cow(lv) && !lv_is_merging_origin(lv)) ||
-	    (lv_info(lv->vg->cmd, lv, &info, 0, 0) && !info.exists)) {
+	    !lv_info(lv->vg->cmd, lv, &info, 0, 0) || !info.exists) {
 		*sortval = UINT64_C(0);
 		dm_report_field_set_value(field, "", sortval);
 		return 1;
#1 lore raw

PATCH 1/1 If lv_info fails, don't report snapshot percentage

Quoted 1 line · Mikulas Patocka

If lv_info fails, don't report snapshot percentage

Ack.

Alasdair