Received: by 10.213.65.68 with SMTP id h4csp1738598imn; Mon, 19 Mar 2018 11:55:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELtTprFbdqd/O1op1J6K2JZByUHe7/8388uc90t6mLztXfp8vNjEXbbdL8JwRD3yhipeHjZ7 X-Received: by 10.99.97.143 with SMTP id v137mr9719921pgb.175.1521485756381; Mon, 19 Mar 2018 11:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521485756; cv=none; d=google.com; s=arc-20160816; b=S80eNLr6Jvl+/6J/pLZGBqwz00IAJAWaDYQPH6/oRblZlZ7LFgFLX7U5S+vAZIV67+ KS3o9/dmB3oJ+dMUkI+Utz8Nh2szjIBMIbvfHbqwitwzRqxBQwikGeNM7mi+5vvy370K 0/54VTFPuyNFE8H3PeKNh2a5yJdJZzsd+E4FETvemEFKKhifJ17zPg2QjRYHgn/+NZ3n IaHJPaNt0m9WZOq7ym4jCgFJw/kxRlioFXG00yPYKS5CMoiOIfIEsOJMb3W6bbl1W2Rj OuEP0DufqAEd3iUa1+iLofTcu0EyK3GNBPJx16BxWk20dREh+Cq8ntD3ZfCrq0PvH/bU BZNQ== 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=8CJN7NTR5WClvbjC8AJL/G5X5ZYkFP9URlxnrZnq9rg=; b=wyn+jH+ZFwgxOEdCxJV3gP1Xpnruzt+5/St1QY8k37aCUIV9I5LWIJoxfDKtpO8RMA /VEQJ7HOu1AgLvry/FMXcgj4iRFK/PjkiQsgn4tXGNVLQIWBd2gPdxJtkLd1XjLxxAm3 tuD8PFFvPPXxirIEW7zaYnkh9z3sqTGkv0+/vRh71tcmjIJtn035fDmP+Kmv8D2BDSoz lfapXjzW9zYb1C231dU+D4Sua5M2VtDG0PvQTAxpxmo48j8S085ThtlFvSv+tcJRatX4 839oSUrTa/7cgO1JGIexq3bAQijKzW6O2nmqJ15CeOJKhmzEZGfjDImi3a1Bnwd4qzlV XRUQ== 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 m4si339797pgt.683.2018.03.19.11.55.41; Mon, 19 Mar 2018 11:55:56 -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 S935688AbeCSSaV (ORCPT + 99 others); Mon, 19 Mar 2018 14:30:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53140 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935656AbeCSSaO (ORCPT ); Mon, 19 Mar 2018 14:30:14 -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 BBF371222; Mon, 19 Mar 2018 18:30:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Edmund Nadolski , David Sterba Subject: [PATCH 4.14 31/41] btrfs: add missing initialization in btrfs_check_shared Date: Mon, 19 Mar 2018 19:08:31 +0100 Message-Id: <20180319180734.271249639@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180732.195217948@linuxfoundation.org> References: <20180319180732.195217948@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Edmund Nadolski commit 18bf591ba9753e3e5ba91f38f756a800693408f4 upstream. This patch addresses an issue that causes fiemap to falsely report a shared extent. The test case is as follows: xfs_io -f -d -c "pwrite -b 16k 0 64k" -c "fiemap -v" /media/scratch/file5 sync xfs_io -c "fiemap -v" /media/scratch/file5 which gives the resulting output: wrote 65536/65536 bytes at offset 0 64 KiB, 4 ops; 0.0000 sec (121.359 MiB/sec and 7766.9903 ops/sec) /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x2001 /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 This is because btrfs_check_shared calls find_parent_nodes repeatedly in a loop, passing a share_check struct to report the count of shared extent. But btrfs_check_shared does not re-initialize the count value to zero for subsequent calls from the loop, resulting in a false share count value. This is a regressive behavior from 4.13. With proper re-initialization the test result is as follows: wrote 65536/65536 bytes at offset 0 64 KiB, 4 ops; 0.0000 sec (110.035 MiB/sec and 7042.2535 ops/sec) /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 which corrects the regression. Fixes: 3ec4d3238ab ("btrfs: allow backref search checks for shared extents") Signed-off-by: Edmund Nadolski [ add text from cover letter to changelog ] Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/backref.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1496,6 +1496,7 @@ int btrfs_check_shared(struct btrfs_root if (!node) break; bytenr = node->val; + shared.share_count = 0; cond_resched(); }