jbd2: fix race in t_outstanding_credits update in jbd2_journal_extend()
authorJan Kara <jack@suse.cz>
Tue, 4 Jun 2013 16:22:15 +0000 (12:22 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 4 Jun 2013 16:22:15 +0000 (12:22 -0400)
commitfe1e8db598b259eafdffbe3dd5fe849cd2ad97d5
treea5f7f35d95ab0737457f3ab6ea3a0234c3009df8
parent76c39904561004ac8675f858a290129e439d5168
jbd2: fix race in t_outstanding_credits update in jbd2_journal_extend()

jbd2_journal_extend() first checked whether transaction can accept
extending handle with more credits and then added credits to
t_outstanding_credits.  This can race with start_this_handle() adding
another handle to a transaction and thus overbooking a transaction.
Make jbd2_journal_extend() use atomic_add_return() to close the race.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/jbd2/transaction.c