From patchwork Tue Aug 13 16:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13762267 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 66FEA1A2556; Tue, 13 Aug 2024 16:37:01 +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=1723567023; cv=fail; b=Os3Er8iXsWMf4UHCaQToqWzZd8eR6Hv7kv+9M9kG4aC87PDTuHgc8s33n/2BxA5BA3FcwOPmYYtgXBya8L4DuzIP0t0XFqZEyFpTm0rD4eyaD0cDoAJZoU393SMjLct2OEyU49gBEWbYpWVdJ42Sf0Sp4GhoaD+bvSBh0GkR0M8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567023; c=relaxed/simple; bh=3d0NAqismK1oHxyZsbPGHkoTG01Z3JS438mo/jksfq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UR2OhIMkA8plaRtL1NfwN3hh2WOygTQ/693zFHqq+1m8UAbK7nUCqc0/eFz/fkulgoWXo2JoyhJ13sOfl5WmO4GQMXrp/sXUPpDJqmOonNmo8/FyMj3tgPm61QjAMDwn5jVARthYih+8csHhsmUntZOMcJLQ463wGv8ViCgd1eY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=if/IUaIK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=fq8w75e8; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="if/IUaIK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="fq8w75e8" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBSMU009718; Tue, 13 Aug 2024 16:36:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b= if/IUaIKoPcFwnH3MFCYTMonO69BjPiOkybPS4yXvA8fBJfLfyGApOJUTEfEn5bZ D7nh/FfjjxDqJaGBmjxOz4fXdkHrN2A8Fje29rpSt0F5yAwHW/1BY1+jir2lF5Bh HxiFisZhAfNkF1ufDXun8DGe33zoOOlIIgfV4Na+rJi/e35Acm8/euzjU8lsCHEP KM5Ur5WraSB9uklj8NRJo+PM23mukBnP5QvlQjWDfymhvsoWX3xs/55Eo7YBcLVN EVdd0f1KEtK+bx7/AqXLDDNA+vLFSIlGZ+RimQzUsIKRCiYDXdfw+Q9v2FzZVo+g kP2wjRp8KB95lAma9kqiMg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy02xg0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:51 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DFeTNp017662; Tue, 13 Aug 2024 16:36:50 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn9pd6n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aAnYJt6OU9HDrMTZtwz/u5ytiarc6QoI38lZ3JEZmnA/azfJ/WOk7XDSnVJm7aGQPXbg+iZNFzCsEIdxqq0mH8KA2f+tmW0f8mhOT2EGsDHiV77zJdVWE6ObcXNp46XpcHovGFUoaiXZg8hRPhVz2oLvP9+oEz729Rs3p4rDcVeoX3DEaP16E3VI6nmGoOAt/ggpEVJhakLf1/6zZ35zoSAL8ypJNZrCn3xZfUgj42A8wD2n/HtiWmsos6Sq41SXOcOgS8xYbROWiikkrHc9wtgyWc+QeACgpUtb9gSzixYMM/7DjVpJ/Q7ffDTbqQefpZDRPGK5u6bHUv0pfAEVqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b=wCnhjA+/X/LozG71F4PDbJ9yS8tqXgWsQ50zj7Cnc1KZTEVmRFj6gKNY4QM5nh2XVspQ9wfGqbG9kwV47FKwHfstmh8Y7aLaztmBYzPF6GfTHuhMcvoUjYPRlDaipStDeNtpWhiEJafYku7ZmRipxhuAksP8F3grAtSS2HU5KcBmLknA5VsKz2D+CGyKa+Bxikt72Pzl7ToN6sMOA6noNUmJ2vi3zPvloa+L+nzTbQT5TEdOJPnyl1ICDEosGEZ0AW4B8sVnfxehNp7OGzSHWyEgQNBRIpbZdYA3kvJZlQE7VPO0lc7biMeafWBxZF+0NiXnV7YTmGS+OEeyzzYnxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DVAFJDnrzrSAvCrZzveWH0484OJH9pv30i1p8PpGPbw=; b=fq8w75e8GVyIMuc9wIcY8U81e1nhbGnglqcw0Lde1R+MKSoE1BKuRUPTb5rwDiUV5OZIPHL87piFat4k4YOYb6UVNtfCBUBo6J08R8D1vaiq35eQLpLs6jL3BurSKiX1pQMcyOu94G5opJ1RqXfJvivs+9L4I+BTzY/zw2KtB3s= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6354.namprd10.prod.outlook.com (2603:10b6:510:1b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.8; Tue, 13 Aug 2024 16:36:48 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:36:48 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 01/14] xfs: only allow minlen allocations when near ENOSPC Date: Tue, 13 Aug 2024 16:36:25 +0000 Message-Id: <20240813163638.3751939-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0018.namprd05.prod.outlook.com (2603:10b6:a03:c0::31) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB6354:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bb7caf6-f74f-4574-fb16-08dcbbb6207b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: xbcmhv80oHu7Q05S/9MGmehpHKnkvJ2+cBTvJcSHRIakYYfASDHxYqQrgCNbupDoAI6UtP1xcaDV4p0fAU+W4/2C0XxUjbXDBUmtJOAHjbzLJu8wKjejSYOSTpb1rMC9GFMzEn6NoOo2opujDM3h3I62obIcJML1rhWGq/4Kd3Jow5KMYYj/+VWBrdjnjUd+kTvmAP49pY6l5/0r9uR9xDLEFkm42uiwWPn7XsMoUBtfH7AqEJdFO+MJf+IoSriBwCr1pU/gzo7tOz85tvaO42bc9FxNU3kFIr32LKbj5JUxH2FseLpklSnJb3LGWryRBB8bWuwdklDBlrIoWnLW9mOQ4WEdg8WBZMO3DPycLsmKLjq1LbDdryio74px9Z//w72saaaAngt0/ouzbEnfXIEVQRuHENQxY6n7yC8OeyCYHOpB2fahYRjPBxqM5JXI1CV9d8+MWHj4siXp4DThtH/eQ6qXiO0eI50AsPxHnR6Wiv78T6lbbfgOn/cZTpfxUOjPFFdtLSozoeLSFLTUCS/jduVuh/SWydvCfZUoYQYu3KtW/+1rF3GIdrqrwwZVpu/spKIDhaLYSSQ2+ViescY7PmJCQuQ8sJSevbuRiMHyqdsxDomvzO6XnIKCxh+AcZsrHwzLFz11idjdcu7y/aHPGGAYpg38qR+vCn98dIHfpOraBMmTkdViVxe4X2SUOWFT95TadaHycPH3iqPI3WLOndsleE+yxI2TlFz8ygBesHti2+G2QPR1y88e5rNEmNFGqkWLjkYaBLv/m2F3532YuvKJu8Uva0lKVcqrv4myBIXSZn1tw8ylOzikzFCHlvZiDmemoPCz83UI8Ep3CjpnECnRfdkBgIjclb5VGZDA0b8JP6x9uQtIG6tquZ+DqRKR4G0Tg6USuonauZAJ2G2oXN4dMvCLWezcGm1d0zUdlUdH1qqRD1ah8M/8lUaB92OC7PEYkmafDooZJNMkuGy7JwW4YrE/gU/PdtK/YJ20cwzOqgsy5q9ijRUx8OdAu97tRDRWH0fMtqULKy2m1/IeKMlbWtvECdTMn6redICohBnGV+9IY2wJo4U/CblWA8X25ulT24tYdGJidiDioxjm3LwDfQvxuViLYfVZQ27YksYU776VR8M6ipQsH0ebfVkuV767L6BR0DUnDB10f3E+qRRn3WdbMA8F3b0Wy4za3MMC9TUBV32zt9STydrp4XdwI83Y8F1ng6NjbbpfG+xfb9sOnnqK6+N5gkSOmhqQsiYzGyP5eCJmG4RoQyMybEiLjEDzdT7y7ysQiPTXSlr9I/9QuNL8Z7oWFdOzNE4otcbzVSv/CwgADUkBoCGfVjlRClAhLc0VtCc2S0ZTLg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4NEey2LNvjulxOIxT1Ohl9HWViJiFq3fc9J/kI2QokHYm+J9tFv5AgDqQW34KOiziIA5vvErqWXk+clo6b+25UDsTqSZWQqmk21QlOyG/IbB5GACdftspCgn4bZ4UXDgqsxrAIZ5DBypsobj64Y1hzQvSV26qNktfIBIvK2iBJGO+kxJR8TQgSKFDrD7BAPlXbxVINihWQc0+7jKLLUULmbLk8oTeOTQAMmPCPfsdlAVIcHOZinvj7/tcwcI8C2B1Okk6MhG/dwyoUO4gUGabCre1T2RSOeAnWQu5yuuB76DgBnh7PFdpQZAwElWcNinc9SliQT1A3DEus51OgtC9tpgroG15x1Uq7ED6m3xbXvpNVtkVBcQTbNvrZpIU2ptNTiuVlQfrSFRUxu7hlwhW1Ar4Ocsb6elDTInLIupXwNwL9CjqRdx/4eRk5H8WsPGDdMHg+xLy94LQ9G5oh7uB71Ux0PaT48xSXYLMYfmSKIn8VecWeYziK4VMqHhe13lUJI3OxSXnqqp5tY4aH1wQvwfhMra1n0/S0Ns9EJI/XzciVP18X5EAPSmijTsaN4tWY5uT60czX3JI2OhLgQtmEkPiYq8wm12moc2aXJwUCreq6fCnvRaCYvhtoiVi4Y+/GaivHDeU5fUmPQ0y6bGIyuXsfu1zkYnnBXR3SVOsuZEw2Da/wZQUUDbG0MX1e/6CHkEa5hYmiuPMYuT6iOGfRLolgfpJhnXI/nfJycQMxwUhOdWC09NrT3ekNkuG2DJTcszACEmzXN7sQXSR0tzJVbaUM2S71ksebnwnU4qJiooGDV+YJm8gBX8ZAjioC6cjz8XMxojlVI/c9qOO+3Ymi4yD0ncRG7/b4ZORSovQ5d90fv+NMhpEJ+y+w5qoecGk2sCqe4vrTGlZ426k/8zIk6MJ2HxwqrGrxratxFdN0ZEoiWh33ZCxXvtPPu9b6JaLSUl697snr/gWyKV2UKJSlO5IBkfanVIH6u4AhSBETtefTboD4203v1LvbDZlvw4n18QwV1oGRW+SRtLx4OzYoY6BdoMOluRBgTV4AHmJEI8ofgu6jdepCErJgjNID8xpxXl6Xr4brC6i2C0ZscAAQBI1VkM99roYI4u/zdnVKi4XGHfWksPAxEhYXGIogs1BNF78PkrmX4dUB2Erz2Fz1iGB5zV7o2S8oSvdD/2rMJCyQuVxFE2R6eBhli29vcRxO1Jlt2UHNGwpAZw80owYEjX5/73kdE/DiwO3WuvdJliGmIoZyKDRNaXJadQ1a/2nU7K2MQRLobQXDyKULGRAs5iHX5ErGFyKKly61tVNPuywaCtWZfd2agsi1XBDeDjHSysZoVoqzvTRw90vwBJ9b4R2KC3jw//qgjiCdM8IoWxBmC1LsloJM75jZJySyvg4YZmZ1tzvkpiNE8b55SD8MiqlV29fG271zlMzELO62sEEytiVTz30pfArcveeZGWWl0i7109Udfq0qHagqc9Bf1Aclm7cgI6Ap45habS8Z6QXUenp3MpiAlyAuPx6o0fdE6B2wjMhCWBSAenpPdLsYIbXSvjd5O/a15jYVyYbjDZUU6Fh7sljTEpa0x1lc5oW2chfWzFwObgZsHBqX6MYA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0CF0Ytb+VbQre1viLXx8rEdRLGmNzxZLQjfMRDSBMvwSo8cZYelLTbQ08HnoIjdDQp1dovEI3C0OU7hl0WymFVsWZmiq5iYN3iBE6gel4g31GHW4mXXyUB6DbCktmeKiDLNWGaWzPxok+PTKnDo+JVAqe0CgSIGeITh2P+1qpY22TxFCY+DesjdQAmPNv8c/cD53Uba4a5OmLpK/QD8toSAt6Xume+JtTzPtWF2Wb8IgOMjGI+Dd88/dcLgpfeia1pUCmCeNoxrk+OKLnKwMv2U13kmK8w5yGWSWDacBIiPvOv2ovYc5WtJEfD2XugRc73vCg/3yzYCJbDdnzEnRnuYCf2i8I27ngEEnT7xmSzX8R9OCUO/zhb75VAz8Fm4lQopCq3Lk2KKWuQvtjQzKSH3Fmn+AF0N+pIMsOvq8aoIIwx7SefzpvYovRcqw+SqjdZX1AFX3ycXhZ23c/9bTbNlE4f1e/YgamQ0wOr/fCTBb86zILNuIXCFq4c1/W8ksEDnSHgxNo0aI7481R+SX3ewLF0mJfkuoPT6d4lFTaVfgT9VgPWPVBQ5N7tL58PoY7TeE3k5b2/JZMzFEv21dQ91X8C5NKUlwZBSAYga/v4U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bb7caf6-f74f-4574-fb16-08dcbbb6207b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:48.4049 (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: ayZsT7MrQWJPkNzQAJg5BJnPX0i7+8zev9KcwgbJKK7Q1gFSnve0jd939hd2shfXcTDozhcddSp3VXOnjrYjGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6354 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: jnp5KPw8xU6wet_PtmX0QRaDjEVr0zSo X-Proofpoint-ORIG-GUID: jnp5KPw8xU6wet_PtmX0QRaDjEVr0zSo 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 Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_alloc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 59326f84f6a5..d559d992c6ef 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2524,14 +2524,23 @@ xfs_alloc_space_available( if (available < (int)max(args->total, alloc_len)) return false; + if (flags & XFS_ALLOC_FLAG_CHECK) + return true; + /* - * Clamp maxlen to the amount of free space available for the actual - * extent allocation. + * If we can't do a maxlen allocation, then we must reduce the size of + * the allocation to match the available free space. We know how big + * the largest contiguous free space we can allocate is, so that's our + * upper bound. However, we don't exaclty know what alignment/size + * constraints have been placed on the allocation, so we can't + * arbitrarily select some new max size. Hence make this a minlen + * allocation as we know that will definitely succeed and match the + * callers alignment constraints. */ - if (available < (int)args->maxlen && !(flags & XFS_ALLOC_FLAG_CHECK)) { - args->maxlen = available; + alloc_len = args->maxlen + (args->alignment - 1) + args->minalignslop; + if (longest < alloc_len) { + args->maxlen = args->minlen; ASSERT(args->maxlen > 0); - ASSERT(args->maxlen >= args->minlen); } return true; From patchwork Tue Aug 13 16:36: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: 13762269 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 92EF01A2C18; Tue, 13 Aug 2024 16:37:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567026; cv=fail; b=CqnBKyh4IGytUZjyuE5P75Vk4NhnYgDRXTDxYO5QE6yL+ppar7DWRAbf/jGex4+6nNQ7BQEBkzKcV9kcNdA+/Oj3uG2Kj6hkRaG3eIIfd2PlYJgAFKxySHcB0fNE7ohrDwPG3N+G2zxsHoFB5nk1xcIVKkByDJV1mKoU6Fca6c4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567026; c=relaxed/simple; bh=zWRDLuo/ILWanQJGpQZkcZulk/YZxcolQW3I7gFzbp8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P8IJDw0EhNzPu+V0eYTxg8Ng33eIEC26ep3KnX2pbHcRE9BK1Vq4IH+ugvTiBBM3NwLoaDMjeymeHMHmJhnLyaiIWFm9oBIg9owIGPCNx/rb4GXo8rfI9ui3OnrM8u5mTa+9S4dSH9POrBFydwQqLgFVvK/MpcZLjfjt07y2zxo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=GebHMFTl; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UUd2+ipa; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GebHMFTl"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UUd2+ipa" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTwV007375; Tue, 13 Aug 2024 16:36:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b= GebHMFTlXJcXbQJqTkv9+LQauWnN+4UH3I43Jqb2kbDjTpsQZKaWcf6IMwCqdSXL 7ye51fjAk+HDHJLMHf/6OpdjC89mq+n1VauUQ4ritAmfVMKolkKP/ATfLcaLpNFP Gwl5lyWuhSX9dOwBSYbUqlRM421N0n0/GIJ6Q1MYPTJP0lXSBpXg5tiaRnX/6jQl W9RZ5G2xKxbjJoEB6l/I3jSc/6rmO0bHRkmwoUzP6V+i3OjcWjSbDiNgScDpPuqC E/crQDzKlxr1tiH3qaq2F6NacU1D023gusC1XS+LEqlqX5eCwp/K04H2ApIpO9Zy yeX8RQT7+uSVBTcCKDtgdA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxt0xff7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:54 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DF7Bve010631; Tue, 13 Aug 2024 16:36:52 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8rytn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J9SqKbbNJy8xIrk7EVSsCtenU9RBJUs1Sh/fqIA5ChSjmMxe4jetguSsfD1FOQdIedJ3lMZ1Qt+H+xThQdr7rAjUrCp/oYfAcs7xUEhVeVTpoguzcGoRKttqpVfiQlBOX/dymaBkk9l2wr/C+MWNdmj3qdGL4AmNH1AGmCWNOD3mAap+ch9YDVk9RGjATU2uRnoQXmHSYFouA+KpYm+KjQEg+4KhIRpvSod2EBAyWK5lOXU/TOCTRdNqulKZu1YcY2HADnmQGds8FqRiWq+c+ncSkGn6MVO8S2LeJX2vszToCw/2ImxKE4h8MUACBxJj2H4K2ihFL2/6BaSDD4o0eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b=APMgizs+niEm+pY8pw1ndAs1hBdmT1YdYBmegp1flUxb0BvpHHnaRmV9rpZfbQkBi37uUl0wxFo50bJdwuGdXvEqvv/kksM3uwgV/iBXMzrjLXiAX4TAHWd4qld+NQlCXFGr5FUS52oFjlwpE0ThhZQXy/m05cRIC9nkkEvNSESWa/S8E29z3+U68Rn7Q8eNOJBTVDV0LXfasabMNoeiiGFL4/lTzr2MefWkyT76nCKVcxzsycmIpfycs6Yh3Ee7So5pkaEBYMMDweA+EdpzH9K8Uqro0VCsEfbnvksg/a9/mI9JqwHgtBn7AuAGHC2PznCy/B4hCmoyY+jIMf3+qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/vGPOSgKv4rwY21roIrT4v81Jkb2+AWEDbk7Fux44jA=; b=UUd2+ipaxXhl7O8XO3738w3313J98OCjy7EmQXu4sDxyjm4GrMXsNqxrIJBm8UIB6BWe9LsoFDTPuekmwEZ1hcishXuU1kBqkANOZPxp+4i8goHZWkYCrzDF6owxV4ectuX2XIqne5U7lsyM3kgoB2arT2QgpStsbRyTmPQJ9Rw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB6354.namprd10.prod.outlook.com (2603:10b6:510:1b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.8; Tue, 13 Aug 2024 16:36:50 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:36:50 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 02/14] xfs: always tail align maxlen allocations Date: Tue, 13 Aug 2024 16:36:26 +0000 Message-Id: <20240813163638.3751939-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0020.namprd05.prod.outlook.com (2603:10b6:a03:c0::33) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB6354:EE_ X-MS-Office365-Filtering-Correlation-Id: eaef908b-0916-4ea0-b3f2-08dcbbb6219f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: t37LI1OkaXGQwN0WGDs8h6GC46Cxq4ibyopdB7VmM/HnpuXASeic4M68t/tTPA6M1PAyUG+pLUIPJk1Q9BPKjjHyn2w6Wl6okuiqal2EiaNDw6WnxFaKgr8VslbA1FRZc4XZi/t/46LLGPSXbEDdsApH8DOSa+uOVkGL/ctJFNDE9TBbZEY/xwhdGTNi3v26bGzNmd5SSrWDTKufVnvLQe/xf8DSF82bFgm0uNdl/7UvKXkVEKeWCkenEZZ5ryTRKdovXQTu7rgRVnqkLxuYqDqMSsaCStXo0xgW9bXXVwqFpRvA/E3NpuYXdlAFJ4rPmFonNurVUaSslmwx51cV0W22HcWw8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IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x/jm96ua/n4u6KJAfoQXwgsrsCw6cmi9rmUMw+pT8AuqrLNNmbFxoI5XCRls5nXDgzslt6qBEFD+IVbmmkBJDQdAPLbm2ghmE/vVtbl6d3DJim6W87Hg4vHfPsGEmbCPBW8r0YqTIfm2VjJIHdcOf4vvwkyahcls9Y2KMBNRXOy4r4keghnlxpxRnIVEcRuyNs9l2WJ9LKPbcLahokEOqk7y8zNyP3O7vLSTZSyzmYfoqcmMOlxOf7IeuvQQ3EJHhyIBbfQo7+1JGS/bRDVgXES6CWv+PxoYo4R6M4eLdQ2G/7cdfYPq8fQAoaJNR3RIVoxE14FebE6b3E2QbsWMAGRcsypcjKyRMq/kGqvt/MBVlBtVDD+jF/APnmrzQya3b3nGZuvbVbPH0ssGsyi4fnh44xMg5g3zAcASHPONfyMUy/H6vkdyrKWQbn3qHdCLgtuw8SEOEvfksTC6Psz4cB63QKjTt9bKWwtRqwPcXtsEe+yaYGmEVKX9PpmaQyfyhPjENDRFIjt/JP5WVYOVhbbBNWQKQndaWd49UAZLY5erK12UX8u2KTFF/nOQknFtGJ3wpK2VWkH2hu8HBZv7fEVEMSoByehWx6/mdwGGVNCFAccQTlH3oGQsqiZShzvZBAHTsVnr352QK4S4YgT8ST6yFb8NlfRDTK3+5lHAdNEA8StD+ER5gSM0Fs5zWNmxSU5C+14oJ20tdr/dHk9q1NPEhssZ+5vIqA0te2qnpjDfZ08hJCiQK4ylEAUf/ubWw4T8IeM43amTkUgIUAE2O8Y8S9d1vsZkCaKAbeY5swWTLOilS4jEP6uF4/oGzWeVrj5krxzQ5ZW3vhkZKOP1LbYqnjHFX2VIwWatgUkH3QkDhfwBCxmwQrm6ofGUds0MLy9cp3IPQU0PgUIaONGl6l0EYCN4wE9NAiYv5xAWzXx1K6tcaeI15xXvTshN2L/JbrtrdxgP7sZATKjasTvoHqTKcJ+jsN3KCTKhFyBbvjrzxg/chU6vMOLXiJ6cPbpxf6T4TcNpY+PNbDX4oa2l0joj0b4FaDK4NtB5sk8O+/oNLhW6Xj3rHcZm5TkTGlyX0EiuEbxqvdkNpSE2+GiMPhK+WJxTBjDDy3HGb8a1ftpYoFtfcG7tAF5ETETBQ4gJm5GHRapCKPl96NH4SwRXiz1pq43PP/lZ3uIexQo35oZr8hB+DlzmceqhMM1OC09djRQQQyqfXdXq89HVpzb6eIxv+ZEYmiOc6YNbr0VAPB+rf0DmGRVcvWe5iXNkjqBvePqP/5/8t5pH3R80bp2ugLWCff2ASv3L4m22qv1FQkYQOClrw3STbAjTetVnz9oxosbndbr3qBT9Q0pRl6Zll6IIBgnZlhNh49es876YIqwyUsRrb9dn4skXMSpXuOf4M7FXAsBHlrBrlBg901A0Gpssce+85I0UOduioObAQHB3AJ3FdfY6mugnKN/vTjVikw4yi9fVNQKVpXqPUUsW4qrm52Jos8MEsddXQEHRgQtZQ69B0xuzmTIulh09378b/yl16Vt17myF1Tbgb1dM3cJqVRqPjRq6821bhYroA1F3zsoAnfTzrNR8jdNsiCs74/MBDNaKyuB3EdWkjuBtKw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: AOo0fQaTX9cgUSfNorzwuaG5vC8oLhmXEZsewNPNxmFF7VcPjt/itmgKCslZYVqPl+d1lQo2255SuNCSYNxOQRIp1XWcgcDV5MOtllLMGeJhVR7vOT705V/2DEUxWDiQVVKF81wKFgGeBHgfzO8hafSQ8KPIOzR0v1uwRO9GWWyS8difktsgqcAWG73qQllnru1w9NPqyXPeIlcxUQi6aoHRa7IG8eKO33UrqPWqDBy77S6TV8Y+POqzixl+ofnasXkV6lDNkoocOUpOmkHe8LPvOAmSJ4Wu3togRpj2IbxySoM0zAmN/QtTLPLu4+MzT/v4nAYIF1wwvFJ20DAUi4KFYjoxLi85u7YzOVYP6xnP5Ljq3sfJv5ow7HNygTuB3yLI9ddxuh5agRMgmJVsDX2xVNN4myOnI5GAvQhqLSxBwnb9qzelObhqARB1Y4D4c9p3N41g8WrblrQb0Yf42SSlqYl6yxNc4IxX2b9O/HcH9Kx22E5XCbscgphiWZ505fCAQY+Ff7FNeglVE9dvW376dJIGmc40UsU307tz+Y9An4aeqs4O8eLWg0EpxhMO0F3s2R1h6tHN9+qWzDYNQj016RVu53veFvX8vjFgb3s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaef908b-0916-4ea0-b3f2-08dcbbb6219f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:50.3085 (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: Zo9r/NfD2nFSy0ErQA+S7snN8wRYTToTRPAigCGrM2WP97MVk6IocD/sf+laDavROlNYCHo7hC1lNdwN+2OHUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6354 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: nRN4WGXnxfwQXj8aqQC5g_sKKlVLJzbJ X-Proofpoint-ORIG-GUID: nRN4WGXnxfwQXj8aqQC5g_sKKlVLJzbJ From: Dave Chinner When we do a large allocation, the core free space allocation code assumes that args->maxlen is aligned to args->prod/args->mod. hence if we get a maximum sized extent allocated, it does not do tail alignment of the extent. However, this assumes that nothing modifies args->maxlen between the original allocation context setup and trimming the selected free space extent to size. This assumption has recently been found to be invalid - xfs_alloc_space_available() modifies args->maxlen in low space situations - and there may be more situations we haven't yet found like this. Force aligned allocation introduces the requirement that extents are correctly tail aligned, resulting in this occasional latent alignment failure to be reclassified from an unimportant curiousity to a must-fix bug. Removing the assumption about args->maxlen allocations always being tail aligned is trivial, and should not impact anything because args->maxlen for inodes with extent size hints configured are already aligned. Hence all this change does it avoid weird corner cases that would have resulted in unaligned extent sizes by always trimming the extent down to an aligned size. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" [provisional on v1 series comment] Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_alloc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index d559d992c6ef..bf08b9e9d9ac 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -433,20 +433,18 @@ xfs_alloc_compute_diff( * Fix up the length, based on mod and prod. * len should be k * prod + mod for some k. * If len is too small it is returned unchanged. - * If len hits maxlen it is left alone. */ -STATIC void +static void xfs_alloc_fix_len( - xfs_alloc_arg_t *args) /* allocation argument structure */ + struct xfs_alloc_arg *args) { - xfs_extlen_t k; - xfs_extlen_t rlen; + xfs_extlen_t k; + xfs_extlen_t rlen = args->len; ASSERT(args->mod < args->prod); - rlen = args->len; ASSERT(rlen >= args->minlen); ASSERT(rlen <= args->maxlen); - if (args->prod <= 1 || rlen < args->mod || rlen == args->maxlen || + if (args->prod <= 1 || rlen < args->mod || (args->mod == 0 && rlen < args->prod)) return; k = rlen % args->prod; From patchwork Tue Aug 13 16:36: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: 13762271 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 705181A38FE; Tue, 13 Aug 2024 16:37:11 +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=1723567033; cv=fail; b=oMhoCriygau4don6DjM/TbUYfj2n3BcGbggzKFQ+Zx9qJp7p8bncN5dHGl0Uq6VC03qu4YU/sWyLJUwIQihWkYutMKyoUrL8MQ+IPUawuFM0EQDSv8oc0MtWUsynUhFdIWytwSa4haIFO1lDId3jmNZWMtHiRERXl3iltfcKDh4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567033; c=relaxed/simple; bh=Ib2HHk/yTuVdz4dw2DPmbyIXO6Y+gsfiEIU6NeveZ6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h6jLTrJmc/JPulfDihGfD56/thgJcQROzh9EACAlBJs+o4CcegHLoG3GTD1kC0/QFndV2FWVz8XN4snvMiOOMKpyrrv3kn37bwPaqOWofjOWLfoUQXpqFrlCwfUefdcA10OSHDUSZsHYbxGQUuiWSQ/dWVyGWhiFc2qLfwk1ZEk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=SbNx4PYu; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=NRqVEukx; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="SbNx4PYu"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="NRqVEukx" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBVuq002879; Tue, 13 Aug 2024 16:36:57 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=/qGtRo1kUwZOp4SUJ/OyBt8SlWcPF46XhO9BSs6+/Rc=; b= SbNx4PYuDe0PlPOE/ENPn4jUOopIadcLWD6iKzpPQ0R1dmWErz8/ZZlfWmcfjY9d NSUedeDvLtlEUKcxttmFLiFVV1cPMmfQ6NIQtLwWC3CUsFqY8xxzijzpMxcLdKjY K4QIBeQFjkv/xIbr1gdp8UdXSCYn1ZIFvet4s0ySf6Fc1InjfnfdMDDIDId9F2bo xl/JwFRzGeK46kXKjLyQVzUXV40kth5suzAkYKXeyg686s2ycSFlKZBpCHSL8IkX RUIPLQTNCrSPYrULl/R29zJhGZt4n9PmloiyY8sDcvw4l7EBG0raupwdyo/RkzIV wRJfjLv3+L0NyHngrEawWQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0rtpf7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DG94Wi017631; Tue, 13 Aug 2024 16:36:56 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn9pdey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RgTkx25AeLjSExTO8NMDZN90CQJMIswz0Y3eLhH0+DJmSg5vPkNBv8F004PIFsIqV2ZvTYOlD5onkSCHEK/UPdXEu1WjOc4aoUxoUMqanYKFmqkbEG7NjReKl/S6HfLJTdHEVl6qs9g6qxLv+DF6GH9iAgLwVojPxkzXHsGP9YCSona5M/2Vg2T9ZIUAi1HgZJYX1qyJy+kkjluHLRnRdGYqXYO92ngg/l3wNTyovLrCbA3GkErZf9jY10YzUwMZRrvcQnx8Q/sPTt6KwH+VQ9M37RSQkZDk8cuuteuKP2XNCJKrzLd6EapafSvvEzTsHoOqVeP45cFPRHscXlSk3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/qGtRo1kUwZOp4SUJ/OyBt8SlWcPF46XhO9BSs6+/Rc=; b=GN76wfBJZ/wrdqsJOFX1mmaJb1zqAyfYRnEXUvGpPzQ8SArXzbHBDAJIsA1RVi2jmnXvK0HjXDBc+98++wHeU/0IrujrN582UpL9IzAGXhB3VzJNMa972GWYO0I4fh/sRPVk3w8/cxGaHYRbLEHvNdarPSsgDYX6yYLreHvkZkbeWbd8DgKiaCyuNl4bAKXfHbDGaVDp8poZfTmJa37HDHWfZ60wiAia3RfIQTjT1AZGXehdtqXBpEH734OdvKnuuXp10bRRUIzyIXBdExC/p8Ro3mv50zQ2xB7Mn4f0XI+dO/gupiGDaqngbgL0x5vjY6VbPrlU6kDPTJqPrK71iA== 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=/qGtRo1kUwZOp4SUJ/OyBt8SlWcPF46XhO9BSs6+/Rc=; b=NRqVEukx4Jjac6c9XOKBY8J10nhcBYi0vGips/1GYLxUtU1kf1b2/Bo7scEz/CJkwoILZT52MW5rh2iFLLCI3DWG7jv2WtFG2l+zwRaDy3nkQTaZ+wrkK0DjRLcNWbQ2xRbVgLT/GIJ9uHoh6DT1QXy5s9s6/QoPb7C27Yt5saw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:36:53 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:36:52 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 03/14] xfs: simplify extent allocation alignment Date: Tue, 13 Aug 2024 16:36:27 +0000 Message-Id: <20240813163638.3751939-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR05CA0001.namprd05.prod.outlook.com (2603:10b6:a03:254::6) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 2898a4d0-8717-4de5-148e-08dcbbb622f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: SEzPhPovtYX3+G0Ux65Dfuz1nue12Yu9oFoT1/iHxvR7WBV3glLMQ+COPSxFMLFee/wYQCTkqOWIyJiXqDbbd6IEHjmvPyt5Jb6mR5RU6HyByYoH7teGgS7HFPIBBLSb59/IsrhTlkqxDsTJH26NH3VZ5BbaP3vNP/9dHPF2sA15Oa+AcO46B0cp08BPp0E/aZW8Jz0OFcL7blJUhMpwFGSk/h08wORY95+tAOVA8jyrXIErDwygLZvQRgFM3QxSWMnlBq7eyIxPXBjQEqV4WHVFkFMOx2q4AGZI+DZkNkou9M7+EtIVuebTHWx2I1tyfUrZdiTEQLOw+HT8wYl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H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TWj3KyKAZb5d8Bl0bQQnHxeXh5LBPDylCXhMBa0Cr+yHN16ySStfH3FSEJ2ACk/CFclyT+R69qbDYRdRSmce4PyulC6efXLI6wRlxZFbqOURgF2qPWQHGPRvRztmJ52AsDgaic62cLpjHTsfOxH2loFAGf/J76IBj8E81QqYt+XdSOQY3biJpeoXX1eD+GsIF0dDY+Ho5bKSR6+xMu7aGkxPqW6JI0zhXz6Iu0fMGw87PLTmlIvAKwfaNn3n1aWPUxIJTPNRH4Xj7l1p7Pko3M2HZajVttGQKYRVyR4c9ghUlHswzpS+lzVcYJtF6Ipd4v5bxgcRYvtj/4OvrJKrn4TQAEO0xhPpDD25/5UjDvIJpiVClhnTB6GZiqAO6HA1ag3b0kKSTU4IwToHcxf3+Tcs5ljAH/GwO3489heMqnBxRY6ZAEJ5fg2QMLFx1ODOF9DjKqDnPrf4lltIMrCunWaewTv046eXld0d5VNxScAMYSEe6qFYCcZAqRnjLiQBUmWoxsvN3SAkm0qYlpdJCFGrtO5k+fLKNEGX6uceketI0lWuQ/tIHD+naf7lV0YFOnqsjnwOb1YPgZSmABPXJ9cWCpIQpAv6gfyJCAKO+JPNRiQXim5Ni0rZWiPOXbOK9RYdE76jzHlEZ8CpI9ugt34OoF3yzUJo+FDBAlrhyLRbjqcLMNfBNqtaE1poig/kNCAtNHySYCBY6OiQ9EifA3y4/lKQYbhxkDfV3XlrEtqswylbhbdb1wHSB2/AhjkAZKOYfxJefLOVVaK+dman3etXdBae8XEZ1yyN7WdnrK44+/1CbVaPwFjGqvfgJjEKi3aCicZuvXt1a1rZjdPdXvfVPRKJzGYkTo0AScMlbzkq24N+8J0w4zDCZMrbkBJ2XmQ4Z4jrNqcwipiZ6KUtj/8tmI6YHSC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+NCoxT8P+nLdDDW0Lci2dtZSrtD/QA3jiRjhNd7Yr8Z22Ol1qiwtEvYfGlqj6JQv3rX6DFeEarCas2UlcS1WDEwK+BTrGMsgxXWVJvec3PWaeFziX8R4fMvsZT45bw0+gDIWsTVpOG5L/2whp534xvD1LM94q+HiE56Kmh1UZgRfKtZR4cn1Qs3QUz8O60IAinvMIptCTsm00p/1OhTCUHtJUNMjTgq3LxXdSiGrzOYUmyMolHxLiQRspM+mzNeWOaCDJlmMe1snPwaZue5XhJsZwocqfYX9cDaAiqDBdJR9hvm1NFw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2898a4d0-8717-4de5-148e-08dcbbb622f2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:52.6199 (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: l2fPU4weNJ7DPbh6oz3DUqHVqTYyqeaq0eBNUizFeixAjJjmYp/PEa5GQiDtPXTfS7Y8hDIkCp4ED/Fy64tt7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: uQLoRZqidYJw3hQ_Y8svEv7BhJED4Ebz X-Proofpoint-GUID: uQLoRZqidYJw3hQ_Y8svEv7BhJED4Ebz 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] Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.c | 4 +- fs/xfs/libxfs/xfs_alloc.h | 2 +- fs/xfs/libxfs/xfs_bmap.c | 95 ++++++++++++++++---------------------- fs/xfs/libxfs/xfs_ialloc.c | 10 ++-- fs/xfs/xfs_trace.h | 8 ++-- 5 files changed, 53 insertions(+), 66 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index bf08b9e9d9ac..a9ab7d71c558 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -2506,7 +2506,7 @@ xfs_alloc_space_available( reservation = xfs_ag_resv_needed(pag, args->resv); /* do we have enough contiguous free space for the allocation? */ - alloc_len = args->minlen + (args->alignment - 1) + args->minalignslop; + alloc_len = args->minlen + (args->alignment - 1) + args->alignslop; longest = xfs_alloc_longest_free_extent(pag, min_free, reservation); if (longest < alloc_len) return false; @@ -2535,7 +2535,7 @@ xfs_alloc_space_available( * allocation as we know that will definitely succeed and match the * callers alignment constraints. */ - alloc_len = args->maxlen + (args->alignment - 1) + args->minalignslop; + alloc_len = args->maxlen + (args->alignment - 1) + args->alignslop; if (longest < alloc_len) { args->maxlen = args->minlen; ASSERT(args->maxlen > 0); diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index fae170825be0..473822a5d4e9 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -46,7 +46,7 @@ typedef struct xfs_alloc_arg { xfs_extlen_t minleft; /* min blocks must be left after us */ xfs_extlen_t total; /* total blocks needed in xaction */ xfs_extlen_t alignment; /* align answer to multiple of this */ - xfs_extlen_t minalignslop; /* slop for minlen+alignment calcs */ + xfs_extlen_t alignslop; /* slop for alignment calcs */ xfs_agblock_t min_agbno; /* set an agbno range for NEAR allocs */ xfs_agblock_t max_agbno; /* ... */ xfs_extlen_t len; /* output: actual size of extent */ diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 7df74c35d9f9..25a87e1154bb 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3286,6 +3286,10 @@ xfs_bmap_select_minlen( xfs_extlen_t blen) { + /* Adjust best length for extent start alignment. */ + if (blen > args->alignment) + blen -= args->alignment; + /* * Since we used XFS_ALLOC_FLAG_TRYLOCK in _longest_free_extent(), it is * possible that there is enough contiguous free space for this request. @@ -3394,35 +3398,43 @@ xfs_bmap_alloc_account( xfs_trans_mod_dquot_byino(ap->tp, ap->ip, fld, ap->length); } -static int +/* + * Calculate the extent start alignment and the extent length adjustments that + * constrain this allocation. + * + * Extent start alignment is currently determined by stripe configuration and is + * carried in args->alignment, whilst extent length adjustment is determined by + * extent size hints and is carried by args->prod and args->mod. + * + * Low level allocation code is free to either ignore or override these values + * as required. + */ +static void xfs_bmap_compute_alignments( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; xfs_extlen_t align = 0; /* minimum allocation alignment */ - int stripe_align = 0; /* stripe alignment for allocation is determined by mount parameters */ if (mp->m_swidth && xfs_has_swalloc(mp)) - stripe_align = mp->m_swidth; + args->alignment = mp->m_swidth; else if (mp->m_dalign) - stripe_align = mp->m_dalign; + args->alignment = mp->m_dalign; if (ap->flags & XFS_BMAPI_COWFORK) align = xfs_get_cowextsz_hint(ap->ip); else if (ap->datatype & XFS_ALLOC_USERDATA) align = xfs_get_extsz_hint(ap->ip); + if (align) { if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, ap->eof, 0, ap->conv, &ap->offset, &ap->length)) ASSERT(0); ASSERT(ap->length); - } - /* apply extent size hints if obtained earlier */ - if (align) { args->prod = align; div_u64_rem(ap->offset, args->prod, &args->mod); if (args->mod) @@ -3437,7 +3449,6 @@ xfs_bmap_compute_alignments( args->mod = args->prod - args->mod; } - return stripe_align; } static void @@ -3509,7 +3520,7 @@ xfs_bmap_exact_minlen_extent_alloc( args.total = ap->total; args.alignment = 1; - args.minalignslop = 0; + args.alignslop = 0; args.minleft = ap->minleft; args.wasdel = ap->wasdel; @@ -3549,7 +3560,6 @@ xfs_bmap_btalloc_at_eof( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args, xfs_extlen_t blen, - int stripe_align, bool ag_only) { struct xfs_mount *mp = args->mp; @@ -3563,23 +3573,15 @@ xfs_bmap_btalloc_at_eof( * allocation. */ if (ap->offset) { - xfs_extlen_t nextminlen = 0; + xfs_extlen_t alignment = args->alignment; /* - * Compute the minlen+alignment for the next case. Set slop so - * that the value of minlen+alignment+slop doesn't go up between - * the calls. + * Compute the alignment slop for the fallback path so we ensure + * we account for the potential alignment space required by the + * fallback paths before we modify the AGF and AGFL here. */ args->alignment = 1; - if (blen > stripe_align && blen <= args->maxlen) - nextminlen = blen - stripe_align; - else - nextminlen = args->minlen; - if (nextminlen + stripe_align > args->minlen + 1) - args->minalignslop = nextminlen + stripe_align - - args->minlen - 1; - else - args->minalignslop = 0; + args->alignslop = alignment - args->alignment; if (!caller_pag) args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); @@ -3597,19 +3599,8 @@ xfs_bmap_btalloc_at_eof( * Exact allocation failed. Reset to try an aligned allocation * according to the original allocation specification. */ - args->alignment = stripe_align; - args->minlen = nextminlen; - args->minalignslop = 0; - } else { - /* - * Adjust minlen to try and preserve alignment if we - * can't guarantee an aligned maxlen extent. - */ - args->alignment = stripe_align; - if (blen > args->alignment && - blen <= args->maxlen + args->alignment) - args->minlen = blen - args->alignment; - args->minalignslop = 0; + args->alignment = alignment; + args->alignslop = 0; } if (ag_only) { @@ -3627,9 +3618,8 @@ xfs_bmap_btalloc_at_eof( return 0; /* - * Allocation failed, so turn return the allocation args to their - * original non-aligned state so the caller can proceed on allocation - * failure as if this function was never called. + * Aligned allocation failed, so all fallback paths from here drop the + * start alignment requirement as we know it will not succeed. */ args->alignment = 1; return 0; @@ -3637,7 +3627,9 @@ xfs_bmap_btalloc_at_eof( /* * We have failed multiple allocation attempts so now are in a low space - * allocation situation. Try a locality first full filesystem minimum length + * allocation situation. We give up on any attempt at aligned allocation here. + * + * Try a locality first full filesystem minimum length * allocation whilst still maintaining necessary total block reservation * requirements. * @@ -3654,6 +3646,7 @@ xfs_bmap_btalloc_low_space( { int error; + args->alignment = 1; if (args->minlen > ap->minlen) { args->minlen = ap->minlen; error = xfs_alloc_vextent_start_ag(args, ap->blkno); @@ -3673,13 +3666,11 @@ xfs_bmap_btalloc_low_space( static int xfs_bmap_btalloc_filestreams( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - int stripe_align) + struct xfs_alloc_arg *args) { xfs_extlen_t blen = 0; int error = 0; - error = xfs_filestream_select_ag(ap, args, &blen); if (error) return error; @@ -3698,8 +3689,7 @@ xfs_bmap_btalloc_filestreams( args->minlen = xfs_bmap_select_minlen(ap, args, blen); if (ap->aeof) - error = xfs_bmap_btalloc_at_eof(ap, args, blen, stripe_align, - true); + error = xfs_bmap_btalloc_at_eof(ap, args, blen, true); if (!error && args->fsbno == NULLFSBLOCK) error = xfs_alloc_vextent_near_bno(args, ap->blkno); @@ -3723,8 +3713,7 @@ xfs_bmap_btalloc_filestreams( static int xfs_bmap_btalloc_best_length( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - int stripe_align) + struct xfs_alloc_arg *args) { xfs_extlen_t blen = 0; int error; @@ -3748,8 +3737,7 @@ xfs_bmap_btalloc_best_length( * trying. */ if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { - error = xfs_bmap_btalloc_at_eof(ap, args, blen, stripe_align, - false); + error = xfs_bmap_btalloc_at_eof(ap, args, blen, false); if (error || args->fsbno != NULLFSBLOCK) return error; } @@ -3776,27 +3764,26 @@ xfs_bmap_btalloc( .resv = XFS_AG_RESV_NONE, .datatype = ap->datatype, .alignment = 1, - .minalignslop = 0, + .alignslop = 0, }; xfs_fileoff_t orig_offset; xfs_extlen_t orig_length; int error; - int stripe_align; ASSERT(ap->length); orig_offset = ap->offset; orig_length = ap->length; - stripe_align = xfs_bmap_compute_alignments(ap, &args); + xfs_bmap_compute_alignments(ap, &args); /* Trim the allocation back to the maximum an AG can fit. */ args.maxlen = min(ap->length, mp->m_ag_max_usable); if ((ap->datatype & XFS_ALLOC_USERDATA) && xfs_inode_is_filestream(ap->ip)) - error = xfs_bmap_btalloc_filestreams(ap, &args, stripe_align); + error = xfs_bmap_btalloc_filestreams(ap, &args); else - error = xfs_bmap_btalloc_best_length(ap, &args, stripe_align); + error = xfs_bmap_btalloc_best_length(ap, &args); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 0af5b7a33d05..2fa29d2f004e 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -758,12 +758,12 @@ xfs_ialloc_ag_alloc( * * For an exact allocation, alignment must be 1, * however we need to take cluster alignment into account when - * fixing up the freelist. Use the minalignslop field to - * indicate that extra blocks might be required for alignment, - * but not to use them in the actual exact allocation. + * fixing up the freelist. Use the alignslop field to indicate + * that extra blocks might be required for alignment, but not + * to use them in the actual exact allocation. */ args.alignment = 1; - args.minalignslop = igeo->cluster_align - 1; + args.alignslop = igeo->cluster_align - 1; /* Allow space for the inode btree to split. */ args.minleft = igeo->inobt_maxlevels; @@ -783,7 +783,7 @@ xfs_ialloc_ag_alloc( * on, so reset minalignslop to ensure it is not included in * subsequent requests. */ - args.minalignslop = 0; + args.alignslop = 0; } if (unlikely(args.fsbno == NULLFSBLOCK)) { diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 180ce697305a..52a517a2c8e1 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1811,7 +1811,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __field(xfs_extlen_t, minleft) __field(xfs_extlen_t, total) __field(xfs_extlen_t, alignment) - __field(xfs_extlen_t, minalignslop) + __field(xfs_extlen_t, alignslop) __field(xfs_extlen_t, len) __field(char, wasdel) __field(char, wasfromfl) @@ -1830,7 +1830,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->minleft = args->minleft; __entry->total = args->total; __entry->alignment = args->alignment; - __entry->minalignslop = args->minalignslop; + __entry->alignslop = args->alignslop; __entry->len = args->len; __entry->wasdel = args->wasdel; __entry->wasfromfl = args->wasfromfl; @@ -1839,7 +1839,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->highest_agno = args->tp->t_highest_agno; ), TP_printk("dev %d:%d agno 0x%x agbno 0x%x minlen %u maxlen %u mod %u " - "prod %u minleft %u total %u alignment %u minalignslop %u " + "prod %u minleft %u total %u alignment %u alignslop %u " "len %u wasdel %d wasfromfl %d resv %d " "datatype 0x%x highest_agno 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -1852,7 +1852,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class, __entry->minleft, __entry->total, __entry->alignment, - __entry->minalignslop, + __entry->alignslop, __entry->len, __entry->wasdel, __entry->wasfromfl, From patchwork Tue Aug 13 16:36: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: 13762270 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 E82741A38E8; Tue, 13 Aug 2024 16:37:08 +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=1723567031; cv=fail; b=KS+4lX+OhHYH2hSGQI0DY6lOLacKbuZnEuPdZshG33JDR6uitAdbTRY36crZveHBsftsDT0/HulK9GEtqdGs8aCjEjirVzxyaM3iwE8Pr69qiWz22vYUjhVQussJLpQ5MjWiD4PxXCiR/snUP+8TrHsmggJ1EoVqWwSq1v65CG4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567031; c=relaxed/simple; bh=7i1LDL3WYDWP3NMJkoXNt2iBX7UCtqjbXnxeIXFwoEU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=U+hzbAONmq0Fo4+ts4b7RThNSQ9dbCCgLWSTbxS5BjOxeT+c8UpthPV2dKkcCfrOT+4gbLf/86PH8oIK7iTHBEU71ydgf8LvLqmz+6A/To49tMu54HhsULlErdxqsl/F/aqZZ/377L019aXK1I5YZoPJvU9jWI4Cq9gUUtTlU9E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Q5NuGMJx; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=lDk7bSEk; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Q5NuGMJx"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="lDk7bSEk" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTwW007375; Tue, 13 Aug 2024 16:36:58 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=vFeIYph4qKUhP+iOm/lVH4SholLkFyhjHY9Wba5Ldkg=; b= Q5NuGMJxcsAfGwG27z7a9wmFy37uzPM404+RAjZy2QxLFRFxgGFUBdTwAnYcGtNI RQHlqF5sSLRFHDycIAnPgZOVtljQ0uKmAvqcQMxuDXlfeiEyCAqEvJb2R0OBNzNm DNtphhYbCODVl1eLbI93JPg+Ra+as+bAgVGbl+QJ34aeFPzh3NcZg9slQBmNDgHW al62pUmJxoMn1QVmkhInpmxPSkYYXOYbS8OIKBXugdHaT2kgXb4FwLJzEUKuxj2E 5cHZLsrid8/JnFBJvBfjoTlqFYmtnr9mczElSb4qK2DfQc2MzB+0Z8h6equBlqtp lXGVfUe5ilyAhCt1+sORNQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxt0xffc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DG94Wl017631; Tue, 13 Aug 2024 16:36:57 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn9pdey-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:36:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SiCMZ/xh3aL9goHqeh5DFmg39bXjJvk1IXiKA+3WEyvtXxuTYhcgf2tGf5UrmHrlGK8eeWvIBBhwpt4nHrSDs5PpTRlz5ONpSiPJql+hel3YxlCdCa99ma/5oJOcaGMfqVqWNspjkvhE7TYSuJZcl6Lrwbvgxu74LjUX8CrrdIMAOC0E8R1ml/vtetAtE0vbYiAKUBnQvzOTMTKyjdBo4ClMfBQNFAH8Nfk0dDC++e4PL7GsT0KcTtAbxm0bzAfY9jNPXGWPtS6n8iQ7p1L8QHO9ZN+1ieYb+bIfsRLSBgtL93Sv0PLBHLGYRuJJgy/D6WSWEJJRcF4z8P5UPl/15g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vFeIYph4qKUhP+iOm/lVH4SholLkFyhjHY9Wba5Ldkg=; b=dgKk0ic+GNE6TVK42kLyyCjyDTldQIo00fhHAUtqUp3SybJmLKf0Gvo7wBawXusvj/7SxwNMUqkIB7jlSPeIeH8arJfC7BAtC2M36hkRETIvTHvvWi0MSUHwkPrXqqiybueWdDM6v8B2r8Hs+WE0byEEol6p00tJbruWM9pfCzq84evN3Z+LuxvvqD4k65q0UE+wBFkS6YngA1k84X5t1uBcYG7ECBuY11U/G7lvSASXHn1POA2owUBwxJUzW3JBsUGjGc/AMeCIm21gGqaS1ykYtRBJMnYCynxg6LKtDlyhcQ6DHlQqFx2tn7Urg+Xx2oYmDmWTXcTmDlBJxapIJQ== 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=vFeIYph4qKUhP+iOm/lVH4SholLkFyhjHY9Wba5Ldkg=; b=lDk7bSEkvaCsyc9VkQfc4DwcZ9K96f1vehEHY9JJ9QQgtOpk3lfx7S+fPR2hBRyOSYBXCyvaY2EPLsje8tmObo1vjyuNvNLasWDydteSd9Yd3K/E7LnqXwEt08vY91ihEqMPestooaymziy1xg47PvtsGYKqiKaBT02sPW/Hv/I= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:36:54 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:36:54 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 04/14] xfs: make EOF allocation simpler Date: Tue, 13 Aug 2024 16:36:28 +0000 Message-Id: <20240813163638.3751939-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR03CA0016.namprd03.prod.outlook.com (2603:10b6:a02:a8::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 2098a8dc-cc31-40b8-b45a-08dcbbb6242e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: W6U4TIxZi3zTkTM0PQoGPwzm/vbyQ6MYUCXmc6ZT1KkpzZMrk/KPieL+p28xCwgXqtQMOCcr6bDMnUuV98ddOAUNROSBM9B1eloU2uep5tB9cMKRM91Bz08VP9o9hTLJ88YSswet7Gn9xm9p9lyR2NOmQ40ATcXz20sOH+AxBwpQH2eSlsRYb1MuWV+TmH/Qk3laAS68nQZPYJUWAQKdy87DGcSXic2VYhHXQ7wQ6pzVd/LqVX685s8mOzxQAZj/XPpeEasBQ2kmzGPAyccEYqn4eOxpdrfUwlsEm9XJ3w3taC/UB5Bs1qYTmDkCkfoCY8QfgwRxh86tS2kXwvuYuGgZXWk9RtG/5ard+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R10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H86b4ENeaKxM4gCeUjhKGfLF2hVz1Uc34MJVQJUYfoDfHs8HsCJYTuJisRdEQUUQyQluSBmIkqTRARs4xBCiFP5rudQuMjlSc6SXSdDCHEr8dYhwiG92T9bcJe6XRT0CVqrAHCVQ3weeba/V70yyVodkKWDlMydY1+n7gQhrnAtqpnKyaw8Wo+9spMiMj2I/5kMPAjL1RxVAwoZJ6njJvvLZp7hsXUpfCc+ZensxD97tcNpy5Ehh0uuPjJWe0IHpX+M+BBunn9OR2UTiPS9Jv/a7LGAzx/H/LqjMrDk8K3lA78LeZceh4FyRqNJ1FnoCMnxCpSYvm4Kf1w4cH7tTucSvgnf5Clc9HDxIT0qaAFSLRGy6mKQgyIAvh1pR40NTD4uRX/XppMQN2/ATpJOZBki57eEAJaO/pHrTE+lqFmiv10Chz+8+hVT/zjXIXNzN0dYyju9BjgcQKElBk+IY7cKxk58P9DIntqkz20nWRTTaWzQkVQK6GBUkybe0nsziFdzRFwJxRGj/ru7kpnDuA45Y+z5X9WI9Ws+oCZJCfdRF/GFJQ1YF5qDdUCCc3Pzzmb7JobUSaEPGrrB/qdh4VD6MIhm3EKzyGY62AdK8VqAKpyYvappx2srBzpBfjn2aMcBxQiq8+SflOwiC1LVXlnFQupNuIO+9ivgcfT9NNLhmTKB6SMxpIewTV43MZNoerOn3UK8wIca5pbqXHOKbzE9pvicCC3JTQJGpqwwXtw0hjHmOXGKrk+hi8+xRcSrlq2kkq8evkuSnWWYDygWhTJbyotmnJiFiTmQWFh0z+d9v+twXO4yyduutZK4f4OsDRVot4jZO10T1kDyCYSZKF09968w2CHk4+Y4909AN2VEs0ViLPQLD2+knwhzuLF3IxUClgPFyLuamtllztl+IleZ+8Ic9F8IHV1wCu1WAICoZEwMw3/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0z3DfZR64cFg6afkRGGxF1WC0iAt6FfMEjto+JZE1ZiDZPwkIiKNzpkjY4HxN+k37BeldnLmXTy9WamkZeo5KUhrNJDCJ1EdcybtgefBP6gkA0it74H0nedIoZM3VXyLvVWq4wOForgCUFCAoIi1iXuVpUdV82aYdJ8Vwp/Ytk4FxHGxQZH5YIl3M8RUkxKUULafmN0joyHKomlSzCuW1TGStR86axM8hC6BDtgoQJaW6MBjwX9KcllThs17On+Ux/loR9OxyeWUzjFbnFFFIQDjMqfmA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2098a8dc-cc31-40b8-b45a-08dcbbb6242e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:54.7098 (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: kY4XHqsWZ8Z0d/spyKFv9IIS8IbeoLPPrwAJbx7ULbo+bhJwdBKab5umUdxQ1EBudGYyFeVNs4SoBt91pxwloQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: uKkXokAwG8QeXvbnL0Y0zFig8fhvpBj8 X-Proofpoint-ORIG-GUID: uKkXokAwG8QeXvbnL0Y0zFig8fhvpBj8 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 Reviewed-by: "Darrick J. Wong" 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 25a87e1154bb..42a75d257b35 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3310,12 +3310,12 @@ xfs_bmap_select_minlen( static int xfs_bmap_btalloc_select_lengths( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - xfs_extlen_t *blen) + struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; struct xfs_perag *pag; xfs_agnumber_t agno, startag; + xfs_extlen_t blen = 0; int error = 0; if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { @@ -3329,19 +3329,18 @@ xfs_bmap_btalloc_select_lengths( if (startag == NULLAGNUMBER) startag = 0; - *blen = 0; for_each_perag_wrap(mp, startag, agno, pag) { - error = xfs_bmap_longest_free_extent(pag, args->tp, blen); + error = xfs_bmap_longest_free_extent(pag, args->tp, &blen); if (error && error != -EAGAIN) break; error = 0; - if (*blen >= args->maxlen) + if (blen >= args->maxlen) break; } if (pag) xfs_perag_rele(pag); - args->minlen = xfs_bmap_select_minlen(ap, args, *blen); + args->minlen = xfs_bmap_select_minlen(ap, args, blen); return error; } @@ -3551,78 +3550,40 @@ xfs_bmap_exact_minlen_extent_alloc( * If we are not low on available data blocks and we are allocating at * EOF, optimise allocation for contiguous file extension and/or stripe * alignment of the new extent. - * - * NOTE: ap->aeof is only set if the allocation length is >= the - * stripe unit and the allocation offset is at the end of file. */ static int xfs_bmap_btalloc_at_eof( struct xfs_bmalloca *ap, - struct xfs_alloc_arg *args, - xfs_extlen_t blen, - bool ag_only) + struct xfs_alloc_arg *args) { struct xfs_mount *mp = args->mp; struct xfs_perag *caller_pag = args->pag; + xfs_extlen_t alignment = args->alignment; int error; + ASSERT(ap->aeof && ap->offset); + ASSERT(args->alignment >= 1); + /* - * If there are already extents in the file, try an exact EOF block - * allocation to extend the file as a contiguous extent. If that fails, - * or it's the first allocation in a file, just try for a stripe aligned - * allocation. + * Compute the alignment slop for the fallback path so we ensure + * we account for the potential alignemnt space required by the + * fallback paths before we modify the AGF and AGFL here. */ - if (ap->offset) { - xfs_extlen_t alignment = args->alignment; - - /* - * Compute the alignment slop for the fallback path so we ensure - * we account for the potential alignment space required by the - * fallback paths before we modify the AGF and AGFL here. - */ - args->alignment = 1; - args->alignslop = alignment - args->alignment; - - if (!caller_pag) - args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); - error = xfs_alloc_vextent_exact_bno(args, ap->blkno); - if (!caller_pag) { - xfs_perag_put(args->pag); - args->pag = NULL; - } - if (error) - return error; - - if (args->fsbno != NULLFSBLOCK) - return 0; - /* - * Exact allocation failed. Reset to try an aligned allocation - * according to the original allocation specification. - */ - args->alignment = alignment; - args->alignslop = 0; - } + args->alignment = 1; + args->alignslop = alignment - args->alignment; - if (ag_only) { - error = xfs_alloc_vextent_near_bno(args, ap->blkno); - } else { + if (!caller_pag) + args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno)); + error = xfs_alloc_vextent_exact_bno(args, ap->blkno); + if (!caller_pag) { + xfs_perag_put(args->pag); args->pag = NULL; - error = xfs_alloc_vextent_start_ag(args, ap->blkno); - ASSERT(args->pag == NULL); - args->pag = caller_pag; } - if (error) - return error; - if (args->fsbno != NULLFSBLOCK) - return 0; - - /* - * Aligned allocation failed, so all fallback paths from here drop the - * start alignment requirement as we know it will not succeed. - */ - args->alignment = 1; - return 0; + /* Reset alignment to original specifications. */ + args->alignment = alignment; + args->alignslop = 0; + return error; } /* @@ -3688,12 +3649,19 @@ xfs_bmap_btalloc_filestreams( } args->minlen = xfs_bmap_select_minlen(ap, args, blen); - if (ap->aeof) - error = xfs_bmap_btalloc_at_eof(ap, args, blen, true); + if (ap->aeof && ap->offset) + error = xfs_bmap_btalloc_at_eof(ap, args); + /* This may be an aligned allocation attempt. */ if (!error && args->fsbno == NULLFSBLOCK) error = xfs_alloc_vextent_near_bno(args, ap->blkno); + /* Attempt non-aligned allocation if we haven't already. */ + if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + args->alignment = 1; + error = xfs_alloc_vextent_near_bno(args, ap->blkno); + } + out_low_space: /* * We are now done with the perag reference for the filestreams @@ -3715,7 +3683,6 @@ xfs_bmap_btalloc_best_length( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args) { - xfs_extlen_t blen = 0; int error; ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); @@ -3726,23 +3693,33 @@ xfs_bmap_btalloc_best_length( * the request. If one isn't found, then adjust the minimum allocation * size to the largest space found. */ - error = xfs_bmap_btalloc_select_lengths(ap, args, &blen); + error = xfs_bmap_btalloc_select_lengths(ap, args); if (error) return error; /* - * Don't attempt optimal EOF allocation if previous allocations barely - * succeeded due to being near ENOSPC. It is highly unlikely we'll get - * optimal or even aligned allocations in this case, so don't waste time - * trying. + * If we are in low space mode, then optimal allocation will fail so + * prepare for minimal allocation and run the low space algorithm + * immediately. */ - if (ap->aeof && !(ap->tp->t_flags & XFS_TRANS_LOWMODE)) { - error = xfs_bmap_btalloc_at_eof(ap, args, blen, false); - if (error || args->fsbno != NULLFSBLOCK) - return error; + if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { + ASSERT(args->fsbno == NULLFSBLOCK); + return xfs_bmap_btalloc_low_space(ap, args); + } + + if (ap->aeof && ap->offset) + error = xfs_bmap_btalloc_at_eof(ap, args); + + /* This may be an aligned allocation attempt. */ + if (!error && args->fsbno == NULLFSBLOCK) + error = xfs_alloc_vextent_start_ag(args, ap->blkno); + + /* Attempt non-aligned allocation if we haven't already. */ + if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + args->alignment = 1; + error = xfs_alloc_vextent_start_ag(args, ap->blkno); } - error = xfs_alloc_vextent_start_ag(args, ap->blkno); if (error || args->fsbno != NULLFSBLOCK) return error; diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 2fa29d2f004e..c5d220d51757 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -780,7 +780,7 @@ xfs_ialloc_ag_alloc( * the exact agbno requirement and increase the alignment * instead. It is critical that the total size of the request * (len + alignment + slop) does not increase from this point - * on, so reset minalignslop to ensure it is not included in + * on, so reset alignslop to ensure it is not included in * subsequent requests. */ args.alignslop = 0; From patchwork Tue Aug 13 16:36: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: 13762272 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 1A3891A4F02; Tue, 13 Aug 2024 16:37:14 +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=1723567036; cv=fail; b=kurXv9GEfzXq8DXBSTMigIFJkSMse23ynKyVJu3iEuDuOJCSmsUWKQF8HHepFrlaJMrzkd7GIQJ5ueEDViozhh5pQ3PgZ4zWb8drIHD4GUuOz9mntJJl0rTn2OCxQOwoJ6qwS5nPRTEe75hGLE2eXmDeCpOKMBFQrMQnjpYzTWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567036; c=relaxed/simple; bh=deJFZJmQeTeQtt5bIB7R/BwktTAKm9MF1pqj4PFteDA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jAwvVgYu7V5WFG9K97SEG1CuyfXH1m66HmIlZl2FXtAW9KVhoe47uObXYA2BzuxY5tCVvJ3BLW8mhBqCFXirPLRAwa5WWV00MhZkEWDSzU57oQPbdqb968dpXau3cGlKnAmDdb33i15W1i30CToLUbvGSPnxWNbGHHtjdvddWVM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Z9+9X0d3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=wl8l/jWG; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Z9+9X0d3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="wl8l/jWG" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTwA009743; Tue, 13 Aug 2024 16:37: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=HZ2MJ034kz/+yCHz77EDP8UVitUjCKn41Y0vvkTtB2s=; b= Z9+9X0d3CsMyw5A9sxHVtLPQfBOELSeIk7DZmOZcm4ZU1KGT7dQFRddyXWTSu8ss 9tw85W61r/bisIUziyP9koh8tYc1HTjKjtEetKduDMVjB4pz8A+TWP2C3w6PzcR9 fpw6JJ43h3Fm+JkNOZSWUPUYoeHxCHNSJSP2UASMdsvLrLHt1pjcRDoNHisYTA96 /urzz4t7rYAfn1E5Jnux2Y3WSfQ87nnnaYRrCP0EORE+HJ647UibMbnpylHmJMq0 0l0I7VRWQUUfqFbX+zcx+vg3gqxNtIteIamiFHX+TzpH2HncnggrJMWFH4kFQVOA 1vjvRP5VgvXaLmrVg5P6HQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy02xg0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGBTrc010640; Tue, 13 Aug 2024 16:37:04 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8s053-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YHQgFHGH4rpLlQwNyDPCXiJne9WtfhKtQ9eK2t59k5o7VaxqbaO7pqYQ3jOkbfkj0YC1leK0Wt0Q5mZc3hRiLEXih4RZ+X2xlHmJLMw3GKM2V1YaGTmr61cFBzyuubbB1Bc3lullRlnxSOU3MUHlnXzoqzBVqnNKb/EyvfV6lAwBTS4H719Hkchr9a7mXjyyBEEtwpJSMtnoe+80lIYL3D/eYBAJH83xOOiFet+m53UHBlnefE6+BcWYghAgdEr/DoVtez1vwaNK4ld1gScXExFqxY6sjOS9mHuKzTYZoMMFdnoUMqE02z+lEEBJ8cj5/kCbeaaEXrGM3rQLl3+MHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HZ2MJ034kz/+yCHz77EDP8UVitUjCKn41Y0vvkTtB2s=; b=DJiqLFK/esoQuTwZaY/xd6sad8Tm6986OgkiH6rR8+po8cOicC2uYTzrwuh9kT+wUFQgCqPqCUboag3w72p6b3ufQvEbHwilDx2zvJLel4nHL9XSUExwqSqNEwWIRVa9CO3lUBZx4WyiG+j13bNyRjTkAdNKoMsfxmnngFI7Yvl6yRKkeu70+H7Mulo+sxwnumF/JBQ/owypXBPge0qv/nwfzRxTCgcjLinap/jtJ7gjIRcbXdjt4Ivv2+nERq4Nu0SL9w6wvNFuqr8TNLKVRooqQaAC59Wetwq+pSZg2UTK1ERkTIZIQ9IzP5r1fZYJgV5O5FxjX57VacBJ60UeDg== 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=HZ2MJ034kz/+yCHz77EDP8UVitUjCKn41Y0vvkTtB2s=; b=wl8l/jWGU0BUvssMZSRgisk3BPbpSF8OgUYLKg+qt+FO+mU/hpOjWJmmLfFXNo0LuVTiAIAd83l32QHRb/NXXKi3gPb8QPYOF3dPWGi5N+LEnKGWD4bz/f8y8qvFU/Jl/QZA/jRyE4svUBhKu3j4yQe2mnHFt7ZLiXD3haUB9b8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:36:57 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:36:57 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 05/14] xfs: introduce forced allocation alignment Date: Tue, 13 Aug 2024 16:36:29 +0000 Message-Id: <20240813163638.3751939-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0193.namprd05.prod.outlook.com (2603:10b6:a03:330::18) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 285dfb27-b2e2-4dd6-ed12-08dcbbb625a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: YLNSP6T2A5KHw8CosCBxFDOBA3MX1co9tfl0/5mgPq6JTEIxQ6fkmLv8DzPf66nX1Nx5EN/e3q5VmknCDnTQBXncxThQJYCsZpJyySpZfxLpT0fRovQT7ZSkMfjRKhVOXoxzwD5n9MnrW2sWwcJdiVFBLaQw9eWynQlUATcIdvkz1eT+UUx6nMOD9cQLwiarDqLznRWQoEwAv5gJEUu0CSsqj3cMfLR45aU1uR5Ofx5izMTFBi04LRLBwlzkI+vonw9Kyrk/852MAlf82qIpPDNOHwVSr2ruqEruPq8YkNMSn5q5uMF5icPTIE9S/1oRnf1ODkL4e/qk+zX8+zs8G+ungB1/ZzG7cGON9dzedPM97jmKQWDlgeSWB8QDGOFwpQoP4m4Q/39wY/1aeNR3Eavw53c6aO8yv/0+PwSySvwWZfEs5PpT3q7vEHNAADQa4VOjNHBqkCjKDQk8QiFPdm1yWj7g5bepYSr83suTD5UAJbyYeglQp5JWFRXL6GF4ZCKlwc9sgV4YEgkSmrlqTCUB0WEYXcHCz2n6TfNVCxSB+PwEtRKF4LRupQH+mnVuXF73EhpBOsHy35zIOchZNTatrDMQAmd1gV1Rp90xeiOEKxIwAAZ/jBbF+fiwJhvJzvhIX4UWbPio9gX4zG3NMpe45JIihnd1UAf0isx4AIBfaglRPZGMxBzrFpFmu8t3eUzq1erECzQHGhMJfLgHYTf0jWd7vFOHSshs9DDKCn8DQvpW0Tft6mjhjbCFqxvqXkrhuqNb7fOHAzrdVSuaYgLV2Hss/fuvW0vJqkQjzCOnnA66pytii2AVetG+r6tjoFAAazs+WC7gn1c4IjB349BRZxVw2e2wiU+QzmthaHYYyUHT8GBGNS1Los1u/WH1I+deBmKwerGkXt8xrFnwvke3zIzD6ZTbJO8bM8mxrmrPOTpu5D0iW17tzbsrEI1C7brocL2R2S3QqNI+L4AiCNvUDan6xCGoXFliER06noIn7APGfx2QDAVJzZ9M0J1a/7FI7uvsceSt1kQNcgeqAI+WHGIMRJWPop8ugM0wNL1FR45hg4IxhEScV93eqYznaq3JzCsbgi1rWXw/H99WBdHCz1cdd0WYlIEilqNAZAsd8A7tOuce3gOkS15ZG4Hd9kKa+l8LGD6O9oV4kqex4OIX+a5JStEr0mBVLtRR2FQM1Fe+YGJhuLygJFKBnYE9aBlrqW+k9qdupCiU001K194D9EhZW+9N7Xv6AEhWo+sCuup1xdn0CAIambphWl/SW2HjPIBCDRBs7BLtGEFslD6sfouAbLS9yoQld5y+U4Rl59v4EsfDuYY8IbN5DXi8ob1zsGrN/PXV8AEvd5idXg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RJIaXLh3tRaJjftoZaMOc4EeGudtckyxCSVym9CcquTC58Q7bzDveOc6FUL8bu409r2USwzqbu8HdbCgAZvDHFyxc6AvU3dmkHJQwf3CQXogTIFpt8mwfQe8RMZ2tcS8bycJAfcfvaBqB2OrJgYcJwffBT511U1tkEI2gHosQUs0fo/hKW7z13Bn7/m3PRDoKipsmHaH1JG6/ybcjLP8dAFvzMYsglVgrjxnaLA7tf9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+6PmGq9eiKGCA2HrwIGqm4tSTgi2dczlvfDgOUX8Jy9Hrs9MjgQ2gvu1Gmy8QFH/KeSxH/3Dggh91gfn7R3Xfg9aOYRO/SFFmQP5iyE4Kz/V/y1C8B3qXQL9OqYJBJtv5ctnt8XkMSw0iFDo77V8866ys5uNNWqEdOVEj/+33dYGovL3VljYN91kX568cD0kjD+QF/1DfJzHitKFNNTz8/fomnTiHIRPuQVuJVun9dZCv0F2NxHBHetxZAZFCbGTjQkv8cuGhLbmWcJ9s/noSB/+WaUSZU8J1iw93VFHHz3w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nQ4qvxgpr2z+mBcJtGejNb90sbmsVhqfTGrr6QcLc9hhHlicNga3mIGBQkxk1bH8kuW8EX3C1HnCMdDHLYjHwNUah4vf7P1HDdzOdyLutMeZjatf4lsuvCzpJBDf5MGlwB19WVwy4coLe+u/z4gs+P/wM3DOhyTn+qxNSgy5Ay9EmHmRtjizDtbJgArEhR/HTpcrfhKiYHILPmbohDiRQqwiUj59TngVZgWxxA0BfwWDWtNuS6CM5S1Is2bBrIgSOLlIeURTv4DUjfwpvqGk3SYxhRwzthRnZVp2xSVZL9mt0iqStGJLcIyk2vFCWxaevN0IKcaLzs83MyXFP+gsSu532pQFf7oPOveZ1919zE1T7N6nb7/bRcIibyOhEnBjIpXkmxJZ1UI0ngP+HcTI/lS5roKgpp5Nssq1IJfz7o3XnuQvOmIdjnevE0ac1v0rqhm0QuevEEJ0Zh9k6RMr/xyx8N/Tht3/O6aBqdyC0dWzCte1lYdTEopxpvhTZNjJekNcoDI5+YBk6MWsOohC7alwsdgMwa+4WLCyGArapJ34dBLHPe3aeRHv+CbT0bWQRv95IrAin+1QqwcoKJUS1hTx/hbaQVWg1PUHtjahy+4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 285dfb27-b2e2-4dd6-ed12-08dcbbb625a9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:57.1434 (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: PkQxW+AdkWzN7MfGmFqe7cnARjj0Dp54xqmgUde5dnMUuN+CrHSmJamzSOJh0g97kGf03l9sLbnPN9n/xd80sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: TYohKN7o0sRyVUHEiMbW8-aH6slHKEQh X-Proofpoint-ORIG-GUID: TYohKN7o0sRyVUHEiMbW8-aH6slHKEQh 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. [jpg: Set XFS_ALLOC_FORCEALIGN in xfs_bmap_alloc_userdata(), rather than xfs_bmap_compute_alignments()] Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_alloc.h | 1 + fs/xfs/libxfs/xfs_bmap.c | 28 +++++++++++++++++++++++----- fs/xfs/xfs_inode.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index 473822a5d4e9..17b062e8b925 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -66,6 +66,7 @@ typedef struct xfs_alloc_arg { #define XFS_ALLOC_USERDATA (1 << 0)/* allocation is for user data*/ #define XFS_ALLOC_INITIAL_USER_DATA (1 << 1)/* special case start of file */ #define XFS_ALLOC_NOBUSY (1 << 2)/* Busy extents not allowed */ +#define XFS_ALLOC_FORCEALIGN (1 << 3)/* forced extent alignment */ /* freespace limit calculations */ unsigned int xfs_alloc_set_aside(struct xfs_mount *mp); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 42a75d257b35..602a5a50bcca 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3401,9 +3401,10 @@ xfs_bmap_alloc_account( * Calculate the extent start alignment and the extent length adjustments that * constrain this allocation. * - * Extent start alignment is currently determined by stripe configuration and is - * carried in args->alignment, whilst extent length adjustment is determined by - * extent size hints and is carried by args->prod and args->mod. + * Extent start alignment is currently determined by forced inode alignment or + * stripe configuration and is carried in args->alignment, whilst extent length + * adjustment is determined by extent size hints and is carried by args->prod + * and args->mod. * * Low level allocation code is free to either ignore or override these values * as required. @@ -3416,8 +3417,13 @@ xfs_bmap_compute_alignments( struct xfs_mount *mp = args->mp; xfs_extlen_t align = 0; /* minimum allocation alignment */ - /* stripe alignment for allocation is determined by mount parameters */ - if (mp->m_swidth && xfs_has_swalloc(mp)) + /* + * Forced inode alignment takes preference over stripe alignment. + * Stripe alignment for allocation is determined by mount parameters. + */ + if (xfs_inode_has_forcealign(ap->ip)) + args->alignment = xfs_get_extsz_hint(ap->ip); + else if (mp->m_swidth && xfs_has_swalloc(mp)) args->alignment = mp->m_swidth; else if (mp->m_dalign) args->alignment = mp->m_dalign; @@ -3607,6 +3613,11 @@ xfs_bmap_btalloc_low_space( { int error; + if (args->alignment > 1 && (args->datatype & XFS_ALLOC_FORCEALIGN)) { + args->fsbno = NULLFSBLOCK; + return 0; + } + args->alignment = 1; if (args->minlen > ap->minlen) { args->minlen = ap->minlen; @@ -3658,6 +3669,8 @@ xfs_bmap_btalloc_filestreams( /* Attempt non-aligned allocation if we haven't already. */ if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return error; args->alignment = 1; error = xfs_alloc_vextent_near_bno(args, ap->blkno); } @@ -3716,6 +3729,8 @@ xfs_bmap_btalloc_best_length( /* Attempt non-aligned allocation if we haven't already. */ if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return error; args->alignment = 1; error = xfs_alloc_vextent_start_ag(args, ap->blkno); } @@ -4151,6 +4166,9 @@ xfs_bmap_alloc_userdata( if (bma->offset == 0) bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA; + if (xfs_inode_has_forcealign(bma->ip)) + bma->datatype |= XFS_ALLOC_FORCEALIGN; + if (mp->m_dalign && bma->length >= mp->m_dalign) { error = xfs_bmap_isaeof(bma, whichfork); if (error) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 51defdebef30..bf0f4f8b9e64 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -310,6 +310,11 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_NREXT64; } +static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) +{ + return false; +} + /* * Decide if this file is a realtime file whose data allocation unit is larger * than a single filesystem block. From patchwork Tue Aug 13 16:36: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: 13762274 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 2DDA11A256C; Tue, 13 Aug 2024 16:37:17 +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=1723567040; cv=fail; b=SgtAbc9pmCUhChbu2OzmCb6dQxqgL2QXjAWH4kgw50YZlZGXNy+dh6C62qd0D0NQ3kaoInu/Z3ER0HRvm/QMG/6RvQVkdzPmDrQolO3aVwsTrBZScCC9NEVC8WHsr0iLLsNqc8KEiw7DDNWcPuT+70W8ASqpyYcTQxrPqX6pLUU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567040; c=relaxed/simple; bh=9rAvIZkBqEMJF/OGzmC8x+TbIitZExhngqTTkGjs7wQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RxDEqvAoVeBXeK1iPRjBehYb8uz2hKD2tudrSjYLLnOUVy+qInw4bnieE4gs0Yt/FVusS9ybVKE0LxQA//NTQsV41uwt7/Su/+1nexN6kgwfQR4QpLWdgmBCUb7ih13oMEutAhojZiE3FL441EgKQMaXnQ1pnG1L3fvNmjP/pPg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=jPh26O6V; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=M+I3Iygo; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jPh26O6V"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="M+I3Iygo" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBUmB002871; Tue, 13 Aug 2024 16:37: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=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b= jPh26O6V4hMAa7F5jTvsD62QX26hOsuG0iiFNBzImcZSL+DuRdyoPqAxtgiVt6nS mEFyPsQ1Dhv6RO+azTVzZV/EerIVd7YQPFRmSLJkaeuX7CK9qbHP/vjto4OdM1fP XOc7bOQBiV1u7SK5vBAbKOmlCiDttYS2BjuYT1gFxu0uqTwDwdtRMEOUVfWkrQUb LqeOLIBe8PAaVfGH8KdDhYKgyHyWq3+PsNncMm7z5Hj5lGQidCpzysYlsX6TZbfq hPn6vN8PUWIirMzdigQMVGtXiUDoda13+Wy+RTi760shDnzUhDDTZtX0NWQmMl/3 oPJFH6qVBwDhLycjhi/Ccg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0rtpf84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:05 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGBTrb010640; Tue, 13 Aug 2024 16:37:04 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8s053-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bIexUcPPIjER2DEYrdl/69gF8FhdPczjN3UyxkIoUyNbpByU2dNMcSbGdZYp8l+i9D/l8FqugfoJfSHgXqp+ZHaZbG3qv5ydT84z/Iysb/Sq3EJS8jaKx3c6P4gR2XfKkIe+OT2t0i1TiEWV7qMPe5MZMT+D3uaW4nrG9qQb7HTBsP6tq8/Xn454/6JTrYDX34VvwVMMgP3OYRV4jHwDPrV/SvDDzKRBEP3PzlR2KK7ZPbF2ay9nVxxFNrIytUyV9WiEhNs1mWNJWY5PIQ7SHvrn3CXqWsqBETncfEENRZhBe2HmESTnPB2GmYar7f8eGtklX3nS0IW3qsaWq/bCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b=ZrCv6msycZq0UPYofy4/cxFKDx9cEnYJUkfbqXtCaburuOcr8Oujc/qEbFHt4Pm4MqkZhyPIGaYytx1qefLE63iGDM0enB+Rc4PeXeoCMKx22Er+bpLTtw/89Qq9htvuaTlSdnz2TfVAS6VzdrR8aanYxEpVcEPnB0Sp0gW/F/q1jUabMZSStwrH2fqY9g/Y3EUdvFVDSVxLZNWBRBtn/9SzZBDQy1RrkeTvhFd+eO8rq7ILJZ88bmqisVvx2AJylSnM7LzuI9Vy3wpMqvmmXM8C6hSOrC/MoPO/tUdr9fez9YxchkexoJaflTr3Pd/3qTtNa/xB+udyIdHMt/uwEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O/SjPFt2w3lZcOi2q8fMPdZvU7KFRVtFOTV0GecvV74=; b=M+I3IygotY8Z/C5Khu/fTZ3MDHDgJEbs8y30AHzueqyqItUfNyoeAqZboJalcgSRIdOUSDC8YYUE67WogKdvb16J0gchm3vi7x9yJlsdOeJ8rjM/XB627Hx8C2lBvKGqw/QayyIu88LdebamT8ltSPD/Q3MS+k9WsdGFaMZpuGw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:01 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 06/14] xfs: align args->minlen for forced allocation alignment Date: Tue, 13 Aug 2024 16:36:30 +0000 Message-Id: <20240813163638.3751939-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BY3PR05CA0015.namprd05.prod.outlook.com (2603:10b6:a03:254::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: d1ed46cb-148e-4051-c9b4-08dcbbb62711 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: YMObGf5gL9oEtioyRH+yuB8zpQorVYQv6NIvI49steUxGeFIw3GNyJbiLj8FIPSq+HVSC8lVQlJk+rtl/v+h7ZivjV2BRt7xSp61VXadJSOQtPPaYQWsa/2O0VXsTPTas0EpoqgFHAeXzgjEjnKz0JN4+t8xmkmCBie4erfuNl4U0joNg92nxx7lnreXj4r7/+sCszM0jbdfkC5As0gSkY7S7b30hj2XEMbJKKI7AtEtmZR1zmdRjAIAnI0cuncLCy2S61DnzWB+G9J51xzMPrpkeq2KhFufG6AoGoRWrcC6EoYaFkJdRrvPVOQ1x1oWc7zgUm5KlODVYTGU8oPQ8xlNDAnEv/qxtAorIN7Tb0u+GiEh9Qs3cTPiRMQiq6A0JCrw9QD33E1Xru7CimpQate73csUqS1ZO0W5Yy5YSc0J1gji0Y7i0wyd9YVG9mopRdTAfR1ez7Ezfx2E0UMbIAKxZNBl9gecCCfDqe83iO12PjNeWruemZ8mKL9hBw46adFX7WKmKuGQfl1LcZA4YA6JtHNKen3nEW6cHCXMedaeAVPPqxzmSpjw2+phqUf8/KYYMUZG0/U6qEFYCB6O0YRNbNVTz5saBnCBUfTGTgg7BdMgQMGMl3pllgY2hOUXpQnkJNriIF7NFbQU1GqW1c2Z630rNMINlXEp3eREA5TGCgWfDKHtTq1ycMTZm7shE7yc1/bNgx5kktD5wAq/F+b4DkQWLSCXDlXWJsoZiRcQdmYV7WOHBAzMOxwjIeRjL1j3UbeNic6K36omDwB4Aa0ZlSsmMkYnOhYvZs1bkthtcfJ7e42/+zgtoCsMqDAeLc/Sp01nNhTQuGZ5xgatOEhFJPSM7BPtd/Cx194EF/4AUk63iLqcLyMa2ThjAmXn6efxEGAisiH8p1zwrEk1yhW3nMHsLvnbaLPI0OPTLkdQqJL9rpwK2nL2VHHv9QlFwerbBYfBeyOeLQfCGQkjWB23C1fW3HvFdGwH3/+Pf8DRpaiq2uvi8Bpro9WaElbpgI9K3KoGplVe/kuDjcf9ujk4JEyNPVzMpF9oEUXnn+1hQBMNY1QyeawBTcPUXEG/WcX8f1Aa7ZHkvMou6y9JkBOyYoP6oCijl4iD2M97NIgrav/CSOMDtMsD3drMSlhpv3njI7Fn/+sHKE5s3SF31HfMaMJLW+hbKOhnCxeI5Y2YVPcQZibH3WNJZLN5ZIqOkrN5KzUIhRJrktJWAPzpAFcAhB0KpPkBgS3gCCMcBOM3pNqSSVa880yXTmg0HeA88kHIQWZkyFD9BCwQIOthN16zig3B6LJR1KCeOUz/YM1ae6uJSWDHyILMLj53EC0Qtjds8eX0HdYhT6slz/fKEA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-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TaxdMSqIIGOLVhAiskfQew6s0NvsCQu49CXWITdFuxeSVCGXJU8Mnir/2sxbGkyMznfQuuDSeKRVbo/6cL8c4ND2CoFu5zzitmd99rS6og+mJXjhi6gA+1mcpymxULSIAd0rb+ziHu22HgxJcD6vox3UEh+wG/HhIhffKgvfgrb3VJSfrKovYIwqvbNVzgG+ivm0hsjIDZGBxUMTDHVTS0qXvXd1c= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1ed46cb-148e-4051-c9b4-08dcbbb62711 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:36:59.4860 (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: oLiOj2Rpu6xcnT8Iu8DaINwyVjTfWbgXFtqjojrcORbLBVN8eSVWoTCtyIqkkqum4wtC6akWM2K6A9gr/QCgXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: mwWc8HRP1xDGx78KAqTwtV6UfzJ8BfQn X-Proofpoint-GUID: mwWc8HRP1xDGx78KAqTwtV6UfzJ8BfQn From: Dave Chinner If args->minlen is not aligned to the constraints of forced alignment, we may do minlen allocations that are not aligned when we approach ENOSPC. Avoid this by always aligning args->minlen appropriately. If alignment of minlen results in a value smaller than the alignment constraint, fail the allocation immediately. Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 44 ++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 602a5a50bcca..0c3df8c71c6d 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3279,32 +3279,48 @@ xfs_bmap_longest_free_extent( return 0; } -static xfs_extlen_t +static int xfs_bmap_select_minlen( struct xfs_bmalloca *ap, struct xfs_alloc_arg *args, xfs_extlen_t blen) { - /* Adjust best length for extent start alignment. */ if (blen > args->alignment) blen -= args->alignment; /* * Since we used XFS_ALLOC_FLAG_TRYLOCK in _longest_free_extent(), it is - * possible that there is enough contiguous free space for this request. + * possible that there is enough contiguous free space for this request + * even if best length is less that the minimum length we need. + * + * If the best length won't satisfy the maximum length we requested, + * then use it as the minimum length so we get as large an allocation + * as possible. */ if (blen < ap->minlen) - return ap->minlen; + blen = ap->minlen; + else if (blen > args->maxlen) + blen = args->maxlen; /* - * If the best seen length is less than the request length, - * use the best as the minimum, otherwise we've got the maxlen we - * were asked for. + * If we have alignment constraints, round the minlen down to match the + * constraint so that alignment will be attempted. This may reduce the + * allocation to smaller than was requested, so clamp the minimum to + * ap->minlen to allow unaligned allocation to succeed. If we are forced + * to align the allocation, return ENOSPC at this point because we don't + * have enough contiguous free space to guarantee aligned allocation. */ - if (blen < args->maxlen) - return blen; - return args->maxlen; + if (args->alignment > 1) { + blen = rounddown(blen, args->alignment); + if (blen < ap->minlen) { + if (args->datatype & XFS_ALLOC_FORCEALIGN) + return -ENOSPC; + blen = ap->minlen; + } + } + args->minlen = blen; + return 0; } static int @@ -3340,8 +3356,7 @@ xfs_bmap_btalloc_select_lengths( if (pag) xfs_perag_rele(pag); - args->minlen = xfs_bmap_select_minlen(ap, args, blen); - return error; + return xfs_bmap_select_minlen(ap, args, blen); } /* Update all inode and quota accounting for the allocation we just did. */ @@ -3659,7 +3674,10 @@ xfs_bmap_btalloc_filestreams( goto out_low_space; } - args->minlen = xfs_bmap_select_minlen(ap, args, blen); + error = xfs_bmap_select_minlen(ap, args, blen); + if (error) + goto out_low_space; + if (ap->aeof && ap->offset) error = xfs_bmap_btalloc_at_eof(ap, args); From patchwork Tue Aug 13 16:36: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: 13762273 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 B84BF1A2575; Tue, 13 Aug 2024 16:37:16 +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=1723567038; cv=fail; b=GKLLtaVm1RwoTVKQ97hRD+fehoKI9dROAj9al36Yvab0Pilx4ptxnMqY84+bghnNKTBBcHfs4t32rI+0hLc1GzIshS1noXAZrIutwZPvEtjaqMt8uEZgAesJ5C2w2bYGRRFK1eHfdW7IU2nvGUCTmliBudL/W8UpDArVy6iEYAo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567038; c=relaxed/simple; bh=Z7LLq+zV9tmtxtH7CKsr9XEVpUgX/3s9P1O+oRwkdvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qIYREQzjDyfsI8LtdOT8ASFETua/J39p9KqOluqQKmFvcBxVTffgpyqpmbPr6bno1K4d3VgieL1zIITWQS1Iae9+e88MleZx4iIEDoptXgLG/TUEdQz2i5rUlEXi6XIUEB/ZRSmFdbSPpW2F+ALWcxbjZUNrDIaRxw9m0DwZU3w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=V9WXSXNE; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qOBHWcjv; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="V9WXSXNE"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qOBHWcjv" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBV5S022283; Tue, 13 Aug 2024 16:37:07 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=JKxlh27GsuWWUAHXyP7CKwSvfJ1z6wrm1JzCJZJ03YY=; b= V9WXSXNERlrZ7XrmTJ6/ah1APf1sbMoyoAJTbaMqlZqpvVrL93XzDLvi2jV9QCS/ dQr8lNpdYqGC49z3fQbfu775AMOs6ZxBuXcoqqscya3qCwlaywCuMU7azZUrX8bC LMz5sr+M6EPJixE5ZvYvRjsidXmpQr+eda9XRen46B8im6Fk0xzsvt/w2V57nhQV ClEzLft9cSIY7DMujJZnHnDMJz+QEbLo04+2eN3V7ynT4Wgc2fw3tRL/54Vao6cU Zktb5qBLRufNzTlo7wTwa7b8lPFLUxEkWDw6JJ0uikcYWFk0f48MVrCFvi90uKu9 rKS3TEWJckPBduSFN8Y71A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0396a9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:06 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGBTrd010640; Tue, 13 Aug 2024 16:37:05 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8s053-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CsjP1qZnVs6ZzEgRT+IlI0SrTR2NMG9VL5D6IYFUiRw0A1F/sg4vlijECrDPmgChOwjJ8fKDz6syqSvlxADjBZskN4D6vkRvIMpav3bnVw4Ci5IgF3+ZEGJBM8gfUVS0sszC3os1NBLH1HzbpPJ3apB7vj7EZ/Drplpr8zUwW2peX5RlulAiJRyd5+iT+v8MRtJfjoieD/Fp0H8/MnvQCrKjMf0rwJfOXSTgtM4l6wVerri5bp6IbQSSdjGnlX1dfGDKAxUfiqWA5iyqO3nplIJunj+0g+lC5ZoGRy8NPNkCAKok69wQztF0RGY4OPcCWk5u8ExOfp/VNSro1PQt1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JKxlh27GsuWWUAHXyP7CKwSvfJ1z6wrm1JzCJZJ03YY=; b=I5a/VZDstNNzDR8EUZpVh+6txd/4qyVbzsGM+Ub29b22ufhEeIKXG5K8YPA8LPCyQ1dqbjjgEhmmn4lIoWe3E/Ex5J9TZxiDLVZVBF1qsjVTQEi8FSwuveiHyGzOurBgDKPHGcwHkbpDTjZ96AaG7A/ZdjGXGJ4s85YcmBYoH7rQv3xdBoPMWLDCKnfTPh+/aJ0NhBDUiH//4Dgx1Ap+t49LJaWHnbvb8iy671sS4PlFTN0LjMHhagmX2ewuQlbrmZ+XGqjlm7c63nAQ4y1dprzkilUdFTf/GUAr9W0ujvwip2D/qO5m8zeMEiMwf0AeIqAXDee2sPk5QHN7WEeEkA== 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=JKxlh27GsuWWUAHXyP7CKwSvfJ1z6wrm1JzCJZJ03YY=; b=qOBHWcjvmT4J55ZUtSmD+Ib/y2ws+zk9zcniIMDSk2ehdIBL4aXrVz5/cBow4QlYBncORGE/kMPUzu9CYGq1YjhModvtFxdbCrAEsedI/CY5BCfjZJOSG5Mq26S7W0MRtrNZH47IXJW3taOblOjdLYQzrJ8DXhpmuqFNK81u/PY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:02 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:02 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 07/14] xfs: Introduce FORCEALIGN inode flag Date: Tue, 13 Aug 2024 16:36:31 +0000 Message-Id: <20240813163638.3751939-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR03CA0033.namprd03.prod.outlook.com (2603:10b6:a02:a8::46) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 18fa0bb9-0a65-4062-0c14-08dcbbb62897 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: hh1JU1w5IqLRoC9e/JuVBdUmPbu7I+wFepvDAWQuLwAD9WUV9vXGLCCO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yTtr514yKPlBQpEr190TNXt3Mnw2JBCL2rXcwIGjJse0JdmaCGXWLd0CgtY6oPgSkytTDEhB2C+CZhqf/J7AGqBVffYyJdFpUy3sa7Dp6txA3xbUpXtfaVL9LR4IYSgUCa+ubBEdm8Hz103ulIEdlXybHybamMpU91mTFPtGvUSLwrruzReY8QMbmepSAtZMH7yoKrEJ6IwJ4MGtJyO3t/0q2sjrY4Tkd+976w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: awoeJVhcBRScUUPecfWYF9EhTwTDvUSLXiwLJmFYYg9gdIeJk3IhwP48oYfPrBmLiTZc3mCGFbBlllt9A+xEeMwcqjUMfbw+t6gVyAeARpTxMnXYZZh9wxZm7CrSP7ju054Z9sWtsRGHCRD/lCaZI42LJMEgbhRaNMLRrFZxwWvmKtpWseXt2dy0i+v1fMSpROXQc46M+OO8ROxZQpCEmjrDOBBlhGedmqM0jdk/9IHzu3FPM7S5WW1tAY/fMhEVXxzXw9SE/BDdVGScFWNECt8IaiWMMtjvQplhcri+dfanaZ3GAf1tTcFtBZLZY6/+jnSD5luTMti78Ihked3JibCv5kQXZ2UFznx1335ulTTnWknnLWDl04Dgc/yR+C+Br7IUpwxa2YuOFzCZ1tU8V3G5c8wceUsHLoxrWzcKynfVjaxwlMRV0Q6TLhqxuPlXM4yR3y7dNqX327Jr1YYLvCRCgCpldtZwQvtfBH3f0nxN5HBWZIlVapjKwJFBCeu/uCjLL9p7ynaJevKrAU+xPfs76Wl65btvpdPzGEyQ0PyOVM94huj6nfWUoViEi70TOr/e8hQDJVK7k6ArUxeSIhLhi49MM5Qg8j1CW4feMyZ2MUeZ+qu0iBXRbfSu4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nDZDNh2GHE3HctgPK71b3JHITTyUhXtgmAm5TlxPFYlUOd9wA0UpR8bfXGlpzV+ss7mmIVZL4qfw5x/paNFn3Jlx2YmD278E6TILb7EgDw8NXR5Os4KtBFxYjRK2aZyiM3pEKz1MohFCvTIcI193B1HWR8E0Vzo9TGOV97str7nGoNq+LEnphGcXR2bxiWCRJ+UXnCAGu4JfbOHVgJ6bNZJTLHYXg+QuI2nmbalT2l6j7OmBGXEOwwooJmf91r9FCoqZHIRHw3UJVrLnbfDvDN5iIdSjwau6kXAF++tIimhDnJ3XlOFvzK0PB2DEuOTixh4Gh/8q72WGbmW7186gRA1SFpzQyV9+nNJ2v04SPHIWQQq1xG0GoCjsxBnrj6UtV9TRcSwtvENiYh0Lf4F9Q3H2tVO6uzJvWJorX3gf0wazM8mSqTyC1iNqH98+9NI1lKcThQ1Wf/or6U7SP6qRbGNakhjDXk+216+zHt+HO1NXXUGEcEYsfY4Lrr7m5UMhKRzhZn/1wXyhEP5qu+GM4/HQ794At0UjFOzIB12M/VVf+5DgUdZ7aZportj1/jLzKcf1ORA+i53CEYpZYj2cGLIpCjc4v8Byo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18fa0bb9-0a65-4062-0c14-08dcbbb62897 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:02.0816 (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: tOnw9zCh+Jfm8R6byl9XrbdLZe0r4CCr1QjoD1RyjsJb7EEWXEiUrSwQQ+Ju+chXxVGEuCFpvihrF4jCFt0H0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: Qr5L0ATrAra1jzd7mfy2V8zWS2AAvbOk X-Proofpoint-GUID: Qr5L0ATrAra1jzd7mfy2V8zWS2AAvbOk From: "Darrick J. Wong" Add a new inode flag to require that all file data extent mappings must be aligned (both the file offset range and the allocated space itself) to the extent size hint. Having a separate COW extent size hint is no longer allowed. The goal here is to enable sysadmins and users to mandate that all space mappings in a file must have a startoff/blockcount that are aligned to (say) a 2MB alignment and that the startblock/blockcount will follow the same alignment. Allocated space will be aligned to start of the AG, and not necessarily aligned with disk blocks. The upcoming atomic writes feature will rely and forcealign and will also require allocated space will also be aligned to disk blocks. reflink will not be supported for forcealign yet, so disallow a mount under this condition. This is because we have the limitation of pageache writeback not knowing how to writeback an entire allocation unut, so reject a mount with relink. RT vol will not be supported for forcealign yet, so disallow a mount under this condition. It will be possible to support RT vol and forcealign in future. For this, the inode extsize must be a multiple of rtextsize - this is enforced already in xfs_ioctl_setattr_check_extsize() and xfs_inode_validate_extsize(). [jpg: many changes from orig, including forcealign inode verification rework, ioctl setattr rework disallow reflink a forcealign inode, disallow mount for forcealign + reflink or rt] Signed-off-by: "Darrick J. Wong" Co-developed-by: John Garry Reviewed-by: John Garry Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 6 ++++- fs/xfs/libxfs/xfs_inode_buf.c | 46 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 +++ fs/xfs/libxfs/xfs_inode_util.c | 14 +++++++++++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_inode.h | 8 +++++- fs/xfs/xfs_ioctl.c | 46 ++++++++++++++++++++++++++++++++-- fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_reflink.c | 5 ++-- fs/xfs/xfs_super.c | 18 +++++++++++++ include/uapi/linux/fs.h | 2 ++ 11 files changed, 146 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index e1bfee0c3b1a..95f5259c4255 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -352,6 +352,7 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_FORCEALIGN (1 << 30) /* aligned file data extents */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ @@ -1093,16 +1094,19 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ #define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define XFS_DIFLAG2_FORCEALIGN_BIT 5 #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) +#define XFS_DIFLAG2_FORCEALIGN (1 << XFS_DIFLAG2_FORCEALIGN_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | XFS_DIFLAG2_FORCEALIGN) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 513b50da6215..1c59891fa9e2 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -657,6 +657,15 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_FORCEALIGN) { + fa = xfs_inode_validate_forcealign(mp, + be32_to_cpu(dip->di_extsize), + be32_to_cpu(dip->di_cowextsize), + mode, flags, flags2); + if (fa) + return fa; + } + return NULL; } @@ -824,3 +833,40 @@ xfs_inode_validate_cowextsize( return NULL; } + +/* Validate the forcealign inode flag */ +xfs_failaddr_t +xfs_inode_validate_forcealign( + struct xfs_mount *mp, + uint32_t extsize, + uint32_t cowextsize, + uint16_t mode, + uint16_t flags, + uint64_t flags2) +{ + /* superblock rocompat feature flag */ + if (!xfs_has_forcealign(mp)) + return __this_address; + + /* Only regular files and directories */ + if (!S_ISDIR(mode) && !S_ISREG(mode)) + return __this_address; + + /* We require EXTSIZE or EXTSZINHERIT */ + if (!(flags & (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))) + return __this_address; + + /* We require a non-zero extsize */ + if (!extsize) + return __this_address; + + /* COW extsize disallowed */ + if (flags2 & XFS_DIFLAG2_COWEXTSIZE) + return __this_address; + + /* cowextsize must be zero */ + if (cowextsize) + return __this_address; + + return NULL; +} diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h index 585ed5a110af..b8b65287b037 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.h +++ b/fs/xfs/libxfs/xfs_inode_buf.h @@ -33,6 +33,9 @@ xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp, xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp, uint32_t cowextsize, uint16_t mode, uint16_t flags, uint64_t flags2); +xfs_failaddr_t xfs_inode_validate_forcealign(struct xfs_mount *mp, + uint32_t extsize, uint32_t cowextsize, uint16_t mode, + uint16_t flags, uint64_t flags2); static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv) { diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 032333289113..b264939d8855 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -80,6 +80,8 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_DAX; if (xflags & FS_XFLAG_COWEXTSIZE) di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; + if (xflags & FS_XFLAG_FORCEALIGN) + di_flags2 |= XFS_DIFLAG2_FORCEALIGN; return di_flags2; } @@ -126,6 +128,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + flags |= FS_XFLAG_FORCEALIGN; } if (xfs_inode_has_attr_fork(ip)) @@ -224,6 +228,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (pip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) + ip->i_diflags2 |= XFS_DIFLAG2_FORCEALIGN; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, @@ -232,6 +238,14 @@ xfs_inode_inherit_flags2( ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; ip->i_cowextsize = 0; } + if (ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN) { + failaddr = xfs_inode_validate_forcealign(ip->i_mount, + ip->i_extsize, ip->i_cowextsize, + VFS_I(ip)->i_mode, ip->i_diflags, + ip->i_diflags2); + if (failaddr) + ip->i_diflags2 &= ~XFS_DIFLAG2_FORCEALIGN; + } } /* diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 6b56f0f6d4c1..e56911553edd 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -164,6 +164,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) + features |= XFS_FEAT_FORCEALIGN; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index bf0f4f8b9e64..3e7664ec4d6c 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -312,7 +312,13 @@ static inline bool xfs_inode_has_large_extent_counts(struct xfs_inode *ip) static inline bool xfs_inode_has_forcealign(struct xfs_inode *ip) { - return false; + if (!(ip->i_diflags & XFS_DIFLAG_EXTSIZE)) + return false; + if (ip->i_extsize <= 1) + return false; + if (xfs_is_cow_inode(ip)) + return false; + return ip->i_diflags2 & XFS_DIFLAG2_FORCEALIGN; } /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 4e933db75b12..7a6757a4d2bd 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -469,6 +469,39 @@ xfs_fileattr_get( return 0; } +/* + * Forcealign requires a non-zero extent size hint and a zero cow + * extent size hint. + */ +static int +xfs_ioctl_setattr_forcealign( + struct xfs_inode *ip, + struct fileattr *fa) +{ + struct xfs_mount *mp = ip->i_mount; + + if (!xfs_has_forcealign(mp)) + return -EINVAL; + + if (xfs_is_reflink_inode(ip)) + return -EINVAL; + + if (!(fa->fsx_xflags & (FS_XFLAG_EXTSIZE | + FS_XFLAG_EXTSZINHERIT))) + return -EINVAL; + + if (fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) + return -EINVAL; + + if (!fa->fsx_extsize) + return -EINVAL; + + if (fa->fsx_cowextsize) + return -EINVAL; + + return 0; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -477,10 +510,13 @@ xfs_ioctl_setattr_xflags( { struct xfs_mount *mp = ip->i_mount; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); + bool forcealign = fa->fsx_xflags & FS_XFLAG_FORCEALIGN; uint64_t i_flags2; + int error; - if (rtflag != XFS_IS_REALTIME_INODE(ip)) { - /* Can't change realtime flag if any extents are allocated. */ + /* Can't change RT or forcealign flags if any extents are allocated. */ + if (rtflag != XFS_IS_REALTIME_INODE(ip) || + forcealign != xfs_inode_has_forcealign(ip)) { if (ip->i_df.if_nextents || ip->i_delayed_blks) return -EINVAL; } @@ -501,6 +537,12 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + if (forcealign) { + error = xfs_ioctl_setattr_forcealign(ip, fa); + if (error) + return error; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index d0567dfbc036..30228fea908d 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -299,6 +299,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ +#define XFS_FEAT_FORCEALIGN (1ULL << 28) /* aligned file data extents */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -385,6 +386,7 @@ __XFS_ADD_V4_FEAT(projid32, PROJID32) __XFS_HAS_V4_FEAT(v3inodes, V3INODES) __XFS_HAS_V4_FEAT(crc, CRC) __XFS_HAS_V4_FEAT(pquotino, PQUOTINO) +__XFS_HAS_FEAT(forcealign, FORCEALIGN) /* * Mount features diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 6fde6ec8092f..a836bfec7878 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1467,8 +1467,9 @@ xfs_reflink_remap_prep( /* Check file eligibility and prepare for block sharing. */ ret = -EINVAL; - /* Don't reflink realtime inodes */ - if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) + /* Don't reflink realtime or forcealign inodes */ + if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest) || + xfs_inode_has_forcealign(src) || xfs_inode_has_forcealign(dest)) goto out_unlock; /* Don't share DAX file data with non-DAX file. */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7..b52a01b50387 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1729,12 +1729,30 @@ xfs_fs_fill_super( goto out_filestream_unmount; } + if (xfs_has_forcealign(mp)) { + xfs_alert(mp, + "reflink not compatible with forcealign!"); + error = -EINVAL; + goto out_filestream_unmount; + } + if (xfs_globals.always_cow) { xfs_info(mp, "using DEBUG-only always_cow mode."); mp->m_always_cow = true; } } + if (xfs_has_forcealign(mp)) { + if (xfs_has_realtime(mp)) { + xfs_alert(mp, + "forcealign not supported for realtime device!"); + error = -EINVAL; + goto out_filestream_unmount; + } + xfs_warn(mp, +"EXPERIMENTAL forced data extent alignment feature in use. Use at your own risk!"); + } + if (xfs_has_rmapbt(mp) && mp->m_sb.sb_rblocks) { xfs_alert(mp, "reverse mapping btree not compatible with realtime device!"); diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..f55d650f904a 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -158,6 +158,8 @@ struct fsxattr { #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ +/* data extent mappings for regular files must be aligned to extent size hint */ +#define FS_XFLAG_FORCEALIGN 0x00020000 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ /* the read-only stuff doesn't really belong here, but any other place is From patchwork Tue Aug 13 16:36: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: 13762275 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 765291A2C02; Tue, 13 Aug 2024 16:37:21 +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=1723567043; cv=fail; b=RkRVTBcJi46rTJPZYNGArTGRo7rsNLB5SUYFFDXnr9Eunv9DZL9mkrraYWrBB6XQzJR6zIabIJNWUlKFRyP9RDoDxXRykjMhh9l33cEu/Kq1uh0M1MglQO6kpvbzQLUvHGuycKaoYoacVmrP7A5WkLiVjx4D3omUc31ooY+9DI8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567043; c=relaxed/simple; bh=2ClA1e2FmbSnIZpQLwZEWmkHuRXPdreDCtFLRpEHgwA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KKatpwoWLPGS0cAXdTmM3pVMkYR7UdG5gIqucNBsCjVYy1f4qMTaY9gntLyM4oS4E+oZIHfBxCV+YT9ihllFCyzCWNMD/FPqUE2Vsk7V3T8rha5MstKTd4/IakUMvjGsV8etihwHxOe3kavMa0r7YsHcsH2P2QEukJcttENswqo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=eP++CCFd; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MilFklRG; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eP++CCFd"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MilFklRG" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBT0M022167; Tue, 13 Aug 2024 16:37:08 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=2Oh1HQs/HrD8Y+07swwT6A+lkbWoAZZpvbgy9K0ChVM=; b= eP++CCFdOh2EyCnNRTUKIbxgowaq9yJL0BymtNp2ubb/moQ2/Sd7EW1z4FFLpQpt J66uoZN1DVwu98pfiG5vl/MRUiFgRYGYClukV7zSHniYfD2odBHAP2rVcCLO9eU3 1HIrx953ql5Rcsu2MX2U8QexxJy5t5MRbPy9v+EjgHfQxzjFVZUBsDGwsjU/LNgJ YEcXQqTnCFirIp/lzNJqnSgH1s7zYs/ZGEJ+UY8Y+BXn6YcIYvuvajCMNkINGMx2 uJwVlGeSYphKr4Sn4pec5Cz7JBnuwgPQVwBkgJV+Fi7cu3Hz/In14PgytlqVQDhd 7AmmRTgZVrTni5g+Lr8pDg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40x0396a9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:08 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DFriCu021164; Tue, 13 Aug 2024 16:37:06 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 40wxnf93h4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=USl7WTjj1blGMaxZgcFLM4iyuvFLrzNDRF+OU0j82V+odE7D7QHrlmS8KuGmJjqpgclEvYQniDxeN64wwIYilutZjCvKl2OVjZ4tpOpt8CoCfbqAQkK29wLg+YdDbsiKdjy/VNr724jahe2xPUi2E0xFQSMFzP9M8ionUwg+OaCnO/vgCj4JGVsy3RzzYvct7AjziOshliBE+73zCnZl1MXurgC4XTQmZ1OXwVziARoQKPQRxfZ18cfqlTlAmBgt9SnjMQCI8tUmwLcVaPz147Wla92SSQFq6pC3pDRmXexO2DTa+6fyYi9FbQYUIqqd0vQh2wOPku5V3S3OTlvXaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2Oh1HQs/HrD8Y+07swwT6A+lkbWoAZZpvbgy9K0ChVM=; b=GBzPN3L+qP9kx1CztdNTqnr4ur8oEc5pEHzFjg0PV+zbh96DKbBMwuXN/DHyReDfzelzZL84RTSU0rR3FZiBKmckvGa8vMX3139cbDDKOYDlsHexPBcffXQezqu8DvtDg+7YXpn746YF4N5RphPF9axphGcYbPHI7erOKBEg3+ktlv9NUYSfy1Z+Bi5jlzaD1OpVEe/XgQ+fhKocP+cOhYTTwZZ/DUVR2ItXsTA4J3EegZFoNOiK17ChP7H2TVkPCTlzJH802J0GR/c+m3iSLBXnv2eO5JL1Vnk694aHj6FgiAW3sqTARKpfVTMF8JaMEx7sHiMnPA8rJeLGPksAjQ== 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=2Oh1HQs/HrD8Y+07swwT6A+lkbWoAZZpvbgy9K0ChVM=; b=MilFklRGNbLv1UegNSqO9/EuHH4rafLi/4rI2GKvyxNuBYA1G7Z4RoiqRKbHF54wVreaJtGTA0scxt6Leq9AAWmu3y/GOPFgQIfCAsBs/leNWMfYA+TYDdEe0Syg4yonqcmQIw4OGe4MYQDRmb+TWlHd+F2hA33xeO+4MxUMOmw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:04 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:04 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 08/14] xfs: Update xfs_inode_alloc_unitsize() for forcealign Date: Tue, 13 Aug 2024 16:36:32 +0000 Message-Id: <20240813163638.3751939-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0080.namprd07.prod.outlook.com (2603:10b6:a03:12b::21) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 54d2c33e-91c5-44e4-508f-08dcbbb629f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: /IwiWZeNAcSLfBPgNnvoaCbVPADW8cQF0OIszBUJ+zrnNhlC7ZE5FqnpdLfE6WF52HEQGx5/UQzEcpan3JgiDf+e3V9lDM542/ie+fSVELAkmR6nBwBLZrgLyHWm7tAYQtXYgWmDYIeoYEIF1IKe9ZOrk3JnEIk/WF9i83tmkBKDtP/9IuTcpwWUaIFNTalA/W1EgRF5mC1NNRkeStq1ZDLuN7u/Aq3gnPI+c7PrZ6t31D8W+YPFq8Dgqg1qiyF7JD34Qg9KUrxnqx8lxXhf/+o9h2D7PdzjOUm3HJLNZq5E+SimIrc7DWl18EAvUP7lBlwEiwN1KncGRtwWtHzAxqcJ2viWLZyFy/ZmlOZQ/wJccX9ZJvneV34oniaz49HvsOOHcZ7WdiYPC0tRuzYrRfZdkRXVrmQQvjTg7NKA0jvtsnoQx8y+98y6Dqh001K+LZDZ1AUZPDKwf/wllJVPQQaPreOrtbgcIbrxM7WkFe/7jTz36dx3mugMKY/m2kWCraca3ejSGUex4jmDHk4tUNDKSyC5BRQTBOIHzROkIFbo7Jm4n+edyU/D/cl0M3ToibG6mqS4aAHOygZU685rhY8admXVohPVVVfplzYTVqI7t+bNd/uEKA+gIkK0jZOM+To6u6sEk+g1k0dFEM3TnI6/7E0txplnNCSch9TPa9h1d8KPYxKNl3VjgJ+iL8qqXKTLMvkQEgzePqNbC10CJS6SMMEwL02qTUewLdkAcBzx12aKTZQdXjBAIzF4GjuuhF+NBRLcsZMbuW/leARDXn4ljLQ8kW4ZUFLWEp3R4YWgBzYTLeF5TVE+d8IBkMETKXCJQWAQQTaiAiuVRnS5ziot1tnhKLIGErk7SRA5/4iCM9XY3mTee4WMGqChZ4B7Mwl2hj9wqph76yEIzwi1BnjeFN3bRPY0giDTeRAAAiMFEGlaEffs3sNt5lmW9V+XMfvd9dZTWt6+EAmat03YcjDSQ5EPkApfAAbBnjQP72zWNPx2CTBnnsHH9sQiF2OZ5aydPRPAUSxx3QsYNagv1pgFsgspaB2FWAmOm3lGXEqdajHvxRiBG4q5HqLhAAfSQs6QlwX2F9H0mjCfTZli6reKJi+6vca9sGHSSyEdwK8GEchVjN7XDbJNmdIDPvHScuZeBFpjubjW3xp0YcQdEuj6ihP2bPJ0++a3HcBs3xiLZ/4XRovTASGYNs4VBFlPo1KLewLxqL6C3LEMn4ElA45kkogS2Mo9dNgDKFKrc20S+UNfoeH69Yio7mLxqk9uDfCOMJJega1Sm/Mysp9m71IZnVzkOJOvxfyiJPR4U8ofD/tw+F8XyBf9nM+XGg7sdz8V0YrLQIlGoDfBclELpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +vK/PWQFEbGZlCGy+00CDuAzPqsHTtI1ocGTp7BfSKx5oqW5HE44DCoiCdW8wdgSyQUySu/LxZeZneRW1VRvuH0DUgRD/uw2tzYE7ooycqmB+p3fpSlSbD+95eLSsecrpD61WT0rEF8VyifKHvKSNrJNdXO+bZ/evWpS53SXq6giIk07yfLmxJmwE/2EyW0Rcv9dIEhbEgIbXuX+HNc7qGFniPpNlHXlJCOlZM6c0E9FS+fm1Orf4/JFq+cy5wZ8OCsQvNHgXD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gQVnwvwgP7gIxl2qOqqMAb9V3q33R2L9Q8f6b2tf36o7W6N5G9lnUtmM4JRPjK4ez8Vd6SwviLKHtmqdkewqHNDiVONlit4ViOBwoUrn4TbwBCKt30rDubigQjLGuksv5yqSfoGZbSgHPgngMeqqpuuIIMzyMX1p32ffU2E5vfEcH8eey5Bt2P/+wuA+ux+gJpIUuJPe0EGPcHNeveC2fNsqakGDUwS60V5hpxe1eJtAmDTDF6dB8c0G0eMxi6EOEyQtZuRuVDKcBXiRWDFU1dkqIBAblQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8OlD1cCLtsf9HlE3nCNqQJMrbyZyAMFlXf1/NMYuhhDNeGngG1W3oGA8a/UlPkf97Iy+8Fbqt9koW8bn78VizWXo94F8kI/n6c+vF1wjWUNxHKI8jXA5XgPGjuG+9YpQXRmHONCxrkRHbHwtV1tUgYOvXGqsgOKY/xdxwAdcKot4d6MfO65E3+ZJN/7g+K2GZ+6mTQJ5dl4ax/w8SHj32j/ZvRxZ7O2zsaXpz35O0JsUqgRVaw2wV/k+wAvEoXEnTBW8jsMUyjTdI+3riOalI3nbvO3cIL5JvnW0K09k8GfzIQ3A6PQ7IGgEzqxF3GrqDQnG1MWzcO5QOg+asCTbO6n30HUsGUst4KgMwD4PgaE3Calg5Sz1KM2zBNXQvGgJ9ci+XWHSYkGN9mizs5X4y+U+smyKBZiivpXBqKm1xNFy/CMSpNnhnKjUYTNi6+jagknkNYQmDh72DWKxwtXwD5qtgDr9q6O2h7BC/iEf6Mx2k1f9oZUmwzCu/u5fvgHrVMVNpwcTMvCVD/xi5xSm6Za6o82EoGfaDW5J5f817ymqPq7O2nlncyJ0Zi6vDscIvd4xT1k6Hq+ZujVFKONuIDTkeTw1ssvKKqHO2A+Jt28= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54d2c33e-91c5-44e4-508f-08dcbbb629f8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:04.3511 (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: DBgNHPnZvqs1PTf4ClQ46jbJ1IeGpNHMvUPZz5Y+gNU/cdgZ4RY6y4Q8WvvvVtDb6YIXh/7mdgMKGFZ/+rV4Ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: xsoGDamHn5hx5UZ1DBeIcKRFMWNGrSGx X-Proofpoint-GUID: xsoGDamHn5hx5UZ1DBeIcKRFMWNGrSGx For forcealign enabled, the allocation unit size is in ip->i_extsize, and this must never be zero. Add helper xfs_inode_alloc_fsbsize() to return alloc unit in FSBs, and use it in xfs_inode_alloc_unitsize(). Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_inode.c | 17 +++++++++++++---- fs/xfs/xfs_inode.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7dc6f326936c..5af12f35062d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3107,17 +3107,26 @@ xfs_break_layouts( return error; } -/* Returns the size of fundamental allocation unit for a file, in bytes. */ unsigned int -xfs_inode_alloc_unitsize( +xfs_inode_alloc_fsbsize( struct xfs_inode *ip) { unsigned int blocks = 1; - if (XFS_IS_REALTIME_INODE(ip)) + if (xfs_inode_has_forcealign(ip)) + blocks = ip->i_extsize; + else if (XFS_IS_REALTIME_INODE(ip)) blocks = ip->i_mount->m_sb.sb_rextsize; - return XFS_FSB_TO_B(ip->i_mount, blocks); + return blocks; +} + +/* Returns the size of fundamental allocation unit for a file, in bytes. */ +unsigned int +xfs_inode_alloc_unitsize( + struct xfs_inode *ip) +{ + return XFS_FSB_TO_B(ip->i_mount, xfs_inode_alloc_fsbsize(ip)); } /* Should we always be using copy on write for file writes? */ diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 3e7664ec4d6c..158afad8c7a4 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -641,6 +641,7 @@ int xfs_inode_reload_unlinked(struct xfs_inode *ip); bool xfs_ifork_zapped(const struct xfs_inode *ip, int whichfork); void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, xfs_filblks_t *dblocks, xfs_filblks_t *rblocks); +unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, From patchwork Tue Aug 13 16:36: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: 13762279 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 6C8B41A38EF; Tue, 13 Aug 2024 16:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567116; cv=fail; b=EtqPe85k5QYnGqoXWorsqtCaDOQQtyN2vwxfLua5qjCX1IlBZEoNT114pw9dHmdQ8KLHqZzzYf9Kqt17rJDrnM5Kg4f/etBeQ5vlagHKyV5NFPV1SJ4pXQJIgqC6jegGVsEPTHBv/JibfJLaMjv0UVhRr4GC9oqjyk53HCZRBGg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567116; c=relaxed/simple; bh=B6SMnyeFKBH/KVgsMqCFUs7k3Bv1sSdLtVIYxLSN6ag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pGMVkwGHZfuKye3MnN4GNAbodq0w+8bFkMCulCMB1M+BMIqH8710CN4HiXuxciqMPfeCuUTcHz2FsEaoxehcAqwnd7SfQVGavkTJmewYYMPjX0PtrxlF9hB1j3i3Y4Zr405jpW8IplailOn1pwT0izx/B88M1Yv3pvu9Xq34vhU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Q0D7nCBt; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=WBnoJniX; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Q0D7nCBt"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="WBnoJniX" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTrP007385; Tue, 13 Aug 2024 16:37: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=J0I4eHC7It2zetelmXV4UCVZgEaqiV1PPZw2a3x/WhA=; b= Q0D7nCBtZ3Z2P/5IBRHfZ3UXG18TqewO4/g42eIr9Bf+3SMtl2ArIStkbF7T/4eN xJC0L1UE1lzcdguH4kag6JXSaM2g8qvy5NwqcKjdl5F4CHGY+yPot9g6u12FGMDQ alPLPMfY2m4hxpP4gnQY1OokbAqAnfjO/kfISPa9Rdz9/4hLx3hCzKfoxcr3mxem AaTN2Idpz7/RG6ecqj1hAPtiqoNSWUzDTK1pOCg1D8wzzwIZ8W5pKbZOJ9Kda9im 2DsmbKPbsMzSl4B+brQOSyiI2Yvsyybkw0vN0+nW15X6j97/qGenaen65uEqyNCQ yaDWASATbIjCjf6KPtxsJQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxt0xfgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DFOann003532; Tue, 13 Aug 2024 16:37:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8q3df-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wd/xVKhDUcExYWTFK7VkamPCctNE8Nmz4ZOn2oLSQ6imU1NpT5Gfwah4YNfNmJFGT4eoAc1Ux8GHcJ/IHWuH9bdkcOvxoZ6hISu9UBhVX/b+eCCRLPARiGFmNwseGx5h0LhhspB946GUixs3U8E3BxOAoP1SYSz2q9WrhrrRdHppRRzm89A4oUnwKFOM2eZBQvNmpXmM/ueOpaQKfXKWd0SFPnSKSvUFiaojJABV+P4FM51oxnBVCKjl8RaCSzwRB/vB+9ZtNBG+Qgco/DZOuwwuxYN/FgxgCA5fPZRK5OCnwgLM9am57XsaB07B+MuQN0iO9OT+QJAyB0Ev7VD8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J0I4eHC7It2zetelmXV4UCVZgEaqiV1PPZw2a3x/WhA=; b=rsfhvbWHYNoYYomjKBnhTmcNYRXcx2dvQDx+HLwh5QmyWyQAKa+6Jug6cWq9oL1z2A7QEMXRG9z5/C+/CBdB6WYB8MdwpQwh/KZuHqgWXtTu7yL+26ADtK6Ui9gfgD3oXaO1ItMreqL1Lip3skCIRyWzTvfqEQ2xLhHzPu8HRNUQP3NMw8PYHYydtOKEtfQl0jGdMqwXqCROoVoDYhNANmVdnpptews0K6Hhk+u6/DyEhF4THDp4YOqhSHces3I1soYtetE6zmF8o8KjcLpp7aPyRFiyooty47IsuJlSdxIej10CRlFA8kr3m5yA1hDuUJHqfzh1Hv9IYjoYoIHm8A== 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=J0I4eHC7It2zetelmXV4UCVZgEaqiV1PPZw2a3x/WhA=; b=WBnoJniXUMAwcB4Ew0QtegEngoIut2GtP53KBpE2eKSe6cWdAeNCNnrWuma+4Ierlc6FlX3jDmSb6skq559CA640L4gE2vLe/vwu4ab/m4l56/jvT6SIsJNM/JY0FDwetqUe2GLIyXBBQ4cg7No+zjKJH509elyRIJMbMIm4Zfg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW4PR10MB6462.namprd10.prod.outlook.com (2603:10b6:303:213::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.15; Tue, 13 Aug 2024 16:37:23 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:23 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 09/14] xfs: Update xfs_setattr_size() for forcealign Date: Tue, 13 Aug 2024 16:36:33 +0000 Message-Id: <20240813163638.3751939-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0106.namprd07.prod.outlook.com (2603:10b6:a03:12b::47) To CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW4PR10MB6462:EE_ X-MS-Office365-Filtering-Correlation-Id: 889bd875-6169-4897-4f5a-08dcbbb634a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: JQ+vJcQhHm3ATBEAUEhTAarRthE9V/MaRh+go676iC0lYWzoStCMf+12JBBC008Xo5KEEbN3ig2s9d4g6suhVQvgMcVHSIYD6gYdoaJaJhbG1L0ywOLDTiGsHGRD5hxMazA0DZP4+57DOExdFE5HdvPyD+VKsQF1TwXBSUmXHmc4klkkUrY6pCoWXjz3DRbGBXCqULBWRc4swczmWCkDbP1CLYITWtr6yJNc3RqYcmgNYQCaBGjTkvxrsZcn876KTKmAsmU+tzaqmySiMaACHq1JhClUzrNhaoxbfKN9IwwE/X7YY77pJHelzN/dXFY0w/VN4PO3DsnA+FuMj8+HLCY9eyKakKEhtbuQpwWU0JOLtVb1scWH8V6Ti5VbydU2S6iTkEWA4BNhL0goGUKFU8XID1tWxk6ZRN9v87QISHUeooq4BxmsRBZuNvr2C7iC6AgKsZA8hKxd3MfaiN+uqqh7o7ExuRTH7zJhbx6H2ZbvnJwz423NkRqOx+ibFkht61KGTRH38W8+rvjTcu90E2CKL8vIVb6BHfVlPd3V3/OBZAENfYo35MaBxSzZiUD9Q2BnbyyNDln19titmwmfXomqm5FVMNZ6bScOcyQkj4SMDivTDHuHAyzxzZW8c3x2l45cOibSdaQ8Wu4KHYyf3Xst80j+bTKrGE+o78bnqi8pzGt3vE3csDF5wb3q0MENqN8ltQkaEU+oZE1InTfJ1NS4Uee8HbeT2tnzCUFOddq6IG1wAadOYesgrfCvZPguD67J/md0y7ONF3m3FbJIORHgB3umxbvalS6lhp8J0KA/mZ5Cx72xBeCrIRslAWMoiZVerDLrrS2EHHOW/64b1YDq1vSbx7bmkNZd0unjECBCyq62XcbNTl4l/c1k4wReOfM77xuui+0iC0N/M8ndjq/svpVvkh0jwP6oeD3fwxMdErNabVceV2p1kWM8Cd6QhOF2EAuS2HDrYop2/fI3YMYmmAK0QhWyEFTjG7yR5gc8khYvQDrZv/SJkSu9fkM2IPmHOeQSln7TBzJuqvRxh1mdxotWia7qy9/YaD6y55+GN7s1hVsSY881xT+b1pZ+usG+Ckl4NO4iWW8oqEQXkf2gduiUgeVaKMIIoGG02L+pIdlF04O/8C1Gu/+qYFNzf9DT8XRHPyUX1rFSKMdFs5z5+JuxKN6+c91ET6nByYeBkKmi77R/CVyrf6Xep8eqHifMu/uRJGJFUqcI9aW+xVCabR/q7pTddaBSIxZQeCHOJjMguA/2h+cnuowbZBRspZ8aCbmpUwSyFgVoVjo0yXnKGW5gR7R+/KqCmkBzasAV15oci3Pw8VL1bcOeOFgXzaMrQShhTIQxMFkEWnrsRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KA2bh2VtltfUf3356Lh2DNazMt7T9EG/d2GF0jcrcjtZP+NjjgS2TUQlUou5j7paxGQXLerrsDXgSLjsMniEE0QG+0jQbFtzcdT9otcnKpE6ZDBll6zt6f+oZuEwsuQUtwSnrM9GaX3j565xMrLL1GiST8fBMh13mumdCgTc8D4V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ginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 889bd875-6169-4897-4f5a-08dcbbb634a0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4312.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:23.0009 (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: mTrTxfEUQ4PnSbKaoTGQiKrTnfbJnC+koO/4OI5FxVA1NYOcTDjgGjJEZJX7Dtusz0zW65Lp8gI5S7cqtLZ8vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6462 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: g7Du_1t26b2ICkobVI8kMxI5nZiPx21Z X-Proofpoint-ORIG-GUID: g7Du_1t26b2ICkobVI8kMxI5nZiPx21Z For when an inode has forcealign, reserve blocks for same reason which we were doing for big RT alloc. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_iops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 1cdc8034f54d..6e017aa6f61d 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -926,12 +926,12 @@ xfs_setattr_size( } /* - * For realtime inode with more than one block rtextsize, we need the + * For inodes with more than one block alloc unitsize, we need the * block reservation for bmap btree block allocations/splits that can * happen since it could split the tail written extent and convert the * right beyond EOF one to unwritten. */ - if (xfs_inode_has_bigrtalloc(ip)) + if (xfs_inode_alloc_fsbsize(ip) > 1) resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, From patchwork Tue Aug 13 16:36: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: 13762276 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 97A111A08CA; Tue, 13 Aug 2024 16:37:36 +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=1723567058; cv=fail; b=r8yJb8MFHCPTWU7fSnBVKFbovF5ms+j5z1wZVReQVT5IzAzViBx1LXFH0hHHV5CWHUsjsjvb8A6SbJCnaZN9eL84BiQLVVUAE5V4g5jfbIRgpPLYhoecvBkh1zd30930B+m2OyHMz4L5o4W4uVfvBATOxyTV8ukl3e+0nYa7EzI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567058; c=relaxed/simple; bh=R4TNwoUQ34uM3y60oye2mjfs3Zbk9ty/bjQsfakBfbM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uu868aFiuZIWFvOmqY0v2Kz4nGiKThP8fD9ghjQKtsjkb9QyMeTxeLMFRdW9k3ate2sDl/tTLED0Vfor/9kcAASSEfXCWQKDQYB2dVPSx28XfhkBbJnO8hnBTTXiO78rwqKSAPln+GPFpYANpkmbDyxZ4/fQ8DkH8LlFptP0EBc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=d3v8UffL; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=i1kJS/L0; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="d3v8UffL"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="i1kJS/L0" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTHn021469; Tue, 13 Aug 2024 16:37: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=uogWhrXDWya1MOmagrwFqyvFD5Xa1n4v4lHkxGsQFL4=; b= d3v8UffLwyM3oxXUnJQcp0jo0QODLi4Zh1PZcgut8M7Yz7R5n/tnvvMC6RCgbFDe SHua1LFoZNimzAj7SGz8J2SCnYwrm9h4LdTg/bJnXQLAprBREAEs5Gy7hljy32P/ qXWNneHRt9UBwM4L/ck9t9TYDJ8sMQyYZqg9aVOtJTbYCQD+znRWI3xZLs22ErW8 /I5ygJc+rDh9+y5NGKteULkxM0IzEJBVhBxMo94JYlN5YJlry70IAljGk+fYX9r8 rlg/SlMmK+dXWITx7yuhUHcd1hxNKjAxY45buzfswb7L2Uw4m0IkG7DxIt6CkxZ8 wkU2KuQW9jQ1qq32kwQ+7g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wytteery-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:29 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGWvco017699; Tue, 13 Aug 2024 16:37:28 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn9pe3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nasw1ZdwxxK48ijUHGEm3EggSWyx2VhTUYccX2q6G9c+P5QvOieiiF81phhivnGHrV3RyADugQ+XyfElBml++u3WFvbUUZuToBhpVQRBelqYcvOxIBQ4tVQrf3Vvp5P2ZMjJIGcRJ+P5hD7efx1BM3OjXNRTAXa84AgFTUBDIqc+G4Yx14I0jxc21L2rpM0BHJeq8XyRR1Se4xx9F0SK2DAFhrMx/RXB0DyulH1Rd4kod42qiAWQJaPXRdnQQC98Anmm/D1RgSplwmWgyUdIOVK+zB9jz3GKwW7I5uiO8j3vIkaLE6jHJniwn4df7Wk3hQ5TYJnYTrI2VCT7RnNIAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uogWhrXDWya1MOmagrwFqyvFD5Xa1n4v4lHkxGsQFL4=; b=SVuBS/rL1WAYzyGVqaP2o3cnAR+Ft94MySVnpG0KrXK9dHi1nm/Z7yxK+BTiSxOhA0P3tagpbmDvhVzRbkdiDfeVMr5LMGrnP8xBQiJ/dZaGF3G16gOag4BpbmwgregJZK5j/Wi33HC7PWXGLJya4bf+bGcXzyicsRxx58deSk+OsK4MpXknph3/a2rvm+h8L+3zUamh8b5Q0VxnVExcr5GlAd2+2L8bVn8SiPvDMF9gUyiRaN2C4omF85eAtoMoNEeKCiBzHssN1jZh1ln7gaHrewziXxPSU6lQQhZRCb2x8wjIsdmLWtkwFHLtspqmkccVjCwTgE3ihfsZivTMAQ== 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=uogWhrXDWya1MOmagrwFqyvFD5Xa1n4v4lHkxGsQFL4=; b=i1kJS/L0knJfGFONtRliF5IhlKnstUFCiHjshFsbs0DkIjFWP+J1woLXdz+hbfYdFUq764A9eh1oROS6VGsH+hBYBiCWQUUdOp9xy5yI/FjBLKb1+cbvgEce2w6FPPJeG7tcqXtx0B+bCIbHAghd8fvwBVRVK0gg3fuzr8RDOZM= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:25 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:25 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 10/14] xfs: Do not free EOF blocks for forcealign Date: Tue, 13 Aug 2024 16:36:34 +0000 Message-Id: <20240813163638.3751939-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0003.namprd07.prod.outlook.com (2603:10b6:a02:bc::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: afa4220d-8034-439e-f8e2-08dcbbb6368d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: fjGa9BaDWzfM5srOlWqUiHYlKTQDxsbMWIFiwtrqjNPRAwMmyLbrk4iqAlG5cuxC9b4X75Zjyygm3te/xy44jLcGaDMD9EhXAH6AzA7p/9HIy1oT1H6uLh3+3RyfVAw2l8yMBR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xAjeVoa6BrmOsMcG7GdcYk23vMpeaDPMmMchOIKG+2pfK8xfv1s57Ht4SR0VuxEJA99vvErPMxz/hCkD7HBrLc2PPOXDi189KQ7inGjdk65rb2POo81aiinFIM+Ma4iTvrjlwObKm0wGmZx9Qz1a4QnedSfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9ag9TKPQOcwceVaYZklCnM3vlnwbRc8jYwUPqmbEg+cOQ8rBU+zbcoCG8y84/JIIO9pQXYJe7s94MKxf4yR9vVjGlVhl9NHkkgTOlVcwDs1mJZGegmBRjsCq5up/J5UqgodDEomz4BLfxr+BWEhs4yLm8ZMRzGZNi5XvBWQH3svcXPnP8OJSjjKMZdOD0ITjBd5Tx+xdCeiat44o3Ge8zNe+0NHq3200C/qDgUni+2LcHChQ65ot1ivf4itSxhe2p6mHgSfNG1ehi42vL1yfnJNfP1NEpdiWnJN+3dg/9gJolZeHttRfRmeUrngK2/ocbsPeOn15PQWfl0Tnb14r5fsIAD/rkuUulKL5rKAGub5kxzNf7W6oXLoQr0R2XX8SxFiL+G4/SXv1ckawb/5pN9czPMvf+Ty3qvU/s2rHTXcMcO09FGaUOu63G5+YlVPaOG9WpGLScXeembB9YHP1/ZGJKhyfbZ8s0p0y9gNSGdDmb2sSFx2VMBvE4TgVmeJptmz5WVpEZaEhZqQXtipBtD1fncXrp+piISNnQbBXiBG1p52cSvaahPSX/MihIUat/cnFcoWt8EgDB/CPzBkrrNOXZc5VqvoV419woXmFgvt+cEe4HvkoCBzvPWBgsyxcTP7oElZiCjTXFxBGwMYlwF6CX5l+n9KtFksRL/Mr9Mv8xaariiCV21IGPQfjRVJwjiZ4P/3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blXjH3dXGm4ZwcSKOvC/UIEVYImjJ3dXV6uPcluDA/WpQ/HZ2oJZtMCE0+ROaVUIWeCqwvjK9VATw+KeTOLbH+iFT2C5Oc52hv9zpb7cWpOTcngxLK3FbG5fJXd4ByWKtTTumn8Uyc4BB/xXbZH7V9GjZNATNdT4pamB4JPL5HoiGyGVznHnb+fahIqg6fyjQJLDJZ0uaccf/gstIjjepr/9GwfwKBGcxrpGT5TTFg3CLqZV3APBIrvcR9UQzyhbMLn5n6bdhIlW9m5vMD892h+4Zy5nszYh8ACXGIt6eoPxbFuac89bC4yeqL1hr/gPwAMMiOlkMbNbJOEay5rpAysfa/zBbXMmYdvKIE0auzNaR1v/SwMd+KeS5V5u8mqJIqt4nMwMUkCVFjdbyuVbmcsaUs3IiLzMkk4ykfUmQEmmpyp0h3vIjYwNSOkmR//GIQ7DMuokw7xsmM9BU7fZ5errkSI+KbdQYe3yR+M0i0awGMkjxZmK5dAiiHP1d1p48GguyG89+nL0EU1/g631pVRuE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: afa4220d-8034-439e-f8e2-08dcbbb6368d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:25.4900 (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: o0RHGQ3eX2+AVxf6Of67/wnJU3mS84e1heBbRRd2KCyiYkpbej5JrHZJ1J1r1dMomoCL65Up2R+lZwJ+AxLWUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: B0IlbtRFsZRFG8SyfZKrMIigGnS_MekA X-Proofpoint-GUID: B0IlbtRFsZRFG8SyfZKrMIigGnS_MekA For when forcealign is enabled, we want the EOF to be aligned as well, so do not free EOF blocks. Reviewed-by: "Darrick J. Wong" #earlier version Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 6 +++--- fs/xfs/xfs_inode.c | 12 ++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index fe2e2c930975..7a51859eaf84 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -536,9 +536,9 @@ xfs_can_free_eofblocks( * range supported by the page cache, because the truncation will loop * forever. */ - end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); - if (xfs_inode_has_bigrtalloc(ip)) - end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); + end_fsb = xfs_inode_roundup_alloc_unit(ip, + XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip))); + last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5af12f35062d..94ab3f4d6cef 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3129,6 +3129,18 @@ xfs_inode_alloc_unitsize( return XFS_FSB_TO_B(ip->i_mount, xfs_inode_alloc_fsbsize(ip)); } +xfs_fileoff_t +xfs_inode_roundup_alloc_unit( + struct xfs_inode *ip, + xfs_fileoff_t offset) +{ + unsigned int rounding = xfs_inode_alloc_fsbsize(ip); + + if (rounding == 1) + return offset; + return roundup_64(offset, rounding); +} + /* Should we always be using copy on write for file writes? */ bool xfs_is_always_cow_inode( diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 158afad8c7a4..71acddb8061d 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -643,6 +643,8 @@ void xfs_inode_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, xfs_filblks_t *dblocks, xfs_filblks_t *rblocks); unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); +xfs_fileoff_t xfs_inode_roundup_alloc_unit(struct xfs_inode *ip, + xfs_fileoff_t offset); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, From patchwork Tue Aug 13 16:36: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: 13762277 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 382061A0B10; Tue, 13 Aug 2024 16:37:50 +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=1723567072; cv=fail; b=QRUyUeH+5gj33bg7ynbSksZMGZycLKPBUVDOEeEL7ViPlAAYV/Xy1LbuHhiyXvz6eUoVUFfcUkDBsISxX8tHTmayfk524WTuvijHCB4wCEVxs7gLiJXtNeXU2wewxpL5CA1KNYWvB5x7OgEB7Em0Dx8VdnDOpRanAXzJ784HERk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567072; c=relaxed/simple; bh=tvOBFkmA1FSH3Iqg041Q7GR9lW9fWCOBVWJ/k/fN5KY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pBvp6pP7tbfWLXOVVT0Z74aMgZ2DwLEkUkDZUb+Hk281ofGQgFdYTfWmqkW0VKgiA04Znk8shxBhdZnuMcWzxYICO+gvfdqxs3BpzhtNhlE3CtNC0xWPca1bQ3EnmfAXJ0WmOUVlBvVnKgTOHxiLFTf3NlUHWhmeAyo+PNRFxrE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=lZt4bXWp; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BHOcfzaE; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lZt4bXWp"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BHOcfzaE" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTvX009742; Tue, 13 Aug 2024 16:37: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=BCdyY/Ypi+YgB3nH62tJoJ8Jwr+RIHWi8YBMqdImZ+4=; b= lZt4bXWpV0sSRAYqjkPcXDFlv40p/0YlajaSM8Qe44PhKUnOL8WGd75GHIN3n8Qh C9HHa97SvLP7LmQ7Uog5ni1hiZJ0AU/6ONSSFnRl3A5PZyXwh8i9FsZoPCzK99+m RTZhY0dcVBaua7TAG18SH8M3qx7yFhGfNzLumgPfO9CE8wDj3Rpma/5eVFmcB72W anBP0tjpflrHhLMPiHgtB87fQ8+rj52hJVccHn+Clz1lOOsJH8Ait4nGhSDqJHQ0 jxRWQvwBW5KyiusuAsWMUQI79quLCf2kfEFTMAb5TZ/fsdTFKEpcdpvsXcfWWOjf 278rvNqhRaZ84niXN4SHqQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy02xg3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGH99G001485; Tue, 13 Aug 2024 16:37:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8qkvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=goXWhKKv+iNjheg/a+RwslB2hywPmm4iMD8teYkHszS9LdQ88nptJbrQDylMmknL4fYyDxBkYGplt1u3gtmQnRbwLar4HfKFMca3AoJrXEARoOrlwYu141L2kZFgqeaCN3VAyi/Qi5zAHxYTsjDXSDh7ffZBOuhCJNaue9aeN/WZHn4ya0KA5V+G58obiPElsUo+6o2BE2ihTavwTLolTLmNn8UoVLerPpWRfnBaLxj42UzAtfKE1xqS6lVNvZ+Cjv7ywXUkCk8sDd1Xe9ewQbYLopzzsAwn/sHZ2o8u2QuhUT+BkpnvkcTcWAE0/iAadmJV6Ge+rV0RGHCrgBJyAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BCdyY/Ypi+YgB3nH62tJoJ8Jwr+RIHWi8YBMqdImZ+4=; b=QtOCvpUSHDD7y69pJ4HWJ1tAOH/wWx1QRI7oqFb3DDjhr5SsSi70PZvycWw3VfNHTXbWFbF7kTPDRvtylhQdgszqKqy88Zqh25Il4RfXrsFu5pPrlTvjQBjSfLA6oTFokAj+k4xSkVhHJRwlle478Cjk7ropIe6/IOIpsXf6W4ubhLK7kn93ivV/aMbZdP2EXqJTBaUpuRIGENe8MrrP3igiki5BAlfA8pXrnFg5iAAvw4L5FnGu9CfQz8NbIPs0jQF0OzBGegO/HlzvBCZ63ZATPLVAavni9PJuuNyo61Tm39bZcZBVEDkrHFPTPUdT78hn6EXNmz8+Jc+i3xyqFA== 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=BCdyY/Ypi+YgB3nH62tJoJ8Jwr+RIHWi8YBMqdImZ+4=; b=BHOcfzaEJC1C1wAmEHWJags5v9AI6aIJxyft41Qxqp9pvHuQt1A6LlgBu1cB1321lq6OJySdTl42pVXGAi4mmU5YayjYZa2lO6KeCRcxWOcrdDrZpCNNu/zN/cLMNqGS7SErfPPXvop9nE6iM413UH0mG4SN8vS7Tst1zmjjC6Q= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37: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%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:27 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 11/14] xfs: Only free full extents for forcealign Date: Tue, 13 Aug 2024 16:36:35 +0000 Message-Id: <20240813163638.3751939-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0072.namprd13.prod.outlook.com (2603:10b6:a03:2c4::17) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: ad1ba627-714c-4d72-bb2c-08dcbbb637fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: h+tyW6xUKTQHu5TdZSAIEu3/5deFhLwiOmfjyLs1njC4+Xn6MQb5UTTxyMy/lkF7bhDU0ApVCUthqVaAumwKguo6ZcIhNaq40fxDL6IU9Rj/Z+63WCCQkjRuOQcXZRjnNeORfzfYeBBKJIRm8vbZZ9JbQtqjm3MkChzgFMPrF7M3Yvego5VhS/ewdZdOhRFzZq81oZ95a5TfGnKmB5UUriQaYdj3Ab2Nu7P52YrmpljQV6aG7YUFz7sFi30QuJZVPmkCNr0Tp/sTCDFbx0cZDAu7qtjqjb95F8SuGiWJtIvmRu7C3b3sVVKqLGfKT79Y4fcWxZjwuLcBzYjE71su+NBqazwh6qUkHfeZ2Ptpahtb16RL94uAJmUBaB457O2SQ6kPEbRC4W6SGiv/E36N87ddtjYVDHJ8rQS6V9fOkV8ofNGIf8PFpWDgPcvT89zmMesWbGu5j+Qs0Zcy9bAC3damX9RlyVNSRbK8JiGxkfGqfhIWvIi2zSshVXUYq3EAVHUK5JyG866r3qw7mBZQxTFFPfbE1IFQH/oD4Z7W8gOIaqdwIPBPSbAQY9gM6w3d0NhPf+KjIiN7zKTRDARxMM/8wCjr+WmQp9KELL0RDKGgn1NJfmhqK2+5eQ+9abiwQYu+x4VfDjLYViTliy/ytN1jEzrumcEvfQopV1+gvpFESsquU4P1DRyUZ6I7TbdU54e2N1NfuRVdVP9JMPhmHj5aMc8xPWU+3QSTdqhAebskDLeOEMeoKQ5QgDFX9Ko5asjFReMz+DCPMRLxhqLGUsKnt8J6z3TPuUmvuOsNei5HI7BQJhWkmn0lqq6sm/IKUxtAC4+WME+QxwFHadboQiY3fxAPOwg31pwgEcF2hbRWOph+vV2/Oe4deNE3Q3M2SjPnrjhpHaXtqwJlnmgn+28SxQ0EjReCG1Hy0Y0AUuiI5gHmMGypvBUFJ+Yb0p57Z8LmSu/7UlNViG4asTcXxmCnr39Kk1dH0DNAd3Z696W4eYQ0yO8xUk/cycs+hluLYeDbvTQHPSnrOiZfAHyBeLsF8Hn5wmTwyVBXjhSMR42lDJiF6e2Gb72pyeTobtAZ75JGLBi1FwCAyqdqlRlihJjU44yawaxohJcsmANO9IPw8n5RBGKn4NoHfrZQk1KMMwakq4PmfUonK5T1i/fYXzLxb7QZ7F91edy7MZg/gAJ1f3QCVBC/6cD8ltwB3IyXxzl6h/SygNcXvA7tgBOIw/s9vsTQ7idfLKPQEbqkiVwdtWUiQ8IohKw0X7KjtUcP5oG3epCIy8thoQWqLdd1WvtXTVgqByI9FAAZEeF/U6JITQp0gULcNzrHAqRYnAIYEdh2vpdmgXzCNN9/TixkLg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zW4x8J4s2gcIutNA4jNF+/Pj3vEEL4T0/soKUegja4MB2HwEBlHUq3szwx6qMJa8eK2MmTesBNYU1pQoHhB+gySzFvoCKjeXrGS8dFedMqLVVajH7i36C4//w0jLFZ3lycCNFhbNASmUV45sJU9Ud2LE/Nb8Yw5NTp0a5wOE8CpaODXM6msstX2omBwdM6pc0OZGo/sYr5xT1i7hnLky3TxZ80RRQz6EO/AVS2YOAoKvpUTa+eqK3Jo5oRIozAJjHwt0BmD/4GhzKAR+Z2jqxWr27iaUnWUAyWQ+J8A7xCRveK/cO9k08Tgx464AjCx1XjAlFrMhv6k0N6tTi4zFhsjhDzI4Bk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rxrhKPXpAVrx87zu6hrwKgdFFDftZ5dp9oLhQSawaxd/har26VKzNO3Eq1iUNxrc035CyLK5OOz4sekwje9StRuDsjckaHiZBJJ551e6FPPkVVtb3xqM9o5i2Gko6Xnf4WvJGrpFz7RKcMBEFgwhdkSXJEWgA4TwePe9VZThcNyysKZTRCYoffsVpX3rc42Rr7mvQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kC4YomEuK/jIvqOIe+YFOruGdcihcJy5weAFbkXNDwMhivvb/jyAzM3YWDK9lBUiwEEN9d/8E47ana9Ykme+jaKZeuIiv5hD0vaf0/wE6Pb0LHCVKpTbzdsbchmOERIaLCJoR2q/BioYDZPx4l++3scUaoQstjLDpUIkwGnyeMkvQs67u+wTNEXvvxuSryeamhE40zk8R4WZMCRn9zX6zbkwknwzLeVVSNjks2uxGLqkj5fh5bfAyZdraXX85wOwV74CFk5lM7iX3N1BIgXRHi+JALSeF1+PjWPg3SeRxJLCguQ6ZRw9tk7L1KAYsrQL0VWrQGx7lYI/gxWcjcM5sNFA2/TY3MLdiP0WqArJt9bcZd4iySJ0QDX1pHYxdHzoDHkrM6VEPkiC473ZyFiy32lYOa2cbcahNmP+qdroy0WMqSr/+XD4FZ5SZzoyeE3+tJlEtEr08y40kX6+JjuXlP1egwdX/xVGdi+Wj+XxKATdk4NnSMHKoWCN1wLRz2By1s7roovHXB0ImkX99HpZwmdUCQJixycsvAa1qwRcAwp4sj/DKwZyA4Xmj7aiENgG43V8id8/RA7tdjn1IalsNsIQprSDpJUYwb4oRtT5fv4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad1ba627-714c-4d72-bb2c-08dcbbb637fc X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:27.8823 (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: AWvXsJGrOeqJke9UZUXEjObrRxbJ5gsXLATlPhiMA62s/tLuYQVYqAlrOsf9R2L7xxQRovDkdesXJK2k0u56nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: UGQDCkHBaLQftarH04UVEhh15LM50We8 X-Proofpoint-ORIG-GUID: UGQDCkHBaLQftarH04UVEhh15LM50We8 Like we already do for rtvol, only free full extents for forcealign in xfs_free_file_space(). Reviewed-by: "Darrick J. Wong" #earlier version Signed-off-by: John Garry --- fs/xfs/xfs_bmap_util.c | 8 +++----- fs/xfs/xfs_inode.c | 12 ++++++++++++ fs/xfs/xfs_inode.h | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 7a51859eaf84..317ce8947e8d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -851,11 +851,9 @@ xfs_free_file_space( startoffset_fsb = XFS_B_TO_FSB(mp, offset); endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len); - /* We can only free complete realtime extents. */ - if (xfs_inode_has_bigrtalloc(ip)) { - startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); - endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); - } + /* Free only complete extents. */ + startoffset_fsb = xfs_inode_roundup_alloc_unit(ip, startoffset_fsb); + endoffset_fsb = xfs_inode_rounddown_alloc_unit(ip, endoffset_fsb); /* * Need to zero the stuff we're not freeing, on disk. diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 94ab3f4d6cef..73562c6f9a1d 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3141,6 +3141,18 @@ xfs_inode_roundup_alloc_unit( return roundup_64(offset, rounding); } +xfs_fileoff_t +xfs_inode_rounddown_alloc_unit( + struct xfs_inode *ip, + xfs_fileoff_t offset) +{ + unsigned int rounding = xfs_inode_alloc_fsbsize(ip); + + if (rounding == 1) + return offset; + return rounddown_64(offset, rounding); +} + /* Should we always be using copy on write for file writes? */ bool xfs_is_always_cow_inode( diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 71acddb8061d..336124105c47 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -645,6 +645,8 @@ unsigned int xfs_inode_alloc_fsbsize(struct xfs_inode *ip); unsigned int xfs_inode_alloc_unitsize(struct xfs_inode *ip); xfs_fileoff_t xfs_inode_roundup_alloc_unit(struct xfs_inode *ip, xfs_fileoff_t offset); +xfs_fileoff_t xfs_inode_rounddown_alloc_unit(struct xfs_inode *ip, + xfs_fileoff_t offset); int xfs_icreate_dqalloc(const struct xfs_icreate_args *args, struct xfs_dquot **udqpp, struct xfs_dquot **gdqpp, From patchwork Tue Aug 13 16:36: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: 13762278 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 49C3E1A2C02; Tue, 13 Aug 2024 16:37:50 +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=1723567073; cv=fail; b=uJGHGlL6jyEtj1oIkkkR3G/Pymgiy6lfmWexc/fjSJRTlHLXcA4lBbMH8A5OAeRVoA2tWft4yzFaHDJlFeMciDYkQWVPBqyMa42zMa3HdaA3K/tDlVavY/S1DYcbE/CanTTVRz25BadzrKYPzpmFnlBG7ZuxOlL8rSgWkMhIVLU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567073; c=relaxed/simple; bh=J7nW7NGX1C3BFAJ/BjB6wyd39e6bDxHVba+UPYW4R/k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=P0txsJFboPA2ZA9fIG+63z9N67iB4im33i2y17HesJEeXS/DFELf4LhiP2n+Bi0e96jaA44EyMMXNH76qxWU/lFf3tD5zNeoCOIipAtN2LRQVby1eJB7G00jugSqKWqdVh5fJNSze/2kruD/GgRv9/rjg4brmeXHK7oai4PWd9c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=gKXa6UL3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=JJaiom+d; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gKXa6UL3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="JJaiom+d" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBSW9016458; Tue, 13 Aug 2024 16:37:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=x2Y9J1eaCYNgKkvbgENOkf+92iOUJ8DTF29UgVZMx9o=; b= gKXa6UL3ul5SwKK88ShK1lVU101IgW5kH36W5oKnRyJkxDRenjQiD81ir7F//5PJ S3QEmS0IhJhhNGchfs+shCGEPoPbB6Ir10Pqs/uNY/iY5G/htOVPgLzNeQCimn4p rBx+JM1MuoLGZh7ZwgBhg7xokXpW/duXB4X/grwIR1fB7o/CQj+Op6VvjAR+uxlA KFe0xGbc87TSKfXeJVBwO0IBOtUS+LsmvWFo7T7Iu14zVKqhCMg1wsrwbJGGWDTb KQ/arZH7K/YY6XcpoFwjBCPsIPni+Y+MkTz5U3dFdGrsrQUVhAg3K/CdiEm4EiU3 ePed9DSR9zbiRqAXmqtZKw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4104gagymy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGH99H001485; Tue, 13 Aug 2024 16:37:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8qkvm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eN4aYk17IIsdPE+V4x6mzz1VbvOk33M5PMOFjqSLOv5bdZPXjbyz1HAxcz9ZbQFL5Z55dLxh1B5f1JnlCegzR8vrkuq/WvpAshrawPW3VKehT0IRH7SVJt1Y1Ya7i5S/+vsvG97PwFlRpwIxQYMARCc/GJggx1DFdz0uz/A81hNHfqCssMY/54RZ5wCO+v7VZIGwcNw3wkNY9fBJ6yTXOAms/vXrz0wXl9rcBj2z4CO5fVC0GT+5NBMRZ++3c6pGAjm0z9m6PnldAzd6sWs9BD8ifBbL5SqafY/4w3+X26A1afgekhzwvP1+B5qxr8lcHwZRJLCf3No7o0NIPSnh5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x2Y9J1eaCYNgKkvbgENOkf+92iOUJ8DTF29UgVZMx9o=; b=yx1W5OGPSoffCD9Sb++JlGgXTMxXEjOH9gSk1TaKZne8PzHJLL8TYHPKBBYN+Q3LJrtAUXCE2eYNpAtkUA9IjDpzcyHs5TCm2vILKTrYq0WYRF7ZByp/9uD0Q1cSXd/O587LKRTViZ4Bk4zcP/aXGOEvnEy5IQwX3j1fr1izlnOw1WPRsz0GpfCoswW2AOhDiL/CsLDjhQHDrbWEIW6zREOntk2g4pdDAS2ymAkw3emEV+CQvD2CQpQ/jlNvx6fEI2PSbovNcehKjslr7jhfa0SMIJDVGzdMtYnC7SHkcbV+JXqkUFOgmtyYyamDG2bf0/rrnULSTzinG4aRa/9m+A== 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=x2Y9J1eaCYNgKkvbgENOkf+92iOUJ8DTF29UgVZMx9o=; b=JJaiom+dc8l2OY8JP00HvTBxQD6U3ZaGWOQBNEXnvN7q/JYxI+ug326YOjbLRLl0l1y1Z6PMZzP86h7FEkM0lY5c5S8FGb1v8jeKSf96HxSXWm490kdfBFAKhLD11hykGtmwCd3zITd898O3/zuHNFZwhIqtbp28kYgWf5xcazw= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:30 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:29 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 12/14] xfs: Unmap blocks according to forcealign Date: Tue, 13 Aug 2024 16:36:36 +0000 Message-Id: <20240813163638.3751939-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0143.namprd03.prod.outlook.com (2603:10b6:a03:33c::28) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: c307448e-939c-4d25-710b-08dcbbb6392e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: LGPfUNMGJqyd6CinO3yUppsrtlXrZUBzw9w5fVgmBi2MgbSRBFff9FKDNvIS01WaN+q8QtwPGwnb6LJHj1LQYR4sQrMqaU91xaU01K4KerZy52hp1j2xh/oPwlRJioCnI0dk6sEsvQ1/lZIhuwNwxWxoMZIptQElhyTASIDsY753b86Y/EuNwCBfuaHbkoxgzH6BzgPjteWE1smg3JnZH1Hl5KZBOTI/pNHmpGfRRr8z5Irp9BM3v/h9WvBL7Kn/QKkCMWggpsMSKP9REr2SOZIiRKIyKrg6vLP2NRtKwmEVOJDwtaYdPFNl7Lct1uXt7AsWDqW0i62y2to3aau9xy2vZsFrQxESXzfEjKnDyN/9/CBQ5j+lfn5l+uEc7YZAugHx1ALqsBO4jmI+7qmGRfYOx+Ub979K2nJz6sQU88dkXWclu2r1Zu1S0GcxcgYSHCB3sBgMOmscwq8MeLcuNCw+ig02fAOlwa3vjCtRlgD8KqshCM+ZR4w7JdksLvgFz5XQaw4yBad+vJH1d90EJfELnPMtKaeYe4ZVbzHxsXhvK01MqqC52etKtlQC9M8hj3ZygdU9ug+1KUtm8HBjzjnE4gM3j7quji4BslyD294xCDmFo07SsfToEwvPC9kpL5BjS2prbd8fFWb3+FF0gmyqU26tNYjkEu+UkZ15gxgqQze7yQy8S8xtTxiqimE3A5yn2j8IZOmWfluMNksi0JNAhUcMTUYcop0sGG1nj6ElVh+T3ecUyQyaJdAWGnC18qYhU5MLDnMX+wYUGSVmRCpx10//CukpH5LWYEfJdJOOkxM450GXUO2Bp5BN9Tq7ZJgx+dYadp56kYEQPvKh4N4f/kXC3CNZ+BqD6K6P9gU3p5NHOsQ34Lf2+XOt0sovnmWVTiR+tjmrzDYVeJ0AQhTni5Sx6u0J19MkksbjOBRDlA/2LsK8Ie8auQ+kmmlQpxLfNOn4Y4UT3ryAs3fYU8yjqzKe4nPWzs/c3bOt1yOxJdjpZtfbg+llzQveOad+yQJVXyVMKrztLm+3vOgqngi0vnIYQm+bBEiNopQlHTO34kyFDbvgDIk0tai2AXdcT3oGQ4OwdTBeGrbCoL7esMTWjtFajzhEKkg2YIzJg9lnKqoDo+4SCcnJjJR3Zf4B42qD97+Z8E+WKv6mdBw0JjiPjEBKgoJP+35zRTpkb9XUC2uHPJFCRl4lHk8ulcKRvtsWCOZfBTX5Kj7BGMM6hjNDjAWcC5PeP0s7pVwr7GW44mR0mWtbUZ+dPvOdf2bIMagUEwE8jPfrOc1olKth7zy4VqJ/6+d/ejoQ048A4G3PCbm9biyCG3/qv+PSaRMLK0K7TMa3/eRLnJsVY371ug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C1Wu+xqBQr7Oj9xK8idjCSNcxRgzDs8kcBufIhFwoaVLlPk2fdkYuy/rOXm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q0MaQXQJv3KENRBAIN3mZXQrj29D5/FhjgBBFYVof3QmO0VGHED7wniblNwcZ2GaaYA8bVu37gCP3MTf5/3BDABe3iByxvIji1DeH0Drwc40RJeJAhBDG/ppDkk70bAFvJsQfEQ0GDXBtUuEIhYjVUMaYlkxucajCtiBZIvM9PwClQxGRFd1IRubVV/uhjN4Y1UXermMKRwLUkCeypW+AANJZzhpVibC5rVYN4hCBSHb1sZrabxO65xNfRBqAK8wencYkzKeutF2KjIkBzg/VHCIOkiXNOZVigo/AU0bA8BT9VYoUDivVXzVRFOez21B983CUr545xR7g78e+4ct86utw+hq2uCYDVeuxiqGrGobTR7YXQV6gC2CYO8UWpAAmPBVJVh335RRlljuwXSIGdUDREjh+j1lSuMYbxMTIz+qRBgV7L+m+13/s1+gy0Bo6khMm/c0VfufhgleXIN3h7Poh7e4yLMQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: I7VnBZhIYPqA/qXRgYe+boP1f+5d0fjVC+OnOydB2Z+/jpPXgqCql+L1mdrqwsXscqBJAS9+zmkQdJIwP7z3mx2uJIFQi3f4ZDm6dibruTOawIpQCADwuljMjO7vTqRa1YgnzLuV37AXDotdm41dzbfPU8YB5LB0aMMbKuTsn3z+VwAniaQuLcFWWyDDcDk3gJUwazHULOWgQA7VS5gaCHbolTngdo4pRPtRy+h19/VpltH0mf4mH0gQJGWeFkb/BBKnYEsX7zrxb8avNCyi9xEen6uOnIt+Px+cf/KmQBvBxhGANIbS8DdOBep9LkaDVAPtwND9Mim9wzu/j+ubPse01QeiAAS43x72HFuks2D+EySexiNIEluIjo0zOMzCHzKS2CYgne80t9hX/WTPzZzLJFdWXckxcdGhehycGcqbUWK7LdRDbE26xpBCNOO6xaSUEhDaOJF87BpjIFRJm3bClL0HbjYeHbcX8PeXwH76oBWGszL7euK+HoDoC6Ay6PYZ+XwLd82bvgf+DPOKJQYma8JGtsfMk+3Odv5Fo080UBtuk2AgpNgUzea1+njX5J/3aLU7tq8fkJdv9LvW194hAQXNX1GiX8TGEjb2aZE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c307448e-939c-4d25-710b-08dcbbb6392e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:29.8925 (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: z5acMMlF/JTE2tdiRxZSOvVCwONQdQQ5krqzCC99OJXAGJEIEASEDpSTW5y0hA/Dr6WKuKjfS+A4ziJTMIHsTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: 8Wb-OMpPiOVjq91gEWtLKRukE9jkF77e X-Proofpoint-ORIG-GUID: 8Wb-OMpPiOVjq91gEWtLKRukE9jkF77e For when forcealign is enabled, blocks in an inode need to be unmapped according to extent alignment, like what is already done for rtvol. Generalize the code by replacing variable isrt with a value to hold the FSB alloc size for the inode, which works for forcealign. Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 46 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 0c3df8c71c6d..3ab2cecf09d2 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5409,6 +5409,25 @@ xfs_bmap_del_extent_real( return 0; } +static xfs_extlen_t +xfs_bmap_alloc_unit_offset( + struct xfs_inode *ip, + unsigned int alloc_fsb, + xfs_fsblock_t fsbno) +{ + xfs_agblock_t agbno; + + if (XFS_IS_REALTIME_INODE(ip)) + return do_div(fsbno, alloc_fsb); + /* + * The agbno for the fsbno is aligned to extsize, but the fsbno itself + * is not necessarily aligned (to extsize), so use agbno to determine + * mod to the alloc unit boundary. + */ + agbno = XFS_FSB_TO_AGBNO(ip->i_mount, fsbno); + return agbno % alloc_fsb; +} + /* * Unmap (remove) blocks from a file. * If nexts is nonzero then the number of extents to remove is limited to @@ -5430,7 +5449,6 @@ __xfs_bunmapi( xfs_extnum_t extno; /* extent number in list */ struct xfs_bmbt_irec got; /* current extent record */ struct xfs_ifork *ifp; /* inode fork pointer */ - int isrt; /* freeing in rt area */ int logflags; /* transaction logging flags */ xfs_extlen_t mod; /* rt extent offset */ struct xfs_mount *mp = ip->i_mount; @@ -5441,6 +5459,7 @@ __xfs_bunmapi( xfs_fileoff_t end; struct xfs_iext_cursor icur; bool done = false; + unsigned int alloc_fsb = xfs_inode_alloc_fsbsize(ip); trace_xfs_bunmap(ip, start, len, flags, _RET_IP_); @@ -5467,7 +5486,6 @@ __xfs_bunmapi( return 0; } XFS_STATS_INC(mp, xs_blk_unmap); - isrt = xfs_ifork_is_realtime(ip, whichfork); end = start + len; if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) { @@ -5519,18 +5537,18 @@ __xfs_bunmapi( if (del.br_startoff + del.br_blockcount > end + 1) del.br_blockcount = end + 1 - del.br_startoff; - if (!isrt || (flags & XFS_BMAPI_REMAP)) + if (alloc_fsb == 1 || (flags & XFS_BMAPI_REMAP)) goto delete; - mod = xfs_rtb_to_rtxoff(mp, + mod = xfs_bmap_alloc_unit_offset(ip, alloc_fsb, del.br_startblock + del.br_blockcount); if (mod) { /* - * Realtime extent not lined up at the end. + * Not aligned to allocation unit on the end. * The extent could have been split into written * and unwritten pieces, or we could just be * unmapping part of it. But we can't really - * get rid of part of a realtime extent. + * get rid of part of an extent. */ if (del.br_state == XFS_EXT_UNWRITTEN) { /* @@ -5554,8 +5572,8 @@ __xfs_bunmapi( ASSERT(del.br_state == XFS_EXT_NORM); ASSERT(tp->t_blk_res > 0); /* - * If this spans a realtime extent boundary, - * chop it back to the start of the one we end at. + * If this spans an extent boundary, chop it back to + * the start of the one we end at. */ if (del.br_blockcount > mod) { del.br_startoff += del.br_blockcount - mod; @@ -5571,14 +5589,14 @@ __xfs_bunmapi( goto nodelete; } - mod = xfs_rtb_to_rtxoff(mp, del.br_startblock); + mod = xfs_bmap_alloc_unit_offset(ip, alloc_fsb, + del.br_startblock); if (mod) { - xfs_extlen_t off = mp->m_sb.sb_rextsize - mod; - + xfs_extlen_t off = alloc_fsb - mod; /* - * Realtime extent is lined up at the end but not - * at the front. We'll get rid of full extents if - * we can. + * Extent is lined up to the allocation unit at the + * end but not at the front. We'll get rid of full + * extents if we can. */ if (del.br_blockcount > off) { del.br_blockcount -= off; From patchwork Tue Aug 13 16:36: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: 13762280 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 E77DC1A2573; Tue, 13 Aug 2024 16:38:50 +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=1723567132; cv=fail; b=MBWaAEsQYxeUA2E5YbWt+6BQnUEqUcrGfJjeTwRIhKnYfJ+eqmg/8yT4w7FU1EK+fWdLpTBr5YkpTp5D8WsIlwKOogPNpRBrOqdp20H0ifyQ6Coy5Svc0ixIDDZKZ642DckVrlodzxNGuc6g2eXbwPyBvCBRBiS8HFRnQYmrIig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567132; c=relaxed/simple; bh=apTMNsmeaZFfv/vSlTANpdyw7UG/LQSLKvpB8RDkyX8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Nmr9xqq9Ftjfh7XkLCvAdqyL77h6Ejrkk0QiqhGG5jhTDfceKJxdzUenfB4sIEkyTuHWbndjkzuxC9puQzT2baumshe0io1CP5dLrpLhBmKvR20UMv+kCZ/Zz6d6U0E5LBBMg95q7EXOunz749gPBKCawuQAvxzCsaNyJJhVM5Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=iOYydids; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CKhdcul7; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="iOYydids"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CKhdcul7" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBV6Z014971; Tue, 13 Aug 2024 16:37:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=SOK5U9V8dVJ4nSPTW+vPt0P1ozrq54R9NP0RfkIwwrQ=; b= iOYydids0F1u/MjFJ8hlddoK/qbsBYo1u8SlaXDVuVmU7NK7kY8qYU8jOL4x3LzV B+ES0CxO6VwCGqTQSsDPKfH02HwcyYR1sNF8AJfE/n8RrJelzY4EdwHqxFv1Ii7j uS4K8oxP7FcePJYsCzGF0dtD9JeQE1pHTOErfWtKhP35Om7JG8MIYLD8zYbX3L1X wDSzhQCe/yidYnLu7zOQW2eap9ldZ0m5fix7nliwYvCWbfYV+eF1QnESLO2UoZYS tNFDnAHUKdwBoNzKJ7WbazBnx5G+AcFEfOSLAtu4mtcRjwWMvg+TJtqYJBzw52x5 RnSlFRbSXixav4QOuOoB1Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wxmcxans-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:43 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGH99I001485; Tue, 13 Aug 2024 16:37:42 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8qkvm-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lydkyUtz78hdoGOaimSHusg2Nfx1dARNpUTx4oRNgjFHQ9MsEjlcqRW6sfVRRKd3vPgvTTMCzUYcswEgY+Mge52J0UrlD/VCZqgh1IGdVXVyVbTNJFCG+Cgcw8Lw1v6tP86bprUyXmWaKsWEsbETbZ6MXcCjjB2+H0GpHSeQ4oSUAN1bO1mr1ao231iFdPwE/jXddV3uk49t2JiCIWpE5SAoCRLy4iutYTro5hGaXOyA8iPEr12hFs+5IOxIMfCRuS4OQRf2CUV+6GYeN+HX6TgfYPJBj3EUo6U1T6jnS1ipvrBptyygsyPmwexpdOk0FvZpLE8nrxDZnKjc47WVkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SOK5U9V8dVJ4nSPTW+vPt0P1ozrq54R9NP0RfkIwwrQ=; b=yMYQHcBufCF2euAuLRMR5qrn7GeXXGuy/O5yDnvsQ8s9xLutSlEGXje6XIacCKJO/+ab4KSRMmg+nku6ek/GlK4gR7a4ZJZubHPcdCbMTF9ySX9xR4XzJti6ul7x2Oep6GrSk+WpWsceYn9Yk4yt3GFBCC//fAwhlNMFNbKGXoRUWOy5oTn53LbmTrozLl24hPonpfea/vHBdebL7ZUCfMrYajiVqIo+r3RHotrkfenu1EuIiTueKOVbZ31jMcGrfnSqHEhOWAq6tbck6QHOPfAX7s9NMk0SnxaPXV9Uu8J3itu8uPQkPSRov8MhEwq9L+dL8TcE/B9ysj3wgKqwfA== 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=SOK5U9V8dVJ4nSPTW+vPt0P1ozrq54R9NP0RfkIwwrQ=; b=CKhdcul7U3VgX1TGZEvluwCUeXpJnJXGlbbJRJzqX+3onge8N1B+AfrAGZJc38VwE7xIAJx3HKccLVXOewXwZD9mBUq/+iwPvpcYJOMd779BGzEE6x+Jp/cj3JmTuaByDkPnMKC6UTZmX2XzAJkR05ktKTWkGx/1PmIQeZOqvTY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:32 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:32 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 13/14] xfs: Don't revert allocated offset for forcealign Date: Tue, 13 Aug 2024 16:36:37 +0000 Message-Id: <20240813163638.3751939-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0128.namprd03.prod.outlook.com (2603:10b6:a03:33c::13) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cd1da73-63af-4d2a-7cd6-08dcbbb63a8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: ECJF/Pb1VxbqkCqJ/HXHZQioEG6PZh5FuvE9ZPp2mokoesum73/0MCRIR+u3iLKD4G4lAucfoVqwqWD4S2PqAs/AN5b17zzTPEwwQe6W87YBpSakoT1avtpvFahLTUPFGQhPDVF6OA7xHG3xL6FnYGNYvJCqJ22fYXEopgChpSRtE+1Qo7RkziuJEWhQtCih0O4bS4K68k1b0EY2Ot3w0Ft9hoOOQpt6O4TfBxnwpSaVtEGke3mDyV8Uib2jHIs7rx2o9rdUyERVy0SY0wFUYoyfnUqmgg4qQ3LFgzDXL7nglryuG7Z1sSfB0DrV+cs5CVrfPvuaucftDly4pPKh88N3Uj/QAuXpgHLLYR8Sls8n5zS0V1eLABLnhzWoANIx9WFRoumrKH6A4HkYnhXSp/FLfex+X4+HFpK2v5yF68pYOXuVBgAHHNQBxXkUY7MXzK71HC2d5jnv7/n5MCPaYYpXtEXuwX3w2cTv1FCVRHZ8bds0jWMkFz2N+fJpzDck7c8dHgAMduuTye/cgOo5mLJSQA5PMtRF3504c5F5IA/W27RfsLfUk77SolVd6c4NR58ppwQ6ZjhiXcieN3qJaS4fVmD7wwepgWN/tfXYqiC2Kq4AoOSkNtyHEqK71ytPpT/dIW8HuBKWZ9ViyatYfF0dby5a1dgop+lTEWb4yELo4H1wy8PWm/DG8IyyUj7q0/ENX9vo2x6eSWagT6jjr84m2rt5SugRfbFL4yovhP5LgKspgpIQAZXPs0NZi9EhqettaAPsbQxJTt0l3Km+uw4J9t1UGv71dQFOMeO03C/kxAqyA1YOTQBtF0sYmVtQX1rZBCnk/GxHawm6yGiXhKzWIx6I/JI0BIGUuMQRmgxUiQRxogGWHhVAAcnbSlVc7hNEKoB1Aogl12DSn8Wxxwm/mpPRZv8+ELL6JDunWXI1xhjKV/gNJ71zgHc5rqc4QwY4lGNQ5Qvbbz8bJ/4U1+HWZajEaLHlWhT5lP5IkCg0lGOF2ZkLnBSpPDx4/6IV5Gj4rW8S+GAqhmf+SMHZW/Rva6+Y/eruWpT1CU9o1gtYZor+E+oR/unNE4iI/0qOSVPWvE6gICjSkizP6UZ7vwq5r2++5Elp6YnI7aohzBG0C39h+/0l0ww5XH0r4URLJb8tkxtvdGCBa1lPEnCOGPvNtTUa/eBBEiuIGE/80nHHVte+XGKkg1xI+HejG1Q/JMaHpUHkyqItvvnreFHawXAtXzjfM6m154pi/BErgufFz8OawWeyO21iAk0MDjhTt82jwAgUm639I06axABXqlPmP/dBFFGiU9LB1RCxS18oWRokSWrVedGjB2h5hB+i6fKqQGJzw7/HSE6+4oROkw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lRM7I3DBG7KUQdQZ+kcQlV/9n6tHFip1Oq67RbaMkZDIT1PgRJnX6KHbVJUUmyVwzm1FaaZuSPXx0K5UyyUxfuKXEXZawwO+/Idjg3o6HZb5cnrrIMpE4QImFQnmbmqdowuJQ4oSB5XwSJN0BHg2aMOREalKqLlD3mYIott3+EEXOCXmYk8HaFr6qHEEMSXSFIlU9JSdGuGLIft0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0r4RJNFcl9SpWWCn9TSC4rrwmdqKszYbos+sD0Bj+oM54r8Trevf4ay0DQ9V9B1/iW53cTZhvmJtGN85VEdxyLfltYhmq+orPrz82nU25Z2VhonZC7Oxg+0Nbf6AgvEi0gpwtIHPaFaHPymAUHMO41ZpA/1qGKsmrQ1+RpfNSdtuYxkHBgFRm7ViO50S4u8mMOogEpazJsfaFyY7bM5CHlQxs2Dv1F4N9FdY3rMgGwaeYPjomhMolfQVVnNq/W0d7fal1/ThvKXKXc+T7+0hkqUpwC3mDSz/+bU1ukEVzFi1CPGaw6FLt7JP09yUQgpcB3UV/sTRyDNmw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 2k/BbGt5aYmTF14smxThy1BfofB+6q5vVDDhT7D63G5Y7joGr6GnDdfiBoFFVk0kV+81xoH/NiERFMT8yk8cFfPRSrALH8q/im8I04HTz76mngoRiJ/JmBOnLs/KNgiq1oSNLav1l9jyhmssZHYcMYcjXlhbR12WQuY+1rgXddEN87CcPKWJZNqe8kHiajFCXhczoyHgaaxTHX/Xt6/8HCtJ3WSxUIbtbzFhNdQrXmxCpRmiMd4eVWWcGg4dzUs11C3ms+jlmepDrNudE7ikemobpKTo2bb9CMbViWovW4lxvvaHUC5TpXEvwxp/3jUrGUgUARS+D22kUK3eOtijhZqeA+A+RSDnQaWElW5RGCnq6HVuvzwnOnaTiLOqRVL0a4PihRg4LHODUz0jHXmG9F+Y2nxibjEd8k+fB2tRI+hrm9NopmWwqxqEy1FK32UGiN7NUYWRF7a/js8z/iTp6Mb05FuBkxha9FflA2YyDOvS1TO8uXL3M79rWKW+zaBJuC3Bd5roFwzSzUCeVMd9tHCMUtuEkmRULPDk97IrYHZ0bf4QxJIjrEH0PBGNRUrdJrBpNwKun38aoy5OgnyeD2w3dqsP5bZDTm7uCFrjjV8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cd1da73-63af-4d2a-7cd6-08dcbbb63a8a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:32.1519 (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: +8XXuGhXyg9ZldvFPx/qE+tmCWG3+WGVG19+/HH17t0wRKy6hgOcSG4bb+N7QGlg9fCigOs9W4L35eBfhrjz/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-ORIG-GUID: shgvuF27TK27wdgeR6TebVTr10YTrpam X-Proofpoint-GUID: shgvuF27TK27wdgeR6TebVTr10YTrpam In xfs_bmap_process_allocated_extent(), for when we found that we could not provide the requested length completely, the mapping is moved so that we can provide as much as possible for the original request. For forcealign, this would mean ignoring alignment guaranteed, so don't do this. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_bmap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 3ab2cecf09d2..a9e98f83e57e 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3491,11 +3491,15 @@ xfs_bmap_process_allocated_extent( * original request as possible. Free space is apparently * very fragmented so we're unlikely to be able to satisfy the * hints anyway. + * However, for an inode with forcealign, continue with the + * found offset as we need to honour the alignment hint. */ - if (ap->length <= orig_length) - ap->offset = orig_offset; - else if (ap->offset + ap->length < orig_offset + orig_length) - ap->offset = orig_offset + orig_length - ap->length; + if (!xfs_inode_has_forcealign(ap->ip)) { + if (ap->length <= orig_length) + ap->offset = orig_offset; + else if (ap->offset + ap->length < orig_offset + orig_length) + ap->offset = orig_offset + orig_length - ap->length; + } xfs_bmap_alloc_account(ap); } From patchwork Tue Aug 13 16:36: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: 13762281 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 B56E41A38FD; Tue, 13 Aug 2024 16:38:51 +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=1723567133; cv=fail; b=IHz8TxkP+ZZMYjAaWuPyvGtof6zXRti25UAVwokJ0GsahDc58tlkz1Uh6bT3Y+TDVrgiGdMuop3JKIIbSxV347ii+7YJpr12/p0jwMLpnXsnmUJnM0LwkojmtSXh9ZIvdlyb+6UcpfmOxlfJYMav1dVaoplAHTvBibMh2kAe5WU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723567133; c=relaxed/simple; bh=tLAT+7yTG0erOfjc01XunsibZlefS4hD+rb8ihxgoHs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rBl9CG0U9G3YKTEjQUEHAH0UdkJfepM5b2ptWyvHMiMoYPdk0t31JU3XwJTdG0FMamoXQ8ouLbDi9Mfsf72CoLLbffA82sPD8L62Vsx9gL5tMKqTZriuWBd9AOqiwoqB/XyZgylxOAfUReFkIMZTQDmZgK1b7msz0MvP+hNQ0sA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=W577+x4E; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BVHxBHCk; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="W577+x4E"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BVHxBHCk" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47DGBTwN009743; Tue, 13 Aug 2024 16:37:44 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=s8OBHluIYSrq2MWT02Gr+cDMi9351QGcXWOLsWmMmeI=; b= W577+x4ENQRj41r2jdKqEjbJtxutCuptMODy5P1zPomYOPcE0DUCVxesN9vYnNA6 9z+xB7cSwxUYl3oUvKTiDBYwMogBjknHxR/UvfOpjMa/WI70Dx9qURnXYyYqd+W4 r5hJwACw65tkBGJl/pr7wstsPzeIgwKgxZvXYAkhA1y/0GDMaBDmBNTyXHm06/Fu ohyBJe91dTSKZ5Wfh/LpbUgo9tIm2SwSJ02YcSVjm27vJW7RzswnAcrpizuXOnIi Rea9vYF5pXP86YtSa5blvacgCNQeajd4xmSKM28aloqRRof5pZ9nyx1SDI165nYM yw9RA9DtCpWu7MoAMzhSDg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 40wy02xg3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47DGH99J001485; Tue, 13 Aug 2024 16:37:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 40wxn8qkvm-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2024 16:37:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uZy7l4NAxI9ZmfDCxlxQ4ZPH5/ZfKsB3WF31Fa6TiDTagB7Nw7Z2Al3/xkHjd3S15ciwNfnxkX+BOooDJg0pxKClCHN0+XnytKv8sHlciO8yLr3ZCu3ORgcpYBEps8eUUdMsAby9WyPgShRVTTcuBHQXvmAWMLzBv1D+om5bYnTU9VE95Q8YVT/yOnN+5W19yUuH9XznfOLH6xb7Nk6C3pKC3LVgu4a4fpIHusHhEgQAOkQGHOD5iBeWGs9KN+Qzfi9bRJ50bcOoOz3D5OM7p37aQNa+3CMKEGmh6mhYSjHjrW1Db5+2xx1I1t7W/HVcxYi2ESnVS8CTwu/oiaeehw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s8OBHluIYSrq2MWT02Gr+cDMi9351QGcXWOLsWmMmeI=; b=fXj3YgLKQg9CT0POC4pp/Be7KOFrreg7oPIzUcVIvrI29PSnxZPfabO6AnPjTmzmgNvQQLrw3ybzSmuyLzAOOBaa34tyr4XiiY2VrujIR32fnv11f5fiJgnlyK0v8k6VQJRqMe+cKXrhTdrzY3g3yv/zHJm00fJnyjtHM99sFlYz4uxZ5ngh2GXP9SqX1+4Q/1LKtGeCaFIFlDwNN2ySGbSKkMTqD9xxaQnZgSq9vC9qGSIDwAlpWWS5cfLiQOD/rmItIYbTy0RoU3PoUVdER5jIkF1YBCSgODm6OE4sr8uI6FYvOg1401MGraFs5pax3WObd7S0L56DqZRu3eKUIA== 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=s8OBHluIYSrq2MWT02Gr+cDMi9351QGcXWOLsWmMmeI=; b=BVHxBHCks4Scgp4KT1VB4TaKqv7nE0E7YnZaVD/OxfW6nir4QHUIKnknyDaMRNngc7eykq5pDktxdjf8qg+cwdibyU5KWIh+zdQpwgEJBDku8jM3nOElWHBjRhtUT9/FkbTB60SAU2Kwp4O2vyJp1iQh4Uf4Qtab6dgFFTxHy0c= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB5747.namprd10.prod.outlook.com (2603:10b6:510:127::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.13; Tue, 13 Aug 2024 16:37:34 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%7]) with mapi id 15.20.7875.015; Tue, 13 Aug 2024 16:37:34 +0000 From: John Garry To: chandan.babu@oracle.com, djwong@kernel.org, dchinner@redhat.com, hch@lst.de Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, catherine.hoang@oracle.com, martin.petersen@oracle.com, John Garry Subject: [PATCH v4 14/14] xfs: Enable file data forcealign feature Date: Tue, 13 Aug 2024 16:36:38 +0000 Message-Id: <20240813163638.3751939-15-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240813163638.3751939-1-john.g.garry@oracle.com> References: <20240813163638.3751939-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0373.namprd03.prod.outlook.com (2603:10b6:a03:3a1::18) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB5747:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b36d086-d1e1-43b9-b254-08dcbbb63bb1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: g4dwm1O6q5y9x2qokgqJRPGkbrxH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h9GNyMV9MBbXLvsgEoXefpwX+VitLILpRAqYWDPVAndiqC2JeNSXPSb5vCftbpt1FSvuK3MUQ4ui1ZoLZ9EcMpx4mEXJEtuxna19ZdixuAlwoeS5UICawWGNeKKdOP45IuBKqVRBuWOx7jw+HVCEQPH8Mv/TbiKDiBJoBhufWXHnWcV08Ish73Tp8ex9bk1V4fcDl75Pc7qmSI/P6jHSVagLEKi1QrGWgY6xdq2C/+y9yWUCRY2gJUtYQSFYkGPP5sE97wmdCzGW7vTws5dAJNUjlNRCszwMOskdQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mCpuBjw2DCQ6eIxZgcrXUv6umxvpvd+DRp5RmL0P4beh5IqpFhI7xEf/iicnV8T7jhEMVakeuWhVuwDFFCF67S3OTodFjgEKde0z0fU4x2jOtBmEo8DxyRoxcEuMzOtzW6qfNwBvfDyOsvirY1e9ihOS8TYoKkyeImyv+CFLdAobz7IOmRbul6eBjdW/oL5eYzJ44cgH9tBli1eNmWGgLnevWyUYHrJ0qteY1OvhNmwJ0X8Ya38Yve882OAD6ss9T89HkiE2DzG12RXMY1BzzY3mL1UX970Do6B1RjrNeX+Lv8IjCp8vCy0ZWRZM4o7tOctYxu31HJSnceLOl78q0Pm3v2klFZfBNUGiDuuygwJ3Xf7rNQSBT3H7UD9RCFFqFqjjdAV6kAkIjNv4A7Xus3VbUtpf7ka8ZiAUfq+FPtz0Td7VKQBV9XhT7Lphq15F5g9EnScH0N9YNp/O/wUQSLkrYrTDS0JtxuGVdvFsha1MY/w1BU/zY3Nffli1Bmj7rvyMOxx5Y/Tkk4kz4CoRCFW8vpMUplSMBVdpKfHrE3ZJYbd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ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: usvVC83fNdD7F7SzZaMbxwzGI3D2yDVUv6KlwQXibBQV43E7M5L3i57fkxz6tLuRsgNtZnmg3mKxuxblKx2GIsaTpRe5rhY5IO8f6clfntiwZKmWpSyn2W3vnN9vKSVuqH+B4TJ1QmEoy2O+THonCVAQrOit4DrxuHG3lZRVlv03csIHV2xAT3pc+cqkQfht0UQLNaTUhKmS/VQX3UWPyyuXia1LYgBOQp8IVCTYGjGQ5/ygRgDYvQbzDD1xRzaelj0L/I/gcCxRWVi2sBv4Ilbf0KShL+1I3da/6xbP4fRJlBhQmgpJd3drbLsrrjLMTdXIQ4QYxmXQQZJSmo1eQprEwQZp+tFhUmPrnMML7h8jMCLLt2BAGnapUCMv7taKYcRMnibl9DErAae8pf+hfeYzAWXMxhChWtSUleOHk0uwOVJmG6WEcbPZEuZUGTK2w1Um2OFIHtlxjaYB1snzuIrNjgWBqPc4yuw7CfiIN1qRs3Wy/KPBzYwjZ6tOSaA+xalhcXR9CZ0Y7JyeRm3tAesIvxb7LEv3LHIojJ44oS/u4cPcvxknmuBh8yRE3ANFC6AHJPgkO6j6p++tKspKp4dLF6UR+XjcNZ10Ix+4jSE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b36d086-d1e1-43b9-b254-08dcbbb63bb1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 16:37:34.0462 (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: /z2ZF1l06MuTRONgKe2cf8S+S44nL3UO4RtrLeiWABXhmcVNkqMmt+WfY3sUuovf/i3coDd49k+lT8ddglsV1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-13_07,2024-08-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408130120 X-Proofpoint-GUID: PiOif-9E6dVPNAJmuxrXuG-SvtlKm0Nl X-Proofpoint-ORIG-GUID: PiOif-9E6dVPNAJmuxrXuG-SvtlKm0Nl From: "Darrick J. Wong" Enable this feature. Signed-off-by: "Darrick J. Wong" Reviewed-by: John Garry Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 95f5259c4255..04c6cbc943c2 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -357,7 +357,8 @@ xfs_sb_has_compat_feature( (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_FORCEALIGN) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature(