From patchwork Wed Sep 2 21:36:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 32849 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id AC6F5B708C for ; Thu, 3 Sep 2009 07:36:38 +1000 (EST) Received: by ozlabs.org (Postfix) id 9CD17DDD0B; Thu, 3 Sep 2009 07:36:38 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 3AB74DDD04 for ; Thu, 3 Sep 2009 07:36:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750943AbZIBVge (ORCPT ); Wed, 2 Sep 2009 17:36:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751188AbZIBVge (ORCPT ); Wed, 2 Sep 2009 17:36:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41707 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750943AbZIBVgd (ORCPT ); Wed, 2 Sep 2009 17:36:33 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n82LaXPh023697; Wed, 2 Sep 2009 17:36:33 -0400 Received: from neon.msp.redhat.com (neon.msp.redhat.com [10.15.80.10]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n82LaWGh008904; Wed, 2 Sep 2009 17:36:32 -0400 Message-ID: <4A9EE55F.3030800@redhat.com> Date: Wed, 02 Sep 2009 16:36:31 -0500 From: Eric Sandeen User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: ext4 development CC: Ric Wheeler , Justin Maggard Subject: [PATCH V2] libext2fs: use proper functions to set/clear block group flags References: <4A9ED75A.7030406@redhat.com> In-Reply-To: <4A9ED75A.7030406@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org As Justin & Ric reported, something like this on a 22T (sparse) bigfile: e2fsprogs/misc/mke2fs -E lazy_itable_init=1 \ -O uninit_bg -b 4096 bigfile mount -o loop bigfile mnt/ for I in `seq 1 5`; do mkdir mnt/$I; done umount mnt/ e2fsprogs/e2fsck/e2fsck -f bigfile would give us corrupted block group checksums: One or more block group descriptor checksums are invalid. Fix? yes Group descriptor 6301 checksum is invalid. FIXED. Group descriptor 7799 checksum is invalid. FIXED. There wer=re a few places which accessed bg_flags directly rather than using the helper functions; fixing these seems to resolve the problem. V2: use _flag_clear not _flags_clear, which clears all flags ... Even w/ this patch, I'm still getting bitmap mismatches, off by a 33rd bit. Reported-by: Justin Maggard Reported-by: Ric Wheeler Signed-off-by: Eric Sandeen --- Applies to the pu branch -- 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 Index: e2fsprogs/e2fsck/pass2.c =================================================================== --- e2fsprogs.orig/e2fsck/pass2.c +++ e2fsprogs/e2fsck/pass2.c @@ -987,12 +987,12 @@ out_htree: * we could call a function in pass1.c that checks the * newly visible inodes. */ - if (fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT) { + if (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)) { pctx.num = dirent->inode; if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT, &cd->pctx)){ - fs->group_desc[group].bg_flags &= - ~EXT2_BG_INODE_UNINIT; + ext2fs_bg_flag_clear(fs, group, + EXT2_BG_INODE_UNINIT); ext2fs_mark_super_dirty(fs); ctx->flags |= E2F_FLAG_RESTART_LATER; } else { Index: e2fsprogs/lib/ext2fs/openfs.c =================================================================== --- e2fsprogs.orig/lib/ext2fs/openfs.c +++ e2fsprogs/lib/ext2fs/openfs.c @@ -350,11 +350,12 @@ errcode_t ext2fs_open2(const char *name, if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { struct ext2_group_desc *gd; - for (i = 0, gd = fs->group_desc; i < fs->group_desc_count; - i++, gd++) { - gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT; - gd->bg_flags &= ~EXT2_BG_INODE_UNINIT; - gd->bg_itable_unused = 0; + dgrp_t group; + + for (group = 0; group < fs->group_desc_count; group++) { + ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT); + ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT); + fs->group_desc[group].bg_itable_unused = 0; } ext2fs_mark_super_dirty(fs); }