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

[lvm-devel] [PATCH] Cleanup partial failure of activation



Hi,

If activate_lv() fails, callers won't call deactivate_lv().
However, activate_lv() may succeeded activation partially.

For example, in this case: (with the latest 2.02.29-cvs)
  # dmsetup create --notable vg-lv0_mimage_0
  # lvcreate -l1 -m1 -nlv0 vg

lvcreate fails. "lv0", "lv0_mimage_0", "lv0_mimage_1" and "lv0_mlog"
are once created but removed from the VG metadata. That's ok.
However, maps of vg-lv0 and vg-lv0_mlog remain in kernel.

Attached patch deactivates a partially activated LV so that
callers of activate_lv() don't need to care about partial failure.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Index: LVM2.work/lib/activate/activate.c
===================================================================
--- LVM2.work.orig/lib/activate/activate.c
+++ LVM2.work/lib/activate/activate.c
@@ -561,8 +561,10 @@ static int _lv_activate_lv(struct logica
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_activate(dm, lv)))
+	if (!(r = dev_manager_activate(dm, lv))) {
+		dev_manager_deactivate(dm, lv);
 		stack;
+	}
 
 	dev_manager_destroy(dm);
 	return r;

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