grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getroot for ZFS without libzfs?


From: Zachary Bedell
Subject: Re: getroot for ZFS without libzfs?
Date: Tue, 9 Aug 2011 13:34:37 -0400

On Aug 9, 2011, at 7:54 AM, Robert Millan wrote:
> 2011/8/8 Zachary Bedell <address@hidden>:
>>  Also libzfs is considered a private API and not intended to be linked 
>> against, though admittedly what I propose (reading on-disk structures 
>> directly) is arguably worse than accessing a private library.
> 
> I don't think you can figure out the disks corresponding to a zpool
> just by reading disk structures.  You can guess, but only the kernel
> knows for sure.

It's all in there, and the structures are pretty well defined & stable.  You'd 
need to look at all the raw devices to begin with and see which if any has a 
ZFS label (always in a well known location).  Assuming any does, you get the 
vdev_tree out of the label's nvlist, and from there you can discover child and 
parent devices to rebuild the full tree.  It looks like the code in getroot.c 
is doing pretty much that by calling the various nvlist_lookup_* functions from 
libzfs.  Doing the same from the pool isn't much more difficult, and the 
necessary nvlist-related functions are already in zfs.c in Grub at this point.

> The other API that is available to us is /dev/zfs.  But is that device
> meant to be used directly?  How stable is this interface?

/dev/zfs is probably less stable than libzfs, both of which are less stable 
than the on-disk format.  That said, libzfs is going to be stable for the 
foreseeable future until/unless Oracle dumps more code.  I do know that the 
cryptography related work in Solaris 11 changed the on-disk structures 
slightly, though in theory in a backwards compatible way.  Likewise, the 
particular functions of libzfs that Grub needs are core enough to ZFS that I 
doubt they'd be broken in a future release.

My reasons for looking at other options were primarily GPL driven, but given 
that's not an issue, it's probably moot for now.  It might be slightly more 
elegant to use pure Grub code given that all of the underlying functionality is 
there already, but the real benefits are probably minimal.

SO that said…  It probably makes the most sense to withdraw my thoughts of 
removing libzfs.  In lieu of that, I have a patch which allows ZFS detection to 
function on Linux.  I'll post that under separate subject momentarily as it's 
unrelated to libzfs in getroot.c.

Best regards,
Zac




reply via email to

[Prev in Thread] Current Thread [Next in Thread]