[PATCH] Fix list scanning in __cleanup_transaction

From: Jan Kara
Date: Wed Jun 01 2005 - 02:53:42 EST


Hello,

attached patch fixes a bug in list scanning that can cause we skip the
last buffer on the checkpoint list (and hence fail to do any progress
under some rather unfavorable conditions). The problem is we first do
jh=next_jh and then test } while (jh!=last_jh); . Hence we skip the last
buffer on the list (if it was not the only buffer on the list). As we
already do jh=next_jh; in the beginning of the loop we are safe to just
remove the assignment in the end. It can happen that 'jh' will be freed
at the point we test jh != last_jh but that does not matter as we never
*dereference* the pointer. Please apply.

Honza

--
Jan Kara <jack@xxxxxxx>
SuSE CR Labs
We already move to the next member of the list in the beginning of the loop.
When we move in the end of the loop we can unintentionally forget to scan
the last buffer of the list.

Signed-off-by: Jan Kara <jack@xxxxxxx>

diff -rupX /home/jack/.kerndiffexclude linux-2.6.12-rc5-1-checkretry/fs/jbd/checkpoint.c linux-2.6.12-rc5-2-checkskip/fs/jbd/checkpoint.c
--- linux-2.6.12-rc5-1-checkretry/fs/jbd/checkpoint.c 2005-05-27 11:15:31.000000000 +0200
+++ linux-2.6.12-rc5-2-checkskip/fs/jbd/checkpoint.c 2005-05-27 11:18:08.000000000 +0200
@@ -188,7 +188,6 @@ static int __cleanup_transaction(journal
} else {
jbd_unlock_bh_state(bh);
}
- jh = next_jh;
} while (jh != last_jh);

return ret;