git: cb59f7dd2201 - stable/13 - Correctly update fs_dsize in growfs(8)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Jul 2022 21:46:29 UTC
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=cb59f7dd2201100ac5fbd693c144b21bb265fc45 commit cb59f7dd2201100ac5fbd693c144b21bb265fc45 Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2022-06-28 04:46:15 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> CommitDate: 2022-07-08 21:46:16 +0000 Correctly update fs_dsize in growfs(8) When growing a UFS/FFS filesystem, the size of the summary information may expand into additional blocks. These blocks must be removed from fs_dsize which records the number of blocks in the filesystem that can be used to hold filesystem data. While here also update the fs_old_dsize and fs_old_size fields for compatibility with kernels that were compiled before the addition of UFS2. (cherry picked from commit 2049cc3218151f8d4108d878196905c34bbf15bc) --- sbin/growfs/growfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index 6a57924fb7bc..69e6f04dd4c2 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -427,6 +427,7 @@ initcg(int cylno, time_t modtime, int fso, unsigned int Nflag) sblock.fs_dsize += dlower; } sblock.fs_dsize += acg.cg_ndblk - dupper; + sblock.fs_old_dsize = sblock.fs_dsize; if ((i = dupper % sblock.fs_frag)) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { @@ -636,6 +637,7 @@ updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag) DBG_PRINT0("\n"); acg.cg_ndblk = dmax - cbase; sblock.fs_dsize += acg.cg_ndblk - aocg.cg_ndblk; + sblock.fs_old_dsize = sblock.fs_dsize; if (sblock.fs_contigsumsize > 0) acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; @@ -813,6 +815,10 @@ updcsloc(time_t modtime, int fsi, int fso, unsigned int Nflag) DBG_LEAVE; return; } + /* Adjust fs_dsize by added summary blocks */ + sblock.fs_dsize -= howmany(sblock.fs_cssize, sblock.fs_fsize) - + howmany(osblock.fs_cssize, osblock.fs_fsize); + sblock.fs_old_dsize = sblock.fs_dsize; ocscg = dtog(&osblock, osblock.fs_csaddr); cs = fscs + ocscg; @@ -1507,7 +1513,8 @@ main(int argc, char **argv) "filesystem size %s", newsizebuf, oldsizebuf); } - sblock.fs_size = dbtofsb(&osblock, size / DEV_BSIZE); + sblock.fs_old_size = sblock.fs_size = + dbtofsb(&osblock, size / DEV_BSIZE); sblock.fs_providersize = dbtofsb(&osblock, mediasize / DEV_BSIZE); /* @@ -1628,7 +1635,8 @@ main(int argc, char **argv) sblock.fs_ncg--; if (sblock.fs_magic == FS_UFS1_MAGIC) sblock.fs_old_ncyl = sblock.fs_ncg * sblock.fs_old_cpg; - sblock.fs_size = sblock.fs_ncg * sblock.fs_fpg; + sblock.fs_old_size = sblock.fs_size = + sblock.fs_ncg * sblock.fs_fpg; } /*