From patchwork Wed Jun 21 21:21:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 779160 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 3wtHrX1RBsz9s2s for ; Thu, 22 Jun 2017 07:28:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="q1heiq7V"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751974AbdFUV20 (ORCPT ); Wed, 21 Jun 2017 17:28:26 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:36020 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbdFUVWK (ORCPT ); Wed, 21 Jun 2017 17:22:10 -0400 Received: by mail-pg0-f52.google.com with SMTP id u62so62813667pgb.3 for ; Wed, 21 Jun 2017 14:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EqC1WFssNPLzezVXBSVK7vSi25F9431lTnpVfJrBZFM=; b=q1heiq7VLw/nyUX6PC/Q6jKLhn8WOmVNeCjSmq1lPsjGjpzMeyYR+csPpxKOYXEXVv 0hTAjqyCQ7TuREfeyevWxgf9xdjGR1v0xgBnwnx21447l+R32FzCSBPiqrKeQ5hQL2Qu 44ORltlhY7gU1DuGrJaWHdMHJTf9xntUa924NETxPtxcWyXfla/9JTw7l6goe3n65Ws8 B1YYNI7mSdtcLdXxrTSsigilQ3eWaNQ5NzjTFZzTLSA7KsoZLsDELjZ9xOQur2LOUELr DbkQLsOJsRvOqV0yyqobKdkCxnneye8GW2HzWr3eTfsjIEa3Jao9omIkcOnr0Qy1s+ew YvUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EqC1WFssNPLzezVXBSVK7vSi25F9431lTnpVfJrBZFM=; b=S5RC7rOfFky4TMai0oM8ho4RtJCdt0F2tkml0vs7a0j192tixh3aY2GDLnr9T59PuT lBkEhlKLQJVDW/GG93aDCKCmjkno5J3zMQYXFvdk/uDkBvFuEDWkzIg6zrskqumNMnjt wY0SkLp78IjyNmSCJG4Rto4RPMj73K8/R/nqVVmRPUzzb5vh3mH/TO4vejbUCKyYip4C NSNubuc0KDJaJl/Nt2+RhBY+9jq5C2x5k7jc8PAMb5jvEmYr894TdA1Ka5yM/wC0GKlV bzUUI0X13AqjNSBQ9Enb+5PKpp+1gSgagMCzKeee5f7n45GL8SLpHVADB0FeeKAqPAx2 umzA== X-Gm-Message-State: AKS2vOyjMXoh8U5h8ZcuDfEA4dIzdDL9YvrIQBB1lMQdVCiiLKSyPrpK bSmH0PYgpVTffDiq X-Received: by 10.84.143.68 with SMTP id 62mr44465154ply.123.1498080129797; Wed, 21 Jun 2017 14:22:09 -0700 (PDT) Received: from tahsin1.svl.corp.google.com ([100.123.230.167]) by smtp.gmail.com with ESMTPSA id s64sm1829980pfd.77.2017.06.21.14.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 14:22:09 -0700 (PDT) From: Tahsin Erdogan To: Andreas Dilger , "Darrick J . Wong" , Jan Kara , Theodore Ts'o , linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH 15/32] ext4: fix ext4_xattr_move_to_block() Date: Wed, 21 Jun 2017 14:21:25 -0700 Message-Id: <20170621212142.16581-15-tahsin@google.com> X-Mailer: git-send-email 2.13.1.611.g7e3b11ae1-goog In-Reply-To: <20170621212142.16581-1-tahsin@google.com> References: <20170621212142.16581-1-tahsin@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When moving xattr entries from inline area to a xattr block, entries that refer to external xattr inodes need special handling because value data is not available in the inline area but rather should be read from its external inode. Signed-off-by: Tahsin Erdogan --- fs/ext4/xattr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 6a6bee246873..9c243b3510b7 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1658,18 +1658,16 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, struct ext4_xattr_ibody_find *is = NULL; struct ext4_xattr_block_find *bs = NULL; char *buffer = NULL, *b_entry_name = NULL; - size_t value_offs, value_size; + size_t value_size = le32_to_cpu(entry->e_value_size); struct ext4_xattr_info i = { .value = NULL, .value_len = 0, .name_index = entry->e_name_index, + .in_inode = !!entry->e_value_inum, }; struct ext4_xattr_ibody_header *header = IHDR(inode, raw_inode); int error; - value_offs = le16_to_cpu(entry->e_value_offs); - value_size = le32_to_cpu(entry->e_value_size); - is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS); bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS); buffer = kmalloc(value_size, GFP_NOFS); @@ -1685,7 +1683,17 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, bs->bh = NULL; /* Save the entry name and the entry value */ - memcpy(buffer, (void *)IFIRST(header) + value_offs, value_size); + if (entry->e_value_inum) { + error = ext4_xattr_inode_get(inode, + le32_to_cpu(entry->e_value_inum), + buffer, value_size); + if (error) + goto out; + } else { + size_t value_offs = le16_to_cpu(entry->e_value_offs); + memcpy(buffer, (void *)IFIRST(header) + value_offs, value_size); + } + memcpy(b_entry_name, entry->e_name, entry->e_name_len); b_entry_name[entry->e_name_len] = '\0'; i.name = b_entry_name; @@ -1703,7 +1711,6 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, if (error) goto out; - i.name = b_entry_name; i.value = buffer; i.value_len = value_size; error = ext4_xattr_block_find(inode, &i, bs);