Just last week I got ATA DMA working on my OS (Available at https://github.com/champo/ArqvengerOS/). Now during the work to integrate it with the rest of the OS, I find myself wondering if I can access (read & write) memory that I just asked the DMA controller to write to disk safely.
If you feel like understanding why I ask, this is it:
I have a cache layer between the FS and the ATA device. I'm trying to offer the cache memory directly to FS, and to have a kernel thread write back dirty pages (checking for the dirty bit set by the MMU). This would allow me to map the FS structures directly to that memory, which will get written automatically, freeing the file system from that task. The problem is, it's likely a page that might still suffer modifications while it's being written to disk. So I either need to do extensive use of locks (locks that I have already, but I'd rather not use if possible), or things get sorted out by the controller/CPU.
Operations on ATA DMA memory
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Operations on ATA DMA memory
No, the CPU and DMA controller do not coordinate to "lock" memory that one is accessing.
Perhaps mark the pages the controller is actively using as read-only and do copy on write?
In any case, most of the time disk data is cached after the file system, as most file systems rely on the ordering of disk writes for integrity. I would make file systems issue raw reads/writes to the disk layer, and have caching on the data read from the files (i.e. in the VFS layer)
Perhaps mark the pages the controller is actively using as read-only and do copy on write?
In any case, most of the time disk data is cached after the file system, as most file systems rely on the ordering of disk writes for integrity. I would make file systems issue raw reads/writes to the disk layer, and have caching on the data read from the files (i.e. in the VFS layer)
Re: Operations on ATA DMA memory
Well that sucks. I imagined journaled file systems and the like manually controlled writes to ensure integrity. I wasn't going down that road here because I was aiming more for simplicity for the programmer.
Anyway, thanks for the answer!
Anyway, thanks for the answer!