From patchwork Fri Sep 15 04:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13386334 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 AF747EE021A for ; Fri, 15 Sep 2023 04:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbjIOEOH (ORCPT ); Fri, 15 Sep 2023 00:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjIOEOH (ORCPT ); Fri, 15 Sep 2023 00:14:07 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB86B2703 for ; Thu, 14 Sep 2023 21:14:01 -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 38EKxSuA032061; Fri, 15 Sep 2023 04:13: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=bRbozF+jKHcsgVAFl15nwrEOcEV2ZQfXxbp39kqWvAo=; b=owAK+nUAqxVOIPXl0mdcmlrS3fAz11EA0D3XN/BY2/B/M7i1ykpRiU2Ap9EQrvdJz4eV 2983/IZ4xO5fIglXwlQ6c0S8U3E46LwMKaThgzfzafYZK2IOaSCAuTWjNIshKCvNTEXt HF89ankx081sNt4zu3HQ+4U6/Ri5T6Ja/fklTgrtSHxhJHYw4sY7k8AWeYz4j0j4zoOE YWMFrzXouYztqV4Na1cedzb9P7EoP/629lKAArWykqWFIow980MM32zm7n2g2ywaOGSQ iPG5Li7lIqXFPIKWxKvoyEgOit+5OlmD6YSJoSm7mi0aB+K1DCWcUwGBRud/Gwacb8RO OQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t2y7hewmg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13: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 38F46rYD008927; Fri, 15 Sep 2023 04:13:42 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2047.outbound.protection.outlook.com [104.47.51.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t0f59tqf1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TKLjF56acCWf/iWj//5V5/FCVqnTzqePsF9SnaolbXfSlwXzUXlTtV0qRet68F7UloCJwOa90UxalDAh8CYQgm/cpG1X7VEa7km1hgaELr9kKEQWH5jevBKml93VyRNAPPMfO1HSWTBTfFl0BHnjvMU0Wskrs0FjWyjjQ+SlRX2qLcnH0s5rtVHASe4aLlBBXCYZgMK8AJ5SMJOXrk4NjzUJM8zrkq98GlD2YJRvQtm1Rh9IzFjsfERsOB11ZW4DvnToBRP+hduPu+CJd1KKp1/HZOr4MdixQMVYsblwpeX3SVZJeEVEE5sAKfaMn/kmVcjTv8+GzMxwWAhwafdlFw== 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=bRbozF+jKHcsgVAFl15nwrEOcEV2ZQfXxbp39kqWvAo=; b=XsRMgTV+xHgpToO6w6gQdHh1ghXASiuCgXjkpStF5RHli3c7GGaps8riTc55x9IssOOhkEFKjCR9tRb4RmAS//5/s2AJM062N0jEKB0xoEWugbiAFjmFM3ZM7K7u3qB7U6pIs+koUSe+GGIODIXK7akUXRESjLC3r4ocQT6NbSk5xjydgIhPWtoj70CV7K/iOLfMwbotEpm2UWio8JJrZOmyEPN/yDdIWGAQvF1bXs/T+WyMHV2NZgXgbZ0AtL4kX51b7fsty85mmpuLfCssZC8E01QBjGath7c9VgpYBTWw6hpxSPKeQxEly7ADiEtowVGjYdy5xR+gsjc3EgzMHg== 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=bRbozF+jKHcsgVAFl15nwrEOcEV2ZQfXxbp39kqWvAo=; b=pUz7cWTqwtR+wKFQ5fkvi1PCrxq+jHzWQdD4DleWAMzmIXQiftGQ5w7cbfiKArGHim1MBbIzaI0AdP0kbPhSvgJLfRUfDMEnir6tumlpZ4OMevSiLVe2HWrzAVxhIl58NxSt4R4rFxIPYoloaOEQ3Q7l7XAizPuH0wFk9m6HWvk= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6544.namprd10.prod.outlook.com (2603:10b6:806:2bb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Fri, 15 Sep 2023 04:13:40 +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.6768.029; Fri, 15 Sep 2023 04:13:40 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 1/4] btrfs-progs: tune use the latest bdev in fs_devices for super_copy Date: Fri, 15 Sep 2023 12:08:56 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR02CA0032.apcprd02.prod.outlook.com (2603:1096:4:195::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_|SA1PR10MB6544:EE_ X-MS-Office365-Filtering-Correlation-Id: e9b36553-7edb-45cc-d89f-08dbb5a22470 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QCTSl0j4DbgiR4BXfNRESpo5mUUiUXyAQo8J7rrPWgFAdOBTz8IU4ToDWJGjNlPmip2BQhe9CAomHj2EM9SKu8MSGjZEzqraPQFLDOx+KVto9aLa9IP/fBA0fjcAVFoBLDfFCYKqFdB+NR1hszQAebL5/st0JOJe5eWZNh2YBKKlwPRXqXv4dn5zS/N4DpS5i6aEvQ3KEGTmEeVwk3LCRv38acLYV9efC+rSlRp60EQXcHgX3JH3/MbAwTKf+GgTe9XfK2kaBJF7o+in7El4WAkn1octf889BWAO6TrjceepKqLbnsJBYzJAJl3zvY+FsQozV+ki9kkM64B0MJZXVI80ifOLNPpb81OdIDzs5gX22ucvXmMObkS7o9K2geJuiUGhTGDFFqc8ryQDkavz1ByEb0WI+iUo8AavQpPy3rRwFLRX5Q5oRiO7hRM9qXWwKbzxqD2PZhf6SLWASHkhOkSZ5V+MGBnnmulOz7d96Oh9N4XLJql50X48Y30U2brnOzsNWGmIDEAx/mSZDeX9MYAulGn6Un1fc9Vf3kCSQNfBRpEoJr2bRS0b9DAqM76q 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)(396003)(366004)(346002)(39860400002)(136003)(376002)(451199024)(1800799009)(186009)(36756003)(86362001)(5660300002)(6486002)(44832011)(83380400001)(8676002)(8936002)(41300700001)(6506007)(2616005)(6666004)(4326008)(26005)(6512007)(66476007)(66946007)(478600001)(2906002)(38100700002)(6916009)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YKRUfD47Rt3d9k6gz+9hO7HV6U7gnn92ji/HelXdk9zItd9FcYdRFOo4pHBKVlUSo/ep9LQ7rLp0Zxd4X3ChzbM+3TE0oaYZVWLrJEc6Gnzq6rdal03Cx2irUwznYzeYtzVPzwjTXykUTxIqL59pJMhq28mG2T/25bEdyOipn1TYFAXAJfMZ/CMvHc1BpiM3JEJX9uodGyLTwwMCC0i74vr0ZV0oHUKdmw3qWF/I+78ESP5q2OVUvNkuiQYoSj8VK+u5I50wCdB/W4VnAOEsVZRuc7tq7ZLvBkNlYadn79AqDUKjVOkICO1Hl9LrYdhTx0xddKxJYdCi3m2X2M5tGHQGr8+6TmO20NM+cjiNMMOaKIceOihbrml0p9tl4iLGn3QHZyYJkCYl/CiS5VpiyoIMj38cxU/Yii/6a/z4JvTVzcM2QlduEBVPtYlxeOO9v9082btIg4R038Eb0SeFA3rK3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9AN13qd1rP5c26Vf4bV4RV07cv/DV5tY5bYcF7RXan+kOEuwX3DMMrPclUwgWMj9A50fQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tawZehNlNq10wU3NIHGjlWf0tmBOSWG3waKI7ai9GGrVsSu6PRmseKbPYYR+qbDGl5cwRlaaxph3NCI8530uX4gs++pTRN7ARg2XSWTcZtjFFeVMVieHPxBSnnXAXROC9qbV1Qexj+aCAH7rCauY72b4Fv9j4wenRnwWhm10o6TNuV3aEQck8xZPZrvFupjxQQzgOi+kvmZG3hYxbbUcsKUPKxV8jpBS4N7oHLHFrNlFaYHm7tMsCwOJJbz95OG1sHWgVzS/vjCxdVpxM7HNSdenymrYCguGWG/ekkUsT6LwIdJp1X9oS5hOa+YZWbIIMhTTpN/e/xmlh4BlnuUgvycmJ5q2Xw3z7T3Y8uk7zHpZTFi969RmUiSO2J9eI/UuAHM22wP44BiO6oMEZIeRJoFJvYXsjdaG1JC+Jx/5YvomkUmNMIaRfCsCHZ1/TdoJAmi9H2Hi5RYfUzpYy/dIDQBIkX58gtEXH+DcFPxodpJO0TK6eXMFt1W2Pc74H3NbRPQOzh3UvuHmRUkQMdOEt1PsrXMvi4wMBoFkF2Q25g5h7WA9DpPhuX+B4SLd6EkIjvTqO0CiguPFzaIRR9QZNFEuKkqAVN2So8vliBZDZVCQHBFUAfoGKWiAkwuDbWt3GLnHoWVPZmg5b3J6w6eNUz0pn7v/Xg2t8+Q5v9djtAkjFVHM6V9uF5fos8Rfsbk//cVPMrAAo0Z6j0rUsu7ffN+6+IWLKZFB++tX9il9WsF0IClzU7Pg7qTXBXxeNUhoNeaRVYlucvTP8NDVfiU+b3x+1rt5ru8rfHG/q1VjXwM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9b36553-7edb-45cc-d89f-08dbb5a22470 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 04:13:40.5192 (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: 644N4NjTHRG3BK0imc2NfKagEXRoHuj+EKBntVXxnHDLjyYQNg1jQjiiaGogAnu1j6A1QXxyqN7dUDu8/NJzCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6544 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_03,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150037 X-Proofpoint-ORIG-GUID: jgRzoUk6NLYg_Q2bisQqZNX3O-bJiV5h X-Proofpoint-GUID: jgRzoUk6NLYg_Q2bisQqZNX3O-bJiV5h Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently, btrfstune relies on the superblock of the device specified in the btrfstune argument for fs_info::super_copy. However, it should use fs_devices::latest_bdev, as it points to the device with the highest fs_devices::generation number. This will contain the superblock updates that other devices may have missed and we can now support reuniting devices following failures of btrfstune -m|M|u|U as in the patches: 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 902c9d97956e..2d8f2b012caf 100644 --- a/tune/main.c +++ b/tune/main.c @@ -345,6 +345,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 Sep 15 04:08:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13386333 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 01AB7EEAA42 for ; Fri, 15 Sep 2023 04:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231328AbjIOEOB (ORCPT ); Fri, 15 Sep 2023 00:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjIOEOA (ORCPT ); Fri, 15 Sep 2023 00:14:00 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C28412703 for ; Thu, 14 Sep 2023 21:13:54 -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 38EL0Goh031855; Fri, 15 Sep 2023 04:13:51 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=hUi44kM0giO4rFwKmNqwxnhmTnu7uM7m2vPyjLtmycw=; b=14EHGmIOm2PsiWQl4lVgfT8lTlST/0/4dsT34b+H6G0Gpaec9FbNGphSk7otjt/f8Ety TIiimOeIIUJ3eFlvTM2b0N2F/2ZiNYm7PIxu/VwfAJ7Z2GpZ1nSymIlmgjyRgCzSwLOe SbwlfaZvz8cvHXGRDYXhATImMeLtVvqkPrlg3ZWAVI8EzZ7aYaB2B/uSyFLz0L22Sz/m u0B0CwT0oNTzvXcErFE5SQpNT776XQlNNzjt60OMmhOc5vXFjmGDpfzDL74Qsk/uws8D zGKMpQs4jUCu8v8yhS1iIE7y4AaxCdibGv+y4ii+8DtMV4z/Vi4bh7618Y88Uuy+6ehq Iw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t2y7mxqxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13:50 +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 38F3FhXV028173; Fri, 15 Sep 2023 04:13:49 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t0f5fvdgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JT0VoW+MgV+AuAXc5aN+TZPrF0KFsW0pLfz5bBpbCoIOfEJQBdopp0Sple6je7NSGSuaYF3ruZ49THyDoZAsNjH7Jkw698K8APRa5+g1bhVP1fJ1jbeV3IOmlcEjw4dXBFowRzdzfOv8EaM3IcWTC7sOlZLB3wOpINLabGHigYvNiTOJJB1cMwvGDKsxgOIJu7asXnhTDsJzsOAPWSEGjWpXwMWHQdj5q05ybGM6a786G+ZKiuXEYWtcZT414JfzSqaMOuyRDorRoTbc4imkbu+b101RVnFx0Yte3tfQlC1j13nUKE3u9c8DdmHUbbpIEUI4Vod48eFDIOHt7gKvgQ== 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=hUi44kM0giO4rFwKmNqwxnhmTnu7uM7m2vPyjLtmycw=; b=DwRXUm2RUFmlhl0whu8xDm6rXcX5AlgO+YPsu3lTw+D3y4UQehrIH6wqvwQS1Qxsm2wphGRVUllXo7dkq9a8doEeOCRHd8GCE7+DxVkmuYjV9+rdWCzCeITMa1KF5BpRtmAXi9TkWOtaln4nGXZJgVpUKMfIuLQEKcvNQVm19b2YpA58c+9QYVJnoj/vfn25uxv3xB41KgHr/EntpWQA9c2q0/n1DfBzBdTVCSyb9bhC0kom+2pJq0wlkA+LDJJXQn5b8jri9JJwg2wke84mbwbORmwSiKcKwWVRbER6EQcfsELhqJr1ORYRn+uiV/JZKCUupMhhws+GddSikuoMTg== 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=hUi44kM0giO4rFwKmNqwxnhmTnu7uM7m2vPyjLtmycw=; b=mV2+yo+FZ6OkUGUgBcebm2nZ61rtDpse3BO14bApcuO/AzH3JKapQnapXsjGC4wbuh+0xtD7AgC+njIW6XXDc8zVt6imzdWrMz/n/57CYXl1BRmuMRxxPrxmNQZ0mL6nr2STftVA/ecyprLGsZCYnZCsQAbQuMixbf7pmupNGwY= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6544.namprd10.prod.outlook.com (2603:10b6:806:2bb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Fri, 15 Sep 2023 04:13:47 +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.6768.029; Fri, 15 Sep 2023 04:13:47 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 2/4] btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag Date: Fri, 15 Sep 2023 12:08:57 +0800 Message-Id: <4514fc6c2ae49957e349a9b186a61ed11a0b7d4d.1694749532.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0020.apcprd02.prod.outlook.com (2603:1096:4:1f4::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_|SA1PR10MB6544:EE_ X-MS-Office365-Filtering-Correlation-Id: cf67154c-8006-49c8-4b30-08dbb5a22887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6s7Dt3Q5aoCfJXiEfCDCn+uTYa+aKCBBHEAvG6MiFdQM9lNVVfHl8VqFeVLEDn0xm2IeKR2dfZg+La6rtEtxb8KOoKRQVuPYIxDHm+Eh9sUnhppRt9rZMehGe8BtiJOML3Kfp/RvQMSX5qw+9d2gmWIeyd9rALHJmSClclavrzTLTei+6Qt1pCgx3WtPGEVwKQIsHeTAWqA7OD2qJWIR+GcoR6IkjLgDteuuXtIi0e6BeZeAFQPK4Cb7oG6Is92K+a8D50vwheiQAiEoKu5fCr1hdUV8WjlV7cM44wfCrBGdBLQe27fSZIs+DaOKauH4gSbrIeJMKt7RSt/4TEyWp2iXOOKmzOOEfzAsDaPRRcvE3kVA8FbA2pyQiDfoh4YbMegHN2yWwI2LC0G290nNhvLA0FUk10zmxlourTuqRJR96IeSFBepJUoU732YYtM/ghkqV7zKAer85Sdx3ijHPkGcGeO+Vd8p7X19tfeeooLiXb12DQZpvhwhQ+93JGPcZ47fiS/GMICbRiFbL0j9TJoVvrgpMzBpfT1oR4OPlhRdKiCGyUA2zVkpCtgusghq 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)(396003)(366004)(346002)(39860400002)(136003)(376002)(451199024)(1800799009)(186009)(36756003)(86362001)(5660300002)(6486002)(44832011)(83380400001)(8676002)(8936002)(41300700001)(6506007)(2616005)(6666004)(4326008)(26005)(6512007)(66476007)(66946007)(478600001)(2906002)(38100700002)(6916009)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b7wAvVWG1YcTgdG38Y14cqpdTCIfqk6N5spsvopO9ijIMad5fUzOaIOWGfyRif+IJN/xfx2KWusywIeLVpTvQIp5mIcKtjUyVKuuIT0pOFzyO8fBV97ebJArTfgskOxxNQRi2jojAZAKusHE+BOgB4hK2ya22Iv5br26rxI6oEjWaEgRnlRBN6lt0DhLHaCRz2sXxxds7FboafMdBrbbTAjknZooUJFxEV7n5Ec0ePBXJSJQrpVq9HJDNQ7vXR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gNm/TLOoztNCXRNQ6QhK2NGlOBlaEaTXOPKHy6bNAsI968wjYZNRQteJRR1Ta522+laD8pan+sqOyst7pmXT0LVJfmhoBJDBYvlgg3VPY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf67154c-8006-49c8-4b30-08dbb5a22887 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 04:13:47.4902 (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: jsfM/QRBoNCO7n8rFV3Eu3zARWVkt1zAEW2Zplf/D0R+va0JKh9ppytrCG2Pu3FKguDC3E5Iez2ulrM5fxX7Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6544 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_03,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150037 X-Proofpoint-ORIG-GUID: pXcy4OTfqed_cDc-vvx1IV7hnDyG07U0 X-Proofpoint-GUID: pXcy4OTfqed_cDc-vvx1IV7hnDyG07U0 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 e3f8ee3e0242..6a1ec0d907e0 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -338,6 +338,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) @@ -352,11 +505,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); @@ -381,7 +541,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) { @@ -435,19 +608,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 d68ef0dc221a..ac9775647e12 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -111,6 +111,7 @@ struct btrfs_fs_devices { bool changing_fsid; bool active_metadata_uuid; + bool inconsistent_super; }; struct btrfs_bio_stripe { From patchwork Fri Sep 15 04:08:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13386335 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 F1823EE021C for ; Fri, 15 Sep 2023 04:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbjIOEOJ (ORCPT ); Fri, 15 Sep 2023 00:14:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjIOEOI (ORCPT ); Fri, 15 Sep 2023 00:14:08 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 018AB2703 for ; Thu, 14 Sep 2023 21:14:03 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38EKxZSw029217; Fri, 15 Sep 2023 04:13: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=v1XTdY/8SMXzJ/kK6SHlu9knIbc147IVanONA0YYBTQ=; b=SwyYuvffYAQzDzFFi7Z9mwEV1aF6MRxaith6fjOELok3Qk0uK89mJhh6MC2kXxJCT5jO 37Swu6NjhBtvKeRRmweb5l2dpRbCHORzdLH7JHQLsEQ4E4+DbD8zzaRr06lUwanjnwNl 7gzTADzjZmazFntoJeb1o4hCqyP0nVZamEyKOs0G+7/ROOxVx8seGmdMH3jopRe2aXGS zqyuucnHKWq8MMUxmqm2lF/7YiPZCROmQ4yvziK54oUS7kZlx05VSItbyAlTg1mpB3f6 +3EWLgRcxEpTelItntgvvxBlthnJ1bkrsiQ2Rnm6QyJOpabbFfvkLpOkb5L+2H/GwMov 8A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t2y7rf13x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13:58 +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 38F1Vo0N007350; Fri, 15 Sep 2023 04:13:57 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2042.outbound.protection.outlook.com [104.47.51.42]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t0f5aaq8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:13:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ViIF2kc8pPJkH4EShTJ6QyXeKS5SnY6bo0SyJ1OFRGWz9fWveMf56/ff2pQmtSHPe/NcwwBT6NNm+NmbgGEM+sm1pGx4k2Y0n6JBnewa3SCX/OnPsSsw6prv869fTAmmVv5f80eLW/uOJQkrjLC/6jwde+5NGwPRo9NSiHl4l87g8FQSd2fU20nAvyTpqxMpD8Y9H4RYOvfLEJkmRYtvyuThb0ZccqWVhOACd1lNWGkmn/3AgMJaG19R6yMxOt5+D1riVmrvb33Q7VOpDqy5VQSCp8hcfAWye4PUWxd9+apx6Z1njCvEonTQH7e/N7EpjlflX+/NMTzCCr+p2qZFwA== 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=v1XTdY/8SMXzJ/kK6SHlu9knIbc147IVanONA0YYBTQ=; b=Xk2xLHV2DMiuskUehPUGCq2fHhQxnWOxM0LjV4qZHP+Oo5pRQwbn2ai7KoRxnbWBCYLkrO6c37QhDEwEU0dZxH7W+TY+xfc5f0gN+qXTAfG+X1bKRbUO2vXY/3CDQcAXMB47sEA15V7L0hIN4jnJvYCUsPSiEeTpT9d8njP1TWuytYt0fPrlJWDV16c3kAKYVAP6OM9kr20dkDtfbIPqcRnhX9S2cd2vIFSo0MqcGfFPLjOyEiqiVoPWvCuNW4UxwKFldKTeEPPEk4iFg4v0RYYpUOYG69npeehIEB9n5jJmfsa8e2AGR6NzoFfdae4WS48JDllUkRrumIpfRRByzQ== 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=v1XTdY/8SMXzJ/kK6SHlu9knIbc147IVanONA0YYBTQ=; b=QQMoQu1+t5MbO3Yj8d2WK/4GMN/Sin7La/nO48tXgBcNRgFqo9z+B4TdpDkxzrNaiZ3vHZIy4t9PzkEWf9c+Dwvxt5VlMvcSlPxZJXmfDf/co1OOjWBE3dcC2WOSMbr5c8piVtVyH41BmK2ll5FKUiM95krn7Gvv/3XhbV1tHlI= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6544.namprd10.prod.outlook.com (2603:10b6:806:2bb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Fri, 15 Sep 2023 04:13:55 +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.6768.029; Fri, 15 Sep 2023 04:13:55 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 3/4] btrfs-progs: recover from the failed btrfstune -m|M Date: Fri, 15 Sep 2023 12:08:58 +0800 Message-Id: <3d40d1d595d0cbb5a772877375532d1864fcd8d8.1694749532.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SA1PR10MB6544:EE_ X-MS-Office365-Filtering-Correlation-Id: 0321fbde-c5ba-4285-c57b-08dbb5a22d4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aKXg1TuLmWdAd4s+lRlvyXq3ht18ubXnSlnd0lBh0jt/MuAVCSHTx+Svqenh7ilBTkhqTpbCh8Gqwzlx/uZOl3WL9AEWv5+WsNBKFmaYO7H7uP6yVQYdxQUkH8pNwq/Qylq/uHezj7otWOJ5kRjqw/9wI9L3Qqh6Y9nIHW91xmr3i5CNfSyu4u+4JRGRnG7UaBZAcD1CUTbsXlDew0hFJC/OqWavQF5vpZ68vw7wBTBOLm4tHEsTCej5r89U+J9JeuUgl+eypvo2GxJ7mlbsZeMy4lPyneX6nTkSME1cakQMBW1WR3RevH87muSst0JxMyXpfjRcIcs2ioxA+RK2fGMDRIwekoF1A22ZOV4Rmiu6BUmpxlHtsHuUsGe4uonbDWyARDQjkYfc9Fei0n3xfi8tRDb4PWifS7wX6zFiiavXMh2DKC3CUeg9c1nDMMt5ol90XaIo1Mir2FtWbxPrtrTJ1ir0B4A9Cb9Lhd1mfqhTzEsh9qvdzstFALi4RWwPAl77+YgLFRIC0qrmNQ5wk0SIqJYZaZxfZIzfqakY6PmiclmGrjBDUJ7dPN6HQGhh 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)(396003)(366004)(346002)(39860400002)(136003)(376002)(451199024)(1800799009)(186009)(36756003)(86362001)(5660300002)(6486002)(44832011)(83380400001)(8676002)(8936002)(41300700001)(6506007)(2616005)(4326008)(26005)(6512007)(66476007)(66946007)(478600001)(2906002)(38100700002)(6916009)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3xnW4ju4wMNkT8LlT4xSpG6jGHueES1SpwauC/v4dBjro10VlvX2nwe+nv/CkYyQipOIJLFN9OdWD//JSaPMo2JYtSztbFf17ogWBlimrl3iJtDvdWWahLWhr3i+ez7Fz1/EtO04sOksKi8Xhjbh5w4M6lWvDEmb48FLKCS8owB4rYO3/Yltuka1Ak6gSyE8cZG1nJgsGpniQBMHUd+g4naTrxO93YEgK8YBz5ZfOhUNGS88jeuL7NDnJuFzctLxJ8a1Pyq/u+F3cxJxt8YT4DyiWB3F+YTh9skSj+2v8PQT5xZx1oYH2/8MRk1nDfF9eaL1/q2SrgOv9fqf+BGlkEvxszIluvFVJ+OWA3+1zaOIWV2wzXcW6yNmullsJl92bTKYYxO4EY8DgpEKc29MWT8RVHM0ZnQ2/eAB9ldhYtcO97sKUHVlC2Uv6BNdurmnrDAhhT9syvrZcwZsMYuDvhjKFMhy532lc5lBQu9JFmzteh1l+w/9wkiANBD6u5t4tdXXbSvhvmIKGOqqTDapjTB2O7nuXxzRvtuIdn8+fcNn/yVh+kS86pO01aPfBOp8dAyTJ+iDYetODzjJHAQRtLzN6YrN3SLjZkvI0Bx8LhvkOwAraevy+/z98ghbjP6R43x86HEI4CW+KTbG4yfdjGPIiHOUglB0GtkCSBkkMPRffTStynX+K59M+H/strZ/0nnLMp1/WcGyIJr1DraSM1pvJyQO5PEIdndPzDpjucKEbpqtjE1szGFBx0nvrVcg0JDN1QbHyFyz4k+d3MEuZJTDFI6eo+9CymQkblxPkTNnAHvJL6/5qecRG39TZC5rgdhoIp3w1OMTrIqBKdHw/ae1SedWhIwkg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HqB0w6y+KmPT0aoLpytB6zHZyMdhaEEEaMFE/MJabTyx2RLJPpn8oinC4NWJkM2uC9Xk98Jq+ixd9VW31YUg6b4QsLQBCeHND9oJ/aPUed3cow32ru4GRv4AD5+LL3wyl32nlsrBTlEEKtUgpyj8iC4pdt5VJ0+M9DVGB6s0rbSlv9Ul5sgO33+oLFx8ESXR3gPooSleJb+djKiiwiK+5sUZPcWuOeMLfMlJavkdUab2TmJKPjhS4FPIDUexvE1n6/4DAv3q+8iN8iuE1ZyrPSAKk6HQk891G0TL+zRCfsR+ZP2NhDo1fkqxxji0PMTIOC9Y8j167RSlc0UXC65eX4AwN/SMzm7vs/0PcBmu1f3tCkixJRSrl/f9gMjKj39Srxr9o1Ij+AuEBIi6nb6x9s8Z2wBLiF9uJ1OwhBg62cXAExShpRsZ+doQxgFE3PAOYGVHQdhDQHR+41G8wL+nf+chI7Lc8yVZbCAaoHH7Egj5t6X3loYig+2PAMO3XhJd5tplqgsHsExSQFL9mBiSi9En+GRxvAN1x1Pd7pRGnuj1Md/CodluyF9k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0321fbde-c5ba-4285-c57b-08dbb5a22d4b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 04:13:55.4874 (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: T2GeyhJgUoZJkyIX84IRAk75cziPq215C5mEajDLMfifQI7OtCCV39tUy1eu/ay/X7JfyumAS4PnVl9cb7kHPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6544 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_03,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150037 X-Proofpoint-ORIG-GUID: 9DnJ_-tauvxr2MuVc9_dqKPT9RDduu92 X-Proofpoint-GUID: 9DnJ_-tauvxr2MuVc9_dqKPT9RDduu92 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 11c6b4669949..c118d06fae10 100644 --- a/tune/change-metadata-uuid.c +++ b/tune/change-metadata-uuid.c @@ -23,9 +23,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; @@ -47,15 +69,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 4030bd523bce..810e85e1af45 100644 --- a/tune/change-uuid.c +++ b/tune/change-uuid.c @@ -211,8 +211,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 Sep 15 04:08:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13386336 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 EE174EE021A for ; Fri, 15 Sep 2023 04:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231952AbjIOEO3 (ORCPT ); Fri, 15 Sep 2023 00:14:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjIOEO2 (ORCPT ); Fri, 15 Sep 2023 00:14:28 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546A62708 for ; Thu, 14 Sep 2023 21:14:23 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38EL0Bct017151; Fri, 15 Sep 2023 04:14:20 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=Me7vCOT5A6F+eHhtG6G62eVpbTWMZtbYb/J7+/VE9P4=; b=YLqF8NDrw1IuAvMCLiiXyVVW/UZw+rAOooGHgrZw2+lapyznP+bZIQMvnvK5LYzpdVXr dcTA8o7g9sPQksNesHaVQDbUJUClu70gxH2abf/0pcoW/3qR2KMmA0TK+VD5iySQQJ8T GN76Am7l1Uzu/Dnw5roXi9XF3CK72nk0/hNPQWdWc3ZlouNai6b6BQzw1z4JPcarKUah mB1lGLjrULNvL5C9MtRY0HfUVYxXt/qvIretsyh3fDyLn5u28vK6Cz0UVSSFyuWmowAu lO4oZJeDpxSFUsc1ec/p8ElgbWe8WjpgKyV7yWw/ODvmqo2dTMhRkqMdKWKcWmuluGyh 3A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t2y7ppttj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:14:19 +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 38F3l4R7008846; Fri, 15 Sep 2023 04:14:06 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2041.outbound.protection.outlook.com [104.47.51.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t0f59tqry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 04:14:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYfQ8gE0vNZsZChfKb9WtpY2RvJP40RxoSbYMjgNvWgcsixWRZLcJo6XXhCtHZEhps4OhT4s4/7pFAX0Pk+YU+qPKjcUNELgY3LB4vifs6b5T44G83jselQBgMU94tcJPhxHtf2MPl97OG5Qq8RscZGPGt09NNT7/GwPf48DXeMyoYkuy269SbHpb8hqkPL07YYCzAfa5ypuoBaN9E4Vs8Bp25m8OLLIY8CBiFbF+tEbJMhZlW+cTyUsSo+LifPPYTEqcVDJNIFtZHd1RS08wPqmprU/bZXc9ALzvtpDT//THMs1KBYwOhrb2LQkhPdTHGwxzWLUB8uBKWghFlzY2w== 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=Me7vCOT5A6F+eHhtG6G62eVpbTWMZtbYb/J7+/VE9P4=; b=QYO65/yv2PtGEk5wPNDElR4Zrrbg+LyGNqAM2qJwmBBDDpj/t8Z9Kdxjjzwu14PWUjMNFaAaYxXxq5S1UbeJIzpeyKxMy2nTSnM0DhNTW8ZMyisVe6H86N+AMfErm7vAqXipWQEPT3/P3knWaLm8R/8zp9GFdo2naEHnPX9MQjwZBjNkzMeOJsII0mbqoW//3x1UNum3R3icUbIMa4FAJzHHWm2ZWmUHoHO/1LzsDD5jXOUj1RmBKr6cjOIMcYYIiq2I3uBqz3ozekCPqU+LrCXi5xWq3zgJlsUJdP254filC1qsnxAJvFi6aB08prX/SkqakWn+bj2cQvglbBTqMA== 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=Me7vCOT5A6F+eHhtG6G62eVpbTWMZtbYb/J7+/VE9P4=; b=Q7afMTA6ArxneSlanhmQkpTkqip9vVW9ueeE9Ll3vALX3VHscvSOkv3wyqGmbNujUNk6tE+GVhYLQki42uNTUpRtXTF3LkUxwO770dnLG2vxLNB4QbAvF2K2j+mmHUYGWFE+qGbH+CnrxNLBS0of1IlfScQ/G4Otgabqfw9jAJc= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SA1PR10MB6544.namprd10.prod.outlook.com (2603:10b6:806:2bb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.20; Fri, 15 Sep 2023 04:14:04 +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.6768.029; Fri, 15 Sep 2023 04:14:03 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH 4/4] btrfs-progs: test btrfstune -m|M ability to fix previous failures Date: Fri, 15 Sep 2023 12:08:59 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SGBP274CA0008.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::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_|SA1PR10MB6544:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e4edc45-2e9c-4736-b665-08dbb5a231e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TKFQ4S5vAOenKVsID+z4esnZSX8oA+a7HesPPPSkipms8ASFXkdlTMB1rDOS5lapOdqgZx/cJJa6IU9UL5te9IyuURb61qssFMSQmKmwaFVqV3dEeQUks8tryjrkzeMDKMLvNDRfoDfpSVEB/cNGjwBRVjGjrCizBC4KZ5S068aimYueGDpqU1arvu0fPPOlfxRly1GWCJYYlWE7GzJGXoBfn4G9VKk3GTxajv2L1dP1S0ongnc3TPYshv3JokO5FhN/JZVw+xXaJTRgYcBP6UO4G+I+slXYbClPeyVgxmXpbFXndbbiF3NYXPjHNv+Giq18TN+EDMgibKH3Luw9R/qaj1y7kCzxqyihetl4xyjApAW4qUFWsH5yBD4hHG0oTq/ypD7MZ/CkQVPzC3poVZt0XBQZcO37eMmx5oCmPpYTukDn9nqoCx+uScHmIb8NgEuM5G90trVnwz23aB+3kcP+ekMHj8lYM0/QiRhqXAiDYKRUxmgtrSWALMRausnLheAxjnsXJxdOPj5RQXPpuRLlKnSJ6/D9Cm+YydOWPrm2VvbCe6d+8Gzc90ztDT5x 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)(396003)(366004)(346002)(39860400002)(136003)(376002)(451199024)(1800799009)(186009)(36756003)(86362001)(5660300002)(6486002)(44832011)(83380400001)(8676002)(8936002)(41300700001)(6506007)(2616005)(6666004)(4326008)(26005)(6512007)(66476007)(66946007)(478600001)(2906002)(38100700002)(6916009)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pixqPrBJVvdixEfmArmFQdZyNkXWfp5bHVIKEjBCer1s5/kNPKPX8qaahSi1gGOPQ5/wl3O2OboBzusYq1pbVGnb5sWHhdXaYwEbyXf7NvM5VcCaZmSOE099tzwcnUi9lhS0iKL9faQY8C3CAE9Sol/PLMiR3B0xsQIfSupaVqGBEscyWBX+K0k6ZslbrenfPOIptF6YGMfUrga10sbdYOLHW5r2OIL+9K3BibMsMqNpxDPCmVg6ZJ1zvED6064V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EMPNEU4BGTQH5a+lPpF3H4PDAXc3HUfmxds+3gGicpKgAn0kuJYBQpR2bzwHPujq6cIsrn6oHrDumN6Bt8mfuW2Zg/nMk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e4edc45-2e9c-4736-b665-08dbb5a231e7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 04:14:03.0493 (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: zG/+/7Lm0nXmMR6TNvm1DSw9QFCG3NP4t5Uohg2cPUJ39s6DJZrMF0QyQP3MV+lwgDZ9SmSQj/EstFYJHRxF6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6544 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_03,2023-09-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150037 X-Proofpoint-GUID: zVYGmzmclBn8ob_gYcHTK45EqfbhFk8y X-Proofpoint-ORIG-GUID: zVYGmzmclBn8ob_gYcHTK45EqfbhFk8y 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