linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] jbd2: Fix a race between checkpointing code and journal_get_write_access()
Date: Sun, 5 Jul 2009 22:53:19 -0400	[thread overview]
Message-ID: <20090706025319.GG6706@mit.edu> (raw)
In-Reply-To: <1245859360-5261-2-git-send-email-jack@suse.cz>

On Wed, Jun 24, 2009 at 06:02:40PM +0200, Jan Kara wrote:
> The following race can happen:
> 
>   CPU1                          CPU2
>                                 checkpointing code checks the buffer, adds
>                                   it to an array for writeback
> do_get_write_access()
>   ...
>   lock_buffer()
>   unlock_buffer()
>                                   flush_batch() submits the buffer for IO
>   __jbd2_journal_file_buffer()
> 
>   So a buffer under writeout is returned from do_get_write_access(). Since
> the filesystem code relies on the fact that journaled buffers cannot be
> written out, it does not take the buffer lock and so it can modify buffer
> while it is under writeout. That can lead to a filesystem corruption
> if we crash at the right moment.
>   We fix the problem by clearing the buffer dirty bit under buffer_lock
> even if the buffer is on BJ_None list. Actually, we clear the dirty bit
> regardless the list the buffer is in and warn about the fact if
> the buffer is already journalled.
> 
> Thanks for spotting the problem goes to dingdinghua <dingdinghua85@gmail.com>.
> 
> Reported-by: dingdinghua <dingdinghua85@gmail.com>
> Signed-off-by: Jan Kara <jack@suse.cz>

Thanks, applied to the ext4 patch queue.

						- Ted

  reply	other threads:[~2009-07-06  2:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-24 16:02 [PATCH] jbd: Fix a race between checkpointing code and journal_get_write_access() Jan Kara
2009-06-24 16:02 ` [PATCH] jbd2: " Jan Kara
2009-07-06  2:53   ` Theodore Tso [this message]
2009-07-08 22:31     ` Theodore Tso
2009-07-10 10:07       ` Jan Kara
2009-07-13 13:19         ` Theodore Tso
2009-07-13 13:29           ` Jan Kara
2009-07-13 14:44             ` Theodore Tso
2009-07-13 15:29               ` Jan Kara

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=20090706025319.GG6706@mit.edu \
    --to=tytso@mit.edu \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).