aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-09-21 20:01:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:24 -0400
commit580be0837a7a59b207c3d5c661d044d8dd0a6a30 (patch)
tree4a659c92ed738367c1ed4d9b1b50fe018f401b81 /fs/inode.c
parent5be461657be65460ad92be3527e3bb1dd11c49ea (diff)
fs: make sure data stored into inode is properly seen before unlocking new inode
In theory it could happen that on one CPU we initialize a new inode but clearing of I_NEW | I_LOCK gets reordered before some of the initialization. Thus on another CPU we return not fully uptodate inode from iget_locked(). This seems to fix a corruption issue on ext3 mounted over NFS. [akpm@linux-foundation.org: add some commentary] Signed-off-by: Jan Kara <jack@suse.cz> Cc: Christoph Hellwig <hch@infradead.org> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/inode.c b/fs/inode.c
index b2ba83d2c4e1..798052f87035 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -695,13 +695,15 @@ void unlock_new_inode(struct inode *inode)
695 } 695 }
696#endif 696#endif
697 /* 697 /*
698 * This is special! We do not need the spinlock 698 * This is special! We do not need the spinlock when clearing I_LOCK,
699 * when clearing I_LOCK, because we're guaranteed 699 * because we're guaranteed that nobody else tries to do anything about
700 * that nobody else tries to do anything about the 700 * the state of the inode when it is locked, as we just created it (so
701 * state of the inode when it is locked, as we 701 * there can be no old holders that haven't tested I_LOCK).
702 * just created it (so there can be no old holders 702 * However we must emit the memory barrier so that other CPUs reliably
703 * that haven't tested I_LOCK). 703 * see the clearing of I_LOCK after the other inode initialisation has
704 * completed.
704 */ 705 */
706 smp_mb();
705 WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW)); 707 WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW));
706 inode->i_state &= ~(I_LOCK|I_NEW); 708 inode->i_state &= ~(I_LOCK|I_NEW);
707 wake_up_inode(inode); 709 wake_up_inode(inode);