From patchwork Thu Mar 28 10:34:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 231971 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 C92CA2C008C for ; Thu, 28 Mar 2013 21:35:28 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751852Ab3C1Kf2 (ORCPT ); Thu, 28 Mar 2013 06:35:28 -0400 Received: from oproxy7-pub.bluehost.com ([67.222.55.9]:58665 "HELO oproxy7-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751730Ab3C1Kf1 (ORCPT ); Thu, 28 Mar 2013 06:35:27 -0400 Received: (qmail 23327 invoked by uid 0); 28 Mar 2013 10:35:27 -0000 Received: from unknown (HELO box585.bluehost.com) (66.147.242.185) by oproxy7.bluehost.com with SMTP; 28 Mar 2013 10:35:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tao.ma; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=TdO7R2T5Oaoii94mDQOG1BSX5iXp5ssxX3eFLP76keM=; b=tvx9Ky4JbX70OTL4Hp27KzPQW1ONLPWkxMFmFEHQcQoxen5XT4uD4BMcSDWZY5553JCZri+Cqw5gYZfwh2lIClWoh7OdSmWNWYrSvaDXiJuvJN6vyNIW3jh4kRT84sFD; Received: from [182.92.247.2] (port=29862 helo=tma-laptop1.taobao.ali.com) by box585.bluehost.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.80) (envelope-from ) id 1ULAB3-0000Ru-Li; Thu, 28 Mar 2013 04:35:26 -0600 From: Tao Ma To: linux-ext4@vger.kernel.org Cc: zab@redhat.com Subject: [PATCH 1/2] ext4: Return proper offset for '..' if inline_data enabled. Date: Thu, 28 Mar 2013 18:34:58 +0800 Message-Id: <1364466899-5599-1-git-send-email-tm@tao.ma> X-Mailer: git-send-email 1.7.9.5 X-Identified-User: {1390:box585.bluehost.com:colyli:tao.ma} {sentby:smtp auth 182.92.247.2 authed with tm@tao.ma} Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Tao Ma Zach reported a problem that if inline data is enabled, we don't tell the difference between the offset of '.' and '..'. And a getdents will fail if the user only want to get '.'. This patch adds a new offset EXT4_INLINE_DOTDOT_OFFSET which indicates the offset of inline "..", and now 0 is for the "." and EXT4_INLINE_DOTDOT_OFFSET is for "..". Reported-by: Zach Brown Signed-off-by: Tao Ma Tested-by: Zach Brown --- fs/ext4/inline.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index c0fd1a1..9c09dd5 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -19,7 +19,8 @@ #define EXT4_XATTR_SYSTEM_DATA "data" #define EXT4_MIN_INLINE_DATA_SIZE ((sizeof(__le32) * EXT4_N_BLOCKS)) -#define EXT4_INLINE_DOTDOT_SIZE 4 +#define EXT4_INLINE_DOTDOT_SIZE 4 +#define EXT4_INLINE_DOTDOT_OFFSET 2 int ext4_get_inline_size(struct inode *inode) { @@ -1330,6 +1331,7 @@ int ext4_read_inline_dir(struct file *filp, sb = inode->i_sb; stored = 0; parent_ino = le32_to_cpu(((struct ext4_dir_entry_2 *)dir_buf)->inode); + offset = filp->f_pos; while (!error && !stored && filp->f_pos < inode->i_size) { revalidate: @@ -1342,9 +1344,15 @@ revalidate: if (filp->f_version != inode->i_version) { for (i = 0; i < inode->i_size && i < offset;) { + /* + * "." is with offset 0 and + * ".." is EXT4_INLINE_DOTDOT_OFFSET. + */ if (!i) { - /* skip "." and ".." if needed. */ - i += EXT4_INLINE_DOTDOT_SIZE; + i = EXT4_INLINE_DOTDOT_OFFSET; + continue; + } else if (i == EXT4_INLINE_DOTDOT_OFFSET) { + i = EXT4_INLINE_DOTDOT_SIZE; continue; } de = (struct ext4_dir_entry_2 *) @@ -1373,7 +1381,11 @@ revalidate: if (error) break; stored++; + filp->f_pos = EXT4_INLINE_DOTDOT_OFFSET; + continue; + } + if (filp->f_pos == EXT4_INLINE_DOTDOT_OFFSET) { error = filldir(dirent, "..", 2, 0, parent_ino, DT_DIR); if (error)