svn commit: r246237 - stable/9/sbin/growfs
Edward Tomasz Napierala
trasz at FreeBSD.org
Sat Feb 2 10:04:24 UTC 2013
Author: trasz
Date: Sat Feb 2 10:04:23 2013
New Revision: 246237
URL: http://svnweb.freebsd.org/changeset/base/246237
Log:
MFC r244295:
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:
stable/9/sbin/growfs/growfs.c
Directory Properties:
stable/9/sbin/growfs/ (props changed)
Modified: stable/9/sbin/growfs/growfs.c
==============================================================================
--- stable/9/sbin/growfs/growfs.c Sat Feb 2 10:02:26 2013 (r246236)
+++ stable/9/sbin/growfs/growfs.c Sat Feb 2 10:04:23 2013 (r246237)
@@ -1609,17 +1609,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;
}
More information about the svn-src-stable-9
mailing list