zfs parition probing causing long delay at BTX loader

Steven Hartland killing at multiplay.co.uk
Thu Oct 20 17:34:24 UTC 2011

Installing a new machine here which has 10+ disks
we're seeing BTX loader take 50+ seconds to enumerate
the disks.

After doing some digging I found the following thread
on the forums which hinted that r198420 maybe the

A quick change to zfs.c reverting the change to
support 128 partitions back to 4 and BTX completes
instantly like it used to.

svn commit which introduced this delay is:-

the specific file in that changeset:-

So the questions are:-

1. Can this be optimised so it doesn't have to test all
of the possible 128 GPT partitions?

2. If a optimisation isn't possible or is too complex to
achieve would it be better to have the partitions defined
as an option which can be increased if needed as I suspect
99.99% if not 100% of users won't be making use of more
than 4 partitions even with GPT, such as what the attached
patch against 8.2-RELEASE achieves.


This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 

In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337
or return the E.mail to postmaster at multiplay.co.uk.
-------------- next part --------------
--- sys/boot/zfs/zfs.c.orig	2011-10-20 18:15:29.966685430 +0000
+++ sys/boot/zfs/zfs.c	2011-10-20 18:18:22.291033636 +0000
@@ -45,6 +45,12 @@
 #include "zfsimpl.c"
+ * For GPT this should be 128 but leads to 50+ second delay in BTX loader so
+ * we use the original 4 pre r198420 by default for the boot process
+ */
+#define ZFS_MAX_SLICES 4
 static int	zfs_open(const char *path, struct open_file *f);
 static int	zfs_write(struct open_file *f, void *buf, size_t size, size_t *resid);
 static int	zfs_close(struct open_file *f);
@@ -415,7 +421,7 @@
 		if (vdev_probe(vdev_read, (void*) (uintptr_t) fd, 0))
-		for (slice = 1; slice <= 128; slice++) {
+		for (slice = 1; slice <= ZFS_MAX_SLICES; slice++) {
 			sprintf(devname, "disk%dp%d:", unit, slice);
 			fd = open(devname, O_RDONLY);
 			if (fd == -1) {

More information about the freebsd-stable mailing list