From patchwork Fri Aug 25 14:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13366054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 787BCC7EE2C for ; Fri, 25 Aug 2023 14:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343857AbjHYOsq (ORCPT ); Fri, 25 Aug 2023 10:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343846AbjHYOsR (ORCPT ); Fri, 25 Aug 2023 10:48:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41EC32119 for ; Fri, 25 Aug 2023 07:48:15 -0700 (PDT) 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 37PDOXml009444; Fri, 25 Aug 2023 14:48:12 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-03-30; bh=Prun5xbqsPd8/AZiam+eDFNiFyBWa433K6nUBs4+lFQ=; b=zNsUzlX6bavm7PVAicOITFbpXQzf9UhEZ5TCQo30B5U+Pw0EtecYzgs30K+5DAcJHkSz 24+DhkIfveGgZaTSeigeK+kvBUupEypHmZANOkC0WgPM6vEtIXXbmrRiWawGNL3Rws+j nIIMM3gVgSE/CrKMlKi/Jy3TZ+XY2L25piFk0GErRBvzTnk5NxJ/0dIPUVRmMBIoZ7vP RKqHUV8tyev9wj7icsg+4x7I2T8OSgoKSIX0nXc90yEC7eLwy+mgjnbCD4BiY1XwZ8wM RzW2DFAKz3sIkw5Vjv+dDbh6VjF0X19ujM5Hk1FTjX8olyRKppq3JR0/rGufeMwz894L 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 3sn1yvxf7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:12 +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 37PDKIXO035989; Fri, 25 Aug 2023 14:48:12 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sn1yqx0xs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RR5Ptm4yiZQHbA4R7RJqctimcdXIcgwapOke4UkqNRMxRU4Z/a3czIJ47bIFdVn43VNBgqvD7on3RUn8TummlnYTKYLz6Z7YVU6gLvyWnEs04KP/QIRxrLLGukkssY5Uw+ZwCF6Ths36feN93qerlMtOaxuB/38h1sOgSmyhA66+MEa1+pVqD9u0krj723vxjg+ScECu5RzOu5/RLSU0CqirvpJvFdhb9/AMqW8bmy3lYg8d9GqKlOm/1AQJG2gaLO5rrnVFdFtHv+OHk4vIKRQkek8YwM5oo+L02JXsx0VTCMV/3DQM7yd6+4HHUkJfMHAQb5pOYqbyoOg7QMWLIA== 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=Prun5xbqsPd8/AZiam+eDFNiFyBWa433K6nUBs4+lFQ=; b=HZpTTOVKM9bKTUDyBhKgTFKESjxwNg9fstidd/XoFg9mBfRvFgyx7+fXcOsR8pFqp9I8FEtvEgvp9aDmDkvuBvCZ3+GZw/HTZ6J4yLBsNa8ffQd/IBJPHJaBOy4txD9ugY9pQV5Ntpvn0kpzcyhb0DqLbKNyHwiDEX22HZtIcH3dtwqEqaKUyExYTS5T1AcApz8Ol25det1+wY+ajmnFW5J1Pra+jOrJ0qEvvYY6/IV0UFSAxDh4VFZC85IGt5SE6sLCBQ2ZHReeq2HmJcGKhA6C5ZaL84bRBA3fKiaIdVDW5ddz+Es/Pp4RTc4tIV/OXl0/8U00TiaxaO8vvb4YSw== 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=Prun5xbqsPd8/AZiam+eDFNiFyBWa433K6nUBs4+lFQ=; b=aB0J2ZZ8RqJe88u3upxDGN5aEdhYRVvL368SGKPUZ9nK9lqZ6ulDoi6ko/4oayq/2MhMG3gzCPAcJso7hnt1Lp/4kxOu0HJ6kKD5WF/4VCgjFXpXiP0nCQIcLFOuEZ2qAfbsSSr3s284eEvIDgxhB+yP13phTN7gE/OYLsVmqso= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by CY8PR10MB7338.namprd10.prod.outlook.com (2603:10b6:930:7e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 14:48:10 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6699.028; Fri, 25 Aug 2023 14:48:10 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 1/5] btrfs-progs: cleanup duplicate check metadata_uuid flag Date: Fri, 25 Aug 2023 22:47:47 +0800 Message-Id: X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: References: X-ClientProxiedBy: SI2PR04CA0015.apcprd04.prod.outlook.com (2603:1096:4:197::21) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|CY8PR10MB7338:EE_ X-MS-Office365-Filtering-Correlation-Id: be073175-edd6-4eb1-c349-08dba57a4d21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f1KFdJ7wWq99h4a4ygabimDFTP/3Zn0b1kLUvPUaSSr1ktvm8UCQmujl1EEIE2IWmaPCXejjp7y6BkAQkxsmmt67JRYLO/kz8vkq8tzdBBWU+riKfnFUSo5iTw6d/q3MSOz686M2pTN4zUZx72jmoWYl/6p5AIXbLNOe42adLNuQ52w6UJswfc6VNxk1hSpSipbW/utGAiVqnd9Gg7iXqWzFkNWjl6XYOLsply/pfW8NIg8pEAhaEVg2yqN8/8viGd9MCd+SsDqLlRDZQyXrVH1nb6SBOfzYFuXdTSiZB1PNMRshwQIm5BFbE73K1QIFt8oQOtazI7HSZ1SEost1WsvxZxSdNWLmB73ueQXBWcRt+7SUEapy02Wfc6RmD2nqQATH9GEuf926EgSDtOo+P1OKU+0WVoLFq7D7wqef/uARXjFOOiqFdoeIVwYvcj3kkWjGrFcriWnOGbwWHNgfioHGFapo+gRsIuCptS0UsOFq/0HnzcbJcAro1JJT/cod/pCYhVhV+9kEZOsIQk17F2DaOFUWSFkXd0Ik7udZX0LPSnNX+JT7Jd3UoZ1dWK7/ 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)(376002)(39860400002)(136003)(366004)(396003)(346002)(186009)(1800799009)(451199024)(6506007)(6486002)(6512007)(6666004)(83380400001)(86362001)(38100700002)(36756003)(26005)(2616005)(2906002)(66556008)(6916009)(66946007)(316002)(41300700001)(4744005)(66476007)(8676002)(4326008)(8936002)(5660300002)(44832011)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 51pQVube/53zubmbIlwtnGv87z7zb/nzbOPFetCs6fjos0xolV+FlqpQTM1aqHPNfRUl4j1G8w4ZKLn6OmEqK3t2jPvBNgdNzmRUbQKjxzRWHQX2Ow3hGEYtE8DpVaaFKQASrhvorwpJQiB1XWePSSvEH5EhYFrF+1x6YsMMIMZ/YrsibM/8JL7FH+rxWcoM8zaNbxLmxb2nivzcwnEVIu8YiCivE5fcA2CNrt9JRqjn16vRQZ/+s8MoS+wMSUOACqPs/qsrFhcv+ZOAAKvPoNzWrbWq/a8+CvbPuQLIfw4VaWYn56hyE+Y9D3okh3T48UcMHjHxy4hKTC+Ld6Zu3DQbj5mRegCEhdtsoXEgu9Fs32MS1rNB3lN399WI7LfSrPFdvQexBOAX/+8i0k8emkEP0hGvqMxv9KJeReIj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Y7hrcHmN1L4V7oGMvMa7mBR20uk6Nl8kGti93/4kHWLYtwGIFr6OkjZE0zMEiBlkiYjBtEpe43j5v3AKiaJSkeJcgr7sAHoM5MAb4BK62EEZypO8oGuD67FhRsAmp1UwZKg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BtoxyAm6hnpFVYmg2FJ4/NtoI57CVuRyYs5chT0Rlfn/8szsbJI5Tea1up11SKZrrdnKujJrsRJT3OC7A8GHMoCE9iYETiDDZOHy8pIWAyRNTFvUK5h/HAR77/EeSS2bnTXGeQNCR4e9Owc56+PClLKOfZdMfI9EMpZ/ZX1oqd9sXO83dSRX95BIy7+mkZ532AyxV9k4ptQTk7e061PWUxpWRI8Jzgumsh8ffgf2rBnhZqRP+8LU/cNNk+f5MvHF8jpeMTGvfsbLopTC59WptNRfH7o2Ojxtg/CULWNhS3zyTghlQIq7jtVfLwnbOVOwDtP9OUhwZ2+9pdUg1LaVuJkXM+C0mfC9BKokHVXHbFNCw5lYJSNSR7IxgIXFTbfpddb1z+RpYebCWdWH/1kTgNj5ci3k1vPudwGAGD48Tc1Dw6eYRQc6HOirUJPIyH1XgSR514zqOPQSEQDuRk4DkmXazHnXMqo8jI3bJck0jEFybHnCPd5RNOh38B8CO60p7nRQ9Ts9RsaaLzYpmarkMFzQknTt3vBhK5FlKv0jVgkm8TE8bPTLFpz6Riwjupo9csJDC+u/8c0OX7zHEsmhiY/Bvn4IuIFaEPpoF3ylYVDucmhDplVgyle1fuyhLmsPp9XACSadz6QTPm/Zcw+ZMMrcoRPBgcgsYkHSHWwN8rasqicmEggDaQkpWZVs+FDZBou8fvl2wmJMJGqs1d8VK7Obns0pN8KLBlm4wgKM1/V6W0wGyeg8kOLd2MehYAn6kopWNfce14d8ch2tDd858q0VTzD63IBvI2ce1R0XJxk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be073175-edd6-4eb1-c349-08dba57a4d21 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 14:48:10.3159 (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: BKGRgjN22hCWQYbOUqUaZkxv1HbdszgmgoZOcNohY9as4QIFW0kIFevbvGpQ8Ljhr/zeoviQkn+1Rywl0lAZng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7338 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_13,2023-08-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308250131 X-Proofpoint-ORIG-GUID: yXyNfnxJk4XZBF1_AoD8g54gK3j19xiM X-Proofpoint-GUID: yXyNfnxJk4XZBF1_AoD8g54gK3j19xiM Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The active_metadata_uuid already holds the value of the metadata_uuid flag. Remove the check for the same flag from the super_copy, which below patch forgot. btrfs-progs: Track active metadata_uuid per fs_devices This patch should be rolled into it. Signed-off-by: Anand Jain --- tune/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tune/main.c b/tune/main.c index e3b199c10dad..d344cdad06e1 100644 --- a/tune/main.c +++ b/tune/main.c @@ -426,8 +426,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) } if (random_fsid || (new_fsid_str && !change_metadata_uuid)) { - if (btrfs_fs_incompat(fs_info, METADATA_UUID) || - fs_info->fs_devices->active_metadata_uuid) { + if (fs_info->fs_devices->active_metadata_uuid) { error( "Cannot rewrite fsid while METADATA_UUID flag is active. \n" "Ensure fsid and metadata_uuid match before retrying."); From patchwork Fri Aug 25 14:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13366055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB67CEE49A5 for ; Fri, 25 Aug 2023 14:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343846AbjHYOsr (ORCPT ); Fri, 25 Aug 2023 10:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343847AbjHYOsX (ORCPT ); Fri, 25 Aug 2023 10:48:23 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF242119 for ; Fri, 25 Aug 2023 07:48:21 -0700 (PDT) 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 37PDOUII021574; Fri, 25 Aug 2023 14:48:19 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-03-30; bh=VLu1c6xlfkJswHdiGJ2idxnp1jKQ1O+XJLWwUfE7Chw=; b=IbBLptHuk9u7R5+Uz70GWPTYetpbmEpaQvqIdOsj7rRS2ZGvmKA2yUbWOBjmy2nHEntO rFThr0TLzKVMuBRttB5PKXIX3P2hOCZD6BNzPyMAYVtrkoODEqshqqzr3FmTerWliFuN 2Aa0o9N4KzN6i+aNKsq7dltdxXDf3r4DmB3M8GcQLpQGZiiBIxAiCNRIfE70ruj777C7 nXf26vcpuFGkdc1p1yvMVBfX5fIyHD4dA2XQUolhcXBZa/P9v0vldnH1rhSAsy80vKp7 UYw/FKA3QRp8rbbYP/rv6qqVkTePfemtX8tlP24AB/+bHtp1MVGuA2X7mYvZgGvU/Wqs Vw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sn1yvxjtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:19 +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 37PEdplc005772; Fri, 25 Aug 2023 14:48:18 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sn1yup3fn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6zeVMpeoDWkiz70qk/vTs2gtdUA8rS+9L6i3f055zFxqhRtGpPFNA0f+5D0eVisWOWn9zl8OZ992nNtk6KBD0Pf8w/DTa3UjCytzhW7Z2TQ+EhrVj5seys9ONRpyTXOchZZVCtbEKE2bSQgij9gwTSiR86dkAYXd1iejGVLU3uHUUyuvzHUEvXYWljL1bO+Rci3ecIRB0ivCowKXc0XxK4MiYiVVLcy0fJK5bh/MUtZ/xD1067f/MMG57h9X9ZiwVt3WhfU3fxpPRk/dAwDQ0PGYR18U4Waod2MZ9zXfCwcNTIGHZfg0yt1wxYembaKz1CypUOxMZd3Jq8x6yMVRw== 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=VLu1c6xlfkJswHdiGJ2idxnp1jKQ1O+XJLWwUfE7Chw=; b=BRPV+JMenKGCkuZmCQC1kuvKPxuGyJdHSq9InXr0jV7tCwK9pMLn98mK7QdmFZjPdH7ujJh60JVMCZckcTOjvQ71I+J/ROiPmtBGp+H4sZfOunPaZdC6ROMclV+GaItaF7yzQEuJeU8WC/b33R2s5E/d6QkFG5h15NMpbxoaxTOgGyZwYo7W1qw/VQ1OX6H46MsOC/WoSLvf/x8zrV8ANzNVB5BIo7LKCE2Dzys6a4IKN+UYkm9SMI7KQZrIUCejMvMbx8ZrDYiCymBMzTBXbBSkRZZM9LFOp+GA3oy9hrPGZquaSvQK4/eCeYCIQK6UezqhvmjVo6buuKqD5TDK3A== 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=VLu1c6xlfkJswHdiGJ2idxnp1jKQ1O+XJLWwUfE7Chw=; b=Pmq2UvFhdKv7PF7GQPwHvq1cEAPDRGv9Wb9iYduc8Udg4dC7S6HqLT34J0cSDxeiSA+YB2gVQ2eB3bSrm/Wt6gzFSouHre6QlycDCUf+MHNSPBtleX5l49K7FUe5iWfX7Whgv+NG9L0otJEMvbbCwSJt5wpGlBxRjS6jDf3tgf4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by CY8PR10MB7338.namprd10.prod.outlook.com (2603:10b6:930:7e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 14:48:16 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6699.028; Fri, 25 Aug 2023 14:48:16 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 2/5] btrfs-progs: tune use the latest bdev in fs_devices for super_copy Date: Fri, 25 Aug 2023 22:47:48 +0800 Message-Id: X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: References: X-ClientProxiedBy: SI2PR04CA0011.apcprd04.prod.outlook.com (2603:1096:4:197::10) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|CY8PR10MB7338:EE_ X-MS-Office365-Filtering-Correlation-Id: c69f296e-7b2c-4009-54da-08dba57a50cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qk0h66FVlYlUrUNhL50um/2zEbw9ZdHCNupRMHzjSt/5eup2HEAxRGlaKPPbWtf3Grz765NMDxAvDLiFMNL9pxqsVe6eJgaPwr6ENiJCYFMP/bqUy9uyBjCvX7uwDXgl59B/kZkSLk7taWgONQ7evPLlwwH3ZrxQT+/LSTofd/2D+QpXHlkf5cu3jKjngtjGNQq1bkFkujgpIFLTPIESDsNzZiJUOa709WBRZQM4bViruKFc7H2ZR9RIfcCyMTwweo5rjq419MKarXpCyoqJQYovTYqngAhAaQUfKlWqhfdSb5qKfx3/VMesPDy5mkoh+OXx80a7fpchJXxw9JtAA1VGiVrb+Teao9MT+jxff+bpYYLp04tZZnrzaQTetyh7mdlPzXuT8TBbVbuTD66NF2+EQReq9Ocgbm3EBXQzA5Zar9STN2zN/9CR1CkAeetbagpRCv2YVklR0fx2XaDx2zlEx5PuVk3gmTWIgo1V/wzh4wtguvWCn8VbCYQ0QbL4MAK5zZeXavQRMWEYMHhdPo9y7DpiXyFSWmPcMAp+6ebd6RUcE5hg9j8NX183le5n 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)(376002)(39860400002)(136003)(366004)(396003)(346002)(186009)(1800799009)(451199024)(6506007)(6486002)(6512007)(6666004)(83380400001)(86362001)(38100700002)(36756003)(26005)(2616005)(2906002)(66556008)(6916009)(66946007)(316002)(41300700001)(4744005)(66476007)(8676002)(4326008)(8936002)(5660300002)(44832011)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PujWctNH8CHD1y7cFCNZTTiBiMwx36991iC4Z9qiIDb4a9m70UWFq4J9X/JRvY9F1MtydMnNcfA9W9LlK0dib3JJQMknmuxRCILMoR6hDgd0uyZrxxxI+BBHwHGucorjjxVQB0uwvHt0t8drpFRLDol+HAt5AJg0RAJM7gcqwMkrTfnvUY5iY6XRQLvk5mDZ2CwuphJs9fBymxwzE55EYpkBwlL3U+vOHOF4E/NQluTbovOjLupKYWlvTZ/s9BjYTE8wazD/1Z22j1Yaf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0P688fQcNcwmP12P7QsHFMyXxhjrz23ihdjKb9emIC5sT5jtrvlV9O7JwDkA8Qjj9hWVdhhpyM58OWzsfHFvyQp5L6EUf6foliaogM40BYR1f3/75k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c69f296e-7b2c-4009-54da-08dba57a50cf X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 14:48:16.4441 (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: rQOW8SDDh0swzhiPt+1BbMv1+XIYgwFJxFFzPY7SQH2JnhtSvaGK0BI3TH/+nfbbRJURKDS1yWOx+9GEhfm/rw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7338 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_13,2023-08-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308250131 X-Proofpoint-GUID: 30MVAIyE-BidyS9maj8U8bkiuq2ekfWO X-Proofpoint-ORIG-GUID: 30MVAIyE-BidyS9maj8U8bkiuq2ekfWO Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfstune relies on the superblock of the device specified in the btrfstune argument for fs_info::super_copy. Instead, should use fs_devices::latest_bdev. To support for reuniting devices following past failures of btrfstune -m|M|u|U as in the following patch, use fs_devices::latest_bdev. btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag btrfs-progs: recover from the failed btrfstune -m|M Signed-off-by: Anand Jain --- tune/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tune/main.c b/tune/main.c index d344cdad06e1..7d2e2fb3b97d 100644 --- a/tune/main.c +++ b/tune/main.c @@ -290,6 +290,9 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) goto free_out; } + if (change_metadata_uuid || random_fsid || new_fsid_str) + ctree_flags |= OPEN_CTREE_USE_LATEST_BDEV; + root = open_ctree_fd(fd, device, 0, ctree_flags); if (!root) { From patchwork Fri Aug 25 14:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13366056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BB54C88CB2 for ; Fri, 25 Aug 2023 14:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343858AbjHYOss (ORCPT ); Fri, 25 Aug 2023 10:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343848AbjHYOsb (ORCPT ); Fri, 25 Aug 2023 10:48:31 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8152123 for ; Fri, 25 Aug 2023 07:48:29 -0700 (PDT) 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 37PDOHIJ030481; Fri, 25 Aug 2023 14:48:26 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-03-30; bh=4wUIV4mEMnhH2Mye/ZvprXSdUUpvU5ZgPKBakei0dOo=; b=jRl27paGkobnXLUBSFQxCYJB4hChN+E2x42zz2o+fjHEIN9h2pUV0mFtufI3hOORD4/a 144Pdx9yyBL09PSXUXF3ZHAJnm94s9u0XRBDEbygPeGZbfVMcTmZ6GJKM01hNkI/jN7f WhOSRk0/wJqxHo+xcUTSJVjxyjMYrx6b45BncIbthb3HLcsqEwwz/chh3vMINSYKPZp5 9+qZi1LK6VmR/du7GnvA0KlCM4Hb79pxVqmKXYfs9nWrcFZH/z/RyUE5GtiREhfkxNA3 qPaaX10g13dVhgb161CMcpbkiCM1NqmpgJBjH9lB+FfR3OvzWgOZqJ2HCFEz4jvJkASP nA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sn20defvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37PEP5gv000914; Fri, 25 Aug 2023 14:48:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sn1yux3n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYUJpWI/izz+xLvHWpGW6Y9Uke0JZTkU78BfVbK0gwvExK9jUalRVadzTpBT+DYDC9WwV4lqJ6EDN17yaYgZqhODJUr00dUbjbHhSu2GAh04xLZMk/pEImQQ9T9D4vsqgYkwXHh5q7ZkVrIuPMWnlz3kh1ai/J7Q62U9TLAdl45jmFddDvuLm098UM/L0EPdQrRA6O6wjfGh69innVyKPO8JvP8DBH0kkDI/6X8oKQz8OfQ3idTv5yuFfVVxhLDLyDXdD/O3VYSOX8ZJ9fSPpqBKQQr3woZ4JF1ozWR9S3QlobCKbmVIODWXI/WY0iDw1z+bMJoODOxUi8Hv/OjYoA== 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=4wUIV4mEMnhH2Mye/ZvprXSdUUpvU5ZgPKBakei0dOo=; b=T3yLlz6EeCHjyuk70QMbeh3NCKeJ2K1P9i6MrEWtxUxbGu1lXGPYUaDSJrOTbMDI8gILRaLju6y6hNacHBZ0k+bhucAPU3vsy6AgUvnw5Iq3dkkPHrRc7nhkpRDOhRDX6cOr5eMXD+UrItiQks+vhLxXZ+d7OjEYF6ge4zZ/Gp1ox3XmjTV4S1QP6LgQIo4U2vafunvVVZ33RAYvHyu0W4SsuuiDMbPgPiclwcVRpC/PnaKs+QWPtzP92JhAo4C8AU9J2ThFMo2QZ93U2nIQO9KdoDUSdbZ1pf0q0xSJuFb3hg50CoZl6Fb0tj3eTIVQBSMfVYeJnwNTM6ozRoUBNQ== 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=4wUIV4mEMnhH2Mye/ZvprXSdUUpvU5ZgPKBakei0dOo=; b=Bs0H3YKNcnJQ8VPLx7ULDHVI8i35+0OJxvGP9mtX68xsxh/vpPy7irMJg+IwSINwxo/rusDV9RPnb/exQV8UFjOSWJJ1KUM7lTixNo1RWR3PvaK9RcQdRkzMvfgEhc4+cc58FwDs1O4LMk3xjSIT59tfvpQ2I1uripzue0qdqMs= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by CH3PR10MB7120.namprd10.prod.outlook.com (2603:10b6:610:127::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 14:48:23 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6699.028; Fri, 25 Aug 2023 14:48:22 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 3/5] btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag Date: Fri, 25 Aug 2023 22:47:49 +0800 Message-Id: <0032cada2f51721640cc98dc91aeeb3d1e0646fd.1692963810.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0050.apcprd02.prod.outlook.com (2603:1096:4:1f5::12) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|CH3PR10MB7120:EE_ X-MS-Office365-Filtering-Correlation-Id: 510128ca-17c0-447a-8706-08dba57a545b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QQxep0a7mwuivK/TNnDnB6vD+E+2ezKzWzDUtlHFYHigpKcKcx2RUTeE53ZIlcN1wLnRekIUYQQAZJZZPVddUxUYWgH9ZvM6iBp4jiHwI+AaZdHQrSZ6X+fQW9RCtxR+GWk4S2uREh9cKLZZj/xhauD9TiffSTUm2tyXAfuIphD0mn0uxHDOM7S60y3NLBydQMeUW1F0TyeeaZwTvKPeQlv1iLq+qB4ZLdZhiDwEuJrQPpU3SG/U3NB8vVaclJOep9KAKIyYnpHghX6OMVucn/hV2UMAUqcPNFYBCucf3L5wq0CYf3inoK7i8z5ke0MLygWfAVvlLM1/FQ2Pom4JqdfzB/TLs+GpGXZnpmLLohHEJi81msEDtEzFtOulVDUIsWSZP4S1C8lo+K5+/rvLj3ySMviSf4Zmo54X9H5FOsBD7kXgvRYs7yiVLaaupnGQpE0zifah5GkMzB1VFtz7F3uOwEtraXiyl4iLAcYqEzi1LoCLn5zisjypqBI+5G7tfrHkWbgmCoeY10ORO/spj9ROs7LkjS8aQNtrswAtJY2yETNx2beV3hKbL7CAKKgG 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)(136003)(396003)(346002)(366004)(39860400002)(376002)(1800799009)(451199024)(186009)(44832011)(83380400001)(6512007)(478600001)(26005)(2616005)(5660300002)(2906002)(8676002)(8936002)(4326008)(38100700002)(66556008)(66946007)(66476007)(6916009)(86362001)(41300700001)(6486002)(36756003)(6666004)(316002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MJQCCxnM2tED3pVp9Oyi/Zy628paLzWmW7aT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W2CN8P9G3/c3MtXSqJ74z4rW9n+KiBS0KpXcgysBncRrcz+GxU5grBdhQEHlS4U5oe6dU6u72U7J9EgM7/rS385vWXndbNMjZu0qR8MkxSm78z4kWF/vybQH/x7Zyan7AxViYHhOf2aDVsbylsMkzbbHtil+rf9upWB2NSXfEliGEqhgOq0UUMGGeaBCXTATFYLwJSj7ZrSvf77IFMYNCBNHEhr0tX1Jqztv5dnVm+KqQkXnFgMAcX18Lt6OmGAmne0c8qalRupTug2luh3D0H8AnWqhmNngG9BY+Q+2KEs6utckzLPbhJ2hxEiS3gb5W0P01REdfiwn4W1eNb+rDXNjY1/Aq/m2rvR9GjFKoyhEbmPttVeh0B66w+/jlqov/2innnBG5Ss+sr4XKDwI0aJvWUEbFALQZOllM83+956YDHW/iL0U/hs4DcbAkywjD6c9qKLpfZAa6Cqn1q/KCvGOkIrKhh4rIJ2nEohqpTdjvuulP7IPH+88L6SNjWSuO6E/v6yw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7IJIUOlJ0HtsTge8IU8h/Gpiy3wbe7cjVYKHvcm/VGHr19K+sF+gOHTiRaJA6LdYoCU2/h9UP3jI5ACZii2rVlQ6Ga4+Q2bhpefwN8u2O7KOjCKoKhj4u5jO5MrUlQOBl2thFOsevJthdJTfXHVpuf15LrPXFxwQr//fWFdmEaj98aGq4ExQlpt9fZQkyCbjbUVodR8ehBVq6WE2njphq84lnzSJzNZjk/MD4tGAI0hlwHnuMmBrxBMnPeeLhm56OSDth2JJCOOcZKW/C3VW1eEGKmNWxxdA5nZtGVcM22YoI9C8NVQro0//V0zcG2r9T5JaoLK5F62N6Enyaj9uCumfS4RMF0mRxdwz687UGE3b5jRcd8Rweez54KWIqP5rXDh1lfL/MVyaouVh9RDRtZAQAVp11gCxn0SN4y17wDrzFIhj0jOoTIekbC4Teiydr07qdnxBRTj6epDx0T5OyAjEEDqHZB8EiUAJpsuUkouK/WlbnCYSiVa+lEPGII0wULtbWgARU8irXkIl0psBVcR54WcvTm7D7uAxU4A8ItggOP+WJiYMbulb/jgcfhYtF/Jprn+ymhmUqDusnnyIpRVKDLBHl5ptm1m4/TAGjTQf4zOdzWhjyT8q1mkcJX3u+OOVVnhEwzbIZ6qMeXwcQatgbesKPgsni12bkMFc1VEGZFnczR2vRj+xVnxBqLR7XOKxzY1pErpsm6ItaM6MM9+nqoctYy6Z0zmKM7rO/5RGGwfr5xmndGo6lDg6G0sskxs9/uAIWnMUDvD+9gRftuxEgwinG4mv+kQ9gs0KfPo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 510128ca-17c0-447a-8706-08dba57a545b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 14:48:22.6023 (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: LBtnuIN+jGJzU+jljTl1ERWtFPJG1DgExvpuIC9nugsiG4p2MkHoDDJ/YUgw1RZU/9eTCXDucf2rnGQfBeWIKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7120 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_13,2023-08-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308250131 X-Proofpoint-GUID: Y7uE_3iBbpk9USlG6e7wLpeu6fKT8BPh X-Proofpoint-ORIG-GUID: Y7uE_3iBbpk9USlG6e7wLpeu6fKT8BPh Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Most of the code and functions in this patch is copied from the kernel. Now, with this patch applied, there is no need to mount the device to complete the incomplete 'btrfstune -m|M' command (CHANING_FSID_V2 flag). Instead, the same command could be run, which will successfully complete the operation. Currently, the 'tests/misc-tests/034-metadata-uuid' tests the kernel using four sets of disk images with CHANING_FSID_V2. Now, this test case has been updated (as in the next patch) to test the the progs part. Signed-off-by: Anand Jain --- kernel-shared/volumes.c | 193 +++++++++++++++++++++++++++++++++++++--- kernel-shared/volumes.h | 1 + 2 files changed, 182 insertions(+), 12 deletions(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index ad006b9de315..e1426a526f6b 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -332,6 +332,159 @@ static struct btrfs_fs_devices *find_fsid(u8 *fsid, u8 *metadata_uuid) return NULL; } +static u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb) +{ + bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + + return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; +} + +static bool match_fsid_fs_devices(const struct btrfs_fs_devices *fs_devices, + const u8 *fsid, const u8 *metadata_fsid) +{ + if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) != 0) + return false; + + if (!metadata_fsid) + return true; + + if (memcmp(metadata_fsid, fs_devices->metadata_uuid, BTRFS_FSID_SIZE) != 0) + return false; + + return true; +} + +/* + * First check if the metadata_uuid is different from the fsid in the given + * fs_devices. Then check if the given fsid is the same as the metadata_uuid + * in the fs_devices. If it is, return true; otherwise, return false. + */ +static inline bool check_fsid_changed(const struct btrfs_fs_devices *fs_devices, + const u8 *fsid) +{ + return memcmp(fs_devices->fsid, fs_devices->metadata_uuid, + BTRFS_FSID_SIZE) != 0 && + memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE) == 0; +} + +static struct btrfs_fs_devices *find_fsid_with_metadata_uuid( + struct btrfs_super_block *disk_super) +{ + + struct btrfs_fs_devices *fs_devices; + + /* + * Handle scanned device having completed its fsid change but + * belonging to a fs_devices that was created by first scanning + * a device which didn't have its fsid/metadata_uuid changed + * at all and the CHANGING_FSID_V2 flag set. + */ + list_for_each_entry(fs_devices, &fs_uuids, fs_list) { + if (!fs_devices->changing_fsid) + continue; + + if (match_fsid_fs_devices(fs_devices, disk_super->metadata_uuid, + fs_devices->fsid)) + return fs_devices; + } + + /* + * Handle scanned device having completed its fsid change but + * belonging to a fs_devices that was created by a device that + * has an outdated pair of fsid/metadata_uuid and + * CHANGING_FSID_V2 flag set. + */ + list_for_each_entry(fs_devices, &fs_uuids, fs_list) { + if (!fs_devices->changing_fsid) + continue; + + if (check_fsid_changed(fs_devices, disk_super->metadata_uuid)) + return fs_devices; + } + + return find_fsid(disk_super->fsid, disk_super->metadata_uuid); +} + +/* + * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices + * being created with a disk that has already completed its fsid change. Such + * disk can belong to an fs which has its FSID changed or to one which doesn't. + * Handle both cases here. + */ +static struct btrfs_fs_devices *find_fsid_inprogress( + struct btrfs_super_block *disk_super) +{ + struct btrfs_fs_devices *fs_devices; + + list_for_each_entry(fs_devices, &fs_uuids, fs_list) { + if (fs_devices->changing_fsid) + continue; + + if (check_fsid_changed(fs_devices, disk_super->fsid)) + return fs_devices; + } + + return find_fsid(disk_super->fsid, NULL); +} + +static struct btrfs_fs_devices *find_fsid_changed( + struct btrfs_super_block *disk_super) +{ + struct btrfs_fs_devices *fs_devices; + + /* + * Handles the case where scanned device is part of an fs that had + * multiple successful changes of FSID but currently device didn't + * observe it. Meaning our fsid will be different than theirs. We need + * to handle two subcases : + * 1 - The fs still continues to have different METADATA/FSID uuids. + * 2 - The fs is switched back to its original FSID (METADATA/FSID + * are equal). + */ + list_for_each_entry(fs_devices, &fs_uuids, fs_list) { + /* Changed UUIDs */ + if (check_fsid_changed(fs_devices, disk_super->metadata_uuid) && + memcmp(fs_devices->fsid, disk_super->fsid, + BTRFS_FSID_SIZE) != 0) + return fs_devices; + + /* Unchanged UUIDs */ + if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, + BTRFS_FSID_SIZE) == 0 && + memcmp(fs_devices->fsid, disk_super->metadata_uuid, + BTRFS_FSID_SIZE) == 0) + return fs_devices; + } + + return NULL; +} + +static struct btrfs_fs_devices *find_fsid_reverted_metadata( + struct btrfs_super_block *disk_super) +{ + struct btrfs_fs_devices *fs_devices; + + /* + * Handle the case where the scanned device is part of an fs whose last + * metadata UUID change reverted it to the original FSID. At the same + * time fs_devices was first created by another constituent device + * which didn't fully observe the operation. This results in an + * btrfs_fs_devices created with metadata/fsid different AND + * btrfs_fs_devices::fsid_change set AND the metadata_uuid of the + * fs_devices equal to the FSID of the disk. + */ + list_for_each_entry(fs_devices, &fs_uuids, fs_list) { + if (!fs_devices->changing_fsid) + continue; + + if (check_fsid_changed(fs_devices, disk_super->fsid)) + return fs_devices; + } + + return NULL; +} + static int device_list_add(const char *path, struct btrfs_super_block *disk_super, struct btrfs_fs_devices **fs_devices_ret) @@ -346,11 +499,18 @@ static int device_list_add(const char *path, (BTRFS_SUPER_FLAG_CHANGING_FSID | BTRFS_SUPER_FLAG_CHANGING_FSID_V2)); - if (metadata_uuid) - fs_devices = find_fsid(disk_super->fsid, - disk_super->metadata_uuid); - else - fs_devices = find_fsid(disk_super->fsid, NULL); + if (changing_fsid) { + if (!metadata_uuid) + fs_devices = find_fsid_inprogress(disk_super); + else + fs_devices = find_fsid_changed(disk_super); + } else if (metadata_uuid) { + fs_devices = find_fsid_with_metadata_uuid(disk_super); + } else { + fs_devices = find_fsid_reverted_metadata(disk_super); + if (!fs_devices) + fs_devices = find_fsid(disk_super->fsid, NULL); + } if (!fs_devices) { fs_devices = kzalloc(sizeof(*fs_devices), GFP_NOFS); @@ -375,7 +535,20 @@ static int device_list_add(const char *path, } else { device = find_device(fs_devices, devid, disk_super->dev_item.uuid); + /* + * If this disk has been pulled into an fs devices created by + * a device which had the CHANGING_FSID_V2 flag then replace the + * metadata_uuid/fsid values of the fs_devices. + */ + if (fs_devices->changing_fsid && + found_transid > fs_devices->latest_generation) { + memcpy(fs_devices->fsid, disk_super->fsid, + BTRFS_FSID_SIZE); + memcpy(fs_devices->metadata_uuid, + btrfs_sb_fsid_ptr(disk_super), BTRFS_FSID_SIZE); + } } + if (!device) { device = kzalloc(sizeof(*device), GFP_NOFS); if (!device) { @@ -429,19 +602,15 @@ static int device_list_add(const char *path, device->name = name; } - /* - * If changing_fsid the fs_devices will still hold the status from - * the other devices. - */ if (changing_fsid) - fs_devices->changing_fsid = true; - if (metadata_uuid) - fs_devices->active_metadata_uuid = true; + fs_devices->inconsistent_super = changing_fsid; if (found_transid > fs_devices->latest_generation) { fs_devices->latest_devid = devid; fs_devices->latest_generation = found_transid; fs_devices->total_devices = device->total_devs; + fs_devices->active_metadata_uuid = metadata_uuid; + fs_devices->changing_fsid = changing_fsid; } if (fs_devices->lowest_devid > devid) { fs_devices->lowest_devid = devid; diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index 7f571bddee87..593fe75ed087 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -104,6 +104,7 @@ struct btrfs_fs_devices { bool changing_fsid; bool active_metadata_uuid; + bool inconsistent_super; }; struct btrfs_bio_stripe { From patchwork Fri Aug 25 14:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13366057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 230A6C71133 for ; Fri, 25 Aug 2023 14:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343862AbjHYOtV (ORCPT ); Fri, 25 Aug 2023 10:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343860AbjHYOtD (ORCPT ); Fri, 25 Aug 2023 10:49:03 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3DBB2119 for ; Fri, 25 Aug 2023 07:49:00 -0700 (PDT) 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 37PDO0xY009064; Fri, 25 Aug 2023 14:48:58 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-03-30; bh=EoYcCiqUlV3ZLzN20nFr1aKGslr41ghOuf8WpdwJv8A=; b=x9ZCPKEyxVRatsRHIuO1V1nBGKbnZ9u7J16cFKISQKXrM4CIad5mf17P8CKCFbIkCaFR DmE8b97dwqSVqB5DH0/biVEFVSO1+nx3ZyVv6yl6hJO23aEFyv7ybuNEaFZVVv3xUsLK pn90SK/F9fR8/HOdIRszbogMarXpIAPEYBgAe/1rCvkpB8yptjJLywty0+PP6lNFs1jp 6bC1oQ8OEGTMfPW/ci2R3ALu4/J6x6cs5ltm3pbT5cqhfnu2o2n5BA67vzh9TjgzQ+nh x1z/GApIHtclXx93bxhnc96g99RHWSmXo++LbeSjEFEssqjacbykPzomRpnBTygBYT2Z 5Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sn1ytxgsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:58 +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 37PElcgV035966; Fri, 25 Aug 2023 14:48:57 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sn1yqx189-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QxMBIDKmehkX3ODY4I0tfVY7hqCoDBOKvMvqpdOnzLcOKz31R1B/KR6GRocK0aS4t8i8EQrkFBkg+JUflw2P1WFfXCpIfMH89KEY80JLeCO35LBvJvwBZZ5tiNkmjG9GRQcpjMp6pHeXEamqRdIaRLaE3gAf2/8P/9wlzgyztozzmVnnqMV8uxIzeLJxuvw1f6qIM6DCWt9ZymgilvqJmy62S9EoX4Y/bL/Ue4ErQTJhQrLjc1SsTQgpjOiQxao+Z0PMCPxOzKisV2I5e7pq3/0t59x3h10pct22FL3XGCEL92ZF6jGaAf3TVHU19HTgBg3I2XMqEPhl7VVnOeSn3g== 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=EoYcCiqUlV3ZLzN20nFr1aKGslr41ghOuf8WpdwJv8A=; b=NVTSaG3fy8RBZTFYdYxlCUdbLlh6w91NQwwtBRiJK0dyxcKd76Jfo5MZ0L0Zv4OW0QbfOMkzAeuxHfE00FUkoNu3Xm0+2HTXlQ5EhAH/9BWLQ0Dc2Pz4ZA0Ir3PNPEpAwjbpkT9ylx13JsCpR+1zR1SXo0FgLc47fMFF7Rk5E41Bj9l2kLRUSRwFolbtZ6JUHfzxV7G6sQbvB3QsMStaWlkwCwgwHjvLy8MvySw19AH89fO+V1gq6E+oZABSBNT2NnL7a4mmQvdyBcqfDbj7duqGLaTAWOK0XeXm5tnASpGx+5Uchvnf9UFxUQq3pI64UjpmVu9ff04TxcXthbHquQ== 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=EoYcCiqUlV3ZLzN20nFr1aKGslr41ghOuf8WpdwJv8A=; b=a+hNtLZDhjMZZsjnvP29jt0N+Opifc1Rxaf9bLacZM4mUdwLWPeW9WBaZGIgQjOZfn9M0KOPKi4yAXrqxnr37BnTp8Htd3Lo5TBO+HxFNp+TOfu8rso1TGw3Md/gDNbnnW3j6Okg2hiJ7NoCV694G8AXQFzgVLtBfFwID6vRgqE= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB6326.namprd10.prod.outlook.com (2603:10b6:a03:44c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 14:48:30 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6699.028; Fri, 25 Aug 2023 14:48:30 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 4/5] btrfs-progs: recover from the failed btrfstune -m|M Date: Fri, 25 Aug 2023 22:47:50 +0800 Message-Id: <2f5d995aeab0df884b2f8fb3dd57d7011bb5b50c.1692963810.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0052.apcprd02.prod.outlook.com (2603:1096:4:1f5::20) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB6326:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cb02892-875d-4538-2188-08dba57a5946 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRlw5O3CQSHF2imEp3QPZUOCJ+RmidQAzKTUoeKpcSdnJxW0gxpS5MyLAjFCO+0VZjwgWgTXETlbMN0UG3oWsioTde5l3esPRInP5glgdePvq9B8dJH6z5iEEDK+y3qcuu0lSNWfYSy+bHThw1lNrv0zaz+8siCKcmIekUrRo7pfuoFRoF3Y7fja12Akevc9KMllTZlK/PG4QnQ2UljW8fN3jyMYLhz0Ex93wmgE40braOFEXbX9F1uyW2eB03510zoPTS6w5doAfs6D+qnd2BlqNN5MKCNhy/Z7zVcibeeZxmyTI3q7HiQdpBXMkwIpUDvvva6t6/T5ItUc6Ul7aoN9bcwiWrh5iqeSvPZFEmyJsCy+DmLImSAJve62CtIdDRXAcRCwIluTTK3gyJ7Ls6AdCl9JIHcRx6XrC26uODk7xCJ3S/OEod7KBPbuQ3sSO8xCWcrRycVDOrIbMTILNiZpDP5odEM6IQzPBKbrH4Xxr7DlvhNWT+xhENxDXA/bXj1VAAMyyHLc6cZokx0Vq9151FrBSOWbzM1QI+dJfGZNxULOVyIroZiWQtcA7KuK 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)(376002)(39860400002)(366004)(396003)(346002)(136003)(1800799009)(186009)(451199024)(6486002)(6506007)(6666004)(44832011)(36756003)(38100700002)(86362001)(2616005)(83380400001)(2906002)(26005)(6512007)(66556008)(8676002)(66476007)(66946007)(5660300002)(4326008)(8936002)(316002)(41300700001)(6916009)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ILE3IsaQXjlEdTJrU2KlM/rLuYt1G6dFvWUMxOXih4esd8RSPAcUAiST0j81rDQOQ3RMWn9OiC3spuGgug0DjQlfD4IWqGZcdlv0X+5lEhHbVDZU0ZBp7Y2x/jNxg/6AwgTgwLxPgJIRtYEFQb1YybiuCJfwQqzsFGpTYjyFVayxpSOyiV/5BxsVenQNpZWPjNFN8Nd4pzTXX/UkKE86t05nZkhhkYO5vshJUwYTydK8SwzgNuZmhY5tAwmgm6u08PwRFhswadiquIxWXs11hAkWA61Cqe5ftcL8RjitkM+sPUp/G5i2xU3E4a6AD2mlzwjOP8wvCB5Smvv4+sjgUYzE/GoNRoTv6FNsLzmabRT2ml9YD30IjLmlADsE3OsKv5WCPVu3pn1P+AsZVpt4cb1f3dKeqHWtEYlqQQ8LmAIjwSNJMzakmeLZNkccWco62DpfbGpr4fjqVa8k25FniiAcCXT0Jmmr/UlIULB2BuYQXD/5dwIUML2XFAA4/83jg/Rem/vEFXTPjZF3FEQPdSoahIEqxbtAAZT0jmhTdevZ/ZADitYPBo3Nj2OspB8OOuAvupoXEvL2doQkHCchyp4Jsyt0SNazvK7IHUA8MGStLdAIyHQThrVzqQUfYFTu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csI6v30u3pceOrwHJKdns67cNK6sm5xyQf2SgeZXsWUjwY8ZW6HWD/zi6cQNteOIx7Acci1BnZva2006czuJRnomEixz2uk3CH4x11ln0jcyx0DwWsYeSfeBOZ/UCPB122a+uNdgGZ4JXOsSMyKX8rsj5MGPnm8Fu8Szfe5LqXbKecrveKrKndiFwCaWBRWp2/huK8XEhnPQPACkP1CAy6jK33oeN/7FYZxfUCOT+w0BNMOxjDNdmPJ5s4ABFO3eeIE9T7Y+ftu23OAzCAYzT67PmmluTsLYBVS/VwSVB11JqbSkChqJWLTpa8ODoR6EdP5RXrgOWZzzBIhB4hEM0tcVFQCmZyvPkcrfbCtTl6qvPWF8QfsOsXUpN9jJJWHq6YULylgJs9MjIbwYQar1Kd9klSPloT4Jd2pzXYP20Y+EDPue0Mv63Pi05YFuspGOqgtygKry1VSlhO24110oCSgcDjlynyBZMCIoFSH7VBRLl9CgaKP2JJEkdlJ/BT2+1i3YEqRzeUrQNxc8DeUZLwzY4VJy19AAeGtyksDktBVkjgycHK52ym/408wWufl1u+LFuYyEZzhh0KZzg2p8QS34nRj3Gial6GvZfDhvH1tXivtt58yXqI68zUKpA7jLL1z30zLBn+YguIqzlCcbyv2gi1tR2sjLQVyOgtibXYtHTCFBIs8kGSnk1mOnKAnwra6MkyGAaGj6+XTDPFssHXVDqi5LM3XO2mGus/3GvRk0YhauIvew4S+A7PxhFjKgW8gY4LBqkvAy8tGyI/18= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cb02892-875d-4538-2188-08dba57a5946 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 14:48:30.8477 (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: PMqccq/AJIWVzUxIF/R4bSEuw6Pg6J3pI9rQvpvgU50wvpMH/051yaJae3oetk4ZFR9wCZmtIh2Kcv6vKE9Ejw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6326 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_13,2023-08-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308250132 X-Proofpoint-ORIG-GUID: C-_DP35YL-Rd1dacW7AXfAbYBWysIAZQ X-Proofpoint-GUID: C-_DP35YL-Rd1dacW7AXfAbYBWysIAZQ Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently, to fix device following the write failure of one or more devices during btrfstune -m|M, we rely on the kernel's ability to reassemble devices, even when they possess distinct fsids. Kernel hinges combinations of metadata_uuid and generation number, with additional cues taken from the fsid and the BTRFS_SUPER_FLAG_CHANGING_FSID_V2 flag. This patch adds this logic to btrfs-progs. In complex scenarios (such as multiple fsids with the same metadata_uuid and matching generation), user intervention becomes necessary to resolve the situations which btrfs-prog can do better. Signed-off-by: Anand Jain --- tune/change-metadata-uuid.c | 48 ++++++++++++++++++++++++++++++------- tune/change-uuid.c | 4 ++-- tune/tune.h | 2 -- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/tune/change-metadata-uuid.c b/tune/change-metadata-uuid.c index ada3149ad549..642977c3747b 100644 --- a/tune/change-metadata-uuid.c +++ b/tune/change-metadata-uuid.c @@ -21,9 +21,31 @@ #include "kernel-shared/uapi/btrfs.h" #include "kernel-shared/ctree.h" #include "kernel-shared/transaction.h" +#include "kernel-shared/volumes.h" #include "common/messages.h" #include "tune/tune.h" +/* + * Return 0 for no unfinished metadata_uuid change. + * Return >0 for unfinished metadata_uuid change, and restore unfinished + * fsid/metadata_uuid into fsid_ret/metadata_uuid_ret. + */ +static int check_unfinished_metadata_uuid(struct btrfs_fs_info *fs_info, + uuid_t fsid_ret, + uuid_t metadata_uuid_ret) +{ + struct btrfs_root *tree_root = fs_info->tree_root; + + if (fs_info->fs_devices->inconsistent_super) { + memcpy(fsid_ret, fs_info->super_copy->fsid, BTRFS_FSID_SIZE); + read_extent_buffer(tree_root->node, metadata_uuid_ret, + btrfs_header_chunk_tree_uuid(tree_root->node), + BTRFS_UUID_SIZE); + return 1; + } + return 0; +} + int set_metadata_uuid(struct btrfs_root *root, const char *new_fsid_string) { struct btrfs_super_block *disk_super; @@ -45,15 +67,25 @@ int set_metadata_uuid(struct btrfs_root *root, const char *new_fsid_string) return 1; } - if (check_unfinished_fsid_change(root->fs_info, fsid, metadata_uuid)) { - error("UUID rewrite in progress, cannot change metadata_uuid"); - return 1; - } + if (check_unfinished_metadata_uuid(root->fs_info, fsid, + metadata_uuid)) { + if (new_fsid_string) { + uuid_t tmp; - if (new_fsid_string) - uuid_parse(new_fsid_string, fsid); - else - uuid_generate(fsid); + uuid_parse(new_fsid_string, tmp); + if (memcmp(tmp, fsid, BTRFS_FSID_SIZE)) { + error( + "new fsid %s is not the same with unfinished fsid change", + new_fsid_string); + return -EINVAL; + } + } + } else { + if (new_fsid_string) + uuid_parse(new_fsid_string, fsid); + else + uuid_generate(fsid); + } new_fsid = (memcmp(fsid, disk_super->fsid, BTRFS_FSID_SIZE) != 0); diff --git a/tune/change-uuid.c b/tune/change-uuid.c index 30cfb145459f..e81b7980bb69 100644 --- a/tune/change-uuid.c +++ b/tune/change-uuid.c @@ -210,8 +210,8 @@ static int change_fsid_done(struct btrfs_fs_info *fs_info) * Return >0 for unfinished fsid change, and restore unfinished fsid/ * chunk_tree_id into fsid_ret/chunk_id_ret. */ -int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, - uuid_t fsid_ret, uuid_t chunk_id_ret) +static int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, + uuid_t fsid_ret, uuid_t chunk_id_ret) { struct btrfs_root *tree_root = fs_info->tree_root; diff --git a/tune/tune.h b/tune/tune.h index 0ef249d89eee..e84cc336846c 100644 --- a/tune/tune.h +++ b/tune/tune.h @@ -24,8 +24,6 @@ struct btrfs_fs_info; int update_seeding_flag(struct btrfs_root *root, const char *device, int set_flag, int force); -int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, - uuid_t fsid_ret, uuid_t chunk_id_ret); int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str); int set_metadata_uuid(struct btrfs_root *root, const char *uuid_string); From patchwork Fri Aug 25 14:47:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13366058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01E2CC3DA66 for ; Fri, 25 Aug 2023 14:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343859AbjHYOtU (ORCPT ); Fri, 25 Aug 2023 10:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343863AbjHYOtE (ORCPT ); Fri, 25 Aug 2023 10:49:04 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783482125 for ; Fri, 25 Aug 2023 07:49:02 -0700 (PDT) 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 37PDO0aO009073; Fri, 25 Aug 2023 14:49:00 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-03-30; bh=y78thrKHqKEwx/1GSstmbRTdt9j/CSJv+FxzbOtnjpo=; b=Uxb3mkm4ceu1EVserD75nEGvrJTL84u+czUc8CPkLZt/w3tK2EiHamKpuVOFHQdcCaLz wWcIRGKyoDQ0sPlwsJ90PEHwOJIQfCwSqwO6LYc4pRaVgK9tOii32WwbyB8Pc73lwnC9 hjxxwBOs+13DJhk5f9VVSzplrY6wOUBMyw/t3v82a7nwWR4Qpcuhutm6jM9oHVXBRgyo KSFuiBlfDwK+G8agT7SoLqmbudIIt27epn9gsj4uAKyNHnzlbQK7fwO6VuboPuqGxrY2 NsUTpM7uGsBXf1j9VunwF7INJMy+glY3uEpbNcwJ/Var+Tb8GZ9rtqAM7uaDduHp6+qb 7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sn1ytxgsu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:59 +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 37PElcgX035966; Fri, 25 Aug 2023 14:48:58 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2105.outbound.protection.outlook.com [104.47.70.105]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sn1yqx189-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Aug 2023 14:48:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MsYb20thWbywPKXT6qE+RPh7hPn9LkfLSdqtFdxGMGZM/faE1pt+i3HMVbjf4aouy1yF2GQcLJWmRMPQj7d4crEE3n4IR6uf98YlNLOYdpXMKlwzP1AF4aqCjO1QjsNXuXheFBSolgGRfQMIQ73IY+J2LMi/EIh1u0he7RBKh76UABQL2nAjvFZHSDkSXej8nAeX6JZem+RIUqHCJ9E9KZXHPWKlLBPS4v/HIQwbXpqq5K2RSbyZtB3l2vX1lAo+FGIu36Cwk9Gsl4TAgO2vjWKLS9lpn1vovymujDtO78AeZORNiGgML/30iB+8wQViW0Gk3Xf+9OtMo/R6ZrVSnA== 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=y78thrKHqKEwx/1GSstmbRTdt9j/CSJv+FxzbOtnjpo=; b=fLXm3izdqL5iy7zxSWqiafVOsgMebhYeetLENsCCKYl384MzHHe+iA+BXxLMEtzEFcfZPq9UB68C37oOIAeh5KtWd7QeVc+u4eS6Aqj5+phJVcuG+qh41AMHCDy/m3CokmLOZySssdCnBGgbW4bUJOaYuBHDZroCMitj10AvQY28Gufrho+iDk7q76Ko80Eni0bTSvts2UszGyH5ZscyeDoDdcg8mHOGmWHAz8dji4QjxwDVkMmM6n5H/u5fXv151Fm0AWNo97It33uHm4+DgKSh4I7wf05czFfO5moozS+K4HyJ+nAkGP9CRqWrZYhffQXq7Kc3F4JUNx5emjm/gA== 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=y78thrKHqKEwx/1GSstmbRTdt9j/CSJv+FxzbOtnjpo=; b=qGYEx1eD2jR6P8QbI4NwZuvyRUHnXvNG9wYuz1EIaXpGcSydxH1XQ14ew5yupXxnvZmm2nTeFfUJDhQeigmBMOqqAhBvhKEgoCKe86v5AswNIRI88hPZ0BOGdCHd5h1PVDU+6ofXoJ0lc4ssXHkGc/eA5iYcZFBOukjJIAcrwP4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB6326.namprd10.prod.outlook.com (2603:10b6:a03:44c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 14:48:37 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6699.028; Fri, 25 Aug 2023 14:48:37 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 5/5] btrfs-progs: test btrfstune -m|M ability to fix previous failures Date: Fri, 25 Aug 2023 22:47:51 +0800 Message-Id: X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0058.apcprd02.prod.outlook.com (2603:1096:4:1f5::9) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB6326:EE_ X-MS-Office365-Filtering-Correlation-Id: bb666239-1683-41bf-c200-08dba57a5d25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /rRad7SsI2tRoIsEIlh7BNZR7UnJL5gK4mACHunva27vMXVfjaCPjTGbdnlHKRZsYl9CY+AFprovkuFpeUOZFvJxkeUn0Ffgs4NrNwOzyMtAako9sgcifH7H/0rd8IzE+xJrkBTePv+d2qA6uf73zVrYZSKB3UgPgEh5wdwGhsiaEyyur2mu5GxvbvZJbiRfyLzs6Ap4+F4VEmHRfIJz48o0lBFvZtqTTOkwyaA6Pi42tIIJlXjPEUzl+qAlFGkNpGUThjislO9QEAmTm0UDGuOootIwJZXaCr8hdajieFty8jdfZA3TK6BL76Nt7vYLufUhEj3Q07prUyRNdGEM/kCh749KGa1DoYBkFCQBjSgJhskWN0RTdP/G5WFl7gQUabtjH5uJagySk50CaA3lObcx5i7d7L8HG7biDDqf3V8lOoJRZRN+zro5MyfwCDaH3xola5UDcR7ubeQS5dpQFjuao/yVkFG0+VsPomDnv2edA3ER2ZKR+QbcG4ssM1Bmhd0qi4wNQiQnBUDcGDM7zlUggegpKAsDet1xqOSjhmq+/QFzm9amXJPOkeFDq0Y1 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)(376002)(39860400002)(366004)(396003)(346002)(136003)(1800799009)(186009)(451199024)(6486002)(6506007)(6666004)(44832011)(36756003)(38100700002)(86362001)(2616005)(83380400001)(2906002)(26005)(6512007)(66556008)(8676002)(66476007)(66946007)(5660300002)(4326008)(8936002)(316002)(41300700001)(6916009)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2CYAgFyKxEGpycXJJYyWzCJXMEMuCG3vTqsFGge6PQrQ7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W5nDnQJb3wu5E1odlN1QzhLuWDT5LLa43d3AuQ3eapbFxf+OXXBiiOh/BdZj3yJed9Z3QnD7LPYuUFeCQ25WPeXnuGGYQJckAB8uCDBUpnVKhSdNYkw+tiF+3OR31gB/HCjEbaOzdzI27baLPUscqPiSL7TbZkTWL3mY0F6MhnnKJ+DBQH5lU4eMZqh97IxZMUnaWLajNtLT/Lh63eafa44jKYgKhkeYFWHNZyOLlh6MpsBSqBsdsL3tK3XzMDRpKpz7Lk6ebYxx6eUoZb6bGO6RAOPqfXr8+j0JoF9W8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb666239-1683-41bf-c200-08dba57a5d25 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 14:48:37.3524 (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: IIdqUpEaPtSQWKr++NFakNqcquPJmj3eOJsruZjwi5EhBpz92vEDEGg5+na5INfgEyOTUXRiSCzzsYetxIKAJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6326 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-25_13,2023-08-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308250132 X-Proofpoint-ORIG-GUID: E53w5OO-V5OD6orX1T6LB6SLzrMDeg8Q X-Proofpoint-GUID: E53w5OO-V5OD6orX1T6LB6SLzrMDeg8Q Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The misc-test/034-metadata_uuid test case, has four sets of disk images to simulate failed writes during btrfstune -m|M operations. As of now, this tests kernel only. Update the test case to verify btrfstune -m|M's capacity to recover from the same scenarios. Signed-off-by: Anand Jain --- tests/misc-tests/034-metadata-uuid/test.sh | 70 ++++++++++++++++------ 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh index 479c7da7a5b2..0b06f1266f57 100755 --- a/tests/misc-tests/034-metadata-uuid/test.sh +++ b/tests/misc-tests/034-metadata-uuid/test.sh @@ -195,13 +195,42 @@ check_multi_fsid_unchanged() { check_flag_cleared "$1" "$2" } -failure_recovery() { +failure_recovery_progs() { + local image1 + local image2 + local loop1 + local loop2 + local devcount + + image1=$(extract_image "$1") + image2=$(extract_image "$2") + loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image1") + loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image2") + + run_check $SUDO_HELPER udevadm settle + + # Scan to make sure btrfs detects both devices before trying to mount + #run_check "$TOP/btrfstune" -m --noscan --device="$loop1" "$loop2" + run_check "$TOP/btrfstune" -m "$loop2" + + # perform any specific check + "$3" "$loop1" "$loop2" + + # cleanup + run_check $SUDO_HELPER losetup -d "$loop1" + run_check $SUDO_HELPER losetup -d "$loop2" + rm -f -- "$image1" "$image2" +} + +failure_recovery_kernel() { local image1 local image2 local loop1 local loop2 local devcount + reload_btrfs + image1=$(extract_image "$1") image2=$(extract_image "$2") loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image1") @@ -226,47 +255,55 @@ failure_recovery() { rm -f -- "$image1" "$image2" } +failure_recovery() { + failure_recovery_progs $@ + failure_recovery_kernel $@ +} + reload_btrfs() { run_check $SUDO_HELPER rmmod btrfs run_check $SUDO_HELPER modprobe btrfs } -# for full coverage we need btrfs to actually be a module -modinfo btrfs > /dev/null 2>&1 || _not_run "btrfs must be a module" -run_mayfail $SUDO_HELPER modprobe -r btrfs || _not_run "btrfs must be unloadable" -run_mayfail $SUDO_HELPER modprobe btrfs || _not_run "loading btrfs module failed" +test_progs() { + run_check_mkfs_test_dev + check_btrfstune + + run_check_mkfs_test_dev + check_dump_super_output -run_check_mkfs_test_dev -check_btrfstune + run_check_mkfs_test_dev + check_image_restore +} + +check_kernel_reloadable() { + # for full coverage we need btrfs to actually be a module + modinfo btrfs > /dev/null 2>&1 || _not_run "btrfs must be a module" + run_mayfail $SUDO_HELPER modprobe -r btrfs || _not_run "btrfs must be unloadable" + run_mayfail $SUDO_HELPER modprobe btrfs || _not_run "loading btrfs module failed" +} -run_check_mkfs_test_dev -check_dump_super_output +check_kernel_reloadable -run_check_mkfs_test_dev -check_image_restore +test_progs # disk1 is an image which has no metadata uuid flags set and disk2 is part of # the same fs but has the in-progress flag set. Test that whicever is scanned # first will result in consistent filesystem. failure_recovery "./disk1.raw.xz" "./disk2.raw.xz" check_inprogress_flag -reload_btrfs failure_recovery "./disk2.raw.xz" "./disk1.raw.xz" check_inprogress_flag # disk4 contains an image in with the in-progress flag set and disk 3 is part # of the same filesystem but has both METADATA_UUID incompat and a new # metadata uuid set. So disk 3 must always take precedence -reload_btrfs failure_recovery "./disk3.raw.xz" "./disk4.raw.xz" check_completed -reload_btrfs failure_recovery "./disk4.raw.xz" "./disk3.raw.xz" check_completed # disk5 contains an image which has undergone a successful fsid change more # than once, disk6 on the other hand is member of the same filesystem but # hasn't completed its last change. Thus it has both the FSID_CHANGING flag set # and METADATA_UUID flag set. -reload_btrfs failure_recovery "./disk5.raw.xz" "./disk6.raw.xz" check_multi_fsid_change -reload_btrfs failure_recovery "./disk6.raw.xz" "./disk5.raw.xz" check_multi_fsid_change # disk7 contains an image which has undergone a successful fsid change once to @@ -275,5 +312,4 @@ failure_recovery "./disk6.raw.xz" "./disk5.raw.xz" check_multi_fsid_change # during the process change. So disk 7 looks as if it never underwent fsid change # and disk 8 has FSID_CHANGING_FLAG and METADATA_UUID but is stale. failure_recovery "./disk7.raw.xz" "./disk8.raw.xz" check_multi_fsid_unchanged -reload_btrfs failure_recovery "./disk8.raw.xz" "./disk7.raw.xz" check_multi_fsid_unchanged