linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: akpm@osdl.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] Fix ext2 error reporting on fsync
Date: Wed, 11 Jan 2006 18:43:02 +0100	[thread overview]
Message-ID: <20060111174302.GD16728@atrey.karlin.mff.cuni.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

  Hello,

  attached patch (from Chris Mason) fixes possible bug in error
reporting during fsync on ext2 filesystem. If some previous metadata
async write failed with EIO, it just set AS_EIO in the device's mapping.
We need to check this in ext2_file_write() and act accordingly. The
patch is against 2.6.15. Please apply.

								Honza

-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

[-- Attachment #2: ext2-sync_check-2.6.15.diff --]
[-- Type: text/plain, Size: 1831 bytes --]

From: Chris Mason <mason@suse.com>
Subject: ext2 should force the FS readonly for metadata write errors
References: 65718

During fsync we should check for write errors to the block device in order to make
sure all metadata writes have been properly written to the disk.  Without this check
writes that happen through the normal async mechanisms might hit errors without
reporting them back to the application.

Signed-off-by: Jan Kara <jack@suse.cz>

diff -rupX /home/jack/.kerndiffexclude linux-2.6.15/fs/ext2/fsync.c linux-2.6.15-1-ext2_sync_check/fs/ext2/fsync.c
--- linux-2.6.15/fs/ext2/fsync.c	2004-10-18 23:55:24.000000000 +0200
+++ linux-2.6.15-1-ext2_sync_check/fs/ext2/fsync.c	2006-01-13 22:56:43.000000000 +0100
@@ -25,6 +25,7 @@
 #include "ext2.h"
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>		/* for fsync_inode_buffers() */
+#include <linux/pagemap.h>
 
 
 /*
@@ -35,10 +36,26 @@
 int ext2_sync_file(struct file *file, struct dentry *dentry, int datasync)
 {
 	struct inode *inode = dentry->d_inode;
+	struct super_block *sb = inode->i_sb;
 	int err;
 	int ret;
 
 	ret = sync_mapping_buffers(inode->i_mapping);
+
+	/* it might make more sense to ext2_error on -EIO from
+	 * sync_mapping_buffers as well, but those errors are isolated to just
+	 * this file. We can safely return -EIO to fsync and let the app know
+	 * they have a problem.  
+	 *
+	 * AS_EIO indicates a failure to write a metadata page, but we have no 
+	 * way of knowing which one.  It's best to force readonly and let fsck 
+	 * figure it all out.
+	 */
+	if (test_and_clear_bit(AS_EIO, &sb->s_bdev->bd_inode->i_mapping->flags)) {
+		ext2_error(sb, "ext2_sync_file", "metadata io error");
+		if (!ret)
+			ret = -EIO;
+	}
 	if (!(inode->i_state & I_DIRTY))
 		return ret;
 	if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))

             reply	other threads:[~2006-01-11 17:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-11 17:43 Jan Kara [this message]
2006-01-12  4:24 ` [PATCH] Fix ext2 error reporting on fsync Andrew Morton
2006-01-12 10:20   ` Jan Kara
2006-01-12 11:52     ` Andrew Morton
2006-01-12 13:58       ` Chris Mason
2006-01-12 14:21         ` Jan Kara
2006-01-12 15:36           ` Chris Mason
2006-01-12 16:32             ` Jan Kara
2006-01-12 14:26       ` Jan Kara
2006-01-12 20:47         ` Andrew Morton
2006-01-13  2:08           ` Chris Mason
2006-01-13  2:16             ` Andrew Morton
2006-01-18 22:46               ` Jan Kara
2006-01-18 23:06                 ` Andrew Morton
2006-01-19 12:21                   ` Jan Kara
2006-01-19 21:16                     ` Andrew Morton
2006-01-20 13:41                       ` Jan Kara
2006-01-20 21:24                         ` Andrew Morton
2006-01-20 21:31                           ` Andrew Morton
2006-01-20 21:33                             ` Andrew Morton
2006-01-22 22:55                             ` Jan Kara
2006-01-23  0:06                               ` Andrew Morton
2006-01-22 22:32                           ` Jan Kara
2006-01-22 23:31                           ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060111174302.GD16728@atrey.karlin.mff.cuni.cz \
    --to=jack@suse.cz \
    --cc=akpm@osdl.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).