From patchwork Mon Apr 29 17:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647470 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 97FC11292FC; Mon, 29 Apr 2024 17:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412974; cv=fail; b=pk+5RSkM9yEXeksrI4PlKu8Bme5ie/XVV57PMCnA9/TdxbiRRnIQOWw0+1acDC10q3Ob+tb6ez9iC05dShKZpPtC/v3sm4TJUJja3RiAR+roVqAPNWUanQey9Dtqn7dhTyGtzE4UdhnibyDQ3pGZAlcm5NDghZDC/jcXzg6h2iM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412974; c=relaxed/simple; bh=iHCHI6mi1dkX8hWRb5N7guyQSaNUC7ecYv4z32iAUgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QHLuVv1x+DKBnMhtqyZDIIuXiCzPRy51Au1Qx5VPdikOQxShi3mrlpFG33wy1G1EzQ6DHqVBQKBvBqpk7V2rbAQyIydd/lgGVaMEKZzW4KxZacDlBOWWLPi+INAOEM9u/P4Ipc2EmuIumjshvwOYsiq9h5gEj1JLmSuTcxZrKtM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Xlv7S2xS; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=WNDhmIzE; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="Xlv7S2xS"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="WNDhmIzE" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxRa5020045; Mon, 29 Apr 2024 17:48:25 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=z5fiq6XyRE51nFIbwNmIhlOIF8X5RoQbq2JLAjay9UQ=; b=Xlv7S2xSHLXhF5xZDY4IB2h5scu2TrRuQd7L0Dv2sDuj5bacptZag3Rk6i8q1Q81DcQD NpxCyHOXu7KjvXaT7P7Hn+mvuj5uayN3ZAJ0Q/WO+QnRfDEHbZjZCx2/OxOQRHuNTmg9 +O3uYlbcVTLIXZasstPSf7F9FDdQG4BLI0OcZTjjQvz+0X9BKk5LBr21VGTsfaLNjUHs yN3EhDtcv0BZFd+5jiHAmfY8ctK0KY4pBQbtQhyei2UzSO+wyFZwFTDsWfmVFEX365Sg s0il3Ij0SOHw1XLFZehZ/s4PEV++/MVNd3vL8YheRqGY0S/NN0pCdVTM5Kj46a2FFwh3 ng== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrs8ck67t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:25 +0000 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 43THkxUL004324; Mon, 29 Apr 2024 17:48:23 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 3xrqtc7ns0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pqs01GnvTOmmeUgelUSsy16Djgn1fX1vh00EiWQCCRubU8gfxcWmr8fBEJFmmqFKBwyIM7bDZ3VHVjhN8ZLhMtK3YzneYu4baFiIJF2vQIPslMTF+u9SGKis0orIIVgOdlUdUyr9K/hjiikbuspAsCfHy226YfK4sZAgKDMIk6zJEiGBEJbnO61C+8+lZpgZDDmHj/WqiSM7ulljDWKMAI28+XqQ2Vtc5XwIVu1c1nTQmLo3vUQNGlRmOO5mi36P4kD73UVOY7eSP6rOjgVHfMZwZAnxvWKAy8QihDeTR3Lk57yYr0i171X8hMNSZJvKODcgAwDb5siHOiwhyvihZQ== 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=z5fiq6XyRE51nFIbwNmIhlOIF8X5RoQbq2JLAjay9UQ=; b=dRlujkZ15p+28AKI18cSffwUiF5tFndBoXbwcoMW05SeK59Y9py6fD7MYb+wASXIFrtrRvF/7upG5BEnXdl3lVQkJHaQXzGftZJ94jd7HPc5p83VWZ99wNWU4RckfJ2prVxUDN61uAwZh98L4Ejx2jvfY+cVoRepT16w0y2UWELGp+pF2OP3eesP2BIb/WKRYn3w69B7Bds9rb2A4QYVrAyCxgTmcRrsJsVVenZKfdTeILHcaMBcdzMNgP1kqJF43dSIZ28KniHQ/U/O+S98IgtBJzOlpgKaLXb0ER7mXV0CbW5//dTpgkxVTlYnhMBTHzUNkH6Wp3fKegNorbUnLQ== 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=z5fiq6XyRE51nFIbwNmIhlOIF8X5RoQbq2JLAjay9UQ=; b=WNDhmIzEGjfjA1lT6jJ1PKxFwjrX+cqUdKRd8bz8XIDRfkpPeBl0tcwG/uvmAGTsq2uAEy0OT96QtFQYDxC3h1tP0UY9iqNoXJ/7HYdn/cg5AQajwpCO/ZoG1GtmMMb3aXGq/reJFLuj1XfV+kKArw00G4fmr+O1janPfdoCLzM= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:05 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:05 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 01/21] fs: Add generic_atomic_write_valid_size() Date: Mon, 29 Apr 2024 17:47:26 +0000 Message-Id: <20240429174746.2132161-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0019.namprd13.prod.outlook.com (2603:10b6:a03:2c0::24) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 2fbfbcf3-4c58-4f31-f6b9-08dc68748610 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: K99eoXrHtu8GM/dQZ4N0ugIJO9pvSbf0zPMgiBrluj9qjGqJhus2SJlt6pyV3fkVJ4tPdgwLtG7lDzCJBpL46t0wFqnt6Jg9AxSMf0pBWTGHkz37oZY70NScBi9bGg0g3D8G0awuD8ZEdbV7wv+2oVrV2nvRJ8IUUnh8PQGD3OHbbWDLVnon9NA7geoDvCVq39Su8KEsopvZFhW2p1zVUNAUbOCHaueXrV2ixh4QddpkgPduK44dJkF181ckql+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.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jqs6r7/eOgqb6n6nBqvWAXyRXIrO3BWMG5ksZF0ZHkzRcOCWL970nVBwbHKuM9pBFhPx6SH+Yaw5yTY+OhRfOJfohUyDOc6icKnG+iVa6pdsWvbYCj3tjKdIJu3AJtRG212dUwiFjO1rHWIKtznXJQooSg/VYXC2FCHI+GWwAISvbgzLQ4CzwUHPA7CeOrr/txjvq4J0Io+7E4ktOSqn1SmoIaQq8m260ZhjVMV7iWk3UcwGaw/vEaFv+c6XLAp2forGfsEXW0luloeEkWCpVdN/tJHEzrF+FFzARzjATR8rQOkXASMHdGy8Va3/lfwV3YDY1bznFPs+huhMhDFhK2woIqjryMNODqpN7riAO5XmdXWErb4SvIq/A5RSblFlUZRWjq1k64IOviRsB+uJBdLksYWSadhznlZ6bUvmETkz67zjhSWeL3fjayriHOcSbNNEUuVr9KvvK1+lyy9ry1aV5sUeVj/PIAvD8K4fU51e+xGxEUGlqD7BgSQHyR8e+YLtLP650s3laRFQQdZl3qIfcvn4wJX/Ej/LEUfGCBmA6Y8/QEFPg4Z7Z6yBoYeso0D+dAd9/3ts5Qae9rHogI4q8l7wv13SnTRuFrGqszwooP/8FIyHs9ss4PccanaTPyJMIPRJHXHZwL+8Cb7EAwboqNiRcvXDKr69SF76kQzZbrtxrf6kHUShLq5xcx7NfkXIZbqYuIxaKWmQ53AkaMIJ6lJJw9aj6cy/hvY752io/yxFparScfaWHSklDIlddNiD/uauBen9bNAo8hoMuUYe9ooNn+VyRgHyuSIm1QfQmAwCxRoX2WvmmZkFpVPXPUDz8cAyEelzjdErwuCOtr7cHW8rM1bEFEgUtVp8Ni/BmdgrEIC4F32mWKZP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fgtbZcRscRWz37mHzpTXMLJKtFmFa1IDq4Z335EHXOEJea0tzfRJmTJsolYRykrUZUIH23cebrAkij+zaTWkBsikLOmKKC4k5sASxoVz2U0UM1pR1ultWPsbIMsPfH2T03xaa8GyJuEUvY75uIoTZLCFP6QQMk3gKWkLsjNcuxi443BzyCrNooxdMr/6R4XCJDGA2VVuYbk7VLBW3TYCgKRVPpqVMK1GqJdwtAB9R9XP4tIOK+kqsKlcbhsJtlmrumrr2DuaJ/qhD3JgrVSJrfWllb/zGmLv1zzfG08Mtsjpklm0A6gvMCwJ2kgnCtw0H4i30ruTqiO7JwFllZC0UwstW8zNSwI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fbfbcf3-4c58-4f31-f6b9-08dc68748610 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:05.6125 (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: zTaK3K2KET+EgypJFluXHVK8BOzJ/P+kyJc6dANu0K6CDsNdf0aCop4dZGOxZk1w5UrEwC63er1+41NJfBTYwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: 3UAwMplDnlAEfmpLs6lZIu2HfnyQCLzq X-Proofpoint-ORIG-GUID: 3UAwMplDnlAEfmpLs6lZIu2HfnyQCLzq Add a generic helper for FSes to validate that an atomic write is appropriately sized (along with the other checks). Signed-off-by: John Garry --- include/linux/fs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 6ebefb079740..9bfa9b68d800 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3648,4 +3648,16 @@ bool generic_atomic_write_valid(loff_t pos, struct iov_iter *iter) return true; } +static inline +bool generic_atomic_write_valid_size(loff_t pos, struct iov_iter *iter, + unsigned int unit_min, unsigned int unit_max) +{ + size_t len = iov_iter_count(iter); + + if (len < unit_min || len > unit_max) + return false; + + return generic_atomic_write_valid(pos, iter); +} + #endif /* _LINUX_FS_H */ From patchwork Mon Apr 29 17:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647468 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 2C5DD127E2A; Mon, 29 Apr 2024 17:49:19 +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=1714412961; cv=fail; b=ciuMo4oAvebIa0/Cwk+Td0vTeVM+YT35fSzqnTuLEs9m1l2RZU1bsbtJ1nOY7S1kVxEeSeCvChIDNy4j1Dbyknb2unzJF3OJzZJmKg2F2hkF5ZDhfIIkOYo+RnxbF/fKCnlmrSMJe9LH8Un7TbL88pnQIhPPEvsBxREucG8GVpc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412961; c=relaxed/simple; bh=smjgA1lHm4sf5KhA7qhIuo+DbYCATs5kLmu6zbLk4hE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ASN0MKvsDi8jeWlgmA932ONLI3jhtjAt0XerapxCBQZvrGQriCnU2EaRimbkikKj2gRgOv4FtCIu9Gwu1+n/cbdHxUMZkdBnEWBAmSU56uLfvA0sHuxgW3+dESUIlTfnsjW+40XSGuCGN+LUwlgVJdL4+SNvQbqn82JVLMrIq3w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=eFcR4rx1; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=aib1qAId; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="eFcR4rx1"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="aib1qAId" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwkoF004986; Mon, 29 Apr 2024 17:48:25 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=kvyF5iC8aBAqSD3cqY8Xi3nCwgg/rkCiCE3eLrk74bo=; b=eFcR4rx1amFg2Y/JNXV/P1YdR8MdfzrFHGGQwv0ZyM75WWMZwLr0QAAvbiypSsAFRFAz C6sQYcVOGsymLTO3dq6XlOWMQEMsRrIOvq3u9UMDxUXn2YNrKdJeYU/g+G0blsruU/0S syEZ1OpVAY2/Vc18KaQScXznkpdUCoTeiA89vFf8u8iUSMMe8E/VxkmosDhHfWMYtGd0 /p9DtFOvqZqYpXmV29XHnhxfT27N4aM/TAvrZ+uZEw29s2WLJunATDr3z0qgPsQrk4RZ gbo9nE1tjnRo3qUmHBnDMmSxNePgKnJWtYbgWXB4K0qY/AJ1Fbm7kl+9a5ZG0j2eLsXP eg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdek6ar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:25 +0000 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 43THkxUP004324; Mon, 29 Apr 2024 17:48:25 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 3xrqtc7ns0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cM3J1jPttSF4qASYB/PKL2evvK44o399DE4/WS9UgbdMYIb4TnZLwu3NrILA4Zm1HfYbvCFdNMCg77Xc75PLQJNARVv/gEUSHO6N8hqnBEPAIyL9GGOFc0Ea2+hblQW25tVSOCILZDYPUkTQJd4ru0THCE1JDirqrkUu9wbSxx3Wq8hapODxeD9qwwRzdvAPSGTKeaKMwkjZM1AA+74Llw2G3E7SByJlC3ZQ6f4PE6c2oi+2NnfrVpYLG3Bm4SvSJ+4dx5BuzC+O+H277VbiAWHWWPOIF9UfAluiOKSmtUo/wZ+epLMBvFEPGHLuulN0xsKEJ0TRDUhD+fsuJ5SaZw== 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=kvyF5iC8aBAqSD3cqY8Xi3nCwgg/rkCiCE3eLrk74bo=; b=OPTygwt83BnYNcw6LQ8bIeTg/OkoAm+kIYJzz+piVi9q5hGHR0iUBxPOuS3miv1I5toOuW+RZPn2PYFml66oktxQgnbbxB4T8hc0Tlx8f2XsCWEhxxIvKhpcivtMehJzHa/DnGmOKm3PSRR93kmSf+xcSHjXNWoCM/QJwIyET2qOjO6eKMYowywJWB4FS8W9VUlU9Z+auzw/HC75HDLijPVlvlgPMsiqHXzve/s+vaFlcliQRx6JMRmsx718m5oqqRlhimAtF8Hsc8yKFHxSBchak958i+ZmvMOpHzDOV3aaRdt6eWBA0AudhwFKHL+9uyE+OHomeBvYVW5Lt7/bJQ== 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=kvyF5iC8aBAqSD3cqY8Xi3nCwgg/rkCiCE3eLrk74bo=; b=aib1qAIdJITi3ydjJ1mCyD3i2bztinF73raZirecNzy0fg83lV/k372IZJ8z7/zxBqFgrRzEuGiXPaX8Q6I3cg59uHQqoz2v8VHBxqKn2OIgto7UDMVeoLv3Dvr2dHmgntyA+Cv4X54FcVvksrlDQQexPzNnvUbMWmufp0TKz18= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:09 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:08 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 02/21] xfs: only allow minlen allocations when near ENOSPC Date: Mon, 29 Apr 2024 17:47:27 +0000 Message-Id: <20240429174746.2132161-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0035.namprd05.prod.outlook.com (2603:10b6:a03:33f::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 5695ba6a-0acd-47c5-801e-08dc6874878b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: Ws9quFqA6jjgDmqZLJMI/WuNOBvblnpfG/Iiddu/go5mcZhKmyqjHSmSs9up8nIaQQfqw3lxA5e4M1guIMLaTjqMvixMPgr5sZJ4adzxf2NEdquZz3s/aNwlnNR/Q+Jb3ObASmk1GF6KBPIW4kO3CS49+W7SV5IOpvFk18v7u7ZKidRaglQgwFLvt/PX9SUUlc2fNPc78T4eFzDm3boWLSQ5AbKWN8ZbTFDwEoMurTLGtPPvur7h8wztRNnVI5Nn5qUuSLJL37TUwPHvEPZAxFhRbnZx7oM4ERY3D6C6lKKInMAOKvY4Ng+o7NlzfV0vdxvfO7o13i1Zxz3geB0Kvljab/7WFCUKAf9cOB7MAbXLa8eCkpILLt9JwPs3sISM3zLxgFcQUavkoyP2ip46+HcKtHLH/q01Sf7LQ+GkBp9QUEcatQ9I2wn3zMi60iVGKLSMP5dVZO0yss6lviEpE0JxTQ33AzRL2SrD7TXb2ESZDzVHINuT3cKQj4oUVLYbuWbVKaiuKiM1POxq0VouZFlG/oFiKw33ILE+yJ/P4wdvdAPSw6jbejfljykJUV0M0CnbeoV2IPoA+nwpK9g7wNQ9fzvS/nSRltpd+2QfdHN4NWS9XfTRDpj9MeajAWlbVSoU5o7qFO2KTmQji3GsUGdIrPUu4c9WNNEEIzWkEoE2613wko6lsHuyIngdE187g0vEqOULKGl0Gnre08hqYCFfTEj1oBp7qW8vQRJK0yb4U/PR01ISHNh5fxSQZ3sPZL0qEjx4Ft3E3ymJY1xyPBkKAWglMR4vwESpuP8Zgearq2OnwowR9cZUfTgDBmmwbMl3kiK+ca39WwMvFEI4GLcYrS8ToHRQHmKD4C0boWnYfx+iXMFxlvCmvZlVrB//5vHQ63l+8sy+TUiFDQNH6i+Jd9aaM3tvCvFD5pTXAF/SzvknvtJCXMRjeUsyzn/MlyVXzWJFr1Yd+ygRlSeileGto6iuZkl8B6R7tNn16hAC4lx1SgetAhF76D7qVYKYC5HPbn/jCh4I44IgQyJvexPuoehULBCj9h5bPg4X/Y54UdVUmDOdgq7bSXOCWu4vQaUe23sFByLfUf+3EyeswEW68TUr5zLiHWb3JtMkrZ6gbjrzta/Y5KS/B0tiVBxrolX4fV/0RcvNgGfe8qIgqvXQ0HgLzJ3u/RYpLiAjveZZVcAXTJSwfn8JG5Yn8mdGwd0QCKIYC7zy0r1JVmv8eJrhn3eRVGIIeBOao+5/OwKtCzlDp7T3GQQHt7UFAxPW0QYGVfew56u8ATvS7VDfvQ== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IvxQOzEwaPNQCEyOcu1rMhmOQLtw4VtjLDnEXf8cZ8lmr9qFz/u/Njz9AFkOeh7raHCpk22V+P0A9JNKu0eAl97Tjwcptqxa2AKej2ShtB/YikzpFbjuMloG6FuV+jZMwLk/PVYEuyfGGLH/cLm0ljsZvwogS9JtwDJiolaLP1/fIPG88Mc0PvLggjtnw7YaQZ92uqPK40zIr+TQFKzfif380tZiD/Llq2q88JS7YJwt6VOemSO8j3iqezahvhMEejGjXUmHr+m86YORh8Lh+daCPBxClv4EUqVBCFKCqKp7cF1qgDZmrpOA/dn66E3nzHpVhUE/mjeTu9isCTkSuopkLVljMDsgU+o9FehF7VPcJUxBgGUCua+sX6n8JSSqRayhc5HQSDvHWNt4BgyN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kLWL96VjusPNwJg7iLU81SCpIOQqVrHNO2zX5zfKMh6BhpOEVL0pZ6eXYHS62/OwDpZbUoGpSyMlQLwL16sy7ToMc3SjqQ3f/2w9UQ5PEuDUalbPGocbcb0k3JH0SlEsLU07eTxCnAc5Vi7PNXw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 06yQTTTK35zo4E8pYJIeefBfPLVBv0cGaZ6x6lYc+D0pNift7os+rQLHSS1gyfYsr7hWA1ja/yM8Jqne5QXZVYMzR7DEJV4n943V7OY0xFCffRCmPflp8Oi8ombkfhn4XV91rQeFDtndguaGRKGYsxX5qJlWg1ufr08Rh2Tl/ypV8XUjgdDyPYMYY4YA6rtLLcajaXQx6s+UUrAhVT2wuiA28CU72me623JKnbu1bEr5dyfDS5nAymPHkeTFytuXcEWefmBAKOvejBJ0dQjPbrm+Sz/MGjWqDzRNgff6RMcxTJx9oeXLVQ3g418w9a1L9+xBu7pBQEUBFvfXqHTzhFStjsohK94mRbZwjr9HinF2vdno+4yEGCT1tEne4zsOwU2vAWGIt6d9Rg6f2bkb9QzSNBf8uHznq1XJeBKYu6lA/Zs3uk7qno5xVWhe4VtnXGierIOG8zWA6ReIzTQHKTilMCVm8uIsiov5CqIov0GH1VNQ49aiptpNjCq2QcA0Q1/Og9sTMcZnbq32lC/Nij2KWlX6AEPdZr5j+ZhoFig7Li/nkZQqhBoIXNMJW/Nl6pdQBSUKPdEsguWiQB12tBQhCN4AJNpI7eKJQOEDqUw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5695ba6a-0acd-47c5-801e-08dc6874878b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:08.0631 (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: WhTSKpt8dpucyr6L0Ul/NlyaOKWoqVfb6xn7zp7L9c0E1+1b1Q57yE7bhyQV1jv5/Cr1dNFb07pcIb+Bke+tbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: qfILHBm8c47S2YHnTktK-CgH_3UH8vAg X-Proofpoint-ORIG-GUID: qfILHBm8c47S2YHnTktK-CgH_3UH8vAg 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 9da52e92172a..215265e0f68f 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2411,14 +2411,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 Mon Apr 29 17:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647472 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 D814112BE93; Mon, 29 Apr 2024 17:49:44 +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=1714412986; cv=fail; b=PWipVrVQjjK3u7AUbFShzkE4bPF5r9wqP6XqnunhXStTS3OAaANf09Azky03xVXuEPVBgbhp1toymFWLLJ5fKsYRTkM8hKO7uSjOrC/lc0nDS5jM0dh+HqeObNuZn863MemGGiexRS0SzwcjbmlFHiFWmuSDo+gUejkXaHTw798= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412986; c=relaxed/simple; bh=87VaBi2mzOZ/LRfQ2M+vyZC8Fr4MLP2IC3Jnq3BTyg0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IRtUc1zuS39FbSHVTg5/uVop9OrOW5y58ETrZAdnH98DUdu3hFv0r8Sre+hYenEvSx+yIuIPG59C24yuECdEArO0k/VKfAP5GuAvaeLOa6aYr3EP0AjHYIKas6vZ6+gQRPp8u4boQd3AqAbvxSJx/5dTRF682eOt2oIH1NLUzDk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=h7C65GK7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=AwvBgWN7; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="h7C65GK7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="AwvBgWN7" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxZ3f008529; Mon, 29 Apr 2024 17:48:27 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=v8sKAym2FR1+PywaOrvdp8qefz7dyIVZOstdXk+Mx9g=; b=h7C65GK7AYz1crVqTi4snO1P4GedjvesCqht1Dfif7jm8nVQ1HOcWNGf/4XXgazaDgLI ktBi3sV57RaiS+5YTcrpdTIsgWOA+ruXCcrlH3cR6dc0+lg6iZx7orVMmfFEvVs6BHMl 3S96QSemolxGkjc5+0sCJ1fxKYPAXcEu7U8jklllr/lxDcj6iMwusFXEK5K/vJ8q27Eu Nf0rNboP3qc+wVefcsT8OUP7U4OEQefJ9oVRaRyIAq6WyNxVs+voRHGgxR0Xe7uMlRJj jJ7XIBmNGFUi/uqp4r3VgBTfHHW6LldAwvdqjgusCx9nyrEPugL1jfuqKUz1S/GkF/8c WA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr9ck8xj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:27 +0000 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 43THkxUQ004324; Mon, 29 Apr 2024 17:48:25 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 3xrqtc7ns0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mly8092TAgQj7gZ/820KdCnPCrL1gPLOhduHYA4sW8tqbR9c1I+04ljTZqIOR35c30Mlh9ydKD/EFLicQUOpSP+KsJJxV4O0ZeIMF1b24zMddd/o1z2wlwUuyH7+xYhffM9b+7BlG811+EEaNjzikT69rvVSxe3CL2EDXn2Su+Y00mQ6Fttne0c0CGfBySTeDYNqr7VmLV5Wjvdgfcdb47o0p7wHtnSad2jErGAwug4YVY8r+rUNmEgupkblq1wawLRCJ0s0IUS8QYjlBDZLS+JUEFw14hH2772Y6MF6sydZq7f+lAOrTFP+dDTFBSaLfr6/xcRTy3yn4mOwRr1wdw== 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=v8sKAym2FR1+PywaOrvdp8qefz7dyIVZOstdXk+Mx9g=; b=lyXW1jt0SPRICl8Pyrvn3opagInGGQhcM+0AZjXGkKuBhLrEaz/DS6B0g8DuTql3qLXswDDm/NoAlf3SRs/tMP3FGcpxI+U0WPqzarOz/gZ6ARkbYTkSj3OoooThWjlHEjlQrmlaK+G5oJOF7F+PbDsq79gj3ssIAomiggPPmmbQ7ZW0HnqJTWrR7Sy8wSvraXJCHrsSjY3L19peGm5Y0spo4tTFgq30BB1g8boe3ufD7o5L8kB9ajV6Hg5TJB6dlIx4eVWCzdDc/oGYJJzzVKX7OqsVJII7jb3GdSfkhG3fOoYKOI/NQobdmAY3MCriEetfmCT5dqAUau7pcMUPsw== 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=v8sKAym2FR1+PywaOrvdp8qefz7dyIVZOstdXk+Mx9g=; b=AwvBgWN7wlKM6Z0gyO/E5i790HkeorOBG0YFJLeeUqYz/Ey0Vk/FcXfyRDa8VGmY/0Ax3dxFENlJO/nbzQqNTCrGJspqd7nzhv5G3zkenzWEu+JpUVSdV96ASkCt5SVjlZWrXKL4yStTGQBSisjFROHeeHtVzvi+IZDL+Ow6W8I= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:10 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:10 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 03/21] xfs: always tail align maxlen allocations Date: Mon, 29 Apr 2024 17:47:28 +0000 Message-Id: <20240429174746.2132161-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e4398b3-6973-4c29-1ade-08dc687488f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: BZQiT9TCZqaoDkybxYdj9ZR9OqKAtoq+3TTKGB/H+hKEOqBeYLXMLZVkD338wMUIwzOLssjFdh7NXCp26Qqe+2M54q060rnfyy5RWvIJRM9mN7mU1GbwNnxKWNhXBFL/4q05pkcQLIMIsrIWXevkNS0cagK9JoyfVeK/4GqlbgKVeDIBMts/peBHcT6rmoMY5ux1A8y47+ollbibVMgsp7nNDbJVxIaTIZbBv6hUEOs2ny8pS3GklcS5VE4XSSFG4DiApxWEm9WCq3tpoALddq+PHhSLix+pTnd1C2L+Jy8/RAzewjNwwmPrdhloh1TscUy6dN0miNyDobQ35I/CklTNp4JhlsgxhZqlSoK1QyWbjB7eMy2FrTO3+ydUbbEu8DF2SKkqYiwm6VHP59kBIFz9/ruJLLB7i/buFO97FWWLplzBHeK2OC2lIccuvrmrGfV3yFUfhPTLQIlxsCinrDjB89Y/d5Z5LVH/m3a2TNamTx5IBfSoKY/GFYOJsCaAurz+kYtp1iTWnoLJC/z8RSfpMHmISMFyJyEpd1J2wXKSi09l6jX7iNYwd0xlsbnBPylk0TNbVYT5MvJFyTSKxASdcSksGBMgQqC7QZ0JMkEyVcI1zZ14lk9+MVJSW+SOAOyM92O9/KaIARxyqbKsmLFm/bp7/ylEQlMFHLmvbEu5fV5QCZla1v9TsBWdKtOJWfIAXasDR4u4JJq9wUu0QnaTGLJ9Re1J2cqKyJW7KSCjmZQpw0O1kao6lLT+PMr50G6slwcCwfuMNNN64vV2LTO9MVN7z0fkQHkzBbeADHyJK3tfTnR97SoXSuTjhGKnZLfSnD8nN1x4v1e/l6uYoY+PHZ5BscSpanbjwlr8Eg0x8WGFJw6fKHI0bBXNLJmyPC3Sz6eJfEMadSWcS3ZnRsBf3vfRw/sBk3sZ2mPZ8qjKDrc98v3j397D8vPy3DN61qlpUUKSyN+5qIQAdjHa3rauHPYGo2PXvF+pgzP+Hsrfn52H3+wJErYrVD6ocVl9zaK7XENCWnlG4b58qG1H3dvlORCIAmmRuNEbgVU9ENejl0KXqLjEGXHFkRAWlyHX1Ey9Ttc2c8YSK8BLLlX/PZ6zh5y5y4EhBFFy6wl3ykOJB27+CXwToxQ/bYIFXKJ4klN4qNzMQXxc4BJ/SfMmTcRe61L9vRjL6g9cf7L6WsLsTGZhBzCJqxLe7j1OYG9hB1Crx5/4e0aBkYKnQc2Ssrn9M0/TH2uKzBgokJuchcSdBqvB5xBhemOSUAVtb25FEq9n4/DZY+9UfyhftIaf9Q== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KGu8zpbk2ZZfckkC3ndY48sO66rrUfAu+sw/5XF61ZPUdpm7u/Z38jWHAb88hcf5Lgb0xp4m+raPdjo/Y8b3InIrtLRw7IsJmD5Re7Bb+d6OdJiX52dx1k7k9rEpdXp6bvea4TjsBUANBPdpDjPpCpjGGz5rrt3OJ3SpJJuTDWGC9F8VgFXHRmM4naaAkMYQyhlk6F1GLcCC2iBX4KWQSnjvu+tSKDDp1uxClDp0a2aM67XoZKE2KzPA0hDTEJ5qkiL6NTm8rrkqg53jqnIMKfRYjRSe5Wnh2b68or32mOgs50T0Q438G4+Rz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qXaT61x3F/mx6OJUKN9OBq50bJEM7+hwn/gRy4RW55HvsqYf99tytFksq4/vGn/mt6hu5TDkqGocTf3hABPUqmd0Si+XdyqOKTsDhrQNq+LfFYgPFMzwpDGCfgZXLFf5SHc7RwZhC2ntg9SfCNTCIGyQx/sxJKMAtWpgFdTrw88wVAi9Iv9DbLla3Z/uULGUs/+vHx8MfvBwyqRlORgR2OQUrGyySPFCFpNPOG//1bZfAtL6Nw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: k3RyW7BInsIqAiD4m3NC9ex6ziisKNUpQOw25w16mv9kT/t2qnhUDuFceMxgsAFYc4RpETy9mfGCfnovbGS7twA4PaF648xspYOz2nDrw4dzuSx0hyRW40ppdKmAcJOoWQHyjUMoP86dy/LG+JMrYNc9prp0Eyap+yOOJil6GBwqTXXrNXhbWFQJLoww1y4dgGp8C4veY+EYB99eihBG5/t8bsIhjJwCKz2O3WQCbvUGzfe1hHCPHP/5XeL/wYWHm6uEjxMlebbiKwLpZJPHabFPK3JO2HlwwYwjMykCrHAkulbeLpW9Rvj88T7TR6bp3S0JMXteI8LC3wRGVZMlgEk8pXepqv4HKM9Z6PCehDEtd1Hr24eLEzf3RGHUPBClugKxiuTzbc24xASgv/cN4fuX41tTIOeMfGVfl5lIfrF+qMqLNorRpy1LawnqUdRSp3ThC26Nc4xKaoS4gXaSOUi+Qr5vm8hppUtwD1hxjwqjA9ysP2ehXHh2qzXvoezyjWC3IAEGoFRZ+f5rEAIoyTHClFZgKe+e4zSlJ4GJJpCYNllpgWBkRg2c1EJ5XUhATZNvN4VxpHYvj0fvqVI0viZ3F7uT7reUUuqlJvsJKS0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e4398b3-6973-4c29-1ade-08dc687488f4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:10.3948 (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: HYmB/HfyQH0NBE/dbd/Ont/ruCHGai6OPYjZuflaPXEVNS1f4kj626GSIMt/FI0olAa+zOkolmQTALC83yLuJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: QOPvHHvD4lejHF6_XX_IolkHdF64Q2H9 X-Proofpoint-ORIG-GUID: QOPvHHvD4lejHF6_XX_IolkHdF64Q2H9 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 e 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 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 215265e0f68f..e21fd5c1f802 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -432,20 +432,18 @@ xfs_alloc_compute_diff( * Fix up the length, based on mod and prod. * len should be k * prod + mod for some k. * If len is too small it is returned unchanged. - * If len hits maxlen it is left alone. */ -STATIC void +static void xfs_alloc_fix_len( - xfs_alloc_arg_t *args) /* allocation argument structure */ + struct xfs_alloc_arg *args) { - xfs_extlen_t k; - xfs_extlen_t rlen; + xfs_extlen_t k; + xfs_extlen_t rlen = args->len; ASSERT(args->mod < args->prod); - rlen = args->len; ASSERT(rlen >= args->minlen); ASSERT(rlen <= args->maxlen); - if (args->prod <= 1 || rlen < args->mod || rlen == args->maxlen || + if (args->prod <= 1 || rlen < args->mod || (args->mod == 0 && rlen < args->prod)) return; k = rlen % args->prod; From patchwork Mon Apr 29 17:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647476 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 4DAB1129E8F; Mon, 29 Apr 2024 17:50:25 +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=1714413027; cv=fail; b=bEM6t6zRiuVuoJnGhmZi1shj6W6R3BMN5yor2gok3lwH+UGV8qusgPiuuRYTX9ksaVht4APu7hHs3CppjPNzhd/DYWKVILAoYvXKt2On06vc95b/iqo8UGnUZBaQXU1BSyGIlW7RV+NUc5857PEjAyEtM7pDRFkolXOCeGQGDz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413027; c=relaxed/simple; bh=VCPkpAEQjz8u8EgR6KUyGxQAA3+mxbDUFf+1SHWJ4Ik=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DkqjwD+RDtgGIkslk29k1PgCBJkWPit0rfscAzuSoYmCTC9BT5XZzpVzfw5DiCjYQkq9PwH6i7GJhAFaV0iVqWWbXGLvghIJSslo4/LbPQGrT3ovBbokc/04SpMeqfmsuYZfqfV239G4eBjU/oM8OOXMWOfqfQE6PTQWbF9mK3Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=NhLFB8eY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=N4HVY+bu; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="NhLFB8eY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="N4HVY+bu" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwu8W030178; Mon, 29 Apr 2024 17:48:27 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=OHzS2fYFc0bOcvih7E1zlHuMxQTCpvNo8lJ07t9uTec=; b=NhLFB8eY/boS9gOWkCV4+BAFYj0AX4yZzKwY/oHU/4zPbc4tdUsqb3s61D5K38GZy3H/ 6vxMIa7KazegvbCVk1RJFLtheeOE3MjAsq0nU+3mNr+QjapeZelr8nHVBmPJA3HMVOj2 b2EeqVl80nZGdfJyqZ1f7rgEsh2VWXG9PZOdQ4QFhwgnYLvtsr3sjfywRxBMQ6Dipqmy P/ZSv3ySdk+EwgKqUvs55Tkq0EQgHZ4E8zEU2EejhEF+scFYMpVlKShJIxcJfZJI1kkP bp+P0CXJqLimvao5Fsbowy5XHvEUVKclIKZ9pRTvkgQTc7/XgKaTRLObpLtY0HoQhqeM EA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrryv365x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:27 +0000 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 43THkxUS004324; Mon, 29 Apr 2024 17:48:26 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 3xrqtc7ns0-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pc288GFFDl7jzMDYmfID9NZ/ZxZdXLAOe1t0qJ9CN6wyjGCnzCAE8O1roYtG3VZXxwMsrFGvL4qlctEJsRqm/2G/3rCGkCWt0fiGKuMSd2NwX4W8kI0rCm17kvCiV6kUCJiTrA/zChGdH1XSGvk8xcczPvOc1HrOcamtsdgNhM+zrfYlaCNHa7dUnO5gnnnxxNcEP6EyUNk1wihp5fWLoaFYsRmNuluHT/bEMU816gj7G1GJwThoHw9Xt54i8kgwOuDyED+jcg1sZ9WXHUWdDdlDGwnw5mTSm4ux3+aHLGXPRuQpt0srCAn55jN6RpP1K/vO/1YG8IqXjSPrUZSoKQ== 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=OHzS2fYFc0bOcvih7E1zlHuMxQTCpvNo8lJ07t9uTec=; b=Aoy9TrC9g+BcJ/XwEFXXDDBw0+rkgtO5MS7+eDp0Q2UlmBSPzUJo0jzJJiEIS1EvARrxoN0vKk9AU0JQ9Yk1vPxInCXcT7n9EgFLPJOW13arlL5T125CdEqa3d8YmaV9nLO77f44sWAvmtYRU57fialXOVThyga1DRZeruzSbfYl7HcjQqEW0pYuhOgfOEJCsL+jzsF5FECn2PwwRBjbCSp9ZPxTF9IuEHcQ5+DOTGgakBAYzoozDq+29SzZU9AHvpfzwkbn8i/OD/Zmr8DWFmB3xOjCiSbSMeht/7/Pmu06Fp2qMdzztyS8tTEojJ7PQr2KwhUN+OWrFiJ5zoe1iQ== 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=OHzS2fYFc0bOcvih7E1zlHuMxQTCpvNo8lJ07t9uTec=; b=N4HVY+bueJSh6/2n4dpmVOm2cGCtXONjI97b6pa4b/vYbi16CU82PUWvP7GiSAXeONBqRo6hoBZ09W4lBezEXUJVnggoe8lOH/7RM5LeYeOEadsog1PrIm+XoCA88WHvklI9X1WO9xYTYeEm4Wn4tJLVEfh4Cyiq4XEU/1fnb2Y= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:13 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:13 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 04/21] xfs: simplify extent allocation alignment Date: Mon, 29 Apr 2024 17:47:29 +0000 Message-Id: <20240429174746.2132161-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0055.namprd05.prod.outlook.com (2603:10b6:a03:33f::30) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 3263eb56-8d38-4977-17fe-08dc68748a75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: vKpGhRnGEKmHHocWMzFdzvdYSsjYNp88CesIj+cwXEdFI7WdyepKKMVOtYosUbNm3DCEvdJhKNTFM9bQoKbkFe5swz7cL8MjjSACQfIesqGYe3DdZ6HgJDS0vBMD/4wksFcUwZkNOBsl4O94JQfvFQHF1oR0/ruqso+rcOPa7o0wvVdhjVk0iCDauaS87UhxYUvaFXsIFRpLDBu671y9Xu+edJmWJEDermkyZJeBISZsz3ZqJI+pv/uS95dTXZL9I0oEBB5ApHVXqxMgWaJKdYG0NgEq26ZipceNcpnES6e9YixF1hsjIXQELK0qdDsA4N6oa1WYbdoeYRNKECSdJ9hNKt7lpDXxhugWtZeDkMujbnmC9EliuXDtnW7wy2iP0n0ZU3S6yHlN5b7C8EVhYrhr0ErUqWfJ5l5KtOVe1h6QO518TxVuJ9ErMekJPiQVd2GYeziwLOVx27L2Z2b3j2KsGZPK4lU4DSMk/bHngelMzGQxlIBXNUEmOYfbSTu5/7LKKseUqZ3RlyQ84wmIl9zEOhCDBApjKQPmTCmZOHSidYyg51dvp0UOMvxlfcdxThvOSrPshP+oz0869aA3TXJJnBoNx5xNHG7AxDbxWCSvHPFiuqrTe1fnK0Ljd1py/oMyKEuJ5JADpKMMUBdzPpTQQ9SWoAXEHn4F9HkoZoiu/sHDHOb831URS7M8PuVcGS35zb81YGiEmL29sJv2BSWfQ3SD6EUViHd8VHQKwRY5n/gEHL/x6lUMWpE1jRiBui825aN+fyYz0dCsN+1BOeAraTh7ni7HuL0MXyPweT7nPO0fFNTepsV9YxCYUc+e6k7CMSfa7ZJQS6FtfbMwZ2opeGCyTVjFgwV4dtM5e50KwrKBl+JatpkWym5spjf64N8Lu0cx1zpsWQbR0MfkjslYhzwrBByk4RwVl0T6pyD7+TOkgkfIAXTfPSyGMdnVkAxejuFwtkyz91nkDTscHMtjHLPiaOFsCdJ0WZaJDBo8by+4TAAdERF5LlKmeDy2kUfDZlrjEtGwpiNgIMA4poMo6ANNxiLszQzYyBNGynjvoMtlL1b8+zp9UDC9EM9jG7QEbbvU9/Bt6oLC1upPTRpeiIctlvIDGv42iQLm1u6iaSyyoEvUnJqrsgUya2d2BUUhhwVa0pJXlsyLOnp7v3j/pNVaD288ZbR1ogjO5xU7eNKQ6i44YTHwhHqYG5+/4ksdBjgjedGXy4UTIjHtByr5xXjD+IXAZpNh3x5TN83CWo2QI1eITTbGBgurZzjAvPpMB7lYVA5jvEwbxowWSQ== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kjwVhF1Ix75EHdombCV8HA7MEElN8iCEtbLrbUZMIHDLqHf/T51o5XOY2hRsOG2Y71u7S5tzlKtkSgUnJLVt9r6GvwKBQ80uaOqJZkS6QNAmFhkZGdvyZvJpD5kYMdGH19KTHAmfn+oJSG2s57d6OuuTDmZ2/raWSLGHBvqG+jj1FTBtN8YtLR46et2CPH6jlbnkspM2axhZhIturjfQnj8FR4nntCEtkARgC2saqHnXEGccaZbBsO8uYEw6afSipTrSIwPilcNDj7QYiMOp6TFFIXSK1iWKmymsLmGXHkXXPswfeon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IMfijWCXr4EfOEmCTndHQZ4MG2GziU3W1VkSVrucs+qeferGjDPsTOQddq9qmu/088x86R3VukgBqi2xLjxYV+YePgsd7tOPUo1F0J+gGQ0rmdeBS275HL608nknTo3zMJCn1KSBnSFgWfyZRodzm7rDSGVDpKMMdiaZClmzZhfri/tWqVPGhfQW7Xwv2dnJjazrGvghpKLbZVNSZuz4W/aIVG4FNMtwA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bbOX93HhsGkcrj0ITYvs0aHrZM4quzNjN1n+Ku2X/rV1DOQFMN36Smivlf1qTbW8x7j+Yjr8EBVALq/h/pYQZhGOikxvj7X44iv+YpGsff+757cul6QhRUvh7o7kLZqqadwzZp62Uef7SQ1z4J0Cz9T/XHIeDmQhHEACxbkmD8HRFh/llZXV6In5yaVIHXWVl1Q6Gh2TQzG1U0bw68ZZfVdrSHNFNVspFrNG4HcYCwdGDimuFEL4GRE0yIvwY7iSyZOmMAGT3Sv1ZGevW9y0MBSFB2Zo8Uu/e2A9So9IG+LhrXHdwAbxGrMar+CbjQTpcztK2a9kNIh0V3M19dqEIl7iWZqhKeY2SPDLX6D7iSnoaBZXY2kiSd9n4vWKi5IZ6qIrb4qceBUCDkCFDYCbPq/8P9oWVU4OODXhFgnpcoaxQuBrtkVZZG4e33gBVrse5MekvmD/l0eHUlqWLbo+JEn+R897dvTUxRR9Aaytsrgj+tRb/hI/tlAavE/V0A74ihgYE+USbKTPcgWGEPD4TPQ+lXhNsVWdq2FEg3uSS2QJCaJj1SwN+ufzKu2J5S2rr7Axl6kkI+lrGh65nKXMvMd4cfLWTZNd7S80HV7us+g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3263eb56-8d38-4977-17fe-08dc68748a75 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:12.9903 (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: jbk4OEA70MNOSOS88qQRYTcJ48GW6O7N3Cpp52r45cRQgc/3NouqEwVRJLcQX1yce3NaXlpjb7hy8MO5BLn9Ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: gy9Gpf2Hf4EckUf0FfDzAk-Kgumks-Yn X-Proofpoint-ORIG-GUID: gy9Gpf2Hf4EckUf0FfDzAk-Kgumks-Yn From: Dave Chinner We currently align extent allocation to stripe unit or stripe width. That is specified by an external parameter to the allocation code, which then manipulates the xfs_alloc_args alignment configuration in interesting ways. The args->alignment field specifies extent start alignment, but because we may be attempting non-aligned allocation first there are also slop variables that allow for those allocation attempts to account for aligned allocation if they fail. This gets much more complex as we introduce forced allocation alignment, where extent size hints are used to generate the extent start alignment. extent size hints currently only affect extent lengths (via args->prod and args->mod) and so with this change we will have two different start alignment conditions. Avoid this complexity by always using args->alignment to indicate extent start alignment, and always using args->prod/mod to indicate extent length adjustment. Signed-off-by: Dave Chinner jpg: fixup alignslop references in xfs_trace.h and xfs_ialloc.c Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.c | 4 +- fs/xfs/libxfs/xfs_alloc.h | 2 +- fs/xfs/libxfs/xfs_bmap.c | 96 +++++++++++++++++--------------------- fs/xfs/libxfs/xfs_ialloc.c | 10 ++-- fs/xfs/xfs_trace.h | 8 ++-- 5 files changed, 54 insertions(+), 66 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index e21fd5c1f802..563599e956a6 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2393,7 +2393,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; @@ -2422,7 +2422,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 0b956f8b9d5a..aa2c103d98f0 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 656c95a22f2e..d56c82c07505 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3295,6 +3295,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. @@ -3310,6 +3314,7 @@ xfs_bmap_select_minlen( if (blen < args->maxlen) return blen; return args->maxlen; + } static int @@ -3403,35 +3408,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) @@ -3446,7 +3459,6 @@ xfs_bmap_compute_alignments( args->mod = args->prod - args->mod; } - return stripe_align; } static void @@ -3518,7 +3530,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; @@ -3558,7 +3570,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; @@ -3572,23 +3583,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 alignemnt 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)); @@ -3606,19 +3609,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) { @@ -3636,9 +3628,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; @@ -3646,7 +3637,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. * @@ -3663,6 +3656,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); @@ -3682,13 +3676,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; @@ -3707,8 +3699,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); @@ -3732,8 +3723,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; @@ -3757,8 +3747,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; } @@ -3785,27 +3774,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 e5ac3e5430c4..164b6dcdbb44 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 aea97fc074f8..14679d64558a 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1800,7 +1800,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) @@ -1819,7 +1819,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; @@ -1828,7 +1828,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), @@ -1841,7 +1841,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 Mon Apr 29 17:47:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647469 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 9820F1292DC; Mon, 29 Apr 2024 17:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412969; cv=fail; b=pzcO37zCxjuh0gxtBIpihgcGj18NeoGOBZJ/wl34DgKug/Q+G1grrbOJo/esDYVlPwGOMTGP1GU3Q2/5IIYV06TpIYBXo8JBxjakgJtEs39D5b9bjOoDp9Crq56aYIgUACe2cBxHo68l/4PrxFTItDYuKGLrcGXgcBL7sUSos3M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412969; c=relaxed/simple; bh=0WZ139grn3c2NSb5G2oObtKn5U2rJXKAgC49Le+Q5Bo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=L+MYdQhWE2ak+H7UyiFwt/u45wnH0lGMtWBpolfGw4bquFtjkBfUfyUjs2MgX8P9Ff7L2afLosAif00R9xlWTqUsihYqxK8BtGCNqFFE/A5FS117+EN8FCU/+nPXdbJwdMRYtS9Ue4UZ73nzPt6VpXDvenc3XcLgOySzXaBam2A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=lCFt/uYr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=d8bBaizj; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="lCFt/uYr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="d8bBaizj" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxZ3g008529; Mon, 29 Apr 2024 17:48:29 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=bQca/KQRMd05SKmt7x3nXh2+RrWgjSRx4vJxErKEjkw=; b=lCFt/uYrxscEkyYGAGJ1xC5rMdepnDuEdONaiVDsQsgS6MAcob4IXiVsVjHuxpK7ogxF rTL3c2arNfH6zdyAbpD3blnU985SWlAuuH9Ldpvu5Ynpf4TDcHXGDuxMMgImxI8bdStQ ly37rXlaSbv+OblXwA5SsZsX2yOdjI2o9/HWQpLrS9aO5iWFog6cUfmWWP3QYOQZMMLl PjrHPjuXhXYlsw2HBGinpxm186DQlDkAuKvniQM3hnp+H5jVs4PElBkh/3Ge3Ed5yfFs UH2AvnTAkatAtudf+Mf70FlnWYYXUM7ktEJlGR9TyoduQFFmCk14Vm1R2Xq1OITizazP Bg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr9ck8xr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:28 +0000 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 43THkxUT004324; Mon, 29 Apr 2024 17:48:27 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 3xrqtc7ns0-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QNzhdnqXyhMEWtjFWHDD7iJ62Xhe+c/tDLYJBm//L4sJvpa5UD2jbRXso0VrohdBTzx8/19scNq3dTZUqHtrw1H7CKrIjgydD3RxG6vY/OO4ERYUHJ5urT2pTPfDeJ/LeGy88Ypl9jC7cGqJ1nsXCwW4JcZorFPtSVLMf+ouPgBPG2FOxMUeg1SJ7IsIFy74DoiaByDEAS7u70ITSkL+iDpf2LHzkyLN/NML/m2yNUE00hc+7ETRmqAbzdZl/022rrf7NVsV81dNeSWLnSNfh3IhHv7duSj7bC8eX4Qyt2Zm4WPpLwRZKWE8zFHFOEyHfLCmWLTbdFoYKGyU9Q03JQ== 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=bQca/KQRMd05SKmt7x3nXh2+RrWgjSRx4vJxErKEjkw=; b=F4XJXHsd2lKcu/2l1h1/fHFc3ryrmPWJXR4+2nSLTv4swQ/3/ntEpMeRI63jCSYek4xsSN020Y2zDSw2fR/+wgxeGW3xhCfxfXBpp6nB2HwgwBOwB6uqrZavuBUI644S8HmOMIfY2NQX+c+bOOcZVe8taIP9hJbb7Syn9uqoBG7HH1SbB4aK50jOhcK+3TDbFGgS366+4NCE5wFpijzImTYQ2/qcFAR4Ue/2h+repsEUQ9oGw325aJXuALxXotbnXBI94EHwgoJXi9o0uc+//uIYZTlcZKtD4M+9VW9XTqt0Sj//FHuixq/RtSINlLc3hriD+7PZDhZ1XAWi+xb8xQ== 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=bQca/KQRMd05SKmt7x3nXh2+RrWgjSRx4vJxErKEjkw=; b=d8bBaizjIQvb7+rN2FtHRd543eGEwxIhXi8AqiZko52r7j/RDNRsrBe9V6IJWuLAxUT1+/BewylGYbB+OXDAj9JNR7NRSgyy9pAgfEt8epqKaaFEk/k/rQqWoajuy3F7eEG7iyDBi6XwssSJBNl16Q4wlCWYcGXgyCvF/RA8IOw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:16 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:15 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 05/21] xfs: make EOF allocation simpler Date: Mon, 29 Apr 2024 17:47:30 +0000 Message-Id: <20240429174746.2132161-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::22) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: aed19173-942c-4a2e-4c2b-08dc68748be1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: vnbfYk5C+TC4mE9gf9yBCsx5wxWqwCprReXrY/xrAVxiK4eKIQ9eH1oO5tTZJv9F11mabN+2npavtY3uT6rd+hwN/J8E9CGiVWSj69dbfC9n99if7UaMKrtdkTBk10+QDssa4fwUCHYRDTOeEfMZGjk6m8UvUZDX8qVh3Lfg8396jguZiYxDInqrRn0SY+GEX9lk0TasxFL5ucFofGaRYLQQAiCq0GH/tA+tkDV9oFNjNeDZlQT3VSxKe9BDrXtIN1gFBP/KYp5VTQOesBG8jSwkLyfo5a6tGw7F1YadmGhcXU6l1HB130ZTcz5oYIhvvtNGgdLOSbX7j8EUvfmn6aAyi2vvNTozGwVJwVwSFwKBBjLSBLIpukUiJxxzNR6N3yWHd/UnUjAb7CQHZaP+PJpnUl4hFd7qIBGqRwTBFaf6JXPaPMirHtwvWNqAD1fL3hffUU8MLfxnCUmwJ0MFCyDESPo0YNKRdZYE8MUCXAAu5aaf9/XhI/vUZEBLPBAEJP13EXbuZgd4yEnWjSQL1iia7x2sdeCa3DtOO7ztFCwZG5hUocUyjJSl/QqFPT4yMwAro6cJzt/bLt1erVShjwM8IdllcydcmLDyd3Mn/2YZurAITFx9cpNE/lK/9OJte6pxJHg0DlaYLOoE4JLxj732VjSgrmfDJkbAwgFFQiB6Qqa0T1zHJqz3LDS4tvQaneF1jSnmXqTMO4VlzZDGA9G7KqgcwGw8TlRhfcdLUL8RwwJxImVSzb4VFse3O0vK1K34WgRKIqnMVYmLPRMC5ye06K1XuNSOnHaJnghTd9PjcfUs3GhY2bG6h3jaRhL2GtQleWN0S3heGKKc3j1ZI0gEfrNix+ZJNyYF6OcfUoHH/tgfgWYeeFa6F0rw0DrO5mP/RaJhMtyGKBi0xvJ7mZAqi+amQtqmqIwexLKP3cwzimTnExpDWhVzqEq9LhXPRy06EVsfLtJcT9i5B0fwibWVKEnS5mpGVN2RzSR10FxuBQLfgcin3fz+SWeZZABxTcXEosvFF8olDUdqWogYsppyZMwn6DGQo49mcA8ECIFIVkNCLmhA2yhSrmaVef5F5fQJnANXBKgfbd5ND5xL1ubdweKZC8yTCdR32Va19jv/CfyDIL+N7+4/EKIYyTolOjbnrJuUZTLaezIjHNNxYS1kIkh8qQ9WFkbZlhDL6P8NV7y6ieNFX+rEZDTYnzZvK7DO+2QJkzblkVjvUmhdeV9SvRyjAZ0AsuOX8Jwo6Xn/sUgPexb2Y6pPA9OWz7VBuu9z4jJl69Cq4puq070+lg== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w/2ogVyCLEUscD4tl8LAkkOqM2zWKFUa+zejva/dvVaKxdDn3J3EEiuTkPBb0zVYm6hRr4Uwqm/GmX9V5iPt9zqieT0KNdlsUqRabL8oUrlx4373teMgSyeZ31U/DbxoC+ViSnwCK/MRQ6tzrdndNT2dRQ+SX8qsloEZMFTUiR7qendQ+Mo08vNsCGP7ShFa78+aNAfFFCZN72Yv+VyshYbZMDyQ8B4md+wH/kzz6KpLXmm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+ns8nD1UYmfldLCbqjSR62TyiB5XXx3JYz6zUTOCQtZcqOZ5mpcPCKBrCcYNpIH43wH8oZhw1XhNhERZfoAiOKCWK7GQZX37ED+DsHIfAUasnZS/aQuwidQregU4CAH5L29MEvoOeHAplYevoI+QW6YXTk9nVAZMCNsxG0WehdH/2tYlRvuW3n2M4p2kxg4RbI/vXgbdCsTtGUNGDtMZBqVKYgAUqepCX/WsHBFdzky6Ics+RMdRf+ppwBFlkGYH88vwa/4ugppwGgaaNeR+d84qjkHA01gXdTH8g8yRFtu+PnhZuwvoyuNg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mXjQ+TR+x0oksFDtDwVRBAQh1/2DkId0mAEeiTbFMz8HHfr6wuzHpbi7k8669G2S0nxc3Mk5ZVO7cHsBmbG3qo11cTZlmfwZY7rU6JtH+4JyxkCAjF46gh/TaOeOkIA2gGcyL1aJgxL/rTfRhCzDCPcfutf5b7r18/4dZRDkVByPkw0l9o/G+yXyr9DX79Nn9CklGk6zuVo8fplLr7VpBUY23GsKXxyc+/4LowH3QPUdvO4CrGbHrHwZMlOAW8fXCIWahgtl2MexHME1uVhgzseLSIMkN/EpfDCErT4feIO8ajEe98TuUn8LenR0nCdrBecc3zaoGKADsDuK5ZnKVnCDaFXiS0UDGVy/r80SfiSmzb2ibovPnl/9qSvtoPwWDL7CiqViJkKzAKRMYI70kKsQHOxZEkWhNwF7EJY8PaP6aoFwTQJgDVbULu0dB1wP+YsPIGgtBhtIYCnVqhaCIO+KYnq59uohXL8YHRDBAj8c0ZMjrA6wMMCsQemlVuTlfyU6vjBm+KcGSjA9jZfq2JoUWmucWJCRIliKXjriEQT+La60k+CUF7MIkpHVo+BLUCutqcZ8IO4+knxJeEM6IZVZZiJMkCGL0FZPI/otKgk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aed19173-942c-4a2e-4c2b-08dc68748be1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:15.3950 (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: ePQkf1OTCzm67dtiCpOmYC7J52pQK4GhzNbVDf3XlHjASvxkK9ArFXmPfSX/IArj86CxjbHiTDQfm7bF8sLteA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: -VYy1QLgAcCq8jDG_boLqWWgtjpIWCsx X-Proofpoint-ORIG-GUID: -VYy1QLgAcCq8jDG_boLqWWgtjpIWCsx From: Dave Chinner Currently the allocation at EOF is broken into two cases - when the offset is zero and when the offset is non-zero. When the offset is non-zero, we try to do exact block allocation for contiguous extent allocation. When the offset is zero, the allocation is simply an aligned allocation. We want aligned allocation as the fallback when exact block allocation fails, but that complicates the EOF allocation in that it now has to handle two different allocation cases. The caller also has to handle allocation when not at EOF, and for the upcoming forced alignment changes we need that to also be aligned allocation. To simplify all this, pull the aligned allocation cases back into the callers and leave the EOF allocation path for exact block allocation only. This means that the EOF exact block allocation fallback path is the normal aligned allocation path and that ends up making things a lot simpler when forced alignment is introduced. Signed-off-by: Dave Chinner Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 129 +++++++++++++++---------------------- fs/xfs/libxfs/xfs_ialloc.c | 2 +- 2 files changed, 54 insertions(+), 77 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index d56c82c07505..c2ddf1875e52 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3320,12 +3320,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) { @@ -3339,19 +3339,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; } @@ -3561,78 +3560,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 alignemnt 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; } /* @@ -3698,12 +3659,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 @@ -3725,7 +3693,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); @@ -3736,23 +3703,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 164b6dcdbb44..592ee9c2ae40 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 Mon Apr 29 17:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647489 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 22AF312BEBB; Mon, 29 Apr 2024 17:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413099; cv=fail; b=RpnfrmKT43XpPgLe/u0U0ttyVFN3t+0fpaeY3fBsdfqSo9mvh/rdThCsKNFRCEU8rHFK/n4Rk7xFWSe+j+DU/wVOrzEV3N6veeA16+9JoPHCgf/aZYjtDqeuluYZEEBnyDhrJ/5P7RwtbPJe4u9bwRi6mSI1WCqeTO0g4lsoDPM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413099; c=relaxed/simple; bh=WyGggRr2b/045rvam9wvV/tiYirHJlYKPkAjhqRa0mk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YatEZeT0Ht56WKGjzZkMOsD99S9SBIL17Yc+0fyia6QFQERo3cywJrfa5QeT/Z88bJxu9LYQxF0LNtTOffzY12sBYHjvfa8jH5noSxkeYQDhxMePNK4xQ4q+PXqIEeByNZJ5Di0X+9pIMrJXzpabtlMQCt/4G/qDiN1RfHxfumU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=bHgazVpq; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=HhNIqA2y; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="bHgazVpq"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="HhNIqA2y" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxRa7020045; Mon, 29 Apr 2024 17:48:29 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=S8m9/G07q7toMjQ0Prow/pJ53GLzLkvO8Dt5ruPctuU=; b=bHgazVpqckKDo3DGUG0sCxP1VJkKDy1AY/LBwzcT0seMPUEXKxOkRRSQ5jPmSLhL+cGU 0nUF/x4lPiYvABBFG4oHmGdoPyR4I57dTZz6K6xwz/zlm4HviIRIHKreOzhYG2Z0OS3r 7VHeI1fSMCMAcCoSvYgJ2XsqffKDr4O08A9qHccG/+vlHB64w3ADylEpUcuhl+iqS+EK 2gnqH6Cz7iz6qKQ1KlBZrg4P22EiTGw2HHckyjyeh0E9h2pl94e1UahErDo9HXaLlcTy E/jvhpwp6yhFLZmCQPz5MHw6VXClJH4hNwdTT+ZhR0Vdeh/8a5mcKT6g6iEw7kLOtF/g pA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrs8ck68a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:29 +0000 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 43THkxUU004324; Mon, 29 Apr 2024 17:48:28 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 3xrqtc7ns0-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBEEkzJTUXnNRT7o9XnS4bcAqvUiHe+IfrP2o8CGAk3sEOO+YIzDHt98jZZ0NUWxsSed1Ftap3C7unenXpXyGKgY3LpYW71HxtI/h7SQWqvl1wTixmvYv85nrxOMEKAJ0BjeTPOycXSWpvB/9enxCoisiKkqcI2ya8ndbZdhWQ5TQrdbXdv7A+gTkwprK3K5cR9RBwasKKvyQRtAgXTkP4e/bpBjXmN8CWXTtYPeHEtlH6KBhNlLNM4rSboqZmM4sWNDTBAhw1crbVTj8HziZhQ302vH4xOoC3STbksqRSg0Rt2vSKsJMpsCTMEiiMfSXaIjVpLqZVJV3VjtYyREWg== 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=S8m9/G07q7toMjQ0Prow/pJ53GLzLkvO8Dt5ruPctuU=; b=I4AmwZoSUPl8jaKsjiLiZr0cZpI1L0MkErWQmcY5bK2QjHbOu2Pq7z0iOKh10ktsoLO2L/Tu2ABdtOLmAr45g75pjbDpYQqnJZe7K8YnGUd0x23QiKJ6n8KM5ymE3JGdAqSZ3OjV3qZsKeYppOM75WD9BNqMoiQb0Gf00wLoXM+dLqNLMV8dvr62znhpdIatriW3vNnCyBpVPQx2cwHO9/wziIDpa6tHlMxXVeYNWAOyP2arTDXbScKELpTI3Zk+ZJCaAlifOuyuch2pB8WAGQPkgBbQa3dvu/XndZP3w6LtU4WsEoq9M4fa99AaGccATW1sSCyUJNkJG/vkMNT5rg== 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=S8m9/G07q7toMjQ0Prow/pJ53GLzLkvO8Dt5ruPctuU=; b=HhNIqA2y4eMJ7XM8Aw4axshRL8kM6XFiOIl+aaBWNWiEEksDCUdAkCKTveOE+5YUQipj2k/Z62CJgTCc+3OcZzIFuywUH8yvNxbSwhOqb13eknJhvg+l03/HIEWv6ulm3fQEHNfQ2p8VOkpOMHfQjYMRBNGSyBQu06irP2zQ+t4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:17 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:17 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 06/21] xfs: introduce forced allocation alignment Date: Mon, 29 Apr 2024 17:47:31 +0000 Message-Id: <20240429174746.2132161-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0054.namprd05.prod.outlook.com (2603:10b6:a03:74::31) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: a6d79cae-188e-4f9f-8ed7-08dc68748d4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: dBkPToG/AAFhSY+vJ79OAnxbHyUlKVRWpkt+sUowzCE+oJm1yAU+MMacqk3JLjmzzDUzyVLQ2mICXvEcKa7M8wpczs6DyaX8U/n+bkRyBYipFx5H74EPFH5xW5sa1FMZ7G+BPCIeLg9Jf5FBzVGQXt2JzfVCTseJ7QUT0faenv0TYrAeyGbyIjUKKMSyWKn6LYoP/iGR2EejAORZAKaLo5n1d6kz2V9iiab81UhKd/4wefA3Yi8vbi6eP28Aa6YQPo1VJ92PwE1zAD32wdqCjhkROBFGmAChqzkoZEZN62OvV9PbWY69+A77wVFKkbI0V/nHaWUH41dUvaJjTzF3dVHFu37J5Pwqw8Cwvskw6oVBAxQrA6rhQN6wbiohk9RObgjMwGQrifT9Im0ESpa5cw5/ldy98fHoAGKMDEamwuIuT89hsO41MDvfDP2hLXU8QQR5DAdj8TiAgzmmJkk8roFctNxKMQ5ywwnXCsh+RfgD0LnYvzQY/wLc+oC/7iLz+S3QgT6hE/jpl+Co8XlwiDQPcAAGZryzE/TVUgnpm1nEHAAwjC5brIq0HEuPEmlXcdn3s1Q4D1n4CXJlH8NVhPnIsR4vFMMbm2e63LgUrg5olZxRz7uPx8kjBZQB3Az8eyCs6hxt+/FciZtvwPWh6NtwS/xFwlYRszQqxIbQxgc5aRyEi59W15x+ucTUXnpF/C68aiFNijgfSwV5ewrPRVJSr0XyqXfkOjyfrrGA4s0qjnVhTUtaghDYzJrMIUZEoiN/impoX9SzoZmxivFKawDtJ1MK463DHkam8RCSh1VnIQWMUYpnUWF4ml7be+9QtZBd5ni4iVQjF3SO2zHVrmsmhFXmNA7DVacrF2hIdpr2N1quTwLVR0/VVrCDazktTH2Fb/GbnEoP97VltMK35OBEyMhNz1cCPNDTDTKCWRbhQOekOcq9gTdZ7DCqYv+a86y8mZzKrIp7jvjPobQGlAImjtz1ZfbzQfWsZE6k45Xgq4fbUvdYRS2qL3i9M1JYTDpmMlGaVqa/VUhrSj9I5LMn8LyaZ+e2yw5FGBVqc2rqcp+ILvKv2z17p0yTIKiBJSrLiL3M1ly/HGfzqXH6N9ZJZOstm7vnCp464diPc8SVDXWRm+9plzbdsHgZOcd4e7dEr9oNF16s1G4m95gBXhsOm0KPAJ8VMZWvcuTqqF+H2XrHvi1zOdLkWJiHnyunBmMHglB/vm0ugdi87T7ED6Ap5ZhWNFGsT1cKCJn0HU54VQ5oGIatZ5HzBk5eWd8WBywwtRZ8bmXIL077Y2ZIGA== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oyc/F0sF16A89CVp1PTPCzB8qRLLGqIiwyL4161XQpO8JVPzBPJqbyYbGDFl87fMRbt+f/FfnV1JtZAx8uvav0PjYQTfKDt7jqIMGwC54VHcJxecq2yAI8fznyQ5wbC20J728+uO1pTgPg9dWaffyFUEKCHvlEWg0EBu7eI0Mjz70/Ks0wVD8M+864iTse+KBXnqY05IBA2u5AUv3jOj4wgo/5/xC1VC9nBTQOa6b6AO7OLT4mWeYzudiZMy9pMuaP6tER5Go+HhHZvlV+6ValXQhraAqeofRkTfsCW9wdsfEBziJeYAuDjH3BuFxAI0rhKmvBUzJwOb4VTfocc6zjSJSS6m/wAwqQYJ+PtC6jt+5OtwxVlV7PNVBALXJFD6mzD7W7Ae6/UNgJZOb7YNOOygxqIJlCqVuINMk14osYx37cT/6JL7gZN02xy52ZzGgCwnIv/YMekcWkfv/0z7ZN5lgPZd5ECTQUSr6RKEGlOEVByr6qP69/fkUF0NmdOVXDwvY/A0x0jw6C2jKlXjRzFl53HnIWRx1BZ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Hop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: uEsHoWnwkINPXZ3GZaxRR7JTeKnkXa8Bcqxxnh9i2g1NqA9/s+QgDUY9hJxJlSoOU9MkF+7GZndXuXdHzgkEgFs6wkuFXNW3LMHW1ymBnhg0T7lLx8CTnK1HLfWp0SSQDpsLQQLG26I2mGhiVSaT76vkTQm/GFY6CPgsL3GbSZvhfpSwRBfeML76xhhjgkxcTx78Wx+uJX0TRqW2vqVo7VTjdziNNuma4Tqnp8Iab1Igrrc5C5IZbKYq2e2JiigoJufWu7qMLI7q+a9B2OKCAX410MHUEA0nlgIpuWnFhaaceXfGQ4bOgbtLuURDG+BIptTy0traqLH5QmpcY8lp1iaawZW0QYXtQqsEU7wH2wlpXNEth5NAfa6qUIEpxFLxifUjYnsvOhsyaEfLwQSpOF+gqBXVzzgHHRy4puhYs/S/IyG5zUjjVST2vSxTS5aEWrNSK1Ge0IvfxQl2bY3C6gJr5Yu7e8Y2sM3K35tabJSJfUQY7chjEJvl3EkAF50nLJmPlIjdxS++L8TVMKAjtdMTyj6IGsxBBfBpOAmXdnlbnYFemPhuCicv7ojkpZOIDwrjuFN9c44kIIn0QI5bzWO/AoNVSxPvgUDZEGThbiY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6d79cae-188e-4f9f-8ed7-08dc68748d4a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:17.6631 (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: BIsw0gVw9s1C5RZj699Ddr7E3exsvewoAYA52h+c/4ZA3IRffW09/N4bhRkgwjAkwTZVn8lSoRkRBS+Rfn87lw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: LJIaQDbXh59l6_0Dw2nVUOUldAxl7pNF X-Proofpoint-ORIG-GUID: LJIaQDbXh59l6_0Dw2nVUOUldAxl7pNF 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 Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 29 +++++++++++++++++++++++------ fs/xfs/xfs_inode.h | 5 +++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index aa2c103d98f0..7de2e6f64882 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 c2ddf1875e52..7a0ef0900097 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3411,9 +3411,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. @@ -3426,11 +3427,18 @@ xfs_bmap_compute_alignments( struct xfs_mount *mp = args->mp; xfs_extlen_t align = 0; /* minimum allocation alignment */ - /* stripe alignment for allocation is determined by mount parameters */ - if (mp->m_swidth && xfs_has_swalloc(mp)) + /* + * Forced inode alignment takes preference over stripe alignment. + * Stripe alignment for allocation is determined by mount parameters. + */ + if (xfs_inode_has_forcealign(ap->ip)) { + args->alignment = xfs_get_extsz_hint(ap->ip); + args->datatype |= XFS_ALLOC_FORCEALIGN; + } else if (mp->m_swidth && xfs_has_swalloc(mp)) { args->alignment = mp->m_swidth; - else if (mp->m_dalign) + } else if (mp->m_dalign) { args->alignment = mp->m_dalign; + } if (ap->flags & XFS_BMAPI_COWFORK) align = xfs_get_cowextsz_hint(ap->ip); @@ -3617,6 +3625,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; @@ -3668,6 +3681,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); } @@ -3726,6 +3741,8 @@ xfs_bmap_btalloc_best_length( /* Attempt non-aligned allocation if we haven't already. */ if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return error; args->alignment = 1; error = xfs_alloc_vextent_start_ag(args, ap->blkno); } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index ab46ffb3ac19..67f10349a6ed 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -311,6 +311,11 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_NREXT64; } +static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) +{ + return false; +} + /* * Return the buftarg used for data allocations on a given inode. */ From patchwork Mon Apr 29 17:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647474 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 19E4412C488; Mon, 29 Apr 2024 17:49:49 +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=1714412990; cv=fail; b=t+9jYSy+qJxFEsWkJ9SCg9FVvqmMLm16BeNp+AKNfanf9db+rfJsF5c4Un79QObFet9LIFlg0WdzVQVABFOBz5vMNQdG2r5ncYhJFi5d0b2zlkA6J161vZS67UTTzHhRQh30Y5mDN3Ou2e8or7jn8zQpvo0ZCGFfZVF/1gLSPL4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412990; c=relaxed/simple; bh=QAePCZqI/JHyujnyJUtKNaAC9BykVi6XEIoUzeCmO7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tgsBIyJ24pyT4EUBhJ1Q9p7YPhcINmVteIIzUl/B9DLW7vhDCHpwrhpt/SbSHeSC9qe9kGGjVn7/iqW6Km+GsBbqDe0mj94UB82Mw+2Nw01XyZdRh/sLa+TLo7bt7MXVdEzJnbAQ8CpINq/8q9L/U2eg2MkahzX0Yg+XtNqXzdw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=E1cNoswg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ZOVQmiHv; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="E1cNoswg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ZOVQmiHv" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxZ3h008529; Mon, 29 Apr 2024 17:48:30 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=q4lIYrcJX3xMjOHaoyH9FHJcI9CB0jlHDNsszHxbmiM=; b=E1cNoswgoowhNQUxu9BvwA+Ffs3KIfCptfZACH5JBI6HW7YsAOLLsLB3xVsJdE7usgZU R6Wn93eW6qfSN1IWF2Yiv15Rs8TJZLyxjmMRU9QgHkrbt8yReDxUDegw+L4OC2mODKfR Vyz4/58lBZLTRjuyJdzNx32tOjPZ0Ruqq0BM4IW0fl2i8K5ifpYooLMx9GItVuCD4AdK /OcLbSeIgPdDef9NYL5K3DcqYZ0rZJGPi61mXE6r2oRWFt5J0ikdKgpWtaZ0zRuopm5C smn5r19rG0mhYRJkQzpRwcqrDgN6pmILZVHgXcHlvaZQGsTU0loPImQNGvpQ0+Zg/+Q1 lg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr9ck8xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:30 +0000 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 43THkxUV004324; Mon, 29 Apr 2024 17:48:28 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 3xrqtc7ns0-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hy6surB3VWGVF/qEjqOEUJDkIHpmp40jP+k3gvPxUtVtajRgLbmaz1JJVMHRPUheIyeRX7gF9wwq4E7bdfQ8CbgwydwNZQ3oxSmzVk7nj9lm/8qvCzTgTIWjI3iyYyNGgJKhkq847oflzhKsZ7uF9Bna7w4EZtqb/kcO9DmAbn7I7Pt+Iog1Fesn96ruMIBWB0EVIa61XcmPVPD71M9ddmFwvjK6pUkDoV6TN4zmIEp2fHAzSeH6TIybm4fHSRurcA1znFVkMJv2IcBlfMsLPx1Ui7m28ou2tIDqKJ2zelb5pkWW+LGt9qmj5h6iS7z/9hIgiF4nAapdwlFYyWAMOw== 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=q4lIYrcJX3xMjOHaoyH9FHJcI9CB0jlHDNsszHxbmiM=; b=M2K5KJEnMmAFggLVWM9lVxYzcHB+uxn6ID0hxOQsIS36ER8Jy/fiE8dS+kEIQOoSGqmj0JEQL0vWJNPUqjWR34mqomulYRkKP9UaiB+FeOhFy2KktFjH4bg4bhgt+CUeSgakjkqV4qAOC1RnYjPsbu78MpONphifKcQg5kF++riK83DEcKS+k4DCVOjniSxvUdXvW5RULpD9ptKzr91Tskcw/xVbfDPGAS14qduvIkaErrFadzwLcVp2ElH7AN/1qiuvTdlRkrMFcgYuVYpCbUHTDNbHCwJBZuQ1Tt5TL1Lahp0RgWb+tLXFvH9qdVL2T/XanRWBJ/KMcOiTducEXw== 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=q4lIYrcJX3xMjOHaoyH9FHJcI9CB0jlHDNsszHxbmiM=; b=ZOVQmiHvRmKyXvzJoZz06x+IpLzkGVwkWjfTyS0JbFg5JAJYfWMLiphDOFjSH9zVEWfmxuHwrMH8ePRvjs7MyB9hb3o8A9D1UlvN0fEMa1dTySjO1HED69+KF2sglqqfenK9AAmlXtrNtqPTYBYn+yEu+bfeARATddOls4ckXkg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:20 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:20 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, Dave Chinner , John Garry Subject: [PATCH v3 07/21] fs: xfs: align args->minlen for forced allocation alignment Date: Mon, 29 Apr 2024 17:47:32 +0000 Message-Id: <20240429174746.2132161-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0116.namprd03.prod.outlook.com (2603:10b6:a03:333::31) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: ecf9de87-da57-4292-4a13-08dc68748e9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: m5j1j8bwhPzk5c1j3hgrsEzfyzYtWXqK4JCyFTBXUisdU6WGK1V/dsdx/kxaV6pF8qn2914vXaVDi/ZNArzFbOw4tbT/lWcdDf6insYjusI32qKpZlZp445fNImZNUzkSaZB9Fl07rZhlHHTZkNG3p36N0EIAkNYAcTHXhO/Y6hGZ9wqK6jNfhm+In+QLZpp5E660J/6y+a1PPICXKMdHAuhKw5MM0KxglEE94MLY/jntG59lfzGcgyfXulzjF6qqh3WXF8qwsjPsBSYWmYhIifoF/K76WGazkeSa6SM8PgOsqTTQKChEFzXmU0t/cW8ewtjuWnc4CeaVkBNy3GLIYS5DEkpJXF8i6FA7wCA/0opE+fwRN2YaeUKMDOHt3obuhmYRz5/wsFVBqdDviHTOT0tEPSZb77myr4i14UhEVweBlZAUQJK0NGU4rOpCBT3uPCOJeyecsb+78NLvYmQC273x70MqiApwuqdbUvt6LE6gMb2IwJgrP5HUylD58i36XjIRBD8fYGF/y+lai3s2ZZdpa+eWTuWQXgQ4+zGyn6fXfVolxEK7cUegiMJdCzXQjfBZpcVwKX5y8tThUK/RGG8aFgtkVP4un6tP0cSQyOS1yh4DxGGnPSmh4T74rQEK2nAEpYN8mNCWTSFq3GvSUviogp19SyiyDsqJ9SLN5gUxNUszg6SR8KW4bXJt7Lt/NPnR5F2QDwD0pg7GYmDcWKmD2jXnfu0n+BfrLBbKXNv/HOSmNqhA1qW3FsbIAlSB7LmeavD47eQIB99L4AOOtYPlP61/S6FttIE1pHZTqGi65VFSSS01PfosPJvZiEOQeSep2yT0a2j7j9l8D2ym3cokgA67T+afMDxg3PMe4GCcp0uDvO9CHOQQEfmsScqXdpa1MMXhO+W7JbFRwprG3fuK25jnL9qXoBkeCYG4o72/uhwmBFR+8d7P9JjhZdxmFm+2ZhsQyQ2U3EhfrUiL3nTnHfcrguEBkQb1/JcKuPL/A4kymVCqyKwgAOrZ1vi0KNAMMCCDi+/bF7VsKhtuNftBHiLi4XVhfsGILGc/Vxu5u2jt8WzfW9eJKb9i4G3SDyBTIxDtlkntV30La1lSTlwiUBnwaFTMl19XO1XDeS8naQTFGOf3gmwTa4a2GURXlPfl7+HWLwSs7F93U+0ZoGIPPIuuZ2ogQm3F/T/i8CuXdhtrJ8qWPOa9Oy+wcN039+SoKvKYqht21JGCsdhlIXxiTc7Sd2wekzzscKLW/wqGnTz4LBjRt8rWdG4NFpQc5m+pfe2qDtSizFa4MnpuQ== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xpvBzAsBMysZ9hGw3MUB1wZAS/0WfCybnt39PgqMRgmEBLBGPilektonXDCpmp0BS4hnZ1JGM7Ksrzt8Bdd5KWZy9wAdEegkbs/kftwGr54/dazg8HPD6Cwxob6JOUKAR36hl9Puy7/lQbK8N/aWqwiPtLP+i6hXAnFRnZBs+ah50iuhBrdV2ZWaya2LX4nAExTKLHLm4Irjt9t2ylxymlxNMi03ftVNLOiMCS1b68+VPM2DomJ4QXn66kOkVTRGpmNs25NaMTrG8G2XjIFABswS0vtS/KUVMenGOj2MgYuSpM0fyMRIHWX7on+nWsc/BTx1V9hYgzgsLiTRin7/jL9W3FjlgjuQK/nr1+5DLGLPBnvHoC78QojKl1f79/M4DxLpBG69/u0Zv+FL7OT4rYJ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5d8Hu2/C4IfCfjwjeZnbEj9jIYie+tWGDcYYiXfXGLhd3K5riUcuDDitGSExRMG8ErkxoSPJVql19nR3uVweKfuuu+gqBiC7BcpQBacPshy94YwLKvX4xSpdXKT0x5UbOBAgT0U5HocQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: h80BBX1JA59y475haG+QjYIo8g9CyMAMgHWMKtvaeMimwPLdYbNGCO/e60lApBF9x7hSbHwqVEaIMG5rbvJigu5F+EyE2OzItlkhxdqd2nLJwM5zwzSGkFV+zegz/1Cu9KNVXQgHGy3kBJVAadZ8rosgO/Da5MNAmLILfpU4ovfGP0MV2Q0kgkgD9hBYkAA3I2Hx9wcv/tBbs5+YDG7f9Vld1tCGE3Coo20YydFH4gpq9iZz8Dujfptudlmu+LSkIeLLAOVY2G+dbP63s0JFiNyecbHG29UrAheDqt/OfPxA6mCDGP72gS9U5Z0HDc+0oaWhQ7xEymG94q8vbrdKMoAA3wd7fILvt5FlOpcC5zDoZiz4e7mXnaf+d+/q8BF+OC3BmjCoCVvFAVYQeSA3rxLcFMlP85FQypqAt2HH6Ui2ScXOKc11t2WoZXXJGVSexcRsEK/9sj4p9sVs9nT5/ot0kahvy1fAF5RhDdwWUMHNalc5dR8Fy1UXSKXEOvz7Z97Qf3hE1GpID+9sNASdeIEdaP46CyHeqN/6ML/be/dngc5QiJ6YfPBTUa5VDEhqjv/eYi3+/4XJR+wOiu3gSSadCOeU9fHewP0ym6JY5G4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ecf9de87-da57-4292-4a13-08dc68748e9b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:19.9236 (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: lUCTNjwceTj9JKt9Pi1DDhWExQfzN6Un1LcGgwX0TV04rsmUiUJAf+IA3/Aa2+HaTChHiE1sO5FzgMmc3sDfpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: LiRcRaZnlLnuWjnpsNyfzO4hfB0S1M_4 X-Proofpoint-ORIG-GUID: LiRcRaZnlLnuWjnpsNyfzO4hfB0S1M_4 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 Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 45 +++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 7a0ef0900097..4f39a43d78a7 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3288,33 +3288,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 @@ -3350,8 +3365,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. */ @@ -3671,7 +3685,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 Mon Apr 29 17:47:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647473 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 859D6129A77; Mon, 29 Apr 2024 17:49:44 +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=1714412987; cv=fail; b=c4NMgd+c1MN0zwDsdg7Xq3EIIeaX2OGEkiFMA+AyJJjfuofhVaiGlAuiPs6q304iNdIQKzHuOwjR+nkKYiRrjD5uG1Z07oO4Wr+xmle4LWRwlWWc1T24x8yjMogP6XxcIAUbi8RbHko5+KWnP3MoXSUZB2z5IMAAtD/pGvZnBgE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412987; c=relaxed/simple; bh=nU8dBY6kIilE4oMPwLvHuXlZ7pC4Zvwi7GGZMGoHoy4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fkDM1bBG1mxRf4rypdr6esf34NAZzMPLyCh0ItnkjWQ3ylFyw9b3QVoj51iy0acRQZN3U3KAnBYK7h0fhX5ESMz4QDasTsfO+6DlDMIuVkrh5XxxV6kLaKVYawYB/9LfVzaskU5gL8RPZNyd0NWZo1PyjMFyKJTRJeWf4s9m56M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Wx4VxFBY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kEUqHOJe; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="Wx4VxFBY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kEUqHOJe" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwmqb024649; Mon, 29 Apr 2024 17:48:31 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=MJ7X4gxgJu+VhcJHcXp6M87hdic7gkThROF2VmuVuyY=; b=Wx4VxFBYH/4S+kFtXxzCGmKQ/wsuiUHh4ZrKw/df6waEHLEFijjB+MXCE8bEqXdfvBQA mOdWBz9f/51BTB7iP6hYzkwoskEXSV0qcBGHIe0igZtakKE2ZSLHLeWIs9UPlEwECbB/ MhBZWUCbha6hrQKAGpG+IHiFuAMsJ5K7x7acXdCRBbEjfl66Dhj4LuAPCrY+MfXyJJYV WPMeAY0TzRfQ9DXrEdLlDWFWktE+R/nhh4Zg16HXFFbZgh+WAbKbVBrtMDDApp6Do2FF YDi42QwDydNNfqBcWzl/Wp4n9ta8ef65d9FWJwWuXRdPQW3Xhs5gZVBKP6kXiL5Z1mzk Cw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr54b7ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:30 +0000 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 43THkxUW004324; Mon, 29 Apr 2024 17:48:29 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 3xrqtc7ns0-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFNCFWwO+0G0qaFMPT/6byGrnMZPdNaygpfa+Bgl5uJYBHn9WbDz37phZylXeNKWZW3PAhzjoXL2bPKCh2It4t3NNSDXOS5VU7nNgaWWLGC1ge64mI9JQDA3NLFxBK91QZqWnBn25H7Mb69K0AOZ24jabbf7ik5sEg/JaHAfrCw+ZVAAbSY0uFInGoN+JjNNs1bHQfOGq7dcV8d/YuhCdOJBIOZAVBabZX603nt5xPnqvZGIvnkYadNkxLNHS8gU1rA6771picNJaHqDeOexYR3SoflgJjiTKjOl8pxJ8UKsaWGELQHroOEtya6YTlrfg89aLTcnqRzwZakPMjKzcQ== 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=MJ7X4gxgJu+VhcJHcXp6M87hdic7gkThROF2VmuVuyY=; b=MvYxnhHWQGRo7h11u6NHT63H8dIClO0VZQyKnZZzczCMZscrH/6sxOj2ScnmRF+JZB++aWt7PSED6gX5FfuuD+j1hEsHFYKTZ8V374g1h3n5VQkDrtLqxNfl/iMaWZVe4tcg65cO7O9ybQdrBHqfOx30bievwz7wglrO/yhiHbjZ2MSXS2l4fw6bAzAVLjI3BRg3fwiixkE6ZSWZz1AZoWA6/JE0fDFWRVES8lzHm1NDoTq/aRHxIsVdXESibOLXF3Rn9IYywO081bm7XwrTDSKEAf8wAD6IHd6+HU0WL2X5R74TXGvDHw4hKSomfxjZ31azVCDXCsytleYzR4vO7Q== 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=MJ7X4gxgJu+VhcJHcXp6M87hdic7gkThROF2VmuVuyY=; b=kEUqHOJekcyP8503j5NpIg6kTfWUzjqaUHcHWfT6+85sq+8f5IjZT35LVexdzher77JnKdJadBF1wyLgIz/giy76f1AV1aKWrjmeIyOkCHxKYHkoqWnJu6Soq8WBwLAT9i3frPDvcf4Ddeup0Q+rUTubFEe8zrNxgxIbH5+GkiE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:22 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:22 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 08/21] xfs: Introduce FORCEALIGN inode flag Date: Mon, 29 Apr 2024 17:47:33 +0000 Message-Id: <20240429174746.2132161-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 84a161dd-53d4-48ba-b6d7-08dc68748ff7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: 2RFmEsVA6Jj9OXdicvXh0ww/Swfqjh6W7g//ikrV3x9W10GRU1HfxLzEQIg4yvCRVJct9lzoKxrsvYVSja1mr9aPuNUClurmFv5pQsHN5I2A+qvAuWRBeaWSPVbVo6owZgUTCJGXfwSz9YuiO+ZfxBQyopQ+1VFJguAuK1aIeP8827U0hTwUAVYIZ3/ymv/1BwCR99W/WIhJ/FoJcCjAnk2oN/bkIBAIfPFEp4vQ+fN43etAZhvbDkQZYHoqlgfV/UIv7qK68jmcr/IoLlQoV3GV1DhKE/Oi90DqJswSzncetptGZH/omdVMZlFKIyFKXgTJFPXmsfVmsGtBgg8Jzw/owBzAgBAB/JWgV9IPhepPO0uLZBkWWT0G6sqv3T2Gr3uRF10YjdzFDt3PvyAVYVnjv5/6ugxvKdqkTe8mOUh/XSBhGMZcUJL8L4NUgdB7yb78kj+K3zSTyH+E6QGzGEixSjzJ0ioeGVsLPUZS2w/TYU7sWq05V7og/1iEh/NIv7G3vXp/FoOpj+B+Hv4wYUYhqjRLWT1T6Gu/T+bbMtCGpRvXsU+W5nOLILQdH32BfMoO6yJdKLT5OUpzmQxbz7U+UlsVFtv6te8XaBERHEwZC3whANfHYmkabSQByryXOHOe/8HSI4ka5mzCyshopSgipLjQmTkIbV0FggdsIaBRrZXkrjkiAZ2zL+RJDbxdbsnK2sBEkHSm7jsKuQwi1tS+rpfCcoACH3l6umLK/oYUDkrMVj3U2E5WUfFp3CJeNLJjzKP27xtmb1I2fXcKcTxwTNYp3nyXWQ9Jr64RZrizSgpU3MKc++9dI58S/EAl/BAIqYpoUioRgE0i4epjgvtKOwIDXFkJwseVYRVrCUwnQfzr7nDxHYtTfUV7ZY0rq28IJe0Sx4qctUw+Dq8A69nD2/xNjcJq+oSLKXz7kWguqJdxnAf1IGkNarDuCrGdSQkAfKQhZbBTc6t2ZyEl6uHup+QTf/w+ZgKcUXuRZZFy2bzT43+teOTfyNEyHXKTu66PM++bP5+WDgVfr5eHPRHbv/cnvcuTT2opFGGwjpiD3NVQvabES5BfEnQ93dje9TWsB9Drk5badldvS0kdPKeuxd0g7e87ObFK9mu3SvEjYdc8rXBvYNOaOg0SzV30drwCQVitsr0+kNIUQy7vS5Hfuw+aUkyRIwOITrYX3rs5fdT/qL4DKxKXKJFgqJyJodt7J1JtI9lTHKL+/NqSEC+/hNSlWosPtQcibzudh3WERiePuKvdTbLq2oHeJf/qhGVyV6pasdamyRvJJPV8Hg== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: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XywpmnAf2yAWsKc324yawGvJv5oL2KPxwlp00Abx0H4UzP/zLJJK7Ce964umHv6h7n/QC6MlH5nboSTlr/7tm8JORblpD/1Ntfe553zTNYsoeH9kIxrLcR1YMBEIn3Ppm7LoRblx8HEv0990l6CBIaWOhNcvzbDlp1cg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84a161dd-53d4-48ba-b6d7-08dc68748ff7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:22.2334 (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: 77xg6vemzGkkHxBfsEWWHbN3WK1SuoVWcTdeVYLUbnTx1QzbAzSH/oIbjxSbqP/5JdWsorhg0G3naTR3jTicrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: iFW-5L8-POjprmXgruo-v1_u5IIcSaN7 X-Proofpoint-GUID: iFW-5L8-POjprmXgruo-v1_u5IIcSaN7 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. jpg: Enforce extsize is a power-of-2 and aligned with afgsize + stripe alignment for forcealign Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 6 ++++- fs/xfs/libxfs/xfs_inode_buf.c | 50 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 +++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.c | 12 +++++++++ fs/xfs/xfs_inode.h | 2 +- fs/xfs/xfs_ioctl.c | 34 +++++++++++++++++++++++- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 +++ include/uapi/linux/fs.h | 2 ++ 10 files changed, 114 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 2b2f9050fbfb..4dd295b047f8 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -353,6 +353,7 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_FORCEALIGN (1 << 30) /* aligned file data extents */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -1084,16 +1085,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 d0dcce462bf4..12f128f12824 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -616,6 +616,14 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_FORCEALIGN) { + fa = xfs_inode_validate_forcealign(mp, mode, flags, + be32_to_cpu(dip->di_extsize), + be32_to_cpu(dip->di_cowextsize)); + if (fa) + return fa; + } + return NULL; } @@ -783,3 +791,45 @@ xfs_inode_validate_cowextsize( return NULL; } + +/* Validate the forcealign inode flag */ +xfs_failaddr_t +xfs_inode_validate_forcealign( + struct xfs_mount *mp, + uint16_t mode, + uint16_t flags, + uint32_t extsize, + uint32_t cowextsize) +{ + /* 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; + + /* Doesn't apply to realtime files */ + if (flags & XFS_DIFLAG_REALTIME) + return __this_address; + + /* Requires a non-zero power-of-2 extent size hint */ + if (extsize == 0 || !is_power_of_2(extsize) || + (mp->m_sb.sb_agblocks % extsize)) + return __this_address; + + /* Requires agsize be a multiple of extsize */ + if (mp->m_sb.sb_agblocks % extsize) + return __this_address; + + /* Requires stripe unit+width (if set) be a multiple of extsize */ + if ((mp->m_dalign && (mp->m_dalign % extsize)) || + (mp->m_swidth && (mp->m_swidth % extsize))) + return __this_address; + + /* Requires no cow extent size hint */ + if (cowextsize != 0) + 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..50db17d22b68 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, + uint16_t mode, uint16_t flags, uint32_t extsize, + uint32_t cowextsize); static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) { diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index d991eec05436..e746c57c4cc4 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -163,6 +163,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) + features |= XFS_FEAT_FORCEALIGN; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index ea48774f6b76..db5a0f66a121 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -607,6 +607,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)) @@ -736,6 +738,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, @@ -744,6 +748,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, + VFS_I(ip)->i_mode, ip->i_diflags, ip->i_extsize, + ip->i_cowextsize); + if (failaddr) + ip->i_diflags2 &= ~XFS_DIFLAG2_FORCEALIGN; + } } /* diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 67f10349a6ed..065028789473 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -313,7 +313,7 @@ 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; + return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index d0e2cec6210d..d1126509ceb9 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1110,6 +1110,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; } @@ -1146,6 +1148,22 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + /* + * Force-align requires a nonzero extent size hint and a zero cow + * extent size hint. It doesn't apply to realtime files. + */ + if (fa->fsx_xflags & FS_XFLAG_FORCEALIGN) { + if (!xfs_has_forcealign(mp)) + return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) + return -EINVAL; + if (!(fa->fsx_xflags & (FS_XFLAG_EXTSIZE | + FS_XFLAG_EXTSZINHERIT))) + return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_REALTIME) + return -EINVAL; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; @@ -1232,6 +1250,7 @@ xfs_ioctl_setattr_check_extsize( struct xfs_mount *mp = ip->i_mount; xfs_failaddr_t failaddr; uint16_t new_diflags; + uint16_t new_diflags2; if (!fa->fsx_valid) return 0; @@ -1244,6 +1263,7 @@ xfs_ioctl_setattr_check_extsize( return -EINVAL; new_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); + new_diflags2 = xfs_flags2diflags2(ip, fa->fsx_xflags); /* * Inode verifiers do not check that the extent size hint is an integer @@ -1263,7 +1283,19 @@ xfs_ioctl_setattr_check_extsize( failaddr = xfs_inode_validate_extsize(ip->i_mount, XFS_B_TO_FSB(mp, fa->fsx_extsize), VFS_I(ip)->i_mode, new_diflags); - return failaddr != NULL ? -EINVAL : 0; + if (failaddr) + return -EINVAL; + + if (new_diflags2 & XFS_DIFLAG2_FORCEALIGN) { + failaddr = xfs_inode_validate_forcealign(ip->i_mount, + VFS_I(ip)->i_mode, new_diflags, + XFS_B_TO_FSB(mp, fa->fsx_extsize), + XFS_B_TO_FSB(mp, fa->fsx_cowextsize)); + if (failaddr) + return -EINVAL; + } + + return 0; } static int diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index e880aa48de68..a8266cf654c4 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -292,6 +292,7 @@ typedef struct xfs_mount { #define XFS_FEAT_BIGTIME (1ULL << 24) /* large timestamps */ #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ +#define XFS_FEAT_FORCEALIGN (1ULL << 27) /* aligned file data extents */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -355,6 +356,7 @@ __XFS_HAS_FEAT(inobtcounts, INOBTCNT) __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) +__XFS_HAS_FEAT(forcealign, FORCEALIGN) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index c21f10ab0f5d..63d4312785ef 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1706,6 +1706,10 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_forcealign(mp)) + xfs_warn(mp, +"EXPERIMENTAL forced data extent alignment feature in use. Use at your own risk!"); + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 191a7e88a8ab..6a6bcb53594a 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 Mon Apr 29 17:47:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647465 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 8403E128396; Mon, 29 Apr 2024 17:48:55 +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=1714412937; cv=fail; b=rXEkBpUhd1P4E/rFMMFH2EXE6Xone+Ed1yNPYYhFuSAuA0NYfdPOWVN6lVYl/3Rsj+0teaT+gOwr7QLH/fZ6TWRXaqwFps8xeDCTwAuaCTDnOISyNbQPwHooQZH64YQWt2Bje2+ozZSlHTNgBJeRpJxLut4hyqf73h4IBL/YTW8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412937; c=relaxed/simple; bh=0U1Gj3Q/lM/59A6wrRnadAI4iVWAMLN9fTcJUu51G+c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NH/ppkDs+CPfOkIb0dMALNpccwrP+otwE7ilhXV9uI5fgJdiG/JUq9AsRX6+6TjrPGjI+1St3jsaIP8KU3CstKHKrSn4vCFUuJpgNT/fOlu0tqVJ8MfrJLkIelazz+kFrg2wkpEd81CGs3m2xtbdHYj4tNKKw3zEnEpjVjk48go= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=odAvedA5; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=xtFCDX+p; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="odAvedA5"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="xtFCDX+p" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwm5a024638; Mon, 29 Apr 2024 17:48:31 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=cujYjwAgxSeJQc8BnVyHN3WNsZ7r74mVihvnZTZtYZw=; b=odAvedA5vg80o6ipJKhOLM8WC8/6J5WyHW838i1M6QD3q2NPf7zIJRJ/4o6ChxQHMvYX HnSQI1vHQDGzBvwZqwSw2OKiwWFDnDvZb8uai9EGQpCFz6mAcvhbOEDOJfGJn4/p+xxG YHcR2UxkLjMw85OZKmYFaW+xzHz6T7Ge3iOrOHgdUgQWSiAdc6pLkKotrlEnxiTcnYWf uERVmplLF8UdTVbkf0eN+bkGM9D5sS1FQjIuSMlljPdeMewn2c8SD6twkHV7rubHiNoI uUgCPahjWkmHikaObRh65+CnxAVNwVA2WmePCWXUmUzAqi0ZHJPu8ArSnVX6NEiRh71f lQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr54b7hu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:30 +0000 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 43THkxUX004324; Mon, 29 Apr 2024 17:48:30 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 3xrqtc7ns0-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BmOmqdYBYh4N+3saXl5MDs2tw73srxmLpv/cNF1XoGmM0XovkqeiF5Jiy9LEk9zQirZO+MUOH0NgD+18i2CJtL3WEvL5FB5+CnWGOw/TYfe80uNodSGo/Um/zD4vO1oOxCJ+E061Kh3EN2SBiBejP4uViJuukUC/LO+fpLdwDyDN16jKsF7ZGcvtPlPiPGfOFDdvoZvsCgF9tYXOnK1QUliyVjO9Nvf/NkYop8y4KSJ9dXMJJszZr3JiHrR9ZzfVU1yqoEk89QRV8ZW+U1Z1smAHG5UCl/VuDVaBZ3vnR3eG/2GKE6Prl2QBQfo4Ahg/kK+a7xXcp/YGWQA4V6Oc+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cujYjwAgxSeJQc8BnVyHN3WNsZ7r74mVihvnZTZtYZw=; b=cXXke1SpBV1qddHlNJ12ZMpT9aYB0PPCZSeQQOIofVSu309WK7mlPI3eAehyphVItMcVsaj1ERn7B+XngV0bkYzfLXtX9Ls5YDnGpQUKtFek4QmbAwhrk3cjPifSoH9hg5Mv7Ae4KAcEY6oYM2cBGdEM8cCDy/Z3si5L1sxXocRXDRAPZRu6+wKWLtUl0EcDfyOlnm3f5NbFdhqAtmmSHq3bJH3ZQH0nf0I8Y6dXrcvcIlX93L53xg3PYe2HDcy2Vi3EKyiwis66G5+dgp8ALLw/zfkpC6T4C+XrGb7Eo1iH8PbYH5aISiNzp+ZJ7W958XZMC+/ZFuA6KXkEhpFRBg== 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=cujYjwAgxSeJQc8BnVyHN3WNsZ7r74mVihvnZTZtYZw=; b=xtFCDX+pRjcIDu0N6WWBomEh3XKV8Sapjp5r/bVE3hgapIamVm4sIXnmEHJ/UeGWg40XYWj5zOt6QZppb90O+oV1f02s6uD8FvwhPy8Tfgle1O6o5jJFn6qm8p3dT5lKMBswU0OQ/V0FBrfv+M/KnakdlwEswRoXGJrkTGFxI6w= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:24 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 09/21] xfs: Do not free EOF blocks for forcealign Date: Mon, 29 Apr 2024 17:47:34 +0000 Message-Id: <20240429174746.2132161-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0352.namprd03.prod.outlook.com (2603:10b6:a03:39c::27) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 2aa4084d-edef-45b4-fd07-08dc6874914c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: 0tyMJd/U9Wl/T2e0XahRzcdEBgKEImYag6SFrfpCsZS8cyt6ts6dBK3V2gRhj4IzzzXY6ibsh8iOAQTYwiqrWjY1v53Ja3kU81hK1OOjMJPoqSgbQhZcKtLwYw58HOwxkay0dQ0WvJ6GAM6lFPznA/VcypX6ekSlXNM0HIxdDyT3SJTF1XReDjjqczMG9T9uuNRXYVv6qNYpkQv87/9murZuj8bvvSCMAtDXnAp0ChyHt+nSnGzKP97pkDf6vHbJ5u3TMhVUgK6JhUFPbAOId6tNj6+9dxMAyCVMZK8FJ/VxB17P/hL9yXyfkz0f7Wf9sGa0xdZOogAp3dLebNpt35tlsERucooveC//axUP9JowrJ/ccPl3Bjqj5jXLClxQklQlTgM5g1Ue0uoVBA9sSlHKUul+xgpw/Df81+TZ89hNcJPKkVOzGt/9lg2IKBbungDz0NVI7oJoH5pRfi1masyKcTivDCBvksFPVdRKMje/6QrzNnteAapBHWqqVIibHW1vR5KtTDQYt6E21bXQmlZmu6qwNZstk3vDgb1XkPo+IC2hZtUXGBY4etUNaA2voyhwL01G2evAyt4czq6ZUigLxWEJhv2pWE1L1OWyrPxNMJNRqy9EmawGKfJ82wLGZzaiC7XsjrEc6Y8D2kNmlza2ZMeZkyAjEi2e2T8VJxzyZFqUMWxygY6GmPyvxMSC3iaSea+uQWrR+GXSaspSgTDsT0w0pAQjIlErKf3tRyUlMPiaKn7tJO68jBC2z0hB3ZkyBnkMRHnG1Yucp80lXZ4U/Y5oFKlYJ8rdfhO2qWbAES463gxwL34xWPdqESdZ8enLtrhZ4KzQ5j4ACxzmF8ZaqAXL+srCquAfgVw11ugR5PMF6+Vl1bVKrKOadRYo7o5IemlA/54pEPbk5ojl+gNpLqzeKBHTv7QfTEt2cks/Vt4mJm3g1rQNz81fUB2SC6S1YncJBIB/iybkHSmBCruNAo2ZnZbDgK+MhgYTumzAAX/jSSPxJ8mX2N+Dx77R6V6uywmZPoeqh8ULiKXsUO7iIVVfQCk3S8OA5xTgV4NGci53+k0lcGUvZQVto7cD9EE4/KYGjAK8WgODxbmLBk1VOxCuUUTrZBIctwKEM+GudX3j+GOOSWKEuZvtB+VgiVILlX159JVjv/eJNfq/mdLle3+Ec+4zGZMA1pGOO/VdVyRT9/MKfTD/48wGj/+N1dMs/G0MT7TIZMKG0w96dk8iUeL8yUa9YpxsKyYFlLdPVBo8//ksfswjF+53B+BJnAW2dX2e56ojHi59exAHGA== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 91RRcrwHMTcG4yFAmWn2hgCtaT3Hype/MYohzyihXHmH760iTOSEvLV9D839RKy19vxDqGXbnI7eiiI2wCA2e89ChUwFllI3+lzQjZNFewbJ8ZjFZXFCeEAMLlHboqE6pO2zOcc3+GeryuLJsaFuvzl17gNK6HBMikE9V3iLMYBxJAxEsf0+g6mLHvynNQxHNkf48En3IZU9U0EE6b6Zl+fJeryfYoCH8CcFV8HRA44JGA9fOM+RHf0nFJHt4y9eivAHV5DaMYNeevTed+kztaF0EhWFT/QJdmkZ5LnPaA0bLsm2iGn0ihbGCM0K32w7YrBE+7AxuVJCYK3QPt/6BTHlNjbwix5sfDP4SxMfm7y0jFtDDVcgQSiJdtwY5jSJofUNckBFtqr4aKnSry9Cz/kPOM/DXjk9WNPSOW+KQoAHgE4IcWeAj2OxAMNF22sUr75pUnZ49dnsb7z4WOkv10rsN1evd8WpFNFf2GuC72+8Y+XhubEKw3LDIRd+HIrTLZ+iC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TYft+G1EXUnVGFXNkbW6HUW3IW7xuKw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7fBpFEZwTi6op2cq05BSsJlP9g7Exs73RoJ+aN7GZhLfS5jvCdYCI4aDDwXU5nIo61EmxF2/kZQIdX6/3BNywt+K2uba3U55dBBuBG/4EnGMps1r1aAXt4Z/U5IZHNCmI8XD2DhRP+1CA/nQb1FWYZY1PBBYN76RvJkBuKOmE2GPkzKkApy7yxUqpGhXi4h4HgqemOZRRCm3lm2Ytr0UnZmjmRA2mfQZ/1ZkBT5ZNUoADTfvwlgg3PiveLSwS8WZalCfZxYXW93wOwEYkJCGARuo7CihOQpTdD3ph1mhsGNPPLARO/eVcEO9rHffu2t6s4tbDWAOf7oEjUy8kw8X97NumwAVviZaFnJScr2I6TXFnDUJDsI4Y1rhmGWxZxxgyGBXTG0kP/JJA7jnsNC+XuH20RTHpZEH0y6Gg6nsMGCV7zUyz5mE3fXOMRe9DQCkbIR7r88zCPg1QetstBEnhD6NBESdGFvJLYn5+c/aYuslK/8G2vokjJhV8F5GkfdNYWuTc4bIPHFoel9OX5nPVBZ9l6CJvI4ulVf3fKgA3imMTDBZupU+pYDEN77I8/ZDGK90veyn6JpbMT+iCIxpce3InBvtnTkj4hL75UYQdHg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2aa4084d-edef-45b4-fd07-08dc6874914c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:24.4368 (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: pLqshfIfGTb9YFzntd48Mg5mEFvpBxSMjwCefwuUx7KvFKWC+HNfMyShKtHWROk30hFxj08JSOaLtcTw0C5erA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: WHnWc_zOo-e1g1kgH9DOjTUfoS0NBJI6 X-Proofpoint-GUID: WHnWc_zOo-e1g1kgH9DOjTUfoS0NBJI6 For when forcealign is enabled, we want the EOF to be aligned as well, so do not free EOF blocks. Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 19e11d1da660..f26d1570b9bd 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -542,8 +542,13 @@ xfs_can_free_eofblocks( * forever. */ end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); - if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) + + /* Do not free blocks when forcing extent sizes */ + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) + end_fsb = roundup_64(end_fsb, ip->i_extsize); + else if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); + last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; From patchwork Mon Apr 29 17:47:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647466 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 95E6E127B4E; Mon, 29 Apr 2024 17:48: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=1714412938; cv=fail; b=Uwb2MNhVEcecYZLM1oloiTMFNxEluY93xqlAa6jXY6ApIjs6vXJ1iBvu9dICIws9wARDNX1ujInE9G+NDPRbj05sk3OfEoR6hl0NwyzkdZhRCD4bGiOllQ6PGuKDK+5NzFLuSSyulzPra5uxUHHVaRVXrBve8TcqBaKxi+1MAzc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412938; c=relaxed/simple; bh=dB5gSlWFXJvHmdCUR/S31Ip4hqxj8kMFpx2YXc5hqxk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=c5QwmYmu41AcPvPev8dkMWCUFBU/z51KYWYsZdDglFVL3cr8VaJg9VRamwMeg2UmSXHL+2IPPaEj4MRv8touDay07sthbzAdgef0aJtmhDqzDAyvzfmcqSEGGV4HzC8CdwLnm5E4Itrn0V8n0+iR5ikdgSKqNKGKuoowIX/gxpI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=an8l4E8g; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ih39yMY5; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="an8l4E8g"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ih39yMY5" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwmBq002395; Mon, 29 Apr 2024 17:48:32 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=sE6iv6DI5Dzh+Sm5956ocukjy6rHOPoR2oP4a6r/Abo=; b=an8l4E8gnQHiZsTtXIEnVg1Bi7mOv0/JuDEFwdGDJGc/anQ1GEUHMFFGaxcpY7tGn0CL duUplD82HYVI3OnYaPXOENifZDf5cX11W+wdEi8VF+8cpR31FiZA7Wo2WiW8Qx/RAi5i biQKXKxQuYpPH5udJtNsP49J6VxsBJWsuY/Y0p3qwI+nkUDuPCGl2RkN4jznwJrNMhny W5LaZZStcKCP1h2X1lWak9M+b1m6YAwC3XXiedit53FD5nUz9biu9gtDSaiWTjwJDv9K MPIbwM9FRsTPxnupsoX7A/myNRcUevP3nebiNlR5HmNOMnkbRDlkNu0I3UxwayxLuTKP Zg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqseu6p1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:31 +0000 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 43THkxUY004324; Mon, 29 Apr 2024 17:48:31 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 3xrqtc7ns0-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kn7PVVX13m7opCfwag+warNxAcD1gWJ/VB5VlfVB5A/yGsienybJckZKSbmqlW6nm8lYRuwFYkr00W6sWCECAjU05IGMh8RT1HkNm1OkUh0xBuKl0LkbG4OJ5X3KriedJPN/GIo9eEGtNnHFRnyDNS4HuJFAd7K3l8ghygvl1JePuzMZZL2Zb5MDkQYwENHUpPoPDYUmvlm6WwzhKhdcd15kGsyh9LivA7gdgnHV7mFg+C2DjfHlC5g77gdu+nRukTKo3RIyWNTtoFO5NOzu3qBaN68mBsjKKPnEc5tgTr4zCNq3wkYLEtJzct883LiKnbiHotp2YTBjYiPxKYBeeQ== 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=sE6iv6DI5Dzh+Sm5956ocukjy6rHOPoR2oP4a6r/Abo=; b=R0+zV0AVzUZ8YxdDJW2NEIs/+GyYGWJpy5raZRlYg8uS1VGitgmESc7oNU9+WWnLRiGWYZzUoyNDdsvnISSMI96WgClUx1+nPLhJVPZjIg2bafu6tvbOp8YMlFciw4Z7imh5yBbUpf1IieGCwUKhbkROV507XQfxALItrK8CxMdtJnlGmbXvmdnkN69/xxQicCUDmmMoJuqg3G6DcmjhgZUo+m587WGQv8mbCCzLgGP1KTtAAZGf+TKtmexBBgmhjFNqDQvdE+PhCfSrz72ClXbPpYKfIV2yV7xhaNkrk28D8zJrr7Evyn7GLrJLZupIyC+cPvvoOeDV2aRFDmKySQ== 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=sE6iv6DI5Dzh+Sm5956ocukjy6rHOPoR2oP4a6r/Abo=; b=ih39yMY5G/U3t1vciTdf+fKSd9YigGsiMCTNuSpNQUHzQ5I/rNM3HMO8Py72U6ELB4uL8eXo8q8RWtRBqBiDwHSbQ+wZzyPJwQamcXcsdVR/+0MFmiYLL6KTnQh0WhWhnhpQcajap5iD0+ffKCY58JY8UkOp9BEag16hWZKDiRY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:27 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:26 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 10/21] xfs: Update xfs_is_falloc_aligned() mask for forcealign Date: Mon, 29 Apr 2024 17:47:35 +0000 Message-Id: <20240429174746.2132161-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0084.namprd13.prod.outlook.com (2603:10b6:a03:2c4::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: be02b222-bbb1-4d11-7e88-08dc687492c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: mmU4E3SJDZ2pFuKB8BMVq6z7tYtPUQPSGBUlduHy/mD+lu5ZdYfZHPEmsii1Uo9Pas85IOCxYUf/uxuFr9T41w0HqOZ054Y+H2kwanmamUNp5kzAHue6eUFcmzzZaCkKd2tEpOoE8N+s80W2n7iaQU7qMvkrz5qsypbknNJT3Q3f3TMhmF9uQaFf/BpuoDUaSTYbtd5RWcdFSuCAE2IZ5ClkagxTW002nF53ppYdBJ9gVcgugicZiBMXfe2Pz1O7bAz4S4HcR9wyyD1xgAZ3yaS73SF6CBf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I;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zKtJGjhPdlPNA9WJi6Xbo5222SIqK7Ge5L0U6NOf8zuaijjxEMBPG6HifL6NJMg0v/XngcIW2fpBTfc+imvQKiO/vOw7HI1qQS+jYNp2++mE/kHleOTxkdjRM/y/Q0xa4pyA0Qp9A8eSAoPDCSlQYi3vrtwvxBaEvaBhJm+O5h0ukHlsuiQFzw3e7wmUineCcWoQLZPOZ0yDzmt9ha23TKe03wrM8JdUe5xMzs2Tl0pKtM7+h3s8cUXaDEZnfZh9LUbHCxYz1pqbU61vvYj7H5gWjZJ2DbOFR7V+jml4Xt/c1UC+G7rADonHCTts0u7Nf9uB71We4jkO+oFh+F7BNJEXGu10jxGriuoC+YO9OCchkrtHCOqVUltgNbr0lrEx0DC0CWzDIE8J9Odl9EPvzn20rps4tPeYd/5PfifERJfOl8e4D0stPkIxdPFBPGdZwXYQ05Qbike9srpldr/KCKwYaBOhvmAS+XK7d+T37ZI7I/NCVD25Na56bN9fnDDJfAeeMV4d2p1dCrLdXGh61j2xIfyULRp8I62Bn93BNG9N/g23SJjgH1nOVMTHL5nRgaEG2UTAEKANa5EChmXn2TLY/DD4UKUUd3VpFf0vJRrouW0qnq1xLUFNw1Z1+VNSq2LX7iA5qs+MX+MJVIt1HoMWng1/F2QhwjVaxzlBrymMoDAhCfpenuBLA/z8ZZuDl0l3DGl2s1mY9QwCJfLvUhIxjFD7enw5eI3bP0yj+FQvLuhGZPJYs6xro6bFKdyNUE9RNeI9jNl56KTWWGECdCNX4X0KEYWNkc4zKsYhhGN4ucBXueNxjaYFj9UN60eIWpHz/HnLkCM60rfA9KTehXf0jfl4c3aQxNDfdEzbVGesBunMwScuKjRKrtCJ80JzFrwEwYpY1FXQpwCWCnYMQ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uXdYoUBafk2omlbwRNQeP3Yxfkb3BmzXyatmFZ0zilYWlr9PqSVZPwuYERotcS0AZtZJmtZtYXDzeS8egrLTeTEiMaDEbGEa7/tS9qmx/32FwhmOrZm+hVQXD538WGV8VZWWgu/sigM5kx26WFvv7/5hNAxuhTBtzQWOUz+O4d/cPgR1xUm9zZL8XNOGjdgoExI8pi+ca364wnKMegb+JBSdXYpHfXEI8TjeXFfWd9ZGhjDuOLHy3Ai85Cjx6cQ7VXOgUwdFlG47SSe7p5qjK7J7ZvBpPb983D3/Bl5VrixiJcwR6mv6LHKP/DX+ow= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be02b222-bbb1-4d11-7e88-08dc687492c8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:26.8911 (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: ohnPUBShgN3AEPpy5CrtrhhqsoUe3npAnJbpRwCJ1GEoKFthyWDNQM6ftN9GO1X4QhLgNs3vGtKMUR5bVz0L8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: buFI0N80llPZ2RrX2aF-lQ16QFipq0dp X-Proofpoint-GUID: buFI0N80llPZ2RrX2aF-lQ16QFipq0dp For when forcealign is enabled, we want the alignment mask to cover an aligned extent, similar to rtvol. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 632653e00906..e81e01e6b22b 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -61,7 +61,10 @@ xfs_is_falloc_aligned( } mask = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize) - 1; } else { - mask = mp->m_sb.sb_blocksize - 1; + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) + mask = (mp->m_sb.sb_blocksize * ip->i_extsize) - 1; + else + mask = mp->m_sb.sb_blocksize - 1; } return !((pos | len) & mask); From patchwork Mon Apr 29 17:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647464 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 BAFF81272D3; Mon, 29 Apr 2024 17:48:53 +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=1714412935; cv=fail; b=peH6FehkM7iRHpFlOOffm9zhrzn7mA0myPES7fylLzM34lrYIUzFYsozKhkjDQuFwFbvYXe8WiLWjwxzw3vqhW/9QVBFuidNVITHpfs0cayPjHUc3balnWIxtwgbYJD/2jIes0j7AIYeutco45qVv/tYmAvuOr49p62xeVKpJRM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412935; c=relaxed/simple; bh=DN4HWIb6KH5rd6ktbPAXWJEe37BdzJzg1/90WnjQ3cA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kgklEgiWOum06hqrQwJSWW77/ddqP/KCbvq6eWaxY3UUjZOIRYEW7zXH4f+D0ojpPUzKbXGZjOeE+cD2vE12Ta6OAStKz26QDBz3tTnvgG2uvIS7D9uz0i75A5F3PRmSih76sxunl58sfjkdrda3k3Jrdnxnjhbkfs4sXH6FtTo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=HtnPlLOx; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=I6p020Xx; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="HtnPlLOx"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="I6p020Xx" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxYYG018146; Mon, 29 Apr 2024 17:48:33 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=64hoEnrzlSZIzbdkJysfJjgcI/JWZhuofsOPS79G52M=; b=HtnPlLOxLyvWnbNfr9GnfhvlJ3PHcuFSJymVZedXmNxqHK5UKTsZLEqlM+4cRLBHQVRV KlKdtr6ixhqs4iK9q0gU48J03UDXNW0crKs/zdfOpL1kzZ+DEaJYXejXuBcRRUMnqfXE wagdgHoxM/P/SZVjXpe70rDS7jQwL2L0el7ioL+roFhYVZksVFcL5/gDwcbUOHlkQDZP DHLlaje3LYRS3VM5vN+Nvc9FIdYATKUrDnWQhW/uHS+YlrE2OmeSvYIri81Ts5Wlv8gm DFdHo5AxKJwgfcO/kthUOLf/QjXDeATODWUjLo1KBzu3+ZNC3yqbnZ8aptPeBEdExMEt sQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqy2u92q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:32 +0000 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 43THkxUZ004324; Mon, 29 Apr 2024 17:48:31 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 3xrqtc7ns0-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSNURzVGxb2sRvf1tK0emr08j7JkA5FSuApybRTfyVunsbwcCmBIUJQAcC3Xy5JzJ63y0723Aubdm8vImYRF99b0tv0Pg+5ksvcbiTaVc74L9hQPZkHBRl0FUwuyolsTCNtpvfOLu6SxE0np7TDabnCDbZT64iJEPeUmVeVu605378j+ICxNY+SjYuB4ndlI6TnaJGMRrBVJjWi2GnurzjBIu4gQzuIGyXnqA6iG7fWml8IaOWxiJV3wPUo2yUyIoWVSDrGSz585CUKhfN0bC0vryutcJOuKaN2gtC+oXabftWH24NecTdpDAnhSocne+NcqHjW7pBfL05mqPjVwkw== 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=64hoEnrzlSZIzbdkJysfJjgcI/JWZhuofsOPS79G52M=; b=DBcbh4/2xK6oPNpfbxbc7Aq9rHgq8S1DBqgEjbPJCOfZcfxUfsOwjyVElM/2eWNmt9E9bIDW7hfWbhpXDfqpZmpMkbVEG3cDeC9cKk3ROpH9O2+ijuHXgvywZVnoOJ0QC5Ihso+m0IwpxRtkiMfmtddOTybzIHv7UQ77OfXZnr9HwVT67AqtavCpJ612wSyOyfiXXR7+ffd3o3MMMDlvix+bV3oe5LXG7RCuJ2a7l131gpa5jc+IRyraS1hfgDn45gTUySarZ7M/eOqpNT8hY28mKB11eRebZ7r+HQwzPDd+Kn/KyKgJfCIlR9btC+gKsBvexC5d8PjVGgETxzaaJA== 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=64hoEnrzlSZIzbdkJysfJjgcI/JWZhuofsOPS79G52M=; b=I6p020Xx4SQCkGCBiCKJSo1KmU78YWCnzuSeFkGQI1axk1y6oZZ8f6eA1J4eQeJPrgfTP29kOIMs7/YnFIQb0v66rbBE1Oud5pkHCLS54RqHIEvKSgObsLJNt8P7PkRwN6ndb+DUr8A/0CC6w3pgoFT60u79xY26gO7ZZtflbpg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:29 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:29 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH RFC v3 11/21] xfs: Unmap blocks according to forcealign Date: Mon, 29 Apr 2024 17:47:36 +0000 Message-Id: <20240429174746.2132161-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0028.namprd13.prod.outlook.com (2603:10b6:a03:2c0::33) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 3affdcbc-7577-4cf5-9c1d-08dc68749420 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: ZlGmEVXSHDP6J0J/4xI86BwuRf+oFY+s/EcxTxCZhOFPrgYGCs33C2uIw66ndcH41fC0NU5uKkmQMbLR0NYcqtPERtWqWYHAPpg5SP/I7llI3aMPgLXoSGA/R4V0gailZnlmYNhB4hJjpEAKjUgPtDPXiNzJ9mLDEWr6yCcMl+HzvqqCnHjKLjCzjQAxxaaue/hLCoF1qL6kwj20skDjqVItuyq0j4gwVnD04/AdpieyoaLi/22D6eqt0SyXI/CM/b9YIzsCc8ly25pERiPdqr32Wc4fF7VuM9hO1swF4VRdN4VfjbfDVxHdO86AlnEJFAsSaxpqrXgeZELvOxyZx7IyGoZyb2UxMInKGDdJMGkmqpB2drXM5ZxVn45bbGi93MVOGST/gFOYxdMIxG49bgvQ+rCBiZopXn+GojYQLS+R5XxksJVuD+VaYSbJjHom8OIGmgbzae9Lar75ekgFLeCczPzawQ1WVx9+W21zvxKU6/gtJYhbsHWjQlCYVQpHAE9ZsEtZIdE+4o6S+nNnRMXi+TcKiBctSVg3GRYn1LWGQezc4rjhO4Pzi48fVcuw6VXriaDvhu1K5NJR3+CHpIFMDnO/DpGdt894TLGbk2XYvXDJRir5DSqjikJITH5yvphFwNXJAeq3t1/fTMYH1TFVGXKrGWQnr3lHf4BnpFN1sgS4lHaXbmiGKpsXAQ/7CW4dwwLCG+KStrMzvVgnb9x7wRrb3GN+W3YHdRh7OCeFO9msiMLFpbBARAZYxPA8T70+LJYqEsAW0Xra+UVs0Lgfd2hNMiBQwW1oTMToZey2/rPWEL3/nT2ok7HDYMI2CNAUFVIQFbs5VjK8XzfXnZAdYN+lQh4uyjRtbiPwAAvZjezuwNB5drRuCq62arrHgX89hzpY8IlP82cZ0iQbExUHs+Ya6fEJGw5jwynmcRT45t8M9eRumrE1sqI/N1WtEb5L6rYJS5K/kaBNu7vX1CtTL80n3A80K6DnuKsnTNfXONI2m765bEiVaML5BX1YY7InROv0yXRew6TUL6KeJFTFa+ECEiPUkThJLhA/k87h+X2sWYmrT9ELGdVs9bOIUJc1l66YBB37nvdmEunddKNzBroF+EdRdr9EysF19+XP1JKAdXlUISpOMOi3ehIGbLCbo3G3WwVQADQKH8sHnH6vQ+d5uuuzy8zDR5pCGnV2qFa1KbKuvfhMEQkRuxSzjqaLLppRDYwpkilr5HxAO4t1SyIA7M0ea576B/BtO9xaAgEQkTYhbwIUlzVwO8C8NZIFse8IGrsIc+DR0Ybv9Q== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qnUUv9ywoAOiBuQkDexybCyRK1h1H2vuU4aBL3PEZ0c58hOKD0cYLaSfKeOgxczLtmRWI98A+Q1gbXXNEjXqnRX+ybUoW+v+r/1K96ShjsWwVZfvqXRk8c5K+CjQqDt4VHQ44qLVXp11A6h62C48hrXV3do+9JsoIfR1+OP4IQLII0sqzDfthw+eZHC7YoONSYKsU2XSX3R54KQSCTaLLVNPtgDyBfArsvgua2c2DwH6YFgfzn5aF8sP5jD9fjqgdY41zSlkkZYKEQlgX1j2wVOZ7cuEsPK3J9YrTncnaGTRPPXxLpi/+9Zfe4NjZMCrXKvCKMLNL14parvoKTZwB3L54f7/kmSbvigU3fyrf9puiCO4foiKPfUEhDDUr4ASvg17cUEuPjRJfJSDW8mvdrWFHuyfEHm7ot5807cwScKWavIeZ22eDRrtYyVw8GC1mnIMXw4thwJR98k+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/2g/VuLMoTXA9Eono2OQuvOiDPzrKnbS3C4O6u4vw1nTRLhS1DENRe+bi07fLHYW4Vcu9h6DZURf/Fi4B5atoJBEw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HTRfjn3giintsNfyN5PIZdhEPoaip9/qKpVDbzSzMy+/UvSZvazy+FuqFmPkKDY5WHWymmTKQl67GzOvC4smMN4UTaLN9GGFNmavwoTpRgZW5CfFRNMFhoV1FoDL7at2FHTl3+jSWi7RGOlTGUwHHgcr6Fy60O2TtMRrJZiOePCwBHr/nPCyh6Rxf8odEksgVRSsTLD5Oyl0tFPGrp1uT9FIBEY8aSSykdypReRAcxjFAHbKMNw3jm4Aa2Gq1xBkVRifGkpU3DFSuN1Y/UvorE4UQiLzrEV4AuN7iYBRNO8lA5zbHwNbGTg+w81ojxtDQaAjmVYJ2lZHQoi/LLwvBEjvCuPluQ/mollrbJWyJRdZJl3WHXMOn/EDdyd+ywsk9+QqE1R/Vlzpf0TjA08PCZ05OIRdDwDpeqng4rcFj3A4O+mnn90jd8X1jx79BtmqbWS16EgH8N7yXzh9N+5AsF1Olb7o1ebHuS3cd/7tkZkiawSz5FtSXZf1Zt5vmMOos1Zw71g6y7Ltw7dq0QA5aTlaNe9GONe79yEwa2av3+FFnNhsV6rxVzvx94igjPe4mLaFs4y2clv8vmrctIy9E1fuxeV9W/iRRAxtfy6j7rw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3affdcbc-7577-4cf5-9c1d-08dc68749420 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:29.1676 (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: AH2DmNqHluUsvPB1X2ma1SSBQkG5WjmJ+qb849QjLKIDqHHOrXFae6UH2xyFaIzb/hyP+aWbjLW3ofY4bbeFuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: UQsdTb0sNUBlD5dv5_bmf5HrNoiyv2xm X-Proofpoint-GUID: UQsdTb0sNUBlD5dv5_bmf5HrNoiyv2xm For when forcealign is enabled, blocks in an inode need to be unmapped according to extent alignment, like what is already done for rtvol. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 39 +++++++++++++++++++++++++++++++++------ fs/xfs/xfs_inode.h | 5 +++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 4f39a43d78a7..4a78ab193753 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5339,6 +5339,15 @@ xfs_bmap_del_extent_real( return 0; } +/* Return the offset of an block number within an extent for forcealign. */ +static xfs_extlen_t +xfs_forcealign_extent_offset( + struct xfs_inode *ip, + xfs_fsblock_t bno) +{ + return bno & (ip->i_extsize - 1); +} + /* * Unmap (remove) blocks from a file. * If nexts is nonzero then the number of extents to remove is limited to @@ -5361,6 +5370,7 @@ __xfs_bunmapi( struct xfs_bmbt_irec got; /* current extent record */ struct xfs_ifork *ifp; /* inode fork pointer */ int isrt; /* freeing in rt area */ + int isforcealign; /* freeing for file inode with forcealign */ int logflags; /* transaction logging flags */ xfs_extlen_t mod; /* rt extent offset */ struct xfs_mount *mp = ip->i_mount; @@ -5397,7 +5407,10 @@ __xfs_bunmapi( return 0; } XFS_STATS_INC(mp, xs_blk_unmap); - isrt = xfs_ifork_is_realtime(ip, whichfork); + isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); + isforcealign = (whichfork == XFS_DATA_FORK) && + xfs_inode_has_forcealign(ip) && + xfs_inode_has_extsize(ip) && ip->i_extsize > 1; end = start + len; if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) { @@ -5459,11 +5472,15 @@ __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); + if (isrt) + mod = xfs_rtb_to_rtxoff(mp, + del.br_startblock + del.br_blockcount); + else if (isforcealign) + mod = xfs_forcealign_extent_offset(ip, + del.br_startblock + del.br_blockcount); if (mod) { /* * Realtime extent not lined up at the end. @@ -5511,9 +5528,19 @@ __xfs_bunmapi( goto nodelete; } - mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); + if (isrt) + mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); + else if (isforcealign) + mod = xfs_forcealign_extent_offset(ip, + del.br_startblock); + if (mod) { - xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; + xfs_extlen_t off; + + if (isrt) + off = mp->m_sb.sb_rextsize - mod; + else if (isforcealign) + off = ip->i_extsize - mod; /* * Realtime extent is lined up at the end but not diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 065028789473..3f13943ab3a3 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -316,6 +316,11 @@ static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } +static inline bool xfs_inode_has_extsize(struct xfs_inode *ip) +{ + return ip->i_diflags & XFS_DIFLAG_EXTSIZE; +} + /* * Return the buftarg used for data allocations on a given inode. */ From patchwork Mon Apr 29 17:47:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647482 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 51A341292DE; Mon, 29 Apr 2024 17:50:46 +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=1714413048; cv=fail; b=YZwYMyISpM0wciWtcuiVfz0m1kCrAgqRCEmC/7pfPK9CftkrYPMT3fwa5gb43EQNwtHHcZQHuHuWv1nTpAKK1NRiXXBfujNf3qFHGpsvBkA6Kk5WVSm1TmiSY9v4oPo4yyvl7n5xgj994vn5bk0XuP5zMhyiQUvre6wY5q9e1/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413048; c=relaxed/simple; bh=Lfj7dnv4oK8/tZrWvQrNy4WYdN8nGaWeSFop3om3WsI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fn/ZPOjTEVQIZpoXbzxkuumaUUsIN2QH2zsF8SIhr6oQR3oiWh6v48V1f7dUYGgxz++D9qFcgyvT00Shl6ZDNuTylY1C0q6a3nkYSGqSoUtguRw1Plkltrbpx/34bouyqu4R04m6fr7fg+42Gg61FwZaBEBiMIqgeHSLkBsBGlQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=likBJE/v; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OBytg7q2; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="likBJE/v"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OBytg7q2" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwmR9002385; Mon, 29 Apr 2024 17:49:05 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=R5W4dPRDujBA5kLMQBCt7AABRo3nuz6Ha5zCRBAM1Vc=; b=likBJE/voF84C/csKKuXZy6kZjap3Ll6yRkZzefpsu2usYWjSYTEN7Q3fsVSEkCTDMJr KAbA6Nk+ui6b+RZK3lnu0bu/GcWSYE6I7oQAWYBI3bcL35broeQxH4trNiPk4oR2x1Ul 2zad6vaERj9Cf0nQ/GTftPgMadWzjUBGqfQ9BB+ZSnQIWhFfvln5emeAbnVXVEaS6CbK i6ebIqEdXJH/piONoThO/5JHzHVkspuYROAfiBneGCOu7JQdzapB2QzXWc0BZaOSbEaW E5742evpZZEq2fbl9GU351qU8fF480R668iFeCU/BsE3NA5pXsJQ1kcjcxRcsnx7Vkjd 4w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqseu6qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 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 43TGRTcs016720; Mon, 29 Apr 2024 17:49:04 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtcpxpb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fSlZTJnY0MpgoljU7NzMxhHlHQHNo+2nMeiqteuhws/LWZOurzcD3RgUIiqqNfIgwaV/WKkS50YVh6rbW/WoT7YESoJtSutibJoHQA01AsOK8UzWYJmEeh2wpVp5lkjGkjZzbNBrkqXNqUAsSJev/g3hUlQbb8aXaC6J81u/HTafPM+I7H2AaVMf34MX3HqxY+7FU/VI4tHT6xPCtCpG20rwXLNjew8JZyupS+xVvW7z5yGpw4aKcdLQBp+BPftZ14WNxeeMtNgFaXxfy/LpYFZ6FRgjDKywnr0zbX9uXh4ity1D0Mv2FHc48wrMiyeud5KKH5Fy9oS7nrJ8b9qp9w== 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=R5W4dPRDujBA5kLMQBCt7AABRo3nuz6Ha5zCRBAM1Vc=; b=CrPGMZ3DNdfbRxyS/8F+gR8liD+5PA+DuQk9qxHygRj7ptyBZIL29O4+w0313HIncS0uzLPDUWa5bR+wiAgq3ngw+u/IrO4HdDA5H98Fyt782mgsxTAx6jyHhGoPz1e+qT06ZV9Ct52ncJyICFVkenLEDd1DcxZVVYM+HGFfOqNwxsHSGfx7XXLxv/gPDIya7Ov/gGmtuMG/t/T6xA88M+EscNv3bYUDL3W5LWH/BMr1YVXbMiNSVPn9XO8f3tvXVVoDyXkME1gAaFszwXQQp4xuOKaG7iJHNKlfirncDnHkuyaiMgEP5T4mr9giFhDTUYgCQq2EqrhzNUgKLUMJvQ== 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=R5W4dPRDujBA5kLMQBCt7AABRo3nuz6Ha5zCRBAM1Vc=; b=OBytg7q2rR8iluTyZjXe3KXyi4aRV1L8q2RSz90CwcKKgfYFAsuvYAD6/XIkqRBmGmDLPn/PGjLQn30xk6YN44w5Jyy9SflvDsMjA6bLUvn4PiHC0wJQGMJ/DaQL1Sfb4t1cjxd4ykJuHmicm2bm6MwjkNfdU2Fs6nZAfum6W28= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:31 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:31 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH RFC v3 12/21] xfs: Only free full extents for forcealign Date: Mon, 29 Apr 2024 17:47:37 +0000 Message-Id: <20240429174746.2132161-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0016.namprd13.prod.outlook.com (2603:10b6:a03:2c0::21) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a16b780-9eff-40c4-bd3a-08dc68749577 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: BgpTXzLStBBymoN2URJi//MLVrQaNewGIoUmWEOV6BOIbEE3KrT0DMTNnnO1ow7q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xGhxzrrpNILl3/d1SeDdzEYuWnIJ9O42LjQWtAbVbn/ZEDkqznESdWobRQ7UmAq+b23pnndOBRq0K34n90GDlp4TZ/Bw2i9mY70lN1XoBdvylNwwPQFgyoslvbc7z1JgYmg29TlfdCy39nNGuFw== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UP3KRZPJfLY9H8J3XhlSS/jBiZkb9xIznhOTDUQyzXdD6RtW1fYUN59cBlnkZ3aPJzw43L3Fu32SMBxVUZS+Kn0OPzOfbMz0ONR4Uvq0jiJ3ne6asz5OiuSmLJvdnHFE0kfZWLLplBahLHtSDjtP+Mw+YRbg5z5njP+i5BiIWJWrKcGFKk8KBOtR7OZfCmK90nH0mKkPEXek6Y6K8R2sm0qEACBZD5y83NY3+C3SPPvzCSHDgsucCRMw3Z4w2PrGMYWRoKvUVP5uiPDYshovorIKMyH2y3DkamxBVRetF/wcYrSNiXc8Xuzg7bKUTGUhFFB8KSTaK7NArn9YeQ11m+09L3auW5zNNeV10/G1bJZyuILVt/sILkTyCnUsn8PA73wCbzB6b+U0XBhpk/zDrKsRGYvnybGQ9zs2b4Z+Xr0Q28RFANdAAOHX5HkLIfCBZk3hzF1k5FWlfPITy+scLa6SRLFb1yt+gyOWl3KElnG2H96+xR/EIKbsCCcURBWXeoAoDrloxIag5oAb0GjVDz3sKm5LzstukkQQJd7aqhhpZLG37HJbvZWOT/2IeWl5LN1hEAb/NdsNQejoUEcrSigg4HnLzFJZsI1df46urI5dbSHdqpJBTwoJnvOG2qPgw1TnX2kkSsdmW2tpVUSKMy5LxSaxi5p0z54yBAhydY/wNw4Ike8I/RDDE0zJrhUb4R2NaIg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hnc0W5PrpN2C/0OtsSwqLFgrU8OXPDaY59qu5i/0eyEvTMMJCqaxotwaG8eawN7DJm+kecV/1EXCV4uNgs0VUn4OU8BIwm/5/8hmemI3an9+qBeKfTfmeu6GB+7dBYAjDE2zLFtylpo0jcLgznhhfGeY7ubhyFtVvd+KDOL1X9TMbVAN9Plnt4CNq6H7tED7qm/n3mYq3fhd3aEHVDF2BOveV7HUWZwPmxwuLe6FIkynx4mCxeqOVekBfyBxVKYOTC562fz/E1vGV49+7zeW+dRMrs8A7gpLcpRKwWga7kDNaCuaVq0NQR5duhYFXe6Rp0L+6eYb5Dvd28ZbyXhr1dzAf/3dVWB/hw+OZwDSbzai++UPYNi38mvKzupvMHPNWKmzQO9UNiuqRU68mkablfZ5iEXHlgzyKyMk2q98vQM7JuBbk8pp9kF7jNk1KQ3NQFQo6atlcICKW3fjpwzWVTUACCiP/jNWgnyzOQTuxtMg4fzxZ1QP4CwaLkjTGQ/CeRIsx0/vtxKG2ImcUXHyU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a16b780-9eff-40c4-bd3a-08dc68749577 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:31.4206 (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: casGE9bpcE9Gp7Ptcs7713NE1YykhwxthcxUs3JbnvQeynd2nj96Ki4YgCYL0KX726dUVAM4G9N7ce2JXQ9kpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: UADoqFf8zx7YVw6YBSeZQm5wU0rBvb4p X-Proofpoint-GUID: UADoqFf8zx7YVw6YBSeZQm5wU0rBvb4p Like we already do for rtvol, only free full extents for forcealign in xfs_free_file_space(). Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index f26d1570b9bd..1dd45dfb2811 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -847,8 +847,11 @@ xfs_free_file_space( startoffset_fsb = XFS_B_TO_FSB(mp, offset); endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len); - /* We can only free complete realtime extents. */ - if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) { + /* Free only complete extents. */ + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) { + startoffset_fsb = roundup_64(startoffset_fsb, ip->i_extsize); + endoffset_fsb = rounddown_64(endoffset_fsb, ip->i_extsize); + } else if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) { startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); } From patchwork Mon Apr 29 17:47:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647481 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 61ED3127E1E; Mon, 29 Apr 2024 17:50:45 +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=1714413046; cv=fail; b=vGVbgzTzNlzxH2uVuU4ew/m6KKvXWu5kn5WghbiCOyh70lSVTw0MDSqbXM6Dtw6fVnd6mh3ZhlAmTuuxCkcSJIxRL8aW2kZ7jb0CpgGLUSFWnWaupKoTRTwrMMfn3KVRe/xucYc6/CyJXlMnzxu6zRuoBqHaYVDlaseopydAq4I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413046; c=relaxed/simple; bh=2+Dvc/iH/zUzuqViOW6sj7OwK/eifVH1xVRGMCKilGU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hCDca6bgSBP3gNwuG0gNw7hRCKu2AdyrimcqMM1zHnovRFzLP+2UcDRxREMQ67K1MmVq1HKTtasJhICM8vbE2hzeLrQtx+EaH3J5xAzv2leoQQpMD6NvB48KaAlaKRe4fzMY+hQvclFVOjaUaoGdIjqpJa+Ivtd2vSo0Cv64rwk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=NXoSUrzY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Oytqzklx; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="NXoSUrzY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Oytqzklx" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwmVM024630; Mon, 29 Apr 2024 17:49:05 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=Eioi8yuVZzq8jDWbsEiokCsbC+jOLcMAsr3yVp0kG2k=; b=NXoSUrzYMMP2NJVVwZXcvgkXhtEWEm/OcdfB4ZltPMxMTOIM13ab035pWoJn9esiKcre V7oTP4D+LIntdw1taIZ8/rzaGOppZ1n61HyOUh05RSp7MLOXi3Mb1A4dwKe47kARBpP3 3tfnB91Yp66XGPe6GRGdvG1xeJhFY/6SpBztTcCY3h3zUuKXVczl2l1r6tVT+VmU1R9s e3t/RsWlQ02nf6NubDd6ksOpUWFvWI+9/0k3z2dD2ETKzraWz0t9KFJuNWzZ0PhgQ/Lk 3HDFImiyyAwajzd/0HzBQguxFUB9gGQy4+gmFg8qyLR5Juau6W8d2eOUEGRpnp7oElEC Qw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrr54b7kk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:05 +0000 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 43TGRTcu016720; Mon, 29 Apr 2024 17:49:05 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtcpxpb-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UHccTBhe3Wl/9m8Wp08dV57m5cGL3KmVOOLP5l0snTUum8t2C3whElRyoqLbgQOtcxDyA67TTPqJP+zx4BtITTzLO9gEz/w+4zaiHnX1eN/Sx4p0TEcATBF6nIPv9kQzC5wtLvyd2cHFMlyYVhckSIUt095rJxmN2IvJ1tLzQi9LLzdD2r8/HohxpasDfg9NsH+iL/ZnsOzYgh7omV2GSHU3wZPkiLbsMoEVoTd+hdC2og2w3dbcPth01PZDm/rj5mwkMdubf0zPsD+D6PcGWjDinBx48u6WqhGC7v/7Myybw01X4huObA5yK5ct+Jvw8onXQjfG5zYpVujqOCxduQ== 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=Eioi8yuVZzq8jDWbsEiokCsbC+jOLcMAsr3yVp0kG2k=; b=Bh+kSRg25eS1Kt/b9d0NqYIDg+WyOL5L8o8qRXVp5mWINJY88eFf036/KXu61qklgOaWpUxIVCqvRYztPSrLps2deUbCARX7JzUYIZqu6jB8hEY33wuq7DtR2BumaJ+LxIwnRAK56Tkga/p5I0rrNxRdTKYlLzvqFmIP+kt8ff9QfHOuarZg9WWnIYyJqNmiAci9NqUMjBWyYRGKvc2tlEDQpU9NxBbAvR/WoyppEUgpU1T0c+diUgmWR+T4S/TR5W2AtPWrNw+S14xCiM9MU+c7EWBPjyzDAmHbt0P0UwIgPYlVcN2v7BlaLv0S9mOruLC1+8amTYQ8dZ/I15yofg== 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=Eioi8yuVZzq8jDWbsEiokCsbC+jOLcMAsr3yVp0kG2k=; b=Oytqzklxw1uxgqLLPMYXQu7C0YFzrDts6/uC8wq+/KmoJdFxQykmuGQnHYwugwqEYzdCccv/YKYTwKR/6Vi7M4V1y6lnt7vUI3Kq+NR6z5HqQXpwUpPxyMrKKDBZnCbCSExMiqa5noOeDb8/8gohd5zCLkeeJ0VLOen5MS2pu3M= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:33 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:33 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 13/21] xfs: Enable file data forcealign feature Date: Mon, 29 Apr 2024 17:47:38 +0000 Message-Id: <20240429174746.2132161-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY5PR13CA0022.namprd13.prod.outlook.com (2603:10b6:a03:180::35) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: 524ea22b-a72d-407e-1741-08dc687496dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: 6ZzAXW0bdrl2Wg2bIX/CLpEnmQ1TI2t8frAx15GlSR3lsSEh0Jd6iqxNK8v1aFEVe6fAn3amDoGYMEPWjlLpRoHGoQtZm7RThiQRaGuNo/5PEuic1LQyw49MPH3qyLmFLCaDFqLThfl1tuo+zJdZWxDOJPZwk88ia6Mphv5zW3a+xRMVrzycwOGiJXYX2XeIEF+cg71GZkCF96zRKsAkm14yboXCTeiZH65qXnR4Ptp3nvexpmVyKLTyTDyf+LbIcyPhXt1ormdNTOu6hpRqKCGj/XIFKJlgcjuMbozdqsaOKK+XeT3SOPPDSTjBndT/7u5cZWlvoX6dFgV9L+IeCc6yRmoqKkNhiMpDhHPRZkjbByfiubv9f5ucbFLxqCwDkdG/wicYRmvYqumW1/iOSFgP6KLO2G/P0YuQ9qgELTUHfI+47BSQBZbgc8CV8e+0KpcWoP+fXUdZQ4yBlK9xYMgkl3QUi5RqtNMsMiQVRLbYJHfCQhrsV1WjJiVGGeRjcqkSV+9Koi7luCeLN417/JryfHs/orTKD+f67v+bMVo/ynGPg00gfU9DKbGo2X604/Uw59GUEMNp3gPlTftxLZbFkYT+QF3fvSMfCGn7vL+9et3zfhCXfzOAX4zGw8YJQ2cd45QChLs/PV7m2Omv4Nfu5wFBKgBRmYEZJPKXDlBc9a6a6wUs2P6qq5+CuIWtu+hyJD2x47XK2PjVPUVqN/3rPmyOuNxrRZQGyWLkjBGCzg0Z0q8CBEcu2ytWEcYEwqyZkHjyekx1zA5XRfB1oPDxFlvArmpZ68d9y/J4Zk2SytMML6a/msU7DtbK3dziQ5DBNZbflrCP8DBfmghubkW4MxiGqEy3eWrFW1AgxblUrg8K3DmcH4mhhx3FUdtDVg2Yw3QyHa3UXXCqw1PMpuQId+2C/+wYPVn5jRrmI1tqSR5yrcmbRztSCt+9C5JkjP1EbBgAV//QaUbLVcibTy0pkZDliywDQZFVTv095qzo9ol6zUiV656YuISz522KndCnSVM10olZ5QcnJbhsw8AMFO15IMa11Rt3FNY2IB0kPXibEaXxv3DXEAfBLEypnmqwwm8xmtt/Vg1RgFRZj6Cr7X0aAR2erz0We/uOsly9Q0Sppv5mqs8xqjdpscCxZ527DRRK+lXTbNTIv23HHMceeI/VMEYdr6bVnKZ+iRcYDMv3oRSen26F/RXymm7ugHh2Qzndsh87tEkZyb08eUx/ImCszO6QJrJz3G8wKuK9GgDN7GwHRq6gPO7FsDxvgbLM6pWVaP2jTkNOEHRNaA== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSp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staCCA/6uci5/FzIZnxcezV24/XBTxPyRkBCSj2d2MCOE2qTUm06AiqJ7LsQDMOfjg2/J5HlWmoWx3bYqfpOTzF1et+YeiFoD9Z2S+XBvKyzaiqKLeWziNmpnV4d3eeRJB3pneMFUssYtXZmVgNvyJCg0SfHy4cpAuRGKI4l2XYQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 524ea22b-a72d-407e-1741-08dc687496dc X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:33.7591 (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: AvhQ/JF0s0I/P4lERFC0olQHI8Mwwk/tdpxwuGRIa2bOxXvVzjm8GYhjqj4NRj8QSiwza3srMCNObZFh96N5bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: H7y42Yr4XOUNxFnlV50wAfjKWYqZxqtQ X-Proofpoint-GUID: H7y42Yr4XOUNxFnlV50wAfjKWYqZxqtQ 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 4dd295b047f8..0c73b96dbefc 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -358,7 +358,8 @@ xfs_sb_has_compat_feature( (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( From patchwork Mon Apr 29 17:47:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647488 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 2FD181292F8; Mon, 29 Apr 2024 17:51:25 +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=1714413087; cv=fail; b=mN/4du0xP5mVwNMLWY66SnxuiUHM14MRCXhdIegb1dLrHKM4WF/8nxuSQ5KunZsn8ypa4xVYxiwjj2wXFutZL02MUAFU0CpRK8Psa9r4EMcmOQNlfjEA7bi1fb18ylGrVy3GdwpX0mo8SwAXMZHCnVd5xqhpu4vvrO+wtlCH50M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413087; c=relaxed/simple; bh=Ns1eGcdSDRI1xfTlYLj8DGPEDQHU8NWelw1WlDH81ck=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EA3AdeubcTY6t//9k9UHMj7oarJ8BNp6mGgiFYXk0jHvJLvQCN98B2ixDD7U/bJqVsEzSUT7p6oeUyYhxs5PY6f5075u8FAYeRCwYxF/pCcafX8+ZaYdkgThX7TK1+dZRWOJIiMOIQzTiq/ze2C4Kk1bLPJXdFanMP5M/Hw6WTQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=N8L92++3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=H9fmtQvz; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="N8L92++3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="H9fmtQvz" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwkoD004990; Mon, 29 Apr 2024 17:49:06 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=C218C2V92sC/N3cwZ20ex6c/BuPCg1fOvQVItyDbdwg=; b=N8L92++3Jw8crHtrOuBDPnJFT/eoxNqmWZYUAHPD2OXt5Elc1CvAU3PGqUgGpOU5EGN3 jcf1SA0Z7pkWYsiI6bqqEq0DEvYJ/WYHLaoR6Dv2udfcYSnRoyXbw8eZaInfQlbZcCVy is9aM9IHpvMD+XRbONpDhDQ4oFElEaA267TNz0GW6h+L46uzVx/rjI7SHlUsLHRIyTXJ U17Ms08TJPT/in/m8f08T9nGkXRTfY7/lYsE0Na0AtoUxWb5d68twcxJYMpd8zsxJKeD pwmlIRPjbN5lIH9wZUFDKJBnoybZWC2bFNlQLVbfdsMNpXbYWBQMKuOLSBOi5N8C0bcZ Dg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdek6d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:06 +0000 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 43TGRTcv016720; Mon, 29 Apr 2024 17:49:05 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtcpxpb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bf7nkTaH0VN8Z+7JABJHV49QKsABzLIDVgbTOTJUYeiDfy3Hn5aZAsgpxNCNR6mE9+LTgi8F8mQJgjSDA/P0r0twaKmM2+Qli+hXYfVaKPd/WuB+D+iWTu0nCYm23MHd3tWJLg/FWY8osUgWTt7E/a6Hs2ol2iKZCnsOkY6f+nHZ3Yt3qkj5Rh63BZdx/99KtmFSmnjQH5vdCvwyN2iD1sMce4SrvYuRry9KroSqJnbtM4LqtUNid/WE+wbfRZlqk+De9sZXwN16oJq0vdyOrI5i0P2T6YF8Jqgn/YjLziQGnr54KJRukHl/uUcGMy0cyiBn83CzhsVH6Bd15Rtp0g== 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=C218C2V92sC/N3cwZ20ex6c/BuPCg1fOvQVItyDbdwg=; b=eDBcJX97LubsNbh2vlkQCdbNT+3bKCFUkArlHHhs77CA1R2nsMXuZskTgU9d8o2McssxidaJVmstzfE1VynU4uzoWUE8MM7Aap91jcgzLOjb3ZyfgzXzLJ+ABEfAfH0vxd4H5ya75u8jgAZz27wV61ycVDxebMlhCrQlsIDkJ+3t3nHI642HB9L2cB0Jjc9GGxCI6gF+wTi6IVF/k5Q9ra8/XkDtnp5GN/mDfaPYPIr/GFyuMI2Fl165dD5kevbK47TsJy9Izx/birY7SJPBbuCttsA5r6+MUjDXxUpo7iztj3HFOzfFxsfaAzbVnazeFZFH9EIu80Rzn/j7UlatVg== 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=C218C2V92sC/N3cwZ20ex6c/BuPCg1fOvQVItyDbdwg=; b=H9fmtQvzgc+dmMfxDc4RjOOpBUDncuGJOhkBvWhnnR9Ggga7HkzqvEzH45EZM6U7OZTuaOhefNrUdwjf0ON+OvrgmSREbOSm5LfdGXI/ZQ8MmOsHUZyv2tFjPjMwneH2MFGJe1aluI3FqWx6u+4/7CbBks18AcmeBPpQsMbGB2g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA1PR10MB6389.namprd10.prod.outlook.com (2603:10b6:806:255::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:36 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 14/21] iomap: Sub-extent zeroing Date: Mon, 29 Apr 2024 17:47:39 +0000 Message-Id: <20240429174746.2132161-15-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR02CA0003.namprd02.prod.outlook.com (2603:10b6:a02:ee::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA1PR10MB6389:EE_ X-MS-Office365-Filtering-Correlation-Id: b62fa46c-ae53-40b2-c314-08dc6874987f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: p1NjG31GBtMy3iNBmv+I5vUrG/45gurRCv/D5M1u5b9/H7QQ5ipxnj9Tl0Q21Fz55TAdAGcx1TnUI471zNRG7HPKxthhQJc8jQMA037RD9PcK3CxkxzKeinENr95jdTWWXASAG77uwgDReDwbJMyAy42NCCPMsKjbppauvZMpPxPrySugscizpWcvC6z7laQmSQcQmv9C+QJ8xi2p/PGljbOE5fldSb6vl43QZxt5sTZexdczAE6+ltZ0fcvlz6AOi4MsKYdZTAWTNRCwm8Xe4x5C0iXRzAwi4vQL4hLhyR882a6YNAIEXP+AF2I6Ol6izjIq7/7ckGY+I/KVXeNGD9WAJrjKDJSvEAg7ZJfj83+qku7tQ3plh3HHyHcqA+/dDDNYU8vzWeCwjYSBz8OddAcBywkDuSbe16EgDOMYvtndKWhxKq0nGTJLcheqzKFixitIGHz0X3dKnMUfX8m043uF0XYX0bpsd/Gsg3X6ZRTZoNgiAf/aJBQuP13nS5OMegzn2+QoLj18fQhJqj5Vfp/WAM1H0tbcHStz5WUrrAd7gIqlmYP7TZLSRk+TQUeBhQmf8kf7y84sbGIpuhbwcaebRyuxIurfptL9OOJ/HJPrXHjqUN93q8MyEv2HXtF7VJidVczG8KkZTN8YrGEgLHzeRBuQuvsTZ021lI4CiEkk9rrTjoP+RgfVnej89MTFyA18ax0fRnb6LDfF0HIHZv4ZAuxhumIHlGZoBd9fVI75kqtpv6hZ4SZm02mh0nO+f+XUrwZPaqeMS7G+6tVyKg7hsVESMx7XF07yHQH40soMd+lXCjuwoLpejzYHn5KjFce1xX0dawbs7tcTpkpS+ldf62ZcDn5RbND5MQnFqwAIjfh/66hz/lRZo1fJKHUFrHFtByumuxPLv9kWwcbDA3i0AFW47tam5inxy+Eu0Jz2BMJm1LAD2c1QNd4/6nXWELKBFOPWu+ZyTt9FYZ41uibr7rcYclgSh2Sov3JPgSKjWzFekx5tfGt0VEfWZEHcKgwHBps3UZkbUOBEaSt0sWtXRuU+tAoNisDzBnLCwq59QuAFDXZAUQn+m1z7YcuBQqdxEkT6J9hFbNrSg9RdnjVPn0pZHu2spfm09UdmulwFflhnFk2xmmvRxU880LqtMfHR+J1k9WanSmljR8hdrIEz0yI7qQc7Dh0CEUwoastrK/AMzbLSoVsY617a3semRQSc3I6EapCfJ7Cuj/jM1cQJ36qQm0bEeYOoDhfs/1iQFCYetvUjqYNGUyrOVe398JrVgCk9S9iVeRUyVA1/Q== 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:(13230031)(7416005)(1800799015)(376005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B3LKISGJcpf0PyhV2IPI0LydQNC++HfUZ8dsu2PX6Fn9nn6sPld6qiYCmCWI3q0WfGZtim021i9PPzG5hJeVetQihz65NO6S3K1dD86KovtlnExpZj1Bq06TF7+fQVapxB9izBcGaORIh2NuEkOpBXGAjGZWAz9f5TQEMldqhN9fzdFNCUz9Qe1Ls/xo4nKKYrEf9vwEt3G/J6DbfronKoZWClRkJzNBb7T/PE/b7uP+eJ84jB7HuqwvvD6lDkFIF68YC9PF55de4fiN4GfpfrZoSkkjVj5yhcnJL/dm6oloS6tvq3IWf4CTIWBxLDoHG0ZzttbGte0F11u+u/o5hltoxHC4arl3acdx+Y/I47dBz6B7HNKAezlscuJjFLpgKhy+R818kKtLRhAZ3Qeid58sQwHj88k5GFC6+MT78G0MWPOCtVn4VArJzby6tIgyEqBNLVDTTlmVAbRV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JOgvsNYQ11bEpBj1ba56/cRWMCIf5mMFzmNjOewc/+yNu6QRLPEaYey94GsyeV0h3bBWOBTfmZhA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8Z6yAJueiz/mvuU77lMrij41fDmTnh918gFmY4HnSKkyLlrcv3JQcLQJPe4ww/ZxOdFTyyLg9tQ8ia33zfvwXfekFXdGGpeYDqldfEsbV4yhwOfsCm+zbKZQQHzHt8I4g/0Rj14YJkoxQQJxqqB2ItDoJ/Y9rZpPNyHn1ZTR0LUDkXieQqIeYEpbWaJGESQIBjf9zQ9eh4PMnGr4Fwzj1S3OKH/b8VTgfyqnE7YG7gJDWRbFGluA2hPHpdtRrW0N4AMHialbOZ8zJi/35bf1YrhJj/wwfl/XNfWmzL8NKC5lju8pehBlnJehTseDHmO9ds1EDSLKUqGp6wTY2hNaf1lzdkK9RkZwbK09eR+vPSZs+pGQSfd9QfICCApLMBaGHRji6jq0ON3IvvncUp5qbhwVOotffA55NfA5oblFHJMYq7IA5bx1uG3FeCsA1cwEN1c3IJ/UnqgpE6ofJ2/MYrdgP+hPIVkFDCLixMtXEMMRuff22McrE6+tYCZ3XO2Cqoj2Ybo8GUcyfrd0OZhdRqkywZPZCo348Vm6F/x44xFtahlCdZq9Pc/czQynK/WDms2KJsPpuSM+QrJlNcRMoiiKksCexz5yrUlnd3WnB84= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b62fa46c-ae53-40b2-c314-08dc6874987f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:36.5129 (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: pZiwM34RuSlhR9gFQjbDlkzEkCPCfJJdMBI1JDh+jA3nxzuhO17UPY5tlFZas+WaDWUWkJJS5+8SdaIFdpWQUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: 1hRdqiq1s2UG9xZaHB6SR0qS_Kh73KIJ X-Proofpoint-ORIG-GUID: 1hRdqiq1s2UG9xZaHB6SR0qS_Kh73KIJ For FS_XFLAG_FORCEALIGN support, we want to treat any sub-extent IO like sub-fsblock DIO, in that we will zero the sub-extent when the mapping is unwritten. This will be important for atomic writes support, in that atomically writing over a partially written extent would mean that we would need to do the unwritten extent conversion write separately, and the write could no longer be atomic. It is the task of the FS to set iomap.extent_size per iter to indicate sub-extent zeroing required. Signed-off-by: John Garry Signed-off-by: John Garry --- fs/iomap/direct-io.c | 17 +++++++++++------ include/linux/iomap.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index f3b43d223a46..a3ed7cfa95bc 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -277,7 +277,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, { const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; - unsigned int fs_block_size = i_blocksize(inode), pad; + unsigned int zeroing_size, pad; loff_t length = iomap_length(iter); loff_t pos = iter->pos; blk_opf_t bio_opf; @@ -288,6 +288,11 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, size_t copied = 0; size_t orig_count; + if (iomap->extent_size) + zeroing_size = iomap->extent_size; + else + zeroing_size = i_blocksize(inode); + if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) || !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) return -EINVAL; @@ -354,8 +359,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, dio->iocb->ki_flags &= ~IOCB_HIPRI; if (need_zeroout) { - /* zero out from the start of the block to the write offset */ - pad = pos & (fs_block_size - 1); + /* zero out from the start of the region to the write offset */ + pad = pos & (zeroing_size - 1); if (pad) iomap_dio_zero(iter, dio, pos - pad, pad); } @@ -428,10 +433,10 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, zero_tail: if (need_zeroout || ((dio->flags & IOMAP_DIO_WRITE) && pos >= i_size_read(inode))) { - /* zero out from the end of the write to the end of the block */ - pad = pos & (fs_block_size - 1); + /* zero out from the end of the write to the end of the region */ + pad = pos & (zeroing_size - 1); if (pad) - iomap_dio_zero(iter, dio, pos, fs_block_size - pad); + iomap_dio_zero(iter, dio, pos, zeroing_size - pad); } out: /* Undo iter limitation to current extent */ diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 6fc1c858013d..42623b1cdc04 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -97,6 +97,7 @@ struct iomap { u64 length; /* length of mapping, bytes */ u16 type; /* type of mapping */ u16 flags; /* flags for mapping */ + unsigned int extent_size; struct block_device *bdev; /* block device for I/O */ struct dax_device *dax_dev; /* dax_dev for dax operations */ void *inline_data; From patchwork Mon Apr 29 17:47:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647467 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 B0F91128396; Mon, 29 Apr 2024 17:49:02 +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=1714412944; cv=fail; b=iWnarW9wqirTDBZ4iL1WsGjB5nPgcTdNy14S1bTXkW/cfwDZKY8JR2v1iG1Z4rQwYOqGU4+jVrcgHLAcH84DeBxEmPn5tY1jJB82ziCER1CD0FKMFbtQ1/wEUlPBejOdheMNm7GHbnxDIL7OfnXg2azgEGAKB5s2T9rPG+q04Ic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412944; c=relaxed/simple; bh=CelsyOz6xL/rUB1Lt34waX7pfJegaXuezpaYTEGpoIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VY2ycf+VWU58r/VcSFbwS8d3wk0hyCFlPclFyM2S7fZlk1X0933f5kJV2bajVh+GHKcqKnJUcjAL+7iB6GjNvRQkisQTu50ep7Us4aunLOOpRXE9xsK8nkKR1ayhYuy94GpVyrL7tPINb0zmvJX5b5iYozDXEmr9iat58xg3ekY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=XH10qUr/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=XhTCcEXf; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="XH10qUr/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="XhTCcEXf" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGxRJV019992; Mon, 29 Apr 2024 17:48:42 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=VrLs352xxRW0JJbIYwLtyCQy+MOFRrqjiqzwUpMO8m4=; b=XH10qUr/uRRWhEJOmP2Kk+HRjfbPe1aUjplArd7Qwj1fwZuzmD9Meiy8EQ68b+4eAPo5 IEktnsf7y/xjGgI28VP9QfHhXsR5zmycR+PsK6aIDeXMlztKMXECLnQBvUeghEebJHkn foEoE+0dNErqlYE16YqCnDFdD6f31WuhE9yuTa14KVwCa0ONXVsQo4RvrgBeazbey2m2 8oNHzIHX74GF4A4lqiYYS0/J3BsYLNuzfz5fQeidr2aJReq7OKcfh9n6dVUm2cseWOF4 i2zQPPSZ5Q9qSvTKA4slN4J+P/jIxT19VIeQQaJLmZB8uX8cGIV+S+qMg5TcwsbZUQH2 LA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrs8ck699-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:42 +0000 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 43TGLjY2005030; Mon, 29 Apr 2024 17:48:41 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqt67byv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sxpsmyrta6KFaDIkUxTqIF2TkCh7MVCIakHIjF5xkC3hnj3m7IjlY9W0+XHEmSWlArbGwDG2GzqjPrYdFaIAjMQP/citLJBawIJE1XdET6eKCW65MCLLFdWJf1jXnOmk2n95MXGDToYSjeeh3Ptn8/VUkCnSqntQvBDhZkGAzZvB4ox8m5JT/wVxJAd+tnQ3Xfdrt3i4l1kPP7YfAZJZyhQJZ35tgJgTwwdSbzd4p7WSmks+iWGKv+Ydxky/RAbK1Rb5vi5GwsWO2yFNKq1WwsS21mynJma8VNJS9065kUKM4DqrV5vi7Xc9nnBCrVzzeeH4KHeQGYzHSXf+dto/KA== 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=VrLs352xxRW0JJbIYwLtyCQy+MOFRrqjiqzwUpMO8m4=; b=jZLjhDSy1D7ArqxT8l98A6ldbHa5LJsJReobh1sh0c9fqwFuKQwIWtoXGhky18movxGl2Yr0Z6dRl9E6ASCkVFhVMSHfSK8OPsuTXdNF6/3y7I9CnS0hoqFZvhn+qPZy5SFo4ZS7I+F1pH+QnAh2pafBmG9AXkfAHDoRMqwcReYw5xOS875FWfpIME9MRSX1dd2R1nIXvnK7jjBPFbkI4It1rcZQeEm9tamYn1k1caRsqd9QHrY/5v7VRFMQ6vYgK7hgXyu1MVrCckiOSfNXb6mInST2SC/uQ6B0eSKRtGE7ZVSXma4AkkFqGGLqKGI9kPmR6PHhoAw/OjEyAws0pg== 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=VrLs352xxRW0JJbIYwLtyCQy+MOFRrqjiqzwUpMO8m4=; b=XhTCcEXfAXoxb5G/IhTBkEKMvZRMIV2hLVh067cMhSIuAcjg7YV3cEnM2EXoqvh0MStfZDG4jQDSnoAdA5wRrUA7VVSSmdeo8qmoSIyNSta64xRTNpF1w1QZaY1xw5nKrCKtM8sZ6tp6xY4MM4b4gKt+7nLHK8+e+hN0ZNkVy5M= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:39 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:38 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 15/21] fs: xfs: iomap: Sub-extent zeroing Date: Mon, 29 Apr 2024 17:47:40 +0000 Message-Id: <20240429174746.2132161-16-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 6738c47f-df69-4c98-9105-08dc687499e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: S1zN4gkvUrHF41dz7oDOkyJOAZSCMoNL/54H8k6Dmi0ZCbr1IJg9LrqE0sBCTi3S+8hK2FdMua09gdkg+vb/kLyHtABsUTa8Zv+zyS59FDuGGu9ZswdzNbzi8kYp+Vg7sJSrjQ+VmRt3ruRmHGb6pSow3YDp9F8KbmMRLkf7ohiUmiEqrglBXvZ84m3QGhFOUfG4U727zQKzrueUpKF1bn9iCsSufvwqL4hAa4Dh/Ieqo3JxYh8AuZePyARCKQyLO19GcWHgnSTgRIxN0/TFLIuMkt/H5ltm8LtiTWsjqduPE9O26rwkviBut1eWsL7Lp9RN/4WKCI7dfyMWPJoxzXrMoQLE0/L7md0mR+6QxzHJItKrV4gYthocX/655nkdHw5GZEbTX71hLchI6imHzxkZWfuMVjNBoQ9z7kMKWUafmS/LLC4O8mZlEcinZUCoVOjDM4AvEyXBe+VRMyp/mSzsQUOBVcq62aGR9M5LMvAXy4Etp7REMay1/0KOFNzWbMJ/rUs0Zyj6ktoCMsqBSWLFxB5oD7NS5QtaSme/GrL0cOPDzyfkwrivyqKKboERjp7qgIdD4I8uftjjHakqBUe8zlwos9Y2KBUN6hyt7o5xx2hZTEJVo0PUM3neC9ae4gHccgy6gVqA5vl2FmGz8olx2QDCRMpAEGngtyShNNrset0GCVNj8icfE9Uae5tu3CG4lPkqCqH4JchvqCjTOzqrRxf+bwXqpvOpEt6YQoyiSWHClK3W5Kaw+282HvKFIMDgEqPNz727mWUppQz6Mn6KW5+TrjgzeHbmupZQT48YFgMRyqUeku8s6SOGu0UxL/Bex8CkHy5VYh2PmB3X/GNPCVeeIVtg7e+3Vzf8/9n6IF2qIwMM3Q32WE/a4Oqah7ED1c84zlyPT4QX2Pe1T3gWaZSipHF7lEFakxAC6ls4FWFF1/gBuDqnDnutDeTTu6ssdld9YUahV+94IpL4mAOgoX3MUM+MQNxSpQmLBAS9G9HES76H9md27C0RCX+FCyeLeJ0KWmDc5/O4d5ni8PjyvmF2zCq1Ulx8DkrHfNbzQMPNM1QnpVxD3UrOUPI/sXhhCtqw9z77MlanPEO1sSY2ecl+ykmbR01voNPfclgv0AhxOHaiH91eexBjtKQ123U7F2rIxGbOQF9lOlupQsl/IMA+W/o79zoc3zpUy/2F+jGNpCL4Wo2MQI+kgTs2Y+bNxfcvQ3Jab4B6sM9NbmG3zvLl+bWHCLUzi/A38S2utiyBaKXcC90DeowKC38PaZRQxKKq3JEJCxX82LfXRw== 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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fUAgLrXUR9Q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tcUdH5yud8goc6Aw0kdV2hBDEitKEBp2rUHZI54QqwPYqL+lplDP24JpMSAI0O2cL+ghutROy6csR+9u7t2nRfzw9hdHNagnUz4e8qQz531jqy4P8K6QdTLjiE0yFs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6738c47f-df69-4c98-9105-08dc687499e6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:38.8422 (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: O3TjdIDH23t6mlWkC+lwJ7GE47TdhWrI6Ps653D4xeuqQ5PtnN/wZxxvw77RU6v5tot8QOBgBnNB7bynIJXMfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: 0Lw-b671ApsmBz-E6o1J_h4fPx9gAtd0 X-Proofpoint-ORIG-GUID: 0Lw-b671ApsmBz-E6o1J_h4fPx9gAtd0 Set iomap->extent_size when sub-extent zeroing is required. We treat a sub-extent write same as an unaligned write, so we can leverage the existing sub-FSblock unaligned write support, i.e. try a shared lock with IOMAP_DIO_OVERWRITE_ONLY flag, if this fails then try the exclusive lock. In xfs_iomap_write_unwritten(), FSB calcs are now based on the extsize. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 35 ++++++++++++++++++++++------------- fs/xfs/xfs_iomap.c | 13 +++++++++++-- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e81e01e6b22b..ee4f94cf6f4e 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -620,18 +620,19 @@ xfs_file_dio_write_aligned( * Handle block unaligned direct I/O writes * * In most cases direct I/O writes will be done holding IOLOCK_SHARED, allowing - * them to be done in parallel with reads and other direct I/O writes. However, - * if the I/O is not aligned to filesystem blocks, the direct I/O layer may need - * to do sub-block zeroing and that requires serialisation against other direct - * I/O to the same block. In this case we need to serialise the submission of - * the unaligned I/O so that we don't get racing block zeroing in the dio layer. - * In the case where sub-block zeroing is not required, we can do concurrent - * sub-block dios to the same block successfully. + * them to be done in parallel with reads and other direct I/O writes. + * However if the I/O is not aligned to filesystem blocks/extent, the direct + * I/O layer may need to do sub-block/extent zeroing and that requires + * serialisation against other direct I/O to the same block/extent. In this + * case we need to serialise the submission of the unaligned I/O so that we + * don't get racing block/extent zeroing in the dio layer. + * In the case where sub-block/extent zeroing is not required, we can do + * concurrent sub-block/extent dios to the same block/extent successfully. * * Optimistically submit the I/O using the shared lock first, but use the * IOMAP_DIO_OVERWRITE_ONLY flag to tell the lower layers to return -EAGAIN - * if block allocation or partial block zeroing would be required. In that case - * we try again with the exclusive lock. + * if block/extent allocation or partial block/extent zeroing would be + * required. In that case we try again with the exclusive lock. */ static noinline ssize_t xfs_file_dio_write_unaligned( @@ -646,9 +647,9 @@ xfs_file_dio_write_unaligned( ssize_t ret; /* - * Extending writes need exclusivity because of the sub-block zeroing - * that the DIO code always does for partial tail blocks beyond EOF, so - * don't even bother trying the fast path in this case. + * Extending writes need exclusivity because of the sub-block/extent + * zeroing that the DIO code always does for partial tail blocks + * beyond EOF, so don't even bother trying the fast path in this case. */ if (iocb->ki_pos > isize || iocb->ki_pos + count >= isize) { if (iocb->ki_flags & IOCB_NOWAIT) @@ -714,11 +715,19 @@ xfs_file_dio_write( struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); struct xfs_buftarg *target = xfs_inode_buftarg(ip); size_t count = iov_iter_count(from); + struct xfs_mount *mp = ip->i_mount; + unsigned int blockmask; /* direct I/O must be aligned to device logical sector size */ if ((iocb->ki_pos | count) & target->bt_logical_sectormask) return -EINVAL; - if ((iocb->ki_pos | count) & ip->i_mount->m_blockmask) + + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) + blockmask = XFS_FSB_TO_B(mp, ip->i_extsize) - 1; + else + blockmask = mp->m_blockmask; + + if ((iocb->ki_pos | count) & blockmask) return xfs_file_dio_write_unaligned(ip, iocb, from); return xfs_file_dio_write_aligned(ip, iocb, from); } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 4087af7f3c9f..1a3692bbc84d 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -138,6 +138,8 @@ xfs_bmbt_to_iomap( iomap->validity_cookie = sequence_cookie; iomap->folio_ops = &xfs_iomap_folio_ops; + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) + iomap->extent_size = XFS_FSB_TO_B(mp, ip->i_extsize); return 0; } @@ -570,8 +572,15 @@ xfs_iomap_write_unwritten( trace_xfs_unwritten_convert(ip, offset, count); - offset_fsb = XFS_B_TO_FSBT(mp, offset); - count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); + if (xfs_inode_has_forcealign(ip) && ip->i_extsize > 1) { + xfs_extlen_t extsize_bytes = mp->m_sb.sb_blocksize * ip->i_extsize; + + offset_fsb = XFS_B_TO_FSBT(mp, round_down(offset, extsize_bytes)); + count_fsb = XFS_B_TO_FSB(mp, round_up(offset + count, extsize_bytes)); + } else { + offset_fsb = XFS_B_TO_FSBT(mp, offset); + count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); + } count_fsb = (xfs_filblks_t)(count_fsb - offset_fsb); /* From patchwork Mon Apr 29 17:47:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647480 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 4EFBB12D77D; Mon, 29 Apr 2024 17:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413032; cv=fail; b=sebeFUSnCesq7xsrjfhBDxntYVkl7c3A/Y6MtdDtondvOlwdz3jNcDR73hMTkaTE2/DunwgqaqXjH7rEf9qUxNDhIUwu4sqkl6S5q5LlKBAhdv+w24QZSdzSp1rEc4tQSNpNTf6g5TGKiZSE+cgaK3lnky6c+ETjyGxtMvemmWo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413032; c=relaxed/simple; bh=EeTN2G9wBb3XanDdpqivJLOdNI7yk+KkK/HbT2rooh8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SvtwwuJWc2aaIIfahC1nlkwl28mreKIsV5ZMV58sMoxCZAHPy93HrO7dyKmVNPMiBGbVrMmXhZWHRLKecHNGJ9Jhf3RA09tQqPgPwuXQpfTV/Sj9Ucnu1UFHsmn9zaFcU6r7CUoY8SrKBOGbdoaXhClM5I2a2zJ1YGbfC5SsN8k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=CnNIz5T+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DmC5K2mQ; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="CnNIz5T+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DmC5K2mQ" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwuJ8030172; Mon, 29 Apr 2024 17:48: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=d5I8ocHWHz6H2pM2fMYDqS7WJ4JA1u36cowT/km52RE=; b=CnNIz5T+wkcQqZ38QOb7YPZAJEJygtwwh6nTbPVPOvfoJ6c/ARN1EUfP0FMmoEVZhrFJ 2hMvqWxaK9eFMYJIBb4qiYxAmDFxdhz2agtReOuONp9Qo27fhTY569iz0b1jFcg3onTZ eQFA9+WFKMNuaT7NcxCy1RHZGiotx/SiPqwRMX0T0hCDoU5ecH/o2WyYKtLoCYSVHsRK 6fE0DBPn9oG2xs98bWfgw6NBerdzQZAk5yVZGXiCuLnMCJixxPQksLxgbY08RYRpDG96 +UUcRQdYuA2UFPPukE09nHN/JeEa5aERAQngrHDV3ywc0321K9hVLQl0a0oT+8AVYrPf tA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrryv3673-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:58 +0000 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 43TGqC8Z016783; Mon, 29 Apr 2024 17:48:57 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 3xrqtcpy8g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MlLsfWdyFuPTiVEAG7pAr0tKZg+d0iHoZQ0D+Ma3pqrnaANcXnHAatVTcUbMAHFmaoORcmgGQgyJdW4CxHDHuSZOY97g/pXD2cUl/rRWS99PO6iyjusabUaA+gruS07SaePpABMQ5g3BOH1JbhH8RBnsAnHhwMhp2KBPXhaEqfXJts31EClW8bRNyiZOTjV0tnU0yQ6RD4gkgVtyK7qrgy1OHKQSRNv4Xk0L0nBfwcVah206SM7ZsWUrhDLHIb+EDp07hdrkYZdX7rO/awL1kvGW5SMOulc4L4yCbxsUeo0hzCNOKwcPWpr2tJx/Ny5BY8VgElOh84yc/Y+fwEPo0w== 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=d5I8ocHWHz6H2pM2fMYDqS7WJ4JA1u36cowT/km52RE=; b=JDNTbuEHqWD1DgCRUcVUkMKROyQjIjsCyIurTeieXPspNzOLoLGva8ss8HZvXJcJLWMEpXT5M5M6lDWSsdgnIUozvwvFSIiWOi89TecPmdZuqOSY1o5OW4j2NOZX51qRlBNhIEVdPkKLFwf4HzPxndD81L5HWc0HRR5CS7srGBxEJ0H/RzV41WFYqPybLkzzWott/j4X/KCM46hjFg2//Zav3fESmyqD6QnlJomt0Wiznzb3SMROsy2DZjsUtJeW1FYUbqUnxgxZUPyhURPbmgW2K8ix55p2hEbO/KhPEqpiRFZ+WjwifhjQRePrg058bEWUe+f1x5FszLUofWN5DQ== 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=d5I8ocHWHz6H2pM2fMYDqS7WJ4JA1u36cowT/km52RE=; b=DmC5K2mQ1Pr2LdmsFryv/O9ot0GzLi/7bQk7qa28bV3Cb4pGxJ0P9Dr1VCsanjcWy3MxPOYVMS7On9RGKZ9G2ZUuVw0nsTY880xc0MbCAQJiN1VE1cvfoy17FZrbjpA6J5lR7erPQkvVQ/F+Mq2vSLKwbYaJmEITtLmOi13kXU0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48:41 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:41 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 16/21] fs: Add FS_XFLAG_ATOMICWRITES flag Date: Mon, 29 Apr 2024 17:47:41 +0000 Message-Id: <20240429174746.2132161-17-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR01CA0028.prod.exchangelabs.com (2603:10b6:a02:80::41) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a7369a2-599c-4aaa-9829-08dc68749b44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: nV5rRUV3bngPVXRzxeasucEovRC3Ga0HfACic+nP+DSv3Fbljh38tyMR16zAhGxLMqCt1rwCdLOequ4jCeB58gQi4k9Tn9gnIqnnVywFDbcE20FjTOJ8JF0hFPwUKBzaKrijonKj3ASEWTTmVRoSTBp2/Ucsz/D/ualQTzlnqDjAPlrHv6gxrC5OZJy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Zl7A2DVtpQkEBtpNDLeWTvSnYw== 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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KLWCfpJufffSsh6J/NqAo6mysQUnW4KoNWsfAK0Ivc/dlZG+Et2v9hBG/4LbPJlVW9pZJuAiHJ4C3IX6CZqk1qDX8ha8IsqSqO7Hj9Q3/HO+qieJPXbUeU5/So5JnXz7DqAv6lhSR77MjVzWH3Ks4LJUtBz6cBAN75RvbpXBL9kqhL6PN7+wQZsuz26SglNgDBh4CO8Z2aHIby2qDse1oqwAGZRLLK+sy6E8xFgkg0MdJi6P+bGCEI6AqHB2Sf0Uoc9vCOTEE1bFHGe6YkKq8zkMsp32YvjNXMKrGKKnSRxKmDBalg7kWhOIWuA3Gb/BH/vD/E8xESv4ZHYS4+BUAdXL0LQGQTgrXSTFYUIjSUtlkdJJ3h91BPL/9QAByIEuiSR6BaEdU1llSxPmJLQWvEMt0ES5Vp0Pl1DxXzMS+AJiMMmvA/da87UiecOnXA58L3K2lwvYjCN/ENih8u5zKSBN5XDvsrYvyX6Pni/xF1AiLMLweQuWjDGHX2rsWsBcuTgsOajfaugeTed9lBtmisiuFcyf3mp5fKu6MaKWH1AmxDyir3ORCDkM2YsPa9or7y0UL5tbdky+j93jtOa4yEse0VaigdM7QP1/am8VFvOH7OASx+sg16yQiB5oA89JO5Boc6eh1kxMw8UlZ5cPvFl4CgNl5YzC1we1miFcM+O67sw6UL4wpZS4A7s441NgfMzaE+RSXH1PZV7+K5QFV9IE2ZlY323LtOZnDyjUCyES0432P6u9tkvEHnLQZVQ98IkkTpUbIPofBVsLh868ig9YIZTwo+hidcFYTvA9XwpCx7YlRu7s5MgZsGca51N0DvAzmna5P14w7fdCPCZsbp2EMZ6i77unPSZl4I4/bQBhDA25Zn0yoqgAEaGIbZr0XXVUmTJMFNSEYK3PG/NjyxG6owaqrl6Mx82kPtQJL+EsoioPREIkbsu+e247oAwZNrNpYfcgh2rs0dTEi12piAZyfgxKBYGwHJeqGeK0X9jlR+VsjubDt6OE+by4VRKSgHmoOg/+7sbbrPi0SJ7L8E5scroDiLr8V1cJleN2Tq2afhtiPuhs0oNKa5mehaDZoP/DRhkfH4pwAQjstuT2wur8B8ui/NYscv0uILhKmUNUwHdSDt5Dk74H9Iv32VPL9pPNd3HmwUtaA8Y4B+zVg832Vk0tO5W+rAVX1E582eNykrujAs6xI0aY/G+W65MczbkjbViMB4IIfgkP65Lit2fa6T6FWIgwGoETboarWixp9KIAid0acx8iW00ES1BmMKJFc2UOaPr70ErGLFWhzd/6Bl/b1sQ5Fmss0WXxbKF6T0+BWvlZv8gOaJtzZqvM8EQVj5MqX16B1/rQNROyLw89N3eOCwlXUG8cKpazjQ3STMraEDbTRzp64euxbQw8rnYjKxcdZ4ExHfYNs4TGuPWy7seHpcZF9M6IqTl4QTW4xFo0GcCxl5cyHdt2SjCNk5W68+wF25GoLUVf7dR6XeBkwA9I4geidfU9xLlAD10XqDJAFoVaZvuZAFD3Tnac32df6Ie0Et0zp1rE9u+lh6v+T06lsC+nkxHxXQtfP8Nya4psnxEvTNtjpxjx52Y9hzYHHcenVC0CUVpO+dwjFA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: GIcK9cLA8nhzwGL0t/W5yzLDcg8/o+aYn2sR221+QFyhsfLt/W53wBnSC9DAI84doIzhuQhtdXPQqMZPA30ZJbWtRAbdbXae8hFFjQTbrj+090CXE+pren0ZxoXT1Fs8EuNWEHNHvyUSMxgSvISgAD2TX++JHH+/DnQGLAa7hGwgp0FBf6WqmFnr5ha3FATMHYcYD8oWEh5Xw6INhrkwlKDGpYMGMIvWPRhclpWmwOzHzJlDevAw+jUmAfK1eZAFtz12NKvEW2bEz1jJqhvGQnF6ggNMxT4FLGiq0OU7+RR3btEvhknCW/rTiUOwuiYgm6HGDK8iWIlFJ2zY8T4mYpJQwzO/QTomKb6fbYy6VOT9xnrKIOPV58uxfPiuq7jYXDTpCNcCVWDCzYKvsbCoripDgcqemcgONTU3Qsxzkt6l5xCbquWkZXwOf8+l7mjivJ5aCtFNacePZ9l87J9caEEsGOS1OH4RiJRa6QNt96whr1F6Z6xFO4AJwLUP/9su53nw9QJl0iLl5PSs+VNSUso+Ab1AY01MnULnedsnbI3gB8CzsXFVl0zQpv8yL1IN9Zpw3JSqQ4CnYK0QwZAzcYgmMJS2GLfOfdmCJ1CIkzY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a7369a2-599c-4aaa-9829-08dc68749b44 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:41.6149 (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: M1XC+mRlLDQ/RBpCkhjeJwwjthLB4XVcnLfyP2cD9RqjXFGqaj3FsVMXh3HT2zAEAOQuWCcVm4navye8ihFzKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: rIXZWGI222KSaPu5ctNp5PhORGxg4Smf X-Proofpoint-ORIG-GUID: rIXZWGI222KSaPu5ctNp5PhORGxg4Smf Add a flag indicating that a regular file is enabled for atomic writes. This is a file attribute that mirrors an ondisk inode flag. Actual support for untorn file writes (for now) depends on both the iflag and the underlying storage devices, which we can only really check at statx and pwritev2() time. This is the same story as FS_XFLAG_DAX, which signals to the fs that we should try to enable the fsdax IO path on the file (instead of the regular page cache), but applications have to query STAT_ATTR_DAX to find out if they really got that IO path. Signed-off-by: John Garry --- include/uapi/linux/fs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 6a6bcb53594a..0eae5383a0b4 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -160,6 +160,7 @@ struct fsxattr { #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_ATOMICWRITES 0x00040000 /* atomic writes enabled */ #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 Mon Apr 29 17:47:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647475 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 A4D30129E98; Mon, 29 Apr 2024 17:50:25 +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=1714413027; cv=fail; b=g73qhdG9Y88lBdoty7Lb19yWfDLGGs6LhvEjW6w1YykIsrVyAIJJW/gKssrxVV4bRZE4WomX2dfEVroHeC8wIrbysL3Parp584tsFAxkg7VGeIKHbPQGWMQdEHhmf9bYCSSLiuiZvUMW3yjMXPnYmUR13mYdC28QWw0KbsVOzas= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413027; c=relaxed/simple; bh=JbkPmEDEJ8rNknM+tCPz5T59A1WSee+u+OSydeKE6pE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=d35kiKOWsOOfD68RiMp92Aup/xZXEMf8yss8y1Ha1nKvyekHRLEE8FMNpwBvCkmlKGHEUbtay4XCYt5jXZDT0ckhPR5q6oh9aQMqkn5gn4v6MqQO6Fx3JFpaqz/LZLh7NGyFjne1iURj6wGP5bpidtqeW7Uwm4iLVdkOvm/9P6E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=hRC9W21d; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bHGx4Hc1; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="hRC9W21d"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bHGx4Hc1" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwkoB004990; Mon, 29 Apr 2024 17:49:00 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=61sLh2yOZ3zQoNsuxoSg6LFBJxWtPicx4LLisInDs38=; b=hRC9W21dWgUIscIc4C6kNslis+B16GFcyFux+zMAp9rnR4kj58nCQqqRf8Uk+NZO3S1w p+3BZlmgMzyR57cm19SuAuNkk8ReFjmnaNGQj/LStcEV4fULzPzy8oN6z+vFlFUzARsx 5LP1ZFxYbYREE/OibqA2jRfosDn3Mu9R0zWgMRprNEWkWIaLlgI74TUGtKX+n1RQE4Us KIPSMEnDVuc9o/33XFrtLcLqZ1FLsMgHESgkaWgmSkYtcWLV5eApcRUts/JdJVFtG7Tq +sOP5Jgf0jtNxwfHrjfrxwCExJCoIfxQ6PNhn6/7w94d3ThdbFPu3wNWrFskN10HVHRY Qg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdek6cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:00 +0000 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 43TGqC8c016783; Mon, 29 Apr 2024 17:48:59 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 3xrqtcpy8g-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:48:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AyoF4haLvyleKMDzXvUG6rKhpxBZJFoXWZqRNgaEqCzofDTk6ImWmkyyOgDfKD/ZkoKqxOas5MBkRXDEuO7MIuM1DfgQXT6NPvBmSS+xly3AEQWob8g0fPg4F7WVDRCfvfqtNzJcVUPnLp+AHIFBtc0z6890CYNvavZRIXwzdWfClOmElO0yawPEkpGcqaezB0yJwm6a9CRFjsuO5CkxU8GfRdPkEg2JKzbpFFvKFxHVQtxVWKVvi6A4/1v4uh8d2yOI7b1AtYzz4Q+ZfZZ27OZ88yrGxgW5sAeLPyEqvgK00e3BPqRDOpflmriq1gB+696W5fEHEiIF4xhtqzAl8g== 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=61sLh2yOZ3zQoNsuxoSg6LFBJxWtPicx4LLisInDs38=; b=OCQ9Iwvjhv73EHRKQ8Ta3b5o6kcAWkkjQLIEAwC5t9Z37ZI/VUyH6nZWL54Mamew2J14TXFRIj0qgIKb0RWvdvTjDrzwyRsXGMmzc4tDuIgnkjCK2wjXIxztMrYveTy48HdKWWw4XWpQAORaMLPYnoJz5iXGwyu52ShI1H4jL8enXEu+e2wXAvdF2ibVkYMPUK1qm5g612htI4HEm/0+ol4yk92+NEHgp4HQeYLDlnKDpi8iXP9TXgJtk/bBWIJGrw8eW7XXhOw8q5wlIbBPHNr4X2NWb5m0gsowVCjDdkYv8yeHc7xLcnAomHFsirCGFNX0nzop7EWilAnG2J+ZnA== 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=61sLh2yOZ3zQoNsuxoSg6LFBJxWtPicx4LLisInDs38=; b=bHGx4Hc16ei3nN/KLdNE8hqy56ywXLYHs5den+x6wyWVNWCQoU9KUcuKYerTSVLDoQcbI1WS2Qpoot7Dbq5QS0g+3J3hnj0MKW3fdh7adjsMJZrt/+/+0DaBC9eWETUqEKRUOPbzKzhSaWJM8fvn2RIvBtmYm1aVOq3Zn3fRtdA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:45 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 17/21] iomap: Atomic write support Date: Mon, 29 Apr 2024 17:47:42 +0000 Message-Id: <20240429174746.2132161-18-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO6P123CA0021.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:313::12) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: b06148c2-5b0a-4b29-94be-08dc68749db3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: caEE605iHTebpLrVZ4eLkE9tzeESz3VZpcyGmbOnWI0IwK5xcS0YEtdbQ+uY7wRqUltyRCnxNrXOiZzdFeDP00MGI8oLdqbkLljkJB1uUSs22dW71MX6+GTn5IUxhttF/GiF9kSeZ+YwiHpKaf6z4PU0Pm5PD08OJV+9akbMg9O2DKPifdKbqqxy1A4fc1LLssdILsBwKYYn+oW541Pwb6SyiuyVFEigzny589/tC7RTLMBJN+IpolqR7hv2Nt95hsRrSVj4c3k54PKitI68FxBpixrx0eZ/d0lYGzGWbUKsNuqL02sk6crAJtfHIaBR1iW1xbZ0XXePzj6U6OwUnhkIYXe8denXAbwvCvBRXuCARtdJG6lquxR8kIxMNO9NaJ8TZu+fhWUXoaymG+2+qQ7/2mUkJoT58Tar4UmdC1o1TzVi9Qe1KcRWZtigk37wLFpUbB5ndxK0ybOE2rGI0V5lex9UMXrEvRCviCM5YzaXe02EiReKgCJhvRqJ6XS21RIZ0nBIu3Ik7W2izm1BkBM1QiW+IrspkzVH8OpCOitwEyGHQUaf3yF9wiWXxOKYYl56w9kHB0oBJ1cdEFwarDGjWAUFjSJrb+0cyRRiXDgw1Hak7P6a/ZBep0D89GWEWtnHg272sy+pvcLs+Q4qGJOzqHKxREICNRcTdk/jSo0JIHi48/3WOfZ5udxcKNJZ9hZAosiE/Gkhg7Kz2V7ffg5xjHiOwHn1YRfhQG8IU7oIVgqbu8FEfRnvxabyXK/JvvaULQFIl1ltwvrwkEtWDvAmyj3Bq7tXyXdpJqIjXkqE7Hl1RRthHFnVUN4mQyQ6KH+qtBdMWw0zNzmy68ee2Naw/IcYpfRJHyKyxb+hUZh3vb8kSEmZQZC/uP1SIC3ikWVS6wOwJzxqH6gDPfrS5/2y5DnON5n2G9/T9BZoxCRlKLPlxmJZ2P+TUUTv7cWn3WVTxq6rUXUO3sH/y/zRHn3PCeuhWEjWLoa2NOIeSb/5a63nRUUS1WrEZquxpnvEQK5C0gjXZg827ex4m6DYgmemF5V31hnS4WVqCSJgFDuXBTMRmGDHKiPCKKPd6cH7A3UXRRW7FPTlzR5lyI9QZW+P4zPZ9wFxxNjmx/Yn8K35dH5ik6/b1YUZyxV4LduDdgG2oJD8vmodGawB8DWeVj6XOF0F8zH0wFC5X8m5EQQqi1S8JGk+t5bI5p82BarFtYOPp7GRH95YS1dEzVKWzOtY5KyARBjc9hyG9WTarI8XujoPFVk+MzqYuhyk7KgMuRKhGVFyJkGcFTNuwcrjjg== 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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UBCqII4TqbJL+4el0XlfMrxMqPjOQ6Z2zw6eW/qzvZr9k00zkxCQJoeeYzc1IXk+rtF76Cm1nDBjKwQoRqS2Ehc/Cjove1PjrQsbhBbhjv8NHVDQdj6vWu7CArgyJXa7YxPlP2fiZ9btMaEBXel37b+z+n4snZqM4Qs47CJmdiZziIj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rwsEWhYNLgcZAsNzRFxHvjLYqRd/O/+FtX3Pz2gsACwRFLmb9G/qx7TSJSdHElxEF+ChVFn+2h01L9SMo9W6rUK3Y1GIc5E3SufiQa3A1LrzSbb/WMI8P8HgArR5nMdYdbp0oyoOY6YWA28SOCx1NRbiM4crd0JeE2T2EMckImWOXiqrpFKMTgI0j9jx7SMP1PUmBya32JnxzpkoLAezblW62+DVoYRj8/AamhrnVA+RWRZbT5vsRoQT0Eyyizs/5LJTmUFJn949OvywMQwvyRz5aVTfqud8e6GBoaFqR01oW2mY8sNhJnixkzzH0NqOicL8AAUv+3qPELimZJNBJfCZ/c8f1IqiDM6vPZMtqA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: y24vc8+nCMvJSOnAXrsl6InKcI/E4Lh2AEeVf6UyuP8JBrk/hukrJa7dwm46YWlVY1XSU+j+PQTQhQCfYxTnTly0hPLYJMS91CR3Z/RHCKCdVqy18/WJHV0Yusf/awICen01ghFpOO8d+EkII98KG/ep/e0GaliMw29NJKbkNTIYOrpNFl+1/jIc/qrq2rCWW8AY7+XB5kjvr2NBKpsdQb9pB+15XDdPbKKSf8cN77SebANRHzNpICXRnZzwdjuHFULZxEwiKj6miSuAimg6GzRFmJPOvaBwnugqDKjp5ccGO7zgGj+vcZNEimAcia7670M1KSl3EN1lq5IJ1cVrFFr69Tz3q4Q9hHsX+GLwVcr5hkN9FOpPcYabvhmp4qAQiaQ+dJzXHttE4dtbcLdTexQk33Z5F8opuNTaxwPpmsO0eXeiDLrwIMBlLCRLR9i09HMBdOU3KxWXaucFxMPexhggKNG83CIR9FSC/LduGnqwGwXzXuhiv+v+kzc7GCUA5DkfuRIo7OzgdFRJqRF66KAlhERXuuEnyt7dRQnksPj5VS3CvHD+7q06XCRjM3KdfxC85Z4rS1UZzPObTQFGFV2g24lCY4rYf9TKZAA93R0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b06148c2-5b0a-4b29-94be-08dc68749db3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:45.3007 (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: e7ujqYL59XztNftBQKT466lItzV0vYZzZVQy8cXRTaf17NT1tw5+nXWzQ7EFrgOWxLvZniK0EbH4Pb6eDixHQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: C1qosgTCqetTfyof4vZ3cbmq4rrdBfMO X-Proofpoint-ORIG-GUID: C1qosgTCqetTfyof4vZ3cbmq4rrdBfMO Support atomic writes by producing a single BIO with REQ_ATOMIC flag set. We rely on the FS to guarantee extent alignment, such that an atomic write should never straddle two or more extents. The FS should also check for validity of an atomic write length/alignment. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index a3ed7cfa95bc..d7bdeb675068 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -275,6 +275,7 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, struct iomap_dio *dio) { + bool is_atomic = dio->iocb->ki_flags & IOCB_ATOMIC; const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; unsigned int zeroing_size, pad; @@ -387,6 +388,9 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, bio->bi_iter.bi_sector = iomap_sector(iomap, pos); bio->bi_write_hint = inode->i_write_hint; bio->bi_ioprio = dio->iocb->ki_ioprio; + if (is_atomic) + bio->bi_opf |= REQ_ATOMIC; + bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; @@ -403,6 +407,12 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, } n = bio->bi_iter.bi_size; + if (is_atomic && n != orig_count) { + /* This bio should have covered the complete length */ + ret = -EINVAL; + bio_put(bio); + goto out; + } if (dio->flags & IOMAP_DIO_WRITE) { task_io_account_write(n); } else { From patchwork Mon Apr 29 17:47:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13647471 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 3D69A12BF07; Mon, 29 Apr 2024 17:49:41 +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=1714412984; cv=fail; b=FuT5nuofcemBaQoLL3eguDKJNRPvRuNqqLss4ef/kWJi9C5v19o2VQlcX0zmOkuY6ES9efZiJm1Xu8hiXSYoEP1tVY7Rp+gDmaTBNf/ZAbv6kzTX1fWsTQBwW9cT8nKqZlOFhGyzHboQw+Ir+Io2vWviE6fcs6Rj6ec0YxHgXSg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714412984; c=relaxed/simple; bh=/KvSl3ytoQgkFU54DbvpofpRa2xymhmiQfYdRCadIc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pIxi3e5v+NQWguGJAq6k4uh724kJtkFu2s291Yq9eg/azdaabe8TI6Bh35Xte39rkmUij9wcUkfGHfWOBdfnT28pjN7NSDjteq8NQP6eFR03LfZNQwrCoHb/jHWNOJrjDHJX5/qB8jqIGCkdtzYz5O94V7NP/YPWqswSE2ecGVY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=HaMSHxDQ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=dyyQmRcU; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="HaMSHxDQ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="dyyQmRcU" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwmQb002371; Mon, 29 Apr 2024 17:49:02 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=SheU/MsThsAx1QFkm4UlXzRTBBDYDD4ovPjB66yRbSQ=; b=HaMSHxDQaOJ9qQfEN57fqKFHyVY73QqfKOCy1lrChfByk9F9XRwvVbR5864FVObIept1 ql+M+u5y7DMWDRlygjE73a+kjA1oF8BWS5AlKimshUDvG5ltlD0lU+eUz/InAqfDmOOo rtIcD8vKp/ixCZy2d6yKUKGfRRMi7ZTgF8YVkbuAPG95Yw5lIrNTaVaLqp9LpRu6Je68 YNc31nH4Zanssvynb+S0whnB1peDK6DG3wyjCfx3kTkCXwPMfqEzp8et+J14BaAEzK39 UHWOXCHD4qvhS1viw4BzanHelkwGJjMPfn+8UDKZAwHMMbSdHlboofZwgKNIEFBT92LV 1w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqseu6qd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:01 +0000 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 43TGqC8f016783; Mon, 29 Apr 2024 17:49:01 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 3xrqtcpy8g-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y4L0QWnLL8kKpDf3A6YNMUK1vOoB43A6+hFMYAoYWOwrovP9PLVD5eqlvcSQdZIo6Optmw6pMriX3yj5njI1F1LNSoulkrzUl5lApYRmfq0R57YIvrstkmVFpBgChvNl34Ww+4ZK/U1Oq1evgC264x4Jgh8RBfBJdpSVWMkIy3yI6ssmfylhjmqmt6iND5Rij8yipYLjUD9iDRgcQz/8lFd9kkt9+wPXYAAcyOcJvDOog1uCvOivIaMW1qORvxqGIYIeHFHeh/an0K7LExbUoq/d1dhvPjegX1LTVJpwzJxqmF5VMF6/euIQMYvziyhnT7Rta4mK4903GYSJefj9cw== 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=SheU/MsThsAx1QFkm4UlXzRTBBDYDD4ovPjB66yRbSQ=; b=mwW6FJQdueKT4AR49N2Rl8aeAcnCmtNvPpQjdKeeoYd1HXdeVZt7k3XWr5sIy0s3tY66+gFsQParYwyEVEP1wQLeOGpMhlrorqST6Va07uku2jYXxA16gLMC+heosqG2kXjobdXLfKRqcHSReF0fktZtSoc8WA7wkB6/yLM01s90RRO4Dm5CE0u16Dmt6txqYLYV23BO+AAoOyH71yp454oKQmW3BOsXWW/eZyQ/p/kqUzfHB2YucjxPe1+RVDMBRvRLtIqvX/vSr2kl0Ln8auLF91LJ+QirakDDpFCwEK3Dv9fYdgZib5TGUiS9o9d52sXC2DUQXH2cc0pxaUqiIw== 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=SheU/MsThsAx1QFkm4UlXzRTBBDYDD4ovPjB66yRbSQ=; b=dyyQmRcUXmqadrLEouVZ2Tvzz7HnwvFsx9vIXH1WJBf2lkrawun6s2I7bF4V4W/PYEGyfemITX5jx6Rm1kyY7QE0UcKbcxBlKqBmCCwiOmJAOSAzVW3URCpV4Gtktdlfa+XpBTpganBg8spdANl3d0geffAo6Kp9+eWOzM/H+Hg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:48 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 18/21] xfs: Support FS_XFLAG_ATOMICWRITES for forcealign Date: Mon, 29 Apr 2024 17:47:43 +0000 Message-Id: <20240429174746.2132161-19-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0378.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 9120590c-995d-4612-d6b8-08dc68749fad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: EpsgECvyMpJQxt7ONQ7uvu57GdId1xIrbG21ZlKQi/F5SlWzt5XMW0WSV6SuRZs8fowFVt/2rmEOz49zcPpGXNBvYEMXqHiRUtwcM9v4NIxlhE6rpxs2Re17+WB16oAgmRP/52UiJHhM2ixrceG/9afx4/iBUmqjQcpr4OGzavEokXhD5eOPPPlslSV7AC0mqX4iLtWOQV29oPcg8y9glAuhjrccWrGQIZmWV3ZL66M3g2d6mqzXyj+2v/VfwEenD7UDrWIsXZYo4zcm2TVjdg31PwzfURkOT3REktrJdvpifWSyoiShhY4JM2fGuodb4XuuNZTEU2zhhoeuft7ZQugUt6Z6zmmqPFSRpj7rxbveeVvqByQvpthRN+fwVlhXNbNUXEWqcK9KQvsCezFDZ6HNaLakR0Ld+rVBC1emQsV1Fses8t6S5uXMw+q+n9736q0P7GKwTvroyVyin0kE0VxRrEX9siK4/koZMdiY6EHXvQbmsS2POAeBqlHx70vfP7kE3zZ4l0UnOBgnrtx3r1F7ioj5JAwe1GyqoUdF6dxcdIQNBzb7o/8bx/QA+/+jLmuYjBjc8MmZo/RO0+gGOY4nNOA7GZNjw18f4nsnO89m4CkJmRu1kK5Xa1j1L7pVrk2YB+x078b3zzOV4ZIGqo9+0cU2WSWlxNX9TiGf1FjegMiwY2koPcB0Cycl3ME0015AAo/GcqRxRm/fT3enMay8ug8+0PhpDtz03oj9dFNvBqmeZALq8vNXorFrszlbcja28afjhvunlvB0yU+7GQ+B+o7bF9QeamImRh8G3YQFDBw/tXV9uaQnlgNC8sASO6Hq+oTzSVFMJlej1ZCgLiS1Qfg94axFyWCKzFIFng44Hh37hC0kfsouj06uNeuTjIWQduwCcUO1dXOt087x6Edc4Twq2EMH+2sfASoSeEfN1Cdox9eoD/jCw96kbKGahfQKW9HteVO3dufJW/HWRvrZFrUE8yUAaFD0KzM9EUVvvaCeJo9QPw+M6d8WNWjPSYyUtai4GQ/aDJ+5LJucZf7Oxcd4AIpwTuO88/ohwrg8zm9oquhG2KpcSTbtaFsvS2NOcSlHncY2fCU0/GoVCcsByEfsbf6H5Ynom7LCyNn9HOMARzzBmit+hM1gVR2QTi4dAMK9qSSQr/v9z+4T+AOcVByHHGZm+IaK4vSIHPjnGhnqDtLVPB8usFsnAqvvGkS3a3tCxsK9Wr3Ew4d/z5gJw/Gdy8G/2rzKZPc3+ZeO6ZZ+t6eIqnX4mfyqA8PfTdsPUuV+6lfbf+VF4neQKw== 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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nkkeVKvPY1sgr1IjLpx7gVxewy2msyoWUquiU7w/MzmCntCsLGoGxYcJO39P65d5b2k2E5UOwBgYJFcylm7YhCWXngLorM3gRcoBBsI00BmVkA766oh5htmNY0LdVnsytQIpIwOMb7bZDNW4LhVumsrk1tli89XmT8cBu58RnYVjOrXGPR2ORRpt5hFMWiiH7jvSYaeTd2iqaAUfVLR5LwcsQZTm1hPEO1DITkTVFzryave/bf7XzY/UNrs2o3NFgC9K7rli0deHrzGwmdvOGpdlEDwQ2BI0EUD6sHaxG2Z7mZGyRGss2LFGLa15IFOIXh1fLwWdxTR4i0OPykQNF+xgSl1/6Bfu3gEaDOj10A9VhtT/z/stLQ5jlEmEYZU9seSWj/Rk/1idqshoFyp925+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ZWBuck4EICdo6/vR3i9bDQzdVeKOXCeUtBO75iC+x6BpW2ecTKUG98LXWi5MqvC63kuTyE8MqKg8cRsKhty/F/gwCpBx0QkmsXkZzEUVnBqOFljUJHulzZGtRZ+pfFffpXV6VY1Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Qx6LbGXE4z73CAymEKUxr+b7b56RCvCBm+NtUPBLRbzcY1hkzoxwyyyGlPBF8tg41Dk3SRPH5D/UlPlMpPy4uEB0BTawTvM5Z1hHoY2YkSki834fWhj3TPtAXoX8Cr/0nQJZBKT75tfrg2wWFcPb+4sLKmzZOjLc6/zZORtgGunU8StMDB9tjRloIo+opWe8lY95kAc8O2Xjdxum6vLcKJzq93b/Qizqa9QA0bUObwJbmmjReL4z/xsDeKj9J7wqRHN3zY8wSQSp3jWikAt+chvzz4l0Q0peCSojT9RZDRK90zM4yqV06D+rvz23XjHGmFWW+TUxcn16UT3mqFtWufxV8IFo5RMj+p9p41dmuU7x22InRkZfq6o6RzypAEXjg+3AZ5ZtmVoaMNRJb54vo3AtDHC86waWl6Gh+6FoU0EB3VRDJ+9ncqNPC08vbpZDgpJZXyLuMCQRqDCMVJaDzme+b5cohi0fHD6CjiaEEGd7W4J2xW4bicnnALk6MARJNdPV7mDemreVDi8SV5yUq9H+E6wGOEcaz/DJjpdwVFWaOgiLexRsIHRMt4UWhJbVxDcdHnu1dhOihqCvqAURbkaDJI2XjtCrgUDZByDx1LY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9120590c-995d-4612-d6b8-08dc68749fad X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:48.6966 (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: OXiXVu2UlgC2fsBy/7UPIV51UKdIBOuVls0x7v0kADLrPc7VGSK5WJo7drS8OPn399fEozAsqVLCsigynvfzxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-ORIG-GUID: F-RIy3EU8DDCt_LTN95REpuddbvZz3h4 X-Proofpoint-GUID: F-RIy3EU8DDCt_LTN95REpuddbvZz3h4 Add initial support for FS_XFLAG_ATOMICWRITES for forcealign enabled. Current kernel support for atomic writes is based on HW support (for atomic writes). As such, it is required to ensure extent alignment with atomic_write_unit_max so that an atomic write can result in a single HW-compliant IO operation. rtvol also guarantees extent alignment, but we are basing support initially on forcealign, which is not supported for rtvol yet. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 11 +++++++++-- fs/xfs/libxfs/xfs_inode_buf.c | 36 +++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_buf.c | 15 ++++++++++++++- fs/xfs/xfs_buf.h | 4 +++- fs/xfs/xfs_inode.c | 2 ++ fs/xfs/xfs_inode.h | 5 +++++ fs/xfs/xfs_ioctl.c | 21 ++++++++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 ++++ 10 files changed, 96 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 0c73b96dbefc..8e32fb068430 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -354,12 +354,16 @@ xfs_sb_has_compat_feature( #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_ATOMICWRITES (1 << 31) /* atomicwrites enabled */ + #define XFS_SB_FEAT_RO_COMPAT_ALL \ (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_FORCEALIGN) + XFS_SB_FEAT_RO_COMPAT_FORCEALIGN | \ + XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( @@ -1088,6 +1092,7 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #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_ATOMICWRITES_BIT 6 #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) @@ -1095,10 +1100,12 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #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_ATOMICWRITES (1 << XFS_DIFLAG2_ATOMICWRITES_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_FORCEALIGN) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_FORCEALIGN | \ + XFS_DIFLAG2_ATOMICWRITES) 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 12f128f12824..5e42ec1dadb6 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -178,7 +178,10 @@ xfs_inode_from_disk( struct xfs_inode *ip, struct xfs_dinode *from) { + struct xfs_buftarg *target = xfs_inode_buftarg(ip); struct inode *inode = VFS_I(ip); + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; int error; xfs_failaddr_t fa; @@ -261,6 +264,13 @@ xfs_inode_from_disk( } if (xfs_is_reflink_inode(ip)) xfs_ifork_init_cow(ip); + + if (xfs_inode_has_atomicwrites(ip)) { + if (sbp->sb_blocksize < target->bt_bdev_awu_min || + sbp->sb_blocksize * ip->i_extsize > target->bt_bdev_awu_max) + ip->i_diflags2 &= ~XFS_DIFLAG2_ATOMICWRITES; + } + return 0; out_destroy_data_fork: @@ -460,6 +470,25 @@ xfs_dinode_verify_nrext64( return NULL; } +static xfs_failaddr_t +xfs_inode_validate_atomicwrites( + struct xfs_mount *mp, + bool forcealign) +{ + /* superblock rocompat feature flag */ + if (!xfs_has_atomicwrites(mp)) + return __this_address; + + /* + * forcealign is required, so rely on sanity checks in + * xfs_inode_validate_forcealign() + */ + if (!forcealign) + return __this_address; + + return NULL; +} + xfs_failaddr_t xfs_dinode_verify( struct xfs_mount *mp, @@ -624,6 +653,13 @@ xfs_dinode_verify( return fa; } + if (flags2 & XFS_DIFLAG2_ATOMICWRITES) { + fa = xfs_inode_validate_atomicwrites(mp, + flags2 & XFS_DIFLAG2_FORCEALIGN); + if (fa) + return fa; + } + return NULL; } diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index e746c57c4cc4..a9ae8ab7d610 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -165,6 +165,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_INOBTCNT; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) features |= XFS_FEAT_FORCEALIGN; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + features |= XFS_FEAT_ATOMICWRITES; 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_buf.c b/fs/xfs/xfs_buf.c index 1a18c381127e..6e7ac6c90ec1 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -2057,6 +2057,8 @@ int xfs_init_buftarg( struct xfs_buftarg *btp, size_t logical_sectorsize, + unsigned int awu_min, + unsigned int awu_max, const char *descr) { /* Set up device logical sector size mask */ @@ -2083,6 +2085,9 @@ xfs_init_buftarg( btp->bt_shrinker->scan_objects = xfs_buftarg_shrink_scan; btp->bt_shrinker->private_data = btp; shrinker_register(btp->bt_shrinker); + + btp->bt_bdev_awu_min = awu_min; + btp->bt_bdev_awu_max = awu_max; return 0; out_destroy_io_count: @@ -2099,6 +2104,7 @@ xfs_alloc_buftarg( { struct xfs_buftarg *btp; const struct dax_holder_operations *ops = NULL; + unsigned int awu_min = 0, awu_max = 0; #if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE) ops = &xfs_dax_holder_operations; @@ -2112,6 +2118,13 @@ xfs_alloc_buftarg( btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off, mp, ops); + if (bdev_can_atomic_write(btp->bt_bdev)) { + struct request_queue *q = bdev_get_queue(btp->bt_bdev); + + awu_min = queue_atomic_write_unit_min_bytes(q); + awu_max = queue_atomic_write_unit_max_bytes(q); + } + /* * When allocating the buftargs we have not yet read the super block and * thus don't know the file system sector size yet. @@ -2119,7 +2132,7 @@ xfs_alloc_buftarg( if (xfs_setsize_buftarg(btp, bdev_logical_block_size(btp->bt_bdev))) goto error_free; if (xfs_init_buftarg(btp, bdev_logical_block_size(btp->bt_bdev), - mp->m_super->s_id)) + awu_min, awu_max, mp->m_super->s_id)) goto error_free; return btp; diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index b1580644501f..3bcd8137d739 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -124,6 +124,8 @@ struct xfs_buftarg { struct percpu_counter bt_io_count; struct ratelimit_state bt_ioerror_rl; + unsigned int bt_bdev_awu_min, bt_bdev_awu_max; + /* built-in cache, if we're not using the perag one */ struct xfs_buf_cache bt_cache[]; }; @@ -393,7 +395,7 @@ bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic); /* for xfs_buf_mem.c only: */ int xfs_init_buftarg(struct xfs_buftarg *btp, size_t logical_sectorsize, - const char *descr); + unsigned int awu_min, unsigned int awu_max, const char *descr); void xfs_destroy_buftarg(struct xfs_buftarg *btp); #endif /* __XFS_BUF_H__ */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index db5a0f66a121..d674fca22de9 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -609,6 +609,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_COWEXTSIZE; if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) flags |= FS_XFLAG_FORCEALIGN; + if (ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES) + flags |= FS_XFLAG_ATOMICWRITES; } if (xfs_inode_has_attr_fork(ip)) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 3f13943ab3a3..d796456215e2 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -321,6 +321,11 @@ static inline bool xfs_inode_has_extsize(struct xfs_inode *ip) return ip->i_diflags & XFS_DIFLAG_EXTSIZE; } +static inline bool xfs_inode_has_atomicwrites(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; +} + /* * Return the buftarg used for data allocations on a given inode. */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index d1126509ceb9..94a6d9f6d0d8 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1112,6 +1112,8 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; if (xflags & FS_XFLAG_FORCEALIGN) di_flags2 |= XFS_DIFLAG2_FORCEALIGN; + if (xflags & FS_XFLAG_ATOMICWRITES) + di_flags2 |= XFS_DIFLAG2_ATOMICWRITES; return di_flags2; } @@ -1122,12 +1124,16 @@ xfs_ioctl_setattr_xflags( struct xfs_inode *ip, struct fileattr *fa) { + struct xfs_buftarg *target = xfs_inode_buftarg(ip); struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); + bool atomic_writes = fa->fsx_xflags & FS_XFLAG_ATOMICWRITES; uint64_t i_flags2; - if (rtflag != XFS_IS_REALTIME_INODE(ip)) { - /* Can't change realtime flag if any extents are allocated. */ + /* Can't change RT or atomic flags if any extents are allocated. */ + if (rtflag != XFS_IS_REALTIME_INODE(ip) || + atomic_writes != xfs_inode_has_atomicwrites(ip)) { if (ip->i_df.if_nextents || ip->i_delayed_blks) return -EINVAL; } @@ -1164,6 +1170,17 @@ xfs_ioctl_setattr_xflags( return -EINVAL; } + if (atomic_writes) { + if (!xfs_has_atomicwrites(mp)) + return -EINVAL; + if (target->bt_bdev_awu_min > sbp->sb_blocksize) + return -EINVAL; + if (target->bt_bdev_awu_max < fa->fsx_extsize) + return -EINVAL; + if (!(fa->fsx_xflags & FS_XFLAG_FORCEALIGN)) + return -EINVAL; + } + 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 a8266cf654c4..5856a72d431e 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -293,6 +293,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_FORCEALIGN (1ULL << 27) /* aligned file data extents */ +#define XFS_FEAT_ATOMICWRITES (1ULL << 28) /* atomic writes support */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -357,6 +358,7 @@ __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(forcealign, FORCEALIGN) +__XFS_HAS_FEAT(atomicwrites, ATOMICWRITES) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 63d4312785ef..757c90b3d71b 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1710,6 +1710,10 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL forced data extent alignment feature in use. Use at your own risk!"); + if (xfs_has_atomicwrites(mp)) + xfs_warn(mp, +"EXPERIMENTAL atomicwrites feature in use. Use at your own risk!"); + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, From patchwork Mon Apr 29 17:47: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: 13647490 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 E003512C478; Mon, 29 Apr 2024 17:51:53 +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=1714413115; cv=fail; b=a6WkocxjHNMaBGeP0hGheWSmVXRI+X18ihyUacFx5loupM1wNGTFl9WyJvHFD/UddAjSm5VRnFtA6NjZZMl8EG1VNnU8ZtV92IXYIBpeEQYgdbvB6tEROqAAZ7TQuDVQysPnsER3DZDgg+2241Vq0R6VFXWCSvrJ2Pp0eMPTvYg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413115; c=relaxed/simple; bh=C1uPySa2UjoSalJxT0kJkpre/zMPk3DE/vNubo+9YpY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SnViW9yaz51CiCpgILv6fIPru3MMMifWwG3XuW65I8rp690mtImoquCQbE1W9b3dU538oVjf1/FxZMr8sy7M0rHIopYd8z0qN9ZrXoaAW7+g5z+DFLjmcdi9ghJlm/tZwf0ciGVR5r1mwy5qxkBzRs6vG4J5pal1YFqY4XF/HME= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=NDwfR8jM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=LcON0kwL; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="NDwfR8jM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="LcON0kwL" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwuFE030165; Mon, 29 Apr 2024 17:49:03 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=z3RLnYUNaSWXsZvwZ1Zosbq05DKqEiYU3IiL38q9lZI=; b=NDwfR8jMSa5eXTxvP18eOUIHqz6t6bUQ7FyHxf1sMP5hLPw986L5n+G6Uhj98yvSO6zJ pixFhXqGCooT5Nr12sGqIPtQMcxDQnyo60HRX8IJJiHMDA6s0pobyDIl8wHGGPHF/lKe LASEnX88AaMbfjBkGdVhcGSh/msysknjEkh/hizHLMirTumoiC89kGyitZWfkZeqRWvu 6uPoYmva9Qc7TQGpNj50f9C/YCo9rw7jMd5v2yu0gJEtOWE8Ai4XyMffAlrQ4oCRQjye Fa6DFm5fIrxMolqR8hq7C25IZ1M4Sll542wP2S81Y3HmxOY2RouZ+V76fk57pGK9gGPL nw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrryv367g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:03 +0000 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 43TGqC8i016783; Mon, 29 Apr 2024 17:49:02 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 3xrqtcpy8g-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLuDBpvSkkDTstdTX5HEcF+m9WHb04K4Y3h/BEWinbQ8pkLDS4sTV4NrHOhrGDA0JeHpA6sdqamlf57On+marQV39WsPgQDXj420qvlB98ciJztFfubI47kteK00HFfOMg5sgVjM91ehdn5qmLH++JtfrlnWohJGgtsjXCjYBfkFT/gbJvI1j3fSkU+iabqCFC0u79vDd7fHly60/l2o0hXjkUTMFELEVsqO+KGDK5rV1FCfQ3dAtO/wbGPb2sHwq42n3krVMX0KFmmg7r44GJgh/9y2Vn5Ayd1cx4alJA+x1Fwer8eTDImAB1uZAlGy+ZdqkWd20s66NW+jKx1x2Q== 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=z3RLnYUNaSWXsZvwZ1Zosbq05DKqEiYU3IiL38q9lZI=; b=UFRz5oQQGCp7qoXVV007mg3mNVs4u+Ihx3ei0XpgVMhqzv4D6grE+mA3MrVVfpO5xO/mgYjWp1jM/7Svgau5utEmLMFm7QMCRSkBSVhgoVEneX4rRZwMncTSB/MUe9eQDv9PJ39O7JIRarey+GTBkEXT0w+d4Sb4yU2FmHqMNogftWC5TkGSvAyhXeTJdqSCVzxA6z2JnSywzfVbmFbXG4Xwy5FEwFSdcuPI+8ArGmLFoJBoQs8JXFNoL02CAGwq8ypo1rlUexU3LRVRbr4YU1dTuG+dcwlKVgWyjA9tOAiEuBGuloUqL1DdCd6p7OrmROMURGBo+kS3X+dWfpON5A== 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=z3RLnYUNaSWXsZvwZ1Zosbq05DKqEiYU3IiL38q9lZI=; b=LcON0kwLVYPR9pK2u4QMa9c12UFadLgojZnbsAUOvPPkX89jKbnoG4/MT46bjlSaTkS0UebChxLhOnVputWu0+BEWJkh23k5/Bu2AMtXpif8QXr6QDNDY3qrm8uvjKrVY2Wagga+oA2EruuvtRKeU4nyoQwNg8kacROlpSsL5/g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:51 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 19/21] xfs: Support atomic write for statx Date: Mon, 29 Apr 2024 17:47:44 +0000 Message-Id: <20240429174746.2132161-20-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY5PR20CA0027.namprd20.prod.outlook.com (2603:10b6:a03:1f4::40) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dbd49e1-164c-4313-363b-08dc6874a154 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: EUhuJzqmBGx76iKfj4mpWTyIh11+/gpcYuXYaDi8s/lfYG7e6QkoNC2jrWhkJSl3Fhc9VZb4q3Egwe4T/ElUakxm5Dtl2M62k4rZDO35a5rCSWsbRYPbOkSQOu0womDYnLFhhSbU9x90VIIl6jV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2nhkQmtXHk4X6AoC+bplMJBASSWLbdp6wkvsDD058EXtVhZeptOyvZ98RrN01mlbJ5gREGl+OgzQgVabfViEZ6UA== 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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RtrNDAWwShaMB/ZJ2rgOM2MqYCpXBkl5WoxebgcSbVluoJglQjcUdeoGZwTQVL/91c75vlb2X6aPd8zLx07j2ajKgTMBKXYNJslpva+JcpNAX4es+GQKBf2shGYKqQXDK4ieuAciHegrDwkbl9ADX/B/Tj4q2LnEC4xp0dpT4/mmJresbq9fuSfuXtGRf1JNtU7SzbO5i/VDZUvBvL2eZqUzXzjOnU4BYXkoCV69rHXC2xkqqmbL5+BUXPXGm4BlMkhNGW51DpJ6lsROmYxgKWuvvSsKiB7i6+sCe7ty8JvmcyzxAGBi5SbLwz8EagTImSX0PcxTYU9zauhurYJmIxafJOC1lStSWTsJhMYhXwexJNoBZE7U+OjjgDQOvLVeEEgjmwh07gH5epyrEmxZEip3p1fDDunFAPntuyIxr4YFa636tO3DNRANlXIG+5DF4h4es3ej0Tkti65NpqZMuiImCPF0a6kOUoLTV52XkZjtT51UN4mR8iEcRUZlHKlqY3ePyqCsvDKDDXNPbQdNFwwWFjhe1e6/89bg9pvVmETkjeVFUzSRDk8kSx9ryHoRCLivKRI0CMO20+IUFstXb3gpbqRm3N0xf1vyuGRemxWIEIm8yftxCIsXEqcmk3saASSeyqB6kx0CwaT2hiMiB98veW/ZvmLeQ50t2arZHakoI23YIu8f6U/hTmJ6vA7CCQjMWrhHGNYkbwv8NpaC4+Wtz1XWsniya5JaixwB1ViFEeiUG3HYh/B55I1akBMi2SA/WLSBSQpBCwxK1F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rSyVhvSWsPt3b147c140OVyEiWv5Z29wNAbgpFFjcu25K4Q+Tf62ZUF87K3s9UwbooXvxWQ3yBvNpAM9M6NW9WEy8ToGlVuTmT0tD8qk3w3Vqf4GHSmbFwgwt8/bK+Qm4MiPSBw8dR+BqkhTDAUw91ZYgp7yXqh/mR2S4VS/N0elV6wQODT8cGRmdghZu1pXMaDt8NLbIQqgcNU+I8/qJg1IHU92XA5Z5wCFHTnrb5qkKs2p4LA9unBEjLXcZTFXo9TegGpj8hdSEvCV6N2YwacPblkCpDRZSaSnn9caUVAK8fMlFp4EO+idTtoHe3+SErGGRyGyJFUcb6iYLrjuC2DKFdz0Zm3EpB3xhiuz0Yha7OeLxDwubsXX+Z4mjboiEcmM2vaEvfxJEFOuCWmJ19+Mj3+7RsGXRwlH9xTZs3efPWkfVpWgiaIPhVi2yES6ZmsUYvQWQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0dbd49e1-164c-4313-363b-08dc6874a154 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:51.3054 (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: ZG/QlkvMf56xG9dy8aaZVWM9abdkUK3xQATtdII2vMcCh9XZ8bvfKnUqqQcUJTE4RL8YrkyKPEarIKZgie2U3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: CiN6czIx49mofbrShMfhf-tLumTypuXe X-Proofpoint-ORIG-GUID: CiN6czIx49mofbrShMfhf-tLumTypuXe Support providing info on atomic write unit min and max for an inode. For simplicity, currently we limit the min at the FS block size, but a lower limit could be supported in future. This is required by iomap DIO. The atomic write unit min and max is limited by the guaranteed extent alignment for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_iops.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 66f8c47642e8..7d2ef3059ca5 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -546,6 +546,27 @@ xfs_stat_blksize( return PAGE_SIZE; } +static void +xfs_get_atomic_write_attr( + struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max) +{ + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + unsigned int extsz_bytes = XFS_FSB_TO_B(mp, ip->i_extsize); + + if (!xfs_inode_has_atomicwrites(ip)) { + *unit_min = 0; + *unit_max = 0; + return; + } + + *unit_min = sbp->sb_blocksize; + *unit_max = min(target->bt_bdev_awu_max, extsz_bytes); +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -619,6 +640,13 @@ xfs_vn_getattr( stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; stat->dio_offset_align = bdev_logical_block_size(bdev); } + if (request_mask & STATX_WRITE_ATOMIC) { + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, &unit_max); + generic_fill_statx_atomic_writes(stat, + unit_min, unit_max); + } fallthrough; default: stat->blksize = xfs_stat_blksize(ip); From patchwork Mon Apr 29 17:47: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: 13647478 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 6AF66129E93; Mon, 29 Apr 2024 17:50:25 +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=1714413028; cv=fail; b=risDqmAgTmpjGrIa5X+PLKOQxufhMSMxik7qqeqydGO2z/fo1AH0f7N6h41pyBmbgWOCpkhaogZ7j6HgH1vcGuqVbrPjTyN5FsBCQQNJdWyZlVKW1lODQg+G0DVZr74g1Ox1MGtNtW2YXFDAFZN9/ScOH+yBVRLe+VC6dqy0WUc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413028; c=relaxed/simple; bh=b08++4pM+DzCFc8if3CCdgXTEJFeNaZ5kozpvHEbAJE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HVcTtlMKjJ9cCp5tRsemhhSW1X8OMiACWwxyDr2jKkvE0+fTaWt2RyC/e5eyB4vIfkQ0pZMcsErdtnzjO5gtS3San9Arotdc3xmpGBy/6A3NvyTDt1JXM5NmCa9miFZU/w+IcZjMboD1jLKhv19X0u83kW7V9mAcFwFz8QVIrXs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=DuvnJqZ6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qv2i4SMl; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="DuvnJqZ6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qv2i4SMl" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwkoM004986; Mon, 29 Apr 2024 17:49:04 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=0dc9PhpJvK+yLNLKeuZsuX+148+Twg6hbRxHjBBXH0A=; b=DuvnJqZ6do/ILZiKrkXdEuEKV9S25eGPI3SoV25zVV8H/j6PhYHQXR9RvRuM9I2pPnxw sBYxP+hXvAORGrKgrv+o204oRaldf6cEqQ0UvzB8t6S0zQpEAExUXklGCVOU3Lyenk9+ LGXurSeRUEicE6S0J3TM+nPffvyjIbvnrVzbE5xPHP5lply95K9p6rLih2GirsekKv+h nA64jU+hjnAWCEKVELs3A9vKmFxyj4WYlkiA+QVVkthHW5FzQ81Eo82Vtrsf8OVsIeN6 75bLUiLYanN0Hd4XI94VYFs2g7e3eJ0o+/DqHSALfsoCwRhREDV7xwCEmQollY9MECzc 6g== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdek6cu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 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 43TGqC8j016783; Mon, 29 Apr 2024 17:49:03 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 3xrqtcpy8g-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f9DEnB0VekhlKWW1G8DlTic6BJZ5UQIiFVQ35AuOMECxwZg+HNtusAkM9jOKcRaHrWRHJY9h+7oI8ISywxTRf1MV++Ui1ZU0RIpt/9z09vKAjKYYb5U08y2XLB8gb5hYG+tbhtxtuf8b2xO9DpAuircWM8Fhfmp2ljlN9GMyJtVVZ/RY31m4J9xrywJR2uyM7eFZnucmhXC49HfrkMiGaOkeR22tKCg8re1Klt15UGq+LIO/fGY8lLz1+cXy4dsu7cJH6d9d5CCgJaS/bC5J2M5z5y+thX9yc5yeffx6Wws/kVqALxV0ZEbdnbIUGxOqXxdwCxeH5jwzaCaDoXIfZQ== 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=0dc9PhpJvK+yLNLKeuZsuX+148+Twg6hbRxHjBBXH0A=; b=Vh6d3ifCS6T1fhwDrV0vOMTvZ7Y5RbHaFBSPtvemlJasSkK6I/SQQE/yvPlck2DnG9i8xCytZvva7VD87FsOXAiYRATKoPqAk5bucxkhUf9ZC0iHHlBtzn0yEMtWdc9U6BL6FLrc755NTqpyoJuzCTT/3TglFaxxaKrUmVHSa+y1JcE1N9Wqr1PHBHFOnzoXrGZtmRJ8nplYoGEZyiwvziaANtqyws6oBOsiDxjhaS4z3gVjL4WM5zh0wk6lUKRdGzk0k7q+x/5O2EqStsaYKMnPyXOKGx9/lDVmP7ZRglX93+YzO+Hlc16m2NK4UtIH7/ZYvSFU6NJaf5o6MsCgpQ== 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=0dc9PhpJvK+yLNLKeuZsuX+148+Twg6hbRxHjBBXH0A=; b=qv2i4SMlNB1vqtn1FAorvD2yBnJGsDZy1MadEXG7VhZdFpMi+vNY3vF7Jac915zVrlnQUFZCE1TRt2QiFdTLJ+XBtuPpNHFTxywES0Ustk8F058bMYv6DnoRLnUMgw3QyFdfahJFdBoSsKuyCRO/svBWzL9GzQN+JEUYSeLrp5I= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:53 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 20/21] xfs: Validate atomic writes Date: Mon, 29 Apr 2024 17:47:45 +0000 Message-Id: <20240429174746.2132161-21-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR06CA0044.namprd06.prod.outlook.com (2603:10b6:a03:14b::21) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 476e5869-ffc0-4d2a-837b-08dc6874a287 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: 738/O+YdcIlFlXFPoWYpaO3IsSBNnsCvRkrFaZVT7gmrO0OuPE85QbAASIHP0qhkWXzmr1xW3fei7xYZvj4bYQSvoYhreCaa8xdjxuUzZbC64AQgEOhppRKQE4H5As9/c2skqvdo7YzFqWF6Dn53sQKwGXTnaok557liGNYl9Te9gw128jVZ7WkQkBXu13fmbklIYMsuGO1a/561U+lgcK1lK5ExS9QJ1mT9bxKg59MjkNVLF7pvWo8LqwaraeNJvd2tAOU5oA6IVe5A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DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fgaf7NAfC8Z8A6wC3PXx9aChRV6dbatLoSnBNWJscvZDEhbAQ34JB1Lx5mZZXwqV56uQ4q5zap7DqR+hLNWIZsM/lFile5AxUNDUkNL6G10RJHH65gqb3quihrGnI67/+L6T/K8L3yOm6RMgXKsXizwYBNUmm0PRMhCybLYbbsk+Fz2v/FmzwdHXqQlBcC9mCMY25SaDpmv2BlWoAE+AU/9dkz0TAb8+xNF3mnGFUtPNDg5hoPnr9FRfc6OZflaw143BaMtp6vrRyfs3ZJxZCkB90Q1mKo5sVELp145YZF9ZJ1R3dqAYPL52/Y6q6/ckKAVCUnnmy9b9oZDXHIjuvlCSIdI4ZKevkw5vPcFGsXju5iyHZKHB0OB81yXg889Zm1NsWobbBKJNBdV5pc+ovha6wG3dfZ3lotBVqeFG1WaKX32j6W0Dq1+hmapKtsM3hGfPJZCiWAJuP9vU5AhVoJ+xMCQoCdG4aTC0zk8bV2h/lE2lduOtMp9xz7e26m9WfHwQUAsLY3RCFM6MUPonEa4ZRsYbbcK9TPKCvTbVAUZNN6fmTsRX6dB4PHGEcbmFziy7wn5HTv4TepRE8jsBNgIqB0+dbzd/wOKAoOlHmwOKvRCapjHM8Fp79miN37cjDx5bTP9IySCGC4bxBVPppjnRjei9evcbmi67iqf3kWgnV/zWZXKJP3IYnjhyWUL41P0qp63w4aVb8TU2cJ1fljoiTRjqiv3NV9yHxdfaJ3eYqZ8NTPo9DGo1mpAjjh/4hfv2jztwDSztYxUXOx+tPsszL16ThdavkNh/+90peK8IBUeVQtV/Nkpy3vOYabeY3On75vXX99pGTJZYtQGjRDQpVrMZ7K8ArHlASaX2WsTONoLM5+KVPXOXx0ElzPVWHciWDPSFlBF/LB23LJ8gE5Ij0al+pSakSo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QNTllom20CaPKRa4IYuWJ2cuCJ3vKhcwRiGWAEjJ4fxf5KiKMkHtOOpKRYMKgR2pWImDDwt3IWjURv3WbOI1KJDdI9FOmUxmfcaKpOzB+4V8lRqbNyr1gebVfpVJ1QXmMsGJKE303GlrPgnVqMyscIcuXdIsn1D3bmOOBSOFd3fFkJSz0gx7qSsYtNYlVM64uLeiChc330RuVvfAbgorOVVw5lLn8TKHuIs4FckFylFonwHdmK+tqpTVfXAa5J5PI7xy3XpheXB9NN/mmEpsS1SdEGPuOw2t3mUdvT6BdmwABF9UhJDR6A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 476e5869-ffc0-4d2a-837b-08dc6874a287 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:53.3231 (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: g9p9Z3rpxyvjSG8uz5s1S7csJCpfTke0bsqylrFCB9ao96r9LaQvZQm4tMsefnANl/5Aoz7UPWOeK8CIY8qz1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: w8XJjCVjeFu7x7h5YYAF4oa7fQ2gM3xQ X-Proofpoint-ORIG-GUID: w8XJjCVjeFu7x7h5YYAF4oa7fQ2gM3xQ Validate that an atomic write adheres to length/offset rules. Since we require extent alignment for atomic writes, this effectively also enforces that the BIO which iomap produces is aligned. For an IOCB with IOCB_ATOMIC set to get as far as xfs_file_dio_write(), FMODE_CAN_ATOMIC_WRITE will need to be set for the file; for this, FORCEALIGN and also ATOMICWRITES flags would also need to be set for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index ee4f94cf6f4e..256d05c1be6a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -712,12 +712,20 @@ xfs_file_dio_write( struct kiocb *iocb, struct iov_iter *from) { - struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); + struct inode *inode = file_inode(iocb->ki_filp); + struct xfs_inode *ip = XFS_I(inode); struct xfs_buftarg *target = xfs_inode_buftarg(ip); size_t count = iov_iter_count(from); struct xfs_mount *mp = ip->i_mount; unsigned int blockmask; + if (iocb->ki_flags & IOCB_ATOMIC) { + if (!generic_atomic_write_valid_size(iocb->ki_pos, from, + i_blocksize(inode), XFS_FSB_TO_B(mp, ip->i_extsize))) { + return -EINVAL; + } + } + /* direct I/O must be aligned to device logical sector size */ if ((iocb->ki_pos | count) & target->bt_logical_sectormask) return -EINVAL; From patchwork Mon Apr 29 17:47: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: 13647479 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 5DDE312A15A; Mon, 29 Apr 2024 17:50:27 +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=1714413028; cv=fail; b=mmRDjdQx9G5/3enq8D+7C69+IxK994ukYzgEz1Ul05Ade/MCU9Jia6IRJCkKODul4Yp4VhZJRyOovVShvMTL84zENPkpZMchSa41tM4SEZB+WNvc1P0fuNC11Naq/e9Zf5qkL3hvhJ7Ngs8Z9aE1K1J+0z9DJm0/yvYCqa000AE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714413028; c=relaxed/simple; bh=Ih8tEafXb+2JqesJECMMFEeN+UBfXfympEoWDMU1txA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VesCaQYrZvTSO/w74G5ylMzYwWuqARolpDsB/6gyURc1E+ojEH54b8rBc0hOUKYF4k4FksH3N2mvuetRQtDpOLRfciitSXyEJSrQBM8KKSLrMz1sJF+Wgcn9GDYRcPLEMlLDiVffOFJNa6fE0Sq4II/GcQVH90klCPgxXpxa60w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=WjCDxek6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=LNnfqUdP; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="WjCDxek6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="LNnfqUdP" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43TGwkoC004990; Mon, 29 Apr 2024 17:49:05 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=ZyOPNx/GZG5DQWwJEomXpGL4+JD24uptc3CmBdlQf30=; b=WjCDxek6gKk6eNvdgubbePAn38mAUF/ei+TNsVOMYgAnD+j7T32PAkyJtR3WPXXHPkpx ZkICQwFxiY1/fmOZqTevA0/siNZuREPNOPNN3T15BUe0A8z7OUfNBCxbwP9Gi71i/ZFH Ivt+FLsRmYVgS+706b2Wed68vNb/hlqU7TZJLYfKntNlJdwvHoJ2tHFKV88jV3RHt5T5 Q++YQ1lW2Nqcxu9yuKjS/UtVffwQ0FnML0YQWgThxx1Hut1ZsTrl+IE/vM+Ks8BEgtfL /LDW3E5378l8jvRgyd9t+K712bavk9BBGYbwY74VrBm37BII6Xqvr9fTDkq4vZ1JwOXr 2Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrsdek6cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 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 43TGqC8k016783; Mon, 29 Apr 2024 17:49:04 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 3xrqtcpy8g-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 29 Apr 2024 17:49:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GA5/TDJWVWhIVKcmSXLmEXtVlnfK/QncjyRwdJbBj9GsF6ijb3s+iI8KwqpLcKmbMs+MH5A+aF5ElGcwvIvvBIMjW3GtUv54WLeyw4I+jwjxdz9NRX78GiSRXKY9oMH1iP/gUdQDpl/XVbTmnSlcFGzOQMeUyAeYKyW7ysRyarIuglWGrdZcZIwe5NdK/RH6mjS0kJb6b3OB0G+JoPPSMLAmlxdV+GgVVZY/qZGnfyd+BWQEOq32x6x4K4InNjp6mbnXAoOR1egsmzGpl61i/2b4vQVEpSnaaw8EW8G3EDOdsu5z85JHRpYoRevIhz8VtmBWx1eBwqGTk7Db9w/7mg== 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=ZyOPNx/GZG5DQWwJEomXpGL4+JD24uptc3CmBdlQf30=; b=JTHxRYPx6vKiAR5Hly7dHMZeZdo+K4p8ojeSTgKPVY+FW73EWty/n/5J2CAb31u6cQ9Z2sUJwZE8PE3IVk/HCOMBxloqC37GetVwXOJajMPGon6YyxDuL1v/6qOYSWPc6nlALWieC4f8h72FlXRC3l8/xBiJ0LhTDx0wQbgYz9YtJoUhZGfFHzlJtQOHYFqkrDJuTgNF0e+WRIZPUheu4VDXSNP4jCnWoSRHU/3+X2Su60jpxZkguBcIdo6pY/42cNHtk8diW1sS2bKSck77p86BnL8JJZ+TTBHnjqW72w3oqDyhZvRaj15BftC2HEbTi79ZocBmMUFe+mbjiE6B8g== 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=ZyOPNx/GZG5DQWwJEomXpGL4+JD24uptc3CmBdlQf30=; b=LNnfqUdPxYW2MrQu1AxIdarx/kY/VMYBTMvO8f4eWtAktwctx+NG+VF2f04kkp0fmWv8xLP5uVmrW8EmBOBxQ0SUbJ7vz6B2+aXRIkj9qZfI9Te/viNLzOfgYdgIwICCZfPYh3CPSmG1+0ba6lDLNjQMTx6QgYXXbrPOse8SyDw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7763.namprd10.prod.outlook.com (2603:10b6:610:1bd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 17:48: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%4]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 17:48:55 +0000 From: John Garry To: david@fromorbit.com, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, chandan.babu@oracle.com, willy@infradead.org Cc: axboe@kernel.dk, martin.petersen@oracle.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, ojaswin@linux.ibm.com, ritesh.list@gmail.com, mcgrof@kernel.org, p.raghav@samsung.com, linux-xfs@vger.kernel.org, catherine.hoang@oracle.com, John Garry Subject: [PATCH v3 21/21] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Mon, 29 Apr 2024 17:47:46 +0000 Message-Id: <20240429174746.2132161-22-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240429174746.2132161-1-john.g.garry@oracle.com> References: <20240429174746.2132161-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR06CA0048.namprd06.prod.outlook.com (2603:10b6:a03:14b::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7763:EE_ X-MS-Office365-Filtering-Correlation-Id: 14d95c22-3e3a-4629-bf1e-08dc6874a3ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|366007; X-Microsoft-Antispam-Message-Info: C2uPRdk1dgMU0OhO8jSZS/Je5nWs8jZb8ugzIedGsAmZqoyECI225tnOaek2/cvo80EiuxXIThETi2OHyqBbi8kOnJq7Bfs7Oexm35I9KIh9LPdvh2wl6GEN+vbnGgXY60muo3xGbNQ6jcc1i/5Udv3H81wid5QkrkGpAtswNr9jKdfqDmB/lER3oDRXdIUdzFVu57zExWfyBfcO3eoGTT5kXHbCORr1aO8F6XMw8qdqtxB0aKHPhDtKcM8bLw8NCjUvQB6tD/JxrnksflTuimp8KR3Sxz/J8FPGULQlD1rrCdIvNTFnyD60Is6cInFefHKxQDyWRAK45gAo50uCobq04OGm+KNNn6INNOT5ZMwxvaWsVgd8T3bN6cjFmdBiw9udpg3w7lcnQ5seS+SGsmfvMqMvRKo2tz+avTtVVTsR6K6qIJkykQmrx514NGKhpJdGkTE7+ekmVkKc/mw31ZEONMMUGvXz3qYA9XCReH8e9vYbeQyXAbZbsuE0cpSB4NP+nG0aiq141cI1aVo9d2vogQnnCEbJ5g8zn6l+7FLbHLoBJzYED7Jm2meFxjoMrcaOrkDcs5TI/Pwgr5jaWqSe9rM46n16LZU8PcNBcTj67Ip1xMP0TpndOJn+XnPMiMXZ/AmJbuHD10RndvSrW5T3GnkqXv9YJUDxrpzgkeES1dFwMfDrD2TQMZ/97zG4V0VsiCBs3jnL0NvLsL8iD0bFZ6GJ98unh+c9FUwNaEQdAE5G5TESecknf5F5gN3AQ73uTzMpvl/xHmOViJhCHtFT8WWocf8Iw2zlOekF9FsGpUI8E7Swo39ULYhqMhG+g/X31MMYqUllnU97PNzso02o5w68OC1QvptLa2BG3vHVD2PeuglGJdIHbpLISlLTDKrMpVDJaUgyU4VfHH30jSJ+fqT0CEXYDsF04Q996HG3yY2g0o5fOhNLv6upStBE2c21bCazaat8pnHJGlDbv3211/UE10/FWFldzG8GeLA56Sonwm+a9koA0qVpi8kWtQcAMEiuWUmoYjeFXktryGoqxUgzurxsdrdYlQlGKfoiDUB6ztUFwZZbEOtbU0DPwbeyhOrVjuugO/eSnDNByLnTsI+cVH/gANnso9ZRB+K977mtyRsRQV4gPBI5poAWmOrTcDgZvDr/xVi4KTeVZpvefNIsSLTW//yHM9CeAkGy0l2zQRmeHj7lC1aucDamXGW51StEq4wp0LtkZRy+JsNbDqMHa8EdmtOP/P6V2dw+ejh6yno7crx/jFVEDf6HjblPtbcWQ/8KaWtlLoLk/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:(13230031)(1800799015)(376005)(7416005)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EzndzFO9mmdOxb0tNu3jSoXQWd9s0JzMC43SbgNQFbpZi159FvdFCf3r40FN7Yhm4zNjsPbVz9N3v0MAcKslAhXagPdWu33SefR1C+HzTw5NzNz1tNjDyzeVatMUb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gVBELOJd2NPfERi3wvczk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14d95c22-3e3a-4629-bf1e-08dc6874a3ac X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 17:48:55.2732 (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: cs7qsxWzzj4L6buyIbrWfBPdt/uRID1FcPHgOzUjT+38Fdke7YuUQNFhcfkNKz7+w3b1lkZoyTVhyXFSfqZUhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7763 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-29_15,2024-04-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404290115 X-Proofpoint-GUID: u710AV0qDp4fnXW7X_rA97Mn2cxLE4v- X-Proofpoint-ORIG-GUID: u710AV0qDp4fnXW7X_rA97Mn2cxLE4v- For when an inode is enabled for atomic writes, set FMODE_CAN_ATOMIC_WRITE flag. Only direct IO is currently supported, so check for that also. We rely on the block layer to reject atomic writes which exceed the bdev request_queue limits, so don't bother checking any such thing here. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 256d05c1be6a..5a17748eb6bd 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1243,6 +1243,18 @@ xfs_file_remap_range( return remapped > 0 ? remapped : ret; } +static bool xfs_file_open_can_atomicwrite( + struct inode *inode, + struct file *file) +{ + struct xfs_inode *ip = XFS_I(inode); + + if (!(file->f_flags & O_DIRECT)) + return false; + + return xfs_inode_has_atomicwrites(ip); +} + STATIC int xfs_file_open( struct inode *inode, @@ -1252,6 +1264,8 @@ xfs_file_open( return -EIO; file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC | FMODE_DIO_PARALLEL_WRITE | FMODE_CAN_ODIRECT; + if (xfs_file_open_can_atomicwrite(inode, file)) + file->f_mode |= FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); }