From patchwork Sun Jul 1 13:48:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 168410 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7CD882C01C0 for ; Sun, 1 Jul 2012 23:41:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932425Ab2GANlQ (ORCPT ); Sun, 1 Jul 2012 09:41:16 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49296 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932426Ab2GANlP (ORCPT ); Sun, 1 Jul 2012 09:41:15 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so6469492pbb.19 for ; Sun, 01 Jul 2012 06:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=0OUxlAzgEee11AV+b33UHDPTM8axetehS3xbZYg14HM=; b=Fr/f6ctdKTYXEhftRgScIipc9gT1lCG3UT64w4sY7bsWO0Z3zg0Yoz2KcTN3qzHI8p 8jPniCTiw8o+IkeOv+WFfUkNopGs3h9Og9JW06h5NMc3rfVWNSPoAyl+ZZolJt3pdLYM ouRupMsXMRmSNFEiu7Y35HoArIrkv7cOAxvcOX/Fa8Fxb2Ql5goSH2zDg9rkccKcq+h5 NS80DmwMMLRtc7YeKwh0nGZObMjfjx9FF/xJGNZtLH+7TJ5DyvCLxzZlC5lqn76g5F6X /ZOaUExrkLQiGXanSAbmhM3HZPfJ2TaLRajHZ5mbD6kSmxtta96+UYa6X/0Q5ZOmblrq kxMA== Received: by 10.68.131.10 with SMTP id oi10mr21662811pbb.122.1341150075431; Sun, 01 Jul 2012 06:41:15 -0700 (PDT) Received: from localhost.localdomain ([182.92.247.2]) by mx.google.com with ESMTPS id ql3sm10544254pbc.72.2012.07.01.06.41.13 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jul 2012 06:41:15 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Zheng Liu Subject: [PATCH 14/35 v3] debugfs: make filefrag cmd support inline data Date: Sun, 1 Jul 2012 21:48:37 +0800 Message-Id: <1341150538-32047-15-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1341150538-32047-1-git-send-email-wenqing.lz@taobao.com> References: <1341150538-32047-1-git-send-email-wenqing.lz@taobao.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu Inode with inline data doesn't have any fragmentations. Signed-off-by: Zheng Liu --- debugfs/filefrag.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/debugfs/filefrag.c b/debugfs/filefrag.c index 7f28bc0..c94396c 100644 --- a/debugfs/filefrag.c +++ b/debugfs/filefrag.c @@ -153,16 +153,18 @@ static void filefrag(ext2_ino_t ino, struct ext2_inode *inode, fprintf(fs->f, "\n%s has %llu block(s), i_size is %llu\n", fs->name, num_blocks, EXT2_I_SIZE(inode)); } - print_header(fs); - retval = ext2fs_block_iterate3(current_fs, ino, - BLOCK_FLAG_READ_ONLY, NULL, - filefrag_blocks_proc, fs); - if (retval) - com_err("ext2fs_block_iterate3", retval, 0); - - report_filefrag(fs); - fprintf(fs->f, "%s: %d contiguous extents%s\n", fs->name, fs->ext, - LINUX_S_ISDIR(inode->i_mode) ? " (dir)" : ""); + if (!ext2fs_has_inline_data(current_fs, ino)) { + print_header(fs); + retval = ext2fs_block_iterate3(current_fs, ino, + BLOCK_FLAG_READ_ONLY, NULL, + filefrag_blocks_proc, fs); + if (retval) + com_err("ext2fs_block_iterate3", retval, 0); + + report_filefrag(fs); + fprintf(fs->f, "%s: %d contiguous extents%s\n", fs->name, fs->ext, + LINUX_S_ISDIR(inode->i_mode) ? " (dir)" : ""); + } } static int filefrag_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)), @@ -240,8 +242,12 @@ static void dir_iterate(ext2_ino_t ino, struct filefrag_struct *fs) fs->dir_name = fs->name; while (1) { - retval = ext2fs_dir_iterate2(current_fs, ino, 0, - 0, filefrag_dir_proc, fs); + if (ext2fs_has_inline_data(current_fs, ino)) + retval = ext2fs_inline_data_iterate2(current_fs, ino, + 0, 0, filefrag_dir_proc, fs); + else + retval = ext2fs_dir_iterate2(current_fs, ino, 0, + 0, filefrag_dir_proc, fs); if (retval) com_err("ext2fs_dir_iterate2", retval, 0); if (p) {