summaryrefslogtreecommitdiff
path: root/0 Inbox/Writeback cache.md
blob: 83495c43a7ec08100d90e600341c5b3c3f9db486 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
tags:
  - linux
  - qemu
  - filesystem
references:
  - https://avidandrew.com/understanding-disk-cache-writeback-ext4.html
  - https://docs.kernel.org/admin-guide/sysctl/vm.html#dirty-expire-centisecs
---
normal: write() -> cache (multiple layers) -> disk

# Physical server write cache
![[physical_write_cache.png]] 

Page cache -> RAM

Journal -> ensures data is fully written before the transaction is considered complete.
`commit` mount option -> flushes cache to disk every x seconds (configurable)
`barrier` mount option -> enables the ordering of groups of writes, controller ensures writes before barrier are written before writes after barrier.

`commit` + dirty_expire_centisecs [2] ~ automatic persisting of data.

If we call `sync`, `fsync` or `fdatasync` ourselves our data is forced on-disk right away by the kernel, no need to wait for commit + dirty_expirty_centisecs.

# VM Write cache
 Guest has its own page cache
 ![[vm_write_cache.png]]