Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp435844lqt; Thu, 18 Apr 2024 23:22:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWiSklocRqdCnc239T9gJ1k3CwAxdSnI2hodjwo4bTfW/Gd9CPwgEj/McN2JKK6cklgNVS9jmT9CDK1jyAGngSX44k+c/bxxY7peqruBw== X-Google-Smtp-Source: AGHT+IEGkvq/eZ5E0M1ViwTNSTn60TZRQDYb1+L5RKEbmd4KW7OC8p9EaHc9KVApSBOvCqCtLKW7 X-Received: by 2002:a05:690c:7084:b0:618:1dab:2f0f with SMTP id jg4-20020a05690c708400b006181dab2f0fmr1254148ywb.2.1713507747924; Thu, 18 Apr 2024 23:22:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713507747; cv=pass; d=google.com; s=arc-20160816; b=JLVvxb8rtxhANNVd6Wf3/4i90wjfgONmckoo8Ccv1BiN1yBdj3/UUfukC9vdoT911s o3E3J0b3XeAtgSaV+rwH+JRXW50YVRbGcM8FdjVx0Z3AzsBfK0Uo1YAEpNKVjnkJqMkr f1Q49zSqvdIpay6Em6ujmhlVNqJ8kWUa4g9Ihs49Q2KdXhZutQs2nknwnbVrqc1sHF1T W6UJNT0Vkq296kMkuGshWq6Hk8UBQhivK3mow2YqeyHUkFLFOnwuTNF1nKcWOCKkwXcm XvWO4vc37URpFQeZmtpkomctd21jE6w/oOD+4N7UPdifNE7VxOBNk/9XJxrlzRagQbfu zMWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=izdOcWRXS87tHASpqZ/4TYwizQ4QRqKgSdegNWHya0E=; fh=eRvJ0V1iXSRmAjJrGJXpnUpuzPk5oJ3SF3QZsqxFduk=; b=vRp+8hFz7P0rxeXqnC02kgNI9iO1vTYGcl0HwYFgvHXadxcWuw5+RE7czKlewoKgtV cGBdK7FaYuko2vxrz4qLadiGQ5+I2mDqBTpXYbizJvMNzMvZm5vfYhYC0XHMamHL/Ro/ c46WiDi1J8VUEQ0sJw5ryfZOGbws6FbEhfl2YBW5nV4JLecAXl48wE9t1ytIEk7A8f3X +UaXPbU2xPAgKG53CIQr6cT4SsgtCEqs1eP1jdQw2e8OIXrWzVQIlzB1aj+wR/e6vUU1 AHYG5jEsAZaZuRYp5xfW6V4PPmgYBkW5OCGpqNJiHJ1lvYXpYqMcgeYpQ8BjRA52PjUL MCBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-151050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h8-20020a63c008000000b005dc189d320csi2672304pgg.399.2024.04.18.23.22.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 23:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-151050-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 16838281F66 for ; Fri, 19 Apr 2024 06:22:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38CD910A31; Fri, 19 Apr 2024 06:22:12 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3724C8E0; Fri, 19 Apr 2024 06:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713507731; cv=none; b=I2KTOvfO9+yVVqxqGSfNaHtulEWb8HBmV2toCfV2/ZDH/5puLnkUZ+e+QcQIjwA4jg4ld7v6eVNw9EEV3zfqpEfQWo1wgra6o//d5fGY6cbg4wwh98awF6xWDYlDDHxPXwzxpP1LVwa0Qp9mjXF6nqkYVFqVU0fkkJ4f8f31Vgw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713507731; c=relaxed/simple; bh=OgtNH68QHSOCj2Q1N4piVftBi0yqKXVj2TEitr652PM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oQueyN0L16s+cHzvgUHhy6onI0lQl7vqCcXn4UPFX8uuNeQqKxoBoRaOMRi9OpVVHHh/a9sMJs695rQ/ANYM4LDBxJx58crr4bWFed61RBS/GlvTk1Xbm4VIHjwqfLWML9tCWVVxPZUisuO9cRJQpOse0wvsGxBiJfvRRy0Cj9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VLPcJ3b4nz1N87g; Fri, 19 Apr 2024 14:19:12 +0800 (CST) Received: from canpemm500010.china.huawei.com (unknown [7.192.105.118]) by mail.maildlp.com (Postfix) with ESMTPS id 42AF4180073; Fri, 19 Apr 2024 14:22:07 +0800 (CST) Received: from huawei.com (10.175.101.107) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 19 Apr 2024 14:22:06 +0800 From: Ye Bin To: , , , CC: , Subject: [PATCH RFC 2/2] xfs: avoid potenial alloc inode failed Date: Fri, 19 Apr 2024 14:18:48 +0800 Message-ID: <20240419061848.1032366-3-yebin10@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419061848.1032366-1-yebin10@huawei.com> References: <20240419061848.1032366-1-yebin10@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500010.china.huawei.com (7.192.105.118) As 'pag->pagf_longest' may be temporarily set to 0. When the AGF buffer lock is not held, using 'pag->pagf_longest' to determine whether the space is available will cause misjudgment. When the fragmentation is not serious and the reserved space exists, using 'pag->pagf_longest' to determine whether the space is available cannot filter out the space that really cannot be allocated. So remove judgement about 'pag->pagf_longest' in xfs_dialloc_good_ag(). Signed-off-by: Ye Bin --- fs/xfs/libxfs/xfs_ialloc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index e5ac3e5430c4..bb0ce2248386 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -1689,7 +1689,6 @@ xfs_dialloc_good_ag( { struct xfs_mount *mp = tp->t_mountp; xfs_extlen_t ineed; - xfs_extlen_t longest = 0; int needspace; int error; @@ -1717,12 +1716,7 @@ xfs_dialloc_good_ag( /* * Check that there is enough free space for the file plus a chunk of - * inodes if we need to allocate some. If this is the first pass across - * the AGs, take into account the potential space needed for alignment - * of inode chunks when checking the longest contiguous free space in - * the AG - this prevents us from getting ENOSPC because we have free - * space larger than ialloc_blks but alignment constraints prevent us - * from using it. + * inodes if we need to allocate some. * * If we can't find an AG with space for full alignment slack to be * taken into account, we must be near ENOSPC in all AGs. Hence we @@ -1742,12 +1736,9 @@ xfs_dialloc_good_ag( ineed = M_IGEO(mp)->ialloc_min_blks; if (flags && ineed > 1) ineed += M_IGEO(mp)->cluster_align; - longest = pag->pagf_longest; - if (!longest) - longest = pag->pagf_flcount > 0; needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode); - if (pag->pagf_freeblks < needspace + ineed || longest < ineed) + if (pag->pagf_freeblks < needspace + ineed) return false; return true; } -- 2.34.1