From owner-svn-src-all@FreeBSD.ORG Sat Oct 6 19:48:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E89A1065676; Sat, 6 Oct 2012 19:48:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6D0228FC20; Sat, 6 Oct 2012 19:48:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q96JmFBw028551; Sat, 6 Oct 2012 19:48:15 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q96JmFPU028549; Sat, 6 Oct 2012 19:48:15 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201210061948.q96JmFPU028549@svn.freebsd.org> From: Andriy Gapon Date: Sat, 6 Oct 2012 19:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241294 - head/sys/boot/i386/zfsboot X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 19:48:16 -0000 Author: avg Date: Sat Oct 6 19:48:15 2012 New Revision: 241294 URL: http://svn.freebsd.org/changeset/base/241294 Log: zfsboot: simplify probe_drive() a little bit The first discovered pool, whether it covers the whole boot disk or not, is going to be first in zfs_pools list. So there is no need at all for spapp parameter. This commit also fixes a bug where NULL would be assigned to NULL pointer when probe_drive was called with the spapp parameter of NULL. MFC after: 21 days Modified: head/sys/boot/i386/zfsboot/zfsboot.c Modified: head/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- head/sys/boot/i386/zfsboot/zfsboot.c Sat Oct 6 19:47:24 2012 (r241293) +++ head/sys/boot/i386/zfsboot/zfsboot.c Sat Oct 6 19:48:15 2012 (r241294) @@ -345,7 +345,7 @@ copy_dsk(struct dsk *dsk) } static void -probe_drive(struct dsk *dsk, spa_t **spap) +probe_drive(struct dsk *dsk) { #ifdef GPT struct gpt_hdr hdr; @@ -359,9 +359,10 @@ probe_drive(struct dsk *dsk, spa_t **spa /* * If we find a vdev on the whole disk, stop here. Otherwise dig - * out the MBR and probe each slice in turn for a vdev. + * out the partition table and probe each slice/partition + * in turn for a vdev. */ - if (vdev_probe(vdev_read, dsk, spap) == 0) + if (vdev_probe(vdev_read, dsk, NULL) == 0) return; sec = dmadat->secbuf; @@ -399,13 +400,7 @@ probe_drive(struct dsk *dsk, spa_t **spa if (memcmp(&ent->ent_type, &freebsd_zfs_uuid, sizeof(uuid_t)) == 0) { dsk->start = ent->ent_lba_start; - if (vdev_probe(vdev_read, dsk, spap) == 0) { - /* - * We record the first pool we find (we will try - * to boot from that one). - */ - spap = NULL; - + if (vdev_probe(vdev_read, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk * structure now since the vdev now owns this one. @@ -428,13 +423,7 @@ trymbr: if (!dp[i].dp_typ) continue; dsk->start = dp[i].dp_start; - if (vdev_probe(vdev_read, dsk, spap) == 0) { - /* - * We record the first pool we find (we will try to boot - * from that one. - */ - spap = 0; - + if (vdev_probe(vdev_read, dsk, NULL) == 0) { /* * This slice had a vdev. We need a new dsk structure now * since the vdev now owns this one. @@ -493,7 +482,7 @@ main(void) * Probe the boot drive first - we will try to boot from whatever * pool we find on that drive. */ - probe_drive(dsk, &spa); + probe_drive(dsk); /* * Probe the rest of the drives that the bios knows about. This @@ -520,20 +509,17 @@ main(void) dsk->part = 0; dsk->start = 0; dsk->init = 0; - probe_drive(dsk, NULL); + probe_drive(dsk); } /* - * If we didn't find a pool on the boot drive, default to the - * first pool we found, if any. + * The first discovered pool, if any, is the pool. */ + spa = spa_get_primary(); if (!spa) { - spa = spa_get_primary(); - if (!spa) { - printf("%s: No ZFS pools located, can't boot\n", BOOTPROG); - for (;;) - ; - } + printf("%s: No ZFS pools located, can't boot\n", BOOTPROG); + for (;;) + ; } primary_spa = spa;