From owner-svn-src-head@FreeBSD.ORG Sun May 4 16:43:58 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 24C4415A; Sun, 4 May 2014 16:43:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0610C19A9; Sun, 4 May 2014 16:43:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s44GhvB5073957; Sun, 4 May 2014 16:43:57 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s44GhvJR073951; Sun, 4 May 2014 16:43:57 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201405041643.s44GhvJR073951@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sun, 4 May 2014 16:43:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265331 - head/sys/geom/part X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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, 04 May 2014 16:43:58 -0000 Author: ae Date: Sun May 4 16:43:57 2014 New Revision: 265331 URL: http://svnweb.freebsd.org/changeset/base/265331 Log: Prevent an unexpected shrinking on resizing due to alignment for MBR, PC98 and VTOC8 schemes. Reported by: jmg MFC after: 1 week Modified: head/sys/geom/part/g_part_mbr.c head/sys/geom/part/g_part_pc98.c head/sys/geom/part/g_part_vtoc8.c Modified: head/sys/geom/part/g_part_mbr.c ============================================================================== --- head/sys/geom/part/g_part_mbr.c Sun May 4 16:39:18 2014 (r265330) +++ head/sys/geom/part/g_part_mbr.c Sun May 4 16:43:57 2014 (r265331) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "g_part_if.h" @@ -353,7 +354,11 @@ g_part_mbr_resize(struct g_part_table *b size = gpp->gpp_size; if (mbr_align(basetable, NULL, &size) != 0) return (EINVAL); - + /* XXX: prevent unexpected shrinking. */ + pp = baseentry->gpe_pp; + if ((g_debugflags & 16) == 0 && size < gpp->gpp_size && + (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) + return (EBUSY); entry = (struct g_part_mbr_entry *)baseentry; baseentry->gpe_end = baseentry->gpe_start + size - 1; entry->ent.dp_size = size; Modified: head/sys/geom/part/g_part_pc98.c ============================================================================== --- head/sys/geom/part/g_part_pc98.c Sun May 4 16:39:18 2014 (r265330) +++ head/sys/geom/part/g_part_pc98.c Sun May 4 16:43:57 2014 (r265331) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "g_part_if.h" @@ -360,7 +361,11 @@ g_part_pc98_resize(struct g_part_table * size = gpp->gpp_size; if (pc98_align(basetable, NULL, &size) != 0) return (EINVAL); - + /* XXX: prevent unexpected shrinking. */ + pp = baseentry->gpe_pp; + if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size && + (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) + return (EBUSY); entry = (struct g_part_pc98_entry *)baseentry; baseentry->gpe_end = baseentry->gpe_start + size - 1; pc98_set_chs(basetable, baseentry->gpe_end, &entry->ent.dp_ecyl, Modified: head/sys/geom/part/g_part_vtoc8.c ============================================================================== --- head/sys/geom/part/g_part_vtoc8.c Sun May 4 16:39:18 2014 (r265330) +++ head/sys/geom/part/g_part_vtoc8.c Sun May 4 16:43:57 2014 (r265331) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "g_part_if.h" @@ -367,7 +368,11 @@ g_part_vtoc8_resize(struct g_part_table size = gpp->gpp_size; if (vtoc8_align(table, NULL, &size) != 0) return (EINVAL); - + /* XXX: prevent unexpected shrinking. */ + pp = entry->gpe_pp; + if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size && + (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) + return (EBUSY); entry->gpe_end = entry->gpe_start + size - 1; be32enc(&table->vtoc.map[entry->gpe_index - 1].nblks, size);