From patchwork Thu Jun 4 01:18:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 28082 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 D008EB7067 for ; Thu, 4 Jun 2009 11:19:28 +1000 (EST) Received: by ozlabs.org (Postfix) id BFD30DDDE5; Thu, 4 Jun 2009 11:19:28 +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 59EB4DDDE2 for ; Thu, 4 Jun 2009 11:19:28 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbZFDBTL (ORCPT ); Wed, 3 Jun 2009 21:19:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752464AbZFDBTL (ORCPT ); Wed, 3 Jun 2009 21:19:11 -0400 Received: from mail-px0-f182.google.com ([209.85.216.182]:42107 "EHLO mail-px0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751512AbZFDBTL (ORCPT ); Wed, 3 Jun 2009 21:19:11 -0400 Received: by pxi12 with SMTP id 12so410442pxi.33 for ; Wed, 03 Jun 2009 18:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=rZZFu/DbiahGh4pXdMZmUfoRzT2mTp2lQo0CJ56OlFs=; b=hDDFeUgC7jbWgVxAEAyuZBcnFA/rkeRNGOsiChOgpyURfqNF1ygb01PF82dThzL17l PY13mJcJx7xlj5DJyrqLHZCpkmxW1vS7D1wcU05Ii/RswDDUWryvVk4o9b9WzuegPi9Y SQ46awLjzTwsQTn/3zoQlJscsIXy8vmiC8mvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=UY4nHaT69+wQoa5AU3t3RB23INufEJ+pjFgK8bifdUYL2gaT5dCNbhnX7lQbCG1blA 4Ndt/UJyu0WIxrN2J0C3EL9U1hVMlfpu2eL5FODLOsB/0wSD38zPfEjXKh/5TfXE0H8c WC+vonzN2QxXLotCUocifTKfJoLMT075aUAVc= Received: by 10.114.159.6 with SMTP id h6mr2504088wae.19.1244078352466; Wed, 03 Jun 2009 18:19:12 -0700 (PDT) Received: from localhost.localdomain ([59.64.158.44]) by mx.google.com with ESMTPS id v32sm10285031wah.13.2009.06.03.18.19.10 (version=SSLv3 cipher=RC4-MD5); Wed, 03 Jun 2009 18:19:11 -0700 (PDT) From: Peng Tao To: linux-ext4@vger.kernel.org Cc: Theodore Tso , Andreas Dilger , Peng Tao Subject: [PATCH-e2fsprogs-resend] filefrag: fix fm_start in filefrag_fiemap loop Date: Thu, 4 Jun 2009 09:18:40 +0800 Message-Id: <1244078320-13888-1-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.6.2.GIT Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When used with -v and the targeted file has more than 144 extents(double of the length of fm_extents array provided by buf), filefrag_fiemap loops and calls fiemap ioctl() multiple times to calculate the actual number of extents in a file. Each call to fiemap ioctl() uses fm_start as the starting logical offset. The patch fixes fm_start in each loop( except for the first one) and makes the extent calculation correct for files with more that 144 extents. To produce the problem, first run filefrag -v on a highly fragmented file. Then change the buf size in filefrag_fiemap to make it large enough to have all the extent mapped in a single loop and run filefrag -v after recompiling. The former will produce a much smaller extent count because of the false fm_start used in the loop. And the two will produce different extent output since the 145th extent. Signed-off-by: Peng Tao --- misc/filefrag.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/misc/filefrag.c b/misc/filefrag.c index 6bea2cd..7786646 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -239,7 +239,7 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) n++; } - fiemap->fm_start += fm_ext[i-1].fe_logical + + fiemap->fm_start = fm_ext[i-1].fe_logical + fm_ext[i-1].fe_length; } while (last == 0);