File system block size

2019-03-09 10:59发布

What is the significance of the file system block size? If my Filesystem block size is set at say 8K does that mean that all read/write I/O will happen at size 8K? So if my application wants to read say 16 bytes at offset 4097 then a 4K block starting from offset 4096 will be read?

How do writes work in this case? Suppose I want to write say 64 bytes.

2条回答
该账号已被封号
2楼-- · 2019-03-09 11:20

You are right. The block size is the unit of work for the file system. Every read and write is done in full multiples of the block size.

The block size is also the smallest size on disk a file can have. If you have a 16 byte Block size,then a file with 16 bytes size occupies a full block on disk.

The book "Practical file system design" states:

Block: The smallest unit writable by a disk or file system. Everything a file system does is composed of operations done on blocks. A file system block is always the same size as or larger (in integer multiples) than the disk block size.

查看更多
叛逆
3楼-- · 2019-03-09 11:34

Normally when you have to deal with files in programming you should use Stream abstraction. I/O operations through code are often reads and writes to streams; reading and writing from and to streams, can be buffered so that chunks of file can be read or written.

Block size on fs refers to mapping disk surface; minor the size of the single block major the number of blocks (and so the elements in the table that keeps information on allocation of files).

So OS's so can map file on disk discretely based on block size and have a smaller "map of files". As I know this doesn't affect stream abstraction in API's of programming language.

查看更多
登录 后发表回答