Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3029283pxb; Mon, 18 Oct 2021 06:56:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFXKDDmzi8DV9G9nkunGtveUD2ctUzJsfSaaZ2YFtdqSlmuSUXDr/ITZ15aVEgpgNqskb4 X-Received: by 2002:a05:6a00:1346:b0:44d:242a:8151 with SMTP id k6-20020a056a00134600b0044d242a8151mr28693733pfu.62.1634565381359; Mon, 18 Oct 2021 06:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565381; cv=none; d=google.com; s=arc-20160816; b=o9KTYh0x2I0pN/sdHj4q72gdn00F3bQUgyg9nd6HTKJfep5e/3c/cTY+LMfjpRMPXK /+cInI4gcrh0Ig0pcA3HbU8DFS5La8WBzgl3UjxcTcb6F26Cp4r6FeqbGL+kVge91/mi onkpXdXnLFM2cmI81ZUb4YfJQagT+4pPaYiZVqAwvzzlmzN+ud0Diyg16Lq8ruAGar4K kLPbptYlE9j4Lg3RSX1Fee79wqJ7tTBLwR+qjqRyxVfjWnDgDlDft7flN7GS/OSPKIsS 2NiBa5ze7t+kiXHn1nD61MwKUnBsO0xtx3UM4HPXUKIIKA5AhYn2dKNQB4BtjmZN+J9P 7haw== 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=/RpV4HApDPQeouGp2g9DI0p1Y2r2J7PUQIrt7R7XVkA=; b=dig9yWhSGwkwdN6exrOMvfRjPQ2bXaC0PyKXm/8Y/fypMl0jK8iSZb+0jaeqy2VcX4 KhcnN4jGhoD7FeLHjpxRJzj+G8ZyUDbxQWnjWaID7wNaxt5rRpxY/QTFa3JYHcxGORYA cXj57UPQnafqiCsPo91IRdh0ty/1OceJC3K465XkRw0qYFZyE2CCrE0dc3MsPG58TkIT 2zlxq9pj823VzGtExsmpTwbSNGlSKG+fNkAhMrw6kVZ2t9JDXGNElW9f9RjD1IiR8zgt 6JBaCqAf7pTaKh1JOKHFg7W2BsrijGeUNsn/TYY3Y3WzyDkRJhnMfv9bpBUkri+ASmHq 0tDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cQTywcMS; 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 s21si14179408pgk.310.2021.10.18.06.56.08; Mon, 18 Oct 2021 06:56:21 -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=cQTywcMS; 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 S232553AbhJRN5Z (ORCPT + 99 others); Mon, 18 Oct 2021 09:57:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:57702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbhJRNzT (ORCPT ); Mon, 18 Oct 2021 09:55:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 72E18619EC; Mon, 18 Oct 2021 13:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564398; bh=afczrjsrsAncSFiK5jjPxBvK2MlNPTu3B4UP02iRIxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQTywcMSZJ7o5OJittk+yj+Srx8GgjiYh5H9LhU52WUYoryxuIIBeWrHGm3pCbIts PpveLRm83atdVMq7JmSRt/MzLA/efB43+ZiYamIoV6gAUf/BP+sB9C9aDmUSJSxfs5 H4TGWiN2DlxiblXXjExsTF37vWxSh04KBhxeVES0= 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.14 031/151] btrfs: deal with errors when replaying dir entry during log replay Date: Mon, 18 Oct 2021 15:23:30 +0200 Message-Id: <20211018132341.696529082@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@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 @@ -1977,7 +1977,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 */