diff options
Diffstat (limited to '3 Resources/Linux/FS')
-rw-r--r-- | 3 Resources/Linux/FS/Tmpfs.md | 16 | ||||
-rw-r--r-- | 3 Resources/Linux/FS/Writeback cache.md | 36 | ||||
-rw-r--r-- | 3 Resources/Linux/FS/physical_write_cache.png | bin | 0 -> 32969 bytes | |||
-rw-r--r-- | 3 Resources/Linux/FS/vm_write_cache.png | bin | 0 -> 40616 bytes |
4 files changed, 52 insertions, 0 deletions
diff --git a/3 Resources/Linux/FS/Tmpfs.md b/3 Resources/Linux/FS/Tmpfs.md new file mode 100644 index 0000000..b8fe839 --- /dev/null +++ b/3 Resources/Linux/FS/Tmpfs.md @@ -0,0 +1,16 @@ +#linux #filesystem + +--- +Is a [[virtual filesystem]] that is stored in memory; it uses both RAM and swap space. +> Kernel option: CONFIG_TMPFS + +`mount -t tmpfs source target` + +A tmpfs can only grow to 50% of RAM avail. unless overridden with size=nbytes mount option. +Only consumes RAM for actual usage. +Data is ephemeral/volatile. + +Mount stacking: mount over existing /tmp, to improve speed of apps using alot of tmp files, then unmount to delete data. + +Kernel uses tmpfs for [[system v shared memory]] and [[shared anonymous memory mappings]]. +`/dev/shm` or `/run/shm`: [[glibc]] of [[POSIX]] shared memory and [[POSIX]] semaphores.
\ No newline at end of file diff --git a/3 Resources/Linux/FS/Writeback cache.md b/3 Resources/Linux/FS/Writeback cache.md new file mode 100644 index 0000000..03917bb --- /dev/null +++ b/3 Resources/Linux/FS/Writeback cache.md @@ -0,0 +1,36 @@ +--- +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), ==default = 5.== +`barrier` mount option -> enables the ordering of groups of writes, controller ensures writes before barrier are written before writes after barrier. ==Default = 1== + +`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]] + +QEMU/KVM options for disk caches: +- Writeback -> write complete if in host page cache; guest required to flush for integrity. +- Writethrough -> write complete if committed to disk; guest no need to flush. +- None -> Equivalent to direct access to host disk. Guest needs to flush. +- Unsafe -> eq writeback but flush ignored. Performance. +- Directsync -> writethrough but without host page cache. + +Safe if guest uses `commit` and `barrier` and therefore `fdatasync` syscalls on a recurring basis.
\ No newline at end of file diff --git a/3 Resources/Linux/FS/physical_write_cache.png b/3 Resources/Linux/FS/physical_write_cache.png Binary files differnew file mode 100644 index 0000000..819c834 --- /dev/null +++ b/3 Resources/Linux/FS/physical_write_cache.png diff --git a/3 Resources/Linux/FS/vm_write_cache.png b/3 Resources/Linux/FS/vm_write_cache.png Binary files differnew file mode 100644 index 0000000..1c63843 --- /dev/null +++ b/3 Resources/Linux/FS/vm_write_cache.png |