[linux-lvm] Snapshot resizing bug (LVM1)

Dale J. Stephenson dalestephenson at mac.com
Wed Feb 5 12:08:01 UTC 2003


I've discovered a problem with using lvreduce/lvextend on LVM.  The 
resized snapshot will have a new exception table and hash table 
allocated for it.  But lvm_hash_link will be called for these in a loop 
that depends on the lv_remap_ptr counter passed down from userspace -- 
which will always be zero.  The result is that existing COW on the 
snapshot are ignored, and the contents of the snapshot can magically 
change to reflect the current state of the source volume.  Reboot (or 
deactivating and reactivating the volume group) should solve the 
problem, although it may be possible in the meantime to store a new COW 
exception for a chunk that already has one.

The fix is simple:

--- lvm.c.orig  Tue Feb  4 18:36:58 2003
+++ lvm.c       Tue Feb  4 18:43:26 2003
@@ -2792,7 +2792,7 @@
                 old_lv->lv_snapshot_hash_mask =
                     new_lv->lv_snapshot_hash_mask;

-               for (e = 0; e < new_lv->lv_remap_ptr; e++)
+               for (e = 0; e < old_lv->lv_remap_ptr; e++)
                         lvm_hash_link(new_lv->lv_block_exception + e,
                                       new_lv->lv_block_exception[e].
                                       rdev_org,

As a side note, why not revert the main LVM cvs tree back to LVM 1.0.6? 
  1.1 is dead.

Dale J. Stephenson
dalestephenson at mac.com





More information about the linux-lvm mailing list