On Thu, 8 Jun 2017, Al Viro wrote:
The nasty cases are around short files, especially short files with holes.
Linear writes as done by cp(1) will do nothing worse than bogus i_blocks
(and possibly mangled counters in cylinder groups). Random write access
to short files, OTOH, steps into a lot more codepaths...
As for ->i_blocks, it triggers this:
root@kvm1:/mnt# df .; mkdir a; rmdir a; df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 507420 4504 462340 1% /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 507420 4536 462308 1% /mnt
Note the 32Kb (== one block on that ufs2) leaked here.
Every iteration will leak another one. Similar for long
symlinks...
Test results don't look pretty on FreeBSD. (I will also test OpenBSD and
NetBSD.)
Freebsd:
#newfs ada0s2d
Linux:
#mount -t ufs -o rw,ufstype=ufs2 /dev/sda18 /fbsdd
cd /fbsdd
#df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda18 20307184 8 18682632 1% /fbsdd
#mkdir a
#rmdir a
#df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda18 20307184 40 18682600 1% /fbsdd
#umount /dev/sda18
FreeBSD:
# fsck -n /dev/ada0s2d
** /dev/ada0s2d (NO WRITE)
** Last Mounted on /diskd
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
FREE BLK COUNT(S) WRONG IN SUPERBLK
SALVAGE? no
SUMMARY INFORMATION BAD
SALVAGE? no
BLK(S) MISSING IN BIT MAPS
SALVAGE? no
2 files, 2 used, 5076786 free (26 frags, 634595 blocks, 0.0%
fragmentation)