From patchwork Fri Jul 5 16:24:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13725360 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C720E171084; Fri, 5 Jul 2024 16:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; cv=fail; b=MAttATD5KhwTmAPtfMdUjebXEF01ckOWPeRuuxvdjhysCwrWGY31hdc2eDOiUySgs7qrGf/dPU8FBffKXF7E7rELWLdQ+7EIxcraMrd/zp22cCkfFvqdOz8QF76giPCr/da74K5sW6H4bA574Bf/GuCSmDPErj0p6bVD5xccY/s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720196738; c=relaxed/simple; bh=wwqgAiTHSgyLmPYyn3J3t0tYESGjLmnJyRJ9xaf4qWQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Re9xy/YLBkZHnXR2vuBY4KwoMzDtrMXQ+aTpVtDqCIsVMizpPg4KXOHYyhNgR/sw/b00HhmbCjJGLZVZ+OnsML66116O6S/rYNZR/oh0UtysIqxONyYu0mh+D34vu6SjKrXDNfu7/uMbtt6DQuNEzi+zwLDosUw/5+XHQD/6eYU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=NuMp3eMz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=nkxhgXd4; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="NuMp3eMz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="nkxhgXd4" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 465GMepI013563; Fri, 5 Jul 2024 16:25:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b= NuMp3eMz3ZhCTOLxc30PqPPopBUw1uxpnkbM3CxYZ8RVeduf3LOFkZg2yP4TXvU2 LC8T2ODhF0bduUbRCUOtnXmTiPspSb8dntH2f0QM9nTEolB5r/cDCYLaVI3pgXOX GQFxTV0I2UOg4Krq/lGyD0+I0tDbjKatY68cUsWa8jAeBE0nmHyz1I+AlTGbmn5l n6lJEqpXwxFBNb23wxd7MzfmlOjj/9P9zz/SBgR3vGsowM2gy90xWFec73voBTTm ealb9ladxNZhcs+rRiZnBZVSkn/W8IC745bu46mFzrzKIlDxV/SU4lXcrfVyiN31 emrht3AY8sPLF4BoSttWLA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40296b496c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:27 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 465ECGxY024807; Fri, 5 Jul 2024 16:25:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4028qc1c54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2024 16:25:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VwYJiLQKGKMJBJ0btdHlNdidT3GSuUnS1bic0JCj+s50eYW49PTAFuOVPd5dCXKXLHvaqzDplbVqvNTOwjUHEosZ4nRCb+ItrlFKAFI2bP3DFyldlvpc/IwnaSbMXRfuEeR2xEVjIMSTsAd5yc/Ybx7lQPseJWkPqP4VBOtKoJFDegkaTtLOD9TOmMbFtPegMmmgQKCGvTgi2UhMvlfT96AuhwUeTrXjYZxfV9uG8Dk7tyhOAgK4D/EZoVfih45P4LimdBz4OlKmW+Ib++C5kAkoxZpXDtSeoHZ/6lJ1AQBlUnnrNcWbUC30uCS4D0BIZc1w86lF4kFtOw/OD/53cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b=E5hlJmZq//TBHnKtd0ZjPUdk6ml/lsZSa8NkakBa5j3oNhZfMc63KmZQGYHgsyYZvuUu2ruZQUOdCwPrW1Tf69SHz3Dm4TRN/nk/1Pt/H78vNMhQw2eaRKF806GJvZ574flsKwE7hcEGlNRX+UmVNMpZ0wkRdvK4yZM7WcOTy7qhy0X/tHhwspo1Lw8YBMcxHT1atogxQWj0MxMEEts0ehrKdow/90ctVYwrL7aOM3oP40BfL5xOc+o8Mqqsu7pDl+9XJ/MKdXdIL98HF02afPoNybymmWrZUbaoPLDeK6A/JSC2qFtM/8GIrS7aw7pqUTqlA4mzoh+NASZv5lrjZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nUqjdO+97k+6nfPaQBADrHbf38zy3S9cZ5EqosvGqIs=; b=nkxhgXd41JF3mEOnxzwHCPOw3Nk+is8NeNZ24KspTC7CTOWM5AEa6lNFIYXg9jzaVNMsDyoumrc9caJAEBV6t2R5Lc13cW3eFA65S9+0U6I2KOUBzKSk0tSax4Sn++itLT4MjIf1qSMGx0RLrxiQH6Zbuz+ujXyDW+bnz7ffjSY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by LV3PR10MB8201.namprd10.prod.outlook.com (2603:10b6:408:281::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Fri, 5 Jul 2024 16:25:24 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7741.025; Fri, 5 Jul 2024 16:25:24 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 12/13] xfs: Don't revert allocated offset for forcealign Date: Fri, 5 Jul 2024 16:24:49 +0000 Message-Id: <20240705162450.3481169-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240705162450.3481169-1-john.g.garry@oracle.com> References: <20240705162450.3481169-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0352.namprd13.prod.outlook.com (2603:10b6:208:2c6::27) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|LV3PR10MB8201:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d33d1e2-47d4-4121-a6a2-08dc9d0f12d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: K5zovPFcvZ0IJxRAaa1emqDT4qJm/EH5p7tvZzJrEAEu73USDeaq6xFz397u2N9npDdxHizVtOvyx3NYOs2RR0dulx081kFzqbxFHYG0KERQOX+UU6v31lJsa1bETQjocoA8NM9yR9k56D5tmnRxLUJp4mkpjmyZ6r9gNYmp8veLEpyS+1UR7AOo2pJiWQ/v0yu1AeFja0VRic6tpcGwxJaEqDKVfd0C/gpaToP0m8NQpTam+lFfyXezigKkxFL/0sOpWsKMPs5c8mBejYHj/4KEfozKeBumHD1E66JWlGTy2sASLRbusKj4bTS85T7grQZr3/gf27bQvQsmNr7Z20H6Td9kq6hdjiV4WX3V/jj2Q1k1QGMpryo7zi9cUi4ALK3O/zx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;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a/0X79t+6I5+x3MgPCvhaAO6JTO4hmeN1PX0fBiHh8jiJACVmUbSDVq+xLbe/3QBa8iAzgCBeV9t+zpwLSGnGvBJX/rQP3KmTfzob19/OC7LBi9KSdUg23IJKEclDFItZE1VdkpFqOrJ9fDadG8ov2I+1r+BweHe7I+03SGIXdwCdY8+o6W/MkPYgOzKLjOqqFWrqS9KwMlXrunMqlINrJhdHdQD8U6vAcQuOnpII/noS0rHO0sK1+v6sVqXVkQ08QvkM6HRehfOyXOrXy1w5WuNTtsu4arZW5GftC/R1rD3IpBB12M573THy0yXepL6w5jDvbPaB6qCJu9UXIp9frO3bBuGTNkw+KuUuinC+b72dX8SANTCW2qksCqzuTBMtU/UdfyoKRPvmgM3v7kx53KeKoaJ4x3RpjyCq4bhHw4cZqtiZO2kMpBTPld21N8kFcJOTk/1w0GbIXc030tWCNaIidGBcsS/JY/3rFKzVzqgxa8oD1rcWmJUc+tWnSjiIDkEQheM8Sh2YGrbMfyik8n08XT9hhAPk7l2ERiiQ32CW4qr3iK5atTj8QdEcd0XYQtH0E9dJ694QvO+7wc39O0B4bOeB2nZkzPr35NVnZwbm55KceAnUw+lmYQm2+J6rPZa3Y1gbxWu/SEtzlwAJ4eYQ4j/rFA8BxFNPFU/oIUynY91Pv6s3u4pdG02GNRnbz/H18cprAZt4pDSu+TMczGTvUJKzTp6q6WqbBW2lRv2xHnMpknH0a6MWng2iiOOHDCe+g0nDsWP4Rq2EqJ+2kJTMGmbrQalI3sBNmAWMCVbwdPZfngDwB9mp55FVx1ybzwT8xVdRvoez4IQjzupy5VVIOa8dI2jx4y3p0NBb4prBbDjRV7zftryYPRoUpX56VKHx/lvjCLsBR47KYFquekBym1u7KJVdr8jSqIe/jrUjZZlpeF3RxM0b7wiYvJjqt9E1H3rRg5UMH9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7ofbMT6wcgHix+VEZfMsEc5YlOFi4TGXrpzkRqhh1SQkb84KGiUlaURWHOBbCD0LXudfkJsKynm5ziFdp+8/1ks4u/HWuh5udarh7iIXLhl5CeLsakcqjFBBAMA4tfcgORM0i0hSAZcRv630MsGZTAsDerXuV+FsT7AcOFD6hC/TalhVsk41tzRzTvbZb9Zxh+8S0VD8MUAvHuvRg1VfNvFqb2ZyMYO6/lNqLargAYvNmFwHKFbXM5u5Q1/TRc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d33d1e2-47d4-4121-a6a2-08dc9d0f12d2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2024 16:25:24.6806 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kAv6ujsfRdFqM1polloOqPqftMEMGKRnv/5XxnCvUXuq3+Nb/eBnrKhB+eUEmnsn0snJ7F2x35jfHeu1xTNCWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8201 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-05_12,2024-07-05_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2406180000 definitions=main-2407050119 X-Proofpoint-GUID: B2gzC2RxReFgOk3zOBdoPDDJoZapq3YN X-Proofpoint-ORIG-GUID: B2gzC2RxReFgOk3zOBdoPDDJoZapq3YN In xfs_bmap_process_allocated_extent(), for when we found that we could not provide the requested length completely, the mapping is moved so that we can provide as much as possible for the original request. For forcealign, this would mean ignoring alignment guaranteed, so don't do this. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 07478c88a51b..45694ceea35d 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3492,11 +3492,15 @@ xfs_bmap_process_allocated_extent( * original request as possible. Free space is apparently * very fragmented so we're unlikely to be able to satisfy the * hints anyway. + * However, for an inode with forcealign, continue with the + * found offset as we need to honour the alignment hint. */ - if (ap->length <= orig_length) - ap->offset = orig_offset; - else if (ap->offset + ap->length < orig_offset + orig_length) - ap->offset = orig_offset + orig_length - ap->length; + if (!xfs_inode_has_forcealign(ap->ip)) { + if (ap->length <= orig_length) + ap->offset = orig_offset; + else if (ap->offset + ap->length < orig_offset + orig_length) + ap->offset = orig_offset + orig_length - ap->length; + } xfs_bmap_alloc_account(ap); }