From patchwork Thu Jan 5 14:40:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 134485 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E3F311007D6 for ; Fri, 6 Jan 2012 01:41:04 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932568Ab2AEOk0 (ORCPT ); Thu, 5 Jan 2012 09:40:26 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39832 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932507Ab2AEOkW (ORCPT ); Thu, 5 Jan 2012 09:40:22 -0500 Received: from relay1.suse.de (nat.nue.novell.com [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 51DFC8C5DF; Thu, 5 Jan 2012 15:40:21 +0100 (CET) Received: by quack.suse.cz (Postfix, from userid 1000) id 88E76205D8; Thu, 5 Jan 2012 15:40:20 +0100 (CET) From: Jan Kara To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, Andrew Morton , Christoph Hellwig , Al Viro , LKML , Edward Shishkin , Jan Kara Subject: [PATCH 2/3] fs: Do not clear uptodate flag on write IO error Date: Thu, 5 Jan 2012 15:40:06 +0100 Message-Id: <1325774407-28531-3-git-send-email-jack@suse.cz> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1325774407-28531-1-git-send-email-jack@suse.cz> References: <1325774407-28531-1-git-send-email-jack@suse.cz> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org It is semantically wrong to clear uptodate flag of buffers where the write has failed since the data in the buffer is still correct despite the write failing. This also causes spurious warnings when IO error happens, we decide to write the buffer again and call mark_buffer_dirty() which warns us about non-uptodate buffer. Sadly, historically buffer_uptodate() check has been the way we detected IO errors and quite some code still uses this check. Eventually we'd like to convert all users to use buffer_write_io_error() test instead but that requires audit of all filesystems. So for now just provide an opt-in flag in file_system_type by which filesystem can say it detects write IO errors by checking buffer_write_io_error() and thus we don't have to clear uptodate flag. Signed-off-by: Jan Kara --- fs/buffer.c | 8 ++++++-- include/linux/fs.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) 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