Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2297892imm; Mon, 28 May 2018 05:37:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZop4VPY7xrHUF1gf2dSWJ/hquK3T2KifmUwgDjfzQHDv5hmJJQSJO/261TCpLx99jTFGkUZ X-Received: by 2002:a62:78c:: with SMTP id 12-v6mr13416667pfh.178.1527511064833; Mon, 28 May 2018 05:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511064; cv=none; d=google.com; s=arc-20160816; b=gcxjaBf/dgnD3qIfMcIgICIdwb1rZZNhrpMxwomAu5Ma2l2VW5AmfcGPq8x/luFWYg BBKDml/VODbadu/E7G+e2NMqnW7q5ikn3WQALW3ApObkGVP1S2ArocWGFPMMh6TtnwIy rsok4MW3bsRHdNswEINDhLt2ffKDFv/FVfbLt+TghRhRcoctr1xEwn+9Nr4tleUOC9FL FEtuj2uUCbPsq8aItHH8indPhgB1hTapjCXWTBawe0wQP3hpv57c6bRNOdrN2o6Vo80B e0pRUkiUdaCUVN52p+3XOsj/dqSZe7O50Nx9Jq15va3AzZAW0ddSNI9C27nlS/qUfqwX g1Ew== 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:dkim-signature :arc-authentication-results; bh=06bRUxKG/bbeDYqe1EDGL4aUCmPAkCxwG5DjkBNWFmU=; b=Y6ETv3+dMPUm6MYT3XAcalvqEJr39dMS7j4n/x2ixFq2gfejlDD4HCeVRDpU4Fkfd5 hp3e9rh13/jooWIdf4fdZQtp1G5p0bk82mSlTP3br6K78n0RSGHEKGRIYP6q4IBv8aJe m4ISxDZx4ORPY5QtD39XYiAvQfyRadUkSOuzx6DgThkBAocxSRxiiSCjBR4LHahoM08z UXe5QQdBHDPDSfdGpWaRY2ub3QYyqUPv2YCP0hVxDvy9VihZ5/r99wU1Va4b/U7ubXG6 /P2aW9Yuk33KvdZnlvMcSJKxjHYoVpmI4PvgBOeq62ZdFDL2H1EHrliGsV8YMhI5AJfi dErA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YwdQ//vG; 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 m37-v6si13718317plg.491.2018.05.28.05.37.30; Mon, 28 May 2018 05:37:44 -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; dkim=pass header.i=@kernel.org header.s=default header.b=YwdQ//vG; 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 S938082AbeE1K7A (ORCPT + 99 others); Mon, 28 May 2018 06:59:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:46848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938058AbeE1K6r (ORCPT ); Mon, 28 May 2018 06:58:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DA0B2087E; Mon, 28 May 2018 10:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505126; bh=TjYYo994YovwQN4Qc8hSmN249gwNROru0H0RSL6JZ7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YwdQ//vGAmuNN2UfrCSvTAcP2nfTajz+7XNffCv49OI4XtcWLwypH6zmLywxAfTf2 tWQaKQgUBZaeEWNLd7JQM0cGw7vgMmIOSmtmyNoUsEtiw8YeqixzlUcq9rJhmPusD6 2lSCM7ajf7cVlX5Jz29tZAdz2ubEv+1sjZFUwwvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 4.14 354/496] Btrfs: fix copy_items() return value when logging an inode Date: Mon, 28 May 2018 12:02:19 +0200 Message-Id: <20180528100334.718425651@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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: Filipe Manana [ Upstream commit 8434ec46c6e3232cebc25a910363b29f5c617820 ] When logging an inode, at tree-log.c:copy_items(), if we call btrfs_next_leaf() at the loop which checks for the need to log holes, we need to make sure copy_items() returns the value 1 to its caller and not 0 (on success). This is because the path the caller passed was released and is now different from what is was before, and the caller expects a return value of 0 to mean both success and that the path has not changed, while a return value of 1 means both success and signals the caller that it can not reuse the path, it has to perform another tree search. Even though this is a case that should not be triggered on normal circumstances or very rare at least, its consequences can be very unpredictable (especially when replaying a log tree). Fixes: 16e7549f045d ("Btrfs: incompatible format change to remove hole extents") Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -3918,6 +3918,7 @@ fill_holes: ASSERT(ret == 0); src = src_path->nodes[0]; i = 0; + need_find_last_extent = true; } btrfs_item_key_to_cpu(src, &key, i);