From patchwork Fri May 3 09:08:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13652517 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 80A3B1367 for ; Fri, 3 May 2024 09:09:31 +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=1714727373; cv=fail; b=l4XwmxwHgED9VsU+Vh4BNJGqAgzJZnFFqJVqVth/879LXHzrxdrLSlFysCJqjMxRBEISNDlQ6be/YEVm2+QP/2c9tuVicrfP9OS804ZSJVVHqQcyJIkwEBMcy63CvusJwM/eIr0HSNgbJbYvIiTV3W4SBeyqwKoM/dMAj1bU5x8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727373; c=relaxed/simple; bh=Krs3jhmQz7NuUXFJsdHbG5zTfzVQmZQ3kEA6m6ru9PM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VtMv5A74HhtsCkJWyQuS0NYhq/Hb6Wu5/SenPMbtj1vf9dNHbpr6ITUJ1tnCRAv6aPkO1cdS0yzV5KhyZwJDNWO7ZF/3lut16F4igg1XAM+J+b2ak4ArTpt9axvQs/0KYNANjuhEOeBlGNKewaGCyWnvwvnx8+YG1D0Hp4tsdP4= 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=LVNYPyM2; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=xcI5/cd8; 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="LVNYPyM2"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="xcI5/cd8" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4436hweS026009 for ; Fri, 3 May 2024 09:09:30 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=kV3N5z1KDNpRfp76uxvthtVHAfsy+jaKZRPmlyCFv8Q=; b=LVNYPyM2flJ8hKLWDEYy7Z0YgBZpIvDGoVlH7k8Upiwc6kgPasBcyLYL1URTk2yvMym6 VWXlYYqdtGbAw6gYMyXiW4usXo9qiVzS8Bw4YotUts44HBdjMAWAJeSReaG/r5dcmYUT L+cFqIWJd/arOK+EExE/4W4kgXL8KY6BmqPZbEVcD2rgmR6Tnr9SKZHghj50AkmtihX7 TBfrwh3XQQgXIjbnd8kkR1rE9l1RHmXAfy/ortkUZwcwQ1Iob1s9V5IOjLbjMYg6WEPa XpAuXXhkACTEaGCvPbqddkCI7P0Xv67h4iRaMsq6/GeY/Efs+KJIE6zelK3S3PNeNq5h TQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrryvgcdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:30 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4438UYJo034694 for ; Fri, 3 May 2024 09:09:29 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtbuuj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jghjj33Njy2v31Glve1LdHR2uNe6ZlX3NOfvCULlHKNA0cFRmrYzu85nDte7dWYtjeC+rhNK1an8TJCX4mOOox0yyawFPcepf9Qv0mP4Zy3mz/z8wVBURxQcmXn0yDlqyOglJZJSLy0IGq9NYCwkj5JIZomCY7GWhI8Ra7cL8/9znSXS7h8lpr6YV4ZePCDtiLLg4xYaaCxoJ0z2XwukDqkr2moInsaymRJ2Tclq4UbPqPeefJ8rxGbDQlweb8aji0Cv71EKaVnQNlO9+AxvXGvcyxjjw9VhmaescpzYx/ZXaI8I+ykiWCsu7zbKaUyo03lKk8mu3QfbXk7kmgZtqA== 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=kV3N5z1KDNpRfp76uxvthtVHAfsy+jaKZRPmlyCFv8Q=; b=UVY9mZ3TEvyweRlZGxe3hAzB+KZGieT/5R6TweQRUaqxQqoaS7XA1bhfaEUSAUiF/XQEGiSwg9V8VGFws0cZ3ONo2DPMMD1oiw7WIVv5UUSsyGbXWD8jfhZs1/KpcYdY0Fn1BrM7qOL22WZPs8+CR5CxoM4ba1rWA1DKGg1oAxRakSq1TCdGwNmI9KP31XUgzKC23Q5VBeWpquIpAu2nR+7eWvFAvUnNRxsbUi7ZvUhEygpmynLz9vXkRDEd6s/QD5/n6NFRcSK+9WfaVAXtDWSOYN326m2CWt9J3gCPC1rYJMVBDVgY76L4OgDo0AHY09wk3e2HbjoXHk7CArB9bA== 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=kV3N5z1KDNpRfp76uxvthtVHAfsy+jaKZRPmlyCFv8Q=; b=xcI5/cd8ZJcke+JgMCaL0GmKQXZUsgTXWbwGkOXsuKigQ8waUPMuxE9qS4DU9+lGwCxnYpP0nmxjNotNyOY7I3Xlc+pxwguAaMw4J4CP+VNI5Ke9N0h/+tHFueWisf+lO6x0T2yYNqNrNznWJSvaJz6AnNtsfm2JFkNkeDnwuEk= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by LV8PR10MB7752.namprd10.prod.outlook.com (2603:10b6:408:1e7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 09:09:28 +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.023; Fri, 3 May 2024 09:09:28 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/4] btrfs-progs: convert: refactor ext2_create_file_extents add argument ext2_inode Date: Fri, 3 May 2024 17:08:52 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) 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_|LV8PR10MB7752:EE_ X-MS-Office365-Filtering-Correlation-Id: 411f0c6c-1077-490a-7db8-08dc6b50bc41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: c9kczHBCBxdP3dg4GTs8/9qC6lyMnwlFfVL63t4CCPuqt6zxRF7+cnMfQ1CfHcmWVnLV11q7oVsqi8yagh1PvXKClBWNreHHuvONnN2x1jnxNBRKjSEEM1DfBa7uvYAIZjUO+mMc2xlVT2EAdR+aI1426/JonV80Z01WE6ZzUeDQahbkOMRr2xfSGUJFXHNQ6PhCo+PaaRIQ4x1JbS9Tmiu5Wcf/7cnMmtoYtEVn5eJhM5KMbh3DWsDmlLQ4HIaKqL+uIadn3coVEH1r0VlYmGkAksg/Qi9oaSO8qUhApNLThck3eboF1JKjv7wPL57dkpgLDcjhkREe4qLcwUalwkrFvpXQ6PWG3tijph6uyEKMe+QRXEZ3h+ixIXh0DLo77y/DlOKTOPVIZtFR5YqYFfaxbyGjl+r80jY5FPVcuUVGizSU4LcrY3QN4HfAA1YM24o8NE3835RqRFUBJG7rmvtH3zIUuoU+37FWNK2v8fwO9RL7/qCjl+5gnipSAntS4QC9cYiR5MMH2wI8YYdMAyfbArOAUYKWhZXqlBQIaG9VdoK7ibJ71vPWb573fApru4YTNg4c+pRy+lGetPL6TuV06y3dB4JBQQ2r8DQiEurezrzOHZPGCLsnxX1AdoOKoPXO7GtRGQQsvzkF5LfHG9j1ru+yl8JOlnwM7yoPGSphCG+rQ7hkF4G5RMXmBjGerVbW//nHzUH7OuTA5YMCPCpx6v2PwPYt9yJoeFqKdKDa33mltp5eHqvG8Z6eTLJ3LFahP6WnLPxsIFXN6hwzUrfPW8anUqOE1E3KmjTHYdmZBqKNxklad14kiiYGEARXvxSAN4cZerZOB/e/wzqNkOtKqMKi/9co9hXSSh4rgXXnEBBSeRfph0fiGbtluLv2h3mpQ1cR8br84Jscmu8w9tVDusuRepgycl52bQIZQRVyKBsObUTDjTCgKKwJ6RqIplpR10VDSRtE5S4k5Ay3UPFBBA2CELAroK8OtqmiJfnfStEqfu26npOXeMtdQV7Kvu/Bo3wj3KtNcXKjCfU0yPxjenoYZr4SNVJ/AfdC3sz73gBf5bJulYVMyXQzPPEAelyxAUFcS0QTsM/VF0jrT1pJ7kUXQHfy7L1xA8/DcteB/damjgtXuuX1kHtfFsYBALTgpPujby1yo1QETZ7HeywwxhZEu4LNVYy9h5s3H/54Y3G9OEBb6jeqbGpR7mNOVLpn2r/Yo9jaWmLwi1t7OK2wNnJ37m/RRfynCreBNrALh/omAv41KNksmUu3GQQT+MYHfXSGclKkplZkp7G4nw== 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)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: acUJxAGKH4PlngY/9H3gwM4EW9nf7eb5/oz22pr0sqnlRUhu719EYXlaJgXpDW5NDqJzN2U8qFl7El19LbP4pEjacNfbkhfhegy9MM8QqHjLeYIuq8C7yg+tKNCqnn7u/oWWGvNHUcqGEFb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PuaAMLF34pYuq8Hy2K1XvRLexHXc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 411f0c6c-1077-490a-7db8-08dc6b50bc41 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 09:09:28.2374 (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: jC8ZDOFWTE0zW15L0NtSbkTgRiBh24/DikEzdQKcTcgHEhfYaEZ2PioKzvwppKYeAH/mHs03mXjDESnNiYTPAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7752 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-03_05,2024-05-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405030065 X-Proofpoint-GUID: gOjTS0PsLQYkCcKj9ifJ79rfuhs7EZjq X-Proofpoint-ORIG-GUID: gOjTS0PsLQYkCcKj9ifJ79rfuhs7EZjq 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 --- 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 Fri May 3 09:08:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13652518 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 092461C695 for ; Fri, 3 May 2024 09:09:41 +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=1714727383; cv=fail; b=Etz/DeW9NUs6WzVhMJ/Mj5FSHo80furrGJ3y7dZqMtwlouUkDv2JJfwF84GeqnX5zAVbjfvDwnbWeSKKAvbrIZi5TOk2RQ2+PsxeD+dweeo3mArdIljL+FkH2pGBbpEITk01Xj7Ha9QJOHFYrbogQI7gR9l1POpHiNJu+X6aKbQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727383; c=relaxed/simple; bh=yRdFkBFBg9qmVXSAXJbJ0/YudlQTVlV+RLFXEb6EOuI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=aGZTMuqhuYGwzS0sYFJGMzmYP+MzBzevvVgSjkUrwmIuRY9dKoozha9X/h7dUHAscOhKB77nIv3P215IVtSYS3wf3LNvF0yLk8GiRK2jas46nbR+wjjx5tcBve2O8q1wnh/d6f2c5tALUSK/C7I+J4WS8HCM0NvmG+orktHYIwQ= 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=eGVB4MEy; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gOORCO4L; 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="eGVB4MEy"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gOORCO4L" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4436i9Tn002060 for ; Fri, 3 May 2024 09:09:41 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=np/fUnX940jZt346gPctc6PaSkbIuO/tp69i6QaOCvk=; b=eGVB4MEy2rkJ4SbtzuOoC3d4j8wZx3/Ahm2hgX7Vee+MPfXQvLCbdWrR/lvxOe8RBZVj qmgLZR/dsfnrisKhxrlib6w3dboTAcWJ0xBZFZAaZSDKbEuy0sv1dOTjmLpV7YWc9rss irxEze1hqAof//eTMXfqlZHIGaniyoy49yq/UOChiRur4wsk2EN6357Z2OlYFAsTZdqa BQdSZSEhaZi6szgcNjmrkzxg1EvHEtJpYjb/sXKc4VQ3T19CnylM59Djs8FA9GI+jdf5 dZMk04duDuGs+xIGpLd1jX3twaNF8rknm3ODKRDJpZyU1FSiFzuMlkfaY5T52I1olOx8 ww== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqy382bp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:41 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4438H4FU034735 for ; Fri, 3 May 2024 09:09:36 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtbuum2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l13gIQDyOyLlNwkpzBAupItabwC82EdsZU2hsyDDrm+gMdN8hlKcmguN32Q1DhBIxx7SnO8zXI0VMS6xAh86XIbmA5Ow5XXO9dbqxPH45uzAWUNSaflNk3oSXX8T3ZQJdvmIgEb5BO9DAX8NGab8amikGzH2BhfDEEv9OLpODhBKl9S/vSZQWduTZsBelYmGwRGntYf9yhzp78IIy6gWQpLe07CirxtrKfZTftyimHE/4XwgVC1ZLElJO+ju7F5P2dddmJ2Ur1pjhtDPS/zqxJJ8ih0XMeoHQTjtnpT/R762RU3qhyZH/QqnTR8l3jcMbdlh95l68u2BK/dVBZm8dg== 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=np/fUnX940jZt346gPctc6PaSkbIuO/tp69i6QaOCvk=; b=dIcvHkubu7+xe/Fj1wuIxXjS8scHnudoXum+l16uc5yYqgPaj1cxcC9FSeagvRYaGyRdatzIKH8mqrhd6jLed3nJf/K74QWwAmloFYTUyQWXHwF/C8rHuXVRqrPlJ5fJXfSWpl/9afjtzAygoELcMtJUUqbYSUXpiQAq3WDaaadTTDJjc5rubeyELzcZh4bdY6g80GPA/vK/qI7J9AUPazgT7Yo+DC/093RVeYmdxjCZmFS0OkAZ0vYLI+PMLfj70TTJruSCGrbAHLOBYORXrefSgMNdEAu5RNRSLY3cyIMh+dtsocHRn3d7T8aZd8ZGxUfgO7xsGaBYr79nrnmahw== 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=np/fUnX940jZt346gPctc6PaSkbIuO/tp69i6QaOCvk=; b=gOORCO4LufoW9lagWcg66UZnVRGHxmjVSY+eH4O9hM2oAOK9jQIK2gH1m6U387jZRV/T+K0akTJx6HyRuoKrN5yTuIlx5lvWWbNjCLtpXw54c1A45w3FCZYoC08j3eZ3gVCxgsfqxRzcuXeUxlNNvreZ7GHFDfrWHBlFuylsbQI= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by LV8PR10MB7752.namprd10.prod.outlook.com (2603:10b6:408:1e7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 09:09:34 +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.023; Fri, 3 May 2024 09:09:34 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/4] btrfs-progs: convert: struct blk_iterate_data, add ext2-specific file inode pointers Date: Fri, 3 May 2024 17:08:53 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR04CA0188.apcprd04.prod.outlook.com (2603:1096:4:14::26) 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_|LV8PR10MB7752:EE_ X-MS-Office365-Filtering-Correlation-Id: 933d0b4a-1317-410f-f4a8-08dc6b50bfd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: A+6KwqHNwMekRAV7lPyVTX14EWX40XyYESUdnsCAKIoUtRzF+5+N1o4RWjF1JtpQote5wOvNoyOIYZUz44XTb89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AHPG/r8pQrpmHlUIp0Gu1/Ah8nIkqxIldhW8gWajlDe7iQuD1GuajDKSXOZhZM8r1LQ9Vkn6HtsDwjUTiU9nPMYzZFJjtD8LeepAoQkuZpHsGoG3epMjqeYHTdVLEQ== 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)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ak6+ROLFLPppCnLtoxeDBKZvYdZGfErIalGg5WtlxzcWdSaE9t3rhgeP1kjVAVqzQ7qkUL/k8mE26T0UkOtgbfjxtiBr+sKoe3KV7umjNL+nFN/lo4xSgcQZ6+hf90hf5SANOmiVh8gWzFyQzTyBrhuoTyv2+UL2B4PR9fFZInSP0lWoOYCUJIDoiLWsPwiXE4eIMov/4vNx+aGHA4mMKb7N+3RRqMiPDXEtrvH/r4houGfHVV1OpSdl8lbbYdvxzBbZ3IfkaTY58KaVIcEhfnawR5q2mP2yHKqKWlHhO6iZ0/hySTZsGkmObXI1QdiJdxQxkAedP6At+SGugWJSRoNdgwojCJiGFgIkxCoBrn0Zi+FEAYIBu5w1Kef1UKiEQtQa22HAXWvpGJ6DV/KBxVcmpSXvw4/+XJxqjiqG7Wk0dwg9itmDqhf+tec/9sigzBNlkTb6/sS0H4+DMagM5nvq1OdUgUoeuel2W89edtRQuNHqMueLp2OfHiZc7VNE6AiQAX+7H+Ud3VW2kubDy2uv+lo7j+HGvcgA1QLkLOsKWG1SIb5viBdBZfbalWGczz8krd9XUUrIppUPYjlyLPlp3xO7MiHJis7FtCIAN4w6V/XTcOMEXe7Ocej/DPF2TFgNmupqps8XNNZJUOrfqOObfgMSaDe0UFujmwAIzBbiG8a+kOkzu2qxSki8RigeJY7Th5oDW6vYveGi1HKbOWi3yZ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Fhf1QQ78u/oNaCEDv8iIXYiJ/UclNRXOJOQiLBLjvHGCGg0mtElk8q7Qu04vLPDkfntckXMNxIqoUNEYPYIEktX+fkmAuXWikjJfIRdXbwxUgLLmYpAo9MJgQoySpJKjag9qeJxrwrpX090HX1tkdESAUltImgt2XbNFxUJHHiVOOHBFajHJuMjvg7ZLQfvXrCrgs37QlqUCzOg7uT9Z+X1WW9ehn2EmCh0H2yq7cabPg2F/5hX4Nerd5996yJEs88oaUw8l3N6jL0N51VYnAsyxRiOCZfYj5vQh2ZGy6FEVUhRBagWjZX6gF/LEh3BhOXOEkYXtNb59PHfAoIUYpO+BVujAaPX/XrDstcYacsT0bb7UVKeXjgxmBhBwu1dYpgXpBpF5RHUX4V3E1Tep9Jye3Y2NiRASfGNVtEErdi8oy0vJ5E9JEmtG3FV7nvhLer42X57B1nDmcjeDP3RjIMOgEQvkBFVBrBFWs6JLPQUqb+Xbu32zRaW2oDzneEE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 933d0b4a-1317-410f-f4a8-08dc6b50bfd2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 09:09:34.2346 (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: yT50aoF9IEVNYelxmZRUi0o3GB2NedJL1weg40aoTKTFlD5miDjGEXR4RK3Xr+L2xJW3oNbaVPQNYkUK8MEKFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7752 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-03_05,2024-05-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405030065 X-Proofpoint-ORIG-GUID: GpLTf4y8ToAgyw4Rpxkq2JHz_ddWTliK X-Proofpoint-GUID: GpLTf4y8ToAgyw4Rpxkq2JHz_ddWTliK 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 --- convert/source-ext2.c | 4 ++++ convert/source-fs.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index a3f61bb01171..625387e95857 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -324,6 +324,10 @@ static int ext2_create_file_extents(struct btrfs_trans_handle *trans, init_blk_iterate_data(&data, trans, root, btrfs_inode, objectid, convert_flags & CONVERT_FLAG_DATACSUM); + data.ext2_fs = ext2_fs; + data.ext2_ino = ext2_ino; + data.ext2_inode = ext2_inode; + 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-fs.h b/convert/source-fs.h index b26e1842941d..0e71e79eddcc 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -20,6 +20,7 @@ #include "kerncompat.h" #include #include +#include #include "kernel-shared/uapi/btrfs_tree.h" #include "convert/common.h" @@ -118,6 +119,10 @@ struct btrfs_convert_operations { }; struct blk_iterate_data { + ext2_filsys ext2_fs; + struct ext2_inode *ext2_inode; + ext2_ino_t ext2_ino; + struct btrfs_trans_handle *trans; struct btrfs_root *root; struct btrfs_root *convert_root; From patchwork Fri May 3 09:08:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13652519 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 F156414B076 for ; Fri, 3 May 2024 09:09:43 +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=1714727385; cv=fail; b=W6zohquXb6n10Tf9rGtPe7wBlT9Vk066+1ITyx+g/b7i4+R5lHISwjIuW0Ti0E7HF2Xf3dNCgRmSeLN8Kw62XvIl6VMjzyEYsob38TSIrfRXqHbIZmei1u+Ba6dYfFNt5fXu2YcvTmFeAPB83+VbOsbnwxumgxhyQMrRxeFdvIA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727385; c=relaxed/simple; bh=2+A3dexfmSjHyd1g84Vmf0R5JJdoWEJ9G/w1WbWrylQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=LNfUfe3ZokxWy7/tGiI0lFs3aDvNNC5B6MrBIelv21XR3kD8W4ho3jeEqeYC/+u3mdTBTEci2uaUjFZKD5rKRnR75sipQGpTWEM3axJ7xkg7KNyzJYrCFJecfMh7iNYlNOZePnpkQWLCLgH8WianTjJhAFiHDzisTguMKv4IupA= 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=e/uLt6FG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=mcmQvAfS; 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="e/uLt6FG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="mcmQvAfS" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4436hxXa004322 for ; Fri, 3 May 2024 09:09:43 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=sxqfER97v2KmbyX1GAxjhcIh0TK8MMj3OkdG4TvhjFE=; b=e/uLt6FGS8GzumLmvMjgU+YinxZsWYgBOwD9ib05AobLdzhLmvx2aRinPuAOwAfdShy3 2Gfbe6+c+y92x8ddZbYPuXYgjLlYS/ojzRQvLiUwsg3t28rkQJ+gPc6Ckaiut9qgW834 LPAXw97MmGhIJ86ex+L5Ae5yilNTdNDv8GAlx4qoNwppsqL08oeu7Drpy7ZELyWsbGHm c4Bvbf8eW+xKzlUh5ymdwC8MzzqKNWbtNm9ZdgUn0vOd/0tldeK/EeVPb/WpvWNPnxnF eqB347uQIGHLRUya2FGY5NDoTdnapRmCnqIImN34iSNPrDlp+hENwaYHls4vDf+L1URO eg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrqsf7eb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:42 +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 4438hO04008825 for ; Fri, 3 May 2024 09:09:42 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3xu4c3c862-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWlxBB71MePeqxzITYu0kNPC+7KpkCSHmHQqDL5eSkCqtgBeSupf4p/wtzvosprCvz1PJokQ/cHWXPOm9JC7SxCkU8V/VrIXLQASQy0DqscYEBVZtUUAiwkIvZyAmeqAtfjqslsykUapDDHIJExClOJeLxoimYvGQWKYgUCSXo0K3SgMh3prTl+8DvdRdX0Dfy8ffjZ+Nl3mzDATzXENcK1YDrctYUkv6q9wrriSrz+DE9CGWfrj5A0JmWErRHe05YOgx+7KaH5ts27ONugMuQWJcbp2LDn09cG23Y5yY6g00BUk+VFGIzrEnRkvhTnTwWw3ZAxrKZPrnnb3BIkhcg== 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=sxqfER97v2KmbyX1GAxjhcIh0TK8MMj3OkdG4TvhjFE=; b=bEAtiSatA+HF4VyYdlXVtGpWlll99Zex0go7zlZmBLjM4yM+bVon44qEMaD2fqTts0cRdjVTiVbsDvfrtyhJKNSBIoT5FZJeYunJ3YcesXTPUsOgVYi2K6a7YD9LXRfolYvZd1ndyTG4Srt9IwJowNImi2jn0YJ2ks1XvYm69fspqEMrM/H33PAw8jsLzPETVdv2OKBbsL8BIaHJZCFRYsai9AC6BM5g58zmuWdAu1lcw+KmfDNSNH4xpsOWjEc+FGg4IdgyNHMOITeZ7IkdlW2XZz9XcpM20UPJ22PbhiT2/WDLMCPpxwFgw03bNRSTpjBiehrK9dhcv1fscN8HjQ== 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=sxqfER97v2KmbyX1GAxjhcIh0TK8MMj3OkdG4TvhjFE=; b=mcmQvAfSsJ+e6PnzU8TI2LHAISnMdikkexhkFDd2cXq2ijBV+cTuNCFOHuxfQMR+/fl2axC+lsKEIdgOYVUUbFbCTgwmPy0ss6ce1hwGow9E10veVbw9jX1oJtt4Mmntvk6OSA3oxOkNmdDcVZirzbrZBl4lcQTo2mK49+FZKy0= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by LV8PR10MB7752.namprd10.prod.outlook.com (2603:10b6:408:1e7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 09:09: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.023; Fri, 3 May 2024 09:09:40 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/4] btrfs-progs: convert: refactor __btrfs_record_file_extent to add a prealloc flag Date: Fri, 3 May 2024 17:08:54 +0800 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0092.apcprd02.prod.outlook.com (2603:1096:4:90::32) 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_|LV8PR10MB7752:EE_ X-MS-Office365-Filtering-Correlation-Id: d989e53d-ec7e-45e2-9a37-08dc6b50c35f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: KXJJ6Y4WipjPqUYPtApri6/VSOzEARJ40jcpdH84+CtUYzYm8lkoAz3xZv9sLUNJHxTxNubZ0QfP4hmnrxYMH69AUpn/FgrCmA3G3mgyLQM65AjsGEIhJdYDbTRJeHNRweEeHV0Fb6JnIv9e6HutMPOCnUu/GaANDf/Bcj0EzSXI6FszGs3f1eq80LMfPoCOupiWcOmRjWYwbZQWCNydVIxHZWsCIIqO8+WTSLXoxrcxqJu6bJHX0MXu/kXT1ggCzwqWu8UF+DzkYme8ifG/rs+kdDL5DHBCGSqqVM07KHOV3sbwmIlK79nw44xnU7X3R1zv5G7IoPDrQq3g/n6JNQ6EuOxCoENe1hQzKhJsTMzeNCONV5c/LEK0JVossKIdK5LRYlWQF8FWUO+qrPttOenHW9Vlrv9siaOL6Sukjsc+xS/7SzT47twfDfk0k3lGxGgAnRE091YcvT9wh63No6QAcxg3GFOUH0rxarx7SobCRcE79Bu+F3pF5HQCoknRHMEk1h2/Y0uXPKCZ2xAop8irAWBcKvguIE6ZzEBS2cE/xCQuobmpWougXvsnVpUeBRg+XJg16cETRGvNgeKwF9AtX+1DDst5ev7EP4l2H56LfId53oxyctgkEupE2MgBny3SwK9BN2ldHoWHjEj/SsiNMNHggWpPmW89o8Bh01nIj+X0jV0bRhtvKMKeUn1WuuX+jagRLAXCPcIs1rSPr653QKDElvrIC5fwfymmc6n7j4oNUSPwc07g24GEO8g8Vz2WkbU7Kc0nhcdYbTaHYArmD7XDLW315bVyWVrhJcUsNUnijCBTcOtblBu3Fhs7zZD5LjF34pbXmY+JTyJEpI6U822hZpVBQ2kl0GdEnMfDGTpD1edRpRHCYX36iZlgc7WBhTYz2iIUg+yGx9o1gpfwvX9Xypo1LF4pU8Gxn7bIc71uPiCGcOcGc9tbQ2HH2XB51HLSWfhYXVKgxR6YgwA1N/BnBvlkqPcOcxxcW15Arkqj6sKOiYUof5M++P3ITaQ9/5sf1ewXK7uhGWXxTlciVwTl2m6wEL6g1JYQb8Ny7ZU5EpWSQcW84ySWQ1dICIE5L8IyPmxXwLZkz2llGxko3+SfgnoMjzCsHyePUt6E8LH6EgJ9QmMQoGrF9tC7P83n5TNGEtqfWzm6jRpUBgYOtjIOzN0xUgx5g7SrLTL/EPhJPcuXSMeRi1HLdncVKeL5C3PKa/QLkjXFwt2bUkPVXQAFpTOfy/HHsuDwwhtDTZoNP99QKg98OyVXmH1o0wUqfRppQYQagdlYCH1IKw== 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)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9aY5+xzBXLOuLiQ9io4ExeG1DgZ/nprbPcOlPl2VT8rswkn3aUBuKiBmsTZaoVTezb8qi0oOybiKrFModx4ItHcoanh1E2cxC977RsRX06s2ogvoD1Kf2Aat/T/lOL2P/O4jmqXHeVhu1fSPhOW+XjDtntRoBqLFcLmzfGUJDgztmRlugtINj4xZjxMm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0xIh4SGtzSOeQCCGDAb8e7t2D97MvelqFAGHSoJjiTB14CLnQ5EQKjJDSj7E2i4JPXYGWEp2ztujxNf2l6afA/sNvCVyPQKIT94C7D0J2Gf0TNbDtNCiydNJseMI0OWXekYdqSEG59Q5t1RRGhzUhysnRKM67A0HMGTG4xxDM8+gR9gAMwYiXM+M2oW2WK4S8x+J6bDTmqT6SHCB8LAbjx3kkAcsDxdaKCvY7nSkOBHhAJiQo2P3sHCFcmKZ4HICN5JbtCP4vOvDRlpDIA399CXUDWH8u0cGyJ6VDdHJYsOnR9bJUATJsE4OPRn X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lFU6RmeedhesAH/s/7P8yH+KDR6hQ50QU2xt5t+fHlDa2IqNfED7hMOwiAQ2t2lHlnLsWIym6jJ67Y3SvtqK3GQ8msTivQaDUNaplXMoo1aZU/AqaL1inkBsmmf3PGjo2azA2ff9nlHQeEL1v4uu+4pS/DxAmJFGSbcpMoVm84X38byHm8gJSidTw5A5SmtUe7NUpi8LdDIAfefEuVWhmMtnfeyZDipinKVKfYy67IpzYL3GxaQgngjOHjqJCy4WFI6xhGQbxalZJnFiCMZ/krgvwRsNVpCKfHadaJ3MK8y4gxl7EOthqLw4C8S4RlFsIc/1niV4XY62kBB7V1iD0J56MnII1r573CeZgYEo6CwQVfXlxRnolZtDbtAzSaFBowWV7tMyRceo3ePM9i+bNa9bzKDthUhOsSIpFIZATrTh+ba9NjXCs/kanYhRnhtEj6f5oMq8QA4I355tWzMpAsLZT2FZYtDTU9Smds/tQoYtBzP/fHghLdfh6oIk+z+e0dbw2qg/XbN695AybMmMQIzGfue7YrMusj1gSvJf8HGYMVWJ+3E0263eX3R0459Y8caIu+uKcAVghgJCigIAG2fl9Fc3a/NzAdWJ94L5D1I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d989e53d-ec7e-45e2-9a37-08dc6b50c35f X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 09:09:40.1897 (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: aX46imnnNzLbw3nzZJdSuidXg8SQy3uB14oPZMG7u4pG0+E3puPCRznC2L0QgjPoau4hkDk2+Ul5fVla7wXC3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7752 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-03_05,2024-05-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405030065 X-Proofpoint-ORIG-GUID: b2JwpFbWZ-89KMtfLpokf4X6LFl2CCNV X-Proofpoint-GUID: b2JwpFbWZ-89KMtfLpokf4X6LFl2CCNV 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 --- common/extent-tree-utils.c | 11 +++++++---- common/extent-tree-utils.h | 2 +- convert/main.c | 9 +++++---- convert/source-fs.c | 5 +++-- convert/source-reiserfs.c | 2 +- mkfs/rootdir.c | 3 ++- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/common/extent-tree-utils.c b/common/extent-tree-utils.c index 34c7e5095160..2ccac6b44cea 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, bool prealloc) { int ret; struct btrfs_fs_info *info = root->fs_info; @@ -229,7 +229,10 @@ 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); + if (prealloc) + btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_PREALLOC); + else + btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG); 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 +268,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, bool prealloc) { u64 cur_disk_bytenr = disk_bytenr; u64 cur_file_pos = file_pos; @@ -276,7 +279,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, prealloc); 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..7abd0337ea0b 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, bool prealloc); #endif diff --git a/convert/main.c b/convert/main.c index f18fab4a236c..d67c4e8eac25 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, false); if (ret < 0) return ret; @@ -426,7 +426,7 @@ 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, false); if (ret < 0) break; /* Finally, insert csum items */ @@ -438,7 +438,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, false); if (ret < 0) break; } @@ -455,7 +455,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, + false); return ret; } diff --git a/convert/source-fs.c b/convert/source-fs.c index 66561438866e..9039b0e66758 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, false); /* * 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, + false); if (ret < 0) break; cur_off += cur_len; diff --git a/convert/source-reiserfs.c b/convert/source-reiserfs.c index 3edc72ed08a5..c67ade9b4c90 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, false); } 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 Fri May 3 09:08: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: 13652520 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 1C27E1C695 for ; Fri, 3 May 2024 09:09:49 +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=1714727391; cv=fail; b=L/lxNjzz7Zx+TUDWimLu10tRm6VQ+YKIwxJE95IwNI+CFSsTzOkCd6mPJgxjWkLAEwjlpvJU0imhvU4/BrDB24upO6kGtuQYCI4vFhmrSh1weU8NHxqI+ojRW9Ggo3yj4iLUNEHZthQpq5j50H1wlpfTPTVXDB+3EacAsfj+q3Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727391; c=relaxed/simple; bh=vhYuaKojezyybnjtl5g1EjvWbyQPeZ9/iR5UpITdyEs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=AcWRXiiDC8frPm6SaK+wlW9btEXVb0LcXj06UHBkJXfsq4uReYT8h4Q7gIEZQA4/FlLKP3QRgatyW270ayhOqxYNwFDwUIuAacBrXb82U+BayqrPPFao70TQc9EGOtJJgs1E/j8RT/bDOuZRYTKmk/S+flNwlKA+Q4dCGyOVoXA= 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=ebuSvkB7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=caPKniKY; 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="ebuSvkB7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="caPKniKY" 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 4436i868010900 for ; Fri, 3 May 2024 09:09:49 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=1LvE3QX6p7L9T3uWZilrYL+WS97VcOucvcNpRE51acI=; b=ebuSvkB7Kk/cVxuZlYnlmN7VFk2xfMVg/PRHHq5Usheo9MAqtyvRnsuF2oaLP1UVfL06 U+Tf6XQQrXUiWv/wxCW/z8k3tbaIvbZYVHKArvECrlNMOsZgb4UiWMNrKBnz/YmO8Q69 L5H9irOp03agUWhIbM9l4kJxB3A4QdnxtjQ4jkLJoxNdybqSU06+FYdwRvgBVp/FKgL3 X1OP5rVrOp3YnH06yoGmir10zoT8QUA1oVSDsHCBg0RmZ4HQhAqTI/8UqZ0JXmhit7g5 BerrjHgW/BmGFP07gS5jcxBcD5EQYlLOxtBpcPgYmaHqsL4cmcTWlKO+k5SliyB9sH3W pQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xrs8cyc4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:49 +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 4438YYtd006073 for ; Fri, 3 May 2024 09:09:48 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xrqtc28fr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 03 May 2024 09:09:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TPSG8ysu2E/nxb1Lw5v5nnlmE3TVC8lBpbJVEh3OgoLkRuNaoVi745Ik/RBWPTVUm3++z9Ta457NBcyrvuD1IASKiYixEG52WRBbHjmVH/fLY0r7VyQEXlSCe2H3+FcBaU33KMLbbzKknW9LoYgm1Vlrw71sU3Y9EU80A968mc/XSxRH49gFiGoMWIsAeDDbHlmZaelqm2oQqequeLyuguYIk0QqDf5TM1wIoPIioE3opZZ2yJr+VLvgYeDP+PHShkBz8OllmJYxKFJbOzvzjoWoMiqG+/XvI+bJwQtagt9Hu+1atASSt+B9z4oUc3z2gwD8KRJNcmUTDF57iCYb3g== 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=1LvE3QX6p7L9T3uWZilrYL+WS97VcOucvcNpRE51acI=; b=BT7gZT3bFrSWueMd13PzZHdUzmTNBPQ0el/swNccS0INW8uQDdYatfrqYyl+tpA+9b4sCFojuYmXP+hZKMjakZ0Wx2cJ6wP95T1HSLlRrU+mh0L5V1gs/bSLTrptmOPtnaOVFvcr1/95AI85T8qdsLwHR6nsTLCCApS8SIXxbxm7OxnAhSl7ltmDFyEvfiJNHWOnPx9KBinvTmUgTuiEhe7s323oEEIRNRZHXc/ZLFv/kD5z8006loPLjpyyvVRr2LYr/imc32L2pnyF+FWTFzHrjT73t9AKoBACWcqYw928D9l8HzCWrnHuH+Y/VdiqNNRTazQ6j8JXF6oQL/5Z+A== 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=1LvE3QX6p7L9T3uWZilrYL+WS97VcOucvcNpRE51acI=; b=caPKniKYSvzysq+ueDq7Y6XC5lBSW+/xpfv4e83ul4rIwn7nIte5yQzKHa5PbB30k9bMmdXVE+0oWLIXbjBJbvOKmC5rhjk78Ef7T7hVEMIkkQ5GoahfKpmzEyPrZESfS/abC6SuizzmKHmDHjVKLZmclbg3rDm9NDItUcVRxwQ= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by LV8PR10MB7752.namprd10.prod.outlook.com (2603:10b6:408:1e7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.30; Fri, 3 May 2024 09:09:46 +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.023; Fri, 3 May 2024 09:09:46 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH RFC 4/4] btrfs-progs: convert: support ext2 unwritten file data extents Date: Fri, 3 May 2024 17:08:55 +0800 Message-ID: <6d2a19ced4551bfcf2a5d841921af7f84c4ea950.1714722726.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0078.apcprd02.prod.outlook.com (2603:1096:4:90::18) 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_|LV8PR10MB7752:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bdca01c-2693-420a-e73a-08dc6b50c719 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: 5wMT0peTbzuJfv9/YVm8pao4LTG23NSVyBhiSKty9Mn7jLL7bmZa5DmuMctZ7R2QjQXByF2U3lZx/eGyhKXCyWfqAiIhVoRgByOVXLlatXr3kvmKmbJ2M+5zi+Z8eXyjtc/K3BGrpDKquUYiTcsu44CydIUS/r6WnqMh+2nZCYjqQ17TFnWX7ZQu8iqpGHYqc/BptZsRYc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9C56t2MWfNLXYBSbhFy11NmNhlDCGOqmsQ== 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)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EN//Pocsshee1+6BO873wvLe71zS1Jcr4X6Z1IS6MielUmFa4kY9kX3/3wWp3nyZEZBXeR7o6r7drnEpvS3rT9NhfuGqpDlOL7vXbaQzJ6QMBlIvoLltLPNIdxXm6/ZxEnrnJaUtkOW00gC3rrqaclqNi8IfXGh3E/BpZWTfBUd9pV7anDWOMPOaweoBhKai81fELAt366TDOB8HHOnl9opeGEM3tjgvIQqq8wBgxEs5NuvACc4Jd4BuCIG+3YAWfK2o54pklTFfEeuEBpGH0fIkBWKfkJLoVXl62GMoeeWDWgAn6ttSXv1Pd1bmj4WaBJRqsJE26ZiRxdP19R+auoH8JDPfwu0Ljnt/HUjuWS25FHts5t+NUzLylo1MS+om77WsJTtqJ58n8sOzUwbaF+/ancX6lT07iZjDznFCisesL6Zvugze/6QjW9bgkjv+Hi0JtagdATdDsGv+y/AdedyCwLam+gWlg5Me37rtCNOcLkUfYOFP6kIlFP1Qj0rTB4pMrlytsvoaB9NnP4qwb1X6W7FibN6vb6MV4FYOzkgYzwz/j5p8VzuTLYWsV8y6EKsmK1sVe8R776aJOQm9xAb2CB0YFlvn3DHx6LXJDG6BYj4Ivna6XpupxeckH8n9pb42bRwZ0AP1+bi9QDdfW2Yaay0ladScRHPcsifvHNUq75K+vO6nAW6obWnHIGho7UosuoCZmgnZPkCJYX65Le0j/cRFyru/nOUwidF702wC+4oCpPuRL47lkzQZXM/3LkMZ+XlzizV9ErRRBwKwdcYrk6gzpCcLKMuNu6tfE/lM4W4gKB0eSyjyAcf5oobsLDZMR1MLN0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99GDRXzFDZ+NqvOI8JkgLhmcjmWswUZtmVhb/HACSQPHuFRZSy8CUvIWEKJKv63qilSsFBkVr+iTUW6GFuXTaKwzYA8vksU9lB91N2s7Sk2cW5QdlFcucEN+x5N1WIt61JAMP89e3RpKznt8VyRETEE5TrQ/HHrcn4qHbu2CIbOo5IOxZiIKaLEKZMf3sWls1imXn72Wgey+RBYP6PypKlNkZ0oXnhfKv3rNyeFrvB24DDONw1ff+W8jd+JYTpEU/4XReXgLhOxAV1/CNy5lEwlZfFxqtlbUsinzFTEuLn28ghGoxmtlvjbHRY1UTB56PEpNon4poqK3jloHKr2iC2kq/9gZDpTXLsL9lBWbAiN4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bdca01c-2693-420a-e73a-08dc6b50c719 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2024 09:09:46.4332 (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: 7Y0kKWJxWBotI22IIy6V+bFWCEKkaXCCLxtCg/Zwoi7YhZ1gtZw5H34p6OuANKfMH4qCGHZjdcvA4pBhzAvwkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR10MB7752 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-03_05,2024-05-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405030065 X-Proofpoint-GUID: VRjLNTJNv2KFSBqcqbsLnEvJ_NtQ_5CN X-Proofpoint-ORIG-GUID: VRjLNTJNv2KFSBqcqbsLnEvJ_NtQ_5CN This patch, along with the dependent patches below, adds support for ext4 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. 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 --- RFC: Limited tested. Is there a ready file or test case available to exercise the feature? convert/source-fs.c | 49 ++++++++++++++++++++++++++++++++++++++++++++- convert/source-fs.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/convert/source-fs.c b/convert/source-fs.c index 9039b0e66758..647ea1f29060 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -239,6 +239,45 @@ fail: return ret; } +int find_prealloc(struct blk_iterate_data *data, int index, bool *prealloc) +{ + ext2_extent_handle_t handle; + struct ext2fs_extent extent; + + if (ext2fs_extent_open2(data->ext2_fs, data->ext2_ino, + data->ext2_inode, &handle)) { + error("ext2fs_extent_open2 failed, inode %d", data->ext2_ino); + return -EINVAL; + } + + if (ext2fs_extent_goto2(handle, 0, index)) { + error("ext2fs_extent_goto2 failed, inode %d num_blocks %llu", + data->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", + data->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", + data->ext2_ino, index, extent.e_pblk, data->disk_block); + ext2fs_extent_free(handle); + return -EINVAL; + } + + if (extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT) + *prealloc = true; + + return 0; +} + /* * 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 +296,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 +316,12 @@ int record_file_blocks(struct blk_iterate_data *data, u64 extent_num_bytes; u64 real_disk_bytenr; u64 cur_len; + bool prealloc = false; + + if (find_prealloc(data, index, &prealloc)) { + data->errcode = -1; + return -EINVAL; + } key.objectid = data->convert_ino; key.type = BTRFS_EXTENT_DATA_KEY; @@ -317,11 +363,12 @@ int record_file_blocks(struct blk_iterate_data *data, ret = btrfs_record_file_extent(data->trans, data->root, data->objectid, data->inode, file_pos, real_disk_bytenr, cur_len, - false); + prealloc); 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 0e71e79eddcc..3922c444de10 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -156,5 +156,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 *prealloc); #endif