From patchwork Thu Jan 2 14:04:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924476 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 582692A1AA; Thu, 2 Jan 2025 14:04:52 +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=1735826693; cv=fail; b=X130kkwPkK9nMBVnmJ8+yBv2SembsMlQBEoLPQYjyE1lQScmAM0yQ9PfLUKbGVMYdaSJXLStDS1wEcahfOKHXovybUWsw083S4Szcva+T0kXL0aht3LB/H0BmNC3Cq5qgtgmo4CqEaYy9z0r+Z8s+mFVS36INfLh0ep5ArL029I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826693; c=relaxed/simple; bh=L+4Knl7nCtqXr5ksJZkH07sbQASo6PXxqrkkVpfcwCk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Tagy6Gr6mNGQCSQkTO/5ulsvyEib5ONpH5iAEQxtHa+ZoYeijHV2zfyIz+LLeW+vhGQSXQPce8cj/BVvsj4k4+8OIrK7OcBuBPhp0Ub7eE9lONHTspgCkTOYLpLNx2QG6HQolhEcIQKXhCm0LdjTvoPngv+gBT5Y7o1MrmFD6gc= 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=D0GEaRA4; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=vDzv6gtI; 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="D0GEaRA4"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="vDzv6gtI" 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 502Dtq4u007357; Thu, 2 Jan 2025 14:04:43 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= D0GEaRA4uSkTi7DgP/EXsK3ii1OQuIW28TFUC1aYmzX2IGE6oDCU7RKaED5Aqdb5 ts8MKT1twStw927iQsXOiSwp3FH7eyaAggExOLZiK980vgic9SWU/rICEapi3m0Z 4sQEEY1dCQzPU5o2vdxlyS0gdVS1MXR5E2pr9b5knfU4xTW+GlPwNwmXf7lkqSdb tX/d4y4OkVolJnFVBmkXYU9x6P00MZT93Oa1ScOyxDQj4v7epMB9e1G4jmPTFHwN Mfy+MQgh7ceZeji8tybeytNGH7UZjSWETVYSF5jFQ+wuHCEO3nkZ3NKkcFit3T4a Y4dj8m4Ix10Y2eydF2Xxlg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t978najc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:43 +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 502DEWN2012914; Thu, 2 Jan 2025 14:04:42 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8jqvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lESuceQ0FxRw/u6O3vgrHa8BfFvf6t/TfRrdDXuW32WxQVLAzV95OkiEV10xYRWMB1kF1t4UITdyVLEvjw/59m96B5XfzTcqhkrfMVYx691EFyWiVadrWw8Drq6UzlXZxewq7Tq+aY+5ldt7F51hOKluil80AiTb3EBxSvt/M4/NauboH5PMitaCVfL4rZgaaA5jV+OUY3d8T2+lzikBOxUK3FSc+FQlrT+QTC6ZjcOTK5IM8zcw5BTdrB23VJlk4xB8MHd3+btOU6evPBNFhqWwRi4pwLOtnzqoBgKjFcWPkrdR3p1t3vwxYyIk1sGhNcWranl9pSuF2zGqYrtVSA== 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=wh8sExwsYt3HJL1DJvDxp2CP87sk9Bkssg5DiWTUkV3yXk0bD6So7nUQxC7trnCMoJ0ItiDrAxMk6Hh7eyqiUHRR8e6rf/KIZCSPBhm1Ie/15uSyCWXjbzCbOqo4gvJNLi9Ll1IM0FDlj5dmk5H3AII3D5PL/7u+Jj7bF1kQGWnG1m9+pXoOZrH7qeSe5FaOevSiP8oozOC3jgp82FlNvgoj8yQU0njKF2jjLfVjpNEQL4knQpqf4WF4CTDstbD+eRImJFKenwWEdmbQUk2i6y0B/ZEOzO8M1on8Sow3RrgP8Qv0ZDjryRTqrVehEPGGwtVXQ9vM8d2wOT07j1j1kA== 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=vDzv6gtIKNVG66x5Qqyl35gFZ1MY5/uo2wiLARUq5QEmFZwyp2moehwki0XV3fLJa1i0DbDhPNGnj8vXIGDOTZQ8Q9Q3spElAccduFoJ/sUVyigORkkL3zT9YTEcdxxbXkIYu9SC709husCmIToeJhwzNgogXrD7PXG+82nPUtM= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA3PR10MB8164.namprd10.prod.outlook.com (2603:10b6:208:514::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 14:04:36 +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.8314.012; Thu, 2 Jan 2025 14:04:36 +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 v3 1/7] iomap: Increase iomap_dio_zero() size limit Date: Thu, 2 Jan 2025 14:04:05 +0000 Message-Id: <20250102140411.14617-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR11CA0022.namprd11.prod.outlook.com (2603:10b6:208:23b::27) 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_|IA3PR10MB8164:EE_ X-MS-Office365-Filtering-Correlation-Id: ff93f813-1a47-4ae9-3c99-08dd2b3663f7 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: B+vShM4YYQSqrYSK12qRZFmCi3i7Rw4FUHlP8bxnxs0a5hI2f/knnQG9Podx923RRcgrOa0CjzA+0xN8NXNjsxul5K52LLjVdhDPVQc+Jcs5Ijfw00oeq32VKSKgwHxz8aSODHWMXMCQtvSxHVc4K0qGfMq9WPdK2Thpa9QP8C66q76wvcsvRnqwzhjwBBZVyBGDCZ8Qd+KM+G9JYpQ3UbocQU31S441Q7KUUqP4leAO4wpkkH0nyimLoBpfj0bTHPBj2vHhtBtVVh6SI9EqXLt/ZQ0y3PcobPC37CLvLchLKzlbMdfsuU1TS/FWuOS/XjO7h7Z6wvTc1hqoIvPtZqSsOfykQwZp2ZjHBDEQP/+B0yxIDb+qWu9FMA1hVjAR1H1fM/ZEYNVT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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: 5evN3mO3qMyd4gjv1chiDo3kdYLru9+UEr2iqW9wCDeKL3wZcG0k7kSV7BzTXQ5pCGEUgGfCMq7KVDchNuyCJi+cGWcPew+MUzjWWGIJHyewVQrMEK1tAWGIOazUI7HPpnqzqi83o+tcYGoQczoeKGAVSNtixQPLEPailTwrlgTvj/mXuDDiQ6jC+DitKvVS/MqvFlkpi+XfAUlG4XNCKoamMkbCQdyIzc16WxL9sNKZ1T+K4mCHS+0FxTjA6qTuW+UWo6CwCLgpk15RZIKOYRDbK5339kQ/buoX30KPusMRa3B6bwkLy/S9Pnwa+P/h1Y3QJnq7hckvXCHXm2/G/zafei/Tdj9Xwdhz+rgVZ0pXx3LiRT7uHYXUaIOaJGOEz3s28eRHQMaCgvXz4ueide1CoEbz4jdTXdJpzzZCbMqXIWpdK1n0DFf9yY98I/3j47KFEKi0/jnC4fPA33fTzMh774yue4IRa6A6ehPkahb77q+TO+uRBxGJVIf99hgTzWG32KSzGyG3plGEzzEFoIQs8lDM+oPu4UmOB9IEOvMTebn0rQnkfRq0Ye8VPMi2+mZtalvcbRGzHMpYjDgxRbdGKAqFOHsD9KLm0U91OBlGWIZYEywhcrmXAXfXLiTiUDpxuWdLWvMMuG1PQj1GeXnqDna1+RzSv9EBOAlE+z7IULOR9PbyrJ8mcGKWElsuD7sv3sGyit/qeGUg3MKTBvYX7A3T7SZEzOQqQ5gkHJXs8xW+qujBbo/c2LEigumR9VSc3iqKZXK4vWLkvLVUyyJUapnU6amkpLFoIjDnNGlDsJCx/0Kzse5Hu3gcrkzrw93d0HwUjxEn1FV23s1HzniqMFoaK0779UyKSpmEZxotmdZ6dWU7O+lxrkr8MhuZXKDJHRFVIw3j1JUghRh8+2pCeP1fv91iTr86gaN78GO0iQFAkjuV3zKhE6/1Msg0gCV0EXVyzHQS6rmRC80AjESg5Z1aGRsDSCJ3YVsMX3dokcL13NCtogNLivVrREEWFbNm0ahFeGR6WMkaXrIv7GZtSxac73Z/qE5mrGzbirokHoO9NXYpO90tsztSFnlNkjpkf4wTlg7tQLQ+1Az6C9ht069LJALnM7CScfLjanjWTS3Izph4/uovLJnu4b6WZXEihpd6CEV3SVKckIy9pzwpGhMat7BE3tH7+TtyT1haRROgtITDXEOPL6nawVROHyIJj/qK4eiD+VvKREpoyHdnnlAGk6OGgynqYWlHsLiJ9Vh8az6UiIss0mQqbKJ52LEww2aU0DSssOploX9gV8N72guaUSqKNNhXUCcFkMfzRnspd/7jJsHyIpMZai5oTTL0j1C5IFdkZoCMg+43JJWTrmkQKIJeBTje8K5g4yMr6xSEkb3dGIqYvmYE45NTausFO7da9AWaJAvw6EU3hb8fjzSLg+kTPRP3Szj8rHk4t3FWngJKaaME0PRcMXd4eOB2xr1CQ9V3hhmPa5CctMpyMIL7/ZjtG2FqakkYiSpR/Ss0SLEntdULVgL72ytI4xLDckX7r7TNArsMcN8/OLgtey71TfEx8OYV/vAmijSIDzkhxkkT0uk2zB8pUXfTiibfSea5C3le2w7TF5j71A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EFhAiLGfbPtkoLrEW8EG+2o7Y4X6pHPXreadphqMYTWzkAbs0Yja41rJzaBvZ6ixdSr7IC5B6wWbruTB+g72hbXP4HEA2rJRXK++oNjaycLZw1FhMpMm99ceE/AGSZIZ/Ahty/7V5TxggJg+SlBS0zzfhkG3Utb4qBJXUJWiQwGJxziNNSryW8sw/rc7EVWsxP3wWY5EIBA/WzVXUlShWfsbLee1svR0VPOWpU4gBjQbfn5RYZniV7g51Qzwv0HNStJDoACBPMquiW0fkf9ELDIZrA3fwHqcKT9+CqO9Q11ar2AZ41NFNoHKVSeK4QW0UooXPWyYmVu7m/tR/5FGD9VuraB/UYbRTWDFqL3R/LrFjk5gTAMJqyc9uQyM8GQ9Hq2UJqWqE7lzCLDeFibf2Zbam7o5hNqnMfvcknvvdI0nTZwdvG55oZPEtlwh63joXXJLCwm92oyBMG/ZyDSYF2SkkihEyxQX+yrdIrKjPq+gnBLYh8dQWSfrjirw66+57hH1DAvkyQadsg/lTMcp+gqUScEeUEtDB3GreRmRIIAtdKlZ1nD2meXEpS0r9lpaKuXkC/dM+zXSoFXsusI9d0RZlACBOZ/nKLDX5LJL/Uk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff93f813-1a47-4ae9-3c99-08dd2b3663f7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:36.3357 (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: YfTRv/bVWelZldLlACe70tkn4D8pZtces9h+CPvkyQEe7XdF4j0xeffOmeUY1c1WutVBM8txYjwm9T7seQJMQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8164 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-ORIG-GUID: gQwG63cTWAJta1yF78SgQ4R9MajSp9do X-Proofpoint-GUID: gQwG63cTWAJta1yF78SgQ4R9MajSp9do 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 Thu Jan 2 14:04:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924477 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 7BA97191F60; Thu, 2 Jan 2025 14:04:52 +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=1735826694; cv=fail; b=Ox3DlCIhj6pNwoisA5QtfoOECnZeU4usvPpJsJQHfDw6JkY09EjdxWtbl4W961Dk/YAbb07jTMc+4HS6UEvESknwwEkTywXu2t111mSdT0LQM+6jKYcude8+Je+Y+mh220/mzOPS1GHDsl/cIRFlPXPxzkHlK588nfAWNuU1f5M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826694; c=relaxed/simple; bh=6zfnmFazEqBaBWIRgVqn2WJ9JeRsqdBhAwUf1JTLJOg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=WU6h5CkzhepReJyD4SVQr7eOMZ8qmtCc/2f0RBsUZnNy/PXBD277x3Xt3trCuB39LlJFdfxWJo38Zl8ZyOVUhik/lWIJngaefjK4XC7YyyKL5PdlBXiM1Gzids0uNq3t/4jbZuR40e4VuDumyCSUJ9VzmdMxp60uGiXB0/Jb9po= 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=PBIwEoxr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=N9PTx3xg; 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="PBIwEoxr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="N9PTx3xg" 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 502DtxLe024660; Thu, 2 Jan 2025 14:04:44 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= PBIwEoxrqGmK5aArCn4NjtmBn/TkeneSzlj0UQ3YwaIQuP8w98oL8oBUhGuQe9aB dggL6A2+mxGUsp3KEuny91BR5oknkuFz2XwoW7UpZzqP1c/KQJoAUUJhlyTU3Ajb yTPwubGPknq13F5v4uQ022IBbmQyyVaBz8Dh3cJz//08Qlht8oCM7ASmhw8STmNC nfS2yzdhAC0SYPUGxwKH7PzTzzPupYoU7FVaX82gXueDs9MuPR/F/SX1mwHjE4WH JimBvc9zIGtDLUZDw0257vyWFH3nKPkOTn1ux+ux6B+aOBdMqWfM7+an7Ejo7h3Q lMrDvVX9ZvpNwQhL2gRBBQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43wrb889mu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:44 +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 502DEWN5012914; Thu, 2 Jan 2025 14:04:43 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8jqvn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kifeLFQcpMx857oRdhlVxhahvVaGo1fqWIlP72qs75RmBUAyduPbsgNpBukQxLcjzRt8jdXUtyWoJbehEtTQWwgThS1x7oeCyCCd3EmFiAMCy25vxPeweBj/DtALl48btfNNtHVn0Dm+kbcH3WIxi3oA7CIHW78LQGVy2gWDOcsSWzCRjO5CCq3zQV8/2wpKa5/uwPO50q1ySXnti3jFQiYQQDYYerXvg6SF/gIWb8WWo/KAzmqapBvCS8OZ3Cp7aJYlHKGrlKoQwA9eIK5GGZsuuWmh7fg3xwTGyG01vHwtrALjXgn++7fW6y8FRBU1cCOSdqiGR0hwAVSHsxYQNw== 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=CLMF0GQ/qR1EkGWRh/k07XbfiOgOj/M54be8SH/uMGkxUD7VbFAvsMTnrP6z/k2Oz1o9NkW6g4Au2P20YASQ6nYdKVKhjH5bR6OJXM+sDCIG2f7/KMj3Zq1vqSgzU3s0xwU3fu1SBP4geVv4l7nWzmwfeEuyRTypRgAXGkKBcX4d94GAyHzuOWlEwMWxftixZmnt9XgXf1R147pNmj+ww2rCPP6XTnSxyEPYakSab8rMzyepYaLKZbCqY3LeAYkP8tzUEco049jlieawXS8bSAijUYrjXmTXQzRlehxsfDHfv18Ca7sErgnsTU+H+XGowrhnmR6zQq9XxM95EjFbBA== 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=N9PTx3xgpazMvqgEY9EKaVqlwcXAqDgDPm0mRhyn8EVO+kJ+Wlrr6YbOiq2U7OfVKCramOXY+4Ig69Psoi/eQXMlLljNqpIUBFUpP4nxmvHv8xRtVSRmk36JT/o51Dzxofz4TNZNxrK/VbFRoMtKTRO1C/yI94cQun/vy5DYEDs= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA3PR10MB8164.namprd10.prod.outlook.com (2603:10b6:208:514::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 14:04:37 +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.8314.012; Thu, 2 Jan 2025 14:04:37 +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 v3 2/7] iomap: Add zero unwritten mappings dio support Date: Thu, 2 Jan 2025 14:04:06 +0000 Message-Id: <20250102140411.14617-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN9PR03CA0045.namprd03.prod.outlook.com (2603:10b6:408:fb::20) 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_|IA3PR10MB8164:EE_ X-MS-Office365-Filtering-Correlation-Id: 5829d814-0c29-4586-fb3c-08dd2b3664be 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: Ni+U9WYFDX+FBRmoleq91AzFh/Tb0fr4UsdZVCE1WYUmdWje+Eh0aTeoH+lK2z+0+aSdqxrmgpWqV1YfbKBCj82iw1UC4tyCe4q36wxyfxCRLtKLtBSRU/MpZcSlBsDCbfsmOik5A8cox6ec5RVOgHy9vOdnAb7qHqg1TEji17tlfEk7Ra7ztbLNglC4D1nJPEy5DpIKE+KglSAo4VVFVYteKHaUMKGhcelpv10PceAquaUdhxKzdBcl2pouOuRPrSfadQM04DeHDZwrHhOCpOFZ/uQE6HIWoTe5LqsyHWphCPjE0pjvGq59xl+0ybRQyLZR7pdPkg2iDcL6rNAXOCsk6gFMG5Jtp/qNIl53cv1hpx5VmJGnv4tNIDBP2f4XWHmX9qYVNxxAf5n+o9mGuT5CwofPIU8AVlW0Qyr61nSB7qDcyCxauPF98T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ONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SR/ucCmfJZUAcyjWeNj9rhirI2GrH29UntJlzs38gBhGZo3T6pa/By0jxo6qCYxlNu6nkzGJc2UmN8wWcJJYKwx6yC+q/6LX7s1EQRIArBPo/PP5mzBzK3CUfjRMhySIvf0y76hj5536tZRpDQgEuZEJRGe9M87AMy6zWXFURS9FAAnsr7zmxdPp9CGTwCgKKy8XIWa24rPwcNx044SNvujgU3qbtKuV6sDm3YCq5DL1Hjw1VEsXta5OahYnYodBAAtfSz/iVEMUO3ZOh+82uC+yzkzlo//nrHBKfalKZ9vpqyxa8x68TAXsH04VlYEo4nD0S2ZGmNi9TVoZ5vx6HwyqmK5ZnvR1r5HukQMgEbCH8cLWS2uEQNmoDQNiwKzSEY+J4ZQ+wADcbH5Z1aQd/ESRt/isFm+imh85MSWleMxHRB32qejRnqq/FvZGsDX7Lq4KrdySG8rpETzY15wAOsRWoS14QRcuiaFHvaSYSkLaLtUD6rNvyj1JZvXrsF9jHwgnopSbCKw4e614i8aHOYNnqdVATj2fTjhAj0PyDJ+68IOI0AZedhX09zyim2gBc1XNb1hnQwboARiN4OhWAqpFg/SBeI36XLf1XXWryk6eMG2ivL/Xoaz6abo/TE7LzOwA1N/evcFFPG+KUj2/sPvTv/zJxsZ7z/cEzu2H6c81RLPoGDhdgFE8lerEEHbXQDJQsVjYvC6EW3Fa9D6hgzZ8i1GKUrJWqI/IU3D4qvjFMn4c1oLBMtCoFgJz0177phMHS9eb1tQ7wBkbpExUA8dLC+tNyMCd0GgDCrKq6uHmreQoIkWOVqdcFJsFpvEFJouxuDLyjOyPCPAPmtBZRD1SrZ+Xduy14VwFy2upqQHe7v2kXaynHo0veCEe1FjY3qyXkpZg2Lils2dnPWkupx4a8Mro13HjgJW1yxpj86Qi/3UviKfpQAgom6aSoAM9zTetWOcWIpqNKQasIs+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X171VZBAQaoScqKvtnUX20PTy614Ya3a9TIBYn04IZ4QBC8X9KbZnWrmMWyeMxYPHx18jT9jQW0QlT41AoVyA2uPlZh9x1KyzWLc3kopK/tLfSZjvEbKDGbAyYVOEEahpx6ZXDuFqGPrmOtLcLso7Jft2SgNwIrkhnKWWT+Rekp7PVFnLpNvc3/pjUAr1jX5EW7ptpw8xy4Ec/dREpooMsX1lCf/acfsir14+PHPSb8eQpTNdvPC3jg1z3s90PxR0kErsg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5829d814-0c29-4586-fb3c-08dd2b3664be X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:37.6235 (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: p5GzaetZqb3/KOURBXTk2bv3mRd/yuxawYuMZFgr0yQ6X7yUi3dMgxb0+fVzkTFWcSTFozXpIsCSUX95Bz4x9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8164 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: qYMn3A6Q_QpLIbtC6yOte6KoQo4ackOa X-Proofpoint-ORIG-GUID: qYMn3A6Q_QpLIbtC6yOte6KoQo4ackOa 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 Thu Jan 2 14:04:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924479 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 591231B4140; Thu, 2 Jan 2025 14:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826699; cv=fail; b=VI23ojv8tK4D6A149ZBJCvVHenF0XT0VEf1sF/u2CG7NOtaRqB5DUrL3AiMLiE2exPAAA8HRUkRxLB3MK+UiCYbbgZD98PXyCF1+1ocofdK9cWTbSFHMNIgE0Hv2hU3lD81U6t4TiFNVTC0xL9UqYjiAPOeXTVJa1LS5gBTDAy0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826699; c=relaxed/simple; bh=kWgiwjQoCWVCg4ulv6EuuV+2onieZIrHz2ifgwcsd9c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ajT0hfiS/vX96PYtTdK1X89RVTsAHMRHyoiHv3S62MmPsQ0+fZtEQLBzuR8TVA3Ie+Isp+JILw6jWwbPJ6GsULB4wESUY9FUcn6noimbB9jihUf43L6zIli9e0SL2zh0snQswSC+YJQ6VDVdk2tQVRQ+0am2dkgBkMJqa9iOBe4= 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=hxpghGNX; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=mRjnV7x5; 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="hxpghGNX"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="mRjnV7x5" 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 502DtrfU018980; Thu, 2 Jan 2025 14:04:46 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= hxpghGNX+BrMVby9r6dukWnnYR6ZWTWsmtFpT4J/SBWkBCwA9bxCR/tUA8x95xI6 Hp3C/scNTEorBgR4AHdSDvBjLX1vr0v8wuU8R9/brm9e0LW+z2G7RhjKNpoB4hSG RO9lOIfzWXOLRbdqKjPFQE5UCqLJbaaK2/lXir6X/QwCzPVMyjWHoukgZBGbJD+s 3LPi8tfvhuX7aO6s3Im5qVT7Nonnzoz0NpBl57gxFGonNxOyn0fTDBrnYSAj8IU+ WJPP8vkpm+LfWduDWjrTqEmeLzZgCumD7QLpBpo/BaaSTHmXWQ5UUp2+ZL/qfE7q 31KnVl0wItaJf16q1ZINcQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t88a5e39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 502CqmBM033469; Thu, 2 Jan 2025 14:04:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8bg1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KVaXaP0sxS5MzW1tT6Nfp/YblOL5AvUDy/Z/LqYh1W9XiUX+bo9zu12l0B0Mb21nwZPxD6uYen7zrIZnr7ZhFjBH2Pg/gppjuRFQP0m/W7XvbGU3GFg93mOhVgbwVtpYv9c+7rMdbJTZHpfoROE/BvY4H0pEa5eszplctB6iapQK8YjvZu/prfm1vcuf4MgcBOfi38o3gUiihBGDyh7IuxddEoNUroG68RHdXgsVDoKspSQb/NRHCgGj9/LjbaOt1PioDUg9eFM9VMA3Qzl/hW6Kb9fOyDrmdPAwDT5awDzZB2qo1X3SNCNvWpkjhgOoX3fbCxumUEPIXVYDstrM1g== 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=SlHUuBVJpYiwDetapkO2eDzaQ3EieIyWBq3YROnqzN8HPcNtDeT7EguDAvRn0AWklMDNG0GxRsAMuNY2JVrpTFW/KLPLJNbrkoy5GeiNEMEeazzJikwxoEmRwFsamjO8d72dxB3trFsU/AzClyjfl3RCwncjziblVYr3/9WWK8adKt1pSp6nB8PH+IfxeWRYseGD4JKPyHy9Eo0M2Wlv8S6vfDeK4XtrC9x6DsO5rmT0KVZUMKMr9AqJm4FibQzHmhln8FM50rENaQqagDoOgyEA7Tr6Xu68xm9mOpNXGrKyNLKEpDsLrkvCwvJV2YEtVLloYISxUhDrzCKP2pg4Sw== 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=mRjnV7x5978W0Eft+/3V1tqBeiYkw3U3RJRWBGkEmGT+O9ix8kr8Do3Q206cmj/HGwFjNuJFYinz50eyhXOyBq/Tfdc7gzYkiSAu78JoeuJaK/2jP/q5IoM4h8Umyh3xRasdBlXJuIM4egLvxyr36NoS0Tb5pCfxMrXp926FB0I= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA3PR10MB8164.namprd10.prod.outlook.com (2603:10b6:208:514::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 14:04:39 +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.8314.012; Thu, 2 Jan 2025 14:04:38 +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 v3 3/7] iomap: Lift blocksize restriction on atomic writes Date: Thu, 2 Jan 2025 14:04:07 +0000 Message-Id: <20250102140411.14617-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR11CA0024.namprd11.prod.outlook.com (2603:10b6:208:23b::29) 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_|IA3PR10MB8164:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a183e3b-df1b-4cbf-b57e-08dd2b366574 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: Ptjqqd5tw8CVgqH40NcevktjxHcwkcktjkmXImDHcGTZ4mULI+5p2rB6Wcihb/Sllz4eOpIIWk1K1dArqDNx5r3GmkGEhxJLTWlx1a3239ebcoCMQ9oRRVk2fDvOxmHuCnqRwnuK7JK6evBjKZTv645c/zyx2XYoR8/nFBb/4EbTeAMyR8RHhIJymDm04fHPusGHBlzaSWNRr1T0bsiiyv4QbNGfVqSTJfBsSvpRPDT/19jNNquzZnVeFT/1oAeXfGVJVI5YiNiy3xaZqhL0au21YPwEmOymtrmGCVxiyZlIl0bgWoD64De4gKb7JxD4vREHmsPqG2A8/XHGE4vTV8qFo6jnZY5GVMFeifyo7MobD6YBUEO1rtd8Fi1WMeY79FL6L0ySt8hZTbrhVRGwetoz5PCv0Lgc8NjdOUw9Uei8Wim3M76LWbcNSCYIC3GCn84D1Waz0qAdSazn8jWBV/e34F8+XLLE0hfGNRfLgxWOFOIcvrm2mzQOfr2dVGK317wdB1o4pexGs0p/QX3A6UT6O4OxX8+TaUMKCrFcvCMTIKQBRbMXvnoaxzX4i8/QqBBJURx2d8VqBxdxMiYVvLELqauVGUSk2lcL3tohL4gQSx+sNBX1hl2IkpDDzYhRVrWaCz2zf8HNzEzSQWWQhi7JSz7ngG5r57o0J90o/V3LTKx4mOxFGDfU4oogTWaoMT/5t576cHLlOBacp3ohlYBqmHtYrv1sqsREmXcZ3WNT7wxdYO4mY1d4ra5hqt15s2dZboWGAa/2C2wPLJP2UUqe8vekUCOi1QeTvFxPzqfUeecpUO++LRDlEXesdAgz7sbx78LXI1gpbtXy3iiM8h9YeUG1RRN3glfVetuzvVS7yfedO3Mb4obt458ZvjI4tgbzBrk21e5BZE0kNdJ0uJUQc6AP9Dsw7dTJKDli9aaIAVa/iDmA/L2BcF4S3f9wfR0q+JQldBV1gjmElkPKQEfgNIXgbAXJwn10mUy1+FonHBCb1NTGq1QV50w6obyooynTVpK/4mNDPC6P49V1sOtib38so+p1ewQ8ZBv8latzhj+pISTr36+rM0XIJWpE+r4b0ZRgThJXZWl0zp1Js0j4VaXpo5LF63aKGNRuLtBkyT5UdM4iLMrp6DIFyxvwEHMRfEPTj6qEReJcNX6jngPuJSCPthnZbZUZkppTyBwHFh8By5ipeJn69ef5Z9IG4mcsJDfo/Ldqo4/Q85Cge7yiu32N2oDNDM0aHqoMg3WRVq2/CVf9jzp+8LpPiGl0IHjjtw05IS2mDoZtKmEEY0cfzSsagczV42Oo4O3RWYAmh7mcHkH+G7pmhtEAP/y558Vuwi01gAjpm7DGVRXfpWZZzTRGA5P/dWJXmZcp7uArCdpdPGzpRQW1OLEhBiv4 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: 2q5ZgBJEoX79vjqvZy3UWi9+gnkIr6SaLV5uyjZ6siiyMH/M0yJUnu+wFpDNpt6y3uJ5FeLoFzr/Rn0ig8s16q6CiUWoemuIvMKi1F+K1Mz+q4SiYHg8XaYR0JPdlemtjglv7FGKZZgciXVs1ywvb7sV8kveXVhQrRxToUB3cqGEoKoC8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ange-CrossTenant-Network-Message-Id: 6a183e3b-df1b-4cbf-b57e-08dd2b366574 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:38.8171 (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: FCcwQ5ZvFXFuo5lwnzj2fwa1nQgEbJfhiGMtHVkQBbXnzvN3EssM7ebm2cSLz2uIclMNMy/7dPKMeMR45qbu/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8164 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: fti-B7houOccjxpx9_VMsNrCZ_MjE_nY X-Proofpoint-ORIG-GUID: fti-B7houOccjxpx9_VMsNrCZ_MjE_nY 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 Thu Jan 2 14:04:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924480 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 CA2C219F40B; Thu, 2 Jan 2025 14:04:58 +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=1735826700; cv=fail; b=SKmQMI8GfBNczKB0GZpUEf/wfjwJymUYUaTnDeFKyjwAMO9H5XBC3uLS+ZT/6i/bWICg1qADJRdAfzI0Q6B1a6uoUnN/9JdwzVM7+nMFa2nAcDHu4KEVi++5NB4RepryJ+2UTiYfGJojR+6Qt87HVWGvreQa9YHIiiASolZFA6A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826700; c=relaxed/simple; bh=m1S1732lOVZz6DZKQChS7imby3DhgO8lHrA190ll1po=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=AFumijGh7XpaChMQ6FZYEJJdqu90gI2nCYR0iXEB2WlDqLqygvITpKoebikqou3FEyThnXeqAIF9OvbXRJ8UskSIXAQcoLlqYK3Zq3/LolKobJTE+a43B1mTpPnwFWt5fIv0hhkyw6hjyAhaPN9K0ROvbuZaYfYJdRWdnpooeyI= 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=Ji+TTqwO; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bhD9miDt; 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="Ji+TTqwO"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bhD9miDt" 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 502Dtr57018940; Thu, 2 Jan 2025 14:04: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=AbnVAj7zIP9hPrQ+PyTnlambmPbzIJJkODeP3dbjYN8=; b= Ji+TTqwO4nvbaxPbEeHuktGYNNGcTW4K0NI+7Pq4WCvbIGfLSEJPzXjgN+gMyY+8 DkbcI6gIk4wb0he0lhGIFvpER0mOLVilC/cwgZuDIPiLBT3A9ORd9DMX1NNNzH7m J84Qyhh3qO2xvN2ntDbYcx8sO0hxEbRjC6bVFQfluxc2hQSpvzVmSuC8Lx6APlsR 47eL4zFre/t5009jZR/dEa4+Bkpa4yGzaAeTbcipXjIWEB7TNwUo9PBhnquqFJZv tm9Co974GgVtqBZqhO+BoHGNi29JbCy7M2GKZLnivZsNzw5FEIMYA++fvuJoa5z4 gbsPCtM6I5wI/oqSdztQbA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t88a5e3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 502CqmBN033469; Thu, 2 Jan 2025 14:04:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8bg1h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uP+5/W9xwHrCPgDAoG1jQuAWmeba3pBhXap66cvSe9TOB46HckuC4CDGtHtSyhLZqFiQ/R08HnoXSJDpf+Rfv7TFpLXzlsiFz+GZBL4QmVLo1W3AUZ9nd0I5zjWTFwXcJSTJWd/HJc9DD/TY8ezKMRCZa1BYA1zdEGwRv/V9m7rJdWZC33bxTVZiSR7QTwfPe7B/R6LfMQHkncFdcc2i8sGsIE3GH6ScpP3dretkS7EJSnnL3OPNm94fAaMp4xI7D62N4OCq8hN0cinjP6ZBJzgUEQVW0rAteTIJ0+vxSvSEeOGT9ek0AiaaTXrY9vUpfX4cvEs/60S19AQZYdItGA== 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=AbnVAj7zIP9hPrQ+PyTnlambmPbzIJJkODeP3dbjYN8=; b=cfcg3oYVLlR4u9OTAXok4Ty8n9WQfzJGTaRSbG7Tl4twhvJldCQjMxSwIV1PMyHtWQNOgM63qxZot89L2ffKHErHGtHfj2qE0zcuea8qRf6zPCcMGiaf2Q2/cS3tsdtfjFZsV3c+90ewS6xJCFXapQecnFCoBuzpyNpo0S4F9AjX7YgM8ruqas/rX3iPmXRn/GUoGuABW8IcHvZvv/hWVE/ky471t0H7lx2fWv9u2LHmzTtI3Yyl5soerChuKfhZeYbroe7GfYveMmxbmYtV6KUqcops4Hu3e9W3vtaHcwuN1weOJGx7nwNuyKQKTMpgTnv25sFVwiJhkfvMA/tZ7g== 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=AbnVAj7zIP9hPrQ+PyTnlambmPbzIJJkODeP3dbjYN8=; b=bhD9miDtylR62vBtASfV0nokJX+s2kLh27jkQ71P7Falm+MxxfAuts0I7MNb1SFRSrD7H8DPSCRUTFxsFbLh1Km3ESYV/O+lg5X/RqCkidg6bJ2J8TnpCW04/BGgxm4hoypT/S1CsbaOw09Z1mbjvY9zfkJAMl/JApryX3Z5MhA= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA3PR10MB8164.namprd10.prod.outlook.com (2603:10b6:208:514::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 14:04:40 +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.8314.012; Thu, 2 Jan 2025 14:04:40 +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 v3 4/7] xfs: Add extent zeroing support for atomic writes Date: Thu, 2 Jan 2025 14:04:08 +0000 Message-Id: <20250102140411.14617-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1P221CA0025.NAMP221.PROD.OUTLOOK.COM (2603:10b6:208:2c5::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_|IA3PR10MB8164:EE_ X-MS-Office365-Filtering-Correlation-Id: 0607ffa0-6207-4980-1635-08dd2b36664f 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: wXKDHZpZon8MStx3OzIhXH8RDbu+pHYm11SW8REXVLrM4fiLo9p0MBv8xBYtiu9GJORmuS2RLbrE9gKhwqPFIA7BHeb/5YyAE4RMHjQcSGwaWuY8COEgCH4KXXeNO2dG4A/UMiq7d9y1amMjt/fUb8B1+JKnJWeXIXjfALC7SiSy9R1hg+Zy/j7Vt3zLK8knuTAEtfailnL6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4lPf8lmTjKLJl2pRNYB3/7MdirKPz59729zeZH9+PntnpDtrZ0gaTNlciIjpLXnAIoyJTwBeEYFCkDqJQiwXKDTGz6PaNfHUay0Dau0FYR2jvVPkBp 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: wCF81YoCfd2kKOA2GgwxvjBopKb59Uh8jd8niz7TCUjAASN6XrqzYgjMbIVEnkVfzsZlb0iZBHPWJSUx7pIfNoJjihf8SzK+2KxDKcKItqR8ZS2rgFMLwLydu7VfWxl812TXAjVrA6sqzbJz1ZS9wnQTcNkG0zPMs6d+rPOVzMu5T7J5S2NSd/egxv5pSZTu/bYn+8ipFRFUNptEs5T/S2GuhzUI6SJdSdvCiJ+DWMloHmQDtUOGSeiX6MKDTpzcbP6Bn0GtbessEw/fSMUop0NqYiMWs5uFwXbs1UObZ1J3+4riqVqTzA6nmfkZ2LmNWzmjdMAgxSFgSDXJ4A8Gse6HjcqaSyBv8jl4p18KSeFvB0QO6LvOWy2ty2Ol0HM++6lKJZRvEAXcMJD55GN3p16uZBJtxMWS4Zg9oVGb9t/XAEzzIOuXfRl3yrqDOr3BPhE3Ht5IzmzSn5JQDD8HQMFVUt1kli+bP1IUeCBgeliON4z5JvX0ip5xgpp1kku38oODEG2qwUgW2ClqXAGSxqdPc31jJ93SEKlz20sQS4/ar19WeN+GQQ44yw0YEvvIuXeDvenqn8VTjGcCfyPZEKq85v2uPK350eoiYmzovA0/H3yjeM88SAA/HgUShwuoKbAmnHTL+7Y1Tj5rQ49SBS+uGrRCVsQDraxPlBEQN8SzELn1Q0qakYs278TLPAYmD87OTxKsVMj70aKChZF4q+SJIGyMySee9IIAWhaWbuPs8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/HNmprz+T3mWg6X3EPozPnRhaFMuFt0EkKw4+Nwy/6La6B7I1N7pi2t963KJgUqZ8qm9VL+TrbhIpz5YaS26k82PM2onvAyweywnc6chg2MGmQjsrHgCr4UupJR54JJAyPNRSR3hjrC1vcvKYSRchroXitvmXhgZOQ3MKJfLdvwQWWH7YNdGFVqf9tGHuU9QX++tyfaLB4jSTqvCwX62IfzCImAQLi45sksj95nrM1YqY+FlwvdmRKMd4/KC34Y4VUxSO7Yv4fwyOUpmCIBJaslsHS2KE16avaiApwnnwOsQbvHsliWrTny9dMXca6lYfxY2VJvomssGctz4PKV12iJJhSZUzxFxyKDLtdzf/xhuy6wzOwuIFI4/653fCYKMldz2cOsu5/7979ScljMw6gnx5np57RNhBoaSC9eO1+libbd63QxHHd2F5UaaFwDYuUlLO9uajXtNismnpdpWEusRKykVJckFkbE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0607ffa0-6207-4980-1635-08dd2b36664f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:40.2364 (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: TlcFCECXWaRGClC9UYnJpNvqvBeAOFImG12Zf42xmdkSib5BI+klH/+X97lLrp+DaMrXFmDUzQnGECNNKeDbOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8164 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: _6j7UDFficM33KmuSiyEAPLOTX8plNgK X-Proofpoint-ORIG-GUID: _6j7UDFficM33KmuSiyEAPLOTX8plNgK 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. However keep the same behaviour for writing a single block, i.e. we don't need to pre-zero. Signed-off-by: John Garry --- fs/xfs/xfs_file.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9a435b1ff264..2c810f75dbbd 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,63 @@ 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; + unsigned int dio_flags; + ssize_t ret; + + /* + * Zero unwritten only for writing multiple blocks. Leverage + * IOMAP_DIO_OVERWRITE_ONLY detecting when zeroing is required, as + * it ensures that a single written mapping is provided. + */ + if (iov_iter_count(from) > ip->i_mount->m_sb.sb_blocksize) + dio_flags = IOMAP_DIO_OVERWRITE_ONLY; + else + dio_flags = 0; + +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, dio_flags, 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 +817,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 Thu Jan 2 14:04:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924478 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 A613B1B395D; Thu, 2 Jan 2025 14:04:55 +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=1735826697; cv=fail; b=aBu0j7okdD8DbXdaVBhRV7MSrDA6x18lz5V4k/nBFlTR5RdK7oQw2b5LmtBugCgOl38gKgOeY4BwyKseEL5/bJjF0vB3D32krMTZDSFtjWRmEoKMIFgIa9uiPp0iHnNj76juBHvI8HKsFyR2S8p13NApv1671galSi0EVzAzJwg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826697; c=relaxed/simple; bh=H1o8e8YnNVViXxG+sQw9cSh9KhxfRtE1hzn4SZSKGv0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nJPEpkvRnfK1kX38vEUIfaiylC04zS1LUM/McXL593UYoSJLZRhFLJD6fd5o3pO8VH+WcNcbNp03hzcPlN2cZmJ1m/jNUBTxR2Jjgorzb6vQ7UHrqPfM60KILLmYaGQoyVRU4ycH/NhbrCyrNrgjrq0CzhA+KZsEFFe7wjOan90= 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=lWDnLmwG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=BcruxG1V; 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="lWDnLmwG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="BcruxG1V" 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 502DtpJd014818; Thu, 2 Jan 2025 14:04:48 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=eVzjfwpjouHHWfThZXSXLNo1RzZ3SFT281E31EQPR3k=; b= lWDnLmwGTlUo4VtVVvkue+k1yhRmGzS5jGBp9q7zYsTd4FPG1BzMXuADd35SOC9y tXkF/R8SBWQKJAe5NndVVGVBpnzFnTiHmatJoMBgdYUSrxb/FIPVnxNEyUylJkUn OLezIqT/TavVVn9O5F6fHqtaBy8YTUE0pHXC6v3pOX/n1LvIQfLhgx1TYhFH3WDl IcDQVwETW/qWvHpzyrStP1SnFiLdvzkuTUdrlp4nYHE4ezLlVqDR43N+OILZNVVd VY8s8iDbVH2HN7HLgE8UnwPgRCWamGb5woTvh5Mh569lpReZo+uNb+F5vDN+xadv WO7znsMVxx3yP5giD/YI/A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t9vt5bvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:48 +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 502CoJI7009189; Thu, 2 Jan 2025 14:04:47 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8tsax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bLM2qes5knB+1xf/+lpR6rhdUoyYiJvbwhfv43PGfbD5m9k8j++ef5GkzupQAmQ+Ii/upYIkK3VQZIlaN6KR3Uaule7YFTwqMsH1PAfaQoLtdY8i020u2gX3gZ967s0FTJyXISI7mxG+cEK6R3x6MIFUc8Me+fp+Ny3Q0INiUEy+cxPPWagPZZTUFyvi+1rG3U30bgvXaGjx6FdSDQLg6TrfXqQcolVzFFhWY0FvyxJ73D7typb2NJgfTXjmFv4bEKopvCkYJWZdvPHiax4f4yAwe2LBwNQ0LKW3wOu/KuOCSqRjpHpo54t1uwmE605Ox0FFA9pe24ry70P1i94OjA== 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=eVzjfwpjouHHWfThZXSXLNo1RzZ3SFT281E31EQPR3k=; b=CsCwc6mh8psFREm1sKoOidXZDpti8pDy2qM7eEILpEboVvUHukXCeWIkDRefgSJy2Z+iGvit22J9L2jrJm2hk7qZ8djhaXXQt7Ydk4yxtYS68yWiRrS2dkvyXbFxodWxd12SbeCUCUtYm7naUp+S9UlMmNn9zV3SivEIDvS0dL1TAA+E2bc7TUpFxsHMYmmjhznbW/A/91MSxcpQR9WtxUzZxFixCdN8qgpNPc1MVyDeK56E9mNjcPiWAe5Lyyabb492QFRj+xRqdlT3LiZBdQNriiIyCpxefUE4NmulySCCXkOK+jmglz05W7jRo4CW051WQLaxyr+qqzaLOrk08A== 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=eVzjfwpjouHHWfThZXSXLNo1RzZ3SFT281E31EQPR3k=; b=BcruxG1VlU0rhh1Unf5u3ia3myyK0qdEmdILcwKOV+RoaJh2y7r1qKE6u8yAO+EjuwQ5bi8/oKcucrDFTaUVzs/TItLAxwx7ohNwQc+V6oildEGnvUTfBzpk7XgxssAm1C7qGvowM/dZTXCKvD7F3B92yJAscGAKZxPzZp5mUVg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by IA3PR10MB8164.namprd10.prod.outlook.com (2603:10b6:208:514::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Thu, 2 Jan 2025 14:04:41 +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.8314.012; Thu, 2 Jan 2025 14:04:41 +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 v3 5/7] xfs: Switch atomic write size check in xfs_file_write_iter() Date: Thu, 2 Jan 2025 14:04:09 +0000 Message-Id: <20250102140411.14617-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN0P222CA0020.NAMP222.PROD.OUTLOOK.COM (2603:10b6:208:531::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|IA3PR10MB8164:EE_ X-MS-Office365-Filtering-Correlation-Id: f21bdaba-c56c-46e7-139c-08dd2b366716 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: t2S/Ml0JrWLAo4JYXpEv/eRIeG7A0KwDkCdplqyMfIk7eZ8Jx1Ba+RXvpoTH+XLQcCWbHh7/SLo2aHTItoqGmSCUixhvNOB+21yxWjXACzkd9Di3rwkJ7/rAs6kDBdgrrsF21btFmHYLGIkwebqvM41qlh1v7aiDA5zZ0XmAU5N9I9ZjtInS+iZQk4U60b97s2qcaprv/qz+omi/BjBSd1UMbwyZZsUDjO2LG9waHgW53VTPFQ2A01gepWzRVoix1j3QfH7OXjJlQYGOBptZwZPYekfYp4sLjrAuB+dj2rd3s0G49q+DFH+RgxCJzXgIHIXqFuemKA4m88hbN9zKPqIMhxQNUwyiAgqX08TQbIfHNeXM8IY5K007rmlONDKzC+gugBsvQaUnuUjRVQvkiZNnT2pZHc7QWwtU967lfrOJCzI3jdjcrSrWXXmKK8E0DWY0f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:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ofnVEC+lwdn4FLFrcZv8FKA9ONq7hVBpAofbYMes2yaEFkq1pW9ROv0Qh5NMu4Br4QitZXaMAYbIrWdy3AmQ8TAS4XLVfIvh3BcU2P7JYU52QCSJowtcO2eYsolTHzXReoNoj2NVQMS1cjB+97p00ihWz25/c1JUrwyh/Sus4UTTGhtY/TYwWxaXoZ9gTG8LV2EjGPkN4SoxlAG92G+eVo6ZnqYw2znvesm9e7iyh71XLXg0x/nRfMySpuPvYxcWkuofRKG9LhdjMft9Kig4U/K+sCvi18Th/p0/XlJXmVHWAjnCdnrMGgpmw2YxIM/4q5aDhlbkvXFF7qq/woEcjcnP05SExJA65bXQKWlG3l73ngUDmFMm6DcitxQcpvnq91pHCwix4zD/5tU2Mo5fe0DrVmih+8JXC4FB/E9AD0vpB+DXdmjb3/kU1VVWslxjhsH3VTISX2JMYfur9/MAnKfP1J0EmarHAl60e6trk2QgX3srXlogGymuirb/WKpw5OZAi+ww0DSKFf+qoutTXoWBuZQIiEXNdNBPEi4V/+th5bHEqTa6LYhgMaKm/38mKR5mBjSK2fLjbfcl7dne95jO6TFwVbRaXVv+HWzWoNBHRzJxMbT7HMFk0N4NvM2DdDhOxbxIPZAgR2Jk+46DjC/x7C2Mi6u416FmTTB/gerp6qQgke431SBF0NSDBruB1kduJ062b+oAihtqqkrvdebTB+bNehPsyMtzGv9ZfUVHNqLFT9KIzV2GeF4I1rRBALRCFo44Q6WV84COrXDoaOZT+stExaOQ41x10alResNYDcGq+iAnySAA3bxdcmHE1ajjyMTOgBH7IB9D5Ha7hywiN+io3ImoqgGjUlC7lEZDB9X4Oxkqcpnu4+U0cmfHvE5R1PgK6T1cEgWyiQ9+exepv3erKvmpT3Dj7RRxwkKI0mHFMWXvS5qtrPU3ocf/PvRmCcmEjFcbGmDM8pN2cDydkiGBQXk16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7sfFWtQSyaVlEWFYa+Fxvm58CBDpa4/YY2gaOnZ49Ib3KcNFDk2cocroICi7wbjQg6AoCJh/srAPsgypafBaflsoCgm082FcR2cVGjBwREqhso7yXXX7EkOVvROaHwelpBMS7/x2XFXOT6qNOVo3GiNyFiGgZ/VX2jiFfTM+Q3DFnNe0fXCItBLgU4A5+M9uJ18n/G1XckVjxO2mumm2dXVBa95DfH9fK8AhcZAY7KqBlUfmS8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f21bdaba-c56c-46e7-139c-08dd2b366716 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:41.5682 (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: 9Mfz6pjwyx/8QtkdiFAvNJ40gQFagLmXltiZdl3Ne+MbmddGugxfNESskRjUx0s30YwU72fQwUrZl19EM6QmfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR10MB8164 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: EaPrGF7yKnf_y66899c3gYk3Cor3cvv8 X-Proofpoint-ORIG-GUID: EaPrGF7yKnf_y66899c3gYk3Cor3cvv8 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 2c810f75dbbd..68c22c0ab235 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -949,14 +949,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 Thu Jan 2 14:04:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924481 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 15BA2191F60; Thu, 2 Jan 2025 14:04:59 +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=1735826701; cv=fail; b=bL/hGwjxumDb35H4Dz4pX/ezXvhylPAGrskA5KOocqaaGScoyeZdTa01SjgI0xPsDyR4nIqpDjUX0Cfjx5kAOVj0pQd1w66CtuRq58Clj7V8bXJBxa+90uqOSXuojLULjurkMvxCuhWho6Y0/PSzzf8PsTNW0uSd+J/61Jt6BXE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826701; c=relaxed/simple; bh=MJ9t12TgjZvqcrHrVZ1Imc56VXpyRVUEoM3BhtDOGrY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Uz82Zg29zfAtOh5ozFMVozuUNlTuViRjoi+tt79ixzs6cyLdanXpbAYS+Vxxu8zuzYRg+s7iwzZNsG0rK4EFpicMT0TjHiKXzLcCxTvBrLHFOD/bu6wtdNecz8F4K+P5UV6YDsdw1WoFGB2tkfHV/oiK9rN8BtejzkMVxaYzsJE= 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=hpH810wK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=HWKQxNLJ; 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="hpH810wK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="HWKQxNLJ" 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 502Dtv0P024654; Thu, 2 Jan 2025 14:04:49 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=eel+vuNBGT4aK4raL9Cbhn4x7jQbMj0b8vAB77caeRg=; b= hpH810wKj9cbFgSMSyjS6fXo4nIDVBuBKH9Pavn8jf93mxjYxLEwPcanD8gyX2uX 9kjkdxBEn4f1ELgxUhIO7IKG0dBFueYjDsUMAG+th0A4CZuSORIThRpBszZs7fNw nyd+kXb+GF9jRkFvNxKC8wwSupbgMK1ZI7ZkECZXrrHYMF9Qfp4It7dtw97K6DuW wQaCneHfGa1bNI3FjXQGc2RP93avh2UosVKyUP6IcHcVFNiLlMEc3tuW9GQ7J0ZV JJpcaRUjixNLhoK5BLzcWJGTMSVEay0LMcGCmKN2LktEk47vqAsh59y6RfC0NQHN mI7eEkeXoVd/QkPDvjn2og== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43wrb889n2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:49 +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 502DZNhD009071; Thu, 2 Jan 2025 14:04:48 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8tsbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vsLoZwGHx5erFCqj5BDTbm+AQm7a9YL+68A/hHs+xJKfq7qGo19DNyiC17fnqzQBtwfavQht2Oq8bHUthhzjO6rZS6XEFsW/TxrSYGtJIKCClJ8fsjpWiaOp87ssys6Q1HgsK1EhAArqH5zDONvD1WjHJg8gu0S7ylMUVUg7RFwKuiwJdM9LdFYT55dhq9stdUFF3CExfF3k88aTaW4ZYqeuJqg+gzyqzbrUM8n6QkdGgKqXePuPFt9za582z/TQeEQx3h+747G9oeIalDaZTfG9TCNJwR8JTC1QFaCW9XiHOc5cGTI0ZezLMRGNahp5C5IQUPB1OKKiL/lre5rQEg== 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=eel+vuNBGT4aK4raL9Cbhn4x7jQbMj0b8vAB77caeRg=; b=qc87nw++zPiJxv1osYHDXV2EK0oNlg+0JGTmdl/eCyip27QQfrA/iHg2wAwxYjWZ+9YptIbCvu4W53VKWXUJPUxWmnOVkIgxYnzljdmgKpnyf++2Ys8IVZE4ObhihkdXiOnEOfg1B57pBE1hagMlAHqOr2exGTJXZOWkfzjH43mLEABgj2Sc6rHSSgIUE0xNI9AgkvzJWoG72SdFJPWDLfnK0kpn0hfdHzzRkDFgr9Ad9bgEn0KZuisQfR1ycB1azyS8oPAWpom6XZu+X8TCgFeYiNAoJezcCiy8ppSvKrJGkvloIGOaGf+mriBVF40yQtXXFFCpFYW29QfRjn5ZXw== 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=eel+vuNBGT4aK4raL9Cbhn4x7jQbMj0b8vAB77caeRg=; b=HWKQxNLJyMTiJgBbQTghRLU/7p0r4dZ4BGQmMch1axvAqTKdsgH8oZhmv44tcyCAE0PanAQfNlds+jqthgpHx0Fz7FGCRUsUit1cdCiO8C4M3LV0J3uHxC3dV0YFjIUelltP/71cC0TgAeMLS1P52e9qaLuGShpU//tOu/4X3Q4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DM6PR10MB4281.namprd10.prod.outlook.com (2603:10b6:5:216::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.14; Thu, 2 Jan 2025 14:04: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%4]) with mapi id 15.20.8314.012; Thu, 2 Jan 2025 14:04:42 +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 v3 6/7] xfs: Add RT atomic write unit max to xfs_mount Date: Thu, 2 Jan 2025 14:04:10 +0000 Message-Id: <20250102140411.14617-7-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR03CA0012.namprd03.prod.outlook.com (2603:10b6:208:23a::17) 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_|DM6PR10MB4281:EE_ X-MS-Office365-Filtering-Correlation-Id: e4b3d45e-9f6c-47eb-d6ab-08dd2b3667ea 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: wc99lgkhgNrKGhMWQaOFHQz+OUwdn7KzoO12TYnBFZiwhIp8edib+FE/CLlln3zJvSvt12TQ9WpNH2eY5vAk9DAJIVvnnT3nR9oTAvCj2CcUCQb998EsbS3/ff3pnKAfT1XYpM6hTkk4YXc6pUl9HlmZ6V+rU2eg2mrzfivOr+yss6wo0nJnuhmFjk0XMkYXJ9ZBehiKKwrov2pys/JmxruCFc8OnRZERDuXu+Jw68iW3pF1oEvbkPcfFdLJ6DSfu37ioOlZtFw9MfqAuaYBP0lCAskLNmY3sp9L5og6Uq3H+IolLbujhpwmPfJURwlnBn3RzYPC3wDgE5V6ofp/GgekoGsGl5khTm/HcJWq787W5f+IShXBy688JDaKHh5pGBB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6PR10MB4313.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: zQEeEd/azelVsLdqFGbSmniNXPsvz5j2K6H6+5OUlAnHCaxkL4SiEdfREpnFN0xyYqSgsLlu9DZd1zJaxyb2Q13W8qLMLT+Ag+OUgaiCNxKzadjzqA5DKlvHhw9PvGmJ9hf093Ebj1+9iqHLQIceIo/W5ZpqiAL090IOTICEOKVJ4KXY9qFjI2QMgOmA2FYuygzQNH67AOFzQObCO20e6D5uFuJ9kHJIS3q14CZWoyI6ZVpQ3eZflRjB4Hly3jnCZez0AKLEC7eXbMtFIk/6RKEnPoCWW0+vwmr952GiTnRB7F97GQQObKRwg5isZEWRSENUctgO8VgOfBsg2KmVea7oWRChVF7YK6yKjxmgrJ5Ew1cJFOU7urDRbueQhSq/6ybR+HCpgQnyZ9etq3VSMHjG098aYtCaHjsYu4Bmznub01zMVNTfZ3CQkabVnPBMY0p40B2VMITX8Wsdb8uf56hG8lK3NPysquQNC3Kke6WFAuHF/aRZYf+yXu/qtvJ9z9Q0RK/F/J8IA3atwb6+MAeq0B48vLO38jbJHJteCTLrouP3KX2jm7JuALc67S976eGZE3IACjOTtf6Yt805DUc5rDxodO1n/ik8femyI9UM17Ud0izoSAqYYIObkSbwdeCLwoEYxwGAW9wuBn+R4qQ1pZMUWydPBVlTTbojAaOWVYyZkET7/4JYTH3120hxMFA7eSIYAPotA2UBtoJanXdX4bY+QFd/6lnre9+FDpL/yLcEnASydN8dfp0wdQESwbvuqX3otS33sc2JYLgugpKyPCNKJQgAUwa3X5gdmzrKHK0Liw6K/Vw8TAI8/37S5EdTpQA2et8vDg1P+mhNalLdXK4oqYI2Ne+UUqWpFWnI8gOzGVlbLk898hZ1WFAuSUQ8CbbPGspsNBzt9jXi2x55Gd9yNyUs78eJKon6ESTbSOTiy27voLKwjl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vq1LliJ96xhY8h5ZJmUOGSlra4MA9/vjzVlUAL6pY6G9omme+9fvrD9bO/cazwm41PAZx1kuYkla6GOVngg+FebnPMpWNFae1Z7iL7CPfP+YGuPO8PJJ+An8WCq5iKyMR2/RvU220c1ivu25zHWDytBsVzZcA9RgHO5Uj3k4R4UcGyu5h+/ZGiFlRBTLBUcy56LmgGQmvrI59kFeAqziMHiDOL5y6oACsAZmf0d4ytxqNR2a12usEmypVfmyHqeNTNclDp+YdW8/IXn+7ljRg2Eljo3ajVXgbUk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4b3d45e-9f6c-47eb-d6ab-08dd2b3667ea X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:42.9393 (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: IV26QjyOjQ94pYkPN9Rmm4YIok7SndiqJZlVSot3fbE0VRPVjOkW48ax5DVF1QVxMnjDpIW0wj2SpblPfA3Kig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4281 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: 4HZ2QW9U1iVLrf_BVagBqgyPMXkHeCE6 X-Proofpoint-ORIG-GUID: 4HZ2QW9U1iVLrf_BVagBqgyPMXkHeCE6 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 is not necessarily 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 | 23 +++++++++++++++++++++++ fs/xfs/xfs_rtalloc.h | 4 ++++ 4 files changed, 31 insertions(+) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 3b5623611eba..6381060df901 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" @@ -1149,6 +1150,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..f2f1d2c667cc 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 */ + xfs_extlen_t 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 fcfa6e0eb3ad..e3093f3c7670 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -735,6 +735,28 @@ xfs_rtginode_ensure( return xfs_rtginode_create(rtg, type, true); } +void +xfs_rt_awu_update( + struct xfs_mount *mp) +{ + xfs_agblock_t rsize = mp->m_sb.sb_rextsize; + xfs_extlen_t 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 = 1; + 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 +991,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 Thu Jan 2 14:04:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13924482 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 BDB9D1AF0DC; Thu, 2 Jan 2025 14:05:05 +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=1735826707; cv=fail; b=N2WHagnmYfnSAkjK9q2A1ZZ5bFfkNciGrMnIJAf9aMiHE9++txxzTPhRyY5bofezDy2BPG9UBwzRYhhwkw2QyEGvLDrFFjj12FrDV2EeLX6sWLnq7b3HtlogwxhHn2L3Vi+/H/XZPFoym09FOeagnHTk7GjEmtWfoA0tOBHiPx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735826707; c=relaxed/simple; bh=/gTgsd8C2wDSUJdPQ874dr7U+M5a6DFpeTG24/YSL8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=L72E9MLFo3IXs3ZWZTan1V4DOEBdffL0CPRcgzCNY9TBMwgZ7FS8l03LLN3DDe59cGqKzeble5YTR+0Hv0wLC8UA25XT+0p02e7KJhU2XHOgEcJvgiINS3yOGOffuymsz+dHzLF4DIceVH1Z4HTk+VJ2aOaX8Sjw7Nqt7e/d99s= 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=OfcV3ql+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=fTn/S4Ed; 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="OfcV3ql+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="fTn/S4Ed" 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 502DtnuB002758; Thu, 2 Jan 2025 14:04:52 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=gJQxMszfY7yZq4B+/BFIpVNyIDT1uwjImi+sP+UqPPE=; b= OfcV3ql+Vy06Rfb7VWf/sYMafqCtputJfzIO9Q5LBvopkAsytnGkkZAljbjRMclc C/u/GyMvqxwo3dDiBu86VG3Oiuwybx7vONRaReoQkj9Z4uzVmQs7FrqoCrPw7p0d oXeLGrh+sg2phDm3GdkzZbG/JvWIdZxhf5Wk9mWOQM4Oq5E5jhbwPRYrE5HIKcm8 I7Uajp320mEMy+4R3oYybG80hnfMT8PXvWvJlEfSYaAwq8gKzfZ+L/E2/S5BeRix 4MztcECxUvQvZXg4YxN6tN21xw4Bv9CDVnPYGsZ6ud/Pmwn4P9WIccV0mv2yvLYw 62RuxM38CHo7zxO7r3gEdQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t8xs5cy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04: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 502CubXO009245; Thu, 2 Jan 2025 14:04:50 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s8tscw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Jan 2025 14:04:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hHL0Dvzn6NIV1jDTTVsB22sHO46Kp9cfnNuYZQ+lVHPRA1yRP5cQFq4KIO0PYuFRR4YsoC/WoodmRQjb0D0iTpnsWfanEsNpmtif9cX4oLJ5kRx+e1b4Ix56oWc9nhYgfQJV1MDazgtPXoZ3ozAnWPr5dADc0UWDoIJl1IHWTpNV3e8SyWKryNqay1ef1hio0in5ii/B8f8k5XEmKGMnBsXus5lzVjAHl7z+vfPN0QCBIo0EUqQwoPkpCtjQ/JCzWw9/Z1xgz4vmlwvudUmEV95btjZGtkvv+OmKk65lWkFzo4DFQdJsxdymhto34PGDP3xDfTc3hlSB8IwFdTy0cA== 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=gJQxMszfY7yZq4B+/BFIpVNyIDT1uwjImi+sP+UqPPE=; b=Ach7jJVWOUtH9+4Hi5ABeclnS/sadzIKMmQ/euaOZwsWhPNMhT8zkSMvv8J3X4WUyIyO98Ah58ie1RiPNKPUUmlFYRcscwiSZIsHNVqJpk6GXSWFclADN1ePFdsp8wZMXGc4CflfYz3S7w4Nk3rfRmvAZWnNQpXu+Q9vWTnWtZNY9VW7EtQCDVtyTAmU2XnnLvo9dYR/T3mTShiEOsZPLMOmXNdHt4P0tBRY7pUzfU3GAlOJ8Z3n/63+s841kbnH9wOXLMkosHJ9c3ZBOH68/HoF8gnXL3yPIC4mouEpQJcCdvF3Ol7Y6LViT/F6LraSc9lWEJEoCjTHK87h6UrA3A== 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=gJQxMszfY7yZq4B+/BFIpVNyIDT1uwjImi+sP+UqPPE=; b=fTn/S4EdZsu9CbiioWXpvzXscFk+RkWtXLM/TLqDztFBkesC/waV3BSX0zEGHX/3aCnwaOF/VRZZ2G7f3Lsz1wNbHx/x//iapybMjjD1zjukcv0A12g6+J7xlzsyAoGKeS8acN1XmiC6+4Ijg+Q4liKKBnTTUixU4u+QHxqta0w= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DM6PR10MB4281.namprd10.prod.outlook.com (2603:10b6:5:216::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.14; Thu, 2 Jan 2025 14:04:44 +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.8314.012; Thu, 2 Jan 2025 14:04:44 +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 v3 7/7] xfs: Update xfs_get_atomic_write_attr() for large atomic writes Date: Thu, 2 Jan 2025 14:04:11 +0000 Message-Id: <20250102140411.14617-8-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20250102140411.14617-1-john.g.garry@oracle.com> References: <20250102140411.14617-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR03CA0022.namprd03.prod.outlook.com (2603:10b6:208:23a::27) 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_|DM6PR10MB4281:EE_ X-MS-Office365-Filtering-Correlation-Id: 91bdaa33-7ad4-4c90-b70b-08dd2b3668a2 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: xoY6PMefVXfsWEPlN7RRD2kndijiGrmUc/E+x6ZcXvXgk1HRjyFmL3IVY4mNsiA7N2mY/vtXGio/0O4M2HLG89SSKzDSzL/kRcLyimpyEsB0c66jICCpr38fgd+fTIAtWAA9yhs317R5DT6ypt2QqxV8REMnX4fllhl/OC5mQzkcpcsq2hy8gdie2Xjcs5RjEfKxskakCnAHWov91LwKgu8seOE2dqYgJnAu2wYZAR7GS9D6aTPH/z0QepJE1qGGa7YUsbPuTNCee/rcuZoAr6KfY9OqY3PjcTXuGRt4AnRfQOHzUGk9g6V8qFPPL10H8eimwYydSvXpwAoywi8/Usx2jF+J4PS6wE/Bnm4EXHC0rUYly8ejyMOFt3wj8gYDfhzqqICegQbt0kWmVn869a9E6/mvQ+c6Gdt9uBM6iviDC9osmvOwCSPXgmF1wL9eok1IbU/PLSBQsn9pG6iYRxtXf4t0SwNIWeuhCofEacio3h/ptOY3OQ3rGskk6FIrkg1KUrlpNJzTFalk5M/6EKJvKMyNnrCcOnwCUPIZWq6qDf0xkR9PgLf8rPiJuW6n42vI4eRJLXXn+TyRWq7UJDR8MT0TAQwf8gcCqvfmjdHPwNuS9n3gFg86TyEupBg2TglYAft4Gu1/B+6Ja3eRzaJV9VUiapShQoiIHV9cHSf79N8b3AyvY7oavAIwalEjajoKaaK6pfTVX2WCjv6SOITrC1m43DOGx6DnINGBJxZAFQAk3JLpcAF7P6Fct6Ma3zGndef8VRRgIy+ahusik2GAb8ryjp71rKfe2e/j4dS5IWTwNOSDsr5vQbNJzprxDUNg6yAKILRsiC9UOszlpeBiTbifef2rOXpWiIw2Lbn8mYAabeiWmCrW7fNh0DoajaYcORvP2PtpXpGbWwsKLnOS9fO5gNT2V1T3aiwZxzRurN0ERhDegWLAI4oVlSDll6Ew3Ao01eDYDcVITBnVQufw8BJ4o/tlkK1kRiIwQa25kBTxu+A9JRHAo5t09Fh+vMbQnA00QwZmpyG7FYPQin8QDrKmjR9ORLkg8ExnXwU6PmkU6SYiYZTzyNORvJwThnZgmNT+qBWKIUtakDD/JKpP6l9v7FsEgtZcdrXcblU1nBsa1xSdNxYFDWRwtKjnGmQKSdjL1ugn0uhHYdnwhIA0GMHGLhPwFBYDDaTPKDpRfsSdmcodz5TPUFL7oOjwuj/lHS54iIivJyM5ue1hyui1tPJgJ8E6951BsvWT7wu2ZYR/WSgPZyvaql9aacibAgYBgvjT6GjtmQnJ86j+IguxNJNDL7vL7ZffsW5x5Au7K5VK5+tvv2fNwqpaAabnWSzNwwpZqNFuGSVomuWdSGq7cU8chVkksA+CyYVKnvshjSnEeceV0/CWAVhwVwOL 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: hVlMjVeP/cks1VrIl1PeMWLw6yMRC5wtwHLmx463XogPy5Ti4jlfwv2A+T8+Ctx8A0GL15KJGMXU41goDwT4Q+mrU/j8JBaKzhKi1UIf4B6YbauSSwwhgKCkukIBMRb24g+18oUz1CV3MC7IAp/3H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ginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91bdaa33-7ad4-4c90-b70b-08dd2b3668a2 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 14:04:44.1478 (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: WFPkCl+70OJbrEoXti4arEOwNjHdKX7A75PYnNNC5TwWr9P1Ru79PqM0dc0O0+hVVwS+dxLxvVWMO9FlvcZ8Mg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB4281 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=2025-01-02_03,2025-01-02_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501020123 X-Proofpoint-GUID: CX9e7hLgBrbt3SGncPIo2OaE51XUvlr3 X-Proofpoint-ORIG-GUID: CX9e7hLgBrbt3SGncPIo2OaE51XUvlr3 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..02b3f697936b 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 XFS_FSB_TO_B(mp, 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