]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.27.36/fs-make-sure-data-stored-into-inode-is-properly-seen-before-unlocking-new-inode.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.36 / fs-make-sure-data-stored-into-inode-is-properly-seen-before-unlocking-new-inode.patch
CommitLineData
31953fc7
GKH
1From 580be0837a7a59b207c3d5c661d044d8dd0a6a30 Mon Sep 17 00:00:00 2001
2From: Jan Kara <jack@suse.cz>
3Date: Mon, 21 Sep 2009 17:01:06 -0700
4Subject: fs: make sure data stored into inode is properly seen before unlocking new inode
5
6From: Jan Kara <jack@suse.cz>
7
8commit 580be0837a7a59b207c3d5c661d044d8dd0a6a30 upstream.
9
10In theory it could happen that on one CPU we initialize a new inode but
11clearing of I_NEW | I_LOCK gets reordered before some of the
12initialization. Thus on another CPU we return not fully uptodate inode
13from iget_locked().
14
15This seems to fix a corruption issue on ext3 mounted over NFS.
16
17[akpm@linux-foundation.org: add some commentary]
18Signed-off-by: Jan Kara <jack@suse.cz>
19Cc: Christoph Hellwig <hch@infradead.org>
20Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
21Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
22Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23
24---
25 fs/inode.c | 14 ++++++++------
26 1 file changed, 8 insertions(+), 6 deletions(-)
27
28--- a/fs/inode.c
29+++ b/fs/inode.c
30@@ -590,13 +590,15 @@ void unlock_new_inode(struct inode *inod
31 }
32 #endif
33 /*
34- * This is special! We do not need the spinlock
35- * when clearing I_LOCK, because we're guaranteed
36- * that nobody else tries to do anything about the
37- * state of the inode when it is locked, as we
38- * just created it (so there can be no old holders
39- * that haven't tested I_LOCK).
40+ * This is special! We do not need the spinlock when clearing I_LOCK,
41+ * because we're guaranteed that nobody else tries to do anything about
42+ * the state of the inode when it is locked, as we just created it (so
43+ * there can be no old holders that haven't tested I_LOCK).
44+ * However we must emit the memory barrier so that other CPUs reliably
45+ * see the clearing of I_LOCK after the other inode initialisation has
46+ * completed.
47 */
48+ smp_mb();
49 WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW));
50 inode->i_state &= ~(I_LOCK|I_NEW);
51 wake_up_inode(inode);