Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Dec 2012 14:37:26 +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: r244295 - head/sbin/growfs
Message-ID:  <201212161437.qBGEbQMX093587@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sun Dec 16 14:37:25 2012
New Revision: 244295
URL: http://svnweb.freebsd.org/changeset/base/244295

Log:
  When growing a filesystem, don't leave unused space at the end
  if there is not enough room for a full cylinder group.
  
  Reviewed by:	mckusick@

Modified:
  head/sbin/growfs/growfs.c

Modified: head/sbin/growfs/growfs.c
==============================================================================
--- head/sbin/growfs/growfs.c	Sun Dec 16 14:24:59 2012	(r244294)
+++ head/sbin/growfs/growfs.c	Sun Dec 16 14:37:25 2012	(r244295)
@@ -1611,17 +1611,20 @@ main(int argc, char **argv)
 	}
 	sblock.fs_ncg = howmany(sblock.fs_size, sblock.fs_fpg);
 
+	/*
+	 * Allocate last cylinder group only if there is enough room
+	 * for at least one data block.
+	 */
 	if (sblock.fs_size % sblock.fs_fpg != 0 &&
-	    sblock.fs_size % sblock.fs_fpg < cgdmin(&sblock, sblock.fs_ncg)) {
-		/*
-		 * The space in the new last cylinder group is too small,
-		 * so revert back.
-		 */
+	    sblock.fs_size <= cgdmin(&sblock, sblock.fs_ncg - 1)) {
+		humanize_number(oldsizebuf, sizeof(oldsizebuf),
+		    (sblock.fs_size % sblock.fs_fpg) * sblock.fs_fsize,
+		    "B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+		warnx("no room to allocate last cylinder group; "
+		    "leaving %s unused", oldsizebuf);
 		sblock.fs_ncg--;
 		if (sblock.fs_magic == FS_UFS1_MAGIC)
 			sblock.fs_old_ncyl = sblock.fs_ncg * sblock.fs_old_cpg;
-		printf("Warning: %jd sector(s) cannot be allocated.\n",
-		    (intmax_t)fsbtodb(&sblock, sblock.fs_size % sblock.fs_fpg));
 		sblock.fs_size = sblock.fs_ncg * sblock.fs_fpg;
 	}
 



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