Many sources, such as https://www.commandlinux.com/man-page/man8/mkfs.ext4.8.html read:
...block-size is heuristically determined by the filesystem size...
What is this heuristic?
In which source file can the calculation be found?
Do all modern HDDs/SSDs (i.e. over 100 GB) cause 4KiB blocks by default with this heuristic?
答案1
The calculation seems to be quite simple: if the block size is not selected by user it defaults to page size (so 4096) or logical sector size of the device if it's bigger than page size (there are few more exceptions, but this should cover most of the cases).
The e2fsprogs
source is available here and the code that sets blocksize in mke2fs
is here.