Jan Kara bb189247f3 jbd: Fix oops in journal_remove_journal_head()
journal_remove_journal_head() can oops when trying to access journal_head
returned by bh2jh(). This is caused for example by the following race:

	TASK1					TASK2
  journal_commit_transaction()
    ...
    processing t_forget list
      __journal_refile_buffer(jh);
      if (!jh->b_transaction) {
        jbd_unlock_bh_state(bh);
					journal_try_to_free_buffers()
					  journal_grab_journal_head(bh)
					  jbd_lock_bh_state(bh)
					  __journal_try_to_free_buffer()
					  journal_put_journal_head(jh)
        journal_remove_journal_head(bh);

journal_put_journal_head() in TASK2 sees that b_jcount == 0 and buffer is not
part of any transaction and thus frees journal_head before TASK1 gets to doing
so. Note that even buffer_head can be released by try_to_free_buffers() after
journal_put_journal_head() which adds even larger opportunity for oops (but I
didn't see this happen in reality).

Fix the problem by making transactions hold their own journal_head reference
(in b_jcount). That way we don't have to remove journal_head explicitely via
journal_remove_journal_head() and instead just remove journal_head when
b_jcount drops to zero. The result of this is that [__]journal_refile_buffer(),
[__]journal_unfile_buffer(), and __journal_remove_checkpoint() can free
journal_head which needs modification of a few callers. Also we have to be
careful because once journal_head is removed, buffer_head might be freed as
well. So we have to get our own buffer_head reference where it matters.

Signed-off-by: Jan Kara <jack@suse.cz>
2011-06-27 11:44:37 +02:00
..
2011-03-31 11:26:23 -03:00
2011-05-04 14:08:36 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-06-01 11:36:49 +01:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-02-24 19:58:42 +01:00
2010-10-15 21:18:59 +02:00
2011-04-01 02:24:31 -04:00
2010-11-23 20:14:46 +00:00
2011-01-31 14:03:00 -08:00
2011-05-28 17:41:46 +02:00
2011-01-15 20:07:45 -05:00
2011-03-10 08:52:07 +01:00
2011-03-22 17:43:59 -07:00
2011-03-11 14:25:50 +00:00
2011-05-31 13:45:53 +02:00
2011-03-31 11:26:23 -03:00
2010-12-16 17:53:38 +01:00
2011-03-31 11:26:23 -03:00
2011-05-26 17:12:34 -07:00
2011-05-26 17:12:34 -07:00
2011-03-31 11:26:23 -03:00
2010-10-25 08:02:40 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-22 17:44:15 -07:00
2011-05-19 15:59:38 -07:00
2011-01-10 08:51:44 -08:00
2010-08-04 11:00:45 +02:00
2011-05-23 10:47:06 -05:00
2011-05-29 13:03:09 +01:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-10 11:35:17 +01:00
2011-05-24 10:21:29 +02:00
2011-05-24 10:21:29 +02:00
2010-10-21 14:47:59 +02:00
2011-06-09 15:05:48 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-06-25 17:29:52 +02:00
2011-01-12 20:16:43 -05:00
2011-03-14 19:12:20 -04:00
2010-08-19 17:18:03 -07:00
2011-03-31 11:26:23 -03:00
2011-01-10 08:51:44 -08:00
2011-01-07 17:50:27 +11:00
2011-03-31 11:26:23 -03:00
2011-01-07 17:50:23 +11:00
2010-12-07 20:16:56 +01:00
2010-10-25 14:11:37 -07:00
2011-03-05 10:56:00 +01:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-05-23 13:59:54 +02:00
2010-10-12 16:53:37 +02:00
2011-05-26 12:03:50 -07:00
2011-02-23 00:53:26 +00:00
2011-05-25 20:43:32 +02:00
2011-03-31 11:26:23 -03:00
2011-05-08 16:41:45 -07:00
2010-11-16 10:58:30 -08:00
2010-09-21 18:04:47 -07:00
2011-02-27 16:11:51 -08:00
2010-08-19 17:16:23 -07:00
2010-10-26 16:52:08 -07:00
2010-08-09 20:45:05 -07:00
2011-05-26 17:12:37 -07:00
2011-03-31 11:26:23 -03:00
2010-11-24 11:16:42 -08:00
2010-10-07 14:08:55 +01:00
2011-03-31 11:26:23 -03:00
2010-08-10 11:49:21 -07:00
2010-12-09 20:17:07 -08:00
2011-03-31 11:26:23 -03:00
2010-08-12 11:27:58 +02:00
2011-02-17 11:12:40 -08:00
2010-10-22 15:34:12 -05:00
2011-01-13 17:32:31 -08:00
2011-01-13 17:32:47 -08:00
2011-02-13 16:54:24 -08:00
2011-01-24 14:45:11 +10:30
2010-09-09 18:57:24 -07:00
2011-03-31 11:26:23 -03:00
2011-05-22 08:47:53 -04:00
2011-03-31 11:26:23 -03:00
2011-05-19 20:50:53 -04:00
2011-05-24 14:33:35 +02:00
2011-04-25 18:14:10 -07:00
2010-12-06 11:03:46 -08:00
2011-05-29 11:32:28 -07:00
2011-05-26 17:12:36 -07:00
2011-05-19 16:55:27 +09:30
2011-01-16 13:47:07 -05:00
2011-03-31 11:26:23 -03:00
2010-10-12 16:53:34 +02:00
2011-05-20 11:46:11 -07:00
2011-03-23 15:29:04 -04:00
2011-05-26 17:12:34 -07:00
2011-04-20 17:01:19 +10:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-01-16 13:47:07 -05:00
2010-10-24 15:07:11 -07:00
2011-05-26 17:12:37 -07:00
2010-08-21 23:40:14 -07:00
2011-03-11 15:13:26 -05:00
2011-03-31 11:26:23 -03:00
2011-05-24 12:10:51 +02:00
2010-08-04 21:53:17 -07:00
2011-01-13 08:03:21 -08:00
2011-03-31 11:26:23 -03:00
2011-05-13 16:31:00 -07:00
2011-03-31 11:26:23 -03:00
2010-10-29 04:16:31 -04:00
2011-01-14 02:36:43 +00:00
2011-05-05 23:16:59 -07:00
2010-09-08 18:16:55 -07:00
2010-08-09 16:47:27 -04:00
2011-03-31 11:26:23 -03:00
2010-11-15 13:24:06 -05:00
2011-05-25 08:39:19 -07:00
2010-10-30 12:12:50 +02:00
2011-03-31 11:26:23 -03:00
2011-05-05 11:10:14 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-08-09 16:48:44 -04:00
2011-03-31 11:26:23 -03:00
2011-06-15 20:03:59 -07:00
2010-08-30 13:23:33 -07:00
2011-02-28 18:00:31 -08:00
2011-02-02 15:28:18 +01:00
2011-06-15 20:03:59 -07:00
2010-11-29 08:55:25 +11:00
2010-11-29 08:55:22 +11:00
2011-03-31 11:26:23 -03:00
2010-12-20 09:37:33 +01:00
2011-06-07 09:05:42 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-05-30 11:14:16 +09:30
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-01-13 08:03:24 -08:00