login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
May
»
16
Re: [PATCH] Fix DIO EIO error caused by race between jbd_commit_transaction() and journal_try_to_drop_buffers()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Badari Pulavarty
Subject:
Re: [PATCH] Fix DIO EIO error caused by race between jbd_commit_transaction() and journal_try_to_drop_buffers()
Date: Friday, May 16, 2008 - 10:17 am
On Fri, 2008-05-16 at 10:11 -0700, Mingming Cao wrote:
quoted text
> On Fri, 2008-05-16 at 11:01 -0400, Josef Bacik wrote: > > > > > Got a couple of whitespace problems above it looks like. Thanks, > > > > Thanks for catching this, below is updated patch, fixed the whitespace > and comments. > > > --------------------------------------------------- > JBD: fix journal_try_to_free_buffers race with > journal_commit_transaction > > From: Mingming Cao <cmm@us.ibm.com> > > This patch fixed a few races between direct IO and kjournld commit > transaction. > An unexpected EIO error gets returned to direct IO caller when it failed > to > free those data buffers. This could be reproduced easily with parallel > direct write and buffered write to the same file > > More specificly, those races could cause journal_try_to_free_buffers() > fail to free the data buffers, when jbd is committing the transaction > that has > those data buffers on its t_syncdata_list or t_locked_list. > journal_commit_transaction() still holds the reference to those buffers > before data reach to disk and buffers are removed from the > t_syncdata_list of t_locked_list. This prevent the concurrent > journal_try_to_free_buffers() to free those buffers at the same time, > but cause > EIO error returns back to direct IO. > > With this patch, in case of direct IO and when try_to_free_buffers() > failed, > let's waiting for journal_commit_transaction() to finish > flushing the current committing transaction's data buffers to disk, > then try to free those buffers again. > > Signed-off-by: Mingming Cao <cmm@us.ibm.com> > Reviewed-by: Badari Pulavarty <pbadari@us.ibm.com> > --- > fs/jbd/commit.c | 1 + > fs/jbd/journal.c | 1 + > fs/jbd/transaction.c | 46 > ++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/jbd.h | 3 +++ > 4 files changed, 51 insertions(+) > > Index: linux-2.6.26-rc1/include/linux/jbd.h > =================================================================== > --- linux-2.6.26-rc1.orig/include/linux/jbd.h 2008-05-14 > 16:36:41.000000000 -0700 > +++ linux-2.6.26-rc1/include/linux/jbd.h 2008-05-15 14:12:10.000000000 > -0700 > @@ -667,6 +667,9 @@ struct journal_s > */ > wait_queue_head_t j_wait_transaction_locked; > > + /* Wait queu for waiting for data buffers to flushed to disk*/ > + wait_queue_head_t j_wait_data_flushed; > + > /* Wait queue for waiting for checkpointing to complete */ > wait_queue_head_t j_wait_logspace; > > Index: linux-2.6.26-rc1/fs/jbd/commit.c > =================================================================== > --- linux-2.6.26-rc1.orig/fs/jbd/commit.c 2008-05-03 11:59:44.000000000 > -0700 > +++ linux-2.6.26-rc1/fs/jbd/commit.c 2008-05-15 14:12:46.000000000 -0700 > @@ -462,6 +462,7 @@ void journal_commit_transaction(journal_ > * clean by now, so check that it is in fact empty. > */ > J_ASSERT (commit_transaction->t_sync_datalist == NULL); > + wake_up(&journal->j_wait_data_flushed) > > jbd_debug (3, "JBD: commit phase 3\n"); > > Index: linux-2.6.26-rc1/fs/jbd/journal.c > =================================================================== > --- linux-2.6.26-rc1.orig/fs/jbd/journal.c 2008-05-14 16:36:41.000000000 > -0700 > +++ linux-2.6.26-rc1/fs/jbd/journal.c 2008-05-15 14:13:02.000000000 > -0700 > @@ -660,6 +660,7 @@ static journal_t * journal_init_common ( > goto fail; > > init_waitqueue_head(&journal->j_wait_transaction_locked); > + init_waitqueue_head(&journal->j_wait_data_flushed); > init_waitqueue_head(&journal->j_wait_logspace); > init_waitqueue_head(&journal->j_wait_done_commit); > init_waitqueue_head(&journal->j_wait_checkpoint); > Index: linux-2.6.26-rc1/fs/jbd/transaction.c > =================================================================== > --- linux-2.6.26-rc1.orig/fs/jbd/transaction.c 2008-05-03 > 11:59:44.000000000 -0700 > +++ linux-2.6.26-rc1/fs/jbd/transaction.c 2008-05-16 09:27:21.000000000 > -0700 > @@ -1648,12 +1648,49 @@ out: > return; > } > > +/* > + * journal_try_to_free_buffers() could race with > journal_commit_transaction() > + * The later might still hold the reference count to the buffers when > inspecting > + * them on t_syncdata_list or t_locked_list. > + * > + * Journal_try_to_free_buffers() will call this function to > + * wait for the current transaction finishing syncing data buffers, > before > + * try to free that buffer. > + * > + * Called with journal->j_state_lock hold.
Fix wrapping lines ?
quoted text
> + */ > +static void journal_wait_for_transaction_sync_data(journal_t *journal) > +{ > + transaction_t *transaction = NULL; > + > + transaction = journal->j_committing_transaction; > + > + if (!transaction) > + return; > + > + /* > + * If the current transaction is flushing and waiting for data buffers > + * (t_state is T_FLUSH), wait for the j_wait_data_flushed event > + */ > + if (transaction->t_state == T_FLUSH) { > + DEFINE_WAIT(wait); > + > + prepare_to_wait(&journal->j_wait_data_flushed, > + &wait, TASK_UNINTERRUPTIBLE); > + spin_unlock(&journal->j_state_lock); > + schedule(); > + finish_wait(&journal->j_wait_data_flushed, &wait); > + spin_lock(&journal->j_state_lock); > + } > + return; > +} > > /** > * int journal_try_to_free_buffers() - try to free page buffers. > * @journal: journal for operation > * @page: to try and free > - * @unused_gfp_mask: unused > + * @gfp_mask: unused for allocation purpose. Here is used > + * as a flag to tell if direct IO is attemping to free buffers. > * > * > * For all the buffers on this page, > @@ -1682,13 +1719,16 @@ out: > * journal_try_to_free_buffer() is changing its state. But that > * cannot happen because we never reallocate freed data as metadata > * while the data is part of a transaction. Yes? > + * > + * Return 0 on failure, 1 on success > */ > int journal_try_to_free_buffers(journal_t *journal, > - struct page *page, gfp_t unused_gfp_mask) > + struct page *page, gfp_t gfp_mask) > { > struct buffer_head *head; > struct buffer_head *bh; > int ret = 0; > + int dio = gfp_mask & __GFP_REPEAT; > > J_ASSERT(PageLocked(page)); > > @@ -1713,7 +1753,31 @@ int journal_try_to_free_buffers(journal_ > if (buffer_jbd(bh)) > goto busy; > } while ((bh = bh->b_this_page) != head); > + > ret = try_to_free_buffers(page); > + > + /* > + * In the case of concurrent direct IO and buffered IO, > + * There are a number of places where we > + * could race with journal_commit_transaction(), the later still > + * helds the reference to the buffers to free while processing them. > + * try_to_free_buffers() failed to free those buffers, > + * resulting in an unexpected EIO error > + * returns back to the generic_file_direct_IO() > + * > + * So let's wait for the current transaction finished flush > + * dirty data buffers before we try to free those buffers > + * again. This wait is needed by direct IO code path only, > + * gfp_mask __GFP_REPEAT is passed from the direct IO code > + * path to flag if we need to wait and retry free buffers. > + */ > + if (ret == 0 && dio) {
drop "dio" variable and compare here, like if (ret == 0 && (gfp_mask & __GFP_REPEAT)
quoted text
> + spin_lock(&journal->j_state_lock); > + journal_wait_for_transaction_sync_data(journal); > + ret = try_to_free_buffers(page); > + spin_unlock(&journal->j_state_lock); > + }
Thanks, Badari --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
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)
[PATCH] jbd_commit_transaction() races with journal_try_to ...
, Badari Pulavarty
, (Thu May 1, 8:16 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Thu May 1, 3:08 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Mon May 5, 10:06 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Mon May 5, 10:53 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Badari Pulavarty
, (Mon May 5, 5:10 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Fri May 9, 3:27 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Mon May 12, 8:54 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Mon May 12, 12:23 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Mon May 12, 5:39 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Tue May 13, 7:20 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Tue May 13, 7:54 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Tue May 13, 9:37 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Tue May 13, 3:23 pm)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Wed May 14, 10:08 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Wed May 14, 10:41 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Jan Kara
, (Wed May 14, 11:14 am)
Re: [PATCH] jbd_commit_transaction() races with journal_tr ...
, Mingming Cao
, (Fri May 16, 7:13 am)
[PATCH] Fix DIO EIO error caused by race between jbd_commi ...
, Mingming Cao
, (Fri May 16, 7:14 am)
Re: [PATCH] Fix DIO EIO error caused by race between jbd_c ...
, Josef Bacik
, (Fri May 16, 8:01 am)
Re: [PATCH] Fix DIO EIO error caused by race between jbd_c ...
, Mingming Cao
, (Fri May 16, 10:11 am)
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] Fix DIO EIO error caused by race between jbd_c ...
, Mingming Cao
, (Fri May 16, 10:30 am)
[PATCH] JBD: Fix DIO EIO error caused by race between free ...
, Mingming Cao
, (Fri May 16, 2:01 pm)
[PATCH] JBD2: Fix DIO EIO error caused by race between fre ...
, Mingming Cao
, (Fri May 16, 2:01 pm)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Jan Kara
, (Sun May 18, 3:37 pm)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Mingming Cao
, (Mon May 19, 12:59 pm)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Andrew Morton
, (Mon May 19, 1:25 pm)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Mingming Cao
, (Mon May 19, 3:07 pm)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Jens Axboe
, (Tue May 20, 2:30 am)
Re: [PATCH] JBD: Fix DIO EIO error caused by race between ...
, Mingming Cao
, (Tue May 20, 10:47 am)
[PATCH-v2] JBD: Fix race between free buffer and commit tr ...
, Mingming Cao
, (Tue May 20, 11:02 am)
[PATCH -v2] JBD2: Fix race between journal free buffer and ...
, Mingming Cao
, (Tue May 20, 11:03 am)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Jan Kara
, (Tue May 20, 4:53 pm)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Mingming
, (Wed May 21, 10:14 am)
[PATCH 1/2][TAKE3] JBD: Fix race between free buffer and c ...
, Mingming
, (Wed May 21, 4:38 pm)
[PATCH 2/2][TAKE3] JBD2: Fix race between free buffer and ...
, Mingming
, (Wed May 21, 4:39 pm)
Re: [PATCH 1/2][TAKE3] JBD: Fix race between free buffer a ...
, Andrew Morton
, (Wed May 21, 10:57 pm)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Jan Kara
, (Sat May 24, 3:44 pm)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Mingming Cao
, (Wed May 28, 11:18 am)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Jan Kara
, (Wed May 28, 11:55 am)
Re: [PATCH-v2] JBD: Fix race between free buffer and commi ...
, Mingming Cao
, (Wed May 28, 5:15 pm)
[PATCH][take 5] JBD: Fix race between free buffer and comm ...
, Mingming Cao
, (Wed May 28, 5:16 pm)
[PATCH][take 5] JBD2: Fix race between free buffer and com ...
, Mingming Cao
, (Wed May 28, 5:18 pm)
Re: [PATCH][take 5] JBD2: Fix race between free buffer and ...
, Aneesh Kumar K.V
, (Thu May 29, 11:24 pm)
Re: [PATCH][take 5] JBD2: Fix race between free buffer and ...
, Mingming Cao
, (Fri May 30, 8:17 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg Kroah-Hartman
[PATCH 041/196] kobject: add kobject_init_and_add function
Lukas Hejtmanek
Re: Another libata error related to OCZ SSD
Greg Kroah-Hartman
[PATCH 023/196] MCP_UCB1200: Convert from class_device to device
Florian Fainelli
Re: System clock runs too fast after 2.6.27 -> 2.6.28.1 upgrade
Christoph Lameter
[patch 1/4] mmu_notifier: Core code
git
:
Johannes Schindelin
Re: [PATCH 1/2] Add strbuf_initf()
John Bito
[EGIT] Push to GitHub caused corruption
Jakub Narebski
Re: [PATCH 0/2] gitweb: patch view
Junio C Hamano
Re: [PATCH] When a remote is added but not fetched, tell the user.
Andy Parkins
Re: [RFC] Submodules in GIT
git-commits-head
:
Linux Kernel Mailing List
ahci: Workaround HW bug for SB600/700 SATA controller PMP support
Linux Kernel Mailing List
V4L/DVB (11086): au0828: rename macro for currently non-function VBI support
Linux Kernel Mailing List
ceph: client types
Linux Kernel Mailing List
ceph: on-wire types
Linux Kernel Mailing List
crypto: chainiv - Use kcrypto_wq instead of keventd_wq
linux-netdev
:
Andrew Morton
Re: [Bugme-new] [Bug 14969] New: b44: WOL does not work in suspended state
Giuseppe CAVALLARO
Re: [PATCH 03/13] stmmac: add the new Header file for stmmac platform data
Taku Izumi
[PATCH 3/3] ixgbe: add registers etc. printout code just before resetting adapters
Eric Dumazet
rps: some comments
Thomas Gleixner
Re: [RFC PATCH 02/12] On Tue, 23 Sep 2008, David Miller wrote:
openbsd-misc
:
Stephan Andreas
problems with login after xlock in OpenBSD release 4.7
pmc
Make A Change. Alcoholism and Drug Addiction Treatment
ropers
Re: what exactly is enc0?
Fuad NAHDI
Re: What does your environment look like?
Matthew Szudzik
Typo on OpenBSD 4.4 CD Set
Colocation donated by:
Syndicate