From patchwork Tue Oct 15 09:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835919 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 D53BC1E7C21; Tue, 15 Oct 2024 09:02:34 +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=1728982956; cv=fail; b=qlNnRPjpU7kDv9d0/R/ebkGCPmV6R1OIpOazMefTk7qnaQ+v5jQ3pr7VHN/6JfjwoHUW01T5RDINnsbkfilU29kyPpgCBgHlfOooyFI7Zv7D+tZmMNiW4+6MZFdff2HFMju3NdzI2SAjeXbkj/XZuawceKj3OoEawksXqfuGDVs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982956; c=relaxed/simple; bh=X3U10wfn6VZKScjWTDOaiqO+ijk2vv06rH73YhyzAOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hkH3SrqOZUcoUwHY+dk6p+CE5oD/rEjJ3U2uf8gYY1Ltfp2k1CP8PxYqtuuzlwrh5beslRgemuvcl5YHG7/1LGiftid6GdIfWXS/TiWUbeYKnmDN4GJN17um63aLIKntZGNOOPGNa+WFgyMuYeTKRf7VDLonlRfMJFrSuXrQxOY= 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=MMTS/Gn0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Kv6qr9dM; 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="MMTS/Gn0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Kv6qr9dM" 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 49F6F53C029379; Tue, 15 Oct 2024 09:02:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=3Wz+PKAUG3I3uWHJFoCK8hDmtQ0OHydkijKbkOLn0cE=; b= MMTS/Gn08zbhyfR9000PL8KE6v2ys5n9QQFsvaoEVxtFTeRYyMo8C1nCgTNqPWx6 p7rIhFT8uETgd3NafM0nMKmLEm7i1ltqBUCc69gry6T1pKtiiuPO8gW/qfQoiShU D2JC4gxv5Wp/Fec/H4Yk68ltqiQ2K9oPPdWfYjg8MA6T3ofQ9dGpU3L1EwjSh0Hn HqdkvfMgqRscQTv/W5aQxPV9iFpd+25Z16ZUd7MF6oqJO+bdxATngmHMAFAf50l+ ShyWTjWuimMzMHCCMLqpvTq+onHnqxSxgRAKT6RrXH4D4GZ1QjCV7cw4up871QIO +GX9W9/el6U0eg61tRth7w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427hnt8anv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:11 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49F90aRp010968; Tue, 15 Oct 2024 09:01:57 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjdehqu-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:01:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e2iW9cP1jQcko1qO013LuiQkoBzWWP9CJdjZ6AflA5V9C1NMwg6pzTXVECwvHYBpBGyANvgQlknkDA/LZBoQm+/X06mVhTvOTJU4SaLJZX3uLphdcb75Wb5CHHvuQdZ62q0Mq+naucYrWmkp62gAKwF6rcSZWzLwjKsl+Y3vofwpUdY653v3LO7Os/qNY31trOfibVxfTSo7IJSOQPQnIWRSVmVbUo4/DppxsSWlMxWJxoRZX6P55a2Sgvzcx5Zl1fwUqfkELLeZWW8U1pkuYHyFm+TqwdVx/PgTSdHM7BrFAP4X1yGwtqOb3MHkVTS/qJFgRMJaOBq+G9d0OUh5Cw== 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=3Wz+PKAUG3I3uWHJFoCK8hDmtQ0OHydkijKbkOLn0cE=; b=FUK/FxWISClT19ZQhTrjEwfXCar++jEASrMzK+m9u3DGa+kmmx1o40uuaIvT30MAHInYNf+eIRIO0fFVXUbXSMJgo/AQibnd+rzOOxMrZqgBWwfC1lUTDZaUNW6a0WlBFp018EPrq7QtZfMY4OiyFLaf8rgwTI6OEq7Fs6aqskzYX29ho2sStHqGFjkq9BQ17UPOMX4PsGCWp+zhwued7Ba8R+4TtnARuabdGR5ECFMGe+737s+RB08iCyHZ+PYe9P7qeCDvQlzqGYjXBjI1blqdJMJUIWU0+Ah1z1CxzWmJ+g0jdySw3OsN2k75uY3FmQN1VxUvoClhh331wW27FQ== 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=3Wz+PKAUG3I3uWHJFoCK8hDmtQ0OHydkijKbkOLn0cE=; b=Kv6qr9dMiyH86pFEwO35YFA6qTnP98DQ6typGT7QAQEjLQnFMnVvNNthyWrnqZR6HKdccGs16V7RaUQyQa+CS/EMnOMu3WRcY2eiIXjoNOjWfUtREYmzrCx7vHjaZiXmzafmQfxWEenEYJq8g+pfs8ZzZKOsNXyrc/NM3tuK1yg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY5PR10MB6093.namprd10.prod.outlook.com (2603:10b6:930:3a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:01:54 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:01:54 +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 v8 1/7] block/fs: Pass an iocb to generic_atomic_write_valid() Date: Tue, 15 Oct 2024 09:01:36 +0000 Message-Id: <20241015090142.3189518-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0154.namprd13.prod.outlook.com (2603:10b6:208:2bd::9) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY5PR10MB6093:EE_ X-MS-Office365-Filtering-Correlation-Id: 33cc5779-dd7c-430d-b595-08dcecf803b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: TQrpOFF9EZrv3f45ucM2YHDTIbjjLuJlO+zkhimK5giCsjhSHOAJb0r9npezgmrXJhMgkZsquy2FsC4yfLLTcPs2R9FLRPqft1w5SASCy3HC8rHiPnt2dgmhdzdKhg4s81vDgkK9+fRHtBkDc/V2Hsr4OQvvZ1jLwev7kVq7v6m7z/oT1DIf60eFbM+jYAyUqe31tJ5f8dwHbuTips6vJzfdvMZBPkAhAJv/kowxz1/NosNfvupMbrXZfXiFIILBBU9Mo4XCt9AAgF1ucI1K3U5PWx0K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IP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OYfcxssWs4F+0+LOpndbhxQ+/8Cz+LEakq3VOzhKHXcqpR70j0uYR9CNxnKMs0+8KBMi6wZzm5kurxchnucfjHO2NJ81mnSPtt1ebtiwi8ndRkG0X1k5w4q0xtEMnIfCsNdA/kO371vdhMc9Owi8SVrT3Q8a4cpu8GE0Z51PuU3XoV1cPhTDknMu7W1muNSZ0u5WawpvachzH0JPo7ID53QN/tzp6E2mzwca1SYNHr5A9pX1I8oPpPMCjNhUxHAZLTKGvA/R9ZQ5zq+tgtX9TjRoxxrjJdsixQ7tsXNTsEOalSYX5bWbn1vk4VLo+P4SdjtmSsHVkvrre6gBlm9lyrE0b31SAhkcH9hJUCQ55Qp1sW+knNdS0c+QNGmmd7NIdapkxiq82iXLyHzlGjCcc5goiftCXm7U7fJ/qF7hEZG5LOdb1IikPUatyc5IbRNhrkouFOdcBPyNkLYoGgk7aVFa6S/jsO7j1+O0aOety98DgFvZymI1JSNTOP15NaQ4f8gqYhf/bopHaic+TZQbZua5HJrBVVg+uwHq7jpATOMKF99zPJRnvvCdK9Bg+et+cboXy5c7Lk8uMcFpR0P9FGPX5gaOoUuvdojAA8c72WP47399sJWbYcTt3EiHiIldB1JvHqIqbYBuBib+nZZG0QgqQdV2TJppMsMqVFnBCEEdiIT9j4trBi1cCDjApYSRAZPtr2T+fPhlYEAfcuhByNwDFpTrawlf8sGUR49lWv6Iybm/ArG1fceA5RfcEoUtyWT07Vm/0cYz7x8yUveEIsKT3mvbdMYI+Bjwj+FEkcUNeRCOwOvWDE7Goi3orlA3VO9F3/kl8giYvdYAIuvCl1fBo062Tc9p1I8KUH5Y1PmzFx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iScqMRt2a0XFIg3IRCa5FoMz0wO0gFTcSnJEFjAahUuUGzdUFeo8BNfcqy3TocyPW31H2ADT7QZOaS8sq7XaZxwOads9vBIbVBzNiVLkysQO4UmVkv2FM+8aoiVA7QZ9esNoPV9GQ9GclfDjc8kdV6vQa1lNOlgeGuP1FcN0BqZZWcnufFl4KoZ0vzn0im36P0DYrv1VYz9cVgMLLkTdeudGWpr9FabEVt91Bor0ZAuSZP3J3esAcRXPI309SrKHGdRRdawYMqD/ykLh8280Mo3iVmJ/iwHmyU4zRmlOBpL8R6e4yo9v5i+evsxnAcOY9OL5+nwvA2HgfJ7ZweTEBKqN1xb/bHIWslcFQp56wSiwcS0UxSo1A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33cc5779-dd7c-430d-b595-08dcecf803b2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:01:53.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: n/AzC4Xw/TvcPiMAG07pzDENqEzHBLQFim1Er4yD4McSQlRMUM8pyXP4shS/jpILOKydnAUnYNdhYsPsDIow5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6093 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-ORIG-GUID: Uqejx3LkqsfNB_L4sD_mFDkjx13CYNDB X-Proofpoint-GUID: Uqejx3LkqsfNB_L4sD_mFDkjx13CYNDB 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/ Fixes: c34fc6f26ab8 ("fs: Initial atomic write support") 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 Tue Oct 15 09:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835913 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 DDB581D5AC2; Tue, 15 Oct 2024 09:02:13 +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=1728982935; cv=fail; b=Yax9jGaMQ9gwR3icsvSZrWZpYhwk+CREJjfwgtEFlRlA6/w7QVKFIEc9Cz0GIXjQLSQSusV+bN7JnP3h1+Tzgbfdoz1qF7HBhgLsCggUuEPUMGf62VdUzXOmyjYIN7otGZ4EgWRU05hNG+z0iMKnb8aQ5J/WTYuS2/JCoM/jL8A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982935; c=relaxed/simple; bh=KJAmP0gEIqFdsDHQw0vXq6kl8BLXN7Ilg5QGz9ewTHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PqCZj5/m1HEYbNrMc9CbmTXi/lsi9oxS4aQtBMvALu/IZWRYn6BEvCkRf+MptiQouGi7a5jwGNJddCuVtfQwQwNAmarOIGEt1vEEvXx5seMjyCIGU0McvWzTMD9umlJ6Q+nKHOaACR8VqQj/UnCiUw8d3Mg8pcD7ztnfxjxQOVo= 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=Bn72OfeG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Wqzbiauu; 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="Bn72OfeG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Wqzbiauu" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49F6F3jt012543; Tue, 15 Oct 2024 09:02:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b= Bn72OfeGd/OKvaRl5cgdmfrl3k+HNdcdgiGhdBOuCl+1wGSqB3o/BrYIJLeGa/ra 9fAmwQgGBWwSdOzWbkoJYQ1lH/asmM/AV8EsdVRcHXrNYlGVte+/QkfyWTqbhmAM t5GUS2B8o3Yf1zxDnmwhlp49r5O6h4PsFjrobBBO+o6oiTVlZhA3RDPxVW6z3Ipe UjRERFfz1sCmNrTbFpludJiRpwkydIrPvOFN/douccKt2wneImANPVriMO+7dW+2 /h60M53kdRmhjVaArYnt9Z/c7pNR6nxVqOa5ANhvgOyjkDOyyizHaOwTRikK44Ls jc93i5t3S18HLnC9MgsTjg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h5cgfc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:00 +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 49F7XTSw019936; Tue, 15 Oct 2024 09:01:58 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj75k05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:01:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fvqxJf6ggJtKpa66b5x++juovuHrkdJwvm+iwapqxxQqw9yi5C5v32hTdp9ORdChUCMyl7tl7Z7q8WgPhYlOq9tMvLI4WcoLyRNRU0l3cF5kOlTsvS9IhrnS2L4yzD0w9sj09ruYn0GY45/7fAyo1SLY9VwrodyxH4RSg7MjfeLnwn9KeiCT8IsFCSa4c8yNpK8vv1U7LP0nH3ooNpFTJjZqIzWqwDNblqFU6FahB9R7LLqJFaHibPRpiLK05rHMlN+A1EAASdIYaoIaQFTa7iIK78wXO3UtfPT176Ho6DM3hE7XRSf/gh/dKlEd5/5R6NC7V2DC0StFOvNveXOcow== 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=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b=sxFkdEmEGO8WpnPPiX6xoOpZAacXYEjef10V+LfDFNnAKAe2FFwYYNzFOTxJkju7xRk0GAswUwSi30i/LSEg9kJ6aWxZ3vKs8/v2gmRhH0KvuHgFBOH7ZOIfEViJHSQkrXCiXggDuRSO3aO+txo2buu6tF/2OfSgj7DJThnkui09fluuWJrl+/9kd02JGBhYbMdSPjCgxNOJuj0+/DnxQi35Q1w1Shz4Q0pJc/B63+kB40zpeVOR3WRXPPukol8uoXuoa1KWulVuKqKbviZI1QzZ0LMxsLFXSVBwqZeW1tPdPRC0+1h0ksgRQOPsvEBeQRZiS+QwOf5fyhVPg+jOVQ== 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=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b=Wqzbiauu/otUCbKy7gTy8vhxI1zmtz/pFOionjJIPRr8+EcUCXYgeKqJY120WXC/As/TVCjODL24H5GijkxYlqwYOv/X0WzYbJSzn/IehPzetvBi/jam8UbSpf/8HY3CJqzlOnpegxqjM7Rhzd6FCOA4wBAXemvHGIAZikk572w= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:01:55 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:01:55 +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 v8 2/7] fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid() Date: Tue, 15 Oct 2024 09:01:37 +0000 Message-Id: <20241015090142.3189518-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN0PR02CA0021.namprd02.prod.outlook.com (2603:10b6:208:530::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: 86c5d5ba-9b55-481a-3322-08dcecf80470 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: fI3FNGJslnfZTrdiQ1h+qMVeWShZe3MuPvNiOa05SJ9VBL2Lqgs44CdxGWa5NmG+PionfhV3ooxPfhLKfbFsE3H+GNdEh7jUvQcqCJndD/nMvHL7e/kWmGVJiylPucp5XGhE0/92RnAoJZ6sUAr7TIMO/oYsgvvdTWlO1bjrtc4RSKiz23OIOvtgwgdb+Ew6KiuzbzF2aM39iC3NcpuArjYq6APXEOYu3J2Dqc0acD8spajocQ6chJYDcQI2fNGZmGc49IQH5qqQglbjnkLHO6L7R97ZjAfDiUlDmp35BpiQL9tBgjS+BKJIA+nxL4dvbJB4SmlLEomZ5SimCU3hEel4GAV6bo2ZAhzLyFtFY2jCBwms3eMElU4PmTvsOWtby4Ur5tA7C+etgKZ2LTyIE2dcBrLrUMiOEga1xBVgrZR8fLKREesl2K/SZabCswVAby7nT86M6EqaA8Fk1JdFAHUeMHKnfIUqlY3HRZuRm7JtvIHYZjcbZvJbE4l+7Ovx/yNYp/7jMpYMTComBH1QMLjBzZOxhEHaWf4DGO8vFv5oA7Zt6VvCsTOv+tT2rLftD7gx/oHY0PgThqkKdUAbtMhWjo7p/1PhgUer+g6e6McdOEGs0IHFJWIrBTCbdTQHH8ljL1sAGJKh9wiTztD4Gl9M71DbMGBbPAvzIY+Tb7GDMtwX3xpFZQk1ImMpMF3p4D9IIn3kDA1dv07wCxYzO/DLwxrDnEP92Mmbhigdrmn1gxXzdpyXfMaSPwCXB0VaJY8PEizU2F7gm4TCxB6xPVFeSDlfkuVw3YnfcqPSaFp975Mm9fzmZIaxr87+4jJzRQWtrJV8fcYGiOv2xBZur9LGJTn3xmDdCyimAjxuEmAgwHjwXqhBIFyPs79sW+Al/uBVgndSNadd6F/LsYCdBbMmK5d4PzPB1c9/rqWiu7ZM2CQLQdxit+KeH4Ga9i6H7ndH+qzPa5+0KawWEO5JKoXh1/5pamNeDvipTxSPptWvGeYybes/qhEMi/0W7mNsiC4DZp4qu/u6uO1jim5MPrAtoX+dg1AJInve7pggN2qWySnUsD/eR2rOh1UzXmUiAIthyL4CdtEN+JVFJnVUCu6via0kSrQspXeJHWWTmQrXLZdrbRAShRDrQaDQnSGZI6vWfeGKldQHX+YvjfLpPU89KUOCUKn0s8+eu36bO2zaG1XgfjGBdPPC+S/XwMm2PIH9DBdz5u7ZUV8JFv/rDh6DZ6vAojCdAS0AxSeuQ4BkhPigDhk28RPPTn1N/1nsdING7M2BxolvVSCUh6E3XA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: br2ddAFTtgttvsexIHDtQ7TaSFl+zdI27tgR+UXH0Xo6F+l4Sf8Cr8D5O6xI47bDvGs11rTlPM4+ZqBmEXuQNrxXcCxkC2/ynACs37o3NHQx4g67iQLyVmz8vm0KBLmL7tkNdJS1xvWqBrI2uc+kltpZUKlsfs6yOoOH28hd6lYuhiofSX/w2I0t8DwsVHhErkly836lMrMiuMy8AtcZ8cWlZ3jZOij4i6xhH25xYPs4NJFz+0Y0FFZxCxJRx44AP9DQUIEqiyScC62cvtmqb5ZVD1G3VNUGPEH7ctWrXXP7RJvGxVEFlEoA3nisikCwVmrt0qNimFAtIH36YWtrtxmL1b7pQ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IT4i+AIFA+U8gCke+EKf87LkDtt11mcQvYTP4nUKm9hRkaq9UfDxYj8uX2YIEHdnHr3MR8Z2XolAZKdai1CMmy71ddyoPp5PDt4IBILKyKml89o1BoSF4hK61pzs3F7nYNf5HRUZBu2Nwy45JOJrrSI0PSaWWw/1qfG6SdHYOtiGMJa9VYbTh4/2KRw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mLKPYC87kDwHiMkFZFD7IsuTW6y9GVbo4erb8MMeaw9UV0f8H7yCemq7AJCdu7D76qDpl4nRacRzdffZrUCYTeNUzCeDuV/oVbx0olxddB2vFm8uIvpu0ntnAIdL4QW3UzLKVsdbYE87LQcyvZKIG4Kejg1JrVt8wD7BEj5TCyW+flMJdA2d6ALTdKVALp0wDq4S52E8HSKpzgznKKnZsbSl6JIlI3a+7Qnli8tlresHxx1HwsJehhluOrHnFc5w3LPigfgotPh/iKZzM1HXdM4nuw3IvVCTIRsdf5GNUJc5AQUOd9Ws+3XRmQxiHnABl5AgWMHgYTbLO9KK9rYB4XY/pAIMUq52iPqnKYzvkXpdjkS5UKy0rM+Aque0oKx0aXQN6uq6VSqDcPICd8Tn/Bra88QQ3KqUw3VXEnqrlALzwJXoHbBGfFedFxW/ISrZYYwqRFre/qX7xnZTfLQ165LBa2SoK83KpHvlI/ilG1zeJ6vHmF4uQrjztEHNUr9/9uk9E9zYDTyQT5JUZRWCr/VHeess10oG+vN/bDSu0lS1lRMOaV+6RenohF54h7DU/DZhzZDcjY6f9mRL/rmuA1s98E33SwvxKTy8Ni33jnE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86c5d5ba-9b55-481a-3322-08dcecf80470 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:01:55.2193 (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: y1/3VwpEy12hhQ+uHBIcNHR5Vk5RIX9gkc7IoiE7KpzsI03acsEvJLj1ovt3YF8jC28++uH12r/BC3nf/kvE/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-ORIG-GUID: 5OEUFGsC5HWO2-CspMtqL2Ia0dburWVi X-Proofpoint-GUID: 5OEUFGsC5HWO2-CspMtqL2Ia0dburWVi 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. Fixes: c34fc6f26ab8 ("fs: Initial atomic write support") Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- 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 2c3263530828..befec0b5c537 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,18 +1830,21 @@ 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; } 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 Tue Oct 15 09:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835917 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 328181E231D; Tue, 15 Oct 2024 09:02:17 +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=1728982941; cv=fail; b=urGYuKjnOoK6UQXAd6Evd5qE6yShekZeB1MC7Ty1BQi2TmGL41Yqz2+sBM3tAIj8JEvUFx6rajERrEsNgI/zTmUbY6akTnIO6HzP9ROJtMuzHCqMCYf7BDbzpux8KWlPUjyOK7nJ5Gz0K6daGUoLlMkU/asYftSvUYsEz7Y3suA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982941; c=relaxed/simple; bh=EOxTGgWGNvSBh5KVqmsKi5I5eCDIe2YPdvjUuB0v+j8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=OPv6uV0Z6Pj0kEcu+gjNxSk3LK1fpkm8NHtOHD49F/JNDAP4gcIrSB22IbV1JMMmhS+EDozz6P5k2jQr2giHteJigiUa6MBtyN7C5hsNKWJt45RtAHiEbyeM23G3MQ6EWPnd2rahWThb3dQYkztBVPjZhhY6LReANegefJJ56KE= 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=QuAIG1g5; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BpuJn0/H; 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="QuAIG1g5"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BpuJn0/H" 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 49F6G9VF003405; Tue, 15 Oct 2024 09:02:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=PwGjmoZ5QwxhepSH5fFJmt5e9UiJ6neS0UoagzexhoA=; b= QuAIG1g5kyZ4aKl27FmihQWFByUiwd8gj1Yo76bDbads2bzrDvXI/daOuFExotG+ u+69SbuuVQC8Wlq9XhZcsYEGMRRWxQ0UWiwy6eomFTrqEzyb93P42crLrM/hHMTW J+EgPrITadTbq97iPsQwac1ExtpjnBIJs29SBWQbHKmH/EIDf1yH6scJ44Fcgw3x riDbh39NZ5cknjY5AU7NaBncd6+OL5b2YSUNg9GQElHWK0OvTS81l6EZ4XzwqutI l3NDb/QTZ6f7R12RLyGP9S3XOa3XOAQacoOaN1yNUrDGudgCKBhrXz7qnZncnz50 4XDz3ISchOflgu7YL1JAGA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fhcftw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:04 +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 49F7XTSx019936; Tue, 15 Oct 2024 09:01:58 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj75k05-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:01:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZNC0ScCn1swtXgOUhEpKoaA+2eZ9uxuv66+0IWHuxuxFCnynbeJ9yFmhwrW8DKBQzB0olXNItCQJqCXD299CdcHqWAXef1/p3e89TofL021Uyi4FNl/IyEwWogJAmSDo/nBQ5QKIu9u2pR9ulL6JxD/zLcq1tGLfGBESITl9JyOHhfjptw/BnHIAla5XlyVVM7O/PoLLRVwbxV+nIIs4kV2ipF/0MF6UXb7AwceKay8+79HlP4cKxsCgzsTQBcRYOcu6VQBGsbqHMLQaheOxsuxqqCWxdprjn1rhRskFAx/x/rcihmA9JqELFXsRPqYaD/apOFOPpfzMSrEISXl7cQ== 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=PwGjmoZ5QwxhepSH5fFJmt5e9UiJ6neS0UoagzexhoA=; b=hNMF01UseAWsH9va6Jezz6GK06k75VN5+7ZzEHlSLwjqlIba75oG77shd3GEipwXbQl6MlRskt7mbh+7ppWBqre9CM81vKmtN7lWLyEaNcszTZbhAQsKVf1xC2E6Is4FibKYPljsM+W0ed72seq8ae/HEZrlF4uuEBhv3OWY30ePD3LPwdq03A9tag0O0iWca64AylNYBYx7ZzLlulsGlVYxHdj8qhBl+9d8Iy3qitYsCncPFFgYIZUBb1fDvhfLJWpDmfk2iJjDYQdkgbIlsVTc9a0cT33BH8zxHXAwGz0o4tO8xvHs1HctWH3dOxPcNqv0IoqOFVw26oD+8sAKSw== 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=PwGjmoZ5QwxhepSH5fFJmt5e9UiJ6neS0UoagzexhoA=; b=BpuJn0/Hri9i2ltGiiRLWH8Np0GTmGS1pQdUVYryq9+GikAzNV95UCcDr4hN8V4TkIAY2mw3/Cd5wZ9hT0MH9CJHsdQoit8j+Hz4eRxjNKmrKXX6bGRAKy8/kcgy3YDxy5t4c5S8R4yi0X74f2AKrqotuHcstcA+cVO+3IzvsfE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:01:56 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:01:56 +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 v8 3/7] fs: Export generic_atomic_write_valid() Date: Tue, 15 Oct 2024 09:01:38 +0000 Message-Id: <20241015090142.3189518-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN0PR02CA0005.namprd02.prod.outlook.com (2603:10b6:208:530::26) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: 21a1a772-1d8d-4709-a388-08dcecf80542 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: QwjxujmzXJi8Y00McSBCXfq41TyFlBpQjcgZbTe7iyHl5LcHkpI6pydyt3YXnX0QPyzbHfbVem9Ap+UOrL8ZuuBiHRusICJ0t9lWHbu9QTPPpyEOY0I2D6whoxMZAqn7DVRBIMpwsxkVraG91kJM+FeF1yB7r80tpJmXJxEh3My1mrz2ZTIjz9J2V+E9w3JwFo1tvZ9L2Vi03+GXDJ5VzAH+s17pkvKwG5Ax9mUeDYOb9wAfIjkmYm8vh2zbWQiOMM4T9a51K8kI0HMPG6HxPu6RvJOFYHVK8/jEE8A8ZkyUXA85Ayupeh2rJCoalFOahP1KonCjVdae7IJAgt+IYvYBf78QnOF75NFpjV2w10qlXZVd5+oaXZvJxQUSvfnav4/T4xU2Rm3y7PXQwdnqJDu5Wc7UJ+s81soYBkHl1lm8xXHopsZ+yV7C8KJLqVOZxPR+yVimvMAeqWvhZ2LpF6Ypohjrs2cu1QSEhHL31TtNrKpqBQ0rmMyg+KOm/rNIQq6SwKDZtwW+vx1PXZjjrgXrzEnZiKsmRZqr22mrgHxJhZmPybUcSMWAWpZc84IeU+Ma+1YVMiotxWIMr4xw3vB4UWSqT3J5c12C7XOCE+vbHng8LhKkwfn80mGK/we+oXJcZjGeS5qMtk6QXHuUg/JmeH1SUTbIRXdQH4LtciwLXhre32pBQFQygaFbBJjV/eXTsBH8qd4MnLL6KZ1AFpz+iV2gU4EhLzSWHQCzoNaxilbAWt0vr8ECcVW1frtuQE2Knu6LSpzZyLIlE3kZ1ZnsFzJTV/pQd0du2aKMSE6kZJCvSyW59fbDmJGeGZFKpSHtKA7enyf+4rT9iBz5HWnqI4Pfltm0cK7rG9UFEFmv5RhQA5x62RU4cnCP31DCADaosecVdOKMBCre92KyagDX/Ye7/9LtyB/Q4oofQy71EwKNw9eXJngp7HXfD4UjAmGqOw7e0InXI8WX9ZJNzKh77hbtHqo7LiYISXpKUI5lpzqXzdTRdP4hTOAccJ7ULF+p26S3T7MtGc553T7yNBh4CTxcVO/Jx+E2fnwMLptgnZFv675Vmf9vis123l95pn6JmIPkCK3p7T1mZx4pSyo18PMIYj8FtpWYRkqq5n/oKyTL0mr/jW4G/1g3B8wWcZokejTJOxhMhzD2LBrfYKBEFNXLXy6elxRLeuLEqgJnvqqkFH7e8CFpWiLXkpJD5TsH5r0u3d8tU4bXy8hb+4u3Y4MGVKgIJT0e6U+ZJxUIzg6xAy0QlPRgcpE6NclIUu9Ehg9AZEzOOaoxKkIVXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UkU08/qTg6e09ZNRQf2rqa9+8zmAK/cTYO1+BAy5s2o12Z5KNsYMB4YeyTs4Iei1QaFijUkcOc7QC16LmgKHEFSL3nlWACgyAejLba9y0yP8DDo6Km/60jBGZflFYHNbkfOPs4I7+o5pA95O9R6lg0qHvnGK/fyiM26MQed3297dJhMjesvPbVlq+MHlxVidOfbp6XCNw4NLydLy0ipl90Ni2c85RFOEQxxg8dqADpBpPDrfoKJTP+9qBYRWq/lta9ydby602pzsn3RFTqaPjxxtkBTLpis+UH5eKfjggDPu8pebPzjH5hT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XIi621Y4v1hiVN3gFVHadZOcSqrXzkAYrjCUS/OTNKSJbblRKfCx22x2/x05F5b0D1IBM6fNXYPLzvqTx1mx2UP6k+WnJMaIhG8qdx+1IExkvcb52BLneyyiphSD9Fiekgwvl9lmsIJI/llYeUR7F+/wb3eaDdoNMHYKxR5Rf0Y1rpACXarOJ4wyGmeZfGlSzZRFWgLK6szcHVXMEUcxH572Oe97w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: abJGR2Fuvs2Xi+O7XTVXjQH2RBrCMK1AtM2/xbVM+DkJ19iIXqYFVt6ybzNh9aOXeNoRti+JHzEOSIVqpusY9g7lt2zFCFMxzCktv9jO0iQG/yxtM0UK4EdquLHc2F3wme2GH3WjIXsV0vo8Se2BEuoO+D/+4qPu3H4RsPEJGoR6yPBWyCjfvk+Pp0QzM3jgbWP9/Jr1EVqhzt9EgjOyo3NNgpBtLM1qc6Fm5cRjd4KlZFk76Z0rouhBEWaj/9emjii8mkR6rb6T5VbMoBbb2kWwwD10vROovYZBvXshnLsRb4sh0+sc0Yii4q2VvOcuXZgxZ57/BouYuqP+0I/G7qJLFSs2TPdOMjq7YMnIefoQ+s6z8dK/xvARrvgslUnzA3fDHhszt17HpwS0p0VirR1ybRaMDAVAjGPcgj7yZGggrMUCyIZ9Z+T6suWa9kngP0J2/822VS8r0ERPFyfpdqCcT8lqoF0ILHsL7I2+H+x75Akd6i/q8pGFijpQjG37eAfcwBMaJYBwb355s9lZTM9dfUeTk3d1RwIdLm5PfdSNXenPPbuKouMe+GkW+Icy0WdD/jm+Mm0OwI4LgCWVn2XJM2xXLry+PXhn4IkH2gg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21a1a772-1d8d-4709-a388-08dcecf80542 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:01:56.5121 (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: AhXIuUFc9V82XlhNnC5QcnxESmHbtYMgX59lVXGrBAkZFus3EEdmRo0q/z1iWdtFfn+hGxpuIPSrzMvAnNXAAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-GUID: ZgvovGMMlXsw9OGu_iWOUB1yRSJYAb35 X-Proofpoint-ORIG-GUID: ZgvovGMMlXsw9OGu_iWOUB1yRSJYAb35 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 befec0b5c537..3e5dad12a5b4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,3 +1848,4 @@ int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) return 0; } +EXPORT_SYMBOL_GPL(generic_atomic_write_valid); From patchwork Tue Oct 15 09:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835914 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 DDAF81D5AB4; Tue, 15 Oct 2024 09:02:13 +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=1728982936; cv=fail; b=JcnVjpeiFahlOfDZs5ORcRI9ymaIrKUQ8xJdpiu5ndLjOIy6YGSD2xS+bbTlM+++SGSWAYGlarpwOpnV+vBoOqkGzKuPOVw6rsD1VER3WQNNjReRPOsOxUXYIv2sDezkWwtDfuopaqHL/CSEbcQhrKChUHRtzY8JYEYr97I40ac= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982936; c=relaxed/simple; bh=m4fx0+cCtC52nY4lgOxPzkNwkAToDONzLOcOPTArYK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ITF2pGbUvCKE8OfFOfGlX2lSv7/fkY7Ar56ndPzsq7gn9hhbmNwect93xb764I+IsBGQSXIc22S6w6eGtI2c6BjiLlEPBfNdvtAi6VzPyiozNvc0bGgL0nBGoZ7x2+vcbdzmP0gH8IrvW+hvXoD2XN8mmb/Mjjg0IzZ9HH78atY= 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=Gxtni85q; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UV8rpvWn; 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="Gxtni85q"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UV8rpvWn" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49F6F2Vu012540; Tue, 15 Oct 2024 09:02:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=oPSQkBKXTw/U8/Qjn5+7yaMQ+m34nUuJMuR5LnQyssk=; b= Gxtni85qrt2kJW3Ke3R/prEhvytecINJ9JG72y2y6iCSD0AwlhHpIPRAO7sSl7PH lDlEZDSDmjbe40rb17iSbc2inbkp7V0lHXqv1bPacoFc7QrS7i7LbTj7QEWhiD3o rosQ37VJri0ZNbL3tLdRoCOt+UZ0ZMCI7QQIJuAy5QWWaCNU62i0nCDBsa0DMxq0 aD8dbwatyye05n7A9k6VZlFmY5kMVdd+O3gcYv3HaDt8HwUK5A0dMDhX2h2nzVeC 6gemvRKnoXbTepVYpwN3zx33l/rbZBrPhXEv3FtVJmhPvzh4WV/fM/CA1eyKAO5J 7AzH7ueNIJ31yC7GCUFOXw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h5cgfc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:00 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49F8wukM027117; Tue, 15 Oct 2024 09:02:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjdp9t3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RTMSBPnHKMRpqluubqxsQeWpWId2nBkcaQ0S/PqdeD763RbHI8g4TWGxvuNA+4IM84XZOK8RwhiRsxgMk4EoC5bNCfuCHqyY5oidwyyVlAYufm+2gjG6ubB1joyRgOtS2gR5AkYmVRR/C4g3SADBKBH7A24ujokgUicGknQQM5o8JD2slxxba6R1CcRh5EPPDyGrq/Tvza1iGH2AKsnlJC/0WARgr4VmvYlGdpUM+L1xDfdcyenqj37uNQ4dmm1DJ+G+LpKw1Ub5pUorEYIsnDkmM5RGkloiRrbEwVs7USlyLXuxdhp+No3Hs7NfKmXlUewm0v+AmoKHS6wt67iQtA== 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=cw0L7fX9IlCAT6loQ8eFU6X4H/AReTtGLBXITX4nJfBlaqR7AFEAbO99SiSmkPAs5x9hhmVYm3jPh4+2+izHqSQlVbi2nCFKgiLY0gaRmgimsvywnFICXVCm1DliXcp55xUGmjFkv2+ZzB2+oznBXqJHKdorkSuRlbA5Lj/VIO5NTlX7zl17TwarLU74PAVTzrZV7dRoN8SD6mna6sN5JbkuMQhQnLFiB5PhgMvxbqpmtwUrdJ6YUUAPVg06/LdjHS1Phit7wBlRs6jSG834zALqjDs0s8p4e/ThUJwaSynghRTn2S8+gLDD11oZBxtxhYXYAnECImcBLYHjHyQ6hg== 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=UV8rpvWn5cIu4GvMvPFy4+R/Osse+5TDsS9uTg2C0XWRCtO8PZYw3UpeaDy7qt6RwJQyFwYPgM55umxn7MCxEarsLU88Zf9oIxzRm7srB5kaZHKTEuLY48EOesxc/0hGh/275outkiEYEfybS/ZG2OpXZgEXpVZFwfcdboBJxiE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:01:58 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:01:57 +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 v8 4/7] fs: iomap: Atomic write support Date: Tue, 15 Oct 2024 09:01:39 +0000 Message-Id: <20241015090142.3189518-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0030.namprd16.prod.outlook.com (2603:10b6:208:134::43) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: cffb2cda-5f73-4878-6cdf-08dcecf805fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: iSctveB6IKAEH494Gtj/UxmFCzH+lW4MDbgh5L7yvfjpqKQE00eqjPbCGXoNxVHBrb4tzXT4RZKtLaPCqDVUfR0NrqQnAMQI8CxAKTG8dhhlYj/3fPq6t2akD7QL2qoNUE+b1OnALjvTKVfM6H0Qhu7qJA86VWImhf8g/N8JAmhMSwaDgM/8h2E/y3m8xvndlVRN6d+J9CI4ll8/OOObYSYckS3g0JUNtbUxumTivl2SDLzRI1BtgRT1lIIJz2JRCV83VS6164iAP10W0chGIocL5J/Es3ncMukQH3jDjmD1Be4iLmn+KSNygLg3rkWP8SfOhi1sBo4m/pBqtpG2KjAYuKahXe/eaCjbp51C6zbKbraW+oIO/uYpegpBBn4PLfgvWrlaKnfysOQQi/eaita90U49ZsG1+yn+To/SqtqtqN9ynjaaGll9qiLDnjHiKLM5F3q643IiGvX8VKb70WxaCaenJss3/jsrOp+3sv0RY+6+fjFtfMb/CiUgF6a1i0ReEXMEa+l4bsV2ZSRiUO+MHzjTxMtxtQnzSLMYeaUlutV+s+hbkryPlzzHV2U+VCysdlhMMWMNER1opu5gMFI7QRXdsMgqMwnj95A2c/T0Zf9n+8v0Gi1PaQXaN73nwGk/TyRetrlKUfpr0Gzof9nAJM5KvJ9pUaGLaRgUdrXabrLTKkcwMC/ysyAUQYz8CFIFbsc5KNNcdWHOf8WyOMU2jOyf4UT2bpsjvQQvXrNj90S8WpGSOwJZDzk7gFGtrfn8OWJYt3k1H5wyM3rt82NdTIBCi3+qBtdRCdug5rwtr5pwsz2HjIAH5uwFyk17Nvv2xw12HN2E3y/8Bzekf12/q34dfyv9ccksXG/WcoV94YJM0a4jPQwmjrGAu7Fq/JTmy9Yqbz9iQRmdTOWKckkljp0LWdZSwc0lfTbS/lUsW43n7hi+7lJOxUfilYAOPtj1o7do80F11P6JvscxE6FEhpWu3Qnp4EPAlomYR1DaU2w4/VVJWiAU7NAytIVc/UOW5z0CG8stco6N+In6J9xAQBlynr15jUyCM+iXccZiqno6gswHCgZGpbUWHwAJV9ooxelPMrKRv8mmfgbMEbcwAhRmBpPQ/W46g6yBx+bbt/8EhdeQ5IZtCuZy4AxMDvm9IZRc0YJhvzSn5rLilhWJC9azESUBFUp0IBG/8RXxYV40h7RMWV1qnQYi84fSkvpAEQ64VTlJh4n958b2YeNzyWD+pI4hYJq7X5BzjN4mt8MpT3/9UmWyxwIBpGLQcVPZvhgJe8orSienPto70w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AtmSS+Oz19+qh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8G49fDN7CuU8ruaW//U/0rmAWCMFDOuzVs7nOOShYfgKwz+BQ0EsyKKfrF5hwO3dpU3XTvOK325TCAQGxc5BbPhOobCabRfvgsfomvWy6Irf6GH+MMrYH+bagSNGhGOkeuPbbfejRozjC5OA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cffb2cda-5f73-4878-6cdf-08dcecf805fd X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:01:57.8595 (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: OBX8eism9TqedjNN+9miSE87IqPBO2m09jg3viG4ALxaLVy15elDvEmDx5E1gd1XBjCJLmN43GI6Qx58XuqlGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-ORIG-GUID: 9zV_QkJdDubBPEtH8TwEIgzTD037EKbs X-Proofpoint-GUID: 9zV_QkJdDubBPEtH8TwEIgzTD037EKbs 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 Reviewed-by: Christoph Hellwig --- .../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 Tue Oct 15 09:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835918 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 681A31E282B; Tue, 15 Oct 2024 09:02:20 +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=1728982942; cv=fail; b=Ehuj0Qg4zdO+1PQ5VEXCj3jSvRpsBN1OOJu1cotLfUhLSiQW1Z9kYM/27OwO3dsJ1JnR2fc/OVXmSrjOlJvYMP4/OyosgBE61/0nlLhyokxE3PBj+oCUZ/yPamRRsPFRuIz1uQq6lN+GJulMe5PEDk0S7rYNQkILdl1/TwZAOyQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982942; c=relaxed/simple; bh=3X6DJPSUEKcZCwy7yqUUBhkUVjg+/1c4hSZ2FRoWwls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ROHJdeZXmYzuRD5sEyWR4oI5MzAKJpq2v+z9Q/OvmbcZTtTWcKyajqQy6AHAh4Mji/TAepYy9biqkVrVvWKsdzIgN65T0MirnA3yuzvniu4XAVY5v8H2YUyGscuTqBhDkh/ij4WKunnDrsNdyLnzgaanYlSG7iJSb/73nj0g//A= 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=oKwZeqZf; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=d0TRRTyB; 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="oKwZeqZf"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="d0TRRTyB" 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 49F6G9VH003405; Tue, 15 Oct 2024 09:02:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=L4N3as9Q+VWUsT4A8loGuGqUn7/qQQ0MakGNzOMVgOk=; b= oKwZeqZfMh1TGYRNMsPhjO3wH7JpA0OYN7u8qt9P1EOWfzcSdaTYhf0RzxFJAJOU Hu50uxklMeA4Qbd84Xy7KxmKrRv0eFZtSuZLjIozhshKfZmVWc3ALzdOtB5hDUTI Pm2XbMLFohB8pQRBTzgiHQ2+rOf89aNY8Pxc6O4sViISBpTqXbcYvjw5FYtTwK5f OmGPYdOhxzeGIqxmgKK9PyO425kuhP1ZaP5uQbaBkGmmWISjO0ZAM3Q4GYH2VdZ+ Gsgy5++Z6qGhub/ski9AjXt41n3vsuST8PnRVdB+mmY1TRTdkOeLr36eoHxR4r1f /HfOobw7ulZRwfUluezeug== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fhcftwa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:04 +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 49F7XxXv026388; Tue, 15 Oct 2024 09:02:02 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj754ms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UHyo/nlH0kUjtpZc9qA+75VEEH4BG7k2vjrjKsUngdvvCgg0R4RBd/zBPzgzh4QUAlipR9YchY1vh+47E1mD+qVYryKHmf27NJkUMVsH7Q3Y60I3XeVSJhb2MKn5z2AJ2q9O+TiegPV5gSFXEJM5uOP6Uf/2vtB5AALaj15jBBmYBxK6s8vsieOs6tIRQsAh77kDzdrTJGcFUVtTFtZGmNL0S6aEAKyGcGHlDwO6+7qAtYr6NrwDjrm9r/nXPFldsK0gjnnkw0v+rZUDv/8nIEJBbCnTRLFDiVPGQLdHQXiCIAQU4MxQfTWCgm+zEUE+vXUDR6bbGK5QuMu8ugDgpQ== 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=L4N3as9Q+VWUsT4A8loGuGqUn7/qQQ0MakGNzOMVgOk=; b=Jy3FE2LK7OQyzWQW2xLnCtNM/awVLD/SieAbhdzuRWFsvM93noEKq+g/lxib+Kt6xT161mb3dwa9772JB8l4QWnTMxpl78/7uLnOAuNJ+mlYWrpdKZDG2CXCvqohBAAcHPSqElTPEHPAOqFCkm7MDMqIqn7BwnqEEli1fRQe3flFpxGYqtRmh7vLn+GjFwjLnvHO5CIOSIXsZ58bdMDxsXGf4Z1BwSPgq6zpKLXAbx4jPKKChQoFoy4sGGTrXxDfCxNzvo8KM71UJcoD05C7u1/BVqJMHMHRZpVSilwJXqvP0d22yZtsIrl6pF2aYpqF/VD6L+N12MwrzejQEeRO3g== 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=L4N3as9Q+VWUsT4A8loGuGqUn7/qQQ0MakGNzOMVgOk=; b=d0TRRTyB11efm6elhSUjVo9b2E6aQGAcy3FEK5d+eYVjsiwF7ECbXy5BcPetr3QhEnn3zCUOYxH/9mdQq3rPfRcuzTl0r2DzP5gar4MYMJruAtLiCDl9f92pnTVY3pNWijdfXDk+jMtTPBMZXsi3kEYMo1pAt9A6iUmmNrumU2g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:01:59 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:01:59 +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 v8 5/7] xfs: Support atomic write for statx Date: Tue, 15 Oct 2024 09:01:40 +0000 Message-Id: <20241015090142.3189518-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN9PR03CA0137.namprd03.prod.outlook.com (2603:10b6:408:fe::22) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: ad9667dd-e374-4c4f-75cb-08dcecf8070c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: guiy+HLFcsENXNtyPve6nAS8nAGIMIfb6exns1WG57FIvnNlQxvaeGZyRjAJPYsAQPYpbtr9SKK0G2sbX6J/EmLmVOu00GxyBuRptDOGZrMRifmlRZFZuzej4yCDhbSvilaYtqWdm5vBkQXwG6VymO3FKXFxFExO6vSOvOK7pinwGEok0m5tAPeMY3e2ErNfk2KuoxnYzzPsbLWJP3afLioqsEGxMk74xYOsktAbHNEH52quNgHB8I1hNeiCTzMMUd/Bx9tdWx7T0PFZxUEkVaLYW9hGkZYUtChkW3NzN0fgZp8yyIx4Mx5o/JMCCPrBKeVO248n6JD3j0dPBlu3m4fZ1UUPP9P9lyuNb3EYmSd9wqDYEAZF08Mq7KauL8kbhN0sP0vRcVUv5Ycz7lBqheHLqenlEbMihtlJQj37Kbl4PlBtXwLqONMWmsResUaDr4xXsV4I8V8DeJnuliwUcmDAxs2Dja/3xtNJsPyzjPKT3wID0ruWYvqxLPCp/G8zn4CK6nCAMZlN//Q38Q1j/YFiVtkx/n6JRfgjxuilPox6BdecaVnMr2S7h4SLG0zSYLTHNoGyWGxOHHzBnTL2020mUJqDzi1fCcRS6FmBuMdPqrsAhw/72DGWBtA0kGwGbg5RZIguoHRTDf+AgCBCAMiAc16/3lHqtGSrwLFoMwqvwoF6plxoTu0AQOD/0q7a5iJQcUdK2AYOZZJpG25OEJm0nWm5vPXALiWX9lo2aWeq9tGs7QcAXibSnowkv1Qf8ZO+ZO5X76pzFvc5laqIUtMTs76Pk9FAfPqvzjz3I4s9TzsucHGuZoGoghPWM3dTIrNNgPfoEB2ti3EA5GhJbI1Bw61xgrhtYimO3g20AzYPs+i8o+FDspgLKIgYLJa4S5CM6EM0sreWS8aGIaU5dcD53lfSuVZGEqX/NYCSCD4nZHJStwcoDQcELju9tKn0VDxcHzT8gzOoEvSw0sr4OOGyGFqyGA6WErPVyGTc+rZRsHhCGczcpjyaMN1AedGYt0BIkqxgjiLkkF1wMyTLJPrEMPGXnqg3EtG3+9QtMnZv2/NQlxJ8Tqnk6h7Tw4ONUjORFSe1O8Pw0kaC0TLF6tjHlgN7iTp0eVRwM7E/k+mharfifPAacKaDfgVeGqL2oZJiozUarJh7G5JhR702g7IrPvt+eLnfi+2u1Purl3pkmWTm1xstKIm2V0D3Sh8r3awvy22mu0N+/Sc9NPxNaQLwQVb73wYwOFbpY/6xHxxDgUDDkoFPSZCE4ndhs7aEtrE1Z+5W6Em364A/Jmmk5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zcy54dnOcBi2lOOhTFqMpx6iMrpz9O0Dh05C19tAq6KQukEV7+b2nvTXHkMooN6hFOG5jCeQZpEiA89h6NWKgb++QnXFCM9yKlhEaTWMUMDkwf+AQ6sWH8OqdjJ7F0jwk0wih3cykYq/61Zdv6LaYBPRYTmQpdz5tAxqz+HPHAh8c80zS/LgozlYg1QDjtqKvadYLkTE20b/+mcZYnIPP+GazpgrSoAIpqwFyWs0qsn8fspaRA4henki/SzBAl3JF885qyri9VA/rHZxfAD8GMGcFzUTq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rTdDNoYVlaqNlvYy/1Bacl5eQZYqHFCJwuCyfl0QBR9IjbYt4SJeQ2oOs6KKed/oQclasJFMx3U0MuLNUv9HVORiuqtEZmRfPJI3m/rkWoyFzHyBJGuyiLuK9XHlRenxfn/iGY3E1u21Fywqm0ZdTqg6d3NXcctQQUMCEJ3dxzh1mwP4tv1iFogAU6p5+NLlTsIc/k4yLx4A64yFNW/W0t7H3AxZbAui3j0B0K7Bq+JbTsdvJsTfNRMA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5/IBgxUVSUrR1fWYj0V/dmOk26MHU9QRp8T/jpNmWCPrKxRwOtwYe2Vzveb96ImdJGJgPSvrEyyxxY7Qw9G7mKrqAofjEHaDdqUSH9BtJOGCaZSKqu/xLvU6ola5lYRAaoSSuKPLLNS6sGkOarRO/2ZFm5uHMdlA73dkCMVryadaiWo1StMkVR1NRQKetDNIV92/TU5xkAZydGslcz6J/DnvGD1XXEcQpJGrogSPGitYYiB6gXXOxb6wLdBgoc/eQTqA6C0/MlJ6YKDZJWv+3F+LpWb7JDhDNTgSif/cn79mczOSXfENwGZIwFBoLrTbneaMQyaFIBWCiSpVsRvPsn5yCn928DoQPZOLDKnF5F0tN7NWELM6NaPEpzIHTbX0+tZMvVuuCchfhk7nJIQCweigl9ibvNwwPwRDOjs7vSC9Vr8Fz2HisgUHYULbnEOsBDuZBEQlmgIfQbhqIZR8kp7tJ07V2V1N+/e/7l7ftZUXnh9aPRfIG0H/IHXSmBQAWGyawgPXXiaYEP6zrk5LrEuriKy4i0jeSYFqhSeapn9H5zWLMZBzjEjWwkx4bGCv9EwD8RQssu4pOHbeN0h4FLiVjMLhClcPXwJU9DOGOzQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad9667dd-e374-4c4f-75cb-08dcecf8070c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:01:59.5309 (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: LwHDM4SYMWJ4/hFfvv4OoB5ZYlPbIYGaT3fKaD2DoSWx9BUMC5WKln1iFQtwdsC4buksXzo7YHTHkWWR5BYUCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-GUID: c5gg5Rr8n71HYZOpxwt4br7S_32Qpkl5 X-Proofpoint-ORIG-GUID: c5gg5Rr8n71HYZOpxwt4br7S_32Qpkl5 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 Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_buf.c | 7 +++++++ fs/xfs/xfs_buf.h | 3 +++ fs/xfs/xfs_inode.h | 15 +++++++++++++++ fs/xfs/xfs_iops.c | 25 +++++++++++++++++++++++++ 4 files changed, 50 insertions(+) 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..73009a25a119 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -327,6 +327,21 @@ 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_can_atomicwrite( + struct xfs_inode *ip) +{ + struct xfs_mount *mp = ip->i_mount; + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + + if (mp->m_sb.sb_blocksize < target->bt_bdev_awu_min) + return false; + if (mp->m_sb.sb_blocksize > target->bt_bdev_awu_max) + return false; + + return true; +} + /* * 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 Tue Oct 15 09:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835916 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 DFDE91DD557; Tue, 15 Oct 2024 09:02:16 +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=1728982940; cv=fail; b=B5tVJIS0KsEZwYtwjmtgwBZDaXe/L9VAW90NtlcYyT4HFHtRclcyage1BCqhQelrGOZwEz2sVEYqPF8oyXOf2M3ZCUHIvaXuHflXVTpmXpay5FRWEbj2w5O3ub/42rTcSHBbp3eAfZwdLuJspTKdDzI46GhLmZ7uckSjNxjCcxw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982940; c=relaxed/simple; bh=PRrDkoSeESCFQmalYb0tyyf6s2YdIZ8qgL2KjK4WWoU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YK4F1x+Gs+EBJ9ttkvk8Udk4PZC+SwM3WmIs42DhXWys2i2rRdxeH63jE7d9KpzAL/O//LV20NsV1Hv/Lj1VlJ883iAvOcrOrdVnZK0ZfYU9rWwl1/qvA08kAbvotpTMo+AbBAO4dZU/j6EoJqOYT8hZWuer4+gvTIegNdiZ9vY= 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=Fgsvtswo; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DIiJQdmZ; 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="Fgsvtswo"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DIiJQdmZ" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49F6F3rv012550; Tue, 15 Oct 2024 09:02:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=8MqU1/P/auBsdf7FWpVOBsuUx8R1RFiawgabOzGdm10=; b= Fgsvtswo4uHYQAU8Z0jr8qmX3ijZZsyQkykFDTtBiWD5AJLtTvd1a4hm/xVqS7Wi w9NhrVOVkDECTaRNXIiaKcFFlwHbIMszBAyiRavkGUyhpKadcUJ6GWyR5UnkSSjn HpOgQO3v6K4tjhN1ggWsEfbqrZaJqn51o0xmEgKOShDjPpIkWKgLlHoakR8GL859 inuZDrhkgoHH92+DN2jKvkX/j1DoRMB1s0PspyNpcfkapUBK+N8e+pRzx/zgnk1p +DGH5v1vLbB5Uvtb+hNueBEBI0uyVoegoVkeoRc8TV2WSmePoRjZnM6o9sD6F8rt N0OnmUKfL/5E45rQxR0Y0g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h5cgfcd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:04 +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 49F7XxXx026388; Tue, 15 Oct 2024 09:02:03 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj754ms-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oA562IMzbBrTm2nmuOgbKbaTdGy0DebLXRGc+Q4oN/zP8A131FU2Qyjb42SQl70E90djM8EfzFs3xEFSVKUNuPwrhUvhL9Rpe3ieUDPF40sqvKuBnlD8+jl/PlBApB4J+dREkrhpucSKnswGdITLZEUBwsWWHgsHQYeZndrdSpI4RX898iSirvJS5tp/OrNoymY7Sfpxnm9AgqJ8vjPBqkpJM3P5sJFltSKYDQNMbuFHmhD6uR8hkz6fLlRlRieqB6KflFzMVPjq3SZTXVATWRAXv084hMEET2aoFJmLpFv7AKCdQAHBxMIQAbdqShuHXJ2ax1135g8O+I53c8PBUA== 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=xEEuG35k1AFrslkO+WEIS/5Retnn5ovJ5cJmdfva0+9UfvRJ5ouSxc887M0bsUwic9tbTXSaOm1psPt6VF78alASJVbVreOA4AY7orMDx8I/r6OpbjmzWk+Wm3C7e2EVb9D3bO4Jd6M1FtiIxIcRTFl5hb4Ui5kBagCm7YCscxGVSzjAuTXZNwhtFmJE6+BtinaxTaC4MTs+TMBCunMNDW6cJXgYNM5479NkCLzEbpFWaLm4A3H6IiLXIsjRYy6Aa5LehMKVtm4cBujFZLgyOKlh5eIWp+tpaQAbKy8XBJMLFW1V6my0cRsDgBqnIgDJCG6x6iUxoQafI2NZP3a4RQ== 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=DIiJQdmZAwZUHzQq6+Ns7bhjKGBNllAgqZhnROoQPji/cFIME2Yj7Xqq3YNyf2YptUWHgmj4y7fcvR/cKqNUHkdqe3C/4qs0HOMZ2O2gB7SdMvsnnzlP3l/vRplbVoWFBXHuq2HJZiSGOc585zD/2nhEDfAZ3Xi31KwHNWmALcA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:02:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:02:01 +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 v8 6/7] xfs: Validate atomic writes Date: Tue, 15 Oct 2024 09:01:41 +0000 Message-Id: <20241015090142.3189518-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN9P222CA0028.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::33) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c0f1342-09bf-4d5a-8fbf-08dcecf807dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: ZCUSLs9BuiKCGam6NiOSdm11hCR4lS43uqlEJcRDfpdMrOoALZydnFXlWdMqGRo8KOHb6mIpYwwyZXiOxJ9iyCuMpF5qVsHu8l2BX7fHa+AL4UVSPe4yBQfHKEmhpFexoAEa5Nun6DuioUrGnJsmjU16LXY35MD3Q4buBOisQm1O4mDJQZ9IYmjEFyjJzoHQXzyVKkf2GqhW7u9FEO7mNjY2weEirNdXQGgmKgraSzGuN93dlzq72vgOtKS8KsJ+AmbLQfRziS81mT2Sqxko2YDXJzvJl8suq4XFWAtiZa2AUHZSld22tFqAmdPFq3OUwost25+Whm8iB1hsSgi3ADQmQJzjx7i6plu/hnVUbKglV4OvJ2zaqI6xojChVhJXGIWhBXZj6AOHGGSWvznq74ipSEOe4ok5tpy/8DEwNSFJ52ZdAQywvEGUdJbyRixu3Zlz9x4CV0P/2y8VQInRC1eA8preScIf7RyyKgv28i5Teiugd4KQYIVVRNOgT5kLGBvCW7XxYNJaElLSIMy0tqtuhcKKEhTDiCUceatYKA05JEHu64lWWJqWuPQ2n441a3M/NkUVCHT3GcJyMURG1hm9iNImfixX25mZeCNwG5oenuvYopfCW0v3QOUTXNbqGq8sk9MXuuSblcW0VKe1FHBe+yr044A1Ds4blh8MJBaWaIW26VgB4Ey7B2+tP6q8KDoe8c16//NubnqoiWeGlhQ4p4R/aBwlHkG47LbDrAeI0LYUYw+FcLvMqdoFqX2a9gdsnIDCQax1ELczvfVKUHxZLNyXgBDvJR25cwl6tqDDREyqxmJsflCUfg60Hj1T+leARfBo4wxLaoOeo7jGJIQxlMIN6Mc1/vs8pDlr+QJroaPNWxTXMgJ3LIXD+aX8jriEGoMCCGNqvzDmKXVrtL6XTJd/o7JojtvzjAe87bmCeUqm+VFszYQsyhhDxsbOQNxhWoOhAG39XIUKFYgKx15OI9Sx04hm4A/KLhH66u8p/MoknwQ5ITsAn2QuVe+nnf65IE7jvoQVbgaQ8xuIpLEYncuOB6ZbAz1rtTjD6JHBWgwg1C4zprB4y/mIMJFNZtUEwf/DViKRtc50528/9S1cPrpxYSFNAKmNK6uY7H27ImrckNDBpiTcgKmi4yDCUjhlXcvWXKF11gtERFTdnAojpnqrFY05d6hJ6QyM+mvobpWw1kX+d8ljD9/IE4RuOv+Szr/h09lzcDLqy3zowa+u5V8ya/qqSj111YvwgO7b4Dt2FCpBoK23QAtLs7kh37J8+fH9fcxGjrX1PtbGLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TNwITTpJsdVRhCkZmSliMxxSe58wW+0BOvkdeMDAONcqRHLvoo/qVvplI8KrfaAVLSNAqQ3MTmLCmpvtFSMSOmhr3UpxHt7/W9xjw7CuFrHvyO4SQHjq4s8++g0CljzhPXyeNmIA6PWQ4AQulYBH9hqTNnM8Yg/LIYD967WEDnhQZRAQ6l/kXywKNhkN3va6WWoxuMs71SNbLrbuFB7Vwq6tH4sKq5MtEOV9H7P26MMnrNaKMbWEcPxkRPFRxfkjVmeJYVmJ2oTyLD6Z9lwn9b0lALdfWQ9Vrq+lt9VyxZX3l5xSiZC1xwPpGj3CzFUjLK5UNtnG1705RyrSewv/U1b6hTL2X3sDcnbEFFWA9OSjPJbcICR8EGKF5KZ/vii/LdFOon69SQTL+1/Tp9rBcSc1sLVPhszbLWQkGfL7lUF2D/6JCYtuCN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8nWekMZZUGfSboPOzek72x+WeG1zAaZnnSIUTn2bFdwslVrP96Oo8nKHh695RZwqpAMBgoFDKCIXCZP2i1rk3kzEExIkvuRxsvUfzW75w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dzuRvvY3zjkwB7+PVpl8dbPBACVOcH+s4EFqLKkFIV6ZhNQDJ4uhWCvkP+zBXOGb6W0Y7wPngbi+THc+CFi0H/OrlZe9QBz5CD3BmdMhJj3KOsF/mIiO1ShWHe72V+GZJdFakCHR91K+T4Eg8QvgNRet15hkFoPW3pmkFq7lzql7ZpztnOvMgCGMyzHQDidkOJChGtEjdbq14a6bj6xZjYlC7IgFIHUeVvd9KOhDwP3NQfqIhGe5WdB+RX6evPTZ3AurIC5V8ZhTa/0StT/hFNHUpDo74Kd66w3Whx8BI2Liq2jlmX9fE188/dG00GPgS/KUM/Ij6H7jJMkUiSFlRsLJcCKfKYxGj8oTejRHYhVvvzt0+Dq+tILYsv01yV8ZFRuMLKV4QK+nWehP9tGMqjTuNhb4ddgeVZIJX2LSnO+Lu4B4qzYELfCfrC+SCOvE7Vao3/kkLZc/L2+nQxMcWc0OCc1rJ0F+SoYajoBgPq8HpoByekYkLt3Hafb2fWwzTRl4Nfq1E4x1L4bdmuNipNf5OhffyF2+7PQdIR33rcYODzOuqxPLOxamGc9MT8ZPYyEdBupYxXUXeJieXQ+AgHecrjk5IvJhLdk+Yk6S4tk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c0f1342-09bf-4d5a-8fbf-08dcecf807dd X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:02:01.0262 (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: 6e2/Y/0jcALrP9ttEDLTITaDsG7iRZe1QO+GIbICPhCvrf9Wouw6pfllSu0LNPPKLUzTh95SCCtAVEfWHA+pLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-ORIG-GUID: vll1tEY-Vsw4O88w42UkSMA46KTKWPJS X-Proofpoint-GUID: vll1tEY-Vsw4O88w42UkSMA46KTKWPJS 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 Tue Oct 15 09:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13835915 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 DFD911DD54B; Tue, 15 Oct 2024 09:02:16 +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=1728982938; cv=fail; b=SJeu/A7Y32cYo9uIoMvgGy/KYqHLM/ouS9mNX9rlNPNn0UgKN0+uWvdpuBbomvLODab71+2WIvCPcOf9nNza41hrgMqQFOY0vtKi+qbTdUvUf+1zEk0qqGRN5bxp4UKjsnZay573duzqZgZp0JDIu2b0/6be4tBnP+1G3UOMo6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728982938; c=relaxed/simple; bh=DyEQh7TJksNDFD5Q6ZoydjOuWIB7+nKug/iMT6X/Bmw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ex07aJqkLzuXnTOx932ru6DMyvNKWMh6oagXOKGtIRf3cb+571ImNsuci4YAIa4lhKyN7/9Oj6sCzR2/QSTorkEyyzUeee8wiasuPmpjQZ3yo+w8wTSqzwqLjX4ZGQEJv3B0M+GMHHAOmPVm3qPFvuEV1bxv6aI3F/bQiw5MRsc= 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=XofeCrBu; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=WTiJXtUs; 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="XofeCrBu"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="WTiJXtUs" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49F6F3HB010191; Tue, 15 Oct 2024 09:02:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=0/Dp0FpxB/g12r+FsHa6wK6cib685ZOsysK1B1ETDNg=; b= XofeCrBuDe/jSLATHzZRAgEzqGZRg8xCV1+5/ljHy8/kVX4o58T0634jZaBUCjt4 h28iTrT7+KfbKJwtupotT/nSb1mjhT5QeyQBwI+FlsYZXkW0p1oTUso3pMisAre4 wtUrmMLuvqQrnZawLCmHYYvvuE9X0GpvzCha5HjcrRMzoWaSro0OR+oKOiE/FDZb QF8JEauAHXtiPRCW58DgG0f3jsKZNVZZ4CT6tCNcKkI4FuV8z1KKoHNOEFKG+ezc KsWnYksKCzXo6GcAhxELZwj/BFN8u9BeyHyTqo7vkSXC4mCHrv22zGjBx1bJzomt SMa7n4JffDuufUHSkNGBiw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gqt05g1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:05 +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 49F7XxY0026388; Tue, 15 Oct 2024 09:02:04 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj754ms-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Oct 2024 09:02:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AC9+7wndVr8+Up9RG/W59vkT1kCYrTmP0fy/mAOZDg5EP/N5L6uyf3s7oxalHzDWa8ycMHoXfHIBHaOLUApZ5ZInaUftiiCuXk9tMSb4U25LHg5T5HrTqFoGm6QJ4pES1C21DGblQHDYofbTM2OUI3u5MWhUmhwmDhAtUZ5lMd7eLlOp2U4ew9rbVySwm+eKak1uifXvbtlaUzaxqA0iFxPWHh7A1CXfr1WqFWjUep1xuK50pOBteUUvGynX+1EQO0d+uY/4Djf6em0D0uLl3oAwq6Owx7sILYFM+7M999/O04/mlimtboXP5zt12VExQG4xBweZDMxCWcgbCsEnJQ== 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=0/Dp0FpxB/g12r+FsHa6wK6cib685ZOsysK1B1ETDNg=; b=uqD5H/AcSjMMXVpUmqAKmAOJvUfVF8VD6dzyUQIElZzvn3sZW4CGG60wk0RHDN2Q8zBtTlNsy5jC18NO6+G2t181A0oTM2tQMU38UC0C/3d60LFE9/PI0aw5EHIGnu1Jhej9OBeJVilIGA/lkn66rwYLHgy722d9CfZOajy7CeTQ70pNvfHDrlQBhpOKFILoNFspAa1IuFBBCvbk5HCCLoK3VHT/E3Wwy9wyFtm9JiUbMk4Nw0qdcEbuD8plCKffCQsHHEVxfBmUHpFPWuPDxjYNGfi071E5ENTxvEAVVDGz8j/wDpeQQteyKDJTpk3v43LaayopE72Sfprlua4ZuA== 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=0/Dp0FpxB/g12r+FsHa6wK6cib685ZOsysK1B1ETDNg=; b=WTiJXtUs41lVBdkpv7YMdGAjvAPQ5EzfuzSUAzCJ+77+RvA4n2u2oELD1c8WUOlc+T5IHtff98Im4GJM7vdcZJnYucn6NDAA/Oz5VxSppydda0Wzm7YT5t1EbsZPZSAe14iNDrApsX83dRuzdQ6mLY1Rmr7y77gGiVir12OsToo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB7439.namprd10.prod.outlook.com (2603:10b6:610:189::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:02:02 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:02:02 +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 v8 7/7] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Tue, 15 Oct 2024 09:01:42 +0000 Message-Id: <20241015090142.3189518-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241015090142.3189518-1-john.g.garry@oracle.com> References: <20241015090142.3189518-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN8PR16CA0012.namprd16.prod.outlook.com (2603:10b6:408:4c::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB7439:EE_ X-MS-Office365-Filtering-Correlation-Id: bd82e121-cb40-409a-a0b4-08dcecf808e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: fYSjUomuDFGMKXFn5M7k1MIBtminB6CEhilhOCvEYe6opCJY8KMeV1Ge9tXZECj4owRPS1WFNwB8v1Tb9564JO+zYSRXt1RYmwowu7ym+v1TP+bdZSDzytt2JgFLyYCZ6+N5X1Qbkofbt6o1otSMgGOYEss2ApavO4eIF5Yn+wS0XJ3BwzXDPnYaC5YTaEdtM1ODazdeD4l0o43cB8TQIaPp0XOZT9oDcuEaZK6jlD15EzVHrBEjVYnkD1amRHCACEri988rFJMN1xsPkUNCaOiBFq8H3e7pJF1pvFKMUz+wXtqkLjwMUeK1awVJ+SHzsrZee+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nipoBprLrVhbPicmmh5R1bxtB79Ks6flqLyXYbnb8PVvtgpQ3lMt47WlFw6DXPEldvqzQpwPs/QnEGN/x4Jjp3Htedye2jyMML4Ki5c7BzZLmLknQb8c1YSa/LJWAhgEUec2ag6FVCqgl6zT3EHi6vfNJIONlyQk7ThkO7oFPvdIhhW0Nm1BAD2xuBB4IxKL28tuqNOWI5RbvY/wb2+tM+Nr8PnZR9jYDCO85rEzFvs+2YWUL4vxY9mHWnLjv96T7PnpXHtrZqIKGSDa32+I+3R2DLl4cYOO5J+Ifk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd82e121-cb40-409a-a0b4-08dcecf808e0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:02:02.5739 (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: ifLDX2t5t25izRp8P0+RDoRHwsXs4yKtm+FHGpW0fi4Pk6kNV/qpniGIqIV1+/VaVylKtYIjdGChZq7UrhfmJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7439 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-15_05,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150060 X-Proofpoint-GUID: KN1EVtYJJ_bJYYj3DyB2GIXQyeGWWsCK X-Proofpoint-ORIG-GUID: KN1EVtYJJ_bJYYj3DyB2GIXQyeGWWsCK Set FMODE_CAN_ATOMIC_WRITE flag if we can atomic write for that inode. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- 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); }