Skip to content

Commit

Permalink
[GFS2] Data corruption fix
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Signed-off-by: Steven Whitehouse <[email protected]>
  • Loading branch information
rhn-support-wcheng authored and swhiteho committed Oct 10, 2007
1 parent 16615be commit de986e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions fs/gfs2/meta_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/ops_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit de986e8

Please sign in to comment.