Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 May 2014 16:43:57 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265331 - head/sys/geom/part
Message-ID:  <201405041643.s44GhvJR073951@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/systm.h>
 #include <sys/sysctl.h>
 #include <geom/geom.h>
+#include <geom/geom_int.h>
 #include <geom/part/g_part.h>
 
 #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 <sys/systm.h>
 #include <sys/sysctl.h>
 #include <geom/geom.h>
+#include <geom/geom_int.h>
 #include <geom/part/g_part.h>
 
 #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 <sys/sysctl.h>
 #include <sys/vtoc.h>
 #include <geom/geom.h>
+#include <geom/geom_int.h>
 #include <geom/part/g_part.h>
 
 #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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405041643.s44GhvJR073951>