Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3411810rwa; Tue, 23 Aug 2022 04:27:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR5YiHUUXLnTmGyRZni54FVcnq+YyDHQiWrkX0gtWiEJI9HmQHIlI0b47wcfteVky1BkMS1S X-Received: by 2002:a17:90a:c782:b0:1fb:307f:7cbd with SMTP id gn2-20020a17090ac78200b001fb307f7cbdmr2829957pjb.14.1661254076330; Tue, 23 Aug 2022 04:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254076; cv=none; d=google.com; s=arc-20160816; b=aYhZ4aCozJfJZtUZ8QcV2BOhjpNojv7hGcAQhSY0YvO2hbbB2PXr3Lb2M891/MI82G nx8+cHi0SAL8pM5ckonVGfpmuhu7ru/MbiWHjQc1SxCdEUm8TKK7yZHdoDoGTEKWvqsK qIY+F5FNtHIzgJ5E8CCoDtJLZbb5Ha1K+a4v9DOz2JXfX4c4rEnrpp9a6RUZEusU421z 3QA6lErqqCxZWCHNbYW7E3ym5Gl04aPUAII39LoVuPGxQis/u1NNyByo1MiL/L7CMOXl iYfqrAyKEFZGZqKRlxziEJqMLe+3QxQ3rSm2j8HLSG3FwSCGU3btwT85DWVzMZeXQJ29 qWVw== 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=ph02Z6kQsaMVZ/DFw0CIjQxOQzs8mWj+U2t7NCI2i7g=; b=ZSRvhCnC0QQxDZtEovSPn1mwytfTrzf0Wj14VOBK/IiiHgi6ZIUCYeqRbaueokkYLK QAlkuo2m7xBxi5JpViqhHfj/+xUHGY7ZbV4g03A9CV2/IAGFH6o+i69Gv3WC/mL6vFlJ FnjM23dq5QshWFfdQOPBqfghoOePe94IsIqg5tq7j5yz1XiWyJXLt0WPUp/vA/Hlr1Kh Fanw39llsSfAxSVseQNgT9q3UVejd3lk29mzsB3FUixQ+oy0a2Vk7JI5JEr9mzHTl0bL mxaN6JMZB7d/DRieHnihPMXodqkb4fUKiiRmQ7JSghtB8Ni3RwqvToT/zS/0N11N0yP8 vwaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ETy0rjJn; 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 129-20020a630487000000b0041dcd13c180si14711137pge.366.2022.08.23.04.27.44; Tue, 23 Aug 2022 04:27:56 -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=ETy0rjJn; 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 S1354525AbiHWKaO (ORCPT + 99 others); Tue, 23 Aug 2022 06:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353488AbiHWKNi (ORCPT ); Tue, 23 Aug 2022 06:13:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0F86BCDF; Tue, 23 Aug 2022 01:59:43 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1D9CD6155E; Tue, 23 Aug 2022 08:59:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C06FC433C1; Tue, 23 Aug 2022 08:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245182; bh=PgyVFjM/sJzqAes88J3V0mrgRt5TxTayDfFQcvuLosU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ETy0rjJnSnG5In2P4BeGlbzOPdCiI/iWAWHUPcWL6ze1BFTbRGRaWZp3m4Rb9G2y8 V1zJVOJr4fMAj1MALrdlpLqQCVh8r3GzeVXDQYMd5BcDaELtq34MU9R17bBFdJ5O6g at5ffxj+Nf4hhI9NOoyQj34BZTB32TDoHB0sJabM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Brian Foster , "Darrick J. Wong" , Christoph Hellwig , Dave Chinner , Leah Rumancik Subject: [PATCH 5.15 242/244] xfs: fix soft lockup via spinning in filestream ag selection loop Date: Tue, 23 Aug 2022 10:26:41 +0200 Message-Id: <20220823080107.705143443@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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: Brian Foster [ Upstream commit f650df7171b882dca737ddbbeb414100b31f16af ] The filestream AG selection loop uses pagf data to aid in AG selection, which depends on pagf initialization. If the in-core structure is not initialized, the caller invokes the AGF read path to do so and carries on. If another task enters the loop and finds a pagf init already in progress, the AGF read returns -EAGAIN and the task continues the loop. This does not increment the current ag index, however, which means the task spins on the current AGF buffer until unlocked. If the AGF read I/O submitted by the initial task happens to be delayed for whatever reason, this results in soft lockup warnings via the spinning task. This is reproduced by xfs/170. To avoid this problem, fix the AGF trylock failure path to properly iterate to the next AG. If a task iterates all AGs without making progress, the trylock behavior is dropped in favor of blocking locks and thus a soft lockup is no longer possible. Fixes: f48e2df8a877ca1c ("xfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers") Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner Signed-off-by: Leah Rumancik Acked-by: Darrick J. Wong Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_filestream.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c @@ -128,11 +128,12 @@ xfs_filestream_pick_ag( if (!pag->pagf_init) { err = xfs_alloc_pagf_init(mp, NULL, ag, trylock); if (err) { - xfs_perag_put(pag); - if (err != -EAGAIN) + if (err != -EAGAIN) { + xfs_perag_put(pag); return err; + } /* Couldn't lock the AGF, skip this AG. */ - continue; + goto next_ag; } }