Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3009410pxb; Mon, 18 Oct 2021 06:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLg5Ak7F26y8X6jZ9rImamHUd5Iqle1xLkqFJlOUT7VdPHKDKr6lkG9EHLZUtZBiqHYQ9z X-Received: by 2002:a17:90a:a513:: with SMTP id a19mr47995337pjq.26.1634563924205; Mon, 18 Oct 2021 06:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563924; cv=none; d=google.com; s=arc-20160816; b=r98W43KjbJpvcyrAfILnfKchjVKEi+N66hYWE1P8RaIFYuuq00LkEpBoRUYlii6fqY Lv+CTP9lyCipf+q3E+fmxFumdhQQSFg5VvY74BEWEtVbExYqdrLqXfDgLGZBlDNsQnba rKyyO2EHuwvzvcX19OenV55PdfF5nZDuyUaFbgReDlMwJ/1iCgap1mv/RmTAkLCTYeSK cpXU7tHzqxZRUstiHDzkEYK6hi2+2LQXkDwZhrTsmaiFpRwi1VU3pynDgCpLMRLRYTxp mHKlkuTbfk//BDrPH26jhhwqquwq2503ul7rWnoCBuRlMOXe5x4Nr4LBsSUAj/4TX6o3 bx8w== 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=rQNyUpHECDjgU5hU2sJ3ZFHSYrjfEbM5hZyJxiFUIII=; b=KRnFrizzi2Xc/0smOp9dESF/x1q+lJ81M8pKvDPwnmm5/JGxzctebpofqjL+Qyfgl/ LdvGNwsJ3J54nICodRakLHdaGCbeqIv4JzxNYem7s/H8KVFRSxLGinvh3Et36Lb4SUvx qoenl3rDXzsnlQdkKxAeH75a4A8m9KNz+b8Cu/bdFulyBzrF+45P3htZyLZZaFiUelOf xcfgvE+zNKT+N23OtAkQwVDhb/kToDeOrJcgkpxBTG961g9ywGu491EczqAiqvwQOOhK ogwlRudTs9KalahcH1MTVb/DtiqnqiNMeZG46yLrns9xhnSlLeL48nAcANKHz2hWAHwL YZuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZVpoB8mV; 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 p3si17524306pls.428.2021.10.18.06.31.50; Mon, 18 Oct 2021 06:32: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=ZVpoB8mV; 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 S233017AbhJRNcT (ORCPT + 99 others); Mon, 18 Oct 2021 09:32:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:44136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbhJRNaX (ORCPT ); Mon, 18 Oct 2021 09:30:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1022D6136F; Mon, 18 Oct 2021 13:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563692; bh=2Wp1Zy23ncLg73L2WZLf5Lzwqc7HJa2GFdpduRGAWU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVpoB8mVeJjxkD0y2fFzqxi/kiiAVKf1ZD9M7F/+pecsD6aMDPwur2oytai9lwivm v0PGWCE7UoE09uJ7zpZWhK4+gtj9pOD7fkCO12Q6EC4wgD1Mh6yV2c3RmKZAN63xfh s6CdtjygRrxy/7m0lC+pkitKX890zUjP3gxGTj5M= 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 07/50] btrfs: deal with errors when replaying dir entry during log replay Date: Mon, 18 Oct 2021 15:24:14 +0200 Message-Id: <20211018132326.766656666@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 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 @@ -1907,7 +1907,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 */