Received: from list by lists.gnu.org with archive (Exim 4.71) id 1QqqCR-0006Jl-PM for mharc-grub-devel@gnu.org; Tue, 09 Aug 2011 13:34:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqqCP-0006JB-Dm for grub-devel@gnu.org; Tue, 09 Aug 2011 13:34:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqqCO-0007KU-Bg for grub-devel@gnu.org; Tue, 09 Aug 2011 13:34:41 -0400 Received: from mail-vx0-f169.google.com ([209.85.220.169]:39837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqqCO-0007KO-8j for grub-devel@gnu.org; Tue, 09 Aug 2011 13:34:40 -0400 Received: by vxj15 with SMTP id 15so231457vxj.0 for ; Tue, 09 Aug 2011 10:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=Lx1UWITlmvj7P0+S4q5qZ7kAkYzC3UBClp9ArsvviUA=; b=L2MqTlxnqod3Us3F/rhLWhob9mvOzuHPmGZoEE/zMKcea4YRMqNhdY33PsUElNdN/J IZtaplLZyoz1qD0emm1X160kPCySeWwsB5qyOzGvBW4TudBs+dqFTDXGPQLtWpfXDhY5 6wjMrur+UUGKA8TXnqO4uUppqw3vV1I8YrTv8= Received: by 10.52.93.12 with SMTP id cq12mr3516001vdb.159.1312911279387; Tue, 09 Aug 2011 10:34:39 -0700 (PDT) Received: from [192.1.12.151] ([207.29.40.2]) by mx.google.com with ESMTPS id er5sm117544vdb.26.2011.08.09.10.34.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Aug 2011 10:34:38 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Apple Message framework v1244.3) Subject: Re: getroot for ZFS without libzfs? From: Zachary Bedell In-Reply-To: Date: Tue, 9 Aug 2011 13:34:37 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <624ACA48-86E4-4ECB-A975-A47B1FB7F7E6@gmail.com> To: The development of GNU GRUB X-Mailer: Apple Mail (2.1244.3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.220.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Aug 2011 17:34:42 -0000 On Aug 9, 2011, at 7:54 AM, Robert Millan wrote: > 2011/8/8 Zachary Bedell : >> 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. >=20 > 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=85 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