Hard disk LEDs and noisy machines (by Julio Merino) (Developers)
> You are confusing buffering and caching.
Buffering and caching are essentially the same thing (or are at least trying to accomplish something similar), though they do it in different ways. Every application that I know of (including the OS) reads from the disk into memory and manipulates what's in memory before writing back, or manipulates the memory before writing something new to disk. They don't work with the data while it's still on the disk. Part of the reason for that is that the data is stored on the disk in blocks (sectors/clusters) and you may only need to manipulate the data in bits or bytes, or at least something much smaller than a sector/cluster. There are other reasons as well, but that is an important one.
Any OS worth its salt will never simply buffer/cache data in memory before writing to disk. The problem with that approach is that if there is a crash in the middle somewhere ALL the data is lost. That's why they invented Journaling File Systems (JFS). In a JFS, the data is not simply stored in memory waiting to be put on disk later. The data is written to disk right away, but is stored in a temporary "holding space" called the Journal. What is stored in the Journal is enough information (the data and/or metadata) so that it can be moved to the correct place on the disk later, but while it's stored in the Journal it's "messy". If there is a crash between the Journal write and the "real" write, the data can still be put on the disk where it needs to be. If there is a crash while writing to the Journal, the data will be corrupted. The point of the Journal is to get _something_ relevant out of memory and onto the disk as fast as possible and worry about cleaning up the details later. Also note that in a JFS the disk is used a lot more than in a "regular" file system since the data is written and then moved (written to a new location and then deleted from the old location).
BTW, that's similar to how databases work. When you update a record in a database it gets written to disk right away -- it is not simply stored in memory waiting for a "batch update" to happen later.
Complete thread:
- Hard disk LEDs and noisy machines (by Julio Merino) - rr, 13.02.2024, 21:44
- Hard disk LEDs and noisy machines (by Julio Merino) - RayeR, 14.02.2024, 22:39
- Hard disk LEDs and noisy machines (by Julio Merino) - samwdpckr, 16.02.2024, 23:13
- Hard disk LEDs and noisy machines (by Julio Merino) - glennmcc, 17.02.2024, 22:48
- Hard disk LEDs and noisy machines (by Julio Merino) - samwdpckr, 18.02.2024, 19:02
- Hard disk LEDs and noisy machines (by Julio Merino) - glennmcc, 18.02.2024, 19:19
- Hard disk LEDs and noisy machines (by Julio Merino) - rr, 18.02.2024, 20:20
- Hard disk LEDs and noisy machines (by Julio Merino) - bretjohn, 19.02.2024, 16:40
- Hard disk LEDs and noisy machines (by Julio Merino) - Rugxulo, 22.02.2024, 03:50
- Hard disk LEDs and noisy machines (by Julio Merino) - Rugxulo, 21.03.2024, 07:22
- Hard disk LEDs and noisy machines (by Julio Merino) - Rugxulo, 22.02.2024, 03:50
- Hard disk LEDs and noisy machines (by Julio Merino) - glennmcc, 18.02.2024, 19:19
- Hard disk LEDs and noisy machines (by Julio Merino) - samwdpckr, 18.02.2024, 19:02
- Hard disk LEDs and noisy machines (by Julio Merino) - bretjohn, 18.02.2024, 16:09
- Hard disk LEDs and noisy machines (by Julio Merino) - glennmcc, 17.02.2024, 22:48