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

[lvm-devel] [LVM2 PATCH] (3/3) Add metadata validation for snapshot



Additional validation check for snapshot LV.
This one is enough to prevent 'cow == origin' snapshot.

Currently, a snapshot whose origin and cow are same is
silently accepted.
Example of corrupted metadata:
                snapshot0 {
                        id = "R0o4p6-DDyy-O2td-RQDJ-dRP7-24zy-90VzgR"
                        status = ["READ", "WRITE", "VISIBLE"]
                        segment_count = 1

                        segment1 {
                                start_extent = 0
                                extent_count = 1        # 4 Megabytes

                                type = "snapshot"
                                chunk_size = 16
                                origin = "lvol0"
                                cow_store = "lvol0"
                        }
                }

With this patch, we'll get a following message for such metadata:
  LV snapshot0: segment 1 has a LV lvol0 for both snapshot origin and cow store
  Internal error: LV segments corrupted in snapshot0.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Metadata having a snapshot with origin == cow is corrupted.
Detect it in LV segment validation.

Index: LVM2.work/lib/metadata/merge.c
===================================================================
--- LVM2.work.orig/lib/metadata/merge.c
+++ LVM2.work/lib/metadata/merge.c
@@ -119,6 +119,15 @@ int check_lv_segments(struct logical_vol
 			}
 		}
 
+		if (seg_is_snapshot(seg)) {
+			if (seg->cow && seg->cow == seg->origin) {
+				log_error("LV %s: segment %u has a LV %s for "
+					  "both snapshot origin and cow store",
+					  lv->name, seg_count, seg->cow->name);
+				r = 0;
+			}
+		}
+
 		for (s = 0; s < seg->area_count; s++) {
 			if (seg_type(seg, s) == AREA_UNASSIGNED) {
 				log_error("LV %s: segment %u has unassigned "

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