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

[lvm-devel] [PATCH 2/4] lvconvert to refuse mirror addition to 'nosync' LV



LVM2 will not do initial syncing of mirrors if the LV
is created with '--nosync' option.
(Such LV is shown as 'M' in the first character of Attr field.)
Writes after the LV creation will go to all mirrors.

The option might be useful if admin wants to avoid syncing I/O
at the time.

However, if lvconvert adds a new mirror to such LV,
we can't skip syncing. Otherwise, mirrors are kept out-of-sync
and makes no sense.

This patch changes lvconvert to check the LV status and
refuse mirror addition if the LV is 'nosync'.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Adding mirrors to 'nosync' mirrored LV makes no sense.
So lvconvert should refuse it.

# lvcreate -m1 -l1 --nosync testvg
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
  Logical volume "lvol0" created
# lvs -a
  LV               VG     Attr   LSize Origin Snap%  Move Log        Copy% 
  lvol0            testvg Mwi-a- 2.00M                    lvol0_mlog 100.00
  [lvol0_mimage_0] testvg iwi-ao 2.00M                                     
  [lvol0_mimage_1] testvg iwi-ao 2.00M                                     
  [lvol0_mlog]     testvg lwi-ao 2.00M                                     
# lvconvert -m+1 testvg/lvol0
  Not adding mirror to mirrored LV without initial resync

# lvchange --resync testvg/lvol0
Do you really want to deactivate logical volume lvol0 to resync it? [y/n]: y
# lvs -a
  LV               VG     Attr   LSize Origin Snap%  Move Log        Copy% 
  lvol0            testvg mwi-a- 2.00M                    lvol0_mlog 100.00
  [lvol0_mimage_0] testvg iwi-ao 2.00M                                     
  [lvol0_mimage_1] testvg iwi-ao 2.00M                                     
  [lvol0_mlog]     testvg lwi-ao 2.00M                                     
# lvconvert -m+1 testvg/lvol0
  Logical volume lvol0 converted.

Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -376,6 +376,11 @@ static int lvconvert_mirrors(struct cmd_
 			return 1;
 		}
 	} else if (lp->mirrors > existing_mirrors) {
+		if (lv->status & MIRROR_NOTSYNCED) {
+			log_error("Not adding mirror to mirrored LV "
+				  "without initial resync");
+			return 0;
+		}
 		/* FIXME: can't have multiple mlogs. force corelog. */
 		corelog = 1;
 		if (!insert_layer_for_lv(cmd, lv, 0, "_resync%d")) {

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