From patchwork Fri Oct 4 09:22:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821933 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 ECBB0136345; Fri, 4 Oct 2024 09:23:30 +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=1728033813; cv=fail; b=MI6BFsJ4b80oUT+KA2wgGk6N9A+7OG7w7sTwP8VBp2PAet5SGFUPKCjLGocv+IHXkL/ftmxqgJh1g1Q46ccA+7S4xEBnDwz/J7ruVdzoFRM04+R82SKckxsraeebAYiJDEXAH0+zKRkExAPl6Fp92rV+12+AOdWM+ciBLPmUdM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033813; c=relaxed/simple; bh=VYomgq7XPScT9hq7HFcQVndBFPpuoTrLVq3Yu4X/fWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ers25l72nSjFcIkFcnP9FgjyvktI5PUTfSgCWr/Vda5l0B30CiIVzbawIkQ9NH7tNihgp32meGE33/5ng+ywTMOT1GZkcfLC3OwwKFyg89MXFm6DRaYWBYXiWBeGJFbQpkBWC/eBXlzWo+gXeV545xedMtUn7rwAn/PLeKdInnY= 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=PueZH2l7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OQFNbddH; 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="PueZH2l7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OQFNbddH" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4947tfxA009097; Fri, 4 Oct 2024 09:23:18 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=XHBSpW4EsR4GoFQKdwYRSrTS5Gxr2Ae2VonrBgoXKcM=; b= PueZH2l70Chlsi2KVN3sTwmGRi3QpmRyso74MgsNMKqWpcnc4oY83Fc72rCzozIG LKqBSAZskesjcF/BV2+8o5BXbSeGfu3U8QuLJaLJrOxOcwtMeYjRtQArF/9KJM+8 iqc9KGcqCSBHwRR8pbF+Anobem8HHV2UzmHDXO9R47foUbbTw9NEjJgiZgznSZxS UfL2KD4jrAwAyCC5FKxTm3T9cfjcY67qBrE351eLH4d0hrbbzSmk+dxPhcxzJrDv Gl7yV1JVY2N74ZXfgXgrwx4rRAlFvXfqScDyNA8kzkwGiLd6FUthH1lZQ8gWSPQj e5YKoCT7lnz3/EM0ZhL+7w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204917xp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:18 +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 4948fmVP005835; Fri, 4 Oct 2024 09:23:17 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4220568vra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vVNmDeTvihUM0mGcxpGpxMWSDQigKovcP3uwfCO18axJtF8+4C8UKdEwQ+mQEKUHW9rVakaecDzaiZDrFy2vXk0S9j+/qhOzEo1eOZSpvw37++ldA5YRog9qQ9rxhRVEPaE7coszK2yCuki02lwSzVkP1dfU9dh1h3wqhLLhTz6g2H+MwjamGVmzxOSOjzzAhP+DKUUkTvkSTXlEmVaIcjVtdBllScONk/VayjHVxfdLbHaVKB7RxlnuCAhtW6LnftQnmSFhV0m7+JKLGUooZ0AP0hONovyy4+c5pkZ5rDOe3f+n8p2pbFeU6KSdY01w5rntsouN2PdwHfxba0Mq9Q== 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=XHBSpW4EsR4GoFQKdwYRSrTS5Gxr2Ae2VonrBgoXKcM=; b=y8PSIMUi+xDYy7LuhTNNgkCElvXrQDfXJn2XwPOq2rVE7lGH/1eho2jN6Y1H3GWCiaXf+BqJWZuWqLx5oNKqlAatU1wdVwX63DFUjEHOIZFtgHoAMbhkpALqr2Qf8gD3BkI6vWjNqWkyLXpZIax923m6CY2lz9uKvtLnpmu9m305QpCxY6qt2bMh/A6pj2wQLZlM06bpVuUu4zxF8PrhHiGMkxf0nC1ex+tjwycdnGkK2W4DEJBX8LFCatkW0WrSXoCay454zSRQhic5C0ji8U4zT60Jvpb9PV/rI/VWIqa0p/G8sjRyEYywHKFwSTWUnDCkUVOqArD5ntBfUvWeFw== 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=XHBSpW4EsR4GoFQKdwYRSrTS5Gxr2Ae2VonrBgoXKcM=; b=OQFNbddH49CyjfGUObUSncl9sC/9A5AKnACn7KKRxiYdVvlp9Kq1thIHAJ1/vyBqlgsGefi0KVNeDSLP50qvdG7AF6tO1gXrOXFI8QNEUFhFL6h9PBylwtxTjtc7iGsyU8HQ1fn36nl1gUZeCoDQW/xG4ttG0R/ka0j/KKTCXxU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23:14 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:14 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 1/8] block/fs: Pass an iocb to generic_atomic_write_valid() Date: Fri, 4 Oct 2024 09:22:47 +0000 Message-Id: <20241004092254.3759210-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0561.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ccbcfea-81b1-4ced-911a-08dce4562c2d 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: BjXIxm9mrXjTSxyKhAHpWdOrP/48K29jxHZFKeis4B/GR/Yy9aaydaNx7bMlquQjO9z/8ciKWG1rfuMRonbLdWXV8i14VDNpBB1znJBEtIQ0ZCMM4UDZA8PaDrldakf26ioc6ve+4/OPOD4q9o0L2JG4S7RQ+Osoe5CPuRgYZV5bCIVGg81cCC5ZBo5+5vuD+fGONN+onYApeCJoRuYjiN114aZ5YA3MfTzlvh12UoZFBPZ06WDF2gj4aTrvS1bwvPt//Ae9pGSo7JUj6BuORiWPjIZgrfF9k94q7zPtlwzRCWWIwhzcRZDn/+CUKUZBIRGda7J8FM2yzAeKtl6R2IZHU/jSkVRNfZWLgypdmjIKqVZiuFpoa31susZ9kve86DHTA1HdNuFL2uN76zG5NiqhGZ5WPubQ2IguAIZk3pyyordCf023h8z+eaCgfSc23xFpPheEPBSqWr9n/B2ZbcJX41C8/oKVRtDepwGz5apnxDHZ0Nfh7RR0aE90SSwnie7aSzHIf6gbqGntmnVXc9hWQrZvZWkqX45C/y7+2TQyO1obh291xrJT2i/ZEW71esM90r+BhaH4Pfqs10jplu7dOGrouPlChwYgcZrc77Cq6DeA1gse9DikKrMSK+w9MKDrlPZkPFOujSyybO9edJY5RRLTXDe/U1WCDNeu6GF150FHFCNopokAmVejZe8dqLhFD0epFgox03HVgesGApFImz8bCQXHcsDWsbL2yGOajoyDqrnN4mSu+KYqttCbXeej6XKagiPA+DL2fznbGxx0nT3HpgYLStzT/J3OQFJiYVHlAPl5Iml80evCUM1K/Ez0MZSgxYGdxBDnCpDPadiHjdKswVU5HSzYqYm6bShAI7rfKBmZlpSX3sHYPRlmgiwxn/EVroR7iAv93uScLfm7BxzC2mDejx2SaE6gL3y8AwfHvrfNFde5TCKtMNmPYP8i/qulheJJsTYhG4jo0h3f9z/HnseaHk8HEMiiq+Iffrdy1wMJ0hyfgKG3LsP3J9Dct01Tau3XfOoIt23QP72Zr6nlo1lg6iODLzJS0VCx9ZHHgJzss2/UX+gbR9brUydse6mFksXyzcTRfyCT/Alj3KW5yT9y9K35b/2f1JBqOMvkXgNlF/DCOOzfcAG7o5w7H/pPGZwTLyTFzL4nbEXnnOuOcwokGoknPIrQuzMZbon5drgeUCZNLgfU5Zc6tZa80JPFgqgncJnQKxWRFO4yilBSrujpHyNJfjD99/mXn99g/wHzMEXJya4uXHXP+IBhwbcDjIl/GECoI0ViDNP9nbJEltamcRLoqDq3YaM= 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zx5kt+tB2oFfYUNRIDEeWqP7dHCXPgoQycgYYcqzlgvbC8U+0tzWryS465K6BLiXfgd14fFQfyufCWDRgDnah+YvGyvct0MPbqHo37oewX7PSPIEDL7GhaIZSDF349Mt3oLZzbeVaYctp07u4EmuVN1srHwgQNJt8jnHJqhucFQNz6SCJ1R05jt7bDJMeZaAZEIDEtAEuffZ9sTMMiZ5ousQrzbG6kbQncpML8+8NO7s35jZyfXhQ2Tv6m0m8U7C4/XvDSvx6ug73003Rg++Ewq7OT+OScfQTERXwWl8QOPYw55ks8pRALa9G+zyJNOofMyJtmZ3uYO7AFQB3UYsQ0a3iZNnbz/VlZYY7blKw3zTPhqobBsv0auwxNlqj4ar65H+g922nWoAq/oX+5EZkR6+MYhPPZMZC/3GCMEx7hnZDE09IPuGLiXBY/XPzDHD5Q5UkMlcfATUZlRx8yg2WcX09Xx3l3LD9up6y5NPkcCq0umrjZRkAaP5NT7Ev4mrcd/QFdBUvzcIAPrHZbCrbgtjDnHLH5LuzUP9a9xO2DvvdC4yQWhMcJci7C3g4h+qwtTOZQDOmKy8WutcTI9qO1trpy6ghXFvwBixZWRaK4uHOmZMjvqJE4wHIJmLExer9ti7XKXAT5TURvMIVA/YJH/6LWDRCuY23z1qxy9HRz6X1mUlKIIHtv9P9GXB44gw4ras9OVbRiaCn4r7askvHYnOWwDDuYzSsKQnvEyuqbnZtJ/RuWB4CBDT6WrjhY5IS1SKF71taN/uLlo5cb//ZyV6E/HTvhsf9NQYNUImiXt44DiZ1+M24Zipie3XqzzvqBimLwoUlp2GHSgmikHaIWGMCC4W/jMZr88hn273BjqjoQfYOqz5BiX9i/wOn1yFWHHt5t0NT6z8+f0TAwmHR0OHEpb2RXvJmGLfWkSOnULxED9FOBYTeHcJUMdutN3JAHpzKw+j1XqdklQ6/Yw9v4v6CrcVvTWbdYVr+Hfi5/C8W+89ahPPcAwa4LKg6kEfjHWZMjclGQtC49iRtEDw9yCU8lkYvalfv+28UzhnqgIu+ulM6Ms89Z5iWlyY1MyVr1OsSgvUnFSqJ1zj1hUs6QaCkXYkZjjZKC5JTzvxa1vcnuSS3Kd9EbMHncKVRUiJF0406pdzfje7pOp77Kglyhr0Js8lY6NWXBL3xxpc763weJPqKWut32mH2IUPY2lS9Bjoi5tM58VErIFDtyIrayuCB/5jHdks0dnARmTppcENUaRRv8p+dO/i9XkXVEUwMhY0DjQ59wpPn3hxMS900+FDdvvsd8djEpzGmwU6qBztzH8Xoq+/gFWlu+FH3PCDjs4adlkAh90y+yjYn67JMCJX/D/nJasETW9s4cFzv+J4GV1D7OdMmuwg6RUVH2TnV9d4z5EWcmW764S99W5e9/jNjZVLos4CX2jtvffUUk8sb8AYmYHQG3V45ycpFunpl6tAjSinmVsHjmXY9NNyv60fSsS7icrihUTTlMKbYU0qhVYtmgsretl65nYQB91vrU7EaZkjlpHzK5HLSP9hhSsl7CeNxa9BFMiTAhq02u0w98UQNLrKvQLXntuci9MtyqLCzk4FrPFKbsHtUtN4MA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tVr2VSzYJiWreRlIIEBD8pRRqxmVuDQl03O2ux1IbOt3kV4qXOoR0pYWPyXQ5lMBXiIdKSHSKsVhcljYfIDynf4WV/yIAlhnqjtHtwvi/7ezs4fBYij8xJrYz+towOxPwcIOBTNvrTfDzhZIjWCjVnsy/+c1McwrYXcvutbEVDNzoIJqftosDW6rIbdMXOsP7mYuZV8JSDkyhw2LNkxdOC7okwyI88cdnlejirx6jvblvrTbHClIVRTMaqQggnrQjFmLJS6d9yuOmcl3FrGNeMp3fUICSmLlxMCY0BtvqnCIxmw9OiDZIpLTKGBIdqOrdwA4nMB8DdcxuwmxME42fs73HSIHb8xbU8KRO1s/od2gsws1BNoWC7ba2C5ie9YpnJCshUcT1UAukmfoxXaCXd/Klw5dTNs/Vg/dXwjQYRtZLacmtkkfH4DUnEIL5ocsFq7RgZfycyA7h86/pIz9pqsQ/PUiZIhLH+ReTVr5VUYp48+Hy9ci8DaScLRmeH7mnkqCgd3h1JpeB6ckJbwB/AmfwOsksuwbxWks7dpmpT05B8c0LU60rfBepR9hj/i3d7HcVFmwgmvASYOCsI7gWo8w84km5ZsLt+Rq+0iZj98= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ccbcfea-81b1-4ced-911a-08dce4562c2d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:14.1314 (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: 8SJV1PjiwDt5+u+Hj8YNr9V8pxMGr0su+Ge3Z2VgHrWpuiDlvSVZtCwRGM9H1Y2kerhjz5nPawMLRa2p+i1+HA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040067 X-Proofpoint-GUID: PbYhVnXpSRFmwPUbEB5ODjexd6_dBxJw X-Proofpoint-ORIG-GUID: PbYhVnXpSRFmwPUbEB5ODjexd6_dBxJw Darrick and Hannes both thought it better that generic_atomic_write_valid() should be passed a struct iocb, and not just the member of that struct which is referenced; see [0] and [1]. I think that makes a more generic and clean API, so make that change. [0] https://lore.kernel.org/linux-block/680ce641-729b-4150-b875-531a98657682@suse.de/ [1] https://lore.kernel.org/linux-xfs/20240620212401.GA3058325@frogsfrogsfrogs/ Suggested-by: "Darrick J. Wong" Suggested-by: Hannes Reinecke Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- block/fops.c | 8 ++++---- fs/read_write.c | 4 ++-- include/linux/fs.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/fops.c b/block/fops.c index e696ae53bf1e..968b47b615c4 100644 --- a/block/fops.c +++ b/block/fops.c @@ -35,13 +35,13 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb) return opf; } -static bool blkdev_dio_invalid(struct block_device *bdev, loff_t pos, +static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb, struct iov_iter *iter, bool is_atomic) { - if (is_atomic && !generic_atomic_write_valid(iter, pos)) + if (is_atomic && !generic_atomic_write_valid(iocb, iter)) return true; - return pos & (bdev_logical_block_size(bdev) - 1) || + return iocb->ki_pos & (bdev_logical_block_size(bdev) - 1) || !bdev_iter_is_aligned(bdev, iter); } @@ -374,7 +374,7 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) if (!iov_iter_count(iter)) return 0; - if (blkdev_dio_invalid(bdev, iocb->ki_pos, iter, is_atomic)) + if (blkdev_dio_invalid(bdev, iocb, iter, is_atomic)) return -EINVAL; nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1); diff --git a/fs/read_write.c b/fs/read_write.c index 64dc24afdb3a..2c3263530828 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,7 +1830,7 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) return 0; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) +bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) { size_t len = iov_iter_count(iter); @@ -1840,7 +1840,7 @@ bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) if (!is_power_of_2(len)) return false; - if (!IS_ALIGNED(pos, len)) + if (!IS_ALIGNED(iocb->ki_pos, len)) return false; return true; diff --git a/include/linux/fs.h b/include/linux/fs.h index e3c603d01337..fbfa032d1d90 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3721,6 +3721,6 @@ static inline bool vfs_empty_path(int dfd, const char __user *path) return !c; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos); +bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter); #endif /* _LINUX_FS_H */ From patchwork Fri Oct 4 09:22:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821937 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 CB6AC146A83; Fri, 4 Oct 2024 09:23:56 +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=1728033838; cv=fail; b=p8hvVlp55m8TaFF7+e9EYUIB4vryWYdzZUXTUaNbxxauqi4fdkRYQVJ2BK5O/hhmX4V6fvAT5nMJoS//debR4SIRj8zqFhrVGtWeQ/XyCIuT24RzsgcdnN4ert3r8iJKXDpmA3Djb9Z47kGlN3sEzgobdiYqsjlmm5m0YcfuRsY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033838; c=relaxed/simple; bh=TAzP37++hmpuFbFVQkxSu2KA0N+1Jo2Kjhez6BFPptw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dNyeu++l02qsjiAKUTRaZZIMrr8EIpA0aGsgWmwTdCpASCw4UhlUwANpC04y71TT56BR+Xp/fx2O5WVf/oWKF2MKvHfff48JRglXxYc9ivMuLq+AYmG2gn8fPNqVi/H84IbdnGptacKdxXfGJVtt8u71xVOp2/q0QMJXIqjK3+Q= 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=hOP68+aE; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=HcKJU7dw; 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="hOP68+aE"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="HcKJU7dw" 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 4947tmlu028984; Fri, 4 Oct 2024 09:23:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=SEh6EgqhI235SAC4ltz8P09XppVss7GZT57kJx5LopM=; b= hOP68+aEaJWv0JJ8fD2ojgasR0bqMKcxXUfWrkCAeF2dDrwAN6BByu28qHIh3cT5 b75U6At93WrxN6VA8JgT57c2SgR68QICurHMk1bbQw55+lLqMv7+KoBU05wj+kT/ ghdl+84KmcYyYqoL4MybMrXfQGV4Z/qoQi8+Xc6m3UYjY755x0sa6jPFUcGglmzR jjIBlkY3srVAtCdIO+m9xkkSj/wY774GF5DWGYIwP7Owy2NcEvhj/NXUFh8RgMUr vpXQcBnNU0ENEwJnMdwbE2KT7ldvVRs2nfE324O4nF6T8n93IGFsRbE+m9RJdRH7 JtKBI0SlHTZkKyIMke3MtA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204gs6fb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +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 4948oNYX038396; Fri, 4 Oct 2024 09:23:41 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4220550xvv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=paZerGR1faimhIVpG/8KqXiTdQETdIVVXikujCH5O5r30eqUsxz0PheZPE7SpQKgK0uQgziY3sE8Wdwg+F9F4mtrRIrSJnOEfERsysNGa1RA3LEL6R13IxK7JDDQwIlJLdsOv+8FUSq7URY4nFYOpoukSKhQgv1YG9gowIhRnNOEnosu6QJb5R4bsXdE0Nq1heZJgOIMCOLoB9brxfT6Vw5d+CWguH6WXcDB2IkN0B5RmB+8hDcxZPqsj9Due+RK8M6qW7izgTBDRL24RuwpK9cd0z43XYV6Ma0akGQVBBICvlHXExlwsGTqugIyGF+aeHdZ6nhBh08HskdJWLwWRg== 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=SEh6EgqhI235SAC4ltz8P09XppVss7GZT57kJx5LopM=; b=l0KU539sAYCWA8Gfjt5pMr7A2zNBZBBxaXwHeGSWRvxc0bifhl+tcx3tUlmsjUVlfJBhq65zMaA/f337/8reEZEW77xm0BE6KDVAJp7k6jKZuRWl8/o/V6yUpjl0SQtUZEhNloZBLIkA4vuY4U7JADnHLUNgbrFq+RFKxccigSisAm5VWkuLj+sOGWz5rR5/CanJhJMT+u1uQmFlDURTi5uksHlxInPmkLllca8Rdlixt2nrxzm0WTkDx/4mYqC8bBwpyAjmv0FJjUo6brkZCcc2Xu8wdKxthtOO/qps7kFv8M14wlRdCjvo58dBGxFTY1rCk2D1rfjNtTyn7Jg6PA== 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=SEh6EgqhI235SAC4ltz8P09XppVss7GZT57kJx5LopM=; b=HcKJU7dw0n1PB5T3JfmnQDOz3jDie8p5JQl73TtFVrG23nqV9dJb+bpJbku2d6D5/DKMEae0xpPdKbst+xIKpkjWbOeiNebY3TApaO+bjkSV3R2cnWSKH7YzGZ+OXoBfJldzyz44tuSt5fKK3RrqyUPgWLQY+WmhH3YVqaNYKJc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23:17 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:17 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 2/8] fs: Export generic_atomic_write_valid() Date: Fri, 4 Oct 2024 09:22:48 +0000 Message-Id: <20241004092254.3759210-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0566.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: dcfe748a-33d9-4a05-2753-08dce4562dee 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: dOOJjfXwOQ48yRICC3vlG0k62ldVJgIlPvrjUdJ9Y9Pi0LhwcobWgC2Mx1p3jKWVbdbrW9VIDQmU/m+VyN/Y9lJHBsh3CbLJiM7UowN6Q/0nXZNFrF3KgfxYwT2YqJNkSGlzwqYuiS77alM5dMAbqTmUyJrs0OFLydXNOF7Lj6yzRzIRK1pGICurg1BFV//kSVNiFOGWIEAtCoBOELgrRBlVFty/C/3pCD8P7v4wa9RU8RU5t70n25CthIEH83qDpYla8tZqbODEIE32YVsXrBz0I5t36kDyymMozXvw78NeNHESn99w7HRqtUGvStio8tjsK+1eMP2PO6caoQJX3oeVLsa7oSpDcGXjFbedWJ3bRhPocyvNupc4LWv7yhI9kkKICqp/QNfLGs5TuLwHG4Lj2UUtC30a2Yr+zf1y3DUIF+Gj8v0HrqAFgUdfn1WzjC9DTwpvD+6gTzWmqZ7dGYeqdushs9IGmlpXqazLoz7VSabOYYiQtw6eC3x0H/kpdqOScgh7pLJrLiu3RqG1YpxhjSqVpnlCYakJwEHz29UUSuEBN+HdqaA7UP+SXy+SuUlBs+SG7mO1FDXNOpJU8tkqxh5EI24eCzc7qtdu+juy8nyt5T3D5pyR+9oHpYfpYiGreFxm8Jjm1X/Ohi8tdIulDehLlO6kTs82gkOM81aV3aSR4P5y85IRIsWzzIJ52OhIpcjXOMZ0F/8hL+UO/xvOF9LHmVpvhnMy7EZ1cQuBGN8D413lVt+dRdDNFsmEVrCkwRZKxzigDYd2kDEQHOwOc8EZPDGBCKBMOlOV3DNm7OkkXWewoDMsXvvdB3DYrazGbgb/u4D6qUCs3qcDGagbfiEfojAI38H/dkB19mCxg3WpqIUUxBkVOjie/DkQrmJaOZqAdPpjRQn0wrJ1GlGGv3wZ1xIrcfWWqZQSjnNXnyEwBP1jgdhut5+1wMkfUgWvUH4NhO3EZp226GORC7hjKKbGks05AzrXYA8adQBZrwHT6F6jE7baWTtKF5CbybX5BPR6wpdoxbBVcbQt2hJu2rLpj0IzKuCXW+l06RuMM66Ta2zTBIsWLhxjB2XP4wv8R2dsSrVJXWH78TZtQ6JGMXkbwouaiLNZUjC8A4bJnPuLBOZQL3LsIuNEp+CYCHkKcYosk1NoX6pOlQ6pwAdb8W+ConQ84Z0xqBv1EVWvXkVB4eJi36vsH/IKFgF+WuBlLismQeSA9qK22Z3eda1N2HTPgy1FPbbfQ9Zvc52Xv+Cttb3aqeYXCzIVqwA+6u2XRgTnR6QKR9GuGaCrnA== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SrXdCVzeW50dMYRxwyclEVtixdrhYOCt+Rlc2MPhqRp93P/OqtZ0IjVuWfsip5ehcqz5y8rC1FOLg6eBycSXO889v17NVIS6x6Rdjmy3fwj+BAMjkxM5KBELV9SE2SklZrBvKFLRJHs/Z2U8SkRektnxNTQudnxrXzjUKJRo9kAvMKG8XltzOkA6nFA7++Cm/wtc9/dGsgHrHuibLDBFYEAUpXAAnpBs2pprkIpt+F8Kqb9W8v8x1CBFsK3fA9h1/yTDot4rTWpqFaptZHS9LvUI4fDk7vK1dng/E2C6ThZ9EcCEW8TNX92aiveLUvf6ixDngZf29Tyoxc7tybwFcGxUhQH4FC5WSKTKJhdFEd9AJElogPATDjSrFZMYzDFUOZI3lUJGhQC7XgTpFOF7Pgo3UTrKPAU5Zjg8JqEDRVmjGOfY+Vvphqm7pdTkWRnOO2uLpEdUpRVrPT8rr3Koepoj2YDWEq0fM0DJFJFw7oE2MV9mRboRuZNAM2RI0ksbaeGyJj2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ByR2KrUew0HMu5k8/AHHlpcGw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: g5RtjU8dxgXfrCH3T9HZpcyiDKNF8SNKJGA3gDI9lVXue5jo2F/yvpXFbJvJpMccWiz9KTC9WVKfJeTIKTDsk6FhnSlVK16smJZn26ftN+i3DonQHMv2d4+h4Vm46EH495AuukJFDD8lj0stO1cO8LJya/XoKGic2kqX9yTPPJwS3FetkKHyrSj37pnKjIsU6nyjdPmGesFFxNgtXSW2DrtdjDcIqT0JW9r7y57ubHiaYkBG7Ek9Vxk97sIbLeDgyaafxr91XNBo6bfCTqcLI7f9sHLTxUScGDJ4O6pCWQ3LckrFmiteFFmW/LfFW40EUfjd8MSfGYggujwfpnpTFIdhhhflfGm6mokA3ktZNrR0sXw7hoiYSq6xRnQd1GXZ9k9DyIlL7kr7tRVR34hB5JFqVabPT7vgaxpiXQVXqLMIEsShqW3fnQZs7aII9zJqS/6LMcOirS5o1tSKfoQUUDgFTPE+BJSCVHk4ZIsndYtWEuLk0aKFHWjmpxWf1vCzeOmFP18BTZ1kruGOGUwqhuEWgIqGCNeg7tjzsBY3HyOIX1JFotGHJr4TQ/xkcq6L5YhTzLySJ3Nis1TWg5+WoMPs2eJGyzCDOEih9VkY6cM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dcfe748a-33d9-4a05-2753-08dce4562dee X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:16.9757 (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: XHdXGPL1Dpxxxa95mYsz9+jce+Q9hO8Ll1RtvAyoJIGTQbQJcWNVlsiu2F0dE0Sj36JJmTFeuyZ2sa02JWJNVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-GUID: 22QT53WpdFqdCgimkjCfQ8aNBqBmumHM X-Proofpoint-ORIG-GUID: 22QT53WpdFqdCgimkjCfQ8aNBqBmumHM The XFS code will need this. Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- fs/read_write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/read_write.c b/fs/read_write.c index 2c3263530828..32b476bf9be0 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1845,3 +1845,4 @@ bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) return true; } +EXPORT_SYMBOL_GPL(generic_atomic_write_valid); From patchwork Fri Oct 4 09:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821935 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 8433B146A87; Fri, 4 Oct 2024 09:23:54 +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=1728033836; cv=fail; b=TZ0u/tiJHrS/UbujTd+4SoLH03AmVV7GWaXKBP4+EP9U9VUr2Jpk7FPIxDcD1aYdw94sOXDMWfU2Kg7YAtbz1uRc3uCJvM8Qtz8dooRglgjzTMlu3SV601+2/z22oUSRLV5yt4NFC//tY/9bedzQEbYcc9KwTZPxLUBFIrZceos= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033836; c=relaxed/simple; bh=lGNYrri/HJQPWknfrvKz2k+CBLT4mLEvBM9QExasZm0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=FlAhE4EJAoiJZ7M1PM1T+15bJBT/ZuccUXumqfRdFEjXoKUteBpugkswez2vknFgks373KRHJ+ZKmRk+1QLEBKzcniG8OfvVQB3ALoRutDW3RZnDjznSREjZ30q3qa9ivOnMYuB4psT35Dvl7HnipGnTGhINZSri4kf3Hquss3U= 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=PNYxxMSM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=eUyBsRf5; 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="PNYxxMSM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="eUyBsRf5" 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 4947tfDo020700; Fri, 4 Oct 2024 09:23:41 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=uupbWVuUYeTpbKkf2Bdo7HW9s2UUsk1y4e/cYsxtjUk=; b= PNYxxMSMMqwJJGJTxfOPCt/d58v4wX+8vjFLNXUAJXs0vfcTCeobX0jSkjRiQZIL 8iIsXUK3UXV9FjnM9J3mAuC7I/NfY/WUoM/t8tmXNT1F4rAv9l6N7J4y1u3QhcaU ohg3a2xsUraGdAw4ttp5hvJ35lHVBwx0qnHeE08eKXSMrLYqbTHotebPUNd0hK2r UdRN65LHtmUiPFRIK/Q1jLo508ZqNjMOCOMmaL3K0mKHZhjAre2K1egilOJ6AOi6 ZVJjQTHRwtk1OLwty+Y19WeFkQcl/aicmI9F+ry11Km1hlUr3pfMDD1GOHQQgYmR zPb5KbbFazDOEoo7McHZsg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204996wc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:40 +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 49495IE4038110; Fri, 4 Oct 2024 09:23:39 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 422057118t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C7gkixfP3gLcUrF8qe6EQ739+g05uyOo4kUCsLm1eUxD9HCFVxKsl38+Ebeu/T6sM85BaRnpB5muyFS4/9tJo082230sSiipLckzOUzgPDVIzhx4sa76uRLYE3fMsDISUhQbX99LlIgM7ldAmIJKd/ioVa7nOv1htfflKe4LfZ4pAtv56mRlAfHYS0rlGF4n8z/UOguGdKhh9uqYI4/dyIvcv17LP6RnB2oRgqKEJwrQYGmZIhm++Ktg3PJpXNDSu1aKZi9hmqXUwShIDkQ26j4aKGnUUte3EuEiWaYwphmKHxLJSyq6csBeN8jqS2ED5FMkKW6lBPsmulaB+yxxRg== 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=uupbWVuUYeTpbKkf2Bdo7HW9s2UUsk1y4e/cYsxtjUk=; b=DtK6+3Lyz0whneLumrLLBMUbhv+fhP8XABNUSC948uw+k6L7QDEY7giifJfPqVRMTLwmnknwaM0E+8HIlesf9xOY4pBYRaXGNRQ3WMV4kgiTSptqQ/GE8HlrvtKPCC+Op2JecL403c0Y3DDmxwtkUxG2Pw0p3lmNvssE0vPxvq3TObGz84umCSJdFiG6uvXdhrsh0SeInJFAxlJZ3F0LipHT5L/8S6mnbvMQ2mO2WhTW/rV5Wnlb20F/DQxldHNyNXLTERtCg2eoXnmep8rD0vcCxorg354+9saJHheccSi0YGN6CiH9fAIcWwzEhfDcmVdl8ZhsKwOXx4UaZCqUGw== 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=uupbWVuUYeTpbKkf2Bdo7HW9s2UUsk1y4e/cYsxtjUk=; b=eUyBsRf5EsSqo9luzHFaPJQ7Acvw3g/NKkldbj6VE3CV1qJHxTBEDqWXwzswzhHHSo7xvrfshKvoqql6ENR+lo3SFuPKbP1u5KI9EQ3Qk19xfu9zYnZIxpMq3Xx/YevbYhevwCBjZUytBisl1986KikdPVwj+00eCkqRDXUhBD4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23:19 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:19 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 3/8] fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid() Date: Fri, 4 Oct 2024 09:22:49 +0000 Message-Id: <20241004092254.3759210-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0558.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::14) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 0495a590-fa2b-4278-621d-08dce4562f97 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: 5rCHPZjqaQ3gcA1tuWS8Q5vVziXHT9BhtgcgE0i95tb9AhERj7eV10UDOKp/i76yp8yNQm8FmPO8nj/u/KAOVxQQPwM8HjuOQrYV+k/2oRXCPQqZZz2Kii2ZBJRNEPFjmSICOmq2RTs4waPK/REhMF0LSKQ6GR8oCmVNzCADGjEATDdcHvIZeb3fogiTsGVP7wO7eSRBMJwnZr5LCHnPRjosD0Toadphq3y5Io5P37PDs16FTD3UYwVVjtcLIi7m0r6b0AtOdgd6op32DJjDUG6RIKsFxNM47tLGvaM3Q4aG/1HAy+ZAklnbKRAjks6r7neRYAKoCkMK2Cjr6F+jOqXW7/JbE/m+rZsv3DPoSbAYpR3Wc40AlvrhuNONJ2Lve0S2dBITZfJTxvpa49AuWhOb6HKjd6bpWOM5BZpOPZk1GO4NLnLDI6C6HI//oS3r6ZfBgEgLSLdY1FCV9eSrFJ4N0H3X9mmlr7o3ZHM2ZcNagI3y1dAXYaP0+6QVLIlFnjdTtX6h1A8fCG1rp74XsAoWOqQyvc9nvoKZQEfbVNTxj7Xd8B340AfTJwEy3Qt7cPpqNvpzTfbGMvMH1Kf2ssjZUG/cKJLnzm1roOwju7HV0PGjWClFy9wWgmmfBKYLc+6tBejoeGSFgC1D5p5Z4fMZ8g3BCnZyAmLNXscVVzs4M0pgc7KkVzWubzuHYnGgjMVghmFWhzc4MwZz8jGPMHschWWqqiZ2XjOWxKKXUhhTVPmbKKFmihDzzfgzU9pXbd7CBfIf0oHVh3pHXqKY4slHm1132YM5T9vD0APDo322E6lbtXdFPODii6eQuLzhyxUgdDvdJMid5RPPetz7K/Oqm9KNrEjblVArnsoR/+ICF7JiqIDULIV9SAYvYRQHe2bYfMdDIz4mji7N6igcuxk1xqFH7AJmYceQMR9w9n+OQfHv8P6TztU/jUTxnREyUUgdtuXVFRz4oZ80yQnYFkiv28v6xvOvRCmMtqluhA0QOys3pfxuqg4QQv5TB0IF6iy/TaiwGMUtDpgk7hSV2qvdCorHZS7eUgY0J1D9XxqSCtWfmj6d6XYQgBb4gHMWr1PRu8c0+cCdUD6RxfRIn51k+RGFvaz5RFT4lNF3UBRJyBK27KzZDqGl3d1dSO+o455YZR/za1L1LvZi2iI1sG5nJg0s0axATofP+pYg1UTdEA5mW7Su2GkNp90iAyxdoXtpY66YhtksCNf46sSooxvnHl0jb+EWe7c1D626oqRILfrXpygLnf5rWpqtUbUN25zDttZLehuGn19XmF/HLw== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0E4jqGLrfAkft50Qav3Vr2glt/KubXNJCx3/Hx9J4FuR3yn0kTb6YLjFlrxE/F6h1YbOThvxTOeFy0ZrjDTCDsPf6WeJzwtG3QDGqyFKTeqTaqbl5W+MRTMmq2DZ7CehYZZg7shbJMWkJHg/iHEw5a2UZeYBjQ7vCLeUGiZgY13cWBLFYmNAPbFVUIRyny5fq5R6DX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59VuixSyiOckg8zezWgGUZVWVCW/SBhzjUfbHusUx+crX5GQnqrRzppHy0yMJmR2SPg4ZFZtHpv0RM8JilROkFGXJqY5RuQdYAQcd52lF1hoj+IygUayPBGdIw3KcOqTeBIDuJg7iXXjPeQB3VqAdO2p6C5HhrRx7RYPeDTN/+CLV8nZfpDSOjTAQyZYMVyzy22dy0ktiC+oNtv/R4jyStMo5NpXD4sFc62VONC4d9/rBiJX2WIt7X6qxsUM2t9MKvnJAwd7qN8Cq1KDTMjk4SV/rwHKQQCnfuC2A8WRfhspOrqxq4mkBe9/bgbAyTPzVx/rmTzta3S6Mb0rEUXp0Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WcKSaRCSmjBbZe5BrnPemIc/m3KXFOFG9OiIObzlfc5OnlfSECAJDZFU5lc8n2b3w8czIbg19LouhHnKqiWgeZw2CMMaReaWDCCmgZrLaH/JcWHt/qQ/wt5EY+9TPekWgvG5L5r2aO9GNXxbZDKdZMPHTRZ2CjABkcIT406C3Rw0izxE6Sc7q9mBePnxfiQY1egLTsC3XbaX4qG4+a6BPX1URgnyP9j/3LaQIU5y/xBvcFSiw8DSrs0X35LbTV5ttEGTycGboYhdL6LmEIc79IHrpLCSXs3cQ6nKY7iJ3px7rKuC8nDafnt/rXuTevpBf/XGob0TQSYtHsMYr6uLKBpEmiJNBMA3N5knKj+ytngTo0mAn31UkEJ/QXL7O14A2b1farj+ANfyv4p0YjtBVvxCqKPMxRY4udedPboGq6hmn1LZ28FSE3GiiA72oxdCoPW8yk19MjBMRnLyYkZ6gmswa/5f52j4vYqu12/eJoqdu2UtRu8NBcOwjyNAjW9FsjDPk0+A56q9SFFYn5lGYtjBcYWak2y31YYscqxbDRPNGEp4sBgmVS6gHo3XaYbfOZAOB4IIc2mbyvf3lVPa8YPetmGqfRNfab8gXegjlZ4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0495a590-fa2b-4278-621d-08dce4562f97 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:19.7492 (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: uS9eo8tM57NO0Yhbff8DNJhGyNIZVfJcZUwrIqjwA/JYv1LeE55VjSPUV8ckMgXJbsHBs4Q3Cyg2yUGObP2H4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-ORIG-GUID: hRNdTzxuEKJShvqm60_uDONfFt0-CeMo X-Proofpoint-GUID: hRNdTzxuEKJShvqm60_uDONfFt0-CeMo Currently FMODE_CAN_ATOMIC_WRITE is set if the bdev can atomic write and the file is open for direct IO. This does not work if the file is not opened for direct IO, yet fcntl(O_DIRECT) is used on the fd later. Change to check for direct IO on a per-IO basis in generic_atomic_write_valid(). Since we want to report -EOPNOTSUPP for non-direct IO for an atomic write, change to return an error code. Relocate the block fops atomic write checks to the common write path, as to catch non-direct IO. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- block/fops.c | 18 ++++++++++-------- fs/read_write.c | 13 ++++++++----- include/linux/fs.h | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/block/fops.c b/block/fops.c index 968b47b615c4..2d01c9007681 100644 --- a/block/fops.c +++ b/block/fops.c @@ -36,11 +36,8 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb) } static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb, - struct iov_iter *iter, bool is_atomic) + struct iov_iter *iter) { - if (is_atomic && !generic_atomic_write_valid(iocb, iter)) - return true; - return iocb->ki_pos & (bdev_logical_block_size(bdev) - 1) || !bdev_iter_is_aligned(bdev, iter); } @@ -368,13 +365,12 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host); - bool is_atomic = iocb->ki_flags & IOCB_ATOMIC; unsigned int nr_pages; if (!iov_iter_count(iter)) return 0; - if (blkdev_dio_invalid(bdev, iocb, iter, is_atomic)) + if (blkdev_dio_invalid(bdev, iocb, iter)) return -EINVAL; nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1); @@ -383,7 +379,7 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return __blkdev_direct_IO_simple(iocb, iter, bdev, nr_pages); return __blkdev_direct_IO_async(iocb, iter, bdev, nr_pages); - } else if (is_atomic) { + } else if (iocb->ki_flags & IOCB_ATOMIC) { return -EINVAL; } return __blkdev_direct_IO(iocb, iter, bdev, bio_max_segs(nr_pages)); @@ -625,7 +621,7 @@ static int blkdev_open(struct inode *inode, struct file *filp) if (!bdev) return -ENXIO; - if (bdev_can_atomic_write(bdev) && filp->f_flags & O_DIRECT) + if (bdev_can_atomic_write(bdev)) filp->f_mode |= FMODE_CAN_ATOMIC_WRITE; ret = bdev_open(bdev, mode, filp->private_data, NULL, filp); @@ -700,6 +696,12 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) if ((iocb->ki_flags & (IOCB_NOWAIT | IOCB_DIRECT)) == IOCB_NOWAIT) return -EOPNOTSUPP; + if (iocb->ki_flags & IOCB_ATOMIC) { + ret = generic_atomic_write_valid(iocb, from); + if (ret) + return ret; + } + size -= iocb->ki_pos; if (iov_iter_count(from) > size) { shorted = iov_iter_count(from) - size; diff --git a/fs/read_write.c b/fs/read_write.c index 32b476bf9be0..3e5dad12a5b4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,19 +1830,22 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) return 0; } -bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) +int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) { size_t len = iov_iter_count(iter); if (!iter_is_ubuf(iter)) - return false; + return -EINVAL; if (!is_power_of_2(len)) - return false; + return -EINVAL; if (!IS_ALIGNED(iocb->ki_pos, len)) - return false; + return -EINVAL; - return true; + if (!(iocb->ki_flags & IOCB_DIRECT)) + return -EOPNOTSUPP; + + return 0; } EXPORT_SYMBOL_GPL(generic_atomic_write_valid); diff --git a/include/linux/fs.h b/include/linux/fs.h index fbfa032d1d90..ba47fb283730 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3721,6 +3721,6 @@ static inline bool vfs_empty_path(int dfd, const char __user *path) return !c; } -bool generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter); +int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter); #endif /* _LINUX_FS_H */ From patchwork Fri Oct 4 09:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821936 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 E92ED1494C3; Fri, 4 Oct 2024 09:23:54 +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=1728033836; cv=fail; b=lRm3SPrPuFjatxiZhcWWyGo4Ey0nGbUTEY/to3mZEl18ZWDzosdnH31zx5Axl2Ca9y9nhH/RwhnyL5uoU/FLGLVf9s58kv6AVbhfTRmlG15xjr6ChmH6gE+p6DiBw6NpHdUz4WCRJ77G3tf8CCKd5rEB5rcX1I87VX9M3meszfc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033836; c=relaxed/simple; bh=m4fx0+cCtC52nY4lgOxPzkNwkAToDONzLOcOPTArYK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pKuIIdY6EOqv7/nPUif1vJnRxa/FRMkAn671+9VLxQHThxgloIIGrnqJIrPtEIILlBpA+tWaWExqDIH+ftTImyq1gfi9GXA3gltpnOk69MXt3fbyLs0WJ7uOT3otgBhC+jirs8qPQRNIaQxIkxzLCH5OuGlE4xnOQW2orRWebPQ= 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=hVssqkJr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=WWVynBZ4; 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="hVssqkJr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="WWVynBZ4" 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 4947tcAN015023; Fri, 4 Oct 2024 09:23:41 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=oPSQkBKXTw/U8/Qjn5+7yaMQ+m34nUuJMuR5LnQyssk=; b= hVssqkJruoqk8BN9Iw2n596mIbRkgr6nTOq8bUySxnNCDcKw+SE7Riv94bjuKoiX uglLKkuyyzE+ED7FSY8noxWk/dmRlmIkgmqhf6nLlPylfejurdDnwROEUMVCBeM2 YmrQdhB9t1LkvmfOArbL6vWksu2fPPl+Stk6MxaamuaJUxmbSZ9EidFzTlhG0m0V gMYsE2YcAg5xl0PBpO4dpfeMkDoFEmIlLOpsdVRNp1SsXc4NP4HRAZ2n0VZJTxQ7 AG3o9g2shkI92UJl3S92+GL1P0AcbfIiRYKw7h/BZCQFjCkwEuF3Q7k8dRyHPdrj Cw7sOPs1B2K42NXyIZ9ngQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42206m16dq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:41 +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 49495IE5038110; Fri, 4 Oct 2024 09:23:40 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 422057118t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QMetLCU2V61ILkNH24E8EaT2jyUdFNMXQkUnG6ezonqVpANz40qb3HG5nAYx0uDCzhJLqMq7WhbxSrjn0iTMoNn+lK+mcLDqyeAkHM/93qvfpNg0bx+Ua2c/kd/UGct/hT9UfB1SbX6XcbTJFxBdI1648vqObv8MnKmMLyp8PXeJQq+TQAh7tpyTci6sPfPs3VD/EfQiugiOqrmqAySD+u54hPaUleE3+MR7bOyTMkChrAtgeQR4CyjyfyFFsztJyFHAwkMaahmg+vZSx8cx2UB86YgVPaR3Z3E+dezrqI6QL/flBvKW52pH/f9b3/Qz3DDjgKuqAjN8P7pdcV4j3A== 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=oPSQkBKXTw/U8/Qjn5+7yaMQ+m34nUuJMuR5LnQyssk=; b=Zhz9e82EDPbqmdatEL42uMZCAc1AjxNqtiguCk5Cin+QhTN/0jLyOOEHNXFLy17OjihQZAA/9WTF9IiI23yA4NtMMTyp4qtaUgxvB3R2mafHpQsbW6TYUCn1FXTguiF0I8BBOm3DAY5rkfoyivrf8vwajvv4c0QqxxymZm+3rm8+B/YrAthHPgLufXpoWLYsr9xIlVftkuCvbZsJojeJijEmS7FfxiJFnRYtR4OHzQ5NEkgm66R3AwuExa8Dwn1Eya0mn9+Z8pe/i6OwqVnnBxBsrfQ9WGqTkqHmw7MhKZGHFrVfc5FDcXhI7GPaXCgjBZM5ZIt0UQ8pOk1axpl68A== 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=oPSQkBKXTw/U8/Qjn5+7yaMQ+m34nUuJMuR5LnQyssk=; b=WWVynBZ4aKuYGj4WoXFQUzxQ0n3cus1p2nKSI+7xqJK/ht4L+Pj62DBf1WG3vpnzaSaRGzLUW2W8bYT3gJjdA3Eg9VUBV7M7pxbuel929S+Kxed7fJJmK1VNfLN/GYHtMmzgL2oALBghTwmifZbRnd24Z4RlSa81tiymBB+QI2g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23:22 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:22 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 4/8] fs: iomap: Atomic write support Date: Fri, 4 Oct 2024 09:22:50 +0000 Message-Id: <20241004092254.3759210-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0198.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a4::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d40de6b-4a0d-4656-eec7-08dce456315d 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: W8rBRgt8l7S8sHODHyRxp4PKJyKXXwP1a6/B/s5+aGPqeKODnUCMiIDkXGDdYR078aoEd30cAfY/GUf9iQqSK6HXbNFO9Om7bGH6jZtVQuA5p4To2tIPklmyBYsWbFR9IanwUS0ZoQ6KdMcU4cqZkCtR/FmK66yYwnPHISqMlBIvjnLL6NXv7bLuGDyJutfMsoWn/WEQcbvrKKRsZGutJclgX4httxyC3gGQtil5b7k+fopWIR2fp/JmouMJHNe0lcRo4D/Mf2Vs4g/G9mMUw6ZoPaLM3wDk7mL0i6zATm1Gi0Xv4010usmNaN2x6k1rqsrieAK6efPuHELoQf4oLXoKv8QDpEZXUIm7lCPMWrEvFInP+y+XTDwVGj5vblC5UcCcKPa6Oi1qiqmDiACBI3ovBEvaFauv20VC/1Whq8FL2A3YCoF+hVL4E3a4CUH6qdiKE+Ig+TRGvcyLxuKMaI2TZfKOf5OriD8uV4/JzaArC2+boufftrHX69Exd74cFDsUwNJpqJrje472XLx8otaWCgoYOWt39iNS5BK4aHJ1KLNw74+m+RZKdWaTnrikIKzVV6+B4DPiUssxHHNQ2xJ0EwK5YWV0vK8W63XC/nRdJakyLb/upRu5vi0mWiNlkwcO6CqIsuO1mD84J/xWK+fbC7O/hT6wSONVguKYSHgEQfEgsyzKIIyDE9QvSYTq4Jhahgz54HnMODLf4HSlT/dDDtT6Vi12SjQVjxMb7qgPaUB91n4QiDDUEYTUFLF7JHY5mt1BDXS/lzIy+Y9MvV6hWp6fCftw5B8ey422l/9I0XWN1LQ5BdjhVs1amS2h0YP1IKRihiGLujoaY8g0WAcVGAlBHns7oBazO2VhHrK5MMnnFa+LjWxvUeZrIiDBUirRZAU8ui170sUfEynO4wvFRapgjjplKQLatT+ShnzEMbohy30hzve17R4SvJw/wfmVsegOLUAmguT5TGeVURxXgB31d9YARVpjgTXdsLlUp6b6C7vh8SoKiD2sJQp52hi7U8p8gUOb4uABD2MHi/xjeBYut93eyLtfJQ0WNyHPqVDcL84O92RBmoFS+HX8aHO0yRnLzD58c7tj4Qou1NhO96TwCow4FU0BvdfXFsDhJqO1Xl6Db6/gKp5j/mHXnNIzA/mxzykZ1KnqQ5QSElPxaKcA5Tp2AcFNfj3MgXKDbH9Be9AUZF+EhJKlujDku3e9yNN6JVMw61a0bcVXd0FYlfGoyVSDhK1vRQhP3qOdvxjq1fIu/CSYD7jDvK/zcM/IK7C5J2rgUOTIVmKtyw== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GC8IfZnXxRZ6nm8ugxvn4Z0TbltaBbaqmz3pYm7kG8kDU6EQJLguk+1GCJDm+Mn3apSQ+1HoVnP3UsmCDR7P05sJIiaQvsTJluzw35cgLE7hPr1xJmVWJBn0HACvIn1NpqbeuerKURyLAHC0K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-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d40de6b-4a0d-4656-eec7-08dce456315d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:22.8372 (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: V94kJ0FHaC7d6gDwZ/FO/yhhn4//KmTRkZ6UYZyLn4UhZuoQvC5Tk5mxzzK6OwlNGhTYvXj4S4Yfeh/LhgdEnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-GUID: qa-lgDrQvb3pRkv3gZghMqwHwEh9llVo X-Proofpoint-ORIG-GUID: qa-lgDrQvb3pRkv3gZghMqwHwEh9llVo Support direct I/O atomic writes by producing a single bio with REQ_ATOMIC flag set. Initially FSes (XFS) should only support writing a single FS block atomically. As with any atomic write, we should produce a single bio which covers the complete write length. Signed-off-by: John Garry --- .../filesystems/iomap/operations.rst | 11 ++++++ fs/iomap/direct-io.c | 38 +++++++++++++++++-- fs/iomap/trace.h | 3 +- include/linux/iomap.h | 1 + 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/iomap/operations.rst b/Documentation/filesystems/iomap/operations.rst index 8e6c721d2330..fb95e99ca1a0 100644 --- a/Documentation/filesystems/iomap/operations.rst +++ b/Documentation/filesystems/iomap/operations.rst @@ -513,6 +513,17 @@ IOMAP_WRITE`` with any combination of the following enhancements: if the mapping is unwritten and the filesystem cannot handle zeroing the unaligned regions without exposing stale contents. + * ``IOMAP_ATOMIC``: This write is being issued with torn-write + protection. Only a single bio can be created for the write, and the + write must not be split into multiple I/O requests, i.e. flag + REQ_ATOMIC must be set. + The file range to write must be aligned to satisfy the requirements + of both the filesystem and the underlying block device's atomic + commit capabilities. + If filesystem metadata updates are required (e.g. unwritten extent + conversion or copy on write), all updates for the entire file range + must be committed atomically as well. + Callers commonly hold ``i_rwsem`` in shared or exclusive mode before calling this function. diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index f637aa0706a3..c968a0e2a60b 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -271,7 +271,7 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, * clearing the WRITE_THROUGH flag in the dio request. */ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, - const struct iomap *iomap, bool use_fua) + const struct iomap *iomap, bool use_fua, bool atomic) { blk_opf_t opflags = REQ_SYNC | REQ_IDLE; @@ -283,6 +283,8 @@ static inline blk_opf_t iomap_dio_bio_opflags(struct iomap_dio *dio, opflags |= REQ_FUA; else dio->flags &= ~IOMAP_DIO_WRITE_THROUGH; + if (atomic) + opflags |= REQ_ATOMIC; return opflags; } @@ -293,7 +295,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, const struct iomap *iomap = &iter->iomap; struct inode *inode = iter->inode; unsigned int fs_block_size = i_blocksize(inode), pad; - loff_t length = iomap_length(iter); + const loff_t length = iomap_length(iter); + bool atomic = iter->flags & IOMAP_ATOMIC; loff_t pos = iter->pos; blk_opf_t bio_opf; struct bio *bio; @@ -303,6 +306,9 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, size_t copied = 0; size_t orig_count; + if (atomic && (length != fs_block_size)) + return -EINVAL; + if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) || !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter)) return -EINVAL; @@ -382,7 +388,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, * can set up the page vector appropriately for a ZONE_APPEND * operation. */ - bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua); + bio_opf = iomap_dio_bio_opflags(dio, iomap, use_fua, atomic); nr_pages = bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); do { @@ -415,6 +421,17 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, } n = bio->bi_iter.bi_size; + if (atomic && n != length) { + /* + * This bio should have covered the complete length, + * which it doesn't, so error. We may need to zero out + * the tail (complete FS block), similar to when + * bio_iov_iter_get_pages() returns an error, above. + */ + ret = -EINVAL; + bio_put(bio); + goto zero_tail; + } if (dio->flags & IOMAP_DIO_WRITE) { task_io_account_write(n); } else { @@ -598,6 +615,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (iocb->ki_flags & IOCB_NOWAIT) iomi.flags |= IOMAP_NOWAIT; + if (iocb->ki_flags & IOCB_ATOMIC) + iomi.flags |= IOMAP_ATOMIC; + if (iov_iter_rw(iter) == READ) { /* reads can always complete inline */ dio->flags |= IOMAP_DIO_INLINE_COMP; @@ -659,7 +679,17 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (ret != -EAGAIN) { trace_iomap_dio_invalidate_fail(inode, iomi.pos, iomi.len); - ret = -ENOTBLK; + if (iocb->ki_flags & IOCB_ATOMIC) { + /* + * folio invalidation failed, maybe + * this is transient, unlock and see if + * the caller tries again. + */ + ret = -EAGAIN; + } else { + /* fall back to buffered write */ + ret = -ENOTBLK; + } } goto out_free_dio; } diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h index 0a991c4ce87d..4118a42cdab0 100644 --- a/fs/iomap/trace.h +++ b/fs/iomap/trace.h @@ -98,7 +98,8 @@ DEFINE_RANGE_EVENT(iomap_dio_rw_queued); { IOMAP_REPORT, "REPORT" }, \ { IOMAP_FAULT, "FAULT" }, \ { IOMAP_DIRECT, "DIRECT" }, \ - { IOMAP_NOWAIT, "NOWAIT" } + { IOMAP_NOWAIT, "NOWAIT" }, \ + { IOMAP_ATOMIC, "ATOMIC" } #define IOMAP_F_FLAGS_STRINGS \ { IOMAP_F_NEW, "NEW" }, \ diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 4ad12a3c8bae..c7644bdcfca3 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -178,6 +178,7 @@ struct iomap_folio_ops { #else #define IOMAP_DAX 0 #endif /* CONFIG_FS_DAX */ +#define IOMAP_ATOMIC (1 << 9) struct iomap_ops { /* From patchwork Fri Oct 4 09:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821941 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 19EFF147C86; Fri, 4 Oct 2024 09:23:58 +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=1728033842; cv=fail; b=HjuvtWCdKhn0u/6MTtnRFQbkKY4WJSS2D51kskSUNqyIUevDUGWEgxSSWPrlMCj3P53IKllrFaq+ZrbBY4Y4vGmtZ0dX4Fx1c/LF6QM548kHyQ0tjoU/n3aXvqk0bFY1oPg/SOZxmkNVCMzwZtbiwZhyr6OJzQ2K6nF4VH1sWVU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033842; c=relaxed/simple; bh=vy/UgnvFN9RvyoPHn1qLGFRuWTkNA4MYDT9DT4DzS94=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UITQD31nsvEAiwj9EfhVYTeRfCCnd5T0tdBKsvwZZshvG6Y/Xw5W5h/eRyUMixVw1Gv4AWO3dQ1rSMklABArFqBvHZJQpa2OEt0eBc2dYBKQwD37X+D80wkhbsxBMncoNLaEY7IwsAitYomvzoTubvLEKG44RyHhzmuMmtCeASw= 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=HsggSfhQ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=j0AbOGXE; 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="HsggSfhQ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="j0AbOGXE" 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 4947tdUI013485; Fri, 4 Oct 2024 09:23:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=SZTlQiMKnf70FoMsvIMZfYtw6W6E3f7oepCsr97QeC4=; b= HsggSfhQ7Rtov5aZyI+lY/pYjMX0Ig/n9FPNJPSn8eQrM1R6U0vF/fcLLqj62cXQ EsICxgZrmFoCJCQmbN3J4Nsi3IBPnlKqJes5HmzhB8sN8DzitdZRI2kRdRkZAsBc 1m0gwOWJo5pHRrLvic7LRBl+Huk4H9Sax3Hc6+qmUhWWorgXj/MUVDYD2YA27vao w1tiHosI7+aYuTESH47/JF3T5N/rwNBqq6q2fx6uCOywurFtxB4iH9XfQUM2wiIu TY7bjspIl9j/DInSaFQ8bwkfVxr11ROBCupldlO/XTy6WioQt4oT/zFxoOGdiWRO CG1uq919vLXRDTw1qiJdgw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204es6pp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:41 +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 49495IE6038110; Fri, 4 Oct 2024 09:23:41 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 422057118t-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cOGyuAfBmv6tYEsFv2nVooTQIwq9K36uk+BxyWohTJkaBmTgdpb1tKwady49+urlm+xf4hmuFMV6GnC2sI5X2bvzvZu86Vr9i18e3utSaNealA9A+ij1QtQkARLxplNssWohv2qoFCPD6jl/J7gHkhICGa4nKvxLhxm1fVz47Tfg9542V3VqMN0lQT7Ds47yK4JCwbVpKpR5FTXmA+h6nmghnDX2BI83FJOUb+J8ZBMkE1QLlmepCq0C8tJjOuWq5/QNfNwawUXrNM1nFp3IC/FXvB1o7XIuVQsdy4Gk9qcJdW0iOwa2lQSEiCgloQf6+xjJ7Ujr77zeWQiVBjAI+w== 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=SZTlQiMKnf70FoMsvIMZfYtw6W6E3f7oepCsr97QeC4=; b=CQCH5HaoYFQJ6m/GkJxHjwt/YIfcPYacrNkL+xeU2KUr0GPE3z1JbVDIBpz7SwHmpR674X+rNA2D4bapz9ik+QRJaiXyrb1iXGRC9++gjreK80RFPVllA4dHJ5UgF1mens3IU4PG/fPCbCZJJX9KZelupsH2PdVgiDdOlFZZSao6ZcSVVNbn+9glUxR97Kn5rsUWlGcMNWb8VCsi10rxDc/0kdOCT1fTn3ZDTfEbw9kp6esRYLbUXZsbFjbW2TZSI23pyuI+1TsY/YPjyPDONsDMzvYeB/pCl0MIEShkOw1v/9YhhEtF7aHQMfOXzyoYYV98AHUSpm41IGC3CiU86Q== 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=SZTlQiMKnf70FoMsvIMZfYtw6W6E3f7oepCsr97QeC4=; b=j0AbOGXEPpV3X9CeKN1J7rpjRphrrP5yArXo0jVCDEf751vqi8Jtq7rra/UQMPAIFEwE2QPd5QsTevJotuIBEwNA9INldgFT5gG5aqMtY5T/vS6VHQAplR2ewVpHFAugdgFFM2C5X2q45XJsQn0+SQuiu/dNFkciGq4SSy8u/2Y= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23: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%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:26 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 5/8] xfs: Support FS_XFLAG_ATOMICWRITES Date: Fri, 4 Oct 2024 09:22:51 +0000 Message-Id: <20241004092254.3759210-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0028.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::15) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 943eedb2-4439-4a28-5604-08dce4563344 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: x+H5BTBkQCXZV/TpHuGhQOizBCt66Q20/6d29T2cFi6Sekfktmw19i60VG9Oxf3Osan/rX1dFyuK1KybYDQ7L625rhcpNPOdS5XO8xh5JnGXrCZIQZ6PNmnnzcO2wx5kvXbZb8iIh6zl9GWEMi2nCTqoHI4X90pNq4TCdTB265YpkSZ0V/fk7Nw9MLdZYj7gDcVenBCzhlPMRJsyodrN8/2ZgZzEjqGLK/qHbTI8mRLPcxFaw4SEMfiKrWxXB8+oL5Z6eRaoDUAGxxqnnKdYNMZxcJxZnSFJVsRA8xz9pIFKXu6T0XjuVT5i1S3RDwU0KM4sJHSIqeNvIeT8C0u5eyF/+KKmQ9RtW/I0aO0A1YIDbXoayrm90vgdT9n5nO1VWfxMqAUMYYF4KCXlplpHeZ1fse/WCeM2GRTe8gyQk0qQnR7fJIVhPWPWGF1w8I00GPyB1zojGCDtBLfylTzGsXfw1CfUWb1pbooSEZ2ortLaUeYBguz5kbsMhe1ZsVSwSrVRQC/8mv6E6tiD7799PV8TWlCSw8Zp4sBdGGwkgICKSiXQ4WQP86M37UQ4tnlvDYq3beXWREuEdfNJht+g+mTrRtzGsnkwmm4jh/HZmCaNzE375hDMH7bJd4OMXAeJyMitEBwpEFODPVbqgsDM/aEiLBcn4mcvblbI+VItEa2npdHJQmL7+83+TgkMLQvaktFt0S1kULXSNXecmKp/rArA7kpHHAPUr1G1jtz97QgU0gYsXDCCEIgasb6PlIwrSqXHVnB25k1hYVFUtyupJqEvzYBQN+bdTYVYNBNSbMYLXc86Zq0+3fTKcGj/msoyp+qz7OZDTn/JLDmYN1UPHrOHNGH85cr55ui8oOJblcVW/tPC1qiu0TBjbTtmmiVYCC5TdK9vNzCNMVH2tLkeLLHenQSpn5ANmd4eFRHja1hvxRhroT76mUBXbmjrS2ze9s+bndjV+K1Ah3d/h9CWOXy52Pzj+Q6vLZSOxcDorZfVT8DlNfR9wczBmwW79GR/pBwJAQYVO1uN21QYWG/yuwfjHeO3gDmv9zapYPSLhKftJjF6AR1Ud80coYvysQP5Oyzt2B3vhbIZOwAkUeBj9dDchrlSyTBXZKIG2vhKEJ8reCR29AYEYP5C53HEIiccwBmQ5UkIdf+Hifo5z72S8Uj8EyKe5XLFJR5CEjlDLcgKJ2+Wah5hHI8Va1NowliXpC18pYZchsem1o+9hOOETBHWN0ukuN8ed7fIOeK/jhjNpIn5KpA8p0cgjtnohXrc4xQ/0ioWOa58l7pCwpPssQ== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YSCvuB0zSihXd0sCqIksnY9ni0m4RaW7WPzW6UjNq3RG/XsAFy4axojr/JJ6pUqzhwcS3hp4XXkCg5dogxJty6+LqXC5u3Xg5lUDpy14+CDWK197TU+ROxB85cps67FG5IEp9nXdn+fiRAcwy+R5P+0v6imKQn8HTQo3JjRVtcXaQeyUXFk7mJqAfomCQo0TkHpnHp8oDP47FJCWSnDhgh7zwlgnxBAdITIlhNjSSPnn9b537v7Wpdu58D7U8Owa4THuTNVDOdgOjvlB86ejFPdCjcyFW9/u845eKq1CqstWWu3LCbaKd61vltYZu4ChoFDq+c1QThdKk9gPiWy6KgMq0aCUrJageAiTKRv7tK1v2WTyg+z/9Hl3vEG7wNH86TsMqIr+oDiu1ROQJLKd+zwGo0XcHwTsjkXdA1g2aQHUx+08Iva7f4AyhO7+bLm0uBAKqud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tSPeaobm68HMjW8kxmTORmkHIG6fwyJB1WxQTyyGvgUvMFTV68dl7eqZr8UaVHSA2PCx+yRfkdnJI04AqVVC96w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Z66paDGaUi4M89tEdrbm/yBdbiKwa0kcZrhDIq4OYc+w11De5BBR6Y1e+D2I7177cowksKpximW/JSn/Ljzq/WC7aF32lP9A/lu4ufZB1Ri0GDLPAsP08GmI9Pl/LSMc6JkTDoDjB43Cc8ltPrPABCuSINGUeFHANZkWcypDzLJkPR2yJfD8gyBSeCjJMmIyuKMrb0gH/egDxongtx37NGM/hgfPJxtdIJz38AL2gIjgzCVH0oHKLa9vWcN8YzuikAz8iA4E98bz82M4gnOctVUpd5o/3DTazdhU4yRTOqXne4LNCssZGJxCep4cmThua0G3GqJSxHdHEcOBaO9Ldjx+lQ2BbKoKJpmUZ/34qg9Oa3Vv9gS2YMWSwVWJPan6aj+yMv3IA2QkkRL8UCIWWKxKfqBkNiHLX/mARqjL0xJAhwxs906wXMAFVTihC/9Myb2qCi+c5aujHaGqRFgiFJ1au1yIu/oKTjILyf+xWq1tbRvrChfrp1Lbi/n7lCshwd3xtFt1FQH70x45a9s170iZoKme6H2HBofO90LxqJprTQFmykVuQUk5VOPxXcQ8cVQgKapEfku3o02m0hO3GMcePR/0SSktyJVvnxQ+cNA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 943eedb2-4439-4a28-5604-08dce4563344 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:25.9874 (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: hu1jW+4cZ8YPxd+U9HrjLU9LVLBHuD4csceZg9PWFBT30LHPr0irQ0yJMP+PsqT4ypYwEE/DqiUImSmjouSjqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-GUID: duaR-a-0y2wSES1JUBm68e2i8aoV-UGU X-Proofpoint-ORIG-GUID: duaR-a-0y2wSES1JUBm68e2i8aoV-UGU Add initial support for new flag FS_XFLAG_ATOMICWRITES. This flag is a file attribute that mirrors an ondisk inode flag. Actual support for untorn file writes (for now) depends on both the iflag and the underlying storage devices, which we can only really check at statx and pwritev2() time. This is the same story as FS_XFLAG_DAX, which signals to the fs that we should try to enable the fsdax IO path on the file (instead of the regular page cache), but applications have to query STAT_ATTR_DAX to find out if they really got that IO path. Current kernel support for atomic writes is based on HW support (for atomic writes). Since for regular files XFS has no way to specify extent alignment or granularity, atomic write size is limited to the FS block size. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_format.h | 11 +++++++++-- fs/xfs/libxfs/xfs_inode_buf.c | 22 ++++++++++++++++++++++ fs/xfs/libxfs/xfs_inode_util.c | 6 ++++++ fs/xfs/libxfs/xfs_sb.c | 2 ++ fs/xfs/xfs_buf.c | 7 +++++++ fs/xfs/xfs_buf.h | 3 +++ fs/xfs/xfs_inode.h | 5 +++++ fs/xfs/xfs_ioctl.c | 27 +++++++++++++++++++++++++++ fs/xfs/xfs_mount.h | 2 ++ fs/xfs/xfs_super.c | 4 ++++ include/uapi/linux/fs.h | 1 + 11 files changed, 88 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index e1bfee0c3b1a..ed5e5442f0d4 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -352,11 +352,15 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ +#define XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES (1 << 31) /* atomicwrites enabled */ + #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK| \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ + XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( @@ -1093,16 +1097,19 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ #define XFS_DIFLAG2_NREXT64_BIT 4 /* large extent counters */ +#define XFS_DIFLAG2_ATOMICWRITES_BIT 5 /* atomic writes permitted */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) #define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) +#define XFS_DIFLAG2_ATOMICWRITES (1 << XFS_DIFLAG2_ATOMICWRITES_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_NREXT64 | \ + XFS_DIFLAG2_ATOMICWRITES) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) { diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 79babeac9d75..7fe94d038e83 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -483,6 +483,22 @@ xfs_dinode_verify_nrext64( return NULL; } +static xfs_failaddr_t +xfs_inode_validate_atomicwrites( + struct xfs_mount *mp, + uint16_t mode) +{ + /* superblock rocompat feature flag */ + if (!xfs_has_atomicwrites(mp)) + return __this_address; + + /* Only regular files and directories */ + if (!S_ISREG(mode) && !(S_ISDIR(mode))) + return __this_address; + + return NULL; +} + xfs_failaddr_t xfs_dinode_verify( struct xfs_mount *mp, @@ -663,6 +679,12 @@ xfs_dinode_verify( !xfs_has_bigtime(mp)) return __this_address; + if (flags2 & XFS_DIFLAG2_ATOMICWRITES) { + fa = xfs_inode_validate_atomicwrites(mp, mode); + if (fa) + return fa; + } + return NULL; } diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index cc38e1c3c3e1..e59e98783bf7 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -80,6 +80,8 @@ xfs_flags2diflags2( di_flags2 |= XFS_DIFLAG2_DAX; if (xflags & FS_XFLAG_COWEXTSIZE) di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; + if (xflags & FS_XFLAG_ATOMICWRITES) + di_flags2 |= XFS_DIFLAG2_ATOMICWRITES; return di_flags2; } @@ -126,6 +128,8 @@ xfs_ip2xflags( flags |= FS_XFLAG_DAX; if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) flags |= FS_XFLAG_COWEXTSIZE; + if (ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES) + flags |= FS_XFLAG_ATOMICWRITES; } if (xfs_inode_has_attr_fork(ip)) @@ -224,6 +228,8 @@ xfs_inode_inherit_flags2( } if (pip->i_diflags2 & XFS_DIFLAG2_DAX) ip->i_diflags2 |= XFS_DIFLAG2_DAX; + if (pip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES) + ip->i_diflags2 |= XFS_DIFLAG2_ATOMICWRITES; /* Don't let invalid cowextsize hints propagate. */ failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index d95409f3cba6..dd819561d0a5 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -164,6 +164,8 @@ xfs_sb_version_to_features( features |= XFS_FEAT_REFLINK; if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT) features |= XFS_FEAT_INOBTCNT; + if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_ATOMICWRITES) + features |= XFS_FEAT_ATOMICWRITES; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_FTYPE) features |= XFS_FEAT_FTYPE; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_SPINODES) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index aa4dbda7b536..e279e5e139ff 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -2115,6 +2115,13 @@ xfs_alloc_buftarg( btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off, mp, ops); + if (bdev_can_atomic_write(btp->bt_bdev)) { + struct request_queue *q = bdev_get_queue(btp->bt_bdev); + + btp->bt_bdev_awu_min = queue_atomic_write_unit_min_bytes(q); + btp->bt_bdev_awu_max = queue_atomic_write_unit_max_bytes(q); + } + /* * When allocating the buftargs we have not yet read the super block and * thus don't know the file system sector size yet. diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 209a389f2abc..2be28bd01087 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -124,6 +124,9 @@ struct xfs_buftarg { struct percpu_counter bt_io_count; struct ratelimit_state bt_ioerror_rl; + /* Atomic write unit values */ + unsigned int bt_bdev_awu_min, bt_bdev_awu_max; + /* built-in cache, if we're not using the perag one */ struct xfs_buf_cache bt_cache[]; }; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 97ed912306fd..1c62ee294a5a 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -327,6 +327,11 @@ static inline bool xfs_inode_has_bigrtalloc(struct xfs_inode *ip) (XFS_IS_REALTIME_INODE(ip) ? \ (ip)->i_mount->m_rtdev_targp : (ip)->i_mount->m_ddev_targp) +static inline bool xfs_inode_has_atomicwrites(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; +} + /* * In-core inode flags. */ diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index a20d426ef021..1c980c863ada 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -469,6 +469,26 @@ xfs_fileattr_get( return 0; } +static int +xfs_ioctl_setattr_atomicwrites( + struct xfs_inode *ip) +{ + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + + if (!xfs_has_atomicwrites(mp)) + return -EINVAL; + + if (target->bt_bdev_awu_min > sbp->sb_blocksize) + return -EINVAL; + + if (target->bt_bdev_awu_max < sbp->sb_blocksize) + return -EINVAL; + + return 0; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -478,6 +498,7 @@ xfs_ioctl_setattr_xflags( struct xfs_mount *mp = ip->i_mount; bool rtflag = (fa->fsx_xflags & FS_XFLAG_REALTIME); uint64_t i_flags2; + int error; if (rtflag != XFS_IS_REALTIME_INODE(ip)) { /* Can't change realtime flag if any extents are allocated. */ @@ -512,6 +533,12 @@ xfs_ioctl_setattr_xflags( if (i_flags2 && !xfs_has_v3inodes(mp)) return -EINVAL; + if (fa->fsx_xflags & FS_XFLAG_ATOMICWRITES) { + error = xfs_ioctl_setattr_atomicwrites(ip); + if (error) + return error; + } + ip->i_diflags = xfs_flags2diflags(ip, fa->fsx_xflags); ip->i_diflags2 = i_flags2; diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 96496f39f551..6ac6518a2ef3 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -298,6 +298,7 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ +#define XFS_FEAT_ATOMICWRITES (1ULL << 28) /* atomic writes support */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -384,6 +385,7 @@ __XFS_ADD_V4_FEAT(projid32, PROJID32) __XFS_HAS_V4_FEAT(v3inodes, V3INODES) __XFS_HAS_V4_FEAT(crc, CRC) __XFS_HAS_V4_FEAT(pquotino, PQUOTINO) +__XFS_HAS_FEAT(atomicwrites, ATOMICWRITES) /* * Mount features diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index fbb3a1594c0d..97c1d9493cdb 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1733,6 +1733,10 @@ xfs_fs_fill_super( mp->m_features &= ~XFS_FEAT_DISCARD; } + if (xfs_has_atomicwrites(mp)) + xfs_warn(mp, + "EXPERIMENTAL atomicwrites feature in use. Use at your own risk!"); + if (xfs_has_reflink(mp)) { if (mp->m_sb.sb_rblocks) { xfs_alert(mp, diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 753971770733..e813217e0fe4 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -158,6 +158,7 @@ struct fsxattr { #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ +#define FS_XFLAG_ATOMICWRITES 0x00020000 /* atomic writes enabled */ #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ /* the read-only stuff doesn't really belong here, but any other place is From patchwork Fri Oct 4 09:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821938 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 0E7F014BF8A; Fri, 4 Oct 2024 09:23:57 +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=1728033839; cv=fail; b=jo1lQNjQ2TTgQRST2Fg6d+eEjPeMQmHFuYr+CXGOUJERMSXHUrTTDMFJ7ji7egZaRSZl1QAWFH0WX9Pqnb4TaMOBudEDw4Q3Mdln9yrShA0kCzWo4CpBg1XEFkAL4kfu//Hfnd51FjjOke4hX4OyFbofVKtFNpuJ9vON6k/ksEM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033839; c=relaxed/simple; bh=lxd4N7eR28r3sbPqxxker7d0yndncwA0/HmE226Da7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ACZq5SWTJfecn6wDVV/wd9bhu5W8Q0u38xnchoi3INllk0HFNUuKxZocl4ZcFcLFJTWPqE40UECdWPBIMyM4vJQ12Bz39NJ+T0X4/oMnMLcl/oD48UY9/AvsPbH6olfE8JBuaKPEgIKdDsQjB3Z9LPAhwvIx/NLrj92q+pxtOZg= 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=OEkDTVxZ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BhxOzOu+; 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="OEkDTVxZ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BhxOzOu+" 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 4947tev0013498; Fri, 4 Oct 2024 09:23:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=STxOqbCDp/AAc3DmRB7xsYyTvFZ4NcYVVjPDSnzoTcs=; b= OEkDTVxZp1/hgFS8qpptzWZTRmhBng42mevj55n869sVDKfV0/qhtwU+cKSV/Zf5 C8vPZIT2PugdsKlUnGZiF8BTD7+d11/+Tkn6f/RXGrBed4oFP8wAc0nBrno4q0CL DMMVgQGSZUkQ9JtrTxRV5ATtLG9PBuhGGu5OyGhA7RXqLZ0ITgyGYQvmOUnBJOJ2 2kPVp/FqCs98TiBfm04Y/ACUbzKca7NadJBDMUXzmua8HjR1LY0lTHD57r4j07di /sMPP6eYlpW8L169mWQ8jmuCoZ4C5bl7ciDx0Ek5Yhc+fHPBmBHORQ2QspNjYxvM 2Ia/mCG0wn3Rpwvl2LegPQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204es6pq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +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 49495IE7038110; Fri, 4 Oct 2024 09:23:42 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 422057118t-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qw1WCL+nYeHb0bVGkY8t3atGL8cN+N7jvPxR3BFmPoSlVlCzsrHG3oL5s0euy1+XpTaqfve87QKA7GyBkK8Av+FfL0TkaYzl3ER+xbOzI2WMuMJjln38oxE2c3bROnrLjsM5j2ZnYsPkLOKjLUuptZUvTPloJTBbLQkuMj1p043j7heFZcyEpab155MTiOg3qu3kwHb/IOEB5Ii77X3XNGy0h3BkH9lJ6JClYEYx5ehU3jRKmjdaCugw2JZ06ZRzmFCVMEn+Trhtp3KM4DYsJO+7pYqmm4e26gizECo8Vliu7wgUZQTGygtuQVLoc4JTIeioDvYvs16/eF6SIwNHtg== 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=STxOqbCDp/AAc3DmRB7xsYyTvFZ4NcYVVjPDSnzoTcs=; b=G3ZGNqFatcMKHxnvTfWFL/OP1mDr1Tn0ODSfnA/HeaZjDpJsnOHshLMvYsqbFFE6IfM47xS5XXgIO10YNh8j7VBWYM8C+DjUqTh4o68x4sfly1CvLGvu8PCJgotKp/5t1gymPyo7hdf9r+TRAvEdvjy4bFg8RYy7Wo85zsbI/iUizfGVyqbkZZ+6XFlPXemsasYrbQbjUs0PU19AfYr55+SFTZbZSpBlCCisdTarv2SL8p3InSGKdDZLvImHy4q37Kdj/NQZbBLFo1P9jaxlSEJU4j87GoNfYl9UmTdRVizs4CHbcwLd0FesNK65+ic+X/qiJ5lcBGLMjPR1PQZUTA== 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=STxOqbCDp/AAc3DmRB7xsYyTvFZ4NcYVVjPDSnzoTcs=; b=BhxOzOu+JJpTR89Puv6V9yWTtKUUwtCP2msEMW0yVd4zFU/Lnc8Fmcn9pn6ngMp9L/bL6LdaDN95ruOjDryl7cV78xpii1YMT3iTNiRcvjJM2pjh09s7L3YbJ3+DMKJ+Gf8V81bGdoCJXJgc13ChFezcBGOCgz9c9Dv/2p3NUL8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23: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%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:29 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 6/8] xfs: Support atomic write for statx Date: Fri, 4 Oct 2024 09:22:52 +0000 Message-Id: <20241004092254.3759210-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0165.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18a::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 132148f4-8a75-4b4d-00cb-08dce4563519 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: VsEM55BHyU2vndK/nW+oO5t2jvD8D93m4waWNp55nUk1dAG6uG+Tb0pmsu9ccLIgKRC8TrzWdv4MrV5vsMJn3N1mh3XvkD6SOcELazu83JGFIJH/Qli1oJCRpbUgmTtpI0SVPgYwbglOskvDMxMq1wNzjRoABOdq+m7r/xdhXhlsJ9vb5mx9bvjN6mbxRA/XtHptIBPb3eYXiKs585VcSl+5MY1S15qDqBIk1Ij2HARwv79ucBe3Non2ykB4MRKYYsOjsj68snOJqTynefs7A+RSx02fOsNIgNuNLx6CQ8KTs0AUrjcfyCYxVQTC3H9zrjnQP9pTuyMpwHFXc5eLqsEeJbtCcMH5obfOewK0JEzBGjp51dH91LP4rN2Eej54Qk59iHjydbB1E7w8MqIF5qre7k7Vp1js7++KU/ErFXkfSZ3K/AhtmG7dURwnK2KcKixmVI5VRlI0UVuokYu1AVOQ4OGWI0uBlHvZmW9eaHOZty1C1rOSTEa3cs4acq1UiGjgQjaKvwJ+FKcBLMXcZWBNTc767JAd7I5mPiC7xPEDpEjfk+OpFx/hfrb5MgZkYvcP1zfB4MbV0LP3geZeDVn1+1VlRy8zklICtlAiJMnoCSEuLef3+6OHYt0i9b6j98GdAR8pzvSLymDSldBB8liOG/cNjHskemLjMLG6mDfTUnsrdpXKzZTiDol82aFvUnQl+jPH2njXUiIZ0SZypQXb80wck2ebATJGq/NQV0yA7myQ+3RIf1t25VYC4YjkHkOnc8xrVG7KC6WFvnQ8aLT9JqcGfgCEgM8NY1fiF8ax3CMarYp1dWN1Ud+Dr3RBaHpGl6M7DFepii7P6W4TC34lrqN7rGV+XBvW5v8KDaii7WY+4ITQ81BUd642knTP/PpWSiMaBRk0xFbmQc2gHcx0SMDTxDk4hXbrxSZfxQc1rer9IiPvowiNpjTzKUukVpEUJRg0NaZ/IBMqaX5nsp13fo9Za7qG2K/pmAIKnSO7oTQ+37ovw7BK5VJq0rgu8o6vJnSGe5QHZtteH3p3IfWCHzBkqtxMg3vN/5cqiRZp4fO66AQKCaJVxWH9Bs3Qz96BsBf7CbUczy7mDKVk/AOTtmyYVuSEGr+mrXOqC3m3sWoaEUw3R+P4pv2TCKkmeQMAv7CHUGraDbf8ogP6VVxkkDBfm2SiO3Zu0VDRSLoK8bx7kWt/IBzmOf/jZciMT+Va9IcrB15Wq9a5i9Zu0wsBZrB0L5IXLpNdIYNY/jU8tEVtkuAg07gJqJmGKyM9W02nCb0Whd+lI8/1il8LtA== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fJm/aKRg2eRYAk6o2MonJdYG/QGx5scvm6yttoDS7zGszf7337UKdjHjw8wFD0VYtCBxXz5ul0Bx6UVbHujevW2cTQ/SFGOTbc420L+C4f8kyB19xl0ilvbnmrdR5hRnUT+brbeD6oX33fTleL62ozhJRs0NGRVoq+opL1oWZmaqu4hBCyUhrFPpguC5opuCWZ1N+f+15M2SHNRgCME9FioYCb985cWR/DfBrgoCrK71QnxRMO3szfxcU1vejmgCnK1sh1xu5NLs01iREPICJubxrOvnAayN1bgk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7nh6mgIKaktsaRG/ueyRSsWU6zxJS8cIvXMYG1eOP5UX1dzzaynmfOINMxAg0qY8DAVrUI+KeLD0hcHc8FDjN6KqQTTjGMRjfaL0huk2n7AJMW2jayZ+tSOcawg+A3H/almQUNSmN/6nQ+KM71hYjAuwS/BqIjw3JVse2G1M6GQodTPUrGcdQaZzm6dY4cg70V5C5qCMbeKa2/qnl/yMpq2+T0oO4HM9mvWRvPLWn15RjoMXq2KA6z7IjU8DYuctQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: w6gVkQwc9NTkRqEEX5/KRY4oHO/oxPGvdGyA+flNLHhiNHdGYJ2QB+atsmLzkHcm/SJn2OMWNDN5F3L+D2GlNmE/GkAY+4N7bX0XCtzhmSxD1jxD3OBgUo2J9v/tf1McBejYrSFARgesnF9m+rxdel8zVeHGKwYeu++xnBtuP+GAGy+FmRK+r7vNQc8R5UIQCU92yv6hJ+yEKfVsh0SYkcZh/iiVCAVhXAfSluwO9jzrvVrFmLMPf2+VxZkb25nhcVqFIYenIRSv/eO6q5DelxIHfWh432l5LdCWUThbAFAlMzUOeC0tQmMyx8oDapIsgJ1BAgLLvPZA80gp6FpbD5y1KrpZAvM0bCNInggPLi5NDope259i/SYWoA7CiAa0o1t8w/SUENDX1SDmoDAtZNb2Wakf3+5vfNoWMimXseAW0b0+KuIzwrf+0sVXHuoNNcqBoSXh0Mfst1xHpNwuykibihZZmp8HV8s/SS/lPGBeBiXPtx2CSuCu+GuLRqyKr/FYYggxM9cmFCctbRwbme82r+y2BA/MOYuIRlUH1oemRU6u5iUQCDz9/A+A1wXXVyZsQn+hDl72NXPgsowdYj9JoBvZTZjlI8dxKMMhp50= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 132148f4-8a75-4b4d-00cb-08dce4563519 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:29.0258 (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: o2LAVwZQwqAgCMoXHLVby3GxWHWfMdAAgXtvhfkOIFjXCuxmF13B3cDPOwItQH/SjMX9iFYMhA6MqxJw5ggDPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-GUID: WIcIm2G8_eJceelTyYMssxjdBhJQXVnp X-Proofpoint-ORIG-GUID: WIcIm2G8_eJceelTyYMssxjdBhJQXVnp 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. As for max, we limit also at FS block size, as there is no current method to guarantee extent alignment or granularity for regular files. Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_inode.h | 17 +++++++++++++++++ fs/xfs/xfs_iops.c | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 1c62ee294a5a..1ea73402d592 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -332,6 +332,23 @@ static inline bool xfs_inode_has_atomicwrites(struct xfs_inode *ip) return ip->i_diflags2 & XFS_DIFLAG2_ATOMICWRITES; } +static inline bool +xfs_inode_can_atomicwrite( + struct xfs_inode *ip) +{ + struct xfs_mount *mp = ip->i_mount; + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + + if (!xfs_inode_has_atomicwrites(ip)) + return false; + 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; +} + /* * In-core inode flags. */ diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ee79cf161312..919fbcb4b72a 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -570,6 +570,23 @@ xfs_stat_blksize( return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); } +static void +xfs_get_atomic_write_attr( + struct xfs_inode *ip, + unsigned int *unit_min, + unsigned int *unit_max) +{ + struct xfs_mount *mp = ip->i_mount; + struct xfs_sb *sbp = &mp->m_sb; + + if (!xfs_inode_can_atomicwrite(ip)) { + *unit_min = *unit_max = 0; + return; + } + + *unit_min = *unit_max = sbp->sb_blocksize; +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -643,6 +660,14 @@ xfs_vn_getattr( stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; stat->dio_offset_align = bdev_logical_block_size(bdev); } + if (request_mask & STATX_WRITE_ATOMIC) { + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, + &unit_max); + generic_fill_statx_atomic_writes(stat, + unit_min, unit_max); + } fallthrough; default: stat->blksize = xfs_stat_blksize(ip); From patchwork Fri Oct 4 09:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821939 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 561BF14B07A; Fri, 4 Oct 2024 09:23:57 +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=1728033840; cv=fail; b=Rzgsa0h29XGCcfxW8nKoK5RS0IykUPL074TK5/J5Fy1BDVQ4YYDVyAnh6wyr6oxyu5XVdmQt+8tqqRrmuMKPKF0Q3E72f/VX4amLfEMxaAmv3GoHQ0dxWZB3W7NEFuMJXZFrOB/MPndQXX3TSOzY/YEhR9Uxp9Bt+kcjFOpiGWk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033840; c=relaxed/simple; bh=PRrDkoSeESCFQmalYb0tyyf6s2YdIZ8qgL2KjK4WWoU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jLvblQbfzYMXarBQfByHRrfdzIb2mpNwaZ+aYi2YfqOUO2fGuwgku/87ftyyhDGIHvnIxfHQ+AekZcB6CYWAXLe1x1LSzirkufLGNoGIgQWWK1bhEHkt7nojgukA+Ve8UBzWoaoqAbCmvA3tLVY+gD1vvovt30+rT4EoiMPtaU4= 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=Mf3qQ6y6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=E0ef7Hlc; 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="Mf3qQ6y6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="E0ef7Hlc" 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 4947tgad020708; Fri, 4 Oct 2024 09:23:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=8MqU1/P/auBsdf7FWpVOBsuUx8R1RFiawgabOzGdm10=; b= Mf3qQ6y6nOeQUdONglK40rpX73JQqHz7yT0hWqKAN5mT3lPrJ86/qcAzDeQnndf5 vIMoRGe6Nb9Rmj5tXBg7G1SJmd/gARiiXEVaNY40Yjc7gSnL6XFu94hDcfVFADSS ubO3g1idfuXXK4daqWeAeBNyPp08vknyr2JCVAVbwYq99W9SHaLcCdEvszBkdoJe O3d47+nb+PYQCKwDgP7BY9MFSiP0hWeYF8ltoONO59MRaegG00uUR6Z1XREazHW4 NCC75wSJXyJjdjTdupgY0L5zEim+ByRF7eLqnQT3fyHX4MmtEVnZQ/j4shUwxFj/ f5c5V/rg7T1xVI+On/LDNg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204996wg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +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 4948oNYY038396; Fri, 4 Oct 2024 09:23:42 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4220550xvv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K+qLsZ/WPB9NaqQVJ3BtcwKLaZZ7eCplqmQNBzj23phXgtSKgvOrCYodry0AiyRQrbC/oZGhfLM1L1MMZvwAgKcti6vPYmgwezOkpFFlrH0PCAOLySXLXjWz1remAPKb1jEQ74dwkN1s9JOit6Lmns8clAmOrMAC/BJt0QAptmz9ldJYC25X4fXPxMV4Mv2naG/zVS/y3V2bGQ+Nw1fYNJyeMiEA8f8N9gtziRT2wQAnBe89gofkjcEKweMSgWwNuShITRtPZuysmkZRFuOMuHCBc0kg74fea1sdlR+sk+lE5UaBM9rxaWo+s/nA6upw8FTuyKzYMiKqCXgVLE6Pmw== 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=8MqU1/P/auBsdf7FWpVOBsuUx8R1RFiawgabOzGdm10=; b=ijVBa4EvomS8qgh5WknizrMp2XjysA2G8XpUJnZd0nkQE8/8SV8tea+qK7ezg9iDADPqS4+xq8o+9XZhmo/qAigOjaIlbBKBnPjdh8VNZ/n9bj+bJzliYjDrzB1N11Az8yz2awPe6LKtJMQz4azNPuS4V0zjwtOO4iMakSARoeQQ/RZrZJWPJm7IKIt4VF43gnvDLIZqTTVArN1KRE8GiF40F1pKZT0lyTZkOL1drqoW/0YkPk1JmF5DSVFQjjLa1dx3OR12pzaXbN5HzJlrDPzMWAjdWxfLKmBMNWQWlhUJVSXTt9WebTi8B1Cun5Od+RoE/C6wuYUzrl0C0psL2w== 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=8MqU1/P/auBsdf7FWpVOBsuUx8R1RFiawgabOzGdm10=; b=E0ef7HlcMki8yakuQUsywxMGCWDzjnETLz/G2j23/k5V/wuMG34cG7XjwjrPLmcXtIsFgz3Zg2pZ3+IcExeyicyC9djiAH2K5UWcZuB1i+pzIiM9sM935YpFMeRLPChWKzEDt3FqLXuIRZIMzViZbN/WPl56eOXT42hx/EYISRA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23: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%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:32 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 7/8] xfs: Validate atomic writes Date: Fri, 4 Oct 2024 09:22:53 +0000 Message-Id: <20241004092254.3759210-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0118.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c6::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: fd20a228-37be-49ac-a686-08dce45636f7 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: NT3j1Uqz5U+anEb4BOcjqMQwj1fLsOnuQcJP7fdpdjLqhzo7XLuZddihPrXJ+8wTkwaDxxZyu49zfwfG3815cHSz+54KSf9sSK+gW0kChcV3U7J8n8VUuzIuGm2XaLj69PwW4F6lw/qRGHQZXmOkM/RWs96AE+TDwJ/v4L9I2DugAeQekLpbQSkP4igz2VIp+wd19XYOirWGmIMd6jXNNXaHKfFP27NQTBQnK3EtxlhLwl7K4ku1OnnMKuvQJzVqr86xDIDI0682+Z9wk2po+IkKj3MYxjiwlfuVzzdJp5ljm60Oo5F0xL9AgdhiM4IMxc/Pio6032JkEBezkt127cAPrqUfoze9DSM3Oc6nwKARPhOvt6w/P2oaXai423He1GNRa9beP6bkjMfQ/RpcoRyQzeK8N9wExlhuriVHrgZyCsqb1BBZHiHOQDWJfKvV2BEDSputmRVkDCwZshlmXtM0zybRJpjnHcC0vi5jV7Z4yD7XXM8bl2zZjyA5eTx5iyZTvGO0HC1PJQDR6AcO5DhOJ26I24G73fngBkjIGERk7fXDvkEZJXthIgGMhsxNxYy1LCFK7jzOwpbNBZvzpXlrH3JKb43v2ynu4SMcpm0aakCKUjBeDNGY/xJiHujFWtsORgRcAQb6FPcZ1GP9psFH7UXwgVMyOIbSo5Rf6PHnSbEP5wyHXr5xzpPB6FHLojAQ3sgMsag/+HElWrIJJ91lSTPGNgrBWybBZRDu+1ykn4HC8zkqvYMv809/ca1fKrTX5yFX2OipwBg5aA8VS+HosJ1eVMsWSQlkJlpbO9Gm+4n+oCcJgsAkNhJatSquxUaYUew2SQGhMdOsRhPCKH02Qg5aflq50lWM3zca/XUXYXYBPJLT2udBOqJdFi0B7bgzcFcDTcCoxOgSBSpY5uYtt3qwD5Ry9wu3e9ao0ZwUXRv0/jycAswTs9la5wkjIwdsLxGnQ2TlhzvtjkZ17veoEs6xucZKJZHEQvxVhZ3ZLl0L3mAzH/RNjev83Qfqul1jCr6K2U5CNiFH7nyLpWgIKWC4Na/O2oWW1Z4tUNfTbhENntir81hus8HzyrEI8O+HkV/j7fJpRMur4cf6sngq/X2rO766W0s95loLwVYfY8iLkhKiU7YrA/147zvZCcL0FFxWvQCnlCHvN4+mSgwf6tmiT5/H11YS1FICyswpqOirQKSTTaf5iZDA+MJ62MiC7QgzF9J11Ao6wZv/TvXu3ACcp5m9eW7TdVQxTl3M9LTjn3MyxQNvrEaQylYi2V2PAu6kA0VR8gmycD34rQ== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lJKCr/tjV5m1OzY4Czd4MKdgmBdkisfdhwBEMNR+bDBInzdoPC7vJdw4JtdlQcbDvtr7i4rWia3hMU4eIm6ARcXN5B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ZrA6kAFA9E//6DBwmn0lQKYLZHj9kbXQgigmetPWeBhFD+5RzH44CunGZLOdz9ZWiSN9FSfowyXNs8XGlaIlBlL8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd20a228-37be-49ac-a686-08dce45636f7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:32.1524 (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: rp6+yxIOBHUgSKi98ijb77ubT9T9FLL9lsIzuNoY+F5qbONJVzBhZYLhHWMY8e011c9z2Ih4d7R2/hxv5LBhHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-ORIG-GUID: KtWUYD8yP5xyxxnA3p4gpUUbSG-xKLo2 X-Proofpoint-GUID: KtWUYD8yP5xyxxnA3p4gpUUbSG-xKLo2 Validate that an atomic write adheres to length/offset rules. Currently we can only write a single FS block. For an IOCB with IOCB_ATOMIC set to get as far as xfs_file_write_iter(), FMODE_CAN_ATOMIC_WRITE will need to be set for the file; for this, ATOMICWRITES flags would also need to be set for the inode. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 412b1d71b52b..3a0a35e7826a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -822,6 +822,14 @@ xfs_file_write_iter( if (IS_DAX(inode)) return xfs_file_dax_write(iocb, from); + if (iocb->ki_flags & IOCB_ATOMIC) { + if (ocount != ip->i_mount->m_sb.sb_blocksize) + return -EINVAL; + ret = generic_atomic_write_valid(iocb, from); + if (ret) + return ret; + } + if (iocb->ki_flags & IOCB_DIRECT) { /* * Allow a directio write to fall back to a buffered From patchwork Fri Oct 4 09:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13821940 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 5DC1A14D2B3; Fri, 4 Oct 2024 09:23:59 +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=1728033841; cv=fail; b=Msr8UFDhREwxQR3/Nc9tQnm7b2ePJEUXS9R965NSY7R3dM1xVSEYbt104jMT9ll1C+d/u1PwU6ENvX3S8OKyMtTMH3NAaT0cNJO/fzOQFQGrlOkJ/No2ZmzuElaWO5T+VQcM7R7nndrhbxC7beS8d2rCIALu+4sB3RTMmcsFgxE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728033841; c=relaxed/simple; bh=Ao5wS8zFqjiWuLBEFQKIpdd74u7Jy6t5sEuht///BAg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HJb9H+YvUuBR1MZWPJQxdJgxaEjU1NQrwWGFMOTDgjMOtFAQXqpUe7UreQXtzKqkPggUk5iSSW5MnkzFjuGHn4Bg6ywIxnIvSSckMwoo/fdL8rCbdUWo5y1ezokAXp8DSwgo3wldM9rNNJ/3SP74RPYGWKng2y5oNtyX4vmayfU= 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=EQzQZ0mq; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=e7Hm7u8p; 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="EQzQZ0mq"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="e7Hm7u8p" 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 4947tdts013481; Fri, 4 Oct 2024 09:23:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=jIyXK717ZbzgZ9k0xICFVe7kia4cyLIACzQgT4x7Hzc=; b= EQzQZ0mqbV/2LJpCckfdLfVk8C2dvavjdLvTL2Zu6OSHgnCgnfImKaCHKVJz1dns 0EP4geJSAv8OwX5sJspqnxrp6bbqA5FtEEzjIeqC92U9c5atnaDqskxKM3LDkFed NYgmIGDC/sFJ0JPi25VxlTS6R2applHU7XWEj9NnSkZrlaNEtvb+MYB/S1saleDD ENjuLTju5vzQjtP33i9evUy2Se28S08G+L+X2ySdzihzQVOArBjaaBiajAhkJ6+O gzRWO0S2KRMs06VRWxTcsZRFGFLx+8H3v2Dz5AeHSXSgcP0XHAzlkJP7G33NucJy k78tZHGoE3WHCfosGWbsog== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42204es6pr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:43 +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 49495IE8038110; Fri, 4 Oct 2024 09:23:42 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 422057118t-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Oct 2024 09:23:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DLX5gjfvcNSVKmEpZfgldghYPibH/mdAcjAJPHHZcEC2PgGKyMUucYTndf5k+F43xYtJkhpun7Cspe8f4EzmpBZ0b8qZH8siwKR6hcQ/BoY4Cu27/VvRqz43UBGD1/gmI8Cz6G2U5In+XQ+JCYaozIxqiuhryrXnQWquH/qFY4COhjJi9Z8AF4GWmZRNVKxIKt8ldjLZREABBgJBo1N5e3cC5NLlW6pe47EoRHB2hxxaW8kZcbhgbDdDIFM9MfIwwWMlTyL+olRhGIkC1oBC5Xu0QUN1gqzc54P2GuU59AWgJ0EjVK7an49btZuWS99aVWAaQLIptxsOPpiw898W1g== 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=jIyXK717ZbzgZ9k0xICFVe7kia4cyLIACzQgT4x7Hzc=; b=LDFEQNmVT/j2uzXDLtcFtz+3ige7dlEsMpq84iAssGBWi74Upje9EJcFY6hb4Yhcw+PeSbVPuAfHagw/N26tP9wDkDzIdo5XhXA/GWI/SxsTqf42fdhV6tREmLEAWKdjNQTGPB15J3CM/IGjbL5gzsH/X8THPwnC4OiHqVON7iH0u9b7H6yAT5X1llmHNl9CHsbByH4/ziAKkDajZj1CqiD7V5umsPZ46Z6hTOK3vytMZCOgOjrVtjlVnISRGLLHfKeq0ysEPd1SoAL/v5QqXTmp6It6Z2PHzGi4qzJWG+e9KyV6qupfS6dGmhEQxjhdNWFWOM5uR7pn06NX/xt9iw== 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=jIyXK717ZbzgZ9k0xICFVe7kia4cyLIACzQgT4x7Hzc=; b=e7Hm7u8p/XBHDqk93Febu/KXJ41Jjgnyb546bSeaO4ilN1rXR+pt2+BbkTvw5mTfZUACWnaHCUk2SybRninVGMMW89LEDQnRobmUFxyOfsmQhzQzg5tdd6Aq8Uiy1WEM7BOFUNkbp5fGbO8uk87VUyvMYLeuiqa/PNcDCWNjfps= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA1PR10MB6900.namprd10.prod.outlook.com (2603:10b6:208:420::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 09:23:35 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%3]) with mapi id 15.20.8026.016; Fri, 4 Oct 2024 09:23:35 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org 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, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v7 8/8] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Fri, 4 Oct 2024 09:22:54 +0000 Message-Id: <20241004092254.3759210-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241004092254.3759210-1-john.g.garry@oracle.com> References: <20241004092254.3759210-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0126.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c6::17) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA1PR10MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f1bf6f3-d93e-4567-2c26-08dce45638c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL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GU7CQR0o1hLWSw1M7ERHjbHPRY/Iq7ltecpVvbXeH02/No6WTJwFiAx/hHidqlwzjntKjIohKBnV00US7PLY5H/zSe/zhZ/QDi0oLkFj02mLdRTYHLUHKF8H6NSUArtuc+3YIsYEDVQ49bL/pZkRoCorsxB3EkZLKACdofCQI+HB4LRkEskgfBreSqexgYAQwk94aRlc09wfW1LDBWF+1e6f6QBVRZtZG4LCx3KDeGbqvs6Nk/AO7/qfT30PhJ1jIsVlE3gYu36M81dviHg== 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)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X0uhcQYIpcAF7bBeRdfo33J2neHTgKtSLII2f5HPPdwk7IT+2GLd51ERBNlfz1Isjqc/CStLrInLyUWj7UMPuHUjNnaTbM9qljycRGnrbzqq0FF2knie8LdiYm8ttjP9nk3ExbRMdNimObbu0bcQQ3isZWQlDACEyZ1QEPeRZR47PRIL569fq6eGguMew7/BcwBKwCkLiWnUL3UF9QZd5scuohvbZd8gWBeD3VNG1jJlYRomLlxjzZ+mq3f/TA6NXfUPFfaYFAC56IkfyMXnvkPNJUUg0BVfpr2wFi2NXk2EO9sjn2rRKDC4dke9UFW+zklhzkhJgsKB+x15NSBdmS4uYkRgDkKYNzrF2SHKQZK0l7oNa1ljVACuuf7NHOHA8udZJgDHXr3FBygWMzvSphTvRu+Eup87wZNlq5RT+JGp7mU631FK6HEEX5DLI2/B7I/hasgEb1Ph3DwHZJS5PF+rncFO/f5oF66JNZ40JpMbW4+RM8PoreR52U+8gbVjcQmrDh4FixziocDCB+rKXs3VzKoXmhyY8IQU/2mTGLs2fb8x89bdPaONsXW8VCVMdncQVdUrVs6gVaoBVhpcfUNy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change-AntiSpam-ExternalHop-MessageData-0: hhqfeC2M3Qa2uL0mhbwCTlHKh/fhDhs9qNmUL6w+o8WYkYOXUDohAgjKVCLnqzxKRmZii/xlZmQU/MatOsADU1FzR4vcZIriZPLYBVgdEyvoxzjTFXDXVlegoEF9BiR/vvV4DuwJibCAl4dp5Un4JooFnGnRvTySRo7cupI8oPqQagQEkC4HnXJgMMC32BqdAyYCgIeO+LI8FaNzawojRODMBp21WeuCxIk0rMsJ5/uv2soZG0D5HUIWAY5RLbiM++8hvuYT+H7LC+5GSNVXJeULMfz1SdEjA78MqWVUo2Cwv0+SXlgh2NRAGYS2uSiQViMdT8maDtdFzyRe4l4aSyEvF9EIDRNGHPOsobKGqRu3LVR+mdxcCTjbcH0kL56zKLxgVwxWWReZfBbRe+g+X24Zdeaj3cWY4h+Wm+RN9QqYl5mLLu4MEkjMEeQ5nolUjQBDsTZd1TaEIKATE9umEtPMfZ61h6hnRGOXeHBavpanWvy15YZdm7OzZK+B7ctNg7S6f2Sx213g+spDDwoyuzVHrQn4TaVcmif5p6Rv9kGSMxtvp0ddSyvIEQ8smvgLgP32ISlYAr/V2VuRH9622Xm6NAirBpx3e8dWVUaOZIM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f1bf6f3-d93e-4567-2c26-08dce45638c9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 09:23:35.1665 (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: tTZtMDCaznVQ7ZrUeORUST4QVNVcBEY1zg0Ub4l65UgWtg/YnnNffP4b5IwUSXhwupjdjvujVEFsOzutTAFN+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6900 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-04_06,2024-10-03_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410040068 X-Proofpoint-GUID: mseplWj3gWzu3gU3DRiBwvhOMBHNuA9v X-Proofpoint-ORIG-GUID: mseplWj3gWzu3gU3DRiBwvhOMBHNuA9v For when an inode is enabled for atomic writes, set FMODE_CAN_ATOMIC_WRITE flag. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 3a0a35e7826a..e4a3a9882b0a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1217,6 +1217,8 @@ xfs_file_open( if (xfs_is_shutdown(XFS_M(inode->i_sb))) return -EIO; file->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT; + if (xfs_inode_can_atomicwrite(XFS_I(inode))) + file->f_mode |= FMODE_CAN_ATOMIC_WRITE; return generic_file_open(inode, file); }