mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>,
	"ext2-devel@lists.sourceforge.net"
	<ext2-devel@lists.sourceforge.net>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] ext3/jbd race: releasing in-use journal_heads
Date: Tue, 8 Mar 2005 16:12:58 +0100	[thread overview]
Message-ID: <20050308151258.GD23403@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <1110286417.1941.40.camel@sisko.sctweedie.blueyonder.co.uk>

  Hello,

> On Mon, 2005-03-07 at 21:08, Stephen C. Tweedie wrote:
> 
> > Right, that was what I was thinking might be possible.  But for now I've
> > just done the simple patch --- make sure we don't clear
> > jh->b_transaction when we're just refiling buffers from one list to
> > another.  That should have the desired effect here without dangerous
> > messing around with locks.
> 
  <snip>

> Fix destruction of in-use journal_head
> 
> journal_put_journal_head() can destroy a journal_head at any time as
> long as the jh's b_jcount is zero and b_transaction is NULL.  It has no
> locking protection against the rest of the journaling code, as the lock
> it uses to protect b_jcount and bh->b_private is not used elsewhere in
> jbd.
> 
> However, there are small windows where b_transaction is getting set
> temporarily to NULL during normal operations; typically this is
> happening in 
> 
> 			__journal_unfile_buffer(jh);
>  			__journal_file_buffer(jh, ...);
> 
> call pairs, as __journal_unfile_buffer() will set b_transaction to NULL
> and __journal_file_buffer() re-sets it afterwards.  A truncate running
> in parallel can lead to journal_unmap_buffer() destroying the jh if it
> occurs between these two calls.
  Isn't also the following scenario dangerous?

  __journal_unfile_buffer(jh);
  journal_remove_journal_head(bh);

  If journal_unmap_buffer() decides to destroy the buffer before we call
journal_remove_journal_head(), we get an assertion failure in
__journal_remove_journal_head()...
  I believe the right fix really is that anyone having a pointer to
bh/jh should hold a reference counted in b_jcount - so basically the
idea Andrew proposed. 
  It could work like follows: When you first create jh you get a
reference in b_jcount (that is already happening). If you file a jh in
some transaction list, you will 'delegate' this reference to the
transaction and hence you won't do journal_put_journal_head() after
you're done. Now if you unfile a buffer from the list you 'get back' it's
reference (and you have to journal_put_journal_head() if you're not
going to file the buffer back again). The only thing you have to assure is
the proper list locking so that two different callers cannot 'get back' one
reference but that should be already done...
  This solution should be doable without additional locking or big code
changes but maybe the reference policy is a bit too complicated...

> Fix this by adding a variant of __journal_unfile_buffer() which is only
> used for these temporary jh unlinks, and which leaves the b_transaction
> field intact so that we never leave a window open where b_transaction is
> NULL.
> 
> Additionally, trap this error if it does occur, by checking against
> jh->b_jlist being non-null when we destroy a jh.

								Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

  reply	other threads:[~2005-03-08 15:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-04 19:54 Stephen C. Tweedie
2005-03-04 23:17 ` [Ext2-devel] " Badari Pulavarty
2005-03-07 14:28   ` Stephen C. Tweedie
2005-03-05  0:04 ` Andrew Morton
2005-03-07 14:50   ` Jan Kara
2005-03-07 16:01     ` Stephen C. Tweedie
2005-03-07 16:40   ` Stephen C. Tweedie
2005-03-07 17:05     ` Stephen C. Tweedie
2005-03-07 20:31     ` Andrew Morton
2005-03-07 21:08       ` Stephen C. Tweedie
2005-03-07 21:11         ` Andrew Morton
2005-03-07 21:22           ` Stephen C. Tweedie
2005-03-07 23:13             ` Stephen C. Tweedie
2005-03-07 23:50               ` Andrew Morton
2005-03-08  6:28                 ` [Ext2-devel] " Suparna Bhattacharya
2005-03-08  6:39                   ` Suparna Bhattacharya
2005-03-08  6:46                   ` Andrew Morton
2005-03-08  7:26                     ` Suparna Bhattacharya
2005-03-08  7:37                       ` Andrew Morton
2005-03-08  8:15                         ` Suparna Bhattacharya
2005-03-08  9:28                 ` Stephen C. Tweedie
2005-03-08 12:40                   ` [PATCH] invalidate/o_direct livelock {was Re: [RFC] ext3/jbd race: releasing in-use journal_heads} Stephen C. Tweedie
2005-03-08 12:53         ` [RFC] ext3/jbd race: releasing in-use journal_heads Stephen C. Tweedie
2005-03-08 15:12           ` Jan Kara [this message]
2005-03-09 13:10             ` Stephen C. Tweedie
2005-03-09 13:28               ` Jan Kara
2005-03-09 15:12                 ` 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=20050308151258.GD23403@atrey.karlin.mff.cuni.cz \
    --to=jack@suse.cz \
    --cc=akpm@osdl.org \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sct@redhat.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®