From nobody Mon Feb 9 01:17:04 2026 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 AA9D027CCF3; Tue, 22 Apr 2025 12:28:39 +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=1745324921; cv=fail; b=AtA03SMhhqJvetMsMB5NFyK3bEGdMEJjj7582tFD7R7226FwQjnIxiAmJcjaa8SxMdpQlNgc0gnLo0M32jjVQXEF2FiiTqhOIKILfF9pAT2pkbXbLP6fcMt2fN5gk+B8uzF+LNLAghZnpsgtNZUKYGU6V3NTsUoBXImT/aCUYU4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324921; c=relaxed/simple; bh=HXoCifz0GuY1M5rkJrFyR/P7ou7T3D5tc2ERXQsB8mc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=r3eQeOh1MfsA1yjlF8H3+4hUP8unk3YFrruNNRQsDXSkuJr0kGRgtEUpVOTTqIitQv2UN8PZ8VeRdnsd9mrU0O3PW6ZC00udTwCaF0WRDurnP1lk2/kwEHBOvydby0Oi0x5FuXuAu2CJqTS+2o/Ita5DmYx8Gx51L8gZ7t2nuDI= 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=oS9BHbyJ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QvnoDn01; 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="oS9BHbyJ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QvnoDn01" 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 53MB3B48008309; Tue, 22 Apr 2025 12:28:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=PfjAwbhZVoZaFEImTYzZAQtIzj7lCu5hv9mKI611ZXo=; b= oS9BHbyJEiLcreADBxXFLbE3zZ5BAEx/R71SSQxec7n1n7+g0wyZxX23UXk1jS34 FR+frjgfrts2fc0dHuRSy9kZQ3wb1qREfrXNqKJb9YKiyDfJ8OdXDsj78gV8xW6P 948gVyDY2t8G01ZRF6JoKrkOab7bjIda0P2Wi8JifF6EC76oQDRVZs60pNd2rl0R D7w2eAlUJ5Mmew+xzpsEWDnPl9T78+dj/ejuYBArn1VaL484vguwfPOwwd5vLZJz XPnKGtzrZxUK1fhBV/gc4V3IJxhZM122IDDprBxJXlxaIv+QHnaivwQWKqmt8wiS tlChzclXc0MDb2K0BhBW6Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cddw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:25 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBkiqF033431; Tue, 22 Apr 2025 12:28:25 GMT Received: from co1pr03cu002.outbound.protection.outlook.com (mail-westus2azlp17010004.outbound.protection.outlook.com [40.93.10.4]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rm3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hb8rMnRrGW5cS22OR/hLVQVNlylrNe4TfEFiAqnHgrhvYC65gqiLAliiXmYYFeSGnh6SBFBhF/qVzO2bYGc8gtUMpTXsp5D708AinX/C5/sp+xm4vdldWnc3FGgIQhokY4gCIvdlYgT+1p2osNKYJ8la4W6NsGF35ATxY+meGVEXZVkYh1pILh2zUcFeo5+R1N1WwZptWzJeo/2C8EEvkZ2anVVhEc9tHV6UKHtY+7paBNk5llJXErHc5eauRFoHBygfkFDjEX0YumJ5K9mWX+ioFemnBfNkGa3Vf4bUtVR0m+UIgxabONuZGyjWsUNbmEIcnZO/raQ1ZFithrLQAg== 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=PfjAwbhZVoZaFEImTYzZAQtIzj7lCu5hv9mKI611ZXo=; b=Fw8ecvLx0clQjnfqf4elyhaS0Z16kEKY1qvrVHUBMckqGZ2yrQIDkwcRJSJoCXYrJjytk7wTW5ovHojcE1+xaVrnXpgeR7ecFZ5p0VnO1wyDE0rr4DQCX/SHiQ5sarReBb/7PBqogmSI15aV6HHLTdXAmfkqWGL1ce6eyK+JTlUwS4BvpFHta7+YDcPA+12Gi/et6rVWTLD1KjI9/4GRMu3+bdcZDsZdqfGLmdp2rSqoOgsxP+LKueVtZzKfMmmxfPWwqjTg9KvM0nJWpGfxHT5/D6AjodBCbpup8G5y5/o4ImF1XD3BkBMr8t26BW5rZA77PwF4ipqb3Zp1KA8BrQ== 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=PfjAwbhZVoZaFEImTYzZAQtIzj7lCu5hv9mKI611ZXo=; b=QvnoDn01YhOSWPxLiZraWmvibugQ7kLfSdb5/p0wcQYRsbnI/C+G2f1LeWuiuWcgL9pEHttTOlKxFTLSkWlJ3drRaWsSkWVnlQmIPKiGPRe7ngFnRzQDVTTUnTE3GDnf7/4XVvOEZUaCEw5H1+Zgnl0D+s/CqkM8rZ9WoNAxCJY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB7394.namprd10.prod.outlook.com (2603:10b6:610:149::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.22; Tue, 22 Apr 2025 12:28: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%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:23 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 01/15] fs: add atomic write unit max opt to statx Date: Tue, 22 Apr 2025 12:27:25 +0000 Message-Id: <20250422122739.2230121-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P220CA0029.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::34) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH3PR10MB7394:EE_ X-MS-Office365-Filtering-Correlation-Id: b0df1649-b4d8-463c-2580-08dd81992c4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EZxswPA/54ipwL1SjyIDdB/4kJSkP/JNPiToY144YshHHY2dRh96ck8v/YMg?= =?us-ascii?Q?X6/o3wY05Nj+8m1vpi7AUgOQ3eUuzmAnF9GbC2k6ZqQMmitCAH7maoyExHz7?= =?us-ascii?Q?tS2weizPpGPT/BfwfWf3n//yl5iIFH+7qsTu2KNmquPcd8wwO0fN6ZZnZTCa?= =?us-ascii?Q?EcSjWTE8e5qBWouA0HgU6XVCeQx/s22AUn3z6z6EekI/DCTE+0JbfiKBqFXi?= =?us-ascii?Q?RRfWXGemHwl8RueNizCV3hkvuUMgFF752Vg3H/X6e5TAYX+M5OUbhW8YoSCO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KmwZJn4ia5ZzVe9bAZaG?= =?us-ascii?Q?9S/HxxeAH0QI2VJiNbC7UYgLB3ASWSBnu/n3leazLVYD5GIYxTjpUlT7JQNR?= =?us-ascii?Q?xz/Qfg5T7Z4byHooCp7lgFGOr+XsL8zqNA04bCa80zfrtLK9vtVKmYP9WZV2?= =?us-ascii?Q?HFdfM2q6eH4+AOKDq//SBujvY7kvgXbwPIZDw+0D/wbDGmk2ZN4h67sjXypz?= =?us-ascii?Q?rXY+FKpjPyU5Gf7JASH+UEcyfULC9vzRxqoryqCUN0zv5kWqKMNWJUoPMYP3?= =?us-ascii?Q?CRJCG/TN77I=3D?= 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)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?qkoJlzGU7PGp46+w5yfoWdpI9GLzdEkeiLaap+3qHqc9NDReVDxGVRAzbAzU?= =?us-ascii?Q?2yLZyw9GvyNC2qo5d5fP4qzJ4F0MRn7+Wi7nX3Jzu+uVANpvlINlhrQFil5z?= =?us-ascii?Q?fxST3l4ZaNczGDEiLS+2Uhiv74tXX1JRdyqNGIRU4tSm1fKAW2pScyiPKgIY?= =?us-ascii?Q?bufyjpqoWQteU9jbMXVM3IvKZOhLRfttF1Cz0b9Sjt+Cnr2zEtgtXVX35TaM?= =?us-ascii?Q?Fav4Z4icwIC+uO52tgbr25U90ujsSsWGbxTg6TU4dg9sxVOy0WwCjhwk2vHp?= =?us-ascii?Q?F0TNAVzebWJL7qiSQv6w1YWSYxTjZzKWTwJ4ofkb+YzYyXiNMFtGrdRzXPxo?= =?us-ascii?Q?IOj6Ecy/McMe5k/UR0uXNz2pNqCHFOrXwyqsrPhIsIRKK7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M38c9CIpn+G9VYLxFbozfN8a4bOjJRhoJD84fHLOUemTxcnuT8ClEk3xEaF98dg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0df1649-b4d8-463c-2580-08dd81992c4f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:23.1339 (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: TbvPl6XbyDFsaI9kE8n0hps9Y5Q+x2jLZXZYfC9ySChwxoWoMrmBceEsPCbgat1DS1iX1V9HiFjNXd8jUkaJ9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7394 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: 3jh5vX6HzrKs6JeiGjNyYl_TutA_KGSD X-Proofpoint-ORIG-GUID: 3jh5vX6HzrKs6JeiGjNyYl_TutA_KGSD Content-Type: text/plain; charset="utf-8" XFS will be able to support large atomic writes (atomic write > 1x block) in future. This will be achieved by using different operating methods, depending on the size of the write. Specifically a new method of operation based in FS atomic extent remapping will be supported in addition to the current HW offload-based method. The FS method will generally be appreciably slower performing than the HW-offload method. However the FS method will be typically able to contribute to achieving a larger atomic write unit max limit. XFS will support a hybrid mode, where HW offload method will be used when possible, i.e. HW offload is used when the length of the write is supported, and for other times FS-based atomic writes will be used. As such, there is an atomic write length at which the user may experience appreciably slower performance. Advertise this limit in a new statx field, stx_atomic_write_unit_max_opt. When zero, it means that there is no such performance boundary. Masks STATX{_ATTR}_WRITE_ATOMIC can be used to get this new field. This is ok for older kernels which don't support this new field, as they would report 0 in this field (from zeroing in cp_statx()) already. Furthermore those older kernels don't support large atomic writes - apart from block fops, but there would be consistent performance there for atomic writes in range [unit min, unit max]. Signed-off-by: John Garry Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: "Darrick J. Wong" --- block/bdev.c | 3 ++- fs/ext4/inode.c | 2 +- fs/stat.c | 6 +++++- fs/xfs/xfs_iops.c | 2 +- include/linux/fs.h | 3 ++- include/linux/stat.h | 1 + include/uapi/linux/stat.h | 8 ++++++-- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 4844d1e27b6f..b4afc1763e8e 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1301,7 +1301,8 @@ void bdev_statx(struct path *path, struct kstat *stat, =20 generic_fill_statx_atomic_writes(stat, queue_atomic_write_unit_min_bytes(bd_queue), - queue_atomic_write_unit_max_bytes(bd_queue)); + queue_atomic_write_unit_max_bytes(bd_queue), + 0); } =20 stat->blksize =3D bdev_io_min(bdev); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 94c7d2d828a6..cdf01e60fa6d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5692,7 +5692,7 @@ int ext4_getattr(struct mnt_idmap *idmap, const struc= t path *path, awu_max =3D sbi->s_awu_max; } =20 - generic_fill_statx_atomic_writes(stat, awu_min, awu_max); + generic_fill_statx_atomic_writes(stat, awu_min, awu_max, 0); } =20 flags =3D ei->i_flags & EXT4_FL_USER_VISIBLE; diff --git a/fs/stat.c b/fs/stat.c index f13308bfdc98..c41855f62d22 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -136,13 +136,15 @@ EXPORT_SYMBOL(generic_fill_statx_attr); * @stat: Where to fill in the attribute flags * @unit_min: Minimum supported atomic write length in bytes * @unit_max: Maximum supported atomic write length in bytes + * @unit_max_opt: Optimised maximum supported atomic write length in bytes * * Fill in the STATX{_ATTR}_WRITE_ATOMIC flags in the kstat structure from * atomic write unit_min and unit_max values. */ void generic_fill_statx_atomic_writes(struct kstat *stat, unsigned int unit_min, - unsigned int unit_max) + unsigned int unit_max, + unsigned int unit_max_opt) { /* Confirm that the request type is known */ stat->result_mask |=3D STATX_WRITE_ATOMIC; @@ -153,6 +155,7 @@ void generic_fill_statx_atomic_writes(struct kstat *sta= t, if (unit_min) { stat->atomic_write_unit_min =3D unit_min; stat->atomic_write_unit_max =3D unit_max; + stat->atomic_write_unit_max_opt =3D unit_max_opt; /* Initially only allow 1x segment */ stat->atomic_write_segments_max =3D 1; =20 @@ -732,6 +735,7 @@ cp_statx(const struct kstat *stat, struct statx __user = *buffer) tmp.stx_atomic_write_unit_min =3D stat->atomic_write_unit_min; tmp.stx_atomic_write_unit_max =3D stat->atomic_write_unit_max; tmp.stx_atomic_write_segments_max =3D stat->atomic_write_segments_max; + tmp.stx_atomic_write_unit_max_opt =3D stat->atomic_write_unit_max_opt; =20 return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; } diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 756bd3ca8e00..f0e5d83195df 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -610,7 +610,7 @@ xfs_report_atomic_write( =20 if (xfs_inode_can_atomicwrite(ip)) unit_min =3D unit_max =3D ip->i_mount->m_sb.sb_blocksize; - generic_fill_statx_atomic_writes(stat, unit_min, unit_max); + generic_fill_statx_atomic_writes(stat, unit_min, unit_max, 0); } =20 STATIC int diff --git a/include/linux/fs.h b/include/linux/fs.h index 016b0fe1536e..7b19d8f99aff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3475,7 +3475,8 @@ void generic_fillattr(struct mnt_idmap *, u32, struct= inode *, struct kstat *); void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); void generic_fill_statx_atomic_writes(struct kstat *stat, unsigned int unit_min, - unsigned int unit_max); + unsigned int unit_max, + unsigned int unit_max_opt); extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, uns= igned int); extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned = int); void __inode_add_bytes(struct inode *inode, loff_t bytes); diff --git a/include/linux/stat.h b/include/linux/stat.h index be7496a6a0dd..e3d00e7bb26d 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -57,6 +57,7 @@ struct kstat { u32 dio_read_offset_align; u32 atomic_write_unit_min; u32 atomic_write_unit_max; + u32 atomic_write_unit_max_opt; u32 atomic_write_segments_max; }; =20 diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index f78ee3670dd5..1686861aae20 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -182,8 +182,12 @@ struct statx { /* File offset alignment for direct I/O reads */ __u32 stx_dio_read_offset_align; =20 - /* 0xb8 */ - __u64 __spare3[9]; /* Spare space for future expansion */ + /* Optimised max atomic write unit in bytes */ + __u32 stx_atomic_write_unit_max_opt; + __u32 __spare2[1]; + + /* 0xc0 */ + __u64 __spare3[8]; /* Spare space for future expansion */ =20 /* 0x100 */ }; --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 9602327CCF6; Tue, 22 Apr 2025 12:28:40 +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=1745324922; cv=fail; b=uEOUTPhKaPzSwBG2h2gYaYT5iIeFc6U2QajQXq1r7pJBuWTekneVSQWjJ7sQ8XS7kh5oj8IOkQK4sFJR6/t1CdTnwm5mlIGai/pfkElwGs27nupmoqEX+EoiKGH44tKQspO9ZE4oDx1fBIgACd5knJVOfISY0k78Px76PgE3BjM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324922; c=relaxed/simple; bh=/Gc9YxwkEPXlQwpTWBqIaTS+N0I2IhLUfDnljXWFgSU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=s6X2diB12+r7YxygsHVWhGaAsmdc9lR6pbuNXS3kSuC5OwOyZRQFUlm0R+Kpt5VCVWjCwEPdkkdVQU/ujkiLjkJ2XWD2qa1+FcPWuuMWzEZ+cUWVtCD8k1PvxfvwfhrQFiLQCCFW7s9jEbTcwgiPHBck6XZADBhCD8TINZ34dPs= 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=OcH8vusk; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OMwzBz1j; 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="OcH8vusk"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OMwzBz1j" 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 53MB3VOZ008552; Tue, 22 Apr 2025 12:28:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=1DLzKEzxZWroZS79L7ym5z5u37TJWbokIXzfpxvotNA=; b= OcH8vuskO/p4DtJ2uKKnxrctGA4ZJmvtQgH5V6TJW91HcJK6S3HxM5pwt0esYzl/ hTI9z6AupFgrcGfCx5TjgDqrtbVnZufXvz+AILsAWPf632fUSUqqzuSnBhMKABjp 1vunZjG/ajrChtoVaHvgf/w3UxsB+5gCOPHs8VK1fKV5jEXZBJTOXd1YKYBwqbkl 2+lKhCtpLEn8UE/P9nw/iqcVDfhHah/E5bgW92+c5TsdvL4TJda5hCUGNKx56dYU c10dTIg/wV8gYM2xURDUDz2XScSPqYQ3mURChJvkQ73BMh9CCH7XCDwtEkYIgHy2 n6aQc07Ht3FtYbBgq1rs1Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cddx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBidUZ033447; Tue, 22 Apr 2025 12:28:27 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013061.outbound.protection.outlook.com [40.93.20.61]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WToPI8gfZSPpbXjAUcxCvZkJDOxrJ7aB3Z18KqXBFil5qud0dsV5D2D4kKIwa1a8RYskhBM/lISm2s12lNMtg0cyQ5JSRO51mXcrIoQLnknhcPEXr5pGEolmP4gzzr+f0PyowCNI5wQogv3z0USmXGXdPB4VpIVVIDUlsRIlyN6XA+mDPTAbkkPUEZFIKKsoPVXuwy+W4mJps8tBYvXw7YONAdR5P0aSewg44GqdDBCFl/FaFkE0rw+i4EAh0500s9z96FacF02mfRwxPXoFrvGIon5Uexa/kwLCq7t5pTYH63vPEI44uGbm8fH7Bsxhb/tZzi7APqrhX5YwUokTmg== 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=1DLzKEzxZWroZS79L7ym5z5u37TJWbokIXzfpxvotNA=; b=Lq0xfDl2cikf+D05vjjX2qj9bVbFYjmsfKZNMMFsNCZZDxxni3qU0uvt84mS+R1xjlHQkF785Y+g/otWjyaxknpT6TryM/mc0EEpfyuado+/kSqQX2vfAMUkEgeXP35Zh3uDgJT8Zr/8/2E/ikmvFJ6D3/2HAi9QddvJlbcXnd8NjU0Wp6F2TFmrFqJJ077kNQr8wzJGvXDNcr4CxYs/uUUQGnPenXnxN7QMljten7aqh5AULD5trMJUOFc8inxRyTSxaE5Wpqif1XagXJA12H7fHwAeL6YOGaqkU8dq1abfb7pqEYSnVpY1TduBPrSze1L4en7IVZrzI4JRRFIqqw== 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=1DLzKEzxZWroZS79L7ym5z5u37TJWbokIXzfpxvotNA=; b=OMwzBz1jktTbo+7irYxc8v5tFcBPuN125WhjzuAIHL6mliY0ZDrvKgAiIwcsyasM2KqvpuGFjmWqsMJqPhKmcvxGVVK2TEZIUIoTdR/QsyY8kchccnLONiGcXMXKY863MbkI26QVx4QFaUe+iqn4Qxep3Txr6oaRVgCogw/bCtc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:24 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:24 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 02/15] xfs: add helpers to compute log item overhead Date: Tue, 22 Apr 2025 12:27:26 +0000 Message-Id: <20250422122739.2230121-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 3aa8e2fd-dfd2-4a04-8aec-08dd81992d12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Vi2L3Ak1RcEMMQC3fUkrDhALuaZf75goPViImbavfo1DRZ4J3elcNIhADG91?= =?us-ascii?Q?9+J7t/wR6YSGtdDnuy7CgJZCPNxpm3KOgdgTrpXlVqImDs2NL/L/zxNXwPsr?= =?us-ascii?Q?TWBUse3trG7406vHtzadoBGFv+WsXMv0RWX7WqoryMPNL/O9EGHxF1tyxwGa?= =?us-ascii?Q?GA6QJam79h1NPQDz8EEsKGE5fUvLqU74biTChGvXapVLNkRIt9nQtwQ3Jr0C?= =?us-ascii?Q?iPAl9a4G7KSPHMcLQCLweFHViTY3i2nzUvwrLIR7ME8LfuMRL2A2crjYecBS?= =?us-ascii?Q?S+6WnMyDfv0xccwP42qeoWZZG3BkHZi37SGXShA7W8IfEY0Bml7YNokNK9sp?= =?us-ascii?Q?suZ1d8T0vXE7xdh2gFNCqx3v4oK8yJ7Q+iMyvscBTOkC0idb2WWvRDHPhE0i?= =?us-ascii?Q?7UbU36Nikevyc/Lwh8utdevQKruCpPmz4KD80iVZ2ot+4BlYgWLg1XOBsXCv?= =?us-ascii?Q?9nVIKuf/9gEt+Rr8RO2GCcdRYDfuxt6UY/QBuxHHQsZtgbRqTkHLgbEbWYW3?=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6ColmAzd5i+jypk4rzFUNA1pFEN?= =?us-ascii?Q?Efzsc1Df+/U=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vtl4NRES/1ExzyR/wzcwuFPk4/Oyfvja7duYmBrublWgyouJyB5yDsbB+yq+?= =?us-ascii?Q?e38udu3fGyQ3Prip1CJjePJ40/8PA/9CDrS7ucYFUREn8Wg5TLe4Ecud7dFL?= =?us-ascii?Q?7C3No7svyr9CiR46pYjBfnB9Zj2I62TmCyOuNNoeY0wRi84OP5stetdQlIHM?= =?us-ascii?Q?SXDjoccR35yHncAdy4VxXucEyCnJexYnBWO1pJ9xlAc1sIJwLZcJ13URFwcs?= =?us-ascii?Q?zSRnnBUKHR3LVirZpEWF1NObFDgaOeOK85qFSmAzSP27GC04Hh9vQdC4RY2j?= =?us-ascii?Q?Yorebq3EJeflTKyTK3dOpjk0Kk4ftAT0yQs4WEhwhXKakxdxf2F/4+uGj9BJ?= =?us-ascii?Q?bLrNO6ZNI3ygbkyzeGGXjwE671h/R+bXj7NPl27+nfDtvR6pkAIRcLDv5Aiy?= =?us-ascii?Q?Eya33Y/PaNoujkbCRZTV7cAlS9A109DmTD15QEYS7TcNnxvDnuc+o69Ce3wB?= =?us-ascii?Q?/FqMOz8mCN2yg4dJ6UhF86F+47R2aQ0aaZi9gsvN1JV3lHjsiJwq9Jn4YN3d?= =?us-ascii?Q?R6ucosXG7pdJwpEj6qvxMvqWCyxiy/dTckMgQvR1wH2B9cEr/1+svhk8XssW?= =?us-ascii?Q?7Z7DdaOsroFdg9fZmFQqmhS2Bj8RzU+h5++sOHN2pF3jOZ/a5a+ah9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jOgkc3cUJ+q61UOhEzWl0mhC?= =?us-ascii?Q?dE7uyioMlA9mbPgKEPK61aWtbw/6BKg+EipZY/9ZAmVcOnYqDhnuVh8NeNTC?= =?us-ascii?Q?UQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lPnkL2GZ1kQp070lmo4MxyD6Wrb1HsOl+reRQVPFSfiPrIExfpq0wXntbgms2MUWMozCRr8jJX9TSPzdXNQebvSFmAhF5Kb1+U88ce4GrlKoj2hZE7b1L+m9u+a6QqFTaZ/RwuByk6KZW0I2MLRB1JAUBwJdKBvjwQCxBcS5hIav6+840hArfdz6fQIFxTmFcghCx2AW4szu2zCdx6JRcvt2I29BgkOeV0UY+Yf+d5WYTn0/lJfS9MCelPg35Jm/o2+UISzhcgU/hPLTGpcC1BrYRiJ26DbeCTltsm9NAyNS797lPUaOtID61+hoZM3coHg60+mNZ3daIwTOKANriK+kq5BXkdhAnGJaRqWBbihVBTQ1pLB5Jj+2ujKqv2Q8C+5giQ98AIVa+hHGxUGbKC8Htb5nfvuFJoclDzOLUI60xlLcM3W8915aicthskNPGCufbxXWBtXYH9KuiyYQdK6nYzDNgfbwdgACR4mhaPzpJJ+Iu+xFSNSTPUB/x7sqsmHn4zhTIyNHipPWfSTqdcBDigmEhwzydfUdHVbqADpH6oyO731/2uORDoqVUlCOx4N1QosMv+Ip0bpBX0aLAuosIqBVKGCQSCUYExS2VX4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aa8e2fd-dfd2-4a04-8aec-08dd81992d12 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:24.4042 (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: 1llzq7pQ2w7Ru6dvZcbEDELDUhBWSaBYcFWvJKqmAURn3/k7D+LUsZgYZbmnQ6Q+GTC0R9til7V11pK52SBGCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: YFHNpZh8WP8FitKDzQaIPPGbWVnsgHmj X-Proofpoint-ORIG-GUID: YFHNpZh8WP8FitKDzQaIPPGbWVnsgHmj Content-Type: text/plain; charset="utf-8" From: "Darrick J. Wong" Add selected helpers to estimate the transaction reservation required to write various log intent and buffer items to the log. These helpers will be used by the online repair code for more precise estimations of how much work can be done in a single transaction. Signed-off-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_bmap_item.c | 10 ++++++++++ fs/xfs/xfs_bmap_item.h | 3 +++ fs/xfs/xfs_buf_item.c | 19 +++++++++++++++++++ fs/xfs/xfs_buf_item.h | 3 +++ fs/xfs/xfs_extfree_item.c | 10 ++++++++++ fs/xfs/xfs_extfree_item.h | 3 +++ fs/xfs/xfs_log_cil.c | 4 +--- fs/xfs/xfs_log_priv.h | 13 +++++++++++++ fs/xfs/xfs_refcount_item.c | 10 ++++++++++ fs/xfs/xfs_refcount_item.h | 3 +++ fs/xfs/xfs_rmap_item.c | 10 ++++++++++ fs/xfs/xfs_rmap_item.h | 3 +++ 12 files changed, 88 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 3d52e9d7ad57..646c515ee355 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -77,6 +77,11 @@ xfs_bui_item_size( *nbytes +=3D xfs_bui_log_format_sizeof(buip->bui_format.bui_nextents); } =20 +unsigned int xfs_bui_log_space(unsigned int nr) +{ + return xlog_item_space(1, xfs_bui_log_format_sizeof(nr)); +} + /* * This is called to fill in the vector of log iovecs for the * given bui log item. We use only 1 iovec, and we point that @@ -168,6 +173,11 @@ xfs_bud_item_size( *nbytes +=3D sizeof(struct xfs_bud_log_format); } =20 +unsigned int xfs_bud_log_space(void) +{ + return xlog_item_space(1, sizeof(struct xfs_bud_log_format)); +} + /* * This is called to fill in the vector of log iovecs for the * given bud log item. We use only 1 iovec, and we point that diff --git a/fs/xfs/xfs_bmap_item.h b/fs/xfs/xfs_bmap_item.h index 6fee6a508343..b42fee06899d 100644 --- a/fs/xfs/xfs_bmap_item.h +++ b/fs/xfs/xfs_bmap_item.h @@ -72,4 +72,7 @@ struct xfs_bmap_intent; =20 void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi); =20 +unsigned int xfs_bui_log_space(unsigned int nr); +unsigned int xfs_bud_log_space(void); + #endif /* __XFS_BMAP_ITEM_H__ */ diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 19eb0b7a3e58..90139e0f3271 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -103,6 +103,25 @@ xfs_buf_item_size_segment( return; } =20 +/* + * Compute the worst case log item overhead for an invalidated buffer with= the + * given map count and block size. + */ +unsigned int +xfs_buf_inval_log_space( + unsigned int map_count, + unsigned int blocksize) +{ + unsigned int chunks =3D DIV_ROUND_UP(blocksize, XFS_BLF_CHUNK); + unsigned int bitmap_size =3D DIV_ROUND_UP(chunks, NBWORD); + unsigned int ret =3D + offsetof(struct xfs_buf_log_format, blf_data_map) + + (bitmap_size * sizeof_field(struct xfs_buf_log_format, + blf_data_map[0])); + + return ret * map_count; +} + /* * Return the number of log iovecs and space needed to log the given buf l= og * item. diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 8cde85259a58..e10e324cd245 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h @@ -64,6 +64,9 @@ static inline void xfs_buf_dquot_iodone(struct xfs_buf *b= p) void xfs_buf_iodone(struct xfs_buf *); bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec); =20 +unsigned int xfs_buf_inval_log_space(unsigned int map_count, + unsigned int blocksize); + extern struct kmem_cache *xfs_buf_item_cache; =20 #endif /* __XFS_BUF_ITEM_H__ */ diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 777438b853da..d574f5f639fa 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -83,6 +83,11 @@ xfs_efi_item_size( *nbytes +=3D xfs_efi_log_format_sizeof(efip->efi_format.efi_nextents); } =20 +unsigned int xfs_efi_log_space(unsigned int nr) +{ + return xlog_item_space(1, xfs_efi_log_format_sizeof(nr)); +} + /* * This is called to fill in the vector of log iovecs for the * given efi log item. We use only 1 iovec, and we point that @@ -254,6 +259,11 @@ xfs_efd_item_size( *nbytes +=3D xfs_efd_log_format_sizeof(efdp->efd_format.efd_nextents); } =20 +unsigned int xfs_efd_log_space(unsigned int nr) +{ + return xlog_item_space(1, xfs_efd_log_format_sizeof(nr)); +} + /* * This is called to fill in the vector of log iovecs for the * given efd log item. We use only 1 iovec, and we point that diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index 41b7c4306079..c8402040410b 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h @@ -94,4 +94,7 @@ void xfs_extent_free_defer_add(struct xfs_trans *tp, struct xfs_extent_free_item *xefi, struct xfs_defer_pending **dfpp); =20 +unsigned int xfs_efi_log_space(unsigned int nr); +unsigned int xfs_efd_log_space(unsigned int nr); + #endif /* __XFS_EXTFREE_ITEM_H__ */ diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 1ca406ec1b40..f66d2d430e4f 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -309,9 +309,7 @@ xlog_cil_alloc_shadow_bufs( * Then round nbytes up to 64-bit alignment so that the initial * buffer alignment is easy to calculate and verify. */ - nbytes +=3D niovecs * - (sizeof(uint64_t) + sizeof(struct xlog_op_header)); - nbytes =3D round_up(nbytes, sizeof(uint64_t)); + nbytes =3D xlog_item_space(niovecs, nbytes); =20 /* * The data buffer needs to start 64-bit aligned, so round up diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index f3d78869e5e5..39a102cc1b43 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -698,4 +698,17 @@ xlog_kvmalloc( return p; } =20 +/* + * Given a count of iovecs and space for a log item, compute the space we = need + * in the log to store that data plus the log headers. + */ +static inline unsigned int +xlog_item_space( + unsigned int niovecs, + unsigned int nbytes) +{ + nbytes +=3D niovecs * (sizeof(uint64_t) + sizeof(struct xlog_op_header)); + return round_up(nbytes, sizeof(uint64_t)); +} + #endif /* __XFS_LOG_PRIV_H__ */ diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index fe2d7aab8554..076501123d89 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -78,6 +78,11 @@ xfs_cui_item_size( *nbytes +=3D xfs_cui_log_format_sizeof(cuip->cui_format.cui_nextents); } =20 +unsigned int xfs_cui_log_space(unsigned int nr) +{ + return xlog_item_space(1, xfs_cui_log_format_sizeof(nr)); +} + /* * This is called to fill in the vector of log iovecs for the * given cui log item. We use only 1 iovec, and we point that @@ -179,6 +184,11 @@ xfs_cud_item_size( *nbytes +=3D sizeof(struct xfs_cud_log_format); } =20 +unsigned int xfs_cud_log_space(void) +{ + return xlog_item_space(1, sizeof(struct xfs_cud_log_format)); +} + /* * This is called to fill in the vector of log iovecs for the * given cud log item. We use only 1 iovec, and we point that diff --git a/fs/xfs/xfs_refcount_item.h b/fs/xfs/xfs_refcount_item.h index bfee8f30c63c..0fc3f493342b 100644 --- a/fs/xfs/xfs_refcount_item.h +++ b/fs/xfs/xfs_refcount_item.h @@ -76,4 +76,7 @@ struct xfs_refcount_intent; void xfs_refcount_defer_add(struct xfs_trans *tp, struct xfs_refcount_intent *ri); =20 +unsigned int xfs_cui_log_space(unsigned int nr); +unsigned int xfs_cud_log_space(void); + #endif /* __XFS_REFCOUNT_ITEM_H__ */ diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 89decffe76c8..c99700318ec2 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -77,6 +77,11 @@ xfs_rui_item_size( *nbytes +=3D xfs_rui_log_format_sizeof(ruip->rui_format.rui_nextents); } =20 +unsigned int xfs_rui_log_space(unsigned int nr) +{ + return xlog_item_space(1, xfs_rui_log_format_sizeof(nr)); +} + /* * This is called to fill in the vector of log iovecs for the * given rui log item. We use only 1 iovec, and we point that @@ -180,6 +185,11 @@ xfs_rud_item_size( *nbytes +=3D sizeof(struct xfs_rud_log_format); } =20 +unsigned int xfs_rud_log_space(void) +{ + return xlog_item_space(1, sizeof(struct xfs_rud_log_format)); +} + /* * This is called to fill in the vector of log iovecs for the * given rud log item. We use only 1 iovec, and we point that diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h index 40d331555675..3a99f0117f2d 100644 --- a/fs/xfs/xfs_rmap_item.h +++ b/fs/xfs/xfs_rmap_item.h @@ -75,4 +75,7 @@ struct xfs_rmap_intent; =20 void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri); =20 +unsigned int xfs_rui_log_space(unsigned int nr); +unsigned int xfs_rud_log_space(void); + #endif /* __XFS_RMAP_ITEM_H__ */ --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 95FB327CCF5; Tue, 22 Apr 2025 12:28:40 +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=1745324922; cv=fail; b=lVZ5xMzzcbBPDVpo4Q2ZEi1+9VkGKgAupQwDg+u2Rk13vWWe/hPnU7Og/Z+dpsqLl/AzR3UnzLDjWQoTdjne8D8KiJzPoB9mQfC3Ra0V82s+dRF6CH2LqxVYfS6nr4ibLjAk0wxKIV8N2QdF/EHJLJtxkztRcsMJy2/jz++34ZU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324922; c=relaxed/simple; bh=aBbCgTE+0p+dUqM5/IOXqx+WKdyzVIPaWCYBrY++5Rc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=A9jnvnCD1ZJyCTPIawiPM26yP8P0FXPE8m1N1NcP2sd/L4lu1g/GSNGJTyWMkFWbw3S25o0Z9Pakb9gBxgIfc/QUbTmuUnrluXQT2RyvbhdcdhEqE/DrszB8SKHSZ6JY7m9Wa/+MRehdzhSRtla7JaPheZ/rOiYl2ZQbHHkPUX4= 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=JuV4NP6o; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=iM33A7t0; 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="JuV4NP6o"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="iM33A7t0" 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 53MB3StL026435; Tue, 22 Apr 2025 12:28:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=SKB77eQW3EJ+VRK6VE2kRFRgX+2VOScnIommq5SSPBk=; b= JuV4NP6oEkjaWEOTWdfpcYbA2dOsItHUVYt3avauGxYbcNNVTjsprOdbWVSWKWmb XKu5NzLrSXPd6HhOkT7HrSpO54AzSyXfFsy3hBiBBblQ5hKonE41orIcIgkexpgg fkDm0/THKfQggez1JDaaWlfR1LeI8Xv00qzjxOBnkL4RG4p4c4kqnuXquYFPUQZG SiLg2lHsrxs49PFkdeUv0wZSlmIssiyenl40Bz79BLJZObDdQDPOF4DxSAk/QfVU WSOvcHVana8Q6RBRQGy/h3JrH840QaOtprrT9bmSZFWDDz9sW8UZN2K3twnVWJic a2mHolRIFifLYeR0aDm0Bw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4644csvbsp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBidUb033447; Tue, 22 Apr 2025 12:28:28 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013061.outbound.protection.outlook.com [40.93.20.61]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rng-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rJ+l2GXMJXM4DGjhKl3lP2sBdq1+svIw6Xi/4hYkQ4qTADiViTHYQUHrkegMOtI8RmgrEarkWFmxTG+6Vx2+DqeHq8YW2VjPy70bGzuWrqjoiWh1GSihFzZjbdEDda0PyCVhDm8s+XCQqMxd8ylknbREOvzvrJoMFO+Sy+EvxA4oIUnMZK75RmQMtWZOi+J8i0tftxG+BPEZ470C8X1/dpObX7ybDawnPh8huWQP4DqxZQOnb35yuaoFl7Zg2pg165OAthv/H3YXZ2ZYZzJaV84IDDi4yoVpeYxsDgKP79K6ueqT9B2lDoiBqx1+LNvvpGQjVzM6I30mngUhJcNSbQ== 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=SKB77eQW3EJ+VRK6VE2kRFRgX+2VOScnIommq5SSPBk=; b=Gd6dXM4dgZ8MxDm5NkWEC1WwwBBvr2dRg7O/qyA4gn+wFvvodyXcIofP/JpuemTQjTzGxxaoPRuDnLdwJkCVmWcyHn/EZxAvhI0kPVVqMO3zgvJ//lC2cbCeGYq1iT/6OReXZebnIxlpcOL6yMHWKcYg4axnqhX//oW6w0uTwe6hoU0hVhV0TtDOB+I+d0f1fmninLj1dyXYgsWE7x4ljQ3u/2sv6KDrMkZbGpoNLW8+JQ76DX5k+ha/D5HwICqLd74lDvpwQKMlmRrmdkmWqP+tD6ep45cCNL6Uyrkl03TcdZ+/G8HbHZy7k0Pc9/BTV1UnmV/gNmeDvUTNCP6mcA== 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=SKB77eQW3EJ+VRK6VE2kRFRgX+2VOScnIommq5SSPBk=; b=iM33A7t0zOLpENEAjghEfFTTh/0PpbugcDsmK6FIOtEq94XsVl94YTvaqOB0rNkcOJ51V4zzJx7kX53Wbc+EQOmYYNzXYtt2kAe80kiaW8CdkTpB8V9PBN4RuDr3+RSlBtRPF3VP36guuNBDiOJfaTC++4OwCcMgKU/FUDTsY/g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:26 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:26 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 03/15] xfs: add helpers to compute transaction reservation for finishing intent items Date: Tue, 22 Apr 2025 12:27:27 +0000 Message-Id: <20250422122739.2230121-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BLAPR03CA0131.namprd03.prod.outlook.com (2603:10b6:208:32e::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 56025390-2e76-4711-f5e6-08dd81992e01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DGYtF27lqYa2pcOIs0KsBZoRp7HykNmiyCag/62ClWnDF+l1lt8sfwGMJluy?= =?us-ascii?Q?0/qZ03m1Z5e80ipmYuO8qoWP33eoXzrJohOilqHPDyTyXWH3qZ86wF//Zqrq?= =?us-ascii?Q?ufkxr1IxwxEFUibJtyU29Ych0vJoNVmZkYU5WvzpXhOIZX7YHZPnJqWEWFnc?= =?us-ascii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/YbMs8Da2kABMztIJIvRXifBg60NItVXl?= =?us-ascii?Q?J6Q+kz0/VIBhyH65DOBQUMiqc8TMjFtAlVhKvxtQ49QL5yF6MLPMooVK6zVm?= =?us-ascii?Q?qYDAtBpNJVK2lpdB9P7fqY7P7IL8MvLzdtUsCnTJwsPIDNrg5Uc6rOB44SgG?= =?us-ascii?Q?Cc42ckyKNiZClSd1AMxG3xVKBJ8EBO7gNZ/DHUyQYdnnxSeVEn3hsikFW6qD?= =?us-ascii?Q?x3R2Cpfmy0ArwT7t0bfUlwdcK1aom/TRUuF7oUJaLpN3jmXILZ5ZFqPwMyWf?= =?us-ascii?Q?1YQGTMeEfa4RiObRcttCg9et5hdWxvwMf6QjEkIWHnT1h8tDfGQzdCmVIHc6?= =?us-ascii?Q?cUK1c6tMDqJujA0IR/QaboiJlyYfcjN+Lf08pFmfjQe/tOgSRKEJECJUaDZp?= =?us-ascii?Q?zana7vozlrQ=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Sqng66U2X/W02wDXkl4bjFZOLZ4YQiZaHCXndaN8G22i2Un9yV3MqRtuBUZp?= =?us-ascii?Q?xWwg3gbiFiBTSDI9WfEp2HmCWQaaSm6oNWBBEu8Rst7jAoXYe3YjegyHE9X7?= =?us-ascii?Q?liJspQuahplmmXd1r6slymoswWsgCUmmXgH9XlgwM/cVxd88Hri6DndKu74s?= =?us-ascii?Q?mW0kZgHPSgBDjf6NCzVGKzUofHVDoPxYeitXAYtsZMXp6Ur35/MBeclU9gp2?= =?us-ascii?Q?CpVuKq6T/4Jfcdvq/0SJFsa1btYVvuDiwS+hB1+OaSLYp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gXOSu4KWF2E7gDp+aMeDfLou58qodVH0LAyPGR7jUE1JOY3NsOW4235?= =?us-ascii?Q?EKAzTUp6BGX0hAPiZWVuvkqWEnI1L0al1w0BtUsYFxrHoU7z5DS7JJtgoUEC?= =?us-ascii?Q?zDyVxxAa/KqK/GT97qXlqH58iV0tnXJMpG6XMjWctbar2tmptRPd/YXubKTY?= =?us-ascii?Q?0bLruZbfXsFWpzNAfZrLt2dxzy1yNFT1FoW2ToO7wiDcUI1U1NBoBMhoIki3?= =?us-ascii?Q?u1gJYoD15Nokce1ju8sJ2py+VaDgqzhCSvnrbH8H2aB1Tm3m8FMLrrf9C0Z4?= =?us-ascii?Q?jJmb5x5YQhX5uWWy2fRbY/c05jZqd8JsThwNC+r8c9RWZCTyOa8IxFFO+bX7?= =?us-ascii?Q?VZe2g5mjWl28p6p8QPN+tuwTLqo0k6dhJO+LhtoSeJHOtpPujK+zf2+2ncvi?= =?us-ascii?Q?1k2zm9FJHS+ljeqFOVCnvPA7juXxS4UT+1JyktE08GJAOGMVOKlNGUXmAHKw?= =?us-ascii?Q?WA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: o1BayntMLQLf0uhojFyYfbokBmS7xhp/9pGTgIagjUhCeuTmoy0Leg8KyvxmyOTmEgP226EDiEjE7jdowt7EsVuwEp3U2BzILjZH2xd1PVEiebGn0n8X98JTi1qCz31PYRuA+iaLhXqix2HF/lIVUYkMEKeXdhgLWA7qKtg1rs5AAQXORYYp0CBTEE48LmXRrSpOSuTnLAzGREU/a1PLzuhzc0ivDH8Ah5fcvNreBQlzQBFtiJJkuZu8LgV9pUbs3cIVpmfE1lyCZss/KjDDdcTlbogJyBFTBG9TwK1vknkpHjul2cno3EMbVBQQwdO0UK00qCUjgUIZJJZ7fH1bBa98XhQjKR9dh6D4JT8yGPVAs6PDXXGglvRPfI71BTyDRoLEPKYfVoUfbFdnqfOpZf4qWaIzqlNW9uKcGMiOpQuAFNSX8fcZ+XjCto8E/EzDKwplKc6aH6gBTUQV/d5NBZi8VyDMrt8K6H9IDhTQiHlvHaRSNnw0noCqKtw7XXKdfQzYYYt39I1SkUoibUV2w16L3Cxqx6B9GjfvUwcmKHW9Dz33Fj2cd1IJVJHwth7tqXJTtWTcUDa71y9l+W2TQK1tIomF5A6wb8LfazQFra4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56025390-2e76-4711-f5e6-08dd81992e01 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:25.9715 (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: ZxoTHo4zGnWjpk6Mp9yxEUnG93Pk29KSNtjoKKAarHVjAbl7GGEhLSGRjX/bNdxdRDM6OZjdzDTswg9DZwY9jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-ORIG-GUID: YIWKS6jtb4bw4N7HeFUgr1_RsuPyffDL X-Proofpoint-GUID: YIWKS6jtb4bw4N7HeFUgr1_RsuPyffDL Content-Type: text/plain; charset="utf-8" From: "Darrick J. Wong" In the transaction reservation code, hoist the logic that computes the reservation needed to finish one log intent item into separate helper functions. These will be used in subsequent patches to estimate the number of blocks that an online repair can commit to reaping in the same transaction as the change committing the new data structure. Signed-off-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_trans_resv.c | 165 ++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_trans_resv.h | 18 ++++ 2 files changed, 152 insertions(+), 31 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 13d00c7166e1..580d00ae2857 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -263,6 +263,42 @@ xfs_rtalloc_block_count( * register overflow from temporaries in the calculations. */ =20 +/* + * Finishing a data device refcount updates (t1): + * the agfs of the ags containing the blocks: nr_ops * sector size + * the refcount btrees: nr_ops * 1 trees * (2 * max depth - 1) * block = size + */ +inline unsigned int +xfs_calc_finish_cui_reservation( + struct xfs_mount *mp, + unsigned int nr_ops) +{ + if (!xfs_has_reflink(mp)) + return 0; + + return xfs_calc_buf_res(nr_ops, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_refcountbt_block_count(mp, nr_ops), + mp->m_sb.sb_blocksize); +} + +/* + * Realtime refcount updates (t2); + * the rt refcount inode + * the rtrefcount btrees: nr_ops * 1 trees * (2 * max depth - 1) * bloc= k size + */ +inline unsigned int +xfs_calc_finish_rt_cui_reservation( + struct xfs_mount *mp, + unsigned int nr_ops) +{ + if (!xfs_has_rtreflink(mp)) + return 0; + + return xfs_calc_inode_res(mp, 1) + + xfs_calc_buf_res(xfs_rtrefcountbt_block_count(mp, nr_ops), + mp->m_sb.sb_blocksize); +} + /* * Compute the log reservation required to handle the refcount update * transaction. Refcount updates are always done via deferred log items. @@ -280,19 +316,10 @@ xfs_calc_refcountbt_reservation( struct xfs_mount *mp, unsigned int nr_ops) { - unsigned int blksz =3D XFS_FSB_TO_B(mp, 1); - unsigned int t1, t2 =3D 0; + unsigned int t1, t2; =20 - if (!xfs_has_reflink(mp)) - return 0; - - t1 =3D xfs_calc_buf_res(nr_ops, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_refcountbt_block_count(mp, nr_ops), blksz); - - if (xfs_has_realtime(mp)) - t2 =3D xfs_calc_inode_res(mp, 1) + - xfs_calc_buf_res(xfs_rtrefcountbt_block_count(mp, nr_ops), - blksz); + t1 =3D xfs_calc_finish_cui_reservation(mp, nr_ops); + t2 =3D xfs_calc_finish_rt_cui_reservation(mp, nr_ops); =20 return max(t1, t2); } @@ -379,6 +406,96 @@ xfs_calc_write_reservation_minlogsize( return xfs_calc_write_reservation(mp, true); } =20 +/* + * Finishing an EFI can free the blocks and bmap blocks (t2): + * the agf for each of the ags: nr * sector size + * the agfl for each of the ags: nr * sector size + * the super block to reflect the freed blocks: sector size + * worst case split in allocation btrees per extent assuming nr extents: + * nr exts * 2 trees * (2 * max depth - 1) * block size + */ +inline unsigned int +xfs_calc_finish_efi_reservation( + struct xfs_mount *mp, + unsigned int nr) +{ + return xfs_calc_buf_res((2 * nr) + 1, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_allocfree_block_count(mp, nr), + mp->m_sb.sb_blocksize); +} + +/* + * Or, if it's a realtime file (t3): + * the agf for each of the ags: 2 * sector size + * the agfl for each of the ags: 2 * sector size + * the super block to reflect the freed blocks: sector size + * the realtime bitmap: + * 2 exts * ((XFS_BMBT_MAX_EXTLEN / rtextsize) / NBBY) bytes + * the realtime summary: 2 exts * 1 block + * worst case split in allocation btrees per extent assuming 2 extents: + * 2 exts * 2 trees * (2 * max depth - 1) * block size + */ +inline unsigned int +xfs_calc_finish_rt_efi_reservation( + struct xfs_mount *mp, + unsigned int nr) +{ + if (!xfs_has_realtime(mp)) + return 0; + + return xfs_calc_buf_res((2 * nr) + 1, mp->m_sb.sb_sectsize) + + xfs_calc_buf_res(xfs_rtalloc_block_count(mp, nr), + mp->m_sb.sb_blocksize) + + xfs_calc_buf_res(xfs_allocfree_block_count(mp, nr), + mp->m_sb.sb_blocksize); +} + +/* + * Finishing an RUI is the same as an EFI. We can split the rmap btree tw= ice + * on each end of the record, and that can cause the AGFL to be refilled or + * emptied out. + */ +inline unsigned int +xfs_calc_finish_rui_reservation( + struct xfs_mount *mp, + unsigned int nr) +{ + if (!xfs_has_rmapbt(mp)) + return 0; + return xfs_calc_finish_efi_reservation(mp, nr); +} + +/* + * Finishing an RUI is the same as an EFI. We can split the rmap btree tw= ice + * on each end of the record, and that can cause the AGFL to be refilled or + * emptied out. + */ +inline unsigned int +xfs_calc_finish_rt_rui_reservation( + struct xfs_mount *mp, + unsigned int nr) +{ + if (!xfs_has_rtrmapbt(mp)) + return 0; + return xfs_calc_finish_rt_efi_reservation(mp, nr); +} + +/* + * In finishing a BUI, we can modify: + * the inode being truncated: inode size + * dquots + * the inode's bmap btree: (max depth + 1) * block size + */ +inline unsigned int +xfs_calc_finish_bui_reservation( + struct xfs_mount *mp, + unsigned int nr) +{ + return xfs_calc_inode_res(mp, 1) + XFS_DQUOT_LOGRES + + xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1, + mp->m_sb.sb_blocksize); +} + /* * In truncating a file we free up to two extents at once. We can modify = (t1): * the inode being truncated: inode size @@ -411,16 +528,8 @@ xfs_calc_itruncate_reservation( t1 =3D xfs_calc_inode_res(mp, 1) + xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1, blksz); =20 - t2 =3D xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 4), blksz); - - if (xfs_has_realtime(mp)) { - t3 =3D xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_rtalloc_block_count(mp, 2), blksz) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 2), blksz); - } else { - t3 =3D 0; - } + t2 =3D xfs_calc_finish_efi_reservation(mp, 4); + t3 =3D xfs_calc_finish_rt_efi_reservation(mp, 2); =20 /* * In the early days of reflink, we included enough reservation to log @@ -501,9 +610,7 @@ xfs_calc_rename_reservation( xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); =20 - t2 =3D xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 3), - XFS_FSB_TO_B(mp, 1)); + t2 =3D xfs_calc_finish_efi_reservation(mp, 3); =20 if (xfs_has_parent(mp)) { unsigned int rename_overhead, exchange_overhead; @@ -611,9 +718,7 @@ xfs_calc_link_reservation( overhead +=3D xfs_calc_iunlink_remove_reservation(mp); t1 =3D xfs_calc_inode_res(mp, 2) + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); - t2 =3D xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 1), - XFS_FSB_TO_B(mp, 1)); + t2 =3D xfs_calc_finish_efi_reservation(mp, 1); =20 if (xfs_has_parent(mp)) { t3 =3D resp->tr_attrsetm.tr_logres; @@ -676,9 +781,7 @@ xfs_calc_remove_reservation( =20 t1 =3D xfs_calc_inode_res(mp, 2) + xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)); - t2 =3D xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) + - xfs_calc_buf_res(xfs_allocfree_block_count(mp, 2), - XFS_FSB_TO_B(mp, 1)); + t2 =3D xfs_calc_finish_efi_reservation(mp, 2); =20 if (xfs_has_parent(mp)) { t3 =3D resp->tr_attrrm.tr_logres; diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 0554b9d775d2..d9d0032cbbc5 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -98,6 +98,24 @@ struct xfs_trans_resv { void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp= ); uint xfs_allocfree_block_count(struct xfs_mount *mp, uint num_ops); =20 +unsigned int xfs_calc_finish_bui_reservation(struct xfs_mount *mp, + unsigned int nr_ops); + +unsigned int xfs_calc_finish_efi_reservation(struct xfs_mount *mp, + unsigned int nr_ops); +unsigned int xfs_calc_finish_rt_efi_reservation(struct xfs_mount *mp, + unsigned int nr_ops); + +unsigned int xfs_calc_finish_rui_reservation(struct xfs_mount *mp, + unsigned int nr_ops); +unsigned int xfs_calc_finish_rt_rui_reservation(struct xfs_mount *mp, + unsigned int nr_ops); + +unsigned int xfs_calc_finish_cui_reservation(struct xfs_mount *mp, + unsigned int nr_ops); +unsigned int xfs_calc_finish_rt_cui_reservation(struct xfs_mount *mp, + unsigned int nr_ops); + unsigned int xfs_calc_itruncate_reservation_minlogsize(struct xfs_mount *m= p); unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp); unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *= mp); --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 5925E280A34; Tue, 22 Apr 2025 12:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324926; cv=fail; b=djjhLMxLSjdCoieQwifvPPqeGoSGksp4ACJrF2+o9pC+ek7A576BYvJdeZ4mngR03PmwjZ+Rl+0AT8aXOvywDFZL8UrE+ac5/8FW38dRCQMdaRBsig5WkrNOhPNz+hzgEuevHIyCGxM0xpZZikgxKhTitpIAtxOUdD84G+BZLRE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324926; c=relaxed/simple; bh=uCBAHIwzOHfSVKzZlKkW1q67smiS3MDfGRHT0qxYps8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RFujxKpQelrqO0tbK/0Wnu54noqThkU87yVefQ1WakQjLZh9DA+JBA3CJJSuIYArDePy48BM+vJF0Gvw9uW2baUpOeSebWvcGAeS25PrY5fKpLJa/dfGEsysHGrlm3iuFjmAGx/0CBQ0TsPU8ubLRc16QpFlFppItlC3YY21UGg= 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=SV05gqET; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=SXGEW9fU; 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="SV05gqET"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="SXGEW9fU" 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 53MB3DPm003573; Tue, 22 Apr 2025 12:28:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=67/9CFyF1gou1Kj+l1xhrXDmc1NJI+e1nQgbHzsia7A=; b= SV05gqETjlGlEiS8DO4uRXJfrtCA9V/0tfvhTZJC0Q41uWZVIVCfP072sHiZtB4n XXAGPZ/5Hk96rbsmAr66DzrwyUrerJ4O9/RrXZNkh2DR4WbbnaHZDjLP/9IGWT5N bRvTh4QciPmR8ZC6tU+Jrg4NTsjVbtU0eUL4gN1FPp5p/99wDBWBMGxbO/IHMpRj nx7dMcsrzUzoluYi4JlI9QdalAnZIGxZ1ClQrlSLg/t+NnGG/lJ7ITZ6rPV3kEFR UiUlJPyPQ+zQGxbJQXrnR2Mwc8OYiLpva90FuyTTzFxf6AZXbtGEZhgloRkQtPmE z+PwelgzNP1aZHUhFxi09Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4643q8vbu8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:30 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBF6xq033451; Tue, 22 Apr 2025 12:28:30 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013061.outbound.protection.outlook.com [40.93.20.61]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dn2Lm06sLPQvXXFAA64mM8ywq/1FecgVaTXOADrdpWfyAFwomtzwL6ei8A8+F/sWc8SNlBQFQzHk9uP5j2pfsC82cIV7RG2FYQPx0SxXxDw6veBHgdYuOMOb69DrfwmSAsABw8Id2DtoUfxy2CaeUTRVJMuffYYyeiGKpkdf2IchLLr2ZepqaXIv2Uw9/QkKkGEzlY4yeBeQIaKaGKqn5m3i3aMrEhG7aaALQZPchOIVZkSLFiSDIY0RpPkY/IczbxHpjzaxl8EXimUYju/skHDOVebMY70ztubatGhque2bB2k5ArWfzsCmv4BSGG9vdYDh8yW/W/En0FXvojapdw== 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=67/9CFyF1gou1Kj+l1xhrXDmc1NJI+e1nQgbHzsia7A=; b=y5uHTuHkHr7qQZ2585R+cFv2GxGUhFSyZduuMO7Dhv09znZAi5iBV7U3NjADqcL4vfT16M9fMc4lZ5ZkiHXpTsUhMTwLjxZf/gu4imsHsSGDcxr09JRJtfK7Evqw81uonEqHcc6R8EzFEzwUYb+grQvKemH6+E7l3oneYpZUnqEYSrtaLXzGaJdOvf9mOD6YXO0GDvGml4r25mEPPOpSJIJEIbYnJ+sRkNlLabGvHmiXEapSeqvbFh74bcX4uCC5r4Nc30E/+0+LUDy4JM1OH5YRh5d7AjIGXHKazUqAq6OkCKFFXl0JnU2O4MytNeoq3Dpn0XBKNTiU26oD59JpSA== 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=67/9CFyF1gou1Kj+l1xhrXDmc1NJI+e1nQgbHzsia7A=; b=SXGEW9fU+bXjUaBK7OIXqcCMojIDbO7oJtHY5NcsI6eF+da7VOFaLKwOiPcG3MqC8NJu7Avdw1jCfVOigjbdFIdX48cZBDlwG9Qb9n33rwlJnbOeapxi4wuBcMWoJ2s7w34Qa6MGNXG+uCgsDD2pLHtxcCScu5OnynW1iPMuja0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:27 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:27 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 04/15] xfs: rename xfs_inode_can_atomicwrite() -> xfs_inode_can_hw_atomicwrite() Date: Tue, 22 Apr 2025 12:27:28 +0000 Message-Id: <20250422122739.2230121-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR08CA0023.namprd08.prod.outlook.com (2603:10b6:208:239::28) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: d554dbd8-2168-41a7-f39c-08dd81992f0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8csBhntcsmymtMQGlivd/pJgBn02gISzIzxzmjuPUsE7ec4Foy+MHAxbV613?= =?us-ascii?Q?H0pxZzJ0qvapuwcqO+d1g2ZH4+sQ9MGUq8wH+F50DfGVZRt2EqUFfF34CJJX?= =?us-ascii?Q?V7iLip+9HhDWhQMH2253F+MD47HG7IwWVeQTebC8L6bAdJgJbzZz+z/q5K+J?= =?us-ascii?Q?WuQ/tyIdm2c5FHckSwmMk5lkwt7Qlu0D3qudnmhI4HF5Qs1sQLOfklU8kI2f?= =?us-ascii?Q?1VGD60L/tmTbs0P4y+cyxFfrTxx6UAx5seqok2YD364O+I8jkO6DYEeaI3L2?= =?us-ascii?Q?MCxmPEb1S/io30wBPWGR4exh/P3yJk64GJ7h9FSfJ2vkkf+PJLmdm+C9iibs?= =?us-ascii?Q?edW5kNk4ZUfX70Jxzuk6U4pZQCajcimVMQUfJBWkJCj0r54wMI47NHPS+wY7?= =?us-ascii?Q?/FNmemMgKB1ImW4tsjAt6xASElYgz5DWYW/ZfOk5kgojGMOA8AI9tcKVDMLN?= =?us-ascii?Q?abuZ7Ug32DoCnra1PnpFawDfB5o7Sg22uVZQ1JDHRq21kBBOWYUfNH+dan92?= =?us-ascii?Q?CBurCSkVTPa51tfOoT/fGIgh4M/2wvvutq28A7iNXTSUbUQ1fxf+iL+RNVZX?= =?us-ascii?Q?MTlo13X6gh1Xiy7l6/ru8huqQSTxKPMtCZPZSRTnsmNgaurcZ9mX2hFeYqjn?= =?us-ascii?Q?pnoje+lhwB62Wj3FGF+3BAwtX8qRbH5NzKwrIWyFiG4xjSn4QYhjZgICDxVZ?= =?us-ascii?Q?Uw3xX5NckhrZ9Vgw/SDdKPqbExRMoLvrwfrcU4xOaoI66KPPT0aAUdpN1aFV?= =?us-ascii?Q?MQIQGEqtNOUxE14lNdsC3IoMv7IT2QW+k95JucrZIjJJ8ks6ceTEJcj/Zaxr?= =?us-ascii?Q?3qy30Fcltt+nI8fLaxxF9qokslI0U2+JteCnT87iAs12RKzQxHsOjPyko3Oa?= =?us-ascii?Q?cSy6s1fHMKYoqAAHUvyCUHZxyCd93NfeOYjPi9Bl8nMggIXwscqkht5BQaBI?= =?us-ascii?Q?JX3I7qEMhQBDfQvJj9qbW+pjAvEbYC8hxNOKqsMFC5q2jyvL3DCIph36YAlS?= =?us-ascii?Q?6MoAuXyFs6RCKOr5mnRwEJUQmGtltuQhb04UefstsHbW2XbE5gNs1ODqoKOl?= =?us-ascii?Q?YW1NDKxfJKZSEoUajoqjSQ4UG1iUMQEE6UBNM0JZXlVGNbzM8D+oRNYEo0Az?= =?us-ascii?Q?rRbRvUJLcamzlSISRJaae3lfJNK3KwPxc2Ra2Ykuys1Ioe8thiHSTiu8xfJ4?= =?us-ascii?Q?igHYqdcc9HqMKEL04NODLBoasr0WJOU7GaDDqLSdHImZnOnZ92hwwLyKkMiW?= =?us-ascii?Q?7ZQXVZ5Pu83AcCg9VXnrZiWRuIjldCkTdVDxjP1305KDhWvexj1aP7qCPyj6?= =?us-ascii?Q?P76UgCqdenhus9TZVQtE4MUCD5MMlXeUaTa8maOdz544OipjXKVccnB0U+/4?= =?us-ascii?Q?cRLk3A9y5H1tiiVrxCjLiPMX+Eo/2VdtnPkvj2KgL04G7Ul89w=3D=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MMV0C0APUqDSJL/EB/fJjsWSvegzTVfbd7H1JVVmjL+PMKF8ciq2YgdNNaS+?= =?us-ascii?Q?I7rYSHWkD0/hi2H6TJUoKVf3QYOM4M/lP/m3JJgMLqOrxBEXOip+ME3HUmzH?= =?us-ascii?Q?w3B/Ez3VBNbNvwIVeRyAJeD7CPuo12DxLiOh1zXxRnU2NuXPzM817ovolEKK?= =?us-ascii?Q?Rqin4RdkHlGL8KfodSC+rRw9ynmnUjOI7ahv+OLnNNurOQ0x3mDvNl2RLd1+?= =?us-ascii?Q?kD5cdVfeohNjyRGCTg0mzMB9pNCsU2hD0HkJmDCsaWlOFdtk4XKBwYij9IDs?= =?us-ascii?Q?3JLRQQb2HcOAuFYgDg1cAQmlrtVUqoxoyGsJygYqWL8f1P6CEv8eX2Ph8qJM?= =?us-ascii?Q?s84+rhTSRGWm5N0SaBgVGkZjHmUkSg3QCK0xYSlrjpolOIRu2X/4H4Jix6fg?= =?us-ascii?Q?dnhjvDQ2rMSSUmIIh6OSYq3FkobsFhNh5i0ELCur2fPPaA5KBv9N8KY8FMQk?= =?us-ascii?Q?xd55FO7RQnVpfiXEQGH/lgpmJXlxNW5dSCquMoAKsPA3XzU4Vf8xlYxLFWVD?= =?us-ascii?Q?84ohLvX9Ps75YFR1Ggf9fDd+igJnMW9iexrmXcg1PSmTJNLs9Njs5mIn+YLU?= =?us-ascii?Q?hvOP7Zq/Tpur4KntPVTCtAdz8oZ+I2zjwKgiA3R2THwWRUHM2c+hTBbyeAWb?= =?us-ascii?Q?EfRax/3tD3aIYI1mjaFzQD/OGHija4MvKppYh924c72t2FwwWuBn5iqa01nG?= =?us-ascii?Q?dUFk/Rd9YgfBt4ooPOR3FKNa9eN7BwB7OSviQGrT67uRlssjra7CGkY6NyLh?= =?us-ascii?Q?V9koSlilJjy91S1/DklB/JTjLtA3mrEV3aLfyud7H0moh/Z81sAABswl1MHc?= =?us-ascii?Q?B+bdT6UWYFtiJceZEpWM4ECDxF/nnMoWLw6webVIygWWxbHJvBdU5uzaG25z?= =?us-ascii?Q?Chn3I1aDnVV7e4diEexgzxx3vdAZzojOyNJys87NiHMXAFmTSGfsbOq2TgE4?= =?us-ascii?Q?UrW41bqoJzkLyXFXONHcyd0uatY6Bub0rn0WLeJYjlVLBDthCcwQE/LkM/VD?= =?us-ascii?Q?EwhzKBKSylj4XWUEysuFnZBPTZStGafvxDmE8yu+MFYu4z28VNd8aB0dQkTY?= =?us-ascii?Q?A0KTBzSgMAlHF3IVLsgDfdhZvpUr5z/PpkVOqkT0jJubbiuko3GRihtFgKek?= =?us-ascii?Q?nROuFu4m89PEpZJFA4UsTw3QJJ94bbVRsCQYLqFtiq9B5wnnpHHZ2baYmKge?= =?us-ascii?Q?fUG8BFO9uxquoIb9+pTzAvnY6/Q2DL860PxDe3x0ZkL8do7m9G326vhQ4RK4?= =?us-ascii?Q?Orh1swOfsyMCH6/CQjffmGwX77oCdLLLkjPwf3Cp6Pf0hlReclx4SP/aeDoR?= =?us-ascii?Q?VqQZSmzfGf8WQ1oopH1dj7YD3Azr0XH4VVmSB/2u4b0KFSgWm35AaSy373nt?= =?us-ascii?Q?WHhKNvkmSKeemX9LX26nmMesP/UnQm0pZ8SkQ5Sr00qRZpXQwDVipE/QOC2v?= =?us-ascii?Q?l6tjmFKL9n3anBaBziZpjmkAwk+hP5kMk7tkbhg+ekT0cwwBF27BTPuaOiWQ?= =?us-ascii?Q?ZhZNCjczvhTSwW25MGiR0wJzeFWlhmTFkUWWVmRNzYUmx9b95HP/qoFS2y69?= =?us-ascii?Q?EDTYutWmgEitLGabUbokozD0fWvBr/uXVLQ48eCRDdFR1TtrDJOTElpC9K6N?= =?us-ascii?Q?Ow=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: g+B7zEx8XvDtYBNAZ8EGqBkg/s8h+UX4J7c48cxBm3cdbqMbg/kts6+N6NCgvEAjg873RQf1xNa/+UPZHQKn8R3aAXHzK2Krzt6PfRHS0V0hVQpQXB5zQ2fB/GzJtM0N5ipuWAhpaLZo5DMBkxU7Rp84JQo8A6Bnfbya35rb4odvlyBS5oMKupagSIvEWPFZYyDFDubXmMqv2avl68x68ax30wgZ4OagvoIYuSq7Ld6gl8Xzg0NdYUbCaRveD+4npcvbAodwcKAFQ8V/pTIQwRU/IiOWtE6Y1CQCcqaCK7l2bE6LKiNAa7Qy6WhgI3IcHRso82MCQXghwok2vqIp24wnVJLAoxXZLYZPueasG6Uq8AGGj1SUDotp36/8IJf4x141JCdSdT/SpwxyuXZFGk0II3aR2LMgNqThwq3wr74g9a0Kl95cUNijavqH2azyW35drEtfd/hAoUw7bAp0JkQkzWWG96cXU8D84VHf+9ffVkR7uQic/E5rd2OOexr/tET1+0gEzhRWpKKPYKUj+rqV7XBNJG5+u3e3yrtsI3T22WGDNGrC2QajQxmhvB2qixJE+euoSmnMv0jmQ5VBDgc/x6IthKjZ/Wbda/0pwEw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d554dbd8-2168-41a7-f39c-08dd81992f0e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:27.7558 (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: gJb25T4gQJkBMUO/Ojzp/WCE5u4X3OG4HmNODoKQckSrnaH/26m9t2pOG/EpWXgEFmbQepGfb1zOZ7SnAPlZsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: u0eG7kcT2HD5DKR8S8lJeuW5LdWEG_hJ X-Proofpoint-ORIG-GUID: u0eG7kcT2HD5DKR8S8lJeuW5LdWEG_hJ Content-Type: text/plain; charset="utf-8" In future we will want to be able to check if specifically HW offload-based atomic writes are possible, so rename xfs_inode_can_atomicwrite() -> xfs_inode_can_hw_atomicwrite(). Signed-off-by: John Garry Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: "Darrick J. Wong" --- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_inode.h | 2 +- fs/xfs/xfs_iops.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 84f08c976ac4..653e42ccc0c3 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1488,7 +1488,7 @@ xfs_file_open( if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; file->f_mode |=3D FMODE_NOWAIT | FMODE_CAN_ODIRECT; - if (xfs_inode_can_atomicwrite(XFS_I(inode))) + if (xfs_inode_can_hw_atomicwrite(XFS_I(inode))) file->f_mode |=3D FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index eae0159983ca..cff643cd03fc 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -357,7 +357,7 @@ static inline bool xfs_inode_has_bigrtalloc(const struc= t xfs_inode *ip) (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp) =20 static inline bool -xfs_inode_can_atomicwrite( +xfs_inode_can_hw_atomicwrite( struct xfs_inode *ip) { struct xfs_mount *mp =3D ip->i_mount; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index f0e5d83195df..d324044a2225 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -608,7 +608,7 @@ xfs_report_atomic_write( { unsigned int unit_min =3D 0, unit_max =3D 0; =20 - if (xfs_inode_can_atomicwrite(ip)) + if (xfs_inode_can_hw_atomicwrite(ip)) unit_min =3D unit_max =3D ip->i_mount->m_sb.sb_blocksize; generic_fill_statx_atomic_writes(stat, unit_min, unit_max, 0); } --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 518B227F738; Tue, 22 Apr 2025 12:28:43 +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=1745324925; cv=fail; b=hmHWduems4s62oFKM3KV3olpRqsf8tnczTHUFy9KaO9DPHOgXjprNE3wdH4rJcn9T6YqVrqj9eWhba1twL4YcfzoFwNfZBTvr04+YSv/c5MVNH8H1XyFaJcjNLWJBgALTekFfrn2Tgh5zGgozMk3+nhk5aFoLdP2B40rEYm73v0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324925; c=relaxed/simple; bh=FsyFnFDYqSl2HKnrjzAMq7c4nScevavVKjIcGi9TEDo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dh8KVuwZXetdq5cKVe96vpsUW95Zqvm1KUM2ohb9LRwwyCIel2NUnm+PAyx1z/YlK4xgq+KquUgom5ymJKJh6pVWvdWWWvxyzudP8u47EaOFsbf2PvCfL1qEBhhJGSBDrZLA2bsEpb70xLCYjBsDYGCA2d+MHlKHh2Pe929Jd9w= 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=KyYe05r/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OUX/6BRt; 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="KyYe05r/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OUX/6BRt" 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 53MB3C90008318; Tue, 22 Apr 2025 12:28:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=nAjtxvjlIrTPgGkbTa6pwP1QEnFKo2ZRlWGI9o3w8j0=; b= KyYe05r/DyRgrLOshiNtlj05oPz0BcMTLsrT6oDJIBbiucr8D9CR9EBMBrbG0j7h ajy7T7rQ6hk8i6KnAJwOKZBRaeRf+vsmBdKQZ3fN32vmspxkJ4zFrQtoCkzNGqbW OslyhPbzHO/ktbAiQ4cH0qeOlIYvy5PG9hbG1R1e/l9pJ3188TRy0K0xaey9YyZr FJa4xa+Q9rakpbC7v7wmUpxBgPwUOiSyxmNjl3SBxA88fKcPOiI0j4EiZqxcAz2Y S+59hRmvxYAs5QjsoEw3bBm5kdIFYZAHpx1InjLnRMDOX9800T9kiJCe13KuJkax UTGKlLvIoDzlysmZ6F6eCQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cde1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:31 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBF6xt033451; Tue, 22 Apr 2025 12:28:31 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013061.outbound.protection.outlook.com [40.93.20.61]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rq9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ca1MAO/o7t+MsRErM4AqD7Gts6Te4MpJjMRvwC3hsfZoDNoK4+fWR5Rsi76ocNzQS+qkHIwHJG6iVfCJwo6dQjwPybE+93TjpC0X7N57wzkqHxHF4llmFr3e1vfY/s3DGccTAS7BaFZmEJzCt1f81j6j2OmLGddm9Mku/zR0BlzxN2F3ZZuqylB4YyA6zE2OcKayL/PLQfBfmriztDxvQxXTCch39cQA2YTB7VTJYX9KX8fgReMU21YcKxqqSYBh2K78aYdA7VguTPYJJQgADXz9ZgXyHsGHK2co5Adn29brXAWGiosrAB3JON4ht8KRfg3zt9d64cQ3wFWjto/w1Q== 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=nAjtxvjlIrTPgGkbTa6pwP1QEnFKo2ZRlWGI9o3w8j0=; b=pptWMHAYSiSmmDgN2XaQxyBpOz7wLD8J2Ri+uKlCqXH0NjIeNRv5TSpG4XDal1q+eftPTk3uYYbb/coVt8T+urwlqZdxbkpPaR27PZegQQwf4OYKpQo36fajVlGZU3vOiXZYvD4TdRN59yyDLLwAnpBpmSwl5xJAwiqKQtkpBixHsNwqOT+RzfNu+Tyzv49YVcMEK/wAprw0mMSR+UPc2q93mdRBeXO/OzUEbRC8tJbqwhXaDoYvsUQjgQN1/dCEKTyI9382Y4uEfYx4VL1xItdvH4A72Xh80LzFsvpTRfg79zndcY53r9rWbXJsjJd9WdOAp+PfaBbyIUlaDpMjYg== 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=nAjtxvjlIrTPgGkbTa6pwP1QEnFKo2ZRlWGI9o3w8j0=; b=OUX/6BRtj3he/L7H7WJSbAdaaNvU1SG5scWtcw3xZdsCc4ugSPHKRaMLYX1+wy9M5T4f7VZephRG+E4VyOsq74uzZO0tbPhLoTV8cXHZW2N4TrbsDjETgbUAj2JYjjM/5RhVG1+Wd7/fVVFgWYpakhdsUbl83m7/V2ymBANrGjc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:29 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:29 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 05/15] xfs: ignore HW which cannot atomic write a single block Date: Tue, 22 Apr 2025 12:27:29 +0000 Message-Id: <20250422122739.2230121-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::24) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 03f8684d-a106-4520-dd79-08dd81992fd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Bu9+QoFx838Pqc97q67/YMX3nZ0r2/erAeuE6aTQnkqWqkBnF/VV97jZbPB9?= =?us-ascii?Q?S9JMBWT9cnaT+GSiJHXdPiBg8y714OjOu0H6Vp+jC/5+Bo3Qyd5LJ5Yvc1ME?= =?us-ascii?Q?u9AMAjZOiG0oeVB0hS3wEBsdbOGEhGLlzhMD03WrKrF2w+gopZoMPlb+0RUG?= =?us-ascii?Q?9g6M0xMWZATJg068JeovifxzVotq3WVnizRNiTdhYmV7cFdZlATiQjjr4mNR?= =?us-ascii?Q?yB0/aoemrmm/UKCVmZwc0vnMuxR8vp7DKjawvvQ4vdGmOhUdNCTztHQTDr1y?= =?us-ascii?Q?lJw/gx1PSq9gCn+gb0XV2IDt6Hz96h4qMxVcQ/inQe+NYvqYHB19BLQivMG6?= =?us-ascii?Q?xsLSxT2qqTIi1iJ5E/Hcgz9N7kOkaGwmAp1bL7E8h/l2wUpFSB4OS2oxHRiD?= =?us-ascii?Q?Mu4RqmxpwlAO3CwwBmV105jrMCFdm4IHE95EF295+A0nfny+F8xLT1KydpNF?= =?us-ascii?Q?i4yT35VpnIkbxYVPKHGzIRWzYLYb4jY/xGtup6vJ8bJTKvRq8iSKVk0MqJNd?= =?us-ascii?Q?M5EfCRXk4YcgFNXzGiUPqifYPPZOIBZIq4dIzKBJwghtk1aPfy8mzqAREBvx?= =?us-ascii?Q?eUrRi6lUZGuBxljTXAI0Vplem4EmhnRQAaTNFztwvLwJ83nu/84glNDjhflh?= =?us-ascii?Q?2r3n2/WNs6Y+EcSvZcK1J4wM+dszGIglT2FQKhHbu1Diw2fwXpH1OQ/vmp+7?= =?us-ascii?Q?29Dp8hgj/ECD1AtkfoRGEm1ePl2+4KLmgspn959fZd6FUXHfF4hWPTsyGgGL?= =?us-ascii?Q?Mh9z0aUVqFACd2a5n+cNqKznLSfooEfQjHDPLYzaWM7MBvx0UXBd9b9jxChX?= =?us-ascii?Q?lIuZ0TF2n5+sZ8di8vLicD58dMxbAVGRzjKJirfLAhDrDcNBx0scYUgPhBn/?= =?us-ascii?Q?Ouoz8mU4SUOBm+qriI1eVaBZtsHKUUNU3FgZk8LXkXjuiA/38b78rOYs0QPT?= =?us-ascii?Q?6sbeSobNgskDvp7p3z04iJz8FApydVxnbMeImmJBrNVG+81OsodOREh+zfYB?= =?us-ascii?Q?1vR0ymfK8+oOsJEKdcD/D1/igA8W8r/YwOgzPiWcNSmyj+S4K9LZrAW4qEYK?= =?us-ascii?Q?jvsCD1hgMEVbASwjJjB2mdVb5mKSk80gR57KKkoxlB/jLLXbHXmhIs6DOmE2?= =?us-ascii?Q?T//UDLQotklcsrnnlurKgeaCnR8+1jrI1NX5eR5qCRPPX+ncYMOiaivTZgIW?= =?us-ascii?Q?MUsWGwjRN0JJOahGgcNCx4X773JHCsQWNWEZP/oHEsAlgk2ElsSLKHYK3f80?= =?us-ascii?Q?WI6z07El5rlf6YWYeez5ZaxI1943u1xtLIXVF5lk4aYHtOZPpdzQrUSfF17/?= =?us-ascii?Q?fsZx8lz9T3jwJEKpFDFvURa8Q0jqHEIxFjMoOxGrNJKdZZyNrIHCmKDEuUm0?= =?us-ascii?Q?21O7kIEaPKUaKS1l54MQlwMxfhEya7gEazLFvYoV0p3im0COxBRee7vPMJm1?= =?us-ascii?Q?LYs7tZuzTe4=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aDyd+LVf15ShlGJPCrXPI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ii?Q?r7MX7DtDsP/caD53y0YDO0QjPlkwgFqLf6fl5++guOGbXoBv839m1Vj3zLTm?= =?us-ascii?Q?/svFXAabj17u0rv+NjIz21zWeI2Ve5kZArN8xcEzFv3cnnmvsMGnB84DEi2I?= =?us-ascii?Q?nC/9jssw4PN/AoIiulonR4FulkQtDhMUwudtW/5RPJ/vdqiaufw+b8in2dPv?= =?us-ascii?Q?D7p17b/u+lFBO7H4GVtIAnJukeWqqSIfoHbEc8D1XToML7lHomkkovfwzAn7?= =?us-ascii?Q?YlxCGYFQsJQeBSs4DkBkXMYRehDMXVy1bvjTj8lKpjsRHTj0/ZP5z57tnuiN?= =?us-ascii?Q?Dvm96EfgVPKIZdG0DqDB/L5EHMpZpCWbWt6D1BneAwQj89vbgljw3ghY3oZQ?= =?us-ascii?Q?QwEfeh86JRDEQiIDfBhjOeZ4U+uATnNqjTdtFUHUAtb1hisFKk5ASqR3GYIN?= =?us-ascii?Q?4qB+wyh8++tMeOtwRhEs4rwAjBEBdSIJieP89p0ICxq13b3KyvIkZL3/x2xu?= =?us-ascii?Q?HLupmaGPLF3shMF9YZzho1U/j76vupT3+Cr8bsqpa8AbyztO8Hccm8qGXlER?= =?us-ascii?Q?QjvYe+xdexEubGom1nK+DGb+SqXr23NqAuuxosvFok2VNbrNxZRVXdySf8sb?= =?us-ascii?Q?oktPyIrNV+avrztOkd36b1XorTnO4VTwETKEE8nRodVxtwt8/LsAEQHXjSqu?= =?us-ascii?Q?YR6DXy9Fj0X+/2gnbMaWG72Deik/XzW1Esknj1CEyex3BFguZW4xVNgHmMYs?= =?us-ascii?Q?xQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XYBuJ5ISEZqHh+ze4N5/mI4aa/9621+xYY2OtF8ZN4r7W/mOkC5wzKayEzNI3dkgaVOiOe2tC9yaEOgu3ejO4Q8i91GEa2uBiqxXaPLngICpOi6bBMgfV6C4iNNn5I6WrGL3bnRnMPUpjwyHLtMxx8Ui4yU8Re7B2EWDnWu2UqDfWWlrEHHWSL8E7xNJTJwIbYTDQfGxoyQ9hrAN+PyykWz8nEkF5wrbDaBOu/UnZuOdfDdhQwSLnW+0L0uCX37gZQIdIIo/jc6C2oOMIhDaPcfLS7M2aWCxBjL0qXnjPShz09fcLRXm/8Pm3U1zlow9rePFhWTGN/MpN3RkGDBKEk9mWKd6HG4SIyvNIZPXu8+ARpvXQk3WLSoHT6Ugm5U5kJh3CbZRP7oyQmCYCJQFlBvoRJ9LhR2dLIngNEtBERhVP0Z5iQgcfwnj8+Kka2t96lte1vTDCORmLkOsYadtkJbB3BhaG/+FAZMt9mInImauBhis+dPgsfrHKjhe9dFiPWpXMKvdoDNbWAl1xSDuooJE5ZkVmTpd5QHb/ryeAJFClqvVfuiqbdvjv+yI0VhKzf1fwfBbAbHCX7Yh2WXZjeucNJlXP1CnR+ja6AiegpI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03f8684d-a106-4520-dd79-08dd81992fd9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:29.0847 (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: ek/p/ChhBq5gBiGxDHFAF4lD4+rg/jVqHre0w1e/YFs9UvjsWXcsYQYo23d/jXMozLHpOYhqATye3BPgGhjsZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: PLWaU6HNElUSihsPQSD2uCLtt8XmiJNw X-Proofpoint-ORIG-GUID: PLWaU6HNElUSihsPQSD2uCLtt8XmiJNw Content-Type: text/plain; charset="utf-8" Currently only HW which can write at least 1x block is supported. For supporting atomic writes > 1x block, a CoW-based method will also be used and this will not be resticted to using HW which can write >=3D 1x block. However for deciding if HW-based atomic writes can be used, we need to start adding checks for write length < HW min, which complicates the code. Indeed, a statx field similar to unit_max_opt should also be added for this minimum, which is undesirable. HW which can only write > 1x blocks would be uncommon and quite weird, so let's just not support it. Signed-off-by: John Garry --- fs/xfs/xfs_inode.h | 17 ++++++++--------- fs/xfs/xfs_mount.c | 14 ++++++++++++++ fs/xfs/xfs_mount.h | 4 ++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index cff643cd03fc..725cd7c16a6e 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -355,20 +355,19 @@ static inline bool xfs_inode_has_bigrtalloc(const str= uct xfs_inode *ip) #define xfs_inode_buftarg(ip) \ (XFS_IS_REALTIME_INODE(ip) ? \ (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp) +/* + * Return max atomic write unit for a given inode. + */ +#define xfs_inode_hw_atomicwrite_max(ip) \ + (XFS_IS_REALTIME_INODE(ip) ? \ + (ip)->i_mount->m_rt_awu_hw_max : \ + (ip)->i_mount->m_dd_awu_hw_max) =20 static inline bool xfs_inode_can_hw_atomicwrite( struct xfs_inode *ip) { - struct xfs_mount *mp =3D ip->i_mount; - struct xfs_buftarg *target =3D xfs_inode_buftarg(ip); - - if (mp->m_sb.sb_blocksize < target->bt_bdev_awu_min) - return false; - if (mp->m_sb.sb_blocksize > target->bt_bdev_awu_max) - return false; - - return true; + return xfs_inode_hw_atomicwrite_max(ip); } =20 /* diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 00b53f479ece..ee68c026e6cd 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1082,6 +1082,20 @@ xfs_mountfs( xfs_zone_gc_start(mp); } =20 + /* + * Set atomic write unit max for mp. Ignore devices which cannot atomic + * a single block, as they would be uncommon and more difficult to + * support. + */ + if (mp->m_ddev_targp->bt_bdev_awu_min <=3D mp->m_sb.sb_blocksize && + mp->m_ddev_targp->bt_bdev_awu_max >=3D mp->m_sb.sb_blocksize) + mp->m_dd_awu_hw_max =3D mp->m_ddev_targp->bt_bdev_awu_max; + + if (mp->m_rtdev_targp && + mp->m_rtdev_targp->bt_bdev_awu_min <=3D mp->m_sb.sb_blocksize && + mp->m_rtdev_targp->bt_bdev_awu_max >=3D mp->m_sb.sb_blocksize) + mp->m_rt_awu_hw_max =3D mp->m_rtdev_targp->bt_bdev_awu_max; + return 0; =20 out_agresv: diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index e5192c12e7ac..2819e160f0e9 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -231,6 +231,10 @@ typedef struct xfs_mount { unsigned int m_max_open_zones; unsigned int m_zonegc_low_space; =20 + /* ddev and rtdev HW max atomic write size */ + unsigned int m_dd_awu_hw_max; + unsigned int m_rt_awu_hw_max; + /* * Bitsets of per-fs metadata that have been checked and/or are sick. * Callers must hold m_sb_lock to access these two fields. --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 C2EBB27CCF6; Tue, 22 Apr 2025 12:28:50 +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=1745324932; cv=fail; b=HOIsiMnUhNTN6hVFiIfm5juWGMHAFvR+Mm+bK7UzZT5IEkAvmW2+PxhtecQLtd+x3qkap7jclhUrlLq/b0iWf04XdTKa/1HuWGuxLWdWUWNI8ncQYT4BXIzdC8QL+qE/s1sFe6RpcO+9lW48LFJWl4d3qXTrzzjRD4NSDXwZayw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324932; c=relaxed/simple; bh=XwarE5lozIuD/DoeA3qDqC0eBa2mHAhvraQvBi8WVB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pfIxm3M7BJSI888C5HprA/QN9hNGfs17zzpwqCMOopVZ4pa4GMQp7Rtfxh2Z2uZ57uKCU9kXTvIm6sCk0taZTQRgQ/SPolGSgEjwEdjjz0JNAbS/TVV3+DMV3t+L20cjeC/KwkFVsOD8nhDnT8lc7l3wfP8uBz/XPuTV1wndHqw= 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=A33wdfLE; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jC1fjq0W; 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="A33wdfLE"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jC1fjq0W" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53MB3W0k020939; Tue, 22 Apr 2025 12:28:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=5Jrk5rO0oKL5JqCtDI8hF+s7OWc6MOeUBncPCr3djAM=; b= A33wdfLEIUhjc4pvj88F/vRdpYH4OFqxG57v1G6uxIz6KxUwzrqzaQNC+no+RYTX b2XEiYdZJmNEHwXmHu4AeNUq8vYL4eGWf5D7lZ36unUVDnMdjwqdFMvwtlr4XBHw CX8yWjZ4IsBDEkQdkFxlT++DVz8FBoUwubyGflJzwjwkxYzYidxXhA0WTaYrDlhU HUplpRrBafNptzJ+kPtcvbX6bAL23mIOiEPxWuqqgj5iQLp6ti1og03xv/oI/mys 9WLvnjelqJpvUJCQLfUBOPmmoo7bapAa58OER7OxpXssQqnVVOYxlLdYOcLFpBCh ttfO5SOjeAqFbhJUlrqQjQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642race1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:34 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MCE6Df010223; Tue, 22 Apr 2025 12:28:33 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013060.outbound.protection.outlook.com [40.93.20.60]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 464299tb5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hXcuaAQ2W9S/b/oWih/NUsy677JMzdmz36+egZhL+Tgopb3DPmdPS9/m7fZojxVzrUDGdHzqADDgKkhdbJQGNQJl2bFsYUiwWjq/S/pB6SXVKEPRirDc2Kgc2n0kxwPYbnFi0LmAndxi8rMsrT/AZDh/Hwi6JqdcH0rr7wdCj38PeRjgL5NIiY4qOZUIVldVEHI/zVwx1GBwMivi9IRH5UoTJSa/p17Tccoo46s7H6PzrfLhWQI0rPf2/TR/yo8GrKfMqkhXtd7nkQIEroTz6qWY76qtV9TxSwAxFmt0rNl9/ZeeUAd98IKl7nmzE0NQfN2F7mnT+XtWXw4hiHszSA== 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=5Jrk5rO0oKL5JqCtDI8hF+s7OWc6MOeUBncPCr3djAM=; b=Gb0ceNDqcYb/ijfN10Xrkircz4ICldDxKXeP3CNye6uuSDul3I15SSPXDhS3y/JMQpqhpjBTv3etmG3Qll7p3qVOGISnJrWqdoRNpdgZHRe2ZFeYsKNs/+vxXYgBAaamkJ82hs75J3AXSiQCszPg24OFmZTLDcCzyVYz/6WM24EBEpKW20OyZv5ICLUVf4dECCYcHTw7UagCc7E1Ex2MuFNYqNOH+scY6VmLGA5FSbMroTzPoJNVz8o7lUnUgpGYm2bTffG2SaOOhcsDXvlp7LnKtZMdKiCNVNMS2fvMlX0ijVU5amQYv2+Z7gTwRwnBdy7fv7m54aBnVgIEG8xRFA== 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=5Jrk5rO0oKL5JqCtDI8hF+s7OWc6MOeUBncPCr3djAM=; b=jC1fjq0WbVZpm7EpU1kHnX/xpKG859h5cRRbB9ZLVWcODha9tA3pDJickRiiWmcNKT+pyY1Hb6SVx4uJPx3T7crbnJAYaPQM4qXLleNypg4zPIFM95knTZlbfcDNG0bC/qe2BVPFTbskhLNLc8j3uwoUr4JMzTV5yM2zdhvuJCA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28: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%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:30 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 06/15] xfs: allow block allocator to take an alignment hint Date: Tue, 22 Apr 2025 12:27:30 +0000 Message-Id: <20250422122739.2230121-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BL6PEPF0001640E.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1004:0:15) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e1e630f-c141-4127-27c6-08dd819930b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TMoLY+XGuKUzBiWuIiIkyMnGn8g/LWfvBMM97EzdPp+bJUr3Xp/oCMnLgciK?= =?us-ascii?Q?oEDLc5cB/3YY1vCUgWKtJSi5dCoVKW524ClNdQqtq6mp74qy20nDnjUKncGl?= =?us-ascii?Q?xX/18eVBFdGI9JIIzT09AkHuiDCasQxBa/dIA0EVgq0sCW7igKr1amhNzJho?= =?us-ascii?Q?SutA5UTIw08lkQk7fFARBIB4vucZUElKSy0mkR2JAJmF7xjcm0xAoYpTGTQ9?= =?us-ascii?Q?XoQ/Vrdp8jablVyt2/s8dgaBWmgIvEXrh3SYjPiaPS/H8VgYSazTkrcEatuB?= =?us-ascii?Q?7RJ5592/6snz2jKmUvw4B/Lw1OqvASZv0FUODMDuie27BA1lUnVeuFu6Ssaq?= =?us-ascii?Q?OLWK8kNwEkkunwKm7/bCPgJuOrkA72rc2MCmWpY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M0cLLkuN/vQoMwxm3V0zL1rhz8G4phBk3sTzqqPC6hRTGeBq4?= =?us-ascii?Q?6t/USlA6WASDEi7k+I6c79poU/7ROXFQnFi8Er5rnYjYbdwROfUH4NrbMdhk?= =?us-ascii?Q?UAOMYQ9sFT5hnILeUg2WWMt0No7keFAFN2c8ZB93NwvN71mgjsnWoFc7cUN1?= =?us-ascii?Q?UPkhp5tPbn8=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?U1CMuKB2RID0IQA9Sf6129rREjQe3rcOmGo+7aX0iXxdGvI0iZLmYnnG07T/?= =?us-ascii?Q?fNP501bICreh54ql2k68mcM2GE+Pv3QWo9krGSwzbsmiFqN06F7APlC5a0Mr?= =?us-ascii?Q?s796+qlArVzv0Y+1zStPyjShqoM0FKwKGhuQNnXNgzEAYuDhayzC+5ONn1pK?= =?us-ascii?Q?N0WwL3eJwN3c0wJfGxc28ndNyNLd/iOiWfYFPKF3L2DJTlWur3J+6vxG+H4k?= =?us-ascii?Q?5sfZhaNhWmD3DjIDu8PJ9xCyqMKO8hw9q+RGT2WPlMtLkT/zPNdGgGnHT9jT?= =?us-ascii?Q?K7Sday3Dhw1sgk7nfvXqZOnu4KFzqDVT0GeymgwmqnrheUv9C0O20xGuPuap?= =?us-ascii?Q?Y2h+ovDc3lTQ0ZEJiF9NilbZ3xMcHijEAxz4xj5mqqMyJY3dfcusG1GyAxQx?= =?us-ascii?Q?kH58fy8b9shVbPKvd9duiDjQ9WdL6hdGwm0/kmk1RBsjpcMgwJGFBm0s+Igd?= =?us-ascii?Q?UMzkP7A7dogG6Ebin13xaSWcgRRtHpe9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9B6nIRgew9TNGJ2/tW0Wda1/paAwDK51UP+ZS68+AbPhNH2xo8RmB6?= =?us-ascii?Q?Z8HG4juKAHb2uKwnUNuHwnY2+aWbWh9gVZMzwhZvpFD63jfl2EXi6xFr48nt?= =?us-ascii?Q?Nb3LkgbtpaNHUrVqDlZ17AG+L/B++eGuQsljoJA0LwjG/Piy1vF3rCGSQ/yx?= =?us-ascii?Q?GGTlzFYSFRGEWPbRE/NBd/BHICm7f3TiOxXhfZ2yFeqFhKKGEE8Lukacletz?= =?us-ascii?Q?vQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wUNOEMop3OCmYgFCk86J01iydnkp7pbrpFlX7CW3BbEJcDg7T925R0dP4VYQ7DDS+Y0jJm+Tu23HC/mPD9Q6dfLORZRWOJeMd9VDNz7xWmGSBPrloK65XGcS4yFPBbaJew/e/bJxU/NsC/AcHYji2opfPpVBT6fRJiaZ88gtSIjeJSH1bf5CFoxbHbDJTHyoEjEK7Jqb3rrkN78eCCbabrf3fgDqcz3vmPuL9nJ1M0v0PmyyEaYdApXYSQfohuunF2kpXODllEc4WnFwszFXq6vPYdyuxIC+6jMkcXzzJUtUFG4xgZA3G4sH7KiBIdoVM/XszQd6cW5hP/8F/V7cTfh4ppLYtoB8uld0bsITVmdFVz9Po8RQp81mnlr7k//dZ8Jqu/7CvJykxHnx69d7FqzOxOqAWGFFJhi6RWdREQG9g44L7qnzp/55rScZvIsZeRPfh5jhEgktoT1jXgJy333AEixENtZiROLTCa8T/1t9AnVHyzArXBY6bGwkMNsT0JLm0lbT7aUCHBVYzPMwxftBif7jF57z8Sy4zYFW8yXchx3h4vx/g5ArHDyEI1BQ1HaD653onnkX9CfYfixHXyLZoTT4xBShHkf/rsAZdv4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e1e630f-c141-4127-27c6-08dd819930b8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:30.5109 (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: W7GGoLBTJodSClcDPQX5hbxhKFkrKSbEBf07WrDOuU4f4KLXo/T9yk+MIckoZSawmjrCGAIfhNP4iw+saOP8mA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-ORIG-GUID: kaBUO2mR4WEwR9VGR3JGDTLeI24a4oBo X-Proofpoint-GUID: kaBUO2mR4WEwR9VGR3JGDTLeI24a4oBo Content-Type: text/plain; charset="utf-8" Add a BMAPI flag to provide a hint to the block allocator to align extents according to the extszhint. This will be useful for atomic writes to ensure that we are not being allocated extents which are not suitable (for atomic writes). Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Signed-off-by: "Darrick J. Wong" --- fs/xfs/libxfs/xfs_bmap.c | 5 +++++ fs/xfs/libxfs/xfs_bmap.h | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 63255820b58a..d954f9b8071f 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3312,6 +3312,11 @@ xfs_bmap_compute_alignments( align =3D xfs_get_cowextsz_hint(ap->ip); else if (ap->datatype & XFS_ALLOC_USERDATA) align =3D xfs_get_extsz_hint(ap->ip); + + /* Try to align start block to any minimum allocation alignment */ + if (align > 1 && (ap->flags & XFS_BMAPI_EXTSZALIGN)) + args->alignment =3D align; + if (align) { if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0, ap->eof, 0, ap->conv, &ap->offset, diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index b4d9c6e0f3f9..d5f2729305fa 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -87,6 +87,9 @@ struct xfs_bmalloca { /* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt= . */ #define XFS_BMAPI_NORMAP (1u << 10) =20 +/* Try to align allocations to the extent size hint */ +#define XFS_BMAPI_EXTSZALIGN (1u << 11) + #define XFS_BMAPI_FLAGS \ { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ { XFS_BMAPI_METADATA, "METADATA" }, \ @@ -98,7 +101,8 @@ struct xfs_bmalloca { { XFS_BMAPI_REMAP, "REMAP" }, \ { XFS_BMAPI_COWFORK, "COWFORK" }, \ { XFS_BMAPI_NODISCARD, "NODISCARD" }, \ - { XFS_BMAPI_NORMAP, "NORMAP" } + { XFS_BMAPI_NORMAP, "NORMAP" },\ + { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" } =20 =20 static inline int xfs_bmapi_aflag(int w) --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 993BB28135B; Tue, 22 Apr 2025 12:28:47 +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=1745324929; cv=fail; b=d16GW3Ix7Ad/1Hg6+wogP7TjNbi427NPoBn7KxF4+jTtXAz00eBFwEGNZMU0zC+mhpdOEFiUmBibFVSIViSYyfUKZ6F18GDM/uHBXp9VDPyRbxkZzOPlm7jRpixi2xfkZuvwLvXwLmeqiNbPZLb300J8xY+gc67C57ZmphGBrY0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324929; c=relaxed/simple; bh=jkt2dTvqDA+7XgFA8CqtXya3FsSR9oDjqwMU/9d6xLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qw+XY4aTLd2ZYWTSwLUPMR9CqDhETRYlfAXEPJkOvh/qLNWdFwwNVqIPjHabCNnAgSOHPEMWCV6MCo3WNjYXLBwjrzJPtFrJPwHWadJM+IsaS3Nvvj9SbSPr8XLKfK2csCrQfEbyCX0QAeeXsrIJSwSGGQna2MP22MYkYXk29Gc= 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=HcmChmrF; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=buM5Bp8X; 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="HcmChmrF"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="buM5Bp8X" 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 53MB3PZP008455; Tue, 22 Apr 2025 12:28:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=oB+7chQgRjKC1yB1GLnWgsuYB+a971GfEcdhyhMqGeQ=; b= HcmChmrFgHUVNbOi3t8QRC90qHmMWAvBRbXrnZF2j4E40hv/9ffIld+0BjOW99K6 YWNSrR3EE9u0CaSZ0Dr/8sjBhE+3RRhnTQ6+XmxLX0goliUL/KFt9WJpIf//tpJH iFR1ZPaF+8hnoZkuHPYM+2Utr+To6nKOB+WfzAzuZaD0vslcZ5fcPBNECI+aq51z 48UeBHutOrQ8P44fziFnBQGol7zRSUGrc525n+5k/j579kP23vR2dCOEpuX7tBbL 0Btk480TsdiK5y0AHb+93h7fIAyDCu+BcJI652IJoNkMncPoO5ZvT1FRII+nVrUi xmoD6bylYYEyIXO4kEmWRQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cde7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:36 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBOta0033464; Tue, 22 Apr 2025 12:28:35 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013063.outbound.protection.outlook.com [40.93.20.63]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rtr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VEJsH5LxPapQVTiv9v7v5cwD7F+736QcCQQiTMMwcrqD7DfJiJEhJ5appSKFqUo6dHIoxJ9bfLQw2FqZR1gt6Pfsz7q0j0yOtYg/OUx0w+4A1Ky9Dl8+uu5jYMhfKCO7GCoempr/U8fkhzeJe8xlTePIRRNS7drb3adP4zibRqXMoyX7mGHuJyrL9eEJChb4AWrqv8Dlhw5M1x8ES6qB8zV0OahZn0wDDFQMp+ntVETyyOv27ySv4rR4lb6WnL5IYYI2IHF5xEEnBG73zS6G+Brr3fGZhI2wBipABFGTuh0vi+qWcE0JYVKjKwwd0PwIY43ajOPMv0zlMCZWwR7dMA== 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=oB+7chQgRjKC1yB1GLnWgsuYB+a971GfEcdhyhMqGeQ=; b=hwtV7vipnjyXLApFP216f7zu6i8PbY9SG4RrdVhzEk5vNnk0VvYORA5DbJXpjpbQ1HBWvsxN8B3+qj+dOC6G2umO3+GNdxA51Ep1yFHrbN50r3ZpE/X3+zR6khXvPVi5+y3Y7G0ZpAKphrOCy18zwBmVFFw6IsDOxLY7ykxLfaYzMk688iwbBxXtLPS6RAqlZ8XLk76hIyTy82Q0Ijag2AFesqshRHNcvBmIkgRrkKsTpULynbXhBvSEKiHoxnU4cUIO41sSMhB5rqurzHvKXhkGQJVk0M+zgciMD2+bWKxtPCGBrhblRn7ie+sDi05TLpGjnNXlZeUtschOBfD1Xg== 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=oB+7chQgRjKC1yB1GLnWgsuYB+a971GfEcdhyhMqGeQ=; b=buM5Bp8XxQG8FSP402S45uZ65kUvEEZDnC5o5m2i1Y2SbcTWJVSErLcrAwS4umkFHxZe6GRZ+YDYS0EyEUofP7Dmbj6kbCAR5AwhfPlvia8EW2WxLVaerhkLX713sYEGVmlnfMUzqDnOdfNE1GbFFCkgOUWxGyIcfs7CKmKjYfo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28: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%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:32 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 07/15] xfs: refactor xfs_reflink_end_cow_extent() Date: Tue, 22 Apr 2025 12:27:31 +0000 Message-Id: <20250422122739.2230121-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P222CA0018.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: ae2a8611-7d40-47c2-620a-08dd8199318c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?x3FoWcy9mHgMKtw5SjUCumwJ+VxGUELRdmP5yXH9sSiq0ass/++WkIlmn6lQ?= =?us-ascii?Q?Gjscb/NBP7csh0xrzmVmjlqXjUaAouhFmLaxSaYkHRHbKS8UkMnYG8majuBb?= =?us-ascii?Q?CiAo/krhGjdZZJMXBAcQn7Eqx3e16599fMxe5JHEoqvUJJUrPe6xf/YQr3I+?= =?us-ascii?Q?HOScFl8rbOtCdIBmP4dgDfWsE2AOocFXwRvgPdGjoGJZT4ZzZ1owBtMC9Swr?= =?us-ascii?Q?vv/rKn4OWcGsVahoCLPhtUfbYi3ey5TMAps7Mhe0bZG6Y7nXOectrFjXYHGg?= =?us-ascii?Q?My9D0xbDusWxlH5/1+rdHrTFWQCgJsemB0Su328ELL1RrzDbx77RnZU8vLWn?= =?us-ascii?Q?pvk5EpHVcvewoTxrY5fL4Iy5l0a7+XU7daUYlx+Is+/WCrLZDXYU0Q7NYc7Z?= =?us-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ot9zEpQy/eHaiN52IRqW?= =?us-ascii?Q?d+/FbGRY8UWexLy40tyVXa8M8AIWerFnflmsrm9Za91wJrZyqyXPgOco9Lxv?= =?us-ascii?Q?CKN6621tlWY6C+ROd4Mxarq0nKCDmCKd/CKBXuH1o+1fkU7iZDEQSWUhzI9v?= =?us-ascii?Q?vQaE5h4WOXM=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Gk0zRZBYOzdNGlhcVJb6w+Wm/a7s9zfspWxDJAUCvvci3zLeMFO27+04fC0Q?= =?us-ascii?Q?t/8SBsEV9ltUdjp9O6ltEjmfPm5N7OBcUIc9/SxbJzeW9Cxn8gLrbxe37Y1Q?= =?us-ascii?Q?N37GZL1F5v/sFEa6ATGnLGDBJBHQXrea6oOJSIUQeYcepWnBYPX4VDubTZZa?= =?us-ascii?Q?3p6qhiPbhwZJDFftUNYcwRbag9xTTdco5YSoL8eyQsYyMzPNwvSBqomDBhJX?= =?us-ascii?Q?S5udSgJiKeT8iCvly0bLOoZSFjA5EA+xVDlu/NiyMHMtplUZFxdVkGeXoV1n?= =?us-ascii?Q?eSUGI16J+hION/5V8ZZg64CAgyZQNktUnHOfcihqRC7D2vSeSPUpKTAL0P4S?= =?us-ascii?Q?jRFOwgQfn/BoDlkmxSsHnLi4OCYY+FLkAiJcYVzrweDB85DFyGYDpfZ5dLO7?= =?us-ascii?Q?FhLPqMjWNh2gRoF88waQEj3xnOdLZ6Syw46QvT9x89TgXwvo5iC3EoPqlhXI?= =?us-ascii?Q?mSyn8URhZbr4QJE5jr4RCun0prBZlolPL39MjjPgXuCL1kmr0a8LclQdEFnL?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BKT6+FEOPz+vDb/psv3x?= =?us-ascii?Q?0es+Lw7AFeaedfR5fCrnha1gSV5U7k0IyD/0rL9Y3z1jdHyfMKVtSpGVPtun?= =?us-ascii?Q?7PLFX/oVEvnH6jGW3Bh6kq5pkvGtT14Ro2e8Qwie2hc+COI6fPD20WbqeFUz?= =?us-ascii?Q?Wu0ipDhQQLKNr6dh+GZycXcDLhGmNX8nYn6yHxbaLxFAjysRKt3nLcXTPANe?= =?us-ascii?Q?Lw=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0hglf86DmUmP3ZlwNZkdENAyHTDVu2HF9V0eEpwKZS5FfdQ+3MLLm5b1ajnZ3G/SVT/XupkYNesjAIHECIu55CVD/ylzkxcot2m5YZkxtpSBWfzZorsXREq3qOpofSmrwsKL3/a/vvM3WaYJU9OYR5MvGjSZFQQC73O4oXV3dFIM4oLr4KlE/VOgWNaD0Atd8lLCFlyaneFM8jIFgzVtVwfE0fxEjoNPVcIXKvXpbw0UKuaw9BDPI6HFskwyyDbLgYViyQwn1vswhO4cAEx2DCWGlSCDB1hiz2vTUlgda/NFA6QhidA/f8K8x+tXeOHcQksriqW7kA4gQaqaMbhDzho70SiAld6v43pefJCj1n8yAGOhvbPDYgIRmshdRy9GqPRaXLrvL1GLIGiSfHikOdhdu+xa8svE1mpcabicoFiZzVgTw01n1LsifU2BXkB4ZD+AwHHYhofjLZKEPIo+FU1hFGCpAjQp2RuzvCwyjQIyHun1rvhd4ztxUMCc6oFFTnvCGN8KSbMS23XPsPQ8MVN4UFsJ6yaHxwtiXIDLri7Y+GGBwK8wCsAJW66tOPdnrVacOE1ryDDn8hIuWjJrsl7u6mmmu5RAkHIbpG9hxn4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae2a8611-7d40-47c2-620a-08dd8199318c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:31.9677 (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: kKhCPRqsV+85iTGjUKnjcIGdXR5avbSLZrrC4zbqb1U3DJxF+U7YCErJBD6UD23a3G+TwDMkqDLB6/zwTaGflA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: aBcz53KoKXYIU40WF0LxSoTJt_ETF2df X-Proofpoint-ORIG-GUID: aBcz53KoKXYIU40WF0LxSoTJt_ETF2df Content-Type: text/plain; charset="utf-8" Refactor xfs_reflink_end_cow_extent() into separate parts which process the CoW range and commit the transaction. This refactoring will be used in future for when it is required to commit a range of extents as a single transaction, similar to how it was done pre-commit d6f215f359637. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Signed-off-by: "Darrick J. Wong" --- fs/xfs/xfs_reflink.c | 72 ++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index cc3b4df88110..bd711c5bb6bb 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -786,35 +786,19 @@ xfs_reflink_update_quota( * requirements as low as possible. */ STATIC int -xfs_reflink_end_cow_extent( +xfs_reflink_end_cow_extent_locked( + struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t *offset_fsb, xfs_fileoff_t end_fsb) { struct xfs_iext_cursor icur; struct xfs_bmbt_irec got, del, data; - struct xfs_mount *mp =3D ip->i_mount; - struct xfs_trans *tp; struct xfs_ifork *ifp =3D xfs_ifork_ptr(ip, XFS_COW_FORK); - unsigned int resblks; int nmaps; bool isrt =3D XFS_IS_REALTIME_INODE(ip); int error; =20 - resblks =3D XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); - error =3D xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, - XFS_TRANS_RESERVE, &tp); - if (error) - return error; - - /* - * Lock the inode. We have to ijoin without automatic unlock because - * the lead transaction is the refcountbt record deletion; the data - * fork update follows as a deferred log item. - */ - xfs_ilock(ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, 0); - /* * In case of racing, overlapping AIO writes no COW extents might be * left by the time I/O completes for the loser of the race. In that @@ -823,7 +807,7 @@ xfs_reflink_end_cow_extent( if (!xfs_iext_lookup_extent(ip, ifp, *offset_fsb, &icur, &got) || got.br_startoff >=3D end_fsb) { *offset_fsb =3D end_fsb; - goto out_cancel; + return 0; } =20 /* @@ -837,7 +821,7 @@ xfs_reflink_end_cow_extent( if (!xfs_iext_next_extent(ifp, &icur, &got) || got.br_startoff >=3D end_fsb) { *offset_fsb =3D end_fsb; - goto out_cancel; + return 0; } } del =3D got; @@ -846,14 +830,14 @@ xfs_reflink_end_cow_extent( error =3D xfs_iext_count_extend(tp, ip, XFS_DATA_FORK, XFS_IEXT_REFLINK_END_COW_CNT); if (error) - goto out_cancel; + return error; =20 /* Grab the corresponding mapping in the data fork. */ nmaps =3D 1; error =3D xfs_bmapi_read(ip, del.br_startoff, del.br_blockcount, &data, &nmaps, 0); if (error) - goto out_cancel; + return error; =20 /* We can only remap the smaller of the two extent sizes. */ data.br_blockcount =3D min(data.br_blockcount, del.br_blockcount); @@ -882,7 +866,7 @@ xfs_reflink_end_cow_extent( error =3D xfs_bunmapi(NULL, ip, data.br_startoff, data.br_blockcount, 0, 1, &done); if (error) - goto out_cancel; + return error; ASSERT(done); } =20 @@ -899,17 +883,45 @@ xfs_reflink_end_cow_extent( /* Remove the mapping from the CoW fork. */ xfs_bmap_del_extent_cow(ip, &icur, &got, &del); =20 - error =3D xfs_trans_commit(tp); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - if (error) - return error; - /* Update the caller about how much progress we made. */ *offset_fsb =3D del.br_startoff + del.br_blockcount; return 0; +} =20 -out_cancel: - xfs_trans_cancel(tp); +/* + * Remap part of the CoW fork into the data fork. + * + * We aim to remap the range starting at @offset_fsb and ending at @end_fsb + * into the data fork; this function will remap what it can (at the end of= the + * range) and update @end_fsb appropriately. Each remap gets its own + * transaction because we can end up merging and splitting bmbt blocks for + * every remap operation and we'd like to keep the block reservation + * requirements as low as possible. + */ +STATIC int +xfs_reflink_end_cow_extent( + struct xfs_inode *ip, + xfs_fileoff_t *offset_fsb, + xfs_fileoff_t end_fsb) +{ + struct xfs_mount *mp =3D ip->i_mount; + struct xfs_trans *tp; + unsigned int resblks; + int error; + + resblks =3D XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); + error =3D xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, + XFS_TRANS_RESERVE, &tp); + if (error) + return error; + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + error =3D xfs_reflink_end_cow_extent_locked(tp, ip, offset_fsb, end_fsb); + if (error) + xfs_trans_cancel(tp); + else + error =3D xfs_trans_commit(tp); xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 2468327F4CD; Tue, 22 Apr 2025 12:29:20 +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=1745324961; cv=fail; b=uOrpzslVewco3B4niPqGJ7ZAGV8iOVf9q+gMafQaNOO32+wXRLsc42BLWspK9ipGHb1pkN12xyL2d6x2De8/BTNjIHQWm74rFBlopQyoZcbYWD2TFD4FBPYLwrd0y0XxzWTQnYJuHy60uaDYVt9mbPSlS/2qqu6ce6qzwsYcQXo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324961; c=relaxed/simple; bh=IViA9c3MF/M32XRGi1r/feC7Bdm3DYEaDn3kzlaHZeY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qDYaj+r3xtL/QIRTrROsYC0mY3GtnOdpX5d+KojI6EWCa0IMAmHMXBI2eOA/1KFjijJEFPWOCBHSaA9Oa+lN2XFCoDHyc2xdFWOV2V9epZQUXkEJI9H9fUx+TTUaaLWhUzl1WJFYmGmLTpVZcJGKM8YeXvuiLKatG6X9+CaYbRw= 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=JsAuQfBb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=efsSq96+; 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="JsAuQfBb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="efsSq96+" 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 53MB3Gq8008344; Tue, 22 Apr 2025 12:28:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=Wja3wyb7ZmwGDtYxv+ByaX28CaCPRg6Qo+pFNR5u/WY=; b= JsAuQfBbksYK/pgeD8tby5KLZVwYfywko+WgwdnyqOHm+4l1MN3pfLprkc/Tn0vS isZN07WKN/4pj4g8U+ai/koGsoxmvV/Gz5qQS8/8pG1oLNdoAEjPvMWUt8xmku6+ dxV/+TOBpXa+u8nffdGugSrRUfJh+hEyUD/7VwVbqnYx+Ed70dVqBGaqEUcTnBYn s3VTpOzqwQ2gG4fed7nOYlMMFKC3y5btC4AbGgpbaZDrEAn3XjgAbueyhfZPJv2O jm4leJIYEkSpKe8NvqlPSi6E2aNzTq7gXw1jTtv3atLo5yDlC0YKTecLAgK+pvIQ owSQSUxgngu74JBhMQzzuQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cde8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBOta2033464; Tue, 22 Apr 2025 12:28:36 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013063.outbound.protection.outlook.com [40.93.20.63]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rtr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cIaDc2depxN8dyAYIsJmILy4yYniOwARXR1wT/yZMxUVqcSyoCspnKrMyzxioaBzbmVmxEoRHpL15mwxDdVC+aqC+TB14MsBNnNZLp9IxZB35WOIagqBjm1R/+7OCyJTM1Ou8E3k3ToPc9maYDOvE4n03ZaLLYjZrGspbTmV/xR8euIKyQ+4ZTj+m9SqaAlfYr6zhyaSnA2IvKNCMkiZPFPcJUwb5GquBMejsXcBodXAVqNVGMl8hyFEZxMDC7JKEMSvxU+vbB7cCZR00K/MO9B7l10MI4eyk0fAEyOC5GsChsB29xU9mpkFqjnoKhSUq5BAsWnrVC2rK0d9ZIedrw== 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=Wja3wyb7ZmwGDtYxv+ByaX28CaCPRg6Qo+pFNR5u/WY=; b=rn3bhr/a7TU/8VCONIYWoUzAFTKA01uzMZIuIl6nr/Shc3Ls2Yp6rS0LkuCCW5cEPQlA6GpaVPsucsVZ4dVoQaNnxWQMKQVvJY04tmRWXw5x7D6aVAdHfu97Ms/MdyrVScl6hQO3uDhYuC2pQREyupG8ELl/ZsvFwouWR3uknW89br+D9dzI0xOGG452VHrDgY5EtE6LJH9Q2kzlb62HJsY/wf3vnKZT+GauPkHES8v13VAxzc3lsIUbgq1Z93oKwBg4aaRfTjk2Du1+4p4ykLzZGnq1QL9cTFr7pNv+t02tkGSCyikfi9Y9oYJONPxuNUBKFJSqOJ2NcY5OMaP1NQ== 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=Wja3wyb7ZmwGDtYxv+ByaX28CaCPRg6Qo+pFNR5u/WY=; b=efsSq96+rarNWbe00v3AE5zkCcVN6nUBXLNjzSRLSolDj7omvJVUeX2YxmoKufI7Ix4vpqj+xKV9DH2ziCUOQUlufwY9/TjaNduKAd1hvWYWnnr6LZXeSGQ4UkBq6y+O0PlBf21ezNDkO0suKx/xKT60n5/eig5m0Sp9T7oc+kg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:33 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:33 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 08/15] xfs: refine atomic write size check in xfs_file_write_iter() Date: Tue, 22 Apr 2025 12:27:32 +0000 Message-Id: <20250422122739.2230121-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0094.namprd03.prod.outlook.com (2603:10b6:408:fd::9) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: b0d62ebc-8f11-40f7-5e5a-08dd8199326d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?n0G4H0YbFqVdd/IFRC3a/4yJsChIBU5WJXiQYZ2MfryvmNrXRNbyat5xrZ2D?= =?us-ascii?Q?E2iFFkf6gZ0qKi3dxpsIOQ2Mj+2HHp8MslV8mcEs0zNEIMJlA802R5slY6Ou?= =?us-ascii?Q?HndseekKq+/8U6L0yIExy1M9sKHVp9yvO18KguqugkGwdLeiKhmcPGbEpw0F?= =?us-ascii?Q?wIoDJD+/WGB7qebjt58cxrcLsIa1LwM/1xoknLbAk/V54Ljk0ewJu3IRG/7o?= =?us-ascii?Q?nVR9lcPjfdKcehvOxfa1lTbulqUefEQE1lf1qGPkOwWwlHlQAHOWlVc21E3t?= =?us-ascii?Q?kZKh0UVoYA5LZrT6NyHW8XJHbhl7ITlfz/+GYSYo9cJWIO2w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k38DQjn0RbbpwOeXgTtZ+s+1fuaAYLNxPtBJHXQborpke?= =?us-ascii?Q?1zv3PTtiqUlennzem2W+/0HCkHpC2h3yojsMUoPZMGCVFYXJ031TKKR26GmC?= =?us-ascii?Q?xlWBk/gJWJ+Ra/n3aXXR+QtvQ3AWIS5DOfL5IHDgDH5u5mJ7s+uInDVzpgMA?= =?us-ascii?Q?VNWC4SwVSGh8Xoxtc17IKgdJca72kLqAeHLbM9c/2FsdIZAy+/krxtEwkZ3F?= =?us-ascii?Q?N99BMK3R7ZE=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?J+pCFaFI9BSDPKA1jf5r8xwLWH/YoIIJmOhOGt8SQ2uncnI77HXkn6iWvdKJ?= =?us-ascii?Q?3ermufZNBMIabQ+/7ttDGIQDmPTJFffDqMODdbMnZYB91u6EiiWJr3bsE6IL?= =?us-ascii?Q?3rJgIORCKUV33cn91Ji/D2abUb0baRntnJQbpnGvGPM3m4r0+hYPB9DhQ94x?= =?us-ascii?Q?ncKFEf1XHQJajfGTSiWG4O36FCYyQVSB7zsA5RKT4lzjWutfJsVIQfgXNMXM?= =?us-ascii?Q?9DfsC50laxtE9ZguziOmbKPF6IG5mRD7j5lsQkQDDRXI57AXd/mCMmsBJ7yl?= =?us-ascii?Q?1J5KlQFvX10FsAgmf+dwmIIpiZBN0Vli055zEXh9Jv9FrJqIyZ32u72b1jAT?= =?us-ascii?Q?Q1UJ8hoKjp9oSObGo73YxHm+0lg2GppOyDDTLPSKPhg9x1QpOU/o6orMYnld?= =?us-ascii?Q?c8Wp9D20IL8o8lKfqyJzzN1nI+PUoqqI4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q?XL7XwgFgVJGdBh7Yb/CcAKg+iecJs2TNr+kC1Tj5Caq3AwMMcDa3j2jztdLf?= =?us-ascii?Q?E3McO1avHwr/CF3gqADfHJDNonS0nTnRKgupi8dPNuu30JdVDzfnAW3CIEI9?= =?us-ascii?Q?rOZbQnuVNOASdTjV14c5j2bsU5Xnog4U8064mthG5Ih573jKPdN3DgmkD14A?= =?us-ascii?Q?yAQFw3LWJJXW7+h5Qx+fZ3dVu+dxq8GAaDHrUGUpLD2grXs4mXpKjDYjwhV3?= =?us-ascii?Q?fZk1qAbPLcekTsJgCzSYCCi3LjOTI00MIB4fnvlQbqvk9qh/fC35llQ81jAH?= =?us-ascii?Q?nA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eGxg4Nk4dvoLO/xVVFCU4THlDHNeVHnCJEfMRcaHwCB7hqIOAaAY7FBS9z8yaViMmOLEaidTL3ShCdjeInUfK0HJkzlqF6/pek9y6j3jbDhM3CjQojj0nzZTRw1mXrHMhA8MYXskUg3nzXyLFZ+oVfhVUgYSYHYrQNJjSx3r0PyiOmmowp2nWhdh4hP8kxcYGyGIcZUR0VB9XPAJhy71OyhAqSr++2ZVEB51z517y/OVMzowSyE+dzFS9gBwgfIGkk1s7oEeFf0kowvB5ruoS7JWJXm0cK9jwKG5noH/UtJdTgng3cTP3AH7++/JnYQie1X6dA4Esd+lohUTPre0iAdV/DHFHYjLrwKuRkGv6ZeqULRr3KdItI4Js4HxzbebFQVZ9HhmO+OzG4jd6RQNSXtKG/11+UFKohtxQ5nEQ9aMwusxxHycPwhcqM402pSIJtl40lIGKfGMtYfufGGKZxRsXgPiyPGNBERczvR/78kBgwfgJ7nqtN7Qc3vnv30xpXxZbwvLxvtWx+173QQrbXVWq/AtqNL1IsJx5jLQ2YyN0yBl0bN4LFPgG2k9o2TiB5Wb76xpe3aJPXMdThzxpwHzhBJULHGiAwH+QzvzhQs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0d62ebc-8f11-40f7-5e5a-08dd8199326d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:33.3692 (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: KhMqJIFoKh2eyfHLZ1waCJhRaocssTFrc8f0GQpbUiuaVI98a/34zdtsEXGJ+U8oqS/DWFzVavM5w4MM2ZZ2jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: XCuXm0BbY5xhhgg-LBkBkSdYk3O_DLLo X-Proofpoint-ORIG-GUID: XCuXm0BbY5xhhgg-LBkBkSdYk3O_DLLo Content-Type: text/plain; charset="utf-8" Currently the size of atomic write allowed is fixed at the blocksize. To start to lift this restriction, partly refactor xfs_report_atomic_write() to into helpers - xfs_get_atomic_write_{min, max}() - and use those helpers to find the per-inode atomic write limits and check according to that. Also add xfs_get_atomic_write_max_opt() to return the optimal limit, and just return 0 since large atomics aren't supported yet. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Signed-off-by: "Darrick J. Wong" --- fs/xfs/xfs_file.c | 12 +++++------- fs/xfs/xfs_iops.c | 36 +++++++++++++++++++++++++++++++----- fs/xfs/xfs_iops.h | 3 +++ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 653e42ccc0c3..1302783a7157 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1032,14 +1032,12 @@ xfs_file_write_iter( return xfs_file_dax_write(iocb, from); =20 if (iocb->ki_flags & IOCB_ATOMIC) { - /* - * Currently only atomic writing of a single FS block is - * supported. It would be possible to atomic write smaller than - * a FS block, but there is no requirement to support this. - * Note that iomap also does not support this yet. - */ - if (ocount !=3D ip->i_mount->m_sb.sb_blocksize) + if (ocount < xfs_get_atomic_write_min(ip)) return -EINVAL; + + if (ocount > xfs_get_atomic_write_max(ip)) + return -EINVAL; + ret =3D generic_atomic_write_valid(iocb, from); if (ret) return ret; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index d324044a2225..3b5aa39dbfe9 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -601,16 +601,42 @@ xfs_report_dioalign( stat->dio_offset_align =3D stat->dio_read_offset_align; } =20 +unsigned int +xfs_get_atomic_write_min( + struct xfs_inode *ip) +{ + if (!xfs_inode_can_hw_atomicwrite(ip)) + return 0; + + return ip->i_mount->m_sb.sb_blocksize; +} + +unsigned int +xfs_get_atomic_write_max( + struct xfs_inode *ip) +{ + if (!xfs_inode_can_hw_atomicwrite(ip)) + return 0; + + return ip->i_mount->m_sb.sb_blocksize; +} + +unsigned int +xfs_get_atomic_write_max_opt( + struct xfs_inode *ip) +{ + return 0; +} + static void xfs_report_atomic_write( struct xfs_inode *ip, struct kstat *stat) { - unsigned int unit_min =3D 0, unit_max =3D 0; - - if (xfs_inode_can_hw_atomicwrite(ip)) - unit_min =3D unit_max =3D ip->i_mount->m_sb.sb_blocksize; - generic_fill_statx_atomic_writes(stat, unit_min, unit_max, 0); + generic_fill_statx_atomic_writes(stat, + xfs_get_atomic_write_min(ip), + xfs_get_atomic_write_max(ip), + xfs_get_atomic_write_max_opt(ip)); } =20 STATIC int diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h index 3c1a2605ffd2..0896f6b8b3b8 100644 --- a/fs/xfs/xfs_iops.h +++ b/fs/xfs/xfs_iops.h @@ -19,5 +19,8 @@ int xfs_inode_init_security(struct inode *inode, struct i= node *dir, extern void xfs_setup_inode(struct xfs_inode *ip); extern void xfs_setup_iops(struct xfs_inode *ip); extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init); +unsigned int xfs_get_atomic_write_min(struct xfs_inode *ip); +unsigned int xfs_get_atomic_write_max(struct xfs_inode *ip); +unsigned int xfs_get_atomic_write_max_opt(struct xfs_inode *ip); =20 #endif /* __XFS_IOPS_H__ */ --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 64802283680; Tue, 22 Apr 2025 12:28:50 +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=1745324932; cv=fail; b=CgmUs+3C9IXdwGmZJBCEtzq7JbsJ2M6ieWAEhddyvlRuqLlBiJtG9368iL9u9d6zRy7p6+5KVNryq4qS8zaMTpEZvodbnGgyqyNqTk9Np6dFWhLZMmAyFWJTQfv+FYOg4gMf8QFG1FXZlj5+ktXQNzAnyg59HAv205BSEGg4Mh4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324932; c=relaxed/simple; bh=068dv9XImlZnzW12WtVPfp9ICZNAnHZ2liW2DZTv9PU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YuebBOfLi4hgtsU5aLx/qGiw8bOJu4nY0GC4sVScwoAVihBerCoiHtaxoJ7FmxOEuyQNpcDJYzGzDHL47GeSMnSgXT1RzqqZBmAmmJOIueWV3JRLaLhvUSzoo6Q1TnSaSxJdSLxHCywHlKbFlljxr9eW4rcXS/svesAu3456IMU= 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=LsFmNDOH; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ubEwADZs; 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="LsFmNDOH"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ubEwADZs" 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 53MB3Vql004230; Tue, 22 Apr 2025 12:28:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=lpktmXmYT8DcJQpgNACg1M/RAnm7ViUWfNS2ntYoMeo=; b= LsFmNDOHcvZHVmZezKh7dAtOA+IRuxRD+ltJPqkDPOW91nfTJmQJ151KpgULuF0a Xcws3HbrJMUANAxZRTI33TNMwBK4J/dRAStEKBoVJ/H4bZujGQESZRVjcv4Iww87 44GEfCAw7xPUpR3uZOppGGMb/bILWsl5k/8gskM3aj4ebUtT1jmPmpdadG+2ZO49 v5PgvStuBb3w0vy8Ep/Xsnes41MW5viInwcSADPC/6AMO1cGWgTkzacL21Kwtgfh o1Fmcz+ndmChe+TFgPSGOlhmnU3gChXvhf6SWNtaojBP/VP1UDnxa7WGzi74QDlg ihZgFp+5TcsJBZxfp3HMZw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4643q8vbud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBOta3033464; Tue, 22 Apr 2025 12:28:37 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013063.outbound.protection.outlook.com [40.93.20.63]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rtr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q1K97+5P/TLETVerCaCwmWo6Y2kVVpxovBKqYHjwtqyt5rUtIqgrXVxXWhEmwVJpBqigzeS0TdzdPCOCeRaL1Z6GK7CWiWk2DJHnlA46jhxGVAj/3E7eSONAcTEfEMhl5+2Y7Zc0wvgn8h3mB5UIXYFOfvHeQ7qQLJjIvf9BuHG0IiY/sEjDBSflbuEp5fkIbLqSfzmBSRWSVbGEkHwyRbKoUAcNA8pVWxplui5oSesjSIxB/u1kEpjgtPYXDrV8uMtSHIj4x2RkJlZv2oiFWlkD3Jzy+KZJAwcMEWdl5YzfPtvYlJvvsg3pQMRjtA9k1mcPNy8aBOUotRZuxx3Swg== 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=lpktmXmYT8DcJQpgNACg1M/RAnm7ViUWfNS2ntYoMeo=; b=CdcgskxKUiMs9BWZqm/Lf6pYJx/SMxQnFvPJCcmnQvZgG0f7X45FkT67NZ4g8xEQHN7pI9jFV2KBSkfDHunxz0P2utZK8Ln7liFtfGZmQTWQIRSdGzo7ZpnX0R3GzbGc2OCbMvKoWO8SIFrCPsAjTR4GxeWwBCXiPLO1u+dQhcClSjU5a5qsOroKpklERa03aJVgdpIyt6VZRaVFL6pLvvZa6E8YiH5agNkfXySyu3M8UflPtMtNCQ14WERCQHHm0vh01hn5oc1s4s4u0iPjGaDbpFI65BocINS0HfeRMhEsZXedy3cJqDENglCqP0cOx9M8MDVmQY4TDotPGZJt8g== 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=lpktmXmYT8DcJQpgNACg1M/RAnm7ViUWfNS2ntYoMeo=; b=ubEwADZsuYW0btz+Uyz8wXUgd7tB1UrBspVa6LnCSzAFDWzhNMqaVHe42IjzlTE1HIrykMqWdh94P+8rbRiSqLTXvRh74a2W4CU5ZeFis/aOz3uMknUO7TnHFJEjgZAElm0jSfBmHT32mHlDSEws8gZc1OymmQBAtXxC9nw183Y= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28: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%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:34 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 09/15] xfs: add xfs_atomic_write_cow_iomap_begin() Date: Tue, 22 Apr 2025 12:27:33 +0000 Message-Id: <20250422122739.2230121-10-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9P222CA0010.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::15) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 53614662-9081-4a6e-a42c-08dd81993339 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8Bo/9R7pvizb1xc8NR5BwOVUs0gcj1IRNl8c//ZZ2BAUumO9bdgGUQcLCI0O?= =?us-ascii?Q?zYf44+92UF4ZAwnRn273XsOLeLr9qaI18VlRoGMss5vSONCOPx17kjTsG1v3?= =?us-ascii?Q?FOq2hnhiSGqg1GdoIrXZLZQOijwVnxGaUYBX0an46KL0037fHoAsdIjyZT/h?= =?us-ascii?Q?VIVutOFi0IJL2/MRObmzFYKjfARRiIFKxzx3O+wKWSALbpVRqTqI/TU6LSyB?= =?us-ascii?Q?aRt574UNzIaYGULHfxOt9pyxoYxjIcdEvciOWo8PlcvhCtIRmlZOJzvJAF8H?= =?us-ascii?Q?aRrDpEjwOS51xCWYoNzuLPjvqOeZM1MdOpvAPQCx7BLJm/uGA9NQ4v8hbzYP?= =?us-ascii?Q?9/dReQmeR2fOZLuHKyTJmcAdv+Xhsa7gq9z4hIxfpRSCUA189lUdskxIFOIX?= =?us-ascii?Q?bn407OOLwgUu+aAQFGBRfPn4oyYdXjBFmPW03O6dSSCjryPju6wkcsv0l7jr?= =?us-ascii?Q?HkjZYLLf649rRQchmoemvUKSIhZlbSVLcxM82tLYmlZK8zC91wSDDed9oPaJ?= =?us-ascii?Q?EwuV8v+Rw57+X5sMMiUsWZ56VQ7qH12XBK4H95jjCW/mIYD8JNkMnUfLo59d?= =?us-ascii?Q?QHjWLFsZ32TUwZfd5WFZw53pXHXvFwlZN2H3bOij09cgmw7FvaxcZXd9TiKg?= =?us-ascii?Q?GzBGs4Z2gxmbPk0t0s+tlT28Mm9nT8uvZNtZHlEMCgWcSz+S6Hb5xAiqmaDC?= =?us-ascii?Q?vCsO/xVTtBKoAnSCrGBiFX3DlQGPsIMaoStFXavzeq6cy5XdxUtR9w5J0wbj?= =?us-ascii?Q?Vjmn1+pT3bC5k4mGVEFTJUuIBXDUCTyPm6Otx4n4B6mexhDSNrtTC2DrrtXd?= =?us-ascii?Q?vINHv16eEzCXdIlSUV4KwBDbASDHWdNm4qrHZedkrVgxCpS32jRO/OCGBeYw?= =?us-ascii?Q?dxWS1EhOpdPS3G0NkMJizLmV43c8qchSfZ/3qHm/C8l5zJr0XD3OBT8iO43Z?= =?us-ascii?Q?HEp6asQoT72PPRn500K3sXG143+fR2be0cE8hM2BcdMF2LqIZ306NnEyCSQN?= =?us-ascii?Q?kFQTP9Hr1yeHbVCaDrT2HxhGpKb4QmBH030u+f4jiXdoMUTMLT/OHPRPfAMO?= =?us-ascii?Q?fWQ/7KsGn8vAo0GfDx0M0D28I805jsHw3AWiOi6il93qqepIYNLj0MY1R3eP?= =?us-ascii?Q?8gcC4xjBZbIdIFhaVWpGLENBkdM0prohLWzP9iJoWtAu3TgNgSmAywhrBj2b?= =?us-ascii?Q?y+EKAdQIGZOhRchlv0E7BhWlccnLx0tl6yOxkghV09Hrf+r/Z0XzZeJwwvLg?= =?us-ascii?Q?wAKVY+cZsvuGW5Q8mlqGmBHZaXARJz7uc98m7I9g4XzBfkuTzNeTK0EklD7s?= =?us-ascii?Q?CaRM65WZkS+LLL6WWKNikm/H9lTnKomV7s6DkGIQkwZVZm6aE909QW2apYbN?= =?us-ascii?Q?8buCBb2h4aCgIqgeTz+wsFHXXLdj6/MZsj63/MSdlwJzEB2J466Xc8WNK+tB?= =?us-ascii?Q?0x9L9mFM+gY=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?A+93A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lqmS?= =?us-ascii?Q?/PuUUd5W3OMBfxyfSBlzTutmQl5f3ZB5UXBIyeGY2ymp5FMCQe1zmmvzHVPY?= =?us-ascii?Q?E77QwTipLIoxdFYxFmLbrbeh7PN3Mq08OP7bMlqJa3haGW8c6OFK64iXO3Eg?= =?us-ascii?Q?y0gb+E6DcOK3fbhx/QlQM78aDLHZAnl3GyZVuNGkXv10NMGjjks/OJT5JUCd?= =?us-ascii?Q?Igc6HSPhBpGsOAqRNphKVxwNXjo44F9eamuGhbn8RLFx8O+DeFU0o6RPWjM+?= =?us-ascii?Q?Q5f5BpdHVcYiNd2MSo012ZfYxQYDM12mBIL3JkIyP/3U0VkdXOfogCxjkYLA?= =?us-ascii?Q?khTiESk9WW38j0LosuIqMQzvZF5nql3m1WdGoN2mJlSko153hvDqi8URGTZv?= =?us-ascii?Q?VYNHfe6CFW0uoYFSt+ZAJWKzBxrwZupiPCS2zNdAQkJxAWMGm0TfeC2LUnOW?= =?us-ascii?Q?gn9zecf8mP/EPPmd9Q/SdhfPlVtl16etq/HEv7wbWFkhL5RCGPj3RkoxTLSE?= =?us-ascii?Q?yZQ49rC1MsNcOHDP9Mwr21ZxlLpWgf86wxfEP6kmnlKvjLwn4/fwDs+vMYON?= =?us-ascii?Q?fdPj60WsEpmogbauO5/bu3bYkUMsUH19GIVUc/LUM6OLSb0RCOfT8CGgtDf5?= =?us-ascii?Q?eOXLgWOxi+C9ogdvfgaDdVTNzVSzx1BP+BhoSRX/MLcDt3KV1K7zAvqIIPOs?= =?us-ascii?Q?xon+hpwx4py4gUTtBpgixQMiMko0sKZU84HqSKb8BgnxGDWEVtx/3AWB1/bd?= =?us-ascii?Q?Yg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Kip4Wklkwn3xmyjGSsVfUDzOurXnwubXK2aE4kHB08TJXEAGZa2iKiKCWWb69TklkQrrQgJjYW8fY31fU2nTAadH+JGXiyNg1MfxwY6/BJ7GjXWQNQEpMZyJk/xIVcrLtDOC4tcqPttpiiwCZnQNZIoriS2uTXWWn+nRPtCSfU6gWcjv5MhAoyneQ0paGEflo3xZ9N8iyIxgoryASi0q+xncn8jVwTrIk33KYiwhfaB+o0Vf394E2R0dqDVRax8Iy4kxxd5OIM4/lgTw7E1yqGL8BCw2pS0unnYQR2t060yUH2HJA5jjKZerxY/qCajlPZCwfOJFeTcBuO4zLoKh6yU+nuuoM4nKAHr23PfNhQySUjRTfDyqOiAz87tMRriagmiEyek6qE+JsqYfMMbL2WZVGVkkBLhBjHcqVAgusaBV7VlOk1ulv6tOHLta0dKLBzZy1LzjXGWuj+6d4NApUwv7eztIKRxIC751B/E2okx6PNZsvk+oCRRR6aiQjzTBpFuryLg+mNauBSqgkb2zGRqAITYh4G0gYIw5ESWbLW4uEaIA8pWaNhlhwDlandXSjhAmfDaXZruTpAYoBCl25Sykih8riZNfDq5EHVPm9uo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53614662-9081-4a6e-a42c-08dd81993339 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:34.7094 (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: hdtBTV6i7Hj36W6Dr2Ihh3hoNiRvAuJcwIYXnUKnly40WJBemXVaUcC2vuQOJQgaodXbb2ErX6I7IWqw6A9Acw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: emb6_pkvoT7IaMTS0rOxkywYkVW8ttYH X-Proofpoint-ORIG-GUID: emb6_pkvoT7IaMTS0rOxkywYkVW8ttYH Content-Type: text/plain; charset="utf-8" For CoW-based atomic writes, reuse the infrastructure for reflink CoW fork support. Add ->iomap_begin() callback xfs_atomic_write_cow_iomap_begin() to create staging mappings in the CoW fork for atomic write updates. The general steps in the function are as follows: - find extent mapping in the CoW fork for the FS block range being written - if part or full extent is found, proceed to process found extent - if no extent found, map in new blocks to the CoW fork - convert unwritten blocks in extent if required - update iomap extent mapping and return The bulk of this function is quite similar to the processing in xfs_reflink_allocate_cow(), where we try to find an extent mapping; if none exists, then allocate a new extent in the CoW fork, convert unwritten blocks, and return a mapping. Performance testing has shown the XFS_ILOCK_EXCL locking to be quite a bottleneck, so this is an area which could be optimised in future. Christoph Hellwig contributed almost all of the code in xfs_atomic_write_cow_iomap_begin(). Signed-off-by: John Garry Reviewed-by: "Darrick J. Wong" Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 126 +++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_iomap.h | 1 + fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_reflink.h | 2 + fs/xfs/xfs_trace.h | 22 ++++++++ 5 files changed, 152 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index cb23c8871f81..049655ebc3f7 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1022,6 +1022,132 @@ const struct iomap_ops xfs_zoned_direct_write_iomap= _ops =3D { }; #endif /* CONFIG_XFS_RT */ =20 +static int +xfs_atomic_write_cow_iomap_begin( + struct inode *inode, + loff_t offset, + loff_t length, + unsigned flags, + struct iomap *iomap, + struct iomap *srcmap) +{ + struct xfs_inode *ip =3D XFS_I(inode); + struct xfs_mount *mp =3D ip->i_mount; + const xfs_fileoff_t offset_fsb =3D XFS_B_TO_FSBT(mp, offset); + xfs_fileoff_t end_fsb =3D xfs_iomap_end_fsb(mp, offset, length); + xfs_filblks_t count_fsb =3D end_fsb - offset_fsb; + int nmaps =3D 1; + xfs_filblks_t resaligned; + struct xfs_bmbt_irec cmap; + struct xfs_iext_cursor icur; + struct xfs_trans *tp; + unsigned int dblocks =3D 0, rblocks =3D 0; + int error; + u64 seq; + + ASSERT(flags & IOMAP_WRITE); + ASSERT(flags & IOMAP_DIRECT); + + if (xfs_is_shutdown(mp)) + return -EIO; + + if (WARN_ON_ONCE(!xfs_has_reflink(mp))) + return -EINVAL; + + /* blocks are always allocated in this path */ + if (flags & IOMAP_NOWAIT) + return -EAGAIN; + + trace_xfs_iomap_atomic_write_cow(ip, offset, length); + + xfs_ilock(ip, XFS_ILOCK_EXCL); + + if (!ip->i_cowfp) { + ASSERT(!xfs_is_reflink_inode(ip)); + xfs_ifork_init_cow(ip); + } + + if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &cmap)) + cmap.br_startoff =3D end_fsb; + if (cmap.br_startoff <=3D offset_fsb) { + xfs_trim_extent(&cmap, offset_fsb, count_fsb); + goto found; + } + + end_fsb =3D cmap.br_startoff; + count_fsb =3D end_fsb - offset_fsb; + + resaligned =3D xfs_aligned_fsb_count(offset_fsb, count_fsb, + xfs_get_cowextsz_hint(ip)); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + + if (XFS_IS_REALTIME_INODE(ip)) { + dblocks =3D XFS_DIOSTRAT_SPACE_RES(mp, 0); + rblocks =3D resaligned; + } else { + dblocks =3D XFS_DIOSTRAT_SPACE_RES(mp, resaligned); + rblocks =3D 0; + } + + error =3D xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, dblocks, + rblocks, false, &tp); + if (error) + return error; + + /* extent layout could have changed since the unlock, so check again */ + if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &cmap)) + cmap.br_startoff =3D end_fsb; + if (cmap.br_startoff <=3D offset_fsb) { + xfs_trim_extent(&cmap, offset_fsb, count_fsb); + xfs_trans_cancel(tp); + goto found; + } + + /* + * Allocate the entire reservation as unwritten blocks. + * + * Use XFS_BMAPI_EXTSZALIGN to hint at aligning new extents according to + * extszhint, such that there will be a greater chance that future + * atomic writes to that same range will be aligned (and don't require + * this COW-based method). + */ + error =3D xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, + XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC | + XFS_BMAPI_EXTSZALIGN, 0, &cmap, &nmaps); + if (error) { + xfs_trans_cancel(tp); + goto out_unlock; + } + + xfs_inode_set_cowblocks_tag(ip); + error =3D xfs_trans_commit(tp); + if (error) + goto out_unlock; + +found: + if (cmap.br_state !=3D XFS_EXT_NORM) { + error =3D xfs_reflink_convert_cow_locked(ip, offset_fsb, + count_fsb); + if (error) + goto out_unlock; + cmap.br_state =3D XFS_EXT_NORM; + } + + length =3D XFS_FSB_TO_B(mp, cmap.br_startoff + cmap.br_blockcount); + trace_xfs_iomap_found(ip, offset, length - offset, XFS_COW_FORK, &cmap); + seq =3D xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, IOMAP_F_SHARED, seq); + +out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return error; +} + +const struct iomap_ops xfs_atomic_write_cow_iomap_ops =3D { + .iomap_begin =3D xfs_atomic_write_cow_iomap_begin, +}; + static int xfs_dax_write_iomap_end( struct inode *inode, diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index d330c4a581b1..674f8ac1b9bd 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h @@ -56,5 +56,6 @@ extern const struct iomap_ops xfs_read_iomap_ops; extern const struct iomap_ops xfs_seek_iomap_ops; extern const struct iomap_ops xfs_xattr_iomap_ops; extern const struct iomap_ops xfs_dax_write_iomap_ops; +extern const struct iomap_ops xfs_atomic_write_cow_iomap_ops; =20 #endif /* __XFS_IOMAP_H__*/ diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index bd711c5bb6bb..f5d338916098 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -293,7 +293,7 @@ xfs_bmap_trim_cow( return xfs_reflink_trim_around_shared(ip, imap, shared); } =20 -static int +int xfs_reflink_convert_cow_locked( struct xfs_inode *ip, xfs_fileoff_t offset_fsb, diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index cc4e92278279..379619f24247 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -35,6 +35,8 @@ int xfs_reflink_allocate_cow(struct xfs_inode *ip, struct= xfs_bmbt_irec *imap, bool convert_now); extern int xfs_reflink_convert_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); +int xfs_reflink_convert_cow_locked(struct xfs_inode *ip, + xfs_fileoff_t offset_fsb, xfs_filblks_t count_fsb); =20 extern int xfs_reflink_cancel_cow_blocks(struct xfs_inode *ip, struct xfs_trans **tpp, xfs_fileoff_t offset_fsb, diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index e56ba1963160..9554578c6da4 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1657,6 +1657,28 @@ DEFINE_RW_EVENT(xfs_file_direct_write); DEFINE_RW_EVENT(xfs_file_dax_write); DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write); =20 +TRACE_EVENT(xfs_iomap_atomic_write_cow, + TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count), + TP_ARGS(ip, offset, count), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(xfs_ino_t, ino) + __field(xfs_off_t, offset) + __field(ssize_t, count) + ), + TP_fast_assign( + __entry->dev =3D VFS_I(ip)->i_sb->s_dev; + __entry->ino =3D ip->i_ino; + __entry->offset =3D offset; + __entry->count =3D count; + ), + TP_printk("dev %d:%d ino 0x%llx pos 0x%llx bytecount 0x%zx", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->ino, + __entry->offset, + __entry->count) +) + DECLARE_EVENT_CLASS(xfs_imap_class, TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, int whichfork, struct xfs_bmbt_irec *irec), --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 DAEF71AB531; Tue, 22 Apr 2025 12:29:48 +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=1745324990; cv=fail; b=FdDRU1rPgfp9wxmOE2QdfpyQox+TH59E6UL31qaXmt1w72f1JneJ2hC4sADZBbHjxQeO9RHOtQ4CHszQ6e6sY91jlWmVAA6eleg0VItA/8ALRSqHPdg3T5aOCrVIUWdw1MCyoPVL6y/mcsWcAQkverdNLxMRZgfITu4kmgsIhzM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324990; c=relaxed/simple; bh=moBFMDnRa7v/eTz0RLb62ulSWo2wPzxkNIbypv0rLEg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=I4J3WTRdjajnYKOU19LNxt3UH+SJkwylz8hA65Hq8utljAwRm9QaPaWP5zJjV7B65dnyMJinRXX0pMO1qbR4klsvfNAeqHiLYdaK7s6BXE0OuxyVSB8FXyZVLChSwHNEbfqbuAjRKi79Xe90aM3PK9gIJZqQdxr+doEN5yUwDYw= 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=OmBKxps/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Xam5W1zh; 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="OmBKxps/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Xam5W1zh" 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 53MB3GqA008344; Tue, 22 Apr 2025 12:28:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=gUdTYbS53G/JglyD7pykL5+aR4OzZqW2GZp0qm82jC0=; b= OmBKxps/qJJwkXXaV/4JXmSjjfPeAuPTPDULBb+f4IVEHhKMIL6LV9kfHZM26woC t3H4mcbJ07cesbfVHeqOHGvylrdwfUiHHOJKaIaKgqMGXfKmYBpkBhMF73GSRxxH QQ8cyG709l1WMqU0aii4rNbfZ1yWr7Rla8O4dJ/0lgFtCjLjXIuRuGvlp5Tg72uV ZOoFvgnFSzR3yJS9B1vsIK9gii5+Nq86w3Zj2rFt/qulhNue8rZiOLOe466GJ1N4 CoyC0U033WTeU3DCClkJK+HiMDwkJpOsAsgdlAZ1qsqown9wyXuDp7KRexNh5sgQ wqy00sLIj1UvDuqXi9Imfg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cdea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:38 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBOta4033464; Tue, 22 Apr 2025 12:28:37 GMT Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013063.outbound.protection.outlook.com [40.93.20.63]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999rtr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jZREb7gmbPmODD7tAHya7RbOPxzqEIfWEpT3jPilqXj18oxkZwRwWnobhQdKXd5I7kP7Ka3UkcCY9kFMIw7FPzjdZDw4wDntRlyqQN0bkzDNpn9nqHF0WJugOLVCdscjmtXDfHFPklEbFGhResYf/7rMtemGshWFMN/hZXvDWcbHKlTxwIKzv8hyJm3LkEOOg/CgmNJQdCEWu0ygggULTMkkLWc9i4+hTFWs8GojPU2+Bwot60jNxpIyb7Ou2PzGgUjM6xamvcej6huOBPQUUKgEuRcaCW7oHpwhSwTHoCvLSArYtI/9TCAl7voSATFWxO1LI2Qi3Y2Mb0Lk0DRpAQ== 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=gUdTYbS53G/JglyD7pykL5+aR4OzZqW2GZp0qm82jC0=; b=CC+SXdI7OeFI3ALv1he21qd6lwmZasjujuG3JqKjaKVLsblct52SaL/+TebM2ayUJL/zurwkqVQkOk6stBK0XWLmzCEr++tCDWEOT3ktxvNo+HKOjDwfLmB2pudVHQxg95B1b9s3ToJvOJp4CKpgyzvUCsh20etie3GsSSXGdBP2vBNDMd/ztdXAoNK1Cv8gxulAtyjXH7Ft7g1lMhXgu9IlgS5f42ulPlqv5my21KVT9zrprhSqs9GJbo9kCUgGven9m+s4+55fZLImbAn0++jYi2d1lDJXh6U9aBLD2NAQLwNPMOPqwBDVNuAvWwmGjV0h8nuW7mCR1Qi/WOzjXA== 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=gUdTYbS53G/JglyD7pykL5+aR4OzZqW2GZp0qm82jC0=; b=Xam5W1zhVOTYwVU34j+shD11riGm2KmqE/KSaOQZ1YxPcnMgnhKwdZUd/t96RvUGFcVyDdbgS88aeO0ReCIlwYOR3mVuIkH6hlcy9vo48kLpmbZZredaAZSnHT1mg2xb+C1Kl5S/fMlXFvl92JdiOv7/TgkInLIrcS+IgoE7toc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:36 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:36 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 10/15] xfs: add large atomic writes checks in xfs_direct_write_iomap_begin() Date: Tue, 22 Apr 2025 12:27:34 +0000 Message-Id: <20250422122739.2230121-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR15CA0058.namprd15.prod.outlook.com (2603:10b6:208:237::27) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cfba475-b74a-4af9-3779-08dd8199340b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fldRZ80PHz5JgBB8Ow+NE4V/s7gmruf3fyGF1uTSSdD9F3oKZL/TeZC79m9j?= =?us-ascii?Q?YUT23w7jCl4yVqwy9csAVtH7f0gKCKoLN1FurtZYKA14nYdmkD833to2eKCc?= =?us-ascii?Q?vmr7PVTk5SLz7Qlni3Y11PmxFNtkmjdbILcIJQjUuENQQqBntZrTNvPwF3vg?= =?us-ascii?Q?cqzZIjt+dzinK0B/38p9FOAVYoir2zMkMobNFuupwmLD2nkNgxQMj7GoqdAJ?= =?us-ascii?Q?+KqDByhIEPTZImmAYJK2Qvgr+VX3fD576ogAWNInksPqZrGDRKRPhlN+85hU?= =?us-ascii?Q?f1ZZcB1sMZw7G9+MwHxK9J27TG6fVKVd9IxTL3k/OJcUiruvqSdPgaoeCDF/?= =?us-ascii?Q?RwmqBmWExgG8+IveP+YYnHWQl/s6//zzpeW8ftCDqGcGFaOAssprpA1U/5TS?= =?us-ascii?Q?VSs18/d+QGp25LaGkEcQVjYiudA7tj1tAWCVDYbsEEHTy/4r5tgQLjwAMk1P?= =?us-ascii?Q?06eFJPGrT8Q58U5SKUqdY+KyBIAwRGpfYktdBlhDPOn3PlbGlr2MZYsBM7sA?= =?us-ascii?Q?8hFraSv7yNowf/7BH2afHnJVyGNI0ygynkj1jF3r6pUPFL6NxzxUJt/3T4rC?= =?us-ascii?Q?Ep+slb/MMOnXiOmRov8YMYJVuBylWzYAWVSGYhJPYtsPngN0DYki7PzwV5Ne?= =?us-ascii?Q?oKBV870afIHAAtNmlqM2ipDZ2iF2hXDVHeJub2DTmq0nUdlRcm7rV79FtvTd?= =?us-ascii?Q?Fw2jmzgztcFfLcXKZCeXUEMP0dP/4FofphBfuBSKg5Zi+t6w7uNf9bX1EJeI?= =?us-ascii?Q?tOd1L4cJfK+L+ETdg1jS6CqXHoZQXfW5wnRFpY8EsQPWRuEUpieBrOrajqu0?= =?us-ascii?Q?AFchssHCNfAVeM/TMCBK1U5fkDhuB5zwmuPgd0BEcmHqZLEDEYvQP2uD4pD/?= =?us-ascii?Q?UqS6du19iyxLp9djR7qHikOhzUJjwL/MsyvN4xaInhB+B8aENuvoWUw4VzH+?= =?us-ascii?Q?bol95XJjIjrrW2cFm4fhHanm240saBhTS9ltcZbfmRGqksDJJFzMDtJGl/gy?= =?us-ascii?Q?WdQM07DrMi8gaCJ2z9s4D3F9vvtrqKpEHCAOlEZ+igDvpk3zCM+acUhg5Vdi?= =?us-ascii?Q?M1pphelNx1b+ndtD13Ra/DZHzjsHnLktkkFKWHNcsDDxMH7mdbdH1CZom9P1?= =?us-ascii?Q?eL1P6H5eRyoAfUrYyiS/djFvSzpHt96nUR3IiKIouXUq32laFLEnf4+mU0O8?= =?us-ascii?Q?YvLkwilnVPt9b7espZUyXs1qdPmflGuOsezs83133N8P/pkGU1/FZy9LYKOB?= =?us-ascii?Q?hdBsTIUq1y+vl6xlrteEW75pTNJZLd6AkHKEkJ6UgofWMwXlTY9VadeDAQ1F?= =?us-ascii?Q?JeZun2/Xm/x9fYKE4MnXhAGMy8dTntDlyF8jsfgP56rZCG2rMutVOTHZSquZ?= =?us-ascii?Q?knNtuhRrsADvSIVsf8dERmHXwTWJ1QPjpWtundsnlzUh7Vnem4nsF07Azh88?= =?us-ascii?Q?L4vDpZ1VBiE=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4ZYgHrsdudITFRmk7vTQzxlQbyj2zC4tBkhhyMr0xUxGf6iPhmzPlAkWsqCs?= =?us-ascii?Q?FYp9dxDkFHIy2RUihwkAQgK2CVA01i1oJunLecea83k//OzNatEJXnBTqzNm?= =?us-ascii?Q?hAn+pyOy8qMCLS0/zw8cIDx5mokfBzoQAhpoHel6mydd2zuiaCINHoQJ6Iz9?= =?us-ascii?Q?KO8rW1oLL6BVqnjOMZYLn8kguDUs+N3SctUnh5y6yEqcImQxgf5BVGxuZCyV?= =?us-ascii?Q?HgemWQx5PeiZPK8BElYs9mvXs8qJLvQJMHTi9d82Lfvzt1Qa93jqkfrJTyvs?= =?us-ascii?Q?ieuhhIivkS3vQQCOsQglaoMkBLRTKVyVRK3BMkiPxLcwntyYb+g+FFo9RvI1?= =?us-ascii?Q?YxUsR04JLRsUJApq/jr3E5YavvOrY0IxL/jTYUjBlX1cp/VAQIeUCq02velP?= =?us-ascii?Q?O9V92GIRQVCNq+wIKvOmipBsGePpV+zErR8WNwdVrbGgaskaInjOm5BzylVv?= =?us-ascii?Q?9MAfOkV91XeYYJJUevJmY5mM5k0N80aMudvu2vJ4hDsZG8d8/Ga90U5XF5qD?= =?us-ascii?Q?VVrSlYW8Wj3g/QbUV7fnLswRGM2kK0nmUbnwgnjVIMNbvBGUP168HIOejJtg?= =?us-ascii?Q?TgR06CchbDCe16awBoBHDPGlWO0wnXi40uSg97dxVh9gOKH2JSea4ZlcqpMw?= =?us-ascii?Q?VwneaAfORj5jXZvOGqoTvglGQMCiICpxExVEtu96iU9RpvYM2ksKnvlEm8iI?= =?us-ascii?Q?xetFLC5dVVq+4vL6W6BZ9LG+bBd6w72RDDBzPnUo3mH4TojdDhKME+S54Gk3?= =?us-ascii?Q?Ho8KwYtx64IAHDpQGUnujLdUHU6TJI7cAXkiVxwOoclAXuMkMA6r/WXZDTV5?= =?us-ascii?Q?J/FBBbHmX7NqzXGKZAf3n9v50TQnBre0CQYPtUau2J/pbQP8RlCV+1A13dJw?= =?us-ascii?Q?fdDBi5+onQz/lHe3dBixIRftfwEjZyBnMXlXeS3uf6u/9gDfxcd2XwHORH2w?= =?us-ascii?Q?rv2jBOBompeQ7vR5b/4k42yi46kyi7SGzlcVEBq0ZL56PX7+92eqMUDuwL5i?= =?us-ascii?Q?b111V5hyy/C+0INj79AVInm9mj1y3o+P70ejXPpj/k6l8PBlrmtR4BzdMq3K?= =?us-ascii?Q?EaggEypwGeT3zkdEYF28r1/KHPmMXg6DptxUQFy3IMjrTUrfPpiYcr3ILxw8?= =?us-ascii?Q?dfmsO+20DRLj1XQqmubi0RzK4s77hOuZdfCvPeff56ZVXV8SQEhqsoVowVr6?= =?us-ascii?Q?qYOZKD++rT1VdsPfbuHYhf02lo3x/N3uuWq1hZNNx/sngmuhFU4LqLI3EVMy?= =?us-ascii?Q?/N0i5i6GMk1Dr1vD4DvP77/H10PWatBE0TJoDs8n6wtYzTLQPSEkEJ805Z9g?= =?us-ascii?Q?7xfjNLgiYmCp2MZh6bV7mPlIkCJ927LxM/DjTBA2BJqh0dTNBoRNvkgfx9MB?= =?us-ascii?Q?W0QrMvAygXj1h9lweDlDcimKBIoSEW5CQmnWFO+OkJsXuPa56vTJdyO0Mc2m?= =?us-ascii?Q?gerIUCSZgP3tVivkF4RWsDNw32pD+wOWILNaP+q4SP8V0jrTQkrtAswWKhwg?= =?us-ascii?Q?nKS27SQev1QRxf4BYG+ji7Hz0+jA1i1I3DD0AwRYpl3DhnHZOsuQhLORl47R?= =?us-ascii?Q?3p2X7cH7zWjF+yBWHph9qVISrpEOJzGxufkGYBZ6tx7En9m3gcPzRLiN8ovF?= =?us-ascii?Q?ww=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ysQcagKJJuIn9HFodbXOSbKL3qxEe4UBhpg/zHDAsz6lRdAyQ38zg7PixP6zrDsMsLuiVDW2+vZgLJnqjPyXyA7wbiO99/Hw9hs0/MYeNnxOcQ+wRCXMTvnfPKJJJt78Znds9rIvVAv6Xyhn4+6967JMtRr32koHbJOJEwjHU8mE2xYO+SGZ2RGfN+2ablG8EZ+WBHJWMpjvGzlOW/NBalfiDvmE0bRDeBGWj4wi2dXiDVGonEYpTD6UOMIzE9LBvIoOapbOpU4QtVkLFm3fnokxy4fwDm3tB3b10Ie5StPo8tbYuqOBVNhg01i+QnQyqayz5rcX10KfNeOvyy/az4D76ztuK7DiXABZJ0BinjPp/kgbCa4BYBbIFJD274PxpNOOzdoVzLqX2Ky0ZJnHZU3oQfKtsJLJf7t6SB7R0gNKQdXAW9w6AvtqhHP22nEkh2FBnFKAxfpNdd/vToaCgDKeOU90+eFZ31FGgL7Xw+j0wIMZ5taPv3HGzQ5JaIZDVmJSepI3t8u0VElKyaYM94GTI0BlXQn1FpgjE8AO27eGQOZN40QOK7CWQ+lQUbQGR71pnJc5dIKF7UNTiDWS+AGSjpnCmjJ62Ut5fl23YNU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cfba475-b74a-4af9-3779-08dd8199340b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:36.0895 (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: gHXfNV7M+KJmvjv173JRt15fkM4oPtbi2c8+futLguk5MYG3XcXlWf7jc4wvJYVIdR4Ib9+q1kF9kJgz5H0hjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: BB2MaS1IwRL7WZsX6TKJK9VGdISTZS9f X-Proofpoint-ORIG-GUID: BB2MaS1IwRL7WZsX6TKJK9VGdISTZS9f Content-Type: text/plain; charset="utf-8" For when large atomic writes (> 1x FS block) are supported, there will be various occasions when HW offload may not be possible. Such instances include: - unaligned extent mapping wrt write length - extent mappings which do not cover the full write, e.g. the write spans sparse or mixed-mapping extents - the write length is greater than HW offload can support In those cases, we need to fallback to the CoW-based atomic write mode. For this, report special code -ENOPROTOOPT to inform the caller that HW offload-based method is not possible. In addition to the occasions mentioned, if the write covers an unallocated range, we again judge that we need to rely on the CoW-based method when we would need to allocate anything more than 1x block. This is because if we allocate less blocks that is required for the write, then again HW offload-based method would not be possible. So we are taking a pessimistic approach to writes covering unallocated space. Signed-off-by: John Garry Reviewed-by: "Darrick J. Wong" [djwong: don't allow too-small hw atomic writes either] Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 65 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 049655ebc3f7..150354e5b436 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -798,6 +798,41 @@ imap_spans_range( return true; } =20 +static bool +xfs_bmap_hw_atomic_write_possible( + struct xfs_inode *ip, + struct xfs_bmbt_irec *imap, + xfs_fileoff_t offset_fsb, + xfs_fileoff_t end_fsb) +{ + struct xfs_mount *mp =3D ip->i_mount; + xfs_fsize_t len =3D XFS_FSB_TO_B(mp, end_fsb - offset_fsb); + + /* + * atomic writes are required to be naturally aligned for disk blocks, + * which ensures that we adhere to block layer rules that we won't + * straddle any boundary or violate write alignment requirement. + */ + if (!IS_ALIGNED(imap->br_startblock, imap->br_blockcount)) + return false; + + /* + * Spanning multiple extents would mean that multiple BIOs would be + * issued, and so would lose atomicity required for REQ_ATOMIC-based + * atomics. + */ + if (!imap_spans_range(imap, offset_fsb, end_fsb)) + return false; + + /* + * The ->iomap_begin caller should ensure this, but check anyway. + */ + if (len > xfs_inode_hw_atomicwrite_max(ip)) + return false; + + return true; +} + static int xfs_direct_write_iomap_begin( struct inode *inode, @@ -812,9 +847,11 @@ xfs_direct_write_iomap_begin( struct xfs_bmbt_irec imap, cmap; xfs_fileoff_t offset_fsb =3D XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t end_fsb =3D xfs_iomap_end_fsb(mp, offset, length); + xfs_fileoff_t orig_end_fsb =3D end_fsb; int nimaps =3D 1, error =3D 0; bool shared =3D false; u16 iomap_flags =3D 0; + bool needs_alloc; unsigned int lockmode; u64 seq; =20 @@ -875,13 +912,37 @@ xfs_direct_write_iomap_begin( (flags & IOMAP_DIRECT) || IS_DAX(inode)); if (error) goto out_unlock; - if (shared) + if (shared) { + if ((flags & IOMAP_ATOMIC) && + !xfs_bmap_hw_atomic_write_possible(ip, &cmap, + offset_fsb, end_fsb)) { + error =3D -ENOPROTOOPT; + goto out_unlock; + } goto out_found_cow; + } end_fsb =3D imap.br_startoff + imap.br_blockcount; length =3D XFS_FSB_TO_B(mp, end_fsb) - offset; } =20 - if (imap_needs_alloc(inode, flags, &imap, nimaps)) + needs_alloc =3D imap_needs_alloc(inode, flags, &imap, nimaps); + + if (flags & IOMAP_ATOMIC) { + error =3D -ENOPROTOOPT; + /* + * If we allocate less than what is required for the write + * then we may end up with multiple extents, which means that + * REQ_ATOMIC-based cannot be used, so avoid this possibility. + */ + if (needs_alloc && orig_end_fsb - offset_fsb > 1) + goto out_unlock; + + if (!xfs_bmap_hw_atomic_write_possible(ip, &imap, offset_fsb, + orig_end_fsb)) + goto out_unlock; + } + + if (needs_alloc) goto allocate_blocks; =20 /* --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 4500D284B33; Tue, 22 Apr 2025 12:28:54 +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=1745324937; cv=fail; b=ZL/N9KnP9I1OiPJ38CSPjedOcsTMQ5hsxuHdQzR7JWzn7AKESx6jEElVunmX0679xsH/3uAxUZxBfRfvnie/atiXzyujmIIfln4uP0JUmhPAEnE2QWWyko5o6VTNClQJEsTur+Ucb63eXzAIijs0AJ/JhWLQyysmxrjxtcOE+ts= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324937; c=relaxed/simple; bh=5u+GbHU06ZK08aeXXYAR9iNBKDMNLkD3h97Co7Kcsso=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DpZUQHqdApumYUIwz+EnbQGf4gyiyhW/IhJnQeauMcljAi08cYu4C3ZFl3920dRZap4kblOalR2QAXtGAF/n1BhNWajMkXqrDQ9hL+aphXTgWhVe8jGFjKaOYnt7LOpgjnfPO109GfieTM9DojguMHHMkncFlIZqzD7gK1n6/gE= 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=Wz7ohoRW; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=VcEBq4wI; 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="Wz7ohoRW"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="VcEBq4wI" 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 53MB3BUs031447; Tue, 22 Apr 2025 12:28:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=GXTPyqaIDRxuwe58VO1ToDoisTtoontPjBBkYq7GHbM=; b= Wz7ohoRWlfLOFJXWSZ3UYD0XnwapOI3HDeDf7XNucMvm4UikPp+Vsj6jVBctzuGH fieGB54Mmw0iQlzyFaPRAQ8zqRGN41fA6sh03XwV4utjhge0Xq9ycxti1u2bHtSm kVnrrc5juQMV03D923AvC9hMeigIHM9nZmRdN6HOHvqEBpVeCVxJ60Qww8m7igIQ QV/C5LjyXjCFLR+hvd7ZJDuasLaEndcPNhTAKLJFlE1ijD42lUbH36pgZi3TeWSJ 7WWKQL4n85cG/xp//4LLr6H/AseGX4CDf3t5gt+dMa2J9uggulN/Jsna/TOkc8Wz O5zAt4ttty6zg3lrNCmbgA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4643esce2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:42 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBpMX6005858; Tue, 22 Apr 2025 12:28:41 GMT Received: from sa9pr02cu001.outbound.protection.outlook.com (mail-southcentralusazlp17011030.outbound.protection.outlook.com [40.93.14.30]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 465dejga5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rwGoXbIN6+1aVVuiU1EK0ZKnme9ZK9vKjYn4GDj95S4vr4Q6Gb1J3VtuizUvPGOg407lo3d98Vz6bMOl5nL40fbxuY6OEz7RFH1mXwPPpkL0wtAQcE/qqNzGn4dm8fIfquZoWz9aed6BJfR00D9tcNuqUNJYZtkyvkZVldY3hhcE9hmAyyd7bFQQLYt8n00BNuXnYWdQwwo5ROPCiY5U4m0kNaKEKGCIicAvMd8yFksowKwJVbw8Q3tyMztb/L1hh/H7z1BiKoglx1/K3EGubsNxaoFBedLjQs9bW+FgyabP91eakew5Gbjhz02gGG7cHdI0aJ5MK/SYt5OXq8iYQg== 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=GXTPyqaIDRxuwe58VO1ToDoisTtoontPjBBkYq7GHbM=; b=GVeyQTRWjIgfyVyOJiDex7KWMmoN5QCsY9xurK8ApOnTW6v5X7mkRSVpjQN0EpdKmJs8siO4ECE1y46973DOgFwBxnVZuRqYrnG/T5byhw4/pSv8fqrTDTs+7G+xxY0DXoE56y0kfHzFSFKnegPes6JYoVv2aR8IgblfRdz/MGIYKpzgqSseu201Fe4iEP9w3EJ+V9jCPrqBHtmia8ZWOFptIQfiFRRjd1XjGsWOPPtxbE6IUMlNk2Cvz8g4TEGjdCniYXgAVBk3Pz9exR47Q14WeHCFu3x9xAO6Z1fMA3rBqTBdV2X2YzI00ung4ZBpoRIhlH+7E2UGwuZcE5MlaA== 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=GXTPyqaIDRxuwe58VO1ToDoisTtoontPjBBkYq7GHbM=; b=VcEBq4wIKGLr4woM9UR1aFuzlP9UTlYm2GwP3jWJZKGTarbUh/dfs29IalynmilpignWINngYWV5c2JcInLqPi45jZDEvr/24DjR2321WL2EC5eQjaKUCYvzf3O0ltB6PGSpCm9FhC05qm1z3P6yX8XILU2F/Nb9cqnF37facc0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:37 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:37 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 11/15] xfs: commit CoW-based atomic writes atomically Date: Tue, 22 Apr 2025 12:27:35 +0000 Message-Id: <20250422122739.2230121-12-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MN2PR15CA0060.namprd15.prod.outlook.com (2603:10b6:208:237::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: d884bfa9-8798-4d40-4b92-08dd819934b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Zb08aoHTiHpDs8s8yIJ6l2lQmxSiKJzVCMRyfjcEWLGU99ki6YX2hjBIMhbj?= =?us-ascii?Q?PtTSKiTM93GYjWx4bG+XTym9nbDftM0xswNpawyUuPrEB7MqGwF1xzrqa50z?= =?us-ascii?Q?0RmdVTLMyHfGlpUi+zdRtfGTltQLYrnCGi7q+sM8T2VSYAJLb1ShmJ8hZR9G?= =?us-ascii?Q?Jm2fLjqmbH7BqfVKqgmy0ezfUVVQN4qgt3ZUnDnewUAIbmITbEPaa453PY+a?= =?us-ascii?Q?yZQRigJ2Cq1g5YTBpeb8hEwGQRcHfyuyvzfrkZGuy44KaZv0vDo3M1ct3bt9?= =?us-ascii?Q?kuTbNKaZvFcrvnNEqQEuEu+4KVqzae9OhdV2KWC0QDYT0wAB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WzlHMsc7R96ihJP2dDZOPVI19afYhbnPbNRFiIIH?= =?us-ascii?Q?CIQ3xMWuttgIUKnkKHdPqJw4rc/2B2JLo0120ZCIS/JkzTyepskW5KzXgdHo?= =?us-ascii?Q?bmTdmvBLIL8JcPqYV7i3MxfYIct/EURUggphVFLtYhwcbA59Oq9G5LkoEY3m?= =?us-ascii?Q?/FSGb6Pk8iX9q+aOiII5WrnWYBUAywd8oMOCJWKZ1LBNDYw3r/ycQxo8QB6b?= =?us-ascii?Q?queIk1SehAk=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GsRw6P9n9jU8WztUJKXhhcQJwLEKABIOhRoW5wb+KPNcweAFJS/dW/aGIi+7?= =?us-ascii?Q?eSzSyp9qeMlnWj/9+lp9BHuc2Nut8RGuokw5coQtpVHj12Rtz7Jp3rIEHsNB?= =?us-ascii?Q?8B4zfwiHKb/3BNmu4yNJgUgaVkVNFUSPflFR2aV+wJnjCYU+87E9hQjxwg+P?= =?us-ascii?Q?pslz50urnjbFgtDakDS+lfJvoJ2eLUBx6C81qdt/aFnUVaupJVmJy9vZnCo6?= =?us-ascii?Q?M6whGgOj6F7wSxnE8YQnH970Uk4WTDuaS1jeBPh1Vk1q70fsoevzL0rlK4Kl?= =?us-ascii?Q?KhrMezccu+ESSkkq1QBsvDshYDoPFyEsZmPAMjt3pqZ6/qN7r3FgNG8or28F?= =?us-ascii?Q?NvE32q8d1C0trDGWetQqnqzTcxzE7CNoXGKRnnj/BrLYWwPM1HkcrO7/vCon?= =?us-ascii?Q?XNCOKjHt9VS+r2Sw0shcGL8hGhsFqm+K6r0ZyAoJV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2sZuh0TqJ/y9SC3xodlnyyoOqUxA+l0Goy7VG7/j?= =?us-ascii?Q?WwN/RGKhS+sKO7gmVN//y2FDetfJbaROelJsPn43iG/p5oXk61A8D1M6S+ht?= =?us-ascii?Q?W4nQyqA3+4IZLNECdOFG3VHSfJbmz/B1JyQ77LiVH0zD9N5zc7a1nz1l9PqM?= =?us-ascii?Q?vQF1NDaaFBb6KZfspug+Vmt64/rxm5EHRIzfdX2mYlHCbvB1gUyQT7iJESpQ?= =?us-ascii?Q?JkqR+S+8wstR9xXmu4t/8JLhlX0uyPWQZTvPxu95l4fS+KYLNyTuYy5uJWgM?= =?us-ascii?Q?sg=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ga9DtDk4nvUsZth3NK5f2hHdVizwGP1HxWjwk3i0zser+go8IqS/8DMGO9Oa4NpySKE7BHX2fYi06LzlwrApUrc+URBe1Tio4Pq1Z0Xb4Kh6WE5+d/6TCf6YlHTYDgd9aPzJVfzNYDoGpHHxcq5BN3HwiylhP7atVJ/Xcpu3u3qPT8I4iqs5WrgGHGnr+W21oEQkIF647OQXve3kDvUrTUvPBEFhTYOvcqJAaLEItfE46vkaHuLvOyO4rTnemabKMzmQUcP+NdqXXRcsF5qxFmy5be4KCDojoUU7simaLQ/HtsVOCu9bmcwl7AJyvMcosuf/d2k6kilEOJDXwXuQQd2GzdEovqJ5EhPw5KxtYd9tDuNPRn2rL3UysI0EsIOm1mgWgS5B5FQFMREbw3MdIzjrgOWaXpqmZ+8TM5LW3dsoeVtd2qGIFXQ2wEK4qJuvn1stqUeLRjgzlixuNp6lyWe0747pnv/N3hB5eT8ZtTGoRUQbKeTz9jy66miy/1zxl2TQ7RHn2t0/JOTa78Lv20GFufMkTuinCom+DlY9NMtowECUC1PqU2U4fN/RUzvn4CdeCO5liiRH9KOOCTLB1HuAfSffgv1S7Y00GOGepZs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d884bfa9-8798-4d40-4b92-08dd819934b5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:37.2293 (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: hJv5mKfYZwswNNPmoIht3FDe1OgjV4nNVKZGEpDkwvPEM8Kso/Cbxhh8gZtblVUiTaiw6GU56+hd24/xPDbUEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: 0oAFuOGvtwsUjsE_j3UsaJFfj-HWHbFB X-Proofpoint-ORIG-GUID: 0oAFuOGvtwsUjsE_j3UsaJFfj-HWHbFB Content-Type: text/plain; charset="utf-8" When completing a CoW-based write, each extent range mapping update is covered by a separate transaction. For a CoW-based atomic write, all mappings must be changed at once, so change to use a single transaction. Note that there is a limit on the amount of log intent items which can be fit into a single transaction, but this is being ignored for now since the count of items for a typical atomic write would be much less than is typically supported. A typical atomic write would be expected to be 64KB or less, which means only 16 possible extents unmaps, which is quite small. Reviewed-by: Darrick J. Wong [djwong: add tr_atomic_ioend] Signed-off-by: John Garry Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_trans_resv.c | 18 +++++++++++ fs/xfs/libxfs/xfs_trans_resv.h | 1 + fs/xfs/xfs_file.c | 5 ++- fs/xfs/xfs_reflink.c | 56 ++++++++++++++++++++++++++++++++++ fs/xfs/xfs_reflink.h | 2 ++ 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 580d00ae2857..6c74f47f980a 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -1284,6 +1284,18 @@ xfs_calc_namespace_reservations( resp->tr_mkdir.tr_logflags |=3D XFS_TRANS_PERM_LOG_RES; } =20 +STATIC void +xfs_calc_default_atomic_ioend_reservation( + struct xfs_mount *mp, + struct xfs_trans_resv *resp) +{ + if (xfs_has_reflink(mp)) + resp->tr_atomic_ioend =3D resp->tr_itruncate; + else + memset(&resp->tr_atomic_ioend, 0, + sizeof(resp->tr_atomic_ioend)); +} + void xfs_trans_resv_calc( struct xfs_mount *mp, @@ -1378,4 +1390,10 @@ xfs_trans_resv_calc( resp->tr_itruncate.tr_logcount +=3D logcount_adj; resp->tr_write.tr_logcount +=3D logcount_adj; resp->tr_qm_dqalloc.tr_logcount +=3D logcount_adj; + + /* + * Now that we've finished computing the static reservations, we can + * compute the dynamic reservation for atomic writes. + */ + xfs_calc_default_atomic_ioend_reservation(mp, resp); } diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index d9d0032cbbc5..670045d417a6 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -48,6 +48,7 @@ struct xfs_trans_resv { struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ struct xfs_trans_res tr_sb; /* modify superblock */ struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ + struct xfs_trans_res tr_atomic_ioend; /* untorn write completion */ }; =20 /* shorthand way of accessing reservation structure */ diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 1302783a7157..ba4b02abc6e4 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -576,7 +576,10 @@ xfs_dio_write_end_io( nofs_flag =3D memalloc_nofs_save(); =20 if (flags & IOMAP_DIO_COW) { - error =3D xfs_reflink_end_cow(ip, offset, size); + if (iocb->ki_flags & IOCB_ATOMIC) + error =3D xfs_reflink_end_atomic_cow(ip, offset, size); + else + error =3D xfs_reflink_end_cow(ip, offset, size); if (error) goto out; } diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index f5d338916098..218dee76768b 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -984,6 +984,62 @@ xfs_reflink_end_cow( return error; } =20 +/* + * Fully remap all of the file's data fork at once, which is the critical = part + * in achieving atomic behaviour. + * The regular CoW end path does not use function as to keep the block + * reservation per transaction as low as possible. + */ +int +xfs_reflink_end_atomic_cow( + struct xfs_inode *ip, + xfs_off_t offset, + xfs_off_t count) +{ + xfs_fileoff_t offset_fsb; + xfs_fileoff_t end_fsb; + int error =3D 0; + struct xfs_mount *mp =3D ip->i_mount; + struct xfs_trans *tp; + unsigned int resblks; + + trace_xfs_reflink_end_cow(ip, offset, count); + + offset_fsb =3D XFS_B_TO_FSBT(mp, offset); + end_fsb =3D XFS_B_TO_FSB(mp, offset + count); + + /* + * Each remapping operation could cause a btree split, so in the worst + * case that's one for each block. + */ + resblks =3D (end_fsb - offset_fsb) * + XFS_NEXTENTADD_SPACE_RES(mp, 1, XFS_DATA_FORK); + + error =3D xfs_trans_alloc(mp, &M_RES(mp)->tr_atomic_ioend, resblks, 0, + XFS_TRANS_RESERVE, &tp); + if (error) + return error; + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + + while (end_fsb > offset_fsb && !error) { + error =3D xfs_reflink_end_cow_extent_locked(tp, ip, &offset_fsb, + end_fsb); + } + if (error) { + trace_xfs_reflink_end_cow_error(ip, error, _RET_IP_); + goto out_cancel; + } + error =3D xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return error; +out_cancel: + xfs_trans_cancel(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + return error; +} + /* * Free all CoW staging blocks that are still referenced by the ondisk ref= count * metadata. The ondisk metadata does not track which inode created the diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 379619f24247..412e9b6f2082 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -45,6 +45,8 @@ extern int xfs_reflink_cancel_cow_range(struct xfs_inode = *ip, xfs_off_t offset, xfs_off_t count, bool cancel_real); extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); +int xfs_reflink_end_atomic_cow(struct xfs_inode *ip, xfs_off_t offset, + xfs_off_t count); extern int xfs_reflink_recover_cow(struct xfs_mount *mp); extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 E5BCD281500; Tue, 22 Apr 2025 12:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745325068; cv=fail; b=e4Vz2jd47YTHt0MkjR9urbKfTOG6LdSvtPpK0nG8bLu+xnn60/W6iuf459kD0zW96eoiHoPDvB1cL7+nc8WSv0msSvDc4NEat/vcT2+Q4WDUsgrraFGvmg3GPs+rGRJDxmVZjGUQV/Xlr2PeGbzr//F8A4PJ/kUf0F5pGa2Z+kA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745325068; c=relaxed/simple; bh=s1rv24EBXPydx4NqYWkXeYbXMAMlqEWdFT6HvPEXIrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fSmwWi4eJn69JtUMyGof0h+cMbe3iFCV2T1rAODPSNoBv/skhwNPFY3NDsxsPoUS3A9HcJsV2ekVJj7R8xH6F9gbQRSgl6dcpf61mzifAUampaI66b/m8tMD57WnQpJK0IIkCAdQUnXihfdQqD2ekkn4yFednyOIY5TKjiGzumM= 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=IjuB/oa9; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CS0Mcnzf; 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="IjuB/oa9"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CS0Mcnzf" 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 53MB3PZU008455; Tue, 22 Apr 2025 12:28:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=DPVFbFiC6SQWQbtGsc2yh92T0CmYbgowiG4bRgdKF8U=; b= IjuB/oa96j9ffqfrOkf06gs+xxGqLDuwB3dWSSGLbdCkFkcaNtvQfZC96JCtKOO0 wEdO7aEEbDi5pfJ8Zxe4zkYcyLmM4b8k8s4zJUJP5gOE5dg3ejC2d4YOtQr6zbSH fCyOXLWCraSdM29U16PndmvU6+TvyyiGgbjKlV4ROQsD83X+pWN2onAJSuxPYo9x Oe+so+n3WgGqh22H3aHdsXbguZkafz7fireXQrRkKzuzspkOLqfzGOUp1zRTpSaC +xHzjFSR2cf+OKsHRmnQB+K1XEV3IjuqIYYWgP4bTCRgQBRTDDjEcVqZKKAf0dPo INVtb0guzEAy9QOAQY0fDQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642e0cdex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:54 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBtH9Q002293; Tue, 22 Apr 2025 12:28:54 GMT Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012013.outbound.protection.outlook.com [40.93.14.13]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999v45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oOmtpLgQtJdrWAn3yQVmcopnblLRY81timlWbd9f26QLJp5iRTGW4PHsowN9BZApMKFxFE8Hen4634c6+/iyVPLCkKs8G09ZSRXcYvredtJbJJ5mK7x3y5GhLvezo5skUyUHyRw8s9rBTzAVICSVEdj8VXbN0qhoEipp+F8rEIoCHC/TInpdhdG+hy9M2o7ER33ZtcxeRraZolK40afavpZLDgv1472IVDI6w2B0NOKTpLVmUVW/Nhu6adUpLQ/Qfccaxebz1Lav23iC4mJfxoP4MN8QAQLcKGZQmZUPFAeg3jHmtOIJthXnGbfFpbP21V/+u/T64U/L4+s2goa1iw== 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=DPVFbFiC6SQWQbtGsc2yh92T0CmYbgowiG4bRgdKF8U=; b=SZtdVyyfAUQlnyZd6moe20rNqd9jIbquxGeDHkd6Vl7k42gY+YTFouopwHG3pAF2wJe/S72A6bTqKrHwrFWpW9R2qv17pMwilO9M1prybd+H5zZpj6RtieKmw0T5bGcq2eZeylTqqZd5BnjusirqqJfIo+DvfGc+OKPywp/CHoKzj98ZwevOOhEvoPofr1N2+8mkneBBm/EXPnvWRDhs2HqgeGggNPIXQUW/9GXzWx22yma3wnEeL0cCadw1GRQAaaNKrI2a1oVaSGIK2vw+xViYplwZM1RLaOigxiSXxSA4I/G5Y2lhbIBlSkXgQYxY+jingl0H1po9r8SZscS8OA== 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=DPVFbFiC6SQWQbtGsc2yh92T0CmYbgowiG4bRgdKF8U=; b=CS0Mcnzf3UM9uE5Aynb3W4rsY58+uHlFq/Lp1zyH22/TdPk/CgaZw24O8WLAgwkp07dl5BA29elomQWBd6YG1p4XSWQu8oZDgdD8hgskuwdHt9WXMgRH9kVg0lAUYDesbg7B3IW5mZp7XPSaVgSX2P9ZswWv7tmqLZVgTnkX6t4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:38 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:38 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 12/15] xfs: add xfs_file_dio_write_atomic() Date: Tue, 22 Apr 2025 12:27:36 +0000 Message-Id: <20250422122739.2230121-13-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0576.namprd03.prod.outlook.com (2603:10b6:408:10d::11) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 88eed099-28a4-41e6-85db-08dd81993592 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?42ojm/L9eY+OJ9+m0Ocn6KAkrVZ1KH4NY02pIFdBixiCrJjtFILGVwqrNv9A?= =?us-ascii?Q?1KoMPttfMxabYI0wiVUqPwgBMbS9cMWuoHyhnsg6gdsNHRQ7gdU3MwR3GxOZ?= =?us-ascii?Q?uEgc1wSDF6X6hJOapTF47vF5c7A4fQ/mgAbVS8HkJpzWa0Gx2GbgTtJ6f9eb?= =?us-ascii?Q?rsTDgtw5ae8+uTN6uPaoSgNaOEmNk9LbSyXsVb0plWO8PP4jBOpuXMS5T9tI?= =?us-ascii?Q?nZYQX2WNOVNrJmF8qAyF0xY97I/JW9iMEJipLeL8A0iVHOU24pe3XlRJnQu5?= =?us-ascii?Q?3YAePKy2BrKqMfJvyMgj0UoESCWE93Qxujv24N1o5JKmICVbj9UNg58Ie4am?= =?us-ascii?Q?+ElC/zWpCKei/GAKnYfgAqrTqduk+eZsbdN3UjR4kl0CPVIi2oKOPl2ZcGYw?= =?us-ascii?Q?0nvLSn2jy58T2WbIMtg1J332nK+Q+5noNGyA5Ku6YltdCESbiF4bsD9Yn51+?= =?us-ascii?Q?MJ90NOqh7eQ1TDVfWf/VrOSA/VifwHzieS4JI7KVWW4ExhQZdxl1l5smiFyZ?= =?us-ascii?Q?iXzrrwbQgFXVIT7P/B3lp/0m5v1soKblUvsg6zxA72RbNW/90GrZaUvPsezR?= =?us-ascii?Q?eCuy1IwkAoVbKpwK7kA8G9k6UAjknsXRv5OsHSy+ovSsB9+dohfBiRuD7wgx?= =?us-ascii?Q?qWnwcXvRs4c03i4AInjHvegJZdrPWWQJ4Nt3H5kNrrZATOfcEli10GPQjD1c?= =?us-ascii?Q?R6zLCdvwh0U7fp6sNjK8ds1arx0gIgaQ810pHD9vnWtSbaU4oOq6c6JMRuN8?= =?us-ascii?Q?0JDZszcnxNAvkP5aZmqhxPJnPBo5+DS0MGfs8l8WHm3x1NY0dgf38IsQtvG9?= =?us-ascii?Q?Z02YQyH6qwxRA5H0y+SxHsJU+Hw1PpEeR8Z71urpxZ6djP9KUlYC7WOT6eSz?= =?us-ascii?Q?agZyOUaJYTEf/3L92OCY1bwIaqO2MdKuFX2L1xuOIIkY1kkYo8vSl8Hh6yyO?= =?us-ascii?Q?OX/XzgP+lkRokikBOhNmw45oxLg7M27FMskks29sJh88Nd2e/3IU8vo5CYCY?= =?us-ascii?Q?apvTtJ40sMXI2DAc7xD6iGxVdgxJWf/POs6OKChGIHGxOTsCYnACu2ojxRIE?= =?us-ascii?Q?8xGevyPXYqsoxIciinHZRcGdhlLCvIC/7VIgtXflx372CHy1ErOa6HfFT/k4?= =?us-ascii?Q?pmdCmLcLzcX5db98vNY1Y1gmk2D6LFBGde+JTSG6xL/JLv1vof7tVzRd2g2M?= =?us-ascii?Q?643RZG9RCWyzs0Nf50lvaWVgtPqn81PLf3sxRHH3EqJT+HInCWLk9LK8TqU0?= =?us-ascii?Q?SQk2nlGs1BtjPVPqg1ZKNkU7ANfaOugxRnA0WraSCGqLJpb20WzaBU2MPOvg?= =?us-ascii?Q?RDZnn+docEoEvZ3LCoP9/9DPuHNesoKPD1puTFT+oI6RQI9EVRs+Aqvdaw9A?= =?us-ascii?Q?EL1Y7MYwrqkCaWn06a8WjS1zGMWCyhJXRJSH326KLa6rcCvEuA=3D=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JVhP0b4jUCbGt8OPAkCYew/Hw8z9ouqVQNvI9Wdg4DQ2AxfmhE3JEFKR8jx4?= =?us-ascii?Q?5RMJEx8q3+AYgHLqcUWLZzLcpvDYuT12vMLFPLbCi3gQwztIAlY1XHqJFGIF?= =?us-ascii?Q?hqyhexTQBvsyiAPDFZLA+ZnjyjRbIJtk8eVOuyYeh3ztA3xlHKBxN3rL7DgO?= =?us-ascii?Q?5eCEepV843BtQ7QcvZ2+Rbuc7XAHGVJoXAXnrk/HmY6873TcONjSq4NBrbY+?= =?us-ascii?Q?Gqr1mnVgRVRDBvd9t5Suh0mzyYs6idQc7J81t6WzmY3PsyIuKB8jia5GCAiP?= =?us-ascii?Q?nV1F2mvS52JLUbDxgGbmg9XPzOi9ug5bw9JX5fYLaHGWM0y2CsZBQYpwwiuQ?= =?us-ascii?Q?W7i18faiXN6cyJ78Ve7o7am0s8f9LkQz+gd4A3D2udas6eyc80sF5QhhPQY7?= =?us-ascii?Q?xhAnXRJu2G+LpyIKp6AUiKACLNRy9563sGYrwycGb/Wwwjkg7IiMKv3U8g7Q?= =?us-ascii?Q?BXzGG+VpziKKrG9cJ6KvC5DiPppLkLDuIgiRAnO1UuJ3ee1DD4DnsiozCLDf?= =?us-ascii?Q?7lREqK7r2rmHpjmTI5zpL6FLgsKiQ3ZT3vNuQLP3AdUovUkUQooyfsIxY9Bs?= =?us-ascii?Q?hRpuZSK/elr6UXOrdrgwGARkK3+QjfftkrAT4/R8MGD9Rmj5P457RexicD8S?= =?us-ascii?Q?t5QmuIdFAT6mPz7g409aenQgUrnmBqOtNH+6+nPR1+tIB19fDgOlw5erdB9g?= =?us-ascii?Q?iBzGuMg9IDR/5/YIH2YKMzz3LrMSwKeQJrrtP55U/k8T5eNLNQJvs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ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: aclDEr35Lcf8xoIL1m7oe4c0p0XDHxHJ8cwZQD80Nm06iLenWejnk+VELBN3IC+e/G5SBjaj8LcZzwHzGwdnVCwd8qwsP+bpswo1Sg05kD16aiU4iUiWK6poutiE891rHl+BAJoRXz0JZxcMryKrd+wdGblyxvPWnMbxwfDYTUp/4bDEwrIQ/WJq3CPlY9NWD/S1UpIuzJYgavZSAsCkVLtcZF/G8ZuvqhvDLZX2X7bO8IkvyjYLxz2epZbAs1P8TC9G1gSnisdoKR0MOrKdkFgJpQ1//jmFyXvOsvdCPpfoJi5hUybxa+MHiQap2Y6KRKKBL82dVkjfLjBM7GSlGum4Wzrc8b70yfvsf1VJ9YVsW6Joja3iKZ3OTRxs9ZYxQEDe89cpW+D/hqZFkXQUVQlMRJ+ctPncTYVr6G2g0BPvAGJaCji7QqnzfzrJWlq7vkLpes0W0woYh/Gf9XDpr7tx7C5H6GyY869KAj6/Ygsy3IKkHw9Lp+kjSsGOgtpzVycNKZvk3/qmnG4cfZTxB9BoxG2BViHX4KQa2o3Z3NmVtrVGuqiEJq89hm0EweEP8omKBpg4b/RVOjIHAChq7POPjUifhrBEGRzTVWlQWpA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88eed099-28a4-41e6-85db-08dd81993592 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:38.6775 (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: zKcu6Hnr2ojXuCaJsXYULwzwf7xyoMJSf3ikaSLbGJJrZ11BLIUb4/8D+52+8YLTc0DkPHy5UO/w72Z1og3HPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: twUFcU340FPUreyORMvLY0los9no5Krh X-Proofpoint-ORIG-GUID: twUFcU340FPUreyORMvLY0los9no5Krh Content-Type: text/plain; charset="utf-8" Add xfs_file_dio_write_atomic() for dedicated handling of atomic writes. The function works based on two operating modes: - HW offload, i.e. REQ_ATOMIC-based - CoW based with out-of-places write and atomic extent remapping The preferred method is HW offload as it will be faster. If HW offload is not possible, then we fallback to the CoW-based method. HW offload would not be possible for the write length exceeding the HW offload limit, the write spanning multiple extents, unaligned disk blocks, etc. Apart from the write exceeding the HW offload limit, other conditions for HW offload can only be detected in the iomap handling for the write. As such, we use a fallback method to issue the write if we detect in the ->iomap_begin() handler that HW offload is not possible. Special code -ENOPROTOOPT is returned from ->iomap_begin() to inform that HW offload not possible. Signed-off-by: John Garry Reviewed-by: "Darrick J. Wong" Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index ba4b02abc6e4..000bbb0d1413 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -728,6 +728,72 @@ xfs_file_dio_write_zoned( return ret; } =20 +/* + * Handle block atomic writes + * + * Two methods of atomic writes are supported: + * - REQ_ATOMIC-based, which would typically use some form of HW offload i= n the + * disk + * - COW-based, which uses a COW fork as a staging extent for data updates + * before atomically updating extent mappings for the range being written + * + */ +static noinline ssize_t +xfs_file_dio_write_atomic( + struct xfs_inode *ip, + struct kiocb *iocb, + struct iov_iter *from) +{ + unsigned int iolock =3D XFS_IOLOCK_SHARED; + ssize_t ret, ocount =3D iov_iter_count(from); + const struct iomap_ops *dops; + + /* + * HW offload should be faster, so try that first if it is already + * known that the write length is not too large. + */ + if (ocount > xfs_inode_hw_atomicwrite_max(ip)) + dops =3D &xfs_atomic_write_cow_iomap_ops; + else + dops =3D &xfs_direct_write_iomap_ops; + +retry: + ret =3D xfs_ilock_iocb_for_write(iocb, &iolock); + if (ret) + return ret; + + ret =3D xfs_file_write_checks(iocb, from, &iolock, NULL); + if (ret) + goto out_unlock; + + /* Demote similar to xfs_file_dio_write_aligned() */ + if (iolock =3D=3D XFS_IOLOCK_EXCL) { + xfs_ilock_demote(ip, XFS_IOLOCK_EXCL); + iolock =3D XFS_IOLOCK_SHARED; + } + + trace_xfs_file_direct_write(iocb, from); + ret =3D iomap_dio_rw(iocb, from, dops, &xfs_dio_write_ops, + 0, NULL, 0); + + /* + * The retry mechanism is based on the ->iomap_begin method returning + * -ENOPROTOOPT, which would be when the REQ_ATOMIC-based write is not + * possible. The REQ_ATOMIC-based method typically not be possible if + * the write spans multiple extents or the disk blocks are misaligned. + */ + if (ret =3D=3D -ENOPROTOOPT && dops =3D=3D &xfs_direct_write_iomap_ops) { + xfs_iunlock(ip, iolock); + dops =3D &xfs_atomic_write_cow_iomap_ops; + goto retry; + } + +out_unlock: + if (iolock) + xfs_iunlock(ip, iolock); + return ret; +} + /* * Handle block unaligned direct I/O writes * @@ -843,6 +909,8 @@ xfs_file_dio_write( return xfs_file_dio_write_unaligned(ip, iocb, from); if (xfs_is_zoned_inode(ip)) return xfs_file_dio_write_zoned(ip, iocb, from); + if (iocb->ki_flags & IOCB_ATOMIC) + return xfs_file_dio_write_atomic(ip, iocb, from); return xfs_file_dio_write_aligned(ip, iocb, from, &xfs_direct_write_iomap_ops, &xfs_dio_write_ops, NULL); } --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 EE92D27E1A4; Tue, 22 Apr 2025 12:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324953; cv=fail; b=BiCYd27Q3Z5uDrXFE7pAeXmrmkJotpUvzkwKR3HRRVxMQ97/NcZNFx3Wo2F6mGAX0O7wV1U5z7co4k/l7SIBKga3o9qf8UkTD+Xraaon7Z3jOxGuyJ6DWzAKOmdGUiPRB+Pd04VhJxyY6T1DtfiMlHhpiidQ86wFXqiCyjXVyKw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324953; c=relaxed/simple; bh=ZX73xGEFMOMYmNL4et0fTXURB9gouRcKe/bIjQHJKaY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HE0rpOMasUfcTSdBigpBJ2XFw4wsZEbFXgpM7jRGd6QVrYdKXQzFr7hFZ3d40syXiD+u2q7cKBNQnSbsrNKSeH4Z93OdC4ptH/wgGWaKjg4SsKql5IBphFJ2BJFHPmojqn/OTystnGxnYYQOxDTRX9aDqRmG8WsdlhBboEscJzA= 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=nUBt6WNZ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=rVdMn/ZO; 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="nUBt6WNZ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="rVdMn/ZO" 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 53MB3EfE003576; Tue, 22 Apr 2025 12:28:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=c/CLJMpAMTPp80gzwn6FxNAejmPx2XltQc8IXHdhmjM=; b= nUBt6WNZwPDrxaU7j1itA5N+mz+NOlRCYcteSH0KiZzGKM2XhvhZ6WBDWEt1J3Sl hoKTjXyD/tCBs4zy1cw/9+gmRTz4a+vH1AND9AhaX023inqq6E1xum9jL5Ejjq+0 tQZisGVI2znXVTWh3wZWrK126/vTzdgElvvivvxxFuuusfAeOALrs5NC3KKVcyGA EgZ9KZk2fvyk6SHozx0QMuNfyKMBLtG3N/uMyNzstZrJW5iI44STm/EU3EUCA56o j2WwQToa/mmgyHJl7+rVqUYCPMeoMTEEP8//nOhrM8zdm81TYJBy8RX74Vl2v7LS rJTN3j2Yg4Mm6X6SnUl0Fw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4643q8vbux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:55 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBtH9S002293; Tue, 22 Apr 2025 12:28:55 GMT Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012013.outbound.protection.outlook.com [40.93.14.13]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999v45-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kRwuLBhmXELAa/H1xN1y2dUWS1oFaOduS8y1W/qwPt4HFcycz483Vt4qaoFa7xvI1ZTmNYXoM1XWP+LC23+WRzLe+BB6LwObk7lGWYHM6RYJxme5p8xN/jMDL+Xh9KRSagGsKteYYGTrktS5+MKnpsHflb0nWT75FfkbCCSrMs487Jh8ImukiO7AHTJ89kBuKEuZmTZUhTGE1f3+5Enp+BfgDuACxN9L9i9BAO2kdVRhUIA4PLcpdTq1/v24bCxnUYh+GXMy966IJdnXD3Hp/KbKR+XPhCxYVxG/i0b8rKN8imdcSke7FwHuop9Qcsh43zkJwaqXTjuAQo8blHjHjQ== 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=c/CLJMpAMTPp80gzwn6FxNAejmPx2XltQc8IXHdhmjM=; b=kVGxgXOLpZSszzAsy/kZgYdmSjPUkEbaUZ4PU0HLQuFDs9dsD/hgO2llC+7pZdxuV9taHMOSt6rDV6IP8AMn3QFQ8R3YWhgHF6Ie02HZiaQpp1o+1M21TP4kYUWHwmYAIKqloAzHzOS71mzVX9yA2uj+z3v7mU10g8ztC0mPIg3TKKGT1lQDBc73NIX82gYRwlXOTYWhGHxLMox8vJ6i7Jlq+dCcU9Empe5oX3++Y/mJsKsyHN56B8KiOCsRPnzkuBY7LCMCwFSacS5pVjRv1OtZYGVhGEcacUd3NfLbZ9wyUeKlOy7/tPdxqI5PEJX0ZuvyHlvGpjX/bIxqTTdY9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c/CLJMpAMTPp80gzwn6FxNAejmPx2XltQc8IXHdhmjM=; b=rVdMn/ZOD+HBQCyE22BAxxP4rZ2IXhztv2O7CRTKD7+lWSdhxt/KPShgr+RDTXcHwDUCMaHguHULxiJF2I4w/RxgNoMIhILNiuLh8uAwhDjNz1A0h0yjztu8PzIYUZqiwVFshxhQ8cupdSj9m/BugXyaSmlmGd5I/CQKf6wOa0M= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:52 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:52 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 13/15] xfs: add xfs_compute_atomic_write_unit_max() Date: Tue, 22 Apr 2025 12:27:37 +0000 Message-Id: <20250422122739.2230121-14-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN8PR04CA0023.namprd04.prod.outlook.com (2603:10b6:408:70::36) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 065c111e-4a0c-46e3-3e51-08dd81993661 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?oswCRlthuwu6I892KiB5J3urrt3bSE0v6ZlW1gH7UKer8JRGEzPAisUvrXYV?= =?us-ascii?Q?k3f4M7yI9tBAvfBDRMkYXDKiGb53hyY4vjWfmIeuKDX7aFHGFO45upgwqFv1?= =?us-ascii?Q?p9FBRKOIGXG5Mkw2ZuuOEaaMB6BQOXdzK1fv0hOJV+5Mb8QQkTd3YZwqotFh?= =?us-ascii?Q?PJwvKWuEio6Hjcz+McWNCkXWD4JbvQ4gU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ascii?Q?gcL6FBdwVqPYctb8re/yj9nY8se4dKYl7SUmwLS4SD2TyFZ9VynxbpefDULW?= =?us-ascii?Q?yS1uF/9le7KrHdPGoGDJefvWjmjdPqBvZh9hcFgpuMFLiqLhf/3An4uMHXHx?= =?us-ascii?Q?y9wueeQv0nW2HbEOnugOmtfFx1R+6DDSqbzWXm9P7INgdXXgwtEDHYSMBFn8?= =?us-ascii?Q?DW16x0aw1kx4QW43+VH73snc4EMBw9KK7FcJoXzqXMEaO9wmZpkvNrMu19jA?= =?us-ascii?Q?FSVo1LgOkKu892wYdcQGpyB6ZblcKl5NW1ukywl72AOx9C6St/Eu1UbUEl0s?= =?us-ascii?Q?jjHMa+w4AlaW201qKj9FRaQlNKkYw500ZfdI0kh/F1DVcCDrAfld6cVuAwy+?= =?us-ascii?Q?Y8uStRiPLKA=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0L8gFnKTaH9ZqWZFBUZQWaIyq4oIkKeQ1iCorwqI8HnEQDlXTA66By1dtcZ3?= =?us-ascii?Q?qnOBWdxZO6QDq1nDlvALFzu2uGzjkCBXCZr5KuO8sCipEBj8jLmq4pjZQvGq?= =?us-ascii?Q?EgwHOEW4ZSmA+IaRfU8qx4BsqT4UjqNcV/8WpyfzzLXjmGYbijvbbl+YI8yD?= =?us-ascii?Q?go/L43BU/IDbrJTPmI57S0rq5KHULqcWY+VXRSZJH4zjUB6M86SEzjdeemm6?= =?us-ascii?Q?LiVX6iQT5Zfph3nfgsP0liEytpBn31AhVzDaw5UX7N/kyKTpQXcuozD3a5lz?= =?us-ascii?Q?P8nPbi705bSfXL0SCMuH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?= =?us-ascii?Q?ZtGWr1gNeievs7dj+HNuDfh6fbL+/F3HEEXdpY6iYRRmIsS23X0PZs4BFwyQ?= =?us-ascii?Q?LWLkU/2618A5TrRhnolChBWphHIAyai+hj6Gkqcor+z0S2bc3GtselumkQlG?= =?us-ascii?Q?JCE5J7GvROig42FOdlge0J3HQXdqJrqO4YFwMe4bvaXKwwtmRtN6AhGqifDW?= =?us-ascii?Q?mgw61BX0PhmAv08csWwpp1I4KkD01DDMuWT1reFGL620saw2SNyMs2OZLSWE?= =?us-ascii?Q?vXyhL2HJ63bKSs8DJ0dxDZFDu+KFFQmBJNDvNyPq6Wq1GnWCmqXrdLD5X/mx?= =?us-ascii?Q?w51n8UZHYL6tTjooPLFMaP5biho+egDLuRiRj5YR0zoHE9sTOwvqxpBe+e91?= =?us-ascii?Q?61Hz9KnNoi58x4K00LhKXm7PO9FKJrcux7ZKloC1skpZlffhqQINGwFODOS9?= =?us-ascii?Q?yA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gucMJ1w88i9133H7OQjDBIO1biBsfnVcPHYmuFC2eOLFLF1Ze+4kLeT8kTKuINWjp8b5Rf/QZ/UJwt3hkNedS/eYfqyUJ6OzYae/gIhe9vE7UiXnuctNqVWmehgtmJVctx4Qu1rIBj483SJVRJBJsjZLYl+NGbaxrwpa73YCqTnEa+QiOAaRJCqz4Hc5aaDiisACaJE1xXuCfxDGNqUyo9IFTTR4L80WpuJ7WXcQ0hP7hySlqA+dtOALfTSpiOc1fWxxEbk9t+ig6vLMh5n9ITNddhKsALCGUr5OW+uCZgUOShEo9cXWo612dJBrt3SN4+pjzzi2EXI4XP0K6X04/bYlwmSQpCy/HZpF1tPQSGL2Vm86VkvCGwaoDFrHbqS1koUWuejXdcXyywO5bacsA6TWMfqXg3CoTokitAM9eTRSM4m+HuJIPfS0rbv0GBHtOluon8FCmIxc3+zvMk9+BJ7rxUDUY4aBMeRxroNZvWoJIhb7jI8oQaOozJmZ0Y0KjjrINkrgGSG1N+DVJnZyuyvKAHZ+oPeH/epdHsR2YHGehR6O4b3bvoVACEv1JXdRUALXQEZmNPBRHYQKzQ9HcxzCG6xJSr16eFC7pPbZ6J8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 065c111e-4a0c-46e3-3e51-08dd81993661 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:40.0141 (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: iRfjDTQfyTkLxSY6TwnkgFaaWxNoiD4nCekoRIXqCH+GQIaZEmoIu0RCyRWtJZF4S4cV+z1oMCqZlxwCLNKeaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-GUID: oDfzwhuEHGejATeieAH42E5YW6Ppe7n9 X-Proofpoint-ORIG-GUID: oDfzwhuEHGejATeieAH42E5YW6Ppe7n9 Content-Type: text/plain; charset="utf-8" Now that CoW-based atomic writes are supported, update the max size of an atomic write for the data device. The limit of a CoW-based atomic write will be the limit of the number of logitems which can fit into a single transaction. In addition, the max atomic write size needs to be aligned to the agsize. Limit the size of atomic writes to the greatest power-of-two factor of the agsize so that allocations for an atomic write will always be aligned compatibly with the alignment requirements of the storage. Function xfs_atomic_write_logitems() is added to find the limit the number of log items which can fit in a single transaction. Amend the max atomic write computation to create a new transaction reservation type, and compute the maximum size of an atomic write completion (in fsblocks) based on this new transaction reservation. Initially, tr_atomic_write is a clone of tr_itruncate, which provides a reasonable level of parallelism. In the next patch, we'll add a mount option so that sysadmins can configure their own limits. Signed-off-by: John Garry [djwong: use a new reservation type for atomic write ioends, refactor group limit calculations] Reviewed-by: "Darrick J. Wong" Signed-off-by: "Darrick J. Wong" [jpg: update xfs_calc_perag_awu_max() ddev check] Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_trans_resv.c | 94 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_trans_resv.h | 2 + fs/xfs/xfs_mount.c | 81 +++++++++++++++++++++++++++++ fs/xfs/xfs_mount.h | 6 +++ fs/xfs/xfs_reflink.c | 16 ++++++ fs/xfs/xfs_reflink.h | 2 + fs/xfs/xfs_trace.h | 60 ++++++++++++++++++++++ 7 files changed, 261 insertions(+) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 6c74f47f980a..708cfb4be661 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -22,6 +22,12 @@ #include "xfs_rtbitmap.h" #include "xfs_attr_item.h" #include "xfs_log.h" +#include "xfs_defer.h" +#include "xfs_bmap_item.h" +#include "xfs_extfree_item.h" +#include "xfs_rmap_item.h" +#include "xfs_refcount_item.h" +#include "xfs_trace.h" =20 #define _ALLOC true #define _FREE false @@ -1397,3 +1403,91 @@ xfs_trans_resv_calc( */ xfs_calc_default_atomic_ioend_reservation(mp, resp); } + +/* + * Return the per-extent and fixed transaction reservation sizes needed to + * complete an atomic write. + */ +STATIC unsigned int +xfs_calc_atomic_write_ioend_geometry( + struct xfs_mount *mp, + unsigned int *step_size) +{ + const unsigned int efi =3D xfs_efi_log_space(1); + const unsigned int efd =3D xfs_efd_log_space(1); + const unsigned int rui =3D xfs_rui_log_space(1); + const unsigned int rud =3D xfs_rud_log_space(); + const unsigned int cui =3D xfs_cui_log_space(1); + const unsigned int cud =3D xfs_cud_log_space(); + const unsigned int bui =3D xfs_bui_log_space(1); + const unsigned int bud =3D xfs_bud_log_space(); + + /* + * Maximum overhead to complete an atomic write ioend in software: + * remove data fork extent + remove cow fork extent + map extent into + * data fork. + * + * tx0: Creates a BUI and a CUI and that's all it needs. + * + * tx1: Roll to finish the BUI. Need space for the BUD, an RUI, and + * enough space to relog the CUI (=3D=3D CUI + CUD). + * + * tx2: Roll again to finish the RUI. Need space for the RUD and space + * to relog the CUI. + * + * tx3: Roll again, need space for the CUD and possibly a new EFI. + * + * tx4: Roll again, need space for an EFD. + * + * If the extent referenced by the pair of BUI/CUI items is not the one + * being currently processed, then we need to reserve space to relog + * both items. + */ + const unsigned int tx0 =3D bui + cui; + const unsigned int tx1 =3D bud + rui + cui + cud; + const unsigned int tx2 =3D rud + cui + cud; + const unsigned int tx3 =3D cud + efi; + const unsigned int tx4 =3D efd; + const unsigned int relog =3D bui + bud + cui + cud; + + const unsigned int per_intent =3D max(max3(tx0, tx1, tx2), + max3(tx3, tx4, relog)); + + /* Overhead to finish one step of each intent item type */ + const unsigned int f1 =3D xfs_calc_finish_efi_reservation(mp, 1); + const unsigned int f2 =3D xfs_calc_finish_rui_reservation(mp, 1); + const unsigned int f3 =3D xfs_calc_finish_cui_reservation(mp, 1); + const unsigned int f4 =3D xfs_calc_finish_bui_reservation(mp, 1); + + /* We only finish one item per transaction in a chain */ + *step_size =3D max(f4, max3(f1, f2, f3)); + + return per_intent; +} + +/* + * Compute the maximum size (in fsblocks) of atomic writes that we can com= plete + * given the existing log reservations. + */ +xfs_extlen_t +xfs_calc_max_atomic_write_fsblocks( + struct xfs_mount *mp) +{ + const struct xfs_trans_res *resv =3D &M_RES(mp)->tr_atomic_ioend; + unsigned int per_intent =3D 0; + unsigned int step_size =3D 0; + unsigned int ret =3D 0; + + if (resv->tr_logres > 0) { + per_intent =3D xfs_calc_atomic_write_ioend_geometry(mp, + &step_size); + + if (resv->tr_logres >=3D step_size) + ret =3D (resv->tr_logres - step_size) / per_intent; + } + + trace_xfs_calc_max_atomic_write_fsblocks(mp, per_intent, step_size, + resv->tr_logres, ret); + + return ret; +} diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 670045d417a6..a6d303b83688 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -121,4 +121,6 @@ unsigned int xfs_calc_itruncate_reservation_minlogsize(= struct xfs_mount *mp); unsigned int xfs_calc_write_reservation_minlogsize(struct xfs_mount *mp); unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *= mp); =20 +xfs_extlen_t xfs_calc_max_atomic_write_fsblocks(struct xfs_mount *mp); + #endif /* __XFS_TRANS_RESV_H__ */ diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index ee68c026e6cd..eb5ed61b6f99 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -666,6 +666,80 @@ xfs_agbtree_compute_maxlevels( mp->m_agbtree_maxlevels =3D max(levels, mp->m_refc_maxlevels); } =20 +/* Maximum atomic write IO size that the kernel allows. */ +static inline xfs_extlen_t xfs_calc_atomic_write_max(struct xfs_mount *mp) +{ + return rounddown_pow_of_two(XFS_B_TO_FSB(mp, MAX_RW_COUNT)); +} + +static inline unsigned int max_pow_of_two_factor(const unsigned int nr) +{ + return 1 << (ffs(nr) - 1); +} + +/* + * If the data device advertises atomic write support, limit the size of d= ata + * device atomic writes to the greatest power-of-two factor of the AG size= so + * that every atomic write unit aligns with the start of every AG. This is + * required so that the per-AG allocations for an atomic write will always= be + * aligned compatibly with the alignment requirements of the storage. + * + * If the data device doesn't advertise atomic writes, then there are no + * alignment restrictions and the largest out-of-place write we can do + * ourselves is the number of blocks that user files can allocate from any= AG. + */ +static inline xfs_extlen_t xfs_calc_perag_awu_max(struct xfs_mount *mp) +{ + if (mp->m_dd_awu_hw_max) + return max_pow_of_two_factor(mp->m_sb.sb_agblocks); + return mp->m_ag_max_usable; +} + +/* + * Reflink on the realtime device requires rtgroups, and atomic writes req= uire + * reflink. + * + * If the realtime device advertises atomic write support, limit the size = of + * data device atomic writes to the greatest power-of-two factor of the rt= group + * size so that every atomic write unit aligns with the start of every rtg= roup. + * This is required so that the per-rtgroup allocations for an atomic write + * will always be aligned compatibly with the alignment requirements of the + * storage. + * + * If the rt device doesn't advertise atomic writes, then there are no + * alignment restrictions and the largest out-of-place write we can do + * ourselves is the number of blocks that user files can allocate from any + * rtgroup. + */ +static inline xfs_extlen_t xfs_calc_rtgroup_awu_max(struct xfs_mount *mp) +{ + struct xfs_groups *rgs =3D &mp->m_groups[XG_TYPE_RTG]; + + if (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_bdev_awu_min > 0) + return max_pow_of_two_factor(rgs->blocks); + return rgs->blocks; +} + +/* Compute the maximum atomic write unit size for each section. */ +static inline void +xfs_calc_atomic_write_unit_max( + struct xfs_mount *mp) +{ + struct xfs_groups *ags =3D &mp->m_groups[XG_TYPE_AG]; + struct xfs_groups *rgs =3D &mp->m_groups[XG_TYPE_RTG]; + + const xfs_extlen_t max_write =3D xfs_calc_atomic_write_max(mp); + const xfs_extlen_t max_ioend =3D xfs_reflink_max_atomic_cow(mp); + const xfs_extlen_t max_agsize =3D xfs_calc_perag_awu_max(mp); + const xfs_extlen_t max_rgsize =3D xfs_calc_rtgroup_awu_max(mp); + + ags->awu_max =3D min3(max_write, max_ioend, max_agsize); + rgs->awu_max =3D min3(max_write, max_ioend, max_rgsize); + + trace_xfs_calc_atomic_write_unit_max(mp, max_write, max_ioend, + max_agsize, max_rgsize); +} + /* Compute maximum possible height for realtime btree types for this fs. */ static inline void xfs_rtbtree_compute_maxlevels( @@ -1096,6 +1170,13 @@ xfs_mountfs( mp->m_rtdev_targp->bt_bdev_awu_max >=3D mp->m_sb.sb_blocksize) mp->m_rt_awu_hw_max =3D mp->m_rtdev_targp->bt_bdev_awu_max; =20 + /* + * Pre-calculate atomic write unit max. This involves computations + * derived from transaction reservations, so we must do this after the + * log is fully initialized. + */ + xfs_calc_atomic_write_unit_max(mp); + return 0; =20 out_agresv: diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 2819e160f0e9..ba55fa1d9594 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -119,6 +119,12 @@ struct xfs_groups { * SMR hard drives. */ xfs_fsblock_t start_fsb; + + /* + * Maximum length of an atomic write for files stored in this + * collection of allocation groups, in fsblocks. + */ + xfs_extlen_t awu_max; }; =20 struct xfs_freecounter { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 218dee76768b..8c47af705f79 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1040,6 +1040,22 @@ xfs_reflink_end_atomic_cow( return error; } =20 +/* Compute the largest atomic write that we can complete through software.= */ +xfs_extlen_t +xfs_reflink_max_atomic_cow( + struct xfs_mount *mp) +{ + /* We cannot do any atomic writes without out of place writes. */ + if (!xfs_has_reflink(mp)) + return 0; + + /* + * Atomic write limits must always be a power-of-2, according to + * generic_atomic_write_valid. + */ + return rounddown_pow_of_two(xfs_calc_max_atomic_write_fsblocks(mp)); +} + /* * Free all CoW staging blocks that are still referenced by the ondisk ref= count * metadata. The ondisk metadata does not track which inode created the diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 412e9b6f2082..36cda724da89 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -68,4 +68,6 @@ extern int xfs_reflink_update_dest(struct xfs_inode *dest= , xfs_off_t newlen, =20 bool xfs_reflink_supports_rextsize(struct xfs_mount *mp, unsigned int rext= size); =20 +xfs_extlen_t xfs_reflink_max_atomic_cow(struct xfs_mount *mp); + #endif /* __XFS_REFLINK_H */ diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 9554578c6da4..d5ae00f8e04c 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -170,6 +170,66 @@ DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound); DEFINE_ATTR_LIST_EVENT(xfs_attr_leaf_list); DEFINE_ATTR_LIST_EVENT(xfs_attr_node_list); =20 +TRACE_EVENT(xfs_calc_atomic_write_unit_max, + TP_PROTO(struct xfs_mount *mp, unsigned int max_write, + unsigned int max_ioend, unsigned int max_agsize, + unsigned int max_rgsize), + TP_ARGS(mp, max_write, max_ioend, max_agsize, max_rgsize), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, max_write) + __field(unsigned int, max_ioend) + __field(unsigned int, max_agsize) + __field(unsigned int, max_rgsize) + __field(unsigned int, data_awu_max) + __field(unsigned int, rt_awu_max) + ), + TP_fast_assign( + __entry->dev =3D mp->m_super->s_dev; + __entry->max_write =3D max_write; + __entry->max_ioend =3D max_ioend; + __entry->max_agsize =3D max_agsize; + __entry->max_rgsize =3D max_rgsize; + __entry->data_awu_max =3D mp->m_groups[XG_TYPE_AG].awu_max; + __entry->rt_awu_max =3D mp->m_groups[XG_TYPE_RTG].awu_max; + ), + TP_printk("dev %d:%d max_write %u max_ioend %u max_agsize %u max_rgsize %= u data_awu_max %u rt_awu_max %u", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->max_write, + __entry->max_ioend, + __entry->max_agsize, + __entry->max_rgsize, + __entry->data_awu_max, + __entry->rt_awu_max) +); + +TRACE_EVENT(xfs_calc_max_atomic_write_fsblocks, + TP_PROTO(struct xfs_mount *mp, unsigned int per_intent, + unsigned int step_size, unsigned int logres, + unsigned int blockcount), + TP_ARGS(mp, per_intent, step_size, logres, blockcount), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, per_intent) + __field(unsigned int, step_size) + __field(unsigned int, logres) + __field(unsigned int, blockcount) + ), + TP_fast_assign( + __entry->dev =3D mp->m_super->s_dev; + __entry->per_intent =3D per_intent; + __entry->step_size =3D step_size; + __entry->logres =3D logres; + __entry->blockcount =3D blockcount; + ), + TP_printk("dev %d:%d per_intent %u step_size %u logres %u blockcount %u", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->per_intent, + __entry->step_size, + __entry->logres, + __entry->blockcount) +); + TRACE_EVENT(xlog_intent_recovery_failed, TP_PROTO(struct xfs_mount *mp, const struct xfs_defer_op_type *ops, int error), --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 EE99327E1A7; Tue, 22 Apr 2025 12:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324952; cv=fail; b=OyXC49evqOkvog47qFMFtoEZ8cRr77FTLImuvmaBbJ0DathKLUhHw/zCmfK4v4YF/NACgA21mEgRUluuAyZwAPrzcIo1QvEaRimV/DMY/sBBWHxmOnN7R7U3uzrFCqpfDtWtkLrHDPksnjBIRuMoIQOpLTPxOw6tl6zybdAmFiY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324952; c=relaxed/simple; bh=4qJmWMCCAZiOdYEsztIyCzyAgKFhiR1xKFRGWso0gCU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=shA4cp+w0iuSbmn4RUKoGJ0OFrQyUEtrqmwXwl20ezkPaaCVgd8cAKwPHr/e2DmQRUb48db4XjPVmgIrSQGAoptF7XZuTWGnoTLTW8o7c4w4rxidYpOaZCxOGhS5PUll8nuLit9wn1I/xtmt1dZBMtmL/E+uozdwHThQE/dTKoU= 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=FK7SZeST; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=dVfvLkIw; 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="FK7SZeST"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="dVfvLkIw" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53MB3W0o020939; Tue, 22 Apr 2025 12:28:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=40PwpeIzG9nynydBAoU1k/Dw3Kn3C0tzNf1hl1so1Lg=; b= FK7SZeST1dlCndBQSvShnoQseczjh/xzbd6/2EztDUmGb9rfetVaXQqq+gVV6IgZ NAtnwsdI6sPzRZtfXVHZKEWbkOcP5bw+f+Lem4co2YdB/+Zt9xcLpk/xj8ov97J8 zRtGq9S7m0xKr5kerdXnsXwx6KcRJLLswlly8YHOYZqkNh56Wuzoc1vWheRSukQU BNqh/Xg0Zy1pEbq6aDQxMzo/PIGc3RCONO3yoIWmT4FP8GnxHWTlntWPUGO9xwvn Wzpzayw1EOoR0zTlNdamQjOKlv78L7cr203Wvd0pqaKsOgiDUD+d7eU2Au/s+Kes PeSCgH0hA9wd4ULdxN6zZg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4642race2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBtH9T002293; Tue, 22 Apr 2025 12:28:56 GMT Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012013.outbound.protection.outlook.com [40.93.14.13]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999v45-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cixpKZv789Fqk5VdHo2jKQsFofvmjzNyrWORgt8GR6orwgoWmlABCN3mII4piNv5HaRl19fPzbehCitCaL1cCC98G8ngd82XTGDCnFpVDUnzb9Hi4h2fNwF3ZC7YVsY5HllxuGrMHeZwcB+pHNoTHZS400vfYUXWmoZU5rGKix4jLtvugIe+2xm/IfZZMOVK9uEeXaKOfmYL0Pb6HnOx0kIy+1v/hs0Zw3r9El8+9AY652tSwIutN4zNvVaKqTinPnIv1RECBlqz9thMDeMs/7v24Du/iMWJ9vkt0/GWWSDCyTkYqdXQDgkoa25aFT+Ga5Rjp3RRJ816Hol+y2Al2A== 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=40PwpeIzG9nynydBAoU1k/Dw3Kn3C0tzNf1hl1so1Lg=; b=ql1m6cX/lbvIgGxMommfNIpdG/MaMDw3cOKCd16rnj233/eaLu2UtIimgQMcj1cFE2ZN2wqDHs9Nx9bJH5ro0OTp5/2CxalYaAvMWTz04WBT949ZuId4m35D2efqL6dcnt+DYq/qpYYdxAmfovZXOZrOUEswlAamW+XPJiYFYUo9dfAAxiafL3SFHopL3yFntsVqgrhbtieo5xMkgHkVujH+ogJxo6Pu/HxwKvYfZv8cM/VvQ/fZ6W6oWcbOSdW6ozL9S5mDbyUAQyl0N4uLROaNBfPGf/OXXHk2vTqdVUWFimh7F60jfHNKdHlxHJHMdUrihpatj11auIOxlqGRuQ== 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=40PwpeIzG9nynydBAoU1k/Dw3Kn3C0tzNf1hl1so1Lg=; b=dVfvLkIwUyqVa7f36o8Qn+dcsy5D7FdnCYaDZto99xEiEabR6CKwFt8y/6hHOPcwWIc0nPBepXmUx1cFP8nDIcqGrWgCmcVTm8UE8S5P+IsWrc6ABRbIFe4Xn9HTuuCd6X4GB6wPepe7VMr9nADolDHAvEJeRBBRKcKR3YDfdt0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:52 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:52 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 14/15] xfs: update atomic write limits Date: Tue, 22 Apr 2025 12:27:38 +0000 Message-Id: <20250422122739.2230121-15-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN9PR03CA0582.namprd03.prod.outlook.com (2603:10b6:408:10d::17) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ae7349f-da83-4f1f-0098-08dd8199374e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1jKEdUhQT69TKdB5HFxW8zuhPn4en82vSWTuorO6zJgcw20ZmqEZV8E/CDjt?= =?us-ascii?Q?pSf4p9jyOOuvZJAEYpKEQF45e1qq1UWVCQgy17s/ME/L3VLgsWAZr394bGRz?= =?us-ascii?Q?3avqFe/e28Ehuv7iKPJcXBL6bKVgO6E8bZIAidoJcj3x2tnmsSMXyjiZVVZx?= =?us-ascii?Q?G+UYyO1HPWYDc8M23lmxSAG6EoHWD9kTk2MMgKR95vU8LvWPlWC9acw3umF0?= =?us-ascii?Q?1RFVZxhqpnGoM2cgr/Zw+fybFfHIZ07R7fGlwjnBAWd1l9RZYx5ialYYcx13?= =?us-ascii?Q?ZSdTlPztptm0ZlUBMGA8wg0zYhjt2UejlsqbERJwETkg8sKAfsPW/iy1u+/t?= =?us-ascii?Q?L5fCxSlIdRVv6QLfdbC5wC69n/hBrLtt+YDol7ZDa1C16a1rzIj7+4cjGcpW?= =?us-ascii?Q?Zmsy0rOFyAGzwFYylOIYzb+ua76YnYVpgV4GRLwwMsIz4E5YrMwHUf+VMcRd?= =?us-ascii?Q?yRN2OSsJHA5LS4Lqlq9y5+d6ejgn0fw0g+Ii8sTQyxKhUIDfcF59dq9QHh7p?= =?us-ascii?Q?rbD2pm6k8wFzWvmwc+suCqk+kj+02YotaVnvWAthkY5jc2V9XTRu9IdvdiXt?= =?us-ascii?Q?XFHWsmOUeLM8eIK81td86k6iSwU9FtohKddoN1axk2dHH7tOh0YqTDZYRrIB?= =?us-ascii?Q?JBSErHj0SmRg269VsTYiWwgo6qdRinWKIzNAsnkc1ZWB5ZVGfcChO+6WYudf?= =?us-ascii?Q?t+vwE58Jhj5+e7eHpEt4+3ECnGTQJEORdxjNjgwwT4vrFigjdVr5segiG6gT?= =?us-ascii?Q?IToUmAg7C4NPHf9U2Mgsp4fUaBBCP5aD4tjmMYttAElBV2H2YucBrlHpG9K+?= =?us-ascii?Q?40nJlNF70xl5IgRuVA4G56EIHiGQyg2fhX8ikohzYzFskr/ccZFOUE70DaU9?= =?us-ascii?Q?J6Lwj0iwBRUwDaTrzaudf2w4n3az6mGNIddxVA2zb8gd8EOTdXmcjlmNTV1T?= =?us-ascii?Q?N9i6IEE3ZrWyAgwn6pOvq3CDVJoIxZFuoBV0TU+Nh352OVdu59ivQHBtERrp?= =?us-ascii?Q?XRzOH8eYhTsQtrS0xF5eMyn0X3UI6+zlXteqgtHcUxJPNo6LCkBSxuzW2EWQ?= =?us-ascii?Q?HFQZjnZmljx9kN6ASPvCaHRR58IQczJSBTTc/3DFjM9JgNoBm2QWIL8PwH/m?= =?us-ascii?Q?86qi8kQE7F8T8QB8dMXSRD0qtNPf5j4c1zecdg0uNzOolhVtk1JZ1hyvruuY?= =?us-ascii?Q?npNbJqHzFBXpZg2R/c4QNY6MMz8pCc9Uk54+4xoS0qZEYUXOJ6IosIer6qF4?= =?us-ascii?Q?OyAUIRjMRxs9rdAhduBjb40uREd50uApMIg43fmnX/J9uZpWTQayUHIJPq5X?= =?us-ascii?Q?eTE5YbM2nTMTX3v8lHUBkH+B/rJnSMwUr49moy3X0SqdE4F4nds8T8Ay4OYG?= =?us-ascii?Q?tpKDxpe0jl88lYX0PwvhmRNlClESbGwq9uqsphDINFgMMEvUOg=3D=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?yvI4MEjahgfbDDvoTHjz80mz7DmKfxoLttQPCUVB98+TgCB7D5mrCUPIbH+7?= =?us-ascii?Q?UpQFcnVdTMrK/DhefodWvgDKDSLUd2JRhu5rfYUp/D1r2qOEpVQDTMdUfD20?= =?us-ascii?Q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Kb0dfVgw41PwC8p8j6nMtMKmbVIAw48?= =?us-ascii?Q?C7dxu6bYKD0A0cUfd0v+qiBthVZLqAwPsuLfF4rSA3DnVdhdGj2YjzTepGEo?= =?us-ascii?Q?iPC19AI7tUA8ASFQ17C4KwKV2M/TdhkeH9km1LsA9GvjUkr25PpUvpjB00YE?= =?us-ascii?Q?CFP9T8UdxUXahf3mW0RDGZV6MpjFJfJMbiZq8+5s+CANnGNtNX86wLF2N8Va?= =?us-ascii?Q?lCmaTbwtz1ApbehDta0LnRAQJ+LnGyQUpwJk0Qvj0OqflWr3Bm3/QdKcdCe/?= =?us-ascii?Q?xQjRwO7cbFmg5/ne8I4FcRwLLrkykjdAHgdH+YNJ5Z0Ofv2xPfT3Lb+lHUgk?= =?us-ascii?Q?vt0YYjWACyyPAPmd70uB3rR8giiD4ak8RyLK7HwH5sAIEYFjB88AnhCh4Byp?= =?us-ascii?Q?exof+1PaPokQXl2F9JsEvu8Zr5XF5q8ey+72YJ3cYVLYvzvH2Dmz1Jl00HTl?= =?us-ascii?Q?g7r6BZGEBj7Ml6I9436GokzQGCiAzFD1NQ+bxRAbCRNDTO3w+HZL1M4wNsLg?= =?us-ascii?Q?n8Mx4E95ttl/DGD4Nw6SMOXsSxEgf+BWlhA6sh7DDqbDx++Pdt+8yOe83nv3?= =?us-ascii?Q?2CbloUA1Qv6UxRFI8LW1thqgUf7Nlsmc3oKjviYTSBIyIiRHFBhCxdsAEkRM?= =?us-ascii?Q?AA=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NJsbJ66GHTZ6A3BCDagmm5es6uGrY0fRKSW2c+A0WwaqPYFerErgeTuQhP2MzBD2R65vh+RV+8XEtJGgWcINBnUufIBmy6XPfGMuds5WoQNzUyM4/u4ETdP8hD07peVx3OOuejzBarPwCyUANk+id5gCuq8jsZYDOJYhMqe5ta4VPXCc2mZmGMFb+CVV4DQcXbQmN3WjeApNbpZDH5rrGICKEVNK+qR2WrzpzOu3EtQi0t+/VPofynQ8FBsxjJtNdKdSlEJ5UDUeWnJJM7hPbn7aUjbn+mCMgv1HB6KPmTBpQTGemfIZSFe325d02CtlEB4ITeski6OO5pBv1izCmCItwdVK0xadYltuWU+SrgzzujUdAiEmbCn0jbQT4xg5/I/9Old7SLCsKjevtFMA9hF4BjzjHhXn0yNeGbyfUMJbTFjfGhURUH8ZEwlgqA8JFQRLMzmhJT5K5OSA/deujzSHhlXQ2e5cJ74YLozbGzX8cTNTNWTQiDVRP1dyvXEEj9v+codKDW3PRDHESMyYYitzLVfmqk+XVOh5qBv8Kuzxug1fnGIGTq8qfAijU1E8ymzBNT1S1Pzh9AxFRUbS3xGfFyJk1r/xxW9+cK3i7lk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ae7349f-da83-4f1f-0098-08dd8199374e X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:41.5548 (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: +Z6I317H70Y0JETC/jNtQVHZAmscn4yRnv1lMwLeSAQrl9ZowH8Mdx99g8Y/HtGBE2RAjm80D98/Q8OKk3VpMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-ORIG-GUID: -TQTTKRq876o_sQDhqWIa5Jx756jmtST X-Proofpoint-GUID: -TQTTKRq876o_sQDhqWIa5Jx756jmtST Content-Type: text/plain; charset="utf-8" Update the limits returned from xfs_get_atomic_write_{min, max, max_opt)(). No reflink support always means no CoW-based atomic writes. For updating xfs_get_atomic_write_min(), we support blocksize only and that depends on HW or reflink support. For updating xfs_get_atomic_write_max(), for no reflink, we are limited to blocksize but only if HW support. Otherwise we are limited to combined limit in mp->m_atomic_write_unit_max. For updating xfs_get_atomic_write_max_opt(), ultimately we are limited by the bdev atomic write limit. If xfs_get_atomic_write_max() does not report > 1x blocksize, then just continue to report 0 as before. Reviewed-by: "Darrick J. Wong" [djwong: update comments in the helper functions] Signed-off-by: John Garry Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_iops.c | 52 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 000bbb0d1413..371f0d30f859 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1557,7 +1557,7 @@ xfs_file_open( if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; file->f_mode |=3D FMODE_NOWAIT | FMODE_CAN_ODIRECT; - if (xfs_inode_can_hw_atomicwrite(XFS_I(inode))) + if (xfs_get_atomic_write_min(XFS_I(inode))) file->f_mode |=3D FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); } diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 3b5aa39dbfe9..118377d3f8d2 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -605,27 +605,67 @@ unsigned int xfs_get_atomic_write_min( struct xfs_inode *ip) { - if (!xfs_inode_can_hw_atomicwrite(ip)) - return 0; + struct xfs_mount *mp =3D ip->i_mount; + + /* + * If we can complete an atomic write via atomic out of place writes, + * then advertise a minimum size of one fsblock. Without this + * mechanism, we can only guarantee atomic writes up to a single LBA. + * + * If out of place writes are not available, we can guarantee an atomic + * write of exactly one single fsblock if the bdev will make that + * guarantee for us. + */ + if (xfs_inode_can_hw_atomicwrite(ip) || xfs_has_reflink(mp)) + return mp->m_sb.sb_blocksize; =20 - return ip->i_mount->m_sb.sb_blocksize; + return 0; } =20 unsigned int xfs_get_atomic_write_max( struct xfs_inode *ip) { - if (!xfs_inode_can_hw_atomicwrite(ip)) + struct xfs_mount *mp =3D ip->i_mount; + + /* + * If out of place writes are not available, we can guarantee an atomic + * write of exactly one single fsblock if the bdev will make that + * guarantee for us. + */ + if (!xfs_has_reflink(mp)) { + if (xfs_inode_can_hw_atomicwrite(ip)) + return mp->m_sb.sb_blocksize; return 0; + } =20 - return ip->i_mount->m_sb.sb_blocksize; + /* + * If we can complete an atomic write via atomic out of place writes, + * then advertise a maximum size of whatever we can complete through + * that means. Hardware support is reported via max_opt, not here. + */ + if (XFS_IS_REALTIME_INODE(ip)) + return XFS_FSB_TO_B(mp, mp->m_groups[XG_TYPE_RTG].awu_max); + return XFS_FSB_TO_B(mp, mp->m_groups[XG_TYPE_AG].awu_max); } =20 unsigned int xfs_get_atomic_write_max_opt( struct xfs_inode *ip) { - return 0; + unsigned int awu_max =3D xfs_get_atomic_write_max(ip); + + /* if the max is 1x block, then just keep behaviour that opt is 0 */ + if (awu_max <=3D ip->i_mount->m_sb.sb_blocksize) + return 0; + + /* + * Advertise the maximum size of an atomic write that we can tell the + * block device to perform for us. In general the bdev limit will be + * less than our out of place write limit, but we don't want to exceed + * the awu_max. + */ + return min(awu_max, xfs_inode_hw_atomicwrite_max(ip)); } =20 static void --=20 2.31.1 From nobody Mon Feb 9 01:17:04 2026 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 BB99A27C842; Tue, 22 Apr 2025 12:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324952; cv=fail; b=bIi5W7IF47veSw7nKsxoEf5J0wcfIKmSuwbVZNqr0L9hCYbE7H1ZCQRMLTKsnDfuwyz6n19kSCEZGVSOeKFInkOa1cMDwS8EDgDyQD5UYzlojZPOYqxghyFwo6mwvJMvBcqtqytlXc1mYQ0Gceg6UgsYULNb2nRAZeQDJ4kGowo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745324952; c=relaxed/simple; bh=HJsYMi/pg/eHGM9Q+6hs0pzz+8TwQjaQ6L8H+AXQks8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YHSzArYBO02hnYO65ecbUhpWgbb3u326LyVB5MyLy8KsLYnAggqSPYGqQFFiwOcDjA1Rdbalyea0Uv6++sQdZEA8yJjtRnIkb19AJUFTpp0WYWshkPyNui4BfIkNJcxUDUpEm6qVxllzs6ubRWdE4oitbAZ9IfXVAO2pVKoNCVE= 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=czC9CWDG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QYFQdBqF; 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="czC9CWDG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QYFQdBqF" 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 53MB39ns025696; Tue, 22 Apr 2025 12:28:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=ppqIrLNngVB2L71ggEZBNWDOh6VuXPN2WFs4//pEtUk=; b= czC9CWDGuWc50HvFsaXOWZFFfhtVojxq8Vz7D62yVNGymW0DZdmDlLp+g7QIvdFl jh8my5lZ5hRAv8FEgjH9DbBzF59AtxG+elcIUeQ8rXqmebEcDHOYDqgxHJZd94Px JhRgdgvGGx2oIaVAynpS+BpH5gZ1onbPkOAvrYn5kXEAqQSy/PvQFISxgNWBdY/k Ly6BhfwdlygtCG0+FoYanGwglIrkfl775qKHB9GpYCv37JYZsALeMG9tidV56kk2 i3VbEflSqW3w6+PslPPIsPwpl70humv21iL3dh+bNAMhNtBxcJ+YiMpfMa7dfmYQ M57BsyRhuSGDn9QI2S/j6g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4644csvbtn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 53MBtH9U002293; Tue, 22 Apr 2025 12:28:57 GMT Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012013.outbound.protection.outlook.com [40.93.14.13]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4642999v45-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Apr 2025 12:28:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JVMUp6p6Wf8zXMH8G2gKkiWj1owO7i0q4qHc6niZtn67J9SN/cSwYoY2lKUyQcvXnxZf5IP0p0/TpASZfaHDezW3OT6e65gyEJMa2kNN7rx/PHq7MDPC5OCbtYvYkNeC5uSMC7FD9mYNkQ8dttL5+RMVOyq7h3ap2JqqIk+/V6+jwa2FdALKbrzTEV7igwt44wGFGqNkTSpxlkxwescBtlQw1udHB4GYfcgCnoGHf/V3+yyQ/QdM61ExbMwKB8ZH7oNtQk/QfDLIQ6rEPguxl7k33x10qBEdLbDGjgieLF26mZf+97VhZnakT/jwvtpXuUTgU6r6hJiOch48MFEzXA== 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=ppqIrLNngVB2L71ggEZBNWDOh6VuXPN2WFs4//pEtUk=; b=RTTi2S+SJ+1tNaTyl2Ea+VihL74mx398Y+bnPbQZ2ry4fwwL1/BIgPDJovOiI/ZrQ+HpH7h81GUCxYeDBZClmZXYcPiRY7TIkFxxFt8CmfHoQV0EGP9EiI87ALw/Qeau4rK23gXQps8BzA0Seevgo2YywU7fu9aywX30ULZfE42O2OUgob3CuI8Hq/aLBr2oyOjLUu7BiC+4AWCwmH1VyMbrQFxG6IiwEh7POH4MY38Xx5iNvWrORfhTmCue9X9q4kGj0qEidvDSiM3yjtXxPtpSc6wkIg+6353buyoM6r0oMCYP44ChzS3hFG8SgolHRbD9mIlw5zty2Ox5wfhs4A== 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=ppqIrLNngVB2L71ggEZBNWDOh6VuXPN2WFs4//pEtUk=; b=QYFQdBqFniHZHpsPoBQLnQOQ6+9jWyXaHs8pk12Gb7SgxvRNakfQz8PZIYlSyGvzTw28Kx2bwEavChDvowk47WHAIEOxkBmpwEE1LoDJVvqF7Rqsvg+72UroOiEZUk1cDageCfYW7rFnbaDiM9E1ett0yWI6AJ2cJ9Q3VCbKfMM= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS7PR10MB4895.namprd10.prod.outlook.com (2603:10b6:5:3a7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.31; Tue, 22 Apr 2025 12:28:52 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8655.033; Tue, 22 Apr 2025 12:28:52 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, hch@lst.de, viro@zeniv.linux.org.uk, jack@suse.cz, cem@kernel.org Cc: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, ojaswin@linux.ibm.com, ritesh.list@gmail.com, martin.petersen@oracle.com, linux-ext4@vger.kernel.org, linux-block@vger.kernel.org, catherine.hoang@oracle.com, linux-api@vger.kernel.org, John Garry Subject: [PATCH v8 15/15] xfs: allow sysadmins to specify a maximum atomic write limit at mount time Date: Tue, 22 Apr 2025 12:27:39 +0000 Message-Id: <20250422122739.2230121-16-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250422122739.2230121-1-john.g.garry@oracle.com> References: <20250422122739.2230121-1-john.g.garry@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BN8PR04CA0020.namprd04.prod.outlook.com (2603:10b6:408:70::33) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS7PR10MB4895:EE_ X-MS-Office365-Filtering-Correlation-Id: 70c3fecd-a0b0-48e1-270f-08dd8199381f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0ak67SAxxd2wNd8KhlvCJtjzcIswKHt7eFi2Zxo4VBRHOmU0m9oA+qgXl7z5?= =?us-ascii?Q?3u0SfjO8knEVhq2WgH7Um8e2/NJmElU8FlQD7S/Y4SWA8eEEGL8fUy2Qak5+?= =?us-ascii?Q?9ZNJn9CnrPgChQH5a2/3vtKfL0222Q5jC9XXaMzqL+kPw34FNFfxnKTJh3Ca?= =?us-ascii?Q?yT+SiT1EuTU6+nJpEgKIjQblkaPilOwoNC2L4pXz3p6OgQqDz61eQugPglCC?= =?us-ascii?Q?kyQPr0mVoWsAXQVLcNRQyo1fgMPOvIF3ZJyPtjtf9m2+CVIwkZbQlFicvZ3G?= =?us-ascii?Q?z/+HuPH+AzLnrmkih0hAVf80w6n6ErG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Q?Z/oOkkXRXj42uz2+U1xz3g0OEEVEaFAIMxiXb7HakN9IjKIjQ8Bc/ivppt7e?= =?us-ascii?Q?th1dVj/6HzoCx7raMZ4GSR6IQ2xPwIemYQpWj0wMkI0CW7PoPO6BNAsOJ4UL?= =?us-ascii?Q?WTiw+RCdVqB1F6tNBUdrKbC0heFoOOq16iTy8kRf3AM+ENk+LPGfYw2uBPTU?= =?us-ascii?Q?u2aLIQL7S9CW0iriRIJSp+YxUmg5ybHjrrIkVZawNV6C5rMdj05wCXJXR7mZ?= =?us-ascii?Q?5fKXQnIMNps=3D?= 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)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9ErzWIo6fu76Q7uiGdbVXVTPKMlNuvcf1395hn/MRAKWZ4bV4yJF641/2sBr?= =?us-ascii?Q?4JCaAzXw6mc0aKLa+twP/BECWGqvk1g/JZHsRAowWCvRVzCUXKgKkHrmkGXM?= =?us-ascii?Q?QB5UjCdCrCIfKaTYcnDKRZf4B0ppwpx/AbfNkZO3v+svkW5HVOE22M1Me24a?= =?us-ascii?Q?ukWczJWDkPsNC2pN3mZR4wHXBEDtgDjU2NLeE5lHGMmCDsTEUb5j1rEcM0tq?= =?us-ascii?Q?Xd2K7gjGiaqszlvQudzzOLqGjH1cDtOd2xb9BgGYLHav7WW3dgEvhYY5+x8u?= =?us-ascii?Q?bHpvlNHxcxhe5TaabXfhj+aDedys/cUeR8/jdioBbB1tyqClj2q3oSUTn7PR?= =?us-ascii?Q?0syy6uL+rSijeSfNkDVN0R6RH69LDkOYQ8PRVHH80GgdPPZNXvOlPIEPmdLe?= =?us-ascii?Q?VuYGU+vTWM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dZwTyqQfta4SEk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70c3fecd-a0b0-48e1-270f-08dd8199381f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2025 12:28:42.9363 (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: DMA2nAM5/+XPy98GA7kkbjz+1v24BMq5R3vhYD/jNUYBm419QZUbEY9XTZ7V5+aBIutQzRyCb/19c483bL3+2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4895 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_06,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504220094 X-Proofpoint-ORIG-GUID: -A5VktWlUGsUPDt18YcGvwSlMZYzQWIx X-Proofpoint-GUID: -A5VktWlUGsUPDt18YcGvwSlMZYzQWIx Content-Type: text/plain; charset="utf-8" From: "Darrick J. Wong" Introduce a mount option to allow sysadmins to specify the maximum size of an atomic write. If the filesystem can work with the supplied value, that becomes the new guaranteed maximum. The value mustn't be too big for the existing filesystem geometry (max write size, max AG/rtgroup size). We dynamically recompute the tr_atomic_write transaction reservation based on the given block size, check that the current log size isn't less than the new minimum log size constraints, and set a new maximum. The actual software atomic write max is still computed based off of tr_atomic_ioend the same way it has for the past few commits. Signed-off-by: "Darrick J. Wong" Signed-off-by: John Garry --- Documentation/admin-guide/xfs.rst | 11 +++++ fs/xfs/libxfs/xfs_trans_resv.c | 55 ++++++++++++++++++++++++ fs/xfs/libxfs/xfs_trans_resv.h | 2 + fs/xfs/xfs_mount.c | 69 ++++++++++++++++++++++++++++++- fs/xfs/xfs_mount.h | 6 +++ fs/xfs/xfs_super.c | 58 +++++++++++++++++++++++++- fs/xfs/xfs_trace.h | 33 +++++++++++++++ 7 files changed, 232 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/xfs.rst b/Documentation/admin-guide/= xfs.rst index 3e76276bd488..40b7789c8b34 100644 --- a/Documentation/admin-guide/xfs.rst +++ b/Documentation/admin-guide/xfs.rst @@ -151,6 +151,17 @@ When mounting an XFS filesystem, the following options= are accepted. optional, and the log section can be separate from the data section or contained within it. =20 + max_atomic_write=3Dvalue + Set the maximum size of an atomic write. The size may be + specified in bytes, in kilobytes with a "k" suffix, in megabytes + with a "m" suffix, or in gigabytes with a "g" suffix. The size + cannot be larger than the maximum write size, larger than the + size of any allocation group, or larger than the size of a + remapping operation that the log can complete atomically. + + The default value is to set the maximum I/O completion size + to allow each CPU to handle one at a time. + max_open_zones=3Dvalue Specify the max number of zones to keep open for writing on a zoned rt device. Many open zones aids file data separation diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 708cfb4be661..86bc93b43dbd 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -1491,3 +1491,58 @@ xfs_calc_max_atomic_write_fsblocks( =20 return ret; } + +/* + * Compute the log reservation needed to complete an atomic write of a giv= en + * number of blocks. Worst case, each block requires separate handling. + */ +int +xfs_calc_atomic_write_reservation( + struct xfs_mount *mp, + xfs_extlen_t blockcount) +{ + struct xfs_trans_res *curr_res =3D &M_RES(mp)->tr_atomic_ioend; + unsigned int per_intent, step_size; + unsigned int logres; + uint old_logres =3D + M_RES(mp)->tr_atomic_ioend.tr_logres; + int min_logblocks; + + xfs_calc_default_atomic_ioend_reservation(mp, M_RES(mp)); + + /* + * If the caller doesn't ask for a specific atomic write size, then + * use the defaults. + */ + if (blockcount =3D=3D 0) + return 0; + + /* + * The caller asked for a specific size but we don't support out of + * places writes, so this is a failure. + */ + if (curr_res->tr_logres =3D=3D 0) + return -EINVAL; + + per_intent =3D xfs_calc_atomic_write_ioend_geometry(mp, &step_size); + + /* Check for overflows */ + if (check_mul_overflow(blockcount, per_intent, &logres)) + return -EINVAL; + if (check_add_overflow(logres, step_size, &logres)) + return -EINVAL; + + curr_res->tr_logres =3D logres; + min_logblocks =3D xfs_log_calc_minimum_size(mp); + + trace_xfs_calc_max_atomic_write_reservation(mp, per_intent, step_size, + blockcount, min_logblocks, curr_res->tr_logres); + + if (min_logblocks > mp->m_sb.sb_logblocks) { + /* Log too small, revert changes. */ + curr_res->tr_logres =3D old_logres; + return -EINVAL; + } + + return 0; +} diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index a6d303b83688..16fd90b50ccd 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h @@ -122,5 +122,7 @@ unsigned int xfs_calc_write_reservation_minlogsize(stru= ct xfs_mount *mp); unsigned int xfs_calc_qm_dqalloc_reservation_minlogsize(struct xfs_mount *= mp); =20 xfs_extlen_t xfs_calc_max_atomic_write_fsblocks(struct xfs_mount *mp); +int xfs_calc_atomic_write_reservation(struct xfs_mount *mp, + xfs_extlen_t blockcount); =20 #endif /* __XFS_TRANS_RESV_H__ */ diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index eb5ed61b6f99..54fc06285131 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -740,6 +740,71 @@ xfs_calc_atomic_write_unit_max( max_agsize, max_rgsize); } =20 +/* + * Try to set the atomic write maximum to a new value that we got from + * userspace via mount option. + */ +int +xfs_set_max_atomic_write_opt( + struct xfs_mount *mp, + unsigned long long new_max_bytes) +{ + const xfs_filblks_t new_max_fsbs =3D XFS_B_TO_FSBT(mp, new_max_bytes); + const xfs_extlen_t max_write =3D xfs_calc_atomic_write_max(mp); + const xfs_extlen_t max_group =3D + max(xfs_calc_perag_awu_max(mp), xfs_calc_rtgroup_awu_max(mp)); + int error; + + if (new_max_bytes =3D=3D 0) + goto set_limit; + + ASSERT(max_write <=3D U32_MAX); + + /* generic_atomic_write_valid enforces power of two length */ + if (!is_power_of_2(new_max_bytes)) { + xfs_warn(mp, + "max atomic write size of %llu bytes is not a power of 2", + new_max_bytes); + return -EINVAL; + } + + if (new_max_bytes & mp->m_blockmask) { + xfs_warn(mp, + "max atomic write size of %llu bytes not aligned with fsblock", + new_max_bytes); + return -EINVAL; + } + + if (new_max_fsbs > max_write) { + xfs_warn(mp, + "max atomic write size of %lluk cannot be larger than max write size %llu= k", + new_max_bytes >> 10, + XFS_FSB_TO_B(mp, max_write) >> 10); + return -EINVAL; + } + + if (new_max_fsbs > max_group) { + xfs_warn(mp, + "max atomic write size of %lluk cannot be larger than allocation group si= ze %lluk", + new_max_bytes >> 10, + XFS_FSB_TO_B(mp, max_group) >> 10); + return -EINVAL; + } + +set_limit: + error =3D xfs_calc_atomic_write_reservation(mp, new_max_fsbs); + if (error) { + xfs_warn(mp, + "cannot support completing atomic writes of %lluk", + new_max_bytes >> 10); + return error; + } + + xfs_calc_atomic_write_unit_max(mp); + mp->m_awu_max_bytes =3D new_max_bytes; + return 0; +} + /* Compute maximum possible height for realtime btree types for this fs. */ static inline void xfs_rtbtree_compute_maxlevels( @@ -1175,7 +1240,9 @@ xfs_mountfs( * derived from transaction reservations, so we must do this after the * log is fully initialized. */ - xfs_calc_atomic_write_unit_max(mp); + error =3D xfs_set_max_atomic_write_opt(mp, mp->m_awu_max_bytes); + if (error) + goto out_agresv; =20 return 0; =20 diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index ba55fa1d9594..93e2bec24af9 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -241,6 +241,9 @@ typedef struct xfs_mount { unsigned int m_dd_awu_hw_max; unsigned int m_rt_awu_hw_max; =20 + /* max_atomic_write mount option value */ + unsigned long long m_awu_max_bytes; + /* * Bitsets of per-fs metadata that have been checked and/or are sick. * Callers must hold m_sb_lock to access these two fields. @@ -803,4 +806,7 @@ static inline void xfs_mod_sb_delalloc(struct xfs_mount= *mp, int64_t delta) percpu_counter_add(&mp->m_delalloc_blks, delta); } =20 +int xfs_set_max_atomic_write_opt(struct xfs_mount *mp, + unsigned long long new_max_bytes); + #endif /* __XFS_MOUNT_H__ */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index b2dd0c0bf509..4cdb161a1bb8 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -111,7 +111,7 @@ enum { Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota, Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce, Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum, Opt_max_open_zones, - Opt_lifetime, Opt_nolifetime, + Opt_lifetime, Opt_nolifetime, Opt_max_atomic_write, }; =20 static const struct fs_parameter_spec xfs_fs_parameters[] =3D { @@ -159,6 +159,7 @@ static const struct fs_parameter_spec xfs_fs_parameters= [] =3D { fsparam_u32("max_open_zones", Opt_max_open_zones), fsparam_flag("lifetime", Opt_lifetime), fsparam_flag("nolifetime", Opt_nolifetime), + fsparam_string("max_atomic_write", Opt_max_atomic_write), {} }; =20 @@ -241,6 +242,9 @@ xfs_fs_show_options( =20 if (mp->m_max_open_zones) seq_printf(m, ",max_open_zones=3D%u", mp->m_max_open_zones); + if (mp->m_awu_max_bytes) + seq_printf(m, ",max_atomic_write=3D%lluk", + mp->m_awu_max_bytes >> 10); =20 return 0; } @@ -1334,6 +1338,42 @@ suffix_kstrtoint( return ret; } =20 +static int +suffix_kstrtoull( + const char *s, + unsigned int base, + unsigned long long *res) +{ + int last, shift_left_factor =3D 0; + unsigned long long _res; + char *value; + int ret =3D 0; + + value =3D kstrdup(s, GFP_KERNEL); + if (!value) + return -ENOMEM; + + last =3D strlen(value) - 1; + if (value[last] =3D=3D 'K' || value[last] =3D=3D 'k') { + shift_left_factor =3D 10; + value[last] =3D '\0'; + } + if (value[last] =3D=3D 'M' || value[last] =3D=3D 'm') { + shift_left_factor =3D 20; + value[last] =3D '\0'; + } + if (value[last] =3D=3D 'G' || value[last] =3D=3D 'g') { + shift_left_factor =3D 30; + value[last] =3D '\0'; + } + + if (kstrtoull(value, base, &_res)) + ret =3D -EINVAL; + kfree(value); + *res =3D _res << shift_left_factor; + return ret; +} + static inline void xfs_fs_warn_deprecated( struct fs_context *fc, @@ -1518,6 +1558,14 @@ xfs_fs_parse_param( case Opt_nolifetime: parsing_mp->m_features |=3D XFS_FEAT_NOLIFETIME; return 0; + case Opt_max_atomic_write: + if (suffix_kstrtoull(param->string, 10, + &parsing_mp->m_awu_max_bytes)) { + xfs_warn(parsing_mp, + "max atomic write size must be positive integer"); + return -EINVAL; + } + return 0; default: xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); return -EINVAL; @@ -2114,6 +2162,14 @@ xfs_fs_reconfigure( if (error) return error; =20 + /* Validate new max_atomic_write option before making other changes */ + if (mp->m_awu_max_bytes !=3D new_mp->m_awu_max_bytes) { + error =3D xfs_set_max_atomic_write_opt(mp, + new_mp->m_awu_max_bytes); + if (error) + return error; + } + /* inode32 -> inode64 */ if (xfs_has_small_inums(mp) && !xfs_has_small_inums(new_mp)) { mp->m_features &=3D ~XFS_FEAT_SMALL_INUMS; diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index d5ae00f8e04c..01ef8b48a354 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -230,6 +230,39 @@ TRACE_EVENT(xfs_calc_max_atomic_write_fsblocks, __entry->blockcount) ); =20 +TRACE_EVENT(xfs_calc_max_atomic_write_reservation, + TP_PROTO(struct xfs_mount *mp, unsigned int per_intent, + unsigned int step_size, unsigned int blockcount, + unsigned int min_logblocks, unsigned int logres), + TP_ARGS(mp, per_intent, step_size, blockcount, min_logblocks, logres), + TP_STRUCT__entry( + __field(dev_t, dev) + __field(unsigned int, per_intent) + __field(unsigned int, step_size) + __field(unsigned int, blockcount) + __field(unsigned int, min_logblocks) + __field(unsigned int, cur_logblocks) + __field(unsigned int, logres) + ), + TP_fast_assign( + __entry->dev =3D mp->m_super->s_dev; + __entry->per_intent =3D per_intent; + __entry->step_size =3D step_size; + __entry->blockcount =3D blockcount; + __entry->min_logblocks =3D min_logblocks; + __entry->cur_logblocks =3D mp->m_sb.sb_logblocks; + __entry->logres =3D logres; + ), + TP_printk("dev %d:%d per_intent %u step_size %u blockcount %u min_logbloc= ks %u logblocks %u logres %u", + MAJOR(__entry->dev), MINOR(__entry->dev), + __entry->per_intent, + __entry->step_size, + __entry->blockcount, + __entry->min_logblocks, + __entry->cur_logblocks, + __entry->logres) +); + TRACE_EVENT(xlog_intent_recovery_failed, TP_PROTO(struct xfs_mount *mp, const struct xfs_defer_op_type *ops, int error), --=20 2.31.1