Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jul 2012 17:51:20 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238657 - head/sys/geom/part
Message-ID:  <201207201751.q6KHpKiQ022210@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Fri Jul 20 17:51:20 2012
New Revision: 238657
URL: http://svn.freebsd.org/changeset/base/238657

Log:
  Make it possible to resize opened partitions.
  
  Sponsored by:	FreeBSD Foundation

Modified:
  head/sys/geom/part/g_part.c

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c	Fri Jul 20 16:56:34 2012	(r238656)
+++ head/sys/geom/part/g_part.c	Fri Jul 20 17:51:20 2012	(r238657)
@@ -1257,6 +1257,7 @@ g_part_ctl_resize(struct gctl_req *req, 
 	struct sbuf *sb;
 	quad_t end;
 	int error;
+	off_t mediasize;
 
 	gp = gpp->gpp_geom;
 	G_PART_TRACE((G_T_TOPOLOGY, "%s(%s)", __func__, gp->name));
@@ -1301,8 +1302,11 @@ g_part_ctl_resize(struct gctl_req *req, 
 	pp = entry->gpe_pp;
 	if ((g_debugflags & 16) == 0 &&
 	    (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) {
-		gctl_error(req, "%d", EBUSY);
-		return (EBUSY);
+		if (entry->gpe_end - entry->gpe_start + 1 > gpp->gpp_size) {
+			/* Deny shrinking of an opened partition. */
+			gctl_error(req, "%d", EBUSY);
+			return (EBUSY);
+		} 
 	}
 
 	error = G_PART_RESIZE(table, entry, gpp);
@@ -1315,8 +1319,9 @@ g_part_ctl_resize(struct gctl_req *req, 
 		entry->gpe_modified = 1;
 
 	/* update mediasize of changed provider */
-	pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) *
+	mediasize = (entry->gpe_end - entry->gpe_start + 1) *
 		pp->sectorsize;
+	g_resize_provider(pp, mediasize);
 
 	/* Provide feedback if so requested. */
 	if (gpp->gpp_parms & G_PART_PARM_OUTPUT) {



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