From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Monakhov Subject: [PATCH 03/12] ext3: handle errors in orphan_cleanup Date: Wed, 19 May 2010 10:01:59 +0400 Message-ID: <1274248928-5113-4-git-send-email-dmonakhov@openvz.org> References: <1274248928-5113-1-git-send-email-dmonakhov@openvz.org> <1274248928-5113-2-git-send-email-dmonakhov@openvz.org> <1274248928-5113-3-git-send-email-dmonakhov@openvz.org> Cc: jack@suse.cz, hch@infradead.org, Dmitry Monakhov To: linux-fsdevel@vger.kernel.org Return-path: Received: from mail-fx0-f46.google.com ([209.85.161.46]:45621 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356Ab0ESGCU (ORCPT ); Wed, 19 May 2010 02:02:20 -0400 Received: by mail-fx0-f46.google.com with SMTP id 10so1907816fxm.19 for ; Tue, 18 May 2010 23:02:19 -0700 (PDT) In-Reply-To: <1274248928-5113-3-git-send-email-dmonakhov@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Orphan cleanup procedure is complex task and may fail due to number of reasons. Handle errors from orphan_cleanp according to predefined per-sb errors behavior flags. Signed-off-by: Dmitry Monakhov --- fs/ext3/super.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 0fc1293..5ca068f 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1438,23 +1438,24 @@ static int ext3_check_descriptors(struct super_block *sb) * e2fsck was run on this filesystem, and it must have already done the orphan * inode cleanup for us, so we can safely abort without any further action. */ -static void ext3_orphan_cleanup (struct super_block * sb, +static int ext3_orphan_cleanup (struct super_block * sb, struct ext3_super_block * es) { unsigned int s_flags = sb->s_flags; int nr_orphans = 0, nr_truncates = 0; + int ret = 0; #ifdef CONFIG_QUOTA int i; #endif if (!es->s_last_orphan) { jbd_debug(4, "no orphan inodes to clean up\n"); - return; + return ret; } if (bdev_read_only(sb->s_bdev)) { ext3_msg(sb, KERN_ERR, "error: write access " "unavailable, skipping orphan cleanup."); - return; + return ret; } if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { @@ -1463,7 +1464,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, "clearing orphan list.\n"); es->s_last_orphan = 0; jbd_debug(1, "Skipping orphan recovery on fs with errors.\n"); - return; + return ret; } if (s_flags & MS_RDONLY) { @@ -1476,11 +1477,13 @@ static void ext3_orphan_cleanup (struct super_block * sb, /* Turn on quotas so that they are updated correctly */ for (i = 0; i < MAXQUOTAS; i++) { if (EXT3_SB(sb)->s_qf_names[i]) { - int ret = ext3_quota_on_mount(sb, i); - if (ret < 0) + ret = ext3_quota_on_mount(sb, i); + if (ret < 0) { ext3_msg(sb, KERN_ERR, "error: cannot turn on journaled " "quota: %d", ret); + goto out; + } } } #endif @@ -1514,7 +1517,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, } iput(inode); /* The delete magic happens here! */ } - +out: #define PLURAL(x) (x), ((x)==1) ? "" : "s" if (nr_orphans) @@ -1523,6 +1526,9 @@ static void ext3_orphan_cleanup (struct super_block * sb, if (nr_truncates) ext3_msg(sb, KERN_INFO, "%d truncate%s cleaned up", PLURAL(nr_truncates)); + if (ret) + ext3_msg(sb, KERN_ERR, "Error %d wile orphan cleanup", ret); + #ifdef CONFIG_QUOTA /* Turn quotas off */ for (i = 0; i < MAXQUOTAS; i++) { @@ -1531,6 +1537,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, } #endif sb->s_flags = s_flags; /* Restore MS_RDONLY status */ + return ret; } /* @@ -2034,7 +2041,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS; - ext3_orphan_cleanup(sb, es); + ret = ext3_orphan_cleanup(sb, es); + + if (ret) + goto failed_mount3; + EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS; if (needs_recovery) ext3_msg(sb, KERN_INFO, "recovery complete"); -- 1.6.6.1