Re: [PATCH] jbd_commit_transaction() races with journal_try_to_drop_buffers() causing DIO failures

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mingming Cao
Date: Thursday, May 1, 2008 - 3:08 pm

On Thu, 2008-05-01 at 08:16 -0700, Badari Pulavarty wrote:

Besides these two, I think there are two more race conditions with
journal_try_to_free_buffers() inside
journal_commit_transaction()->journal_submit_data_buffers()

3) when journal_submit_data_buffers() saw the buffer is dirty but failed
to lock the buffer bh1, journal_submit_data_buffers() released the
j_list_lock and submit other buffers collected from previous check, with
the reference to bh1 still hold. During this time
journal_try_to_free_buffers() could clean up the journal head of bh1 and
remove it from the t_syncdata_list. Then try_to_free_buffers() would
fail because the reference held by journal_submit_data_buffers()

...
		if (buffer_dirty(bh)) {
                       if (test_set_buffer_locked(bh)) {
                                BUFFER_TRACE(bh, "needs blocking lock");
                                spin_unlock(&journal->j_list_lock);
					<-- here release the j_list_lock without put(bh)
                                            journal_try_to_free_buffers() could come in and remove this bh from t_syncdata_list

                                /* Write out all data to prevent deadlocks */
                                journal_do_submit_data(wbuf, bufs);
                                bufs = 0;
                                lock_buffer(bh);
                                spin_lock(&journal->j_list_lock);
                                        <-- here continue the check without validate if the bh still on t_sycdata_list

                        }
                        locked = 1;
                }


4) when journal_commit_transaction() go through the t_locked_list and
wait for the buffer to be unlocked, it still holds the reference to the
buffer, released the j_list_lock and gives the
journal_try_to_free_buffers() a chance to come in remove this buffer
from t_locked_list, but journal_commit_transaction() continues as if the
buffer still on the locked list.

      while (commit_transaction->t_locked_list) {
                struct buffer_head *bh;

                jh = commit_transaction->t_locked_list->b_tprev;
                bh = jh2bh(jh);
                get_bh(bh);
                if (buffer_locked(bh)) {
                        spin_unlock(&journal->j_list_lock);
                        wait_on_buffer(bh);
                        if (unlikely(!buffer_uptodate(bh)))
                                err = -EIO;
                        spin_lock(&journal->j_list_lock);
                }

Mingming

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] JBD ordered mode rewrite, Jan Kara, (Thu Mar 6, 10:42 am)
Re: [RFC] JBD ordered mode rewrite, Josef Bacik, (Thu Mar 6, 12:05 pm)
Re: [RFC] JBD ordered mode rewrite, Andrew Morton, (Thu Mar 6, 4:53 pm)
Re: [RFC] JBD ordered mode rewrite, Mark Fasheh, (Thu Mar 6, 6:34 pm)
Re: [RFC] JBD ordered mode rewrite, Mingming Cao, (Fri Mar 7, 3:55 am)
Re: [RFC] JBD ordered mode rewrite, Andreas Dilger, (Fri Mar 7, 4:52 pm)
Re: [RFC] JBD ordered mode rewrite, Mingming Cao, (Fri Mar 7, 5:08 pm)
Re: [RFC] JBD ordered mode rewrite, Christoph Hellwig, (Sat Mar 8, 5:14 am)
Re: [RFC] JBD ordered mode rewrite, Jan Kara, (Mon Mar 10, 9:30 am)
Re: [RFC] JBD ordered mode rewrite, Jan Kara, (Mon Mar 10, 10:38 am)
Re: [RFC] JBD ordered mode rewrite, Jan Kara, (Mon Mar 10, 11:00 am)
Re: [RFC] JBD ordered mode rewrite, Jan Kara, (Mon Mar 10, 11:29 am)
Re: [RFC] JBD ordered mode rewrite, Jan Kara, (Mon Mar 10, 12:54 pm)
Re: [RFC] JBD ordered mode rewrite, Andreas Dilger, (Mon Mar 10, 2:37 pm)
Possible race between direct IO and JBD?, Mingming Cao, (Fri Apr 25, 4:38 pm)
Re: Possible race between direct IO and JBD?, Andrew Morton, (Sat Apr 26, 3:41 am)
Re: Possible race between direct IO and JBD?, Jan Kara, (Mon Apr 28, 5:26 am)
Re: Possible race between direct IO and JBD?, Badari Pulavarty, (Mon Apr 28, 10:11 am)
Re: Possible race between direct IO and JBD?, Jan Kara, (Mon Apr 28, 11:09 am)
Re: Possible race between direct IO and JBD?, Mingming Cao, (Mon Apr 28, 12:09 pm)
Re: Possible race between direct IO and JBD?, Jan Kara, (Tue Apr 29, 5:43 am)
Re: Possible race between direct IO and JBD?, Mingming Cao, (Tue Apr 29, 10:49 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ..., Mingming Cao, (Thu May 1, 3:08 pm)
Re: [PATCH] Fix DIO EIO error caused by race between jbd_c ..., Badari Pulavarty, (Fri May 16, 10:12 am)
Re: [PATCH] Fix DIO EIO error caused by race between jbd_c ..., Badari Pulavarty, (Fri May 16, 10:17 am)
Re: [PATCH][take 5] JBD2: Fix race between free buffer and ..., Aneesh Kumar K.V, (Thu May 29, 11:24 pm)