From patchwork Sat Aug 17 09:47:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13767093 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 2D47414EC4B; Sat, 17 Aug 2024 09:48:42 +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=1723888125; cv=fail; b=r4EDHuFbaZH6qCd0lazvRP3ST3Vs/jVb9Lodm+B5aQ6yiJT4b++D8xFTOiPmOuLuXS9bYECFZ2iGe9y9BZB4a2NMFs7jPeH1OsHX9+i/Dltmm7JzZw3GNekr3oLFhB6yA55D7B0LwAHxohRxYZNPCFcMAlrJmAMZyMlmj5+q8Ew= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723888125; c=relaxed/simple; bh=eHi+Sr+xKoY6ew/Iq7+B+dzKCz/w1yaKXTEgpjcVStA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OGCXCusgEHPxD4OuQI/lKCvfkBIsKKu3hC3rJDjnYKgXsjuhuP0y0/UPdDCDSHuPMTd4qpT+h9PYnq1RcQVn1KLpbZDqcsSkUNTU5jIVbe/9Q/erYu1ZC6bw0bxnfzajZXTetnO53S8MTfEC+P0PfsK9AwT+4f0GN3HgdK47iLo= 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=V9ei0Dg3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=B0tQo8IM; 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="V9ei0Dg3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="B0tQo8IM" 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 47H4jcEI010282; Sat, 17 Aug 2024 09:48:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=LFa4FRTWKLYa9qsjerysXyWyYZxrVlTZrd7Quw8jk7k=; b= V9ei0Dg3IZAL0QRHYhHw72NHaNFPQiYZ8LgnSVDOXl9ntr88pDfPlvoEhLcYlMf9 CdWIT+df6AZkWZIz4tXquZXn5WsYYtnEKjLjtAg+OOQoW1Ab+fcWjJbGevbw8XMI lbPsnqt5qStXCwk4j1eIV2yPMRIbKvtFKZ0ThW2T34GHg/oRwYXO2CJQuqm63hLW Nu2jnjq6rhKXaULFDYShaA/LqkZpnUDScLTh/BeS/NAT90qfma6xEOXwJGWmNw5+ 9rtPWISZt5gpuBUqjMfb4YStd5oEV3vfgRM3wV1XB6PIiI8JMdiRxW1T5NMZBLUH dIt/CokKDI+7YjZSgIVtuQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 412mdsr7ax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Aug 2024 09:48:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 47H811UJ031437; Sat, 17 Aug 2024 09:48:27 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 412ja5y121-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Aug 2024 09:48:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i+UXyKH9qMNBP/GrpxXrL7+69G/+8L5aEdN4Q+A/JqGaLtHuMSW2mHpxS6rdfhRyvQhhmyrkuMEps2rpFMOcLIH0GIk5fMpRz10A3aK1xj6m5FTrDcc82zwnWdz8IGX6Z06ZrMuihUWLfy2T0EHO7dSXbc6zkFOA9rC6xYc+66ajP/BiCZnR/78BPHhaNyHL0/LjxH8A4FBacBeweLANEi5H5MduWRH464CMrbTr7j4+7n45uYy1dA7CwRmEDi4K0qObfl0PhsZtzcjHkkPE9QovFgHUgkZJ6GG2QEpSgBsOQKs2RIf/Z/5v6b4QEUbnLwh9nnwm+jBKVrq/KCMJTA== 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=LFa4FRTWKLYa9qsjerysXyWyYZxrVlTZrd7Quw8jk7k=; b=uNkrBQZFSt3ExA21hQPlOy+lHgmWZKElc62OvsG4P//7Uc3cXVDcC6HQYYYfPd3bnog5ZWwaWwbavmGRYdZZ0PPSqtR2L6H5T/2eON2WQPS6RIF3lrsnAmYtSQQfARyfCdR2/I9/rlQYtIKcHBGUNcltSzPAofTJvqNa+cy14mMi80umlrW+8qWRMoQtccs5ayvpF74oMgsUluQjcqvjdZWNXiCWHDf3L88bubC8WgzXAHhrMlB/4Dn89MoiYRU+6Axk0hHIiR00uwjyIpc6GE21WFGo3bt7qqIC5uSj+3WpfFkMgQ/zObY4KcSjtB6vK/dUD8ilo8vkxnL4DMngOQ== 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=LFa4FRTWKLYa9qsjerysXyWyYZxrVlTZrd7Quw8jk7k=; b=B0tQo8IMANVYcO4QPYcGd3XcYrh2ix9opuDEnlPLyukFNuE1NwzH6yNAFzUT60Sl415xrLIIqEgcfzvoMHo+vSXZ00COqcRB6FbV5LyiMfmy8wbMbgbpsPFKxEg5eq/zFIHFZQ61k+GkBX7Ibkxb6xZwHKzGcuMzG2XKK/Ce5WE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH0PR10MB4758.namprd10.prod.outlook.com (2603:10b6:510:3c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.11; Sat, 17 Aug 2024 09:48:24 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7897.009; Sat, 17 Aug 2024 09:48:24 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, chandan.babu@oracle.com, dchinner@redhat.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, kbusch@kernel.org, John Garry Subject: [PATCH v5 5/7] xfs: Support atomic write for statx Date: Sat, 17 Aug 2024 09:47:58 +0000 Message-Id: <20240817094800.776408-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240817094800.776408-1-john.g.garry@oracle.com> References: <20240817094800.776408-1-john.g.garry@oracle.com> X-ClientProxiedBy: LV3P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:234::30) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH0PR10MB4758:EE_ X-MS-Office365-Filtering-Correlation-Id: 827a42f3-a7b7-4d14-6455-08dcbea1bc70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: JCFuHyjOZDhGrQ6PfiAjdM7v11/CZKcurNttdUul7JQI0yIcJUQIBok0sbSKj12AyfUkz3+OdKUFj4W4lFjEYMInY5j3cy1NdZ+Fjsw+xkW4oDwKVfrv1fBUIOOaDGA0LG0xNLUr0G904ubgoCarjy/OpDi6evroT/H2U1T3Q5cGNdLI7y238W6vur+kWX3PX7Yze5v+7wyn7AfzOjJrVL1Bthv24pZ4I7DSb04RiWzOW8qYbsQ8CPJa4XtSeUfxVgCo3pDk8lXhCQSPair8tt0Q6UhsGNCW/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-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TZtzNb1yW+ccGSHVON6rxKGC99CZL2Rt6ohzkhWRi4mUPj7mVoIxlQWlyme7FkWuqTrCplLxHtm4agSaB78RUZlil5qu+t1dsR454u6i3bxJzHnoxEPf/4Kvw34lhXFQXa3bneytiIsqAT0jRBb0jBRneJzZjrXN+yF8AMKBMsxagi91Igy4OYeVs3cUS5J1aLe3oBTg2GwiiNHwXANfmeiWs3A0yBWjMPOyX8Hve/pxyxtTyfnbGgK6AbFZbUtJLS/WcIp9eSOXfnJCKBjKC0EIjDdonl7pIEl2U+R7Gn2x3Onkj2etW4HT/bK6KxfUKaxMyqNq2dCBRU0dVoDX2itR2oS8dv70WRNMUd6m/YtuIuGpoFM3/iCoIDxJxhllan/7U/wgyK9KurIRfvzOhn7eTOUesdiGEnynIWw5/XKtpigZWycwa5IAWaJJ7l/3A2EleQ6565AE4CHsQwaxR+0/5hT1wrskh+HqkJyQUBWlFxa5GzBRcMxfeUcEygqDFPDkSFJQhnelppg2N6PAC0XE07/8ccWUzNPLmJA9gFrEar29fEo9U7iG8EP4NPBpmGNCeK6mulXyXDxWCe/So0EvtEcKr4P2MssCXgd1UOXWtXbM136a9Wb4i1Wz3j6Cd/0YOOWjuPHGU4b6T0nc+K34h4pModrEbN8sm4fcUmxDNLRfSk7T/Xi2WNsmy4+Bxyn1/3753Wgq1/m1O4yINbG5lxaFq78UIQ10VPASvq5wjC5dahaBEn3CJhmsX+bt59UPFLbaTamgjpr9RNhhCUFVF0iMFdqhOgPPosttg4ZVRwq1aXZ5dYn19jX/uryTGCKiA2X9hgQ6eq26MKlfQfjURY7SCKLB75AU8Vh4ux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RtuRQBemKJIHS6KdIZqt9XpzD/8+qHxP+r2FKSQmUFYOxfPfREWGILA3nffTWik0XkPSe1j9y2LHATJ25EmYYnqyQWuxeBny1UUpauE5KaRwgVLCYbnKJwSjmW9HZtVMvNvrFWy3hcRz4aYQiOQTIK2GWoKbN6csXpOzoXG0oULEsH054sKlKTxnKx4rl1cYfUc05FFsIWBG5Lnzpx7p6gWBNrb/FY5+E7IoVFYDIZO8PXdZlcg0WIuiXYtR1NFvk9vgH5RKTgQMDTE/07/+76zyWngPV6OaqwxI+9UbDfFnf+azGvV5aVMlcSWNbElGOHVSFbPJGzwJazTiynMUnUzwJseuxiMOJn6bc4Djbg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 827a42f3-a7b7-4d14-6455-08dcbea1bc70 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2024 09:48:24.1433 (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: ++e/SfUDIPxKVDnz6hjDSA4MWwqXJzdiCgAbjVjh18yrAreJmYxwR+NYPxxY3oiwywsyRNhDlifIV2vUS5WixQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4758 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-17_04,2024-08-16_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408170068 X-Proofpoint-ORIG-GUID: 64SJE5CeYWdLldsjMedtXExwlKzLmXIB X-Proofpoint-GUID: 64SJE5CeYWdLldsjMedtXExwlKzLmXIB Support providing info on atomic write unit min and max for an inode. For simplicity, currently we limit the min at the FS block size, but a lower limit could be supported in future. This is required by iomap DIO. The atomic write unit min and max is limited by the guaranteed extent alignment for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_iops.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 6e017aa6f61d..c20becd3a7c9 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -570,6 +570,27 @@ xfs_stat_blksize( return PAGE_SIZE; } +static void +xfs_get_atomic_write_attr( + struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max) +{ + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + unsigned int extsz_bytes = XFS_FSB_TO_B(mp, ip->i_extsize); + + if (!xfs_inode_has_atomicwrites(ip)) { + *unit_min = 0; + *unit_max = 0; + return; + } + + *unit_min = sbp->sb_blocksize; + *unit_max = min(target->bt_bdev_awu_max, extsz_bytes); +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -643,6 +664,13 @@ xfs_vn_getattr( stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; stat->dio_offset_align = bdev_logical_block_size(bdev); } + if (request_mask & STATX_WRITE_ATOMIC) { + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, &unit_max); + generic_fill_statx_atomic_writes(stat, + unit_min, unit_max); + } fallthrough; default: stat->blksize = xfs_stat_blksize(ip);