summaryrefslogtreecommitdiffstats
path: root/sbin/growfs/growfs.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2012-12-16 14:37:25 +0000
committertrasz <trasz@FreeBSD.org>2012-12-16 14:37:25 +0000
commit1fdcf9e7be7549ebb4e865fadc73f5f6c4daf661 (patch)
treeee498b5fe23ad5b131f1d9248580c4b678f76204 /sbin/growfs/growfs.c
parenta198747e4adcc47898d7fe44d1bc98e460a61f36 (diff)
downloadFreeBSD-src-1fdcf9e7be7549ebb4e865fadc73f5f6c4daf661.zip
FreeBSD-src-1fdcf9e7be7549ebb4e865fadc73f5f6c4daf661.tar.gz
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@
Diffstat (limited to 'sbin/growfs/growfs.c')
-rw-r--r--sbin/growfs/growfs.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c
index c93d111..745e9e9 100644
--- a/sbin/growfs/growfs.c
+++ b/sbin/growfs/growfs.c
@@ -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;
}
OpenPOWER on IntegriCloud