linux/fs/jbd2
Jan Kara bc23f0c8d7 jbd2: Fix unreclaimed pages after truncate in data=journal mode
Ted and Namjae have reported that truncated pages don't get timely
reclaimed after being truncated in data=journal mode. The following test
triggers the issue easily:

for (i = 0; i < 1000; i++) {
	pwrite(fd, buf, 1024*1024, 0);
	fsync(fd);
	fsync(fd);
	ftruncate(fd, 0);
}

The reason is that journal_unmap_buffer() finds that truncated buffers
are not journalled (jh->b_transaction == NULL), they are part of
checkpoint list of a transaction (jh->b_cp_transaction != NULL) and have
been already written out (!buffer_dirty(bh)). We clean such buffers but
we leave them in the checkpoint list. Since checkpoint transaction holds
a reference to the journal head, these buffers cannot be released until
the checkpoint transaction is cleaned up. And at that point we don't
call release_buffer_page() anymore so pages detached from mapping are
lingering in the system waiting for reclaim to find them and free them.

Fix the problem by removing buffers from transaction checkpoint lists
when journal_unmap_buffer() finds out they don't have to be there
anymore.

Reported-and-tested-by: Namjae Jeon <namjae.jeon@samsung.com>
Fixes: de1b794130
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
2015-11-24 15:34:35 -05:00
..
checkpoint.c jbd2: fix checkpoint list cleanup 2015-10-17 22:35:09 -04:00
commit.c jbd2: clean up feature test macros with predicate functions 2015-10-17 16:18:45 -04:00
journal.c ext4, jbd2: ensure entering into panic after recording an error in superblock 2015-10-18 17:02:56 -04:00
Kconfig jbd2: remove debug dependency on debug_fs and update Kconfig help text 2013-06-12 23:07:51 -04:00
Makefile [PATCH] jbd2: rename jbd2 symbols to avoid duplication of jbd symbols 2006-10-11 11:14:15 -07:00
recovery.c jbd2: clean up feature test macros with predicate functions 2015-10-17 16:18:45 -04:00
revoke.c jbd2: clean up feature test macros with predicate functions 2015-10-17 16:18:45 -04:00
transaction.c jbd2: Fix unreclaimed pages after truncate in data=journal mode 2015-11-24 15:34:35 -05:00