From patchwork Sat Apr 18 06:05:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Dokos X-Patchwork-Id: 26147 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 DE7C5B707A for ; Sat, 18 Apr 2009 16:05:03 +1000 (EST) Received: by ozlabs.org (Postfix) id CF2E2DE172; Sat, 18 Apr 2009 16:05:03 +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 55BD5DDF9D for ; Sat, 18 Apr 2009 16:05:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751023AbZDRGFB (ORCPT ); Sat, 18 Apr 2009 02:05:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751091AbZDRGFB (ORCPT ); Sat, 18 Apr 2009 02:05:01 -0400 Received: from qmta09.emeryville.ca.mail.comcast.net ([76.96.30.96]:49828 "EHLO QMTA09.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbZDRGFA (ORCPT ); Sat, 18 Apr 2009 02:05:00 -0400 Received: from OMTA10.emeryville.ca.mail.comcast.net ([76.96.30.28]) by QMTA09.emeryville.ca.mail.comcast.net with comcast id gu2H1b0020cQ2SLA9u50j5; Sat, 18 Apr 2009 06:05:00 +0000 Received: from gamaville.dokosmarshall.org ([24.34.105.88]) by OMTA10.emeryville.ca.mail.comcast.net with comcast id gu4y1b00B1uT3cw8Wu4zBQ; Sat, 18 Apr 2009 06:05:00 +0000 Received: from gamaville.dokosmarshall.org (localhost [127.0.0.1]) by gamaville.dokosmarshall.org (Postfix) with ESMTP id F310C341EB; Sat, 18 Apr 2009 02:05:13 -0400 (EDT) From: Nick Dokos To: linux-ext4@vger.kernel.org cc: nicholas.dokos@hp.com, Theodore Ts'o , Valerie Aurora Reply-to: nicholas.dokos@hp.com Subject: [PATCH 2/2][64-BIT] ext2fs_group_first_block2(): 32-bit truncation. X-Mailer: MH-E 8.1; nmh 1.2; GNU Emacs 23.0.91 Date: Sat, 18 Apr 2009 02:05:13 -0400 Message-ID: <30396.1240034713@gamaville.dokosmarshall.org> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext2fs_group_first_block2() returns the product of the group number and the number of blocks per group (from the superblock). Unfortunately, both of these are 32-bit quantities, so the multiplication result is also 32 bits wide. It is then returned as a 64-bit quantity, but by then, it's too late. Cast one of the operands to blk64_t, so the multiplication will be done in 64 bits. e2fsck was complaining about a group that was marked BLOCK_UNINIT, but had blocks in use (it turned out that a different group had blocks in use, but the block numbers of the two different groups differed by 2^32, so this bug conflated them). With this change, this complaint goes away. In addition, dumpe2fs produces the right blocks for all the groups, whereas it was wrapping them at the 32-bit boundary previously. Signed-off-by: Nick Dokos Reviewed-by: Eric Sandeen Signed-off-by: Valerie Aurora (Henson) --- lib/ext2fs/blknum.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c index b9666fb..fd56d53 100644 --- a/lib/ext2fs/blknum.c +++ b/lib/ext2fs/blknum.c @@ -28,7 +28,7 @@ dgrp_t ext2fs_group_of_blk2(ext2_filsys fs, blk64_t blk) blk64_t ext2fs_group_first_block2(ext2_filsys fs, dgrp_t group) { return fs->super->s_first_data_block + - (group * fs->super->s_blocks_per_group); + ((blk64_t)group * fs->super->s_blocks_per_group); } /*