From patchwork Wed Jun 17 19:40:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 28807 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 F2246B722C for ; Thu, 18 Jun 2009 05:40:24 +1000 (EST) Received: by ozlabs.org (Postfix) id E453FDDDB6; Thu, 18 Jun 2009 05:40:24 +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 8208EDDD1B for ; Thu, 18 Jun 2009 05:40:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755027AbZFQTkT (ORCPT ); Wed, 17 Jun 2009 15:40:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754268AbZFQTkT (ORCPT ); Wed, 17 Jun 2009 15:40:19 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37600 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755031AbZFQTkS (ORCPT ); Wed, 17 Jun 2009 15:40:18 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5HJeLEd031173 for ; Wed, 17 Jun 2009 15:40:21 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5HJeKrO009709 for ; Wed, 17 Jun 2009 15:40:20 -0400 Received: from liberator.sandeen.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5HJeJYs022716 for ; Wed, 17 Jun 2009 15:40:19 -0400 Message-ID: <4A3946A3.2040401@redhat.com> Date: Wed, 17 Jun 2009 14:40:19 -0500 From: Eric Sandeen User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 To: ext4 development Subject: [PATCH, RFC] resize2fs: update sb backup journal if journal was moved X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This was reported in Fedora, since the livecd creator does a lot of resizing. If we've moved the journal blocks during resize (likely now, due to the journal being in the middle) the backup blocks don't get updated, and a subsequent e2fsck will find issues: e2fsck 1.41.6 (30-May-2009) Backing up journal inode block information. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /mnt/test/img: ***** FILE SYSTEM WAS MODIFIED ***** /mnt/test/img: 11/16000 files (0.0% non-contiguous), 17789/38400 blocks This can be shown in a simple test: # dd if=/dev/zero of=img bs=1 count=0 seek=3000M # mke2fs -t ext4 -F img # resize2fs img 150M # e2fsck -f img (thanks to the Fedora reporter Mads Kiilerich! https://bugzilla.redhat.com/show_bug.cgi?id=506105#c2) The following is just rough; I'd at least move it to a helper function, and needs some error checking. But it does fix it. Question is, should I do it unconditionally, or only if the journal inode got moved? Doing it conditionally would require a bit more work to sort out whether it's been moved. Or, I could just compare the two and overwrite it if they differ, vs actually walking the backup blocks and see if any are off the end of the filesystem... what seems best? Signed-off-by: Eric Sandeen --- -- 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/resize/resize2fs.c b/resize/resize2fs.c index 0d5dc81..acb338e 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -148,6 +148,17 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, if (retval) goto errout; + if (rfs->new_fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) { + struct ext2_inode inode; + + retval = ext2fs_read_inode(rfs->new_fs, + rfs->new_fs->super->s_journal_inum, &inode); + memcpy(rfs->new_fs->super->s_jnl_blocks, inode.i_block, EXT2_N_BLOCKS*4); + rfs->new_fs->super->s_jnl_blocks[16] = inode.i_size; + rfs->new_fs->super->s_jnl_backup_type = EXT3_JNL_BACKUP_BLOCKS; + ext2fs_mark_super_dirty(fs); + } + rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; retval = ext2fs_close(rfs->new_fs); if (retval)