Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2182518imm; Mon, 28 May 2018 03:25:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrlbeCWT6pmhBpMQhLGxi961j+W59fw23ywRtOJzI9C2UCG4CXzcsT9UgB1Bc2jxYj+OaVA X-Received: by 2002:a65:4ecc:: with SMTP id w12-v6mr10109431pgq.214.1527503138950; Mon, 28 May 2018 03:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527503138; cv=none; d=google.com; s=arc-20160816; b=Ws2LqxftJtD6GosYTHbAjwCE71ie4jsMKgcTCdNtRFpF+qGb2ab8G1lNmJOL0ZKOrX y/xcrVa6zG5zRcsTyAEjbu0kldlMebrPp4lzseRbmi2JATtn9vrBgBwMDhxMxZCAbML6 HwHxsHuha5hBg0Gvf0S46KbYuPTTmVSIFdQR959AkxKC6TyZVGZPQp9m7eavSV1JWWB6 noBNiZ8aUsVY702hu0bAbpxsrUvRFM+FjaijLYHpB9tllIRohhWqY7y2mkdEoJZ6xoYa pVav5YCqB3qTtZgDPcyUViedhWWB0xL8KO/shBQ9kxOof5tGVVjLS2SzHXUCaCz4VCOp qcyQ== 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=cqlGn/Y1MS2OShb2QRTpmyfZ2qP9T2aEY19tUfEE+sw=; b=FXkeY4kSNgK7HmkIRzhUxXMVPZbeHGWBd5Sp1O9EcIjfr18j55huaSX+d8IV2t7zXd TDt+CtCsEH7uDaCcaHX0Ic9xJR1kw2GRkiLEK16q5/qZ18zoyI6qygc6E7jgY3zP3EkO lrlzjuqiGViCL2V9EMmI5aUnVKDVH4O/ZKzr9O8gC4t8Zjl5OG6jRVFaGyuFY7OQWT/x JXCLMbYNCOxEl2vKxjp3rFmbwvSa+Aqk83QIqPA36bgYonZmFj2JWfyNEVNJW6Eq1NoD su8RU1L3fFjdUdCMNBgVcLJWmO843xYik29viUMAWycVni/isBo/0bvcw822i238rME+ SYHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r3Ldcb4V; 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 31-v6si29925768plz.364.2018.05.28.03.25.24; Mon, 28 May 2018 03:25:38 -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=r3Ldcb4V; 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 S1033770AbeE1KYG (ORCPT + 99 others); Mon, 28 May 2018 06:24:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:43372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033758AbeE1KYC (ORCPT ); Mon, 28 May 2018 06:24:02 -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 9C5A42088E; Mon, 28 May 2018 10:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503042; bh=ibalzbA7Kze1JhC5AtrGl4DnIkItSH20pc0KiHnDLGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3Ldcb4VF8e9N2fDtQOXAFfoj/psQKCkKXvKfkXJBSdbUmfsx+Xh0ZUMilppSoD0t XNQatIf6DkGPrnh67an/9L2DsmPNJGevS7XTeSTRPcsMfQ3uhWKejLoqiohjlqzQMu pxRY+q/hDm1tLm/I9jTe73JcAWnAzi1otrTSnF7Q= 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.4 181/268] Btrfs: fix copy_items() return value when logging an inode Date: Mon, 28 May 2018 12:02:35 +0200 Message-Id: <20180528100222.864980245@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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: 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 @@ -3835,6 +3835,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);