Message ID | 20191003220613.10791-1-jack@suse.cz |
---|---|
State | Superseded |
Headers | show |
Series | ext4: Fix transaction overflow due to revoke descriptors | expand |
On Fri, Oct 04, 2019 at 12:05:47AM +0200, Jan Kara wrote: > When number of free space in the journal is very low, the arithmetic in > jbd2_log_space_left() could underflow resulting in very high number of > free blocks and thus triggering assertion failure in transaction commit > code complaining there's not enough space in the journal: > > J_ASSERT(journal->j_free > 1); > > Properly check for the low number of free blocks. > > CC: stable@vger.kernel.org > Signed-off-by: Jan Kara <jack@suse.cz> Looks good, you can add: Reviewed-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 603fbc4e2f70..10e6049c0ba9 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1582,7 +1582,7 @@ static inline int jbd2_space_needed(journal_t *journal) static inline unsigned long jbd2_log_space_left(journal_t *journal) { /* Allow for rounding errors */ - unsigned long free = journal->j_free - 32; + long free = journal->j_free - 32; if (journal->j_committing_transaction) { unsigned long committing = atomic_read(&journal-> @@ -1591,7 +1591,7 @@ static inline unsigned long jbd2_log_space_left(journal_t *journal) /* Transaction + control blocks */ free -= committing + (committing >> JBD2_CONTROL_BLOCKS_SHIFT); } - return free; + return max_t(long, free, 0); } /*
When number of free space in the journal is very low, the arithmetic in jbd2_log_space_left() could underflow resulting in very high number of free blocks and thus triggering assertion failure in transaction commit code complaining there's not enough space in the journal: J_ASSERT(journal->j_free > 1); Properly check for the low number of free blocks. CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> --- include/linux/jbd2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)