Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2508548imm; Mon, 28 May 2018 09:24:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoR7b4y0Mq+DO5pB96zJirTz20LnrUlLbbZwzeZzW6cUyxrzxnd370vMtpv80pVg9zPny6a X-Received: by 2002:a65:61a5:: with SMTP id i5-v6mr10770709pgv.405.1527524649416; Mon, 28 May 2018 09:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524649; cv=none; d=google.com; s=arc-20160816; b=Ws3JJgpiIepDkEEwfoxlfpyRgnFxpdY8PKZvuKcR9TeLmWaMj6++ONZ2DN7sT9+WtG Oi9qg5Tl577gm4NHgDFJOmJ3oalecmalt3tAjjYMTFa0yBD7zjHd1rFKYdkU7PAz37Ji O6NVdCsJN4roxCnaie4s9IBfiGjRam6vdipKKA8pXiCSkVC+Ai0ftoGpx3EEkDvlRJEq /DPxK5NRrJIOR8dQP7Crclsdm3ODwk16EJzqvxxaGzdutLD10af/v34U8l5LoTizoNr+ HhWOdzAVzpKdKJhe2anrRE2DIcshsztEV8zgD5x6yRTEHEX+LJu+oemYLfuI9tUlfF31 Qxpw== 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=LIpmt1do30SW93805FY/abgwRPe/LtqDPhDiqqItjy8=; b=yfsHaVR3ADKRq+O5Oqkje3Yq/EyBiPpzshgFLs6SEPABCj7J5rTw1+2sJrKTsCh7pS FlFNw9mioS+BACWY04M6x9OEbTVsLC51M0RTZxsXtgOXAWkm0UDkbe85AaSfvYqbUzuF 2vUf5QiR3corx9/fNGi43MiLsic2N/fpEizODXNJKpSrVQsZGOrm2bNTaBr4DYX3siGs hxMZ0eHyE+NSqH8E2kYelS+r/QfNUm73TdKI6vmfmBzuB6mG7y8791tkNcjpmpvx9th1 f/K/bKWmy++FWqg+Gz8lNYycXVmlS+r3keOip+Qy7r2Ltn1DCTSGU/lfM06zdzaaRuxE PDVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p/3bAlxq; 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 1-v6si30175458plv.16.2018.05.28.09.23.54; Mon, 28 May 2018 09:24:09 -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=p/3bAlxq; 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 S939962AbeE1QX3 (ORCPT + 99 others); Mon, 28 May 2018 12:23:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936561AbeE1KLM (ORCPT ); Mon, 28 May 2018 06:11:12 -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 ED26C2086D; Mon, 28 May 2018 10:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502272; bh=080EzKMhv94rf1aLRd1Nxhcc6xmf3S0Wb1thV0BVjVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/3bAlxqn9OSX6vyz2F6nZyIkk/cfUeOf+N2Ww1GRDbmON4oQltOUgaXORsVVvKbi CGXjLqyjYvhlSx4Z1kjE7sC0VENu37okTV9fE3RFbcWVeIBD5p52W9siB3TvayGOJw UXQgyONVtaCGcqSk5YGxG7IdKV7MHtHMVwtWPeE4= 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 3.18 125/185] Btrfs: fix copy_items() return value when logging an inode Date: Mon, 28 May 2018 12:02:46 +0200 Message-Id: <20180528100103.386247677@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -3539,6 +3539,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);