From patchwork Tue Dec 10 12:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901381 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 DB20278F44; Tue, 10 Dec 2024 12:58:27 +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=1733835509; cv=fail; b=T3FNNb8xWpTABlDEC4XmWstFueUuDND7+cENyhb3nsupVTIQPPHLy3Ejq0YVbbXWDc7e8li1DuV/Q3j/dZ6jDgxm7hKfOORNq1/3Uy/8pv4JRQlhvh0hXLTLQHcUBiZCq7O8W9Q2EH/+KbZpaZZzg8pwS4kuGtFg5wELHj3iX3E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835509; c=relaxed/simple; bh=L+4Knl7nCtqXr5ksJZkH07sbQASo6PXxqrkkVpfcwCk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=CtXzViI0p0XYRoQbEjeVrihQXOskXqkeYQEww4kH1xfy0+GF0QazUqV/Gn4hVQxhyMcYzZVH3X2pZjxaG3r7DUM5zogvz/QfseszMjNazRgOu/HF0e1EXm5B7VKzf3Kn3YBM5DAxnG0NmPdEQtYNgvrVxwEz0dXn+k+ddOE+re8= 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=H0vo9Exf; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=aR0ipz0e; 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="H0vo9Exf"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="aR0ipz0e" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BAALWRg005515; Tue, 10 Dec 2024 12:58:20 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=0iE5Kh8TJJCnMiL7y0XxbbiwgChtmDjzVXehBJ8coRY=; b= H0vo9ExffQU5P5dWSIDHWjpC3EWRmcQ1EVrQdqfOFv4uw45zKamjxagVjulQQxv1 D8Uz4Q0fXOrBbjBmqwRTp0eRCdKd/e+GY5Zxci7nE5H7exF7I+Eh4dlhgphXLubb KMArcFiS2FUeNzQfeHLqGfruQxFIiEMqNSCEp9iBMTgM54FCA14fOIzUIsgxfhwd 531vf8/0L+HMMaf0Wdpf0lVIxlGBhUgWeFlsOjYEtqX5A4AmSUu26r9LHCgUmC2U VaTRtcz4BjbnT1v3ju7yRYGgT2M8DD2pJY7JLBickYoStsJzYjY9dfdPeyAsHV3l Mi9bHmzRk1S3N7lh/5Xk5A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43cd9anrqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:20 +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 4BACXpPI037949; Tue, 10 Dec 2024 12:58:19 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43ccteumy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gpVuoODtdTMUvhOpdRF/QYQXeLU2fZG8zbc+XBG8y3TRyZvRwCRZoDC8ZMuDYi7/RvIMQLjCI606fgwyzSva/19BPluVuD0fUhJ4k1mbtKHvUsLumoQYlvt3GMt3XhKdILzfzIrHf20IOuJ0OQxoKyKWdDtBb5gIWb5OZyTMKQuI8uyyr/wGPRcvuLriQ5VorldIrULNnH58ItBYSTjMRXBsFvlcJ0ZLRlpsw61iSJiv4+CpFhr2KRV1cqqX3RSdSVcKmqbkUOPvPCWTN84cCY9k/ywzSJXMu+OLfMuf3pmFiyjV/el7lyKJoyNMjWXl/NU8AthuF8efdNBTHgBjGw== 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=0iE5Kh8TJJCnMiL7y0XxbbiwgChtmDjzVXehBJ8coRY=; b=CV0Rieqai3kx5U/L+wLyk/QKPkJhgBJwKAPL8WLgWXs9/PKFw3Xaxp3J53zbQyq8zM+0EBEY+ihUu9u9LRzdqSW8aL6B2xxlLuuraHTzVSB4f1d3O5joI+m7EgXvStUCxbOpaSMzm+l4JTqrYa01guDCcibLPsyOG3jOyi6M7j42mE7Yewbxi061XB6LJU6NepHQbqV234C95HfjL7gJuCahUfkl5aJIGJwUZE6IAzjzcDwDuCSctPYtlatwXG9QKF751ZqHieIaQvS9syqMXpv0qcRihArR6Wx7oL232InCGfsFNuS0yGjyF1dBVa0TcgaqBeB7BsfrhO4f3bKcqA== 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=0iE5Kh8TJJCnMiL7y0XxbbiwgChtmDjzVXehBJ8coRY=; b=aR0ipz0e2YQbAncaeGGoQF9h+gfbCcXQ/q82H2QodB++5hjb4wbNPtkGvjiUs3YHelZNwAylITHPEhT4UoJnnwp9/xe324Ep07DfSSCbcKQyaazIafgzidv6oZblEv/Nt3jmHwntfeFACkPbDBqtscBm7S12q3UrEA98P6KQVUg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ0PR10MB4669.namprd10.prod.outlook.com (2603:10b6:a03:2ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:57: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%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:57:53 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 1/7] iomap: Increase iomap_dio_zero() size limit Date: Tue, 10 Dec 2024 12:57:31 +0000 Message-Id: <20241210125737.786928-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0509.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:272::13) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SJ0PR10MB4669:EE_ X-MS-Office365-Filtering-Correlation-Id: cfea554e-3fec-4d1a-db01-08dd191a4252 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: lAUuRdeZHSQugoDAMznaJ1rEO4ma9CubzCUmSdOOW1Vbsa75u/8RMB04fpfQDd/wIpfm7fxxxl1xga80tYNvrm78PTF+ZO4Atesua6OyMOCr27grmQe9Gmv/wFg+056r3lfGOTSr7qxUFHa/M42f1h+Z2sbFBYVbyRapRyILFPA350sAfgmVJGdeVz9ZmzsUj/txYLFLQNx02yShesPn1TxilwM7GvojA6n2sl2T2raLYuCXHhb6EI5XIJy5+rHgjENTcnSVJwRD6vfPphWxaU/1WNmNXqTy9SLqh1EkiTJkKdja+OiuFZkq9rRy3IcsTkyEGLuj7vVRTXgZ/MNGM0e+3mYiiGYKHGSSpqCkUV7IiwyiONg51EZavAlkuiE6Vs3Npwgayn4jWTd7tseG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230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DgOPibhsUmhND6B1XvDwo8s0yh0vdUlSx8Hv46oB1c7JCaYFAkLp8rOK/tXiDy/nhvfog00E7XyjcVt0MCx/ZmaPxRRKmjWGsN5DveRZrirxz43irLEEcaeYVmYiJiKNfWqpJG5DfB15LSjloUUrC3htRywvv/h9GnKmZS6ogAugIjydxgQy9E+n1ogGWNT5KqUVo8APE1OZDujTIeBTOd8A1liR16GLIhNpcShn5bgpGvJ/U//0sJzn2tJUCWebv6H5heuA5P6X80Ih+JiaE6bsQp61gYAZSpfYM4F0s9/S8xYuXJJblNinDIYfDer/vyzjkPc8g5aOGgww12WyCUOVzxwXPW7wQSkcrQa4eV2LGnxMoeRf16NgT1V+6h+2y7YKRV8cwM0sYMfW32L+69kajN5m5pA7JS97Q9TK1s61UHniTIIUQ/PDqDx3inDaC5TUhfXzecdCgmJfU2ctwZz8HFi+/csbj9hGB4mh3M18ladUXJ5NSoKrN6HtVqoLHHDEtnVFj6l3OOqKPzIxsg3cLlfqhgf6EGZjPIBv5ZIgHSEr2L5gjfIe5DRXUCXyJlacE+0qWdBSaC6a5qtgFsNvWeXyCojdBr0Y3uzKqeXvKpfykExyQXo1DgcDvXCcaqFDzOn/IQ/7/s3gNeYEAgGZlp6DxjK5H6qzx+CDlrf6DerBIn7eAM/VFk6gb3+pskagUv6HX/bnCgeAOqoeVKgryUKCvswVomU8Epq0o1XotSItUodFVSv4U3i91tVcOoJX/keiQ/E8w7RzCeoXQ5HViZLBgdsNyngkjg7CrU/kSngLDPWXHpX+VC7a/2QzqCh33x3c4Hqgh/vftA2bnwPs11to1zo6KAsVdzr247MrcMe8NDgPKz9MMb9mcgga8pVQCKH4I5W+BITGoFBNwPfRdqEHNEiSLlLHVZ2hv5nC25jOCgTrgonNG4vnyIoFL+ZaiQ+ZcbMDwwN0aQ2gW1MI7u0O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erJSlzGkOYMi8kj5hOfLFIIh62iGFQ9pNnXQU97WQ8ySmOmBeRd+Z8mes2gQX53uN6eDvpKFqhUBH1AmHr1cdZKuEvWno8iQu1rjl/q+0rIttaAyVGp9IaPj5kEr8tNEc638iTNYAbAiPD/vUplZPXoNhPOifIJLYQHfDUmKMyZSE69l+fnyIzFM9W2NPzum0W5DAMRMTfYkbnqBgzrrKjy6lpnqRqxhnU5H+144gYbP99Lfvj45pwLlB3bI8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfea554e-3fec-4d1a-db01-08dd191a4252 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:57:53.1023 (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: o+TVbE6jCpjV4VYzbJmdC2Meg5msVYLKGdTEMRyO54c/iD5eJtWr/WEhz31acTKnn6GOrx2kDKy9Ftry0ub1fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4669 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-GUID: YYDVreSHc6XCgJwqzhp389DqUu_eq7pw X-Proofpoint-ORIG-GUID: YYDVreSHc6XCgJwqzhp389DqUu_eq7pw Currently iomap_dio_zero() is limited to using a single bio to write up to 64K. To support atomic writes larger than the FS block size, it may be required to pre-zero some extents larger than 64K. To increase the limit, fill each bio up in a loop. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index b521eb15759e..23fdad16e6a8 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -240,27 +240,35 @@ void iomap_dio_bio_end_io(struct bio *bio) EXPORT_SYMBOL_GPL(iomap_dio_bio_end_io); static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, - loff_t pos, unsigned len) + const loff_t pos, const unsigned len) { struct inode *inode = file_inode(dio->iocb->ki_filp); + unsigned int remaining = len; + unsigned int nr_vecs; struct bio *bio; + int i; if (!len) return 0; - /* - * Max block size supported is 64k - */ - if (WARN_ON_ONCE(len > IOMAP_ZERO_PAGE_SIZE)) + + nr_vecs = DIV_ROUND_UP(len, IOMAP_ZERO_PAGE_SIZE); + if (WARN_ON_ONCE(nr_vecs > BIO_MAX_VECS)) return -EINVAL; - bio = iomap_dio_alloc_bio(iter, dio, 1, REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); + bio = iomap_dio_alloc_bio(iter, dio, nr_vecs, + REQ_OP_WRITE | REQ_SYNC | REQ_IDLE); fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits, GFP_KERNEL); bio->bi_iter.bi_sector = iomap_sector(&iter->iomap, pos); bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; - __bio_add_page(bio, zero_page, len, 0); + for (i = 0; i < nr_vecs; i++) { + __bio_add_page(bio, zero_page, + min(remaining, IOMAP_ZERO_PAGE_SIZE), 0); + remaining -= IOMAP_ZERO_PAGE_SIZE; + } + iomap_dio_submit_bio(iter, dio, bio, pos); return 0; } From patchwork Tue Dec 10 12:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901384 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 824361A76BB; Tue, 10 Dec 2024 12:58:28 +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=1733835511; cv=fail; b=IwQ7jTs4zYk1FUD1h6G2qnQGo9CIV94U6RTlbRe1MPSTL6MqlZZREg6FGlgggL2OADL91ZAJ8UqKsAn2kNyRyzt8juiX/MwwG//x+aiEDMNJD+EE3QSeUmymbuCVN+7Xn3FMbR/n4SYUktJ921paBJG7epLBxNZOxiXbgqiH5CQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835511; c=relaxed/simple; bh=6zfnmFazEqBaBWIRgVqn2WJ9JeRsqdBhAwUf1JTLJOg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Cynlk8AkA9SpROh2kwaUUJ4UduJtvMFG9OS3OEBIK7Vtm0ywuN0y8UtMonesvjIxbcDlWLV+E4dMQtSgBIKdNVXQm/baIZxEwdml87xS2x/qStAGBI/6uCPnieXdkYQzL9UEkFWyjuML1vW5cF31DB7QMI+pGpOyZTsbmGpA6JI= 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=ScJ9KeGm; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jna6dMYh; 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="ScJ9KeGm"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jna6dMYh" 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 4BAAGnl2010604; Tue, 10 Dec 2024 12:58:20 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=raWm6UgFAyHyqDYUwti3udy2SJevCJIf0CNPaRhdAsc=; b= ScJ9KeGmuGJeAZeS8Etx6OrPbLvtWwZkmGjifYe7NuDADP/mjpqs6CWuLnWDMso3 CB0j8VV/eNLrY1KxjWfxTvk2x/uOw5ZcndggP7CymXfof8oi24HIa80oYAbxO94f eN/SG7czfFmEgkq9YpFo+xRVUVtYHOQT3ftJ+IERPx2HlVGDzpNKtz+9t4RWQwvf /nGKTGnhjWh3ZN9dUkgivQiOQJ7docITrp7aAKrpaBEwW67HLqgSPelgaOuOmh+C oL2yv7EHUNCFbNVXo5d0uA/p2eRxeuEzoWjJkQ7jTivMcn/b73vHL6UxwWCvXm36 t4jwBivxGDpHb26dtgtYxA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43ddr63tpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:20 +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 4BACXpPK037949; Tue, 10 Dec 2024 12:58:19 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43ccteumy1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NSumkScDlxZ92XMTILrELtOS5/WGYxiJkDdCYUVbW+ljWy0rFfiMOlw4pOAg3CGXrKNUZfAss7DHHnXXiJKmUwkbLwkd+CcisGLr3jePe7YO8fVurwo4KSLnfiri0/VslPsqbkJ/vDDtL4FZNtQFv1wVngMK5rMOFfr0r/C2fECVNicGYJT671LuJmenRILs6VTyLHbTH/vChrmER/wvbFskwv3yVbMNvCh5rfrSoxeJlc7+O0WF2IiMt5Ks19HswRfW7K5rk9boQ1qo2p/H5TxK4UCMFFVJRk36dzErbgnDM44IjzeXd0P5WazDmaGP9zR4SmBMRIzJOB1U4hr/cQ== 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=raWm6UgFAyHyqDYUwti3udy2SJevCJIf0CNPaRhdAsc=; b=GKJ2AymPPz9wMKZ5I3Hr/D9RL2bnw8HoSV6Xjsg687U6UNUkm8sizGAb2JPKy7/VHiOYmeS8sgR7eL8fuYV3Pb9tYvKprD5zQwkvOMz9QhJhg2o5NYareMDzKBtDlksK/WWQ3wSnlCpHAT9Vr12wpooSCkyG5hyUugcmwwu8t2cugTgv+rP0nmC3pNG9nQBoV4Z/jh7iYtosFi6eoaFhv1CmgoQ6g38th5/ZW4fsPtsHVJRUJE5wHcKi795KJxJAAMbe1g1mLcXkWAkS5merfByAGj59iyLo60sHgB+C9OpySj/hADZ7k6b8VrtOV+b5nApWGapHxupyb+7pmMZt2g== 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=raWm6UgFAyHyqDYUwti3udy2SJevCJIf0CNPaRhdAsc=; b=jna6dMYh0QGym337SdGNoDNkpePp0CxAcjX9xU17klsG4rr6E1fWIgCGdDCgJidXQAiutc0wSbhMJuBt48qaHgV1z2CERbyUmWQtUgT+GidXTCUnSpeFX5dWS6YRVkBalZOVKvnp4qWGQKh284knJyEv7LmRGGjihEMxGpOZNQc= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ0PR10MB4669.namprd10.prod.outlook.com (2603:10b6:a03:2ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:57:56 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:57:56 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 2/7] iomap: Add zero unwritten mappings dio support Date: Tue, 10 Dec 2024 12:57:32 +0000 Message-Id: <20241210125737.786928-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0255.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:194::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SJ0PR10MB4669:EE_ X-MS-Office365-Filtering-Correlation-Id: ba7e0b99-aeb9-464b-04b6-08dd191a4412 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: IAGDfOkPENzl7hvWiRbRS+KtAk6afeUOfZbVDs682wOw/WQG6a+UUxrr+esILbFUX5TyYle9SL8fRoc1E0LuM1+lO9q1hgFjRfaD89crw7hOLCqXpE1YYTEXzp7yLaZihtWaEOZfWapqu5aTlaXgo+ALEkz7X9hN9Zti3u32rBLu/IaI/4Ck0tWHHAit5DWNQNV2QMlcKarGTguZagvQYpL3sLEl2nNk36hxvU+Aga5Spl6Plrt7j3o+mGMgiECWGnueMwpg7ekW5tLz+qEISMqgDknarQIhyj7n4MPs1r7ETJctF4QOaEwQDSyjJwFpZMSEgqBEpbky2YvaDfVZ5tNcKEiJhepyQxv15ks5UBGcY/wlTSUZOBP8uOxGwoElUTC02Je8GWAZduEXNxzxbRNTsphMxX0jZxi/ipEySt/rKwwXCjnd5/tEEDZljUJLwKNDBXh2nNjQQEEl6SSdOybh6ngfZEsoQtBBKykrxlfY1cjkFKvF/UjdeGSCppVFgKjtKMbb06Gumv8w46AMizmrA0CAJpU5xFC2ctg+rNOE91UBuhdnvwPy6WsWTx4Fw8zuzwTi9UEDFFpsrEM+dM6QzFgaFD6nuViTgrHb4KvhB+hEt7FrONxsCJUTcP7NZCz1q6Fh/eG4ZQ2MoeHlLqCZ7lOMw8yOB18iQsUZ9iwlhcJnOVD/WzJNjN1AquH0qCPp0CsQw8F7C/3MpN5V0HVLtbZU97eVCWv48FGmsJs4dXEU8ITK8PSscSRDfp25NDTYZ84mRwOIiLCSk2tx3ruz/IMP5b1LWjP2cAq86atx6EKkwPwzczr+nKVFNo+Ous/lzRUajNy9tWEPY42g9vfAa1sQPki2G2qvOVH/vK3JgfQj50ia/0sThlHGBU3HAKFSHlPK7n0s5PNRb1fhq/PDpE++L7rsW9D4WWAOQZ8ur+wrspPv448KrDauNDqnNw1YAEMK1zoRBy5TL8yTpAW5QSknKetfsjQIORNNmgfEOc/u9+Ts657SzkOOMeWfsrTpeoTkJuCP+Kwx7wtlOpRq/L0HILkt/pbCTSHDUGetW7Euc7JZZuruAqi/VCmlNLOQY21UNeWHr/oXiu1QD94iqL3eThuqBFFs8pFujhx8yzdZv9cw1YgP87L97q3lkU+Ut2iGKVOjEeoctLuOWlvSPANNpe7gPQ1zI6PCixsb8QkZtr2T5m6kZkMapK/AcHVsmudVeLeUwxn5//CzdOvuNKc3wKfWUssTxJjVKQP71d2fpm1qtppuDKYJsoIgfvVcHQxCdPETLpZEnGahVV7XXArO206i7lWqJWGhB9+V7Apa0OMi52qYzkboTGTB32sppygWNcTTHAdS0ja+lA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkC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LVUqy3i9JtX3lq6Akvm3JY8ckX6gdOB1mPYCmSF1AmpoEQphO3SRsdyJoyqbmPJBTkwAeumi4htUEvayWPgMSL3sPlFc5eJ5S686dKTB8HKXvLKBUPjjacpmb1l5tpNKb3/U/5YCaXoSzSH4ksCWzzHbnOuzo0Wt77OhUyEgECtOl31Dil0wm/x8bWo7MVlk+OjfPlAv+jlk4A9Q94cW9p31na8/E/TlHlqScY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba7e0b99-aeb9-464b-04b6-08dd191a4412 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:57:56.0225 (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: S+ER2kltHrvMF/tBiBgcBj3FnKQKPm53J9o5i7QK27vHaPjxZsOIyWar1ZDN0FZyvncoXhe6qnmahxpO7VHIqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4669 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-GUID: KiJh6xxcnetZbY0cfCHm6Yh_NQe0fgln X-Proofpoint-ORIG-GUID: KiJh6xxcnetZbY0cfCHm6Yh_NQe0fgln For atomic writes support, it is required to only ever submit a single bio (for an atomic write). Furthermore, currently the atomic write unit min and max limit is fixed at the FS block size. For lifting the atomic write unit max limit, it may occur that an atomic write spans mixed unwritten and mapped extents. For this case, due to the iterative nature of iomap, multiple bios would be produced, which is intolerable. Add a function to zero unwritten extents in a certain range, which may be used to ensure that unwritten extents are zeroed prior to issuing of an atomic write. Signed-off-by: John Garry --- fs/iomap/direct-io.c | 76 +++++++++++++++++++++++++++++++++++++++++++ include/linux/iomap.h | 3 ++ 2 files changed, 79 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 23fdad16e6a8..18c888f0c11f 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -805,6 +805,82 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, } EXPORT_SYMBOL_GPL(iomap_dio_rw); +static loff_t +iomap_dio_zero_unwritten_iter(struct iomap_iter *iter, struct iomap_dio *dio) +{ + const struct iomap *iomap = &iter->iomap; + loff_t length = iomap_length(iter); + loff_t pos = iter->pos; + + if (iomap->type == IOMAP_UNWRITTEN) { + int ret; + + dio->flags |= IOMAP_DIO_UNWRITTEN; + ret = iomap_dio_zero(iter, dio, pos, length); + if (ret) + return ret; + } + + dio->size += length; + + return length; +} + +ssize_t +iomap_dio_zero_unwritten(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops, const struct iomap_dio_ops *dops) +{ + struct inode *inode = file_inode(iocb->ki_filp); + struct iomap_dio *dio; + ssize_t ret; + struct iomap_iter iomi = { + .inode = inode, + .pos = iocb->ki_pos, + .len = iov_iter_count(iter), + .flags = IOMAP_WRITE, + }; + + dio = kzalloc(sizeof(*dio), GFP_KERNEL); + if (!dio) + return -ENOMEM; + + dio->iocb = iocb; + atomic_set(&dio->ref, 1); + dio->i_size = i_size_read(inode); + dio->dops = dops; + dio->submit.waiter = current; + dio->wait_for_completion = true; + + inode_dio_begin(inode); + + while ((ret = iomap_iter(&iomi, ops)) > 0) + iomi.processed = iomap_dio_zero_unwritten_iter(&iomi, dio); + + if (ret < 0) + iomap_dio_set_error(dio, ret); + + if (!atomic_dec_and_test(&dio->ref)) { + for (;;) { + set_current_state(TASK_UNINTERRUPTIBLE); + if (!READ_ONCE(dio->submit.waiter)) + break; + + blk_io_schedule(); + } + __set_current_state(TASK_RUNNING); + } + + if (dops && dops->end_io) + ret = dops->end_io(iocb, dio->size, ret, dio->flags); + + kfree(dio); + + inode_dio_end(file_inode(iocb->ki_filp)); + + return ret; +} +EXPORT_SYMBOL_GPL(iomap_dio_zero_unwritten); + static int __init iomap_dio_init(void) { zero_page = alloc_pages(GFP_KERNEL | __GFP_ZERO, diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 5675af6b740c..c2d44b9e446d 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -440,6 +440,9 @@ ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, unsigned int dio_flags, void *private, size_t done_before); +ssize_t iomap_dio_zero_unwritten(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops, const struct iomap_dio_ops *dops); + ssize_t iomap_dio_complete(struct iomap_dio *dio); void iomap_dio_bio_end_io(struct bio *bio); From patchwork Tue Dec 10 12:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901382 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 A56E51A3AB8; Tue, 10 Dec 2024 12:58:28 +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=1733835510; cv=fail; b=qoSQjNElyXQQNbO0tkXIuyITRCEMVlYNFVWm117RzIkObbF7zoh0MeREieZvABSzZE69Py7FtlZoMpb4y9xtDzqUGqGZxkyP4F0kMks3N9tQBGR9ilI4o2vloAiz41upacfN+2cnMe3bEPcvzJMzhCYUNfhTccPe9kOxCkq4FRM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835510; c=relaxed/simple; bh=kWgiwjQoCWVCg4ulv6EuuV+2onieZIrHz2ifgwcsd9c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Lzbhy0WAuRDok+Gko7tlcqwtvj/MU1z/r5xRAE2GX3iMoUO+JQFM89IGWKcxXELqPEgd97CNMsnCq0IZlqgyIdaKoStgHVKZMVq25iihE9QGlYh5LEsGP81tTRr3zwvHQye7JNsfQSm/zxPohWXcR/7wvMvet0cGZ9vYXVXA37Y= 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=blrfxKBi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=rpybqxiN; 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="blrfxKBi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="rpybqxiN" 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 4BAA8nJF025158; Tue, 10 Dec 2024 12:58:21 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=Pi6nNeWKVWfsgMMYNfG6r2SBEVk0r2mrnQLm9/GjiPI=; b= blrfxKBiYC1KjcjLlnp0uM4n0S45uMA6KfTOjvfwF/zcTuwHdEqYbeEJefUwX9Zb XXw8zkv62cmHy8qyjx+n/CieiOYJkBhMOfJJJ3CqB9iGlEPF8v7a0NITdHHKVv1U PasAmfTrOVTy1qKAq2tWblEo6/OXpD0CbJ682tDhjNkfk3NBExOLk1R9ytF0qKLl m4iwGvPQwd61vflcWmY2GNKg1uCgzdltpCQr8TpEkAm1qb4F6zUl29gdGvIySHv6 XCUAUcbL7VvLDaOgUYWBq0xznym4fEJXOoWBC7AAz3hiZpJ+XGNxCQ6Pw6qpOIDv N60nVfW7VYocTpkKB6P22w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43cewt5qhg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:21 +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 4BACXpPL037949; Tue, 10 Dec 2024 12:58:20 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43ccteumy1-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uBJuAPMrRd/aiv/lQSTkgg5L24z0JpQePFSw8pVJRUQOJPNtv8oty6kkiteqlmA3NI/1tArmBdFuw0pWXQzA+n+fvmYg3vAASKqP3Ro7VbubxA4EBuyUgfvY2D9HT9NkfWNJDpAQTFE0WtNDLAjlB42H7TiK9OoyJzZP3uuNfWstF1w7zcZ0gfrJtWdQ42HNEgjIh+nxUPyqbFXxGJufusEEUCgBa7VcTLAcO1YYzUUxLGs9QWSmWmaGG3fgbXgMRz/dIsnulM6+StHFG0RNc7QJ57bZR/thMqFgpgVQRzb/JqqwS8GfhSCV05K8OvpRN3d0KvW15aVsmNlgnrG+Ew== 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=Pi6nNeWKVWfsgMMYNfG6r2SBEVk0r2mrnQLm9/GjiPI=; b=fuC2Ulg3zAbIJ7ON2obreOgavejU2TNF2YaJdn11cIyaqv84j9x51XSnm96AiI7XxLCwQVxxM9nKvc+/NNa5nd8mxATVddCmt3cRuB5x1XmmbjW0HY+whyKityDLU5igHdpgi7CMa61oQpeLrWcpCWEltoiM2ZO+C/O030pULxDdnkgX0+EliuBTQkk0VoWaiCucC9BYhg4fGdruSFN+RzDU/7VWGDU+wkh8WUYpV6AeUEjAUur205BGR9HPPmYTsMZ/7MEtu/V4outyzWORW5UK1hVJzNZjiWBan8YLa3Jfz8cVav9s8y1RygK9el/2J0oXBOfET62GkzthGru9vg== 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=Pi6nNeWKVWfsgMMYNfG6r2SBEVk0r2mrnQLm9/GjiPI=; b=rpybqxiNJOly3kgJ7x9/g0vKQBszEXRG/G4b+0+9OsWf2V44x8Cyp9e0nouMIpC3fiTE8Eo359Yik/bu4oQipIpfCkEGlYjKYxnOIo5GWHaSXSh8MZCBW/fousjJJ/PkIl5vvXEnN6ApTyOG33AYtOlFXWEF4Up/7TBDVlEiFTo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ0PR10MB4669.namprd10.prod.outlook.com (2603:10b6:a03:2ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:57:59 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:57:59 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 3/7] iomap: Lift blocksize restriction on atomic writes Date: Tue, 10 Dec 2024 12:57:33 +0000 Message-Id: <20241210125737.786928-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0338.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18c::19) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SJ0PR10MB4669:EE_ X-MS-Office365-Filtering-Correlation-Id: f6f2a55b-17e4-4001-e69b-08dd191a45ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: xIJ+TvnVEAm/+ckg+2VexsD4N1og9kw9LO+sGaiwBtk60G/iHE/Cz8A52XZEK2CMkZTcBP6H5q9PM5boRQFbWZNHnsZfFZ7qiYPAS33T4I8UeUXDTJK3rjSHS8JPbI4eS35LKx8iQJr44GO0ZNapIIPERA+pBlZRr7SOchWS76VvOuSQQmI5VLWlTBpgaCGhbpqEERkihQ3PpUZdnWF05TYjJsCkWtRMUR/9DnGGa0RlluufFGXVk3aAWkR2u5KrDmokLizyelwlqqd/6VXz6WQ56PAauSzZfn9deZK/tJXiV5l0RjdVg3MSPwVXoAfY37nl1Qrfq6K4RAQsRvWIRikm1S7YPXljXPmlB8u3FkwXRAXZZmfUg9+UhI8r9FpkwSkxY3dBpFYY0Hk68JklBkOPRV3xRWT9ZKB2CggfRXxg6Kz8GPeP/AC+nSbycShlGUU+4pz5iH0sC3iWoeSbdeKM1q31KFN2ezTUv0Nk9VI66kFwp8v7NeQAeUyLmyVpSRI62IY+J81TfIAArHmYIcGvt711zxiBsWel0g8mRA+3p+i9XRQ6t09q7JzPT5dq0GMuhbrzqesR6xDjLeBQt4CJVB0+F0sOdJlwdFijB+dOJld5EAAbNFg+hY5fMlh+O5YfaaktIJnZwH2VhsswJJZvj0YSsWSyUHUta0D8MVY+aayJquQ467Y+iS4ZS7YSvz3ci5azRUgLq90H47xu5VrdBaUH57yyGJDAE9ro3fiX/tOH+gr/9DAZKaQ2EkQ+DtWwWEXxSa5TU99OZ5D1xQUCwguWH30qFeab9WJS4Ibywdzr4Xm2YjKc37RploePS3QSodctFtWE/hrZrHtcKGduUpW6Y5sujyaEXITHArXqef0gyN7MTY0Wy0l/ytG1ceoxWJpWfFioc4JmMDWdJcsRcpsFT3DpaHd+ZV/34YRyS6Eq6eIzVUVCNf73aysR/+PiKH1fDjUFraCpQu1D1MYPfrSWWeqXHeC9zgchoyalvhUcLMsRi1KRzxwyA4wp4YYFONCs940/iDQMI2BEK39V6PiBb7QnIz4O17KIjIz9aQDf786Z535J2E7z3skE4EzDpd4aoiLcLu4Ty4OGjZqEmWN9fPnegwjNBNMzml1ZfmpnNDv3Im0JSG7OAE6ix98ZMjHsVM930YbitKahu7u7eMZ1tJfszpfe4t+x3gJpK/iDPO2CHhLE7ynh4xSwFp8n8h/oPdExjxvvAUZAbC0Lfz2uFQ1z8f3VijrEUrbpR8afOpgGDeBTOXKL91PSWUMxxlRRJRjzALAWs6gqBK4GqMA4p2kE62MFpPu5CeP8jcuov+nVHvbES9hbmGeS9YsKigQGm2wUXEYXG/0cgQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GkMUskjeE0DycB04I4TdGJiLzbDBTAxpSwoiBXu+O8vPtnN3aVUO7yBpGOqwB2ifceZPsUMOetkYf/WvxyBqySFySvvSpTT31r1nsIH1TaJEuufq/VTo1DIQCJeA9vI+VXU49ausHKBfszgK2DZEVBMjhiSKaEMKRyqSn96ck4Fj1ongwhfwFGn5fEuLixuNVbs5Gan+veNWAyxriyJRoBbhfIbs/IEYzDoImf0/HKOePbgmxvdtlb/YwjRYtYqrQs9Pqd0OG60t//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KTkWys/n7fJIO34YX+OPClh61OlyP9K5yWxc/hIcJIWRmmTT+eCv+otvo9LLbtnygg84MHsgfIsd+eej3XSAQpKVo824irvVUkR/StAqjt5hE+IivEr4tqnh9mePjkLu1ElEY2lXDWIawlE2cUofbfU/OiJ4irLi8gms/bWUtatVoAHmPl5ERInGinWeubzmxIlMDEQgGMR7LeRjUJJ/LPsS3gm0W86GNcKCFP7djrOjuTnIPjMfwOV/8GxB4ZRx7nWlmQt9YjTkA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tWLK9E/rrQ/rQdrqFj2wAZIbnYrXrDzKwSjotk4t/eRCBM1sG3+jhCdvD3ex+yTb0T0lNwGfMSmO61KcvraxLfo7n4xUevMSUQRe6rNzB6i0hLvuWNU6sqZ3q8NYX27w7aDRqNJPEpYl83YlJw6HFN/aJslUeIZGGe7whcnrJDq6BUBgYOQhdY3pRRcY+C6jzYPkP8rCFx/t2pSKv2G+gvbl19KGIwqL3Mv4qWizMRExN4l7Ow/fxpRoF5Uc1UgkrnKat9PaF7bVm0eR2zZO9o8KQgLnGcklYFddtFT1+s07cKYMoyQb9a5jTMlwtsIJoCrkXaN+6RVtJLcYu1ctvzfZjOt3ALdIDMXliVBxht64PEkBesSrq6717k5bKR8p5wy3rc0OWcxNP6nJOg1fd5V9kaayufJzohTxi/BoIeWCSmEuoN3AaUPLUiangdNo9fb0165UxZEJGkMGYlV2rhAzG4sV+MIzTFGSsQHtWtp5HHt1lPB5s+6TOlU9SVOamTvcg8XE4QA99D18sAvLWVB7ynAGzPcQrh631Vp1y+vt1vU76qjVKuY4lLrxRh+Yi7Tio2nHy4xZmrBl/sH/mIvZfgOFkDLPrRoPcuxLe8E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6f2a55b-17e4-4001-e69b-08dd191a45ca X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:57:58.9290 (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: Kr6gCgIH/ul50IvmBnvfPuRgbL5ix6Tm4KrYCANcasta6mJh+R8392Nfnrh7rnNLFDFWPKhpCcNDhHR32u5I0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4669 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-ORIG-GUID: ppYPQsMi_wkQLZDMRL2Qi_9pOSCQ0J3q X-Proofpoint-GUID: ppYPQsMi_wkQLZDMRL2Qi_9pOSCQ0J3q From: "Ritesh Harjani (IBM)" Filesystems like ext4 can submit writes in multiples of blocksizes. But we still can't allow the writes to be split. Hence let's check if the iomap_length() is same as iter->len or not. It is the role of the FS to ensure that a single mapping may be created for an atomic write. The FS will also continue to check size and alignment legality. Signed-off-by: "Ritesh Harjani (IBM)" jpg: Tweak commit message Signed-off-by: John Garry --- fs/iomap/direct-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 18c888f0c11f..6510bb5d5a6f 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -314,7 +314,7 @@ 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) + if (atomic && length != iter->len) return -EINVAL; if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) || From patchwork Tue Dec 10 12:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901383 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 293E61A76AC; Tue, 10 Dec 2024 12:58:28 +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=1733835510; cv=fail; b=DD//QbIcj4KAoeh6NSqDcAoo2vhW0kaJzCly0525wB8VPSUejOXyk23xcqPQBlKQ/JXtnXrhUcSHE9snLfBpZnM/48SvaiRMcGFwcA7xBJFBWpaibxlCmjOxbzlyLwYpQ0rdvzQMq7LC+Bnd6QWFmVXc91ySMg8HCpScOKuWidQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835510; c=relaxed/simple; bh=kr4MVKLjqrr4Sbuv5oaGyeYek6Aa5Van74JzRTBzevM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=gYqMr/T8KVic/pYWCr4zGp/g+kMuphyfwt6uPPVNmGLJH9v6YahhVCZLoTZUf0l98i6nIiiNRxIWEX4rNiA5OyZa1f/NgdxadN3ZjicL3ofswjmwOQfNk28Mg7of6t+dzP149yzI3Zy5ujDimcgANeFwg6w5vtUDyZ9NRDP+V5E= 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=lZstlNmz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ookAxM2J; 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="lZstlNmz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ookAxM2J" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BAAECWV005021; Tue, 10 Dec 2024 12:58:21 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=h1bYF2QtEWrwEwmUv3zWhvUfFUbe+NxhHtggxlTLhKA=; b= lZstlNmzq48dJ2tv1rR1K8uA0QrrBz6opZal9p/C2gIAxJpwyr5DuiBtP2A1sGoA /MW4H0XHjZzaH4LBkuGAXtBn7RR32nq5qlUJyx7R+pB8ZPWcI3UB4qnQovSs/WbF 2XsXCszIOzkb/zIBT7RQwBQCShEuQIIBYuXuypKNJ1zqIOIA3FaDictZSbAmvn3e RbYywQ3TqsEhryGsfg7BFqNnz00EdIpzYb3Du2dpPkNcO/hkCUuzadOLzRYIWy41 eiASgl6b7eKxm/9YqpnyJYd9Kd1reOpb0cnvu7CzUdm+YVr1gcGcVPuhcCNAzj3I evezX9Jqz8GVGJGqa9aucQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43cdyswnt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:21 +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 4BACXpPM037949; Tue, 10 Dec 2024 12:58:20 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43ccteumy1-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=skfGPytPrW2oa0lQ19zXdKl7aBN2ekedNtlHc1U12HQs90j539x4P6aefURmFXc9lE9Rb6lZaGH1d3IRiWsqtX9uMd/CfGt0/ebjidYMuNMMhTm919xEPbu6d8DcdqtI6T4+zV1UT4itMAvo6F1oE5itFh+KPj5Y4rVL2lvXepi69dPlZFXygyOxSZT8BzDbSz8oEWJDHNbzaBnY+YyoGqpihnuLUTee0hO9iWrATkPeBZh/g/WT1FaDZmWDf6xu4ps4maRLzn9l+orsGphDUWvd8cgQXr+eoJLeNQhYn8ffCqn+xb4ZjgDFKJLlEoEhSMKWvMq0w8Jfv0veWQYDlg== 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=h1bYF2QtEWrwEwmUv3zWhvUfFUbe+NxhHtggxlTLhKA=; b=bDseYCgVbszhoQuILq6XIVJ+Q+6lkJ5dBDfRBmKJe5EqTi32WCR5xffNny8OTngtV5oc6aJx+p8VgD9w+8R4EFk24URiKhcWGnGYqIPa4b8ufJHLOfmXqktqcf343wefCq7V4gu+bYVK07YQ+aFkCWd2UIJlMCxn40NJ85Gai/evrjyWFphIQEPnwa/EOnaQiB8SRYqxI/TNK9a5q7D7tztpGBhb5RxKxkVpQgg5couj2+iMe06XC44KW8YR8oIdGowirKYR2Arn+lHQAvUIVYYmIVeqfxfNiP9wF06dTJ/UhflgumdUa7S9aI4dEeFgTHxktURMGkN9dqiEd/TP/g== 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=h1bYF2QtEWrwEwmUv3zWhvUfFUbe+NxhHtggxlTLhKA=; b=ookAxM2J9OR8VovJ6ENV+4/q9OlQVamsx5yuYrm5DKbAXjF+AqlyaiFaOX6u4MG+k0GNXvgJAfuIE6VP7NLlrXZamQyqpOjLhx9VVyLwRyKRPjny/31HjofiSrm6d1Gk5FbOPy0eK8q3aJZb7aCwy52I5iL6JsD49KUR4g7s3zY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ0PR10MB4669.namprd10.prod.outlook.com (2603:10b6:a03:2ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:58:02 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:58:02 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 4/7] xfs: Add extent zeroing support for atomic writes Date: Tue, 10 Dec 2024 12:57:34 +0000 Message-Id: <20241210125737.786928-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0050.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ac::16) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SJ0PR10MB4669:EE_ X-MS-Office365-Filtering-Correlation-Id: f2a3b234-e17d-4c0d-7c34-08dd191a4792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: TJOQeI/OT/h1FI0gc9wXgzViw0iYCZukmeacOceumm6DCsQTtuVcAbhRkHV+LRBLNSteb+xtfoLAtuFTExxIhmX+pVKFhyFelOSI/Me2k5IwGtZpOD3IbfZdZhAqXyofxPfgWSfecKXIi+Ntt79Jf3xeh+v18su5kHW8nFxqrNou1YYtrajGjfNEhw8PYmHcc0+KF3t2E1Wa/j8BMZzbBsZigeUO0pDa6grG2aKvk4Uf6nqPD9kra5kyyORqdFocE79oz0fR+WV6D4gVsu7ONWVfxCZnSnCS+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== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w4jfaCZhu14uaBl9brMJraVwkCbKRCL6lgLdApvnSPN9poA0kxT937WawWj9v1QKTPsV/iGs8UlquFUFhpZ1PKnAggzki9GBYrB1ZmSMqtDVMUHj1rJpRsesi2GJ6Y6TRQhej8DE+bYeMMrf20qPPXFyU1aPHwDqk0zzn8Unm5vtBRfYdcEgKR0BDnnpZXpu9kJB+K7YgXSpVqPmue6EI63VLBk0E65bduxtV7VgltaXveFaUoxX+qYJxeplozr61mFRiHCP0jTkTFu55C2fYF+nRsdDnxTS8eBEzVhpMgNEEJGiszOgavrYPFzLh3sDgqBeu0IpVYqYJbTc/3iXKu/nnbm3dKghwQnRssuUpWn2+gVNKDi7sPui3FOwGtnGihRsyDzQ37nK3Z9Bqf1OPUE+Bz2jw31nJOhVnL5SA3fGJNBoJ/IN5F+M3Hb6dxOZz2SgEKo4qziIHz44UOhX40kW2ywAhZlb80XjJfzg/caHmX/zdNHLPMCn7G2Tc43hu3V5QN9SzOL24uXepc+bO/nwRoB8L0htelhCG0pSx8DBaqdLGnQCoJYhnELQnDbX6vSYGi5wE0g347dvf/31nMIXxNNg+I6wK83CK9GX/yuUstsTkrbbHLtUqvVDVsrndCZg+8sZfQqnxZSMzK/xeVfmnT8k/F2rXLg0w1fRKmWuLsu1NFg0XiPgiXcjhwBnS5mbIu70hQofvJbjndQGKMwkQt78Qkfeb5aswYo9ukoTcCqXikZllseJESVYfAiGQjI72zD6Exu8OQqrCOOWu4JDjml6Vca9XLvpoScVBtxEuT8MzLbXcGAIMD2MGc/2smjjQhyo46UOwUMsan7V0OADf86DzOGucNsJSa7GqWIu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ZcbkxZz7wtvTfGbZs27DuYP9Na/Cxe3Do3ZSV7Dh6yV2QtAwCzbLvC6SxfHhEacgtlczB1GwjdH/2/dA947enG4pm5Mtfr8YO576HGyzCaxRAgPr8fZxdB0u4ogRBK4B8e5yMun1/8j5pfZf5hiicpXQxq+mcaByIstXUIlfS7Z9KhunSEzflyTlnfoylxTyQ7KxRhn/E5sXukMYcaFyQMN/n+kXBlOL0+fa8KreDlT16jVcHDyruIiPP3Rv6Wpfg6k/kvcs5aEnXBTSrw4qygevEpRl9Q1Fe/LE1SMUv3esYoQ4Eh1NyjkkPtiZ+UjZVz0mgjPZeODmtiGulSrVPIo4rIGsfpwat6w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2a3b234-e17d-4c0d-7c34-08dd191a4792 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:58:01.9504 (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: g4o9xOhIyDxwUG+scbLpfsb1owgNxL9CdU/adt5Lhjrfff4RRww88gLViEh/nOba32KhEV5N/Q/ZDj/uob+jKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4669 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-ORIG-GUID: vYSFFKDnr2z4fTBm0XecloUdbCNZj0rt X-Proofpoint-GUID: vYSFFKDnr2z4fTBm0XecloUdbCNZj0rt An atomic write which spans mixed unwritten and mapped extents would be rejected. This is one reason why atomic write unit min and max is currently fixed at the block size. To enable large atomic writes, any unwritten extents need to be zeroed before issuing the atomic write. So call iomap_dio_zero_unwritten() for this scenario and retry the atomic write. It can be detected if there is any unwritten extents by passing IOMAP_DIO_OVERWRITE_ONLY to the original iomap_dio_rw() call. After iomap_dio_zero_unwritten() is called then iomap_dio_rw() is retried - if that fails then there really is something wrong. Note that this change will result in a latent change of behaviour, in that atomic writing a single unwritten block will now mean pre-zeroing. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4a0b7de4f7ae..f2b2eb2dee94 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -578,10 +578,47 @@ xfs_dio_write_end_io( return error; } +static int +xfs_dio_write_end_zero_unwritten( + struct kiocb *iocb, + ssize_t size, + int error, + unsigned flags) +{ + struct inode *inode = file_inode(iocb->ki_filp); + struct xfs_inode *ip = XFS_I(inode); + loff_t offset = iocb->ki_pos; + unsigned int nofs_flag; + + trace_xfs_end_io_direct_write(ip, offset, size); + + if (xfs_is_shutdown(ip->i_mount)) + return -EIO; + + if (error) + return error; + if (WARN_ON_ONCE(!size)) + return 0; + if (!(flags & IOMAP_DIO_UNWRITTEN)) + return 0; + + /* Same as xfs_dio_write_end_io() ... */ + nofs_flag = memalloc_nofs_save(); + + error = xfs_iomap_write_unwritten(ip, offset, size, true); + + memalloc_nofs_restore(nofs_flag); + return error; +} + static const struct iomap_dio_ops xfs_dio_write_ops = { .end_io = xfs_dio_write_end_io, }; +static const struct iomap_dio_ops xfs_dio_zero_ops = { + .end_io = xfs_dio_write_end_zero_unwritten, +}; + /* * Handle block aligned direct I/O writes */ @@ -619,6 +656,52 @@ xfs_file_dio_write_aligned( return ret; } +static noinline ssize_t +xfs_file_dio_write_atomic( + struct xfs_inode *ip, + struct kiocb *iocb, + struct iov_iter *from) +{ + unsigned int iolock = XFS_IOLOCK_SHARED; + bool do_zero = false; + ssize_t ret; + +retry: + ret = xfs_ilock_iocb_for_write(iocb, &iolock); + if (ret) + return ret; + + ret = xfs_file_write_checks(iocb, from, &iolock); + if (ret) + goto out_unlock; + + if (do_zero) { + ret = iomap_dio_zero_unwritten(iocb, from, + &xfs_direct_write_iomap_ops, + &xfs_dio_zero_ops); + if (ret) + goto out_unlock; + } + + trace_xfs_file_direct_write(iocb, from); + ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops, + &xfs_dio_write_ops, IOMAP_DIO_OVERWRITE_ONLY, NULL, 0); + + if (do_zero && ret < 0) + goto out_unlock; + + if (ret == -EAGAIN && !(iocb->ki_flags & IOCB_NOWAIT)) { + xfs_iunlock(ip, iolock); + do_zero = true; + goto retry; + } + +out_unlock: + if (iolock) + xfs_iunlock(ip, iolock); + return ret; +} + /* * Handle block unaligned direct I/O writes * @@ -723,6 +806,8 @@ xfs_file_dio_write( return -EINVAL; if ((iocb->ki_pos | count) & ip->i_mount->m_blockmask) return xfs_file_dio_write_unaligned(ip, iocb, from); + if (iocb->ki_flags & IOCB_ATOMIC) + return xfs_file_dio_write_atomic(ip, iocb, from); return xfs_file_dio_write_aligned(ip, iocb, from); } From patchwork Tue Dec 10 12:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901385 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 BED991AA783; Tue, 10 Dec 2024 12:58:32 +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=1733835514; cv=fail; b=taURncOTIn5X6datpwOwsBXFw7OmGqLvkIK3fGJUHJS1T91Zm97Vp5uZYpAPXcddh3FK34EanIaPpAm9xKWUm3srLgrDhVg+OlxVSklspFAf68FC+afEIXwIkk+lBiO9ayceO7zIz9KbHf73/SI36U4SswM1NTFadq4Y4bCF2S4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835514; c=relaxed/simple; bh=e4ERBggPKMxBb+05PUo/HyQcT4nY982FvTK/u880Koo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mapphzyQYwQs/92H9mHp9S6G5fG6/UD/cFOKMagPehIZVBBAkuT/Wr+rKOrQYZhJeEnixIFsOujV4RQQ0bWb6442+DsYqeByG8CKjhDWA0flAqeBGo4lEXtvlGzzY7LVRYhVE1pjywnuVawB6CUgsn6lSjKU/pRjxqORt4BTRAI= 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=EQl1qhDv; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=b3jh33ww; 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="EQl1qhDv"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="b3jh33ww" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BAAECWX005021; Tue, 10 Dec 2024 12:58:25 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=GiDMCOs4tUlP7+rR328HAv7BPIn+wLUf9dClYafh+ZI=; b= EQl1qhDvaMANf7b73MZyyG9mx7f8AHajugMM83jcF+XJp6PnyWMkyBYhjJNVulIW x8HSTguGD44ijIIKnN+mSjsBtQb00bylXwv8/pYpL3MY7EunJjSIBY5x6tR3nQk5 mLWoOzltGnOqcEFUGgk4vpjx6/Bzdxm2wi6Wj7Pb9oX2iITz9ZyXiBsflJ490Tjs p7pvcVKK4/x5UFtAN179IwfcGOg2qdnFuM/6sORZnPb1+uvyHtznhh2rfxZtHtPU J+RpsNXyG5CdjjexAe2UApc70+kJ92l+KE1I/2NYaHAEq285e7vPiB0QNATFi3qR CCph9FQLGAx+FrKU9X6/fQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43cdyswntc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:24 +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 4BABnpXA036434; Tue, 10 Dec 2024 12:58:23 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43cct8kuj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NVgFX6Gxp6WAp9gizeci4EvxTVSAhkjQNyH6P2n/w1S+iNbOcc9EXlM8q7X9ZSxvAN0mDWkOiZVrTCFoI+10FX38prSzljQFioAGsVmVGsqRJqm4ph8uqyvznvXcUR06N4+qZHwlbd4AdioNW/bVfHh2ROj+bhO9GSUjJv+V/DLGR39XzhO3kAtObXRt2stG+WyFexSbFzPpOpyMPSZSkPSLkBN6an11//gSCIN9bOmkoQFE3QCvHdGZG9/U8OhNElbg3TyAs8zlYPhHgWJ3wZAoU6rZ6BGCSmWadVcvLM4oGeXNRmVaz/u8zCfVZvnabol2uAnWRF0b9Ph0RagduA== 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=GiDMCOs4tUlP7+rR328HAv7BPIn+wLUf9dClYafh+ZI=; b=n/K27Ay4jQAQBr58uqC2az/WPkd8JlvgqsAYbWbXjjRFOw+lZQgGUxtuBrRfr2Ow67AIc54TMWwGumgg0LGTLas3GkYcVV/TRlye4+Aa9QUkJAvb+PsYzZcYZz0hFoRVy9Rxx2dRxbiv8h2nII2rUVV6dcTdho8T89d3SLA0MDMjwdHlUqCLDDTDKFSocV6Zk7jSvT+DmtTYYbIF1ptP3kWmTPu4gjZi+o4X8o4P6ejGJPPSm1VqQoPBdeP/JFPNVBEWrQpmTEhJ4BBxG+ClyyAjeH4sOIHJut8lBGCmt/3x2BraxrEYlZRUvvGDTN0CwaMy8pn8/nVlF+yTLWcRtw== 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=GiDMCOs4tUlP7+rR328HAv7BPIn+wLUf9dClYafh+ZI=; b=b3jh33ww00Vl9yJIBc6L/Q/MrtuTIqR2zoIgD57BOzwRoNqOmp9iY5D9U/cPSE6L33X6cNrVFrnfnWdeABZ/qxARVkHXYmhFnxrKTxb5qnmP30BPnk5FC7//tlJkreOCWzLGQifIwgUV3ig4J1ZLaqlx9Xe2lWkIGXb30dFT1zY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6200.namprd10.prod.outlook.com (2603:10b6:8:c0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:58:05 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:58:05 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 5/7] xfs: Switch atomic write size check in xfs_file_write_iter() Date: Tue, 10 Dec 2024 12:57:35 +0000 Message-Id: <20241210125737.786928-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0157.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::14) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6200:EE_ X-MS-Office365-Filtering-Correlation-Id: d0fba004-8df4-4cae-fa82-08dd191a497c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: AHpdXp+bjiuKTBd1xdADQTAyOxB11ykADaeo+OanX+ck/nEZNWDTsPF7HvWaqh7BdbFrRKT2f0siJ+dstW7sAH469YoPYITwe/MDfQP1cgZ7rKm2sCcYkD0DWeRa93tc3gv2rmxp3rY2vmjzZk/5s8H5wDCs3hAcvP6ifiB3o42yqRatFwpTaHMpJ/s4TSX0ebKuxIfuliwxQzF/1EO5rTALIFSHknh1X8L8nisuFk/JpExpwyBZ1WDP4F/kJ7wb2Oxc51dQV/V0FRiwonVsalLeXTtraTQZ9kW37khVh034+UwNMtuTaTlM7uk7JxojF2QKN3Jeg10/9L1DMUpJRr/jE92ooFzwNh7FAbEjUL8hhfhNrTEZRSreJmbb9f/f0tRJEN6BfLi4WkIDPiRD8tp3pAVr+6UA7efFME5SwYbBKmJHdYQ+yUQBA6O6HghaCVbLa+Ag203EXvwuH5CDIr4tCMQEkRE2e9iAN9EM2iehhiSZw4ZF2NkYrSLgb1rUkHnRkKqAxtp7BME78Ss+xeBRJugcmmdtYRIvVxiHoVw1QWzWx479taz+zmqR2RRtTrJv7HJOnXoiWlV4HClHjWy7yosMXNpP7XZXQdGq9zFnAIhKGdZuerrjqHlYNM6rXCkYd3Vjo68t/MkR10rtSww4t2NA+xtxiofjP0sIwstNrialWRpXUoVaHLLH4W7q6zmyF5NI6AOPJDRiwQw8BpUyWVUyRDzWVkz9O4DvrvVtxNgbkC+b3KQi/xE4EOahpnUtdD+d9SPSUDdxTNzegF/u1FawIuB81zREqsgrspmVYn6oSOPg7t9b8Un6vF89TH5lxbAAGo8a/GkzWSqqB5opeqJQvYjR7bRDa4GOAfcdSX+QYsmiRMKup2ft08K5CG5L6KJ9NUGDOwhTK5TJ+IrpynMMs/7KKcQXj7UaKIFQ8L41mr+fZ2jMZnFsGkaw386nbquvw1cLgOw5K3LrEbDnoDVROOVWmm1pAS0MccrQttOFCJct9MqfzvBgkIz8n9As9M5FqQOICimhTw99PUphXb/p56gDuqxuAXJFd0ugtphTf7EMLiziofH1wHM+utnt0gAzb1z9WRkymeJbGJan5GwQ3YW85DaDpULpvZZG/lkif31Wt+D3FHaoqcb6Sy9lxP1U2Pd/dfCSLD2rGpQ9ha7JHGTJBvjxbPOvRuA74eYhShg5sGsgD8F2mokpkdJ4dS+iX3tgNh8kRR+s/2QbBmxYSkpVIW2fQmX5Pt9pIj8vg/ZM6YhJhxBETl0Jw+2g/c+4oED6/Yzux9ndofrB8cWd7iRaEW6njtiJ3rIdEXBb4qPleOuber0NT7yDKMhtlD4JRjgMoySzcNWGRA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7uowtW78iSBKAggCH3fU97yIsUF1Q8oFDRCTHgK6Q2ERqz+iP142J/mnEDHleuI1VGqadfeD83gX26myJy6SuEcbLIBx+AFpD3JEdbv6+yh7+xZAQG28wwPpu5WNrvHulRPe1micPW0QRNimFrsOIFDvd80IQ0dgkOhkc25C5qbh9C/sGU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: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0fba004-8df4-4cae-fa82-08dd191a497c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:58:05.2895 (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: JsDZUb/yVviLOHZpeNsq9TTCVD6Eb3QfnBg3osRuDwaactnym6B0EP4fwv70mynrw/HcshHUpjzn6n5tZCTzAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6200 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-ORIG-GUID: v-YiRDPMHQ3WlE9W16E3b8ah3873htfv X-Proofpoint-GUID: v-YiRDPMHQ3WlE9W16E3b8ah3873htfv Currently atomic writes size permitted is fixed at the blocksize. To start to remove this restriction, use xfs_get_atomic_write_attr() to find the per-inode atomic write limits and check according to that. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 12 +++++------- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_iops.h | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index f2b2eb2dee94..8420c7a9f2a5 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -938,14 +938,12 @@ xfs_file_write_iter( 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) + unsigned int unit_min, unit_max; + + xfs_get_atomic_write_attr(ip, &unit_min, &unit_max); + if (ocount < unit_min || ocount > unit_max) return -EINVAL; + ret = generic_atomic_write_valid(iocb, from); if (ret) return ret; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 207e0dadffc3..883ec45ae708 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -572,7 +572,7 @@ xfs_stat_blksize( return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); } -static void +void xfs_get_atomic_write_attr( struct xfs_inode *ip, unsigned int *unit_min, diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h index 3c1a2605ffd2..82d3ffbf7024 100644 --- a/fs/xfs/xfs_iops.h +++ b/fs/xfs/xfs_iops.h @@ -19,5 +19,7 @@ int xfs_inode_init_security(struct inode *inode, struct inode *dir, extern void xfs_setup_inode(struct xfs_inode *ip); extern void xfs_setup_iops(struct xfs_inode *ip); extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init); +extern void xfs_get_atomic_write_attr(struct xfs_inode *ip, + unsigned int *unit_min, unsigned int *unit_max); #endif /* __XFS_IOPS_H__ */ From patchwork Tue Dec 10 12:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901406 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 566241A0B0E; Tue, 10 Dec 2024 13:00:35 +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=1733835637; cv=fail; b=qY6Fu8gcahARLzbuXigvjKYvCKpkiZjAyoSN++LCRwDtbfPlo764GVFVFkdxfx9O9Yp6A5lowCgrLDwmnJ/cQTyYBCJWsaZb852Jk9F7kTua8fRBGNoJdsvB8lGMkfGyWawoRtcvXriibVfoLuR+IbWJM1AlHd1TiMkM/xrASDE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835637; c=relaxed/simple; bh=45vWlUnI4kOtYaQ1MmTnwY6BIs25J68EBldk2NkAmOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=JzNn4Jgb0+faG6EIIyHO1i9JYaX3OrV9xtCVPkGN44aj6EpVkTeVoDPP7nBklBCUZjvKak0CQ9yqe1TwDt+utKyPvb/Nldr+2HsHbb7/4SEO8YkON/6SPiRF1LR4x0e2pmzvpYaGSPGjaJHFqONo88d7dRsxozZ8gAyJFSOhI+I= 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=Jbc3bnFg; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hK8AzuzM; 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="Jbc3bnFg"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hK8AzuzM" 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 4BABKHDN015769; Tue, 10 Dec 2024 12:58:25 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=aapmy3MStREKbjTIJgXd4R743uNg2RINCcHjKmKi9sA=; b= Jbc3bnFgIECZjiG7CEANSYUB80Lz8TQKV7MaDPWJJNegSEWYxv2pcqJKOPaiatw1 cV5gbOetAm25Wksb8FX1qfLEkXvaHB56jqHNt8Bsoc5rBhh+NrxHK81xuxzjC9Ib Pu9BnHBC1Cw43zXrdMFfb0CyBQTygtZ6hTGhtcRnGfpPgg+z/vYi6bqkiSrKkFMS wcuQcwnn9s5pRqqVWbAG/LJeMlsqQBRYCGB8sOQ5HedwKswy0qLW1vVeQJBn1ycu s4Bzo/k1EQKdjRAycJkwOkiUO7R8HKqizxm7rP0Cg1TCTZrPjiZGInmy/G37ksMH eiVoUf76kK8m153l5fjxlg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43cedc5r65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:25 +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 4BABnpXB036434; Tue, 10 Dec 2024 12:58:24 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43cct8kuj2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jr6wfi8hY17TeNbwt0/B1ENfg8Ptj36LgX1LSVITSHNyk3NNLH4QUA3JLALQYb0qXtG74pwSPuaiCfnoy7+NPyH+3lpYdHivlVHUaaDUc8F9sLGpzvhwQFk/tJb9WCXe6eg+Qb4glUOU7rTX/rr3kqzWYvtcbc9V9TyEOlLzwsfRMkpvuS8po4xwUWoSOuEsjAFsR6O9Byti+nvvwMQtWFHjB9kk+QRxs3N1gbg4XR03vk/yfV0F4eNNU8nNIWXUdqCVWhWHiuNIa7MJaBeGBpMebNP3tsywInGhMotINsjm4bTSh5j1FRTJx3ZcSe+wBFH0dm+63pbVGRz9jLx7/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aapmy3MStREKbjTIJgXd4R743uNg2RINCcHjKmKi9sA=; b=U/2imVuc2XgreJk5PXlhyJPFxNep2Skheke49Ncerv+TIoHkSzzTQYtYSgblf/OO4ft/X76P3n9GKKyivhF7d1fIhm7yab7RK+CSng3XGnIEK7RY0MlxyyibeA8mwZIOGYqFXYskvaCSExehS+352WGeaY9Bb8OTV3FSGw+45baINXUfWsulpb5VTpXdLD2QTW1zkXJmQ348oJX2tF1aIrqQUWfUlYixQppsraf9YdD+hytRH1uWw/s6IYWM+Bq2k8EWcb5T9D9nzxw9H/CgkOWOlLBq+MqqD4iMavkYo6tzhQ6mLPRlk3+xmir6hfBlPUPqw4fk2XyVwqcEEG4hcQ== 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=aapmy3MStREKbjTIJgXd4R743uNg2RINCcHjKmKi9sA=; b=hK8AzuzM9Uf5+/r4PeGCTLxND+xo5cHoy/2l2p/7Oh8jDkfEXlmJcIJB/vl19pFCNXK8bMMTyH9Ryl1B9H4VupEBkXySg+atDbUAd8AIwt2409h3nUJ+H5AwIMbFkffk7AVcBRY40u5d+rQTp656e8Uevy4UyrNvqqunsKFiyzM= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6200.namprd10.prod.outlook.com (2603:10b6:8:c0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:58:08 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:58:08 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 6/7] xfs: Add RT atomic write unit max to xfs_mount Date: Tue, 10 Dec 2024 12:57:36 +0000 Message-Id: <20241210125737.786928-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P123CA0531.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:2c5::15) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6200:EE_ X-MS-Office365-Filtering-Correlation-Id: 97d7206c-75f8-410b-aaff-08dd191a4b72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: +MmhTyulF8CSC6z3ynz1qrEQ7x90vzsXH99SJQ75Y+Nc06k1aI/kX0EdjT7Dvcm1bm6a6Rlr77mCVEzmjUCpL7/+JG3+eA6dNWxdbH53+jRl60jLQVXVDwq16+0pcX8nDGFIBwgl0jxVSoy20GzKsHytVJBp1UvForiMXZsVNPl8CTydhC2SolI7V0e5+IJzzDLNevjxD9jWM7r+8k0kFXpDeuO7tNMT1Q7KojKOI9R26BmbRVbQ2tVMi8G6/datjN26PHHT2XFVle6/HWSUHJKQKDpywHjHNB4DazEX0tLuF8UxY0jVJG6RY/gPax10wPyYi7Hhxi+WTBVi0LJxVyDWX//YCB2dqObrkHrvBQLthyuoyP1DfRUbXHzjfWnG6qiLQeBi5v+SDb8BfxtBV1OsmX40eRd32ocrq914wobnAjoPPoBNLruH77afy5QPELe6XD/9XJXS6T4dgQ9K9IBQg324g6uiBEg2wbJtS9D1AV1McgE/cQVBa8EPvBWHAvZOBbn6hjXxiHUGIa6Qm5Irpw6ddn2sdqQvXGdOWaVnNg24kGzqmQghgJfeQYoZYYwoo92qkgRTcjMX1kr+/PFy4ZxY5St3+zAHZ0cHHJk17YFvpKaDJUJIuZljrbYnsFoeidHPzNOkbLAM1MZzRZZ8cKQ5XgZ++EKfSF7ArChjg4+C5UQY6RGW1V4gcn/7Bh6Q5xBAdB+L9O2gXfpt3oBQNGdwp00PNuD/BsMvm8UR0tbKx54i6MyGPZofCkVBMlquOHUhpPIhC8WD1VdMitzpT/ZhvtqkYxwdEBMxaubkbvmkenbvLgwNtWHGqsO9Bmmm8EL+KXfqru0e8wHffoZGFWarwW1byIC+Jw012RRLAVpigmg9lHPTgb9Qp9NDOW1w9zm1+BUsjpsL5ZypZBbtXpvEynwBEsv839B2fEkweMhSC7vfkBop08pdq+cgY8nAg9Cbx+en/JMlsnaC4RtBdTYT6QwJtA7Y7GhtTAwvI7DUIDhlJq0HnvTwBOdzTCsbjxxIVG8Wo8IZHcP6eDS960hFCW8gNoLVduYFzfmEmAJ0tQDyjtf099NTzlY8A145YwaRR+rhiuMN0xQmgFE4eMa7qwLbK97bG7fEuamdZwSdUtkiqfb1ydS9IRtWPxp7FZv/0+8e2a+lhPfjVqZYhvIDLJtiG+/3498312hAKoBGB08inzIZnYWg8e4fHD/4Ps9ICUugAb7N5nIirZ8PptvoplmOfY4XIaB8X/jUakbfnmDG/3JF4u8wRFpLe5DY9DmVG9Jw3fmeppNTw3Z41MuXA1t4Jep9PZJvbjbjKc6SBPJkr0BbT2kSk68UHLAzxgnCqdOBlwUDp+lu8A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gxXCiwpcdDWXQRWjibFT/gIhrFDJ46uov9Ls9ptQUFJyXaYA9Yv61N/Dk6xGvFZUFp1eMSiG6J7dq6txuTqHNY3388kUMF+xITds4P3uStzaBI4Y3RonH5KdD4S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8mYYbBH3GGHbkZhynjm3EGhzvkhGFhkWHTgkEz/2kUWl0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97d7206c-75f8-410b-aaff-08dd191a4b72 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:58:08.4121 (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: zzR5N9Lex+f0h4Uubov4jTk2sgBy1h7UtG095gfVQATkf5W9IbCgfBTFzolg2mzs0FeA39Lc69j/h/Ee5onPrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6200 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-ORIG-GUID: OyX6LgvSVg0TlFR2o-Zm1cH_jlAsVKbX X-Proofpoint-GUID: OyX6LgvSVg0TlFR2o-Zm1cH_jlAsVKbX rtvol guarantees alloc unit alignment through rt_extsize. As such, it is possible to atomically write multiple FS blocks in a rtvol (up to rt_extsize). Add a member to xfs_mount to hold the pre-calculated atomic write unit max. The value in rt_extsize does not need to be a power-of-2, so find the largest power-of-2 evenly divisible into rt_extsize. Signed-off-by: John Garry --- fs/xfs/libxfs/xfs_sb.c | 3 +++ fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_rtalloc.c | 25 +++++++++++++++++++++++++ fs/xfs/xfs_rtalloc.h | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index a809513a290c..f59d48f6557c 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -25,6 +25,7 @@ #include "xfs_da_format.h" #include "xfs_health.h" #include "xfs_ag.h" +#include "xfs_rtalloc.h" #include "xfs_rtbitmap.h" #include "xfs_exchrange.h" #include "xfs_rtgroup.h" @@ -1148,6 +1149,8 @@ xfs_sb_mount_rextsize( rgs->blklog = 0; rgs->blkmask = (uint64_t)-1; } + + xfs_rt_awu_update(mp); } /* Update incore sb rt extent size, then recompute the cached rt geometry. */ diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index db9dade7d22a..8cd161238893 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -191,6 +191,7 @@ typedef struct xfs_mount { bool m_fail_unmount; bool m_finobt_nores; /* no per-AG finobt resv. */ bool m_update_sb; /* sb needs update in mount */ + unsigned int m_rt_awu_max; /* rt atomic write unit max */ /* * Bitsets of per-fs metadata that have been checked and/or are sick. diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 0cb534d71119..3551f09fd2cb 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -735,6 +735,30 @@ xfs_rtginode_ensure( return xfs_rtginode_create(rtg, type, true); } +void +xfs_rt_awu_update( + struct xfs_mount *mp) +{ + unsigned int rsize = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize); + unsigned int awu_max; + + if (is_power_of_2(rsize)) { + mp->m_rt_awu_max = rsize; + return; + } + + /* + * Find highest power-of-2 evenly divisible into sb_rextsize + */ + awu_max = mp->m_sb.sb_blocksize; + while (1) { + if (rsize % (awu_max * 2)) + break; + awu_max *= 2; + } + mp->m_rt_awu_max = awu_max; +} + static struct xfs_mount * xfs_growfs_rt_alloc_fake_mount( const struct xfs_mount *mp, @@ -969,6 +993,7 @@ xfs_growfs_rt_bmblock( */ mp->m_rsumlevels = nmp->m_rsumlevels; mp->m_rsumblocks = nmp->m_rsumblocks; + mp->m_rt_awu_max = nmp->m_rt_awu_max; /* * Recompute the growfsrt reservation from the new rsumsize. diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index 8e2a07b8174b..fcb7bb3df470 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h @@ -42,6 +42,10 @@ xfs_growfs_rt( struct xfs_mount *mp, /* file system mount structure */ xfs_growfs_rt_t *in); /* user supplied growfs struct */ +void +xfs_rt_awu_update( + struct xfs_mount *mp); + int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp); #else # define xfs_growfs_rt(mp,in) (-ENOSYS) From patchwork Tue Dec 10 12:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13901405 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 566F61A76CB; Tue, 10 Dec 2024 13:00:35 +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=1733835637; cv=fail; b=D+Zy2J2n7ZFM0vvWmjfQfHCNTAIQK9m1RvwsutOXabc7NRlzrPOWk9oIQP0Lg2/LYDSafOzzCd1kRfSNE6jwfzPiwTK3/8HQg3pDJK9536SkuPf4PTmArcgSRVawqNxQup72zLvRy42+AZ8kD0Ljj7hEyv3bioxwfy6niyB4eB0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733835637; c=relaxed/simple; bh=T/H0MQl6+6wQP89dXD/1cxALDZ5syofyLVpY8AZVQvc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=S6T+ExbnQHvLURJn+3DB53Og4ZsV1hAXRTLw1/MQ7GD7eXEeZ58kqWIu4Wz4gbiO2XEG74bL9IYm1kZ7+YgqPf10y+u2yXaFgHnnBjfFr52PK4nypgeuyhLwZ9+lA8ZjNgbGIK8TFslDrM8y2QkmklgAuYYBtJA3Htm5qM92U8g= 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=EeIafqLK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hQ/7vZLk; 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="EeIafqLK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hQ/7vZLk" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BACG6Fn021896; Tue, 10 Dec 2024 12:58:26 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=FJa2FYn+l3JgVXkyj+HzJHLUFWBrqtA+vCZJkGiC1zk=; b= EeIafqLKvbO77QWBvLgSbto/HHb0Ss94j90fAhu8HFKLA7nPGSo0cWgEN4pwxfHF ZVIWbWnq/0yQJ4QmaSoUzqkYICnekOCLv1lk8kqJVU1E6HIHx25JGtPe8Qa26xZe FDqRrWT9Qb9hVzjyrdW5MyWon+SVIlhaljLEhQpKfVg6cwz+jHXURz6qusdwkucJ aNmIs3odjNPTegkQt949R50vhll7bLGuAWYtmVeRxyGkJo10xcOGEuQnKIOezF7Z oLsxAJL6NWZR5UQNgt22IIkpAPFXIGyDP/ATWs0cLMSVNsMzIkWBrbgYoQhZphuC 9sto6gswEel7ckYEbGEgiw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43dx5s2ur1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:25 +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 4BABnpXC036434; Tue, 10 Dec 2024 12:58:25 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43cct8kuj2-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Dec 2024 12:58:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Spv/TdF6uJ2uET2dq3DUcThIZXh96AyhiBi7df9Ihdtz6HrZL8IgNRYRCMEyw6o097MNc26RpuXsY1uohPYZUIUazPjhEDGKtt5mH7SRe7guVM7oldzovkFns8pXz2Be99dbsNsk+Ee20YbNlCLTWK39Fcqd5q2GVAEGedAWmDq7ZVOpZA8lY6upbZJwS41XH5ubRQKl3XYoCZmlFHh6qv9EooHINk3Jkd3FqtLOCxyl4VywD5lTWOuPGK3Nsz+GsNX+yUcwMWF9PLS2PPF9wOsikbvi/oktSRw9drGYqMAkMo+FOMxZqTwpBvLFQqqq+pWPSIbh8rQfjhELa1qQQQ== 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=FJa2FYn+l3JgVXkyj+HzJHLUFWBrqtA+vCZJkGiC1zk=; b=m9/Zk3aS4MijILq0Tojd4z5J9U2kGSSm06POiLrxWwXMnh5OFbjjXWqDElp3GaahYy4c1Un+yrpWqH0sMfid73+1RdcljQBWwv/kZD4IvxXq7unX3Eut8za1gZgIwJn5ZWMYgqISqSIHV+KpoXpWroHfwNkaCP9OK87G983OsfST0EIqlS6+wQTHy5HuDvR9eehNVAT99jMlUWQVFo7bgKcjtznc1W5ZObtwCQBox1CbVD2wuPlkY35IDdWLW0sYhnA0uW2ZPydYAm+Wl9evylOBIo30Q9YFyJz0causP5VrllG/89aZ40l9V4MIofxMlsLLcx17uHSUouCN9D/dOQ== 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=FJa2FYn+l3JgVXkyj+HzJHLUFWBrqtA+vCZJkGiC1zk=; b=hQ/7vZLkPWt7FldEyGpy8BB/U/NBbhhGAz6QqmQhU49N+ePUI7S8nkHn16Ea9Ro+F2ZAES6gjva/vEJkKwnH0j0qvEDS4cPxLZYNLGJtLy/LSXO481FNftFcunWiO3r0rMyWxhiXdE0vUtntM6LHrwg0fJNDOzMzBDgVksNYP8M= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DS0PR10MB6200.namprd10.prod.outlook.com (2603:10b6:8:c0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 12:58:11 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%4]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 12:58:11 +0000 From: John Garry To: brauner@kernel.org, djwong@kernel.org, cem@kernel.org, dchinner@redhat.com, hch@lst.de, ritesh.list@gmail.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v2 7/7] xfs: Update xfs_get_atomic_write_attr() for large atomic writes Date: Tue, 10 Dec 2024 12:57:37 +0000 Message-Id: <20241210125737.786928-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241210125737.786928-1-john.g.garry@oracle.com> References: <20241210125737.786928-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0248.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DS0PR10MB6200:EE_ X-MS-Office365-Filtering-Correlation-Id: 437fc060-2909-437c-e9b5-08dd191a4d52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: ZMnpqFUm3IiMaE9vlLSejls1mbgJSqd/ny8ZaoYD+dpE7G3GZHQTZpgQSheUzYGKvekS23yj7WdKaoPXB/PKXJzJ3GfCOuxtf2ZHtSMfOq5Nx/k35fby+GkR6nZtFPrJYbUG0uhX9xoPmK0wCmzSHMcUQLoRwQGx4uD5NzACbVFGZI7oAeMWUKU0LzMyng4Uy99Kf0fIfg0DXDJFIfre1GN1G9yLTI3mXMMscQD9gGNoTqpaElm2NReTCATs5dEacKQvTv5HLXJ5l8/7DiQQpe6aDx7khXb2aMEWAx9nnt9jq098ZtKAZa0UamKmNpBDW1UXOqMSPHXOwtOmH7mvPQllx9XAXJci/aaQZzeZVWkb7/J4MwjQJ/a7d1sodWwJsf1OL33QFmrSgoYi6f0pxNtnQGiMqrbOFzHB8AX3oZ7AlTIvsIEUOBIBvOatSwr0LJAywkeOvYuL6TcEHcQnkbEEwFSHQuZJ8IYvdP7pOwk8aVwW477aZGnft7MdkMj8VNG/SS17bhqgahXsgiP2YGAYp20Iszs8OBM55ZH4LQLHvqAra/PRuwdQftsn/cXVYxMALng5pHvC/aMqwiZrRDNXRej0ipq9Zi12TVMyjP0Vcr8u0NWzIq9l4cndnQma+o4e8j7cXGOr4jeup0EFL3GWgsgfyQg/amaJIJzzEHqpTNiKmBfJS6ZYqM1Z9f13+8cpfv2q1fcVRGK2y8iBAwqUtlyNJHvvnQvj4w81ilKMGOANTIxO9z/ModsQ6FYams4y8uSUzJE2+uIQMadfnnw2sDXMC5zc46ivVb9WVDS4uGPITFAq1Nipf2TSjMQDu2ZU4Eqsc9IlK4AqJ+2jSfmsKi6ahDydjTSxTKc+nE82sRWPVnIvpYK/MZks+mka/6XU5meEVnfIeN6M98UFVF0wUlGFJRw3e7iLudAXBfnW0YWCwpzmXYeKXpDYija6SscvsTdNMbA8XHZ3OmK/z05zl4kfbNSaeNP59+fjRyit5JvlUdQr8VD6oCFrj5jyPoccjJKfTrORcM/MxshlMUB2PaSAE/C4h1e8JhOhjVztzL91NAAgBOt93kgDJxV+BzLSOvFKXH6vXrnAhPpbvVaVPM0gGYa06Kx9arfpZCqkSKmS6lbd9hyafDpNx43yLoj2dSBNZCB1cI1SfeIxyffhOBXgBnWbfSkjJyJcUXI2JwXcJ6+lbHP2hK16TOywYR8DMcyDCxZikgWL4meku8cNiM1D6FFAPDQ+R0glKcOUfeouzraOoH+GKjcLddrWCugSfpEhg9X7VfGUxVjZzH92p1fH5J+15M+BHU60sCPNIe4FWfQ0aVncn0SAZXw8QsLcdQE5Kp6/pznk5+dfLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 35JI35sXpfG2S5bovDrZt122JWn1ea7Bp/NF5gIWc5vm4ymEy/VkC3WF+0ZsZgu8oVTVmw5ly7J+2mJDPJdtHwZz3aFscm3o2dveB+/xW4TkyVV/bKZ3NsfEPKdZMXv9vapIBFNkqyxjYpotAAQ0xOlBYMMy/7hlE+/l9/ESpLrPFczI4RBHeFnCA5dWm8b9OYF+spdvlBa7b7nsKdK50FNv36EAUPJ4r6VDg1tO1yv+VZNIRYAMYh3axcPxK8FwMIhhKU4mfwl2WMYk2aNIxYA3G2Q1K9TrpAVCeJXtsFCZHQpMZG6L1yhHQDVyGcyT+03RYVpOkpUoXxGD+duxTT+5kVNZDo25rFTLcRmHPOFViBbO45ne9pWYxfA/v26NACzsmFX8CqpdVtOO+ST+pF1HuaKaCsvo12gLxa1rgBEk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pE/FqL1KmL71hcre+t3mSiHwI+DV+h9wsTQiUtlKMd9AQpzN8A093QSQuZMAjv6o3A0t3hQIqgYtNjTlZ5FTsWICVDOBrfx9EOKl/Z/HApqr5P51KUSflJg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: sWigfvaByKSj3tBaCCnFO3Pb53bUy/mZhvoocBPTQs6ZYNgAGY2mk+2S4CH0NmT9KOwSAObpiUggJ2BolxdLuL4ANi3Ph/WEoxuTULYr+ByB1MQ/fT/UxVE3svQreEQK7YJg+oiPbdAtIrosDc7fYQjYbQi4k7eux7nfK8UFIFnqjT59nO925AAPWC4orIbD6d8tHAL4lv8RPgnbRgVGWx9n72ns/harN5R3u07GWvtCeE6AMPMRtp5zz6SJzYk+Gx9LUYvRIFXRHUoHpewGHZqZtkbDFN9sGwOvB1G0Smxp1wraMejd/TknupaWb7YPSVk/0/VWj9t0wUtBv6262f/k40rEBcUsiWVjGfwxiEVfsYL2G5Vgw5v02nvRk+uOzFnNZE67SicxR3bfueJUvTt6lIgmehFVKBgHCUJTkRGt5YZMi8MEvUJ0pYLkRyLfb6RIcxtu0PrHyrNNN/iIpTt6f0A278w+hkC98psqA5wuquhthActdPRyaryI4Ke2nCJc41e727cZt1oSXxa7gcgsbFFJ2NwHMUQ8aLmm4JPuTpWcMxfctBZyo3ZAsaYCpH3vbYW8/X5zyPK+mBVBGGQTrcD7NVHVFv24NIKLRWg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 437fc060-2909-437c-e9b5-08dd191a4d52 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 12:58:11.5680 (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: C1iZO9k0Xfqi+4u2S+yKaJ6T4DGEZmVEXOXyiE23h0RobehDvqXbvCF/jH3ePIMBFVJleKThcVN7pqoh3l5Qvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6200 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-10_06,2024-12-10_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412100097 X-Proofpoint-ORIG-GUID: DJbCvptv66df7L7QCEJmW_h931bsesz0 X-Proofpoint-GUID: DJbCvptv66df7L7QCEJmW_h931bsesz0 Update xfs_get_atomic_write_attr() to take into account that rtvol can support atomic writes spanning multiple FS blocks. For non-rtvol, we are still limited in min and max by the blocksize. Signed-off-by: John Garry --- fs/xfs/xfs_iops.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 883ec45ae708..75fb3738cb76 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -572,18 +572,35 @@ xfs_stat_blksize( return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); } +/* Returns max atomic write unit for a file, in bytes. */ +static unsigned int +xfs_inode_atomicwrite_max( + struct xfs_inode *ip) +{ + struct xfs_mount *mp = ip->i_mount; + + if (XFS_IS_REALTIME_INODE(ip)) + return mp->m_rt_awu_max; + + return mp->m_sb.sb_blocksize; +} + void xfs_get_atomic_write_attr( struct xfs_inode *ip, unsigned int *unit_min, unsigned int *unit_max) { + struct xfs_buftarg *target = xfs_inode_buftarg(ip); + unsigned int awu_max = xfs_inode_atomicwrite_max(ip); + if (!xfs_inode_can_atomicwrite(ip)) { *unit_min = *unit_max = 0; return; } - *unit_min = *unit_max = ip->i_mount->m_sb.sb_blocksize; + *unit_min = ip->i_mount->m_sb.sb_blocksize; + *unit_max = min(target->bt_bdev_awu_max, awu_max); } STATIC int