From patchwork Sat Feb 26 20:35:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 84670 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 55590B70D2 for ; Sun, 27 Feb 2011 07:35:27 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477Ab1BZUfU (ORCPT ); Sat, 26 Feb 2011 15:35:20 -0500 Received: from mail-qw0-f46.google.com ([209.85.216.46]:59612 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752475Ab1BZUfT (ORCPT ); Sat, 26 Feb 2011 15:35:19 -0500 Received: by qwd7 with SMTP id 7so2005576qwd.19 for ; Sat, 26 Feb 2011 12:35:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to:cc :content-type; bh=LM9BJQaA1MmS3I37FZGr+qbTg0T1XsRZDqvunPRt7zU=; b=tGFbr4/pryDZNGZJYWijBxqf74t0vHdDywdcpmr+vTxmHip3pvI9XL8fOApDQ3fxq0 Yo17SjE1ZFyGDf3YhHeqJTTKsKkGbRJWucQdvx2xXk31Ab45LOePYr24wD2MFZFDZV3J WBNax35f2EFeaAtDFPZQkTLxFPKCL8TtHsJEA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=KyswdAu2VVwmhVitwsoDgtoU7eZZElt5Qwj0cOzEyXvSwy5AzHmYwM33n9CWQs36y1 2oo8C7HSUJpKo0c28GdCj3Mp94psfq/ejBQPULdTnggFS+BsB9aUpAsnJ8FidCh8gfkB rLEOe0mMRuj/Ilc5Rk/8WaDfMjm0lo8vR0kkY= MIME-Version: 1.0 Received: by 10.229.229.209 with SMTP id jj17mr2932472qcb.273.1298752518800; Sat, 26 Feb 2011 12:35:18 -0800 (PST) Received: by 10.229.96.71 with HTTP; Sat, 26 Feb 2011 12:35:18 -0800 (PST) Date: Sat, 26 Feb 2011 22:35:18 +0200 Message-ID: Subject: [PATCH] ext4: skip orphan cleanup on rocompat fs From: Amir Goldstein To: Theodore Tso Cc: Jan Kara , Ext4 Developers List Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Orphan cleanup is currently executed even on readonly mount. It deletes inodes and frees blocks, which could be very bad for some RO_COMPAT features, SNAPSHOT and BIGALLOC to name two. Now the damage is done, because current stock kernels may corrupt future fs with readonly compatible features, when doing orphan cleanup. This patch skips the orphan cleanup if readonly compatible features would prevent the fs from being mounted (or remounted) readwrite. Signed-off-by: Amir Goldstein --- fs/ext4/super.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f6a318f..02e3b02 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -75,6 +75,7 @@ static void ext4_write_super(struct super_block *sb); static int ext4_freeze(struct super_block *sb); static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data); +static int ext4_feature_set_ok(struct super_block *sb, int readonly); static void ext4_destroy_lazyinit_thread(void); static void ext4_unregister_li_request(struct super_block *sb); static void ext4_clear_request_list(void); @@ -2120,6 +2121,13 @@ static void ext4_orphan_cleanup(struct super_block *sb, return; } + /* Check if feature set allows readwrite operations */ + if (!ext4_feature_set_ok(sb, 0)) { + ext4_msg(sb, KERN_INFO, "Skipping orphan cleanup on readonly-" + "compatible fs"); + return; + } + if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { if (es->s_last_orphan) jbd_debug(1, "Errors on filesystem, "