From patchwork Mon Apr 16 11:39:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 152798 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 4D048B6FBB for ; Mon, 16 Apr 2012 21:34:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753250Ab2DPLeT (ORCPT ); Mon, 16 Apr 2012 07:34:19 -0400 Received: from mail-pz0-f52.google.com ([209.85.210.52]:62902 "EHLO mail-pz0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753145Ab2DPLeT (ORCPT ); Mon, 16 Apr 2012 07:34:19 -0400 Received: by mail-pz0-f52.google.com with SMTP id e40so6801134dak.11 for ; Mon, 16 Apr 2012 04:34:18 -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=G7Pb8Vw4Icq3pErOUq7HkQD5MsyH3CDQFNxSnT5d1J7VGBtct6zzHkMGjpj2ictSNF vCy2tx8+Fp8HIN1kiJ4Z88OzV6WmpUprgNA184/y4YS8oMHcM7yoo3/Dr7HDafJ1+ntK 5Ck9f/UNnMGxL0b6EP8ntanpudivfKczUZgD3ok0dNnRVYPZ0lQH7LugCSwFLqAb5yoH mnqrkmEh1cyojgw8FfZJ3TzM9oB4bejXLBv7gBWtl/754ew5AqinAijUdhs76xf4lg6C N7IgS0AxZw6dvEBx63M8tzLqkmRTFxrDytUw7P3AIJjxTi1vrm9ljjGUOC7adYtlEY42 g4+g== Received: by 10.68.197.167 with SMTP id iv7mr10158564pbc.75.1334576058948; Mon, 16 Apr 2012 04:34:18 -0700 (PDT) Received: from localhost.localdomain ([182.92.247.2]) by mx.google.com with ESMTPS id l6sm17474160pbp.33.2012.04.16.04.34.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Apr 2012 04:34:18 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Zheng Liu Subject: [PATCH 14/32] debugfs: make filefrag cmd support inline data Date: Mon, 16 Apr 2012 19:39:49 +0800 Message-Id: <1334576407-4007-15-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1334576407-4007-1-git-send-email-wenqing.lz@taobao.com> References: <1334576407-4007-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) {