Page 1 of 1
Disk IO and OS
Posted: Wed Sep 12, 2007 1:45 am
by dillonhao
we know that the disk read or write couple of fix size (say 64k).
what if i got an io smaller than 64k for example 30k. what will the os do?
Does the os need to read the 64k from the disk first then write the update 64k to the disk?
help me.
Posted: Wed Sep 12, 2007 1:48 am
by AJ
Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.
Cheers,
Adam
Posted: Wed Sep 12, 2007 2:39 pm
by bewing
The blocks cached by the OS do not *need* to be the same size as the clusters on your disk. They can be smaller. But it makes things a bit more complicated if they are different sizes. My OS reads and writes in 32K chunks, for any cluster size larger than 32K.
Posted: Thu Sep 13, 2007 1:32 am
by dillonhao
AJ wrote:Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.
Cheers,
Adam
Thank you
then what is the default io size for a disk. Can I change it?
for example i got an aplication io size 30k. i want to change the disk io size to 32k making it more efficient.
Posted: Thu Sep 13, 2007 5:16 am
by Solar
I am not sure I understood your question correctly, but you might want to check out the C standard functions setvbuf() (in <stdio.h>).
Posted: Thu Sep 13, 2007 7:53 pm
by frank
dillonhao wrote:AJ wrote:Yes. If a process requests a read of less than the block size, the driver needs to read and cache the block, writing back the changed block when you write back to disk.
Cheers,
Adam
Thank you
then what is the default io size for a disk. Can I change it?
for example i got an aplication io size 30k. i want to change the disk io size to 32k making it more efficient.
Disks, such as hard drives and floppy drives, work in blocks of 512 bytes(normally, of course their are exceptions.) CDs work in blocks on 2048 blocks IIRC. The OS however could have larger block sizes of say 4096 bytes. Also some filesystems have bigger blocks such as 4096 or higher.