From: Andrew Morton Subject: Re: [PATCH] Fix ext2 error reporting on fsync Date: Thu, 12 Jan 2006 03:52:17 -0800 Message-ID: <20060112035217.1f4331c5.akpm@osdl.org> References: <20060111174302.GD16728@atrey.karlin.mff.cuni.cz> <20060111202459.66f37754.akpm@osdl.org> <20060112102036.GC8920@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, mason@suse.com Return-path: Received: from smtp.osdl.org ([65.172.181.4]:41937 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S1030302AbWALLwj (ORCPT ); Thu, 12 Jan 2006 06:52:39 -0500 To: Jan Kara In-Reply-To: <20060112102036.GC8920@atrey.karlin.mff.cuni.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Jan Kara wrote: > > > Jan Kara wrote: > > > > > > > + */ > > > + 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()? > It actually depends on the desired behaviour of fsync() in case of > IO errors. Consider the following scenario: > * process writes some data > - async writing starts in background and gets an IO error on some > metadata buffer > * process calls fsync() > - all the remaining buffers are written without problems > > If I understand your solution correctly, it need not report any error > in this case as buffer with IO error could be already removed from > mapping->private_list by try_to_free_buffers(). But it would be nice to > report to the user that we were not able to write all the data... > hm, yes, try_to_free_buffers() against a blockdev page is a problem. But I think it's fixable. In the second loop of drop_buffers(), if we find a bh which had a write error we need to set AS_EIO on the address_space which is interested in this buffer. That address_space is pinned by a) the fact that it has buffers at ->private_list and b) we hold the blockdev mapping's private_lock. The only problem is actually _finding_ the address_space which is interested in this buffer_head. Looks like we'd need a backpointer in the buffer_head.