summaryrefslogtreecommitdiffstats
path: root/fs/ubifs/gc.c
diff options
context:
space:
mode:
authorAdrian Hunter2008-08-22 13:23:35 +0200
committerArtem Bityutskiy2008-08-25 13:34:02 +0200
commit601c0bc46753007be011b513ba4fc50ed8e30aef (patch)
tree39017065a8418b60362686a7771afe138e100c08 /fs/ubifs/gc.c
parentUBIFS: always read hashed-key nodes under TNC mutex (diff)
downloadkernel-qcow2-linux-601c0bc46753007be011b513ba4fc50ed8e30aef.tar.gz
kernel-qcow2-linux-601c0bc46753007be011b513ba4fc50ed8e30aef.tar.xz
kernel-qcow2-linux-601c0bc46753007be011b513ba4fc50ed8e30aef.zip
UBIFS: allow for racing between GC and TNC
The TNC mutex is unlocked prematurely when reading leaf nodes with non-hashed keys. This is unsafe because the node may be moved by garbage collection and the eraseblock unmapped, although that has never actually happened during stress testing. This patch fixes the flaw by detecting the race and retrying with the TNC mutex locked. Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Diffstat (limited to 'fs/ubifs/gc.c')
-rw-r--r--fs/ubifs/gc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index d0f3dac29081..13f1019c859f 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -344,6 +344,12 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp)
if (err)
goto out;
+ /* Allow for races with TNC */
+ c->gced_lnum = lnum;
+ smp_wmb();
+ c->gc_seq += 1;
+ smp_wmb();
+
if (c->gc_lnum == -1) {
c->gc_lnum = lnum;
err = LEB_RETAINED;