ext4: grab page before starting transaction handle in write_begin()
authorTheodore Ts'o <tytso@mit.edu>
Sat, 9 Feb 2013 14:24:14 +0000 (09:24 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 9 Feb 2013 14:24:14 +0000 (09:24 -0500)
commit47564bfb95bf370d73906fc4ae57c271e8ba96cd
tree5e2bdd86884e37afbb397ff509d2755cea451372
parent9924a92a8c217576bd2a2b1bbbb854462f1a00ae
ext4: grab page before starting transaction handle in write_begin()

The grab_cache_page_write_begin() function can potentially sleep for a
long time, since it may need to do memory allocation which can block
if the system is under significant memory pressure, and because it may
be blocked on page writeback.  If it does take a long time to grab the
page, it's better that we not hold an active jbd2 handle.

So grab a handle on the page first, and _then_ start the transaction
handle.

This commit fixes the following long transaction handle hold time:

postmark-2917  [000] ....   196.435786: jbd2_handle_stats: dev 254,32
   tid 570 type 2 line_no 2541 interval 311 sync 0 requested_blocks 1
   dirtied_blocks 0

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/ext4/inode.c