Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp117822ybg; Mon, 8 Jun 2020 18:06:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK3VN9v3T07DBSZHENDgG3zk8/wBOoZTUG5f5nXE7YeClB7AfKelqkMgRtTvNXPuGGXOJX X-Received: by 2002:aa7:cc84:: with SMTP id p4mr23786989edt.157.1591664775414; Mon, 08 Jun 2020 18:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664775; cv=none; d=google.com; s=arc-20160816; b=BL3KNfuvVu1yjc60Et3576ZcITMCYjOsI/uKieocuvF32sC8fbDNkQeiI1pOVWZf9u EpEN1w44/X2n/AOWyEg2NU06mT8XcaElNiMRhiRrIQNz2BqoILGubxfT1gTwclnFiD6v qsg/Mm5B34qX2bzJN1mnZ4FP+IwYYDxmw/xi6Ln1Tg6/lA1m5g8CFsKyP0LDlqN7hLXB 2wT5ejmMPFxAzf6qwPP6oI3g3IdXxuQVl/kLgQsswf2Ot4qfE7tfo2WyK/0SOjb5czv1 xpeSgd72ruob19oF+FkudCntEym6p22xLPKBowYgEJ/EdPq3ljJkMz93b758Sxe+KNZm ypkQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BBWtueh+GFeULx+bgyCVsDpfsTSsBi5N6buHDyppk7Y=; b=B3luQtspF+3uoyOFbPaCAIU2TAeG0mFVy4K/er50XaKf4AJ3WFlgvXbHbxlmaE8FfV HR7/1uSoPlxbia0NAQrjYeuUodNCATuVps9rHsbJdvTqgow2Xn6X2C8W1MsfBW/qiRuQ 4oTJrca1Mycn4nO+NNvj+SYgQaWITQbRoV33aL0ugiU5aw669Ics5/F/Tiwh8ojT4COk 1cq4i3z5nOsvaprpiuBJcuWRA3IWU/SHpkyLnRuoxDIKOKln4dAmOtQuiSwuDHiJGfnX 39RZq3GuA9tlYTubFLd3fv4cakhRRPWQi0GMRqaUoagE3LRLScbRPblyi0wskE3KZiTO zayg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XEL/+7mL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si9369603ejr.261.2020.06.08.18.05.52; Mon, 08 Jun 2020 18:06:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XEL/+7mL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728861AbgFIBD5 (ORCPT + 99 others); Mon, 8 Jun 2020 21:03:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:52032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727939AbgFHXHg (ORCPT ); Mon, 8 Jun 2020 19:07:36 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D502E20801; Mon, 8 Jun 2020 23:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657655; bh=7lCL1hVeQtz8UAGaoIfOTGrlJ/SDpMvUCqHKhlreOeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XEL/+7mLxvvUxT2QKq39eZVZZaS/2ZOBpbcH4wqXloqqDLsb5I5cShQj8Sem/LCvd ZCKyYUupsC6Dzb/TJLJ9WYinUVnMBPa6oQeDnIrk0i3+pxg3NObhKfEHdJaYenATPs LMK4dC5JX4kG1m02DO2jG92XSmK3d3dqEid21ziQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Filipe Manana , David Sterba , Sasha Levin , linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 068/274] btrfs: do not ignore error from btrfs_next_leaf() when inserting checksums Date: Mon, 8 Jun 2020 19:02:41 -0400 Message-Id: <20200608230607.3361041-68-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Filipe Manana [ Upstream commit 7e4a3f7ed5d54926ec671bbb13e171cfe179cc50 ] We are currently treating any non-zero return value from btrfs_next_leaf() the same way, by going to the code that inserts a new checksum item in the tree. However if btrfs_next_leaf() returns an error (a value < 0), we should just stop and return the error, and not behave as if nothing has happened, since in that case we do not have a way to know if there is a next leaf or we are currently at the last leaf already. So fix that by returning the error from btrfs_next_leaf(). Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/file-item.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index b618ad5339ba..a88a8bf4b12c 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -887,10 +887,12 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, nritems = btrfs_header_nritems(path->nodes[0]); if (!nritems || (path->slots[0] >= nritems - 1)) { ret = btrfs_next_leaf(root, path); - if (ret == 1) + if (ret < 0) { + goto out; + } else if (ret > 0) { found_next = 1; - if (ret != 0) goto insert; + } slot = path->slots[0]; } btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot); -- 2.25.1