From patchwork Tue Apr 28 15:58:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 26575 X-Patchwork-Delegate: tytso@mit.edu 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 B796DB7069 for ; Wed, 29 Apr 2009 01:59:51 +1000 (EST) Received: by ozlabs.org (Postfix) id A6BC3DDEDD; Wed, 29 Apr 2009 01:59:51 +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 2A69ADDED6 for ; Wed, 29 Apr 2009 01:59:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761591AbZD1P72 (ORCPT ); Tue, 28 Apr 2009 11:59:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761842AbZD1P71 (ORCPT ); Tue, 28 Apr 2009 11:59:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45029 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761591AbZD1P71 (ORCPT ); Tue, 28 Apr 2009 11:59:27 -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 n3SFwY1m008146; Tue, 28 Apr 2009 11:58:34 -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 n3SFwWef012849; Tue, 28 Apr 2009 11:58:33 -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 n3SFwU0E016696; Tue, 28 Apr 2009 11:58:31 -0400 Message-ID: <49F727A6.8010302@redhat.com> Date: Tue, 28 Apr 2009 10:58:30 -0500 From: Eric Sandeen User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 To: ext4 development CC: Carl Henrik Lunde Subject: [PATCH] ext4: fix for fiemap last-block test 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 Carl Henrik Lunde reported and debugged this; the test for the last allocated block was comparing bytes to blocks in this test: if (logical + length - 1 == EXT_MAX_BLOCK || ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK) flags |= FIEMAP_EXTENT_LAST; so any extent which ended right at 4G was stopping the extent walk. Just replacing these values with the extent block & length should fix it. Also give blksize_bits a saner type, and reverse the order of the tests to make the more likely case tested first. Signed-off-by: Eric Sandeen Reported-by: Carl Henrik Lunde Tested-by: Carl Henrik Lunde --- -- 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: linux-2.6.29.x86_64/fs/ext4/extents.c =================================================================== --- linux-2.6.29.x86_64.orig/fs/ext4/extents.c +++ linux-2.6.29.x86_64/fs/ext4/extents.c @@ -3087,7 +3087,7 @@ static int ext4_ext_fiemap_cb(struct ino void *data) { struct fiemap_extent_info *fieinfo = data; - unsigned long blksize_bits = inode->i_sb->s_blocksize_bits; + unsigned char blksize_bits = inode->i_sb->s_blocksize_bits; __u64 logical; __u64 physical; __u64 length; @@ -3134,8 +3134,8 @@ static int ext4_ext_fiemap_cb(struct ino * * XXX this might miss a single-block extent at EXT_MAX_BLOCK */ - if (logical + length - 1 == EXT_MAX_BLOCK || - ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK) + if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK || + newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) flags |= FIEMAP_EXTENT_LAST; error = fiemap_fill_next_extent(fieinfo, logical, physical,