{"id":846,"url":"http://patchwork.ozlabs.org/api/1.0/patches/846/?format=json","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.0/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20080922195621t-sato@mail.jp.nec.com>","date":"2008-09-22T10:56:21","name":"[3/10] ext4: Fix error handling in write_super_lockfs/unlockfs","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"c3b8cd0ae23f2d7a30cc1a4270cfe89f03429cbc","submitter":{"id":391,"url":"http://patchwork.ozlabs.org/api/1.0/people/391/?format=json","name":"Takashi Sato","email":"t-sato@yk.jp.nec.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20080922195621t-sato@mail.jp.nec.com/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/846/checks/","tags":{},"headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Received":["from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id 99F1DDDE26\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 22 Sep 2008 20:58:16 +1000 (EST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753367AbYIVK6J (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 22 Sep 2008 06:58:09 -0400","(majordomo@vger.kernel.org) by vger.kernel.org id S1753298AbYIVK6G\n\t(ORCPT <rfc822;linux-ext4-outgoing>);\n\tMon, 22 Sep 2008 06:58:06 -0400","from TYO201.gate.nec.co.jp ([202.32.8.193]:37411 \"EHLO\n\ttyo201.gate.nec.co.jp\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752264AbYIVK6A (ORCPT\n\t<rfc822; linux-ext4@vger.kernel.org>); Mon, 22 Sep 2008 06:58:00 -0400","from mailgate3.nec.co.jp ([10.7.69.160])\n\tby tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8MAuMU1029376;\n\tMon, 22 Sep 2008 19:56:22 +0900 (JST)","(from root@localhost) by mailgate3.nec.co.jp\n\t(8.11.7/3.7W-MAILGATE-NEC)\n\tid m8MAuMa29376; Mon, 22 Sep 2008 19:56:22 +0900 (JST)","from togyo.jp.nec.com (togyo.jp.nec.com [10.26.220.4])\n\tby mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8MAuMjZ012746;\n\tMon, 22 Sep 2008 19:56:22 +0900 (JST)","from TNESB07336 ([10.64.168.65] [10.64.168.65]) by mail.jp.nec.com\n\twith ESMTP; Mon, 22 Sep 2008 19:56:21 +0900"],"To":"Andrew Morton <akpm@linux-foundation.org>,\n\tChristoph Hellwig <hch@infradead.org>,\n\t\"linux-fsdevel@vger.kernel.org\" <linux-fsdevel@vger.kernel.org>,\n\t\"dm-devel@redhat.com\" <dm-devel@redhat.com>,\n\t\"viro@ZenIV.linux.org.uk\" <viro@ZenIV.linux.org.uk>,\n\t\"linux-ext4@vger.kernel.org\" <linux-ext4@vger.kernel.org>,\n\t\"xfs@oss.sgi.com\" <xfs@oss.sgi.com>, \"axboe@kernel.dk\" <axboe@kernel.dk>,\n\t\"mtk.manpages@googlemail.com\" <mtk.manpages@googlemail.com>","Cc":"\"linux-kernel@vger.kernel.org\" <linux-kernel@vger.kernel.org>","Subject":"[PATCH 3/10] ext4: Fix error handling in write_super_lockfs/unlockfs","Message-Id":"<20080922195621t-sato@mail.jp.nec.com>","Mime-Version":"1.0","X-Mailer":"WeMail32[2.51] ID:1K0086","From":"Takashi Sato <t-sato@yk.jp.nec.com>","Date":"Mon, 22 Sep 2008 19:56:21 +0900","Content-Type":"text/plain; charset=us-ascii","Content-Transfer-Encoding":"7bit","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"},"content":"I've changed write_super_lockfs/unlockfs so that they return an error\nin case of an I/O failure.\n\nSigned-off-by: Takashi Sato <t-sato@yk.jp.nec.com>\nSigned-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com>\n---\n super.c |   39 +++++++++++++++++++++++++++------------\n 1 file changed, 27 insertions(+), 12 deletions(-)\n\n--\nTo unsubscribe from this list: send the line \"unsubscribe linux-ext4\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html","diff":"diff -uprN -X linux-2.6.27-rc7-lockfs-ext3/Documentation/dontdiff linux-2.6.27-rc7-lockfs-ext3/fs/ext4/super.c linux-2.6\n.27-rc7-lockfs-ext4/fs/ext4/super.c\n--- linux-2.6.27-rc7-lockfs-ext3/fs/ext4/super.c\t2008-09-22 07:29:55.000000000 +0900\n+++ linux-2.6.27-rc7-lockfs-ext4/fs/ext4/super.c\t2008-09-22 10:46:36.000000000 +0900\n@@ -49,7 +49,7 @@ static int ext4_load_journal(struct supe\n \t\t\t     unsigned long journal_devnum);\n static int ext4_create_journal(struct super_block *, struct ext4_super_block *,\n \t\t\t       unsigned int);\n-static void ext4_commit_super(struct super_block *sb,\n+static int ext4_commit_super(struct super_block *sb,\n \t\t\t      struct ext4_super_block *es, int sync);\n static void ext4_mark_recovery_complete(struct super_block *sb,\n \t\t\t\t\tstruct ext4_super_block *es);\n@@ -60,9 +60,9 @@ static const char *ext4_decode_error(str\n \t\t\t\t     char nbuf[16]);\n static int ext4_remount(struct super_block *sb, int *flags, char *data);\n static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);\n-static void ext4_unlockfs(struct super_block *sb);\n+static int ext4_unlockfs(struct super_block *sb);\n static void ext4_write_super(struct super_block *sb);\n-static void ext4_write_super_lockfs(struct super_block *sb);\n+static int ext4_write_super_lockfs(struct super_block *sb);\n \n \n ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,\n@@ -2792,20 +2792,22 @@ static int ext4_create_journal(struct su\n \treturn 0;\n }\n \n-static void ext4_commit_super(struct super_block *sb,\n+static int ext4_commit_super(struct super_block *sb,\n \t\t\t      struct ext4_super_block *es, int sync)\n {\n \tstruct buffer_head *sbh = EXT4_SB(sb)->s_sbh;\n+\tint error = 0;\n \n \tif (!sbh)\n-\t\treturn;\n+\t\treturn error;\n \tes->s_wtime = cpu_to_le32(get_seconds());\n \text4_free_blocks_count_set(es, ext4_count_free_blocks(sb));\n \tes->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb));\n \tBUFFER_TRACE(sbh, \"marking dirty\");\n \tmark_buffer_dirty(sbh);\n \tif (sync)\n-\t\tsync_dirty_buffer(sbh);\n+\t\terror = sync_dirty_buffer(sbh);\n+\treturn error;\n }\n \n \n@@ -2919,37 +2921,50 @@ static int ext4_sync_fs(struct super_blo\n  * LVM calls this function before a (read-only) snapshot is created.  This\n  * gives us a chance to flush the journal completely and mark the fs clean.\n  */\n-static void ext4_write_super_lockfs(struct super_block *sb)\n+static int ext4_write_super_lockfs(struct super_block *sb)\n {\n+\tint error = 0;\n+\tjournal_t *journal;\n \tsb->s_dirt = 0;\n \n \tif (!(sb->s_flags & MS_RDONLY)) {\n-\t\tjournal_t *journal = EXT4_SB(sb)->s_journal;\n+\t\tjournal = EXT4_SB(sb)->s_journal;\n \n \t\t/* Now we set up the journal barrier. */\n \t\tjbd2_journal_lock_updates(journal);\n-\t\tjbd2_journal_flush(journal);\n+\t\terror = jbd2_journal_flush(journal);\n+\t\tif (error)\n+\t\t\tgoto out;\n \n \t\t/* Journal blocked and flushed, clear needs_recovery flag. */\n \t\tEXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);\n-\t\text4_commit_super(sb, EXT4_SB(sb)->s_es, 1);\n+\t\terror = ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);\n+\t\tif (error)\n+\t\t\tgoto out;\n \t}\n+\treturn 0;\n+\n+out:\n+\tjbd2_journal_unlock_updates(journal);\n+\treturn error;\n }\n \n /*\n  * Called by LVM after the snapshot is done.  We need to reset the RECOVER\n  * flag here, even though the filesystem is not technically dirty yet.\n  */\n-static void ext4_unlockfs(struct super_block *sb)\n+static int ext4_unlockfs(struct super_block *sb)\n {\n+\tint error = 0;\n \tif (!(sb->s_flags & MS_RDONLY)) {\n \t\tlock_super(sb);\n \t\t/* Reser the needs_recovery flag before the fs is unlocked. */\n \t\tEXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);\n-\t\text4_commit_super(sb, EXT4_SB(sb)->s_es, 1);\n+\t\terror = ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);\n \t\tunlock_super(sb);\n \t\tjbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);\n \t}\n+\treturn error;\n }\n \n static int ext4_remount(struct super_block *sb, int *flags, char *data)\n","prefixes":["3/10"]}