[patch 1/8] fs: mark_inode_dirty barrier fix

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nick Piggin
Date: Friday, December 17, 2010 - 6:46 pm

Filesystems appear to be using ->dirty_inode, expecting that the dirtying
operating is done and visible to all CPUs (eg. setting private inode dirty
bits, without any barriers themselves). So release the dirty "critical
section" with a barrier before calling ->dirty_inode.

Cost is not significantly changed, because we're just moving the barrier.
Those filesystems that do use ->dirty_inode should have to care slightly
less about barriers, which is a good thing.

Signed-off-by: Nick Piggin <npiggin@kernel.dk>

Index: linux-2.6/fs/fs-writeback.c
===================================================================
--- linux-2.6.orig/fs/fs-writeback.c	2010-11-19 16:47:00.000000000 +1100
+++ linux-2.6/fs/fs-writeback.c	2010-11-19 16:49:39.000000000 +1100
@@ -934,6 +934,15 @@ void __mark_inode_dirty(struct inode *in
 	bool wakeup_bdi = false;
 
 	/*
+	 * Make sure that changes are seen by all cpus before we test i_state
+	 * or mark anything as being dirty. Ie. all dirty state should be
+	 * written to the inode and visible. Like an "unlock" operation, the
+	 * mark_inode_dirty call must "release" our ordering window that is
+	 * opened when we started modifying the inode.
+	 */
+	smp_mb();
+
+	/*
 	 * Don't do this for I_DIRTY_PAGES - that doesn't actually
 	 * dirty the inode itself
 	 */
@@ -942,12 +951,6 @@ void __mark_inode_dirty(struct inode *in
 			sb->s_op->dirty_inode(inode);
 	}
 
-	/*
-	 * make sure that changes are seen by all cpus before we test i_state
-	 * -- mikulas
-	 */
-	smp_mb();
-
 	/* avoid the locking if we can */
 	if ((inode->i_state & flags) == flags)
 		return;


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

Messages in current thread:
[patch 0/8] Inode data integrity patches, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 1/8] fs: mark_inode_dirty barrier fix, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 2/8] fs: simple fsync race fix, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 3/8] fs: introduce inode writeback helpers, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 5/8] fs: ext2 inode sync fix, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 6/8] fs: fsync optimisations, Nick Piggin, (Fri Dec 17, 6:46 pm)
[patch 8/8] fs: add i_op-&gt;sync_inode, Nick Piggin, (Fri Dec 17, 6:46 pm)
Re: [patch 7/8] fs: fix or note I_DIRTY handling bugs in f ..., Christoph Hellwig, (Wed Dec 29, 8:01 am)
Re: [patch 8/8] fs: add i_op-&gt;sync_inode, Christoph Hellwig, (Wed Dec 29, 8:12 am)
Re: [patch 8/8] fs: add i_op-&gt;sync_inode, Nick Piggin, (Mon Jan 3, 11:27 pm)
Re: [patch 8/8] fs: add i_op-&gt;sync_inode, Christoph Hellwig, (Mon Jan 3, 11:57 pm)
Re: [patch 8/8] fs: add i_op-&gt;sync_inode, Nick Piggin, (Tue Jan 4, 1:03 am)
Re: [patch 8/8] fs: add i_op-&gt;sync_inode, Nick Piggin, (Tue Jan 4, 2:49 am)