From patchwork Wed Dec 11 01:24:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrick Wong X-Patchwork-Id: 299729 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 AC8472C009A for ; Wed, 11 Dec 2013 12:25:07 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711Ab3LKBZH (ORCPT ); Tue, 10 Dec 2013 20:25:07 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:43815 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751429Ab3LKBZF (ORCPT ); Tue, 10 Dec 2013 20:25:05 -0500 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rBB1P3WR011501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Dec 2013 01:25:03 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1P2Bt000265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Dec 2013 01:25:02 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rBB1P1Au027819; Wed, 11 Dec 2013 01:25:01 GMT Received: from localhost (/10.145.179.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Dec 2013 17:25:01 -0800 Subject: [PATCH 60/74] libext2fs: ensure that inline data is always written to ibody To: tytso@mit.edu, darrick.wong@oracle.com From: "Darrick J. Wong" Cc: linux-ext4@vger.kernel.org Date: Tue, 10 Dec 2013 17:24:58 -0800 Message-ID: <20131211012458.30655.66423.stgit@birch.djwong.org> In-Reply-To: <20131211011813.30655.39624.stgit@birch.djwong.org> References: <20131211011813.30655.39624.stgit@birch.djwong.org> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When writing xattrs to disk, move the inline_data attribute to the front of the list so that inline data always ends up in the inode body (and not a separate EA block). Signed-off-by: Darrick J. Wong --- lib/ext2fs/ext_attr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index e69275e..50f7300 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -238,6 +238,24 @@ static struct ea_name_index ea_names[] = { {0, NULL}, }; +static void move_inline_data_to_front(struct ext2_xattr_handle *h) +{ + struct ext2_xattr *x; + struct ext2_xattr tmp; + + for (x = h->attrs + 1; x < h->attrs + h->length; x++) { + if (!x->name) + continue; + + if (strcmp(x->name, "system.data") == 0) { + memcpy(&tmp, x, sizeof(tmp)); + memcpy(x, h->attrs, sizeof(tmp)); + memcpy(h->attrs, &tmp, sizeof(tmp)); + return; + } + } +} + static const char *find_ea_prefix(int index) { struct ea_name_index *e; @@ -484,6 +502,8 @@ errcode_t ext2fs_xattrs_write(struct ext2_xattr_handle *handle) if (err) goto out; + move_inline_data_to_front(handle); + x = handle->attrs; /* Does the inode have size for EA? */ if (EXT2_INODE_SIZE(handle->fs->super) <= EXT2_GOOD_OLD_INODE_SIZE +