I fixed it!
Here are the somewhat painful steps I went through:
1. Created image files of both drives. I put the images on ZFS, itself, and created snapshots so I could revert any changes.
2. Logfix requires the log device's GUID. It turns out that a sum of all the GUIDs is stored in the uberblock. I wrote some java that inspects all the uberblocks in each vdev and prints out the sum. Note that it is an unsigned 64-bit int. Here's the code (the links are mirrors):
http://pastebin.com/V3jWWcVV http://codetidy.com/423 http://ideone.com/d94OC Usage is
java ZfsReader disk.img
3. I used
mdconfig -f to mount the images, then did
zdb -l <device> to read the labels and print the GUIDs (in base 10) of the devices in the pool.
4. The value of step 2 is a simple unsigned 64-bit int sum of all the GUIDs. Since we now know the GUIDs of the vdevs, figuring out the GUID of the missing log device just takes a bit of algebra. Be sure the value is a 64-bit int. If you're using a calculator, add or subtract 2^64 as necessary. I can't remember if the pool GUID was in the sum or not, so you might have to play around with this method on a test pool where you know all the GUIDs to confirm it works.
5. Once you have the recovered GUID for the log device, use
logfix to build a new device. Rather than recompile logfix for FreeBSD, I used the precompiled binary on an OpenSolaris VM. I tried with OpenIndiana, but I got a segmentation fault, probably from a library mismatch.
6. The pool was never exported, and I could export a broken pool, so I had to trick zfs into thinking this was the same machine. ZFS seems to check two things, here: hostname and machine ID. Hostname is just stored in
/etc/rc.conf. The machine ID is set wi
th sysctl kern.hostid=<target id>.
7. Once I had done all this and attached all the devices as mds, I could do
zpool import. I think I ended up needing a
-f or
-F option, but I can't remember which.
Sorry there's not more or a better explanation, but I was a little surprised I got this to work, myself, so I'm not really sure about some of the steps. The most important parts are probably reconstructing the log device's GUID and spoofing the host ID. The rest was halfway easy.