File IO Flashcards

1
Q

How disk stores data?

A

Disks are divided into logical blocks called sector and track .

Data is written into blocks denoting sector And track

Usually block is 512 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Standard io( buffered io ) vs direct io

A

Buffered io
- when data is written it uses kernel space cache to write the data as intermediate. Data will not be written directly into disk .
- Kernel uses write back to write the contents
Each kernel page is of usually 4096 bytes
- When kernel page cache is full , eviction policy is used to evict the least recently data to disk .

Direct IO :
It skips the kernel page and writes directly to disk . Uses O-DIRECT flag. Write will take more time . Some applications uses direct IO .

PostgreSQL uses direct io to write write-ahead-log to make sure there are no failures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Block alignment

A

In direct io

How well did you know this?
1
Not at all
2
3
4
5
Perfectly