Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3016253pxb; Mon, 18 Oct 2021 06:40:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi11imRj+IsH0BGO7UtNHnxhj8gNsxp8it6yook5jmCnCiujEVyTpUxlIpAdp3Sp60acQy X-Received: by 2002:a63:1d23:: with SMTP id d35mr23545755pgd.357.1634564404287; Mon, 18 Oct 2021 06:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564404; cv=none; d=google.com; s=arc-20160816; b=AB53yNK62dYCIbcPR4XsK+7fWT2bA+sJU3CBat9qku9Oafq4g1wVrM//bDl3r69n06 XGfPt9BrulCAi9InmgKeWhZDd5gH7u4wsbgaK/tZiG+SD3aFO4S0ZIHLTvfrGE/QVlQ7 0nuTXTKW69oU8E0x58x0vVL7yMdtBL8QAnR45o0n8ep4vR+1NlUlY7asr0Y5OotIDOZr P5Z9YDyOKwcvCLp8p9ayTJwXIouKR0FC4X7Kmq+nst2f+kCvdvFJ7Ih574U0P2HWw5a4 sKlz2EW0KfGvozhjGKQqoTkKiIjTHYkxjeePUcnktLlaCPE81jMdNPEjCVndDuwB78C1 DcLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R8aAfURK7+aBHjrhRcOTMgkXsn7aQvRn8Wgj5X3HWcc=; b=PP7NsnmlETadNYiZYeAikhP2i7bcxIhjbasDG2jizsMBjf6kTFxvOHLCVm5sYOW3jc j+WsymQlIInWY3IVa7MofMks75Rkkr8em7LwaksnwOSCyvfR+R92lOFKxG5UV8Aaynj+ b7o2ZQ4qavhyUvuFgWhaxaaZVWzhHvcFNYLj1zpkTqyHobIhxkQ71mo1Bp19T+OmtWm0 dYDjAXV18fYw1Mqz0UVyCDci0jRYcwvdZ1dY58RtOKs5YpGVDLrDudskScYvb99r//cE 4UpobESVbhTgRjVFbpJ4BnseBFVVXXq/JqsL6fb0Fn1UCmWlJ/K8ccnp6ewvY5lOY31h FagA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uIgIDYq8; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id in15si2142373pjb.30.2021.10.18.06.39.50; Mon, 18 Oct 2021 06:40:04 -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=@linuxfoundation.org header.s=korg header.b=uIgIDYq8; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbhJRNjk (ORCPT + 99 others); Mon, 18 Oct 2021 09:39:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:54250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbhJRNho (ORCPT ); Mon, 18 Oct 2021 09:37:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BB3961361; Mon, 18 Oct 2021 13:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563894; bh=u1hIz46C2jmnP8H9SBlQPUIKTyk0NroVgGl4xvA6La4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uIgIDYq8OEYFltR2KoNwMXKyJ/mVD7sWze6KrpvOOLTX6TrHZ89VYQMVT8n5G6KBd K1ebbo1r4lr/qWeVcng/tbXnw01f9K4HBlDYBdOa29Sfp+7sUuBqVVXxciqzPIWpl0 BiInZdg7qVWCsICUl93y8GzyXFumCLIsv+W8Ab8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 5.4 13/69] btrfs: deal with errors when replaying dir entry during log replay Date: Mon, 18 Oct 2021 15:24:11 +0200 Message-Id: <20211018132329.886714127@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Filipe Manana commit e15ac6413745e3def00e663de00aea5a717311c1 upstream. At replay_one_one(), we are treating any error returned from btrfs_lookup_dir_item() or from btrfs_lookup_dir_index_item() as meaning that there is no existing directory entry in the fs/subvolume tree. This is not correct since we can get errors such as, for example, -EIO when reading extent buffers while searching the fs/subvolume's btree. So fix that and return the error to the caller when it is not -ENOENT. CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/tree-log.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1985,7 +1985,14 @@ static noinline int replay_one_name(stru ret = -EINVAL; goto out; } - if (IS_ERR_OR_NULL(dst_di)) { + + if (dst_di == ERR_PTR(-ENOENT)) + dst_di = NULL; + + if (IS_ERR(dst_di)) { + ret = PTR_ERR(dst_di); + goto out; + } else if (!dst_di) { /* we need a sequence number to insert, so we only * do inserts for the BTRFS_DIR_INDEX_KEY types */