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+IkKj3MYxjiwlfuVzzdJp5ljm60Oo5F0xL9Agd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6uI4F5vt7YkV3ZmfglvjU+PVwRWNJI8oi4HSUWMdlBSCHoenJv0iLW2hDrmTLaEMxbqEeL5lxvOq2ab9TTAFlQBdDv4aGlWGfGLgf8BuJ30P3V48OujIrlBVKzWbN4mxPIrmjZvr+hfz1AwtZszfJir07GVeCOoiWkTEkP/Cfh/qTRSoqYVhN1xS/g7ReZDTJqpJpvZvAMoZiC7bZrA6kAFA9E//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