Skip to contentSkip to conversation

calc_max_buckets bug

PATCH In review Chris Mason 2 participants 4 messages Mar 10, 2004 – Mar 11, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 calc_max_buckets bug

Hello everyone,

This is in both 2.4.x lvm and 2.6.x dm code, calc_max_buckets is broken for 32bit machines with > 4GB of ram. This leads to -ENOMEM errors during snapshot creation.

The patch below just changes things to allocate 2MB worth of hash buckets all the time. Has anyone done benchmarking into how much cpu time snapshots spend on hash table lookups?

-chris

drivers/md/lvm-snap.c +2 -6
Index: linux.24/drivers/md/lvm-snap.c
===================================================================
@@ -504,13 +504,9 @@ out:
 
 static int calc_max_buckets(void)
 {
-	unsigned long mem;
-
-	mem = num_physpages << PAGE_SHIFT;
-	mem /= 100;
-	mem *= 2;
+	/* use a fixed size of 2MB */
+	unsigned long mem = 2 * 1024 * 1024;
 	mem /= sizeof(struct list_head);
-
 	return mem;
 }
 
#1 lore raw
Quoted 5 lines · Chris Mason

Hello everyone,

This is in both 2.4.x lvm and 2.6.x dm code, calc_max_buckets is broken for 32bit machines with > 4GB of ram. This leads to -ENOMEM errors during snapshot creation.

heh, this must be the only bit of code I copied from LVM1 :) Serves me right for being lazy.

Thanks,

- Joe

#2 lore raw
Quoted 9 lines · Joe Thornber
Quoted 5 lines · Chris Mason

Hello everyone,

This is in both 2.4.x lvm and 2.6.x dm code, calc_max_buckets is broken for 32bit machines with > 4GB of ram. This leads to -ENOMEM errors during snapshot creation.

heh, this must be the only bit of code I copied from LVM1 :) Serves me right for being lazy.

Do you see any problems with using a smaller fixed size on the hash table. It seems like 2MB should be enough to me.

-chris

#3 lore raw
Quoted 2 lines · Chris Mason

Do you see any problems with using a smaller fixed size on the hash table. It seems like 2MB should be enough to me.

I've done no experiments in this area.

- Joe