From patchwork Mon May 6 03:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13654862 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 84CB24206F for ; Mon, 6 May 2024 03:05:29 +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=1714964732; cv=fail; b=q5hECwYnUyGlEP6URBlF4wPulMkj65zTsAyXqc0l5gk9uHyBpoCLg+Om1iPRDtBDONqZ9xJjPs6l0AUXYnX64iF+h3ITzzqY5bhxPzILd27mJjFbMKoKumA7RLbk02ZCVPrhlGeeCetREiyrNjEb4Ey8EpZwYn1na/HAie3gM4g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714964732; c=relaxed/simple; bh=3CvyoosPG0q54PeNhKRdvpHEtodNBA4qtgSozbK9nqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ju4QGZhfT5wthiyvyWk+ns/Ae4au15Uwj5VQJSEyMbA4c9auOqXSUdGadhIBJHBlKLfmKBUCDxnFMwYdMjWATcrW4wq4J9wxHJ2Ak2rKuOQBgyReeIg2gu7nW50Ug47HSre4rBWfDSkAI14NNZ2hvVkHpiJMGNZEMXPIqt6R1Jc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=CD6A/zxU; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=oPkbB85y; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="CD6A/zxU"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="oPkbB85y" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4460jA9i005021; Mon, 6 May 2024 03:05:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=O4cybG5j1f3aEOiESIEETtTtx/PDCkGWWcOJyaSG3JU=; b=CD6A/zxU54wqWGxTf78NARSJPFI5y7sfJueJOo2UqEvobA3HuEFQVWz+fyCF7P0YquvM AopKr+x0W0dQ9bv3Gbw0CWV2cV6QdkisW7r50hr1fyCt4jwEaatXxMvR3NItcaObxcZE 0VaB6RmqNP5Cb4QbPOhCSjNrHqwgTiTo2zokp3DAkWOnOOHgNGtWjxuRFCU+DhqCxUo4 cgtA3bCgjm71tOg+PNi/Ne6t00kM8PZDlSrHQiwddeylbb0G3HjQp9ITRESYQi4XdYwo r8RcuxPz9BfuvGMRbcaySozXKSv6anNBMf4uhFpYcFGM66FG8NGZjV9KTb9GuRNdbPZJ XA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwbt51par-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:27 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 445NFFp6029349; Mon, 6 May 2024 03:05:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbfb92uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3bK0zat/wDIXJrGGY7ybQ5cg43Kym36zprYS/NulUIByPUQwBynPd465bUQXAq8GNeHnsJ1hebp/lHynbVBNX4cI5ul9zL5MMPsLIlcgZCvZ8LW+BCVUN7Gkvy5kTPBD2js+d/UEGXVTUc2PMH9ar5y7MIW92CKitbuz4n967PTNQkXxoONZmiPRGCfW/y2/6r4Q6n153zLMqrYIOeWqtsXzm98FUzYvxF1VpuCNrDTWP4k0XjIGTIJ59rWPWiIA7MlUVsl/xxNQPcS9k71y69lLi9B2L+3aDO24Y3trsc0Qk/qKwTjkc6i+cm6/EcceH/t9J5Z8Xo+U/dVYxUHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=O4cybG5j1f3aEOiESIEETtTtx/PDCkGWWcOJyaSG3JU=; b=Z1sog56a9LRiNuv+bZvT1iyIecun7DalICL2izdXST1zPGeNYwjtGNWilmDCwnpEkHRo9WlbVl2gOikXt7EXl/2rPCnnCp3+uOql1RMC/Qh0o8hg/MZhoe80UJIVS+8IW2eTuYFtqzV9KlW5OPC4WUV2/WoCkqlKn3xzojKyFOPmbUcUICcRs4HRPdn+T1Elm1RP6eSfaR+Cdxf42dc9wy0J/lr3maQLlvKOMoOQYMIWGEf5mS6Rc0Da6cDaBWz48U+WLxojN7zY2SoukzQHifMfUh7wImSKVDZO+OGH2bA6pJqTVjHaJv7OYM5I6V0I/RN40lqN5hIQUHkTAfSN0w== 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=O4cybG5j1f3aEOiESIEETtTtx/PDCkGWWcOJyaSG3JU=; b=oPkbB85ySIe851vALK1fZY+KYSv7tM8Z4vTxOXNTv5ETT7bkJFFls8bPAIp10iBFpWa0maloqKWNSshFG09JJtrAHmu3TPHqVFqhB+3t0OnHHXlBaOCEHlRl2Wt4NyJ14zCkBe5fHM6aIX+qIlAm+BsGuWcnSGV5a7hqvKfyZr0= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS7PR10MB5975.namprd10.prod.outlook.com (2603:10b6:8:9d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 03:05:24 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%5]) with mapi id 15.20.7544.041; Mon, 6 May 2024 03:05:24 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: wqu@suse.com, dsterba@suse.com, y16267966@gmail.com Subject: [PATCH v2 1/4] btrfs-progs: convert: refactor ext2_create_file_extents add argument ext2_inode Date: Mon, 6 May 2024 11:04:55 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0203.apcprd06.prod.outlook.com (2603:1096:4:1::35) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS7PR10MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: 883e252e-f92b-4166-d22b-08dc6d795fc0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: tqddOVem9gFb/7Jup3r0PlzQCI+nvmSc3F5wH6sUddPKwHFJ6+gWGBs2/HxjsX59UzCo8lAOd2HFZU7s1hysQVodhubnt8JeTsg0RY5flDFJlD84SfT5QSFGK7b+Sg9o0d3kcj3hWxuVPESnTqmipiBBfAJqeMLOoIQnYW5wL/b1GDUNMfwaBibnvW6ZdvsBGMNCyAhoL91WhmAbnzqlIn6fy998ELIoQW2l94glboPXid/hPmE/FfAPkYAWzilIIWQ0sp9OZYzP1UNYQxUSnnAIMuE/0/4MDMvOEDSpDX+VbukgnltqD7h6/9RDHxXsa2hmH+hhT4uiTf9oWvblL+vNndnw+mZ9ZwWGK3KAtKMe6zatkgavUUkibIc001xUE6VvGIpIi6fni9fLP/cSm/R7Xk6F+jDubHSmgu7TY0xlUXU2qcNi7sc1IWEawl9vUsa1FMdiDqjry0+9jk6sr6TqAIJnm6jxLvjcPUzXmvu7U5U9fvlC+tVLPRsZrHqxuX4+lpfYfZnxnP9X6dgXbsOAR+bznSVCYWfxFjoNRh62KsCDF6V5+6WG7YqVxagT0QBBS/COf/w6O7B1U8mzJZo5z1gcI+OL33TATd+g0/Fsrvi56Qw+Vo7E8fTrTO4IkO+yXhGh5zyroXCm7JTcE2lCTd5eEmQH5oDy8yLk9rD5QFiykr535Lb8ptjTQ8ZjsbamL9feCbm7NzcmCd38BsnPXoSBxPQ0Tpo4GkpW3eLAirovkmrCRWL0LYpTSFFE66JhVlm2JheVXDEP+h79fihD+I4Y64lqT8QegZRNIdEj2xkjWAM76Bpsi6IiFROLg3bjkSk8rSol/q7YVX6ECrz+6Jk5bqqIoHvQ1XqGACuTPJi8UHdxlFsjnHvs6Ly/qdQlWaHiysj9Z+tjs2BqtmQnHVx2XRZjhAhAtBfoGnjPTmMka4OPnnAKTVJbFZy3XZoqY7FM2kC/LJ4BO13ByChCW1DtLXeliDnD6ZDS9RHbJoJmCqQw9zQ8LmGL3pbmd4SbrE3U8NK2v9qO5D1MP6hJXoeYEwnIUb6RP0NjIRikO30edqJpsLhOFT6JrLyLz8QxHM7KrQRP51SUYMFIYj6MMygs2XCZNIl17+vm+ap6QjfNqgDz5aEtd+Dqc+SD0Jt9qNVQ2heyLSqUmRLxU2aXTvrTivttsdh4mNhsCBaHNiMyQTOivEDiCfcCLeyxHx/wPSYjPqfUDZ4Eog1Xl4uf1WYUyMxp3b3mPvJWTd5Diq8kU41BruiXR+Ut9a3b6E4EwgFnQa140iCMpgW7jA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RJDvRysYbX+qNmr8FWpvG7rT9hP8TNocHKB6eP6ah7eihfsJ5OATGT98xPORT83i8mq8Bk+8vNDMk8WqQBnkI6ehE1FSU1RmbsyjeExBzSoigA8NY3RiqbJd6Bfo0H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uYYUWVPFoRbDbZtbld73n9qKMbsFadjl4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 883e252e-f92b-4166-d22b-08dc6d795fc0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 03:05:24.8004 (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: zwwQMSgPkJ0fX5nHffd5hgmzSFFj2pwMYdRbhpU736OQoGdSnSIvKZg4Zg91z9PSoNhclq8RNRC/5oOL7nC1qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5975 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-05_17,2024-05-03_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060014 X-Proofpoint-GUID: zL2hX35tJYOG_Mmn6e7-1POz3P64Y-wl X-Proofpoint-ORIG-GUID: zL2hX35tJYOG_Mmn6e7-1POz3P64Y-wl This is a preparatory patch adds an argument '%ext2_inode' for the function __btrfs_record_file_extent(); to be used in the following patches. Signed-off-by: Anand Jain --- v2: - convert/source-ext2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 2186b2526e38..a3f61bb01171 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -310,6 +310,7 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, struct btrfs_inode_item *btrfs_inode, ext2_filsys ext2_fs, ext2_ino_t ext2_ino, + struct ext2_inode *ext2_inode, u32 convert_flags) { int ret; @@ -384,6 +385,7 @@ static int ext2_create_symlink(struct btrfs_trans_handle *trans, btrfs_set_stack_inode_size(btrfs_inode, inode_size + 1); ret = ext2_create_file_extents(trans, root, objectid, btrfs_inode, ext2_fs, ext2_ino, + ext2_inode, CONVERT_FLAG_DATACSUM | CONVERT_FLAG_INLINE_DATA); btrfs_set_stack_inode_size(btrfs_inode, inode_size); @@ -903,7 +905,7 @@ static int ext2_copy_single_inode(struct btrfs_trans_handle *trans, switch (ext2_inode->i_mode & S_IFMT) { case S_IFREG: ret = ext2_create_file_extents(trans, root, objectid, - &btrfs_inode, ext2_fs, ext2_ino, convert_flags); + &btrfs_inode, ext2_fs, ext2_ino, ext2_inode, convert_flags); break; case S_IFDIR: ret = ext2_create_dir_entries(trans, root, objectid, From patchwork Mon May 6 03:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13654863 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 2DF87358A7 for ; Mon, 6 May 2024 03:05:37 +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=1714964740; cv=fail; b=n0S38jwsFVQ199heU7z0FInDlJvsog+rv1bz9tr3QrOCjlEYEV8+20XqpVn79gUU/q4iStDeTMJTgPtw+nZqmL+VT2xzj1F+LCaVPVgYOxVVOHOUOGlDxr3hQSDwBBJTRK7YP61jUQQpnMl/JKTjyoT7rd5WTgKE6YAgBoPm1oA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714964740; c=relaxed/simple; bh=G1ayxffO1EeG7EM6mqoV+szrjW+Jv06IsgivRrYe3UM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VLP/ZJJWvq+L8s1A3Gvlhqjt1a2ADsLsqEOKHPZWxLllazScTDIVeJ0DlNz+Xqq/csT1AqOXrCilyogNaCAU+oQkGkZxj5UvyEb6HoiXwKM/bpbO8GZnjwuEJSi9ItlY4bCkbp0FwELUj5vWxh28DdH+w6RwAvnYAypC+Wm7GGc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=NPan+n/x; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PDAkSHmd; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="NPan+n/x"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PDAkSHmd" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4460iIQd010853; Mon, 6 May 2024 03:05:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=sVyuAvU+W+T6gmigB8W6VZ/liMKG/Jzgvy2ao123TlE=; b=NPan+n/xu03KjH15pjO94fg62Tx2DWDMFPnyTA5bjq3BEJqtIdaN0WVQP0aWUvqFRDsh ls0GK91IRCDotAw4DzDdplwx8fXzgfEY+RLhYYt9WR182dXuL8mAIXzaiSnI79uMmD8o +062gHlfFp1JBVTKRD5671KjsWjyUnUoWC/thqolUKdwxSwnI0sff2D2O6/uOUpNEj0g Fvo8/fAzZWi1lwg42F168tpm5dj3ULwWLk/lLusUIKP+x5g13JQuvciWOm+v7q7l3xQo yS+233mHhR3o8qPUpRk8V6qHTh9qFWNgGIZXgOm4x5ouq6Wxq2lHGdI9NvTXK367pgDd jQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwcwbsphx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:35 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 445MdITr029234; Mon, 6 May 2024 03:05:33 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbfb931x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kj4TBp9TLAi62GvuBy3gOQdcTSB45sZJD1DgGUgIwmrH1/mLEn2KnxqrV12GVx0/CqI0MeUEPDjKm3Ua3/4Vm03yzlKTNKl+S1G1xlnVEEltiydiIlO0hlaFRYDhkOjd6fXV288+wAf5ut8PV72LdCFafjiNI7BqQ7toq8lN7xLllJ0MLzH71Wvk6XW8OD6Cp1UV+pW1hxxUSryBQNQ0PWjYNxUYXZDADv9LMBlSXlB3xYuCgZm56nHO1X91n7t5LsAhvtihzOPk+Xek6lie4LDq9Lu7OybiXET4LswbQ+azdvBxoGcOPCYlJaIv/ecomigRJowKPFPd3q+k36t6gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=sVyuAvU+W+T6gmigB8W6VZ/liMKG/Jzgvy2ao123TlE=; b=J+SsPrynYLn1ZRa8JPfgdKO85XAWyc8PLZzQx+y0kICP+vOnkn4T1YzV+hC/typQ6ceC074bUM7BbnM2bwsesa2IftKqf2b3wr86gr0+fZNplBdW55RF1l+dXTKzEbSAZN6l3zuiVmEFzCuVcxD6ZZrgtz7SdQCWzVKt4OnVVCpASxS1Av6o/AE6QsVT00Bd8t4rnX8bLTU3yGStN2WD117Uzw580nddrfqwquAI95/j2IbniJvAqOV/bHNuUXVXnI9MIwtSwvxYslYaviBs5BmKV8aBq2Frk2bd8SGwBVpKZ5FRv4mkd/ZXWpitt6mw3qp0V3bdgLzvY/TIHOfrSQ== 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=sVyuAvU+W+T6gmigB8W6VZ/liMKG/Jzgvy2ao123TlE=; b=PDAkSHmdszqiR1E/7LObkNFO05XrzBxGj55pynOYJg2+DZISgZNjuING8CkcJcUTu0Upv1VWX0jGUoDxMk4pskOA0Lh2JAk3O5u6WgBvzVsQS9gd6ijADcnGSG6Zxz02SizXEss+iNO8GQVx2g+6h0vw8HzfnVSldiATwU4RZMY= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS7PR10MB5975.namprd10.prod.outlook.com (2603:10b6:8:9d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 03:05:31 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%5]) with mapi id 15.20.7544.041; Mon, 6 May 2024 03:05:31 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: wqu@suse.com, dsterba@suse.com, y16267966@gmail.com Subject: [PATCH v2 2/4] btrfs-progs: convert: struct blk_iterate_data, add ext2-specific file inode pointers Date: Mon, 6 May 2024 11:04:56 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0189.apcprd06.prod.outlook.com (2603:1096:4:1::21) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS7PR10MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f53408b-2a7c-422f-75be-08dc6d79638b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: SDoLd/TxhzO/2lSlXZkvCan+QKpCD8XlXqe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apF5l+WW/L2lEKp7eaCIFpOkUc4bE63t3wjc0Eu290U1zIlp8AyODDbgWCDtmb+iWumJOhIVWou0paMENmcB19Do30aAHziS5US9aa8opFXbzJNs6gTKEVWh66V+IXCRrhOm+j/ZZxva/jPzm8MYMYDZ84/xlhDKKh5nvFSEsGHT6bkw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wvbqpl7rH5ETsG9qTnYZUVwpDDhKxKWosPcN5Iv7WVDmZ7vFQCqBPTsYTBazCG3ZQABgJf6rnMZ9RlsHGRUO4KqWoTHEBUeUpp+fk3pvRhORiUDIEjf0I4TnQlpHEUxbkK3JfW6AaiqB0H9oa7JdyzPmQK2ucG0QzFXfJNbHc+8w1iJzIdkmVC9vx9R7iXINg/DMyE1vYDOXPKIoapsK9Iha22AuUGIF6FQdyVDijxS3PcWCxUeUOScN8df7XJikqvz+jHJdfNW4XRfw97iaZ2btXQB39OyAQgdAaSa2uRcmFVOlgpVx/NEHzyICsPHqq0+qYR99XphD7mTpN3WialBTYGk6rZ3oQ6sNEUb8jyojtv1aoxKa46wNzggDP0tfu5Lox511029Hhnp1EZ7TVEvsO/I1tPHhqcvbVWMCN7lGCM6PwdTkADW6IPMRgNQW+Qtpazf3dXR285UIeOrqBz2MTYQXMKlUGIsWE6WAUZMKdw3tFWBOU4kR7nwPIsRAPVx3Xbjvqa0oaSnudeAfpxUHpgBfH+G6SmyggASl1ERy6418hd+1e327JWNqs1ezZutFqAHzsy+FTnXlb8lC8qNCvKKflBmnHyW2FUuLaQK8VPQ5TaFyra8ISjkQA+sBeUZCbMUUXxWTTgZJHrH72JJ9KOETK/Sms7inwoki6PNXPtWQesepQ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Q6Okzxkopep9c2PQVRw8yqxVsjbK9FHT0n/LGGSTF194iaWz+PqVqeBWUpYT6ElRVkHV8FqvfOSe720yMdNINuJ/vmKhx7EdAZK3+tiXekYci+DoOoIArj+QphA68LukztallqbM9G2W9GD58YOIuQLK8SDufMsxYIPXxABFkzb19OgJmy0JC6zSw43iwZtCLR0z8C9IRjhn8YMUD8PSJJNV5eIX4LVBco9sNuOD6BuaGk7mE90SdGrP08LW4pcxK6/Wu67m8D16MB1rl5x6CcXS7aL/1O6oiL3CFNltS7Gdrn5E/IhUsoGhQgC8j/tk4yPl/g4wKiH51FSy4X7FaSPToohvxt1T4QTeUMlxASr63rYK2irG25oBjFifzG3BVQXxSttTI4SIRzN1sD6M8c69+BZOQjRizqK3b7LykwzpMIO95mEScEGKRXcFNXsuWh2HxU6tY/Oa3Ba1JEoOT6/7fBXZl/AKMRri8uguN0Htg+FPQVtbNafPOxXfmD6IsgaIT+bqxIpA2doIylmKtL7wPbWZY32h81U8QM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f53408b-2a7c-422f-75be-08dc6d79638b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 03:05:31.1217 (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: 6y8JrqmGjlwapFVp5KhK+2Mwm18YDxyq9qJIY7N+XcrmNYg0aQ2xHF+fVve2LIHmywTettwdNfaYQSnjHcI3jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5975 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-05_17,2024-05-03_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060014 X-Proofpoint-GUID: ukRXuPE7D3qHKDB7Ff8a37rgqo3NNzYZ X-Proofpoint-ORIG-GUID: ukRXuPE7D3qHKDB7Ff8a37rgqo3NNzYZ To obtain the file data extent flags, we require the use of ext2 helper functions, pass these pointer in the 'struct blk_iterate_data'. However, this struct is a common function across both 'reiserfs' and 'ext4' filesystems. Since there is no further development on 'convert-reiserfs', this patch avoids creating a mess which won't be used. Signed-off-by: Anand Jain --- v2: split struct blk_iterate_data containing the source private. convert/source-ext2.c | 7 +++++++ convert/source-ext2.h | 6 ++++++ convert/source-fs.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index a3f61bb01171..477c39d9d658 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -320,10 +320,17 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans, u32 sectorsize = root->fs_info->sectorsize; u64 inode_size = btrfs_stack_inode_size(btrfs_inode); struct blk_iterate_data data; + struct ext2_source_fs source_fs; init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid, convert_flags & CONVERT_FLAG_DATACSUM); + source_fs.ext2_fs = ext2_fs; + source_fs.ext2_ino = ext2_ino; + source_fs.ext2_inode = ext2_inode; + + data.source_fs = &source_fs; + err = ext2fs_block_iterate2(ext2_fs, ext2_ino, BLOCK_FLAG_DATA_ONLY, NULL, ext2_block_iterate_proc, &data); if (err) diff --git a/convert/source-ext2.h b/convert/source-ext2.h index d204aac504e7..026a7cad8ac8 100644 --- a/convert/source-ext2.h +++ b/convert/source-ext2.h @@ -76,6 +76,12 @@ struct dir_iterate_data { int errcode; }; +struct ext2_source_fs { + ext2_filsys ext2_fs; + struct ext2_inode *ext2_inode; + ext2_ino_t ext2_ino; +}; + #define EXT2_ACL_VERSION 0x0001 #endif /* BTRFSCONVERT_EXT2 */ diff --git a/convert/source-fs.h b/convert/source-fs.h index b26e1842941d..25916c65681b 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -118,6 +118,8 @@ struct btrfs_convert_operations { }; struct blk_iterate_data { + void *source_fs; + struct btrfs_trans_handle *trans; struct btrfs_root *root; struct btrfs_root *convert_root; From patchwork Mon May 6 03:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13654864 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 EA30242062 for ; Mon, 6 May 2024 03:05:42 +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=1714964744; cv=fail; b=sOAigPHMOZ7+JGxNhAuiGTk9SDXIc4wWqBF6RsuIOGRzBwLTBwixf/wUcsVrRMb48QH8kXYELFRq8vh5Tpxc/tlpKbukKpSMuHhUoGktwMB5DWvoJrdU0HxHJjH23cOVoDpLLEFnryW2pD0EN6XIVmCxOCR+WTZKl8ECLzAtySY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714964744; c=relaxed/simple; bh=81C0yVN3owSj2j2+4jp3yCX8lydduas7Pf+hiEjsC4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=tGpN+MUANayv5d70J49zAm+lr118/QTUbbatjuM9PnOyIqj5HaMQw5tEM2VJGm3P6/NmnxJTJOcgRCluI2Jw8JsyajIOHTBCMWt1no/wOzNj6S2Xqg1m8DlHNd7hNoDLLz15HGZxVC9GKXptcqwqQBjwj7X53LgbxS5GbXPOycw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=jLPSxWDU; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Ppk9Atj1; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="jLPSxWDU"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Ppk9Atj1" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 445Lodou024928; Mon, 6 May 2024 03:05:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=XYU6epzK/+e2/0ZvEgcGGAzysaGDB1hLcOvc+k4kCtQ=; b=jLPSxWDUIB5BmhaUg7QU9EI8+DJsgzAj2mECIGbudVZ/FTBf899J5+24aRlyM+yJTMxg 4J2KMovqAin/GKISdMpotKgriNDZvWssCT3NZyhuZdK1eLZbEIzJ8JFelJTj1iXF/UDS 4X8oBTTfLQpMTBvPs2/nKbwBZr135T81l0ezUsustAiWw+ouKw15k4Yp04BCffGuKeav iBy0yDNJTRCJId8ucFcHn6C9FIxYEx1P7pj81bbKgv+JWaVXRLWNki6dK34+bAbeuA0A u4X9QT+0GugBJqSthXeRBlVriHLx/VabCgtrwlPCveGEXcuO8+EPdRkpMy8NzRotuB4u mg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwbxcsqw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:38 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4461MUl7006964; Mon, 6 May 2024 03:05:38 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf61xw6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e96moF7Po9Zn7g2O29dhJCR3vI1idtxThJwJF4+0bBp55/utd9e9419HUQhllvjy7b+dbusUJr0C3yLsPTf2K0EbeR+Z87mx57AWORkCrqtgCwaRb2/clQ+9hAd5ofkCsbheBBAvfwnJNVrqWqigvWIcK6+aFFA/SUKgkJuGu7izF2EjbuirJj40AsmJ0dl9A5x2+xJD/+u2Z37/yemBhJzPkE0S0g5XefJIW5W47XhDam8TU27Gvui3sFzu8d6/o+iYX4vAXJlwMdDX0uf+Omdphi50f3re8suOfy4HrdSzJn9OGsYlLnqRGnHinFBRbNh0ADvJ4CSrWn/zPBo9MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=XYU6epzK/+e2/0ZvEgcGGAzysaGDB1hLcOvc+k4kCtQ=; b=l6QXLJ8TsxGtS1+mIq7wApyqEsEL6rjOwuIUKg2jd5F5kMAMfrgIkYy3Fapo7dypCWLHaKER0Q458D03Vw33YIcvo9akO0D3gLOUVIEhOePKCna0X+6VrQ8XWDSZvHptFucPB52GTvzjPOnNwie5+Zy72LtPMf/JEhrPwQh24JeT1ZSI9qDFwONYzoMzEWS9oe0IeCAdIb2Cyly0Y2V5aswLXX49S8lYOg3EU8UBMsof+hlE8lX60DX1sXvBCRGRGlNcjUJZFlRJEYkFmTRqxZNi6Oj9VWGfUz2EJ+4j604tplQIUScT4ioYucEwxqalkio8MiW9y9e3K46CLwYTUA== 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=XYU6epzK/+e2/0ZvEgcGGAzysaGDB1hLcOvc+k4kCtQ=; b=Ppk9Atj1KRTfwtvVQ2ub8/eTVqhZdwF+jXYnFUVBy5dWjcpWVp4U2AjNCY85xlj2QN8elqeqtFZr7+BtqGTz1MRK4f2xyn5CUcTT/xxwg+VM9+/wll1fBh2bSIrs+EQ7rdVFuHx3omV/4nHug8GgQFqIOtcrFoYYgANOJg90qh0= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS7PR10MB5975.namprd10.prod.outlook.com (2603:10b6:8:9d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 03:05:36 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%5]) with mapi id 15.20.7544.041; Mon, 6 May 2024 03:05:36 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: wqu@suse.com, dsterba@suse.com, y16267966@gmail.com Subject: [PATCH v2 3/4] btrfs-progs: convert: refactor __btrfs_record_file_extent to add a prealloc flag Date: Mon, 6 May 2024 11:04:57 +0800 Message-ID: <3953c91e40178273e0896b544e0a7bf9f219deb0.1714963428.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0196.apcprd06.prod.outlook.com (2603:1096:4:1::28) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS7PR10MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: 23235a7b-6a48-4a89-433f-08dc6d79666d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: wycVZ+f7nCS4NfEGtJTlYS31AT/KW9+HVsTdz6FOJ2F81pYBwjTsA6oQbiKjkKoIVKgxnGqxT0WPHQAr5TqXI7yBzCUPhoPbQhtECOhHVNT/g0Zahgyzgxv4DeshoAC4MUtftltSB1szsKJ9clY2zxifGZCyWAeWAimEEO0V6+kivlI8qte1KWvax7OcKz5nWrts4PQXZYlE7DSfgJsrUy9B+2huR281pXjAUlSE0V3Ao81vYGkIlOUNLB8K0t2o5sMMCirX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;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i/i1VLtqTGSXqlKVaK67wuUd8zaGhuWQ9ZSr3DMV0/RnxDZXotsXrSs4q9neOeeaxZEea+/gS30ngBoAiWeoZwO/7bWCuQ/sK0tJOoNOfK9gqKGAD/mmLBAlLjrQFwJbnrPavwjmYuJ2x0PM7ONQyX84eUj/ZotESEbn4OMuzWbPZq78ixO3FJ16SAg4nTMgnsY/2nZNYbXIONgYRAU482HGz0FJhntLoi8Ickn4tjHD/696QMb3hgFpfE9hYCTdceGT5tRSN/3lz8Z15ZeNWK4PkOmrYYnuqMeuMMXIY1T8fj+e37Dr7kbOfAQrYS6VifxZlVK6+4hzVCtXv9gqaqKdQhysayZeqVVe3YOKmTbNPl+Z5r+GlopLrJgIVepXcsoCS5MNmwLKBZi3bSrWp/9CwfBzNV7XjaHHcebKAaPO7V05XQJF1chxbTdFbWg6q5OKofatffBO6yM+Yb+b5Pxe28T2zL2ZcjbZqBkyafXnIwfPvsNEcxUpZYVUDsUJsPQFnbvzYgT7jeBZ69hVqRoO1hDm80SwNjzE2FN2fYhUfJVvCLIloKs0LVK5XSZFjCZx4i4hQRxiJJxgZZVXbiAAUwhgnKYbyyPUqLTLa3IMzlOvZ5oN1RgC0qn5NPfKDmUybLnJT+4oZbdFuHMn5n8ofE4MNbXM9oeYAoUpYG1KOSy76WoT5O4rNwR2BaVZh4cKmmkfOZiFL0JQGwJn8+YoxAm8Dg9m+BciOW83UgHYb5Qi98RN92tMKcaQLSxy1EXDkHSxMAFX4vFvok8S0ToJb3D2lcsv1mvc/iUPDiEjXkTucNKyjzUx6SgUASiEl4zokGt5k987mhkFzHEMzHaCYrkM0IGw3sfrDdfRHwqLn6jTXMwV5L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f21ecs8fUKICORDn7hR4a+ZUcV4qlNQtKDhTvRl8hoTciBblLdHIjc9/suj7HsVDqqsqy59TvCtukvSBZBFXSjt0rQL6bLs9xjOj1BcoEve9bXy6zMS/HXtvp7fm17jgyuf8x7yyy4H/JYQbXd4fDFZERf1jnmWPQWUkOmqEzFTFJFRHOoyDZ4Ayudbx6BHX+PcCBylrr3GnuFKf8FBTJLxtEea/UgqnV526iDR7HuSOGdfzA5MWFotFUFitHn0g21nHayHmmHKRZY6bLbANrdt3BMfyEbb+TD0V97YP3chvWoJDedaR7IlWBhrZW5oSe8dOPNX0Iy24BzrU0TsngDYTNg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23235a7b-6a48-4a89-433f-08dc6d79666d X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 03:05:35.9404 (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: dYh5yn2XjFvOcdkMVgkEPrcq/nQUWqoEBw/pqzIiiaeg1BpNDzc0HgE+g4fOu/5S+YRG+HLAy5CPjbbHzJ23rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5975 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-05_17,2024-05-03_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060014 X-Proofpoint-GUID: M5upc7lTFDpGKXK3DxwZz3fsVtDgfabU X-Proofpoint-ORIG-GUID: M5upc7lTFDpGKXK3DxwZz3fsVtDgfabU This preparatory patch adds an argument '%prealloc' to the function __btrfs_record_file_extent(), to be used in the following patches. Signed-off-by: Anand Jain --- v2: pass btrfs_record_file_extent() actual flags instead of has_prealloc boolean. common/extent-tree-utils.c | 8 ++++---- common/extent-tree-utils.h | 2 +- convert/main.c | 10 ++++++---- convert/source-fs.c | 5 +++-- convert/source-reiserfs.c | 2 +- mkfs/rootdir.c | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/common/extent-tree-utils.c b/common/extent-tree-utils.c index 34c7e5095160..53c10734408d 100644 --- a/common/extent-tree-utils.c +++ b/common/extent-tree-utils.c @@ -122,7 +122,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, struct btrfs_inode_item *inode, u64 file_pos, u64 disk_bytenr, - u64 *ret_num_bytes) + u64 *ret_num_bytes, u64 flags) { int ret; struct btrfs_fs_info *info = root->fs_info; @@ -229,7 +229,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, leaf = path->nodes[0]; fi = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item); btrfs_set_file_extent_generation(leaf, fi, trans->transid); - btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG); + btrfs_set_file_extent_type(leaf, fi, flags); btrfs_set_file_extent_disk_bytenr(leaf, fi, extent_bytenr); btrfs_set_file_extent_disk_num_bytes(leaf, fi, extent_num_bytes); btrfs_set_file_extent_offset(leaf, fi, extent_offset); @@ -265,7 +265,7 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, struct btrfs_inode_item *inode, u64 file_pos, u64 disk_bytenr, - u64 num_bytes) + u64 num_bytes, u64 flags) { u64 cur_disk_bytenr = disk_bytenr; u64 cur_file_pos = file_pos; @@ -276,7 +276,7 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans, ret = __btrfs_record_file_extent(trans, root, objectid, inode, cur_file_pos, cur_disk_bytenr, - &cur_num_bytes); + &cur_num_bytes, flags); if (ret < 0) break; cur_disk_bytenr += cur_num_bytes; diff --git a/common/extent-tree-utils.h b/common/extent-tree-utils.h index f03d9c438375..dce48c43faf5 100644 --- a/common/extent-tree-utils.h +++ b/common/extent-tree-utils.h @@ -31,6 +31,6 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, struct btrfs_inode_item *inode, u64 file_pos, u64 disk_bytenr, - u64 num_bytes); + u64 num_bytes, u64 flags); #endif diff --git a/convert/main.c b/convert/main.c index f18fab4a236c..fb0f97d949d4 100644 --- a/convert/main.c +++ b/convert/main.c @@ -337,7 +337,7 @@ static int create_image_file_range(struct btrfs_trans_handle *trans, return -EINVAL; } ret = btrfs_record_file_extent(trans, root, ino, inode, bytenr, - disk_bytenr, len); + disk_bytenr, len, BTRFS_FILE_EXTENT_REG); if (ret < 0) return ret; @@ -426,7 +426,8 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans, /* Now handle extent item and file extent things */ ret = btrfs_record_file_extent(trans, root, ino, inode, cur_off, - key.objectid, key.offset); + key.objectid, key.offset, + BTRFS_FILE_EXTENT_REG); if (ret < 0) break; /* Finally, insert csum items */ @@ -438,7 +439,7 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans, hole_len = cur_off - hole_start; if (hole_len) { ret = btrfs_record_file_extent(trans, root, ino, inode, - hole_start, 0, hole_len); + hole_start, 0, hole_len, BTRFS_FILE_EXTENT_REG); if (ret < 0) break; } @@ -455,7 +456,8 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans, */ if (range_end(range) - hole_start > 0) ret = btrfs_record_file_extent(trans, root, ino, inode, - hole_start, 0, range_end(range) - hole_start); + hole_start, 0, range_end(range) - hole_start, + BTRFS_FILE_EXTENT_REG); return ret; } diff --git a/convert/source-fs.c b/convert/source-fs.c index 66561438866e..df5ce66caf7f 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -262,7 +262,7 @@ int record_file_blocks(struct blk_iterate_data *data, if (old_disk_bytenr == 0) return btrfs_record_file_extent(data->trans, root, data->objectid, data->inode, file_pos, 0, - num_bytes); + num_bytes, BTRFS_FILE_EXTENT_REG); /* * Search real disk bytenr from convert root @@ -316,7 +316,8 @@ int record_file_blocks(struct blk_iterate_data *data, old_disk_bytenr + num_bytes) - cur_off; ret = btrfs_record_file_extent(data->trans, data->root, data->objectid, data->inode, file_pos, - real_disk_bytenr, cur_len); + real_disk_bytenr, cur_len, + BTRFS_FILE_EXTENT_REG); if (ret < 0) break; cur_off += cur_len; diff --git a/convert/source-reiserfs.c b/convert/source-reiserfs.c index 3edc72ed08a5..746892ff0a8d 100644 --- a/convert/source-reiserfs.c +++ b/convert/source-reiserfs.c @@ -365,7 +365,7 @@ static int convert_direct(struct btrfs_trans_handle *trans, return ret; return btrfs_record_file_extent(trans, root, objectid, inode, offset, - key.objectid, sectorsize); + key.objectid, sectorsize, BTRFS_FILE_EXTENT_REG); } static int reiserfs_convert_tail(struct btrfs_trans_handle *trans, diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index 4ae9f435a7b7..cb6659319b7d 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -411,7 +411,8 @@ again: if (bytes_read) { ret = btrfs_record_file_extent(trans, root, objectid, - btrfs_inode, file_pos, first_block, cur_bytes); + btrfs_inode, file_pos, first_block, cur_bytes, + false); if (ret) goto end; From patchwork Mon May 6 03:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13654865 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 B56834206F for ; Mon, 6 May 2024 03:05:45 +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=1714964748; cv=fail; b=cFcpZpSf1E2GKmxCE4B7rZ7INUfHpWGXq5uPPCTa1Ba1OYz9AXwSPxcwftgAw9piz74DDM0qoQvvffeon9XWYbv0JnOJEH5pdvNCHukxwJCjxWwjaew+DjrjihvHtExlIc+By4AiR7mqO/Rn6a60JCk6jQuRXJ+3cKwqzac0Nng= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714964748; c=relaxed/simple; bh=HbM7g9g9KmsxCqujP2IeZ5t01WoELewNMzKlkj/1+B0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=B00CypM94j70lxmnAc52lLeeo2kVOQMlw9bEr1S9r7ySI2hFB0a2bulxA/2kyZgGaZqHJ/i/5VLf1IirTxswtbI7Mb9Ot0ETTwexrAm0Fn9kl3cTxG+UlOy3fY00nnwH87WCLpjUjv5kspBS1wyFvynngh9iMVO3DZQp63GfRTA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=XITrXNNa; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=XH3X09Yt; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="XITrXNNa"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="XH3X09Yt" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 445MVorG007496; Mon, 6 May 2024 03:05:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=0ojAu7Ucp/S6VGxtrKUIdjSluhnJsX/+/X5KyZc0C2o=; b=XITrXNNaZvS09UDMbB+YLqJwZdXa9Fiu9rr2XLFYH2SSQWwYu4rFBKyKy5ps/Oi31r+T S+9YFZIw6IPc+6Z8I+zdYSsSjLCZOf9GgDJXUSMuWglX64TvO3xJIxdlPjnKUPRrMheW Mr+yp5Yeiqee9VIxIXHFeBu9UdeDf5qucVAnQLh8aZc/wtewQBmwCXVGRzyxvLPWirLN d1XSwyXWyC18LlwjQWzp0l+Kb4b9xroSYMsosQaPXMOMZ8Sry/da90epuHAetG2wsq7Q aHmqqHsRMcqdWw5an0qr7LtDcj5VKZGxyAbno1EJMGvUT/xxtg0hiiTZaYPtDBzP445b kQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwd2dsn6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:43 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4461h4vN039348; Mon, 6 May 2024 03:05:42 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf51qn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 03:05:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KW/0itnVPphL7UIijHXKrl/RPJRKYJA2CCQRNWj2LzNtoqgQZ9M1+jzIGygIzBgIU1ZGx9iHMciOSz+I4DJszAj5ERCZ/8N8WnwzUUgAKd0YSleUO7ZfDq0hXYpf6FYplJaFhnH33apVIw7hYDEIQcEi2UUP5/e+8F0/a6OvYN3SuF8nnQlrV0GSyZV17v+uUk35ouOqddjNi7P1I/DLnwifRHJjPLKrJ+XtTZrsCxOYFtb9Eh74Nt4RBIzbeexlLY8DeICg80wzaQZsONCOKnEt8jOAZYR8vNco6H4VtZIT+UiOzDU5MQPJe06xzyY7xkOEdBNPmNIx1hf0xPOqQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0ojAu7Ucp/S6VGxtrKUIdjSluhnJsX/+/X5KyZc0C2o=; b=OXM2z4zTKY6HMnijZfZXTeTCGrQjldr0cV+5+qrzJj9uyA5sUTViD8WumLiSq/vvuUJX9fzCL8D42KtDToooYaV+2l5rkLoY7ZT4csRcL5lLgs2Cz6RW+rKbjqbqArUq/y1brNmzW6dtg5HTCtJ/CDlm+pQ3MEsB+EwHZ5MY/Pu6tzqD+JioTUOXNkSEsXAbY7W78OQDgNgUNXzFHNYrq0dmZ76HP/FyOeZoCacECiSI5uGqo+UXqr7335z0+d69Mwga4U4ZecoOcafmXc9Wy1DszcauuyTSv26+BnDOnSbD1IA+eWmr7+Y6aATEcgRwxI+ZxVrp+k4lJmJGwxoj7Q== 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=0ojAu7Ucp/S6VGxtrKUIdjSluhnJsX/+/X5KyZc0C2o=; b=XH3X09Ytm6iyqGbt0AysJKRH8SJnKHFSfJnwQziet/M+GUVmoMD6hSkxOj4XO5BCCdKDEKheABE1/FXBNPHGM7iAapjY8nR8p++wl3DkL7zn2irx9fOXBd0kPcGlO8BFDr8xqzFBHWFIDYd/p8UQfchzHPkHPTG56/M1wonbRts= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS7PR10MB5975.namprd10.prod.outlook.com (2603:10b6:8:9d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Mon, 6 May 2024 03:05:40 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%5]) with mapi id 15.20.7544.041; Mon, 6 May 2024 03:05:40 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: wqu@suse.com, dsterba@suse.com, y16267966@gmail.com Subject: [PATCH v2 4/4] btrfs-progs: convert: support ext2 unwritten file data extents Date: Mon, 6 May 2024 11:04:58 +0800 Message-ID: <91f25251b1d57ee972179d707d13b453f43b5614.1714963428.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR04CA0163.apcprd04.prod.outlook.com (2603:1096:4::25) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS7PR10MB5975:EE_ X-MS-Office365-Filtering-Correlation-Id: 1acb0284-3234-405c-e736-08dc6d796908 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: Zg0YLGkxBTPJ3JqgZPiGA8g3PxePv5FcQ67Bd2onL2TyAHCZKjFwASinkh1XTjPxugfcX1+L6lA0LAn+cMdPXcdymnKcwFE9Cj6vQAJ0aS8a83+g+Wm/q/0bJPD541EgIKgZdggkXPkYSdqGb3zipNlzGTbrmnBpckQbJCZrjc70uCQGly0rSoebD1SOocg5z8IEu6UTd8AUZb8nG6n2SH/x16nC6GaNMVSOWVWyVs7ggOtZhit6tB0TN6+/1YFaLfCyJuNOLHf4GCpW9ysXZgw6L58ouN9e8eQKNHFIbwG78vGUF0CD9sZqeFoKQM4r2NWTq5riXTDSpr4exZ+DLuM4IElJDlJ/kq649fIBNVTNG5HPFDDggoJncz1M4986wiBcU+DQrSUTWc8m81oOkDkcjoKZ7dMzBpk6pqIaknrakBkdkiI5SSFg+iTXTcBmJM30NaFkUJxokeAHCKXBt9x6FE+3jho+VlBo8mq+mkzACiYPv62Q7O7KGJl7u2La3KcQii+NzBdywsl9CdepB+0Py/PeNd8OAoDaShvrxoQrDpmH6arkAbROLukkdaZXdyXtuuIzvCzQAqBBSzIBHZx6jkCYc7OI7QfXJhpGO5d7SoK7TbY6L1boCz1hlYS8RwH5Ozvez3Jn3Rh7EtOavcFuN4gjeJ30cjwKIFi3e8ovxYXhbgwrarwI2POFEECCxEV6MGGsxR4C1J5PCF7HbFYtlY1I6dcGmu3e/AsolkcXqHlPq7R+ohTMPpQ/8g37uOK7WX2yvUoLc8t88VA/XiKZ3sDj3xzYDYDy6gFoUCSd5bwfX4521qHOHqQgCinVIlT+A1psWIEwq1dw0jwvSLi5/rg33PKhFiDq7OjwDXAfNM51Yhp/5ZfXKUJbJXzN+aGRqud14VWkjsDswlY1wrm8yIgx0ebGe6bio1tLMnD3A1TKpcpoTSw7AmRX/3MLMgD/j6rE5lfdgVDQn7s3eHJ0iH0GJTF5+ZEEHetp/ANG+PiA8FNONXZATSNilshFQ7wMkq5B2XX/P6PwwwFsPxNL5q4YzxbHBtpSSaVnoqPGrPj0walHfnb50t7DBfL4xc/A9EiG2ir7ki2E1j4Nupzisun9mi0J9Eek7mFniOF723Kzyl/dSXuPQZBpbYAfdsekGWuH9T5j1wZaIKwTTlPznobSVzUmtxk2WEQm2+RihCzHoLyPrkc6ujtRohrX9q+1takHCKv0Mf6mOhMGzt4TEt36z+v31F0rd1N5ifT4PV9GBn4jJbwRE1vOfMOQD1uN7FUsHvIXyCSNx9H4pQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tFD0eI0iEezRkC8iS8vfxlO7Ae9cdauOoozTZHN1vY+d071j7GdEden5mcY1P6Tlx8uX3pl+nQii4Q/2TBTV4cSBZIboRvmc6jB2cnY6W42c7FLilZ3pnCuSimr2Xl92gaYvyiRuvhTmZnPoaox2Ky/8l+OQvvoCBxdpA7R2wQDKF1r75G7QuKjBrQz7xddMcyRz4XCc344GRB8o/zEDDWcibA2dky9tub1E3704/ytaSQV5oP8JAxZQT0EChkLXWcv5QYsfrbUdECaPfRz6+pJ87kFTN4xvFRYmS1Uhs93izowbSSNd+MDBrocZQ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BAf/rDPBgaq/jfWeBtQmawEykmVhe6SugEBdYsvFBLN1cOS5XTrL2i5CTCr2GEnNyyvWEtMj/6UzVL3hyG5R0t77n45eOsxFcH6h6n3nDiPMxqglARTdJgBfhHGkK3pR8PjVAn5uyFAhC49Y21pWIfD8kE7MKcMt2HcT0AXC0VV6BCZFawWfgivTI5JeIGHnCdM550qE+x2P1QpJ8k6e5tR0KSQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QBk6SZ3Drm9SOk3gPovJ9ZhfGDLT23GxGP2b5WlUpDANTDyNlIA5bOcuYcLkv2ZsXl0qUah1LGB8O/pgzgyImrqxmEJobZ8uF4n6DEtUhOiqMUD99+qQX5wU+Oew2WCL7N6V/0ER0g2p0Qm6WBqzQfJUtCz03+uP2Fayw+/sQ7vfmeC+aR1au1slf7Y6ZibGYr4lBCwr6mQGkq7PG0b11Ewx+ETyiMq5ClDUxIr0JIkhk/vBRuzSHhfBD1mx3onLPiPGjTRpTHsfH+7dtLMaJsHOPz5sBTdYK6fLm46Zv6+Tgj7+et5D8io+2wQI3QJoCyFif9mfoQXuWp3vyfF/GTBcCYoDxbAyyB6gSQYrdtDdAnM+BE2HXNaSnI3cRObtRlmTPdF5H8HHZMRjRhTOXwMZcdFsiSy+oLG1X+/zDdnlNkN3InNuZilb/lt2drJgXseIDvjje2zv+AWwSSuWR5jmOvi92x5TLPNWSn+OfvhK8xSyRVcRsAbJ/amrsAECLwK+XV1jlzl2T/XswodmggwrY7ASdAAXPimGvY9L2yzQw+EgoSCszjpJHwrd4845nKS/dU3QxE2YitoHOC+/GpHR7CziOH8feqjqcmu0f3k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1acb0284-3234-405c-e736-08dc6d796908 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2024 03:05:40.1695 (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: Sm4sKuIkBqjgq77ABq2nqlj1vnDwbOcVo0gpuMtI9XttJM3MdQITqWaf6mTilEnsoC8JXHTCnfxPkyapJsjEAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5975 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-05_17,2024-05-03_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060014 X-Proofpoint-GUID: IiJIPOUq5sGYrg5OQdlocf7zsTjpeiSf X-Proofpoint-ORIG-GUID: IiJIPOUq5sGYrg5OQdlocf7zsTjpeiSf This patch, along with the dependent patches below, adds support for ext4 unmerged unwritten file extents as preallocated file extent in btrfs. btrfs-progs: convert: refactor ext2_create_file_extents add argument ext2_inode btrfs-progs: convert: struct blk_iterate_data, add ext2-specific file inode pointers btrfs-progs: convert: refactor __btrfs_record_file_extent to add a prealloc flag The patch is developed with POV of portability with the current e2fsprogs library. This patch will handle independent unwritten extents by marking them with prealloc flag and will identify merged unwritten extents, triggering a fail. Testcase: $ dd if=/dev/urandom of=/mnt/test/foo bs=4K count=1 conv=fsync status=none $ dd if=/dev/urandom of=/mnt/test/foo bs=4K count=2 conv=fsync seek=1 status=none $ xfs_io -f -c 'falloc -k 12K 12K' /mnt/test/foo $ dd if=/dev/zero of=/mnt/test/foo bs=4K count=1 conv=fsync seek=6 status=none $ filefrag -v /mnt/test/foo Filesystem type is: ef53 File size of /mnt/test/foo is 28672 (7 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 33280.. 33280: 1: 1: 1.. 2: 33792.. 33793: 2: 33281: 2: 3.. 5: 33281.. 33283: 3: 33794: unwritten 3: 6.. 6: 33794.. 33794: 1: 33284: last,eof $ sha256sum /mnt/test/foo 18619b678a5c207a971a0aa931604f48162e307c57ecdec450d5f095fe9f32c7 /mnt/test/foo Convert and compare the checksum Before: $ filefrag -v /mnt/test/foo Filesystem type is: 9123683e File size of /mnt/test/foo is 28672 (7 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 33280.. 33280: 1: shared 1: 1.. 2: 33792.. 33793: 2: 33281: shared 2: 3.. 6: 33281.. 33284: 4: 33794: last,shared,eof /mnt/test/foo: 3 extents found $ sha256sum /mnt/test/foo 6874a1733e5785682210d69c07f256f684cf5433c7235ed29848b4a4d52030e0 /mnt/test/foo After: $ filefrag -v /mnt/test/foo Filesystem type is: 9123683e File size of /mnt/test/foo is 28672 (7 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 33280.. 33280: 1: shared 1: 1.. 2: 33792.. 33793: 2: 33281: shared 2: 3.. 5: 33281.. 33283: 3: 33794: unwritten,shared 3: 6.. 6: 33794.. 33794: 1: 33284: last,shared,eof /mnt/test/foo: 4 extents found $ sha256sum /mnt/test/foo 18619b678a5c207a971a0aa931604f48162e307c57ecdec450d5f095fe9f32c7 /mnt/test/foo Signed-off-by: Anand Jain --- v2: . Remove RFC . Identify the block with a merged preallocated extent and call fail-safe . Qu has an idea that it could be marked as a hole, which may be based on top of this patch. . Updated the change log. convert/source-ext2.c | 48 +++++++++++++++++++++++++++++++++++++++++++ convert/source-ext2.h | 3 +++ convert/source-fs.c | 25 ++++++++++++++++++++-- convert/source-fs.h | 1 + 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 477c39d9d658..9de591e34c18 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -208,6 +208,54 @@ static u8 ext2_filetype_conversion_table[EXT2_FT_MAX] = { [EXT2_FT_SYMLINK] = BTRFS_FT_SYMLINK, }; +int ext2_find_unwritten(struct blk_iterate_data *data, int index, + bool *has_unwritten) +{ + ext2_extent_handle_t handle; + struct ext2fs_extent extent; + struct ext2_source_fs *src = (struct ext2_source_fs *) data->source_fs; + + if (ext2fs_extent_open2(src->ext2_fs, src->ext2_ino, + src->ext2_inode, &handle)) { + error("ext2fs_extent_open2 failed, inode %d", src->ext2_ino); + return -EINVAL; + } + + if (ext2fs_extent_goto2(handle, 0, index)) { + error("ext2fs_extent_goto2 failed, inode %d num_blocks %llu", + src->ext2_ino, data->num_blocks); + ext2fs_extent_free(handle); + return -EINVAL; + } + + memset(&extent, 0, sizeof(struct ext2fs_extent)); + if (ext2fs_extent_get(handle, EXT2_EXTENT_CURRENT, &extent)) { + error("ext2fs_extent_get EXT2_EXTENT_CURRENT failed inode %d", + src->ext2_ino); + ext2fs_extent_free(handle); + return -EINVAL; + } + + if (extent.e_pblk != data->disk_block) { + error("inode %d index %d found wrong extent e_pblk %llu wanted disk_block %llu", + src->ext2_ino, index, extent.e_pblk, data->disk_block); + ext2fs_extent_free(handle); + return -EINVAL; + } + + if (extent.e_len != data->num_blocks) { + error("inode %d index %d: identified unsupported merged block length %u wanted %llu", + src->ext2_ino, index, extent.e_len, data->num_blocks); + ext2fs_extent_free(handle); + return -EINVAL; + } + + if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT) + *has_unwritten = true; + + return 0; +} + static int ext2_dir_iterate_proc(ext2_ino_t dir, int entry, struct ext2_dir_entry *dirent, int offset, int blocksize, diff --git a/convert/source-ext2.h b/convert/source-ext2.h index 026a7cad8ac8..19014d3c25e6 100644 --- a/convert/source-ext2.h +++ b/convert/source-ext2.h @@ -82,6 +82,9 @@ struct ext2_source_fs { ext2_ino_t ext2_ino; }; +int ext2_find_unwritten(struct blk_iterate_data *data, int index, + bool *has_unwritten); + #define EXT2_ACL_VERSION 0x0001 #endif /* BTRFSCONVERT_EXT2 */ diff --git a/convert/source-fs.c b/convert/source-fs.c index df5ce66caf7f..88a6ceaf41f6 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -31,6 +31,7 @@ #include "common/extent-tree-utils.h" #include "convert/common.h" #include "convert/source-fs.h" +#include "convert/source-ext2.h" const struct simple_range btrfs_reserved_ranges[3] = { { 0, SZ_1M }, @@ -239,6 +240,15 @@ fail: return ret; } +int find_prealloc(struct blk_iterate_data *data, int index, + bool *has_prealloc) +{ + if (data->source_fs) + return ext2_find_unwritten(data, index, has_prealloc); + + return -EINVAL; +} + /* * Record a file extent in original filesystem into btrfs one. * The special point is, old disk_block can point to a reserved range. @@ -257,6 +267,7 @@ int record_file_blocks(struct blk_iterate_data *data, u64 old_disk_bytenr = disk_block * sectorsize; u64 num_bytes = num_blocks * sectorsize; u64 cur_off = old_disk_bytenr; + int index = data->first_block; /* Hole, pass it to record_file_extent directly */ if (old_disk_bytenr == 0) @@ -276,6 +287,16 @@ int record_file_blocks(struct blk_iterate_data *data, u64 extent_num_bytes; u64 real_disk_bytenr; u64 cur_len; + u64 flags = BTRFS_FILE_EXTENT_REG; + bool has_prealloc = false; + + if (find_prealloc(data, index, &has_prealloc)) { + data->errcode = -1; + return -EINVAL; + } + + if (has_prealloc) + flags = BTRFS_FILE_EXTENT_PREALLOC; key.objectid = data->convert_ino; key.type = BTRFS_EXTENT_DATA_KEY; @@ -316,12 +337,12 @@ int record_file_blocks(struct blk_iterate_data *data, old_disk_bytenr + num_bytes) - cur_off; ret = btrfs_record_file_extent(data->trans, data->root, data->objectid, data->inode, file_pos, - real_disk_bytenr, cur_len, - BTRFS_FILE_EXTENT_REG); + real_disk_bytenr, cur_len, flags); if (ret < 0) break; cur_off += cur_len; file_pos += cur_len; + index++; /* * No need to care about csum diff --git a/convert/source-fs.h b/convert/source-fs.h index 25916c65681b..db7ead422585 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -153,5 +153,6 @@ int read_disk_extent(struct btrfs_root *root, u64 bytenr, u32 num_bytes, char *buffer); int record_file_blocks(struct blk_iterate_data *data, u64 file_block, u64 disk_block, u64 num_blocks); +int find_prealloc(struct blk_iterate_data *data, int index, bool *has_prealloc); #endif