]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[GFS2] Data corruption fix
authorWendy Cheng <wcheng@redhat.com>
Tue, 18 Sep 2007 13:19:13 +0000 (09:19 -0400)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 10 Oct 2007 07:56:26 +0000 (08:56 +0100)
* GFS2 has been using i_cache array to store its indirect meta blocks.
Its flush routine doesn't correctly clean up all the entries. The
problem would show while multiple nodes do simultaneous writes to the
same file. Upon glock exclusive lock transfer, if the file is a sparse
file with large file size where the indirect meta blocks span multiple
array entries with "zero" entries in between. The flush routine
prematurely stops the flushing that leaves old (stale) entries around.
This leads to several nasty issues, including data corruption.
* Fix gfs2_get_block_noalloc checking to correctly return EIO upon
unmapped buffer.

Signed-off-by: Wendy Cheng <wcheng@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/meta_io.c
fs/gfs2/ops_address.c

index 1d80f2d42122573cfaa966a9915fac285291cfb3..4da423985e4f9178dd752a92fa5c102cd287e66a 100644 (file)
@@ -374,10 +374,10 @@ void gfs2_meta_cache_flush(struct gfs2_inode *ip)
 
        for (x = 0; x < GFS2_MAX_META_HEIGHT; x++) {
                bh_slot = &ip->i_cache[x];
-               if (!*bh_slot)
-                       break;
-               brelse(*bh_slot);
-               *bh_slot = NULL;
+               if (*bh_slot) {
+                       brelse(*bh_slot);
+                       *bh_slot = NULL;
+               }
        }
 
        spin_unlock(&ip->i_spin);
index b7baf183191281705824042706f0553019aeffb5..4002f417dc19f66ec853a4426e5aa8559e3f31e3 100644 (file)
@@ -90,7 +90,7 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
        error = gfs2_block_map(inode, lblock, 0, bh_result);
        if (error)
                return error;
-       if (bh_result->b_blocknr == 0)
+       if (!buffer_mapped(bh_result))
                return -EIO;
        return 0;
 }