freebsd-dev/sys/ufs/ffs
Kirk McKusick bc218d8920 Two bug fixes to UFS/FFS superblock integrity checks when reading a superblock.
Two bugs have been reported with the UFS/FFS superblock integrity
checks that were added in commit 076002f24d.

The code checked that fs_sblockactualloc was properly set to the
location of the superblock. The fs_sblockactualloc field was an
addition to the superblock in commit dffce2150e on Jan 26 2018
and used a field that was zero in filesystems created before it
was added. The integrity check had to be expanded to accept the
fs_sblockactualloc field being zero so as not to reject filesystems
created before Jan 26 2018.

The integrity check set an upper bound on the value of fs_maxcontig
based on the maximum transfer size supported by the kernel. It
required that fs->fs_maxcontig <= maxphys / fs->fs_bsize. The kernel
variable maxphys defines the maximum transfer size permitted by the
controllers and/or buffering. The fs_maxcontig parameter controls the
maximum number of blocks that the filesystem will read or write in
a single transfer. It is calculated when the filesystem is created
as maxphys / fs_bsize. The bug appeared in the loader because it
uses a maxphys of 128K even when running on a system that supports
larger values. If the filesystem was built on a system that supports
a larger maxphys (1M is typical) it will have configured fs_maxcontig
for that larger system so would fail the test when run with the smaller
maxphys used by the loader. So we bound the upper allowable limit
for fs_maxconfig to be able to at least work with a 1M maxphys on the
smallest block size filesystem: 1M / 4096 == 256. We then use the
limit for fs_maxcontig as fs_maxcontig <= MAX(256, maxphys / fs_bsize).
There is no harm in allowing the mounting of filesystems that make larger
than maxphys I/O requests because those (mostly 32-bit machines) can
(very slowly) handle I/O requests that exceed maxphys.

Thanks to everyone who helped sort out the problems and the fixes.

Reported by:  Cy Schubert, David Wolfskill
Diagnosis by: Mark Johnston, John Baldwin
Reviewed by:  Warner Losh
Tested by:    Cy Schubert, David Wolfskill
MFC after:    1 month (with 076002f24d)
Differential Revision: https://reviews.freebsd.org/D35219
2022-05-31 19:58:37 -07:00
..
ffs_alloc.c ffs(3): Fix a common typo in source code comments 2022-03-28 19:37:03 +02:00
ffs_balloc.c ffs: lock buffers after snaplk with LK_NOWITNESS 2022-02-01 06:54:50 +02:00
ffs_extern.h Consolodate four copies of the STDSB define into a single place. 2021-11-14 22:10:16 -08:00
ffs_inode.c ufs: be more persistent with finishing some operations 2022-01-31 04:46:21 +02:00
ffs_rawread.c vmapbuf: don't smuggle address or length in buf 2020-10-21 16:00:15 +00:00
ffs_snapshot.c vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
ffs_softdep.c ffs: plug a set-but-not-used var 2022-04-19 16:51:12 +02:00
ffs_subr.c Two bug fixes to UFS/FFS superblock integrity checks when reading a superblock. 2022-05-31 19:58:37 -07:00
ffs_suspend.c ffs: remove unused thread argument from ffs_reload() 2021-09-04 12:25:10 -08:00
ffs_tables.c
ffs_vfsops.c UFS: clear fs_fmod once more, in the buffer data copy. 2022-05-09 23:46:05 +03:00
ffs_vnops.c ffs_read(): lock buffers after snaplk with LK_NOWITNESS 2022-02-06 03:26:22 +02:00
fs.h Add ability to suppress UFS/FFS superblock check-hash failure messages. 2021-11-15 09:11:54 -08:00
softdep.h Clean up orphaned indirdep dependency structures after disk failure. 2021-07-29 16:31:16 -07:00