[Midnightbsd-cvs] src [8702] trunk/sbin/growfs/growfs.c: when growing a filesystem, do not leave unused spaace at the end if there is not enough room for a full cylinder group
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 18:16:23 EDT 2016
Revision: 8702
http://svnweb.midnightbsd.org/src/?rev=8702
Author: laffer1
Date: 2016-09-25 18:16:23 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
when growing a filesystem, do not leave unused spaace at the end if there is not enough room for a full cylinder group
Modified Paths:
--------------
trunk/sbin/growfs/growfs.c
Modified: trunk/sbin/growfs/growfs.c
===================================================================
--- trunk/sbin/growfs/growfs.c 2016-09-25 22:15:49 UTC (rev 8701)
+++ trunk/sbin/growfs/growfs.c 2016-09-25 22:16:23 UTC (rev 8702)
@@ -1609,17 +1609,20 @@
}
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 Midnightbsd-cvs
mailing list