Received: by 10.213.65.68 with SMTP id h4csp525976imn; Fri, 16 Mar 2018 10:24:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELs4foLme9/12Z34IXMYlKtnwTE3wxbcmPrmEUWw+7lg8fzE89EOc3AJJfyMs2wOC95q+WSK X-Received: by 10.98.133.86 with SMTP id u83mr2222956pfd.172.1521221052976; Fri, 16 Mar 2018 10:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521221052; cv=none; d=google.com; s=arc-20160816; b=I4lfZ06CpzK0LUmdooc1BnAwyckUtZZYRrbZhIqpEzz16N1ZKLURMejwfGedmiCI/k GVV8ZtTsJTTlnDG1ONJormoc0RqSkWDwU/ZvGb1lkEFlnjhIl5iWzE7tHMpZXX/26OzB vgdslB0tuDZZ391Ydm8HaRNESPSexWxAhkzMlxolnRVvhxXmTHNNG0W4f6YlfpALsHJ1 0xMb+8aEVa1L8jpZVyYCYSyv1zSQmCdg/NqbWOCqFIhe7Wnk3pg+QA7mKdO3Xa3GkbU1 gOfTpPHKRAaWKYfgWSrXIhtLPCPb7CShfoiLKq0lrvsRrDhBojHCwpoYD7iNEwWMQg7I IRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=d9uSKXDyXbGDDhIGHPljwrlVvX9PlSDlb39g7cCSuQ8=; b=Sf9shJ55TjnFXtsGkF7O6cuUgmA/3z3fa4rEYhW+QeV6Bw3gEcqvKqVTRlPSAFPb54 aZOyjts5skMLvlKbL3/4m8B5yuBugxr+AKMM7U/GL6aeKULonuuXsUrra0L50ztI60aT EFdn2wcFOYLi5WKiTigTGz4v04I8ing4vE+FTBTm87uwoy74SlUr+Gh4nAOQmi8UhaBT 03Ylxv1QSdllVvNjx3xRiQTCUQg2oe+CA7CGWFrz+MjDzlMhlZffetee/WtJsd6NV7iR OTJWH9arn/leqrwSpRzKUIzERNyUnxibIHZ4cMZbRM933uikIEL+K15aMDJ3dfDUs13d KyVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19si5705814pfk.128.2018.03.16.10.23.58; Fri, 16 Mar 2018 10:24:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933116AbeCPP3l (ORCPT + 99 others); Fri, 16 Mar 2018 11:29:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36204 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933081AbeCPP3h (ORCPT ); Fri, 16 Mar 2018 11:29:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A335FFB0; Fri, 16 Mar 2018 15:29:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tahsin Erdogan , Theodore Tso , Andreas Dilger , Tommi Rantala Subject: [PATCH 4.4 45/63] ext4: inplace xattr block update fails to deduplicate blocks Date: Fri, 16 Mar 2018 16:23:17 +0100 Message-Id: <20180316152304.770115727@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152259.964532775@linuxfoundation.org> References: <20180316152259.964532775@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tahsin Erdogan commit ec00022030da5761518476096626338bd67df57a upstream. When an xattr block has a single reference, block is updated inplace and it is reinserted to the cache. Later, a cache lookup is performed to see whether an existing block has the same contents. This cache lookup will most of the time return the just inserted entry so deduplication is not achieved. Running the following test script will produce two xattr blocks which can be observed in "File ACL: " line of debugfs output: mke2fs -b 1024 -I 128 -F -O extent /dev/sdb 1G mount /dev/sdb /mnt/sdb touch /mnt/sdb/{x,y} setfattr -n user.1 -v aaa /mnt/sdb/x setfattr -n user.2 -v bbb /mnt/sdb/x setfattr -n user.1 -v aaa /mnt/sdb/y setfattr -n user.2 -v bbb /mnt/sdb/y debugfs -R 'stat x' /dev/sdb | cat debugfs -R 'stat y' /dev/sdb | cat This patch defers the reinsertion to the cache so that we can locate other blocks with the same contents. Signed-off-by: Tahsin Erdogan Signed-off-by: Theodore Ts'o Reviewed-by: Andreas Dilger Signed-off-by: Tommi Rantala Signed-off-by: Greg Kroah-Hartman --- fs/ext4/xattr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -828,8 +828,6 @@ ext4_xattr_block_set(handle_t *handle, s if (!IS_LAST_ENTRY(s->first)) ext4_xattr_rehash(header(s->base), s->here); - ext4_xattr_cache_insert(ext4_mb_cache, - bs->bh); } unlock_buffer(bs->bh); if (error == -EFSCORRUPTED) @@ -918,6 +916,7 @@ inserted: } else if (bs->bh && s->base == bs->bh->b_data) { /* We were modifying this block in-place. */ ea_bdebug(bs->bh, "keeping this block"); + ext4_xattr_cache_insert(ext4_mb_cache, bs->bh); new_bh = bs->bh; get_bh(new_bh); } else {