From patchwork Wed May 31 08:15:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9756235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7DB1D60360 for ; Wed, 31 May 2017 08:27:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D2A11FF8F for ; Wed, 31 May 2017 08:27:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F064283BD; Wed, 31 May 2017 08:27:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9D191FF8F for ; Wed, 31 May 2017 08:27:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbdEaI0n (ORCPT ); Wed, 31 May 2017 04:26:43 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:33532 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377AbdEaIRM (ORCPT ); Wed, 31 May 2017 04:17:12 -0400 Received: by mail-pg0-f54.google.com with SMTP id u187so4573437pgb.0 for ; Wed, 31 May 2017 01:17:12 -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=QKZzM+6hEe6AFT13ilULZzZNaueE31BVGKy+FPJqldM=; b=Cv2ysnfsToxSVrv1T73unA9SRUoVhEGIiVzW3jJ7sgGzLCrPyVTuf5gQ9u69fd3ND4 kxgqAs6bI85vLZO35OZI8nrA/YF2gYJFyYl9sbr3E8PPjsdNE6KvfAsr1USY+giNFKBr wS2za9iAdCDk2NLsuZxpfdj7kk8xy7iJq0DiO4Ul13KlwUn6iDPoNGuoUtNaXy3VHouu At6V2lTDwZPNrzVkFhFFVDYUsXHNQyNct+zjcqy4fbcF+sd/0pnv6RXn0h8F1Jk9xpMf W50mrImaJqHLH5nHpU0AzKZtrvbFyDhC1R6ZA/JkPhS2Mr7wJ6Nrno/5DW9bRmhGAjia 6IQQ== 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=QKZzM+6hEe6AFT13ilULZzZNaueE31BVGKy+FPJqldM=; b=XbeHK2jV0kLGEgT3OfZerPx2F5CzsyMx1kveC7F6yUjZTJdA/vbfbZcxuoCXI7boIJ FwPlF7HgvHdk6cwevuGAanEiIqoZLxYvMqrZXwOGx2KRfABVagijHzgFAVEhZjUW8itD C6QvNVRiBtXqT4TtZOG7xP5rpOeyQaKicmjFXRdBADl+XL5LmZ6M0ysFksH1cJxcA+sH VvW7dv0k750zXGGAS0TmF5cDhaXH/D6tRZwrLPr7w+M67wfQmKYkqE/o/qF/ikJtUSOM Q6I3kDZIAlumX5YzVuIFWtxoSm3ilG9aZrkLxx8fP+sNWriYaL16XlTmhnWjmpy5+xJI FiMg== X-Gm-Message-State: AODbwcDEnPtcomLnmAu3QNBrEFZ98nSKK09+tq2UVdFgstZmoD2fKrlz WYFin8cr4jDfMMC3 X-Received: by 10.84.211.13 with SMTP id b13mr5257320pli.112.1496218626458; Wed, 31 May 2017 01:17:06 -0700 (PDT) Received: from tahsin1.svl.corp.google.com ([100.123.230.167]) by smtp.gmail.com with ESMTPSA id g75sm25469724pfd.83.2017.05.31.01.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 01:17:05 -0700 (PDT) From: Tahsin Erdogan To: Jan Kara , Theodore Ts'o , Andreas Dilger , Dave Kleikamp , Alexander Viro , Mark Fasheh , Joel Becker , Jens Axboe , Deepa Dinamani , Mike Christie , Fabian Frederick , linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Tahsin Erdogan Subject: [PATCH 15/28] ext4: fix ext4_xattr_move_to_block() Date: Wed, 31 May 2017 01:15:04 -0700 Message-Id: <20170531081517.11438-15-tahsin@google.com> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog In-Reply-To: <20170531081517.11438-1-tahsin@google.com> References: <20170531081517.11438-1-tahsin@google.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);