[linux-lvm] vgchange problem worked around (?)

Magosányi Árpád mag at bunuel.tii.matav.hu
Fri Nov 2 04:16:02 UTC 2001


Hi!

I succeded to activate my volume group. The trick was to get rid of
the code path which had the comment:
 	/* Second path to correct snapshot logical volumes which are not
 	   in place during first path above */
I have an lvm-mod with the patch you can see at the end (full), and one
with only the first two hunks (orig). The full module can activate the volume
group, the orig -of course- not.
I am not sure if the current state of my vg is consistent or something.
What I am afraid of is that the lv which was snapshotted is OK or
not. 

Can anyone comment on it?


My other problem is how to get rid of the snapshot lv (I don't really
need that, and I guess this is the easiest way to) and reach a consistent
vg. What I am thinking about is to activate with the full module, create
a lv (any), and then remove it. After that I hope I will be able to activate
the vg with the orig module. (Now I am waiting for hardware to do the backup
first, before anything else is done.) 

The question is: will my vg be consistent this way, or to expect problems
due to sectors allocated to the "lost" lv? If problems are expectable, how to solve them?


About the patch: The first two hunks are a patch which I have seen in
the mailing list. It is supposed to help with the snapshot volume is full
situation. I could not see any positive side of it.
The other hunks contain various printk's in error exits of the vg_create
(or which?) function. I believe that this part is very useful, and propose
its inclusion in the lvm code. If these code would been in the kernel,
It would took me one day to activate my vg instead of 4 days.
The last hunk also contains the commenting out of the code path which
was problematic. Warning: this one is a blind surgery for the deadly desperate,
I am not sure of its side effects. Any comment of its effects are welcome.

--- /home/mag/tmp/LVM/1.0.1-rc4/kernel/lvm.c	Tue Oct  2 23:14:41 2001
+++ lvm.c	Thu Nov  1 22:09:42 2001
@@ -1213,7 +1139,8 @@
 
 	/* we must redo lvm_snapshot_remap_block in order to avoid a
 	   race condition in the gap where no lock was held */
-	if (!lvm_snapshot_remap_block(&rdev, &rsector, pe_start, lv) &&
+	if (lv->lv_block_exception &&
+	    !lvm_snapshot_remap_block(&rdev, &rsector, pe_start, lv) &&
 	    !lvm_snapshot_COW(rdev, rsector, pe_start, rsector, vg, lv))
 		lvm_write_COW_table_block(vg, lv);
 
@@ -1222,11 +1149,12 @@
 
 static inline void _remap_snapshot(kdev_t rdev, ulong rsector,
 				   ulong pe_start, lv_t *lv, vg_t *vg) {
-	int r;
+	int r=0;
 
 	/* check to see if this chunk is already in the snapshot */
 	down_read(&lv->lv_lock);
-	r = lvm_snapshot_remap_block(&rdev, &rsector, pe_start, lv);
+	if (lv->lv_block_exception)
+		r = lvm_snapshot_remap_block(&rdev, &rsector, pe_start, lv);
 	up_read(&lv->lv_lock);
 
 	if (!r)
@@ -1606,7 +1514,7 @@
 	lv_t lv;
 	vg_t *vg_ptr;
 	lv_t **snap_lv_ptr;
-
+	printk (KERN_CRIT "%s -- VG_CREATE called with minor=%d",lvm_name,minor);
 	if ((vg_ptr = kmalloc(sizeof(vg_t),GFP_KERNEL)) == NULL) {
 		printk(KERN_CRIT
 		       "%s -- VG_CREATE: kmalloc error VG at line %d\n",
@@ -1664,6 +1572,7 @@
 			ret = lvm_do_pv_create(pvp, vg_ptr, p);
 			if ( ret != 0) {
 				lvm_do_vg_remove(minor);
+				printk(KERN_CRIT "%s -- lvm_do_pv_create(%p,%p,%lu) returned %u",lvm_name,pvp,vg_ptr,p,ret);
 				return ret;
 			}
 		}
@@ -1700,6 +1609,7 @@
 			/* only create original logical volumes for now */
 			if (lvm_do_lv_create(minor, lv.lv_name, &lv) != 0) {
 				lvm_do_vg_remove(minor);
+				printk(KERN_CRIT "%s -- lvm_do_lv_create(%u,%s,%p) returned nonnul",lvm_name,minor,lv.lv_name,&lv);
 				return -EFAULT;
 			}
 		}
@@ -1707,17 +1617,21 @@
 
 	/* Second path to correct snapshot logical volumes which are not
 	   in place during first path above */
+/* cut off
 	for (l = 0; l < ls; l++) {
 		lvp = snap_lv_ptr[l];
 		if (copy_from_user(&lv, lvp, sizeof(lv_t)) != 0) {
 			lvm_do_vg_remove(minor);
+			printk(KERN_CRIT "%s -- copy_from_user in second snapshot lv path failed",lvm_name);
 			return -EFAULT;
 		}
 		if (lvm_do_lv_create(minor, lv.lv_name, &lv) != 0) {
 			lvm_do_vg_remove(minor);
+			printk(KERN_CRIT "%s -- lvm_do_lv_create(%u,%s,%p) in second lv path returned nonnul",lvm_name,minor,lv.lv_name,&lv);
 			return -EFAULT;
 		}
 	}
+*/
 
 	vfree(snap_lv_ptr);
 
-- 
GNU GPL: csak tiszta forrásból




More information about the linux-lvm mailing list