From patchwork Wed Oct 16 10:03:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838084 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 C7C3721E3DC; Wed, 16 Oct 2024 10:04:00 +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=1729073042; cv=fail; b=tPnT7LYKJrqnod7MAuaqe1Qa+4TFpNir9XMDwDQjCumXyjchbWWefcL8OD5OnXaMFC4nOCzp32S2FeTNUu3u20pJQNJq6RdfRTWHchW4bZIldolqemixKzdTiDBle5z/EXkvLPziNviQ6u1Q+KIiVWl139CSUbQWoQyeAOmiZBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073042; c=relaxed/simple; bh=X3U10wfn6VZKScjWTDOaiqO+ijk2vv06rH73YhyzAOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hscaqralAM/t59o+Ybkp8zU+umSedxy+T2VJqd4ZHq+VgEk3U4cVlBqzvBGUbnHpaGbTKZpZOFi5X3xp2EjtI7q4Bdrbww7U/MVODR0eZ2xw8al9rQ5XWjZIs0O6833VhVYgWKv3C1riS/mR1LDAibfXvF4T+XQjksFWFaZppOY= 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=BP1uftVq; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Z1yLVznL; 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="BP1uftVq"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Z1yLVznL" 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 49G9teBX001150; Wed, 16 Oct 2024 10:03:47 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= BP1uftVqabHMNV0HrW02rCuArpGIReKauYbYUOGkRJkgmT12cZtu1qz/J3QZ1AcE fOeDsZ5NX7mSoMeefLY+qtO47+nWOx1e7TtLggr+3jHmSUygsDXslMjQnYwupmmY Vfni7Env259ePYfQYhipIaIp8YjnY+P2B1tPL0W1nW20Ofi7GlV44LvCr4i9DU8U IQ+Vj6/zAYSjY+6QlotwxpG2VqfETY404todPpuGmzqaYqZDbI1ET8UCWb0v89Qc V3Sit2io8M5SkByJaoD1MWHqm2CasbSG3RccDO97y4J9sx6OmnADbK2nJ2yKemSF gGGeG3L5TX+7JFQfyFHkNg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h5ckpqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:46 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9ANiX019471; Wed, 16 Oct 2024 10:03:46 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2045.outbound.protection.outlook.com [104.47.74.45]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mrgx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TUuWILLTtOJTIJsk69t5wLKy/D3Yk+2hht4XLk/ZWXqzyuG/2tGMBlzHkVRNxZNvq2D4a1D75c0RX9XGkNcxSERC1R7VL6waMTIm+BRzTAGGWpLHCs9DMmLxAx9pKrzsHPdpR/6jo5lWQZlP2eujHhLea+JcDdQRpEGy6Our7042UEmOWNuYds5HTiilxHRIQ+oI3KVk77MYED+7IjHXlYal2oWzWC64/mCqO/ah/ECKwrl4NFsb8ZBPz8A3Kl7lAl97DCevOd8+dHivJlL+BGPeozh6P8bqpGF0qaNwGseLAwPGAbxAyZ/CTHcn2hsMXVqyA8DEim/lcE+WHLuQog== 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=JwD84ub5T1LjL8h1eRmzudg4b5rcbby6EKBCsHN2ngwE7QmvsgZ9ApgDjrhjuK1NgYqDPNy4Ree51ytPxQ6O27LBUp1KQvComqqOMvXsFM0czcvPtneX4xmjFuOxQJicHb/QgX5B5IRZnwQ+xl5vKn4Ddo3A0wD867IQ66rW5uQ/CoiyY/gHcNbNteDt9YnK7U8BRhY+kg8UNkNPtaJD5MHY6oPPrwO+b7eD+tbqT6VBGeRbWkGgHrHZPatAOIt0333dZrZLOrof02OQxvb91Y3kA1dxbaeYQO6DNie6UbWi6RcBf/9/eMa3vBFOpTTVFnKbheSD49D4HOg9Xq8RxQ== 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=Z1yLVznLMOZ6bIrbuF9hBp25QxE/gkBQJvUiM4UXHtibsCZAaVdZcetsvuk9ned0FvPAIt4pOKw/NnrNCYSUHXFsQTgSFnSIBLPDZGsWegFjqGIrnAXQDgF9Jc63tP8rLqo+WHTSsC+SDCM3WLpNUMQXPy0VeM132vMw+/rPFQ0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:43 +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.016; Wed, 16 Oct 2024 10:03:43 +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 v9 1/8] block/fs: Pass an iocb to generic_atomic_write_valid() Date: Wed, 16 Oct 2024 10:03:18 +0000 Message-Id: <20241016100325.3534494-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0087.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:190::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: af2d4001-c4b2-45e8-fe25-08dcedc9d0e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: +djMUAuY/FQ92fZIENw2NEqouvW/e+bxZTjsFUUp2vOdXj7UE0YyLwUzoWwN8JLwFyZ4aJp2HBQv23+mZDJs3T/TwNpnCZfDoB4fqRL/HTKO07WXW1CevO0OX4jBpvjiNkCQtFxo69g1G5VFGnJxLya5XCPrXBeu6OE80Fer/k/XXllm5h2dKXzBOPArB3TV3kEm4TMEDR/pDqB02fiHkCF3fQrtsnbeBoNLpIbuxGSnHTZR4RTXErAxcVeuqe6SJ3dnvW3T/5SmMu9kYKHd0PFI+nNLq05IKueS/lQy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SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TyL+uVHS7QPaZ37CmWaipaOZ4GvHf9o0TDThSeJxpsX+czC9P/blvJTB/ky/jDP3x1rVemFptO5az59ZwLA7y2MTwmkcGE9KnidQ4U6MW6ucF/Kgoi5D1PCU+VpcE/I5cmgsmIHG00doWWUp9DfrPmwa1Gb9o5c8z1504iMWFweIBs0gQSzVkVMMqFE8qZN5CeQZSsLMqHs7f1MnPCgmpsCA/1t+n6+m4F0VAIs2d4l8HBX8yqIu20bVHGax8Q3u0+UHz/Vl2yWp9HNuAZ/QgfE6Ooc2IhGvcIPbEYmCXPjEePSXWHX0mnhKF28DYBOpUMJ/uCyw4G+e1YhMuWa9zrRi/pLtSzUiDpdM44erTocXay4OVnsJXmpecaAY3vdZpPJI1ll4pZJhPTQb0OActvRoIjFk1vVPjgW37ZHaaQykFAXUvq11DMvz6pE+prTqrX6lSGpu9byKnMTJswv22lUzv3WCvU2Ms0XwiO8W4tw4SijXicy9MutsZ2HlnIYQff7kv9yrKmi+uwDKJrRf0XD+4VKQP98bCfK4G5ic3KV8yAJ1keqmfaB6XhcKm6iDJkWEFyrLWP4kKbDLfmURw0WHrCs+285x6385z3i7THtVUKRsgoBSiR9bm8M93H/5eCoeOYcOy4DjgIbdDL386mz+uzd4Dj0P3qwTwLFqNeyoRt7wD6o7fVUYXSwH9o2dsca7B+zUCeN9JIWRDO9oJvqo5GQcaqvx2iNrM8oEFP+j75U0+xTRLguMq78I8yLlnC6w7XW1cTH/C4jSP5W7Cyitm63csjgzoTh7TduSgZHkhyr2WK7aaoSY1LqM2ryA4r7i83nomX6jayIY9FLjDOHoVlLMeqJCyvoov+tsV3gg5PCENKyHL92ULniCY1IPtA+TNuVilXbWG6hzBURL9gu+9urrWqGVO8dfiVWgrT0kK4d7OktFFFFs9PTYRemgbGs3WRMWW4ZKRFXHnwDPajukuxVPOrueNejoWR3oLEernGqPSrsiujJksAdQfEzQcly4v0MLeio5PMVie2AVmn48zSWkih2fz0d1tdhi7aelr0+LLc1v5IP2U44pDlWU8K662sZQXL5/aSSACL0/fu7i++NExqHds2XYFr1qMR/4VTw17zUDzAz5ae5lR6oSU+HONMjqWyEF+3kzfj8FX/b68n1Vz4mgIbL7WAR2bEtFc17Es9rulyAQ/CdMKzcbGWYdBLch2qKFAOJmq62imbfP7wukC9n4oJh7SifMyhhGTlxlrqBueOZuAHvgUfrAcLqJ0GH4YmlByFHZtx7qNYzfNn7sEILGvf5fxqF5ruwO43R3VaGUSOkgvy8fcg8kCHcez+xAG1dDC1DpXywUI7J++Wppg5SJOKt9lAdI9XpoTpm3Myan5LNX7bHXTSbuYKwEQebAelFGE5DY3cUQYuA9TTJMhr7qM2s4oxxDL7dauAq/EesrmPPVIagr2eKqRMupDMWkVfB1f8WQEFlIAwShijirboHPDB1S7ZGm1IpVTVfo22/B4Gg38EwgTm9Hjj6CWHyLniRSgi2/ZTHFHPWAZ9TeB0YhSFbM1+SrN2xni020xzDJfqBuUSbAQlE2t2Z6cSjw+s2tgGXSopQFMw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gef1wZOyQJeNWF0JURc6QH3cmgBM3pigN+Sg2X2Z9LhVYHhkebsNiP/mfr+ZQuOjhjwkbu0gJxvxZtjdMM55zKN/olknHtp3me7/wRfhAy8nkd6uOiSrrQyM0aWsl7Ko1z1X48ZoW/mhEO0AA9ukWsizO4jNjC7/pRNA7USFBJ/Z3N/QUmfR7oRKySWQNxUigcB26iSLoutETTwg7bR7QDBfv2rmI3E7wiuoq8TVPurwlDXIX5JG6zxNj9fvouugN6bNcGhTsseIXHllvfS2swPLckv5Fp2v3BorpNscMJIAA6n2XEXAeLssuJ6NzYbFCeaG6F+hD8ddYlHNI3Uy9KoMx6N6Oq0sTGloQWJyDGpmZ9xLD/70cRHMoY4jAzvtFn3uOStrUiOTQNyPN0RVHPLGAXJZkTwd/qBm6BYRNOGl1NH9KkTtjgGb9kv/6TvIjIeThTeYJXV01ECp4fxtRNUnTBWYacLsMCsMv1swv1CiKIN1OmDPap6Clz4p7lcK2w01KfO/EBC+RBO4H4CPlUJATkWYjkZY3st89YW5L/Abg64FhQbzkAB6FjeXAHIfo2GII0UNIiKy9frfx4iEDuKzvGgSM+Qhjyh7LGdLvEk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: af2d4001-c4b2-45e8-fe25-08dcedc9d0e7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:43.0808 (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: bvENMEjr69HVB0EJwCBQEL3bjq8nI395PJxu6k1wxR7FrHKl4rVY5uyU8bdefkr4Uf98sRHrZ19frigyefFTxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-ORIG-GUID: TCUXOZf03HXU7Ntpm0BhyqEoBBi2llq_ X-Proofpoint-GUID: TCUXOZf03HXU7Ntpm0BhyqEoBBi2llq_ 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 Wed Oct 16 10:03:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838086 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 516BC206E70; Wed, 16 Oct 2024 10:04:06 +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=1729073048; cv=fail; b=qvL78pO8MPUwGLBAi0GAk/+IaOYztZ5J+TZIvYLc4aeItg8ZGE6v4k84od7/0H5b/BR38qbKCYyRWbXfj5oLAgVZzkdf/bmoF5r6RuyNQp42NjmqPVc8fq+/ti6TDqxQIRJj5s3ZyA8ioXNYx4PxLf3SWYOHKGEz2Hvqt+DTPI0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073048; c=relaxed/simple; bh=KJAmP0gEIqFdsDHQw0vXq6kl8BLXN7Ilg5QGz9ewTHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JmA1cV3XKVU14HEIn4z4dlFymOTuXmMHpLBIe5JdqGpmyuxjRXh5efdpDaWrc4GOowXWdIQKBbUrJUAMSz+c76cZwPBs6uEgUwLUdXi0hNC+ERqGLCFB9ekwdfIddCYZBg3jFABHlUiGbcTeR+ZipZ1z+rXbIBkO8wrDGhRtLuw= 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=DGGF7Vjn; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PCnyDUD8; 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="DGGF7Vjn"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PCnyDUD8" 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 49G9tiA3012994; Wed, 16 Oct 2024 10:03:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b= DGGF7VjnCyE7RTfHt3M6gUW7NQyUJEl9Dq2Z36ozzeKf6d0ZVjkYBwNnNEX3GHy4 XvXiPTlxkUbV1T3ZZvISWIyfs8OAQ+6kvBS3TyZEXoL2jYy8G/emzpzSm06aOSuV StwOF1C4A5S5JDPhDrdJYZeMJQBsV/g85Me3Nxs9SQ3+7zweJcoY7lileIhXu4nc h2L5kUi8xMsCXgFSlzmLUm13KeZflqFUwHOfj2QvFFctFCOixMtQk7L4dol3OgPP l1mOCsc9xd9cLZQY2ZBRZkmHsxhn9VCg04pDvSFL6vzx9Zs3vSTvZHxFc1vb3dAK m/mjrg0yCpYkyyO1FKxQ0w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2kfar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:51 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9uuBk013985; Wed, 16 Oct 2024 10:03:50 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2045.outbound.protection.outlook.com [104.47.74.45]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8kyqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UOpD+p3JkI+tjwFiZqcfzkBR7aDBPHkAIEKuN3uDKDTXJJTwVSI5kykjhOX9ESTdRU6WWYFYo3WCGvvnjp3qMVnvvR+rlPsRbnHipuoE+v/MFr8mURwHFzP7sRqziBpnu7z7khn3d/t8iusArxds4EYcqwlZU/YVABzrDhioC+TQgNcpmrcmgvVEuRJycsorLiDaBQDJiD+ayPiO1HQLlDluBI9AFxgqVl+ANv6wKJqpF9gdRmaG8/yX5vQgOXZbqo4I6RFJhvhyZTiqX79lBb1GGf9vSf+Hh+pgvZm5bkXzTy/WzvEsBuDOAhsFMG9qWhXiqc5Og+0xiEW3DdsnVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b=LZD1NR40eXQNP1hedxFpH0H2sRW6vtbktPq1aeBsFmIKRKwAIvxMmTrm6OTTBvsbUFUENmaX+BWfpW9pFaXdhflOcikdnNQOCG/MK+LkZP1v5VViIC3vnqYQ0e96jN6BLv2tHXDljem6HRoJJsRUniN0en56cTf6nbW3L/OSuBwS+QqNLqiYrRJKS8l1A09IPzazlzVOUR+d7CkdIvv1WKmeFXDAWoXRN8CxXnodhbXHN4GE66NxMvqh/mVWj9TAYd/TU32d4WZinf/SiXtXfT8lWiaHUa7MpRZzLvgUR3Xi43+BO0cCnLsfZoaxPxuNqtLytRgOMMRDFtTmXTu8Sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=96/CSpPkbIkWeh3kdzb4Fh9gHbZM5oqNERcAoaBICl4=; b=PCnyDUD898wNTEI97ybGGtNyl2feO1qhZYhezmQSpWOoHtEDD75qQakYvI5ja/pIQDBtZvkWd0wZN1rNuMCPHRBjgZTw6LwEIeIeU9W7CHWz12PLqdIs6wMRWeYBR39/nVGZqoHrBGTg/e6XZsvUSXFPEDhNu6bVS8wWwTKcYFE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:47 +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.016; Wed, 16 Oct 2024 10:03:47 +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 v9 2/8] fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid() Date: Wed, 16 Oct 2024 10:03:19 +0000 Message-Id: <20241016100325.3534494-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P123CA0095.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: a69f2582-a16b-4a70-695f-08dcedc9d364 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: /AIKR34/FF8x/Fg17562qS20Vc07Awsfe3MyoN9uhGeQSVmr1jIqOHGLvceDO0W1xUlAKz0sMaYUT6LWWpgARcUsUSVqKpQAE8euiYyIDt1A3jLwfZH962EsJU8OPDJBXy3xyPWqHYEf50aZ+JL5pXEHxEdXZrX5ItcjfrTihjrxyaxSG6lJ6s9oSlQfQBY1kK00OlVK+u++J+404rCKnyt8eiL5fNCcnBiGneBy3vkVFN8PdCSu4vX5No51fJxNQxaBeMQ3arUmgb9yXnEcYSbPgqgEBLGMNCqrZ3LQp1cObUY99WnyXbqhTxSQ6mQfJBUgGM8NBmCyHsxV0bDMm40q07tV2EVClgyWSyF+jSKRkzXK+nkjUsI/QvWrgL+OrK0UKJEz5U6il58We5AgU1Sh8aNPKGJaJS7plpl0sgacQ0UgqGUTYaNpEWfAjE7/FCqjnlxqFyhg4lnwK43SryLHs7+8ezLbvebROuZH8Tc2YocChx2HLXGyXboQ/Ot9QzZoVHo7y2Y3p/liQUWP5a2OMe2D+IR+RyvJS7HbhLlMd+83ezlUfD8Let0kbfI6hK0go/nSOsEIpXA06jk4dJM0qfqn7zvU+/wRW7Ro6PELZIBrhgmB1zJUbXvz+4/6r8pf83qmScxJO1tgg2hJTS/UYxYvyxad68zhUzegWspwB0lj3aeX/sos6y/P/i81FgSZjeCvB+z4dBeqAygJh4TateyvxSsTEJhFleWUkS6gjN/ugua4In/WmmtJUuWTRskn1RN6qf9GcHp1KvXw96tCpkGcu6dLZbb6vyeCZebuCvtxiUWAz98hvqTvVe6KOPlJEmO4K1e3+Ctfiqo5OdDkBW2wPdlNRi1qYmNWByc3lG4Ij+gUJgERL46QUAnm0NVSpdufALK1p1i2MD6BMWFdOx58KMIDyYFbuyMHSMmyMj1uPDzxj2FeIMfA/H5ojPHQpYF4yMyNXvzAOh9dtkrA/uIM7CRu6+vVr4CrX4G8ANPbnrDtZnvFclNlSfAu/MVR0MDk7+batLMFT2kagNST2O/2KnTriQaBXqdZ0SMEywixVkM/qAFG37NT22S8WplCEzzKybFNKMRDhQ3t8MxIaHQgWGH/oEhwmJ1gb4OOY4aPoAyjdS313mtIqXqL/0rMNyoFQhhfzh0uH4IPRZgUkCiDFnog+N+IKmPRaR3k104c2iAyCoPLEQWxHb3h7+8USHy80HmtLLQIJyLOI19ySuyt9q9wI4eJUtCkBJh7ZDt1QVsLiA61nobwkenVK8zElMuGQrB5WkipZwQeMQ== 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)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gD91Ysr5PvG5faQKLEITC1T1rmo7csumUT3o0Z66hOIhxB2qE52eqL2KqJQOQxktEnt1fYHyUQJC7vLc2OB42HzndImqFRodTlnKLLfRVb/mRfPXzdEB7YoO9U3U6hzwaS0if8SguojjTHTiqqN0QxuATbJ2EUrit1BkAUZTTgitbhrkBAnw/KxMNRtpDT+f1E4HIzYxOlf+OUt7xGAH3+LpydKA749WRnc+mX7Jp/v6kqIVJVy8m9YnKNYWM0LaDT2Fwhcp9PV6O4LrTLGzxgVxCkuPUm24Nr+p1eWdEt/0xZ+KLngKyopVGOy9Ig1edBtZAFBUqZt+MjdWpG6A0m2lTT/a+VLCfK0L8/k2KxK6ptNxoSSXejN6UA9r3Ria0MWYVDsMv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AlKSHMhx9G8HmRdVBGfwfXWR1pc6928zcNdHm1evd6LDizi9vX78W9DEbzazry05w0+evWOJ4qC01a3DLp95V3XTyypLDrEytnhIyvx5KIHU4G2rzfiUuE0ZyWzkHHcpu7OttItAIXJ8uCw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: jJt46lh8o7XqRXaLmMQXxrdzPiRDcZBYJAGr1I1/WJWnxn3p4cveDMljWAg9Rfj4yEPankMrHjLumzCNBBrK662Xmplu1WaxIwmH69WwzMDJ3c64izYQSJvzrIvLH2IvxThzpjfA3bEdbthx+mEkFEa8JB5KtuQpy0RE0CV2gzXxwhYPULrwVCTcjU35ZRYlaZRNDJcUHWzzBZLP4Y6N6rctqQgbIlLpvoEgyPMBTWTB3a+SAxNBTlA9bxEsg+D1+0IbYokLCWBtzXqBIVV8OqX3IaupMUK/Hy40vGqvPQe5RE9IXicLgAIOI1RNDzlKUZmyRr/qh8aMI0FxpBdcGLJcczRmLXyHaNyU1BDB11yFUXF8XAy2fETHOz2HAL87ecnI1/fad/hBZJaVhfhC3hidf54P29OqMcnclyKZV6I5XvpDJhkBjRVj/el5O0rkqN9tNHZppRFbNr1ixtUmoFGmad9Dk3LPzTzsAZSvZ/DDJQzT0G4AmawsKv7Z0HcQG682AP+6j/g+/y2rxeZcDgNZgS1NVrqPVE1NqjO2IK1SwTBlo68BvKplPHkUqn8vYM6ExQ8U0pStOJzG1iC8yxCdsuShV1rUmrrlYA+xzp8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a69f2582-a16b-4a70-695f-08dcedc9d364 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:47.2270 (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: IGo9bSTQMwjPrg7vVwz9XDdIqbK38k8CGvZoGPfndKDssJC98cL9dEsOl5xlMMVNQINi8DKIZKBSKs1z1sG0rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-GUID: QhhghyGrfitnPOPi03m6qC4mR6KG0eoO X-Proofpoint-ORIG-GUID: QhhghyGrfitnPOPi03m6qC4mR6KG0eoO Currently FMODE_CAN_ATOMIC_WRITE is set if the bdev can atomic write and the file is open for direct IO. This does not work if the file is not opened for direct IO, yet fcntl(O_DIRECT) is used on the fd later. Change to check for direct IO on a per-IO basis in generic_atomic_write_valid(). Since we want to report -EOPNOTSUPP for non-direct IO for an atomic write, change to return an error code. Relocate the block fops atomic write checks to the common write path, as to catch non-direct IO. Fixes: c34fc6f26ab8 ("fs: Initial atomic write support") Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- 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 Wed Oct 16 10:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838087 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 E4404205142; Wed, 16 Oct 2024 10:04:09 +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=1729073051; cv=fail; b=PQX6THqt7CfCt9FImzh9gBq/KqtROnUH7KbKVFUraxdpXOZmFqnp5b5MBuIqODArRwWO672SSa17Ay1iwtmjJcslMjWvWDt0lxkQTBmTN0gi+BH+r3IviJJWJjPjnki3KmsltatrqJDQVAjVnJK7ia5v84PqXLIFragWRFhps0g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073051; c=relaxed/simple; bh=7sYTQfRJi+Pg/3bmTlcxn4KenjXJ7ZFkDJthE1pnCSo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mPO9rapUoDNJf/+V+WDSXQsLKMYehI0O53BNVQFhluAmWvMYalbM0sP2xdZU0WkCtrjzBoNCj1/+XVL5Oayovb37qrHorHqtzTFSA7oXdsqHi6cVO7TrN+5ujnnK+kqw/o2Xt/6tFOHyBGniYQ/iYyp9dfKB9yU7pGKKIhjlV9I= 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=KM4ZiaME; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gwRFLkRt; 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="KM4ZiaME"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gwRFLkRt" 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 49G9tdup012975; Wed, 16 Oct 2024 10:03:54 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=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b= KM4ZiaME9WscugK5yt4+kmwNdIaWuipzzz3oGxmkMb+LNG43/U2zTax6u9GuSUUe U3XSP/UIbA50t6uCSEHIXPfn42QKZLrayJAPhd/pCffgFWZUNizJl+Fy1Eab4ZgH N8B4Fq7a/HTyGLnyJGC65zUrup1YIeAnvao++FIGBhCNjqsFZLsM3Un3Q9SEO8Jp f1+5o0zyKPumhHJy4cZWiRzRuNqLikVx4StFu7WfCAxZoYCZ0QjdGRRKzaEpyLf5 XGuPbN812bS6aMCmMDO0UUlIxNEldR7onxlsFdw4wzo4Mab5WHAKZ5lcC7nVTvY8 8KyP4k4VTBSVLPPTIdp7vA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2kfaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:54 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9ANib019471; Wed, 16 Oct 2024 10:03:53 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2049.outbound.protection.outlook.com [104.47.74.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mrkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jFOnMvMHkrlg8bMxYCnr9/Oice9Q5Jjy2Dz05Yhd93X8FW+iVp46uZmwVfQPdTegfG01l6mhmBKeUOTtOHmKmPMoMdCraHHOQWAJlIejJ3BNBOXqb49Jv2JdxaHE+oKsjBc0RCqhXLBL5wv99Caw8GggdPrXyurf64wWvGF8ZjskK3aKChojONnhQ/Ur2YloqWSAEeHssRrnGe0W0LEb7x9M0TgyAd6NoIU09di7efHL40MPUd0PWqTMFHwziVaX17ayQQQhKk5/jJ7yOIO3Z8q/ZFMO0CCby1YGdXHByVvKg0Y9M87jBPuRgr/cOWi+EWr1dcLxrBHU4fZQTNdItw== 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=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b=ZumPSgfSK/F4K4f+XE6dsxCNkyTlvBBTpBSh9lc1RwvsX8ISAyglWobyB6qEVnRdYEjaY78GY6sJ3+6qOHuz+bK7e0wRBiU2HA7n3JwCJXMHP1kCRe8kUty/ERGAFQiSeFPknjvqTNnEXDIxHJqMeYRUn7qmrONYbES3hYsVscs981AbQFbXaO05lDkq5yESJ71OyoC01x1oszeXVm9xBRCHPpICqDAuY0GBxe5kO2u22vKSA6v1Ik+4RsXOYGKRTfdLMOe7nxwNXvwCpawmXwOUzYXA1j3+J33Ddk8raZMYnS1MKy8AmFrxz2/vltryCiq5Ndmi9SmU2QK1EgDNeA== 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=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b=gwRFLkRtq/Kwgv/xt9rcftPwhIih8UXIDejdni5pU0ZwTFznp4paYqdOlUs9WS4+pUexNiDjsdibsMbHy5IdzDQ84Ll30bYo54+KcS4chdsjUh83y22hnAn405ovJzd18wZ9ayiJ51tU2VakpQivE9Kfo8ef305tbNKIaJfgVpo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:50 +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.016; Wed, 16 Oct 2024 10:03:50 +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 v9 3/8] block: Add bdev atomic write limits helpers Date: Wed, 16 Oct 2024 10:03:20 +0000 Message-Id: <20241016100325.3534494-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P123CA0095.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: b6a85e4e-0c15-4da4-263f-08dcedc9d547 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: I8Ko78psgNHvMe6PbuexMJS77DT1S4WKdbQm5YNWUAJYyhQaMKOOBnPr6vYK6m41Q5PSLc0jnyJLUOGRGYMRs6zvIhxM2pIvTBgGNLkuwkJeVh1nRPfC3qeyLrUTnNHyXjzXLRPOjYIkddnekwtYFuxab4QoDbHuGAeiuLcrVtCCK8ioX4nnckPtVhfdYwegnkGM5HnkyXjlDlQP/M8zZvOmUqEi6SJTxcEM722/VX+QZbEjV3+By8CIbkB7lkGeXlaRphAeiDghfKzXRC2tfYzfwKX6UCq50WQFhfeLV3xmHacPY0J4T/0/Ka19uBTLfAijvUjPH5YJWADWyKhIruAzdYNPu6FwOq5BLj0oc4ec16iG36vHvDXZhyv8XdxxZrweVFjfnqObZn36BrUfFmjJg0K+qnjcuo22q62+bjxmrfwK/vdxXUGBldL/ru6X5KvCIFi+4FFi8axAVfRYHIcgdI+cFxkPVQMetFreRvNDbkNQl6xf98Bp4xPIsy5dxq+4vtRYuUVU7GG0TDbbDlko8xh2EfEDBdt7YixpJ8+7fIZqlwnog8xXpwLZoaDECghU4W7uI+F/7jN3AOPQSPPJkKK9oBlsvsr8/7xmbx3ICKoCKqj2hVgP8SFS4FpMJy0HiUzhG2OJyK87ZFFbyGxhAikm/eVTn06WQ58CDnkx8uKdpeuM3TSKQLLL6Ziyku6BFL8gp5wgxEKS9Ge5XezSORDb6P0OgbkFtqRyLOB6DY48TBHqEZrOdshXcwnfeJ12UNkjfcMWq3Ro7xVouRua4Q5D2NQQELMQaa2n4c3cK333U7miH9tq8FmE5sUhkT6oGy4/ddMYdhv3xhE2fH5vpU+BWCuo1D4blrcVRKVPrscio4MLtgv7RzHs7EMcrfjGJHsnkTjbOE2lMws/ZnTC7EyR39XEj8URrT1nulgkdCdhWu7rbDqcxrKzsyr/1cmnjPsLQ35fEgwGqt145cBmRkrIyuwLY0GiXaFWWCFSg7IMddRuaDm6fPLADr/IBv4TeIZXwqXRgK8cZ0qX9oIVuqZYBmW3qSkQIYoqvxl7jvZN7zFQB1cfCO58yF9nk6kQG4R5A0UbkOqqHLH/OH/BZmlLupmDKvtHAyj+Jt2vFfDG3Qy4GjDZTwtD7EeSjq7nnfWBNCyTO9oRCQ+q1Cg5kzdHPJMRo1k2qCpYmIdVm5TOl7Qapx/kHxHegbc+cqqF+YsUZ1Vh/m5wXXdQ1HU8Eb3wehXMDJUkKH8+iGK7QXaNnwW33410jrbG+raO8Pn604OIOhwFsb9HJznAqA== 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)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: opFVRvb1QpVTkDbFW3BXg+48ysIQXQlkeTg6JgXfTLsPviedDR4MvIgJhZFW/OA2RZqAzM3hzD67Q5cCKY513TpTPTX3xSI4bL+KBu0qPY+r9B++K+LFS+yYiq1nOWx8FFOSOk3mU8TRxdk4bLzGWOfkeFpOGjGu5r9IbmJRokR2+51J6QhT650z+jY4/v7LzXu/2niywNRTb+rAtRDAQ1+3OFQEOzxdl+lFxh9HYRz/Fmg2YJHp+3qFAF/gGUX+kX9kRdFl6WANdZ53+EHRTYDbICeocFGcNV5vEx5Z8gUH1qZ0dRy/+7tfqJcYhsd3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TNz6bL+JURlcBJntsgTjzpI/tbI927m1kPfiQgzvxI9jNB+x9lo0C8fek8JfC7+kWJBnHQhGRH0L9MUqH86RadKSX9X13PQCagE3X1a3AxtLvzAjbAZzhgtX4gZcs8evBQgm1VKUZXZMDABpiLf+xqnr6DbiHWxAo7eJ44DmHNi1ohO+MTdnNMd0GnSwUXCgQpg2OPskh+40PGm8oqE7YqgA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YuzwCmIRr/xn4+Fq7h/heYdPcLJJrVBi/PcGyPNVk7iIuvy9Ia8R3nl0OedimIw92UnGsXGB1Qwp5Q6s1mF+McGQjoeRQoCbfocW07urd1W7HnGtwS6/Hwjpe18ICeMqLAbQrzYv6gAwRV6aE3crSou/Hg+Tc9+NBdhkcShui0I5mP+6U1P8IMie5UXKAte6+jM/2ERfH6+8tedv/pKVbqPjG7Fle3v7raOpsoIdGr5TBKs30wmTb+ezSxNr4yNeyGhOo7LpZM+u4ffYD7wFSHpMw4XRTPKHrLDoyTWxvwFrvCpsPpqVzxp/9aKWfEAOz1n1wHK9EoCKKMroWqcuMcXsWeLwrz/aJsoRyq6rzKN5CB3zG2MDBiO2vN8+cQzRxn2+NXOM4N2gM0oxwnDzbKYmJCBEjfc+Nlz5EM9kdG5Kg2hmVm0rqIBf5P/jnG414uYgyAIq+ZRYxvd6gj34BkYKcaHpOdnjcD2FQVsQTcBQ7HAzNu8AL8RgfgUk0wO/6pk2lmzlujfSwMNcgHZ7q5k0O7XM7t39+YMCq6TFPhp+tvrg2Ou3bNaB7D49UBq4efftMkwpjyDAjS6NGw+fCxtwLeNdmX/k1GY+V9/PyV8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a85e4e-0c15-4da4-263f-08dcedc9d547 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:50.4510 (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: Akd9cdv/eOhXaAfoZDEthn5fz/yd663aSlRsXu+2NZBmnflSoC+XpchlcCwJLmBaENmv93UxLw6N/95noL1+Zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-GUID: 4RxZMyiGHPzuUDMKHB88NsSp5zUj50vM X-Proofpoint-ORIG-GUID: 4RxZMyiGHPzuUDMKHB88NsSp5zUj50vM 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 Signed-off-by: John Garry Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- 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 Wed Oct 16 10:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838088 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53E6C207207; Wed, 16 Oct 2024 10:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073054; cv=fail; b=l0iQm1L86tJK4+uiVKCfSHPJ4QAJXK8tdT741cD8SOGjwxWUJeHFJMJUBPYlxPyJlUmBdTRgei5s+DMgR/9K58aRJPVohCy3TkW32kNwWY7oNYdQmDiycj1nCt5Zdw1/A7I4tMQyGJvfIAy0FtSj6KrBmZPp9nkcYhno3g4LQa4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073054; c=relaxed/simple; bh=EOxTGgWGNvSBh5KVqmsKi5I5eCDIe2YPdvjUuB0v+j8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XPEJVR9p9AZF0R+6KNNQnmzdqYNrQjq02lWhsMP7zsG4Oi6sO4s+8V3DLNoszt5yLEDenmcSs1Z08HRPT2fCDUncMS3pzuLkA165Xb4cnQeqm5CD2JwjubLJOZsO7tpcmVpUuMrNnGw/BRJIQK3EcVHzDDD9QIn8ltDWdUIAVkk= 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=k2K8r9eC; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=M73Xhwvo; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="k2K8r9eC"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="M73Xhwvo" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9tjDL016191; Wed, 16 Oct 2024 10:03:56 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= k2K8r9eC+Xis++yP1v1x3BXoEgjVOKV2qKj4yBBKH0gKCCt6xbKoRyvVZv8765JO GqlG9in712e4P/HNb1EXA0NGXObOw5bIIRMpha/x0uS35BOgM0vucS8YXRtvTs0H brqncFxomlohE4Wv4ReIB3NRh+to2e4yU1Q0DnSfWIkJq+BUPU1uBt9g/7LSxDcb rq2rQaK+drLo14ARkPotcPuohW3/GtkXMDWwHEWOSMYfXEtab81iWo08COCrbF7j ZAZIDphsSmaILpqh4NTa1rgwD2eWsvbXJ+5L0ONKNUdusXKieOd7h0iurptPLBHm bQax+rs8NhYSeIQ3s5Jplw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7kd3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:55 +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 49G9MF2r026319; Wed, 16 Oct 2024 10:03:55 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mhnn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KfEQVL9cuy85h0A+4+xiqJ0zUWenWBD1K4Ty0ROZ5RtzwL5CPOyu3XQpIGWlmkJYT39TaJWcvC9dvISiEE00D5w7m8h/zFWrJMMoC6X68gkH93t4PKQzMPkpVUU4iBSaKADzZOwOJUNE6Tx4Igy5n+H//EM906IpnKFeDnuyFDHoGS2CjMHvl70OiK2VAYm9OOthJL3wmSiIaE2jBv8ePXnpPpdIHFX7oM9HFhOmv7o4+fHue732BB4JlGx7E4oD2CyutHIr8FAfTd19WC7ipSfDi9oPu22m33PK/OH0kdqi0JCosW36ritTEAaihfIR39C/T5pJrzq0I2kNIRWXFA== 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=pKF2f77j60MQ9rc1U6et+Ncq7reVsge/07areZVudWgRoUUov8eR6HZEawJQdVVZpiNqYeJS9rCNJPqUpUGcr+51NbMyIa8d+IakL2FA3AHm7ffz9yd6dxn2DGXvqXp72rWK9i4/Rw+S8NzoNa4CSySt9b8Kk3q2umcmshdlHyZ4Fvgj0JRasyjHYUbKjORBixovKLZ6CzimkHWmSfZF1VH+cugDmyUwKr20pNqEIN3Brma7CIbCW7VkxJvppu6ymHuV2/HJU1T0+PVyCEO97Tt+YLd2aaKeXqx9H1WD2tA4Gaq94bDE3V3UBy6NeKJBKzM8siLMxuBBKhkqTtw8jA== 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=M73XhwvoSAQEEHzFwckVS95+OmP2mW0AKnBzaOC4yrxhAOACCJMl3OGBYYitAX5e6TDSmQTnbzfXHPNOhVJNMKX4doh6lAUBrhR4lTBwGe14MGSeleRmu4kyEd7Wh26tZUeCGQVAuAXvs8HdDoshaNWf+knnzZKBjJEYs8T+zJU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:53 +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.016; Wed, 16 Oct 2024 10:03:52 +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 v9 4/8] fs: Export generic_atomic_write_valid() Date: Wed, 16 Oct 2024 10:03:21 +0000 Message-Id: <20241016100325.3534494-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR08CA0066.namprd08.prod.outlook.com (2603:10b6:a03:117::43) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a488de4-5bfb-4472-cf7d-08dcedc9d6bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: gavx/gdtJdfB6RV3DuKBFbCST5Mbh352lATlgGqdzRiN29Zfii27ow2PVFS7ecQduAkv39bjx/gZhNrg+WDkOFti1t6YE63ufhBBL57hJqn/TnHc/B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Xgl92omYg9GihFgMnphh0caowO9Ts6H0QzH5SpY+sGnPU8XBKXsA6o/6lEAN2iRy/G/66Kg98uMUc6/UkKov9DaUWyV2/gJ6rCrJpTks/a2C1yYXsaleoEg/XQ== 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)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /l7uF5QnEnhOlPEIgC4N7aytx+aRMnUkpHodeokBq5oFmjlDwJm/Gq8Uin7ad84+ZXkRsk86sWtawZHUc6OFG4ANAY0TQTC2qEGi5R7iORvnWbwc5LUcX99A8mKoxhKLHpsji3cblRjhrB3qfGBG06UjTHXxJN5Kt45S7Qj4hqdXfgBogLFtEPC/CH+WY36oUZoRBUddBVp/Z+fbzH3A65zF+JjvaFIWg1mYj8Pb3nk+F2P5O/smMQyOV6i90b1mOvve3+K4vqN34t+clxcJzx33bwZVFMijbRD9LnXtmy8LSN6VTOyjSl0nzYBw3uT9s8Ogptrixnan/0IpQau/QK2eiI65FDOKdYxqgvfFKUtVcPskh68SSX3InA1uA5ByOM6GxS0XQM5YxaZghYgRK+jppHZGYzGBrZ2P0cqEQ9VTDmb/Uw/51nQldS6edubO1f7GSc6bA26O2oHq09PmMcX5vYM8Z7EPM6s8euHJtHVd1EXDBUPPXJtsOvcVC8S1vbhJ08DNrUaP2EJsCXinTEvjpUy/68vMBY/uVqAZiWS0Glu62jHIg8Z5hw25w0/akDXVisD/yt03rqrD41lhHE/VRNWRpQHgOLAgAAhbsVDXi228HQbKGH9HbL3XJJfRULEcqp+FkSKGQJrWAAvCn3z70wWhZA+tZ/bzzj8pdH3A/b7VMwofB7vcMkCQCElafeBj5+j+XythuvNaWwk2cbsOtOSuPoB5bOkpSjL33IT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XLGQ8B1zZ8CHJoRkWFRU4hPUMfrUQ0NvGGkNJsF3JkNwZdkYdhOH0F06JW2MaZPLV+gAoYw73jhXdDVB5Ulme/aoxkAxNSyHcrh2YovZvs9NQs7SWqKvjkuzhc3F5gFP0DdMDZKR7JWtTs66LUjPOjwGhPQsmMVBN/PnUGXAIh/lmZ6W+Dgt1Dif2zUJr+qIgrqs8CNyqUC770XeIj9qCgrHOsxl9+S72D55creLELvPXgAfseI9SlU7Hf0U9gSch/1ZTTsvtwy/+8N9YaO4X3u6kbmlDeC7wtS2Br3tZvjtZXNniHKf3T84KPXoMhnRuajqzszi1j+yozUFuj4w4EmX2TYKUXHBxVHjZYdvxc3DyA8QbFHKN90S2BmyXGmikOpHOvZV9EWlihAC19ZhUfZqoW0RtlYwyyBI4EZEJ5lEBXMF3sXbc9nLkBNqZGNouyeW4YFDKc2iPQYzSMtek/WoC24krNy7UOwgCo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a488de4-5bfb-4472-cf7d-08dcedc9d6bb X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:52.9126 (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: xLlYhfLzWu+Y6WxG/84Kat4f87WQng3tfNGSPTjVakNYH+iALnumYKLnyehB4ubjlgSwpEq5V9ZPaOacEqgG+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-ORIG-GUID: 4FHVNSEQwHo5tDknQ_KsAHNpCXJdiwq8 X-Proofpoint-GUID: 4FHVNSEQwHo5tDknQ_KsAHNpCXJdiwq8 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 Wed Oct 16 10:03:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838089 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2A61207213; Wed, 16 Oct 2024 10:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073056; cv=fail; b=gOPMR0svGJWTat3bCWnRT83NPIyMy8g20ETk5FcaBz0+birACeYLmpRlm+dCupI5FSLp7SI7RyLekbo6VCqb2NV5c+10bKzzWU086cIwJsTXPucNbC03faUIRfzVJlEN9P1JhhZCe9BCeWc7aHLAq6BuJMC0NzOJRi64Xvyg45M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073056; c=relaxed/simple; bh=GOiCNcapzhN1Hi79FTL2lTsFiOc15kCIgEEDUH+f1WU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=T+9D+EViVqxU/mlZvUafBS0bw4ipu3NM1zbiLjTGf6RsBQHT9ckVVNiD5ZK/p7HWnrBBYxI9nD+bSH7IJ1lPaEqggbPKmQNxLBrpcwyraa37/kb5CuzBgrleVSQVVzvnHnZiiFk1A5d+XiLP+w+qVTro6WgJUNBEtoUcuKA7F68= 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=RVnpvViY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=rC64dnSz; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RVnpvViY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="rC64dnSz" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9tfEb010088; Wed, 16 Oct 2024 10:03:59 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=IbaI8wdmvgvI+qEvkhliJjNYO1Y1ZNPP3yej5CL/TWk=; b= RVnpvViYpXyY3hg/MT//R4BxKlNSm6J0KdJ96STUG55x47WpB2XHMK7UtFbFvl6I xa3TmqFyGHBgEpu5XFHoKgi/m0Lp3Uh633rDr9FTL5XXfss482FPNnvRUrO/eGDQ RstnaaiN+DwqlrGr6K8Mv67m4HPEOGxnVQnlG+1IdNq4ey5/kM6NEWkVrM7rOhUG xeXl1Llr2FX3tQqcpVzreMhnEcWTnpHcfEecH9A2VG2a284ZvEi+ff7roje82V/g 8JLpJ59JmRIJOMOB5GPnrsHCb3o2pQfVwM82WY4LuQF16c19WOhXIw02+3v3GzZ3 iTN5bXYPJrxSVraRCWweFw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427hntbdg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:59 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G8r0Zu026718; Wed, 16 Oct 2024 10:03:57 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjf6eet-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=INj7BWO9t+ksOsnlsjWWXvzGry5xASX47cU5uziXTMktbRu0hcyQ7w5IMaC07U+F/cxtgNhXw32gxkHiNlCYwBBMm6xlVW03wLlUVij91NEWC41poEzzKvTPzkFWKRvrBnQE5qPIUnKATMjTAjRxokRFk8TINGZthtV+sBgvWrsgBWra/so5uUxrfalaero1sGm1T5tdEu+a+Zk30GeXMRBZNIH8t5no2CY6i9V2JOIeLmG4VxyJmSPJPMAjhbvo6PLqIZAoGzf9o0i8VEdfYm6P/K0b0olhIO7zNZ26q2g+x/hk7B0Kma5wKZrRKt0QUVjlsC656yyvovwJ9jfFYQ== 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=IbaI8wdmvgvI+qEvkhliJjNYO1Y1ZNPP3yej5CL/TWk=; b=aURvqxVcJSoL0FK1E6qJRoGjaunbpG1aNWgc+Sj7uRSvVBWYsimKDKeIuGmIlhLccRgo5eHjtCNe5KN7aG/DSaMxntXE6zWf57wadWsIAgX3yN38XeYBTkjxjZFMr84+A0tIvINJWA/fptxRVbUoNdx5wmexIUs7e7YRYr08E4pgmJORizV154xzKnMtaikboW5ej+LFbITIC8fA5Corqfaeay0pwrNBmmBfMT4CEitTjyxIQ79If4v57PVbWGHZBienh1I+9YupnCZBj8RSB138aQDN5P1wJHM+t1McV5kWMbDdWQgUQ9Eri8ZMVPtMtS+mQs6/I3NZJSzVOTiZ4Q== 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=IbaI8wdmvgvI+qEvkhliJjNYO1Y1ZNPP3yej5CL/TWk=; b=rC64dnSzl6yDg7A8pBYgta0UT0GP7z2+vpV7ooiePYO3JD+GtoEM9Kn08bYq+5tS8LLW0q8NK/t+ghgMW88egfwupB8BbqCrPEI8QH/0OdFiXqbDvAAvqHVQ2KTnHnOtEmIlz9TBbW9WgA15GHwxwIYoGZPJ7y2Sbcb8/xeQ8k4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:55 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 10:03:54 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v9 5/8] fs: iomap: Atomic write support Date: Wed, 16 Oct 2024 10:03:22 +0000 Message-Id: <20241016100325.3534494-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0071.namprd05.prod.outlook.com (2603:10b6:a03:74::48) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: de0c49cf-d649-481d-ea00-08dcedc9d801 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: 69GAg1y6Ic8mhrEVsDzXGdV3jE26K23c/q1UKjyd2R6ttB2iK+B6uTQ6z9vgm6eYnVkfua8MSRvnDkWkZY4cAPP6Ur9sawEca+1yS58Teu60MDITVxOKdv+63LRyvL8Vw0AV+rale1/kxtpBgMNZu5HNIju02Q9smqG81PRvVZAcryXBEm6VCZQW6/zbDDp4dwuOF8N0hoMS+WNEjpIhiBQPuxwWey0WdqBui9hDYC8T4T1J5zCiYAFXyE7h6yY0NSR+xmUeWbJ4Z4Yb3Lgm7HEAXfl3qBecQVx/OQPeN2sFenAAPYHULyzZtBX0gPkzrCwXMRicqQ4gHwLWEz2YTbWw3E68FuvaPvI2g0FZ/HXuQny0lLqBX9bKQ5To0ocwn2Tm2DJUrnLUfftR1LDt0aUFgD7AAuiKiUnpD8WQWUUvSRjp5QAtyTQYLETyVAE2t3AHLT6k4QYv+H6EIhBNd09JFw1BBu8JzlFk7P7VdLuWqduwkNOz8Qg+UUc1i/6Z4QawiBf+j5ocIwngXldLOmMMD+XtPYiADdPyadugO9gqjG+cTdJj/pc32vY3Bp50x3LShctUYg5C+5tYmsxjbneaNzvs+WPFGo1U+V+mn9LJxEeX67YNxJsxTC0ON1z6EhxTm1snsGrBBOuRHCKvxUpf2UUKY3WFzaSObmOjWHgrAbyt6PrUybcl1tY2/Y7BbC99NQmNEupBs/eRQ6RlqmH5o2FhCIY9EMOxxx4pahX2j6crO2/rKrHSbfz2O7tmYJYgSRoaR46jgsGId++NQH9LiTRaPA9R2h6GPUMaFr0YhZv5szHKE12OXIyG8JqQsuCNkAhLmIh71SP01VzaWYfGeMsJXpK9GDrbsWVvKrs7keFowkSi4xdsQtqJjfwDyKQ/cjEbzn1OWcNs3gy8BArqLFyQoZZq03P6VFB6e16BdGe33Yx2FUKihHgvKD+GEKe+uVjhTNuqWVe4qrgmXOqCzMJab7P19o33rCLkSZFcie7Zmw4uR8mcNi0kmpXiwKYAMhS4k9TqaCJ3u35kegyzGQ+SVELWkz5uuIILYE344wy59UC/7xVjjpTkLYnXfmRHJeLpmftNFKkT7SlFCwtR9VyFkOEDwxq6D4THpzH94mKAm+8PUhX78xgxxEBRQ80Izfl6NdYC9mzDKGZfWxdkjJWxrxJmJmZI+KHypgu4DChgPKXIDVEizpJFyjP+fFvs6PHDTOMsFoOtL6N46RUP4bHTYeHi1I5by5xkUXq1MQg5CuutinlNmlVwjS+iOTDxv5MeRbvYQFBhXDMOZw== 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)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5tunbVVUWfO/CNTsisNmd49OQ+TSaUm4COLFZg/mWRDt6IJwD5Xu3lEpMb+B4xEt0n0Xb+XojFmADY/oT1JAcyqDOUUFPq7MV16cPSQX1Fm3RSViOeN8HHbwBFRuSOraIAvfHgBuFitTwyZ4vsh/fnFq5ga7eussZI003HNJpPMda03lYqy/WnKzmfE2ZEx0gDZmLP3M2bKdL4gUF5mHEsORy1G4L70N0Ws4qoAuXAd1ty0ld8IK1lG1n5gFNdQJHGqLltaXnKzExZE4YMAwrjJ8+0Wl9lnZM21s/RkTiLytTF8Xo+WTbVKq531KpTp1rQWAbaVF5iGbLUX3DprlA4Yn/Pvl5fYRhYx1tXE8tHY4/lpoZX7KkqTNE6jtJe9Dg2xSR3E5BBqm+1uBhiNmx+cu7IwFA511LiMfSt302Kh+TlmJxf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n3ob03vcGuP+CGZtx3jVY26K2ukZ11y4cjKxhIbVZRGXIZrzdXVbFH1SVIEhZHFPtajqFbPd8fc9RjsJB3bbf1xyw/eaFvpzSSxQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pZuAD+uk0i0RA1dQ0ezeO3w4CU4jsWXJuCXfG0u/0BMpirgpUqo+UWtj278e6NrANoHFayvzKCboumA5v4WRVQJCm4cNlJMtYM2bLF7Q2Yccn00dY0mGnJ6Eb5cpHBcmlrnx5eHruTPh2DE4Z9qWZx/jRfa3pmr5ulk9LpE7o8t1ZeZzxxOyuwZWjSCPILW+Jg63VbEjoACq5PB95h8ScCFs7fYmCnyfBCLaK8B9Md7c9W0FBGn0j4klKkSQ8fEF/2d4tx3E8XEKh+uxQm9owaBzY8wefR1Kx7cbHpCxWzvKJIJAFMtqZ9/nOVrfkGmCUgKysVlYVEAR/4mvCEjNt2IUAxcAL0X6E0O28xGdWGX0DP8KDIrL7gy0K8vaR9Ie0dRVEsNFcSjByksRkEGp+aVZyjJ24uFnZUNjntJgXVv/3G0p0IugoOa8c2hgb4Y37cm87xCFLwSgY+9EomlrW/rXc4RJ3kESdY2MOGJ54JIrRmpZU+ms+Bk7HTsC7nOGxtxQ/seFf4eC71/XyDWyr2gm20gYjqIuDVjekUFB3Seamw0redZddViVD2brxz3gQBXyGVp6kA1PkWpLTYdSN9mOJXW4jJ5GgESSJ8yhtsk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: de0c49cf-d649-481d-ea00-08dcedc9d801 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:54.9138 (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: 78rYFDsEmAaj+oBvZTJYEaCthpWUNhVLaVVPqPexm/d0KK416IAC1n6p0g3wqqgnRKxzgXLdB2WNO4Cgx7QCWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-ORIG-GUID: Ojg1hsCm37P9PLCW5h4M15p2XToQx6bg X-Proofpoint-GUID: Ojg1hsCm37P9PLCW5h4M15p2XToQx6bg 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 Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- .../filesystems/iomap/operations.rst | 11 ++++++ fs/iomap/direct-io.c | 38 +++++++++++++++++-- fs/iomap/trace.h | 3 +- include/linux/iomap.h | 1 + 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/iomap/operations.rst b/Documentation/filesystems/iomap/operations.rst index b93115ab8748..5f382076db67 100644 --- a/Documentation/filesystems/iomap/operations.rst +++ b/Documentation/filesystems/iomap/operations.rst @@ -513,6 +513,17 @@ IOMAP_WRITE`` with any combination of the following enhancements: if the mapping is unwritten and the filesystem cannot handle zeroing the unaligned regions without exposing stale contents. + * ``IOMAP_ATOMIC``: This write is being issued with torn-write + protection. Only a single bio can be created for the write, and the + write must not be split into multiple I/O requests, i.e. flag + REQ_ATOMIC must be set. + The file range to write must be aligned to satisfy the requirements + of both the filesystem and the underlying block device's atomic + commit capabilities. + If filesystem metadata updates are required (e.g. unwritten extent + conversion or copy on write), all updates for the entire file range + must be committed atomically as well. + Callers commonly hold ``i_rwsem`` in shared or exclusive mode before calling this function. diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index f637aa0706a3..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 Wed Oct 16 10:03:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838090 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48EAF2076B3; Wed, 16 Oct 2024 10:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073057; cv=fail; b=psN2cvN+nG2BEsvRTYQtDy/I3311RNrOUjGt9mF1N99+ynDVrXq9A4JPMD0fKswtcwSwrx9jwvB0q3E0+7WY4+hJyG+7bPTt/kbJGoinvO322QZ56nis3Nxt8aecLujj6nN5upM1UPVqp4n0PiSV1ZpAL3xkGMLJYFt9DvlaHA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073057; c=relaxed/simple; bh=3k8YlyWoedrDmcHXS8vYxXDkrXJWfaJ0K/l8qe3kGXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SLLq1+j/F9/6VVeG05oUMS+fbLS4/Sg+7X1k5xuCjSgzDNa9N9CLJ+HBMOVU948MeRY6ScevGybSneKeSL/U2YuHffvVpqm3WKqsbFXTiIelXgNrdnIDrnvENNPt46KKGKqeAJYAV3rrEEFrqs3QqcGiGXPsc5HW1jtCnTYYmIk= 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=fE3e6bl0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CLmJpQsM; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="fE3e6bl0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CLmJpQsM" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9te91008695; Wed, 16 Oct 2024 10:04:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=6TBUcSBMjRN+CVXfAOayVUIdEUhKXjFo9KkvWHdeKsw=; b= fE3e6bl00n14EswgaBibBVX2OJGPQ/qdTuTuR2mefVivxkfviL71ts1Tpreci52J ODyFa/mjddCL+dqvNCgrF2LsxTRS0INNskbL8Y3eSYggmknHNZ7x83oWQF1NolxC sIKqpKl9rVxbSSsxzT+QOQfqtTfMELbjIfjOi05dEF0hIxzjI5x4nM4PY23/NpXT Z4NmI/3GByk8xhk9KnMXRZ6GGuCLbT9ALRbg7DMDTyEDUxG5Nk8fp+4JujYW2bBu u52NYQ1UTB006NiYWq6JLOj+Oqy/hnppC+JIFPolLElBKyzdBiTBqHHeXbFRsCV3 6ncISedpnOciMT/idEzE6A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h09jv3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:04:00 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G8Ht01027269; Wed, 16 Oct 2024 10:03:59 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjf6egd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j76lMh1rGZBK9YlpFuDXtQaM2NxAOwddmfShnWKgAXfh+CJL++Mnmyh7hkaBh3WPe1gQO6OkEk+3CvWbnmqgAc6UQ6vpEUmi5aHsiL2FdJsVJnW3l//TNq9agAWJvc/VYuNprR3ow2a31U+MruwOjmypTE2Q32AtXHAvDgwxuD277i3wHrNyfoOfvOSR2QtapbjOscysjgkVAZMRxWgD2hpLKbRQtJbPSZVXzxAPkTG+knDHDigudsTDYGBlK5lz3OauIMx3gHRJtmG6KEJPJYAbaU0R27cSDvSA6aGqE8UYsV95K+QgDZoO3ivILLbf3enXgF/ucZP5Ii8jxa3++g== 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=XwKuzzA2QXJJ9x9eG9bsDFakmykGHNY/XNhtKZyswTZhDIrwnuhcjnOZ4Bq667t4rkwL0GTs2BNn7ViwttPG0jidL+GscQzLWYFX9hIRNvuEPRDKWjM5DXVGQm2ZXBRNhdO0FsFJ9h7JoI8fJGs3b4KvrOfOzzHGEnOiIH8mFsZUnr5GQRREvKGtB5UAvXtzttrjSAcb2wNbhyz/xchXUvf/uReikdeJraPNvq7cTO3PX9y6npffzW6druaVwEejklqWxq+FK6Dt58iI1Dc6i6FCSrdRKJq/ATCNMLdVYWZqNgEfE2hY8eyPTnYPqzyuxolAvrFNdTqyhgJF9MX9XQ== 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=CLmJpQsMOXwsjpkvZtL9d7ijBkpFYxiDi/3el80k0DAuIH5x83TFBzi8EeL6d2tn25eKbgQR1RT/DE3gm/2P4FIKh4GKk+xeofWS9levAhnzc/2EBZXHPQUV04VHX8c+GwIXDtIbknwR0rG328F742Cur35Wi5yOvlUOHgIwJ2g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:57 +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.016; Wed, 16 Oct 2024 10:03:56 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v9 6/8] xfs: Support atomic write for statx Date: Wed, 16 Oct 2024 10:03:23 +0000 Message-Id: <20241016100325.3534494-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR08CA0068.namprd08.prod.outlook.com (2603:10b6:a03:117::45) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: 0091ef6d-23fa-4590-c5af-08dcedc9d92a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: r04yUmANPn4UqYWDjNIf61Jd6SUcRHMqp7HWrpnVYjh3LYyadQ22CWrgrM+Co3mRn4f/9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CexSQJSCgLOB4B7qWTdPxOeaFfzosRi1rgea8D959pmgPjZbUT62VWAy3CFOeJakTmQfbR63MOpXISTb4zK7PpZODM8wNudwFoVtabJzRJGNN0a0u++hTl12FEQTFNwan3ONawEngjxD0mCe/Ny2CYlkdr2ug== 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)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VBSBhkfsKtnpOWEvh9AJO+fq6pSiXOuXBfIYTtpkYXR6piUgAF1AQEYx6CEEg964yFWQnPE2TGR7tdPkKoWXGrX+M2ugX9xQgTeWDcqZo4IiH4rCRHA/oZRAiBFE3NXj3SpKcoxOZ9edCBacJLsluShjhRifxJqgLwmuLBCdG3QOElRZt0bJGvraFyAEKf2nTyRT2BOk+WrbVK1hbWvOOj0RYh3SgmUelLcHgMMvcWy9x0Y3xMSA0QgZo0gzlcJyh7U4TW4y+OCzQ/A9fYKzofYrrbNs9mcSngr0li2CvPy+61CA3bQCVNIS/112BNPdECBYFeLvlvQtdgmTe2oy71OhD9K0PhGssZUpay30fsYU10NvjoSvBWF27B2CLGAe1XEkgOyFlWOFO7VmcH3aWKZA7YZXRhZTgKCyTqfoV9r8JvZBsWlyv8NIewKtWh7SLSNkkNWpGKnid+Yf6m8HRF49aAhOMpenh/YqeUjIOJSAknKC5i38vWXjL+ZAE1zDPuw36W18085Hqb75IFRh4ucRYHhv0PZv6LUmgh3RtetJbQXj73M8wTaOczGKVe5AVZJQLhFr5moGRsvJtyB4HtJeQM+z/zpbDHB7L1unJkAKogLQ1RpTjJm3ilGjoih3t3y5yLegQwncLM4qmkFn2+WYA+tBMGwmz9dG+Q7TV/yMcI11n3Hk3w25KHNhD5Ty3M678cqiSb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uoPKqiHGK3B77Mt6ZXnGrPDCVspXz8z8oftMryG9TUmCFmaulExu6yU1nk/9ywC8nQPOBAYlvmoM1ostaxGfycwX4/MpyslyPsyBAj1xSHxTg+RFl41/Qd/uwpaeQabxY+TyLUQ0o67llZBDMsFiao05D0fXW2hDDTtMFwhcINMWREWIm8txJKRwkIZ4KJUjZ9H5LyT+KM21IyAbK1bMZABDCAPe5WPk/PCtomhm44oX3McvWTjwSEmRxRDpV3Px1GN9DAj4xPvRdJMwOn+P8tK0YY24NcM7Sg9BmUmPuSEBL44+QbrFfuo9Uir2RlFadD6qz2/RFOmX+JrLuQU72HsEZ5Nio3bZSuVVFA30qDcKvA9/dJ/4W+UV/hQOY/gM7TZC+8/ZUONHSn4fUGGNK+AlXfdhtMfs6EsnCI2tEvqbfNMhexn9k0tzpd2KjbSM6jyJcoEfhvh2SPY3kW1Jxjhi4pXIc1VRGPvBvsu6pAxLhUDDQvlHSnG9BEJ7bRSfqU8gcGs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0091ef6d-23fa-4590-c5af-08dcedc9d92a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:56.8722 (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: +8TFwPQL3rj2Dbjeka5PWVsZd1q911BrYvFfeVrwjZSfcUQIXEjKoWAgZywdH7SZ/0HffpF3VPToTvsoo2gI2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-GUID: Mymwdgc0RGyVstsPyxwvmmAHmGmSIoe4 X-Proofpoint-ORIG-GUID: Mymwdgc0RGyVstsPyxwvmmAHmGmSIoe4 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 Wed Oct 16 10:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838091 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB2CE2076D2; Wed, 16 Oct 2024 10:04:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073059; cv=fail; b=fQiu+56I9x9CW1mIcJWInlpfBucDgERKzmUla5+Rw3trtAXCmIOQAzeWbFU98I8u5XIAXwQndzGX7bfxGQllXK4AswsrfsAfOxOwpmk0aBntdIlhvJIcpjheqjiDqkMfR7BUOIe6BVyR+Cwgorz+UNYqZBeD0eOxVFxm+QlycIU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073059; c=relaxed/simple; bh=MXdRBkt9h4k25bBTYZJkua5Ybydsg5IdV4X7V2w97IM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bQAHNyvmVn6nW/PrAqe137iDhJCwKL+WDkhOu+01Mzobfk4VwXy4jvYOulaNiCizr9r+QnA4Jh+tRe0FCBgWO/4ZzYPSVVDKJcqEAShFscABmM6c3TKQkyHHUjU1D/eVSnnx04UH8qHHmZwqDHZEx03B+g9bkh4wyaLiuGIusQY= 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=inMiyFRi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=R3T7EMBw; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="inMiyFRi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="R3T7EMBw" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9tesu008711; Wed, 16 Oct 2024 10:04:02 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=tf4u8+QC/LEyz3zn6cGEP9PhoikUK4o8XoflYwEC1ys=; b= inMiyFRiD5NrLIZLkgJ8cXu6QwxHfxTWoheqqwWu2+8KMyvhf4ssvA3wR/DBr7T6 7yXybDU+iKCtJXuRMb65asEpzeHA86tAaLORi345Lvmjky3T/CRntz3JgtnEbtUO gEDPwTDWc0CxOuMnhRH2VBExsk9lkrVxfcLziPy0ORF029+3Yxjc2zi1Alqpohhy ysz70IRWzg3eIrkdYI+gpIC6/UItoSYesL/doTWpCRQK7btx99uLQn7+VU+puJMB 72xrhBMtDnfd+yc4mfiTFQBAjuoO4r6mxd4QMRRWwcLXkCjVpaPK3/zZN+/CH1LE JRSRPXZpkbrPBEzNPiUv4Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h09jv3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:04:02 +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 49G9xbO3026283; Wed, 16 Oct 2024 10:04:01 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2172.outbound.protection.outlook.com [104.47.73.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mhss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:04:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yhP1CK7aur2TD7L2Zfk1vS4W8TYws/R44htLIvpdb1XE8DElhKH5n8MnFr8YTPngKS9/By3NoyzTACEfgOm4WZHllnmiB+e2s34FaKhCNOpZY3z3CA3yoV3KwP9V9b07aDUNiQY4oT+LWqtTuvI6yo2sYciqipDM5g8IbkgkBLIastKMT2smZkg2Umr5D2nzHt9tjXcrBQFWBxbY7GVPyYxGw2xUhs8Z2F5jXZ0WkSkgTGbtJhCrLeQZiklOUxkQabICu+rt2sSET8Ixcenu3bdp6RVnEW+qnsI3w+a8P7/DZkVCSfcgoYu00SBTpSOWKw6i9Rlm5BuzUSb+kKuGQw== 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=tf4u8+QC/LEyz3zn6cGEP9PhoikUK4o8XoflYwEC1ys=; b=O88UPvq9fkBPRJ8hzyIndNebIwiDoyF6as8k9dMCjlPmqFI95kCqlXE+ON5FvioOyitL5Hjr8gO87vXEG8yXf/w6V2gygGVS9eLo1i0zqa6WBey6FzyD4KpTlLpiINCNsgT4lR92QKnx1ZhDwYr7mgItPSTh4ZJkUmBBPVtydvcC2iAXwK6qyoRGvjxo6PHn1g3N97BJ+jl7b/lmSql1HdlGKr9qxd5UsX7QljPQS0nlWb5/PQS8QaCtVvzxBTcDX+CeNYxUeo06j93GrGsb9cYGnTUlZyQfQ4+eQHjdqUoT1tCwgVyzMi4F4pb7drNP4ZkM2HGt+DcYntukSzdAJA== 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=tf4u8+QC/LEyz3zn6cGEP9PhoikUK4o8XoflYwEC1ys=; b=R3T7EMBwxnWgEmRqTu7I3RJcENS5+aK+EqPPfTMHyvlPc5MH5iHEnEYtdUNU6+Qh1CvjUfkR1VXXGRk+H7ODYXzn1WJSnsRBSZLp65j5LBOJ7yf/eaKliZDFYyo5HWFFuRcJSaHy9yyut7kXXuBn6/+gXcGZdJ1bG4b+Yl5L+HA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:59 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 10:03:58 +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 v9 7/8] xfs: Validate atomic writes Date: Wed, 16 Oct 2024 10:03:24 +0000 Message-Id: <20241016100325.3534494-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR05CA0070.namprd05.prod.outlook.com (2603:10b6:a03:74::47) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: dd159a0f-1093-4cd3-3fb2-08dcedc9da63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: LPXFMhGlJ5Ic37uU0finfHiPTQnErR+frXtP4gJ5x6VlHdGz9tGoQfGxT0gwuma8SwgLS5KVzzV8Ygxj4C2cjLIGJn5OnCKlhRCzCUDa3PcuXywC+LXb8PFNtRiew6L4pgiJiJ2p+otMdmyzSgfzlsMgeYIkh+s8PviW/TrYiwqskDCKIx5nKd5BCXD3M3021VzR1np0pZ72mn+YM/d2ssLWBYOFfSCGY8NcXhT83lLRLJcBlRXSrtC7PMOdjs1IpJjcKDdkglg7+NVAXGz65T5aF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YoifWS4E4BVumx/C0fJO2QWW1JKOmKk1JUGam/81nMr4ZTeNuQ6SHFDG/EvVuYmeTypFEC1VynEdgrRYIPZPSsJVMDjPhSVkJV3wSBIWE68RG+x/ZN34UNapnmqYnfEXwO59ho16V+bzVgXRJHz3fd3dFVDtQG1ccUbt7o+v20gY9Ixaf81kWAFN03KadsdwZ9y/u3+zWJbcsOSPw/ZF9sD/U2oTwBK2r+ENAual0fyWRLLXBqxGzhpWElfX7bB5dDY48cXkttm1X1qjdfwDnLJztpkIh06MYDIdqz1KcQu5EO/fDDuVJjgHCOoqpSKSXegg8Utn1x0DB5UR+WvIPsUPa2bEJPsBmUQIDGNNhqx5gzMCru+LTcYoqKpv9R98ddwMU3216sO3Z0iDhHdwoi0oKc39cAufvcDfwaPoOwdrOsyWVySioKPbZk5atU0qB2BxRaM8UZYTusIKNwP6FkWYf6tuouXutBLEENkrER3XYJv/nA2av+OjujqVlGRyT2ManbBnOyIY1QbpEtYHIwMpbHaK2e9Svoe8/zk3sseHooyAPFNMb4erJ8hWk2jIqUCUy9WgJc9no/T0PBRHu0AE4el355+q86XPTHD4dZJDsF4suMWQX/q3AYJJ8jSgmcFFyRYuDPIF9ED5luglLF66t/1SnMFsGnwzTkjcac5Gg30p4pEK/8Fi2odarIc6u4zJWBoj0OZpjTw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8NnoK0STg2PyOhW4vNHAch86OWXS+GofjycGzqUv8pLtmDayCCvaD0OFiLkaYoLiRMV+5oB1G9gylSAAq61rq+sEnc7efJlpIopIYr5DSGjKm5paiphH92MrgzU8hDWoKmiYa4Jcl69EKPfrew4pdlylQYqlt6D0/KMS5SMwAE+1XqKbZXd7aNUY6rZwZ7dnOqyMRqlAw32H8S7gxZf/5DwmMO6OaSj9BgkZ610rNZSuMQuchpxpX2Mya66NobHYLKi4Grs3qeBi0uRG22MOg5kCLX9KTDXKW4i4Ud0dqGlISOeEFHud/aYBuNo5gc/xAd5pk7re6ByzvSX8k9L72AlQRV+pfw6dZ3GpDbNFoiA028n2dwCGw+bt0/4Qa5Fp/M32gm/bH6a03RaMrSCHuCNr0fX6XwXFJCxSIHLkSpIZJLxY6BAHX4CUKOnige0zkmT1FdK4Pz+acxITWw5Eozv/KmsgTKokSYDjSwo/Aumv/tVTnuE0TJZs8qfac5WNCvl7Ny/WuaGRUwL6EhHJbKvVDtn7v1q0oV9BfoBu0ap5N8wMITIbHN17+OSnH8kAVO4QDtD4ZWb0MMwviT5QBom2NSDOU+yzbLu6J+sjYM0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd159a0f-1093-4cd3-3fb2-08dcedc9da63 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:58.9252 (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: SLj1OMdSOSR1BW0wNwGYukjEE3L2XFowrVnk7m6dTGlWeDs/heW9B+M/p29WkcTL3SymToAQI8/B0bo9TWTvRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-GUID: kbDaolBxtCHRUq1tPgZQghRu2xZwbVFx X-Proofpoint-ORIG-GUID: kbDaolBxtCHRUq1tPgZQghRu2xZwbVFx Validate that an atomic write adheres to length/offset rules. Currently we can only write a single FS block. For an IOCB with IOCB_ATOMIC set to get as far as xfs_file_write_iter(), FMODE_CAN_ATOMIC_WRITE will need to be set for the file; for this, ATOMICWRITES flags would also need to be set for the inode. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- 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 Wed Oct 16 10:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838092 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0F9E207A23; Wed, 16 Oct 2024 10:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073061; cv=fail; b=K8kqlDSPZ8Z7YJODiP3k+Rl4M1/SRcIpjjbMd6Xm7j7P33L2KszXI7LqJPiuFt3sp4XUwIXnBEW0pwqqpqvE1dLkrQQ44qiTpGX0Ve4CT+BS6/mfSHKo3XuU/0wCbgaVyXBuJUt0jfovWeCGzTGeqpL9QTnPw8LOByLZLIAon6Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073061; c=relaxed/simple; bh=35kCZDJuXILcU3NkwvBrr0Ysi0FuKpa1dC/UWS+pyR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qCJWrBswts+bZuiS+dqYYT1WNEMQmg5TiHsjlE45yKSABYDljMIW25p49yrB2WVN15GNFvBEUKWanBiuvxJ67BVLklLEVRoQYE1PKZzzokmDk78o6Hx5OD85LoOmW6xm1avGPGEs5+kDd7gbJ+R5a+lb3gnpu8GciCfw7XZ3Q7o= 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=eYJ1Eds4; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ct6k9O+c; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eYJ1Eds4"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ct6k9O+c" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9teal016103; Wed, 16 Oct 2024 10:04:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=fXAcptUI5TJHzxOmVU1fcsTHJkRm2K9FfPNnHxTRgrM=; b= eYJ1Eds41XqQZtTU8W3fS5gtEV8HRhkuG8pxFYInb4ozglBapA4oOJAApXQBehTk AVEdFG1kZKcBx3zQbwqiQXyO4nkaLEn+C7sBZQbaFGq/sVpi3Cya8bKJu45kVy5R yH/Oh92CLP9VqjY/55fcdifPL4ju060s1kif6wbQSy6MTE+pPqDBYtB8a5LJZW5+ w2NocpwMzRziLJG4IjM8ADf/uzdvbIo73/B3jDEidE5q1s1VkWlN9vutQ9Tc/0eG 0JL/ktrOx9DjHG0WX0T5AFflZARHS/eBpMkNi5aXSX01fkNrL9cjNaAMf3ufA1HX ycyrbLTFz2b0g6ioYuj50w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7kd3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:04:05 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G8UAXd019936; Wed, 16 Oct 2024 10:04:04 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mrt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:04:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RkVz5FtBfRdiTBwiLx5EEI5ImnnMofgu/vTVRrzF2YAnlGW3oQ3Xjqw/uB2byVisDawN2Q3eNnsDB8Pbn2bSl0HPun4sRxt7Uj9FDvYUQgw15U3JSWRhnNmVhjdJzHOqBc7gol6gKesSOvxUmkpBiKN7VGy5267rWdtwh1g4aQh6tH89k39aZ/JnzAU3Oan20stWMxEx6dIw8FO4bt/wS3ZWA9CtIXOVj6NhLcEsn8vvdIXQKCrIIZIgiWnRvwCJ0mx1mDe1G7VcNW13rWO8nP87hjwyjmbIyORLfpYSCkYsuymPpF8MN89Xi+zvUpmtiBoHjAJgXXEPMMC8ubAeAA== 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=fXAcptUI5TJHzxOmVU1fcsTHJkRm2K9FfPNnHxTRgrM=; b=pJIIaV8OLhtnwgJ0FuEKfskbn0NGkCUKAjFF8dNI+48FiLAPxo0uXAwx7D/XKcO+RgeSl0AL28guJX71S2po6IzTfSt2r0b00FKw/bcq0oIUvPBdNmYvqS082Xoa4bvIq05vz+PgcFr8CzdSb6f8qdSwXqmbaoypbuS7xC/Z59kuvymLptjBszHmcjqIHfIsuI2rdcWWynxBMkRRw4mmPod9Pg7MbX+/yFon2cvvLl2e9DCfixNi0SVpBy640AlpDJT7Xb+oigQFt0giY92qaJa1jyteDqZHUlAAfOtii05fgMG14KTPA/EaHLh7rZZW8NjNlbCiPvawuf58jq+6gw== 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=fXAcptUI5TJHzxOmVU1fcsTHJkRm2K9FfPNnHxTRgrM=; b=ct6k9O+c6oH3gFm+eGZBQueYsbTXppNxYaDQTFTz1K2iy9Ynf047RPeP9/dhJsJz+ejm7Ywk//tFpAjSmptIuJ1HfekF98evZ/nDeKW/ImsreAnmokk4WCKjNskaHVU1of3z3ZNYr9UY5unXAC8R+6imiYa4ZMi+q3wvbt6duuA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by MN6PR10MB7465.namprd10.prod.outlook.com (2603:10b6:208:47a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Wed, 16 Oct 2024 10:04:01 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 10:04:01 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v9 8/8] xfs: Support setting FMODE_CAN_ATOMIC_WRITE Date: Wed, 16 Oct 2024 10:03:25 +0000 Message-Id: <20241016100325.3534494-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR05CA0170.namprd05.prod.outlook.com (2603:10b6:a03:339::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|MN6PR10MB7465:EE_ X-MS-Office365-Filtering-Correlation-Id: 726f0ac1-d8c2-44b8-3f80-08dcedc9dbac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014; X-Microsoft-Antispam-Message-Info: Y8MN7NvplZW1BPNHtE5ZTXjYgqvA1zd1oS8U1Z1nti8XDPDQGxaI6R/lHn7WWrgVvHYUwbo1Zr+0AcEZfgtC8Z/1rWP7lycFW8eteoTCp6oJEWiVh/INn2OpjtHG6SvhJjl71A7FRazVQnvQ0sgOsxi4PAK9PAX2LigxzJAbXktOYykFOQuOG2tKSOcWB2mjAqNCbdHLU1aWcwXFpfQj6D6M997fNswXF8pkSSbGUqEWhqRrggBTl5ovNqbg6Sgt90HBnycG77q32SQM5kMmo0XOicgzj86wJKRbS2OcacspIO33UMDQOZzNWBbIUrQyrkrevvdl2nLlSCZgbW40I/iY8Vya87YqPfBoi/lpcR4C05/mpkJujzLfQbQfVy+LlRZbLoZSvk0nO4yGUt6qXGcWoQkgIXhMrYkCd8hNmfZf7m2Pih6xZ+ocgw6l+Cop2mfNcJOWkhI4rQdT4pUWfiP5oMpRCqEiQMEeT0PdjuIdMhLLw2eVLcLx2oM5zobBonJaZ3NPL3jrfFVdQY9kMInZqMCOEkjkdrVWrNeYKFDIl7lyponoTfmpp/IZkQnECna3IYtIddliRbJWaKf4HQ04jDevxjxXN8/ewoNMXTQrXMLlY3iyoRrpvg2EvNZKxiXDJkIDiugiR5WDlpHiVJ3qZfHjlz2WDL/qeqGJRzsaRrr9DZECxzP3laO9IyVvRpbKpFiLrOnUWDWNUxa1j3xG+Kx+22Y917Yf5+Yi5zBlqzojTM7kZ0tLT4PaX+wIC0Oiw3+t13BN451wfApEwz6PjsOtT2nQjXoO4XjQ70R7a++NbNda6NQLm3rP2QQXrupnXzaHxsDWD+Z4MIvRrADrTLIJ0b7reFiH6CyG171cSah1dHYOuvzDC3wWXEFmikBsgtTDkALsoY+XC6YCXCIBVCF+HdwJ03zGmTEIxjn+0GUEKFyHuwh8hCD2xzwv6o51d4uy5zcKm1XPkdPCmF0qSwNzUbzvLjj3lJBa+B/ZrMDy+8dk3n7KLjbjJ2NtI7aFqyUzMves407Wr6+fpdfaCvpeenj5dJa8fkX5qZv/GWsmZ4Ra2bsbziBldmqGZFMD9YBheEBDTRO+FLURgt+mFVm+5rvAE4ra4zlwpSk//ZBggPNqswZbh/YmlxOBNoNlKohnL+sGi9yT8xzK/YMmIlWvF0og8kEscj1HmCT5IJxrG4+jYM9YjU4iW2RgwrVgRx4aE6sR7gctel2aaNXVpGMgyWCkkbfmpg4avFrSyGoKxmVZkduj1TC/JZgAuFLqLJP1gDTWrOzMyoan3g== 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)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o55JrDxo0OaATun6QFqcr3MwZcCm027HgXzPFMkKWgblPHI5VWDytctUy1SubCi1L3RG2seUpy8gBn/4/8rW5PpFLR5WJuHwQISB+K6lOUXGO75vEOqY38lUbe2EB18WddsFQaclTA2p6US3JLh2awsJ2VhXZ8ozI+e+wyo0OEKUCsl7Nrtl+4BwzU75kbtVc4YP8V0pdu/58n6kMyfqslu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FHg1gNHNQoFmO8+B1TYSNurcHNONzfpkqMruX5p6sd1CxnW+/QmUevqtvpqWfbCcfKKil7tl5f4wy7EQurzBfQCE3DWEJ7YNbZlpLymhyq73On6/g0aqXl1bggJSg5sGnxV/czJqrQw4Bm61wtOI+as9Olx4OMaqnJhSpNteW4fkkC4zf+Q0y1lWXhrgpQ870VW97JuRDg8Qg7YnwX0eLGduR9e3KpT9ry1bJ1F8Fbontoq+YxAbWg6gzRsSc/nYcRX7kPXTw7RtNkfqlzxeIwR5q8PZ+LqKAJAolpXPXiMvPeJEx8SMzQ2i0Q4am5KXw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XjEFgEiqzvLrik3HQAfdTIdFuNRfsvjQzwxCPozA3syadace1MJdcwoAlkSArqrd2oypscakujzjNbN4AH1G50gnGx8QCABeqQ+2z5irGWEkCr3GXA93oqYFq2gnIzSC8U/beR2HqOBHUalarYL9+miFWD1zTwzNYiccbFj7bvzWg+AYH8XirnnLRz4uzW7+3QmqEHRibvc7QKuMF2lj4nzCbwxiiDzN7B88bnGY3V/4FeITq6K5mzwTyRA/0Z/o/U7cC8dLE11KXy6Fp5bLhi/tEmdOI4E+9PSsneVDWNamV5/XWY1Y/Uy6DsBWHDkKJyTCyDfodn8SiORiTT2QGW/8J1Tl9DIzVtO3etRnxlgan7jGOPSX2ApuE8MElSlOByk+mXQm4H3TEkePxLcjhpMLh0eV50VSxoQNuC7tx5BmNUpvt8ql4F4iCTps0ShSML32rwhfBzXOYHtKUdjR5GGmo9WFPlXu6uFPq+fml80qF8M5On5meenER5iicLa6z/U0zb1olFHR09DM1dJejxBykCGAQ67PkolcALW099b4bpbrP0aV5ae0axuCttF9Bx2cXGEEbHF4sSgCMsTOG1JuLZnn7ViiabSqXxPmWT8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 726f0ac1-d8c2-44b8-3f80-08dcedc9dbac X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:04:01.0426 (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: c4+w0xeYJalirn6gY7g2m5Y7/LQXOlguLAmwY54WDIJBRqbcspmT8UHBK76Mo6g4kpLwt0tL2Wu5NBWCHDaAyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR10MB7465 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-ORIG-GUID: nbd9HJpZUrjoh6OSUk2W_TJY3pPHRIJA X-Proofpoint-GUID: nbd9HJpZUrjoh6OSUk2W_TJY3pPHRIJA Set FMODE_CAN_ATOMIC_WRITE flag if we can atomic write for that inode. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry Reviewed-by: Darrick J. Wong --- 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); }