From: Jan Kara <jack@suse.cz>
To: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>,
akpm@osdl.org, LKML <linux-kernel@vger.kernel.org>,
Badari Pulavarty <pbadari@us.ibm.com>,
fedora-ia64-list@redhat.com
Subject: Re: [PATCH] Fix commit of ordered data buffers
Date: Thu, 28 Sep 2006 23:35:58 +0200 [thread overview]
Message-ID: <20060928213558.GC15478@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <1159432266.20092.700.camel@ymzhang-perf.sh.intel.com>
Hello,
> On Tue, 2006-09-12 at 05:05, Jan Kara wrote:
> > Hi Andrew,
> >
> > here is the patch that came out of the thread "set_page_buffer_dirty
> > should skip unmapped buffers". It fixes several flaws in the code
> > writing out ordered data buffers during commit. It definitely fixed the
> > problem Badari was seeing with fsx-linux test. Could you include it
> > into -mm? Since there are quite complex interactions with other JBD code
> > and the locking is kind of ugly, I'd leave it in -mm for a while whether
> > some bug does not emerge ;). Thanks.
> >
> > Honza
> I also worked on it because I didn't know you were working on it until I
> located the root cause and tried to check bugzilla.
>
> I reviewed your patch.
>
> + if (!inverted_lock(journal, bh)) {
> + jbd_lock_bh_state(bh);
> + spin_lock(&journal->j_list_lock);
> + }
> Should journal->j_list_lock be unlocked before jbd_lock_bh_state(bh)?
It does not matter... The ordering of locking matters, ordering of
unlocking does not.
> The fsx-linux test issue is a race between journal_commit_transaction
> and journal_dirty_data. After journal_commit_transaction adds buffer_head pointers
> to wbuf, it might unlock journal->j_list_lock. Although all buffer head in wbuf are locked,
> does that prevent journal_dirty_data from unlinking the buffer head from the transaction
> and fsx-linux from truncating it?
Yes, it does. Because the buffers are locked *and dirty*. Nothing can
clear the dirty bit while we are holding the lock and
journal_dirty_data() also waits until it can safely write out the buffer
- which is after we release the buffer lock.
> I'm not a journal expert. But I want to discuss it.
>
> My investigation is below (Scenario):
>
> fsx-linux starts journal_dirty_data and journal_dirty_data links a jh to
> journal->j_running_transaction's t_sync_datalist, kjournald might not
> write the buffer to disk quickly, but saves it to array wbuf.
> Then, fsx-linux starts the second journal_dirty_data of a new transaction
> might submit the same buffer head and move the jh to the new transaction's
> t_sync_datalist.
Yes, but this happens only after the buffer is removed from wbuf[] as
I explain above.
> Then, fsx-linux truncates the last a couple of buffers of a page.
> Then, block_write_full_page calls invalidatepage to invalidate the last a couple
> of buffers of the page, so the journal_heads of the buffer_head are unlinked and
> are marked as unmapped.
> Then, fsx-linux extend the file and does a msync after changing the page content
> by mmaping the page, so the page (inclduing the last buffer head) is marked dirty
> again.
> Then, kjournald's journal_commit_transaction goes through wbuf to submit_bh all
> dirty buffers, but one buffer head is already marked as unmapped. A bug check is
> triggerred.
>
> >From above scenario, as long as the late calls doesn't try to lock the buffer head,
> the race condition still exists.
>
> I think the right way is to let journal_dirty_data to wait till wbuf is flushed.
This actually happens in my fix too. And my fix has also a bonus of
fixing a few other flaws... Otherwise your patch seems to be right.
Honza
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
next prev parent reply other threads:[~2006-09-28 21:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-11 21:05 Jan Kara
2006-09-11 22:12 ` Andrew Morton
2006-09-28 8:31 ` Zhang, Yanmin
2006-09-28 21:35 ` Jan Kara [this message]
2006-09-29 1:27 ` Zhang, Yanmin
2006-09-29 9:21 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2005-09-13 15:30 Jan Kara
2005-09-14 1:43 ` Andrew Morton
2005-09-14 12:03 ` Jan Kara
2005-09-14 18:30 ` Andrew Morton
2005-09-15 7:23 ` Jan Kara
2005-09-14 13:02 ` Stephen C. Tweedie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060928213558.GC15478@atrey.karlin.mff.cuni.cz \
--to=jack@suse.cz \
--cc=akpm@osdl.org \
--cc=fedora-ia64-list@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbadari@us.ibm.com \
--cc=yanmin_zhang@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®