Forcefully free buffer heads on transaction commit

On my testing vm, attempts to write files bigger than 7.5G end up
hanging the kernel. The problem seems to be that the page cache gets
full, and attempts to reclaim memory are problematic given that we hold
references to so many inodes and buffer heads at once.

I don't understand enough about memory to be able to solve this
correctly. My lousy solution here is to just free all buffer heads when
the transaction commits. I would expect this to hurt performance for
future operations on those same buffer heads, but I don't think I'm
seeing any difference. Either way, it's the best I can do for now.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
This commit is contained in:
Ernesto A. Fernández committed 2021-10-25 20:58:37 -03:00
1 parent e6de96862a
commit 517dd221df
1 file changed
+4
+4
View File
@@ -512,6 +512,10 @@ static void apfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
/* Future writes to mmapped areas should fault for CoW */
must_unlock = trylock_page(page);
page_mkclean(page);
/* XXX: otherwise, the page cache fills up and crashes the machine */
try_to_free_buffers(page);
if (must_unlock)
unlock_page(page);
put_page(page);