Message ID | 76f85159f72bfef17a702295086745bf31fa09b5.1688724045.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-btrfs-owner@vger.kernel.org> 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 7F98EEB64D9 for <linux-btrfs@archiver.kernel.org>; Fri, 7 Jul 2023 15:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231623AbjGGPxE (ORCPT <rfc822;linux-btrfs@archiver.kernel.org>); Fri, 7 Jul 2023 11:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjGGPxD (ORCPT <rfc822;linux-btrfs@vger.kernel.org>); Fri, 7 Jul 2023 11:53:03 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7137B1BF4 for <linux-btrfs@vger.kernel.org>; Fri, 7 Jul 2023 08:53:02 -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 367FmOxK031722 for <linux-btrfs@vger.kernel.org>; Fri, 7 Jul 2023 15:53:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=d1zlSyJu75TRaqMwq3sXDNKlw3NKDdbbXjl/Dac7d74=; b=Kj3W1ryTtoCvzFZWTmK1tngZwc0bOFZ8GJ0PVlWz0GwCPCT65mOXeU8yyu4iD5ysuDRx rEq8ppA03415hVShspkk92K42K4lpPLb3R6dwO/eWxYHOuQ5+diThyzfMI2lnBNSbcZs f7dDgIWHmRRcUQAYv6yWEKBQ2yPfK/iH5ig0EsOhoSdkZKui6j1skDfKGn+U4f6XN8iR 3fOPF9Lo8+cTIGq/qQxjAzB2vhc1Goj6hHZD/5OETfGc3NlsLowOvwSrcKpvBKy9YpdW n1dBMV/vev34GVEB5YgQBC4b4/lb/d9ao6VyxExHWdOSZWsFS0ktMObTBGCG6Stc8PDd 3w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rpb4xh6yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <linux-btrfs@vger.kernel.org>; Fri, 07 Jul 2023 15:53:01 +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 367FeNVv010256 for <linux-btrfs@vger.kernel.org>; Fri, 7 Jul 2023 15:53:00 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2047.outbound.protection.outlook.com [104.47.74.47]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rjak8kfh0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for <linux-btrfs@vger.kernel.org>; Fri, 07 Jul 2023 15:53:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVZ+PrEyOeWixvz8WGX1F8uEOwwSe4mlGZG6ICNNBcsRtvxkeLxqARK1P+a+7WyeF1eyCZOKo+bRsvserlL8WvY5rTT2w2w7AcLXm8WWkYl7CejaWzTOuI9ADWgp8fR5qQTOlNzrU4iwCKHdM6rc4OKyPoIHrg3tY2bPPVEjGoeOY+nU1H//aUBeK4igA5WX+OmEaqy4XB54BREz/IbkrSdpB9KKKRVeOQcodIG1s/tVPASh4KXoQm2uejN/94CPDpieN3EFH814bsBD0j3ey5QDtkziXe42YfNVlzOBglwFHPzLixtag01GjHsNoaCZojJKrMwmv0L/nyyMu/4YUw== 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=d1zlSyJu75TRaqMwq3sXDNKlw3NKDdbbXjl/Dac7d74=; b=Q6E32Wx0Utta8FPO0QvgQ24XtljIGQm0rkxekrmBeShVgQ00iLw1UC5ldP8A8vWm8LsBKCUgZiWaBNQdYc99CkCpkspDVaD2ahM6MBf50Z3Mrnkz3NPrXU3xkGT4ErMWA95nYByyoEV0ORnSpi4U1Gi4NW/eVnxEmiCmvCu7b7JVjZNP/RPdKdJJBUReCA92mLx02ePcyJqO5kFnbFIQ6r67+CTM6DPAdU/LilQDigMSJbZjh3WZ27ZwZB1vNE9lnd6dvnerYLZ1JUDOdITWVX0qfkLaUEbZ7qH+AbVEjGURyFUyMoNyoyF3UvwmJrYkH3wkug/J71UKKFp8aGoV7Q== 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=d1zlSyJu75TRaqMwq3sXDNKlw3NKDdbbXjl/Dac7d74=; b=KSgFgML+7O5vyETviBoUGQ+FyY5Z7Md8OWwEDzTsMOCRPVEoa4mUo27nvx8XbTiyaWSnFbjfCcEb3VKMt93SGIq2lhzUxNdnspzphMI4AGJVlDTeFWUNmKGDmTqhLSivobW9u6HhJoexXHdVfmqKYNwPVr/XqxZp125CdBxX9G0= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by PH7PR10MB6156.namprd10.prod.outlook.com (2603:10b6:510:1f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Fri, 7 Jul 2023 15:52:58 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::a42d:1dc1:64e1:f814]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::a42d:1dc1:64e1:f814%4]) with mapi id 15.20.6565.016; Fri, 7 Jul 2023 15:52:58 +0000 From: Anand Jain <anand.jain@oracle.com> To: linux-btrfs@vger.kernel.org Subject: [PATCH 01/11] btrfs-progs: fix duplicate missing device Date: Fri, 7 Jul 2023 23:52:31 +0800 Message-Id: <76f85159f72bfef17a702295086745bf31fa09b5.1688724045.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <cover.1688724045.git.anand.jain@oracle.com> References: <cover.1688724045.git.anand.jain@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0003.apcprd02.prod.outlook.com (2603:1096:4:194::13) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|PH7PR10MB6156:EE_ X-MS-Office365-Filtering-Correlation-Id: 4283b207-9492-4819-5c48-08db7f023c51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QNhU9+5ruT7EXaViu8TkA2klBuGshypL2IIQ6OLoUVrn907iJ8hycnSE7llKitkukXAVZfdjhpHOM3IW+eYcHj6OWFrjjOO1V7ywipttdoLjmZU0A3kuLOiRa9J76JsoVLqQRad75aTkIhUyKgNrnsFcxriwibtt/gJDGUE50pjCtZ2yqqEL6TYUn3p/JuU2jQGyrYr0c4ORUVp99Mp2tRFDrsfKzI/qcuezVK2vjE0irKBdBf/Ow9Hu0HNXMXHq7vSvEMGdgpMY6T6YJLThkP3Gmq+jnBWDWZDYPCm68FrU6KkbSshu/RbA3rY86c0oVop3HHhLhU/2ItIZcr+n8PvJOX7jYXyVCKvGeOv8Vx5TcOgE5a/bQYFANjZ+o8KoEWAP0JIysqSLBGOy5OI4+FjI690JXo/lkw8cuajiWIYmiBVaWp5TpxfSBFYGPnqcyEx3gj9ZnWaD0C8hMbzJjRwUg5tU1UBw4/PnOHu5SFyMNQBd9OxyMirJODQ1Sy0wBezk7H9Ol0QxxYxu0jq4XinTEN22Ts/kLCvZciYzVQ8gpw05vA8Fv88a5qCbhmVw 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:(13230028)(376002)(346002)(136003)(39860400002)(366004)(396003)(451199021)(44832011)(5660300002)(8676002)(66946007)(66476007)(6916009)(316002)(66556008)(2906002)(6666004)(6486002)(6512007)(41300700001)(8936002)(2616005)(26005)(6506007)(186003)(83380400001)(478600001)(36756003)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d7OBnxXNPeQiIVSzie2WsEmPMwJUeszRB/PwTfi56xRmNURvS1b9NbYMSwyvCYkpzJB/PzVh/QYw8VBxopkZAuzfbKMAN6ARge0G7bsm0k+SMwaq6MTCuhzY35GY6JywJTSqf6h59Q83nUnL/txUnUC8T7AwAkapADaqQI+/eafyZp3WG4jAonDUnYYGRIzr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f5B9xxWDdcz5BEV2bAM3rC9mL1w5JkeIkz7ACVB3/ZZMn2Oc5mk9fsUFuPpWMxNe8s22vbx9ux95M3dN/Ke6RdU++5+5nOBOHVva X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4283b207-9492-4819-5c48-08db7f023c51 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2023 15:52:58.4308 (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: ec9oKQxQoqyX+8zvGAJ43Z9T1czo/cIDBvp2ona1TEryOMgPZ4Qk58S9/voxym0ZoltYAYI8Ygbw3CQ142kXTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6156 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-07_10,2023-07-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307070147 X-Proofpoint-GUID: uEPnCSsrLbtTdUUT5xb72y_lLP4SvUUA X-Proofpoint-ORIG-GUID: uEPnCSsrLbtTdUUT5xb72y_lLP4SvUUA Precedence: bulk List-ID: <linux-btrfs.vger.kernel.org> X-Mailing-List: linux-btrfs@vger.kernel.org |
Series |
btrfs-progs: fix bugs and CHANGING_FSID_V2 flag
|
expand
|
diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 81abda3f7d1c..92282524867d 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -2077,12 +2077,13 @@ int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset) return readonly; } -static struct btrfs_device *fill_missing_device(u64 devid) +static struct btrfs_device *fill_missing_device(u64 devid, u8 *uuid) { struct btrfs_device *device; device = kzalloc(sizeof(*device), GFP_NOFS); device->devid = devid; + memcpy(device->uuid, uuid, BTRFS_UUID_SIZE); device->fd = -1; return device; } @@ -2150,7 +2151,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key, map->stripes[i].dev = btrfs_find_device(fs_info, devid, uuid, NULL); if (!map->stripes[i].dev) { - map->stripes[i].dev = fill_missing_device(devid); + map->stripes[i].dev = fill_missing_device(devid, uuid); printf("warning, device %llu is missing\n", (unsigned long long)devid); list_add(&map->stripes[i].dev->dev_list,
btrfs_read_sys_array() adds a device with only devid, but without the device UUID. As a result, any subsequent btrfs_find_device(..devid, uuid) calls will still fail, resulting in the addition of another struct btrfs_device to the list, as shown below. open_ctree_fd() :: btrfs_setup_chunk_tree_and_device_map() btrfs_read_sys_array() read_one_chunk() btrfs_find_device() fill_missing_device() <--- dev_uuid wasn't updated list_add() btrfs_read_chunk_tree read_one_dev() btrfs_find_device(..,devid, dev_uuid,..); <-- fails list_add fill_device_from_item(leaf, dev_item, device); This ends up having two btrfs_device for the same missing devid. Before: There are two device with devid 1. $ ./btrfstune -m --noscan /tdev/disk4.raw warning, device 1 is missing [fsid: 95bbc163-671a-4a0a-bd34-03a65e4b338c] size: 120 metadata_uuid: 95bbc163-671a-4a0a-bd34-03a65e4b338c fs_devs_addr: 0xdb64e0 total_rw_bytes: 1048576000 [[UUID: 703a4cac-bca0-47e4-98f6-55e530800172]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0xdb69a0 device: (null) devid: 1 generation: 0 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 [[UUID: 00000000-0000-0000-0000-000000000000]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0xdb3060 device: (null) devid: 1 generation: 0 total_bytes: 0 bytes_used: 0 type: 0 io_align: 0 io_width: 0 sector_size: 0 [[UUID: 1db7564f-e53b-46ff-8a33-a8b2d00d86d1]] sb_flags: 0x1000000001 sb_incompact_flags: 0x141 dev_addr: 0xdb6e90 device: /tdev/disk4.raw devid: 2 generation: 6 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 Fix this issue by adding the UUID to the missing device created in fill_missing_device(). After: $ ./btrfstune -m --noscan /tdev/disk4.raw warning, device 1 is missing [fsid: 95bbc163-671a-4a0a-bd34-03a65e4b338c] size: 120 metadata_uuid: 95bbc163-671a-4a0a-bd34-03a65e4b338c fs_devs_addr: 0x161f380 total_rw_bytes: 1048576000 [[UUID: 703a4cac-bca0-47e4-98f6-55e530800172]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0x161c060 device: (null) devid: 1 generation: 0 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 [[UUID: 1db7564f-e53b-46ff-8a33-a8b2d00d86d1]] sb_flags: 0x1000000001 sb_incompact_flags: 0x141 dev_addr: 0x161fe90 device: /tdev/disk4.raw devid: 2 generation: 6 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 Signed-off-by: Anand Jain <anand.jain@oracle.com> --- kernel-shared/volumes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)