Comment 143 for bug 317781

Revision history for this message
Theodore Ts'o (tytso) wrote :

>But why can't the metadata writes be delayed as
>well? Why do they have to be written every five seconds
>instead of much later, whenever the data happens to get written?

Fundamentally the problem is "entangled commits". Normally there are multiple things happening all at once in a filesystem. One process is truncating a file and rewriting it, and other process is creating a new file and allocating blocks, and so (for example) both process might touch the block allocation bitmap as they do their various operations. So it's not as simple as "delaying the truncate"; you can delay committing all operations in the journal, but you can't just delay one transaction but not another. This is the case with SQL as well; you can issue various commands, such as an SQL "INSERT" and an SQL "DROP" command, but you can't delay one SQL statement beyond another one; although you can control when you send the "COMMIT" statement.

So you can change the journal commit interval from 5 seconds to say 30 seconds, or 600 seconds. Laptop mode for example will by default change the journal commit time to 30 seconds. That will do part of what you want; if you make the journal commit interval much larger than the default writeback time, that will achieve most of what you want. However, various disk buffers will get pinned in memory until the commit takes place, so extending commits may end up chewing up more memory used by the kernel. TNSTAAFL.