From patchwork Fri Jul 5 16:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725352 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 A24FE535C8; Fri, 5 Jul 2024 16:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196724; cv=fail; b=M1xaEgrTQAwZRfw7MFFviRGKK8y64K/5y5pxCLpYONYHz2Njthffx6S3vBwERdSXmnrbre3rJ1hOqSNQ+gqRMEAu5YBf9yzUW35HYnmuC68L1yRHkQ0Wht7Mb1m+PxYkv1uVoNKBXDyKNvvmQHpmkVdp5iqRXPrlsRTvdKU9WRs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196724; c=relaxed/simple; bh=BIhb1tlAXe3dGMNw2fb2g0+Bm6xfJhg+kgSzMouCfQA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=e2W/1TCDuH1MfBkqNEtBtw0iGTZdopUVsMF9F2MZOi9H4YDRTk1qoIDzu1U4Uk1QyGg0FebChXw2B82vC0NToE7540FxaOHHDhx1C/YUdruMPJMpM7pUa8q0FGiIirai/UmRe24UhbhomkM+7lgvceu8n/73T19ROFohZKqMGhU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=db4lhmxf; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=RKyTLdZQ; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="db4lhmxf"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="RKyTLdZQ" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMVpv008309; Fri, 5 Jul 2024 16:25:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=LUyyuu3eE74t0vP7mPsxmZ84L4y5F8i5c53pdB99H2U=; b= db4lhmxf1Pw7/F0Wbcq+aq1r473tPak4roT29doQmWyM0L+DoUOu5Mntzq/fd8Am FLHwMryjQJ8dCaG814n7jy3BecqV1YAEsyLhzlv6k0ao2Q9c5CLFYE5SNqKpEvrM 0i6ubIzp5sw1VXnCMbzfbR9/xAad7RlmhGYA3v7bxIqAZNMjV9nzy58B/F/1BtVd yGYnIGazws+ssody/EvlM+9sAk4aps45uUn1rGY0MVWVFFT0uKS9EaN3ctoPAKZ6 Zw+vyag842F/WJ65tsKFaFtgj8/W5rADZUPZT1q5VSqYUT+bFgw96mQnpvIyvTbB Ln/fU7bQK5ujyaxRFi+yKg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40292347kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:12 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465FUrPJ010327; Fri, 5 Jul 2024 16:25:11 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4028qhwsmh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mo8xfAuu+MaSsNwFuUhiVCqbGYwbCWZfiF9mFDJArD8nNeKewimp0CfXnu06KfdniYYhW1Oi+YCSQYUlSCa67hRChz6Ue3jvhXW2i3fjqASULY7DyOz6aybiavLpmfAWSUZYWzXGMdBOoQaCot08JzmeO1PeaG4UpIbpdjAXv9MP/yjW7ALTmgClSbbwx+Gx5bM7+cKRogL4iMrld8KKd8IF8gtgril48jCGLrmyDUS36y1n+L6oT8lkQLWpaTRvU5fPJYcLr/1AU85eLs0tCHGurYN9jii1cIlLHjsNNsHCl3Hvmxe/rRYjMiGo6eYKp7fBpaW402BwXuEk3is9Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LUyyuu3eE74t0vP7mPsxmZ84L4y5F8i5c53pdB99H2U=; b=VXSkrWou8esX7fweXk4tlkoJefaDJWz2N+D+iJ1+CcSvj9jyMy45B4bwcBUARkpEXVrjkA6yPP3DBBp1RdxOVR9+2lSBLvAP14PuROaQMT1e7YmmKgnEBMJVdU33F6goppIGewfFBGDemJF/4GVFMc/T6qEjT5ZcgbvLITrpD5HVvldZ6z0cmQTrCxKSiS0UmS0iG8XULP7j6ZcWun2YhBguga1jNcmGBmJN7M7jlUXbh/0WppthjJszQk/bEv86zw7c5rWfPHJ+v7b8NWVLpiYxR9Ezuyewjr4R0AM6SKnqdzMhY95CFQKEnC9TAzpP9VU048qKpZD6kFDKUVMutw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LUyyuu3eE74t0vP7mPsxmZ84L4y5F8i5c53pdB99H2U=; b=RKyTLdZQfLbQzv0qR5YpoSpAIapk+9Ql0DaqGlS30v7w0XH5xGQiX4qan1AgPnDvAFuKOpJr0eBjgWsDSMNuAwwVmFiD3VfHonQWoCvF6vdM112UvVKTgiIxi75Gbhn45MxHVff3oN96Wr5NjHR76cNTwPEr9B2pbRUfTTjyO6A= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:10 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:10 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 01/13] xfs: only allow minlen allocations when near ENOSPC Date: Fri, 5 Jul 2024 16:24:38 +0000 Message-Id: <20240705162450.3481169-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR1501CA0009.namprd15.prod.outlook.com (2603:10b6:207:17::22) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cbe74f1-9d21-48e9-efc8-08dc9d0f0a36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: G9syCrLOgxMd5GoJCG2MrEXaUWjaw65Px3blHS3kHJmYVhHagGwlEkKDOYETuNNCgw2zi1UZC5XG5JhCliDvUi12Kw7qP7sKYUhN+/TVf6zYi4tkOfaQ5dTlAXZ5JytWxforJD/Vkk3UxcChi4BaEaUU6KrHZQc6nElQSnuk8eWTbQCC+Gl9CT3B5UoCuZ6oHgzZ5Mx/IK7cJNAHiDtL1G0/6WWNNhviH1jZPL2/YaSSKQCUpNtkXiDsc2TFxYgGN1HlPJVxzOyUdfVYzWGXFFa0bkV6fGZlZNCz3t+CllMtt6mYn4d0a40HCDZ7quFQbl3z9q2j+mesjVZ1xPUvQLwMu9W4Et94x4pUktWin8Q+qo6vIb3Giag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namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tPYjjobDayw56KEUWgHVfd7WLAtW4prQNpeT5zItcgWE2QHoiLgMqXbz0t47majsF579ZLHcHGc9kN6KJQOvJr18CSdJmWw1SAdFke8oX2aJc+YJcwwWO23saTFcBTM12GXOvATDJv3fG+jC0oEOlLUlhEYWoXuO0JeS222PZe9GQcEr/uWKvRt/kONS6pfKeArD/1e+XZavKxWic7PiEwovdi+xA+N98Rgb/zQVcwmaVKGHezSOix6Qujl1dOynK8Ol4TmfNZnDW2pyepA+wP1GfhWdMxV0K7kli6HtA5d6EUnH1zPaMAo0+Bqg4ffDJMiIhA87aUBpgkCsKJrYIKN1MUPUOxuYn4AUrmApRkky8z/R+YEQ+vImAOGvIRuXUxcadkH6VvYGHdQEbSYuV8feo8uKxrjdpEEKcLY6VF8Zhc/VrFEBi4hg7XW6jmbevvrQcOuwLdvAfqd6LSRRgUivwBdmz3n3ZgzAl0nhpLy6ashNhfb2t8mmX3ZaPzulLwrLbltXxFA7rZ7jn2KaNWe9iXmboHgGn9KfqxPNwRON/KBd+ggtdpfrJBq01DrFSFZ33i1zIPr/e0qNLawxogh79AutBba9BdPV6I/lpyj7gWZp2EvwnQGh2JbAiWauDXEiMQbd/RfG5dX5+iGrRbynZqETe0oU4X//FpLvxmVpTo7QslxNSNRAw/UdQpuYqn1Fmvu2Re2B2/W25HwANeMkPGjpoB4Eo9neJzI0DTyO/ZUywHWXE9fiQ8fMCH/qil5FbACZJYeFCfHKrUKsYT0wcpn3kdD96NjU2pndDj0h8+gKg0hz1Af+DcSX7CD6uJqMqcsTeYPWq0UDyCjxVwsUDpkSfwo2ivi4VeiWkfxD6MMCaSgL+rg7Sx0pAJBsc+rjat2V4vSfwcuiX6qSgJKn9S3mpQFm8bpYhHe3LOjp56v7euS8w3gso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RcLe1KuMJ4l/0vqIqOiWKLLJUgc10zk8g9cN/T0DespIVJYgblFwTmInPc0f4oY6H/wp/x8jFTMu6DChceA5SBjPxnkCGLRD5RKiQTSo4XuEbZATrGSrsGdItTNoY4YOnGJdM1DXdqL+hi78+n7b2Johy9iSf4sLDIUSGjmPqUxeRljA/pspr0+KMNyOrUeFOmyXVoWTZqe2IEFch7VCBw3XxX+shz7EsRdcQDlYz5Qeno+/TnXOkfGl/ZfX5I9ayV18MeKQ1Mw6YjYICMLRVBswotwjxObkBNELshtyk0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cbe74f1-9d21-48e9-efc8-08dc9d0f0a36 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:10.2619 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Re/x9jVT8qBfDyMuCtardUIes8vl8lituep/+F5ADzIUCpZGh8NlCDlJDyXXQXf8p9vyT2jgvV6XnI5BY9FaCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: aMCqidP7umkMoZwc2KOgZ8omK0-TOx7P X-Proofpoint-ORIG-GUID: aMCqidP7umkMoZwc2KOgZ8omK0-TOx7P From: Dave Chinner When we are near ENOSPC and don't have enough free space for an args->maxlen allocation, xfs_alloc_space_available() will trim args->maxlen to equal the available space. However, this function has only checked that there is enough contiguous free space for an aligned args->minlen allocation to succeed. Hence there is no guarantee that an args->maxlen allocation will succeed, nor that the available space will allow for correct alignment of an args->maxlen allocation. Further, by trimming args->maxlen arbitrarily, it breaks an assumption made in xfs_alloc_fix_len() that if the caller wants aligned allocation, then args->maxlen will be set to an aligned value. It then skips the tail alignment and so we end up with extents that aren't aligned to extent size hint boundaries as we approach ENOSPC. To avoid this problem, don't reduce args->maxlen by some random, arbitrary amount. If args->maxlen is too large for the available space, reduce the allocation to a minlen allocation as we know we have contiguous free space available for this to succeed and always be correctly aligned. Signed-off-by: Dave Chinner Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 63315ddc46c6..74f0a3656458 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2409,14 +2409,23 @@ xfs_alloc_space_available( if (available < (int)max(args->total, alloc_len)) return false; + if (flags & XFS_ALLOC_FLAG_CHECK) + return true; + /* - * Clamp maxlen to the amount of free space available for the actual - * extent allocation. + * If we can't do a maxlen allocation, then we must reduce the size of + * the allocation to match the available free space. We know how big + * the largest contiguous free space we can allocate is, so that's our + * upper bound. However, we don't exaclty know what alignment/size + * constraints have been placed on the allocation, so we can't + * arbitrarily select some new max size. Hence make this a minlen + * allocation as we know that will definitely succeed and match the + * callers alignment constraints. */ - if (available < (int)args->maxlen && !(flags & XFS_ALLOC_FLAG_CHECK)) { - args->maxlen = available; + alloc_len = args->maxlen + (args->alignment - 1) + args->minalignslop; + if (longest < alloc_len) { + args->maxlen = args->minlen; ASSERT(args->maxlen > 0); - ASSERT(args->maxlen >= args->minlen); } return true; From patchwork Fri Jul 5 16:24:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725351 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 A24C9225AE; Fri, 5 Jul 2024 16:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196724; cv=fail; b=JDkEfZCk769nOoZ6q+DGdOB0HGeZ0rJ5rRh3UqXtkMl5AEjKxT7p7nE3wheFavWuo88lKclkCW6BjNs4n6t1zr4xcQxpKTOnBW3RVK0cFArFcoUMwmxKi9Ep+/BbKNj9F958VOpClXhJJnkHITic0Nhtd1VERFVfYCRBJRIE6co= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196724; c=relaxed/simple; bh=bDIhO7cn3QNHi4OV3H+bBhu6VpbcNqgujdsIUIm7cVc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=V2RxgloOaYEbfi9sb466qHROzljoc+Nm9seBHNFvq1L4SQ0h/L91SS6lEfiarw3wdTLg3P2m9eWwZPiiMSqYPL7yvNt15xHxcHFOCnoNDhDinhduNTs4uABbd2t6/SnUOOw87ELQe7XybpFms0GmYPjSHpyIw5Wc9nQdSydaP/s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=QL4BG4QW; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Oi0VHNND; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QL4BG4QW"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Oi0VHNND" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMURg008277; Fri, 5 Jul 2024 16:25:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=N/VNfmzzzpq9WiOvw8jG5FmH9pc5+ps66GdlNYpQkjE=; b= QL4BG4QWv0Ojpt9rvwSYN1IZRl4j6KGQ/uH3QNjSy4Xr9yr7nXGuynCj3eemzpj9 C1rahphYu2qQ/DIw6yezsoHoyboUzOr8qyLpVkVE1vRS3DDCu5sVCjqfuRMsTWDf 5BL6JNIjmUmy2Ww0/ka5O55/loiNdV4enTQI9X67YllJ7PigJIQGl1GiIeCbthtH 5L4am0xOoQrhQmOQ4RQAQqI7twfgCP0d9Tz4wqrhCVY9fVhh4KlcmmAjVwYp11TH 0PLGkHXme+9zfGlOIsM1E5+uAEL63PKDgjrmRlrFoQn8nmpsM7WvCaIC3ioBZsLJ CTTkFave9wTWgmg8P6ZfKA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40292347ky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:13 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465GITIn010337; Fri, 5 Jul 2024 16:25:13 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4028qhwsnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mcdBoF8P/D9HaV0ss6nG4nvJAUB6O6qBPcJC5o2jVnRv/LJEb7yJnrYOnF6vzvxIaKLSLo/Cc0e4boLDu5R00hsX/wEPFxNFi6QxoEN/MiouHCkn6Dni8ZwiotBzPZR2yClkLePZnP8SpzIF0VGGWH/QzgQptsxeIkPe5LI7ql9rFl/rtkd6Gt9k7BpNRkV+KJF6koCXOgqwt1MUySVYIBTyDKhOAtRxiDE4w3wMS3gd0qfmp+5bvCYKvorPZRtvEaNmW5Zi8lynQbUc5SbaJRC6nrBMkmWEZz77VlQrOOnU++4gywd+fYm0RFQmlP33j/4ScJ5n4Qzw15X+Ecw2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N/VNfmzzzpq9WiOvw8jG5FmH9pc5+ps66GdlNYpQkjE=; b=E0/ukTSSAyOVxv/LzY/hmXBhXMQGf5RRAfYN650G0zAJAJbqtuU+0lJiGrMa96qhdedlJX90OvJPScWfX7ca5E9WQ0NK6Md0tJrnSnk1Ju9W61nvATBOVrfgtidWED8JGM4+89r125JbNSiLrxhXVvzLcEJwy1TUDQyyeARRiohhHznp61mIZadZVXI6HCFjUdGw541sKTS9Vdo2g0boBRa915sWMPJ2XYZgNT8Rk907o47jDGfBWzp3beiDrXhTO4YzapeJeFXdu0rTRpqKBqx36MoUTU2qXtdX1R7AsaeJloS9N2WtOFgy+BEEnXq3SdoE1vKJq+OnwCYhWUVL0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N/VNfmzzzpq9WiOvw8jG5FmH9pc5+ps66GdlNYpQkjE=; b=Oi0VHNNDRo3k81Cu4lalxzkxpgI65FNMy8IeJBUqKo0NaX0PQW8GjkLvktmTCdFRUZooMTwa4yMlNEqXDRUx0xyJZTXj+m2wSqE2kD1cU9Vdx3ostTrfpQMikSeaiHRyQvfT07d2I5Vn377pWkmcC9Ec3Bw6CHRvgccSpyQoFZw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:11 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:11 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 02/13] xfs: always tail align maxlen allocations Date: Fri, 5 Jul 2024 16:24:39 +0000 Message-Id: <20240705162450.3481169-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR1501CA0010.namprd15.prod.outlook.com (2603:10b6:207:17::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: f27ba29e-4b1b-4635-d71f-08dc9d0f0aed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: tyeB3mnlZAYDmoNKwhj6VBQNP54yCN2D/ZEobIx2wW36iKc9sj5BSbppBg8GJdSZMHUnC4xUQxwoWA7TuzgwkEvegAK8HjaPwU1o3pd9M3dkWvTUvXtdjbZGuHei8iYVBitURuadGjRg9tGTGVBqb52Tis03hKnf2ho0VitIL1MTRa2NLjIOYocKGHtMJRpnle915nVfSc4HSwD5MprjhChc9nBoHVHGUxzWAHhOEJGHwOC213R4TLLoe7kFAxYsuueyBmMX6TDYudv6kAtucKwBTv9ErOOQmOkt7RniKMG7MSA6VdAwvAbJHNBDB4s33z73T1J833trYmszrX3YkVd0CVly1x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I;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4+r2vEQLD8puxyWQ+mJ+KXgHalBhxV9+twldLvwmNtHPMSa76yLZCpuQgozVyjFrCfek8S/2xt5pKPphzYn8YHdA2Mt1RD5khBqn4XCNfETSbEpTqDSm0kGovBwWjm+9UZMCeLs0zv0MjPxU/ytoctSpdniL5WVbfloXOwbzUBoPozuKPNHdy6fYKQeP6t2Xjlh4fNPnFljlQ65yJVzFTLEyKiuAHx8dG0fYnItZdvsaqcQbtT9UM+x//OyWPQyvGEm9+BAznJdO+YLzK2GjSikcPau27zRY7VRSAtmUqtn0uLEVe6R/Gsq9b/jLvLb3O869rJtEX8PXcOhJdPgxM9+BSHJ9DnRrMGka29txfdXkJCtAmGqG+ReqS34qMb4luXELH8Cj05Gw9WBrxJYJrcZNw2yeUrQWxrmmuAqy6EN0HHQMCupb+VE7pjV+kadY12GwJnKXdzV1tB5Ac9a/EMl3vOThZYdPPSzp2kTLwFqLYeaB8UJRQDgwd4X+KOuPxHKm28LTgizFwSvO3QtFo/cpTE2t717M1RIXt6R9W/6IcP/ugeiYSLDoTeTV3GcGYrQrqBXCzT+x8PHMmhKC8BDxTsQOUTmHFCwDB9UN4scssF5cZx0riMbxz6lP5AP3180dkyNwfzBVR0W+W9R0X3kM1CS3OZtLWxWRWtZlE1JDB1moBFt4igt2nY+PSyyi2+FRXOVYUCuESQTor9yo51uYQVt7o5Lg0TTrBve4+5IemnerpS1nsffVGQZ8QmtUNdpiK8lzxkItYDXSmGJwbybTqmo3LJBEIAxmecXJrG/Qjhe6/UAb2+EQyzIv5LJpjjwonCzmepFyV32NtiJboKAKlIuHvOIRDOfw8VRGLNbLOxeBBPhWE24Rg65UvOSA5OFgqpD4gq0oqxPMaVZmFdFHNEBP01Ljnp/6cxs63dhT4o7z41yfSTwRArumDvhlZYMzenapcJ+MC+hef3e0/c1r1aOfPWLHopfbpUQz0lsxlXM4EZo1Yl+ivY6hOR073JooN5GrENETh9/+nQlT+9Yj3bmpLNbLiqv91I9ElhIljt0/oruRXusM8uAfc8e0IcVfMImIcBjfA50O1QfdrG8X3rQV/1ps9yG3IWcFue60Dr2g9p8W3Y0nfZWlgs418yC6mlhsiI6dv8hbIn7/klqSmAFiFoR7ybsSwU5LZ6X+FnKSmiQReV9p+71YK1W+8/NP0PH8EnVK7eB9J2PJ3CaZyWTVnvMVi7sszRNOVwTfEei8DzzOk5B0OMykXlSj1HKm9okBQds9SzxLxfuqYePy6tJz1xwZgcym5ALjnYYIXD7NSIsBMRj6nZUdlRx6BVaFGckVMAuBVtiFKXjkG8TxB5UV8nuCN5WlIyU9GCsV1ex86aO9sQb0HtUos3b1mcMc2DehEd4lD55KeIEhLltApkifykhAaQhPndUJqfkMBKIWdN1K849883EIqrd/wAL0lp+UUP499US0wafOXbg3PQQve7afplmXTuvpiC/ewh6q0UbJt1SKHXoiZKbYixgXCMZEKRi/pdBPsJGh1gMR7183ARhzxzz6GNX8XekRsPMiP2h4cpLRkArev8lo/n0Srhkx7BXnJpupAFYxPg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: z5dWv1nh7ivfkGIDAl3logMRpCwYf56Xo2aZk30dMcePzank/gSgguSzpmHWJLh/pXyystOMCF9cnFt6TAON0qXLtWYeoQqgO++zGsScXnBuX8Y8QNm3X6afEDsrNwTXEhsJmcg6N1yomfneLHQ5QG6/28cdgH45Gtg80OgsaIOHmJkYy5bIRCzEEE5suXRaeMgOYWqfOMZ4FyZ7S2zl2OWWklszulc2VIUsnjwhyHgsVDgzEGpPIGEq0iPuRiA9x/ICK6kRIe+OIKQMB4d21/D4k2QQpsYGKS4tyid7XBG6S1IE0oEiGBZatR1Gk9PGDrGrYD3y7rHIGbqHJCU0zLBDLUnJ3VtKdh/MjYoh/RZHGN8bxVSVXhwyaAlK8u51MSwareuK0VPAJn1lFh6MhCtsABhkibIRTY4AHj/0w3hdRFA6anCHO4d9ixJafWzQWZNuZ2/15NVg5d52ZVn2EUYD89FJz/EV1ijJeCW8wD9zpeuRZL5XkqIUn7asmVvdDoXnwvHs+uR/UdWLb4ySs+78+mTHrAAPPcVbyK46XALskQh7SQyG+GiMPnLo4wW2SEzkSWf9RMEqbJqtJWPe//vNyJjy6T/VeGlfa/U6dss= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f27ba29e-4b1b-4635-d71f-08dc9d0f0aed X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:11.4140 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RgG0vYmvFKNuX/52vTnxpO69TQmHwSTwkhc+gI6VI120eExgbYZTSzpIMKRB+pInvpXRjbs90M6hFqSCXZJbQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: YcV5rCAk8JOL0SLA26KsXeJaj-oYmDoL X-Proofpoint-ORIG-GUID: YcV5rCAk8JOL0SLA26KsXeJaj-oYmDoL From: Dave Chinner When we do a large allocation, the core free space allocation code assumes that args->maxlen is aligned to args->prod/args->mod. hence if we get a maximum sized extent allocated, it does not do tail alignment of the extent. However, this assumes that nothing modifies args->maxlen between the original allocation context setup and trimming the selected free space extent to size. This assumption has recently been found to be invalid - xfs_alloc_space_available() modifies args->maxlen in low space situations - and there may be more situations we haven't yet found like this. Force aligned allocation introduces the requirement that extents are correctly tail aligned, resulting in this occasional latent alignment failure to be reclassified from an unimportant curiousity to a must-fix bug. Removing the assumption about args->maxlen allocations always being tail aligned is trivial, and should not impact anything because args->maxlen for inodes with extent size hints configured are already aligned. Hence all this change does it avoid weird corner cases that would have resulted in unaligned extent sizes by always trimming the extent down to an aligned size. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" [provisional on v1 series comment] Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 74f0a3656458..2864520c3902 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -432,20 +432,18 @@ xfs_alloc_compute_diff( * Fix up the length, based on mod and prod. * len should be k * prod + mod for some k. * If len is too small it is returned unchanged. - * If len hits maxlen it is left alone. */ -STATIC void +static void xfs_alloc_fix_len( - xfs_alloc_arg_t *args) /* allocation argument structure */ + struct xfs_alloc_arg *args) { - xfs_extlen_t k; - xfs_extlen_t rlen; + xfs_extlen_t k; + xfs_extlen_t rlen = args->len; ASSERT(args->mod < args->prod); - rlen = args->len; ASSERT(rlen >= args->minlen); ASSERT(rlen <= args->maxlen); - if (args->prod <= 1 || rlen < args->mod || rlen == args->maxlen || + if (args->prod <= 1 || rlen < args->mod || (args->mod == 0 && rlen < args->prod)) return; k = rlen % args->prod; From patchwork Fri Jul 5 16:24:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725354 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 A7F6916DC04; Fri, 5 Jul 2024 16:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196728; cv=fail; b=uEkmPK2dZPK0iHeQyzYC1mxM/HwvY56eMCE0occWFUEk6TusYvCBiMrygPxxmbEPisZdhlebN//I1h2zEmsv6spJbWJbNBzJQni01FVwm7SRsBIsgvVNr248frFUIKwefvt0VYlR7d2Uu48qQNaD9lyF70pvvqwNoZipyM3W/X4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196728; c=relaxed/simple; bh=m9qupusLatiMcRWqxEPW+tUW8YjtqcUUn6ib7LOpjgo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=CY+MHK3MZgrsASFFww30muSDM36CUQPoorC9YTT3P5ApG4foYIP/Dg6fLWO0komN27VfvEMY9ckJo6dfnA7WJ+KxNcTLXC6p2TubPIFaMs0JKnbrUAA2n2yHui28qNG5NMIkcqlT7FjGTrcc50InRLSfFV2dY+NeFKXwJI8lNys= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=oVhkQHHb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kleoQGXV; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oVhkQHHb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kleoQGXV" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMWNG011060; Fri, 5 Jul 2024 16:25:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=mvkmdsTKbmRDYAsUlx0zwcpQYUAjXAurKY4lXK4NIvk=; b= oVhkQHHbKTj4tDpQuImUrfPOYnl3MHOw+A9pC5i2yDVKaJIcaoQ6iPAjqSrXfH2U yC6DClI6uJndMmZAlrnjN8xSxvpIdYIz6+ZDo6ZOyulWuN1Rj2imbJie/4uxe4GP kQtL9lgDQUyPZD8PQwLf/lyuqLkpUPf4BXVB2XABsG+kQA4o7Yz+hiw4gPiaRptw dpaKxf+hLdKGjP6YRR3Tm1URqoCCEa/Gp/gKtdjDAfJZbLiAKDwlPInsIsr11aZ4 /esRZ+6T8cJcNOaR/ez4ytQeJGs9AkyyYTvr/L2mrLPN7BRe5Fib01r5ylaIehB1 FcTMz/Uu5s9Fx3SgiSxogw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4028v0v9dc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:15 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465EErot035660; Fri, 5 Jul 2024 16:25:15 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qb9g3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hIWx8HV3qI0RC1Mkb0VzKiok7+oQMKIDBYqE0Rb16+GW25hcuEb48yVeh4TJYGL45CUvIFaxkpxMuA2Ra2pJRPEELA+MtCfYwX1C63ac1ke0t9tU9rBx1cA9DuA8CyHUtTyMvdhOl8W48/WLJ/l2xSf1Q3iQ4Z9g6Qhr3vKzhtBjWk+eleTuyvkjxcNGm5JPTeBjwHWghRVXvu8g0AyLm7kz1/e73y+IdmBYxYW3sPQYv3MPOL2U4TrQ2cD81MMUiKYMQYPlwHwqtUxwnmFg9V6mZ60pNWYK/1k2S9KDpFrfG0HKUFmRbGrygUo7tiFhkXl22RTyAbG2skTjUGhaFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mvkmdsTKbmRDYAsUlx0zwcpQYUAjXAurKY4lXK4NIvk=; b=EJF4I3MpJPS1dF44dvRuio7Xf8UE0fmOaSXHBGbfIRLzRVsAdQ2uAhndcAd5icXROO+zQK6atKhHfAutmHXSc+tLPYgktQz6Bg0Kwju2e3cnib5piJpguNfMttZovVU2Bk4t9kpswrouzc4N/TXlbwL4oD+5kAWv7JEDAFgaue/gICd+CMkSa5l1oCEgP6kOtFLQBLk9LAcR0TdoZx6JIm19VQ18Ca/28W7HggpADZfKhwjLlQ7KFO0VR8aH4yFx5Z6Tsl3T0T7XXjUSx9ZSkfNQSxuAA8ytsr8/fJ++BJjNw7xklJiFMIFTKkEKPUFGqOsQgXN21YrSZhgVA7yc9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mvkmdsTKbmRDYAsUlx0zwcpQYUAjXAurKY4lXK4NIvk=; b=kleoQGXVEVPI2YbmpkINF+kIUHJvTnR0zHgiAailjnTIH3/BELD8jBFPhBzlvBu7tNh2K2OWwelmXxT3y4zIQtSb3fuUpvO/RjDrzoYHGf8YVI/LwyUqV64FoqRthwXPU8SgI0ub0nxavLYjx82MPHTTZOxopHDeCxjtgL+5wTw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:12 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:12 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 03/13] xfs: simplify extent allocation alignment Date: Fri, 5 Jul 2024 16:24:40 +0000 Message-Id: <20240705162450.3481169-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR02CA0033.namprd02.prod.outlook.com (2603:10b6:207:3c::46) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cb4d5fc-86e0-45db-5633-08dc9d0f0b83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: Fv6K2qfgp/abg2HBcBPcwQDkGDy1pbFJDxBuwCF2mFPkslLh5WPXU8/Cp3ZfCtAigys7P3afdTTRjetXYLve7lrHzN3cS8FyF4nk6GW+IvFPcnZwHUReLHawoeLAuegXRdB8iGGzNd7xw0mtwYwfOCe/nTyDJzuMmn/hhq8iPq/GGxyAY0pE1TbhAjQXfLv1I/Ctjw3M0wcY/q20IA8EE1azLuLXRnjDSyl86LHawiB0I9yVKV7DMrnFa7szJ2VAw1gCAnGDjIQj7c9bEBFcSVNYz/72kPIWeX8Auxy4rxku4i6H3TVfEIgalyO7zONd9Wj8/JN8qvHtM828f57QofaKanU2lRW4ymlnfRR4PV0QSRJ7dKv0sQ3Wsi3nciCeI1R+MJMV1r+fP6mKt4YZSeUPdLIo8RfGmiQlQH9gRaxFHGKnGtDW9TXbPRaTQHxVvG9Po5y06uAVdjIg7+7+RFODUIIKbqoE0DAkbFBpVX2DpfJY21BpJTrmI4yRGvXOgC15ufG4bAXb8xgENt+ivPPtELPiVGU3/+0XTe9fqsfGhW1r94qGsj6TpAOerHImkXw234mN7RRJIYEMbwMnqAPTDe+GF4iRZmVZNeCQITdjk1k287B6XTHAVvoSx6OuQVI+yirb5Tp+b8KliAkvdlPEUWhkbCcHRb44Y/7A2gMhdLiFwJZBqaXYX1cx4SGN8O3uh3msj/9JGKuWxMl/8mNLrTGVtGW+pUBPfEzP5v035wEParQEMu7Gw78yRHbcz5Cf0fzM9xxes5erkQYVPYGIQBI9f2yb09zpbm/7fAYVipUgRPbBTPFKMLBuqqsfDkZRJYv+62U4p1OqcDB99sgc5PEEOw5MwbOXXAMYDcV1qlYTzwQ1iyFF5ko7VIbCShieazEvJ66N1EqThlnXsgjbT8uza1V20pdieKzZcnjjEUAQbWqinfmZMpIh03Xey4ePzYu+PAO+PBOP9QCXc5dWxacTkV2cMCzjlxZJAGod1ZYByxtgQI4iH86V0miPPnturri/X6nHImWytUyhh6mVFGDj95usfK89rVojIZlhk6dD470dzjn8VrJY15HPgnyCx6du1N0Q4h7UM7RH9k3ZBjtG9iRmxGIBcLyF3zDKHHXQUVnQ+gYNRmAE1LONHwYg05hN6my2y4FMCNtnNfj2xny4NT522n4p6Rg4WzVN8LIQxi12ehwDuCNfk/ocppZSjAMg1udnQyUmYTeB8ouhJapW3m9BmkysiFuvfZTnEY55dvQ0sy84EqVD4FROHHWdJInDKJYo9+TdYVk5gOdJQJnvoslN/YKHqIVbZiapRkCm0K+n6+gKOFFai4cixzG/0QpSd9kHcm+Yo8BmlA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE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0in22QFcgqh6OeVhwntYWEkR8Y5qwqcHRRpxFU2k42/dhrN+xO5bvKaAoi2VOD2V13i7fyXNJlll3vQHKSDNz5QC2RbfIlyHlwPpnSkFgp09q82JEnEyRkqYqFvjNqLfZFPuLx0xcGiLrOiMUXSJXOxvAOyz90moZk2euxHH1lLoJHRE4dzsmvwdstfBl7izd5LWl0hfSP5ooTHbCzH5xkVG00n+eBucfO5orcsCPKYu8BWEb5KBrhMlIkKDrcob4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cb4d5fc-86e0-45db-5633-08dc9d0f0b83 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:12.4473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ODbbUEtQCb+lw21DixRFkXOGfyzYDFniTRvhyN0XkUITNEOU1pB3h1wl51UDdYK0yauXdkEgk2NyQvtiO5cBMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-ORIG-GUID: qvIVJKu0oT40jc6vWQmrxqkzxaS9K3ai X-Proofpoint-GUID: qvIVJKu0oT40jc6vWQmrxqkzxaS9K3ai From: Dave Chinner We currently align extent allocation to stripe unit or stripe width. That is specified by an external parameter to the allocation code, which then manipulates the xfs_alloc_args alignment configuration in interesting ways. The args->alignment field specifies extent start alignment, but because we may be attempting non-aligned allocation first there are also slop variables that allow for those allocation attempts to account for aligned allocation if they fail. This gets much more complex as we introduce forced allocation alignment, where extent size hints are used to generate the extent start alignment. extent size hints currently only affect extent lengths (via args->prod and args->mod) and so with this change we will have two different start alignment conditions. Avoid this complexity by always using args->alignment to indicate extent start alignment, and always using args->prod/mod to indicate extent length adjustment. Signed-off-by: Dave Chinner [jpg: fixup alignslop references in xfs_trace.h and xfs_ialloc.c] Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.c | 4 +- fs/xfs/libxfs/xfs_alloc.h | 2 +- fs/xfs/libxfs/xfs_bmap.c | 95 ++++++++++++++++---------------------- fs/xfs/libxfs/xfs_ialloc.c | 10 ++-- fs/xfs/xfs_trace.h | 8 ++-- 5 files changed, 53 insertions(+), 66 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 2864520c3902..67b11e4d30ae 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2391,7 +2391,7 @@ xfs_alloc_space_available( reservation = xfs_ag_resv_needed(pag, args->resv); /* do we have enough contiguous free space for the allocation? */ - alloc_len = args->minlen + (args->alignment - 1) + args->minalignslop; + alloc_len = args->minlen + (args->alignment - 1) + args->alignslop; longest = xfs_alloc_longest_free_extent(pag, min_free, reservation); if (longest < alloc_len) return false; @@ -2420,7 +2420,7 @@ xfs_alloc_space_available( * allocation as we know that will definitely succeed and match the * callers alignment constraints. */ - alloc_len = args->maxlen + (args->alignment - 1) + args->minalignslop; + alloc_len = args->maxlen + (args->alignment - 1) + args->alignslop; if (longest < alloc_len) { args->maxlen = args->minlen; ASSERT(args->maxlen > 0); diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index 3dc8e44fea76..1e9d0bde5640 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -46,7 +46,7 @@ typedef struct xfs_alloc_arg { xfs_extlen_t minleft; /* min blocks must be left after us */ xfs_extlen_t total; /* total blocks needed in xaction */ xfs_extlen_t alignment; /* align answer to multiple of this */ - xfs_extlen_t minalignslop; /* slop for minlen+alignment calcs */ + xfs_extlen_t alignslop; /* slop for alignment calcs */ xfs_agblock_t min_agbno; /* set an agbno range for NEAR allocs */ xfs_agblock_t max_agbno; /* ... */ xfs_extlen_t len; /* output: actual size of extent */ diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 6af6f744fdd6..b5156bafb7be 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3285,6 +3285,10 @@ xfs_bmap_select_minlen( xfs_extlen_t blen) { + /* Adjust best length for extent start alignment. */ + if (blen > args->alignment) + blen -= args->alignment; + /* * Since we used XFS_ALLOC_FLAG_TRYLOCK in _longest_free_extent(), it is * possible that there is enough contiguous free space for this request. @@ -3393,35 +3397,43 @@ xfs_bmap_alloc_account( xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length); } -static int +/* + * Calculate the extent start alignment and the extent length adjustments that + * constrain this allocation. + * + * Extent start alignment is currently determined by stripe configuration and is + * carried in args->alignment, whilst extent length adjustment is determined by + * extent size hints and is carried by args->prod and args->mod. + * + * Low level allocation code is free to either ignore or override these values + * as required. + */ +static void xfs_bmap_compute_alignments( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; xfs_extlen_t align = 0; /* minimum allocation alignment */ - int stripe_align = 0; /* stripe alignment for allocation is determined by mount parameters */ if (mp->m_swidth && xfs_has_swalloc(mp)) - stripe_align = mp->m_swidth; + args->alignment = mp->m_swidth; else if (mp->m_dalign) - stripe_align = mp->m_dalign; + args->alignment = mp->m_dalign; if (ap->flags & XFS_BMAPI_COWFORK) align = xfs_get_cowextsz_hint(ap->ip); else if (ap->datatype & XFS_ALLOC_USERDATA) align = xfs_get_extsz_hint(ap->ip); + if (align) { if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, ap->eof, 0, ap->conv, &ap->offset, &ap->length)) ASSERT(0); ASSERT(ap->length); - } - /* apply extent size hints if obtained earlier */ - if (align) { args->prod = align; div_u64_rem(ap->offset, args->prod, &args->mod); if (args->mod) @@ -3436,7 +3448,6 @@ xfs_bmap_compute_alignments( args->mod = args->prod - args->mod; } - return stripe_align; } static void @@ -3508,7 +3519,7 @@ xfs_bmap_exact_minlen_extent_alloc( args.total = ap->total; args.alignment = 1; - args.minalignslop = 0; + args.alignslop = 0; args.minleft = ap->minleft; args.wasdel = ap->wasdel; @@ -3548,7 +3559,6 @@ xfs_bmap_btalloc_at_eof( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args, xfs_extlen_t blen, - int stripe_align, bool ag_only) { struct xfs_mount *mp = args->mp; @@ -3562,23 +3572,15 @@ xfs_bmap_btalloc_at_eof( * allocation. */ if (ap->offset) { - xfs_extlen_t nextminlen = 0; + xfs_extlen_t alignment = args->alignment; /* - * Compute the minlen+alignment for the next case. Set slop so - * that the value of minlen+alignment+slop doesn't go up between - * the calls. + * Compute the alignment slop for the fallback path so we ensure + * we account for the potential alignment space required by the + * fallback paths before we modify the AGF and AGFL here. */ args->alignment = 1; - if (blen > stripe_align && blen <= args->maxlen) - nextminlen = blen - stripe_align; - else - nextminlen = args->minlen; - if (nextminlen + stripe_align > args->minlen + 1) - args->minalignslop = nextminlen + stripe_align - - args->minlen - 1; - else - args->minalignslop = 0; + args->alignslop = alignment - args->alignment; if (!caller_pag) args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); @@ -3596,19 +3598,8 @@ xfs_bmap_btalloc_at_eof( * Exact allocation failed. Reset to try an aligned allocation * according to the original allocation specification. */ - args->alignment = stripe_align; - args->minlen = nextminlen; - args->minalignslop = 0; - } else { - /* - * Adjust minlen to try and preserve alignment if we - * can't guarantee an aligned maxlen extent. - */ - args->alignment = stripe_align; - if (blen > args->alignment && - blen <= args->maxlen + args->alignment) - args->minlen = blen - args->alignment; - args->minalignslop = 0; + args->alignment = alignment; + args->alignslop = 0; } if (ag_only) { @@ -3626,9 +3617,8 @@ xfs_bmap_btalloc_at_eof( return 0; /* - * Allocation failed, so turn return the allocation args to their - * original non-aligned state so the caller can proceed on allocation - * failure as if this function was never called. + * Aligned allocation failed, so all fallback paths from here drop the + * start alignment requirement as we know it will not succeed. */ args->alignment = 1; return 0; @@ -3636,7 +3626,9 @@ xfs_bmap_btalloc_at_eof( /* * We have failed multiple allocation attempts so now are in a low space - * allocation situation. Try a locality first full filesystem minimum length + * allocation situation. We give up on any attempt at aligned allocation here. + * + * Try a locality first full filesystem minimum length * allocation whilst still maintaining necessary total block reservation * requirements. * @@ -3653,6 +3645,7 @@ xfs_bmap_btalloc_low_space( { int error; + args->alignment = 1; if (args->minlen > ap->minlen) { args->minlen = ap->minlen; error = xfs_alloc_vextent_start_ag(args, ap->blkno); @@ -3672,13 +3665,11 @@ xfs_bmap_btalloc_low_space( static int xfs_bmap_btalloc_filestreams( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - int stripe_align) + struct xfs_alloc_arg *args) { xfs_extlen_t blen = 0; int error = 0; - error = xfs_filestream_select_ag(ap, args, &blen); if (error) return error; @@ -3697,8 +3688,7 @@ xfs_bmap_btalloc_filestreams( args->minlen = xfs_bmap_select_minlen(ap, args, blen); if (ap->aeof) - error = xfs_bmap_btalloc_at_eof(ap, args, blen, stripe_align, - true); + error = xfs_bmap_btalloc_at_eof(ap, args, blen, true); if (!error && args->fsbno == NULLFSBLOCK) error = xfs_alloc_vextent_near_bno(args, ap->blkno); @@ -3722,8 +3712,7 @@ xfs_bmap_btalloc_filestreams( static int xfs_bmap_btalloc_best_length( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - int stripe_align) + struct xfs_alloc_arg *args) { xfs_extlen_t blen = 0; int error; @@ -3747,8 +3736,7 @@ xfs_bmap_btalloc_best_length( * trying. */ if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { - error = xfs_bmap_btalloc_at_eof(ap, args, blen, stripe_align, - false); + error = xfs_bmap_btalloc_at_eof(ap, args, blen, false); if (error || args->fsbno != NULLFSBLOCK) return error; } @@ -3775,27 +3763,26 @@ xfs_bmap_btalloc( .resv = XFS_AG_RESV_NONE, .datatype = ap->datatype, .alignment = 1, - .minalignslop = 0, + .alignslop = 0, }; xfs_fileoff_t orig_offset; xfs_extlen_t orig_length; int error; - int stripe_align; ASSERT(ap->length); orig_offset = ap->offset; orig_length = ap->length; - stripe_align = xfs_bmap_compute_alignments(ap, &args); + xfs_bmap_compute_alignments(ap, &args); /* Trim the allocation back to the maximum an AG can fit. */ args.maxlen = min(ap->length, mp->m_ag_max_usable); if ((ap->datatype & XFS_ALLOC_USERDATA) && xfs_inode_is_filestream(ap->ip)) - error = xfs_bmap_btalloc_filestreams(ap, &args, stripe_align); + error = xfs_bmap_btalloc_filestreams(ap, &args); else - error = xfs_bmap_btalloc_best_length(ap, &args, stripe_align); + error = xfs_bmap_btalloc_best_length(ap, &args); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 14c81f227c5b..9f71a9a3a65e 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -758,12 +758,12 @@ xfs_ialloc_ag_alloc( * * For an exact allocation, alignment must be 1, * however we need to take cluster alignment into account when - * fixing up the freelist. Use the minalignslop field to - * indicate that extra blocks might be required for alignment, - * but not to use them in the actual exact allocation. + * fixing up the freelist. Use the alignslop field to indicate + * that extra blocks might be required for alignment, but not + * to use them in the actual exact allocation. */ args.alignment = 1; - args.minalignslop = igeo->cluster_align - 1; + args.alignslop = igeo->cluster_align - 1; /* Allow space for the inode btree to split. */ args.minleft = igeo->inobt_maxlevels; @@ -783,7 +783,7 @@ xfs_ialloc_ag_alloc( * on, so reset minalignslop to ensure it is not included in * subsequent requests. */ - args.minalignslop = 0; + args.alignslop = 0; } if (unlikely(args.fsbno == NULLFSBLOCK)) { diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index ba839ce6a9cf..19035aa854f9 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1808,7 +1808,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __field(xfs_extlen_t, minleft) __field(xfs_extlen_t, total) __field(xfs_extlen_t, alignment) - __field(xfs_extlen_t, minalignslop) + __field(xfs_extlen_t, alignslop) __field(xfs_extlen_t, len) __field(char, wasdel) __field(char, wasfromfl) @@ -1827,7 +1827,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->minleft = args->minleft; __entry->total = args->total; __entry->alignment = args->alignment; - __entry->minalignslop = args->minalignslop; + __entry->alignslop = args->alignslop; __entry->len = args->len; __entry->wasdel = args->wasdel; __entry->wasfromfl = args->wasfromfl; @@ -1836,7 +1836,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->highest_agno = args->tp->t_highest_agno; ), TP_printk("dev %d:%d agno 0x%x agbno 0x%x minlen %u maxlen %u mod %u " - "prod %u minleft %u total %u alignment %u minalignslop %u " + "prod %u minleft %u total %u alignment %u alignslop %u " "len %u wasdel %d wasfromfl %d resv %d " "datatype 0x%x highest_agno 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -1849,7 +1849,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->minleft, __entry->total, __entry->alignment, - __entry->minalignslop, + __entry->alignslop, __entry->len, __entry->wasdel, __entry->wasfromfl, From patchwork Fri Jul 5 16:24:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725355 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 454D116DC38; Fri, 5 Jul 2024 16:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196729; cv=fail; b=oFTOTCEzwdibM3gFZSJc30U63+HSQhUB2qxJ3iCjyelR4jJO1nAWCdu8KzoTZ2qncGtoguu25NODdBhkgHR6vW9K75PE+7BdZS95i0cquj9FGv7vsNGbmWiPx8bpWrbsW7cUnAFlFa+1NoHe/6vp5OkE5XQsc+sXm/O9RB3ccGM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196729; c=relaxed/simple; bh=dND/GHlUBFEXj0+DDCl3fAJI2QXHIFtPXp906M0Smqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h2aZfcCId+E36BF7LF/ACXBiuJwkUIWBsWdnp6vkxgPQ2acdrJFO+oNMzMQZSJ8xrqurJJteJU2c84/dLXXbcMNodRRKDRS68oO9PpuftET60qtUnoylWy9oPFtG+s6zkwnMGBy1Wa2TjaWIf151PJOCooLZk2AfjZuYk/AMeLU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=UnC/eYM0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=G76jPN3T; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UnC/eYM0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="G76jPN3T" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMVLh024638; Fri, 5 Jul 2024 16:25:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=DT7Dy2BAnYcdONpZTU9BhgRkuFjTpBYvYIoX2uX76YM=; b= UnC/eYM0HTFKLu0Xxkzk69dVT17UsU8OBN9iz0g0JmAl5B3ZgJxVOClgHpz1PhGB Txro531HAtLgf4bZyoYxEFWaLkvkPW0fq16zo24Juyj81831Z1TkZvLjeTXkI2bC iXHduZjl+aRaF1W9scq42lYdDl71n3+LOs39BgHP2XqkjxUF4odiytjR+VboQOF3 Ttcd74tGru9YTqD8PXTNEXPhJ3as1Gk8Scs4WSjIyYmnF1SdoaD5kdMCdK3U+LuJ Kgd/i1dNN7HDuU7TT7PSW0KCxHwbmhGo4J59tSq79jaA875VG2Xc2WwAHrUDwEgS W3FILfxOiisC8oDHohKJtw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402a59c035-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:16 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465EErou035660; Fri, 5 Jul 2024 16:25:15 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qb9g3x-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9HMk7gAWxy8xjXeEfRH7Pgm9E5mDRwSSzsggIi9dfAaE9cKjRGMfAOA94V2sv02uT2p8/S8+rSycL4wo0hCBZ3mnbDhzKurO19fFOe+jgjSEApwhwHM6dJSTmCzJ86/ASI/ykFacvFaksIqzEd1IbDbDzpyCdvVEAkTSr7zOugpKJ/QWnJ7IqZYwQvuIg6kBpK7ONnE753/Ty1GKMxZTFesHOPDKNe/wALgOludTfvyd/1SwpPe52CKn4RpSfA7zSVP+v8c0e2NIeRSvDEvt8eJ2zqKoekHv+Axx/2psfzwUwFz/amer1rqSr9EiqyMyHJ3Z59m/tXDOT3IhCHi0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DT7Dy2BAnYcdONpZTU9BhgRkuFjTpBYvYIoX2uX76YM=; b=HOLTi+v9PHtpSGR63hJ0OVFF8p3Hf8AukWNoahP2avyD16kKlmFeppXjGznkRgYamwdlb3aq2txhmyUdg9plHQGj482rAn1/KfRZcxZ6rKusctVLlLHpA52mrw4FnSEa0efs++OL+85CruOPnlp/Jb+n6SRuRHmlggYW3r9OXkHvo8y9KbQOovNbf6Uew0OWLfQSfwHEF6aRLrccw4rw82r6+eI84Tw6ExpEHD2MnmqBnkVxCrnkHuT92GZutSpksOoMCzG/d/LUZdgX7Q19gN55Vswjtoz9+k1JDegYnqKDZ0NjEkbkuQtIKpZIWuL+LgxBmddHAcwJ/FX0A5rfrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DT7Dy2BAnYcdONpZTU9BhgRkuFjTpBYvYIoX2uX76YM=; b=G76jPN3ThWrfW4mXaitznOPz6OdbRQQRa4YzetkKHxcl0/z9EkWcbr+yJGo+0V1COf9p8mNI1HFD2pRdGJ27ohqoLeJjl7NclO7BJF3uareUcWtrXaXGsZD39Yyl2CrUeVpKchbJT2dji6+CiMk6O0YAa6bWHwH3p0JFlACXssI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:13 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:13 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 04/13] xfs: make EOF allocation simpler Date: Fri, 5 Jul 2024 16:24:41 +0000 Message-Id: <20240705162450.3481169-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR1501CA0035.namprd15.prod.outlook.com (2603:10b6:207:17::48) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b44c35f-249c-4e82-d3e5-08dc9d0f0c3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: IHs5bG2AAoklaT7p4J2qx6OWwfJZY1SwCVa7juIdiybblYw56BQ+l/GpAb4Y9mbOMwmHkLfHj5/jtMQj/xNiyh2B4TzbuSsNg6KCyM3NbfBu8UwFAxL3pm1/VfWFZMZeDjD9wvnKJqlaTLL7eaVZO8RY7xq7xhQXpbxX6ol+V+i7QWkFmGRpSFYMcyajiS/1F2+YTZd0hf7KANcspDNJxbFYFGGKIIJzHfcyU0vJA8zC3jfRBhKrwPcRZ3Q1f7YMWzqk6+PODAPii/v4uAzxek7Qb9ePZXLKCLGip09m/FvwBAM+JuDdXQnFVnR2vfyQLwdvG5q+phobN1Ss3vgx8CpmSMxoKyGfIvcDeQR3dGfSRFW6JuSmipTW7hHiMHPvykVKwu+X072PaLeBQ6Z98XpIKFOcbsS+UJKZW9ij209IQj/G1VbEXieMJakuwWHM1WYHnxp5EcUIw2uh2h1jTVjaTSS0dSRXEfIMQ2MJjzOhprubAQ27zLR8KoT2mxiZpW2ugSkV9J0KL06GMIXsBkosslkPNlZCPHneZPAcHeu9yGMBd5AcuYEeOjnUL94AquIq/zVRtme1GVjv2QLFvi6F+GhLV0gjXQi5Cd37e5qcmTNJzYgplypB5k3CwNd3+3GW0YKW/tI3b1ebwsebylWpnSmvPQxssfkiwRCtcUUZB2g0jhWY6xjrVERGJWOhiRZv0pU4D+VMXwD9J7l0eF4ppMFc1mD25NBDeJ5b1aKPgxQ3OPN8ltxliVaBOBPP9DgdCdVLmpk+sO5N2Mk3+ijLsswNeexXkw9nE/s/zbG09fK7b/+PIglKkbw5B5m85gjMoFoONZ7X1JPsCJCN57C2ECCkEyXDeKkrGgcOKaYVub0EwJbwuTF+dtWJ+HdP2HsDT1dWxrAK/fMCHndxSWv/BVw5Ql9dMT2RtT9+CnhWl9NarhFZQOJE9q8jT6bExZ39Su/5dLteQb/ye+UWC/sPwvgNyBVaQxwwxidwHiTsztlysENxcMUi8C28fKfL/McdYh83YB7mkVoI81ORtxDwxbRFWGZdgbebpKYl7e79OSlzLUf4WLZaytm1U/RpnOKzPvDXc0RE54hXuHVon/QpQSvYexhxpiooWYKgZjnWduu3a/HPS4UalocVSpwzZJxNkYZMvFKLsJsQ2cHExcAnU1CevI06Voa5d8e2l/hNimi354RpRWqkX547Imd9CRAUqQbJETXhRcmd6hlyi2zrylCBI+HrZf8tz96SVuQngkewWCpQFsAoAK7tYDOFNVesL438Gw3oXGWinC4oORP9lzvEVX58oLuY0WCT1HjT/9WdO7tOaDmNbRMvEWVIY8AkZj5WYunHlCAz4tomKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Ch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I+BTi7SsEraBNGpfbP6vjP3J3gBBWzaI/+QkODGNo5DCSB29KL5EnS9QOyJ7TewVKK6NBGcnSDViKBqQElJyVs/FAFQeif41xVPlRROI5/4+MwmRUW5c6gcfH2MtxuiVW1aOw+AZOQMZ26z1JpOY+QNsE5OEI+CZk1U1va2z1i9RTV2hqcRAGt72SxEDpDCB5zjGNRYuBXbLG1d30fxncwnLRwbNpZDYuK/Prx7w/t8xIdziLqM4KhKGAxD3nt5nHg08wMPuHrS2U/yS+W6Wlu46U6WKehvB//efFDmerofUW23fIMjCFV/GzJTrfjnF//KH0zsG/eRsq9u5g8Dkp+OaZXRDn7KVXH/UokCo/FKF/eXSvIjoy+uncwpLpGuCKGof/MmBZbPw9BGvTlSyq14WitbvwIeA8wOLKrTu1O6BW+6aXQ/lEXi0hrPgHXpxkwp2nNh+YpUFhpgvk3Rk0FF5JqVw3F0rA7UUKjVJYomLtahFcIFVDq7YQYuqAFz58EVFfl4cSuBobcN/v0u3E01+NxjvdaLzulx5b7zLBkmNtmZBrwg8/lwTOw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5fIAfEV1keuoPFLbj/9y1O3FRShjuZXZB6/EbB8ZsL72fgcZwdOhFBeAkriLB3EupnZpFDxOT/TZkziRRoXSaMbWk1yNqin1werlhu/389/NQy6hx3zW7FL/RPV7CCg7bTvRyP2Zm+jWMF0srLoKkKNkTFRT/rURKKXpgm23fO4TXfNVexJz3EoddE/KlFy9ExpABtakuMuEEN5oaJksRSZ+4L7T7wEImyGG4bdlsDQihm6b+rFZmRsV73KABovyshpI7a9eG3DtVdflD/pANIlXvioxg0HAdNf7NeMabzkQe/rkK5Qt5GukCEfyGpK+7YxTIQ5O1w3rue/zGEOjqV0JWDCOI7SvJYUvismJUTpraUeUwzSSZe7hHTKMd6IKb0Jn0lUroitKVgwHDO1e86lZo4N34d3pz0jFff46lbLu5OaUBZCdLlmh2VoOvwr/t2JTZID5Hd6ezlsd8y/VkhUaQnbLO1WqFR99RalH9NKlmFIE4p1l4BHmExhM3l7Lla7b4NoXKvQYV+IzEgWttwk5XTgoLOVmDLpQpNMEaTdEqRKIk3w7NT1AfcpciN1JwkjJ/JUWWXyxX/0AZqLpsHcluHtudZ6QgYsd59C9Z+A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b44c35f-249c-4e82-d3e5-08dc9d0f0c3a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:13.6132 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: clQ6NwYa1aEPp/5B0IJssSUEDzmD7I2O8bHzfY56wGa8fGEIW9dhcni+Qow6RgPTUrAAOH5huogTjS44gYWcRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: VEUg6orhsVzBYAy-JXlmJUCawKtokB-6 X-Proofpoint-ORIG-GUID: VEUg6orhsVzBYAy-JXlmJUCawKtokB-6 From: Dave Chinner Currently the allocation at EOF is broken into two cases - when the offset is zero and when the offset is non-zero. When the offset is non-zero, we try to do exact block allocation for contiguous extent allocation. When the offset is zero, the allocation is simply an aligned allocation. We want aligned allocation as the fallback when exact block allocation fails, but that complicates the EOF allocation in that it now has to handle two different allocation cases. The caller also has to handle allocation when not at EOF, and for the upcoming forced alignment changes we need that to also be aligned allocation. To simplify all this, pull the aligned allocation cases back into the callers and leave the EOF allocation path for exact block allocation only. This means that the EOF exact block allocation fallback path is the normal aligned allocation path and that ends up making things a lot simpler when forced alignment is introduced. Signed-off-by: Dave Chinner Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 129 +++++++++++++++---------------------- fs/xfs/libxfs/xfs_ialloc.c | 2 +- 2 files changed, 54 insertions(+), 77 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index b5156bafb7be..4122a2da06ec 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3309,12 +3309,12 @@ xfs_bmap_select_minlen( static int xfs_bmap_btalloc_select_lengths( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - xfs_extlen_t *blen) + struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; struct xfs_perag *pag; xfs_agnumber_t agno, startag; + xfs_extlen_t blen = 0; int error = 0; if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { @@ -3328,19 +3328,18 @@ xfs_bmap_btalloc_select_lengths( if (startag == NULLAGNUMBER) startag = 0; - *blen = 0; for_each_perag_wrap(mp, startag, agno, pag) { - error = xfs_bmap_longest_free_extent(pag, args->tp, blen); + error = xfs_bmap_longest_free_extent(pag, args->tp, &blen); if (error && error != -EAGAIN) break; error = 0; - if (*blen >= args->maxlen) + if (blen >= args->maxlen) break; } if (pag) xfs_perag_rele(pag); - args->minlen = xfs_bmap_select_minlen(ap, args, *blen); + args->minlen = xfs_bmap_select_minlen(ap, args, blen); return error; } @@ -3550,78 +3549,40 @@ xfs_bmap_exact_minlen_extent_alloc( * If we are not low on available data blocks and we are allocating at * EOF, optimise allocation for contiguous file extension and/or stripe * alignment of the new extent. - * - * NOTE: ap->aeof is only set if the allocation length is >= the - * stripe unit and the allocation offset is at the end of file. */ static int xfs_bmap_btalloc_at_eof( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - xfs_extlen_t blen, - bool ag_only) + struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; struct xfs_perag *caller_pag = args->pag; + xfs_extlen_t alignment = args->alignment; int error; + ASSERT(ap->aeof && ap->offset); + ASSERT(args->alignment >= 1); + /* - * If there are already extents in the file, try an exact EOF block - * allocation to extend the file as a contiguous extent. If that fails, - * or it's the first allocation in a file, just try for a stripe aligned - * allocation. + * Compute the alignment slop for the fallback path so we ensure + * we account for the potential alignemnt space required by the + * fallback paths before we modify the AGF and AGFL here. */ - if (ap->offset) { - xfs_extlen_t alignment = args->alignment; - - /* - * Compute the alignment slop for the fallback path so we ensure - * we account for the potential alignment space required by the - * fallback paths before we modify the AGF and AGFL here. - */ - args->alignment = 1; - args->alignslop = alignment - args->alignment; - - if (!caller_pag) - args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); - error = xfs_alloc_vextent_exact_bno(args, ap->blkno); - if (!caller_pag) { - xfs_perag_put(args->pag); - args->pag = NULL; - } - if (error) - return error; - - if (args->fsbno != NULLFSBLOCK) - return 0; - /* - * Exact allocation failed. Reset to try an aligned allocation - * according to the original allocation specification. - */ - args->alignment = alignment; - args->alignslop = 0; - } + args->alignment = 1; + args->alignslop = alignment - args->alignment; - if (ag_only) { - error = xfs_alloc_vextent_near_bno(args, ap->blkno); - } else { + if (!caller_pag) + args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); + error = xfs_alloc_vextent_exact_bno(args, ap->blkno); + if (!caller_pag) { + xfs_perag_put(args->pag); args->pag = NULL; - error = xfs_alloc_vextent_start_ag(args, ap->blkno); - ASSERT(args->pag == NULL); - args->pag = caller_pag; } - if (error) - return error; - if (args->fsbno != NULLFSBLOCK) - return 0; - - /* - * Aligned allocation failed, so all fallback paths from here drop the - * start alignment requirement as we know it will not succeed. - */ - args->alignment = 1; - return 0; + /* Reset alignment to original specifications. */ + args->alignment = alignment; + args->alignslop = 0; + return error; } /* @@ -3687,12 +3648,19 @@ xfs_bmap_btalloc_filestreams( } args->minlen = xfs_bmap_select_minlen(ap, args, blen); - if (ap->aeof) - error = xfs_bmap_btalloc_at_eof(ap, args, blen, true); + if (ap->aeof && ap->offset) + error = xfs_bmap_btalloc_at_eof(ap, args); + /* This may be an aligned allocation attempt. */ if (!error && args->fsbno == NULLFSBLOCK) error = xfs_alloc_vextent_near_bno(args, ap->blkno); + /* Attempt non-aligned allocation if we haven't already. */ + if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + args->alignment = 1; + error = xfs_alloc_vextent_near_bno(args, ap->blkno); + } + out_low_space: /* * We are now done with the perag reference for the filestreams @@ -3714,7 +3682,6 @@ xfs_bmap_btalloc_best_length( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args) { - xfs_extlen_t blen = 0; int error; ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); @@ -3725,23 +3692,33 @@ xfs_bmap_btalloc_best_length( * the request. If one isn't found, then adjust the minimum allocation * size to the largest space found. */ - error = xfs_bmap_btalloc_select_lengths(ap, args, &blen); + error = xfs_bmap_btalloc_select_lengths(ap, args); if (error) return error; /* - * Don't attempt optimal EOF allocation if previous allocations barely - * succeeded due to being near ENOSPC. It is highly unlikely we'll get - * optimal or even aligned allocations in this case, so don't waste time - * trying. + * If we are in low space mode, then optimal allocation will fail so + * prepare for minimal allocation and run the low space algorithm + * immediately. */ - if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { - error = xfs_bmap_btalloc_at_eof(ap, args, blen, false); - if (error || args->fsbno != NULLFSBLOCK) - return error; + if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { + ASSERT(args->fsbno == NULLFSBLOCK); + return xfs_bmap_btalloc_low_space(ap, args); + } + + if (ap->aeof && ap->offset) + error = xfs_bmap_btalloc_at_eof(ap, args); + + /* This may be an aligned allocation attempt. */ + if (!error && args->fsbno == NULLFSBLOCK) + error = xfs_alloc_vextent_start_ag(args, ap->blkno); + + /* Attempt non-aligned allocation if we haven't already. */ + if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + args->alignment = 1; + error = xfs_alloc_vextent_start_ag(args, ap->blkno); } - error = xfs_alloc_vextent_start_ag(args, ap->blkno); if (error || args->fsbno != NULLFSBLOCK) return error; diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 9f71a9a3a65e..40a2daeea712 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -780,7 +780,7 @@ xfs_ialloc_ag_alloc( * the exact agbno requirement and increase the alignment * instead. It is critical that the total size of the request * (len + alignment + slop) does not increase from this point - * on, so reset minalignslop to ensure it is not included in + * on, so reset alignslop to ensure it is not included in * subsequent requests. */ args.alignslop = 0; From patchwork Fri Jul 5 16:24:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725358 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 18BCC16F91A; Fri, 5 Jul 2024 16:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196734; cv=fail; b=VaR6a62UE5ShjKBLnDhtJPMr8KU9QwOKmmbCEWwvK+axbTpkZTy1rntVoLEwolyTRhgveWGdiVS52ZceFqmjMR2vX/VIdKQ8aT5zycqaZsqd/OxJaT8ETF3xSy3pdacv1nhD036hwytqNPj2NZ9StGP68H+/aHlnftEG4ESvWbI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196734; c=relaxed/simple; bh=pUSaUmPvj5Rp7Iq2iwsgn1wkPtGEhxju7DgYXorkw+Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cDljePtm1Ih6A75zhN8c7MoCijEy5Qh4rsSkUneraAkdbgWkhO2PYgxDjUqpa2gmHJzwy55JSxJPuezS0Xpwi/vcugF3DkShy7L9PcfycDweTBNCerLtbK5zFPPpm4kK/mSY9cI4SzQhsAVkxvv2QYtyxASzAUlpDyrIHZvJ/NQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=aFBpqDuO; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=iOnlHnWj; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aFBpqDuO"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="iOnlHnWj" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMW5f011057; Fri, 5 Jul 2024 16:25:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=NT7bNhoR4f291pg4VePYRXY/+5BIkGBmmP5luiTjmkw=; b= aFBpqDuOGRFT0UyH2YRKdgMWzYCHqoLppOuqjGXGxmJJMKb8NT4nfXog/WcOszpP uWsOW0rcm42HUPu7vs9Aisgx5CMv3n+l9V7zcuxgkZRgyxXE5Gjk0wQotMlAZup6 MjTHEiN7yjpcyS9QdZcjdJSCZ/qhpPJbHDsB6lxuB8QXKlooAeU+/GtwDlwC4EsQ UhQruQkwrUYWrkpYILpSL90AuIQdZfnuxkEY0GY76HWYw0S1f/BLvnmceSYmgQQq 6ZCt1tFb6gEvTjV0snPAImCiS4p44ska3TrINmxZnlZCM2YzswQ647CG0irHh+37 ltPppyHUwVBTg2FwLutK/w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4028v0v9dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:18 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465GM3Q7024789; Fri, 5 Jul 2024 16:25:17 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qc1c0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hr4v5sfUFkO4dhKwR54/UJsYeYpaRLYq4T5/UCklhm+FTQrty7QUhbv7Ug/83dAVaRu+AKX9g3zeLeJK9/4k1gv21u4gBK0oGS2UGqJKhtfufW97wJGh8ajP3Cp6ZNseyzH5T/hCEwPDebxa3FPGytzENv4js8KTbCj7GACFFuvDDpEGreqD3ODq3IdTMBtrRh1Z2T7yS+ImcYl0sCHwG6em/KHZjGgABRuMUdWOxE90YLMwtHvhMi7Bs4lss92Z8GnEUGv2A4tInF/1uyFB7xSZcnI85zHxtZNt7LqlxGucWgcd5cglTjHXetw490VRS8O1aQTu/GprH0LkIvAIFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NT7bNhoR4f291pg4VePYRXY/+5BIkGBmmP5luiTjmkw=; b=ZCDg8vtQcYqHgjC78EQKs4ixD2UBbCm3BAc8DQpMk+0mOWb3uQynRZDbKpNGdGscigWN4QHrDRTq4LJOM5TyKlHjGxvCONriz8IToFc8jv71cv6mGPYgWJUgFnsAO8GB4i0j08n2kG5qQeGFcYst02Oe+5G334xCxkgNGuxiTm5D9C0tCoQIi/CfMiiiVMVRi1k3of5NYwK+zqqcQCrbGuRvIdjnMg8yGHGSb4C99I+zHej8Nhuds6v1oB47vBqLkhKNKFKqEDDZ+PFVUtIxoozNMKkBGk1i0DVWzkG13LIkqYtK5sYJzcFRWKFLBitfu52fCF9KMttdTO8QK/xH8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NT7bNhoR4f291pg4VePYRXY/+5BIkGBmmP5luiTjmkw=; b=iOnlHnWjC2Br+a2fwSYtQoRpgaYQz/tX/vLkL5hWJSmz2HaKjJjHFK+IgHwI61sw6c83ruj171sUcR5RpLLKFul8cWE3FxGmrtPEhyOSX7BVGBtAoa5LUQ2oGLLYbGEexuHA6KW2hxvq6lsqe5L4s6D5olBTkIIiwRTHKpksLrU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:15 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:15 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 05/13] xfs: introduce forced allocation alignment Date: Fri, 5 Jul 2024 16:24:42 +0000 Message-Id: <20240705162450.3481169-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1P223CA0003.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: 39280bd8-a4b4-4789-9b51-08dc9d0f0d26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: ZNt4P3Yex7bWfXiurC7pldlooXglTbh22OOuwBYNIN4KKoHY5KjQZdbhmQZOyzXX1cmY/mtB+eNDIDE+CBWWjaLvipctemag6cORZ3wFgGtc37GMTknW/s3YhtjFnv8wX00UVdVX0AMSD6WpOd8hVGC3EUlEoQMssiYQ67qD9HRJUaTN+O1SWnXhfkzHdCekTw8t6cYOStmxaNOZ1iSxQiO1UCfMrPDJq9tMpLKpGXQ3Q67JWPLZp1pzl9ns6QoQJpLh8r53ZN+2D6yA3SyVyCIHf998m+tOT4T6ZiT19TmOlDskykI+6Dnf6HZEQCvnzQikJ+cvarZ9MLkAA1Nh5jV8UOHhXktV8PTyhauvdCn4NQzy9pn5Dn1O1s9EPf99QOC/pJfPpDuyvGaSvAdTKO7d8jqQ0VFQ5sDCXoXCd7ZURq1S9hu2H1jigPrIVVm2qdXFjT7BgAec/b2Vc+b0hhVGxs2Ne3eJ/hzwIfEWF1mj7sJbxnVwGnGgvHiXCDFTO4CE8cPyp8FwZlMstXlZ9Y5teX4EIjnzmswkssRgxFjzeY4KoQMp5sj4csffB5prtLBSW/aC2mSHJSnsCqCNLyQlxrSZLpzIvgQnV3NB0xPHxnGHb1ihuW5xRnpfSKFEJSDCBwI9PT8xyXR7SZwgAoNHBegdvIGEBSX+p6RWmJpNBsdkWA0MpGej3Z3AWR/UwRa6kLIgarXRiVjMd+NaM6DvFxfvKbpKv11ywekUHHYYPQlfOaU39PYS3R6k0tlLhsnGqYZh2PWelpB269kOg7gVER2SkbCKkPfUpnAKmdY/JLQGKH+cFATjCkRtg1RG2RbZuhKqhAFeod6izswVaZhR3+osx5Fkz6KU6RK89wzU38JJv0zxo6idb83y5ykCXMyrF2+5Fu7S9fWM/OoMwRwU7zqfjuWsLQ8qq4TvFfbVsA3JDPJYWv89bSQjNVUt2DN7yhuZjtDrChrfj8IaWF2s/M98F9TCC73AufpOnFIA2b0TxQPeDBTyD5s61/HZQ3Zaqr9hcOnJKRhUflah2KDBMiFXft3ZZggrr5JNCE/eXHOb9NTOuQNwOz3uMOATTWDQBYxCkHj5hI98+qbNLAQH1QLxH5IaI47eQwKmEvFy3UcMKsn5latGN0BWj4sEwpwvwhshOI7HODPDT8YxnyktUQy+rKv9Cb06XXag+EZoEZcOVuhZNBpZnau73cbTj3irJpmQCdn+zyEDOF8372/DaNJy+gvaynuFgOPmCc+bgiLa4x5IIbO2LFPZXoFq6i5KtzxM++cvCK/b/KVehCnay0RRF7VZKNrVnpvptTgiYGH5B7NMtwBNLmh+x0dOo7GtquF+aq91MPUMme0Eaw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qRJAiWugkg81ODobQG1lWYLYz3kCgUMWTPtP/FR4Gt9N1BtYAmG86dJcsRka+9tPp0kVh5w1ekPCfNie4hLzY4giD2N76n5NopbGCFNmJyuPBnkxZI+kT5p7TyrU1zidZIHiD11Q0nuxnsJpTrjFrRA8DQG2OYu71+XAawnvmTjl2p71CNHT77SC7jbjwJem8sWb1MSotyJgE2pgaxqVTWzrh+/0/uJ73dhhb1/6hm0dfB67XKvUAUy8ZvdwCMLFM2VFdi3NZT76RJOAdp+b+SrX/8gchrZiEWBYCgLXiOn8Y2bu2MG+vuKM+lE+kHswGzGAgdZlChJGxQa3D0NlHlhtYKrulkC0pQluY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3yx8HYa4A/QiyaCS5obs3/JzNu14ZAG9pv0THWssaG+tQuEAeA7eVm7YvMBDqIgJ1a6KFm+YdPJ6p8kcLH1tPotTKC4g9faKhVDvKnA4koZ3I9ojed5IoYql5Dsf1+61BF6HSCpHQiIqSXCVYA8MbVHi53yUV2h26PIneSXgig== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +4fSUw2YK9msOEyFpp9GOs9Q81MhEImTjsbjy8q/ygOtprPL6Nfe/4mrZz7Dylet4lt1jV90pDQqVTLwyJQOW5mSD9XDKuIkqQtlsChL1yzjMaoVjMxgbTwD3gFSy/WoE84vKsRfzN2iQi4xDm1m+jqtH3+O8ZxBOGqajvsu8MLhCee3VuJeWA6hKZUMVbp3DY9JqypmQOBaoOtdvIOnwVS9cYBtlfvIGZTUOtwN38JU3ViHazV5nE8l5a9cAOTmaAMvXvGLF6FmfoY2eEpm1KLf1JzHwqFXNtcSDmqWtORhz0wFaSU5bM8TKbS4hWTlothSX6k7b3C6Wa+p/gBgk0s2IA7JzTDMGJwOSPmi61B2zSyZDf9weICQqPMJx2zEGbPlmNBeJyjSOzAsuBhR/O27PW1TYpejhWSKhEqHQaHkkiNy02ybJVP7rBCFXlkDrT3sPcWsqNcVLYtjk9fU5YCQ/I6HmH0N5P7QZzrXP4QAKR5Tp3LsNz+yRBra4fxigsqbpCIjBaqlfc2XBu7nKstyhu6YtbPr0e7kxJSe2LYmxUw5r9tVOYJhTuDpGVOkK5l2D85A48cfNFupG3nQLrzEEMKYdciS6b0wL7lAxpw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39280bd8-a4b4-4789-9b51-08dc9d0f0d26 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:15.1305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HW2XOz6M3WR9UgZ3KO7fqe1QbDUm35IyIaL1EsO4kPflVUKXBAyDbmpBHit3b0/y4gjE/vcwuwM14ARXVnzUgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-ORIG-GUID: llO92BiHOPKPiHVCT0PJy7p8Yc6MC9Sy X-Proofpoint-GUID: llO92BiHOPKPiHVCT0PJy7p8Yc6MC9Sy From: Dave Chinner When forced allocation alignment is specified, the extent will be aligned to the extent size hint size rather than stripe alignment. If aligned allocation cannot be done, then the allocation is failed rather than attempting non-aligned fallbacks. Note: none of the per-inode force align configuration is present yet, so this just triggers off an "always false" wrapper function for the moment. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 29 +++++++++++++++++++++++------ fs/xfs/xfs_inode.h | 5 +++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index 1e9d0bde5640..71a85439e5fc 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -66,6 +66,7 @@ typedef struct xfs_alloc_arg { #define XFS_ALLOC_USERDATA (1 << 0)/* allocation is for user data*/ #define XFS_ALLOC_INITIAL_USER_DATA (1 << 1)/* special case start of file */ #define XFS_ALLOC_NOBUSY (1 << 2)/* Busy extents not allowed */ +#define XFS_ALLOC_FORCEALIGN (1 << 3)/* forced extent alignment */ /* freespace limit calculations */ unsigned int xfs_alloc_set_aside(struct xfs_mount *mp); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 4122a2da06ec..1cc2d812a6e9 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3400,9 +3400,10 @@ xfs_bmap_alloc_account( * Calculate the extent start alignment and the extent length adjustments that * constrain this allocation. * - * Extent start alignment is currently determined by stripe configuration and is - * carried in args->alignment, whilst extent length adjustment is determined by - * extent size hints and is carried by args->prod and args->mod. + * Extent start alignment is currently determined by forced inode alignment or + * stripe configuration and is carried in args->alignment, whilst extent length + * adjustment is determined by extent size hints and is carried by args->prod + * and args->mod. * * Low level allocation code is free to either ignore or override these values * as required. @@ -3415,11 +3416,18 @@ xfs_bmap_compute_alignments( struct xfs_mount *mp = args->mp; xfs_extlen_t align = 0; /* minimum allocation alignment */ - /* stripe alignment for allocation is determined by mount parameters */ - if (mp->m_swidth && xfs_has_swalloc(mp)) + /* + * Forced inode alignment takes preference over stripe alignment. + * Stripe alignment for allocation is determined by mount parameters. + */ + if (xfs_inode_has_forcealign(ap->ip)) { + args->alignment = xfs_get_extsz_hint(ap->ip); + args->datatype |= XFS_ALLOC_FORCEALIGN; + } else if (mp->m_swidth && xfs_has_swalloc(mp)) { args->alignment = mp->m_swidth; - else if (mp->m_dalign) + } else if (mp->m_dalign) { args->alignment = mp->m_dalign; + } if (ap->flags & XFS_BMAPI_COWFORK) align = xfs_get_cowextsz_hint(ap->ip); @@ -3606,6 +3614,11 @@ xfs_bmap_btalloc_low_space( { int error; + if (args->alignment > 1 && (args->datatype & XFS_ALLOC_FORCEALIGN)) { + args->fsbno = NULLFSBLOCK; + return 0; + } + args->alignment = 1; if (args->minlen > ap->minlen) { args->minlen = ap->minlen; @@ -3657,6 +3670,8 @@ xfs_bmap_btalloc_filestreams( /* Attempt non-aligned allocation if we haven't already. */ if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return error; args->alignment = 1; error = xfs_alloc_vextent_near_bno(args, ap->blkno); } @@ -3715,6 +3730,8 @@ xfs_bmap_btalloc_best_length( /* Attempt non-aligned allocation if we haven't already. */ if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return error; args->alignment = 1; error = xfs_alloc_vextent_start_ag(args, ap->blkno); } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 292b90b5f2ac..42f999c1106c 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -311,6 +311,11 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_NREXT64; } +static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) +{ + return false; +} + /* * Decide if this file is a realtime file whose data allocation unit is larger * than a single filesystem block. From patchwork Fri Jul 5 16:24:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725363 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 B348A16D33E; Fri, 5 Jul 2024 16:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196789; cv=fail; b=rE/4Qud3XrvNCUr9lpuimh+/UM0hKaqajl5y3MwYU3zqAXDAABeMMO8vy6+byOG+Zeft6EVQ1ZVxAmUS9pPia3NSHssaC6PiAvOdEq2EiHjqiKAK5cyLevb04eN6PDH22C5p7Icfi07rfXvnT56Tf0LSa/xQEzTCg09AMBju68I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196789; c=relaxed/simple; bh=7S8qmgiDZ4KaKnbLnOZATpk2+zaiQRDYh+tIcES/22c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=g9U00JADlx3zfYzk97+eRQp1Rp+fI8fSauMXpYjpGptQnw+QSZR6F3We7libkmJwq19dcfB+VLrInsYGNigO1Q3V95c85siucy6+trYoMHepn3rNCSF/Qgvnn2jyfo27JoYrqmDizkSzVaj7bX7uY6SfJc1y86tgigMHJ41vcrI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Pryy//Kd; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=EBE7meGt; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Pryy//Kd"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="EBE7meGt" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMVtO011033; Fri, 5 Jul 2024 16:25:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=9Bh/HevQTPbIuyZoyvW7vcmCWvEJKSjSIzlHv+QMp88=; b= Pryy//Kd65Wasw3BAwhvJXGe4QZ0gvkMM7+q6a8Be40sks61XdtmZZk7RPBftr3m O9Bx92phOTKbL2y43gU5pzUYe93B+RNqqBbfHjOHQZD9yHHGrdC2/5qTicKYBciA 4hVbVHMXpXSpJdyvW7AfsSP8tWORpJK59tc/RDerwbq5rnYNs/JRDJbJkks2xWdk 6fKjlJBzMyE422f9h+0nKM2blsQGXnDMe71jh4JR2P89JJtznW0DCPgm7HRINTfp 442IjjjSz1XJE0aoL0GAM30/X6PT6ICfh8YbKXd6RxMSRICPkQBoLC+KfE8HO21x HYrS1o81I0D8RJ3ka9iB9A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4028v0v9dh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:19 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465GM3Q8024789; Fri, 5 Jul 2024 16:25:18 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qc1c0a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AHrAjDxAixxnnM70bKmTDTmB1rooEj6DdpOB2DUtFYsVoZROl98vDLZzq8dnwugP8/e3AoN9+u89PNZb3EylwcJmLV7TQW1qWjXiSKX0ByfEV2Xr6t675amhPAysOJg0xfiRK51KJZm6LgdC+dfwTyUR5b2CH0ZveZ2Fc16vRi3l59bjsoqHk0pdsbSNXvD9AMgXxp3en/xUlC7nenQCdWzx7KwxiczuY//rtJOf72gIYgAViM9sDytdLWwF86QDMcrRTdYV4SQxjEA9twQ+wi6uSlRYrMS8DuP7De0TbgrMo8hww3uzZzOypd2mp2y2jZAOgIiUUV9zbJSbLfezDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9Bh/HevQTPbIuyZoyvW7vcmCWvEJKSjSIzlHv+QMp88=; b=OCQNyE+4kXvKaqQAQzY65yiOIh5I0yOUMs85oZ6BTCah0avEaUqm6OvUjjTAPRlpfCp2L4ycKc086E1/r0/7B+0cwGEjjZyPEXOQm6D1C3ZfhAmuu5neJHCsjJ9Fh2zhnRjrd2K+1C84hlwyys+ZgAe98+NkfRYGgTeaoqWW5WJmkSmu6BM60HnfhqbcHlouFrVfwnS29XjWNhs2zmz/VA27fVLMbqecIRrH1G+ae4F6D022Zl/iK6hwQMs0/YzkRKQ4rXUiHPWw/KuR7EXdyQhPHT2dN29Kiv6gC+mSpF648NCsHx/QhcmKj47/fSRLeOP9fn6a/VRKFeEEqiZP8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Bh/HevQTPbIuyZoyvW7vcmCWvEJKSjSIzlHv+QMp88=; b=EBE7meGt1ycFEcBqiS9HPHeFgcJEXEFR6wkctkt2T9pHwDJfCvncv532uNboXwG+N1kLWqf9wUZCK1155EhKTiRvj/VAOoCH/vVdYNEoGPbHUUmQ/Pt0OC7ESwW/qHA3kVe2GFqW9CfxD0YhlVe3TeylSJ6a51iVAoj7tS8O3Lw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:16 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:16 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 06/13] xfs: align args->minlen for forced allocation alignment Date: Fri, 5 Jul 2024 16:24:43 +0000 Message-Id: <20240705162450.3481169-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BLAP220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::15) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: 25b7c22b-33e8-4bc5-80cd-08dc9d0f0e06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: aACK1O9w0VwireFIWktnyBcpFfHUXpgK1/XWft7z7e+euhoC6awxl/2MpdDSOvLMqPM1OF0vJT2Ptg4VGsD0vc1KCl3zDTkB0cuyFV6KE+NmIRMKH6mHF6vTCIpall99IK2yInubuEvVffpDrjc6IT3QsB398AD6NeNUVWZaa/e8gme2tSg6rEX+ceNKpX0YTmwe4CGbbYCHBswSwSSIUYkfIMLRurETBk66OY0FliBUIGUvIJ9esCm4e0wbtpN07Ay7r2u/ZKNqnRQxGlE+yNPgIB6+6LEqJYMKz1u8NOHwrO40mRvYx+M+qGVmCpbdSd9MQHRdWZf+E8Ng3RqXSMBbkIlYG2nxLXrzlF6KwCqzt98hXCtZUi1Z+/BxlCgEIBdCG00sSMCECKQEox9t3vWx3KTT94RNn/Gy8WOLjqBDLadleVUTFF6kCZd50NGIwR5Onolrl15cgZGlLlIwfFe4LnCOJdeCT6J0wVOQU5RgAbDOLKUpvosGlVtY/3kopp9UENXToaInZYWLDv6Wl4GztwmxdDSfwRR+cVNHfshBYLLiaOontszCCKR9Ro+UVp9ftfmWG1j2dZWDqiq3UCAG7YdVJrwD9VrAfcir9qIUkAJmk2e5DuM8hVJgH/ZsOC0tUgpYXH0u1pGm23tymC3C/5hNa/bcZiyHJf8AePmIzC8knXGIAOY4botvRE2L6EfLhjDBot6zocqL8Wk9/F2LQuH1xTTgeooinMXal2EQAwnomKMQI0nqdRszRVFLbK30pDXYMyC0DeFXJcAjUMllZT9hMZ8W6sXw7k+IIN3mXsgP7aiods8MJhzTfK/Sm5rE1imezOLUozJjePKq4NUg3ByN7sPKIzYJWjOQIjUzdZAHMQ/5RqvuUewr8Kc6+E+4GSgfcDGLTwDqYuDC7d56dTegGglPuR0z5gnWj7ZkMzasbhw31YM2tf7VFc+9HFUFToKl0poOMeW0MKXT+ziJ5fHWQTPadDiEOtDwg0beazBdEjzMyj45w2X0BPj9IkqO08ORHYRynjihbkW3LoijyAJhCQN3l7tszUbaK5isqbVQ22veSA8vEjyzcUXfDRaGsDIwJTD7UwLH4PFc/PykKPuvHVMLOhz+ts6rVe9l0cMrKjWbENHOeI/W+wgct/9jmLW+JARuI4CHiNV7uvtn0yd5T6a1wuIza4pjAcaivD3+Q46JkfQY6B0ovaMLNHcaTky7keyFmMdAaUJ2Wztgt7qovTl04AUGouVs0KyM7/6xWoArI+qmRz+PY67zoE+Ajopr0dlv67KD6GC+Ew/6PaeGXqIjh/QvIV91XOm/7ivmEDkoqdUypgb1i9Ms/2a+1yjNDbMMwCTKcIY6yw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nkl5SJBxXpzoe/UW01aG/K1p1VVNgh/ZyTxq0HgdnzrZlM3Vud/lY1e5c2BATOndSmlXZ3t3UrjiE82PJOcyzprWI1tMqudIQ30/mgQfEmfpYkQ/QwppaDkg5Q2axhFHLPgn9NfGTMnqaL22KYgzQnNZbuaUE3h/03yKUW7dZ8elqjxL2DlwdWI27eIBU/mmvt7HYMPoS1I6E9RMCttvYnsiIxAujSEJUCyP8DKcl9RrrQbYIIFRqErrnPLnvht27f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ycIQn2ynnMgOX7NfN67zHgQly4T2Iz1x2GOAiKWr0pCzVpFuC2SN/BtxfBnWBCPCNnU7h7/5bz5L6r/wlLhay/pQwYDEf2Z/WLHZaao5PfnbYwZVx+8hbJ0NWBbMCLm826ZxrAJzbn2QwEIhbIn0kAkD/R11vq2QuUgSvwV91SZ+qL/EbfWpL8pU8XM7B3FnJLJ/eLn1vkUGUeubYOIzIRNSHJi155MYt8Tt+/bSrRp0/DelDIBfBHuGETOAB9afEFtaR/M5YW/kn4rvSY/Emo9HmdLZyK9Vv+83QOe6Zo2NL5OV5cIrpw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5l+DjQpsWGfqtZRtZwZTuh7blbOTIfognaYBCnN1oeVYMD5lgVOFzaA0gAxYjmP5GIWUYQHvu07ISpMCvDgDuI14l4RU77CTEAArRc1oyN62P+eZ83ZQ/k9H6SSSBXg/9uAV2utTVyllH2F/CmS1nda+HWZQWyntjnhheinWycjljCHWdiMxgER7dzI1RbxSr/8Ko53NwG7HDqLvanj80HcCSncpEX9JWsKof1BDZi+7k/Sy47wpzmbjJKgyrLFyxGUxyP4+XSU835QxDDD85g3RYpakiEBtKzzbOV3yNSjUCwa0Kvb2hj5mB6xC7gbe/i/MisAH7dEOfBLtyVEwOB8CXY/IzNBkzAmBFimwGPbVyXOEPt4ou0SuFu6sm8AcjqZRv6yY/Mv7xKL0HwZ2K48Y4tLx2rcCENJLHw5cDaTzdLRg+hQJjIYyRjmX8+qNeHR9Rger3vvSRUhcWFq9yahNwtsAhtjMxfNWQTLXiHswy6OEdjs/i6cGymKzu4LziQnXC7mZD0ecRiyEw9/Jmea+V2snnatCrJIK1ziPty5DCUZh4m/VfN7Uge5P/EZNFpRuaBAYzKcGb9OPMAMkRC6KDXmQi1JW3PholP513sI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25b7c22b-33e8-4bc5-80cd-08dc9d0f0e06 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:16.5824 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ODTENlADFy+O+XaQxpJRy4MrCiLLCJfxshzm0jb3cUoRMsOBspzG6hoyuAZQyZtql4UcNXFd94k+KpCLOOJFnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-ORIG-GUID: eOimJv3rlVP_YSoPcMlXua-87UxhR8m7 X-Proofpoint-GUID: eOimJv3rlVP_YSoPcMlXua-87UxhR8m7 From: Dave Chinner If args->minlen is not aligned to the constraints of forced alignment, we may do minlen allocations that are not aligned when we approach ENOSPC. Avoid this by always aligning args->minlen appropriately. If alignment of minlen results in a value smaller than the alignment constraint, fail the allocation immediately. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 44 ++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 1cc2d812a6e9..db12f006646a 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3278,32 +3278,48 @@ xfs_bmap_longest_free_extent( return 0; } -static xfs_extlen_t +static int xfs_bmap_select_minlen( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args, xfs_extlen_t blen) { - /* Adjust best length for extent start alignment. */ if (blen > args->alignment) blen -= args->alignment; /* * Since we used XFS_ALLOC_FLAG_TRYLOCK in _longest_free_extent(), it is - * possible that there is enough contiguous free space for this request. + * possible that there is enough contiguous free space for this request + * even if best length is less that the minimum length we need. + * + * If the best length won't satisfy the maximum length we requested, + * then use it as the minimum length so we get as large an allocation + * as possible. */ if (blen < ap->minlen) - return ap->minlen; + blen = ap->minlen; + else if (blen > args->maxlen) + blen = args->maxlen; /* - * If the best seen length is less than the request length, - * use the best as the minimum, otherwise we've got the maxlen we - * were asked for. + * If we have alignment constraints, round the minlen down to match the + * constraint so that alignment will be attempted. This may reduce the + * allocation to smaller than was requested, so clamp the minimum to + * ap->minlen to allow unaligned allocation to succeed. If we are forced + * to align the allocation, return ENOSPC at this point because we don't + * have enough contiguous free space to guarantee aligned allocation. */ - if (blen < args->maxlen) - return blen; - return args->maxlen; + if (args->alignment > 1) { + blen = rounddown(blen, args->alignment); + if (blen < ap->minlen) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return -ENOSPC; + blen = ap->minlen; + } + } + args->minlen = blen; + return 0; } static int @@ -3339,8 +3355,7 @@ xfs_bmap_btalloc_select_lengths( if (pag) xfs_perag_rele(pag); - args->minlen = xfs_bmap_select_minlen(ap, args, blen); - return error; + return xfs_bmap_select_minlen(ap, args, blen); } /* Update all inode and quota accounting for the allocation we just did. */ @@ -3660,7 +3675,10 @@ xfs_bmap_btalloc_filestreams( goto out_low_space; } - args->minlen = xfs_bmap_select_minlen(ap, args, blen); + error = xfs_bmap_select_minlen(ap, args, blen); + if (error) + goto out_low_space; + if (ap->aeof && ap->offset) error = xfs_bmap_btalloc_at_eof(ap, args); From patchwork Fri Jul 5 16:24:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725357 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 E14B216F29B; Fri, 5 Jul 2024 16:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196732; cv=fail; b=jNWyr2noQzVt/qS7Q8zErgJN6A9NafF8nLKHoU1gF+aq3zw0MWvc6/CFxx/6D4aAMoHylN7e6oVTMqu2AmtLcMnU8e2B5/BYlRcS7qrlw0WyNWblMUNBHFF8cSYAmzm9IfaCEW1iNNrVUI0VilMRVadvijUXEQ9yxZOR1s/S7JM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196732; c=relaxed/simple; bh=72X7PTRWy3+kbA/NNyG09WcUguUnjny8DqhDvZIspGI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=WnlS4XYJhYOQIcAATFgR5hf91cxh2FGOEV/WPBEnk0sXV5fLqXfzqM2tbajKZ3Hc3ggFaHSy5QG8PFQ9u430z2PekdTL64ww++25Nm85yhUMqyZP2Nsg17ZaqwiRKNr5CrNGTTXFOu60+Q/2ipjrgY4vTuge0ag1AUWToDcrPw0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=aOLx7nuI; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PPFB+Z7X; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aOLx7nuI"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PPFB+Z7X" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GNOeY001547; Fri, 5 Jul 2024 16:25:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=BNHVy9AS7vwwOInjOaqv29r2lsO1f2kEuSCbpguTGvI=; b= aOLx7nuI1OCl5wuR95FVme96+h9PtJVA9/W8tfF6iFKM0HM05JhKX7on09r/l1Sz bmMEAOa+qGzk/FlQPlYdI3aZqLSmeBpO2f+aRqEH3Kyaipr1akRzkHdFL690Ie28 E69GH4JjiwmTsDsSGZ13QDQg4mWxUzNjO0vSMUZvESDzuKy0+h/a6z8nqRR8JkL9 L+/q5wfq9MdTIiY9nyIFW9wWdM4TsO9j3lC20pH/DIlC7BWaJyH14jcfffEZKhi2 IOyD3O0O6T8A5KeejChBkq/VEy1CzmCyl+rG2AjqrqIQc1MypnlitqFOsbLBfYVr D5wWaLx/a9PSppdOFLjKYQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402aacmbcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:22 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465EUFw2010894; Fri, 5 Jul 2024 16:25:21 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qbjk29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U7AEzn/FdIP5p8m/ahPU2k9ZTUESl05AbjToKEwGsAYYWzbV9yXnIx++u/ucv1qJIXsCwTFmqUztrFAf585eOpxPZKnufDKccfK+BqvLa3npUl21SvjuGpYlfLEVgWhfUhBrEPanV87eJDVBGX9X3bKvKBoPctf5nMuyb7sPClhmqt8005yq7jgqFdL4MUCd4wa932owuDmtyz5Z6EJr4ziIEQXJmXhvdOJX0JnDjkCw6fZydjnQ9LARZdYMtUVtKMkMlnCIlzUaScgmKLxANhqdQUnB4WPcCf/SL+7B+3wWdMdxeZ4Gxll4wxYTfcRsl5CGFJ+p9IEgqy4286tVTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BNHVy9AS7vwwOInjOaqv29r2lsO1f2kEuSCbpguTGvI=; b=NfGZjDbF3Fd6AGjA27T1YGgOENkthpik+wEyWlTOocz+c+yuV798GBFrXp7613MUpjRj79lXW31z42caAY6RjSyoZsCjUFymzC/9tarixpVuHqpqF/4Zh42qb8Xrs7h7G3swsz6H89b1hivEgHwadSavEXDDh9UpD9BUNqXSjy6VTOFeF2wC7yHJkhmKw9acrqAEoUErA8+Li3YCDzuaZvUpHmjM+C8UmEjKTQkEbCVTWTX7bQHwbk4yD3Fad1Y9Fa/+AUsRbth+V74VBwImu/kiERkwQZmKDDGoDsSeCS8C7HUjSERZ72QX4bw0oqvxiKwqxoRpCnmuZoDZ9i2sYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BNHVy9AS7vwwOInjOaqv29r2lsO1f2kEuSCbpguTGvI=; b=PPFB+Z7XB0B23AYWSK6Ah1gUG7z92CbSGAKrqufflQ5Cz9fGSUNFWSgKPKQoh3SARO+y4XRmnnL6/tKcg1X64h1DTyC7CvE/AbFNUH/dIrbghST9QyciAoqIv3fOTDfBfoO4Po3v/jNbJL2tRZNOsbi1rskuUrpWtJxLLkWrQAg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB7361.namprd10.prod.outlook.com (2603:10b6:8:f8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.30; Fri, 5 Jul 2024 16:25:18 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:18 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 07/13] xfs: Introduce FORCEALIGN inode flag Date: Fri, 5 Jul 2024 16:24:44 +0000 Message-Id: <20240705162450.3481169-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR03CA0005.namprd03.prod.outlook.com (2603:10b6:208:23a::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB7361:EE_ X-MS-Office365-Filtering-Correlation-Id: e0c4c72e-3653-4d79-9ee2-08dc9d0f0f00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: TwBQj/r4S0TEb5wr4mzhrsbbr6gv5yXNMQ+1k3+2qgYFSlkQtmTBf6xDnJr9qwG7+c5PkyVvwaueNF7Wlqqvn9tXgJkggP65TqYfxWctgjvJ37MMCG+cINHEDqXET/PL1sJCWhqVv8Kx0Zv7kklMIy4nR04y+gEFM+WLy5bzfajDPlEy90Sea5iiAd+N+KnwsKKLNgRbG/NT7rnuO4j6/MeCWcCtG1tByrvpl1mmzdBGbU4rU9FddMm+8ZSfVJSY19xDxy5avWwBR80X/sYuS2AkeVNJeUbja+9y9yZsc1Kv8SfqQFV30h57Mrtx9LbauNyQ8MDNxwa7BkDLfWXVcY1cWz/9Fyoh74BDhXPPpf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FV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6SNuoMo1WzWgzGp67JmvVgvQJCZiYCF/7jK5CiCEPIh2PFWkK6mE8Lh73kNqv5JLrbHTuk7NQG+seuC0tL7Kl7h7pmOkNgy71RhTFyiwBJxT3t2IlI894juIRHxCfneHXOjjgvzhItOtnBo1O8X+xhWN4MUmVF8L5KiLhxIzw6RslA9q0Bqk7efsDHZC/GfqFaCTlx6nzc+GHHsFnIOV//tRbhPZs/LbSYeEhktaxMLD+p6Lc90svI3zMHzM14vQiEjUtA4GPqkc/IZ+FMEWZ/jALQQfp7ymIUBVADyi0Ioa/WLUNQe9dJ137KbZm8LhPkgVTEtgmDtQkJqYoQEYkKJFz/kKr2R1ob7/MH8NTfOtLCw5icrQqru90Qm66lQywnAItqE27rAATgPYi7eKA7bu688zSfAOJPHHlaJ4ZfQIZH8+YODQjHg6IDewoL03ZrlIuEOZnIZz2EAZ/273V/wm95gLA3LmxC5hmKQh/Uccj08VTNiI7u0l738JWoVM+Q39v6iMdfI4e9uroGwOr/FoUE2HS4U2uVAL3NVZqOniB4My11djVxvHgs3iFa6BMOT1hukyRZns5C0G3PwAFqtzUq8Z0bVwj6XxOiZzszI2hYKP1AXYuXBrjIDPRt33gJ2+brIPZOhAKSi+gqDw8Q2qJCHcsIYy8YWNnNMnI1n6VMciWj0bvOkq42aFGVT11cA9r0wzWd0SE3yPBWK8aLbzKqFQhMTHMtXjRWm3DbGnJdIFnqBGvz+W0yzIJc5Af4uoGGIy8fbY3UzD0k738AQxENJw+R1xw1SEe3+udoDr+g1ffJQ0UFtoCqLRWB7D2aNXipiZ/tREnF2n9Qyk5XLK+8LxDP9ttN85XrDr2MBKlRsfWyCmyNuyuKZaCLNOXNi8zjcRpFnYZITF6G5Vwo3Q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7W5hZD2uA8KWOqqnLcYTpWgtgg3jjZ9RDEQSE2gMMCv6FU3pI2MJQAsoiqzKyp8jKCkdyJH3n8dbixnysFE3aNp6EnRLHo+2WAo/XFx9R4d0QajxPWSmIdIuMxh8+t+9UtENSco0XE8mapuxhPFG8UEd1AL54t7t0AFCaTyddUkc+5eQmKLnKVC1g8lsC/bXhkm2RMneUq5NdR7PvmXpR1cX2dT8zJv/JZvCzO8m3j6QovGGichByGokwa3TOvs1TzTCKnXE5OSjORzCM8+R3AiOz9cGvFn2g9yHV5AopQiE3ewOEN7lA1C6qoSBI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0c4c72e-3653-4d79-9ee2-08dc9d0f0f00 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:18.2681 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MgKYgZd/4hPBeHmI1qszfqwV8+ulFujmgNZ3b7eLFxdYLEw2K3NGAma1NxaBSTm6XCdkI0lYgrwKflXgR4TQeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7361 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: t7vc8yu7igjGDYBx3H-bLu2_CXziki1w X-Proofpoint-ORIG-GUID: t7vc8yu7igjGDYBx3H-bLu2_CXziki1w From: "Darrick J. Wong" Add a new inode flag to require that all file data extent mappings must be aligned (both the file offset range and the allocated space itself) to the extent size hint. Having a separate COW extent size hint is no longer allowed. The goal here is to enable sysadmins and users to mandate that all space mappings in a file must have a startoff/blockcount that are aligned to (say) a 2MB alignment and that the startblock/blockcount will follow the same alignment. Allocated space will be aligned to start of the AG, and not necessarily aligned with disk blocks. The upcoming atomic writes feature will rely and forcealign and will also require allocated space will also be aligned to disk blocks. Currently RT is not be supported for forcealign, so reject a mount under that condition. In future, it should be possible to support forcealign for RT. In this case, the extent size hint will need to be aligned with rtextsize, so add inode verification for that now. reflink link will not be supported for forcealign. This is because we have the limitation of pageache writeback not knowing how to writeback an entire allocation unut, so reject a mount with relink. Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry [jpg: many changes from orig, including forcealign inode verification rework, disallow RT and forcealign mount, ioctl setattr rework, disallow reflink a forcealign inode] Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 6 +++- fs/xfs/libxfs/xfs_inode_buf.c | 55 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 ++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.c | 13 +++++++++ fs/xfs/xfs_inode.h | 20 ++++++++++++- fs/xfs/xfs_ioctl.c | 51 ++++++++++++++++++++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_reflink.c | 5 ++-- fs/xfs/xfs_reflink.h | 10 ------- fs/xfs/xfs_super.c | 11 +++++++ include/uapi/linux/fs.h | 2 ++ 12 files changed, 164 insertions(+), 16 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 61f51becff4f..b48cd75d34a6 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -353,6 +353,7 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_FORCEALIGN (1 << 30) /* aligned file data extents */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -1094,16 +1095,19 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ #define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define XFS_DIFLAG2_FORCEALIGN_BIT 5 #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) +#define XFS_DIFLAG2_FORCEALIGN (1 << XFS_DIFLAG2_FORCEALIGN_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_FORCEALIGN) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 513b50da6215..5c61a1d1bb2b 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -657,6 +657,15 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_FORCEALIGN) { + fa = xfs_inode_validate_forcealign(mp, + be32_to_cpu(dip->di_extsize), + be32_to_cpu(dip->di_cowextsize), + mode, flags, flags2); + if (fa) + return fa; + } + return NULL; } @@ -824,3 +833,49 @@ xfs_inode_validate_cowextsize( return NULL; } + +/* Validate the forcealign inode flag */ +xfs_failaddr_t +xfs_inode_validate_forcealign( + struct xfs_mount *mp, + uint32_t extsize, + uint32_t cowextsize, + uint16_t mode, + uint16_t flags, + uint64_t flags2) +{ + bool rt = flags & XFS_DIFLAG_REALTIME; + + /* superblock rocompat feature flag */ + if (!xfs_has_forcealign(mp)) + return __this_address; + + /* Only regular files and directories */ + if (!S_ISDIR(mode) && !S_ISREG(mode)) + return __this_address; + + /* We require EXTSIZE or EXTSZINHERIT */ + if (!(flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))) + return __this_address; + + /* We require a non-zero extsize */ + if (!extsize) + return __this_address; + + /* Reflink'ed disallowed */ + if (flags2 & XFS_DIFLAG2_REFLINK) + return __this_address; + + /* COW extsize disallowed */ + if (flags2 & XFS_DIFLAG2_COWEXTSIZE) + return __this_address; + + if (cowextsize) + return __this_address; + + /* extsize must be a multiple of sb_rextsize for RT */ + if (rt && mp->m_sb.sb_rextsize && extsize % mp->m_sb.sb_rextsize) + return __this_address; + + return NULL; +} diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h index 585ed5a110af..b8b65287b037 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.h +++ b/fs/xfs/libxfs/xfs_inode_buf.h @@ -33,6 +33,9 @@ xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint32_t cowextsize, uint16_t mode, uint16_t flags, uint64_t flags2); +xfs_failaddr_t xfs_inode_validate_forcealign(struct xfs_mount *mp, + uint32_t extsize, uint32_t cowextsize, uint16_t mode, + uint16_t flags, uint64_t flags2); static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) { diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 6b56f0f6d4c1..e56911553edd 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -164,6 +164,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) + features |= XFS_FEAT_FORCEALIGN; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index a4e3cd8971fc..caffd4c75179 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -609,6 +609,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + flags |= FS_XFLAG_FORCEALIGN; } if (xfs_inode_has_attr_fork(ip)) @@ -738,6 +740,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (pip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + ip->i_diflags2 |= XFS_DIFLAG2_FORCEALIGN; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, @@ -746,6 +750,15 @@ xfs_inode_inherit_flags2( ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; ip->i_cowextsize = 0; } + + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) { + failaddr = xfs_inode_validate_forcealign(ip->i_mount, + ip->i_extsize, ip->i_cowextsize, + VFS_I(ip)->i_mode, ip->i_diflags, + ip->i_diflags2); + if (failaddr) + ip->i_diflags2 &= ~XFS_DIFLAG2_FORCEALIGN; + } } /* diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 42f999c1106c..536e646dd055 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -301,6 +301,16 @@ static inline bool xfs_inode_has_cow_data(struct xfs_inode *ip) return ip->i_cowfp && ip->i_cowfp->if_bytes; } +static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip) +{ + return ip->i_mount->m_always_cow && xfs_has_reflink(ip->i_mount); +} + +static inline bool xfs_is_cow_inode(struct xfs_inode *ip) +{ + return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip); +} + static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip) { return ip->i_diflags2 & XFS_DIFLAG2_BIGTIME; @@ -313,7 +323,15 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) { - return false; + if (!(ip->i_diflags & XFS_DIFLAG_EXTSIZE)) + return false; + if (ip->i_extsize <= 1) + return false; + if (xfs_is_cow_inode(ip)) + return false; + if (ip->i_diflags & XFS_DIFLAG_REALTIME) + return false; + return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f0117188f302..771ef3954f4e 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -525,10 +525,48 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_DAX; if (xflags & FS_XFLAG_COWEXTSIZE) di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; + if (xflags & FS_XFLAG_FORCEALIGN) + di_flags2 |= XFS_DIFLAG2_FORCEALIGN; return di_flags2; } +/* + * Forcealign requires a non-zero extent size hint and a zero cow + * extent size hint. Don't allow set for RT files yet. + */ +static int +xfs_ioctl_setattr_forcealign( + struct xfs_inode *ip, + struct fileattr *fa) +{ + struct xfs_mount *mp = ip->i_mount; + + if (!xfs_has_forcealign(mp)) + return -EINVAL; + + if (xfs_is_reflink_inode(ip)) + return -EINVAL; + + if (!(fa->fsx_xflags & (FS_XFLAG_EXTSIZE | + FS_XFLAG_EXTSZINHERIT))) + return -EINVAL; + + if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) + return -EINVAL; + + if (!fa->fsx_extsize) + return -EINVAL; + + if (fa->fsx_cowextsize) + return -EINVAL; + + if (fa->fsx_xflags & FS_XFLAG_REALTIME) + return -EINVAL; + + return 0; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -537,10 +575,13 @@ xfs_ioctl_setattr_xflags( { struct xfs_mount *mp = ip->i_mount; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); + bool forcealign = fa->fsx_xflags & FS_XFLAG_FORCEALIGN; uint64_t i_flags2; + int error; - if (rtflag != XFS_IS_REALTIME_INODE(ip)) { - /* Can't change realtime flag if any extents are allocated. */ + /* Can't change RT or forcealign flags if any extents are allocated. */ + if (rtflag != XFS_IS_REALTIME_INODE(ip) || + forcealign != xfs_inode_has_forcealign(ip)) { if (ip->i_df.if_nextents || ip->i_delayed_blks) return -EINVAL; } @@ -561,6 +602,12 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + if (forcealign) { + error = xfs_ioctl_setattr_forcealign(ip, fa); + if (error) + return error; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index d0567dfbc036..30228fea908d 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -299,6 +299,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ +#define XFS_FEAT_FORCEALIGN (1ULL << 28) /* aligned file data extents */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -385,6 +386,7 @@ __XFS_ADD_V4_FEAT(projid32, PROJID32) __XFS_HAS_V4_FEAT(v3inodes, V3INODES) __XFS_HAS_V4_FEAT(crc, CRC) __XFS_HAS_V4_FEAT(pquotino, PQUOTINO) +__XFS_HAS_FEAT(forcealign, FORCEALIGN) /* * Mount features diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 265a2a418bc7..8da293e8bfa2 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1467,8 +1467,9 @@ xfs_reflink_remap_prep( /* Check file eligibility and prepare for block sharing. */ ret = -EINVAL; - /* Don't reflink realtime inodes */ - if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) + /* Don't reflink realtime or forcealign inodes */ + if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest) || + xfs_inode_has_forcealign(src) || xfs_inode_has_forcealign(dest)) goto out_unlock; /* Don't share DAX file data with non-DAX file. */ diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 65c5dfe17ecf..fb55e4ce49fa 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -6,16 +6,6 @@ #ifndef __XFS_REFLINK_H #define __XFS_REFLINK_H 1 -static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip) -{ - return ip->i_mount->m_always_cow && xfs_has_reflink(ip->i_mount); -} - -static inline bool xfs_is_cow_inode(struct xfs_inode *ip) -{ - return xfs_is_reflink_inode(ip) || xfs_is_always_cow_inode(ip); -} - extern int xfs_reflink_trim_around_shared(struct xfs_inode *ip, struct xfs_bmbt_irec *irec, bool *shared); int xfs_bmap_trim_cow(struct xfs_inode *ip, struct xfs_bmbt_irec *imap, diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7..4f0c77f38de1 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1721,6 +1721,17 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_forcealign(mp)) { + if (xfs_has_realtime(mp)) { + xfs_alert(mp, + "forcealign not compatible with realtime device!"); + error = -EINVAL; + goto out_filestream_unmount; + } + xfs_warn(mp, +"EXPERIMENTAL forced data extent alignment feature in use. Use at your own risk!"); + } + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 45e4e64fd664..8af304c0e29a 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -158,6 +158,8 @@ struct fsxattr { #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define FS_XFLAG_FORCEALIGN 0x00020000 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ /* the read-only stuff doesn't really belong here, but any other place is From patchwork Fri Jul 5 16:24:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725356 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 B2BAA16F0EA; Fri, 5 Jul 2024 16:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196731; cv=fail; b=INWTi0oz51rIv95pcC10jNKImr1Sd8Pqv77wYV3VqSWGa9TczhSbXXVyCLAcu+rq8OBFy3Yr3kMrZxsEONMmLWLkBiu7i7O1WU4aI4XtjzEhAhxwzANI+IIqot7JTOezIF4xvYAJ97PT7JAdJuB40oJGajZb7tGIqyjdLqBtmSY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196731; c=relaxed/simple; bh=rZVCo9aLhqp1blOlClj0pjFQK9NTtNJrDY8y9Frur4A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SXwjvBYaTN9DyS3iOvythGKy+ia86NBW1FaTF2oKnr8Kzkv/DWhlzD17uxegCYhjLu1+VFDoy8X8LV3Gs3hoF9n5BcZOEaMZARGt9ujWCNaYrsY01SfzoSBFd9iWHbb9/n1RPVLXDWHoCwApuFF4FKiritqTjKWHQ0XX5qHSgQQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=NCOb8bEg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=J3/pJnbR; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NCOb8bEg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="J3/pJnbR" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMXvs007941; Fri, 5 Jul 2024 16:25:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=fH+NjeJoJ8kTTBBuZuuq71TIHENCLkxgvQrCzd+oBag=; b= NCOb8bEgv6DWUFl9sfXaKlyPGH680E/4qY5cvv+QWaYHH2njIqKM+Ib8GFhbqFMf ZXE8EWw06SF1ed/qK5CGSbSmqJHZatqQVhStBGqWyIKyGmbjHs+RVXnbu+FmXy/Y H5Rehju/7ppV5gOFHLPBzRLeS7OgLtijBPxiHejYqsvveDmz2fcB7LSGAxbqcIe8 6KybG1VP0iOUZWOxnl5Q2FYVNHswrdcisty/jbx9pJnmJ4lq2UH8to+jYzHWe+xZ HbzcRmUtAhc21q0IYqetn7MYGYvZknNLegs4jrktM/36tgARCczFJ7R13/7aaH+z qnjKbVK6JDlfr0PAM2kGtA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 404nxgns5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:22 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465Fs18t021462; Fri, 5 Jul 2024 16:25:21 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4028qhm3mc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LcZcQ97tXYMyQ6GOhDWKPtiAs87jJdH9uox/2BACy6xqYOSyAc2fuoMsjisKoDTN/Qextd8ULzDTnx9voSkPRdsEW2ims7ZSIPN7k4GfHVxQl7ecZx5+tiCh5Jv8hTtTWjymv2omPdvEP9lVJpqF2QSajU66KdObQohM4CrhqZ9+VRggKSAeHEyNh5crXj12QhevgpGfEZF0ftvHte90NiuYh0pkorxw92btqqdJqdmFR5fz0YfT1ZK20u7fHC7bXQx4OyZWSLohbSjNpqsQZMR6OYj4XiaxOu7mKJyoSWNd6rIgnGhULuDtUH+X11KY7WNn8aUjM/dW5r88IYO/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fH+NjeJoJ8kTTBBuZuuq71TIHENCLkxgvQrCzd+oBag=; b=TmtnwkVLls8VPCOJ36KqtEBdsOOarirBbntTKQhR0AYVNl/LvcaV/OEWS4U0yYrjg9xRdQEZILns+EFRkUwVN+pFBwgGNbhkoSlsgbxtXTT8aHBxxl8LH1Nso/BYd4YKoDoR9yP8KAZXXULHX3NLb7ScJaf6pxCdmSnaaZ8V9/bm9RQGSx5bSjxWdN4U2B+mBSISk1GiRhvZ7ZKK8G9X+AWzt9f9l6uWlpKfAC/oveDrL7sLeZ6Oh8L9FEALBr10kqsti8Zrup+SzjmE5e+ISSsLm/wEtf5DW03hqYPS4ENF82j3LLMa/Pm35R2UoDvt86pN2b4qj3mgCkwW3EaP3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fH+NjeJoJ8kTTBBuZuuq71TIHENCLkxgvQrCzd+oBag=; b=J3/pJnbRbkCZgpJpJtfL4xg4qu0dT0pB5moupO8gvWdkZA7mVl2FLDiLELxtd6mWpcFnZN6FH+Ta/KuOQ2qcONdLtxKuFzmTCCEWrTsBI8Qq2+Nicr64xCuAVKIMoDoXPG4PRlF2V62bvBKi2sH7GHCEBnrhLfdjc+HzuhJLcJ0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:20 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:19 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 08/13] xfs: Do not free EOF blocks for forcealign Date: Fri, 5 Jul 2024 16:24:45 +0000 Message-Id: <20240705162450.3481169-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BLAP220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::9) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 62a1b470-d82e-4cae-598e-08dc9d0f0fba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: JQVkUC77sMffXaQ73Ge3WU/XhFeYCzlHZshdjUxb+CTk2blzPjkzVwQafVzeaoJxelsnng24DenPr10tJAQK2eKyJns78JW2Jz/sschfLwPX76oSOV/U+4Wzrb5eUQuP2ZFH17VSpyNuz8n1VwqumF3Eqa+NyE6Fn96/PERgO+gyeUBRX0wV0GquDoM99ycXMH/JjODNxNtpwxpCgk2MmlOB50+6q3eiu7KxWiIOxfOUjgaZP+Z3kQgnW8rdwHp73TEJJoRoGm540hfI6qwlSg6Z2QTMkEzJjAUWnhvyP32YIx2YoNKkMzB2yIa1ovcRPYTePPlPDCgXMaOsEZLy+bPuFf8qjX9EInqq09Qgmbn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SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E+CMRZ9wlNQ1v5RZcBr20aYoU5Rz89cPCp9SD4uroTPhYg3SUd4O1b6GUa7lN4zhN3tG/zTjhr4dNzmEHGlTucb9D4N9EEbaIG5ZBJp+u21gRVMGXmf07gnzVL0LxZEfe8LGHNnmVze+QvPovmVnDxJAHuWPMr4sfYnBRhRioNBF+p3neLcCuQUANiC4RyyjhBmp2nF53JZczJoFrcP+n6Qzy+5jsgg6xnYSl4vdw9BpmjxKQHn0gyFOjd0w9nPumNGnUiC5fgJ1GxrwgC2KmljgGTZY+tv8xLuk1PsFyZA9zivVYMF5Iwoqskc44iN2Wt0mKO43i6yoff3cV/e5yEeWAaslhsLvF53Oaww85xJ1E/zpHEULw+isFOKxb8meAfMstxNAuXNqXaVZfEBXmkU+mY7Qnwp+6rshvgXwxpYsEEoqburm/+YUDVII4y+hHPMOWTkgjOSTNY2o21S/0jSRm7WuZ4g0N+kJry4ydRF0uBR+cEBMhfqAnxOHg9J/jzFrSjREwqZi12C4iv8pEiBkkw5bFV8Hn/3UjE8+mLLRu1Fqi+oFgC4sJ2toz8ye8Z+PTgoH+ZAePmef3xWCGvGpLRe3NlY0+A4HPUERudXQn/2/BfkyoSRLGqZL/sarrrqLkhTGxU2nrQscJglLfQQNDoMdSyV+zZjcO7MNSetzMkSj/4BtLui/hVfNnR9Ik9UrDdUEr3DH3jxwWDaYlZ8XWQHGlawhIlNBGXpZLd6XJGAVwWSxUZDlJTGegDNoEf4SJP6qekhlMgSlAjjoMIEQos6M/M2OZQEHUYN4maCQ6qInpX7+WV5JSUqLNHxOTmnllAWRPQddnPYxODYqM8LzwNNyQc/crKybcfsx7ZH1kaoOo4HokYBXEfsB7cYl0reyLBHZ/YGa0PGw1/oVK8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aVQuyXzrC3V9wpPrstBmraP/TzAeea99kKEtIeWJJJ9lmxBeQPnrLMoCXLwhYnj+eq46Hukt3GVuqfdSxFCczWDuQ61upNzfkr6i52SOmP7vRQ9A1Ek0q7ho1R0vjR7J9Kdt5w+LJPWx5MjbL4FDT17IFI2l/RPwhKBIJ7/pn1gGI7FzGeVegQsOZVL5KNP9ACA1Bldq31po8S1R4jZM9WHxaTv7BgxNWNjX1WDSmZRXYHtwlBqrZFkCAlExbh1AHoRswOLPyjH28vOQbZm/7gtNmI7svio+21j5+vFQFjnZ0id7ALrFnHlPkqdDVTypVzV3vU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62a1b470-d82e-4cae-598e-08dc9d0f0fba X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:19.5709 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QdJnPWtH3xXI/L6JkBc/iRvcCHFVmVR/X3edn6kpKIln0AunbrLq6q/MhRqls5C9P55hMkibBnJ2h3iq/X952Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: mHqv-M374h7GUqfwctf-LD2ElSFI2ZrO X-Proofpoint-ORIG-GUID: mHqv-M374h7GUqfwctf-LD2ElSFI2ZrO For when forcealign is enabled, we want the EOF to be aligned as well, so do not free EOF blocks. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index fe2e2c930975..b9f8093ae78c 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -537,8 +537,13 @@ xfs_can_free_eofblocks( * forever. */ end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); - if (xfs_inode_has_bigrtalloc(ip)) + + /* Only try to free beyond the allocation unit that crosses EOF */ + if (xfs_inode_has_forcealign(ip)) + end_fsb = roundup_64(end_fsb, ip->i_extsize); + else if (xfs_inode_has_bigrtalloc(ip)) end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); + last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; From patchwork Fri Jul 5 16:24:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725377 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 ED86D225A2; Fri, 5 Jul 2024 16:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196859; cv=fail; b=s0elGYdU6kbnCMLfAKea82R1xnOenKbBVouGU4uesPISjOW9NvsG/H+u4fClQC36bt4vx12tWspWYddMi8pk2Wu3HGwdfBOpiaKvIXr2UtoSp+mcLKQtIzp19b03rJnVrPiw1x2pipCnRr6YjytaO3FKmrkqO+r8VMLrliRcAQk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196859; c=relaxed/simple; bh=dSJQH6zfU5QX1ZaM/4cYamfXiff6T7JST4rjdWxkhQs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Cmdv6yBlfOTZOdCn9A8fIg1iXdO9gzADmWOeTWB3H8EbZ++o4qTVsThMGWKIxyGIENtnyI/TxEcU8g9Pvxl/8yeZAz/Tp17fgicsfKpCFZe2IX/piKCi9ysjuDmhQpQOUVnGU1HXSuERz6Fz4E21QEky/3UcjwkgP6XRhbUAtdM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=ZemfifL0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=NbxzMkt2; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZemfifL0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="NbxzMkt2" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GNSkL001566; Fri, 5 Jul 2024 16:25:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=vlAYBQJBsgxS6fQgFAGJAsbVGHASzWHqWCB2/1SxHag=; b= ZemfifL0b0OdwV6Tva9x7LjfOL6QNlMA9P1ON8FuwnSHEVoWRbbPuQL9lVjoaiPb QrpbkWM8cqEiMNmVPZBceCCYGVxkQx3AV/wideCu/wetdt7ezf+QaGIxMBxsFLd6 vpkbkaqwo0FPLYZU8iymHn9iVR+0f4zCGWOpPBvCqb5jNLKxVRE2AeeGD5FiHMRV SZBWlWi+jr93trZGuFT7mNa99DGvpaOmRFm2mlgCQIEiEeTeMqBPrnKOxCuE7JpO 2jAl5b5kqm62BXB6QnHlmu3tDtJofLHWU5jHvbIxZKqC0Xe9itTogbLalQs2yv7O I7ZijXZCArGyj3wHdy2WMg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402aacmbcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:23 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465Fs18u021462; Fri, 5 Jul 2024 16:25:23 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2046.outbound.protection.outlook.com [104.47.70.46]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4028qhm3mc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UeFMKDjYg604qgGQ+Vwuw1IAesqoGNEL7RpG6dyJQozm1ih6njTEP40XSTNy4q6yic99jrmcmriQwRgM6Z8eenFdK+0P6SVte02OsoJJCL2TZ0Ps0I+gnlGswDG1XRpSFujo5onbNPiPUqZ9AFxggRXAXpj8fsSinw5jGhPJdThbpr/S9lH5E0UCpuJu91vQKVyVL9iKr7cziCEJEr9+t3RDOGyxE2FivsRVHuqtV5zzzqoBTr4wxr9ozVPkpNSyN0eSdjIr8h5SVHCHRmBLYkXXg5+JcAxZZcHD54e/n3kTj9EINc+XyLBoH/1z0DyMqLML9tHPN0ClCTw6th45sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vlAYBQJBsgxS6fQgFAGJAsbVGHASzWHqWCB2/1SxHag=; b=d6SwcIumYjVeSrmXx+DAZQQ3mExRSMVpmrb6lY2ViiDHid/t4zKgTHD2WXEo+SRFNpJP7cNTH0SQ5U/TfRH6kRRCAgiKeIeUnLoDdOcy+56m35LGjAWk7qFrcyTi1/dhWKup5r9yPirgvHOeyZAG9AtJViqQgOo2Ha8NQi9w+Pb1Gf9mV+24AKW8JGvowjDqrCy5rD3kU1mgGSQokRf+arYLRVJwIfdojEk9uaLDXL0WyeuEGQrKsTixiywuX839jLzbCfNcR3v6G9pFq8VoGZ0k8vSh3TYE0z/88plWBYxNITHQdIPSygIwUbOQPGFcP4+6NP4LCRId/PbbV5Ad9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vlAYBQJBsgxS6fQgFAGJAsbVGHASzWHqWCB2/1SxHag=; b=NbxzMkt2bDX9DahwEo+t6m7UfoYtNZ9x96YM9PNH0thxmqULM7K3Ny7avyD8EepXkmBDWaydGWohY/LbEcSzOpWBOw5ecv0FigrHCkAMZc+RBFFuKGpTl2TcoxBfLJDAltwqrE472YcwKxQAaQUau1qtwui7+z4lgiVgmaXkoAc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:20 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:20 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 09/13] xfs: Update xfs_inode_alloc_unitsize() for forcealign Date: Fri, 5 Jul 2024 16:24:46 +0000 Message-Id: <20240705162450.3481169-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR22CA0019.namprd22.prod.outlook.com (2603:10b6:208:238::24) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b3b1d88-05e9-4506-60f9-08dc9d0f1076 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: R7ARFIlK8WJqcN6aS4E+95CFdnIYJsUUpwT1IrIOf1OkKM23ePtIQ/SIGlM4jx/pksa5OMP4UnW9WIrTjYkv24pIaviPJAYsFUKQ1FUpkaMRuUEY7Z4LBKUJ+yxsODUS7pRJT/WzP0/ILKy1R9PsxUlCJFOLxwysK1fm4C2UeluVO2cXaLFZq7udhGE/y3hxPFxEFEWb39VRGmutcrBsLLjX8nG3dMsHjxTxTXDp7f4bjFvcOfWngtF35aVW4f8kpDPwpYPPv4v1DhsegcG0CdD33vtIJnLloQUNxKOtxWatQlcLcudW7o1R2pt9e4nIqaXicG+XMADDlnkORslX4vW1UQ4/bTkVllbWlRAO0/qPTflpLf+o3a7kM3bWa+Z/3SnEQ4zZNzp57GRm1UFtCDH7FCPlbTOXSsokWpLP5euPZNdD0o7oWRAEHEzg37PQ6hln4UpfeIVsmyBuv1bVEnsQFQXGX4qNlfTo4BDYpQNdpgGDI1OL0qU68W2wWwg8zG5ZDwVSBwLeeP9jBZBDxLtJkUrVDvW4uyGqP3JTJze05o+pqDGXypmSu4SqJ7/Q5/JMijEMYAcqp8vBLNjoBKVagvGZp5aq1Oz6kW6dRQaFfKFWd998SI8VkRwwYhJkPYnUrA8zxOx6jwPuM7KEIxDBn6y/QjP/7jRD5VJ+aDAr+cfRKJvdMyEIK4Cqx3a/lqxuXDVFM32nyw8ZK+JzMuUIXsc+KHm/OhvW1+0NDHIiQJpn57EWP+lXgsIayPQwqhTCX5dX+dj1SapdovR9T77gUYB+NtdtzNEIWsoPp+vkK396UkPBhH+KPZCq8+8Dny6JEQ+T77RYnjaJqol8HZ4RuQUyIARZHLU84zgeTKo8IfcwVXvjMitBBsX+nDKqxK8ImeEQzD5IY+8di0a+D2iDHNYB+RoTvNtsd4ZPJehF0d7d+1G/7RtDWEql522i/IGI5mp2uOL+9Nzq77z9tsP/vlZbBFNCt1JX0mwW/PKik4eFVYVS6Onqj1LOZJQZ38Xonak2mgamFX3+yMakdwQkdDPiyCHDiA8bFswDyhmPSMxMes487HersK9G0H8oIBtHlgF80adBsTNGOMXVz1jJ9bNodE8F6GUmcjGCovtBPn6HF2gLbsD+1iJe94MLZTdBKepiOi+26lvOn1tQxCfBICL7anNx7nc6U98c3Oaq1EZzmY2+ceCK+6cWgHIBYGWRn4ji7qjwAO8kf72XvGZGd0tvm4PXE6SN+zZkxGxngP3n9xZnhlhHM3Pp2AkmatN5a503eJQVyTwvBk4RrmY/g+PaTLsL4HgR0A/aTqYQCl9qZZcrFQLFaPO5KNeh6ZuKAspwgvVVCqyrNEJqag== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zsdQUxMVLrj4aKXKAhLntKeomdP6M5Cywrgnq2hLfxmR1pPwhgGnBtDAd65cb54r6t9JpHNbNgKekPKsbj53pAmOt9gnI7PGnMFp6q0PL2iS51ZUxYlha/FKzVv9X986GGSDCKoQZVGzmsLCHZXSCHvJPEbWfvSoO2ZJerWx6ieL1lA12gAippnJafxlHfEDm1jTBRAanK7sLJLTx3lxEUgG1FgT2CMVc+p1s6cUfY4nKMbUCBl+2uKSrXxSHqU7Q1G+h4Kbs6YTBYaR82qGNSz/eCpCN1eO1EXR6UduK8U6tz8qnq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SJa6CofmLtBhEvszFBSRo8lCycW5U2cNu0uv4mDMTrtreo2+USqYiZos6R7pffgdFyJcdSQ9hawlbfsGIWx8RzZbHjFVHzi7HNudFEJ9dhd1dQU69wOKNJ9IWBiQ9A/hfWyC1JAMwJS2So0EyET5Pj4yd8j5C2h55q0ckVKuqEBckqaWiYSFXh3ON5okYfxB9bDkj0xwHw4ef9ZNblA6/+CKPuw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Tv/1r8QPCRf0uGZWVrSYaoh+f6idKB+nC6eYj0J9trbUoY+OzZauKQxSkL03nofMue2dM03SY2/kDrHxwneadV6FuTNlnDqwZ4GW0Q4DYfLujz4f7RNTaQHY4Onq3We1o5qjKuyhrEK9QS28BOG9QQYDSVAAoP4bU5dznozECb8EAqo3KuIoy+CMioPvxKJjwoWbDMlttTWfOb1WGO3v05OpGObJ4mmeBREtJphjwOfwdYttaEbKUQlHZ49UBQMv/cVYjo0Ta01r7bRkQAHOVzG57IjOpLdDIW9RjluMw/CEIgkms1hW8Gr8cJ/10+3he5OPllb6IQcWSklXtXRJYbJOdlYpZ7RjNct5LADe0tNNwr1lR7EsjsypPxkZN0XqLUZ1uhBDtBPvGQQpU4z4xhSQEyldNXbaunIMugyzl4fPw0nhwzfc5XxPH5dCJAFIaBYLKGsmXfWHD+ZozVRq8a6OeJw0qVgYxypFf0gQ0ETdh0P1vyHGbqo1sV2VYeKAX07PYY1e1iufWJhZ7HQe/Is05rucKQYV8eZVlkCIj/PcKPzF1umRA2tROxEvycC9GO5FJ90RE0ZznDk/gnVzFL54Z8R2Lpkg2A0l6Xixthk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b3b1d88-05e9-4506-60f9-08dc9d0f1076 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:20.6743 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C2tSy9+f96rPYZUsNQR8daqvphXjeiJHBzwFQm1JnHCY8Xw8kJQ+i8yuP6eSaaSyWY9YgMrtMUSc/NtsSbkrlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: tgKXK_JtonLkeTTVe9WHC3BXbxGYNvuc X-Proofpoint-ORIG-GUID: tgKXK_JtonLkeTTVe9WHC3BXbxGYNvuc For forcealign enabled, the allocation unit size is in ip->i_extsize, and this must never be zero. Signed-off-by: John Garry --- fs/xfs/xfs_inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index caffd4c75179..bf9e84243f23 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -4301,7 +4301,9 @@ xfs_inode_alloc_unitsize( { unsigned int blocks = 1; - if (XFS_IS_REALTIME_INODE(ip)) + if (xfs_inode_has_forcealign(ip)) + blocks = ip->i_extsize; + else if (XFS_IS_REALTIME_INODE(ip)) blocks = ip->i_mount->m_sb.sb_rextsize; return XFS_FSB_TO_B(ip->i_mount, blocks); From patchwork Fri Jul 5 16:24:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725359 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 C99C0170851; Fri, 5 Jul 2024 16:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196737; cv=fail; b=IUWGSs/KqXEN7Ekq5pdA6UaPKSeqImzPd453+5NkR88by9qEbNR3sHO/bu3w6cO6wyJm8t+0QA5fyfN3akMyMuKn3cqxIPFNI+mXWNEpbxXSoZD4evkqWsoSw9nXQxlizNbkLM9+ks30uxhEQI/xv9r+QgZsmCYsDqeqxox4vQc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196737; c=relaxed/simple; bh=f2A7X3UBoQTy4IYWo9s2Gvlu1s1yO0GhxLpEXJze4v4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BHUzJaRjlUIiamZa9V2OtZWl4U1d9TMT6ID1GZaB97+BZjBFzFI6eQaw2PGyjsDVLMcY094uapN211V2lq096fuBlJ21938ofWoeudz1f9GrfHUdzuRHbbd18e/+PeAA03hMvbwikdoSYJXYjzVJXnyH+YJNu5WcF7fObmxNQCA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=HzG5cIi8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=r6ZTaFz+; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="HzG5cIi8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="r6ZTaFz+" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMVML020400; Fri, 5 Jul 2024 16:25:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=G6t5KwLc7UksbTD1WiyeeJFTGHZtuMIma3y1qQt//3Q=; b= HzG5cIi8uSN4kLlBRqYtlkapT+l38mUsBuCn3x2otutsUyZ5GlTfT15GnIea2P0h h5HshRPueI02SQE/0kZX7Ce+AqJ89scVdtXNYE4fix74/ujVyiYBBKfe34xDZ7Ir g5b+ysVQTQESIwgx16I0tpwcv/75lZ7VIocdGWx/Ad2ZOH2AQHYEUNmhf92kVS13 XBxSPUIt0akAuTnoidN8w1dBjBMfmTsIP9polxcl9jJJwpOiaSiQRgSOBImUOE78 lIgVrWpdoz55zxbwtp1ZUcAIuygh2xOqCNua9Ewx5Euth9A2UV9n/eoaQGsypsBU E/i9XLL9Aju3rlMrLIfKqA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402attm8gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:26 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465Ef4V1023444; Fri, 5 Jul 2024 16:25:24 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2047.outbound.protection.outlook.com [104.47.70.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 404n12gg44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CS3CgFX/pLAR7gez2uGSINB+jPy6t6TBp1oNrWX1NvDi/LF4ecwQ6FbKMpNEAHP9apxewMkOieYnHlVsdm93f5lc0GI2a+pbo8YFME/Bo4tgpUpwHJFj7WdfmamOPAZ3WpNKUAO+divGsFxragWtto/V6oAivwJ6dlzGiGPdh/PSg57dXlzipmBTM0XPxxy3X7dpAzFAYcrRoDUV2y3hskrk/f/WPbUUJer8OdCAWtKPoGffhr226rOQb3tw2335tDhFCdSJ6MciGZslReKa4yLEu9BHjesFpIyxTXcQoMmLm3Deqojn80boUBZ88i+1CH0axp+HKylui1UlJioKvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G6t5KwLc7UksbTD1WiyeeJFTGHZtuMIma3y1qQt//3Q=; b=YivwMod/uUZjF28ogVMijMdLnN73sMNtHIGpM0pvEhij5mRmIMQfyc9JzIH1TqHRS18zrfyJH+nwALImWLZ//WlAvrJ+xlwG8lmyRCczxu/Lvq6d20DtgWsoJE+UeMf2aH/Od23FN6YlLZhHjATTz3gjyK6F0EPUbmaSiJEVj4tFW7a9ITaK5uDxiKBfwCJu7wcvPiDKTJwYh6d/M7nJyEiz5Zysk+BHe8rh+gkNjKTcXDMWGJfW72ZZScAFe60cwXApwgy/zz3NarCrqdBfBVtAzBf3VBfwh6ad5RRBJ4K/k3vcLPdjFBdj4M8WZSC/xq5gNhCu5oSKjJAWicww7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G6t5KwLc7UksbTD1WiyeeJFTGHZtuMIma3y1qQt//3Q=; b=r6ZTaFz+0VZYBibyPDKyDp9ogSsWDvIWYTM8M43SGzulqJBi4X4bIxUAvQ3VLctbSyOsAXMe3KLDYmnW8zp/tSkOjk3YFHdZBnFLjflNZPJYhSawrOduJx6kejtwBBP5c2Z4AF0WYsp5z65U5pWdYpW0VhheHjbNwikenIwo1/s= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:23 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:21 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 10/13] xfs: Unmap blocks according to forcealign Date: Fri, 5 Jul 2024 16:24:47 +0000 Message-Id: <20240705162450.3481169-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR03CA0012.namprd03.prod.outlook.com (2603:10b6:208:23a::17) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 228fdcf7-5f53-4bfc-bb14-08dc9d0f112b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: f8mGwR3W3prqLQuHrlErnjKZPZ2HAL7MBjlg0XKceqEkHyef024lZPl1tZ9W+UjulmE/baLbmMJ9yPMrTHCJvNytAhm/z3Xd9CvJLLsm3g8Miq2afSsE1KdmyP+7BWAuovZ2N3J40OgNDYrNr3MPCfaYhF4Ht6Kl2jiXR3+/0xEXKqhrO1lZM/v02YShLwFgcwoz0Xhwwrw2SZwSyqR2H4H5QGpmsTbIf4JxkjCDJ2vCb5SqzTPEwPPHwvVPoSS0FzD8Fve4/YxEP7PeLjmw3mGEIVMfl3pjbaOz/UrkxQQvsB2MpCJ5GfeSSV6rloMFKBuBLbnA1EJ8H/79YgapxBhJ3gtvdrLv8IOm3fkOunZnoehqEhq+YDmJHd/SdMJSTY0ie/YD6tGufTAB139apYDgB/1XpNJb5JLm5eZKqxR6Tb4rBB5BBWFKr2uwirL1Y2lCWswrGlcatZZstMaWRqLiX00mC4R0T4JDaZlGH6bTdhAykFfET3805xtGLb8Dq3yeLQ6YkpJwqNALU2Icp8OelYbiuFMZF9KJUnJeFqRH+jz1noW6ior6Vtbv8PggS8IeXlT4cHIjt13V5870qSytEpdUf47JtNVAoRn8ra6Or55wL+cKLt3laxrFRdXbTuKg5yfGHb+THX66EWluk1sLfO2i/binUWwg/ZzS+LbJyrFyLx6IPqfSK5/XoU+M0Vlt203aFuJhIOZ4ktEpNDX2FlVcxba4BvuO+OCh2WJ7P6Wy1LRhhQng0bgwaAUslpffJyLR+iBm3NYRJYUPSGTcr3mc4VAAUbArXsKdl+lxlVoIsQKRzT7uYH+mbZILzEbXlrya20b+d9XKWyFCdAzZPEryEEv3I4xiYbcDzU9hkKij5zY+aK+3ENpjfFDBYvP8o428kc1TLojl2bsxeA2lSKQ2MyqW3ks1l476MRrO+0dVAk0Qu/InXH4Qaz/v3EyVgsLG/AlWLfhpA6y5P8MyJal+0kO1UJVngD6zn59WJ1+5Gt4n9D70D4bN/SbitLFkPnKUhVObdAfbtkOZmyI/bOAfle/qSAdCBZwpS5xC9cDM1bnZZGPyobFIWSHox7Nxn+fv0eYKUYEXXA6pHzaOnrGeCmKu5amsAc93abvCwfoltVZzGOq8QwJSbS/PPVAGAmlzatrFa+MG6kWisImIavDCp8CC/7xx5xxUp4go2Ya02OmwC1dDduVpP5G06ObxaHYbC6a9Y5Lq4ea2MTr88+cYkbyeKmOd07+/MitFOYU317IWKK5OiN1LP1NJj9sRyVp/NcyOsn7J6mZxxiGavFJ1/LMmOMdhtjsAzxIvJdnehY/Esn+seEEueaT375CjZy3tD93bBVpBC1F5qA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HI1GOn68EGkUG8iUnexSc+fvZxeAZmIwPTNDboQvko4nEDuWVRWKACPux429j0weJjYVbM1aY6qcVhQlQEECl6afs+plae0A9oF/5fTRKR0PgU7Sc2LR3l6h+tOr2rSVMHWemw9uV9At58WtgT3VkwnDM74ASkTCD3vbhAXdfyDEvMGIxxVSNq+kXJmFO1F/F+xM3TqPVotvSWsAxqUKhdacPbrt+iJOH2BkoYS7up7KjuO5Tgzf9CkGoJqvduARFTXbGpBEY0ypMmJwy8cyKdTttJHjuRUf1khfk9wCPzsF7rcWBxyxyHnfN4uw45nFKpIO3EmgJXfGHG3jft2fb1QKutJRuRh5LJbmrSrMR2bG0o0jlQurotIEg6g1/+Ehuc96F6/3Gkm0hd4yk8dVxs4B0RGaKIIBvmdMUN21cPU31MtAEXHJkgDCOYjvH1asbeOT0MTBGcq3FU/MJrDSPxtceAGQmG6Rwvk4+hn1+u0BzBWgeqLACLvxs5N7gO04mjiHOhaW2W/K250sTCmityWiDv7HAKl1tBP1le7FFX6kcEemeHM/G8ZtWU9a/7C6TbNMU/1evqg4WuCHD7CeiDKxXeS/KU+NjIeahSrZyvYBidvKHhwGl8vsCfMR35VgYVLlbTttopsWZ2xCOxaSEoPWfR1esK/DDbjnfdG5QE0hQWBQDU9WSyizZz7bDMHuXGtK90yqbw84J3NzN5HhNEDZIYwBIwW/jz7Rbma0d0+YwmSDz9cO4SDNcP6+TI7f9FZclAqa6neLSzGwuX/+MCR7LljVpCtlZ3sZz/fypUOHe1IPjS+O5AzZBhIHO0/dE02WBJFLJmZvc8mp82qFiTVMi92op9C3mTAle/DaJRlvfQZ9kyewp4mZkaEDFR82KAj+dXJVMfA96foK5Q6ir24SLNzQMsTbtECrmEuK7QzfMqs9WNmIz6Ntp3cZDI87o8lP0Dc4PBVqw1Sr048WQwYwe0AM+D95jBNareY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nuwnbsblt0wwXyWJvG2jMrZ0H7F3rUq4RYLhKIdSZmndlIDQ4xWOwRT8T3//v3ybLewCWYG5d+vRXu3udCjcIwpE5fvMEB0g96o515ViT7UTpsnecms39gy2iXqmrbmKFJrzYOo/jZhuxsP/PrefYRJ5NOFIqXh3pFsAHhxQeMYB7Uhs4JUMwp9TQOHh0jByLHaSyQFP4ZkslIE/zr8jvWTIHIhpJEiOST0oykDEqdfyIE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 228fdcf7-5f53-4bfc-bb14-08dc9d0f112b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:21.9218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: E8PAHCMTEVwdl5LKTtJWAWtc7J+okoZwPKig3tZpcP6KqG15XXVU0Dyris7U3hio8xYcKBIFIFZA0ayq3+iY0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: HNbB-2kQtAcPdXszwt8SDpc3oq2bFI55 X-Proofpoint-ORIG-GUID: HNbB-2kQtAcPdXszwt8SDpc3oq2bFI55 For when forcealign is enabled, blocks in an inode need to be unmapped according to extent alignment, like what is already done for rtvol. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 46 ++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index db12f006646a..07478c88a51b 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5403,6 +5403,25 @@ xfs_bmap_del_extent_real( return 0; } +static xfs_extlen_t +xfs_bunmapi_align( + struct xfs_inode *ip, + xfs_fsblock_t bno) +{ + struct xfs_mount *mp = ip->i_mount; + xfs_agblock_t agbno; + + if (xfs_inode_has_forcealign(ip)) { + if (is_power_of_2(ip->i_extsize)) + return bno & (ip->i_extsize - 1); + + agbno = XFS_FSB_TO_AGBNO(mp, bno); + return agbno % ip->i_extsize; + } + ASSERT(XFS_IS_REALTIME_INODE(ip)); + return xfs_rtb_to_rtxoff(ip->i_mount, bno); +} + /* * Unmap (remove) blocks from a file. * If nexts is nonzero then the number of extents to remove is limited to @@ -5425,6 +5444,7 @@ __xfs_bunmapi( struct xfs_bmbt_irec got; /* current extent record */ struct xfs_ifork *ifp; /* inode fork pointer */ int isrt; /* freeing in rt area */ + int isforcealign; /* freeing for inode with forcealign */ int logflags; /* transaction logging flags */ xfs_extlen_t mod; /* rt extent offset */ struct xfs_mount *mp = ip->i_mount; @@ -5462,6 +5482,8 @@ __xfs_bunmapi( } XFS_STATS_INC(mp, xs_blk_unmap); isrt = xfs_ifork_is_realtime(ip, whichfork); + isforcealign = (whichfork != XFS_ATTR_FORK) && + xfs_inode_has_forcealign(ip); end = start + len; if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) { @@ -5513,14 +5535,13 @@ __xfs_bunmapi( if (del.br_startoff + del.br_blockcount > end + 1) del.br_blockcount = end + 1 - del.br_startoff; - if (!isrt || (flags & XFS_BMAPI_REMAP)) + if ((!isrt && !isforcealign) || (flags & XFS_BMAPI_REMAP)) goto delete; - mod = xfs_rtb_to_rtxoff(mp, - del.br_startblock + del.br_blockcount); + mod = xfs_bunmapi_align(ip, del.br_startblock + del.br_blockcount); if (mod) { /* - * Realtime extent not lined up at the end. + * Not aligned to allocation unit on the end. * The extent could have been split into written * and unwritten pieces, or we could just be * unmapping part of it. But we can't really @@ -5565,14 +5586,21 @@ __xfs_bunmapi( goto nodelete; } - mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); + mod = xfs_bunmapi_align(ip, del.br_startblock); if (mod) { - xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; + xfs_extlen_t off; + + if (isforcealign) { + off = ip->i_extsize - mod; + } else { + ASSERT(isrt); + off = mp->m_sb.sb_rextsize - mod; + } /* - * Realtime extent is lined up at the end but not - * at the front. We'll get rid of full extents if - * we can. + * Extent is lined up to the allocation unit at the + * end but not at the front. We'll get rid of full + * extents if we can. */ if (del.br_blockcount > off) { del.br_blockcount -= off; From patchwork Fri Jul 5 16:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725361 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 319CB17166B; Fri, 5 Jul 2024 16:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; cv=fail; b=JF7xwalB9byHri4E1D86xlfBT8xOG6h980c/oWufKPOOfKhSO4ibTxN51IeH2JhgPGJhGhwvWCcRxkpJflWzU59+5e42wXNqBsqVFnUjhP2pOAJ0cRTHtn8W2X8OV6KO8cXPI3YaLiXWGOwVtAfryEwZKgVq403OBkGKxdmU5Ng= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; c=relaxed/simple; bh=qWZCtrfsE8kzzxmRxl96061I3Lw1vNw4TB2JFdVqduk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Vh8AMIRZlIrzgfC3xfA+77/eEUItsbwPRAIIAqKMWSGwrTkoRVtvcivkWZsBRQI8ybnS4PvsCtZfAc71bs3uLOyxb9HiZvf7vMT5HPmHybnF8uVnYdl48Nk+6W6x2PLUki0YOSihrt9deodLRGNWm28PKnSkTaeANmztGS5cgMU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=K0IvMzvA; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qedRWy5k; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="K0IvMzvA"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qedRWy5k" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMepH013563; Fri, 5 Jul 2024 16:25:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=C/byW9R+e2foO5aTnvekCrGcAtn5e0FEqJ3geoLZPbQ=; b= K0IvMzvASOrmafHJlTXY2z6CnR5/PZWq2O1ZXX/gW+RCJnmeqQS5c+BsgtzWN1St WT5QCxICCOJAr0x/PpmGDG4ImmpEcmF7fq3Ob6uG8hZzRaulCxBwFlLeQZAYno4h WWVCsoIYsdGTphJk0+DDCFS7iAPsYoXW79rbb0/jJTgVVuzCx9ETz2NmLHLXeS7h SM+vlLO7HW1Fqpw4JogGWfyX8L42gqTfVFUHJO3+hA8D3/kscIvDHfPDv6XGkkV0 MY2uPT4whvicwzCGR3x16RIGCPm8OuiOMmLpYyaBmWWY22vzxxOS/sCFhqzFrRB5 nwP0QgSRDBtyEqX3XMn4Rg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40296b4969-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:26 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465Ef4V2023444; Fri, 5 Jul 2024 16:25:25 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2047.outbound.protection.outlook.com [104.47.70.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 404n12gg44-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V0yasN6oN+2/sKs0GTNvwlAJzzqYfUuA541WmFSqkhFZHbGmBtTrejH+j2J1uSb/KwRZfzPnTsoBoQfAsmkyh4nWwo666qy9m5DQDobiexb65UlgrPhXQ5VwOHybg1wJTXDar9Jc0Lt+Yi/d7+c2Y0khRU7vzPijcMK/Lb+quWG2c3+sOXEaknA1VJyLghuyYa679pCasC4pCKaIERJdJKUvimzHSUIVdvEY7BFmIuM8CpQ0KudsAVuo90pfzqev8+lKzaFo4T1GIBLFIXUtoiNzGVbiB0wWmQBbs/Oofvfn/rMZjm3iV/fkCn4J7bKNWgUkD8yeI58Zpa0psMY+rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C/byW9R+e2foO5aTnvekCrGcAtn5e0FEqJ3geoLZPbQ=; b=VdGfvUS10EgJ8iEVf+ncXhmOB10qx/d56SfKJ+NnRkkSMGN0OVQE+O4r6Q+FVDQnl+38VirYZEr9HRK5/V41oX8LxYmm4SMCGw5L3FWV16mtShThSZj/xqsq9pHdmLmdWBA7fNseNnb9tn2+iEu9UMaON4QCY46/t2Y1T/5IVWsiGD3wUlMku1Xt1SwDE2HFGFSfgJoC+SzdbJIiGGVhn8IbPiboz0IiKr6FHEQ2NPr77XM1ANBOty1jZuKyaLSrdvBB7yJOmpIvU0BsIzpURdEQKsuG3Jtd8J5zEfa0QcWc5hCnOA1xP9DQkxuD8U8Q516QlfDHH6OrtxqqxFIl8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C/byW9R+e2foO5aTnvekCrGcAtn5e0FEqJ3geoLZPbQ=; b=qedRWy5kZmforIxdu9FXNpsDmPxIAZJA7w5KNtq5ycZw0dXA32ZpLawl+yCn1CakcZbOGhnheYLNY09egaw0EMMy+nv7+amRZXv0ju+NN5iiy5NCTYTDYoqiSZ/5volZ8uX1t6/tnLdlwO8Q/4EYh6outnSUWAa6MoIYAlKT0zs= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:23 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:23 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 11/13] xfs: Only free full extents for forcealign Date: Fri, 5 Jul 2024 16:24:48 +0000 Message-Id: <20240705162450.3481169-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0057.namprd16.prod.outlook.com (2603:10b6:208:234::26) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 67a1b834-9013-4505-ae20-08dc9d0f11d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: gNhyfolMJVkwGi3InOD7gJthwElgNOwasFNnUjK+NPyvcrbnBYUh+3PiihPyn+0GwKQOCIwWJAOIVbMC3OdS+VTayluztBvwjG64Pwz1FA/Bc/jzTAkr8Wz6O+GeoI9nyrh3suGU7lMdYEI1r/3wyrGhp8XISOWZaik6AU1XQLLzpR62p/13+ObftSigtithQlkFcK3J0ZI1IViTs19P2MhV9on6Ym/ldERQxa4873IpUuSMrKYyVv3XMPaeYD98xDG0Qh+4Zlr2UHFdpn17BcrkCG1nBudtVuVjG5ckHnKv2YYrXLnvHvnGDDJIBGI4Ds3Y+Wqh7tCfAdpS6SZZHwwqT/sNGkw5AsLniXMuOByUA9ybVWxksRzv9t++7TtQUzEqhAVndIAiL9zGd2+31dHJJ6cBOC1wNuKfEOyCG4lEGjAALVLo5hgW59m5laboaDSrDX0xVUd7mTSAfswXSNel9KItc8ikE9WKahw7rBPMW4Y14OIcFM451LLyzqV93HQ+rtDyl8o1g6p7ZLivwUC7a/3ppgbvrOLGRDWGbx+sKPfgTZnjT6N8tdirnVbjUWCKrNuXVsKdjpaiLb3dIkNCcfOCD8XM8cfoeFM6nDwEHHF4uL/Nl/IZZ9Xuzvcz/Ze1Jal2wJFgmHzFDH1AHa2KJ2dK834KoGS9/n4pZIv/FDiCh6InewZ0E8C8XaeRgD8oG5eKhXCfvDkEqm8Imz2mmTnvtmPWXvMZk+gJs2/2pHQ7L6bOCrgFPKgKAP3JamxZpPy+Ybl5Y/fJJnGnNQHhLNQHISFGGUxX7WZFVBvWrkfg7i9KnrrZYfytHKUkNbW+ap2eXsfjpjnaUHZIEikHiISpo8JwMq39UZ+OlFolDphnp8DBuOp98I1b3FJJ96ARB0nEUZuxc4WNgljafaLnwgPgMuCRbDTbYr1bSED4npdIKJmji51ihuB7Ik2AccpvNiYMOE/5MQ6QLp9vmPSUoJ9eEiIN4QCV/d3L17Ww+4paeP1OAHJ9HIL1/nPO60R/jFVZJ5tyyki+2ytJ2FPVWe6TX8bDm3Zw4VbFTzUlmfW29bhRUUKhEYVRtHuqqHIfDhQ1LEwkzJASnmlDpSgA7yL5ooEEeyCkDNtoDMbTWVEC1f5CJVs2cHN/BXiHyFXcBnYV94dIkHNZ+324jsZ6GHppDTCzFdr67teTt9/npLLoZ51D3WVoS05dmJOtfL9iMlsyDYB+RyPRTUm4NTjdaVlOadekWmCV8N1currd5ZC8p3m8ozpmL469XuV+0nQl+smU6F4d0Vxo1UjzHgCfw0Cv0V2ec8lpcGfXriil/ietN0s/CgwcBZgg1W+lY11kXN8YdQqalPo2M0MjQQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2TiCxgiYctZL06/maOb8LX9pCY/N9z2N+wqXb/01FFYChOQD9KmSr8IMI2A3qd6BRbp8HH8N6HDrVi/00souNylLXTqgk0qMCSlO+mhdD/upSaX8SFJieaidhBeThXuTFkG+rCQaxVddKsbRVcA4aVQ9VKcNXrO7EtTVBICOydT13Tw1GHrBnLYhPzdH9siL7mdX5RJMnFSdVNaa/hUwkHtkPtAAE3NMJNaocHjqtWHEJTRe40bnDW+K2Asm8T9qnr88JdT8TXrWusDNSckjskXEKez3vf2oq3D7GJydGiK4G/mzFP3o44xzHe8wqEsUhUysUeHHj5+LjgiMjDFTk8wwEh8GBIGDFGUf2ETH9ESvvVduplTgFiZ+4BRqtrQGqK1J42ESjjSZ9cXSo4RI8m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Xgg+cRTC1n0D8/aZq8oWGVJP8Dj3zKRTaKGW0E+6aH1jZaVOwj4/99UMAkOGaa7P5f15tbxFQScqjav8EjN4WMqCb1sZH0XcvM8JdQO7K2/edbTMkjvr8URV321JkXAzXndg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: GwT7b4GGuEJyLkYWcqiNnV9WGTH6piYwz8sRfZsQV3PvOvd6bn7W1L0WCjSFo11YOyLIxTmB2XHmT/0TyoILc6VQLhzOmuy/Wju84QxdYiYPpikYVEO0QCv6CAV+PhiVwgCxFX0cHiYd5GJkonGBZeDbxKaef/rMvacefh9L357fZKBOonJFbocx2VLfZpZ2cnr0ov2R69lf6YEo+ZDgYEI3L9+ZDWc6vLYUWrKyhvFQWhymeqBDLvduHSIZ6kdrFELyFE/uYTEeRQ3eHEI98eYyNN+jZFnEElbk/R4Gst2gLX14BQSl5WlTL+JK6YgQPp4QNv+2GM/gXaRvO6HomFrB+4hvyUF5Dyo49ds+jGGUaUWO9JVD0x0brVW5Jtf5iXOXi1Pc3Xc8rGnw8Hh4b1nSO+bR5F0iIGspwmIPqAwA/NW4Uq+FHslWqkiW3DLiuo0mGs1LkvlzzbMS/+D6Q7/VhrUZP8xilkZS7xTKzedhF+V/hcvG/bLLiCarS+I3XmtzjG92Vq5/MGq6Cf0zdVhidgPXksQy/0Im9jt37Ot3JnIbp3YCbrET9jC/ZCeA3mRRPPD3+ZXFF+F3B9KnmQw19G0HKcSVFB9Im171OLA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67a1b834-9013-4505-ae20-08dc9d0f11d9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:23.1073 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RkSgmu882b0OrL7zmRhb8iC5lP/7aFTH9S1AioiHcpDUZRLkgl/u2Vos83QzxIARisBZBkt6cbd7Hr2/i4a6JQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: qqlunrQaOIGuNhhaiyVhbLZqbNVt0MwI X-Proofpoint-ORIG-GUID: qqlunrQaOIGuNhhaiyVhbLZqbNVt0MwI Like we already do for rtvol, only free full extents for forcealign in xfs_free_file_space(). Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index b9f8093ae78c..daef6085208d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -856,8 +856,11 @@ xfs_free_file_space( startoffset_fsb = XFS_B_TO_FSB(mp, offset); endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len); - /* We can only free complete realtime extents. */ - if (xfs_inode_has_bigrtalloc(ip)) { + /* Free only complete extents. */ + if (xfs_inode_has_forcealign(ip)) { + startoffset_fsb = roundup_64(startoffset_fsb, ip->i_extsize); + endoffset_fsb = rounddown_64(endoffset_fsb, ip->i_extsize); + } else if (xfs_inode_has_bigrtalloc(ip)) { startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); } From patchwork Fri Jul 5 16:24:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725360 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 C720E171084; Fri, 5 Jul 2024 16:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; cv=fail; b=MAttATD5KhwTmAPtfMdUjebXEF01ckOWPeRuuxvdjhysCwrWGY31hdc2eDOiUySgs7qrGf/dPU8FBffKXF7E7rELWLdQ+7EIxcraMrd/zp22cCkfFvqdOz8QF76giPCr/da74K5sW6H4bA574Bf/GuCSmDPErj0p6bVD5xccY/s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; c=relaxed/simple; bh=wwqgAiTHSgyLmPYyn3J3t0tYESGjLmnJyRJ9xaf4qWQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Re9xy/YLBkZHnXR2vuBY4KwoMzDtrMXQ+aTpVtDqCIsVMizpPg4KXOHYyhNgR/sw/b00HhmbCjJGLZVZ+OnsML66116O6S/rYNZR/oh0UtysIqxONyYu0mh+D34vu6SjKrXDNfu7/uMbtt6DQuNEzi+zwLDosUw/5+XHQD/6eYU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=NuMp3eMz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=nkxhgXd4; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NuMp3eMz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="nkxhgXd4" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMepI013563; Fri, 5 Jul 2024 16:25:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b= NuMp3eMz3ZhCTOLxc30PqPPopBUw1uxpnkbM3CxYZ8RVeduf3LOFkZg2yP4TXvU2 LC8T2ODhF0bduUbRCUOtnXmTiPspSb8dntH2f0QM9nTEolB5r/cDCYLaVI3pgXOX GQFxTV0I2UOg4Krq/lGyD0+I0tDbjKatY68cUsWa8jAeBE0nmHyz1I+AlTGbmn5l n6lJEqpXwxFBNb23wxd7MzfmlOjj/9P9zz/SBgR3vGsowM2gy90xWFec73voBTTm ealb9ladxNZhcs+rRiZnBZVSkn/W8IC745bu46mFzrzKIlDxV/SU4lXcrfVyiN31 emrht3AY8sPLF4BoSttWLA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40296b496c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:27 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465ECGxY024807; Fri, 5 Jul 2024 16:25:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qc1c54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VwYJiLQKGKMJBJ0btdHlNdidT3GSuUnS1bic0JCj+s50eYW49PTAFuOVPd5dCXKXLHvaqzDplbVqvNTOwjUHEosZ4nRCb+ItrlFKAFI2bP3DFyldlvpc/IwnaSbMXRfuEeR2xEVjIMSTsAd5yc/Ybx7lQPseJWkPqP4VBOtKoJFDegkaTtLOD9TOmMbFtPegMmmgQKCGvTgi2UhMvlfT96AuhwUeTrXjYZxfV9uG8Dk7tyhOAgK4D/EZoVfih45P4LimdBz4OlKmW+Ib++C5kAkoxZpXDtSeoHZ/6lJ1AQBlUnnrNcWbUC30uCS4D0BIZc1w86lF4kFtOw/OD/53cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b=E5hlJmZq//TBHnKtd0ZjPUdk6ml/lsZSa8NkakBa5j3oNhZfMc63KmZQGYHgsyYZvuUu2ruZQUOdCwPrW1Tf69SHz3Dm4TRN/nk/1Pt/H78vNMhQw2eaRKF806GJvZ574flsKwE7hcEGlNRX+UmVNMpZ0wkRdvK4yZM7WcOTy7qhy0X/tHhwspo1Lw8YBMcxHT1atogxQWj0MxMEEts0ehrKdow/90ctVYwrL7aOM3oP40BfL5xOc+o8Mqqsu7pDl+9XJ/MKdXdIL98HF02afPoNybymmWrZUbaoPLDeK6A/JSC2qFtM/8GIrS7aw7pqUTqlA4mzoh+NASZv5lrjZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b=nkxhgXd41JF3mEOnxzwHCPOw3Nk+is8NeNZ24KspTC7CTOWM5AEa6lNFIYXg9jzaVNMsDyoumrc9caJAEBV6t2R5Lc13cW3eFA65S9+0U6I2KOUBzKSk0tSax4Sn++itLT4MjIf1qSMGx0RLrxiQH6Zbuz+ujXyDW+bnz7ffjSY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:24 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:24 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 12/13] xfs: Don't revert allocated offset for forcealign Date: Fri, 5 Jul 2024 16:24:49 +0000 Message-Id: <20240705162450.3481169-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0352.namprd13.prod.outlook.com (2603:10b6:208:2c6::27) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d33d1e2-47d4-4121-a6a2-08dc9d0f12d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: K5zovPFcvZ0IJxRAaa1emqDT4qJm/EH5p7tvZzJrEAEu73USDeaq6xFz397u2N9npDdxHizVtOvyx3NYOs2RR0dulx081kFzqbxFHYG0KERQOX+UU6v31lJsa1bETQjocoA8NM9yR9k56D5tmnRxLUJp4mkpjmyZ6r9gNYmp8veLEpyS+1UR7AOo2pJiWQ/v0yu1AeFja0VRic6tpcGwxJaEqDKVfd0C/gpaToP0m8NQpTam+lFfyXezigKkxFL/0sOpWsKMPs5c8mBejYHj/4KEfoz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1g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a/0X79t+6I5+x3MgPCvhaAO6JTO4hmeN1PX0fBiHh8jiJACVmUbSDVq+xLbe/3QBa8iAzgCBeV9t+zpwLSGnGvBJX/rQP3KmTfzob19/OC7LBi9KSdUg23IJKEclDFItZE1VdkpFqOrJ9fDadG8ov2I+1r+BweHe7I+03SGIXdwCdY8+o6W/MkPYgOzKLjOqqFWrqS9KwMlXrunMqlINrJhdHdQD8U6vAcQuOnpII/noS0rHO0sK1+v6sVqXVkQ08QvkM6HRehfOyXOrXy1w5WuNTtsu4arZW5GftC/R1rD3IpBB12M573THy0yXepL6w5jDvbPaB6qCJu9UXIp9frO3bBuGTNkw+KuUuinC+b72dX8SANTCW2qksCqzuTBMtU/UdfyoKRPvmgM3v7kx53KeKoaJ4x3RpjyCq4bhHw4cZqtiZO2kMpBTPld21N8kFcJOTk/1w0GbIXc030tWCNaIidGBcsS/JY/3rFKzVzqgxa8oD1rcWmJUc+tWnSjiIDkEQheM8Sh2YGrbMfyik8n08XT9hhAPk7l2ERiiQ32CW4qr3iK5atTj8QdEcd0XYQtH0E9dJ694QvO+7wc39O0B4bOeB2nZkzPr35NVnZwbm55KceAnUw+lmYQm2+J6rPZa3Y1gbxWu/SEtzlwAJ4eYQ4j/rFA8BxFNPFU/oIUynY91Pv6s3u4pdG02GNRnbz/H18cprAZt4pDSu+TMczGTvUJKzTp6q6WqbBW2lRv2xHnMpknH0a6MWng2iiOOHDCe+g0nDsWP4Rq2EqJ+2kJTMGmbrQalI3sBNmAWMCVbwdPZfngDwB9mp55FVx1ybzwT8xVdRvoez4IQjzupy5VVIOa8dI2jx4y3p0NBb4prBbDjRV7zftryYPRoUpX56VKHx/lvjCLsBR47KYFquekBym1u7KJVdr8jSqIe/jrUjZZlpeF3RxM0b7wiYvJjqt9E1H3rRg5UMH9z295EIkQ55QSkLyqM24ufA8/DNjwiM2+Ir4qNSJQoKovuIh+TwIsImjG6o7p4xzJNNCrVIt4lluq6T4Q3Cdm8YoT0rLoi4LWZcheHF6q35aaSXRwDBqOTGcArp8YkognU4vB0tmWxYtBcZkv+VZin8MiXGAH/OFelCslmIwJi9gwKIfemx7otAecwX4QbIcZDZaxJU5QZVrOsAthx0k1XfsSDgvLKABTY5Wtn9smI3tcPLX1m4B+P9oq0x125yCfbX6d2mrb08I9fxMwaZoKhTHz/J0U2DaO6RlygThu8nR1uRYwyJj1f78oA9RH43j5iJJgmDKGT0WpB+scZzhZCZApzGWHztveuH/xGJrwab+dRFvc3Hb4u3kCe53rdHZM0gDG2fGw57Bo6FjixEVFXqf75KWMuFL6/iR9ja38vPH0W6c45b6JVycLb1gblsQmk7c/FUx5fNu1NO5cCdvWahM+SyQXXgNC/FzW5bE5UxoEgi8ydzkkmRHxqoft4J3nV90cDRiw+JRdrIIA5aavqsu+Wv813slZA8J2w3xYLziWxYjZOF1OAej/blK9OQ41M/24gdo/jhfmtJqqCKt+3SBQ6OwnA7wwJ0VvG9OzIDxM90BvF3XdT4dOCDsIiOUQw02yDZA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2Zv/KoAo5PvaLF5QpbtFUmXnOyH7zXETpzf1NJU1g+S/qVbjZpdHm5v816/6ObSsOF1l9cb8VghayCmB79Yk+1ZOTYtP3bVb/k1ApF0M3xUDWYgCdQ+ilKspPgZtSfsD9bgZIEhg3TKWvrQ1wGG2tgDFO5XYICdSFq5AsEAX/X84X6sPFVFZvWe/jPgAv70bC4H8EPzfj77mCV7PogN2ZMNagosH48Dd9kr0tNh6+aMvz5OQbErsRgszfVRyje+ZFq3XErpl7LoMdRrmnpy0Ukt6ggmh/YTd+9gLHhG78UaMYHqvKPcpOh+v22+vA6VFxRXPcAF052mKEdTEx4DTfQG9GldLkOXCGFZv/0VWy/chx7ofbMT6wcgHix+VEZfMsEc5YlOFi4TGXrpzkRqhh1SQkb84KGiUlaURWHOBbCD0LXudfkJsKynm5ziFdp+8/1ks4u/HWuh5udarh7iIXLhl5CeLsakcqjFBBAMA4tfcgORM0i0hSAZcRv630MsGZTAsDerXuV+FsT7AcOFD6hC/TalhVsk41tzRzTvbZb9Zxh+8S0VD8MUAvHuvRg1VfNvFqb2ZyMYO6/lNqLargAYvNmFwHKFbXM5u5Q1/TRc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d33d1e2-47d4-4121-a6a2-08dc9d0f12d2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:24.6806 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kAv6ujsfRdFqM1polloOqPqftMEMGKRnv/5XxnCvUXuq3+Nb/eBnrKhB+eUEmnsn0snJ7F2x35jfHeu1xTNCWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: B2gzC2RxReFgOk3zOBdoPDDJoZapq3YN X-Proofpoint-ORIG-GUID: B2gzC2RxReFgOk3zOBdoPDDJoZapq3YN In xfs_bmap_process_allocated_extent(), for when we found that we could not provide the requested length completely, the mapping is moved so that we can provide as much as possible for the original request. For forcealign, this would mean ignoring alignment guaranteed, so don't do this. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 07478c88a51b..45694ceea35d 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3492,11 +3492,15 @@ xfs_bmap_process_allocated_extent( * original request as possible. Free space is apparently * very fragmented so we're unlikely to be able to satisfy the * hints anyway. + * However, for an inode with forcealign, continue with the + * found offset as we need to honour the alignment hint. */ - if (ap->length <= orig_length) - ap->offset = orig_offset; - else if (ap->offset + ap->length < orig_offset + orig_length) - ap->offset = orig_offset + orig_length - ap->length; + if (!xfs_inode_has_forcealign(ap->ip)) { + if (ap->length <= orig_length) + ap->offset = orig_offset; + else if (ap->offset + ap->length < orig_offset + orig_length) + ap->offset = orig_offset + orig_length - ap->length; + } xfs_bmap_alloc_account(ap); } From patchwork Fri Jul 5 16:24:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725362 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 21E14172761; Fri, 5 Jul 2024 16:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196739; cv=fail; b=Fyj5O5I+oS1Pppybwb40HdY0cjR9wuVWuDFgTJ3amgnwQr2M0NKuPTrZClJYl/RlP6Dn1jGdYHLEj56t1MmHktS7gVzpg2z44OV+mnHKAxPdYyeC0I7AUeLeYm7CiSB5MdR5Kht3V2RZrxwtOkQMfJEdbpi+heliDetD+mH2AoI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196739; c=relaxed/simple; bh=9FTMcA7rkZfmIgyL8VqAmzt5cNENoCeG0+P/w6VgWLw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=gIdmN07iK8JW+gZc2gQN5VI1TfwLBEj3cmjWjjfMCzYHWy8EqwKGHS2By4Nhnjcjq59/lcygdJaNS6fCBWC7Z2r4arH4N1Le5drhh2Xdm9OuKB0h4XtqJRl+9IOLHhWVGdFlrOfaQzr6fVsxEQ9ZUZfy53lLDAZHLfKkzK5vY40= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=DFZem29f; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=T6mbIEph; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DFZem29f"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="T6mbIEph" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMoAp024762; Fri, 5 Jul 2024 16:25:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=IJpgAtqzqy5NPMAuN6MwKwGQVoR3/AfpA32R9j58sLA=; b= DFZem29fW6xHb/5O5i+vZ056qFiAZXwnJ8+D6iislmxzncqBKU5PG8ajcu9/Kgg8 Xd4bIldOFYG1S6oxj0lRdsJtZYhG7j9Q2LR3qeUwH0+TKYKuEcsgUFHKjiNeaRSo WS3z4DvaEn6mEyr/o9jB36JeQ/ILYXU5GAqt1sF1kndaEDypdfUO5qBkLxxUd3l+ j+6dcx8O7QjvxtslYq7EtPdJD+/4bozQiYRbzg/pDCYmgz4EMdcwy74bVZq9Pseg 6jlPHW/UR2OD58bTgLEL5XQdaxBb5RN5zPkBMWl6/tH1OusRsO0OpIyMW0OyWqlc Q8vHXPLVy9DASPzHjoBrow== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 402a59c03q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465ECGxZ024807; Fri, 5 Jul 2024 16:25:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qc1c54-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T8otQp2MTLZqatvACTJqTXW8unLkvVdp1mIpfZ7KiBES+FfXYD/mcm4ho+asBscul0iEByTeaPThibkf6dhV3d3e0An+nHNja47a+YXz/oz3UdYPe4vbtKrfMOx7dHOYi6dlfizHe7v0uMy6gTClRGh7uqk1TJWZbUb9/2V99Ml+sOXcuD1PIW/02QEna3OrbvEksmLGBaVggG5t1V80BO1jjEZPoq/IfN0/rdIhQPTTykie180eJK8se4TTCuS67qVcXzRc5YPBtFG+TOF+RF8xs3Jgk7Ma30v42z/JWAy/jP0e/IpO0tMwd3iz5MF9c9E88pmdhpqT1QUfpCTl+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IJpgAtqzqy5NPMAuN6MwKwGQVoR3/AfpA32R9j58sLA=; b=JDObkB7piskK/iLl4pFngKcQwiUx7E7pjf298NAw+5YtYlM+9CKsB9zi2H74ef4ux1bKZLDx24LJaB3q4LNurkP0FxQCzgK4NQ9UN0PvdMCd3Ci784UIGVzPRXCeE6rftHRRxkDyfgDGrZIgcWaK9L0Ts6KhiGTKtRXB4EomTW9L+m5sVyhVQx+Wc6DlxsQI32Xtj42tfgzl1aoNFE/v5FlzIkXsqY3bL50iYJsQ8wzAfTQzmzblCCa+5pPQ5/ViALy9R42h8HCRUS4Mvv8mezBNteICA6Q2Q5RFUfh18vq/mbFI8dwBFzEvf1s9dnwdH3Jr3J5LZ7v8zN4Z6ATfiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IJpgAtqzqy5NPMAuN6MwKwGQVoR3/AfpA32R9j58sLA=; b=T6mbIEphHA/8e69tLPFlIRhw9ByhwlTgPGgjy17IP5daZPC5+itD1NX6O/Q6/UoOHNf/NfHxlmQrMpKKwf8t+Ookw3c9Hs5TgJ89o1mp5/r/uyR4JCS7cXwkc8w8RvBQ8V9XW4Tock0LXcb+Jsrktw6Z8GkgW9yeMjc7qTk59o4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:25 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:25 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 13/13] xfs: Enable file data forcealign feature Date: Fri, 5 Jul 2024 16:24:50 +0000 Message-Id: <20240705162450.3481169-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN0PR04CA0023.namprd04.prod.outlook.com (2603:10b6:208:52d::28) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 3343c02b-bd57-44d3-aca5-08dc9d0f137c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: WdgL3iXErbQDGWuMwpPI1MapMmta80EC13T36MwOo/qlnyMkSA10VWUVGWCn4VXG1yfOrTPGDGmD9P0oJLzq1JuyyxDRp4Jij3Coz8AFUd5zvWecI//sHIwguYL66SsqNXwUxmvWntHBoUzaxR5EOhnGRwC3EQNMS5fxDYBx5Z7WKnvpkazpuu1i+9n2w0Ui7Nj+ya9NYa28kjF7Q0xl/SJUE/HQvLuWvgTSuLjRK4WndsfhjC6/6L5jEfQwHiCZhTeZNQ3H24kR8qedGsrigmo5P8Ntb4kN/lyV8bQ5ZolvTqNC4zpwDCUjeA1NH99jr4N3wJ8gqZAJ1+CCnAFXQtQ/XLIIIzuguR0BZLdsqmFRWwc7VtucOiMVtxB8Z0eymWtauwaoVN1YE91mJU6oogTraRiQNEgzXU7wI5X3pVa75IU0ij+og9VGO3BuTrSrny/7VJTppwU6Oqh8aGs3x0AyYARiJLRey7Ih6IqBRuIaUDyHi0azbzaQENypY7oc2PRTvofEaoKOEVirK+vjI5H/+TsFbUHzeGCG4CpOq5qXPNfzdih6ABSbucJU2ogyfA9NmVRTeCRv5NQ5dmLGSU+S7Tqz8zdfMih07w7MeHVd+5XtTwiW0rL5KgeUz6p1Gyo9iO5IIhmv54aGkJ+a7uaj7TEclaHenUqkthW9HGo/LHwuAH3TTR9IGBQo2vQ5sfSwpDWQ126cd4ow7KjXA+3AW4ae+raF8i+04ZPkfjxKSPIdrC5gonM6/Ehl/Apeni7w2SClN5A6gjPGQrlXmPwhP/6wi2QspwH4BsHI69DbEyEdXmBdA7fVawMgDWYaYZ+pAdFL+675sGH/aPdhh/hx7xtuHZ2D4I6D2XRqnEr9GaD0Qp1Vo1HG1VmvUdFnrtQqnapI0QnLp8e8rtcmlcLO9gx/O26YOqfadkQPuuDfLs7XGmBPFWN0vxcLDQqWjHQ9E21DyTGhIEcP7OtIcClvWdg70hcqLB46Q38a1NlXXsabENtkW2G/ygGZf6YTQJXk6Ymt0YCDvy1cmjU3rdqQUp0iU0TcxW5ZxAZgUq7G/Q4ogn69m9ej8ATNcsORS2ePqTQVt/zaTcdQ8OR5jmVC43dQoBc7RMrfvgIwTBYdp9QuHMPUQclcSKf2T2zefzrkAnKZTXzF/t1VnJHO94HAlYm394sN1ugHrPqnG8W+FiIAnTkZ9ATXTcGkRPUUn6uX3e+VuWbzm3S8bkhsJgdiV9NuYwRXoPMJ/bjEig3iracvEXfF/54BN3HiVcrxapE2DwFs5RfpIxSmAP6eLycHPeYHucdGGjr4x3Nsk8OuNP19hUM5AdtkDwEG2chYfflqfMKux7goFT5GpeNBFA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yZQDz8zkiQYAIDVFintuZYgBQn+GHuk5Ar/GeWZgq8ex7dqF9uYAj8tVlmwiLEjmRLUd0bbw5zHpCz/JYMenGS/oKpGmW8xxA58lwkRwUUo+fXLxOZ8pKWP/lUY0SrZkLie2QV2flmodsSKkn2ncf0+INHTE9v6UhqxTmm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oZ0/4CwH4a/peHpho3OGNNh/vQbh+rqhJAFfU/z6fVtAExNQkvFr148oBgIkEuaTpe4wun2SM7JSFnm2s7RTO1NempVhvWbHmT1+jbF/hwlnQeOdCGo7jpAIXJ/wSEWpt2yXLpec9Dq1RwDtls8Z9S9oSTO/qe+I/VM24i/hKW/g13MtjQVSI6oQG1ydARjIav5cYiiTaOOubSUic4F4RSZCOZ8jZ5IK16i2FZO0PEe3zROMqtM0CQAieJDoBRq3iK4+zb8iqyPJE7sKF/hBkIIH9LpbfheotBXDLgVSb7HvIVohnzO+8RStdeUaO9T878ipRMuYQdbJL2RLPvlrsVt+C2ttwgtM8xwLFt+uo+kqB1fFrt9EDqCf5NnsBU5g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IvCT9fqb6C0HW9wINmY1tc5thfU7VCiYkGU1dWx385Oofc99fxk+FgHYYkQu1GcipaQ9mETlX0mTC1B3QL5vreJPXKiJuciGiMHcN34x87Ztd/HT6zL6/JwnKWA1V3ty+wvlZP6c7mqNicRIBf4JW5mGP5H7/bhlZQhpu2zXAo52+zrWsfR/8VMoGtAgyNcUK0VL3+juWXYYfmzSroj0diEpNzEJ44deSJxLuPAtLO7Kk+Es70ahzqn0rpzmop+rqVvDAHoWCu3DBCPnaCV2bj2N3fPesRfFyZreegPM9n1d+XeS6qSODx4WuqALMXvqXpIaOCws0Q98q/cqn5rKCNiTmDP5SltSgZh00g/RI7FFXsNG+uitq2jOlqAGjP7Mda6FMaN8K77TuhZkU0AQzHzLIfMe3QdF9fOd1iDKuj7HcGhCwBYXV4TFdoHRahad3jri8DGV5L3jWPHUU3SteV8FB4vd3fRB9aATbJPpF77YefSpNaLd5xLfGhfsG06xCzGcrV57F/PUELn960ewFNbRtQ846gWtZY3IdBmSchsPFgA/nMJUkhPSyCr2NyEht4haG1dwTqpFDPQZdZ2x6+Ll+MDZhUZr5T1YNF7QoFc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3343c02b-bd57-44d3-aca5-08dc9d0f137c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:25.8452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1PcdhYjfWgfEbSj6Uc5sjGszcJ7ylJUE7iwKsB6qW1vWMAlPsgYWiO/xkadVx6K0zemMhZvTs1KrvEI8mktrWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: qJyWGNfNNjdBw-BN3vWvucwWkJREvoJO X-Proofpoint-ORIG-GUID: qJyWGNfNNjdBw-BN3vWvucwWkJREvoJO From: "Darrick J. Wong" Enable this feature. Signed-off-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index b48cd75d34a6..42e1f80206ab 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -358,7 +358,8 @@ xfs_sb_has_compat_feature( (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature(