Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1940308imn; Mon, 1 Aug 2022 05:50:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vp8R+6D3q0UoFZLbzFfF/Qq0+1RP1Fa11QmalT98jXw4MOUYPxMeqe580eS8GQ8AMLssLn X-Received: by 2002:a17:906:6a14:b0:72b:64bd:ea2b with SMTP id qw20-20020a1709066a1400b0072b64bdea2bmr11792562ejc.680.1659358219800; Mon, 01 Aug 2022 05:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358219; cv=none; d=google.com; s=arc-20160816; b=ELVuqMGqNxEjjvOzaisvBtz3YPnUSksXk1MVE6zqFOnxB0+Serq6UmRRsjtnXK3FP4 TU37KC+/setgblCrZFIJ1ADL7Ss807ASj1nSMgFMcsNCYuVoGh1UdvMNcikIyEecWwou mTglDhYcRrtQkiMdBWkWFnTozYJbVk2exlChFg3ed37p4ok940ikyCh5a41v2KwDiVh0 9MP9guZvWFOMr5ux+nogQ3FIwMfcn3nfXgZFDFIGANx6QYEpwxw4KJJ68UhcnE2wWFS2 vdhw5zHuVWOlNR20saFF4hgMgF6TE83TkpFwF5OCs2jYEzaLabCz/ZhmUVW7ShnmaFfB 1wnw== 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=Xdssg0GHOdL+KGrEY3CPcMpVX0Q+/nxGIy7BEPZuOpw=; b=roAYOd9c3ftMfa6a7a0cYmkH8889Ltn5v79AQ9PT7G7b6p8aM3ZUzDIZh9LibpkqQz iQsBUxzccP30ZQqm5rsgeGcIgJOy+hCy8mfjKdn5t2dWC+JlvGleAE62dBJnzDHYCox8 6jUbuKYgNlnGqqyGuw3woZDMQGmd4vxkN3tJdQnoRrKlcxXRXNVnmbBtmTzWgoiuIR9m 1NeEXPP8OLlVZrEijFF42iI5DLUunyoj0fm4rKXQWY0iPD+coJZfCL7cbemhSnSxQsom tjAolJRuxbGjLYIMQDRjvJwqTXVdr6KIEpT6V5L+kVaWiswYhMmG1WWGYbPPJCYkA9qT TcjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hbEEkqeD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020a056402274c00b0043d75304959si5519284edd.2.2022.08.01.05.49.52; Mon, 01 Aug 2022 05:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hbEEkqeD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232755AbiHAL5p (ORCPT + 99 others); Mon, 1 Aug 2022 07:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232229AbiHAL4T (ORCPT ); Mon, 1 Aug 2022 07:56:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B5B481F5; Mon, 1 Aug 2022 04:51:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 98DC2CE1385; Mon, 1 Aug 2022 11:51:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 950F8C433D6; Mon, 1 Aug 2022 11:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659354704; bh=LqRV4ZfOcB+6/pOcYqDRRNAtvrtMClIZXZmClq7SeBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hbEEkqeD2Zx1uOyC5MfxhpRs7qUBdK0QiQ5fhtAleUUlv0ZyhoZl5Hfj5w4bLbhLh slOxGEtvKbTx/j+v9TQIJinVmZE7av4aPPpA77QijxjZZobSyODnesR+7BOE/24f+d JCA12tb63IiDjmpJDkvdRSbV8pLQJ9SNrAXkvoS8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Christoph Hellwig , Amir Goldstein Subject: [PATCH 5.10 56/65] xfs: fix log intent recovery ENOSPC shutdowns when inactivating inodes Date: Mon, 1 Aug 2022 13:47:13 +0200 Message-Id: <20220801114136.025531893@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114133.641770326@linuxfoundation.org> References: <20220801114133.641770326@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Darrick J. Wong" commit 81ed94751b1513fcc5978dcc06eb1f5b4e55a785 upstream. During regular operation, the xfs_inactive operations create transactions with zero block reservation because in general we're freeing space, not asking for more. The per-AG space reservations created at mount time enable us to handle expansions of the refcount btree without needing to reserve blocks to the transaction. Unfortunately, log recovery doesn't create the per-AG space reservations when intent items are being recovered. This isn't an issue for intent item recovery itself because they explicitly request blocks, but any inode inactivation that can happen during log recovery uses the same xfs_inactive paths as regular runtime. If a refcount btree expansion happens, the transaction will fail due to blk_res_used > blk_res, and we shut down the filesystem unnecessarily. Fix this problem by making per-AG reservations temporarily so that we can handle the inactivations, and releasing them at the end. This brings the recovery environment closer to the runtime environment. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Amir Goldstein Acked-by: Darrick J. Wong Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_mount.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -968,9 +968,17 @@ xfs_mountfs( /* * Finish recovering the file system. This part needed to be delayed * until after the root and real-time bitmap inodes were consistently - * read in. + * read in. Temporarily create per-AG space reservations for metadata + * btree shape changes because space freeing transactions (for inode + * inactivation) require the per-AG reservation in lieu of reserving + * blocks. */ + error = xfs_fs_reserve_ag_blocks(mp); + if (error && error == -ENOSPC) + xfs_warn(mp, + "ENOSPC reserving per-AG metadata pool, log recovery may fail."); error = xfs_log_mount_finish(mp); + xfs_fs_unreserve_ag_blocks(mp); if (error) { xfs_warn(mp, "log mount finish failed"); goto out_rtunmount;