From patchwork Wed Oct 2 17:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820176 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 568561D172E for ; Wed, 2 Oct 2024 17:41:43 +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=1727890904; cv=fail; b=DOOK7X8WfB58Wxuwd6fJWyt6ziZ/Po8Dt6GUptVaWh5RUeXxv2mQ9DvsgEvXlId/b7vcf84ocjL6vDf54xOGA83nfdrFgkzVNqqk1uwBsDWUE3SBih3ojX73Gev6RsRQkqtunNKIKAG/FUKDRURzamH8ff6jzdwdAhzP7eYoRzE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890904; c=relaxed/simple; bh=ycqVZMYkC+dfKiRhNiIV+c/Ng+x2368+xfWSdAgBamk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=COWwTyBEeJeLa9tyCBgddj0Z2p33b+ufx5ryBwUBMF+AexPSPIEjjnyjqeB6r1ofhLoJXjGW4Cz4oNejnM6f4Q3dLNcWr+TSwI91ruWrYEOYRkJFzOih1tiRifJizgF7wYW2hviqjcQwy1rQMpaQQImZtqJCmOOeDVgd0MwMaj0= 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=btcFBVyK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PQE0uqAS; 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="btcFBVyK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PQE0uqAS" 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 492HfZng007356 for ; Wed, 2 Oct 2024 17:41:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b= btcFBVyKizDQlI5yMDSAsQ3afONUYHsDPO73G1q0jrauA/3QXqNXLcJ3FqMOexzY ZceiQvzDZCjL2oCYL6GPFOBVEfoXglC2EGeE9rGXizGt9NiuiLXFA1FTpNpkZPYs +iQeeL01Nxmwi13tpFfbryBCzxJ8PkPA3wN7KcvHFRFV7KHNOut2mJ8erYi5f9qB xsWMxdP61DKEJ97zXbS5rpXUtzd/2xItMOEvcXYBMpaLGUxahjpZXMyPADdyqYyu SE8Jhrmdz4WwS450SR2TmgwqAgVGb6HpBNQ00AYI9nT+GwO5eTljdymCAQ8d1a+4 Es52kejv1Wn1xdLFl0R4jw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41xabtt706-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:42 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 492G2Asv012512 for ; Wed, 2 Oct 2024 17:41:41 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x888xgec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NYErH2dWNPNzsMmkp5ipj4r7J5MWbBYVUOuRSsJ2RxmBQgX2onU8yMtv2iNL8CC8/f/LGqq4U8pg++wHpWsYNRn9wR18nJcZVA9udAQG7RFSpjZ9WHoBPpoptkeK6h9KSUpz0RtHutrO5aNm+AX6lKwlMgsRjcDkbBSvHz+Lbz7OAUIGyMvmVUiaPzfqr4NN01VsWc5Hs7wXqP3LP72zGv2oqBKecHNN5IZDdK1evAmMSTviXg4hQJCu9U8Oy62lPPjfkVt0gsibgg3ovxYClSuU4mlpb/5kc3NpZwR8a+Iiss36fm0zMmY02fOyxOU6M53A22ni5Ugf2Jjbjairug== 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=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b=ZKhLoFdXA3z7+Ufyd6V2qcsRxO+Zs9kemcfUr1h0iOW+jCS93uV/7HoCm7QSs2MwengCrMVlp8Vrr3KSViOMpkHDuJ0ifIfexrxVrR0RVmiKbsvklZ9KuygbNGou6rAS58lUJCJphiBwb8dshuwS7PdBbUROuMBrGIhelpEgxQt6sTX3Azj6elNxmHhAwNeu7r0KeJOvGgRTGXA0c+9CaOF8nGveNz+pA/BhaEgFLQObx/QSptZv/m9NjHpOrkGLefdPcisTL0NeExPM3RB905TERxju8BIM8hrrwTaIGj1WW5wpLXC9szqopyx9s0enzlHTgzNRqR6BudiuqYHpQg== 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=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b=PQE0uqASb0U45XnzKvSAA5IKlC27DjmhfZd8YUEsdzMWlTgswRB3qC6KC33diY+i2LTShYWVEmoh4zJ3UeNGGoVmSoJE8OMkar5JIOQWqoE9tPqx8S5d6CVGYrfN076g/xsGVCFRRuu/5Q3pLPJ9o7Sdufcc50ihpntczAjJIR8= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:39 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8026.016; Wed, 2 Oct 2024 17:41:39 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 15/21] xfs: convert delayed extents to unwritten when zeroing post eof blocks Date: Wed, 2 Oct 2024 10:41:02 -0700 Message-Id: <20241002174108.64615-16-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:39a::8) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 2869a3a5-4c35-4f20-da28-08dce309785c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: cFrg9GWvn4hRbXixkYu2N1zh8ZSV3hwP0o5sm/WUV6E9bCvZolQOCNRtQeUlIghrwXireDe/XFdib929GndqkhL36/ADpVr7hRritIWvhu5TEkkinxuEdZu/qsUt+J2CYPiAQUy2tY/38M63k0NjpqhZ1R+cZAt7PRmuAZaiLvaSxhnnF5gdM5UEj6MhgESmFqwUTZefUDcSCJBExc7f5KLWWyeidZ3AMgUpb+3nsEXTLUvce+sJJIevA9SbB5AhYR0oJ9Iow4YSEKi94cH+ICXwGHXTZyniAlY381yqVRyWsqYzlJmezwN2DhE881wnpDuOMViVRkdEP4XERRm7VLPLgACkXqi/3EXyxnL1GQ8CK81gNutLZwuAvdwXCTU3V3h851+ZsyqDnjB4GYul/GZgvob0YtWTERJy5uM8odtnfRU8FR5HzulbZVlkHyjK2uPAlROG2sk0HZGEu+dkD/y3TjslfBAg+nE0j/OA/+FV/ua+zH4BKwumhtRlrmcUj6wVaF2NAMM1iA7kN2NXNGx6be/Aedqp8O0e+Wk0wj1fpt9xOrvuMJ7c2LuogdRaKba6jh+a8J+AXO6KSTY0+X+JEwmIbPIpGvj0ofon0QqmxbBkxi0p4KZPTZ4J0Y/GN83tGE/fHwboEd9JIz+TLEJwsBCIpmdT41Spl1ehV4AhGl8q8VEVmKNZIWR0NVIA0HGw7uVPeYzm5S8SVfjuUzv/2dscJVr/GNzouGv/nGYOeqSSETXKOiIDJjA0W1mizdJIA3sqN95+75J2iyFkYFX/Bi+6eNCL5YQ6M/SLLSlzMpob/ohDUBYVeU+rJuhBLqIwnkJKeUNS3f/BLrhD/T6V8IEMlbOA6DpyHVvNTcwrl/TPoQ8EeoX/QAeZAMkxFHSKK89ERGFecW6K+p+N+a9Xuz8oum1iJ9Ht7VxJyXw0Er8GHGd6EWmiBvAkf1yPJEDD5zGh0XL6XMhA+9V3QqPALZWUHLN4LsNWx4OocSDzED1BO0DRD0bCTHmQAVMwOa4fyHSNAYQ5OtMZhfIl0E7ruE5pIIv9RxpUYkoa1nQuHGrDWxIebE0Y/j1TLGheiQn2YD+kfTKTNep+I1xSLyG4V8bj7PBqmxhKfAvM0aHP2s4pgmQHlPS0jvQlTKEPUevzYIBkRs+GcnP22az9rfpQ1cLz5B/Z5QLQMQMzIxszg3AbsacFtVf9BhZ7crmCfib0WdvmJ1qHu/X3ZfPwsnzeEJKR3seFHSac+JwO931j+GPyYEWBTSvb1xtmVmilUJj93UXexW5Cg3FHADeAhg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F+zQmYyLtOBX/QxBDovXDxrqLlwvb2dKqpx7mThLL20305IwGzP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eT3xB9GfTL84mmqjwW+UY6r3a6vleKvLhUz7V+6GY2D2Zteg57Lw5AucTKwwbPlstd9Srs9c15mAzlgkeYkqwI+vi57cbB8efQyx3Y/cAJ5k7xmzyShj0MhEg0ArYF/zLu4/KSweAg6d/Fr8nTsCJj05u3adVK7CTy/D+uaXJFOHKFBf2dJN2jXCMO0qTn4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2869a3a5-4c35-4f20-da28-08dce309785c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:39.4870 (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: 0mBNMRSgW2pr6vw97SrH/T0ICWDirduoPHunhnT86uoOX8kqp+8gnUy0/5qxsRmG2KskPpQZt8RO/DOvBLnyQbHACct+BmcVOJQEpewRFVY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: LyC7gY-nyBiMIcK-2RhE9TbdQZuMCypm X-Proofpoint-GUID: LyC7gY-nyBiMIcK-2RhE9TbdQZuMCypm From: Zhang Yi commit 5ce5674187c345dc31534d2024c09ad8ef29b7ba upstream. Current clone operation could be non-atomic if the destination of a file is beyond EOF, user could get a file with corrupted (zeroed) data on crash. The problem is about preallocations. If you write some data into a file: [A...B) and XFS decides to preallocate some post-eof blocks, then it can create a delayed allocation reservation: [A.........D) The writeback path tries to convert delayed extents to real ones by allocating blocks. If there aren't enough contiguous free space, we can end up with two extents, the first real and the second still delalloc: [A....C)[C.D) After that, both the in-memory and the on-disk file sizes are still B. If we clone into the range [E...F) from another file: [A....C)[C.D) [E...F) then xfs_reflink_zero_posteof() calls iomap_zero_range() to zero out the range [B, E) beyond EOF and flush it. Since [C, D) is still a delalloc extent, its pagecache will be zeroed and both the in-memory and on-disk size will be updated to D after flushing but before cloning. This is wrong, because the user can see the size change and read the zeroes while the clone operation is ongoing. We need to keep the in-memory and on-disk size before the clone operation starts, so instead of writing zeroes through the page cache for delayed ranges beyond EOF, we convert these ranges to unwritten and invalidate any cached data over that range beyond EOF. Suggested-by: Dave Chinner Signed-off-by: Zhang Yi Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang --- fs/xfs/xfs_iomap.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 359aa4fc09b6..1a150ecbd2b7 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1005,6 +1005,24 @@ xfs_buffered_write_iomap_begin( goto out_unlock; } + /* + * For zeroing, trim a delalloc extent that extends beyond the EOF + * block. If it starts beyond the EOF block, convert it to an + * unwritten extent. + */ + if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && + isnullstartblock(imap.br_startblock)) { + xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); + + if (offset_fsb >= eof_fsb) + goto convert_delay; + if (end_fsb > eof_fsb) { + end_fsb = eof_fsb; + xfs_trim_extent(&imap, offset_fsb, + end_fsb - offset_fsb); + } + } + /* * Search the COW fork extent list even if we did not find a data fork * extent. This serves two purposes: first this implements the @@ -1150,6 +1168,17 @@ xfs_buffered_write_iomap_begin( xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); +convert_delay: + xfs_iunlock(ip, lockmode); + truncate_pagecache(inode, offset); + error = xfs_bmapi_convert_delalloc(ip, XFS_DATA_FORK, offset, + iomap, NULL); + if (error) + return error; + + trace_xfs_iomap_alloc(ip, offset, count, XFS_DATA_FORK, &imap); + return 0; + found_cow: seq = xfs_iomap_inode_sequence(ip, 0); if (imap.br_startoff <= offset_fsb) {