From patchwork Thu Aug 1 16:30: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: 13750723 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 B20981EB496; Thu, 1 Aug 2024 16:31:56 +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=1722529918; cv=fail; b=QAfw9YvVVnwoHovmniR7+AL3CclfHdJspHpuuC0pbG3xgtXDmhKdUc+RIGVrGqVfkzJ1suOJDagpyIZF5B0iS/VXb23jo1acnrs0y79Esr+qPtDVBi5Evl4eNoHewCxi8AHAS7F4owE4xB0LU/0cocK8A0v7QmAUDA9r5X/3IwU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529918; c=relaxed/simple; bh=3d0NAqismK1oHxyZsbPGHkoTG01Z3JS438mo/jksfq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ufC3gvDtnZ7qZbQEdHvP7CcxhI9sQ84vvi7dh6Q6vxd1MVVq6PaalCEJp+H79L9GetK6j1IbDiqV0htuNWECyP2qnsEqroHP0B7FMNSR1FPKwKdu7QTeuTdR9gMW5lsYtOQxSt9RsXdeOXqJCm57moIYlp70AKjMJUjgUdng2Qk= 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=VGwklavn; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UD86mU1F; 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="VGwklavn"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UD86mU1F" 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 471FtXPZ011506; Thu, 1 Aug 2024 16:31:41 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=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b= VGwklavn8Zwr6ahg2NOnjKPb4WoUnhEUjWVAMY9fZyHpCaLvZXJnnPghrdklpFii BVB76Nd7DKKGlynvlyZga+X3Sr/Yy6nIjqfgbSuOUxp7XZrkqLhjX0dx3e4Qb6vc GuOM5MT179bUfvGw7LS9VdiM/CQoopAs/jj40FLYAIcIUQZNwVRgiUQVPQTEVVYY JrpLpWiwZZWOu5qKXWjBPKWy7GUt7m3Hx8IAKP1DZW9zi3nMeuWwRKavCNv3Av6U S8JdpWyeMw1GGpbdPQEEmtdtwyzY9WxOZioJ+DqYo3/d2hE2fxCm2dtHuTGhkSR8 hk5tDOR5hB+7oC970CcdIQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqact5fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:39 +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 471G4CBp029016; Thu, 1 Aug 2024 16:31:39 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40qmpt8g7u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dr2GvMzi/hcer/VcIE7U3vTHWMMbWh7dauz3jB37oIy9EY5bVocvo0ah6Qcja36LgXi0Z1/1IWwvj437goAEWFb5WLe26GJnV+HpMTToT/nKn+JdI94G4FSW8sSL59DuWldO81PoTOskJMv/XMOq0MU9LaPGDQFdo5/VohM2iExVbDGif0OWx25VABTpKHoIJYMnSaYAakSqkJFhXW6bsKb/uCmih9mRUb5uaawaPy4K4297eCgLNqQrL4CHB83NxcaAsL8DrAIcBJwctcXrjO0O9grZhfwv758aMy5cPAMEeRqiBBqrvXAUw0NKjT5QsrpaUPfVAxBo9L6y7lgaHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b=b2MkzZeYIarNZq0L8in5fw069H5WesRboEgkGxdkpEC06oo7GHXV48OR1OfEzk72mDL3wHKUgp2ap6zqpVcnBgUdM5eDLt+ugT4P9XTEhDuihRjDHpAxGvEPYbW3A4wPj+CdtvYxxbnwW2R3IpTsgp40uwLktlUjR+wCSOMvEFibKXN398RlPUQ5YR/q0K9TlZkph1N+xa9II5nOkErGb2Yr9+5rQwOQ8gRQnJkoAauIRifo2jEeLG1LMRUK3TyDIXSMyxDOaCFO3lBGexWNEcHdoMLJocPEUDMV9AAh1714JYNC/4Lq1raYYMS+5hIZoHAYMRtNJ6NZKecBD6MnEg== 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=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b=UD86mU1F76SOW2YDEkPatRtG0Ptb0opLFCbxLOjp6neH8a+2SRa+cUCUtmMVmxPHfiLdjlvs6vL08qaAWFRK5MELXXAHBXTzISu3VYWHHKnqAd18krXO46Bzun8u/bwXXwXXNxGVFLbbidxuWg8CVP6KZ4utgUH9t8fTP9jc//E= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:36 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:36 +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 v3 01/14] xfs: only allow minlen allocations when near ENOSPC Date: Thu, 1 Aug 2024 16:30:44 +0000 Message-Id: <20240801163057.3981192-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BLAPR03CA0170.namprd03.prod.outlook.com (2603:10b6:208:32f::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 67ca4426-8c41-461a-324d-08dcb24769ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: rTxZTz/hOppwnVUXV+Ks0+er82EfeEGz3R3J6PI3IYcKyOb6qBtBoX0mwayhAKmed06YllXY1KQqVQfWqkMb0Klw/xLlIv8wAlNW0X1Pgfz30UBIsM7LPKhCVXVg34PFkq1GmifwZFyEjvi1M2yN+15oG355MWoEPP6k660kZ4F3sgfh4YgjDY+LwabdLUyABp2P6GrlP223cQ3EstsJDXiPaHzOpiGDE6gi31smvwO1iSMvy0J9VF+6V1kt+N5nEnD2oR7pfVltRdapyQVijQLX7RJCq99+IB8HAUV2LSmr8vT968D3RovyJHNbVwzdVz2lLYyKzf02DV+vI18yvPA4ioZVh7p3zCazAfrVCroHmbuvWS4gJ0ylwma21rb8sd5rEZHA6UFRo68lNv8myyqb0yTRcdxi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outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NRp2SZGYQgne7GTgUG+0ZnoErWZLzG6woKyMn7BfD9jmpNSTgtY9RIi4xCdrBolUeWs7iUobEFztalIfhoCL48ZzkqB3NuSxURTfI3240eOf2OWggHxONuEPD3QbCaGQXnKZ5KN3rDRwC4kOg8pgVQ4I/PhtxT/rXHgmrZzvC9DiPBVBB9kKqLye8LbkDPX7U3UbxRiicS2dvGlbnbZ4dRvtruBHebvY6+/Oy80RKUqmeDzD+GJ8fwQuhip3gBCi0IptKES531ylEAWe/HyzkcWA8ux47xHhx+MIPkd1nGcRH6PzUekd4uKFcFvFjJdvoXGg/ujcBdQpS0teRSSO8xIbvoINKjie3zy/Q1cOH2qV04M6vrrRb/Uizh1KqyitE3RUvibhY0qrYX4ZlfI0gij+52556dM+Mncm75WOmbjaMz54I2LsPzDnHNOWLB9/l1snk08LNji1x6nxUqX5CTyxIohq3LSvqQwue/3vk4jHMFCCz3bUCETIRs9XODa1uYeRNShD+NrdAxmJ2apr/W0wKnVbbPOeY8fx1/y9Jlp6tznytUz7j++O/1inaRFEoKAKcwpu6bNDdLFTSwBDA+FvPax0opz76Pp7swzb2BwRfrK9K5mYfdn8ELt0NuaRGsfqqD52BZg2aBkXB2poHdxBUYrNn048jfoMmK1NijzKotFe2n2/NNT1YmFk7xrmZAPMH/tNRbZMFy9tFtOoLobNxmR7r5oRRynwMGSrtzCs2ree9kofRkUj0eeGr6r+NY0zWaIDLCXHIjo1IrL8CX9OdeAakTY69FpSyqnSRiK+u1JMKZHdiqXZmCivgd1rteY5bgR3ljk9/0EDUNUtkg7/b67epf1YoEb4lNC6XNcKyFD3JGD4M1MafPU6Mw8Cp+gJbSi5pfNtQr/1s9a+CMYiYTezvpF4w7XG2lIvgxQ/NPPI5bY1UEsPXYJa42iynycXn5OkeoE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YSlyrF2ozGjjZYkcZJ/6K1rtlBmpxw8I46+IXhA3ERkhdbt10RNHYXtrwO6eG18s+d7/dRjhfjzn5LA1kjTVYwhxOz0KkL/7Fzm8J8Uz8YAw5CTnUKbgQnh0j8+v02B2yikZ4aWVn+WjdSj+JefUY1X/5bD3IWkmkdw8vMkU5DjCGG4pdlvPGcwAi63K0kLQLXou5DQEdoGMi++lWonmWIt/fUWBj6WqSrg0PYWazA9BxtruKK3xwoyiu2/lYiSmyv8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67ca4426-8c41-461a-324d-08dcb24769ae X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:36.6820 (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: wC4jQCzrNe6wGfEBCCGs+YYn/BoZcr3I7gpUKAbmvov+jIvn0pQmSAeTX5ODPpOlK+FADdeoZe7tc5wU5b/nqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-ORIG-GUID: ie_dUltIEFf1ZQKZqMFESsH0v-gzyJch X-Proofpoint-GUID: ie_dUltIEFf1ZQKZqMFESsH0v-gzyJch 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 59326f84f6a5..d559d992c6ef 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2524,14 +2524,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 Thu Aug 1 16:30: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: 13750724 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 B20D51EB4BF; Thu, 1 Aug 2024 16:31:56 +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=1722529919; cv=fail; b=R7tpIzgLbs+vCaVVCPKh/5rZ3cuAAGGrU0B2XJzH+h+RoOKFPPtV4i2ZJedjyOfz7Ej6fLYRsV32EMwUbSLmRd2NO8fDxAqbSseW4M1OyeDHQh5oPfB5DqxYhPkhVR9xi74MGrW5I8abaq83mIrecFA6PELeWSF1bqMWJHRQI3k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529919; c=relaxed/simple; bh=zWRDLuo/ILWanQJGpQZkcZulk/YZxcolQW3I7gFzbp8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=g1DfBDhTdDVWgpVypKhsSkM5BJ3l4bhP00TWLA2bhNFVbHkASROJWNeONGugtmte1FUsJECLStsFCyxNDZMiN3e/jhJGT0l6d/tN8uhT7PU4zFwaWFpaCoczYhJCkjXV2B2qPjzUSeskXovkjRt11aNMFHPERiTNiSP9cMr9Dao= 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=fmLJjKR9; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=l9jtzMJA; 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="fmLJjKR9"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="l9jtzMJA" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 471FtX5b024065; Thu, 1 Aug 2024 16:31:43 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=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b= fmLJjKR9M8nuO4jGmMmE/FqC7rkEBr6UgvqOZqaToD4Ujx85cu1GdZjuJ6xPaM6B Cqkm989m8QU5DMSgmbDlGPzisuZ9W+O7ATkrz7ElQ6BG0eXADdvaXmRHiF/JGjsS yImKbw/NYh6xY30QcGU2248Vc0i6no9SLpTl8cXeHboMtU+hEZpmxtMXhFN8phmH IIr03H42abF2r5HZXhHyBBd3uy2n5ez5KCm3pfPktveZA2jIBcLsHWpzZwEaTQLe mgoqbGLqsnfHGUXVWlS5Y6sy6tMetWzaRcNe5iX9eDl7//wl+QuIWLNyLfgX1dQX N8fy7NKb3ygxNmlnPi+n1g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mrgsa65w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:42 +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 471GO58k040207; Thu, 1 Aug 2024 16:31:41 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2048.outbound.protection.outlook.com [104.47.55.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40pm866rh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S8RHY5fxllzdghXyQw7Kn+UY5FyGXR/K4K6NnSi+jRd9G1XljiSSlCEWlyg2oa+XrhZi0htaDhSlQW/8YXDKU97+hz9c2UMuPOUB2pGQSJpI2dWaijo3MCZBlHi7EaWcbeFWylBTcXXZTx3EknMluacBI27fV+1Gkk6wgj7BMER7U079Hsi4NMey1WHwtfV/33AjSI4u0djIOiG7ywFA/dAxguZIgK34qU3D97Sd834xx3KC/PSj9AWbp31TcgQngcMIK7XDeSitk4z4DlrgjUx3YN07fYpx91l2QWNbxdWV+dD89OvWxEc3KYanHU3OPkciN4QOjwI/cubReDMmLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b=QxUeSYzHvokoeR5/74zzY04Guvs+JZ1blEBoEKzyDe92/R/0NB6Kz5e1hNhT4N35k2JNGQa/BEZj9GG6ajcJYlq+I/9RzIXJ17tapKZywdnB9+o31Rzxmr0Ipo+KHqVhu7UHGUdy9Kt+WCbzenWLE2qj/JaE4DFbY9w0ZNyLV0wDhftdurH8aB1VucMwGfCbJYgc++xvMOVC9p9ArwQ5zfhDoPa4BcJzq0D2FKi8HpKBrNUzThcv6hMj+FNHgEfVe3rHjBUDYqxzZzEawAnATTvNd+JfbJRl/IYjoMOSDhO7Ppe9Rza2PHLC1r4qvJf5dHtxaqShRfNF8Jrfa2pibw== 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=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b=l9jtzMJAiIz8M2KArdnXLaYKL/9BJawDJkEbfGBzpQLev3B+vvdLM5vUN+gq4DdjM9QdJJAS3gPQbEHMgH02ka54gv7rwVZZmGCDeYly69/a3Z/FmdZikm94EyYy1nz93EU6XK4O+OnJEliQ8emzRt9jWfjcDCro+mMdGWA5ChA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:38 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:38 +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 v3 02/14] xfs: always tail align maxlen allocations Date: Thu, 1 Aug 2024 16:30:45 +0000 Message-Id: <20240801163057.3981192-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR03CA0010.namprd03.prod.outlook.com (2603:10b6:208:2d::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: b4fe2b78-b872-40b9-4d64-08dcb2476ace X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 8eHZyMzFo/T1iCPY2WyckmvtdhvvjhBw+w4cNUe2fTSgorMHfHJ6iKRP6NAJKnKnMbWknaRS2g0FCG77wdSXBldRUo1nLXmzgRy0h1lKDL0U8eDDz2Ay1KfIhp9cusMd2iS/3pn/pNboPDhSRQETxnwkDBR6L4T3Xb8JOdGPIM72s67SkrPwQK6tcAUPf6MNx5/aJ4U6FNsW42pi5PNGSoqUhrTgDz/x0c+vJIBxcGRUjqPDUO9liYbwydi8Fq938P2N8p0M1zKVaULG31ryL8QlZJdQNXt4IsLRqONwYNgmVWjzocDpcZk/jBamm8tRHcfevqHyVE30aI18LAR/10VbTae82bnEXOad3H4UAi6YAGBuvbikmpLvcUZ6pJmX7hRcR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com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FGwn0qw55vnx7Eng0OQxgtlNfEoMkyQlAbRD0Wfuu0K6OIFdjlwbKI5wM+twmI8V5MR8xIzHEgsdiqQ/J7ITtVjBj/buADiTnkh/vjM0bJZ8ugzP5TXSkY5QaQOiSYXfpynGjOoekcg23nm/1I3EWpYAbAz0amxHDIoHOgv/cDuZ55ecvaYhb39KMNPKWywLMubYfsecBH6ryk5G2/W0tES+jSnp34i/sFl51Heq3VWXPIX7u6eW56ArNHBcVKfEar+5tPLoDfnAFkoffe35sC9xf/Uqx158uCLjvBUGdiUg5mqNiaZTZaNLwXG2JnL+6lzg2dkPKZJSrKWtR9wR4cNlJZCTCrfbjTUwc4bLUFQAuoPIBY168r2noy8EWRzNY1SYx6c53x1I0vo+lk9dJiDgFT7JZGJ7nSYJJc8UoDyNQQdvv9KBIBeqHKmX+ivG6iYyDUDEwz8LEYuk4+okYcvj80CBUTy8VKHQ0tKM6HAOwtSgHR3aB/eG3sSFQ0hRcg4FELknp28KrVoJRK5nrfUpMxPiRHwdZUkOCxJIc/KJ+VpoKp989lBF01In9qpIjmSbV8Yt+BKqnN9v/juOQbR0wR13/jQjY2pAKllm5kNYJlBXFsRmY3shWm9tRAhgWYf8onvPkuwJ5bub15kxn7rimCsw6Oq//z71Dk/xc+ta3wjFB6N+khJQuAQ7BcJjgJS55+E6GibduKeMy8HYgSUxKJLkFKCv/gmm4ZVuloysrArH1j3FSme3WS+abh2rX/CtIoEPyuaunUpvsrWHG4D2FUoUvXp+biz0zkFeTcBkE50Us6Urd9WOG9WhPV7G9ay6RCYZVZbqUbNlWDK2qqJiTaum1u33Lmftm0vVNG3UR1RP41lxIm964lbr0XG2jGCxnS4RkqyVs5AIGyHquYmRaIQXm//6KReDXwjfZdVO34QeaBLRjebHdNw/LCJq5VBuGeev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TTC1Y6AD/VMp0kJ294OSIgLtebg6TgTalrG3Kesww+5o6Qo3Q9UEbzhA4xaSW2Re5ZWtVEvtC8ociXjhg6D5xYmgX22BTkEJU+v7dVKMI3eR8g4i7wRLLalajlXJO3tRMFevB2p+SLaMPq2mpYTbEhW/sviqtNJYDiO5jDBT7OlkKV08HEq4k+DrLIs5zKZQyluT8hlzR3yOgEwuLRCWEUY4Yrclr0zi2PyXQTYOTeWFeYDTaG/ZLGzsa3mfwQPcHOFcN19KsXK1Qp5me4kISNCg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4fe2b78-b872-40b9-4d64-08dcb2476ace X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:38.5191 (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: Q9RMLUJzUD6nA2wKru8yyv/ZS7fO0WJUeuqc0rTWNdICuiD1TsCrc87PwolC5jYIOxwirMLj28X7J6arH9LScw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: LmTDpyI55qGTdGxH4FM03f5lr4QfTV-U X-Proofpoint-ORIG-GUID: LmTDpyI55qGTdGxH4FM03f5lr4QfTV-U 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 d559d992c6ef..bf08b9e9d9ac 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -433,20 +433,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 Thu Aug 1 16:30: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: 13750730 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 2F7B61B3F37; Thu, 1 Aug 2024 16:32:04 +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=1722529927; cv=fail; b=OYYHP2UesPaY5vosUtTvm7MyV80xvf2tHPfpbk4/VsTlIKTutzcEV7kYiDDogguof3ucSVM23Cew4XKHRSWJdh3cAKjjE2kw1GILgBgVTPRrQ/eWDDtJOM4tbn5YxDKzIRHepg3Wr6cTlj87/bshmzBcAdZcA55VNU9SQZtp7Is= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529927; c=relaxed/simple; bh=kSm/J2GIcpkORW1LRJoOmfjleQFS3zsoEn/U5zUFaTU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NR8m0bKlz2TYmuwLH1I0OanW7YhypmGvcsAN8oqb+jt0Q9m5Zz8jTEoEA6cDqPqNj3vMkVbj4HMnfpizEXgBcTPYDwZK5nluFAEGltxd4B4beJHdAmx+rOEnykOdD5pINp6Y3BqrC71LxJ+2V2iWDByPFvsdG0sQ6WhN+u8Uz4A= 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=Jt9DlyIY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=VglVvXki; 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="Jt9DlyIY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="VglVvXki" 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 471FtV8j028570; Thu, 1 Aug 2024 16:31:46 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=lco7Ffv3l0/S/vyZtdQ3L34JKK2e6B3Aej8RGg51LUA=; b= Jt9DlyIY3RJ4XUXzKRi6hG4nZ+LvOwN0VvW/QtxHXHIAha+pvCGwo1LAhZtSgn0e oXlI+kjpXPo1rRtmFRI855YaYueyiLGXE3HT9PXkAsaJrFV/0xS743EtKBumBclt EnKZkVsX7Jn3ECPgrvJ5126BHTwa0DTEj39+aI7LutZhHRuzVJSja2juNh6Hcqv4 /IpJvnzDzTd9UdBJRw9Z3GH7kKsTI2XvELyegG7r9giX7Ru4nDw2u9WEjdiJDVWA T1yy3XSWgltXirhWg9qoDgIY8PtrpGFn8n2viL0T1bHx11Fo8a/cmAwpQZcB1QrS ztydNz3Cy1I9ov2B9OAD2w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqfyj777-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:46 +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 471G30Kw040303; Thu, 1 Aug 2024 16:31:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40pm866rjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LTIlG+YFrseOKOkZLqmook7J+6Zk9phleUEIn8AunQNwBNkWuBCzOQpJPWV9lyVuIXfyTUXqqmWNEtAkjI1Z/NSGFAozwbj4ca2fC4WbJ1dZOGHzvoY4UyyaVznbqDgwOyASd7luJxfArrcrQ+4tQEvmb9cFbv8eXxErt/4pXGNgvJyJlFFaDOxHnPxA867zUYpL6IL3p4DYAcQpGk6aet84aTk4lC3xDeyV3AAAA5rBRIXVE1WCXzvjQFdjDP1PikqxTrGW0FbwhZmX+CJUR0c02ndbSYMeRi4FAQQ8Y8xPaw6thykWxF1hGzX413gn4cZ5Pq13Gfl152gdr1DTnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=lco7Ffv3l0/S/vyZtdQ3L34JKK2e6B3Aej8RGg51LUA=; b=GifLt89req6w/WsoRQJnZOcpFZJe1z/HLDopByINmrseW4IB8A4n0/xpFO+TUewu8YeoAMdzkHowlDO+FJcloBAH0PCrcNyM2B2NHBBG7xX6U5CmcKqywC5fGh3EzR2xEubyiPAKtWh8SF75ZPVYcoWWSBwnOZHQxlA6w/911yQjZamTa6FLg7j8uTA/XimSYGJ9zlhPl/T48geLmr3/j/j4MwjRT1VOXVBCPEuSp7Bi7QtcjF2ISMD96yAiYwjMG/5txgnyx+jmGdwncTZVuw7riuxaGtX7h199tBY+Z2rEeQ8F9tZQgsJlZRjGPBswyCd9doq+/pOHL0hgFaCTkw== 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=lco7Ffv3l0/S/vyZtdQ3L34JKK2e6B3Aej8RGg51LUA=; b=VglVvXkiAXOK76A7Myau/49a37OJQeOK5kb1CgNNXXYhqJuveTSg+fml+U8HhOq2cMIYm2jZguNxMXuiPYnzm3jrYy0UsACkFkwwLf6W0Mm/T4bSZioXlpHChPjkO3KuWEOw4qpj3335MP43MJr/DjfmKgju0q5Kkn8bx2ymlJo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:40 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:40 +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 v3 03/14] xfs: simplify extent allocation alignment Date: Thu, 1 Aug 2024 16:30:46 +0000 Message-Id: <20240801163057.3981192-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0341.namprd13.prod.outlook.com (2603:10b6:208:2c6::16) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 18581e63-ed45-4182-ffb3-08dcb2476bb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: qnxk5XAHjKbFGxbgb7IrB9dD7ZovTCHFl5aLixLC83K05C0FGeX+TzcRPS2cm1bcon0yCL61qRuksQ2NNf1Emr/ZUwk/oLFbLZktMASUTvhjmJQVfc+Q6Fi5WQUsQGw9zeUe8emaqN+Y7nB2h/d87WOxqIpuowsE49Hu4S/ok1mjnqoK6GMH50gt3k8TKKHPiL1hm9oxXISTu2WojqqzkVjsvL7vcBkOx+0znNTXfTt5mvXpUK3N/oRUMlvoUsRuSrtl4y+kIlgSUbPmzHjAzdeZKL7GxWBjbIYEhVM6qFSexlL/gSIAkVBj6eyK1AT/ck1NgkRHKddG/lBSm9VrVBMHnkcf3B1dTRVX6RgHajB5nuoD/SCXBp3v60VM57HrfS03NZ1RsDK9BYg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e9vfO4qXFV1iwOhp5F6u5mdvQkJnmjQ5SwxbJXS+Z7IKFoOyb04S99nPX2COh4oLpTju6p6VkxjGbwaY/ux1tD4dB+m8w006KyQixgqE5UKNByhI2t3Gk98IpVySEBijxhHJstZ4qyTT5hDEaUzgajq4ZqpeRXhz+n9aYc6S0JcPu5jpcViWl1uirvmemmbrAYJKRLubgRzAGH51vWEpaRIUWqJZq9VOx3b5AtDk+Xjln5iHQnTps3oyJDbbsNc1WYR7xaNzw/cCs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18581e63-ed45-4182-ffb3-08dcb2476bb1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:40.1862 (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: fcm1jU7Zsi8Qat4rM2ySHw0sUMqyof31rpu3zxUqU3fm3ZSBtkorK8uzHyJmTR7cf6srrE+WomGM07TLgHp3cw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: ATuZYtKiQci8Ufk6aZfpjxdFKBTxqWiq X-Proofpoint-ORIG-GUID: ATuZYtKiQci8Ufk6aZfpjxdFKBTxqWiq 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 Reviewed-by: Darrick J. Wong --- 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 bf08b9e9d9ac..a9ab7d71c558 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2506,7 +2506,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; @@ -2535,7 +2535,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 fae170825be0..473822a5d4e9 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 7df74c35d9f9..25a87e1154bb 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3286,6 +3286,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. @@ -3394,35 +3398,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) @@ -3437,7 +3449,6 @@ xfs_bmap_compute_alignments( args->mod = args->prod - args->mod; } - return stripe_align; } static void @@ -3509,7 +3520,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; @@ -3549,7 +3560,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; @@ -3563,23 +3573,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)); @@ -3597,19 +3599,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) { @@ -3627,9 +3618,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; @@ -3637,7 +3627,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. * @@ -3654,6 +3646,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); @@ -3673,13 +3666,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; @@ -3698,8 +3689,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); @@ -3723,8 +3713,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; @@ -3748,8 +3737,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; } @@ -3776,27 +3764,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 0af5b7a33d05..2fa29d2f004e 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 5646d300b286..fb0c46d9a6d9 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1811,7 +1811,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) @@ -1830,7 +1830,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; @@ -1839,7 +1839,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), @@ -1852,7 +1852,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 Thu Aug 1 16:30: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: 13750727 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 063581BB686; Thu, 1 Aug 2024 16:32:03 +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=1722529925; cv=fail; b=MlDwt5JXB8zTl/Fg1Z2F40MXbkEEOrgIqEBcE8J1uu+f1PQ8TmJTiYdEmnXrMUVPVZwPZ8KrEsVckGHIETM0SaAwAX4nVochv7Mev+ZdztMfytaHvEqpisv/+fIOksDrZVM/J7K1Np8okAcqoKlUtJitN9l4u9ZARok6AJX/r5g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529925; c=relaxed/simple; bh=c8gojaNtQGaRgutvm42uCgJqO5Qhcwrfzgld/BMcKhc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=X+rZyUy5gW6ToMhu7WZOuGwkAHXVs1WSNsit0Rd/+uhog2HOROLziz51KBd67Vzw6XxHhoiQDpJGCHfqIk/UA10ZT5zjp5F1mz5MGCIXwqLOZ0DYMNGMfSx9rqdfSl2BE0sRxaCIeX8MXbRTCytwO7x55gYyywBagWvnNMfl9No= 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=WRmqYxHe; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OzmniJQp; 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="WRmqYxHe"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OzmniJQp" 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 471FtV8k028570; Thu, 1 Aug 2024 16:31:48 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=mfT8Q94CDIpjJ9DeddZlavq3BAlepPIDJNWQ+avK3tM=; b= WRmqYxHe5sCtYVSmrnGZlqOkbhndGbf845tclzGya6m//eMJdvkJfBvdHQ9Vfb0c PHjBod+9miBulXUJH0FLAITJIOJL1Tfs3vAcz27HNmpSm4UBpUnjQ+juJDovLNWK S8Ckdve9cEP+as8wU/+kDFtRk/a0P0G1ImuM6BURkoe/UktdwAbc41ku++m5DJ7N fdHdUPBZc5gu25D8u7o5AHQiV+N7o9jssGAWz5u0BM3dXjCNuuVi1c/ZglzgnloN j/KEwxUNGIWq/BdqXmOSmKDV7IGRB39nqF0M/ReS9cxQTL/Nc2vY9v19mseNnzOq Cx3r5K6Vpxw3uJHDIktTZQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqfyj779-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:48 +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 471Fe9Hg036902; Thu, 1 Aug 2024 16:31:47 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40nvp0es54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t26tKcVDsDYGmnh1D0EXikIfI0zeooubdSBdZifjbo4tXe+UGRfVHkXSpRp1gX2T7e/yANuIwLEo3pNnJ0rKPoqRyz1iKtdU0I4AjZZDr7ayBO8MFQoO0xZYqxswYM0pBBHpPRdaGxWXx728XDfmXCf50WOremm0+C2uojsqkOjq09c3QwNiIIg/3WexlwIJxSBExhAtUbC50WPwyprVEmKjIppu+iHZVbFokzHNGR2UstFF1BmCHu8jbc/fWL7aubL+Lq0OqTVSff13UyS8ARzkiKDIu73zFLnqlBLnzrQ+VkzPpwYj5wwJrcQfO5SkYtFW/bqMBKvRRNdvcuNJNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=mfT8Q94CDIpjJ9DeddZlavq3BAlepPIDJNWQ+avK3tM=; b=kq7i/aDrzhgeD1bxEafohueyWzLHMgkhTpYiWMG/iaenNFk08LOwWFYflPtzji3uVbVZGita/9DaaVbGXsHxesv42sv6pV4pLrx1HhTG+8BXvEJNMm4fsezcI/pi/LM7U6TH9g2hTf7l6tEywtTzk9PVSW0qF+ZzSerZYNsUPAoeYaBikNZD5sv/HwKUh7imeJrMvr9/p2BTq5KC2TclDc69AXbEGtkO67Ij7L5p5Fav0EtKe8H6kb4LuX91jy9UybLNNpW//FNSk08rmKDw6tElcnce5fCHqZLoPk6goIyTKU2TL7I5wIsR7f6P+Zv/gD17QzvrMblCpa1U8B9Snw== 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=mfT8Q94CDIpjJ9DeddZlavq3BAlepPIDJNWQ+avK3tM=; b=OzmniJQpuEkLvrcCOcRC2H8lBLdtUIT4ypKA3fw2km6EqmQuSAOkTrLKh0tiAOVvxz7rCBh0lnj5iTD8lbJmrBheVYfsv6f8uUgNCkmJVY3zWwXb/LUcozSFFOM0jYg9Wr4kdrAd8PX+Gi9M0DqkkSM8m4OQR9NsVjHU6ss5EKw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:42 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:42 +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 v3 04/14] xfs: make EOF allocation simpler Date: Thu, 1 Aug 2024 16:30:47 +0000 Message-Id: <20240801163057.3981192-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR03CA0035.namprd03.prod.outlook.com (2603:10b6:208:2d::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: d942695a-1d8b-45a2-ca52-08dcb2476cec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 6BbZ0tYR1Qi0n49cmc2sPUZHSbh96g9mHKSXAMKp9W0Rd5cXxd2AIgWZ6eD7gGzdHGnGW04F94CZgPLxDuTACoo4g+CM7+E0YcWmDbwA6KGXMwBDsdXPkNzfu5zIn1XJUdupmsjwwMn+HVjavonpsjHlpaEuaFAyWXQubumtT1+DPRayycp3In/UG3IaVRbnpAdmqwrnhMySjNZDrkvwbyQXqKziROLxJN6QPzqSGVRsFAoRskWkPfrUkL66Bho1NQ3WyClGErj0sDEPoYV4iyqh3uyDwo/soxrG3HehO3g+pHa7Bf8/36Dg6+1cLiY9Vql9BhGzxOMjKnKGGjQ4K2lmXpJ1UZC+PlwwvYo08DnuY7YWSiIW6yzMdqumiVcGFZUoE71pmniojmYbB9fz+xfIC1i5euzBGaKWayTEqi/38pO42fGOMj1gzmj9q+r4U2w2saCnl0SX0tTVuZZYR+52i/qgh3xEm2Ao/IpHaQq2Rm3ckpikSRod6HsVuy78CM0kX71KDnyGGse9LvGSlzpL8z+znO1MaCGdu6t5SP09eAUZrRHuDrHCaGk5V+hESio4jJFF3pICa3XLu8qMZa2GJLd7DU+3o6oRPDfzyWlwYbeFxrHRzZAKdo68pmaNV/vm1r5QOl38tx5Ny/ODKAOLVCc9BsGHLpVcc2bs/8BPOZKLyqXjva+sq2BCBikJ3dZqLo8WKNrDM+lwt1bGL6DQiNqbc8bCLtLND3K36WQ7QkJUgen36SQw69BmzPOQT+Oi/TmHQucSiylRRAFmLA1NvAf7s2rO7PWAS3/MChM7oPoS/LRYE08I+IpKU9z1nVjxh5kmimDdh+oruKZdQh0gMqQ9bf/igmis1h//dL3LIzPkPN3GVXbJjZUBbOateHWvqb8GvMd68QnJcLLEnCcu2bQNRMDXWOTv3MBAQZs/MC+ZlGOUxWtL/+61wVLFgWkblHZg0qp4WhkyRkvweFhluuFlVUI2oJI6jUEjATaYKY0aLIq6BWJF2L2nE/+2i5hYILktnK0jfAP8ahr+Rn6gZsQzRRlKTfXx7L55/nep4Nd4DPAgu38iA1GPgX+lA5iy4oCTKjgRGxD+0TYtb3TezcLc6TH9/oRA3RogUufZG/D5DrmOgp7nkaVXZYlmP1F6evHOkXYyLKs/zucnzij3vCli/+lhjw80fMLqQSYZFEZCBwpAw7Lfzil0M2jv13kFSkiPOFlUFHdCNWkSclM54x8m/613zQCVbafbVqJwn0fHi+Fg00gSrywGT3DEP0zN4FmAxZO0mIFpcjtCdiaxXweAs5TdsnEz/6aYpQ60V8uDYZKekj2vGyx66l4UcSOBgArnGTBGvIHCaudZpA== 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)(1800799024)(376014)(366016);DI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WazX3hqsYS95S8U/kd5IyJ1KI2vhztNG9K9ptxnNImAA3AoVAVBESO4Q2lQJx4BPqKYMBg85BNmUzz636d6cZGnXpgRsgWDc3du/IInNyfpTj+KCQJvcrzabD7xm+GlVQHxqheMR4Cj235RO9OOZuxz/oziopv2FOMeV1buQEg1dfE67sVhNKGFG+58+sgz3rpJIrb9/2r/A9nYI9TiFhAi3BdgSNsXWRY54/zZE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d942695a-1d8b-45a2-ca52-08dcb2476cec X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:42.2147 (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: qXV33Ad7m2MMMIJ/+/PPh6g5r4hWHRMvbqN4+TxurPYokMBrLXgtRArbz1IzmoO3M7dscSGnOfyibPPUpYPZKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: QaA0oiZVGOYFqmrqbHmqxoCKznQfT-c- X-Proofpoint-ORIG-GUID: QaA0oiZVGOYFqmrqbHmqxoCKznQfT-c- 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 Reviewed-by: Darrick J. Wong --- 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 25a87e1154bb..42a75d257b35 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3310,12 +3310,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) { @@ -3329,19 +3329,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; } @@ -3551,78 +3550,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; } /* @@ -3688,12 +3649,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 @@ -3715,7 +3683,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); @@ -3726,23 +3693,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 2fa29d2f004e..c5d220d51757 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 Thu Aug 1 16:30: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: 13750728 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 2F8371BB688; Thu, 1 Aug 2024 16:32:04 +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=1722529926; cv=fail; b=UFLZz64U8cAncsUp8QPG3h8rlHt6vUzdS50RDSroe8a5iuWooZTAKMdav+VRBUUETTyd+t422evM8rjSu3CvQOfV/8XnH0y5wX0ygcaO3fb59/H4WULeh6037jZuojpBXLWwPmDKChCJ9oi5dG6UZYBqmUbicyy3AKHtHuqDlWM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529926; c=relaxed/simple; bh=z1AqAu1tJg7fQddCo/GgIMBw7lwPeiVDDZo4ripdTns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UuYOTfiG2aOxXbJmBsq0ioxgkteAhaQLpkzjajzqzSNnvWrkwgH9Ynh7fK98I4u5oIlcGRae5qFh7R7gktchUxcuISUqXB7F16ZmAZiAFyq0QL2ZGLit6eV+m7y6ulYsVJxCKa5xqkYysfung5P06NRBNJ6Y/i8wztIMCfgyzXc= 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=P09Pgxuy; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Gr04oFmK; 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="P09Pgxuy"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Gr04oFmK" 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 471FtXdY010818; Thu, 1 Aug 2024 16:31:49 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=0bzkiy0u/DAI6YbJeATr2j9i1rFJTZAu/X8HDWVEXB0=; b= P09PgxuyD730ARYumSYdldFtxRriS9GeW4K3+YdMRhuN/8KsHRYPrzbseJz+2Yme CfqmRQ3lHkFZNgd8fbsHNvfFbUt9kPkpk9OT+hU+vbfs1yonTNyORM01TUxW2khB +1RHIQJ1afAUhs6BpLHpwCmRfZyAdVj5RkHqq7A7h4e3JQWs0d76mV72AndQXero XSII9jpy4S4aX+vJsseT4Cfjm6n4B8kyzIx7UlnkQvIgAdTVMQwNQit7K+F3la9T g/MHlRWt/pbjdGx05Dg6oFYn6Yb4GW0Fo4gWQ2NgFFHOlvHb5/dNwfFo7fmBE8Wl MS2u+9ssa1XtXnGipoiFnA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqtat9c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:49 +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 471Fe9Hi036902; Thu, 1 Aug 2024 16:31:48 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40nvp0es54-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tJXfK/p46dUQ7oH0Yc74xBdVsPSg7Fg0oGSVsR5FVHyJMHFo4kOYlIHztPWVHMm1CVRGOz3dzK/3y3JCBVYK4tZOAdTB34UyS7D6V9fXlBR3rW04yAUZc3lPs5kv13XUfTkl0vsR5piWXsPUoxSxzG/WgSp/9C/qRZrhHU0XMyJB9j/Siihby4PWEG+X/UfuyfdV8S5T5qemJ7NkXDN++2bo/bVJUislDgYbx6N60iPgyjPU1v1aXIgJLg6rJSFHx+MV4GemJTOmHUgNrtB6sG6RSH1VaglIGDCNeVNDiJhYwZ058NW4RgBqqYeEhlkJ9a7Uq6QvVhHWMoaS0XzwCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0bzkiy0u/DAI6YbJeATr2j9i1rFJTZAu/X8HDWVEXB0=; b=EWZiH9Sxogx8wHelc7tSq8RbRCpIKCuZbibBv3wt5YuVvIaHidmd3WRe72brX9Wliunko77wLcUFH3DpUdIEKNC/mhvFqLovNNxG0usyWhU1MfXQ31ZDrXCagaTQesjzZT8vtLiiEhKmWkDmS54IbNG3QwPO1XEuSIj1cnySEnt1Boz/sXwub0CHfeXM7z9Le6GabrOSrAHozHxAUpTYGTiRVbHidGINUd7JtWnkwk9/ZL8vNcCpnT2CPYL1Nesu5BHIukgAQrk/lGNMHiYdV6fLIth2qHi2Hs1HRRIwfjmX86EOppgduRnJ6mzDgUCJB7etEIxWv/PrUfLIxOk26A== 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=0bzkiy0u/DAI6YbJeATr2j9i1rFJTZAu/X8HDWVEXB0=; b=Gr04oFmKZmbLwJgtAWGls6ntK64Lk81oC7dc+qlVaajKQoAmR5afZfE8nRprIZQapE3iFe71EcSV+0PqxDGuMCVfsZiJDQSwTov8KfznWzOt8hzw1xysYNe3Ojyi/IQDdaMdMsvepZ3eU8XHSsep5J4HU5Ol8v7gt2gWiCSHjQI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:45 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:44 +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 v3 05/14] xfs: introduce forced allocation alignment Date: Thu, 1 Aug 2024 16:30:48 +0000 Message-Id: <20240801163057.3981192-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0357.namprd13.prod.outlook.com (2603:10b6:208:2c6::32) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a348af2-c745-40a8-75e0-08dcb2476e38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 06QgEZLkp0z7cZQ2HCNnybvd2t/dh08XfJQPkgKbhahp2UnhBv0qTTTXGbxF0W10k8p6jqTe/Dtd+SRUsYwPZoaiEONGRk02htK1i6AwhmWXrc0mr5zLgv0ftjqZk8BtYg2XgMiiBQpsn1NcDmnoFf4p1ENI9wiZX2+9YGyPofVxered4sJFH/49a62MfUiHXgpxpITZL7HIrpCgssW6+NS6naUKE6GyD8HHD8TuVjymn9z+k92bl/7aNMcemXi6LqP49M23iru+Aduu69bWrvgVANwMhsZJSGJo7eZrr9KC9v1LDuV9aaVRbc6KnYgNqfrXxtASyHgvgMloh6Rwng9mOu8BytJI32pp/+YgrM3ZAjSLaZJDwB7pbjQaeHciI54x+zE5cVgR1MHY0z4sBgjYMqdqbvQSu/FgvZqo4X/xV91r/FVDn3lNu96uvXa9iXMhaq3QGyvs78knIBwHc0btN0ODzt2/wrqae9naO/VSSlaIdG5CKE6AVq9v1/5XJXrSpObylYF8OJxphdL6jaJZ8VlXtJylqAZdrye0VmDwM/3M0IGQIq7sKex9bBMXMzFDyfnmgdO7huW3IOiBeXFRi5Tp0Fhah2d05GrCLEpmpEXaydQ2p0VnMBNIPj0TqKoXmAcUEKf3S3oOMhZCgTxYTFstjGF7l224vfe6lJp9LWBkYdueerVQDo4NdNkcWxvkRkqu2IsNMifUPcWcu8jPD8KJrdOBvq9k7Ph4StZIqbSrDcdnxBgZ8VNnkXAyP+ajlritq/5TfU9jnI3rgytjgyc2ybYwE0Zsr1ObLA1T7IGq1jqVR4mnBdIp6NDhYQNXvhLHkj+Wvi6PcuVqU0F8OjS5oBEXq9pwC/rkA9VXrf4PIQAxkXSgIcAyakpI+7UXLjgWQhau57hsJA783BBh8n/5yXQ0i29x40goD7N4O4WMj6rd2EUJbxa44hZpEx0sYVVNe6LqkpDITGK2Og6Ce4L9iPuHCsXBaBOXqXDc1fyP3nIhhgUr9ic95iHozBGau6JFjIayy8uYrYMQn4XmHDilLI1xVKvpNAeIHYQqHwHYRXGIpeYX9Revm1JXgQ4vAWTDQeEsnpXR0lIRMbiB7zp/ndSk4nVXkc3ofyVaoQBCKlpHpbSkHaPj4t9azaMRh0szgK/1e+hOy7qFGQoyc2uWUa1Or5PjKOWEpgvp9fWYo2y6NtxZ+H+B7WiwW73hhrlS81dvyoTv+YuHXod4SYhoho9p25gBUu5Ga1hyUGGAVyzs+Y4FN07A8TinSkRFC3WqF16kIdj5j51NDovO2xvoYJggsVBeW1n8z8WBigLgTK3OsGwbNP3nSsiTxGs/hrYfPZV00pEgpf45rg== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KaCrfVtBTJa9223MpEYEXCTqeGK1JxUNhnkJcLdE7XYDdrEPteGNPOupWuqJeBWByBr58EFpyc+z176VqvdfgscwL++ybiXUKnNjlA6QHQsuzTA5g2W4BJRHiAvyzdt358UkElYlHmJXfjlwJ7BCTRp+4BNcfbtNIqeI3vrynwODTc3sIpVQgruTM97Y38MjPoLBGeDV2Ugjrcw5PrtR4oKI6rZEXTsUcqXxU4t7pW9S/bnSecLV6UO7ux4zaZE2usOjbonYuzT15wdUEtKh0vc4lW/7duiJOSASVf0kVcC1u9AyYVKT6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vGboVfvbabi5QhRiqLsM0qFz/Nab8Sh9jVeJXEtro+ZdUPLnD7zB1Fu4PUflBjRRGShwIZxoWpHVBma+0hjFPDXy7sbwbKjyW2FyObHk6qFDIEeF+IwHh08urEtPuz/V4s587lIgjLxtwiltByamKNd+ywAo243YneKtZGWJgk3f3wpGPC7fIavp7rzfde7g5mgZHzuJ+PD7Vsl0vH0iJwAYNKoKbGGTp/bdiK2jh4I38yWui06g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 18qF7F3R3IDDRclRydaH1D+SUGCja49LpQrPX473dP831MsEYNlBEBQ+PsWB8p0DQ3iWBhZ/F+frtINDwoif6EsC7ghTUSFHpKVT6lHO/IlU/iNl/6CK/K7tiZxKc5ah7bgMPzIIZ0s5GMC9J2+OJasKl6JeNiHhhSdvlezKbAEEN3wVppoPJ0NuCxr4Ig8BTX+5lx9clskg6StrO7hqmBICitvCKTPIhqCP7Dr/OFKn3PAnRSoMRkl0nCK4LeY9I3Kp8b0R+fCz0pHfNZIDf1k6CaakvpeTocfCDs9NEHBABJBRnTewA3MHBxC/MoAkKWWIWg7sJz5oDRivGTV7iGz0n8UsYOs7o3XCpkGWJy3IUAGefhRHq0D+m3MSdnkzLwcFkh3b6NnDDJpuqodlIj2ytA9QJY1LK6twGpRpkZDs3XPj03nVFgLCNtvOEt5024J9JcOjICumorN3mBZrsTUnk0URhuRtcQejk6SsIAq9q8qAzkN/21BaaBffkOb//VXRf4UOEqrHXdpJj4E4ingIrbuyY++H0pJFFZB4RD1unTXTe5EJqBPDBVi2qcDphGfVcZ0BPmNDMDiJzB9NPc0kjGdBonqDKdagq8JkMjE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a348af2-c745-40a8-75e0-08dcb2476e38 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:44.2686 (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: 2kr8uVHQ+bcHFL2oCTCQRbMIQWmn/W6dh1kDdG1yTUSpB0pjXKIgn0QUG+us/+gObcF3Q2ag/hmbDAilpqqUBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: Tk1_fTFvMMQ75znzE7jlZz_wk9IsJD73 X-Proofpoint-ORIG-GUID: Tk1_fTFvMMQ75znzE7jlZz_wk9IsJD73 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" [jpg: Set XFS_ALLOC_FORCEALIGN in xfs_bmap_alloc_userdata(), rather than xfs_bmap_compute_alignments()] Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 28 +++++++++++++++++++++++----- fs/xfs/xfs_inode.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index 473822a5d4e9..17b062e8b925 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 42a75d257b35..602a5a50bcca 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3401,9 +3401,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. @@ -3416,8 +3417,13 @@ 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); + else if (mp->m_swidth && xfs_has_swalloc(mp)) args->alignment = mp->m_swidth; else if (mp->m_dalign) args->alignment = mp->m_dalign; @@ -3607,6 +3613,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; @@ -3658,6 +3669,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); } @@ -3716,6 +3729,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); } @@ -4151,6 +4166,9 @@ xfs_bmap_alloc_userdata( if (bma->offset == 0) bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; + if (xfs_inode_has_forcealign(bma->ip)) + bma->datatype |= XFS_ALLOC_FORCEALIGN; + if (mp->m_dalign && bma->length >= mp->m_dalign) { error = xfs_bmap_isaeof(bma, whichfork); if (error) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 51defdebef30..bf0f4f8b9e64 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -310,6 +310,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 Thu Aug 1 16:30: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: 13750729 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 C8A821BB69D; Thu, 1 Aug 2024 16:32:05 +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=1722529927; cv=fail; b=GwReDFHpRCrlq9d8r3Vm/EGx4+egZjOFTJJHv7H64YvGBc14GlnpgCj1N5A9Wq8wqhpU9QvYPyqiiC3/vfWX2TVV5IqT7EJrsMhF+Jg+Zl2H8BX2ZCgyJYQqzKnN5gBZLDbzFjk9BCEPaN8DWw9qrDhTJIHvkvt1RcEUOWolN3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529927; c=relaxed/simple; bh=9rAvIZkBqEMJF/OGzmC8x+TbIitZExhngqTTkGjs7wQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TwnPB5CESr0L9SR8nlfE3K+ZwZYkfC3gLRz5SMczA0MFb8vi1+vnACKmLN/mG2D4wne2G2zRuyTlqBAwLk6yX28Ij7xutXmXPwKAPYOqov6dqRBkTGBRCUdENkVK92KD3EnWxmWWPhslKqe+X9Uhx4807wxX9yxtjEhD2/uvN5g= 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=EIk1vtB7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=IhQGXGkw; 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="EIk1vtB7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="IhQGXGkw" 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 471FtUA7002499; Thu, 1 Aug 2024 16:31:51 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=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b= EIk1vtB7mthWYNJSz7cWoOmnk6Gh88nO1TqbDa4cajzR1wDwNCWPgWkqfb4phL2J kN7z+anUc6bi3bpngGYEQlk6Ef5Kib6Ujd3kuNMgGl8/UtvOBB0PiEyOs9beMLB8 kTqByTXL6GmhFdPfW5j1zMcmARE5GzdPZrhMWIWBLRWRN99eaereFYRS3LbTSQCR bNiExW/1PPLeEXGv/v6mzDXTCAuEAeST8DkweqvVl0Jt2wqLD4yVTAKrkkJ95ee2 S9qkNz6jz/LcPd2gjGOm7+UcrUJGjbVhbMkHgj1z3dr9vq0nV2PVcxu6mE5LIcd4 iX4foH3+dnNmDVrf/i6k1w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40msest6sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:50 +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 471Fe9Hj036902; Thu, 1 Aug 2024 16:31:49 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40nvp0es54-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cw+BZDK9wVxiw3TSVPNzHiGlAORMDsnYXa10QEvROzDp7l1MU1xthip2A5sWhMXw8END6apMZJKjekMLua7P1J1T1mK9dcpvxgu1DrRt9HQ/J9wwqxZrweBuHJEjqFe1yBHR1xV2GUb2yl3o21k+55yQKf1Oxb0thJxpnPUGpKZ5h2Fi8Tpyo/KZkCcCQIvy6TAC8GDMbsgK9B+CmDniVNjTiBXwtvylMc5MKoil9BU6MOZEcLuhbZ6mstaEn9Uv5ObRUd9AH3u/zJgk1S/97i664DL0aDNtzMpn6/ckcfeFRvu/ZHUG6O2xYKKwJbGCIslzJGWLsvhUYeZFue8gxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b=o1uyryGoVVmF96XGSN0h1kaUadhlS8Vs+3AMunN70TwadkaFJd3kHRyIhOvjRQgoukAxBg+fzJplJepGp+ke0/vvOJt+5l22U2gpEhL+Fh3EvEygZpsH2+eUMbr2OhvjrOOAglM0lTxRn9/Ejws41EZKDj92EHrrALPzsizgJKOsYHhk+llYx7TtTKbdM0xp8ip7ZdfWR22QTGK6Eco2b9S2BHXQBsWdRThp7bKAi1LzBTQBEjrA6d1ntx1w08DNsj3iwVvwkoiVPbc1EVil2xb+DwQv7xLCtFolN/j18kucoYrxvUa5jjOhW5Fr3rpHAvSqnJGyzLONjnFOVVf6LQ== 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=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b=IhQGXGkwmMuUyt8Nra12Jno6vnuNmNjq7i0qWxAaG5WI7/DjhlhgyXxq9KNhDgRSb8lzbJDvHMU+2xmQympUJX6oDbELoqeSr4OWjeiaJLFHB0wYMVcTUrpArAIX/79GrBwA41mPdt/zVo27ZSRHswPNj7DC09qbykPguyT6EeY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:46 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:46 +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 v3 06/14] xfs: align args->minlen for forced allocation alignment Date: Thu, 1 Aug 2024 16:30:49 +0000 Message-Id: <20240801163057.3981192-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN0P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:531::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 747159c1-9500-4581-7623-08dcb2476f31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: Bj1F3LA7zAXLf6J8o8dpvI0svLWUHfKuHHRvnCG9Q9Fazo+qW6J6rUkStSMqEZXxUB9B33JurZALXNCm7N0MHkeIUWSS42sNMMye6AUrYgquRNG4dWs9vZcuEjOFQArDC+/7sHPO8h1l/ugSsXYbrNz6/F4yRdqnLpXRKOKFcM8G/eN6Y1QEa9fLfbPb+fEnMBJNI2rF9EaSDRYeVOjoiqofftl+bfdIjEUhK8tKcdsfq+8VcQMIltMUskfTF080LbLWOaTgVAc3dEo7q2YV85wjuynA8Yn65dwmcvD88o9VICHhR4HlyY/tx9ezd//r6RLtU/Bmoc5vXBJPqYCoxVNkfQZhlgvtz0DyMP5Gd2d0ZTw7+Foo4uhu/Iw/Uv4RpZ3tCCwbzCAAgNmgdWxANje1i79BdTHNFHCd78lvHeaWp+GoHaIeoQhfWKeqakx+NPCKbqufO1Z566wLDDQR/gY3lVPwA6oU5zEXAMDSXTwly/btZPypA2I9RiCdAjD9dctMkikLjJe2v/UzwySaOcn/RByjg93i0TtzNJKmUNGne4fgRQ6AgU4aF0ExUnkN/ifICdGb9XTXn6LuhSLBdwCSKlnN04pd/vIUIDmWgRntn/srN5ir/hLmvYWOupHtgeDk5uTCylMuzNeDkdpdnbhSXXvV4K4B+x6Ri4wg01u0dd9cDkm/I5GC21QWHv3zEiHneLHFrlchbO7s99uFkAbFMjoDC/WLxrwPo/NxpDCaQm4z9/qKBLK187OEyrEqFsyCgpnwNQt7QYwRxW15VlHPlfuAkO8psKBnsIlWKv/pDT/LFu0WRaK2eMtRgwbMsLGNVt1yfx9/IN8n9v9LU/OKw0PPDGb62IOpidJNlhcX5HeaNh7tP8XULuK+SbP7Gi7oMWjuM0y9fRu4GB64eH29CwLZ+5VX9PJV43iRjFG5PGh/wEMSUxnKQ0I6OmV2Y9sKIy8Wpb8UMSkomAUbljeKhSscsidj/fpDMSDvHIKYcAE5gWbKzshETMQZq34n08sK0RpJL6jy6Y2rEkbFn1Hvs7M8Nm8wDycVEaNNEXw/AOIK72qS4aL04rgTHth43mL671FE2DMA48sKwMJWAf8LgXaVAaA6FUNzsrTfQ5jCSFJ5jre8HydzFBNdTGt95WGObDtPkM8bQXtToetEag2XSpHuTIdP6OVcOdSXqnDk6K+ZBNFV9saFt8kg7YgFsYOsPsb7x6A01sExqLU7d/PtxRSJYuawgXWtaNiIOMRN2XWcD/Nrdv6USR2iFNJ265F9bXPH/u0mWrJETXWUfXW+odJbzXGaL/MMtuTXFqgB3Q3HY1B/wwVVRK6GczUSAfEFgYRfiVdwQYphpUqkgw== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A5oP2ksMmA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7eA5qW/WomD4b8uZ0pTiG26Wt8hU/rvRXrjn7uRh4bzeywwtruazu1NdZ2hyfG3hI/7gVxzo922imUUqTsU2NkLeaiN2MpCFmU6GionM92YgAvuoOtDrwgBXGoVZJ3NrZmAbIgJib5gcq3R0yR+C2nphMsks= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 747159c1-9500-4581-7623-08dcb2476f31 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:45.9397 (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: C5N9s/RtR/7ESokTMd0Khj/gSg76idqssk6BkU81Oooj5mlSBJuPZ61MoguAO58bKnFcYeS3m9YZEJrBVtSshw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-ORIG-GUID: C3P-rQKk3V-7cUZlXVUVDnrkEwEKTcEk X-Proofpoint-GUID: C3P-rQKk3V-7cUZlXVUVDnrkEwEKTcEk 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 602a5a50bcca..0c3df8c71c6d 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3279,32 +3279,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 @@ -3340,8 +3356,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. */ @@ -3659,7 +3674,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 Thu Aug 1 16:30: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: 13750735 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 979AF1B9B4E; Thu, 1 Aug 2024 16:33:06 +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=1722529988; cv=fail; b=d/xCaYOmsPSVkZsPth1Xt8IprqpQotqVlGwP8i7lJCsRjStGuLi0BtUUQxS0GXwvb+EPuApo3PTvB2otcE2/v/w/c+5FH37I4VeN2a0TzbW3DXk8kqEBoli5wM00Wba9NJFDWUdHocrfzR8vEuHgdnkjO97Y9cGhEX2R6UCdzHA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529988; c=relaxed/simple; bh=a1jehRnMmuVsRrguzfau4mgpscPSWewfzNhtTSXK+y0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XGmdy+z/dtLyTOWL13oholUBaKUEyW9+85eMGTFBwK+tvFZxbqOvDEtw9elxVGfOQmEhWadW23NE5Mc1GqQSnesCWo0SG/24uNVG3GG9vNPLnqtyKDnaAuAZryamnSRiGEGbcaloIT06Vif7+mzeXhzXCMVutYsmXhwrL7OiSZQ= 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=DpGzJ+4C; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ZLkW838D; 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="DpGzJ+4C"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ZLkW838D" 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 471FtY1W010833; Thu, 1 Aug 2024 16:31:52 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=8d0E1NCt/EKYL3wXt0IKGbAO3KgnRxvtKCwZkQZIxFY=; b= DpGzJ+4CshFse72ri4tZSVFumCbC42+4zboo8eXYUNiYbTDyLojxr+N4Ulur62pf e7sz0oKEre7kx1HY8LkCXujdk2bqVR+Z9usqHjRXwhWwdLG90MGOZk+nwZLnDsD9 jpjPFjcfsmSbqnG1YHm1oMtk+76B2s8juU1lVqNnKxzGF76Ww3jHffDMT6oPMHxy K9hStQBbhPZuIipCLbMc95hApgdVU5RT+zrrp5Z3JqsqVCSkAvPtnNzRv5dbJL9Q vgpWN7qnG6DDdXDOB0/B++vezVMk9IbJqmbmIVID/Awmt+DftVgWLgQFL49BwhJN f6k6oTWLPVTm/bqzn/+1ZQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqtat9cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:51 +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 471FWhLM035584; Thu, 1 Aug 2024 16:31:50 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40nvp0es85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ct/QIVTdElfFs1Xnm7a5KBlz4atd/ixjh6kNChFaXjg/QOY7XUM681Fe5RDoUM7cI3h715BETivrGcsJGivqTTFVHCmAGeqfXjSAs57OA6spxL0CNwh7WiufY/pVnvamd7wB/8WI1c9Q6xItTNKd1fnlj7DdNj+6D6CuDdiF0JzpKld4z87ToWBaL+NRfVELeyVSqRD5N7HlgF95VB4rZ6WMz0lN0MPAH2cYuAdYNQML92uY4N894/DwUQ55ptiG0y0dZpkHVqyjM+1bynvC6umPb/NRorZLdW8PqN8HZRFxip8j3wpW/4ZWS9ca0cg6CawmvvY2xqkcmhn36oM+rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8d0E1NCt/EKYL3wXt0IKGbAO3KgnRxvtKCwZkQZIxFY=; b=Tae5Ekdu5+zRMsucftaVWKvb9Cbk8sFMdq8bjJzYa33cpm5GGcmbOJnPRv/GVwVt5ZWGK26pERVKbR4BFkIGHREgFYYRvOaAnuQJWTrU2nB2W5GSLQ2AScRJ/jD/u7V1ziQajthxTp4vgs3YE393Hh+cI1A1A2dXcWi3+iPy8XmwfwytwV3NiT42tf+UWmLYQ+81n0CfECKf9wGBGxL5hXordYols6NgaICw7vBB4111mDGGKVKA+lZug1ntTTv0FNSaFOiZnKNcytFGZgkTjx+HY4hCcuu4DCXp3g+Ws7P3MKh3kpxOUMc8KLvDo6l4/n0rOCGlYKfWMQG5NvprkA== 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=8d0E1NCt/EKYL3wXt0IKGbAO3KgnRxvtKCwZkQZIxFY=; b=ZLkW838DWVlLw0/c8JWSQVjum4a/aJmJUxnwd4zBVABDQ9PeChECUFMOMpLylJo6jSfXGiaautqc7T6Wd0CZ4WpXK0XOT3pMDRsO/7y8LvrVIJNROH4AyGKhPd9iZGmh/wkD8fDsPM840gc75B2io7SeMWPKfBwxdHsJ6BfvsJU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:47 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:47 +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 v3 07/14] xfs: Introduce FORCEALIGN inode flag Date: Thu, 1 Aug 2024 16:30:50 +0000 Message-Id: <20240801163057.3981192-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR03CA0010.namprd03.prod.outlook.com (2603:10b6:208:2d::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: d47d9005-dd91-4354-c63e-08dcb2476fcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: MJDTkozl4WcmA8g9WjNEYz/HRszQLb1ZsHT/n4YSUdRyKcFqUcp7sLV7b1+rTxXL14Ke6PX+I+aY22gINC06VxSaFy83qvbrWfxUq26P3MnYhfAeNeOFC89WiAjOt4jus0nrKjoVLvmrp5A6F+hlacnFZEd17oR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ynauVeayquGM+c+jXSAqHACJxp0a99/JqkKrRnQJsGcdy260qKjf6j2ca4WGsdckWWIJRuE8ZzTawhnzkrJD2QB4V5XaIp+g9qo+39ttSHP6OVWys1vEfMMN+V0SwJZxisoBNdnA+qC/Mifzh/JAkw== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QQEvUzAHTM0HV3sMrhvI4Jh7hultqSL9OehAvDZS8OytiJfN8nDh+tExll/10YtEy62sk/AqMrlBJ1lhpJbj578pltb0E3J8ED/Vt+rJUunSXn8GpCP/oPk9mDgK1XQHAg7eTdSskoy1YzG3SX3Xxlgk4pnCWeYdhllQwvLZhGrrWd/2LWCrzOHj6rxkrahSlazOA65C4odRQiOx6B3ApcGy6JPyeG7S8cYGsKyEXuGY5t8e/TUSZCW1n7Cj6jHhhLwCmIVsmjRzPosE9gW6Q3dBFru95FJ7ivOaDq0NPBcCraJUQ+6rqpIg6uJ5wtTVKtCM1sIY0Cr2KNBFinLkC3C2fil2oTM9M2ng0R5Z7ScQ8LDsEUyUJc1gx3axuK0L+/FbyKTpaO6VbEU6p1aCHz4P+pNGI7qGYVBvo/bO1fvNIf9DPkw4XaP3TKFJ1Vs4PamV+Ur+aw7ohIftYlavtOwopY/jyhA3ISmNEGUMejnU1nG0j+pXPAO6k9P83qsBucmZIti2yiQ15rXQUoxivVlaiZB9BARem4XRGIu2Lzi3h97AP9ejiviM9zA6csG5DweWYpIW5YgPbJjdbURrE9hNRXcM3paN5KBz8xgo92+tf6zHH1WjWGOl/qizjaygLUEmWPtzePw2ftHGAG14OtwDtVginNtavpOwPHsuo9qbsj5lNjt1SPY+u9w6T1T66KJwtmh4IBZphpPc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aP8YN1olQfwLjB7vOCjI2ZuabOIrXWqastPYqbj60ETLR5ac3vn7y+LR8zL00ea4dt6ZUPZzOXdpR463ZEDydxsUDxIXnRKDX1SDkX0ALZID3FbdiX7Tq8LQ3iWxQwpZuEbm8VjAmi/R1hLL6Hx3t+12nWoAGqNeSe8zsKH2R+GNdWuu2b8lebFDxUdvwQdZwpASXoA91SzbgSebFqYJl3XHtcEtM3oVWan+td7fLtT0QnmgptQBJoSiPS86aQPiZL7mb+MPk+49dhpEwBfCs9CepF8eYi74EkPOh5wDHP1X2+rZQvc6t3XED5pn4d/GRPOplPsSr1j9XmY6vNgVMDG+ChKKIEhxpEdSC2IxpQddhWQcEEqkPyivnJ8o+HtOMyRbmRVl6glbp5kJ4r3VqWIIaWoxUaj5IiZHFszs9hLoJ1At3pIYbRIlHxgz0/FODS9gQl3yn6i+OOyS4xVsFCyAgRbhxYDKikOHErbKcvkXGIxDpQaQqr0kWrm1yaOKP3zW+peujLHM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d47d9005-dd91-4354-c63e-08dcb2476fcf X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:46.9239 (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: lFR5C6MKsM5Wqe4uHwlc25DpVzabYQ7Cgw55pyT01EJedpcAMnvtXZ6aVjI9dxpN7asLee60QtGski7Iho2jpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: X1U9ClZb32VE4DpftoKkLxUYFVU5tm8u X-Proofpoint-ORIG-GUID: X1U9ClZb32VE4DpftoKkLxUYFVU5tm8u 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. reflink will not be supported for forcealign yet, so disallow a mount under this condition. 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. RT vol will not be supported for forcealign yet, so disallow a mount under this condition. It will be possible to support RT vol and forcealign in future. For this, the inode extsize must be a multiple of rtextsize - this is enforced already in xfs_ioctl_setattr_check_extsize() and xfs_inode_validate_extsize(). Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry [jpg: many changes from orig, including forcealign inode verification rework, ioctl setattr rework disallow reflink a forcealign inode, disallow mount for forcealign + reflink or rt] Signed-off-by: John Garry Reviewed-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 6 ++++- fs/xfs/libxfs/xfs_inode_buf.c | 46 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 +++ fs/xfs/libxfs/xfs_inode_util.c | 14 +++++++++++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.h | 8 +++++- fs/xfs/xfs_ioctl.c | 46 ++++++++++++++++++++++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_reflink.c | 5 ++-- fs/xfs/xfs_super.c | 18 +++++++++++++ include/uapi/linux/fs.h | 2 ++ 11 files changed, 146 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index e1bfee0c3b1a..95f5259c4255 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -352,6 +352,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 | \ @@ -1093,16 +1094,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..1c59891fa9e2 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,40 @@ 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) +{ + /* 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; + + /* COW extsize disallowed */ + if (flags2 & XFS_DIFLAG2_COWEXTSIZE) + return __this_address; + + /* cowextsize must be zero */ + if (cowextsize) + 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_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 032333289113..b264939d8855 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -80,6 +80,8 @@ 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; } @@ -126,6 +128,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)) @@ -224,6 +228,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, @@ -232,6 +238,14 @@ 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/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.h b/fs/xfs/xfs_inode.h index bf0f4f8b9e64..3e7664ec4d6c 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -312,7 +312,13 @@ 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; + return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 4e933db75b12..7a6757a4d2bd 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -469,6 +469,39 @@ xfs_fileattr_get( return 0; } +/* + * Forcealign requires a non-zero extent size hint and a zero cow + * extent size hint. + */ +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; + + return 0; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -477,10 +510,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; } @@ -501,6 +537,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 6fde6ec8092f..a836bfec7878 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_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7..b52a01b50387 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1729,12 +1729,30 @@ xfs_fs_fill_super( goto out_filestream_unmount; } + if (xfs_has_forcealign(mp)) { + xfs_alert(mp, + "reflink not compatible with forcealign!"); + error = -EINVAL; + goto out_filestream_unmount; + } + if (xfs_globals.always_cow) { xfs_info(mp, "using DEBUG-only always_cow mode."); mp->m_always_cow = true; } } + if (xfs_has_forcealign(mp)) { + if (xfs_has_realtime(mp)) { + xfs_alert(mp, + "forcealign not supported for 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_rmapbt(mp) && mp->m_sb.sb_rblocks) { xfs_alert(mp, "reverse mapping btree not compatible with realtime device!"); diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..f55d650f904a 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 Thu Aug 1 16:30:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750731 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 5E70D1B4C4D; Thu, 1 Aug 2024 16:32:07 +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=1722529929; cv=fail; b=NPLJ5M7u2BwtVxmKiLWOhNVrq6FDk59MQAQjUx47BCtHnHpmntEK4fxVZW2CvZnMDpX7sDhkdQJ9Ex7cEPZTfDxFRM9b0P1bfplR+zJHPq2TKkR/LAqadegZOhKfxFTiLLZdwqGsbuL+8L/4+S2MS5B4mwNcju9aBPgs0Uk6vNw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529929; c=relaxed/simple; bh=F1lBOLtMgtfS00hl6XbX6lr3fK1+2gcVWOelAxGiE1k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lZ4l1KFUzXmbOy8f21ZZ18+rcq09nmz380a6cBbYd7OMQV5fl6spIsFAq3L5vtthd0+TSV5qcJurkju9NmBEUD691NJ7tZRo9cTl5s43QFAPkmYe+uIFeqTxb6mDFwIk+JNfyzGyBFWp2w4S/vMKk3ugMerIzWrC3yHwyVn0L1w= 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=FOEpW7L+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=y/bVGEDT; 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="FOEpW7L+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="y/bVGEDT" 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 471FtX23023392; Thu, 1 Aug 2024 16:31:52 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=UPNtKdqO6E7kq+F8wAx7MU/BC64nkfahgWoyy/EgeWc=; b= FOEpW7L+78jtlqLfIDbp5dETYn1Ccj5G+y7+NXam/fzyetBfvnOUod9OOyNFFG4p ap6ssuQwoUo1pOY6su5NSxk2QWpXbKobFW9puS96wzpo/kRAOym6eZzZeTa1UReq aYAQk3MmNsxfrA+iHMVw2TtIEq8vWOGEvdgt9GA47zR1cYjt5Gb+sX8spmwh/wJe knSYGzJjQ+g8qQhFehs78NPKcCZS94iN++2D2vcGNYhMTONvz4BR6mSo+scLR+j9 XjxMl8CCS4q56l+55tdZLrg8PoAb4cBgaVjuFp39k1CmUsyc/Ku8PzBgi/NYQWee mh+fYTigcVgHmdrpEhF97w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mrs8t4c5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:52 +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 471FWhLN035584; Thu, 1 Aug 2024 16:31:51 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40nvp0es85-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lMLhlYuBEOLXcezroTzgJ/ybSp0ultKbhrkCK4E+TDmoz7giH06s6DGO/Zd5SS5WK7Dbib+rxNJL36uaxyQpbEN4+5iyQ9769AXSbDfi2/jI7nLicV8MeJgFcydK5yLbrvywtBhpu1wOFLxDSa3TsTYyoq702qyKo95PeAWt42Mf94HkB9C1YKvyby/Z3ytBqQ3r1Btydk3gshQg7+kgsZ/gQq82Suc/5VtTH75kA+o2a5KUM5/gxFJuvoegfJxw5Ig9xw2zlarzv2jgGcqtmOXTgLeoq0JKbg95szULltMj2AP3+t+cNNYbEp6BDKr4UyFmWV0886OU/SOBGrTuvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UPNtKdqO6E7kq+F8wAx7MU/BC64nkfahgWoyy/EgeWc=; b=Qi/PkuneVi18qAiP29A9GSMMnaHwurGykg8f7UCYZ8UNDtVJM+xksjhXDR5eD1enidDX7nAsgS6ICO5sASj0xICcwxbgHVepbg3kFaqaiWXAbqv9JsI2E/Bhk/3+5QhzEOk+GrAXVyKRnkBjpBHQuXeNgQto2kd+fcjRvW72kg7xr0tz1M/gk2BSo60oYbMeyhAXBKIZc/oqjRaiF3N6F1MSr3QWgPT94AhKnfSUiFr1N6X7nSkghaUpt0oNbfevsxWo4aeWDFaoa6jEjwaSANQz8fH8kjFgTdkmm2Dzz2xeXUvabfprLsB5gtToqFtHcg5cO9GDN0W1cZR6ie2PPQ== 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=UPNtKdqO6E7kq+F8wAx7MU/BC64nkfahgWoyy/EgeWc=; b=y/bVGEDTstZxS97pxEaLOzeM+zPnK/BFQM2q9Lk9oLa1HCOfD23CnVRudhJvzmRP1e/MjVkBwDEBMabEKxuYizPUksPAdgPfkYm76zotTBdiZHaAnZjQ1sv9rS+pw3Gcdc5b2f7TPkkme53O5fawDFBLMkbd1OICxttmdx7HW1Y= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:48 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:48 +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 v3 08/14] xfs: Update xfs_inode_alloc_unitsize() for forcealign Date: Thu, 1 Aug 2024 16:30:51 +0000 Message-Id: <20240801163057.3981192-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0046.namprd16.prod.outlook.com (2603:10b6:208:234::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 06b95ba4-0cc6-4f00-bdb4-08dcb247708a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: Lo2RX2RTidwL+9XlFL3H28TAQzeePAUWejoByFqAtRu2qG/yjWIvZlXnBGvqgNvPcPx72wU2682Y/t6tNExzi4RTTOene5jIBEEohWWVGId2GD3h333lJB3q0hqUdp1mMyjltIsc2qxLUY0/GKwU+YtZFe6l2kb/xFs9WB0Li586B7Q+oZBEbefj+RauJ+Jm2MwO7VXvQzzzBn8EWaIXHsLiHcMIQD3p0HCAXGafds3sGBxURPYNXSjezNRYKGUV0UOTbc0jeRkiutKu2swmJ+bKvH3gBhsN/SKgODYN6J0VitBHjxsQMppi0m83ITxS5s85V4OR5fUfsiH9UnH+quh3jeD1fGvYgYY0g3MwcqDAcm2UtSyeAxsWAnP/ZoHspA3120XkFBkgUOJ8Fyb9icbA6t6X+U7uTicLOfQRGjLvtorSHM7RUZrmhaSEvYRap3eJ6NpS+I22xjZPVME76HU+MyHOolQ0DEGnsqd2uge4h1dK+9hYn0dBwmR/X+XKORk9Hx7OFr7y1ttJsbk7V9mDyLt+cJiCeOUX/3uTl59WSHOCouLlK++v04cu5gJjKbo3F7k1yMwHTJbK0ZjH/bXv0Gl12+UMvtMa5/o95gkGEoX1B418gie1PU1E5p+1cNEnqgAcw0EOmnzNeEnHd6lcg0I6oZUIIGMUzIc6EbFtnIRKNd5aaFnvWdXwFiGKksITLHr19lIFNK8ipC4SB4H32+psjvKc31z0dQeGF3uRySjPybMqS+3oXdO3kKkEQ7+CFOdaROMK5uQXwiBi8uvSS9PN+Vb/DTT0tqy9hz9023ivrpasQZJ3M5QBpwnfJV5CbG08McYxWGvHiXp/5qKt0ufz66UzmpfY70hth/n7Kkoa9cKvWuNRkNM6uKAwfoEi4Y4g58+svzUUKPBH10O3TYm3l8i0V+jqLCNQR2kr5i6Fl0+4hPQH9/nzOlNXQw1IMxoJyz/SbfsDw3udHO02ghH38pxuJCIyHQnKMTz5qkuG4cJToloepIMw5XB8+H1Jm9xNxvuNQzq+3xmq9iilWkDQcmHMLca7Z3lvveCBdSS35MjMGlTFjheGC65mL59BvyvcAr/PLhfaG7a47KVEEXOQnI3n47gACkJL+rnvGXI/IspGjkDFWAy4nRqt0WdrY875jG43P7UoSGv9FMm3AOQwhtyaCGtTYVqnPQ/aqRDAn/VXUwhK53uc03Vx7Cl8w2Uv+6nU4HetLt4qXQ6STNVsOc+JGwKw6n4gxxFv+fo+F6FV0PjILwa1SIKhpD0dSt0DztDR1D/QbgQdHbI79Q4RyLQxGrcIW1Nre8KEFWPtAB+OmFA+2AZ2P5AthC5SRRxuM5C+xKLuwr2hLw== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vMeHlzzVEaMmV9iQ4IEOf6Nj1zN/Fgh90BHlLNsRvaA40E2U7dbF2m4aEybGRvxLe7dPDBXfD/tOE4haZZNx4zoIu9xRuOlo5rwqtt1EXphZ/FJb2irQQ8X6Uip40Fyp7OkrSeKPUBgR8gLj8tw9YxO5+adO053pjLXg+a+dGJSPzcZW5bl1u7e6oNTO/nQGPscR9LrBvHhc0/QtBqNcSvHIkGGJkAo2TNs2E3giNEvAHzpNuUgvtNi5yQKE9i0ez93WZA20q4AzG4RHVlLxvc4GVATr/yWpwcpo0fh48jfPTSZBvC/Nn3slISBzyP0JGxNV05EKEPz8FbTn/Rjc5w7rMWl7krEjea57Q6n6NaLntFfLZcS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LRb9JYqUy156zfUr+bmtnWtgk90fnaU9iZKpUk5K0IJ2EwhumwtzBceKPrQhd1ewMzhr+wpTpDbgWUNLhQ9Slndprw9528Qjk1UKZK45JNFIhEIcQWQt8mNQsM7CujQ51DIrhF5FWKdXCG1tmA05mSvVeqJmK94WIO2XNQ4vQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: UrXj5ehz6n9EoiqMKrwiId+D1Kpbl+L8xHfMuruQR1uEtyh9itDnjgywmJtnoqH+yD4+QBeSyZhlJKddoC+mup8FjsxtzilwBv8afJogOVbrAtGM9bh03ZrifhJi7gEDR2JRP00HTHvinEkP6yMf+coIEmIrv+ONAM7fCm3BbuPVgkvuUWfbkQQ35xQf6sb2S60cZCODCYGiXzR09Az8CIQ4Vh/cF5PVkc7gT3l6j765vA/ml1UiPS1F0SjaN6yzve57Hej0thw/qb5CCk1+7vuUn4m2ezfZDcBkjz8RB2XMRUqCppSA0zBzyUiFTPyv4zL4c9HJ6+1L33/6T3JgmAV2y5LdjU+quvLLc98VsN71DodGFZ8MFjl/Z+f8OQ7g84iKj5lVQ93HaxmnAHUVkjwduJxXrLp0LvmdyxMFayNrTR+XbwdwkliMJKvobCMfWNK3bj7MHXquj3Mqy4oDJVhuUbfBncyxWsqSWXwR3np8T9kiQg/djCu3gCPGrEah+f5B83JQ8wiIkWahnt6mqtRZiB3y+QouBN6ay5tIDeYsGIg6ir3uV0dUQ9ROCGT/v1kVnoH3lY0I65Hkv6Lo57Vd+BSsHjtwCjc7CFTlZmw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06b95ba4-0cc6-4f00-bdb4-08dcb247708a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:48.1513 (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: w3fJLURSqSx6Vo6sgkhL7IJs0Knr/6sVUY2aqGPsaqerBc7K1QgG5yZptzrTSrxXyFWKpi13V6m/FGWwzxCyPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: l9RbobgXnC1Yjq4b195jowR6EP8wqxgy X-Proofpoint-ORIG-GUID: l9RbobgXnC1Yjq4b195jowR6EP8wqxgy For forcealign enabled, the allocation unit size is in ip->i_extsize, and this must never be zero. Add helper xfs_inode_alloc_fsbsize() to return alloc unit in FSBs, and use it in xfs_inode_alloc_unitsize(). Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 17 +++++++++++++---- fs/xfs/xfs_inode.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7dc6f326936c..5af12f35062d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3107,17 +3107,26 @@ xfs_break_layouts( return error; } -/* Returns the size of fundamental allocation unit for a file, in bytes. */ unsigned int -xfs_inode_alloc_unitsize( +xfs_inode_alloc_fsbsize( struct xfs_inode *ip) { 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); + return blocks; +} + +/* Returns the size of fundamental allocation unit for a file, in bytes. */ +unsigned int +xfs_inode_alloc_unitsize( + struct xfs_inode *ip) +{ + return XFS_FSB_TO_B(ip->i_mount, xfs_inode_alloc_fsbsize(ip)); } /* Should we always be using copy on write for file writes? */ diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 3e7664ec4d6c..158afad8c7a4 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -641,6 +641,7 @@ int xfs_inode_reload_unlinked(struct xfs_inode *ip); bool xfs_ifork_zapped(const struct xfs_inode *ip, int whichfork); void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, xfs_filblks_t *dblocks, xfs_filblks_t *rblocks); +unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, From patchwork Thu Aug 1 16:30:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750725 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 062AB1BB685; Thu, 1 Aug 2024 16:32:03 +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=1722529925; cv=fail; b=FwF3BG3s4tgsx5XmikIzXjNefOdTnZkc//r3xiQoomt6P4vLRk8W6adutOxjWA1is+2LoXE//r/DxEEKu5zQ/N8YD+mMhbsTQT7Tno7WN23aOB3TD9k4uZZgfrAXpzdDnF/LIgiHUCsm7PkJL1xIcLQgQF90RVigUg1RhH8sO30= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529925; c=relaxed/simple; bh=hsE5Cd/KIR7uZAjw48M8B1/Vb2rYE3lT8W+MoOPY3SQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cbbqPBkQ+72eiSimpOpaZM/tYb0XWHJ8cjVYSMXbLaO7chel4sYdaFtc76O49fOSG+iQzLudLZMLAifYc6PRw3lVQVvH0WNxt426g32R3APtMkwkqU2/C2BmCP6b2h9QJVnEA5XGdRYdNgZE7QdwqRmILTyNXFD5MW3hjqYmvEo= 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=n1KXPles; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=mJrKFhAZ; 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="n1KXPles"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="mJrKFhAZ" 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 471FtXtx023400; Thu, 1 Aug 2024 16:31:54 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=/mokp+9iiGpAswmtDttU9r8YTdVzCW4mBm26v+Hil1o=; b= n1KXPlesBp5lwN4wy0tjnwjfXKuJDtAnudlrI4nuxxE4JB1GP9hh6jayad2o8kwm LpGOIInsb6SUjo2d77Gkk8JNJj5+u4y5Lo7Ue69RNw6seTW3eetvNEwz0rZfa9OE SDaZXRmcQen0UL2kwb1aPDlI2f++QIEYssUtsmK6Yd2mYpSp3umXlkBMKTM6HOud HT2EGfbdG//INq4IroTYmwq+MwVVWo86rYhTcZyQhZAmH9pZiPp0iRzQv/2oIB1K htYm7aPNf8zr11PD8vtpp414oyDG4YkYD0sNJpoKY9DPJrRpDk9/Hw1yFqTEpeeT I24dmHQ9q/w0Tf5gw+xfTw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mrs8t4cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:54 +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 471GKsKa019040; Thu, 1 Aug 2024 16:31:52 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40qjmtvqgk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qSvwczpDsNBWeCeg7OnMBfsuisERJ2ZxcvTAfDfXy4/W99zuQFqLumpoObz9dpIqUDZeqWcqwkUHP6Cq2xXtWaKxLduGM1CJhFt3dK3vOne3Tad6TZ7DLE84fr2KZMFx512WXrlK9/asq8YIxTMrMRPW8QUswbV6qEKdi4J1QoeYwvoOM1Ma1+JazMC2WlDRX0GN/i467q9uLl5/S/CyGXmOdrlaDz3MpAxQrnTDc4bPKk64Hc0WliEoXZo8k8GCZiRML6ZvVDu0Sl/G1/R1BPqyGrevTysxhKIP7m6DRbNnEkcoTfzxalIYqclMMym7wG2g9T5S17UdPOpy8dQ3Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=/mokp+9iiGpAswmtDttU9r8YTdVzCW4mBm26v+Hil1o=; b=iRxEtxunKhYyO57+ShAtQvdm2vc6zu1JZoExAZDHBXxuhS/Wx6EPYzCzVpSIDIXGZ+26J2fAeXewr28g7TvYRt9jkPmM4pJE67w8mmE/Pcx+S7m9BmVy6h67fkfZs5LWuVfbfNkJ/SDMwt1uRNbWWFgsccroTPJzTnwP/EU4JosjWTvNO30hz7ZMzds193PH9Y2qkgiA05Nck1cx4P9h/cAGwJcUlHcvJ27A+3gHsd4XcKOX1ozXMBXLDBzs+fUHk8s5AqfWAUEHZ7cTQp36oIg6jxBPi/zltE4Jwh7deyrHhXI7UfjnXcq1xqMfNz2r/05KyqHK0ce+c9Kj1CI0sQ== 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=/mokp+9iiGpAswmtDttU9r8YTdVzCW4mBm26v+Hil1o=; b=mJrKFhAZf5eiVFed2fFnlEXW2ncmgiPLkc6eAq14MD1FHwXJnGl4BP17bUhfpHUnJU0rgaGSrWJDq2FQztKoVC8Oh81WRJqJUvFQz6Hq5tsYUO3WSGe7iY10IaCoXX4vl9SwnuAZJautvWbhnuFEKQA050ngEBJhwAeBvW2CHWY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:49 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:49 +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 v3 09/14] xfs: Update xfs_setattr_size() for forcealign Date: Thu, 1 Aug 2024 16:30:52 +0000 Message-Id: <20240801163057.3981192-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0052.namprd16.prod.outlook.com (2603:10b6:208:234::21) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 4723f29f-6d09-4e5a-4e04-08dcb247715b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: fBegi4Q3Zo5ac0pI9hRIi2BHVBT0e6AEhs3Q7sJFwGqKaE33o3zHSFJSjgF4ZdeFE/7qHtYpS1GBAgXzQMtRvAVAd3N3aWYe66DnwbQOaxIqwRths9Xh4CGjV7zDtAc2dfd4dB0IqY9TMi3FBS6qbo/5NFGeLUresYbW+nLerTVPvDP00UiwaAHe9MZpFRYEeh7hibAzM3r+ro1wVzlrFTVlvjoW+F3fM1R0RbGCEPReiLrqJvyMMq6kvr8TUwqnnO2TdplMB2V7nAwRb5+Xzo1k58EgdqLjIMeWjd5QZu4FytOlRPeiVbz9dwqvs0/x0U6jjKXgZHDdrCcTAMHsEhl8yudKxustMvTAPVf7LmPwKUjOhnhGlBMmxxHS70DzyFhwJu8CcjNOUXP1obIiaXOJFDPZqxR01plHIHF5RdfULiiPaNJB+wMEBdJFB27DTCi8/6w5LswNgGlT0RYLsNRpxzgXpUMlB+C+WJnMYDhUyuivRdS3N7Xhl1Tw9vMGyZ7AkT/sKnG16BtkUNFhN8wsghLwRvP7HfszlUc3bO33UoTsmDi+YWAuvo3NfRnVDtPEKHLL2poj8D4bQMYeAX96fBm+Ud26l1NXA+s3qKIAlCPKnUeTpUtf3lR6W8hKbYg1U/6josZcqxv33v6bXiFqegkaoObXrJ7LhGQHNaiY97JxitK8w2EKtuF6xGdi5bcgu8/qKhLiAWIf1gPUacOUJAfZt7dZ2GCqmW6sF4Sr2JBeMGZPlqa/cDjTX8k96xcS1DdZkIL82gmpBXwZLU4OVlUwHDYsWYdohLaxfxpycN1Va0dim9HcyaleRWBxzWTNhv/Ol7GtJzdfhufR5AbOQD7HLq28YmmUoocench3PqoklbmWlUMu48xCP+xhmZROT1ZISZrc3L5635xn4Skpmgd4X63tfOqQ3HkjEB9El3RBrqYOf/KwghIlkyZsb6snSifcIh0jTjBJtdB2wrFAeODh/kbn8a6hPK48sNtiHCeG+AAjJIKRnB6Ju5T6drVgO7KrLZcsdohil3aKKGEbIBRCNa+PfY0mpHvvIl8z+w5HoIVM5SJkeTcXDB3mSkqeokXrnRUruEb0ANk1neGg8DCoPo2E3cqV8MfxbSZMOE78Jzpw99Gjs4wkDS72nx8+66qZ6mvHs9D3Pa9CRJqh5F9rs4lkNY1M8BtBcPSmgqkrmRvA2Csrmqjx1wU6aifbXJH0c1mVt9G15jlu3DFJRBOvdY9ht+UnePGTSE3Z96TRFiV9oNslJEuOZL1juMTw6ey84/9i18cJvVDRQDcQ80tngWSkQfpWk0toMX56f6QtWudFgGA8ekuBgFxQUaDpO3aZfnDIKCQrmBUi+g== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ER2iG8z5Ny0PPfZc8kA81J68pNGLWTg+tUZga/gZq/iFhYHJmuJJmeh1lmZPjQ7ewXhqPmqfVrolRV5fjXsJgZpqNoEDLHYWjwkpkYq9EBRh5tmhkq09DxT9Qho3Nxy4W8bD9Ornj4XktP5FcAMhnH3RsNeJnenCm6ILKY0FrTPPSCJ0peKqUmPB8tGGHnEXGaPv2tFzRmPZ04etM/RwRkUwdsbhjNRq3PX5q6FH53lKf0mam6kdXH7VjWbfPOZtyoX/lq2bz8iN4toovBoZ2G9KS7shrvVziThbFj0+3z63b4BdU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uvWVuZsQ5UeZQij0jjD9cGNZIs/vLs5a01yMiM7UD311I13zn/RLRGb1b3Kp5/RjBhD+w3ttecxtIyrRxH2+Y/l6nAoomRc6qVb2lHuL0feplItz7YqDdsKHemCam76Bs7GNF0TWCB1+nSHJ4gjvLA8XPQuDazUnKo+3cXq8HVm0SldHXG13B4xJ8irwzL7CcPOxghtrniHvnu+pzuyvcGikfdQExRBDdmMJ41krwPag== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: m/ivzNPYA3EiiHUZ3oKZqYsKB8SPrcivzxT4TQL9+jDZytTM5SKYkv/KFUkVa52vUDaBR5YJXSTFNzp0JyfHTvanSEUn38Q9adBFEXwFsgwttE+JZp4A4IOAurONAcxU9icRsx+HFdzTBPSQggdlnRx15PVFJygePwGgSnvgL4gNI2JmGatWzZbov04LHUNFY6mL8DGooi3H82WOD+/66jq4gnjPvDvMT6eOcMKrBuyv7VAkafzN8V/p6M2EUI8LPXrnjdQfRZTsLJI/pxUvrL1A4KByG+Of6jed7wH44hkbEpdIRJG8by+rREaP7WZ3u4v6QH8KJwumVWHuJ8DQe1GtPeNe3C70q4i3gcZIIFTP9E8eH6GoEXIuhWpIXglgn4zi5gFmyuKebo2yCfKKT79gxf2yj7sQpNrWfC5s/b4ZAY8UoTkq+D8w4mR1VIF8dFFlsi15mFL7oQpTt41QQVRJvy5lmiBJb3bmNWDzC5zjXDLQxK2i+bZHv8pH3TtwQ3biehnyxpKdfSvmx3mvG2ajkCsQhrarg8HSZUS6eb3uHk0ebjUZz1X6wqJ80GDZ/b/Hxt7pIOcYb+hUDWnE7xcogqgOAwTr52TSGHchM4E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4723f29f-6d09-4e5a-4e04-08dcb247715b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:49.5438 (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: qISEzY2KRolmKZKhRpUdrPGkx/fUmqXQpvGRzGFoa2Ayct3/rIF5Q4+6y0BcT21fhiDXGh7B66kWdJrho01uNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: GCbFvC60IvfQNxoFA7obwlBlE8XmgnHb X-Proofpoint-ORIG-GUID: GCbFvC60IvfQNxoFA7obwlBlE8XmgnHb For when an inode has forcealign, reserve blocks for same reason which we were doing for big RT alloc. Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_iops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 1cdc8034f54d..6e017aa6f61d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -926,12 +926,12 @@ xfs_setattr_size( } /* - * For realtime inode with more than one block rtextsize, we need the + * For inodes with more than one block alloc unitsize, we need the * block reservation for bmap btree block allocations/splits that can * happen since it could split the tail written extent and convert the * right beyond EOF one to unwritten. */ - if (xfs_inode_has_bigrtalloc(ip)) + if (xfs_inode_alloc_fsbsize(ip) > 1) resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, From patchwork Thu Aug 1 16:30:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750726 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 2F8AD1BB68A; Thu, 1 Aug 2024 16:32:04 +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=1722529925; cv=fail; b=KwG0D6y/RsxT/1rPUq/wMRGv316hZZR/d7QcmhePgY8OI9L8jyjRgf1H1GlQi+OEzpEs3dslorqn+ZQt69HIoYjPcTe95P3ChBGq4SmXFzqE+bUu8zOFhirfyfWx7GKOLy7vd55qt45IBKmYSBiHkNwun7+dD0MILSq7Mpr4Hok= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529925; c=relaxed/simple; bh=ALPxfIOW5h5ScSGEkqs19C6Fme34Aq3Q0vQRV90Oh9E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fOtnT5iaj+FUSz4EScTsqw9aMltdaKDtDGEsNm/fc9TDVSpKXNE7xOSLAlpAvvIUlaiolt7CjuvAhNL6nEiUiZ4URMyizsoRLQpULI3iwmeU+N8PL96wvRCpKYbKm9/CngxHHdTT2FJFbCm5P9RvIVsiDlVSGl6HePmcpeJgggY= 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=oOfDJpK+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Gnk0Ha6p; 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="oOfDJpK+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Gnk0Ha6p" 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 471FtXu0023400; Thu, 1 Aug 2024 16:31:55 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=IryypLhLwt2cksvS7FNZrwLvr17cR1QbQlsUhwsl8GU=; b= oOfDJpK+w79T33ZkuRuuyGYy3srlF9rfGivWdEheRweXn+g3sPoQPxaW80Sv9CAW bd50vsAT0PtcyAreIX6XIpGgNJggyfX+xTXsFXkWO46a3R3QSzUtsL3EaxC/cYpC 6BUAbKr78lNMHR1OnFVlWthtJCDpBgOcb5HUOSDP3LM6PTZliKo5wvFswjSbnAk/ Y2MXWGswWoaT/ILxF+Tnk8GChhSr2eZ7Th6ASNfZD+G+2oIVSIeTKkuthX+gJVt0 FfAYGte79UoaXwa9hZg+nct0zdpmtFh+Z3LRieXZEQD8wtjtregO+7hL3MWi/KFw ymPlpuV4pXiKP8zofqqXkQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mrs8t4cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:54 +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 471GKsKc019040; Thu, 1 Aug 2024 16:31:53 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40qjmtvqgk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aKN5M26kY32Ed2v0e2ZbiVMSTmGyvBTxVfsqq6bW+ifX8JBwjTlJ+qYNu3m8VZUj6CpF+7HTPGwT7WuwNQytL3BGDqTPc1ZMo6psjae2GSDJoRLoJW4VXqeD+aA/Q7l3OyN2i5m5q7W0yhCvFaaJjclk7q5zVmBrG+am5AfcadgTq77n7V0laV5rach/Sx11ZU0OieT4o/HC3UFOX3RBAwHjghDf3ZWV2wiiFDjZTV0Ft194Hz+5cMPib0Wwt4CbMBmkFBZcnVfm6i3i7JOL+nta/PHXdpMlotXG67AFQnEGcpkjgSzG+Wi3YxxwZd+MdIjNlFmaJCQlt/x7Aa6Ybg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=IryypLhLwt2cksvS7FNZrwLvr17cR1QbQlsUhwsl8GU=; b=M2UbD+ztVJ1gw0kmZCbkLDoLebiyVI+cYkIDVZnseJrk/b3F+DI237ewJfNN1ZrlPuocA7svaqFGg1waXud8Jse0FROGGTYku+Na0r3YqpI1cEVD3sea0h5bLH9f0bRvKkgZixawhxIpSFcToD4rPi9hOiY5N2u3al/m0k6yglguGc5DE3Pme8d7lg3F9IaGN2DO4kwvmLqDY4xbCTIiYDMTPvkCOiBWyErTkwuHjjAP/uDcRq4ozB0OhOxFZU2rTWQ9T2nZCztuM1SShDRDt0ZqAP2aPWOK1GoVhjdw6DFI4fl47pyGLH2l5UMtSKXbmR5R7FGGIZO3i8RoRE2hNA== 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=IryypLhLwt2cksvS7FNZrwLvr17cR1QbQlsUhwsl8GU=; b=Gnk0Ha6pbFDR5JoB9uBtU8yCSmfh+2HG8NAdSHIFIvpKhOLOGY9CmI7dBNgCdcNmptfiZ5vABtkGnI8qJK48FU+wSXPOX0wf5/uBnGs0Nf2f7VFsdI6w17zaglxPWkpgeib/9zuF4U2QPOfig9kqQxD4b3VRF+5yNM1QfzTr3h0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:51 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:51 +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 v3 10/14] xfs: Do not free EOF blocks for forcealign Date: Thu, 1 Aug 2024 16:30:53 +0000 Message-Id: <20240801163057.3981192-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR05CA0047.namprd05.prod.outlook.com (2603:10b6:208:236::16) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 64578665-7898-4e6f-b632-08dcb2477244 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 6kvxrAqyoEqaL+3XhpIVKDhbRRtFit0EfGpyixfzJbB3nu/97FGJ4aZvQHDZlhlle37nOhqAJd/u61FH+rjk+jP56ozQuD4IPtOE7D9eYGyTGlxyAmZAZU6Y06TXhT4UVfdskrgg2zCOODJgEzR3A6Pyk28KzQQmfqnSdY/umyim4evuMFJL202GZobHRCHfv0r19lsNAEyws0yvhxPF6SGRb92A3MYS2orjpgkuciMYa7iQ8Qjg82cHBKk+i+N+qqu4AVYeu5fj0MBWNMsqSA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odvysQ== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ghzZ5MyMUb0hGOgpFsq0wxi6OgmKY68ExnERrvgpH4DHUSGcs85/+7Et4VWRGyrrXYv2lDIVz6Lyb5LLXaUDUiB+74K67w1YHQKRNj7pYiTyfwiPvEphtxX/bPWVn3l8dCNsX8XiVAGeXL9H9KgXz+qcaTt2N6nzTzoCBK9UjLxPA6cpRHnipL9uxotwsH0maE2ov7v56PnryTghyNOkHEqwQmHrovh+HE4C4oj3ijm3zICd/hDZ9IaN8KepvmiM/VH1Z5BWhdEmi79Qt97uly0QZByJpFH20zt042uHx95O1Prlb/4U7izN5IVGScSbCkwNGhDMfLPyHtRfFExm71YuRS64bZ291Jqeb9JDSIg+GSNNJG29ObSdxYiivAExMPRvfUsVPzwr+j2HpR3y064RzSjSlIQ1qwWoj6agVxGaKMB7Ao4abpSa71L6loyrKEi+CMBgDszAncKCEZdlWqSixrSxBsUEnh2y+M1G3iUgwjLmGMNgilIjdTxet0CF2vOS1VYRQiR5QyXtxJSmHbb8p53R4LphT1VyX98QKneVnEsmy26P9IlNc33p0yKyET6Hf0Rt0DUZoyy8t89eOzGDnj1EQ7/NCxIaoQbMz5M8g1ktVF7dZs7BfUYJ0RGKyX98GJU7zLYKqnSS+43nwRqpy7/125wO7p0HXm6LjNXD2FFtDBtl+iPS/PfrDcJ3Tkyoryr4fkv65Jr9caQPo/w5rCOR3Qm+1ICf1pxAt832oajG3HATLM/5/V4C0E2xj4EmrKiuuzKb00Y6oa4h4ty01Kp5bqFKdhwTEHLIGMFFospARcQfE21Wfg7847u1aKo+Ro5SUXoxQmRXNZQf4K0RXUEPlf5se/Gd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0abfa2ArWF2zGHEZJl08l2b2LAOh4ROuOuDW3BUQKdf0debs46ZPjMkg697Y2SCc6yAC2cEKXjZNQMyT46vIn2j2IMYGoA0+Gd8mCrOjNB9kljR8cPWP5XETvJFZx998cKrcaGsyDKq6IvWOvJ09q9NBzk13j0JA22V0Iy5NHSodQjLXiUbj8r27vBDtbR3pcoe0M6rEC4oH/FCqNAMjgMBOb+a0k613gjfegv+eAWnrIW0IVNUY3DwBY16Ws2+usgerecL6yE+PNe4f9Wc8qlAdDJA4Igyu92rLv6TWWuibkvreU7e0lUJ/2q3wY1keW7gsYNPBU592oM75TlxNG/gEvzcpxfGzgZjQnrh5VKRzdJqmuc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64578665-7898-4e6f-b632-08dcb2477244 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:51.0604 (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: sctp/MtCh/rgFhTIB8P0fzVLqnVZ0f7yd+LijaH0SJnMbk5y1noA+4VjXxHUMfczwodk6M7Lh5hzQw+OmuTREQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: s_8WxhqaUvHJKosUaJgp5Cv4XriYZDEo X-Proofpoint-ORIG-GUID: s_8WxhqaUvHJKosUaJgp5Cv4XriYZDEo 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" #earlier version Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 +++++-- fs/xfs/xfs_inode.c | 14 ++++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index fe2e2c930975..60389ac8bd45 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -496,6 +496,7 @@ xfs_can_free_eofblocks( struct xfs_mount *mp = ip->i_mount; xfs_fileoff_t end_fsb; xfs_fileoff_t last_fsb; + xfs_fileoff_t dummy_fsb; int nimaps = 1; int error; @@ -537,8 +538,10 @@ xfs_can_free_eofblocks( * forever. */ end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); - if (xfs_inode_has_bigrtalloc(ip)) - end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); + + /* Only try to free beyond the allocation unit that crosses EOF */ + xfs_roundout_to_alloc_fsbsize(ip, &dummy_fsb, &end_fsb); + last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5af12f35062d..d765dedebc15 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3129,6 +3129,20 @@ xfs_inode_alloc_unitsize( return XFS_FSB_TO_B(ip->i_mount, xfs_inode_alloc_fsbsize(ip)); } +void +xfs_roundout_to_alloc_fsbsize( + struct xfs_inode *ip, + xfs_fileoff_t *start, + xfs_fileoff_t *end) +{ + unsigned int blocks = xfs_inode_alloc_fsbsize(ip); + + if (blocks == 1) + return; + *start = rounddown_64(*start, blocks); + *end = roundup_64(*end, blocks); +} + /* Should we always be using copy on write for file writes? */ bool xfs_is_always_cow_inode( diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 158afad8c7a4..7f86c4781bd8 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -643,6 +643,8 @@ void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, xfs_filblks_t *dblocks, xfs_filblks_t *rblocks); unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); +void xfs_roundout_to_alloc_fsbsize(struct xfs_inode *ip, + xfs_fileoff_t *start, xfs_fileoff_t *end); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, From patchwork Thu Aug 1 16:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750734 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 807DD1B9B3E; Thu, 1 Aug 2024 16:33:04 +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=1722529986; cv=fail; b=poexzoXv7pgQELwVyEQD6Fow85Z5+Bxp/xM+CNjIZHpMyGbbEYmyFRUzUY6Q8zjZhoRANFJXT30EpZUdyBz4vL1UETANZG9ZH2aNn95UNvVf2Y3Lb7AUy+pCQJhjUbvrcR2oFulnr8vcw2Nr91K0nx6D+fvwy7Un5bs+rfn7A3E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529986; c=relaxed/simple; bh=xhsvC9cidv9VYbCIeNPD2NCLY42NJYVfpiENnXzylNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Qa4U+ZkvlGkM9B94NAgQM3P8JI+lqKXgJ6fxBWOX0tZQ/hN7IafZFbroBG6o70WhasDozQu4+w5YgEhNjVT9XWUEC4Ijp7kyM/axhjK7aTNH6tJcM8UhbktVFl9EEn9zs6TKi6NBogadCsaYpiAjzTk96QViwtz7vOjHYZKIktQ= 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=VlmoDC7h; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=JMS7toY5; 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="VlmoDC7h"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="JMS7toY5" 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 471FtV8m028570; Thu, 1 Aug 2024 16:31:56 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=kq5rdor8Yi9FDOU95CCsz7JWSI8FSkRGonKqONH+dS0=; b= VlmoDC7hcm/asKF5XG/0/g9HLEyC203EPcBf5twFTv14y1igd6ObU9nr84ULhIq9 dB658sa6b13bxTFuxOQn6UPRbzgYMif+HeIjO1VaIqND1fOuFPOF62rtob1pOoic dpdXvEL+8L4D5a4jEcapJci8gBjta2ivyErNzDrInDgV1mC3bnu4zRq7X7X+4TkF LZ8tQZ9OXiMEqD6+jphvfzO1gFRVFxOnT0ZYMAdCzhiQXO6q42le66wyuZgmcicm 3lAq30kEHQKGJQyyjslnI+sz0EVwAKzsmZz9umtGhjSRkq3N9T+vyqx0tAnsbRcj WCjyH5KOwNea5Sd+6tmDHQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqfyj77q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:56 +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 471G2Pf5005795; Thu, 1 Aug 2024 16:31:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40p4c3404v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Nlx9e4pgs3CiRg7o7WWYDolQAeb0R2GYRHAn5lGMRdVMJ/LUc7llRBTKb93rYSkb1p4JiBFLbXRwBgibovz37SQEGyv0RHs9LKZYSbmfsHlvBKgKEk9M6SsOjylBsHNLwzo3EPjEgg9ETLK++nrKoF8VAFsLyoA2muznzE3tLHP1uosd1o8QRrLC/afsJLp6qVyZ2a04ZzcfYi8UreSRv8Yk+lPeR/K8F9fDhsbbytm2ztq41FM3jauQWVadbMJaI1umxdvE1HR3C+RfYiY9zhM/YrNz/7vb1SD7bf3WD5+WQI0UHlni7B+iDX+dkpsQVFTZvLOL2J3BuX4+7u3okg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kq5rdor8Yi9FDOU95CCsz7JWSI8FSkRGonKqONH+dS0=; b=hJrHqzfEyV3iDsB5bmA27ARDiIhv2ubhXH1vJBpcRNl041UMKt6hOmi7JpotL/VxmCBKVUoWMqWy11CLCzeyZkn1x+8+VlddtkEexZAXn5quV81jjVirIwXMz8PU1JGVHnxaRh+68mUDFawgcTfIGXLP8zAliGMO9wgF0UBWLsNguOCPlgOcN5HTMo6UoH+QHYVVUR/mp04XBMX8JOpDaH1kmJZRFRGIvGsSVFSCMgolLcN4fs8zdF2nKueFZoesIWhgrUOwB+8vOEsf0losUbF03XpPsJ3xJwX3dyV+ETohJ770ToagfZBPWPeXAE11Mkltv2kOs9RmwfVZ9vKIzQ== 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=kq5rdor8Yi9FDOU95CCsz7JWSI8FSkRGonKqONH+dS0=; b=JMS7toY5dSZC5pzqvQzEMMwKoRWB1KaXhPbYCxfGHQsx6O82I/iEYBL6dJSL/mwO+HISzdiuc3lPRuxp+bZlSDtzoX14t2uQXgjLIki1dXs8T7NLq94NZTS28gBekj2Btq1zu+a9NtQ2f99aoYU+zlH+NKoc6HAWQYu72d/xKws= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:52 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:52 +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 v3 11/14] xfs: Only free full extents for forcealign Date: Thu, 1 Aug 2024 16:30:54 +0000 Message-Id: <20240801163057.3981192-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: BLAPR03CA0028.namprd03.prod.outlook.com (2603:10b6:208:32b::33) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: dd58defd-9cb3-47cf-e255-08dcb2477306 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: GnQ+9w0PSCNaksz2ZpKw5RZn3pqjQ54a4EdT8EgNtKIxOkoK+2q2lGVkcyJSqDdiHZWQKTPSy0laz5xHJaMTceci7ckaivA+OximRcxKEqEHxpH2MKDGYoHKyfCgcJmRFc3xbC2S0huPi4PsflSIN7sfitchJoZqvHbtrouZA3rAOwDuIfaOEh9BUYB0wnZeTSdNfUX/RCBSi/tzwaHM21cpHfdy2L+aR2zTtSVRirMU7PPTwF0RumkGw8n06OI/ZQOIP3zNYSwBUuVIg/fQdKtr3d7gUKEJvuLDcULKdIjEpsrMvE/iAhOP5J+gBo+W04LwY3n9omunK4qioebIIGImP8FehvSSSOzLEpjttRTURi0rWJtcP0AqZDkBPJRQ5rjK3gjApXttGbp9S+pIGvjKUqkIdXFF5y5wa5bLsMYWbk4cFcqnus2S/kcuGUro1erEFyPs0jACAuxfxUYzunHOPfjuDdYClbQd2A2Vuf8gpO/UGl3IC5W9CBgHboYWL5Zmhdpakn85JlU6fM1sp7efTSvR6vn2bHHj74Z3EmdE26MfcGIISsEkvbj8LB5ewme6PoYVckxGbUW+SXem2P/3VM+1pdUUnFKV4Mipqylmn0PGxGoFjfuvXP783WQ2roblMWSkpyzwgAZGpVevCpE/H0tnqT3VYTdNTdUa8o9wzLdKDSAkp+chRsvT09x6oBKt96ehnco9VQnLuhGXdzvu6NUKU+W8w8uOcXmUUn3c8idg5HxByL1T5PWjxIF0zsIQjpGxGX4i3ozc3YDhmEV0KuDj1V1KtducZJCOjsGnu1wB6mHeTPe8hBFrOcvp9rxF6Qxx+MnY05CQoU/6C6KGXpzpXeLj0bCmzXhJxtPh9RHDiSDncu6ODauACaQQqO+1oQvcP2I0yrzBpUB435EsuFi7ChyOh46K6UMgArf2rGufhME0f7r4+DoLJgB73Qhms0Ts37HT5FhykX9R/NQVqf8dghDmafhxmRL0VaDDgrGnVmgqwrSTCKUnWXPKvDyVou9DA9Bjly8VCFzzSSjHNDfvA5Wd1qQoFkuy7rh255/O4R0bwToHK25i1BmKrqu6olLCVFSzJquQZ8L4AhtRmVtMTU3kIUaS+09W0fCRzdrob+8VND9nWApU4RVvmqjrfzUDxJESDyQh7flc0bPfNkTclmlebnHlfKQphs1oj6Sn6O4QAfISHrVHF/yj3vbsnCJD/iOBkWGWoWI8w0R7CQU2AZ5vCEwLvwzov709Gty6lFdAifT4ubUEFc5ZbeCBLZkLo/cArgC0lhM6JEzLAL0SNV9Zxsi25GOptqNQPwfFcEBeb1ERVkw28Ie/E6RXfbr0ujbaLn/wIe51Tw== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: myS035wHTs+U6DidAthEtgd3xLl7J9Hed25OsLKqETndAioSH8kZMD6UVUoY0rmSxEJDgETXxKKxeq4nJCCcaRuPQbpxTQW1AToTmYXUyQL4te/XkRQfhyYLiqWeCvqpnG3epv59/K2MmvQXaPtZbxiALcF9md4QSxtwMnA3c6RS0tTBB5dmJj60bCuqY6qxUgGkzWzfBEqLG3viFTY1bdIdy2YXKyfDP99H+q/wMlKoXPTng/tzrFN4lSZ+V0u72HlSPyfZnzkvPIGKU7zbI7JouszWclBybj3N/0jSWjzcBdo3TDuZcZPYTiP+lM2dNj8c0ZqILe1D8u1jIso1otoiL5dGL+ZoogSGzKUzCOLjakOgp9JmM6jTNUhdyJxH1rLix3hO7YDFtqHMXXeXYCR2fwusQL6fu7RCIe326Czg8Z1C9bHtBp/xcwKnGwLvpagtDQWgZ0kAGHZOYlTQKFZzbr7ig60GK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kdhWBm2A1A3K0mpdX8kBsNi+L+tZyY6F3mgVTxJenTGUS7blUAcPe6t/OarATXqPW1g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: H395D56k/4ck6gzKx88Mp2sYs4B825OCyXpvROMSGM9c5cOd6fRG2yqiMOEmKBowgFia4qaso1OER1e+h2c4jWohraFbEvEPl88R82anBr3KRJSSaS/cj3LOLIiHU0K704q4Vt/SDQs1KcH+NAo5CD1Fdqp9zR3E1q9/1oPZNyzzHW3UbdutyRPfooheTcr4cDL0zdGU3Otn+lMXdYUOnTuBkggkR1LF6VsaPwy3aoEOb8Ox9BLmjZ9wzoFEzMxOE4oylZuLe5advo4X8mSUMrVX68xz7/x5K9QE/CQlNO9E+nMxCBWUj8OTV+RNe41JfGmafBCA+vV/TtzPc3R2z7K9ZgELRxdhCD6N+pIa0lJLJiFP0KWAyoDXxUwVel2w6Rhh+sc6kDhiTpuw1tjpUG7zBqBgB9iSrKfYq+gFbaNN+ZpHwmUvL8ZK5FB713pij+qLvuE842gK/PAcg746VkQhxVVkR+1aVYu/i4Njj/i4VRcjjkpLOXlcJLUJ4dFvGOu8Aqdiq+cEhgzz4opHyQF9qrVj0fuSB0u355Y93FCALLH+6pT0Yrg0voupS7Vs8et94pPojeKzRj0lw1Q6VutEepGsAb632GKtifG1GYI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd58defd-9cb3-47cf-e255-08dcb2477306 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:52.3610 (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: 03Xlq3jwc/72m7+/dlDGU7iMjuC5rW842t11Rc55tRywYkx99LmcIZxOSrVFnIm9N9jMNsAqo8T/5NDEyBtotQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: fnd7NPQpygYHB1Q4Xj812Zd7yJYO7zGc X-Proofpoint-ORIG-GUID: fnd7NPQpygYHB1Q4Xj812Zd7yJYO7zGc Like we already do for rtvol, only free full extents for forcealign in xfs_free_file_space(). Reviewed-by: "Darrick J. Wong" #earlier version Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 ++----- fs/xfs/xfs_inode.c | 14 ++++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 60389ac8bd45..46eebecd7bba 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -854,11 +854,8 @@ 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)) { - startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); - endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); - } + /* Free only complete extents. */ + xfs_roundin_to_alloc_fsbsize(ip, &startoffset_fsb, &endoffset_fsb); /* * Need to zero the stuff we're not freeing, on disk. diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index d765dedebc15..e7fa155fcbde 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3143,6 +3143,20 @@ xfs_roundout_to_alloc_fsbsize( *end = roundup_64(*end, blocks); } +void +xfs_roundin_to_alloc_fsbsize( + struct xfs_inode *ip, + xfs_fileoff_t *start, + xfs_fileoff_t *end) +{ + unsigned int blocks = xfs_inode_alloc_fsbsize(ip); + + if (blocks == 1) + return; + *start = roundup_64(*start, blocks); + *end = rounddown_64(*end, blocks); +} + /* Should we always be using copy on write for file writes? */ bool xfs_is_always_cow_inode( diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 7f86c4781bd8..6dd8055c98b3 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -645,6 +645,8 @@ unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); void xfs_roundout_to_alloc_fsbsize(struct xfs_inode *ip, xfs_fileoff_t *start, xfs_fileoff_t *end); +void xfs_roundin_to_alloc_fsbsize(struct xfs_inode *ip, + xfs_fileoff_t *start, xfs_fileoff_t *end); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, From patchwork Thu Aug 1 16:30:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750736 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 F0A431B9B5D; Thu, 1 Aug 2024 16:33:07 +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=1722529989; cv=fail; b=fY8dhh+pDo6l2bG3uIg99qBfolcVHKIaTsJ00CoflH3Qa0CCTUOJXharO3StDat8CPg3Gawb3ZI12x/CRB4dJrTBcAiY1M+30gqQf5aX2fPoPneOcmRcuTED/cHD2L+VTaYnrbiNeoItCdIw1sMPSeeZNFbjD+Ef7PkWX4biq/8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529989; c=relaxed/simple; bh=kKixtbCsgmYyWkkvplpexW1J1znwLLkmBFdC94PMiS8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=m/Lzzztku8Vghow6AtVveJF59YOA90ds6uNBeqGnXoHLrsC8y4V4E4S8NjJMR8cSBj7ce5xHX+hI/zatesczQPbWARsBQbejVlIZYE8A8wGObL4o494DaYnaZ3H2wHnA69H0RgL2Bwc2JY6UESVoCZ9LyeagPcAIOu3GU3sywGE= 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=eiZlTWRD; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=blpxOJrt; 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="eiZlTWRD"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="blpxOJrt" 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 471FtUOl002511; Thu, 1 Aug 2024 16:31:59 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=zGlHm0yX8TuYFKRUvbqZ8nfy0EEKrPkjhdyhgfCxWr0=; b= eiZlTWRDyIu7XUElQXctxV0iJP5o6b/TRAIkDt+47JGhtJ1Ueyo6LM36pGeorgbc Z5b78/FzECLdSD4Z+fJUA81L/8iwf1sjeoJPohZUGFlbxV2Ezdvn6s4iwp8xXrGn 21MqMh2EK78wq5dp7VHshXFCFW+KIC0MZ6xdAN/h8NeXvFNYJa6QV1ACDxceWdm7 8hooJNOFo/tnpTQuNbNTSpyNdVg9PCmx3x4YTqjeC15bt49QglFaLgRy5s340rcI X2N107yF2azELW/Tk5f34aq2JvVSTAeFnWSCHvW3Lvn3CO3Vs2Ol7XAxkAaYAsJy baQgcY2xswfUn3lCl3pthQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40msest6t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:59 +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 471FNu3A030932; Thu, 1 Aug 2024 16:31:58 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40nehw38jm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S6q8PteDra70te55zpYpAy2Z89otPSn4J1U2jqGC60v5MVID6hyXwjjVgSOUHy7YYPDGbTtkRvQ+y+JE6iCnqNSKx6//JBX/f1dTBpZbrGR3rEn23OlMAs6dKINVkPfpC5FfS8kLWjirRaEyta3gPyUtr+wdj5O8FEp+ukNzxqKAsXdNWRe9sI0cT3UMb1FF3VISFyCSSj95mCtDOGev9se+CmzJM9V9rcHV3+azdnMUWdHXxTOOn3ZZlybBrvW0FbQAak8jHQUEbtM5WE3A7ti7GXawP1M30kRjwI+Fe0G6IqB0F9xZmg+P6FQuu3Bc7CKfjqgLLk2LTLKBuBXmXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zGlHm0yX8TuYFKRUvbqZ8nfy0EEKrPkjhdyhgfCxWr0=; b=ZApu/Jhx0UlslmDLUvUP/qquKHq+ijTUiw2dazL4lfp6V3FkF4QFNcR8ZcxiFaYtZgSw0nXwHhtVBK5jUU4RYGg8EIHK6igOyBRzoQJDOBQj7Y90HUwmxwRvlpkmWQLvjIKfUNuEeM3SZkrakon3HxYGMFpRj/oNZPJt7Si+u09SzZQgCXfEUgVIVNCu1YCr3SLWQkCf1O9L9BvdH/0g4H489stI1EbR7H5Rg5VpN/smw2Y1rWM2eokWHXAX1O3HiUWqr8ARfAb7YKRgxYZRK5+WezChmJRAqOuMA4/ZDBEeYFfj7RKPNM3WrWIfUGZ9ecgvVzcEADUvH/9b8LWPCQ== 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=zGlHm0yX8TuYFKRUvbqZ8nfy0EEKrPkjhdyhgfCxWr0=; b=blpxOJrts1yAfCg0nQBlfA7NrEqzsBVPurkzaZU1Tv/ZMMnfDqyAPgfgaFd+BNBdHL+5Isjx6PuocyqkIU98dCVyrJP3yaBvk8zealIxb1S2Td9wDpnRH75GSmKsyswtX4799SKKZ6DUEWJp4jFK7dWRLOnG4Mx94kldEs0FRA8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:53 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:53 +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 v3 12/14] xfs: Unmap blocks according to forcealign Date: Thu, 1 Aug 2024 16:30:55 +0000 Message-Id: <20240801163057.3981192-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR12CA0007.namprd12.prod.outlook.com (2603:10b6:208:a8::20) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cb0e3d2-ccfb-41b4-d42c-08dcb24773c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: QwrQbCcAzoh0zZgPph23ubWavg1OGDWacKiqo03/k0xKdiThN5swALgDRKuuLxI8sJIApX2GkP0R0RiGMUN0nWIMHeNAVSTmZPcOvUk3c5P6YfocgiO7uGOJWU1q1bXY/lneJR/34lNzMkmgS71+3N/bQZvSOHkTZlEN48qRYZo+YTVEfUk4xQaIWQTpo7eR35gVpWiMdbGEnfrCuiqVErIBV9EuBIc0Jc00Jam1wegh5Vdip+KjhKwYdkSyyR9lU9waBIfE5H+VV6O3tw7XeqlSUMlPFJsyW2JP91qzciPhgxEyPwaoMZ5EWmjvvlGsg93RyVU0tSdMSwaKnN9XCAazTa1BF7f+m5plKaCYjq9Jj1TRlPofI/2ugAiMEqkbDXQ8v6N/NALQS7nYky0hjtoME5cZOWE9PsO1CSFly4P1pBY4GFfqbSph2bDuIJuTZEzGtnolI64b3mEKT9YX2DaJXus7Arw5aXkdrVW2UdUPvwFxEu8iA3x188+b87TD7EgQC/NyX3OMLcbY/W0BoUceOELv0U58twV30+8tKqLIkLH8RbMMRqp9vb1EvBhsGwnYSywN8YCADJu8O29wDAZraPocroG0N66Ngj11jdpde7ITkcg6cUeqFwh281VWNInxNko+rk7Y2u1O0i6BwOSMgWMEESkjWKj5vgdyKWh3D/xtJK3lReMMMyHdbVCFApiItRAjAFBZJDfkLXycbNDGFMYQF4zVUhglTdHQG68278x6L7mctxROda6L4sbZfuBe4OjD0Kv0omvrugQ8R3AR/Libjl9uyH2W1VJICvHCata+dvewrQ8KxSJdy+hKhOCCb7WLyifVTzv0PTcHMNMY2ZVZ2/TZm4IQ2BPW1vcMcWm0OxOg5IVRCGKqeag2CiAEgAzfkcibt1QEOA081bAZIWclkLvxgozJhHuGL3J5XrT1hnmwsDj/LnrR6ztS36eCVYHE86bCwzffT0qjAiRYd669VWMndRr8vrT49uOQ24khcozsMIClG6cUCUoFTg9n56XbB4zRZq7+HMZaXXjAKJrtTRTNOGbfYQ7CUHSTKq4aCJ6KGaU+nUaMuYtIu03OY+ednbK7qMOKGGE/QF1+bwMxudMfbaALoTbKTMXy0sbqIpJwMl2erpym/+QZ+vLzPWWGnKEKMG0AUOMRjwwJcIJy+o23Gg+VPRsdhHoeXSrDJK2B1U0GtO6LVf2+wP+DcblAKNs92AH+wovA8Yuy4emu4dCFsKE5AzsqwnUOb8ZoquZZfHp6ZLNEEWouK8cn3/erdwv7DysgFoQZn1lGpDn5NtsjcAQwl9SyB613YprRqkm91IOil77hoBaYbJexm2Kvf9RwaRtlwD8AsA== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YjqoQv5y8Upw2EYNIDIbe8IR8BwWg5PWLdZZh+3nE/o4+cIkhhGR/fKIrMWtwwQV7wI2bYUzgxoqENGXu17hE692lxPCt89Eewvp3e/8v6AWZ2bFG3oTGnh0u5Kmz3S4D+GpZog095q02ixLK5LFXVU7eQig9tCUe3R1wwog9785lfLu4AqmVwEPDhpsl97G/HakX6K4Teb7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+7y+PQfQHEai1Z9tVXeJXzy73P2BDVem3hqdfydT+JvOjokPbzwuWN3VaIdQKXbC+1MlUMvXVTSJ2MXS1srJFhNcManOEkL0j/vhM760KBsfS4c15SulGSw41vOWly48Lny1X7KHKA44JiwBO2CIZFN4fxv7ZutQdZnWNN1ZaJTO9+Q/3TfCHDxrGmKTdJVJWloKrFoY0vNMjPeVBNDBm7gaCt+up69Un4kee9A6dlOy5EcTOlMm1z3HPobJR+aIBXl86TUf4PB38fYYpXynwwlYKqZJmKQzk1vyoUKuSE88Bj6+D/JyNfH8FIc2EqLIPcCO4K7ykGjueJRnY6rQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: KM93j73Wtj0SCXRA3ZavxvMdy8P5enmqg3o6XDD4iCd8cOqcdbZHA5ZcxmvLTxLg6rqydcz3N41Rkgc1Jk8gr26fz5OInLI6jyqObmhP7KlTlkuIF/P6YbFPQpNljvvzHfzn5eZME6N+Bd5LO3FkXxdPk0SdCPx6UzqFmN2SByNDi/id4Uk0Ei1aOtOW73B+EdKB8lbGR27Ijk/ZYr+dr9EKtTHIvPIrh1FhlLth63yLDosva+m5AzwAVO0TcsaFCxtaRimwGZNcA//Ohip9GeQCaQJ6F91H0k/HuOGPgWFZwdcNrZ20HDJq1TBaZL6yhukasUaI3d/w0MU/xE0HCE4eOitrwZzwtXO6VJdywpBdOLOmQbALVN1iXeUVfB3E6DOhikg+ENw5568CR/+HnmdU/ftIOjKza+BhL3Jgrv3u+wq5qKYmDHIo6BWnFALxSJzVzkpc3g0t57xVuo3oa6rPDBlRwQN7W775B2wPsFCHSlTkUdI/Y3LrO1L6lEgmwN1CRpusgEb0bBUzAI4IB9EYBy7+aSVcrTlREFbfiFtju8Amsq+F+JwzyxbFLs1LyauewP8lFzoxiY76MsOx0Qig/UWc4mgZ91r5ne2t3g4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb0e3d2-ccfb-41b4-d42c-08dcb24773c3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:53.5564 (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: UDbgY60TVYfVKlOixOH6cStitSHBZl/A52uXgsm/S2ppR7a6qS8iK5PjUL+RIU2xBtpK/49A2L9ozlZcUHZtmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-ORIG-GUID: ouyBfu0dReZsUXnGp2M8onDS5tHCfSKc X-Proofpoint-GUID: ouyBfu0dReZsUXnGp2M8onDS5tHCfSKc For when forcealign is enabled, blocks in an inode need to be unmapped according to extent alignment, like what is already done for rtvol. Change variable isrt in __xfs_bunmapi() to a bool, as that is really what it is. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 48 +++++++++++++++++++++++++++++----------- fs/xfs/xfs_inode.c | 16 ++++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 0c3df8c71c6d..d6ae344a17fc 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5409,6 +5409,25 @@ xfs_bmap_del_extent_real( return 0; } +static xfs_extlen_t +xfs_bunmapi_align( + struct xfs_inode *ip, + xfs_fsblock_t fsbno, + xfs_extlen_t *off) +{ + struct xfs_mount *mp = ip->i_mount; + + if (XFS_IS_REALTIME_INODE(ip)) + return xfs_inode_alloc_fsbsize_align(ip, fsbno, off); + /* + * The agbno for the fsbno is aligned to extsize, but the fsbno itself + * is not necessarily aligned (to extsize), so use agbno to determine + * mod+offset to the alloc unit boundary. + */ + return xfs_inode_alloc_fsbsize_align(ip, XFS_FSB_TO_AGBNO(mp, fsbno), + off); +} + /* * Unmap (remove) blocks from a file. * If nexts is nonzero then the number of extents to remove is limited to @@ -5430,7 +5449,8 @@ __xfs_bunmapi( xfs_extnum_t extno; /* extent number in list */ struct xfs_bmbt_irec got; /* current extent record */ struct xfs_ifork *ifp; /* inode fork pointer */ - int isrt; /* freeing in rt area */ + bool isrt; /* freeing in rt area */ + bool isforcealign; /* forcealign inode */ int logflags; /* transaction logging flags */ xfs_extlen_t mod; /* rt extent offset */ struct xfs_mount *mp = ip->i_mount; @@ -5468,6 +5488,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)) { @@ -5486,6 +5508,8 @@ __xfs_bunmapi( extno = 0; while (end != (xfs_fileoff_t)-1 && end >= start && (nexts == 0 || extno < nexts)) { + xfs_extlen_t off; + /* * Is the found extent after a hole in which end lives? * Just back up to the previous extent, if so. @@ -5519,18 +5543,18 @@ __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, &off); 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 - * get rid of part of a realtime extent. + * get rid of part of an extent. */ if (del.br_state == XFS_EXT_UNWRITTEN) { /* @@ -5554,7 +5578,7 @@ __xfs_bunmapi( ASSERT(del.br_state == XFS_EXT_NORM); ASSERT(tp->t_blk_res > 0); /* - * If this spans a realtime extent boundary, + * If this spans an extent boundary, * chop it back to the start of the one we end at. */ if (del.br_blockcount > mod) { @@ -5571,14 +5595,12 @@ __xfs_bunmapi( goto nodelete; } - mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); + mod = xfs_bunmapi_align(ip, del.br_startblock, &off); if (mod) { - xfs_extlen_t 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; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e7fa155fcbde..bb8abf990186 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3164,3 +3164,19 @@ xfs_is_always_cow_inode( { return ip->i_mount->m_always_cow && xfs_has_reflink(ip->i_mount); } + +/* Return mod+offset for a blkno to an extent boundary */ +xfs_extlen_t +xfs_inode_alloc_fsbsize_align( + struct xfs_inode *ip, + xfs_fileoff_t blkno, + xfs_extlen_t *off) +{ + xfs_fileoff_t blkno_start = blkno; + xfs_fileoff_t blkno_end = blkno; + + xfs_roundout_to_alloc_fsbsize(ip, &blkno_start, &blkno_end); + + *off = blkno_end - blkno; + return blkno - blkno_start; +} diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 6dd8055c98b3..7b77797c3943 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -647,6 +647,8 @@ void xfs_roundout_to_alloc_fsbsize(struct xfs_inode *ip, xfs_fileoff_t *start, xfs_fileoff_t *end); void xfs_roundin_to_alloc_fsbsize(struct xfs_inode *ip, xfs_fileoff_t *start, xfs_fileoff_t *end); +xfs_extlen_t xfs_inode_alloc_fsbsize_align(struct xfs_inode *ip, + xfs_fileoff_t blkno, xfs_extlen_t *off); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, From patchwork Thu Aug 1 16:30:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750733 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 8DF1C1BD01C; Thu, 1 Aug 2024 16:32:10 +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=1722529932; cv=fail; b=S4EO3LZsL4NboNEPNJzWVIv5HFH9c5ICz6RuiYFpZjjTPu2PXivei8bjC5RTpB88IR17uUEAKr4ST4kLTIjuGB3jsKavSbnRFAkSdE0CiwcrUOp5hxiBuYEVexE81TH7IOlikAAw9qjK5zVKl7vOhs2K9qTH8d//bOVGpChg2f0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529932; c=relaxed/simple; bh=2xJob8bM8FuDhmNTv5sPBNhkIAuRf+6gpXfoewv+evg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TA6pMd7QtJXFh4uc6aquJcAUrZIozaPFoqd25ASyINwNg7DzQyGEzcQXNQQDtm63UpxtP43Qm+QgJTzFwewEXzvhcj9E4ld5x3Zvc3xilZsCygBSU0IkYAyyS3M90iPeMsLh98fXrw5KN3OTM1ZWjlMCvS5ErpoB1j4gCEObO1Q= 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=l9mb+mA2; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PTFTltvI; 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="l9mb+mA2"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PTFTltvI" 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 471FtTJR002486; Thu, 1 Aug 2024 16:32:01 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=PQCgj/fTtiN7ZwNNirfsdVvWimv2TbWwYg7gvzOqD1s=; b= l9mb+mA2r5AX1wMXHacf0Df09V7cetVFF74qrhl4WVR7pjl5gUc+u3LOb8aNTRww ii/6kWGhHDPj8MPDe+2FHCorpJVTIdKvO34ri0R3OqwDhOKEt09iEd57s5yzURMc MrovlD7lUfnH/R8eEtLFZQXD6vn2RV4dvfCewHuGy/0Y9SgYlDr0G6Kr5ac2sylF pVYJghwLfAad2yRdCH5P6BMxlj7WatyU4iHi0qd+Dc9HMtgbUCMuMn7ILREellac wG/QLpjPbclWL1J0lNLbK73PAqjiWJ+fUorO8HiIIE//1Pm0pcGsxInqIHC7U3Ev KXsomOlfyC4KDJkig6ZYvA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40msest6t8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:32:00 +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 471FNu3B030932; Thu, 1 Aug 2024 16:31:58 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40nehw38jm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=glC7teV5587rCTAF3SEC9Fd9T+CnMgfkP2ZWsCVQPzRR0ew4VNqqUyWYxOkztD+vNzCJjPnpkIJJhmfI9HhxSpdY9w3sqvyLfKpKpQQZK/HF6inmUlyRwMeZqkypoNU/V8OW9y6M5aJyvY+caX2vi1NzTbqfAs2HYET/PmKhzrsg2vMWuu3KpMEElsjLV9JWwDyD5pS6tryoAK7M+14cv9alc2NDYw1unvg8Bz7/iwxRXnkw9rtAG6FI/s2y8haEZL7byO8qeYicZZx1eyl2WLQXmD9vN1T+eiSq6xsLUeeYr9gXFkm4MtJ34RjbiB8Qx0rxNt8Rztb+CzFhqLgDRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PQCgj/fTtiN7ZwNNirfsdVvWimv2TbWwYg7gvzOqD1s=; b=mwNsd8qfcal3kp/LBWfruGd/Tr+QbKJm11fxA6d1tdO1Gplpy3MZW5BD1h05Kn1i83pHzwamga6assm6EcpXD6SmL96wKOrrGGJKBX2W6BnCiGnM5BhjksONIFQJxiyPbPMQuDirqhAup1qmnTrFWjpuHY7Bqk/tD4LlIeZUjKdcpej62BWKOJR0IMpP1SFPhfGJNToe33/cJCBgdfFebwUKYgzWkk8Sb0oHZH+2tmNOCLtHuZml3SHa6tx6WXFmnGdXPPFdeCbIz68BBsz4U/YG7rpCsIhbdmEw0arMgQ441XBRgdvMHloxzg9SWlr5OD6/ist7rMG9C6W9DcjPsg== 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=PQCgj/fTtiN7ZwNNirfsdVvWimv2TbWwYg7gvzOqD1s=; b=PTFTltvIMNuGDzQIvgCiWsRBCd/EFVIva8XQwYlDctQyymGV8TFFZBcRF5TPil9ZjntwEgqE4j4h4onNeLBwOSh1Y7A3GARhznEyXkF0r8mkI14EGr2cj/SZU1fbvKDHpsejxEUytJzcDYoggT8HczsAraLh0ga/L1hwjbaVUVc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:55 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:54 +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 v3 13/14] xfs: Don't revert allocated offset for forcealign Date: Thu, 1 Aug 2024 16:30:56 +0000 Message-Id: <20240801163057.3981192-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0038.namprd16.prod.outlook.com (2603:10b6:208:234::7) 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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: f3abb9d8-aa2b-4d16-1a7b-08dcb247748d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: Q3FOzp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gkC4TZdMPdc0zi4LIfsuQVnNB6pOb3Zvp1DytHdb3jYJnqoMKV21TMNwPEAhdWv79avSj8I+t/gGh2Z25na8zXMYHYAdFod4eyWQmC+csAG9tBQ3VAiotwcr92Ul0Hq5ADXckbWLonV7W5sKbS2vOLCsWyFS6i45x5Hcb/fK9aQNjqHb6EK+w//GUFtLDK2DByS+6QRDl8YmIajfbqxL7cqerliPzG/mWnfHwz45rlDLhjPhBOArlM+zFQFbWiNXoH9RmHR4AAsa/aWKFGfWESBMFA8RBLWQCVtGdqL8g== 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5ocMbiLP+ASMcpI+jCDHVqrh/UrLyDUl0tuEYkSpMkoHx2+EaArnE2TOOfEc/3DmbFY2g4dbsv/SgWyzsWuHIbYIVovZ58Iosqy/VEMlTy1LZqgA30jie9c61bTskw9EYGs0XsikkA1wgIgLGsoOsPWyiEJQFPH+d13OOtACMByRxgXC5GZ3f8T6nm2VkQZ/ZuIPpNG6898c7mqQZ+FRfrjMaH6fl2mLJZSFnhjCr6nVAq/mgsRLr++T6K0rZQAmjNa02B3Ro69KZGgSk/GbL2e2XzOFEHWFrgtONWf8p7J+sxspVfYywIHM347KbIF0Ld1XL85ThQk1tYjtjUZ7KuGjMvv5GjXC2pMkx+B/OapzkMvS5jxja4z1mnkOpJAG+qJY3aMRaD2tPAsvUnRnIyK6EXt+L4zw2Af1sNMTUSQ7pUfuM+FDrabWCakagv3GY7sU+TPuX+3NNSaQmfbyX577uY2ia4tnUZ7vrNKq+elEyxxj8BCH0jO2LPd0g03+1crWbDMgVPVepUc0dXE2oMsZaX28ZkOQFmQky2VzEW5dl6gctag/4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unkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7FUWX71pzFEk68SxTYqYjMzB0ZBuUjhO8ZDGvaj74UUhcEqsNVTLuDV+4C7NIN4sAFFn3pF/hLps0JfNGuH6zykUSkIiMXsUbiozxBbXGxfzOqGYMm2PFjZ38bDfsXcL8Ov/AVuvSfm9b5dyadQ58Lu61zkJi3V4IThr4a3LMIVOmnFaf1oF3pXw2JAjASc5VYeo2nt+Di0Cn3/VEuGvffXbAqdduwABREYB9HFwmgE/d9Chpdqza/hZYR5hgWw1DUNjf022FS6y2dSsb7A1vfMHuK6TnK0l/SnG9yYngh2hHrBs2SWE4iez3qYG84Gm9VwRS3uRtFuvPhvlyD1hs5AAw03efXaxJb7pqMx/Vtzs2bZxEDGrziqMR1svUOFQrW3dpnrC90FUXaYrIUDoOOpKKthsVcmcwCKKALJNhgCxkwHjAwY/BOY1EPBakZ7mwXSYuIKj7a+v/ZC3bIOKAp6urzMmctHmly0UD41Y0VWH7idiPU5+sxaP23103y4ANwJCBrl6x7nIV4npEbzo2VDn8gV2hZ6UGBmAEv2rP4AVG7iYTWvISMkCwqz8E7ciyGH5MhfaEkLchAvnU5bxQNYvpzmuJ12BunkntE+EUA0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3abb9d8-aa2b-4d16-1a7b-08dcb247748d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:54.8711 (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: 0C4OqGCiLdSQApem4PylC+qWr7pSTq3sgtdVs7Hm3Hb/8Fyy4/O3/ys71v5ZwzVqvDsdJWzWK/M0hlr1TCV9sA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-ORIG-GUID: qJ0WyqSyhTAGzsqbdLZzCwftgqDAqkdh X-Proofpoint-GUID: qJ0WyqSyhTAGzsqbdLZzCwftgqDAqkdh 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 d6ae344a17fc..d246b15160ac 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3491,11 +3491,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 Thu Aug 1 16:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13750732 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 8DF8F1BD01D; Thu, 1 Aug 2024 16:32:10 +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=1722529932; cv=fail; b=GRuE1SacT8CO6sJqVfJWHySz3Yb10GnqWyWkxGzoR/lx8fgH9QIeEWuQfHy35OKtioT94L4hzk/Dlbj9mDTOvdWkqq4XYMBV81WFTOk4wMil5J25OSr6CXs+ycTg6Ukf/CFZS7MMv8vnlVU3n1FMk+0xlS00Ew012WLF9knbpQA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722529932; c=relaxed/simple; bh=iP5VgZqMMKyaNN872Wec5brnrEankUaD624CQGWv5AM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iR+ZA5h3iQlDQLJkMQJxlyDTEFwX5pcWsjR78MKBtnBYUyKSEo8t1Z2F03pWWOeLBwkrHJcmMRPlTqcDeXb25EfCNDGXNyXra6W6vDhT/o11LWE55TRZivL53m7Ej/zgvPG7ld8yXjbjJk5PxvNAlNBZgv2iYryHNFD8TnFVr/I= 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=VbFY8rA1; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gaXcytoI; 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="VbFY8rA1"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gaXcytoI" 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 471FtY6w010856; Thu, 1 Aug 2024 16:32:01 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=COlt0/hvCG/XtFt/RIQWXv0u+rGaER/I+75DfoqfNIE=; b= VbFY8rA16orSk1ZzWYDBpDqQqjdJ2aJ//La4pEf29gM0gkOoEtFV8RczuDVHmJov Et1ew6bd6gjLAyGF8LnqQzmU+3E/Ejwd+h3i1mQo2Hv5CDytrRhEhaUmjTNywAiy xlz4n0lQineLXYg71xaiZyQ/SJoKaqHLm4d4o+v6QqEKBmC7nfJVdQg5EtvvTMiz PGzg52IVcekMjULnhTl2j7NqgUQmaT5vaRuLFG6x0WMgHtW+xAP2GDCbFtfw92Wr OvJjxssSTbIXcJptTfbkNZNwSfMrg/veHdw5Y4HNZU1SdVCevC2XrXYi7oT0bkhQ f2qXKW2R0IVVRasHDfCzMQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40mqtat9d6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:32:01 +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 471FNu3C030932; Thu, 1 Aug 2024 16:31:59 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40nehw38jm-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Aug 2024 16:31:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BoOPgasDsor08ZE4B2cQsdJPQrJubSi7+Cmz+yu/FcabwpD1Qdr2cDkeGVYfLZZIlLIlJyrJQiZc6LFxZzWv6rohCpSwtrX3DXMagFCRxOPAP7tX/BEXqFCBLKZKhGrk2+FhK7dYKH/SOlHePF8aj7XDxj+HpchZIi1LughaQO25uMDd8/Zp6yNdTwG0shJlCJdtMELyzZe3+vfQlwFA4MjS8w/CF3BY0jcV4sQ8rUTKHkjnTvIT1JZ0wphwC21lNUcFw3b4055LCP0aB8DirdmS6qGXCTqHkEejn2tHqqqTKugvZpV9j5ks9bhTSfqQ7IfVu0Xfwm8wgdOhGDGUbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=COlt0/hvCG/XtFt/RIQWXv0u+rGaER/I+75DfoqfNIE=; b=o8t33JdzU5iwGJN133gn5UvmQ2XlnScLJbSmRJ+2d+eNSxB+l5ZnX4paPVClwEmlMMo3W+ZdoJbmfYoS/uej5/jqk5YCxj0A+c8tL+GTl5ko/VlW2Slgsp9KfhxLrC3N3ZUHsc4R24KIUUORFOTM1tAlAaTtbZIz5dtuC5AYWQ3mKaMqIkMuB2DJigs3K8kMf4FG0nl2u90RMdMAVc29trpEXwp7YnBphKKh8bByu0gQ07DEXmEGxUQo+7izcCw2TjUGUt3hpKxYqbQMPBNhgFqlEVHW9OLuF9A6C4rW+nUtEKDcMS4Rbm8DZBqqyfHZ4hcFegTt2wWabELgJ7IFsA== 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=COlt0/hvCG/XtFt/RIQWXv0u+rGaER/I+75DfoqfNIE=; b=gaXcytoI1ax++elXk/I5GuSWFnMJiWv0kXLaVWeYzQ0qAPV6xiRptzbKM1f/UEnOlMAQe2w2lWxbVAKGCdfo8Q6Yey8XdTVuXGcYI8Q0AD+Yr4aABFnbkprM+oZ4fMZHSGcN+asvMz/c7bdf/42ciKjYqrYr41WK3+xNkshRW0c= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6081.namprd10.prod.outlook.com (2603:10b6:510:1fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Thu, 1 Aug 2024 16:31:56 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 16:31:56 +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 v3 14/14] xfs: Enable file data forcealign feature Date: Thu, 1 Aug 2024 16:30:57 +0000 Message-Id: <20240801163057.3981192-15-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240801163057.3981192-1-john.g.garry@oracle.com> References: <20240801163057.3981192-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR14CA0010.namprd14.prod.outlook.com (2603:10b6:208:23e::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_|PH7PR10MB6081:EE_ X-MS-Office365-Filtering-Correlation-Id: 3028ee8f-1132-41a9-04f3-08dcb2477567 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: eJHy/ckZWo7UIlOQ1Yqz+KWHSV7WNMTuipzSVMkHydXO/uYdmz8LEw/8ij1ZbuGeQDtMrKJYpOyPmL7pcXTCfqz5mdTY+UTTfW66aLra7URKsrOYv+cfNIWCjM1Bj28Uhgv2nt2SJAfe0oZvU7zcfUVSnqvuTKeV/cydKM4VA4aATsbP1vKTwqkVeT2WH3y/zNZIin7K+XcNoUrwLFVl0pOgkTGMA8xoSSAmbK6DJM/68Iz/S8Cc7EsTzx25uljJ7wa6QMNlEvuXm79zO+G29zcRj/2wmgIfRP+H2uwe9MPK4p8Ayvq+ybVSEsiINlsK+vjLsFP57YgkvEeyG/Rp1emDGVcnmW/w6N6D0S6H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FV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: olTnFb/x1nGdblZiyjlyTuKAnrDfpes9Ch1a/h8z8fCSihSpV7WNh8KiRkwmBOTn7AcrkNVGL8VPmf+kLsJurGiT9pA7LDSEYZl6h0J67bvoOAYAYTDbM9t09ujTNjveyxwV+kt3snwj5Xobb3P2vnvS7+Pp1JGKbMiK339lE3AC/EcM96eSqA7mkJNhrfVfS2x+0L6JKoDXTIBOiKZX/KsmAOjHFlIIp7FKP+/KSsD3H3XqGXxkM9h8QOLKYmeENU9HeGianScljH3ZQeFiZWdAWwyi+s1UtGUZhslTUTAjeC0IX8W5j4XQCz3M6L3B7D/T4PHEpZoTPfsAhe7WVm5CXkugBJhBvlvsfuiTA9zfVTEt5rNlu5YlJ1+bFnmepQ6RmuGOebyv1lEIzk4tZxgtpIwq4XDaTkGBV0sNEwOgn/BN6n/qbXP3sbdFF7knsUNGj/sDr42zfloQF8AdbPVWLtQNJCtadCnp6pydFIvs3LBs0k1Tpus8g30F1bNpUuiE79ek9zwjgDmp24hng/aHqJ1Np5KQtL2jj531co08ac3D2P+oMYR/JamBTln1AtCsuKRhM4/7TpaDF/8uwmVfM+lJLLsNbyeUCRnn/nkqBQSIe2sFWPlHipRni2aoFRhUVQcDP4hvxPYygOdfHXQ+FVol4Rzy4ZgypytKOWFkmKfvSQdecH4xDVg64sujYpmuwivjaD4sAcBwlXOszeZJZ+2mg1AE9jZ0Lzi9vcvo4f8ShOFdRoqPLhn8IC0zbx3R/UUWrPSjhYsSNGKyo7Dk6XWLtLvWUJ1BbvRbg+6CD5Q38SFmOEQkMnIw1OBD/iuZBq3zVkqYFQJivl+YtxSyya4ade7lfADW07JFtIZ0gsIx7kNhzebc5/tkEU5TgHK7g7CVGMIeD3O15R7VWwm/w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x8+tUyHd/RBDtWhNHDfXgfmj1yWcmb2/eD4WoE2DKnvHKt/w2FS60IKFTq7hjKnXKoJpGYveEz3gAVTJZWfp2V1cI+Ls6TJEsLAkizUU4C44MrRcWrVDeoW4ubQJsxwLkWSZvHZBjFSjTLIBB3cdjWXZUvjjf7K8SHNg6jp9GPZ331qe5MDz6PoJxNVV2XdgsaEpt1eA5NOlXXi/bqmZps++JxGY6tAIyUW+5o4z4ytKZiwgN+NpyBbMt9DKZ6sWLS3kvSEXNzAKQuikUcuCcGCNOpvr25V+YqXouLQTdbWd1jdwa5h5igSigx4l5+mjA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3028ee8f-1132-41a9-04f3-08dcb2477567 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 16:31:56.3102 (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: A2OM6LUYSV48G7pJigOS78+qIlZa3cfbeLTrC7F6Gubd9ykA7lf9BhQnhCTgoxkBl6Q+83vlOzXNAfGYEK4gMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6081 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-08-01_15,2024-08-01_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408010108 X-Proofpoint-GUID: h0oZ7c8XTMyxfeG_w67kqMdVyh__eyRs X-Proofpoint-ORIG-GUID: h0oZ7c8XTMyxfeG_w67kqMdVyh__eyRs 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 95f5259c4255..04c6cbc943c2 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -357,7 +357,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(