From owner-svn-src-head@FreeBSD.ORG Sun Apr 25 00:54:12 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1138D106564A; Sun, 25 Apr 2010 00:54:12 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB9638FC0C; Sun, 25 Apr 2010 00:54:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3P0sBG0097325; Sun, 25 Apr 2010 00:54:11 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3P0sB3C097323; Sun, 25 Apr 2010 00:54:11 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201004250054.o3P0sB3C097323@svn.freebsd.org> From: Marcel Moolenaar Date: Sun, 25 Apr 2010 00:54:11 +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: r207178 - head/sys/geom/part X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Apr 2010 00:54:12 -0000 Author: marcel Date: Sun Apr 25 00:54:11 2010 New Revision: 207178 URL: http://svn.freebsd.org/changeset/base/207178 Log: Fix undo for schemes that have internal partitions. Internal partitions do not constitute user-visible or active partitions and as such should not prevent undoing pending operations. While here, initialize the last usable sector for the placeholder geom based on the null scheme, created to allow undoing the destruction of a scheme. This gives consistent output with "gpart show". Based on a patch from: "Andrey V. Elsukov" Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Sun Apr 25 00:05:51 2010 (r207177) +++ head/sys/geom/part/g_part.c Sun Apr 25 00:54:11 2010 (r207178) @@ -855,7 +855,9 @@ g_part_ctl_delete(struct gctl_req *req, static int g_part_ctl_destroy(struct gctl_req *req, struct g_part_parms *gpp) { + struct g_consumer *cp; struct g_geom *gp; + struct g_provider *pp; struct g_part_entry *entry; struct g_part_table *null, *table; struct sbuf *sb; @@ -885,6 +887,11 @@ g_part_ctl_destroy(struct gctl_req *req, null->gpt_gp = gp; null->gpt_scheme = &g_part_null_scheme; LIST_INIT(&null->gpt_entry); + + cp = LIST_FIRST(&gp->consumer); + pp = cp->provider; + null->gpt_last = pp->mediasize / pp->sectorsize - 1; + null->gpt_depth = table->gpt_depth; null->gpt_opened = table->gpt_opened; null->gpt_smhead = table->gpt_smhead; @@ -1141,10 +1148,16 @@ g_part_ctl_undo(struct gctl_req *req, st table->gpt_created) ? 1 : 0; if (reprobe) { - if (!LIST_EMPTY(&table->gpt_entry)) { + LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) { + if (entry->gpe_internal) + continue; error = EBUSY; goto fail; } + while ((entry = LIST_FIRST(&table->gpt_entry)) != NULL) { + LIST_REMOVE(entry, gpe_entry); + g_free(entry); + } error = g_part_probe(gp, cp, table->gpt_depth); if (error) { g_topology_lock();