Received: from stbeehive.oraclegha.com [141.146.118.11] by magnolia with IMAP (fetchmail-6.3.26) for (single-drop); Mon, 21 Oct 2019 08:38:16 -0700 (PDT) Received: from aserp3020.oracle.com (/141.146.126.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 Oct 2019 05:14:48 -0700 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9LCD9jU013124 for ; Mon, 21 Oct 2019 12:14:47 GMT Authentication-Results: aserp3010.oracle.com; spf=none smtp.mailfrom=linux-xfs-owner@vger.kernel.org; dkim=pass header.d=redhat.com header.s=mimecast20190719; dmarc=pass header.from=redhat.com Received: from aserp2060.oracle.com (aserp2060.oracle.com [141.146.126.80]) by aserp3020.oracle.com with ESMTP id 2vrbyyjrpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Oct 2019 12:14:47 +0000 Received: from pps.filterd (aserp2060.oracle.com [127.0.0.1]) by aserp2060.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9LCDhhl056822 for ; Mon, 21 Oct 2019 12:14:47 GMT Authentication-Results: oracle.com; dkim=pass header.d=redhat.com header.s=mimecast20190719; dmarc=pass header.from=redhat.com Received: from pps.reinject (localhost [127.0.0.1]) by aserp2060.oracle.com with ESMTP id 2vsbkv116y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Oct 2019 12:14:47 +0000 Received: from aserp2060.oracle.com (aserp2060.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x9LCEkNa057544 for ; Mon, 21 Oct 2019 12:14:46 GMT Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by aserp2060.oracle.com with ESMTP id 2vsbkv116p-2; Mon, 21 Oct 2019 12:14:46 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbfJUMN1 (ORCPT + 3 others); Mon, 21 Oct 2019 08:13:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49641 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727171AbfJUMN1 (ORCPT ); Mon, 21 Oct 2019 08:13:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571660006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M2HItLcEmEbhV/6b8X36XyNthPIRotJVZaLSiaUFkis=; b=RYEBouxA+PvCj+Txe2x02N9O2idupVZEIMgwZFxOJzAYZOiNLGjaQYkKcJg6QfXgVf1RHh E0oWDX2Ou9NeoBoBp2v5S3mcak0qAAF+X39Hpc0K/b674n2+uDWg+mdaVjAHrlajrfhXkW 3LNPTRMB1t+dzIcII6p64XYg2z5K39A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-d1GQ-xLzPEGbfNPp_DANVg-1; Mon, 21 Oct 2019 08:13:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 222E05ED for ; Mon, 21 Oct 2019 12:13:24 +0000 (UTC) Received: from bfoster.bos.redhat.com (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2BA05D9E2 for ; Mon, 21 Oct 2019 12:13:23 +0000 (UTC) From: Brian Foster To: linux-xfs@vger.kernel.org Subject: [PATCH v2 1/2] xfs: cap longest free extent to maximum allocatable Date: Mon, 21 Oct 2019 08:13:21 -0400 Message-Id: <20191021121322.25659-2-bfoster@redhat.com> In-Reply-To: <20191021121322.25659-1-bfoster@redhat.com> References: <20191021121322.25659-1-bfoster@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: d1GQ-xLzPEGbfNPp_DANVg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-CLX-Shades: Deliver X-CLX-Response: 1enkXbk9GQ1xPWBEKelkXGxoaHxEKeloXGBsbEQpMWRcZGhkRCkx6FxgbGxE KWUQXelwSU2MYTW9zaHwRClhYF2lYBUJ4c1JycGlJEQp4ThdsXWJCf2VsfH9mSBEKeUwXbWV+Gk lbHkFBXX4RCnlDF2hNGGtiSB57ZUh+EQpDSBcHGxoRCkNZFwcbGh8RCllNF2dmchEKWUkXGnEaE Bp3BhgSGXEcHR4QGncGGBoGGhEKWV4XbGx5EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNO F1NtTEAabXJbWElifnhLfUNbZ155f0t+fX5kZGtYHGNeEQpYXBcfBBoEGxIeBx8YTxkTTxgdBRs aBBsaGgQeEgQfEBseGh8aEQpeWRd/HhpyeBEKTVwXHxkfEQpMWhdobU1NXREKTEYXb2trRmtrEQ pCTxdlcBthUh1TR1JTZREKQ1oXGBoTBBsZGAQbEhoEHB0RCkJeFxsRCkRYFx4RCkJGF21aHnpca 1N+UkB/EQpCRxdlZG4dbXtFTW5zGhEKQlwXGxEKXk4XGxEKQksXbF1iQn9lbHx/ZkgRCkJJF2xd YkJ/ZWx8f2ZIEQpCRRdpRmd4ZVNIcmxSWxEKQk4XbF1iQn9lbHx/ZkgRCkJMF2lYBUJ4c1JycGl JEQpCbBdie1lifmBPHGZfAREKQkAXbX4BUlJ8BVtTSHsRClpYFxkRCnBnF2hkWHlBXxtwZ0ccEB 4SEQpwaBdoYhhoWVJ6a1lfbxAaEQpwaBdkZWJSGF8fXV5ATRAaEQpwaBdoW39IY3lcfFxrQhAaE QpwaBdsWHhaRHlIHBwaBRAaEQpwaBdvZV0bf1MBfXB/ARAaEQpwZxdtcn5ve05yb0kSaRAaEQpw bBdhU1NuUgV+U0llUxAdGhEKbX4XGhEKWE0XSxEg X-Proofpoint-Spam-Details: rule=safe policy=default score=0 classifier=donotscan adjust=0 reason=safe scancount=2 engine=8.0.1-1908290000 definitions=main-1910210118 X-Spam: OrgSafeList X-SpamRule: orgsafelist X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=11 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910210118 From: Dave Chinner Cap longest extent to the largest we can allocate based on limits calculated at mount time. Dynamic state (such as finobt blocks) can result in the longest free extent exceeding the size we can allocate, and that results in failure to align full AG allocations when the AG is empty. Result: xfs_io-4413 [003] 426.412459: xfs_alloc_vextent_loopfailed: dev 8:96 agn= o 0 agbno 32 minlen 243968 maxlen 244000 mod 0 prod 1 minleft 1 total 26214= 8 alignment 32 minalignslop 0 len 0 type NEAR_BNO otype START_BNO wasdel 0 = wasfromfl 0 resv 0 datatype 0x5 firstblock 0xffffffffffffffff minlen and maxlen are now separated by the alignment size, and allocation fails because args.total > free space in the AG. [bfoster: Added xfs_bmap_btalloc() changes.] Signed-off-by: Dave Chinner Signed-off-by: Carlos Maiolino Signed-off-by: Brian Foster --- fs/xfs/libxfs/xfs_alloc.c | 3 ++- fs/xfs/libxfs/xfs_bmap.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 533b04aaf6f6..9dead25d2e70 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -1989,7 +1989,8 @@ xfs_alloc_longest_free_extent( =09 * reservations and AGFL rules in place, we can return this extent. =09 */ =09if (pag->pagf_longest > delta) -=09=09return pag->pagf_longest - delta; +=09=09return min_t(xfs_extlen_t, pag->pag_mount->m_ag_max_usable, +=09=09=09=09pag->pagf_longest - delta); =20 =09/* Otherwise, let the caller try for 1 block if there's space. */ =09return pag->pagf_flcount > 0 || pag->pagf_longest > 0; diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 02469d59c787..c118577deaa9 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3500,13 +3500,11 @@ xfs_bmap_btalloc( =09=09=09args.mod =3D args.prod - args.mod; =09} =09/* -=09 * If we are not low on available data blocks, and the -=09 * underlying logical volume manager is a stripe, and -=09 * the file offset is zero then try to allocate data -=09 * blocks on stripe unit boundary. -=09 * NOTE: ap->aeof is only set if the allocation length -=09 * is >=3D the stripe unit and the allocation offset is -=09 * at the end of file. +=09 * If we are not low on available data blocks, and the underlying +=09 * logical volume manager is a stripe, and the file offset is zero then +=09 * try to allocate data blocks on stripe unit boundary. NOTE: ap->aeof +=09 * is only set if the allocation length is >=3D the stripe unit and the +=09 * allocation offset is at the end of file. =09 */ =09if (!(ap->tp->t_flags & XFS_TRANS_LOWMODE) && ap->aeof) { =09=09if (!ap->offset) { @@ -3514,9 +3512,11 @@ xfs_bmap_btalloc( =09=09=09atype =3D args.type; =09=09=09isaligned =3D 1; =09=09=09/* -=09=09=09 * Adjust for alignment +=09=09=09 * Adjust minlen to try and preserve alignment if we +=09=09=09 * can't guarantee an aligned maxlen extent. =09=09=09 */ -=09=09=09if (blen > args.alignment && blen <=3D args.maxlen) +=09=09=09if (blen > args.alignment && +=09=09=09 blen <=3D args.maxlen + args.alignment) =09=09=09=09args.minlen =3D blen - args.alignment; =09=09=09args.minalignslop =3D 0; =09=09} else { --=20 2.20.1