From patchwork Sat Mar 9 13:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13587664 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD25116FF52 for ; Sat, 9 Mar 2024 13:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991960; cv=fail; b=mYcWXM6IHfxllZTdlzg2SCDTcddRagDZF8i3d6q1gczsQbkxfE6j6Rl7w5g3QuwUqetRBRBs6rMu8Bf4nunvbIyEeUYCIU2MUhpOjOP/kZ9MAdajtTVl6fcNmD2swbrH0t0goJawhwSn6Gn1MZRDZTFh91f2SeYRWcfeVYRMMuM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991960; c=relaxed/simple; bh=NKM4iJetmOS2edMdzWMxqDx6a7cFufJxQ/IXF7/ldpk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=B90eLmg0jhPOFSzEuB0ut+8dhQaC44/2e1GCNSkafBPzpkPh1Wa3X0LCE7nlYsaz2DgitmzHj+1BWBzxTiQox9jxzHH6mhzQssDNVYxffrwCz8DKoPz73CG2v8nCt+21Q9VTTlFuFAplnPJAlrwT1ZQuC0hU1l2zyYrhZN89D2Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=Q3SZznxs; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=R+jAB3iy; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Q3SZznxs"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="R+jAB3iy" 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 429Aaio1031378 for ; Sat, 9 Mar 2024 13:45:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=pn0qMZFIxIVyPnMKADQ/6pUS1SP5ZFV9uLyunU91nM8=; b=Q3SZznxs8p0Ygvzhaj4J6Ih+iIcY4BffxnVcBi+YIoKgwdv2nYJ/DsPyOYvIX3LuU16H CgtROPujdrNx8GScedDbYfnAfdHeoaEP9zVM1GQnOKK7f62ClZlnjjoESFmTXz0N++Q6 WDigNiOsA1HFUjAqKINvnA8IvfVL17hxmuMwLYjddoPUjc4wOWlyjZxiMdJUbkIew6i6 3SZfMAaxu66JOPs413m/oCz/wmLeCgSpQr3vlmveFztrx+PNVwWNTwUj4I1muSaDFzpC /aDY8FO1p0f66drJG9R5cZzZPYVkW4SoeT0qDdVCW9ScDou/xT+NuOC3hOhQcuRAFWlA 9w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wrepcrk90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:45:56 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 4299htb6038127 for ; Sat, 9 Mar 2024 13:45:55 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wre7abfjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:45:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FhmTljTQNO5QauBO6LGfs22p+0wYJlXwo9s/a0978jwOmNKSDLvOwIVx7D4xHbapVnzBcUr0K+wrI7+3oUc2M5AWGYx2MZ7EzSzTWq075RwsQaaVV3yqd2URW5ByH4Up7V67jyxDtkAOdBTOFu48cNKhdtVA09O6RGEfoT6oO1vz93NcGttZ+8sj7P0yPr5AnYDeJ4WDdjp2VabH2JHPCYERhOs01QFKMbwz+ODCRvb3RmRwcQYkxjUhdJEnuXfHf2EuGbLAj3wXnl80cFogy5zEPTcAxesgN8ZDxDGXvbiTk9FF4TWG7wdrrkw2MEMxRDEBTx5S/TqWNUf0h5DLXg== 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=pn0qMZFIxIVyPnMKADQ/6pUS1SP5ZFV9uLyunU91nM8=; b=f6a5qMFc79BQ6Se09AI0lCeg4q9JfBIh4iUyRIKQBrU7y4WmfbNpjwmjm+OA2auPaUq4RP1Ccya8qZACrgghTN+2/pS+VMYSBcrgGg+UFEZdIC1UeVtORrnBvFVAD0kzl5ZYR6aXWkZEtia5SD9FqDOeSmxTciLqO4/sjSCyaHLP4el2+EyV9/uiiGp6pa9mH0SCadxwnx4t/y2IRTvpqlVuZJnO8IrFHkbOMFQHxiGYa2tmDubF5lGiKwxsbjr1gkTXd8jPiQHZTN9E6fJLpjIzfBs9rOUzjKSyLzV/+2EfOCmk5FL/jc4w+11qFHU5G64HrxbG2OR1QImBzhN6ww== 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=pn0qMZFIxIVyPnMKADQ/6pUS1SP5ZFV9uLyunU91nM8=; b=R+jAB3iyDG/nZi7qgsT6qPuNuYEXbCn/yH+fxlvFjHr6q4m5voTBmDPPaNj1ROQY5GDnKfX1z1MrM2CZop6yG6ltJRS6mqoUUuKgUlwkoF0UlsCeuQkq7QRnPeLsxPtQL+ZqMVFizdpCXnZvB8ZWyHwNNZuwEU7P8ajxrwU6wRU= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS0PR10MB7509.namprd10.prod.outlook.com (2603:10b6:8:162::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Sat, 9 Mar 2024 13:45:53 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b%7]) with mapi id 15.20.7362.024; Sat, 9 Mar 2024 13:45:53 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 1/4] btrfs: declare btrfs_free_stale_devices non-static Date: Sat, 9 Mar 2024 19:14:28 +0530 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0079.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ae::7) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS0PR10MB7509:EE_ X-MS-Office365-Filtering-Correlation-Id: fc24f297-7d2b-40d8-415e-08dc403f3d30 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dluk2tiCV9yuaJpR57h23ecgr2hOoCCsjJuvjvqxm1yPZUFpj48xMiHKKhi+xfk4p3a0WFSGvJfvxiJgmWt2YMu5kzH5SuebLwomEu2pbk6BYi/NouxferOHLOQMP8rgddjIYdHXcv6T698bSVGtHttD8UmMZpb0Jn9s9hmqpoAGAJUSLGM6L715aEtKMumNStU2SilHjjDVC/z7Q0M/zKvZYouReIPII0Wx7ZxMDwURKDnl5TGIqSvUcH4z95+9b/J2/GhSvsACFtOdWTNOlLQhZTi5jnB3RXbOahNeR+cEej7kHJcHvqvEyIcPfmBLkk/AulbypZ/NuzC6OzBORUG7qrCipssLCdL9e5tzuh2OoBIGN5ZNjU71sya55k4n62b/ILH6Jwu+9QE0aaz5/2sZVSDEK6WnbiygKFToHZntuaBiSTLMzyD8eHcF/iiIHBez61gIUwfnJqAEOsz4Xtgu/leFXccVKti6b6pJaBIJ9X5uOBlyEKW6q+rQ16b45rIrysPh7Vy7+4Sq9C508v/kTFwed319SiZ2fNP+lC4srElfS7Fd23WtyonGaNEjBjcqRNSy4rev4PzyZnJuOHDE9CrXEZnguajusa59hNFvYc6QFWvCC4PSt5NEkt4kMpjlgQiZf4/OTX2+EFWEJ6JTDY3C6OO/c3STSX379NQ= 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)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4R/iqKyyv228r6CluTWTOclAmrqLEkkCvLY82TeyVCHEbZI0kz1N2CYHyXjJIsDrxPdJ9kT6iI1U3IhDcO4nCYhIIYpfqvzcP4scafcwyksF7Q9yxnLMb9zNoA+WT9IlSAiIJvojuugLwMEZrFYxU5UHwrIGTPnhtY8WsleM0E6jwN+NnWQ5pvtzctddCTqePDjgtsH24Ve5g16jgTRDtJwibei65fu8VxxuT7jLizBIe7v7VZVJa8H9jxqzfOipbyGCzWiljOvM6Co3xYnK64zr1E33xmTgDQa25eRJARz+9Pyhe+pggTkej3Ywy26EpPMNWYdsDJdp1Kvs/FINt6FkZLNEmx1eJkE91yh9VCyYVyVPPAd4dck0+ZBtx4ObdTXmW48GAsxGptm8rHdX9aBX214vccd7DL//z9XAr2aZpel26J+owPwMpCTnLaXRWYTHjITNtd30b0yh0gDNM37iilTuoGtKHpxfKXD5mclwX2PaAi79PVAE6LYkM92qxdNtNeVC3AhqIZGPKZR1aY84WV5hxvQDeZeOXQwmP6FwhQx0L4xveb1haasdJilfL8qfQDMmMkUPnFXMnncrKAsqtnCtux/38Ij/1SAPQgejziVi12pR8iB+7AfDCKOuXDzMH8OHhqs7Gd2IajzMqUCFdbCYhrnZW8GFhc3yfKmIKXS1ECXQTnVduIMX4mpUtEQB/P28fiPAg8p+pn7r1fM0WRMasjMPrd7RZ+aF5O5I0ZAbaUV61h62wTLwj1V+RBZrAUX0vfgmGm9Y9JSXhTs0E5diy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raRhAIGAKBnUPZWmlRq0FoJ/IGuK6TJj3DJnEsrim/wi4N/cOCIKOgx5eBw3cRopsYTmqzWeNLYYC5bYkzzST2IInChzjGUlzpUegtetna4MNU2HKkD68eIawGSN0hEIw3bZK90TtCf0QJY+zsqMlIMPyJoAR1TOFVOb/ryv2DtcW5XIbrDnlHP9Sebl+h3LTq1mzwCRNx/qbtvTGyt3ef3ZrJIFm68zD+wTcTHbJBzPstUn7gSxdHtiJIC+z2tQfYBl7d+C3MCmkXtQvzO7ylwHd2i73trUXTMpRPGXi3PLc6WZA17LhF5LSpzy2ZKqcxSphUUeaG6QKb4SKU3af+4tBkJYzCnH0dWwyZh6dDjZGaieBRqk8clVNOvQqKg7Ovqll+LVx/fL0CuujDDe9E54GOSK3Yr7NRXR66IC/aVK5BYqnn+WkIXf50SJ5s6ALvGZbPrqiXSXoFwC0R29C5RVtsMT8VsUjI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc24f297-7d2b-40d8-415e-08dc403f3d30 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2024 13:45:53.6368 (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: iDZj9Vo3MnEAot8h4fIsQGY6FKQWJGTX+08yHX8gOzk4uoypdLXG6BvzJdC9VIyxa7LmfY8gHFZVRya3YzmoaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7509 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403090112 X-Proofpoint-ORIG-GUID: _nnph_7hwyaqCvP16fBdrVL3RLSco_qR X-Proofpoint-GUID: _nnph_7hwyaqCvP16fBdrVL3RLSco_qR When the open fails, to remove the stray device, we need btrfs_free_stale_devices() function. Make it non-static. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 +- fs/btrfs/volumes.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 2dc926ac9137..7821c152d956 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -515,7 +515,7 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, * -EBUSY if @devt is a mounted device. * -ENOENT if @devt does not match any device in the list. */ -static int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device) +int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device) { struct btrfs_fs_devices *fs_devices, *tmp_fs_devices; struct btrfs_device *device, *tmp_device; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index feba8d53526c..44942b7b36b8 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -681,6 +681,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, blk_mode_t flags, void *holder); struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, bool mount_arg_dev); +int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device); int btrfs_forget_devices(dev_t devt); void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices); From patchwork Sat Mar 9 13:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13587665 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C41B44085D for ; Sat, 9 Mar 2024 13:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991967; cv=fail; b=sMiaP5TsoVutYAMQDqY7V6pU09QEAW07vmZs1gA4CFwphASS11H0vMRLiXFNcsRuLigk4y2EeWowXJyWaMx6SmfcBURAN+o7kG8JYbtZYLF47hyMaxLD+ZOWsDNIEo3kHwLPkTQX0o0X3VQ7JVDMt9r3T2iOIT9pu+Bx35Xpwx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991967; c=relaxed/simple; bh=hOc9UQUdyzxQoY0f2lnMyrL2IRWnK+T3UFgjVqUaZEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=uQWAwuF0EpERKM3XIvDqIzQaqMwpq/UcN4JlW1TDUNLe1yAgtwRlMAnoPdL20XBtITgifHg9qIeLudAMN7kk2YNjjvh3yIdo4NsZ67yJnkd0Ehi6a5rO0baXn5xFi7Omr8kQ8znrg1ay2IDYgh68pkklSebzbvY/KthhHNat3V8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=nebLi3i1; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ksIr21CN; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nebLi3i1"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ksIr21CN" 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 4299i5Mc012667 for ; Sat, 9 Mar 2024 13:46:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=n4MBTCZQ3UDs8nHLWgIisUSQ93/YDmhtulVDn2iKQtM=; b=nebLi3i1T8kCA4wZCNJj3s97BZGAqMLCZ4Bz3mA+LZFRYb4wzLH0jJ516TVNVcCq0o7o GJPsLk3CsOhikELk1M0FRd/TLF7LXfDCoUMZAr8rJmvc/1OaG21DIU7thM7LJcrJygaR wlc85aVglTjdRdF91AbumGChlbdvwIRC12KnJlJSecocAAPy7quCg/QpOTHWdqDUOyie RxYb/uNemtEEv8GdJJWshDoEkY2W1CCrJIr+8SCkBhAJXXOTgT9mrNudzvY+Xbvlhjy4 ySONhgvebBEhi+ojGdzsLIKLPrGMxPPxXjoUELXvdT9uoUuXzN8U+6SjQzuC1UBaXiiN BA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wrfnbghv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:02 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 429ABYxr037391 for ; Sat, 9 Mar 2024 13:46:01 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wre7abfm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MyNvOc43JI6c89sFeOvShSciniEKzBR7t5Uy+MWN4hnVkNCMWOGWj9Ckmsywk4P1cUDfP1isiUINaYNrMI9IvyUB2pAPC6OZ0rkASUM9OMzezl38llgr/qXwdjPyC1ntYU9Ab7aKHbfXP9Ar3slAoWuFhLRWLLUieUMVxltHRdR5/QNGzEfgSkefqr5Q0yvhfeSe1CWWXwwe2926+pcmI7O2djRACP5dZ9K7wHbgY578WIhu6H6QBjqDL9ROt5nws/GcWFB1ICoaphNZTzMkaQWu3Y0/24fnJfV+DDKKveBCzdlUmBye3dBv6HFn6Xg2Ts//C4hBNSVUS6Wd8Y+geg== 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=n4MBTCZQ3UDs8nHLWgIisUSQ93/YDmhtulVDn2iKQtM=; b=EqkjGZFueBZP/RDErTu3vQT69Fd3lFHLDYW14ScME3VvHN+FCyq3tUqKD5EO0rWDSGy8P7UEObn+aVo/QQupV6Fj0DwjFR5Tnp/+ZQotXU7vacYJdl/WZKOAU/CC5OdagumQZcnR5dYY+kT7b48R5G6m2LcWgzIk+CwR3pI7b3D1A3YG9pzVtmx841PajndtAiJF20x4QHvsWibdY096ZfNTrfJwUQnsSsMxJ18UsJcayN2+rblzRFGqT4TdGMflDdcDxzoXJX9jf7EIvpU0sd9HPehZQByTXZA4VhLXH20NuJqttmnezd+RfNEQDLwmpktHJqGlIw36WwAs0p04yg== 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=n4MBTCZQ3UDs8nHLWgIisUSQ93/YDmhtulVDn2iKQtM=; b=ksIr21CNQhmxEZoHFHoj3GFZIMi6UQ69Q7tTx+r2WJD2NiqyTnvk326eaIcEnLcpDUb4AZLinxQWn+Jw84u90QT8YYJTvIrom1V64JV4isargA3kZRh0m2wKXvOkB1XFqPN/XUDmZO6a+IXBO/cjtxnLrUVLryCgtbqjgOUwA2k= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS0PR10MB7509.namprd10.prod.outlook.com (2603:10b6:8:162::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Sat, 9 Mar 2024 13:46:00 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b%7]) with mapi id 15.20.7362.024; Sat, 9 Mar 2024 13:46:00 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 2/4] btrfs: forget stray device on failed open Date: Sat, 9 Mar 2024 19:14:29 +0530 Message-ID: <7abddd87a9b1be4b6da6173478f2ccbcd3117dba.1709991203.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0091.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ae::14) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS0PR10MB7509:EE_ X-MS-Office365-Filtering-Correlation-Id: adc1e368-721b-4925-4082-08dc403f411b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LuzdNtqxcWY5fr8Y6xJv3Yr4BJUy+Gzlh3m68MxBYhBWNCE/IwHmu3Znt2AFTJWNQxYk135DtHc2ZWmaeaXCEcCYWh/oiDGZYpBffqfTqdQRtbbRmKuT6lxtd9rNJOlkUuIeq/IUIAC4DyTv1pU4CxejMN9UMZSwitEAizQBJ4fhdJmZhYbv5MOwzGvkkMsZnnJFoCNQVtcYvyWEt5kJFr5j+8wyiSETFIy5tbEmquHws4RG4AJnDYbT9fOH0qADY/Sq5CJSJzP0+hXzCPO3N1LAQVwPJEuD0ZUm83tT6zirXQPkf268ooO5nFf9vIxGMbxHNflyaD71eA+X7za9844J/2E7lSc5TbBjfIy92ADMBtunwUkKY3W2v425RzpCRtk/L/h0cl253484rnL3j3XSsS9oqKMCePq+SBDbfWwC0WLbl1gWeFnpsbgGDt7DmD7I+9upQO9yNavZS0JU1Rh/9NVSqyxltGFR8RcyWwaO4gj41E4oURiQCkjBNXpAxhF8OCCwgDwWPsnvwZgDjbuTdLgNQ2tE4f/+vpm1k5hWLlzti3G9HZROA1/YHbUb9dNDUwgtfW5wsmge2YaFEsUH8KiAYKv4EqX99V1udM6zXHLwOzsuu4ODqztTXpFPXHJ7mBvC6ARbA7jV3LGjymtcJgSJP3pb73rpL3W403I= 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)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wF+7XF5RAdexTvtrv4mOaQ0m+Kl4MXOB/9XSh8e574OrGNH6xyN+/LZMDGapkYn8r89cMcjmWa3NX+ujpmBrDJTyfbSULqlkbff1aITckLf/3yx38dgq5GkeX3s5MWcIl6g6HKuFupgt2GDKgRDqc3C0kJ9R5W9oqcbp7kxFVa6WxX/HWZ3P/cw93cqerCC+fxnrJxH0zxII1Mn+089/4eRXS/Xt391og0cvoDlbe0Q8hmSSZz/eGkM1PSWJG9STa/2pRlu0JAZGl3LoZtfGh3FHOA/J4iPfynfpKCB2LepBT05IIqr2RbBBWNNKm7rFSfUxJRpLmq4REDoTcFqI+V5MhV3NBdZm7v4A9qVlCIqEkwvRMOXPa9DcrIfF/dle8vXMjeYMaAApUInVtF6FDrCvdp9/qPo2wRbNMUQR7pWfxVvum2WrXFvFltUXkZ9Wmr8tD5toNjPixDhKdkDMtoBjsP/koQ814uuaQ08bZpvR8unIfo77I1E0ZETTNdbuSK2ItC44wRtYjUhpQo6vD26j7OGHj8F7RQgGH+UOY0lKPfqcG6dYSDnEmNCk74JjP+KXzZP/MZiNb71GHzXT6CkFEvXYVkdtjNW2ndrUaXKp0Nfxy20jyD2Z4Jmneb0wUN52/ZrkZVddkpg1sGaCO1fs4e9i3FQsDZsOC1Iz4AYTvh86ikpjsL/rk7V7yrVwg2Z3vgyAYBbEfqUOV1ydDXaNbejNVWPPbtgviz6627xuETbrCODsAuoI1iy6nvR4gLtGvR7uHMU7Y7vaLOZI8i8mTaVNjmpkZw2mWqk9qztKU0LVlIj/ZwSQ16zY537TqXsv47OP5inJv1zyGYQaMYuw48UOZ+AGbb22w39xQ+61lYNHW2T7jUIuMwpRBdeaInXMuGBHQIMpNQvvNwdnP7GadOaGYowtkdcREFl9FrBCIDmgAK4+LuO4MatgVUrDna2ZAaXrL4mJuI4xiBerDRCHKFywvwZh4pTVvS+GTYfTjkw2kVf047ma+vYrcrdeVXG0KVU9+xAkBo/Xra76CYTDhqLOSvZOZ923Lc3xQ0OuIDjumBsQDV31LgKyZf5P1+BXbJHmBntO5PNpxNAt/Fn4nruw6K4OsGVVIvqCPMnjfBynGRBKROk6LACHmvngxWmww2mz4j70G6zRRkjtb0ZAieYu4YXGOdTgmY4yqB/c5uFHeyIBqjJt90l+FXCyuN93LE3lFr0VNq06ngoP4i0oYreMh44D1GnoyTQjCpl/I7jPrAug5trmqYbdkFELgal4sco+lMZgDQ0/lCjNQdYfRG26KebMT3LFUl5RDiBheBbW5rHll+19keSfdYAGSpg8i/88GqWvSfA8EUjDQ77z0J/OOVnVGdhfllj8PwdTfl0uDVT7IrJyflcIS1zTrHlRYowe/SPIKFoLdyBi4atfnntU2RkjsVXYsf78R7M6+qh5MfaN/h0jmQuvn8F2O0QY5gRlyHtUZJaLEOpmjdbLQbqhPPZ9VewMdZgIQqIeaRSB3D2TQRlQ5a3gMUbvZVrBGOmPi8IT9+d5pb37Nn595rj+q24QOJ++JZJwAvSbhHCU2HNOkViVeeLJud+uY6GD4nQG4LX5L/6ErNisPxt2mkMbf3gk9kqFpKFWF84Gj5IrhnrfX98tdCa4CrW0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pekyHlyNse3xTOrpm/JP46rIgdLizXGppNHT6dZrhzv3MFyM8/Z02e306d6NDiS2gqtfnUYb/rRnl2KGMeUC+Y+bfPmPFv9kqbTv83HK21zpkP/NvX93868x+P0Dd88VUTJhNUTzWC3k7Byut5rWZ3F5hmPB1Tica0U5uUUdBagkykt0yXeVsRo5Dj4GzzgcjoaWQYIm2Wp8nm5GaYW8nMLeKjw7hId58NyA0bDKG//26etuo+wS+yejBMeie+oIWp1gEQm2kAYzQ1IOdBIGFiQozpV1z8wuWyu4ruBMC3c3fOAm2O76fnm/3isruCAcKZgQnmXLO8iO5N4cFFjzAtORhgy+CVwjm5s75cPTkMrB4vHQZKDf1WvSE6cjpUDmW2TO4hFMWaukhF0gy1N79U6sVfxc34VI4H31q/ZXxNMbqdDaaZVIWYatECPVKVG/sDLXudzEhP349eX+OCsacNkwuFe0oDDVt7W6dACZk/YOhYVQYI1ub7sQLRy7wvqxGysmKGwtk+9fkVA3l+O/6wyO1Mu0gYedoy6U/v/xLn/ICX5fnbo/q7wQllIhMQW84+lirvyfBFjL878v6x2556oZL2yAJshvvxpVU+7ffys= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: adc1e368-721b-4925-4082-08dc403f411b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2024 13:45:59.9948 (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: SRjOY85cibJskYbE82gg9L0S4HIHipWct1wnzttsVzyGa+CtgfpxRyztz1OUriNuCpwIUpU6nS67hnH2xO4hQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7509 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403090112 X-Proofpoint-GUID: fk8FjcU0jVJy3YInza1ZLBPkXRYh0HNp X-Proofpoint-ORIG-GUID: fk8FjcU0jVJy3YInza1ZLBPkXRYh0HNp If the physical device of a flakey dm device is tried mounting it fails to open the device with handle, and leaves behind a stray single device in the device list. Remove it if the open fails and if it is a single device. As we don't register a single device in the device list unless it is mounted. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 29fab56c8152..4b73c3a2d7ab 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1820,6 +1820,9 @@ static int btrfs_get_tree_super(struct fs_context *fc) fs_info->fs_devices = fs_devices; ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type); + if (ret && fs_devices->total_devices == 1) + btrfs_free_stale_devices(device->devt, NULL); + mutex_unlock(&uuid_mutex); if (ret) return ret; From patchwork Sat Mar 9 13:44:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13587666 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4893316FF52 for ; Sat, 9 Mar 2024 13:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991974; cv=fail; b=EpgFsL9Vusex2V+kNFf0OtEiEm18PRfN4f5CrMsFeadOculyIX432siVlswqcAogVdqVh2LsYhn/1kDYMDvYCKKwDql1dhtp3rqUbl7O+cHjgngFYng4wobPGoaQd4tcRCacqi1gn9oXBt3BfXY/kWK9YM9Czy1z5yE0rUu2/wg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991974; c=relaxed/simple; bh=G/ofob3WN/6NR5zXFlxrJhe/Nc/U0+xvv+6tHcCzMRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=XnO8kbfmrddSjiq0PhtZXHCI6Li0REnMZ+SghU9C12cj7niGM0inZlUZFEcLaVE2ZnzJbBJjc1KNPNG/vejowA5WTqNn5tqjy69kXa+oUYofyN6ZcnGQ0Jud7xYhG7iDQIgF0l4hTpNAVIIWjTb9YKaNwj+0EU9gbZ7r1qUXwH0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=i7Ixyukr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Y0qSSLWW; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="i7Ixyukr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Y0qSSLWW" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4299iIZS010367 for ; Sat, 9 Mar 2024 13:46:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=gaVUagMAK4PcF0EIEzdkJflkhNeLO9lSGBcK/Fe67AU=; b=i7IxyukrfNOjTtaRIjpJ8BkODu+7nsjelGiZrUcokkBqS6e43m1FpgqzkUhsskTUlxz7 RuSeT6Ai09er2BVuM7RkX7yyup3Swd9WtbUQyValZ7EI6tNp2tT3vFNpzWHsjeFE1PbP 9CoOUjDXZBG5kRPut7+tsYr4PsEqIpOmyR8Uu8ybRczuk4CGfWfldYWV/wEexF+RgD1p f6EQ7YKdYwPBUzQGIyZlmyd3KzNH4jCkPzmeeDO3EqK2VtdBCoxQRhThVdfcFJf9wO2U K1jGlGSTIiq1g5Bg9Rfx+oINIxVjBS6pnxZVj4VvGGE9L1vVOjkCyJyvF/L3yydPWjtq jw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wrec28kfd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:11 +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 429A0akp006065 for ; Sat, 9 Mar 2024 13:46:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3wre74474v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VESDu81Y8J/m7vrJGOfxRQMlcPAHHqk8AaBJfm4M/emVzUqV8eOMLwI7V8J6Gcv6pKBE/OxvT51hpAaaa8S6J2kWBxrM+E0UWJIDHH70V7huYp/9buuVZ8/fTXwY1T67At8l+/yGvEpTYL6G3VBhtdhSYBFo1KIYA0juyMvH2zZ2LP9VzYXPZk1h/ewtZ4xzN3KtxFRUqRAlneeRVPGoMR6Fj1eZFID6VaEIoOEU1XQ1q78MZe/WToEmu3QifCZVEpY7bRnn2ckhCok9FtPDIaEJmG2bCXmCmGoLU/+Vm6oRzEHz7lOtAf2hr9c4BO1k9gh8qR15QUtC19LwoWfzrA== 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=gaVUagMAK4PcF0EIEzdkJflkhNeLO9lSGBcK/Fe67AU=; b=dh2/lglOI/euRNX9ciwFbh91chBzMCnjmEe9vVKPjBrl3X33WCOQ0TEDRzdlC8Xl3XXUvvWjTrL+zrv3HkXcqgE84CflF2xG6kZjmRiAw6Fw2a3SaCp+ryNmVTU4FgzkjvfIp5ZQi1fel6qCaeuaKOfebnk/cI0jDssCthcrn0UehXYIFB3DEgeYNNrOwc1d7n2XyNPZ3a+Xt2cQXRwXEjKRUD177SF7lk8iivC599tcpDi9PFZCv/pkkYWaiM98zJSO2OD+7rD2Ei4pzcZJ3judMWQuRZHVTj7BXhmlOrNFR1Hr/URt1Oe6EGhk66lt5cWAH+73+iTqgr7jUxqgIQ== 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=gaVUagMAK4PcF0EIEzdkJflkhNeLO9lSGBcK/Fe67AU=; b=Y0qSSLWWkUVcBQUzsG1hcQxZA3YWM44CO1FjcENlb12gL7Rjg2+pN4sg2J4wTb3YPwwnOwURsvoFBBsADxjfG5qN1zOiFyEPUOfC5/5k7J9nWQ3Zb/mi1JYx2t5X3YQqVmuoUaTO6TSFbdLCbYcO4F4tTzXOyzX7ac/AavkdTpM= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS0PR10MB7509.namprd10.prod.outlook.com (2603:10b6:8:162::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Sat, 9 Mar 2024 13:46:06 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b%7]) with mapi id 15.20.7362.024; Sat, 9 Mar 2024 13:46:06 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 3/4] btrfs: refactor btrfs_free_stale_devices to free single stray device Date: Sat, 9 Mar 2024 19:14:30 +0530 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0091.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ae::14) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS0PR10MB7509:EE_ X-MS-Office365-Filtering-Correlation-Id: 51c327bc-701c-47aa-cb50-08dc403f44c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sjrvb6YM2tRScQiwWJHN3e34dFIZuquBMhRYO8Re/zG+rImHEPAaPUDHVEd3/yGZyDALXbbSD+LiQKc1TrrA+i2hKEC8vVoOE5CNj+5dbc/DndzdokeYkwFbBD0CTjCejKIVZAlTarVEn2VCkQWZkckRuBXO/o4sgDcYQwo5YoxJk561DxlwIC4z69CcV93cw2tiZ3EUzfr4XucSqKyi+eDCrGBYO4J1GUmpboRnv6pWP4u9RNFC/4mtAM2JnMQa0L2NkF+/q5s5uAqzPJju35/M43V3CkevsGOn8ZwEj79qA+5VHgNBaaSiqA+GQnu9cLAY9Yw5Lz0ZWp7InglIc1WzZB8Kl00qvJAiG80qCnC7B76/M2Lu8ufJUwIH3QCazjk5nApdb7EOulVLpk0VQDT6lldoquUQMsLzWrUo0evO43JNkqJ5eLhQQ90Pwx86mFgP6T1yZdAMXtvDYUFh6WW2/PGrBHNtU24Gtr31kwx704u2+fWuxxASk1iJ3seUDzArQRlzzoHfuVW7UnBqnBoKuyeAUxg33CtfVqJrJ8PFQ0/LKdVd4khKHnO3eqZBPCt6/6uWS3zxEPNf0v+2CTipVNFx2kzy7DyIGwh108st44AlQTyrhpD3OL9dAHLaftM3VET0nUsaukNZXutbSeNTL/th9PiUBRQ/ixgPVX8= 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)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I5FH1nUQABjNU9/Pb4ysZPW5LxFP4I4up2qnN6Nya14UD/nfVJe/DyrdAh0zvt1Y4KNyq1XtXYULx/urFXGbfbLgOs7ntkTnX4N3PAqVw+a3i++B4vXygiOmaJ/j5stUDRgg9I7TtBqFHBaZyf7tEuJ9HYTiahM/vfTw+DIjdvBQrQArIOsEndwAO2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p5J9YNvNUMR2eeVFPrFfA3AmEZ6sYAZk/58Ndg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51c327bc-701c-47aa-cb50-08dc403f44c2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2024 13:46:06.3391 (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: RxoqJr4FLUBG96qwOEjvqbkA5UHs1dRNjtaejIhd8zdxlXYDzO53Rttw2d1FSkZDPaN9QX8vwVVy5+sZQ2ttgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7509 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403090112 X-Proofpoint-ORIG-GUID: _GKW3oFHpSDFV0iYG69zzYdbASyOz34W X-Proofpoint-GUID: _GKW3oFHpSDFV0iYG69zzYdbASyOz34W Refactor the function btrfs_free_stale_devices() to search for devices with a single device and unmounted, freeing it. This a preparation harden the reliance of tempfsid on a stray-free single device, allowing temp fsid activation on a device. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 2 +- fs/btrfs/volumes.c | 16 ++++++++++++---- fs/btrfs/volumes.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 4b73c3a2d7ab..d381abb275d1 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1821,7 +1821,7 @@ static int btrfs_get_tree_super(struct fs_context *fc) ret = btrfs_open_devices(fs_devices, mode, &btrfs_fs_type); if (ret && fs_devices->total_devices == 1) - btrfs_free_stale_devices(device->devt, NULL); + btrfs_free_stale_devices(device->devt, NULL, false); mutex_unlock(&uuid_mutex); if (ret) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 7821c152d956..60d848392cd0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -515,7 +515,8 @@ btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, * -EBUSY if @devt is a mounted device. * -ENOENT if @devt does not match any device in the list. */ -int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device) +int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device, + bool free_stray_single) { struct btrfs_fs_devices *fs_devices, *tmp_fs_devices; struct btrfs_device *device, *tmp_device; @@ -529,6 +530,12 @@ int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device) list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) { mutex_lock(&fs_devices->device_list_mutex); + + if (free_stray_single && fs_devices->total_devices != 1) { + mutex_unlock(&fs_devices->device_list_mutex); + continue; + } + list_for_each_entry_safe(device, tmp_device, &fs_devices->devices, dev_list) { if (skip_device && skip_device == device) @@ -1307,7 +1314,7 @@ int btrfs_forget_devices(dev_t devt) int ret; mutex_lock(&uuid_mutex); - ret = btrfs_free_stale_devices(devt, NULL); + ret = btrfs_free_stale_devices(devt, NULL, false); mutex_unlock(&uuid_mutex); return ret; @@ -1416,7 +1423,8 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, path, MAJOR(bdev_handle->bdev->bd_dev), MINOR(bdev_handle->bdev->bd_dev)); - btrfs_free_stale_devices(bdev_handle->bdev->bd_dev, NULL); + btrfs_free_stale_devices(bdev_handle->bdev->bd_dev, NULL, + false); device = NULL; goto free_disk_super; @@ -1424,7 +1432,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, device = device_list_add(path, disk_super, &new_device_added); if (!IS_ERR(device) && new_device_added) - btrfs_free_stale_devices(device->devt, device); + btrfs_free_stale_devices(device->devt, device, false); free_disk_super: btrfs_release_disk_super(disk_super); diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 44942b7b36b8..0ac25ccde96e 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -681,7 +681,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, blk_mode_t flags, void *holder); struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, bool mount_arg_dev); -int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device); +int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device, + bool free_stray_single); int btrfs_forget_devices(dev_t devt); void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices); From patchwork Sat Mar 9 13:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13587667 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 271BA36AF9 for ; Sat, 9 Mar 2024 13:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991977; cv=fail; b=PhNIaEq8VKWwXNN3Gd+YBRfSQ61hb3gyTfBkBLjZ78p23/i/JxYvqMJfOTPK47+/gj60E3ctTcT/Fdcox7CR0adHQ6UpFEW3A454f9bpzyQVcxu484vuyWCsRmyzkLc17/dt/KfSk+++pXl6WxDtp2mGkenJ96RCgDRAYv1/yCM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709991977; c=relaxed/simple; bh=g23mCWjwgHUm2cfg1X7GFAgXbfqkAe+vKHQkdZlslq8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=BHJwnwukT71l2c5myOGxLBBsrCnLrpcAsi27mvyJ5E5wGORaTc8+SPtFOn+R9SE1rTelV+CJr/z+Wd4ycf/uiyhxpzq/D11qABf3xRlD4CavsH2HolLGN1L3+fojmvsHrHvQCaWXSf+FFZriIsrBa+PspefRH7OLZhoaA/itVdc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=QOBRIPZQ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qXtWy+MG; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="QOBRIPZQ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qXtWy+MG" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4299iIN2010471 for ; Sat, 9 Mar 2024 13:46:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-11-20; bh=rO9U//7c1njA7jidYJYwXtmr9cuR4fSBYmprTgqW0PU=; b=QOBRIPZQG5D0FgysBhnJNniEgad9+6VHzD5S4NkGPuLrH5gKoMaw76My7E9xKTBSY3L/ VzeLsLnHoHW4FbTTFw+n1drMbiv0fjl8/QGffqIYJXbZ5/gdIojyZpsbpY25fwk60ONM 1CGZj+L4GarwOVaSYm93FjLM+ezjH5lncx9/FGIM8HdWJF2pF2g9BrASE9RutjYM7/vY m50XoU3iOWcLifQf/4p3Pn2lOjI3Q60ZSsy9upMCSQBcWZfsrNeTYQEUpbJY2GwSR4fZ iQzoQD5GJZOYfQEBMZse9Od0R+Qf8hGI4rUtTQ07yTGwqs7ASBjA747HfSLlwuOFZ2yo Qg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3wrec28kfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:15 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 429ALhSP037380 for ; Sat, 9 Mar 2024 13:46:13 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3wre7abfpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 09 Mar 2024 13:46:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehERys43KN4/1JpwVLBoIQoIrraJgC9kMjic7GMyGXheJFbPoNEKBWTy7ZU9WGtHPMRciU1JWXeHOEaxVfLGbF4BCJthkG3QwHoeo5+KGv7lmPM+krzT0CRgEtQrtrf+A2YSjiYYF6jq4tcTMyxGB66RX2C/VTN/wqya6rX4hObbdbqW+iZDxbJdj6A1HB0gPmJOCo6eNtrKfdDdH357ddbvxTDe2+8rnDYG5Dsr/SNX/Bsz3VTKQ1TdsYl/GqIemaWc1+jA/VpqO7h2lqrj6g+Dfx21GMnQPv2sRZlhZC/Tx7Tk5aPvd4hTjykEXpMhJU/2O3aVNpEJR9THFlrGIg== 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=rO9U//7c1njA7jidYJYwXtmr9cuR4fSBYmprTgqW0PU=; b=XQM3tW6a/EKRONhwiKhpBwxTYwGNn4ya04J96FAN3Sw5SThEa3iS53PS1HCRU96lnuvQ6kNJUoMxlnJULNDWGjonSPHDJfKZthz4yWMRxvPPo17U0mhM8qRUQtWSN/TLpSwHeHFkAh2mdUfMvdseX4dh3TstNzeORqT54uUd/O29qos43O1YwPNqTqlPx5RycE04dVBsESQl6EKiQ7MJufJbBRdK3ZqGYHfnAtJVjCYKQy3GLFamOAI3bUhoWbGq4XtO0abdW1D+sDFtaZXTtZga+GGeUbZXjT6x55lTOYcmOaIet58DeBqxTBN4ER77UHSdm9fj0vrc7L9rfRHvSA== 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=rO9U//7c1njA7jidYJYwXtmr9cuR4fSBYmprTgqW0PU=; b=qXtWy+MGWSZpShE9Iwf61QM027NdO67XnZ68utWlRJYLfAd3sYde7p9BGTTS45NEibeFABOpNegfxrHaJSoiKnNLh9nKFvmaMDYhSPvFRvKRmMNBQ1OsyGalSYNbTQDOGL+C2Skl8/3moEjHn4aqk475KvIWPxI/4kq01Da293o= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DS0PR10MB7509.namprd10.prod.outlook.com (2603:10b6:8:162::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Sat, 9 Mar 2024 13:46:12 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::814:3d5c:443b:17b%7]) with mapi id 15.20.7362.024; Sat, 9 Mar 2024 13:46:12 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 4/4] btrfs: validate device_list at scan for stray free Date: Sat, 9 Mar 2024 19:14:31 +0530 Message-ID: <87d75575e16637a84b82326d5c53cb78cdf9a7e0.1709991203.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ae::15) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DS0PR10MB7509:EE_ X-MS-Office365-Filtering-Correlation-Id: 85c48661-dd3e-4206-c734-08dc403f4874 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lDd/RxMyPu+564TvVyHZfERTBs0AlaDkMwlTYYeygexS0gOjm/UNaBBnrCZgZlPllXXe+FXiQHlZUhUwbHY0vKMzM061VKVmLUTAck3OiQ1zIE6aSDcVa4B/7AsQW5lRkCGu93Xsb3oQ0t66FGj/Vng15ktfY1THSI2NJYq0BszEMGKSjXBb9ItOIDJApaV7GKot4mmiehAReZtK4knI3p4G3ulrZLEpWHVavReJ3nYC4KEepVI0Z/tUQEp3fhiftaJnfVpW871TGeW5ujW9AinDrcK6kdCU2cO03fUFnZeYUsGNRXHaogbLB9eGg+dm3t50wriU9LESUxhh6xVx38b+XJmh84jjxYbhEJvP3ga4BuJq4tkVGAKvZukcgF3+cH+7VeyrVd7DzmfSesr+LKYbzTaABpmL96LTks+b1HZkeMYBhjhDQArXcHJz1qUAROYtNX1pCtnVpDV3CaYcJ0+xmU6C+CseDzwBcXg1WCk92+m+aiuRxMFbFU4oy0TyTkr85ScW7vGPT5zPEChKXJ1xJ+TFZB5q1vWIxynhAbKUoon9VXTOWkyx608Wvyk/7n+QecmqGjvmuRx9hBEQWBAoxXUfS1HveH5TYj5QRb2WbAQ8q6PSGpWHzfLb5BeBw16xaD8CIDwhsIrhUt9L4TV5P5RYyJ5y2Hv4SWrebWE= 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)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qE/mus1AZRYFM8f4yNe1kgnfFTHIdM2wpfU3pxtnHXXqf0AyZMqH66zLwrZFM4UbkVuGKA7oppQam3SZVzfmTsOEA3dDdFMvvkOjSK+xv0hhDbp35Q9RFNlcLwFWql1acN54oRHKK5M4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eAbap2TJ/ZekPerTmgIuOjgIbMkL3bYH57Ctj+EGFhp2cLfO4xm8Qhp7t/nShECLbQvtC4XBhVSRw9Z6UGAI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85c48661-dd3e-4206-c734-08dc403f4874 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2024 13:46:12.3306 (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: GBWgxjVgcSt8EFBJ2piDT1C7EWgAFNqyiqoZaPx5FBDy6XzHJ/56c3m56XsU6IFgsAhlXXMhjeX5tPdLyrkRbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7509 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-08_08,2024-03-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403090112 X-Proofpoint-ORIG-GUID: unx2zO8OJ0Ck_FXeWt5REectN4ss4gqq X-Proofpoint-GUID: unx2zO8OJ0Ck_FXeWt5REectN4ss4gqq Tempfsid assumes all registered single devices in the fs_devicies list are to be mounted; otherwise, they won't be in the btrfs_device list. We recently fixed a related bug caused by leaving failed-open device in the list. This triggered tempfsid activation upon subsequent mounts of the same fsid wrongly. To prevent this, scan the entire device list at mount for any stray device and free them in btrfs_scan_one_device(). Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 60d848392cd0..bb0857cfbef2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1382,6 +1382,8 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags, lockdep_assert_held(&uuid_mutex); + btrfs_free_stale_devices(0, NULL, true); + /* * we would like to check all the supers, but that would make * a btrfs mount succeed after a mkfs from a different FS.