From: Andrew Morton Subject: Re: [PATCH] Fix ext2 error reporting on fsync Date: Wed, 11 Jan 2006 20:24:59 -0800 Message-ID: <20060111202459.66f37754.akpm@osdl.org> References: <20060111174302.GD16728@atrey.karlin.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Chris Mason Return-path: Received: from smtp.osdl.org ([65.172.181.4]:17110 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S965013AbWALEZZ (ORCPT ); Wed, 11 Jan 2006 23:25:25 -0500 To: Jan Kara In-Reply-To: <20060111174302.GD16728@atrey.karlin.mff.cuni.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Jan Kara wrote: > > 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. > > ... > @@ -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)) > This is desperation stuff, isn't it? It would be better to stick a BH_WriteError into buffer_head.b_state, set that in the I/O completion handler, check it in fsync_buffers_list()?