From patchwork Fri Aug 2 09:49:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 264254 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 807362C0087 for ; Fri, 2 Aug 2013 19:50:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758508Ab3HBJuh (ORCPT ); Fri, 2 Aug 2013 05:50:37 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:41215 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758344Ab3HBJua (ORCPT ); Fri, 2 Aug 2013 05:50:30 -0400 Received: by mail-pd0-f175.google.com with SMTP id 5so482364pdd.34 for ; Fri, 02 Aug 2013 02:50:30 -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=sOQOafGkdJJqQEy8CQu7555/j8A7cWGK08Bzd6Nly3s=; b=i0pQuMJ+/dc5q6ddBtAcJYXzeZrTU0/dTFQ+p1fikRIDKgoBGcdV5Fdur6nq1FK3Ix IX7NdgkxHGSbHvnP4AF6yQBpJU1qg9BccDySObBTCWR2B5jk+ncje0MJKjrASmem/6IM p+kRs6MXms/RhPeDgLvImQSGZJXkinjgDZyVJR51OOfSrOM6YktwxrA0q4+MMDFMj5lZ QRzq/qlERL9tDxkfXox7Y3DVMqRWiCPj9coerfqE1BVVmt1u/HlDvb1D/0CpHpjzXP/+ HMBw+lA8JHlMIuG9igzndFWH0ha5W6Ul2B5YDfQV33uv8T7HRgOa9AnjpkPlFfHc0VSw dnOw== X-Received: by 10.68.169.161 with SMTP id af1mr6846572pbc.22.1375437030117; Fri, 02 Aug 2013 02:50:30 -0700 (PDT) Received: from lz-devel.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id il4sm5912193pbb.36.2013.08.02.02.50.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:50:29 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Theodore Ts'o , Zheng Liu Subject: [PATCH v1 06/22] debugfs: make stat command support inline data Date: Fri, 2 Aug 2013 17:49:33 +0800 Message-Id: <1375436989-18948-7-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 In-Reply-To: <1375436989-18948-1-git-send-email-wenqing.lz@taobao.com> References: <1375436989-18948-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 If there is an inode with inline data, we just print the size of inline data in stat command. Signed-off-by: Theodore Ts'o Signed-off-by: Zheng Liu --- debugfs/debugfs.c | 11 +++++++++++ lib/ext2fs/ext2fs.h | 1 + lib/ext2fs/inline_data.c | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 969dbe0..2837ee6 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -704,6 +704,15 @@ static void dump_extents(FILE *f, const char *prefix, ext2_ino_t ino, fprintf(f, "\n"); } +static void dump_inline_data(FILE *out, const char *prefix, ext2_ino_t inode_num) +{ + int size; + + fprintf(out, "%sINLINE DATA:\n %s", prefix, prefix); + size = ext2fs_inline_data_get_size(current_fs, inode_num); + fprintf(out, " The size of inline data: %d", size); +} + void internal_dump_inode(FILE *out, const char *prefix, ext2_ino_t inode_num, struct ext2_inode *inode, int do_dump_blocks) @@ -837,6 +846,8 @@ void internal_dump_inode(FILE *out, const char *prefix, if (inode->i_flags & EXT4_EXTENTS_FL) dump_extents(out, prefix, inode_num, DUMP_LEAF_EXTENTS|DUMP_NODE_EXTENTS, 0, 0); + else if (inode->i_flags & EXT4_INLINE_DATA_FL) + dump_inline_data(out, prefix, inode_num); else dump_blocks(out, prefix, inode_num); } diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 7b05b48..6e3bf6e 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1344,6 +1344,7 @@ extern errcode_t ext2fs_get_memalign(unsigned long size, /* inline_data.c */ extern int ext2fs_inode_has_inline_data(ext2_filsys fs, ext2_ino_t ino); +extern int ext2fs_inline_data_get_size(ext2_filsys fs, ext2_ino_t ino); extern errcode_t ext2fs_inline_data_iterate(ext2_filsys fs, ext2_ino_t ino, int flags, diff --git a/lib/ext2fs/inline_data.c b/lib/ext2fs/inline_data.c index 922c959..1220418 100644 --- a/lib/ext2fs/inline_data.c +++ b/lib/ext2fs/inline_data.c @@ -80,6 +80,33 @@ int ext2fs_inode_has_inline_data(ext2_filsys fs, ext2_ino_t ino) return (inode.i_flags & EXT4_INLINE_DATA_FL); } +int ext2fs_inline_data_get_size(ext2_filsys fs, ext2_ino_t ino) +{ + struct ext2_inode_large *inode; + struct inline_data data; + errcode_t retval = 0; + int size = 0; + + retval = ext2fs_get_mem(EXT2_INODE_SIZE(fs->super), &inode); + if (retval) + return 0; + retval = ext2fs_read_inode_full(fs, ino, (void *)inode, + EXT2_INODE_SIZE(fs->super)); + if (retval) + goto out; + + if (inode->i_flags & EXT4_INLINE_DATA_FL) { + retval = ext2fs_inline_data_find(fs, inode, &data); + if (retval) + goto out; + size = data.inline_size; + } + +out: + ext2fs_free_mem(&inode); + return size; +} + errcode_t ext2fs_inline_data_iterate(ext2_filsys fs, ext2_ino_t ino, int flags,