File system block size
Asked Answered
C

2

26

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.

Cierracig answered 16/12, 2011 at 17:3 Comment(0)
A
30

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.

Anibalanica answered 16/12, 2011 at 17:29 Comment(4)
How a 4k filesystem block size is mapped to a disk sector(512 bytes)? is it like 8 continuous sectors get mapped to a file system block?Bassinet
@VickyGupta: AIUI, 512 byte disk sectors have been obsolete (no longer manufactured) since January, 2011. The Advanced Format standard replaced 512 byte sectors with 4096 byte sectors for ALL manufacturers. This was done to make more efficient use of the platter space among other considerations.Inset
@Seamus, Thank you for sharing Advanced Format Standard. Is this relevant for solid-state drives and flash drives also?Bibb
Hi @BalaTJ – not really. Flash storage does have a similar concept called pages.Bonney
Z
0

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.

Zoochemistry answered 16/12, 2011 at 17:11 Comment(2)
My question was more to understand how file systems work and how they interact with the block device. What is the significance of the block size in that context.Cierracig
en.wikipedia.org/wiki/File_system#Space_management. Disk clusters (groups of sectors) and the blocks we're talking of refers to the same concept.Zoochemistry

© 2022 - 2024 — McMap. All rights reserved.