[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [GFS2 PATCH] data corruption fix



* 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. * Simplify gfs2 code path by disabling gfs2_writepages. The implementation currently generates unmapped dirty buffers with mmap calls that do not work well with rest of the gfs2 journaling code. Defer the writepages implementation to later time frame. All writepage function now goes thru gfs2_writepage call with this change.

-- Wendy


* Fix i_cache flush problem. Upon glock lock transfer, if the file is a large sparse 
  file, the gfs2_meta_cache_flush prematurely stops the flushing that leaves stale 
  entries around. This has generated few nasty issues including data corruption.
* Correct checking in gfs2_get_block_noalloc upon unmapped buffer.
* Simplify gfs2 code path by disabling gfs2_writepages. The implementation currently
  generates unmapped dirty buffers with mmap calls that do not work well with rest of
  the gfs2 journaling code. Defer the writepages implementation until later time frame.

 Signed-off-by: S. Wendy Cheng <wcheng redhat com>

 meta_io.c     |    8 ++++----
 ops_address.c |    3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

--- e47-brew/fs/gfs2/meta_io.c	2007-09-18 07:33:00.000000000 -0500
+++ e47/fs/gfs2/meta_io.c	2007-09-17 13:41:48.000000000 -0500
@@ -374,10 +374,10 @@ void gfs2_meta_cache_flush(struct gfs2_i
 
 	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);
--- e47-brew/fs/gfs2/ops_address.c	2007-09-18 07:33:00.000000000 -0500
+++ e47/fs/gfs2/ops_address.c	2007-09-17 22:09:43.000000000 -0500
@@ -90,7 +90,7 @@ static int gfs2_get_block_noalloc(struct
 	error = gfs2_block_map(inode, lblock, 0, bh_result);
 	if (error)
 		return error;
-	if (bh_result->b_blocknr == 0)
+	if (!buffer_mapped(bh_result) || !create)
 		return -EIO;
 	return 0;
 }
@@ -810,7 +810,6 @@ cannot_release:
 
 const struct address_space_operations gfs2_file_aops = {
 	.writepage = gfs2_writepage,
-	.writepages = gfs2_writepages,
 	.readpage = gfs2_readpage,
 	.readpages = gfs2_readpages,
 	.sync_page = block_sync_page,

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]