Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3030436imm; Sun, 17 Jun 2018 09:28:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKqFtrXUHLNUu5N9Jvh5qlMIpfpcClX7Kuk0ZBxQ5WsrSn2BcI8N/2kv3P8w4lMOGF4+kmZ X-Received: by 2002:a63:ba02:: with SMTP id k2-v6mr8333755pgf.179.1529252902304; Sun, 17 Jun 2018 09:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529252902; cv=none; d=google.com; s=arc-20160816; b=XpTjTTR1Y4Rbl7EOYRWs4TLfpvgKB7FU2GqrOmfdp9PprxHD9O1QS4wPxBBaP9xn81 W8gX5QIHsrVI+eQQju+04gtdhYjLtZubcFYkOCPzxHMCY45V+KvqrsDf9IvWTwhDrQaZ nWGM6THJGk0MEomE1+D8wBra6UQDCVWZKmJcMCpxax6IUxpwkGHxU6YQkuPC8NBXzTDc gYlWr+WB5aHcIGDkSHRzgL2AtmbNSSUGhtWMCCDAmx2o22oghJepoN8vYodFPGq4Z35Y 3i+/R07TLIyWomezhUPb6U+cS7TDB4uEqaCCMQeITcIQnsy1nCQoUrS/cLhRZeI7L8F7 dW4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=B9MXfIi7kNQnDHFEigT6SKeprt1z9UrK4kyU0LhCsdU=; b=Ji4JeZN6BMq/vJoR+NH6mvkLh6eTEL9w8oN0T5YwKfayxzY9iFhAURunoNaybdAwjT CfDalO3Iz1kjkF+Imgzju0yBP+EV7YeB8MA7zV+6LzHDy2GXhhXAj3wRlE8305/clbP+ 7ajzme8bOmN0/Zv2w8Gp83b8RYjQtxjBegopl6MO0MWPNNOGVVXWPFvmHetu6dLEhQQv aPQFAutxnEXxlaBFAslufIGAFMipz0VvEcrk9EzKJEbiNeQvhi7AFZuG0Lxyh0EuBpTA 9xnQ9iRXoKko/EHj1+YBIxYOmo2HKXZEFvuw7EOvqLozajqn3OLyW/LVEyoaWov1pRRZ SVCw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18-v6si13485163pls.407.2018.06.17.09.27.38; Sun, 17 Jun 2018 09:28:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934133AbeFQQ0o (ORCPT + 99 others); Sun, 17 Jun 2018 12:26:44 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:46626 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933955AbeFQQ0n (ORCPT ); Sun, 17 Jun 2018 12:26:43 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126] helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1fUaVi-0004qW-JH; Sun, 17 Jun 2018 17:26:38 +0100 Message-ID: <1529252797.2289.206.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 181/268] Btrfs: fix copy_items() return value when logging an inode From: Ben Hutchings To: Filipe Manana , David Sterba , Sasha Levin Cc: stable@vger.kernel.org, Greg Kroah-Hartman , LKML Date: Sun, 17 Jun 2018 17:26:37 +0100 In-Reply-To: <20180528100222.864980245@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> <20180528100222.864980245@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-05-28 at 12:02 +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me know. > > ------------------ > > From: Filipe Manana > > [ Upstream commit 8434ec46c6e3232cebc25a910363b29f5c617820 ] Should stable branches also get a backport of commit 4ee3fad34a9cc2cf33303dfbd0cf554248651c86? It looks like 4.4 and 4.9 would need a minor change (inode->root to BTRFS_I(inode)->root) but I don't know whether that's really sufficient. Ben. > 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); -- Ben Hutchings, Software Developer   Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom