ext4: make sure enough credits are reserved for dioread_nolock writes
authorTheodore Ts'o <tytso@mit.edu>
Tue, 25 Dec 2018 01:27:08 +0000 (20:27 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 25 Dec 2018 01:27:08 +0000 (20:27 -0500)
commit812c0cab2c0dfad977605dbadf9148490ca5d93f
tree0a894d93e2d1bf7ee5364ea97b7d5fe10b95f091
parent18f2c4fcebf2582f96cbd5f2238f4f354a0e4847
ext4: make sure enough credits are reserved for dioread_nolock writes

There are enough credits reserved for most dioread_nolock writes;
however, if the extent tree is sufficiently deep, and/or quota is
enabled, the code was not allowing for all eventualities when
reserving journal credits for the unwritten extent conversion.

This problem can be seen using xfstests ext4/034:

   WARNING: CPU: 1 PID: 257 at fs/ext4/ext4_jbd2.c:271 __ext4_handle_dirty_metadata+0x10c/0x180
   Workqueue: ext4-rsv-conversion ext4_end_io_rsv_work
   RIP: 0010:__ext4_handle_dirty_metadata+0x10c/0x180
    ...
   EXT4-fs: ext4_free_blocks:4938: aborting transaction: error 28 in __ext4_handle_dirty_metadata
   EXT4: jbd2_journal_dirty_metadata failed: handle type 11 started at line 4921, credits 4/0, errcode -28
   EXT4-fs error (device dm-1) in ext4_free_blocks:4950: error 28

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
fs/ext4/inode.c