From patchwork Fri Dec 6 09:58:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 297676 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 5B3A62C0098 for ; Fri, 6 Dec 2013 20:56:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757669Ab3LFJ4O (ORCPT ); Fri, 6 Dec 2013 04:56:14 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:32898 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757607Ab3LFJ4D (ORCPT ); Fri, 6 Dec 2013 04:56:03 -0500 Received: by mail-pd0-f173.google.com with SMTP id p10so750969pdj.32 for ; Fri, 06 Dec 2013 01:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lOzKKpxnteRAZN6vhqjhaRfFJItNQqgG6dUmtIEuvQk=; b=MMt4Whkx/Qk4LOP/I+kssv75TD/Hq6CxbQSits4yu5v+xJV5UIQuyJPxQAxwaPpMKN myrqlRS6KoArSs6SEPhcnJlXyCYUvCcIhRKKBVNQzTkNRMkpQiISiooKKQOJ5VLzysAs IFioxcmQJ8d5JWAMg/bfSiuAXUIhTznNk553v73d1UrUXWaSng1fUUrzlVy2VVSgwOdk zI15sANdjmSIayzOzCgZBD2ZY8Ac3tvyYRQvO0XngoZcLIPOtGcWWA4IO9/VtpHMuvx3 AXYFwYSRGeZXJ13Rum4FuKIAN3AteaHwAI7GN83VrJUh5BT2/8A3vi0ujU4S19NfUaeZ Q+rA== X-Received: by 10.68.197.129 with SMTP id iu1mr3128997pbc.139.1386323763317; Fri, 06 Dec 2013 01:56:03 -0800 (PST) Received: from alpha.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id m2sm56582620pbn.19.2013.12.06.01.56.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 06 Dec 2013 01:56:02 -0800 (PST) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Theodore Ts'o , "Darrick J. Wong" , Zheng Liu Subject: [PATCH v3 17/30] debugfs: handle inline_data feature in bmap command Date: Fri, 6 Dec 2013 17:58:04 +0800 Message-Id: <1386323897-2354-18-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 In-Reply-To: <1386323897-2354-1-git-send-email-wenqing.lz@taobao.com> References: <1386323897-2354-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 No physical block mapping if an inode has inline data. Meanwhile this commit fixes a minor bug in bmap command when it prints an error. Signed-off-by: Theodore Ts'o Signed-off-by: Zheng Liu --- debugfs/debugfs.c | 2 +- lib/ext2fs/bmap.c | 7 +++++++ lib/ext2fs/ext2_err.et.in | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index ef5f201..bc8413d 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -2135,7 +2135,7 @@ void do_bmap(int argc, char *argv[]) errcode = ext2fs_bmap2(current_fs, ino, 0, 0, 0, blk, 0, &pblk); if (errcode) { - com_err("argv[0]", errcode, + com_err(argv[0], errcode, "while mapping logical block %llu\n", blk); return; } diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index 5074587..e148dba 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -266,6 +266,13 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, } addr_per_block = (blk_t) fs->blocksize >> 2; + /* + * If an inode has inline data, that means that it doesn't have + * any blocks and we shouldn't map any blocks for it. + */ + if (inode->i_flags & EXT4_INLINE_DATA_FL) + return EXT2_ET_INLINE_DATA_NO_BLOCK; + if (!block_buf) { retval = ext2fs_get_array(2, fs->blocksize, &buf); if (retval) diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in index 0781145..f93f0e8 100644 --- a/lib/ext2fs/ext2_err.et.in +++ b/lib/ext2fs/ext2_err.et.in @@ -503,4 +503,7 @@ ec EXT2_ET_EA_NO_SPACE, ec EXT2_ET_NO_INLINE_DATA, "Inode doesn't have inline data" +ec EXT2_ET_INLINE_DATA_NO_BLOCK, + "No block for an inode with inline data" + end