Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3009968pxb; Mon, 18 Oct 2021 06:32:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx47BErwxV5nniCgX68lEPB3oit8G1BbjpucXRCslLtdEKLb+XXJbvwJhco1favNN28CII/ X-Received: by 2002:aa7:8f28:0:b0:44c:f281:c261 with SMTP id y8-20020aa78f28000000b0044cf281c261mr28677656pfr.76.1634563961201; Mon, 18 Oct 2021 06:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563961; cv=none; d=google.com; s=arc-20160816; b=kEuFhftDe2ul53wf6DNYzVcwxdbRy6IVWpsJTjJd7VZolYyNZ/V8Q+EzfrXYYQUFWx t/PpMe0+9uGMYzUhRQ01Jv8XxUdITsDI9WEquplv1BpBN0ZlaV3XbE6BACbYfbBKDEPo 8JcA/Y0upY0CB+BucoNfU16MxrFAEwUY1g3I3NajIkVna+u0pacXsTE4RwLhT2j5F/Fb S626iVwjH+QdfNwl0pzqOCNaQOleyWhDHiWYduRpA1I+WPT6CMlGIkWup0qb//bsbwGj CptQaz385cAhHUgAAcTKRHM9RjQPpSjNC9YI3nODu8cvDuQI1jS4WbC3PqQXVh2M61BO jTDw== 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=nBmEJibRnqkCByt77WHIyiSfXiMvt28w1Yfr0rRaX7c=; b=ji9qWIqauz7kLOm8HBd0NBHnurvu/fPniKRnUt0SI7UXsMCG7L0jXDJzUp0AkHrmnT GVLCDemkph+qssD2QdPRXKnMGLnRMjWikY9xEt+OGi8GptDtsOz/8ohQ5GoXHwJ0w/2y 4CnoSgwGthCvmoEppDUSpQBRvk2gX+t7BGQNfxwmn0OiE0YWCCfgWLuZVYXtvL6y0zkq rF1hOYw/WZ6WHNNf7X+2VzybcfDlKUB2y9lERK7fiTfgPlgRQXdScbmCk/yt2W7ih1Xh p47kp5tptHAVG/rj4ojHb0ODKkMCG+qmkj95UDi1FzQiXD4XCfhxfsDMCExdqSNS8DB0 ijTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1TY9KxkD; 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 e2si17883331pjr.21.2021.10.18.06.32.28; Mon, 18 Oct 2021 06:32:41 -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=1TY9KxkD; 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 S232216AbhJRNc1 (ORCPT + 99 others); Mon, 18 Oct 2021 09:32:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbhJRNaf (ORCPT ); Mon, 18 Oct 2021 09:30:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 952BF61374; Mon, 18 Oct 2021 13:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563695; bh=PL84pX1c/SYmOTMDdk2tNqwEo98/KqHlko0wlc0Nmoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1TY9KxkDldjIOxbAh3SYFkAYcDAUjTb1DDmDaBTGApnGhEPMaMIWb5k/JsOa4RIlK rCjMwQZfvWNPfk1aZ5NKqbLJ7O3XRsrIxuXaluM6STSnAVOPPXGGQBOQ8xl2P4uZSD SZlVBQHfpP4Q/5oLEVGMPy2qSKLDOGZyILA4DOGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 4.19 08/50] btrfs: deal with errors when adding inode reference during log replay Date: Mon, 18 Oct 2021 15:24:15 +0200 Message-Id: <20211018132326.808243379@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132326.529486647@linuxfoundation.org> References: <20211018132326.529486647@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 52db77791fe24538c8aa2a183248399715f6b380 upstream. At __inode_add_ref(), we 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, 7 insertions(+), 2 deletions(-) --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -1141,7 +1141,10 @@ next: /* look for a conflicting sequence number */ di = btrfs_lookup_dir_index_item(trans, root, path, btrfs_ino(dir), ref_index, name, namelen, 0); - if (di && !IS_ERR(di)) { + if (IS_ERR(di)) { + if (PTR_ERR(di) != -ENOENT) + return PTR_ERR(di); + } else if (di) { ret = drop_one_dir_item(trans, root, path, dir, di); if (ret) return ret; @@ -1151,7 +1154,9 @@ next: /* look for a conflicing name */ di = btrfs_lookup_dir_item(trans, root, path, btrfs_ino(dir), name, namelen, 0); - if (di && !IS_ERR(di)) { + if (IS_ERR(di)) { + return PTR_ERR(di); + } else if (di) { ret = drop_one_dir_item(trans, root, path, dir, di); if (ret) return ret;