Skip to contentSkip to conversation

Snapshot resizing memory leak

linux-lvm Dale J. Stephenson 2 participants 2 messages Mar 3, 2003 – Mar 4, 2003

lore
Share & tools
lore
#0 lore raw

It looks like the current lvm code still has the memory leak when resizing snapshots. The lv_block_exception and lv_snapshot_hash_table fields are set to ones newly allocated for the new size, but the old ones are not freed. The following patch should fix it:

drivers/md/lvm.c renamed from drivers/md/lvm.c.orig +0 -0
@@ -2489,6 +2489,8 @@
		memcpy(new_lv->lv_block_exception,
		       old_lv->lv_block_exception, size);

+ vfree(old_lv->lv_block_exception);

+		vfree(old_lv->lv_snapshot_hash_table);
		old_lv->lv_remap_end = new_lv->lv_remap_end;
		old_lv->lv_block_exception = new_lv->lv_block_exception;
		old_lv->lv_snapshot_hash_table =
#1 lore raw

Dale,

thanks for finding this one.
Could you please give the LVM version you patched in future posts ?

Regards,
Heinz -- The LVM Guy --

Quoted 20 lines · Dale J. Stephenson

It looks like the current lvm code still has the memory leak when resizing snapshots. The lv_block_exception and lv_snapshot_hash_table fields are set to ones newly allocated for the new size, but the old ones are not freed. The following patch should fix it:

drivers/md/lvm.c renamed from drivers/md/lvm.c.orig +2 -0
@@ -2489,6 +2489,8 @@
 		memcpy(new_lv->lv_block_exception,
 		       old_lv->lv_block_exception, size);
 
+		vfree(old_lv->lv_block_exception);
+		vfree(old_lv->lv_snapshot_hash_table);
 		old_lv->lv_remap_end = new_lv->lv_remap_end;
 		old_lv->lv_block_exception = new_lv->lv_block_exception;
 		old_lv->lv_snapshot_hash_table =
Quoted 5 lines

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

*** Software bugs are stupid.
Nevertheless it needs not so stupid people to solve them ***

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Heinz Mauelshagen Sistina Software Inc.
Senior Consultant/Developer Am Sonnenhang 11
56242 Marienrachdorf Germany
[email protected] +49 2626 141200

                                                       FAX 924446

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-