From patchwork Sat Oct 19 12:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842737 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 E247979CF; Sat, 19 Oct 2024 12:51:52 +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=1729342315; cv=fail; b=i43+V/VXTmAq/Q4Z/ZUdF24/Dul3lHElzcaCngbz9QRTO6tmRe6vsO1ibb9790gmZ2GwiARCTdJJgdlfqVXmEiUOBuqIMLinFbjeuWhAP8XML8SfUYPURBT9FLLOYpX1v799jnvKfT/MlUwpRvqxA4pZnhE1O+S6L57mHnXVluE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342315; c=relaxed/simple; bh=X3U10wfn6VZKScjWTDOaiqO+ijk2vv06rH73YhyzAOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=phUhx0qOzhjInJ3edi6zoGtGUJLlKwRUmSlDqbxfUgs3TQO5Y76E/vZrjtayq90e8IYKm9AcdiYqCvhUztu/Q0muNfzvzNDYFrMEe6DJHrern3lCCp4H6Zwmu2VUlaxr1q1qzGWR2eSS81j7WkeAZ0TR5UqBqPwbqhsFWEarlFg= 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=DFInnhz6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=migR0w0I; 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="DFInnhz6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="migR0w0I" 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 49JBi2gp020082; Sat, 19 Oct 2024 12:51:27 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= DFInnhz6eOSJubTV1A/nlmg0MCnaTlkXTAzTeMVbJBoXSFkfYEdZnbsMFa4kPZb8 KFOgmaqd4Y/tW+RrUhpYa+IXOqH+b9JmSrGYUCdQAwabfdvWMoaaUvP9CPo+5SGc OaqCK3c2XQu4hqqbe1COLc2eKodKwBatgbvTZycwzNJhBZDAbXTRTqZmc4cx/CWu BzQCBj1gx0FBUP1xJE+jJERLQahDWI0UuUKIWT4+feAXTapkIif4GO46VmNltMJL iYkUXi1mi+3AYwHD+gBaSj2gGiKVw5woYpM77tJmx/ZVgjYJFVaCGjHntnGFfJCw +3IUfIS69wmFmC2IULEYCg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c54589th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:27 +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 49JBSCAb026309; Sat, 19 Oct 2024 12:51:26 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42c374ssae-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p8tDmp8Ji+Zm57jzsdrKnVDecFdGQ77T6ECyXXT4Z3eTOzloBJrE8fpuXgfp2ODui3an2EoYrbXB/le7emXW1JdRVGy51uYcmlYRaqWLEtFOO35vCrQG4G6MLiwQDW1Oz4nN1iLqIWoXir7Uo4PkjrrD3xVpb/JQ5GzHopRVd7JYZrM7Q5juhP4hxEXf76oP9WIMG4gBFLr20tTwTUehXL1YNigCx+4yW/w4lKk6qmMR3wr7qPTKD6JpRyasTQMgarCXWN8UctZXhvoU2WKaXqWRlbtnl543UxGI3RLwE8D0VmB3GcI1EF2bdNqjkm0MPSrT33PceXs377rSambHhg== 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=Hz5WkPZmozeeBkin8yvcB07A7XL/X3cV6DUZ+Mn9dOIL7xDnrhCuRa7HmuY49fPAQOizk0RR8YJXEHmU8BYR3G0q1lOQO2PVTJJ/fbIt+W5Q/4ScXuq1hiJhxDQqHkarpXGkz3srdFCPzeXp49mtJUV5Jg1SR+rFoLzP3YVujfdAkyHA/Voc1XqL+892N2o95W5szwVwaCVKDSjH1pyundRd6wP38hOiygis2GG6iOX0miExKlmXZgEO/n+iSt0qXEYO+8VmhDQ3EgCrCWPqKqkZsnT4QYbfWolSXSkIpeQKPDvcruV4xEc1Xrm59twEd4SrehBTIFJWWDRCFTNEHA== 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=migR0w0IgVm835fAOG0jRl9ccWx3J6VWY3NSs3KNiRbORk4SZYzuX1L1NHJwv65wT3Vwek4rqPI8HG5hI87p4PUu8VAjbdbjuL3R0vZmIorYd5PXQlazuyoyAsMUeO2Ds8KdNDSXwi9Wci6aLrrZLYUItX89qb0ORsmuO93dwI8= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH0PR10MB6435.namprd10.prod.outlook.com (2603:10b6:510:21c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Sat, 19 Oct 2024 12:51:24 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:24 +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 v10 1/8] block/fs: Pass an iocb to generic_atomic_write_valid() Date: Sat, 19 Oct 2024 12:51:06 +0000 Message-Id: <20241019125113.369994-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0325.namprd13.prod.outlook.com (2603:10b6:208:2c1::30) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH0PR10MB6435:EE_ X-MS-Office365-Filtering-Correlation-Id: cbf6ef61-20fb-4c22-4bb9-08dcf03cbcf7 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: 0+5hT5kv/27nJt9OJBeddf2ExUmCMRj8t46lvp4mrke9MefVXht6uiIgGZqoVV6EWTrWj3QF10Gz1EwjbCRS+2YkX+sfWIKneMVyGmZN6pdD4gxhPdEfZTgma1z7AcAaQDOWG5pKJLsxV/2n90ughmEg3Sw2hOJqPDucvrt1ZODQB65SPFE95K6PYAMNfNkkmDkaFWnT+Sf5iOLWU/sPdh7eCTcWc+kxAGKp7o6HTfCJzM69SdpUQWcbRfXO+aPhPJO55Unk1OG9Li4+VBRtFah1BW8DWOh/cuFJ9Zp2mlnVhN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;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: O3d3ToMnowS12G3HAJaySID0RroLzXd80DqiwDLa6m1iaqJdwKU7qDmAhIiD0a7ah9EkCbuw3wg1l7oginhR+2XdYSrSLdkFOCfGjolJdnMGwA19+VtmDs0ytoi0vVNvfGIY2uufgPbCss0hp7QeM2nmTPl48yOTBhwLgXoR4y40MamBiwgbH1yTcvl30K4z1qLmtVTLAdFfDOn92Gb1Un5ggVlmhoiErxwKKSDyG3IqQ6kFM01Oo8Sk2MakowpULqxfqEZIO5wMTp+QRTrDuI2dTzDnvphqpnk9W8zbXopLY6oioV9VSBZBJM35OeJvEKLIida5R+bjPSDRtPolMgbHHTG2Q+AIcRhCaTNOAYHc0RhJQ+cVsVVh0nUuxp4vUdp9e6LatYcow8a1+CBf1u2LUNPQAyDw2wXSMnEZoGFVBowQiHX03KUv8co1DNy+NbuTcA7hoSJ3LeHciH2iu/fdkmG3XPrf5jAIjjV6fnT/87KpVu9X0Vu1ZMtEHCU+UGgImUcClRdetsiZoeSf4Wb60yWX2SND3mS4dH30XLxcNudW1c6tS81ENp+wryqbiixhV4VxA/e8FV7P7ktpUA5BS/7nv4xGfLf4+Bhq7ACwy8b6Hpf9HYB82UFiQ5yVMZw4JbE2rgWmdFw0zd8ojxzthJLLWEsKUR/9km5Ew04n3DA7Bg6mYg7BUEE5i/+s+FaRe4aepsJumd8bF96XOmHMN9HlbXqB0pbFdttgmH1+oVqj+oBWSm1e131Y1IziYlseABkFAi4QAQKN1eW1U/zv0sFjFljtRyoupWUprxnLH2cNtQabYLHtAUfJHe4E95yDi/KoQx8lfO3Y/91ch92LvTtT2U3DGxxpwMRAGZEcIDzFImXNo2cx5Ygg4P9Ua/S46yueaJ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ncJdyPDwBhXaFx48rt/wLbr3qrSUN4JEU5H1ERWMtFolRmNHWDmlEQo/6F2TMBYykKfvnrPMLhX8WJ1p1ih6s7vqEfyBCdwZZPa0nTUf2BZPXjybR486eTtJueA83Q3s8L9OZgppFeGn6/q4luvQ1ZG0pvT+vVT7y3BS+7M93BmYaIMRHIqmDGVQ7pTnrX+xPLY4Kxt0Ig+li7nlLfdA5Xly+XhO2L+5atqTm59G6KxzzjsteSMcKwWWGjbP1vXLkYUW/FdKHz1cVUboOu1FkKGiLVSm72cDz1is9bGUQDD3ZX2QYLeuwBEl+7T/yDg7JYy7nogx8U2Q8SMsM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbf6ef61-20fb-4c22-4bb9-08dcf03cbcf7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:24.0464 (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: Md+9Fz3MK4kyFKV6LvsWktgDgcAroXaTWuMjb5usnikGK00p/abr/o+hPE/kYvKvLNDPcXOX2uHxt5LhG0tZPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB6435 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-GUID: ITn9qcp29Dr6ZWXyXucXQhGgP0377dL0 X-Proofpoint-ORIG-GUID: ITn9qcp29Dr6ZWXyXucXQhGgP0377dL0 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 Sat Oct 19 12:51:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842739 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 F0EF5BE57; Sat, 19 Oct 2024 12:51:53 +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=1729342316; cv=fail; b=c7ykkzydI4EIEGEGgsozt99jV9NojrlN0hEpjeNIpEqBl2ij3n2JtqWoES+5rMj4U2ybDWXXr1l1b8oAjWity/RD+1paoEgkYtAPwG1C/qJpzvP98CKDzd9APRrO6PSTAn08l5m5fT+ujp0Fye2ESgFAyMNuUc9ZBH7NMgtmaPc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342316; c=relaxed/simple; bh=7lad5ETXW8JBTsvY4IsXUDF/RPCoEMjoihl9zfu3vXs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iRu80rxh9r9JJ96C6CN5yBVc2VsHyXe5gz4iSvbSAVOZwbhRaeO+gkC27m93Jte15A7kjfNA1l+4yuVp3glMaISXO0LSVJuPBt4KD0D1TLiVrAwou7CaV+DoabiF+ojtqEWgXr1Ym8Jn0fnjpimnzj8+cRyxSHFFOxo3zyZ/XS0= 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=HiN2wEEb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ZVWM3v3t; 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="HiN2wEEb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ZVWM3v3t" 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 49J6K2i3019596; Sat, 19 Oct 2024 12:51:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=w+pwMUmApIvUnnO4FO7j4FRwoZg2cKy5ZGQsttPsQxc=; b= HiN2wEEb8EA7omM4lXzJHs+ETLXJKeuOfP5xRmcjuAm/gVceyTZ+58WgcbwxkB9F QE/jQEDiCNhKbZKhbmdFHj9KEXrr3jSPsPOfJLNzcS6xA5SS7BaYcQuBEhl+aSHr wV3Qv0CsSih4VXK500lShOMsx9KUQeZHyrIEFEKBIxbO2n6CHWga0jl07aGqeFyh pLuEt/6ddvv6zVzVbtTCu6JPBYRLDApUcZ18k2XGcCETaYv8sbZozX9DzqrqzNFJ e9b8eFXswbFwkT4tLrEU1uYqqIAcRAXKGB6xSaRt/fsZXp94AjLiZzRXTndcUQTs qY8BNy9g7OyqJrk1nKbx6Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c56m09gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:29 +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 49J7Uvws022635; Sat, 19 Oct 2024 12:51:28 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c8esmbq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vsi1Otkyvkp2ZOxx4ZJNaPG49d3w8ND6HnE5/5P2kgeT9byBeF8FIhxxPLPwXnZ7OgabSye4lGDhTPHPARbyLxSx0/ZCtp10lGklClpCX69F0jwDSfF8rCh4MsBKA4pgOFieDxOopKeJdVSDsDo8E7LPnNKrh0qAYVWh8+TH9zCAo+TGNxhvABk+6+oto0BK03jlpHkelB1T3Dv/uSicbpFp37yG7n0mGau3HlCnH20IaQP350bYomhb+cmklWB0nV54+00ity8Tdl6GfrE1XGk0udDNDjMvvj1ZP0ntG0FIjBxGRKS3FKChtvNFOL/yYYzk2fS++t3WbzUwi7/8zw== 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=w+pwMUmApIvUnnO4FO7j4FRwoZg2cKy5ZGQsttPsQxc=; b=t7rOKgrqG4DctBDDQcvzrSikP1Wj+/pH3Wlkj3X1k3JzzXITupkt1NYOfM+AhXuuKJGSm44KCRPUi3RPOYjxRMRwXnxecbhgXTUJerrJrnbAaqzUfm743d0e8cIuQaEL7Z1+QysMrIV/nuEADT9GUZs5bLyWi1t6sgb8kwW4SryctIZjXReh8+LXKiJ7XkSYKMGgZHJEbT/mwWQ+1FkBmdLr9EDkNZve8QqGD0he+gSKPahUIBb0pl1KzxoaGT1DpuocZI3kbXFW/gKMuaC6isbAcE+zReXBVI6uIL8oprQviNVGW4gvX5vCnG1tNLe4wqkgBC0wqflGJJ/0UnyBhw== 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=w+pwMUmApIvUnnO4FO7j4FRwoZg2cKy5ZGQsttPsQxc=; b=ZVWM3v3tDiqqMUp1UbCmiQN4rWV5galfP43B5F3MsRYVJu9hBWRxR2aPHh1XDqiIoSXPAvOYo6fzB4WUrX73ORaK0Rf+4MfyOZbnwDiNVFeEsqK2WeIhwQ7G9Ow2euoVsRzPVc4IthyzQ/S097WcQxOOCq0pRCdf8FXJ2dV89os= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:26 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:25 +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 v10 2/8] fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid() Date: Sat, 19 Oct 2024 12:51:07 +0000 Message-Id: <20241019125113.369994-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN9PR03CA0449.namprd03.prod.outlook.com (2603:10b6:408:113::34) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c0bda86-f13e-4d72-ca7e-08dcf03cbdd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: pM1n+OwWYw57rsBy+JYAm/+VS5WZm2ZgZN60Gw2C27CI1opAwFDDiq2uThAdpmPiabchU1ZSyZtyzrSRbW1Pxdlw9yiQ6weo/w2f4Aep+TpTH+ebYTz3KPfOZeCmq2L8TP0zc+PPb4uLkCwHFtLXlaxhgpPa5mt8h7uGqP7brz99gP7fQKL4OgZizZCp1Gp5vWq3jMqBVgpieKZw7zX1Ry6muP7M2U8PiU97OcbiSSyyLCLPLAPEgZcAwbZR4RVJld+7HIc7UVo72CaQUNfdLqO/cYGbM46FqyW2lZVqWeXIFwK6pOHDTOO1fCtImAAyLiw1CdpZa6qWdwDuhalNsatlZPmo5Op6LAl0AmJ3kSqkR7FwwsKCFCxCOVQYI7xC9cedet9EGWR0Qkz/Zw3KAplR4+Oz1aQbANEKNdo6GsLxzOIfEQ00kAkgkSBlx3iPVfl7HwHqD9R6wnJxXW88w+kNHtQNM9/bSq/qiUUvbkqq5x/dRR4MqXmc1lM7Gb1HLKYGGWAm7zQbxiEVbFUWC9cN2c21SYPzeYYshrWPCk1WmAdJ+e7rveEhr+2i633wFOQBzJTGdnlt8bcbVhdbc1IQTVSiYcOvGkFea6uT2ap3UilZo0Cf0ZpCkBDmiA/l+7V+QdZuQBOQh2npNgyeHrR8Cd9QjJBZWbaClxfewfvnMmee849NWabEOrp8xkqiA7Dsj/bIRE8IQk1ummIkXo6JegaX4r3UkvMGGckSPeTTfh70RJDlUM+jmFq7uMF8vLX50CN6thxKi8/mqc5tPaMJ5BJ4qojIbzdHEZxl+SKJICqUuB57quQmQA0eXwcudGNQJ2gLS8f9kVPLumTmjD3cDka7Inpw/ICD8TG44hXhwkX6rNqa0EFQFJvjlPIJ9nMp+szydj7yQliuh8frP4Yz4BC8cFjj+fwiLo42rblwEEy7pd5IAH3KzyjrKLWGazVyzS2MQB8mhEXoWR9Zc4bRqNHBD5gYcdRoJrByje2u23VGL/WwSc6bhrGSRpPZnR6yUqYt5babxoP7Q7JRiDa6xH5J9+LmVtGlOBFnG4tmB14VHWJsZOgpvC3EBJMGvgNxdWtKIGf4Py1HrdWkuxDHpCJV5RXt4HlXJY8ZSdmnaWDbx0UpcB0+hRqbME4XRTIIcOqIal4PXRgbnulMbd3yL/8wdWVjl9BDp3D0dSxAwb4agp9RuJ77SXprXwgg0Drkdf31w3uWxdnH4iesVZwmVo1VAeRH7dWJJdlcv3bMbtRurNQbKVn67Ylp7Hx8EFCVUuZrh2mQ4J0ijxWHyVatWlfxk/EivQkO/IihocU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oYQIPaIXAiIb6yILP3cb86U/si181WCELB+4ojp1j25i/ovw2s6aTqG3v7gJPLMBNQ8vMK9Y3GjMuOS+ByjaBqCVPipe7CkspeENsWQFuJT/Tdk2qNrjmy69XOqdgETejcZe6pUycOwh0PzPGk1+pZVtrGUqCjJ0ArUyOB9tHTg+HOBgaQRNgNdrhq2KOcLtEdA7AWqLAjPGO4jcRcqZv7lLAwI0zPKlqon5qlQTwOYzmGRzjxwUfI6BcQPL1RZHyBScO1jLFsMBRkzbsWyXxW9IPugJnRPzX5xhdNJ4NWcfYR4yIS8O+CKb/qFiRnWcQhRLCaCjx5+j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ihpjJ21/wXW9viuvkzwD3AYzCOHUWlFpHuwsYE9oD2mwmnXO3wvS4PrKgGTzrHmlT1V1b/5SIMI/mJ9QX0LwGXYp4mTM5Pvs0a3swk/wFFS40oPC2N1G3oSE05D53YV7pEyHcZloh98CJxDyf5THzjmufFksWl3i8f2El+XFMA4ARGhr0NVvePpHT5Q3P1zE2RDQcPhDZHVDjxVNg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: S8dIldSzQXHWJs022pqPTvTxb6BxfAI0EH0qrAlBtlgtPZBXMJaOaDDLekEx2XajvzDvj3HepUzWoCqTOP0BuY6mLAxW4/LdiYduwuee/+Y+DkJ4vyAnWIYbN3hQSIFZuZv1qYAnh7GkipwSY9TfELvDpW7UO99iOw+JydnDx1zcMP2jGLF+sVO13BtkvI5764HTGE7kTLfZyajUX9a4zA9dpmokPgXlFOE9MFDBsD1ccG9uxwyTVH9WSw9mnE7XtBnrgNaDaNbc4navpBw+/zMLHUjNB16nZbr0o3Gg+NygZM+oQo22Y073MxshTF32EF5RhqowGeolv8e6AWc4YNfKoQGEyq3YCvpD8dQHI3HnPctRky5RKXmcSEFHOI9shkUrNyfGsf/u2pDZYqHkdimCobJY8ewtRu6igTORcj8J0xcwqd2MEeLJlz6VGOQAGkmORxgDdZuiKpQqGuaoIP0duMH86sK5VEkbFEWPbjfjQOU6+6p7wED86mKSv3cfoQZ4TEJ5oRzofl6HtRzCMcdNHJRGflcal5P4uulTp59K2Ph8loX2yALEbZoqua02jnuF3Uh7sTeGYsnQFakiVMpSFEQbotMJXUbsH7c1v64= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c0bda86-f13e-4d72-ca7e-08dcf03cbdd7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:25.4895 (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: oKVcV5nKpr+ezIqbYIqtNOOGX5u7aluxF8Bzlyuu2EqTqcf64osbmzOuwubTuQeiEzGIFqYvySXg+LeP7H/NQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-GUID: T-E5BF9IY17iwLOVqVI2V-DDOgK0jyj7 X-Proofpoint-ORIG-GUID: T-E5BF9IY17iwLOVqVI2V-DDOgK0jyj7 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 Reviewed-by: "Darrick J. Wong" 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 Sat Oct 19 12:51:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842751 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 6686024A08; Sat, 19 Oct 2024 12:53:50 +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=1729342432; cv=fail; b=sLvl6ajeGM6kxQcZvoY7Cn9LkKfXmICcE9HkYeFjJUgww9RdIK+TVFG5QtVPYh7Qg4hYWppeKff02/isbUmZRbqKmXio/kZi9x3F9OoWMDIJZ9qG9Jhi1VhkRcOubB08+oJe5+JRzuOtFZuhIJ7kB719UKYbMdyvSTGlw31WdEQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342432; c=relaxed/simple; bh=d+YfYbHEwj/hhNNJ0Gmuh0J3TJFkwDUl+QLfdbBcbCU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=chlC+738HKphX26VYCMnrMJv0AXfZj/tharP31IWRryJsR7lB78roOj77n/dX62SQJTaI4hkSnSIjNVVMCteWC5e8OCpYw7YPTZ/IoO4eCSB+Bv4iJAvj1bIXrmZ/FiSfzraKGmxFgygdVA9BPB25xPutPs1S764rP19VbTwj+4= 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=LKntPM/r; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=rBCfWJMW; 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="LKntPM/r"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="rBCfWJMW" 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 49J7t6Fx016227; Sat, 19 Oct 2024 12:51:30 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=8+Zx5wv887XsG/Kv67UK4U8gZ7JUuJeZT2NA7tkHJ7I=; b= LKntPM/r94mJfOHIdIvOe0s0n/9uKnCZM7kvCgbXxFTmTqk1fjcUsKlAw95QPmuq maWjDB2tm1yFwfcQ8wnxDbFk4zTMURJke16MgCV/JIXWUBU2qQ03P7OhFKf1bhzE rrhR4u1OJ+1ULzHgz4Xe/MjIEJep7EI5inoA8YdkIvHchJjJuQNL6U3kMJLEFfhq 6+dDY6VyNZiCqwOZlJRCMLREMre32hTentI1EtKtn1aMPo6hb04DBkd/gsRjDzes /FmBmP1WOtNNIizQruupg8jlZ/xRhmOyCVsdvt4LTf/km7WVBPvNlRv7Yja8I0TH VrFwypEiA7gheoS6H/lBng== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c54589tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:29 +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 49J7Uvwt022635; Sat, 19 Oct 2024 12:51:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c8esmbq9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ezSIxfiyQt0PpijCgCs1KWMDPdfsPNwAw9RwkqHk4zfSGQw3bQ1D8CTdT7O0QXrT1Xamd0d7smE2R+NfEds3NaJR2yt6L269RDmhRVjbh1gW+QzPUtnb0018wwB+bcnaBYz4bfwP6Bh6AMZEZUkhOA4PbRoKmdG1YxCfb6S/PEJkngTD60p5XvkYp/mAYdXa7ojZ1RUA0HyL0YoVzh3bP0n69+LHIHDifBSV2Gm0fI8JcXaspjz+XhcYy6+0nQ1nLOT7KL8+i6cQqHGq0v8FAbru+puksFF2CaIB5U6INZBkBejABMJLaBX5GBkly5SvoXuJHzqmsfzHwHV0HBv0qg== 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=8+Zx5wv887XsG/Kv67UK4U8gZ7JUuJeZT2NA7tkHJ7I=; b=Wf0HdPXtM09Kv0FIOLMN/s6Ai/kg/v+kEzaXHNtI5q+TTtXNj2gna2X/B4eh4ss9hRLylQt8Dx3yO+sdI1wEcB0WF6E0cKcb0zSuJ5Vb6IygPxW1xFZzJM+eDqkS2+fAGsvt7272OsSMvamlNe0cJn/5mtQKYBnR7HDOI5Nxy3mKbGMTALyE3VKFWGJ3vu9lMr/kmfPQqP99okJavrvLvxCxV3CM3WVn4I6vv6+UtMRny4gx+TXmnE+8o5uo/0qQxR9c+ydPeaCDLsT/vpVlFE4tllB6pyY1eefmW6898H027b98TKif++QibNL7xXuRAURc9K+FGIuv+wV9hUCQ9A== 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=8+Zx5wv887XsG/Kv67UK4U8gZ7JUuJeZT2NA7tkHJ7I=; b=rBCfWJMWXCbQivEah32HtM+/7xUVmpS6oHOaOgU2ErIocXrjUaIlSy/ZKxWg1Vj21hmnaFb5hbaMrbHKvTICbANbMm2X0zmXNJC+cLRQqi3SVJbSQaTZhJOUULfcV6XE7aKKO5Ogqi4Ek0jqqjmWJSr5VJYGI+rZYLV3DxTBirE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:27 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:26 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v10 3/8] block: Add bdev atomic write limits helpers Date: Sat, 19 Oct 2024 12:51:08 +0000 Message-Id: <20241019125113.369994-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0311.namprd13.prod.outlook.com (2603:10b6:208:2c1::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 18ee4e55-aef6-4bdc-a2b7-08dcf03cbea2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: 6fbtltYVoiwQaXy1eBJCO1R/EiZtDBLt71aXminfUxiwhB9fX/h9uyaA+CevmAPC4VOIYCayhSo05caaQwvUuNTVfdNDcsNG+kaPBydwJHLD14tULTgO60VLQa0ag5jD/p+hIPm9oBaKkQByGEVxdJWz+Vdd3Jo13FRl3l5vJgTZf8fO5gAMz5VMBO61r1ldbaOX3Mi0ap0ir/I+V29nnCP5sCv8Rlb720tOyw5kiVJh6RPhXfL3XfukLrpZrVVNph2P2H5dbiyHMPl4MdR2h67IJqFi3r2ryzGc4YxkOYJh5RgFrkmod9lkB4RqkWiqTUSykerzzN8plcMExAe/78w70KbEJfA/8lyxb+iSytAd2cKvnXWuWX45wRyLu/jmwRPdT1U6DlaHDFKww3u9CQqlEEh/Tv8T5vzY0D0ZGG/dkqz0f0BnUp5DvrRCNdbgraQb+ScRZkWWaPKtPsE5kIWpV2WbFUCC/4IFaWKvt/eisNkscf0/qhqEsFX6rAW3DwLFbfjMn1tGb5azgWauHVPZwffMFQ4zx5kuwTGD5bWRlU+ydo+iJ2jQq4zXy2x9txPv49lnrTHnzTD0j0rUdQCNbmAAgEZeWHfm89/vJ4W+z0w1yp0SolvTS7PodJfzQys2jSV8oK9HmMYIP1J9fKbZ4U8Y0gVXgYt7xBkANZYi1h9FRiDOFjRt86FMGOp3K2IbrroSMaRPhmRvZ8qD47/dx98yYV+T/g0mDYuiAHsAOjcob8UYYWx3qGXlLgzAwOMdapVAUvLjzehBm0jihkAC3ai0SJUXjlRNs8xip7uH/EizRLbGpRxC7k0lGPXEs3SmbpOThKeJ1eq77EXR66cTfKLDpjZnz5h+d2lEZmsXXGk9JF1Jb7Ljdk9pTQrRsIytikz3xKLotfLAwpKKTkEet3gvPc5qaRGjU95DCtMnbZy8lp7BuFF+aU37VHIQcNrlaIW+XKKa1JI5HBnPeg654zHMCIPYSIw+8vTdIlFPMPF2RSLvJuAhQ4bUhYeqpPeFVS/xeXUmFrCXuTpt0smQBEdMWD4ND2UfupDFYwKnyartHEynAj8ej+ZCM945GcPdEHUQ/r7l+vQzhX5ggbt4QhVjDThY3YRoNK0QwbTQRkJh0jMAZEmp1Lfop1RAHosfPiRz/1WwD8VwD7B7lglPlKcK2LbLwzpFxRCu4C1zUPUzbOkN7ccVo1rAK6/id5cjxd57U8cvsfmkLjByhgKjS/gdDP6InVOg5+tStQzqQhFmds8YPd5LzyJDSk1ClHi2pmbd+N6nYKDSKY5vRknbqcTc5XgCyZYYPX1ZVv2aw9z7SPqfLZav5Aw/PtbQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sQcu9FE4DuzciO5WMtW+ujvxYJyAiyjBlHMezNPiKzKh/KCe6OJMr87TglEI7uQUlOqjCYIZoM7zNnJiO6L8DTT1zL2r6jzak1W5YU/z9FvKsk18kB5ccL5x5ztrMFIfqsdE31gBZ4Stgi8F3ZPyi+CqZiJCUxCD1w3WoOU+cU3rCCq4zVuXjz1uhUXVEWw0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Tt1jpLLZBj/yQXgKTTrmhdVahVTsABBCRt9Xur3eg/cs5Vfar24La5POtHgnVEVakSDOIHDjCh0W2+jCkrf8fMAPQY4odDc8o4BNwzUURJ43r85PB28MLb5389y5qiSw9WAixQUlU2yuCja1CruiBSvQvBgJk1VFPFgVDq5fd6sYSVcoyA0gEEZlEp714kvZk3/1At37e49mvHZMGi6Vtnqqu4cCtKtRZTsBhmPMHg/v+nBeZbttwPDGS/JOEFlNE3qmhEswBFE16+9iJuoyU3FQUK2epqChfvSJQibsjjKhd4rQW746cdwWl3fRJcGSj1pa1sww5KzBAVtC8VaITHEA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9zAT18L9W+XmhJPr9Rj9uBdhR29loPKtLqqGKPrdB+NCSuXqmat6qzX1uhJY/17U8+x1YixCkBryM8/ueV2v6FWF2l+Lsc17hcri/jxHwEL27RrdspTXSEKVmxDUbcC0O1QPaeNxYEsQwsUTDQ45Gwnv/cAco55GzjaBAKy1hOI9jT6jwF+7n84gHp2xXTf7eOHc4PGtAomt6TRy5rytvwU8M4Uf4G8hyDDWwmueqlHQrNtCZ4RizcIrn3tsnJL5aJele+yPvmg4pdADWiz14eeJ6upMLQ0yR+pz4jJ50ALhWVhg9YlqZVK05yeeM0iST59zDH1LuO2teI+nZgofOiJuAuken/1whrK7Z17+jLB3tc0FGx4EBk1hMdSxZ/K6wQbPdW0Lx+KZXaiGZJ0s8x1Q1x2MS3F3eR55PmlrkTahFHtQG29B5JbS7RHmNAYbLC7/kOHLH6xU2jJnM0alsM4M15YBDEWt2jnbZzkMAQ8mC9nYzlg3RsiARNej5yZS+Pu6gHZTTBrel/cuo6EP0zcbRtd8bTfjXki49goxGdCmNdeh0m+u3xDCbokx29drd33QVICjygvNa7uv5imtPnyGlMLQ3ZvFKTxFwGTAHSc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18ee4e55-aef6-4bdc-a2b7-08dcf03cbea2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:26.8679 (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: av3UFCSycamUSFi6NzJPOkOa6iwe2nUINoy3rY8BQER8fMvz17AgOiD+EV4xMjbrOmRxUESxZOK1o3NQX+/Crg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-GUID: ro-5EAOiPK1PBBWgglonKvhE44iQgpg3 X-Proofpoint-ORIG-GUID: ro-5EAOiPK1PBBWgglonKvhE44iQgpg3 Add helpers to get atomic write limits for a bdev, so that we don't access request_queue helpers outside the block layer. We check if the bdev can actually atomic write in these helpers, so we can avoid users missing using this check. Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- include/linux/blkdev.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 50c3b959da28..c2cc3c146d74 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1674,6 +1674,22 @@ static inline bool bdev_can_atomic_write(struct block_device *bdev) return true; } +static inline unsigned int +bdev_atomic_write_unit_min_bytes(struct block_device *bdev) +{ + if (!bdev_can_atomic_write(bdev)) + return 0; + return queue_atomic_write_unit_min_bytes(bdev_get_queue(bdev)); +} + +static inline unsigned int +bdev_atomic_write_unit_max_bytes(struct block_device *bdev) +{ + if (!bdev_can_atomic_write(bdev)) + return 0; + return queue_atomic_write_unit_max_bytes(bdev_get_queue(bdev)); +} + #define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { } #endif /* _LINUX_BLKDEV_H */ From patchwork Sat Oct 19 12:51:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842752 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 3696E2770E; Sat, 19 Oct 2024 12:53:50 +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=1729342433; cv=fail; b=i8G3XbkTnG9Ve32kQHEJpJFWKju8n6aj20RhEXai/rB2h0v3RodCHMfPpn6f62jiRpiYnkxlUV63gBq9mcq7bUs0KneqvTvNYJEWrPWFQaSY48y01qua5FX8pEWa7U9C6tPxe20Y9OrZm1PH+RTTAzWSkeJ7lT2JEaV/x4UqMYk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342433; c=relaxed/simple; bh=EOxTGgWGNvSBh5KVqmsKi5I5eCDIe2YPdvjUuB0v+j8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=gLNf0soGJ82VReylmcoItivg/yHdU7LaGahq3xx95MnFuvTPyv3DsCLIx1Jp0U0p6HgM7hoMla+1xmqjRSJqK4lsm8JDZ4uwF2puV8Ihg0BJyDNOANsrFH1v7cLnoJftJwTpBX2FbTpnRZMGa7kTOdPuInnxVOCfUQzOXJiAZAA= 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=eS6Y8Cw2; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Pt+u3SBy; 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="eS6Y8Cw2"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Pt+u3SBy" 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 49JCKJiV030099; Sat, 19 Oct 2024 12:51:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=PwGjmoZ5QwxhepSH5fFJmt5e9UiJ6neS0UoagzexhoA=; b= eS6Y8Cw2o1XJ2/xBV6a1ZBCprILHifHrASzz2FPcTh4tCM9qfZxuvf5yJOA0jfXo NyAupuup7IliBmvVPM9hIotoQAdVixQEklJCmoWAy34QiAm2tUA4kMzbxEoE6N5r DH9nZ7uwKfLGWMGVom7chece1/47Shq3RgfRNWnhURGbbQ3AMhZMj7tX3SSs32oG DG0zjbMMQxXXRW/Odmave1Ex+jfWVYvSJyWq/FjWrfgJUsvOABkFIKpxKVSKwQqs FvNu8hfyU55meJKbaGSvF+aXZg89PFA+CrQ4Scjmu3+pVp5/PqnUvB66nr9Jwalt rDRsVW3TOqM5aFjUB5QHnw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c5450a0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:32 +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 49JB8OLu026230; Sat, 19 Oct 2024 12:51:31 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42c374ssbd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jC2FWeJ7TFL7uUQeyOw7WUKE7+IH20/1mFTKawOtVyQ/VRk5NOrXwy7B7wn8KjQBfESABFhdDnGNGjbWeUOXARrwKTNmVaASK24DdNiBwx1pX1AdmIo5scRjIJAaUKdfgYzpCGaOigFLxHmie0x1SVgKWjCArvLMRNk7vUmmTh8By4FRqqH/58pw6NBrXmAybTSnIknj3AE4qJaK8/Nru4k0ADAiY1nxULf65y6xFB3hUNTX2nqG0p9ua/wky0K+30OxyujmeIy731kZC21pGGwNJUshmg96maObF1d8IuVszWcu/c7q4+s5I16Bxyr8TTf1l+xF3ubcJcrok/oSmg== 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=vimY9cFvb18al1sEsfRTzwWaKiFk6geZkO++Nk+VJM4K1msTwQzMcqo9vqPdjdFEyjl3aoQdIo0cOQoS7XQ6KDT6kXorHQf7f83znvJmyG3mqeaXurOPJ7mIWg36N0vL6Av8v5GN4yk9Yt6CPn0AVG3R85xQn+WwpIO7oyTFgfS0PO11iiOnPljqpIQ21MQM+6WcxNfThGirusxLmO7xFVDmV7hDAQZ6Fu0YDnfF1e+wy7WZISn8xCQfVX7MfCViYttLhM8fh2ikl9TDYVJpYI7LVkKw0ye8TuTMPr+9vN8FbgBW7xmrFW0UiZVL54eZ9IfVHOBN+X5fj/uEGUV5AQ== 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=Pt+u3SBykeupQFPBoblwYyasRkX8woXsBvaUFCl+rbdJpmIPXBA0WBcF8wBoAZljue6lSxa2ZOtZcGhkAil6xonaNOqT656O9q6ITChVpAhvDsQYeiuOoKgngIJPStxCguApgQ9+QefqiWJoBfEcYHcoGSRRDxIUAJkmGS0Ti0E= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:28 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:28 +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 v10 4/8] fs: Export generic_atomic_write_valid() Date: Sat, 19 Oct 2024 12:51:09 +0000 Message-Id: <20241019125113.369994-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR0102CA0024.prod.exchangelabs.com (2603:10b6:207:18::37) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: ee8259c4-d8bc-49c9-23fe-08dcf03cbf71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: Hf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R51kliYQb6DqZrzj156EEYz9pFVzIHIo5ZRB6thjFstlxAvOOApoyJzndJvH4k+XcQHaxsqJCXlL4HqkRqC3EJlDuWvN1TQ6umerxT6JhksSvKEKjH2755eNET41j9B9IZZQhD+HNnySSjutKvmkWD6cjXqBb2/INEF1+kIeSQXW6YgjHg+p644Si8xjy9txHi+UkQnRfyC/tm2wLCNlhuC1JU6yr2inrgNztEZsmB5GkccotTP73JiuRCsZbqZIqoJLc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n+7f1soIMjqq0M+6PVGM0UT3aWzBRLl6pqJmSythzYRbsSYZvS3xF6woCJiBYRhtk2AfxIAREObkoZ3CYa2zbH1fdQmNqD0T3eBrrIpD8/EVvNTiNaaFx4GbDknhKCl9EjkSuWuZzcavr7tyU3BQKFvdQhjNSResKFKjozG0F2u9VIydakm/ru83TbihbmFCSqCDx2Js4Ox5LsFdYyIG7w8mrMnvuZ5MyEW6U57k2xVQ4IuK0V5whi3yQvdqdy1VZeqDb+kzO9U4sjbVHk8DCUyfcmET/2II/lafI5Knks6tB2BdBPunjscNOBL4RzZrGLmjQzHy7ouNETQdloMGshQwcQyzZoA8CY70Fz3cNmBE62xhqZqMuNL7Ovxa76GxtgWPrGnxMwWT9leY2s1MWUuCFnHLSy584v5NEEuhtEHXMOXSJmbbf0SwuqazCCfWYNatu+PHFRfbqZA/S9dNiCxGFXcB5WYovad+UeR6kdWyUc2d+lZtohcqFIuufBRzOLFQGwr+4wswFXezESFgAB0+XcKSwSJokQEkyjDEp2BstSEHIEm5jPCsTp3GsutHjc9Zl3rLT2YHJuwk2z+YB5DxMRDM9PiShEu3qxm+/bZ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: B8kTRNqG09GVG58JQO8O2FmPGIL8QQ76uDEgHVU9otuhtO86p2ojjkuyz/t33tWnCVfnMCMPk9Kuix5e9SUcmIEHLx7Rs6QDOO4NXGRfZC2VX5eh7DCsCAnrHZ5UL1MPwpO865zgBoaAMGYSQ7iB8TGZQl2cYi7CABz0D/fq9x53gww319OScAbNKqOAGIMUTsXl7DBzb1hENpyHfLnvNs6ccfwQgxkHD+K7Fq2ojgApXs/lZmJJ5/9uQbyqhE5k1mYZRoobBFylUv+bpeMfNPKW9IHHpecaqQ1iSHpBV8x1BeQiWaW7Q9nk6d7EsoA7XdLFwtjqXAU22xg3jXK7M5+aCUnmZSSOGyHps8cGpfowKpXh9T6m8PDBVd/UGuegEylm/91ESX9gmQT8xWsAoAV+/3ZsNtd6mRMsVmrpVa1WbF8FRqbnKh40toxtTQYO+ehz0rCtyc423sctADsMsWscWHmjSIHT3cbJpfo6+IID/CL0FEcxAdGS9uCbJ0KMwkDHfySpQjQfSLnqZJieQe6lfLd00XLPYRvgsr62/s1CRhziuF+hpVUXLrOoSWL30MOz5mjhSZBCjit/u4Xn1DSPWzeiHA8b5SjdiKMeUXQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee8259c4-d8bc-49c9-23fe-08dcf03cbf71 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:28.1419 (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: mNRFq1BVb9kF7BHEjKERJszT2RfiknggfyansBc4C3G+laBIFRrM7QG6jL6ugM+NZ8lIqC9nF4Xb0uEmwxSTyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-ORIG-GUID: G9dp5figf8RFje0aTdcuWPT_AWIx--5o X-Proofpoint-GUID: G9dp5figf8RFje0aTdcuWPT_AWIx--5o 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 Sat Oct 19 12:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842740 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 E23E67462; Sat, 19 Oct 2024 12:51:52 +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=1729342316; cv=fail; b=KzDFofaRpb9+O9TgcVuGPyYRHyrxORLn2UodQ2xB48jl0Zn9jJI6p7qiyeF4Hw2Wz+KdxtIon+TzDa72ovMA4npmAbVHWoUhUSljk+virlG+jZVKrLAqFSOy+mstolP0NqEaiiIDcofwUFfTXgDbVu7M4qMr/OVhACpKGHgT/58= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342316; c=relaxed/simple; bh=gu8td7d6bH4d1Et/fr0PqDDy3xNjUFQnM6ZhgSGykNs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EyuUA2EetWvvrj4UzI1AxOftl7f4rb63/I/D9j0950uJyd8o9g/VGsBHMkmpiyQBcX9ZRAGo4YePog3DzTYiURMdSYxIxSvcfBCF5oMg7MQb/3OlmNRUFIQewLdElKP89ii62s/aqHpR6mw7ydU6oFRl/VjGSB6vIWKl/DJpgo8= 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=Y5IVSo0d; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=O4IbyvLE; 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="Y5IVSo0d"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="O4IbyvLE" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49J45fOr008760; Sat, 19 Oct 2024 12:51:33 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=OcIJ8jrrzApf5SR3217+LG2qhbrklln3NjgWYaKsowc=; b= Y5IVSo0dC7gGMS5kj7jx+gaeQ3nGAxZCv6AMdMhm/y/qszHj6KP+YG5a2hvbJQPS mFbOFoNo89C5Rn/rFuj2IQYCoycXT+O6nAQtVvmNKaR8qDE7R69w4aKHOPoQ981W Pme8B6MVJY93G54oYXpdXEiGrRH4a5PBGEHJ4uj22ZUPY/XuneMH1Gk2yLyeLb/h mvWGfhxAOH0aMS8i5/pw3Y6jszv7gUdsucLtpFzb8r2WTlAGXjyX/B01xplQGwOd qfiomINrSX4JWpVRZeSNLZCtfxOBUZyhT6iRbu/daU7tiL8o/NYS1byoiRivOcxh 7Ts/9DJ5BVhbR33POE/nCg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c57q89j5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:32 +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 49JB8OLw026230; Sat, 19 Oct 2024 12:51:31 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42c374ssbd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nhQ4FDQxQQ9ukdHHstjXWMiz+TG7j0gcNYFQkzKIofb908iR8RFi1/fbBsAysHFTibOIgx5VfVi34ALN73ruTJw2XpFX8/5i6ml7YR6imFFRNmSZ8jITZzq72/0qp5V0g4syDO2aCK8tm0y4tpFhvcGyQhSYdx6izUDf7j22EA6E1woy8jWOWg2QLphSPIQlCbHoZmrtC7NvC5q/7yQRZ9yxVIVbTEWdmBc02QhzkV9X6TwVITekhRcxgUPxOPK10mamG2pDor56/KhAVW5uLlA2hMgNuFCM0ZLgPnXhu77zxFhvKLCFsH2hReNF6ZmnPUuPusDF5JyltWQtPhTQzw== 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=OcIJ8jrrzApf5SR3217+LG2qhbrklln3NjgWYaKsowc=; b=cuAbN/F2eeyyln/pic9yJoxQa/pD1tdL2SiJUUTv+exGT6k9UlXSXsORSLicev2RoM3ohZc9IzKYCvMwHnYnqH09EiLhv8AVP7BO0iNSLqwvd7Ct2LgkfoEunRnxxGwhWlph5mw7+hjzZP5gRp+srDZY9thiShFqUCGgNpIJqXihPlzAUCVnW94x3xnxQVdVQG4PrL0zioeZrHs6pn6SdaXSbk59VJwkclXv5wlzn0skcJKm99gbCVW6Ntk4blmJvEgs0GgSKevXYtDgJ+BmHxaFUKJnz4xQ86dN+dfuNsSMmcU0BRS5Wrl+2cJhIPH6B12uzNhCbRo+Ieww11LrwA== 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=OcIJ8jrrzApf5SR3217+LG2qhbrklln3NjgWYaKsowc=; b=O4IbyvLE1VsZIpv6Toh5Vz4be2KbMmGHsW1ddj759mha0ImFm0ejWOM2quYPs+XYdZHG/KZCu05I1XQtlsMQ9aPfQ+5eRPh4rRHAxtGhbPcbFSxxgYokQ9+Qp9Bo7NW+iAAfyEz5LJ9XKnJazOCLNxVD8yL7z7Dt2f6G8BAoH2E= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:29 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:29 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v10 5/8] fs: iomap: Atomic write support Date: Sat, 19 Oct 2024 12:51:10 +0000 Message-Id: <20241019125113.369994-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR0102CA0028.prod.exchangelabs.com (2603:10b6:207:18::41) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 7585ee1f-7c70-4081-d14d-08dcf03cc050 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: pKO6GRgh2Wy8lrj6bI1aeHWZuw2odPF5esbpBPz9JPjaosGIP0iTVjG2KrtlbkB8vSIvH9vENPU6u7/D9rBuTYESRjM6YEFvBw5BCf0MhC044U20rd+3KZg/e+ai2H1Z+njIpH2MAv78sjxGbYIUusFDjR91AdiDcNgUX9Ao0R97zQjhTgmm4oaMeKcVHZbSCUbErpbJoBeEgqU4dl9zx1bLqoowYSgKHVLSehLnB97pyoHhU3uk4FAOMClvUvE9mdhX9+WNGKluTtPkm3VpOVtewJT880132G3Hq8qyi51ECsQe2oFtE5FHzywfk6pNG2nwuwxqkVYIlyKE6psYGkxunJCtJ5elHZ02btDzLtgf2zZxS3sNsrwRQBCmwbY6ai9RAyL0ZyMIku6ONKKHkDLLzhJzl1qjrGXHuRn5yfgjyMnVwCeuprECqJ6qo0reQjCDzQJjpg5Ifnlte+q8GKpKEAoHtcxM3EPbDUHC8pN/IUw4NMlFoYLv/W05eLd8c8LOxyyh0eO1RMRXti7B5GC2o5l+kUXQ9xlZH53Gd1/6GNalv0GzSzm5zrgdBDLOIP9Gul7SCpfc0xFV/mk81DfLOebIDiVv/CdD0Pe21uohxq+VaKVDIW7LaPwicisvn9n2hAjrZEdAHMrUhM5FWyrUAz2YTWl9MGB2hDX/zzj6I1kt1WGfVC6zvr93pQ2txOozbzXQwJFBHo8GNgH7q93daixXA9l4oak1TSfRKUxhLboMysYEjA/KefB0kpSjVIu7nBI/A8DWOK4CC+2OBNUmqRn5/WnGT5OoJY7cWDjO8+JESD7ZOUrciOeZJU/4Vi70Bz+npnFoP0DSeXwtdHo4dxzK10067oQ7PTG6vbZsfxcptx9uBG8fe7HgKaosy2hPtL/ms3ag9CosTIZXlmYlAZx2uUuosSoO1hS4bNeFMTpssknwPeZO4UuZMZEgdlwQxK+ZkXxNQ2DtkGlOoiaibJondGvh9W6I+7egUB3g7BkhVaHAfnpgvxdONf3AIH6GSZjIdcQAhtOizX0T+wrernKDqmRHEt62u3zGydwUWJUEL4xi2GTHku2z69Op7n6/Hqt8pqmVex5zVe/kfm9H7bxvAv8nVB0MGS8VlrLAwKsuR7+culR00ZB/7XotkV2vrsCkqG06X2G0PyBW09lQ3m1UhUuES8LcqQUGFwK1TnFp1HfEJdve0h5ahkYOJ6Nr7yGxzyHydGHecnaa/qazdNCludrb2jAIjatXeKUJ5V4bv2KbcyqWikiKNbK/8yqdQ6nTkD1IcTBENENF5o8cB9bCGFSfMIZUcI2XfyN74Qvly8VLMrXLJEsDLC/F X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rno6ZXwRKBEkyaYMmCX4/tl6xpepT2g/3vjUrvm9vN0rCa3aPbAasD5VvyNprVT+5pbXFUCN2oHe/K/4y0dTfnI2IxEPGOkyigG0u/bLTm/q7KWRdk/V+LMUZrSUviwC/cjLgrQUn8MH/OeXZ7aVg/e4YBaBUTFAGVL+w2d4cuwWxZltcKyvGUYtxrQlrLF5YY4tWfGdDQ4sL5+R766wRIVnTp3WI2n8yXTqtuqY6okn7h/FV/B3ws8WMJhed8sZynID6tMB9UEDpLTpI0fWcux6N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Ap/VSlqBdxDC/ZZNF3plufZrsOs0hP7uuQcOOFrTaP4vfOLNbHdqCbozkL23gioX6ovv8g1NOF7SQU6ymBil47nMNorFPQ8+z/TwoXKJ/pcoG3apiJLfFQBPg9cL44QnOf7wB8umGnKThfColDt+qzxS93TO5G8vSzVmK40Eu/gdjRRGg9BwfbMwSYg+H55o3KTwA6wxYpskm7MbmPoU/+NtKimfhehjPV8PyTwJALXZk8fpN0NhFKVcC4cXogSf8vcyK3e/8dNpf++axA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YxfFiqlq4oYXCYFpRH3IyW9exgVWkzvZazYIEJgI+apdbFkXGo4udX9NAh0Xn9bOFzs2erHlonQUqKjqWJcL7D50LW8uRq2yhAU1vFQWCBLFzWKogRYB5eJUuzOcpn5rBA7wVqpLI82WsLn0UmTzAoPuAX/SJ7JroJCfob6jqczp6HWl6VZNp1Sig90j1y6syIYtVByZbES4NGqQCCq/CWpC1KjhYG5ggwNa9hN2DFIQvF+SMzD096kbKc9dlrhh5fCw1CYyZG5bIsm5eO9MWCIAkAlOnBaihK7ChEpAdbRoIumUFV8Jkuot6fZJ+BP+w86yRHnZ6N6tArodkOVNmNTEXKoElv6ey6jSBhXzU7ho31gsJjR9htLIFe+mRihaU+EboV9PVywDkeAlIZrHIxmnmc3ZH+z8Pttm5EnAXcfxpUfsK2MdeSfsCixg4mJXkUsnFezfNk9YZoTwNKjncumbzwtuqZJmLD0Gbg6DRMR0fyDin7Rc0scNmnY4MOomJGznVerfD5Xi7PZUrm5c+efeBbBvfFG08f6+NoGUv4QoLTsifMMIMW+ayf52kwKC3d4N9dizK35lJoTfYceJIfl8H+WH45SUj3Qi6VbjgSc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7585ee1f-7c70-4081-d14d-08dcf03cc050 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:29.6327 (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: jlYD9ruTzSZQV+teiIU7o8/cE2qc7lWzvhDEbmM+1Dtmyi6dJ5UrRU2pp71hgkCYaNgEaXHGeYTWifvLJ3Rnrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-ORIG-GUID: 8jCUnRM7xHyVDaq_jLByIgmGzGiQkVlS X-Proofpoint-GUID: 8jCUnRM7xHyVDaq_jLByIgmGzGiQkVlS 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. Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry Reviewed-by: Ritesh Harjani (IBM) --- .../filesystems/iomap/operations.rst | 12 ++++++ fs/iomap/direct-io.c | 38 +++++++++++++++++-- fs/iomap/trace.h | 3 +- include/linux/iomap.h | 1 + 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/iomap/operations.rst b/Documentation/filesystems/iomap/operations.rst index b93115ab8748..529f81dd3d2c 100644 --- a/Documentation/filesystems/iomap/operations.rst +++ b/Documentation/filesystems/iomap/operations.rst @@ -513,6 +513,18 @@ 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..ed4764e3b8f0 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 (WARN_ON_ONCE(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 d0420e962ffd..84282db3e4c1 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 Sat Oct 19 12:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842749 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 071157485; Sat, 19 Oct 2024 12:52:46 +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=1729342369; cv=fail; b=dlLfmGk/2TSlXXLagVUQk7CHMLhfiEFiYDNvBNjwmyS2b0MObjUI+dSv3EfEvjzwrvn2y9aCw1uMtO6dFLAjXv+ywcS3Ri0GHfait8QPMqncfPVY1mx8iba6tj9VOPzwsMcD9+NJh8oeXLVCtnMm2X+4G+264dfuNewM2OJ9ObY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342369; c=relaxed/simple; bh=3k8YlyWoedrDmcHXS8vYxXDkrXJWfaJ0K/l8qe3kGXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pgzud69NRGN5TtbBpFE2ncYDGT2ufFxSmcL9ayOdr+CMoFc7+SlXFMv0mb6Kqn6znr6I1XNx61563x9XffzjN9S4VyYTuR45ddPAkbvC8tJE3WKDorUCna+c/FooesG+fgUp2Mb9ZEq+KJiYPldSEbJp1GBgKA30OsbUk2Jbf2c= 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=MEATX+W+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=y4kKtAKT; 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="MEATX+W+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="y4kKtAKT" 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 49JB9rF5022793; Sat, 19 Oct 2024 12:51:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=6TBUcSBMjRN+CVXfAOayVUIdEUhKXjFo9KkvWHdeKsw=; b= MEATX+W+XQEx+3kETN6C8vFm9K2qBb56hSgqPZD19TRKpqCJzIHfuSpveuowN1sA 6AfmbYtZX0Y/hjJX79ASTh2gP7/r+2RM9dGLrg4MnmQZ4n8RUhAGOvtxCmzk0C5r GjE1b6lhYCQZ01ENmW0c4oJE/xtGvTT/nTwz/mhm3lHbHPjWMI7KOY0Vx2a0kAaY gN4TC7/PT/lYWaV9FcnEip2dUUJG0sKfoEXgtG7JxGAt/VOOiT/QXfcqaHzqqNap vjgvEo0jZILMBIbeUfgFRzNleNH6QkLUUWDNoOPvbdbX8vFBXjs+tVoRU+CrfH/m ZGtxMocjYpDgOQz2YmzC7Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c5450a0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:34 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49JBO4PT019660; Sat, 19 Oct 2024 12:51:33 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c37atge4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RTPNWAmYSvc4U9nCUBgJFSFVlEEF6qrRsRCGgRD27wd4hymIK2K7JwSUKUobEM/DuRVwVHiBF0Tl1iI7szd1OG2BOBskRVhX5oZV0v1RaBg+D0d1Guv2qmHHwSu86V6U+WNrcXaPBDNmruB80hQwHbaNDMz6h8Kj3fgyXAMwOrdZ7cHRERNyQHwdz8LT2pylgTLkHz0Wq6swFYdpzR1UlBVgOEsHVvwM4HgDm/wS5pqTx1ssQjlKy/kyAc+vmVW60hks3rbjH3plK5MWNpxU2Xjg3PHBvAfHv1jAqQkRU2U9ZIssg5mo5FF7zuiXZZK0xWHXV2EC8+kGQjJR1mB6+A== 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=6TBUcSBMjRN+CVXfAOayVUIdEUhKXjFo9KkvWHdeKsw=; b=sQDohiNmMbn/28/dty80Eh952qfpfXPBDyUjs++Ib1rR+6snPjUYNVeP+L5RYNC3f7T/D/NdqURFBuVkCwznB84RP3nT7UXpI3oknaxMt4/6Kse5SY97qRPpxkwFxa4SQg7p6VmptkOYeygDrPVs2Zsug+I2VpOa7S7B0IZisjUVjOqG2jDGOjm1BQFcNZarNHxFVnvHGg7RNt8U6WHMuTtD5En+40nvH/TMxiaRgwDrlsg4bNKt+tQKi1431Aa5oAkdSQOyozfE52kRfExg3KBmoHJbXQmNhnzu/SiC6kYuQIdArVH8sSNqYC6K16c81CKyWFRCdB5cE2O//dTbZA== 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=6TBUcSBMjRN+CVXfAOayVUIdEUhKXjFo9KkvWHdeKsw=; b=y4kKtAKTnvOsFxlp9kKZu82OjIRRTyEYB1WA36Zpqrn42hmhIe5gOGIxGMzwt6HO0vALgS2yoLx3XZbUMODJl6au9BcXhX5+x2xLRd/qmMHJjA3ayxUjodXxbVWFMIcD3kxtStnbPceJ0d+8ts672/q7kxBlzuZdAm1Lvfz6EyE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:31 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:31 +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 v10 6/8] xfs: Support atomic write for statx Date: Sat, 19 Oct 2024 12:51:11 +0000 Message-Id: <20241019125113.369994-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR01CA0006.prod.exchangelabs.com (2603:10b6:208:10c::19) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: b48876ab-7cb0-475b-b417-08dcf03cc141 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: ht3b4delUbc4ljRXZE83MkZE3SOE1VQautVK5ya4yM97H876wECcWQz42MavGxsDXJX7aKCaV5tWGkaXIkX7jAFjO1toEBby8TRFGkUgn8naTOfQZua2joDotvMVCzlenIBm648GZLfSkPFDOK8gN7EGoLd5CJNiQt5XyS9BsRhvEDVu0PepP7cPHjMhMRG6cmOjMC6NbZ7OeLNvAfqqIBQtkAQnAUV9ylrQ656sjVxZzKwD6poxywHB2fdxmhya6NQ/+46yMa1t/hyb8udg0Re6EUp45hHVrGlThktlLhBrW9h7T0wypT6UqvWDXsREciHEN4RRTZ9VEVIR53gtddNtfNl4nDRBLH27YoIfx+PKuFRqLmhrFA8nzFOWgODakU4LaaU4WzL8aImjW2yzxvV6WDQPvbclC2xG+RtEab6CIX5vpC5tIjnw3+pEwDY8WeH1W/jy7ocPaOmwe3/MAOT+La2nl2yr1xwps7h1vpL7OtPqVMpD3zBTh8QAxJbM9/SW9B3o4plfJ6f3XxXbaerfqhXiHkmBHAFw6pLoyQ/3lXQcDeyCaIZDP+41084uKe7GFvnx2gE5yrPd9+ZB9QDZw8QFBMohHzuIceI/LvXt825vSIqwaQY7K6N0C468NllVWMJltj91GrfBrZTZvMcpWgc6BnO9RmJbf58bEga0A9lKuirHnG5j4+0mYuJexpx9uw6pj32lwhqRFlWuS5GMYPLeyaIqmQH0LzH9knFg6M9LhYFA04PCz9kmlRJ/vo9w9S2fBDIU3MlNY2IyFbfpGMDltdvJakt4UdvcyTes6UrnMjV2MkRXpKJLEZdW/hkIFqbGC9zk17UbzqtSB9j75mzaa2u3+OFpUIJVJtsgwyNRVHgi2fvbWXP3zEBteIVZhB8+PUQVcHw04lrmw4uOCKsNxkY057x2WjDf1f70FBREfoQ9NitT3hildCS8sJabLosya1IlmvV+JN06m9BHLwMrI/HIHvw9Kc9mM5u06l2oH93bkPVmkHU/3G+UDiW5szZiVU5ORtwpYZMzbdXEfkC3GAK5+RPyGMxEWlvmdbiTudnaOe3G4jRCwtaqG+3fxCGloLtOCFe74oUWUe9Zzg4hiU1sQUc1Jso8mQ2FkwtIN+Y8llUXhyStioDmue7WGJ13cFs4O/UzDIw79rLYIrC2UehJf4OVJcLSvlvqbrJ5iETPk3w/XGfUKTIopcSY5yggNqg2CJiCACYfXCKKHeRIyd+Ox5oAspKc4UhoRER5DnPgB8tQdnRp9bgMUj8BF7G60Wq4Z9pxiyhVwUBuU4bSBih2D2RF16mdO/9LDgxDEvqNcRQMzZLh4F8p X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6CMb2h23+dIOf76LRROJKMvBmFsI0pvaxMyjtzD/aQA30yrUYVYA8W/QBk0RXgLcoNdQ10sLOJyYwE3E+igid2i4I0ZqnhUWApSeHNURhqL2R2qu8jjeI8jbepWvdWy7Qb45Ou1c14VyhbT5cdQ62m5ygAJh1049L6dZUyYLNrlKITP1Cpx4HJ8QgBjh+75G0Dbk6bt07zJW10QV6VvREPKfVv230yiUrOjvVuNMhJ4x8Uy8d6+u9DvLhy6T05J5ncURe/CGQp1D0XvVtce+qIbDKtGkdYpJeCl4jPFknqM+5APJGdgdCeDubnfbkNnzUkO5H/ISydWhDa+u1JcWC3BN/9a9ULrAmX4vqbOcmpL2zgdsqSrwrT6p/YXAMqbUCuNCZjdcNZSxlCaZ1ojZtpKVaxnoakvuVDdfzHh9DAoa4sYEub1NoMhZ7DDrsAeCs6PH0dZ/3kvxFa21DSjQSShpeMa1GAlW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vd+cVHCg6h7rVw3DlR6rItVoJ7Z82JMiE4FdiHyaIdB4VB+QxDvjdJMxR99dA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VHRyxXNjqqjrZ3jIP+YTq0SjAn4lDbKtDYzNFBGSCEPGEoELvWRqZy8DjkyVzQ987r1AMs/IlNowVAbIYzv5P+NIYcJCbbLbZlnPQPs/aO6ScQOCiCZH660+PLtPyVkDFksOFaqLFcdMRqR5uxhgkU3QAGzCTqcTJMlgqtiZXaSOCxENtZe646pfjZ5oGGUB3NIeoBm5HL3FPZ6DhgmUU1gImOyu4Yzp7dxy7kh7qY4SiH5hfa+VfJ7lL5exQZXvwfNXBXCb7roxfRW2W0akXr9VpEARFKV7qeC9dLw3w/oTozisl9IOSlaN2+cT+bUzUEOvXggidT2B4qaB+DrSj7fsb2i7q+OeHW1evd5iQ6l1nTwRTx7pHjsDVeqKulapt4MrMv81O6bcT8EkBlkz9g3zyM9RrJ2eXos+qn9ZEfNYR6r5tbfpt5X6k5yprkwm3QI0IZCtZKkOPZKj0+NI71oxgVHfbo0jFQb5KQahOWvUfoDR4A3pwx2+hR4wjik+qXWdsR3Xfdl2jgshiUbKZT056kKi0K7Kl0Ju3gi1dRlDi2PpLWDs9YZztSDE2P8oCtQQQrWlGHH0Tpg5j3PfPTuiOushR9Y/RAI0de3bL88= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b48876ab-7cb0-475b-b417-08dcf03cc141 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:31.2023 (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: a186CNtSbXOOoua0KbIAhiNsuE2qzcRbYHd425LnGirGVA0Swvj7YHX/28Ozgn5HG5gBquaZzN8gi1gKcAlXQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-ORIG-GUID: wq8f9O-z-A2-nEoG_wWz1pOV1Y6klZYm X-Proofpoint-GUID: wq8f9O-z-A2-nEoG_wWz1pOV1Y6klZYm 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" Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- fs/xfs/xfs_buf.c | 7 +++++++ fs/xfs/xfs_buf.h | 4 ++++ fs/xfs/xfs_inode.h | 15 +++++++++++++++ fs/xfs/xfs_iops.c | 22 ++++++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index aa4dbda7b536..e8196f5778e2 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)) { + btp->bt_bdev_awu_min = bdev_atomic_write_unit_min_bytes( + btp->bt_bdev); + btp->bt_bdev_awu_max = bdev_atomic_write_unit_max_bytes( + btp->bt_bdev); + } + /* * 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..3d56bc7a35cc 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -124,6 +124,10 @@ 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; + unsigned int 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..5cd804812efd 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -570,6 +570,20 @@ 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) +{ + if (!xfs_inode_can_atomicwrite(ip)) { + *unit_min = *unit_max = 0; + return; + } + + *unit_min = *unit_max = ip->i_mount->m_sb.sb_blocksize; +} + STATIC int xfs_vn_getattr( struct mnt_idmap *idmap, @@ -643,6 +657,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 Sat Oct 19 12:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842736 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 E2419746E; Sat, 19 Oct 2024 12:51:52 +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=1729342315; cv=fail; b=QwgYt6NHtQYDeFb86MzwcXeu+fcWdSnxkulgouIUGrd8Ucb31J+DQ9JYj2xW587IlXTWI+Z0flZ7wWpHVDdsTnSjx3PGclSvNV3MMGcxOSJGJW8p4v2YRR1rst1rf6Q90QyWuK0cStCPA11zC+8MLRkBi6OiZe0AMptYGqkkv/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342315; c=relaxed/simple; bh=NUEk1bbDc8usjD6kSJzNyzPJWJ5mEOZbk47XAZjJD9w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aq8huiWeRKk6ITnMN3dvG3Lw6S7qiWVcC+GFJ+qdd7z0VAATIkg7GvR+pQ5tZI3jg/jUx7SZQYsnG/zPtaNO8KklgCpkhbyKppzjR8wkQsGydiSDQLu9GBmG3SmQPvQnmkLqRmaOAl+gtsuno0ZU8nJIDcmMwLxLcL9/l2FlRQc= 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=Z7ZMbQzL; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=zOEMqfik; 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="Z7ZMbQzL"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="zOEMqfik" 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 49JCMujB010965; Sat, 19 Oct 2024 12:51:35 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=wx3cU0sDj9oufseYMbZ3PwTSRTprtFQLR9CAme1UvfM=; b= Z7ZMbQzLCD2oPfjj+J96PpoRvtxk8hS64hmbLsszHYKeuPsHnNMSGrisWP0a51qr NqdVrewzCRf7EUDVlcPeretHWYYdxm8703K60wbcErp7MhDypmyXUDaFkmC1WSdp eeNi/TYJRrepxAXukYSHX9cQ+Dp3BMU3k9Z5G1uc+k0vFvwo9OTdADNUwXkowmu7 ZvGQ6PHBYedoGq8Mm1p59yapvq2bb2Ep6KogzS1x0DOX5ndDIliNlL0cOesnO4Ic 1R3XFg9dEMgx2flxifQCmW30vFtjmkuk7WTHvib5aU4LR5A7NI+huLwNiTDM8VGU VFHqsDBjyk1i1md/zK1U3w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c54589tn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:35 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49JBO4PU019660; Sat, 19 Oct 2024 12:51:34 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c37atge4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nrVCmPazDaURfnH6AkgMHCwfFAbHQ1q37kRYkz7x6oS/9XUoIhBCP73brGakrJVfqocaVlg3+mPErwNgyIZzMakZChAqUn52QUMWsFGOAnjzXyjDi2dfhy0gKx6JbEAMy8bwh4UuDWy0IMOyeaE43PLlFxWzyxS7tYNUUOEgaD+4PXJQDMkJOHCn1+fdxbSvLo4zQigASQJkdRdwfnBeko0KV1Ci1tmKshmKDHIZLPgfQ7ELNmHAJTr+/mTfDZasX+9vNCaigzM9SIGmqbvYZ0vhp4cUGmsxgFAGORKvMz0p5XPnl/7RNUrJ8kw6SC4t4djf1myiaXxfIAv5HvpXBA== 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=wx3cU0sDj9oufseYMbZ3PwTSRTprtFQLR9CAme1UvfM=; b=rzbLQff8uFjhzTCnvmiqKvblYe04FLBQAW6gcf7Q2BNahLsgDZrWGe6Lp0IUreqZJtwJtm+8xzedLMpNxZNFmybEDeDi6x4Bk6iwiBA7HFPuvlID2dqyGxnNpdHI6afQFmZA5nIfAS3fxnRWtmLOXUs28Nto8Jp1OPrckXvBx/l91PzkPMH5Fa7EWIRGD4ssMNp1dwbHccSAXfj6o8CjjX116Mx7Js82vfg4lOf6cucW0jINk4uUSXv9Jm8sXEEObcaok5e6jttjkvi11hGS1lJgOLlEkYEQjimC862XJ9hO37Tm6oGTo3bdXoilD9PiJSg4KjWnkvbuKKZEyX3SDA== 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=wx3cU0sDj9oufseYMbZ3PwTSRTprtFQLR9CAme1UvfM=; b=zOEMqfikhrASQ7fyMflStcBIpBmDweeLI2/JxJjNI7sYhON2MVSNo4ornoIUp+AEvgiZVz+gE9ibitwThd8mbYoKZAD75VvIsSuJYDU4blGKszsqlKSE8g+cZV8rTwZ+19XwExoG0s/vBjtbslYUQtEnQUPS28gsRdEm/FF61eg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:32 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:32 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v10 7/8] xfs: Validate atomic writes Date: Sat, 19 Oct 2024 12:51:12 +0000 Message-Id: <20241019125113.369994-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL0PR0102CA0030.prod.exchangelabs.com (2603:10b6:207:18::43) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 823767fb-f123-47de-7587-08dcf03cc202 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: zKxigOy90dsc9XvSj1mV0Xik6dAQTMCfD0Iqrt+kWxKJ+sIVe8ld3N0yro0kTDL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EuKKO+HwvQxysLSCvPiHoEVBa2qdI1cSikc9V7kh8lS0RP8ADXp7RRlEKnDaMM1c6Q2hJmdu/WKr5PNxcdAfZXFBr2jNmmoYUXmbdgxyu1Hq6U9F7FFYi/nmBJlbW1ftVM+HUpnjqhiJPF+vlhQ7hMUPl9RcXHMzy6j0J6z1GiL/joXKr9YmYMUIB1sKMcCBS7VRfJKG0mlO50VbERtpzq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 159GqL0zg/LTSKfVF11K3Lt63lVBfH+eD0btCZIsf2PX26tJ2JOpd+iqjUGKXxZoExkcKDeOZmsiZhlMvy72kP5Co1SaMPIzvKsbsZzEXKqrujXPv/3bAw5V6sMInpDG4KmdwT0o8J+bBQfOriZjqmVVGrrkzFyjNlSFEO08YCSgp/+xYWTPNV7gDt/RJJyE06pQxj0SlQgf0Skml9sUOcvQ8n+7GY+BB/ebKeU25rnA2CVmlmIaAQ7Jni6BWt97bUMPDRYMaMTG+FPZPZKZf9PLVdDbYKiK3vNw8aPvXZjgTCzR0F3ZT2nxFnLkiv75e7cdTcScm124iswpFyWJ1e/3JyK4AKlFzB33UqBk+YZFLMTVpFZwnvwJb/D6uRpmEUMNPbwIb3PXOJJwEOUPgN3tuaAS3KLxpQmHJm7st+mBWTHjYb7OBv+Y03e0945+Q5Bmg4PkjHV6BccRgM8D7sheBo8+xL14snDTEl2WfQfXqULSzpNN9fZcRRGPkMQdmJ0bzqxcFXOehb2PBsRyX7zie/zOKVwxoGsnrIx2SsEcZSSmeynAU8d9zzRf/aQdGMiaMLkc3MfWMAqJmOchFUhVQuT9Azg5hN4362ZiE9f6CFsXEEmp5qc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Ss9yddP3gM65I9i3lONz3sNayp0zW2WSakZroclqq+vDTFfVfd+gdE/RhazB9YZJDZzen/SsdhDLy6yNta6TSKqO54KcshYE+C4vtGiPms3bNBOU7ubHib6nGZETWAs2TYVLKw5K6lvyHGvpTnX/2Pla8tRZHzKGw2uhpZ54Hb1ifgTwlnGIRUPF2B79XoY41jYhoJq2O1Cw9Tu3vU7WR4jg5JEa+fcwfmkr5wVy11Ubcn9gb3u9p8MvKQJvjRjlsgoV6sOiQ/rBs6g3OUWL4v0dLvqhFydrTzq6S3vcQ47WRmaTWeICrjpN/OpxYrQSqKMFWvRHHq6/BIR7QOE44hE7B4HKgwgirwpyvNVSAIaakuFLg/DEVguICaQbAqSyjhYkttS6FOQ21t1PwolS//J0LKLO92/DvnxvR5q3mZY1WRfcSH4tN+OIy/J+mafmj3b6ZFFxLGK7pNf9NYZ1phJirEf3cpn7Ub4VdPQh7MKvycz4WJVMgHvlOiMJVgCYam/8VyMyk86VlZsU/5sNfb8BroW/z+V6vr1ZfW7zOiOp3zSr3tjmttT/Zo4RmfGCHG2ew28dxmiI9qsYXalGWm8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 823767fb-f123-47de-7587-08dcf03cc202 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:32.4967 (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: bDfloqVSlH40E12vKhQ0QpYypeHcRSY6/J/3dknEVYT+BKotvsGF/zBSllneSp61mALCKRqxFnIXqdO6laF0VQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-GUID: HX-dL4Bm8ey0AAENGJumuEMAfFTy0Hcs X-Proofpoint-ORIG-GUID: HX-dL4Bm8ey0AAENGJumuEMAfFTy0Hcs 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. Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index b19916b11fd5..1ccbc1eb75c9 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -852,6 +852,20 @@ xfs_file_write_iter( if (IS_DAX(inode)) return xfs_file_dax_write(iocb, from); + if (iocb->ki_flags & IOCB_ATOMIC) { + /* + * Currently only atomic writing of a single FS block is + * supported. It would be possible to atomic write smaller than + * a FS block, but there is no requirement to support this. + * Note that iomap also does not support this yet. + */ + if (ocount != 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 Sat Oct 19 12:51:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13842750 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 4658C224DC; Sat, 19 Oct 2024 12:53:50 +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=1729342432; cv=fail; b=K/C0W9voxVhTxU52nOzonQFWMPXt3LJxSgR3d/pAYSoTBhK65reqWoamqh9FUnSx57PUs8DBhdCobiiTSlm2eluhQaIPnhOFy4xwKeKrQLIT53ayq2/y6BRMGsEO/vgLMt+nbmltIHotPUrglyVS/naH+1BpTsywcT3GWDsyFuA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729342432; c=relaxed/simple; bh=d7pCKy/v4R/az5P1ZFT4xRN/KoSadNhULPvY86q3tKE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iPESlg0vtebcGj+srbgjub2Hrl34SlwG0Yj9ziTpFRg3hgAIpG1fbW7YRi2uxltoOdPw/fD6bgszmMJWbCVeBte/b57F/gTahXozL0g73dZ2nCAdE7PTsfwQTl3R82cYHt9Qelb1IfYWh2P42ScUBUAV83tIE5XNA9KDxqiJAW8= 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=CFLolAMF; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=tBtXI4AO; 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="CFLolAMF"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="tBtXI4AO" 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 49J45eEG016052; Sat, 19 Oct 2024 12:51:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=lrb4J8JHejQPyK6TrSyNIOUpJ1mtMiCcpVHtMQikrnU=; b= CFLolAMFa2nAC3e14cHBLlGVXcsf2Zz5JDW44QbkWVh0+RhJb+LrOS4XjkbeHTGp 7sOu3M4henHxejvtlOaJn4WlTURSf6TmFYM0m0gkkGtpPjMFNj0cFWppb9D6Y5IG b/AsQHG6W7hEcyNdeV03hghQLqhImWEWTKNRz1oGYZhMv5gr1q7a4hoxtucKevvp gy0f4zkGUeAIU3gRjcNwlnQamaRE6iB23jWB1gDbJwmR5vFFrbztuZrIeGzOQZBk yXB/U4LkUpGWaJiurlLlWnZ0QK1j7HseUKqAcKEml88j4v4Je1uznC8MUqRemoJO IngrC28TQSfL4mj/E61Qig== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42c54589tp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:36 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49JB7irC020344; Sat, 19 Oct 2024 12:51:36 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2045.outbound.protection.outlook.com [104.47.73.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42c37atgep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 19 Oct 2024 12:51:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hPM3ZfswhQhnWaEPr+gAOa1v0tAKjBZQXl2ycQoALbqEpV/WMmNNwbmxF6UKkWlc+vSzQKXukCktGAlmhZ9a0oQqU8JLa1riIB2N1IA4QCtRB6k28WA4XPSP1CSFdn4FYCwJnxiHFjWfQTPcb0DCX6IL9Hm2UWG6wdHSyEVG+e8/hcaYOKWD2rVvVNDM62HsvitiH3zhnes5AFd/BMFmVdlRMAKQq6+yamctG9FirFuS+9TLXiCJ4JGrQSNRJI9f8jW9OdeQ8HzaTOChWQ5I27CCkaotVeRc9yeyljnounLGWGFM7OpUnQ7CohW1RTwex7Qs2eOLzwayiYIAIEXtrQ== 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=lrb4J8JHejQPyK6TrSyNIOUpJ1mtMiCcpVHtMQikrnU=; b=wzJbUskanVKGMHDvh42zKanzYt8AlcHdU7OcpDyx1PH70tA9vuxgWUAr9uHs4PZSoJNcHmD1srqJSi7bCGvkwA/8EOfIB8YpR4E9tmaAaQtV2EjDzJVdsojnlgvDHUMu5gHnL9zoarmnFrW1yJy0ja1V5W3Pa5UYBNJDVuCyS3LPYR4pz7m1HmTAmjHlkzxieQVp2T1FkDIq9HtPPAfxKfUzj3vcJGt5LoNvU0V2V0wmD09YvgpPGDMgOiMyj5uWIINm2asjDPB7yqXfZCeBSQP7v269lld5Ydyuc6rpROJcHXxbwIf8uqL3vE+O5KMBfuZa4d8F7UML+CiSsyp46Q== 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=lrb4J8JHejQPyK6TrSyNIOUpJ1mtMiCcpVHtMQikrnU=; b=tBtXI4AOgFBdgvIviwoEHRU2Tm+BbfSFGRkAm6JCvU4UzqOYCHdBM+LbTAwdhv0brLUm8qW2IrFLCSwXs5+3mAZ+661x+gaAoa2vIBrRLfJwdxF4uCS5wSkblJo3Iq/30JgEBn61bwTMQhQg2oiRy2NFAPtnGMrfxqW/GexE89k= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MW5PR10MB5874.namprd10.prod.outlook.com (2603:10b6:303:19c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Sat, 19 Oct 2024 12:51:33 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.020; Sat, 19 Oct 2024 12:51:33 +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 v10 8/8] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Sat, 19 Oct 2024 12:51:13 +0000 Message-Id: <20241019125113.369994-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241019125113.369994-1-john.g.garry@oracle.com> References: <20241019125113.369994-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR01CA0006.prod.exchangelabs.com (2603:10b6:208:10c::19) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MW5PR10MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: 85ea9b3e-6ccd-4015-5640-08dcf03cc2a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: OhsU01tV4YPSLCdzOTNha8KUBrG3dSNjxK0w3uSkCjH8xXk+qkkdiftkobZR92Mjzd5//vLUJmliJItbn0dDZdPsYuvTZJjvcF7oKnoI3y9pDD91P9EMqAie6Lu0Y1JPqklfZ+sIplk8R6N6mnOMh1iHrCg+M7wvChrPDbRPIQ1cFNfehHrTFl1/69zhmy2IY0wshokJi+KSvGnx579udMuHs0Qo+YOKl35WWKRiiRq1DRQeBjMAUOR5/8wocqOahqWhaPR1PptKyNtBKNUIak5Z+ZikrqRcrPLkYJGBQeL+adBzKNJM9ZGrCJLOcO05mXjU00ZSrWLarkEqg9geyqkjoc3WU2isn+RY7Kf4f4NcHUGsBFNcBULQp6o+Ur77/GMjY6v28YAJmQRk0xkZheCVjLOvfQcCmeCD+kihkYH52D6tvvQQG+wRd6kZECMwj/XCN5q+Gukp5IHh+jdWaGO0Qc4d4GwBVa89qyAr0Yew6LVxVX0fsSDt9Va0RcuQgywLiNRamcHUOQfRTFHiSfVKO0irwHeEMevTlyBlFhYRyvBiV7y/icJn9yRYJbnfmOYhA2riChweMfck7UaUuo4gw0x1q2BP1KhGzpMIfX3Q/eus6hAsgUe2b83vS72vD5MyAl7E+9BTdJ6nJ2+itkiG5s/Az6ZhxaPYFDSbi6DNPghq44c8A/8U/+vBEf4OQY/fbCiP3XQuZ0kMMcrsNlGW+GoaxDx0VlAQukD8rBgEu64oj/aGx/xT39CK4DV7d1Tje/ZYoq6NTpf6WZ8p1oe/L6fcAJ+vpGPZ1qNiC9hjPqprk8SUL/qz1mDeiMlj5qjwONElJz5sw0mu9TxkpVQXFe/PgggGbqCdTPtXtUqGx3IBXW5apdCa1nVXI2WGMhv+C48qUiViRwUZaIYNtswOfqaAK7Z6oYT1VNzTWIQnuTUH8jmretth5BAJGSoIVcTWOai2iswn07FKejMSho1L+5Ld6QtGZIN46hr36lSaAXoSoCLUURdwcDu9kQHt5RBxBjQWCjMYFS6rGp1qQYXgUU3xZCmmOix6ZEYERX4cfZ6EdN/VW4aD4eZ57TLQYhoQcQxrEW/pJIRCJdW4ZK51TDU0VrUu8cvdccGfmGEFLLg8w416vsBlyCYXZo0L9YwOTS03OZX4lHNjFcQfI9fq4jnrdGU+gwJbsQlHp0f/Oje01j5QeMl0hJkxgHn4PLClk32XfvMVecnSHqXnMYVxMEGBH6fm2PJKsaNE310ADgvM2CVW48MeZklq0fCuxvVyLyFsMQqdG3yxHnnzbFaV5GQbvOaJfSeTJ2AFYr2g3XM1k5cMaJlf60DD2QdT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014);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PVjYx+igMtVZvermS7PMxEdKYronEa7rFLtM3ea5y79tBSlOV15gpzFiJgp/l0SkwoAuO63THdpdkKi4UU4J2uAPVvZlcf1g2XntIkYGDVxjISWwaUPOc47y6qer8pPX4AR/mUpfuyi3SBarosD2cTJCQaYR8bTLBK7kxBSFR/4cT+vF//6fwCfRUn+3KAtnoXxJv0Mayfurm7lIfVjj1awx7SeUQAEE8Nm7yz0vllE9zF2HqX8keck67tXbdBa+xqJgEVbLc2AgWtik8r9LmOZ+DYhFUISanUbxtXdWgsQBV5zKmr8v+yG8AHrCog7RIbh2iWD2/LLiZ1Kh09gdxrwsQZ+ryPu5tkc4RHYbsCsnNaLt8yohQOA01DgjxXjOj6VYTtK0XzF1Xywu2nHYby5o+g3K2WqBEeYrSiTJsOiEGWd8H4kqOLsZMJDkPZZMaPoLX5j2Awya+0cEZwwuCWazT56gOuuss/GG/FvBdZkFYo7zfDZHEiHXpEPoHC6cR3JTwRKitSf9Cj3p5y6eKu80AhzPSwB0alUM6oe34YVqgRQ7T2IN64NVpUbggdo0z1eVw03615Qve4lyR6T6nnsJM4B4dy+I4x19jqjcLe0sYoK6rlG3cMATg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: MZc19Iljx6GHKoemG/FAWF3UyeIlFRVs5FGGhiwU1/sq2BDtcJDk8X+xO2HaHvzphfud9V9hRXFohWbZd01JGt/pXfQkZhrzICp7Qsc/73ZNC192smaNqE1kcnkxDHociWbSRrRsBUfRh1d8GJmBzTqOtryoiUHpcNA/X5mdNdSoS09fQDADSUrjcCclk2bBPNaWww6v9/J5VSQrDIX1x1Pwc3e4PNnD1N4AoqWx468Npu0+S+lErDsXKJtd88HsDvR9y9cInwGvy4ZdTpLzT+1KtyNLFYXP8ARFbKr5jCEQVtb8WTtp6U4W+th5LRxl5Vm2NND59NX19LcodmWZwkmIs89ZQNwft8ldlHyfYkNr0LKOL7S9axn2BCcdxoVZ0Jw2VuEVnXnqS9fXLtBl/mD++qXBCl3ZW2qGMcYAD+4p5YKcSfPYaqzxhL1t1JWP6l2ym8Fbzg/hn6nYyta11zk/WSOf7Al9Py9ax0XL5qY71PjSaSMxdhcfkZ9OK1w/vp/6BaR/Eot0KyC0k/+0RRdeaNi1xHan+jHmHFhmE/zxMurNk0YeAfl6tJpqA/VLGDccXPXYo87+c896mxMLmnYfAuXz3dG0HIIRMkyR838= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85ea9b3e-6ccd-4015-5640-08dcf03cc2a2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2024 12:51:33.4955 (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: FH9jWB10Jwm7eyGnGL7h8zlZPXruMwjcr+JfvgG9kySKWz4JAQ0QeNWujckfi8PSCTmA0Farc1ZDX5u8KVmY8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR10MB5874 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-19_10,2024-10-17_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410190094 X-Proofpoint-GUID: mAJeF7VTANhm4QyeT3v5FzD4C-EU61RP X-Proofpoint-ORIG-GUID: mAJeF7VTANhm4QyeT3v5FzD4C-EU61RP Set FMODE_CAN_ATOMIC_WRITE flag if we can atomic write for that inode. Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 1ccbc1eb75c9..ca47cae5a40a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1253,6 +1253,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); }