diff --git a/fs/buffer.c b/fs/buffer.c
index 3469d53..96cbb4c 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -156,7 +156,9 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
 				       bdevname(bh->b_bdev, b));
 		}
 		set_buffer_write_io_error(bh);
-		clear_buffer_uptodate(bh);
+		if (!(bh->b_bdev->bd_super->s_type->fs_flags &
+						FS_HANDLE_WRITE_ERROR))
+			clear_buffer_uptodate(bh);
 	}
 	unlock_buffer(bh);
 	put_bh(bh);
@@ -389,7 +391,9 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
 		}
 		set_bit(AS_EIO, &page->mapping->flags);
 		set_buffer_write_io_error(bh);
-		clear_buffer_uptodate(bh);
+		if (!(bh->b_bdev->bd_super->s_type->fs_flags &
+						FS_HANDLE_WRITE_ERROR))
+			clear_buffer_uptodate(bh);
 		SetPageError(page);
 	}
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e0bc4ff..f69e5f3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -181,6 +181,9 @@ struct inodes_stat_t {
 #define FS_RENAME_DOES_D_MOVE	32768	/* FS will handle d_move()
 					 * during rename() internally.
 					 */
+#define FS_HANDLE_WRITE_ERROR	65536	/* Don't clear uptodate flag on buffers
+					 * when write IO error happens
+					 */
 
 /*
  * These are the fs-independent mount-flags: up to 32 flags are supported
