From patchwork Mon Jun 17 23:03:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701533 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 80521188CCB; Mon, 17 Jun 2024 23:04:02 +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=1718665445; cv=fail; b=CxrD1vBqqk8yUXQQ4PlUvyvJMABeDIzN+uz7oMKr521mr298++T54Fc6qVKOeTSivZGVHqZ7TcPuaFdyIb/NYv36Oj5pX/5XCBc/Ojvu9mHG1KNjWM1AxwcQJaLA5Bm+XRzgnRhYeugtyhCFlkrnWNq5bpF4fNR7D4x8uHGGlZk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665445; c=relaxed/simple; bh=xTCcLS1SYAwcPVG8Cr5f73mO/PWv/o3+2KP9Al+mzag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=j6LmJgXw3fQh+4s+IubjesWCAFmkV4EsRjUx9Nz3BsfkGUrRiqkN2Wk1hhKCwZA5W2puY+je9jrYOSOUC8SHt7UFsFjHlNUX+ziYgEJQMuIZxhOAScaBKw78VJmZtfbPlcExTLeQzqAfJTzrK1E5A1mzZz+RbIDvmO/q9zhmWFw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=Bi3pGcyi; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=N64xQoK/; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="Bi3pGcyi"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="N64xQoK/" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXT0T025706; Mon, 17 Jun 2024 23:04:01 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=8QWXChfbadAAEGlJho0KAhicvgDlUMwCBiC+UWxbBxA=; b= Bi3pGcyiNOWNAs5qPJ3PXf3P1ya2lFoXBRbdLL9hK4mNKtkxUD+WI6N2vG61uvfW XuOzW/rvlPi6Pkmrzi+OTkQ8xlxYeGrKJp04NFzepFyHZIdmjIyx7tmdVKRxQavH 5CL5t6LsLjdUkHNk0xOdtXUyIW+haPOY6zWfy2k/I+9AGhsi6PgjwtuDVOiGJQ9M zxcUG+48SUSoRpr//XIWffRjF4qGLa323p+cqNRrywLFC41H75ABBO/q0hmeYXXj d9F2wlBMteeS8SQpVHJh0ExPEobB3ChHWxWlorZNYy+DJ/lewDBrl8r2FGZ+vBbK svcB3KUxuETRF/VTaxIy9Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys1j03svb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:01 +0000 (GMT) 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 45HMZDeC030610; Mon, 17 Jun 2024 23:04:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d73jwf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nRT+P/fj+Xz154M/AliYbHEjhkF+owFPkWqNiajOoPxFhhoZveDGdNoyMbE23IEogvOIRtqkVL7Tll0aQ9BsXBQ8Strk996+VwgAffb7FeKWjcEKRcNAjr4688BId8FjcWQnuwYxf58lHxIsgxCU18fVJPKL0NIYLsfGnsu66jfbx6eq5EuJ9s+7AAmdu6Bz6Dutx7b3U6FcibzN3mAeiGm6nob+nHl+Nvg25YvpDxZyuvrJxLwgZ8U49bA/Irlp+4Kq8f49ngMwvEjlX2bVRFKvzWFgMZMpjTc7Bo2HDsiARIcNdutrlmAkkHnHj8i/1s2XOAlS7QYj8jXMT6yQIA== 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=8QWXChfbadAAEGlJho0KAhicvgDlUMwCBiC+UWxbBxA=; b=Kk8Zd47RXI/i08YNXaf6xtNFmFtN+gNWpwi617/bZvtfLbJ5+kkSJ088/M/01ggBZV6YUsnLktCafZDIouEiRiKmHckN7Wq5w5SUa7SkpoQR5SsJ7GhLQfHPj60XtJbg1SyyM2JdHDc9qseYtTGSaFcl/40sFfbmLgh/Gyx/ORekOgjA5ZbctJ7vFFg7i0EaBUcpBnYX/YWIYR8PUtQ2UZe6Ho/UzdkIyrf7EHoVVRDChhs0WIKScCni/yQOG9Em88HwbWS68jL6TRiVnKdSalz69IIvGi9g44yB/ztRPaioVCOcHMtl0h0nc/NEwoyIzV0/iNkkWJogJvv6pK2u3Q== 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=8QWXChfbadAAEGlJho0KAhicvgDlUMwCBiC+UWxbBxA=; b=N64xQoK/Re9KLrv69ILNhDHYA2dt/EidGB03AvStPN1jI//1geSk4Rn6oUKO4X1LrYp7xwVJUESFYyqkyKOXuIGJXhL3T4mtVGKLCNlL4JYQRIlkSgVCtrHCxL5JrpT0r1t7PMcUlpM2J7lOZ/5AMbVLiCkrX4FUB4guwGukWN4= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:03:59 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:03:58 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 1/8] xfs: fix imprecise logic in xchk_btree_check_block_owner Date: Mon, 17 Jun 2024 16:03:48 -0700 Message-Id: <20240617230355.77091-2-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0354.namprd03.prod.outlook.com (2603:10b6:a03:39c::29) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: dd133ce7-1a9e-4958-b67f-08dc8f21c564 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: NNb30TXu0OGF4Nn94pN8br3ldoqJguRiXuw/k/DoZYIP6UCnaUYyf3JVjZDSH8pO173xZN++Dh2qZjeACQ5GXKUUQYLl1yctojr/BqS3gLldeiK7bOdcOx6s/gEJhoKVdJ5biwcol0W8FqGgVEf0Hj8pLXVV/ZbSqW3nZC+5OMHeFc+hvgavu9HS3l7QXIsgsGmlvrqzEW8V37ObBa6k/0O3Q+BdxXik80Z/U9/OCqzzdKxehOLR360eCdCw9nMsrXGugkj7MR/g6jLKkLHQJ/2tqhFSgoepRs/QjRRVfWC9FBIOP0QstWeCi+EYzzdifW7/JwDSRe11bl8D2b2/mWV14qHXchW2kusMRz/7AdXGgBM4kBxZoUBMp/pkT7gCPTJvEQ3vx9jAQlpJiHqKmr3p4XXEP3ePchl6kn+3F6/wXmPrswJWRne+yS7/Ae+QxtEgs0Ca5Hs6ERcQotoJMzpBjGJVIdqDABwqTIWeuiDjC8vSqMmNtOaOt6Ry/rb6QydY2lachZWXS4O/U4UyuzwH8ejqgRsBox/p8npt1PgpXqOxienQlDWKcl035S958yDaEPOtQjx7pADXSRUgjBaoAKmCoQoRmAt8LN4LKUv14OXF9LT5q+w7Vap2b9oDoPNnw1UKwHXroiLaY8UwULfh1o4COwFtr4zfeBUVUrVFHuWSkDf6J63yYbNrAWte6dbiJcCZIxVMNQAGzXP8KvN73tZvgHNszWqwAirj7ylG/HDuVLRiu99FLSd3EmUvtWec8d9tsAKhCy/vt6ETA6nZLrOfyNCxHAC35nzgaNv03V+S8OO/gfFA1fqVCwowPXRnivh3NwUVpJjFpfmJ20rLBCk9UY6H9rrsYFQpVwFdi3hMChhHUr6DSQMirKVxMXpM/F0+1k7R8sVQmnh2Zrp873o50QNe7yBWUsPVXhQQNxuYMLCoKxzKwbzzkH4di6VdSnQzonq+o28bdwgvp9UicXp0YAOZ94ax36z02pU2rQNQFPnL5wiU0orsO5F+H/Y36BYaA9IeKmWeIoTMeqVpPcwChmRd+FsIi/s5wv7IfiHkl88tKK7RfB8mHY088JbMoaCdnrIhY0S2AqbSFLTHXtf0fNk93JIeYw+2Y2mIGnnOjMCndzd+yR6a6gudv2LXUkT4ix/Zn0PWrIxKnRunuYnJEJRM+/aY87CzPeeXu4Nu9iyqf2Fz3oV+8TZImbXejswAZj+6/58p9IvCcvyb5nvgPFW6bkJw2of1Z5uyW+pfQRYKhy0VbMzu6BMGEUsIzvFYTnC4IJ9rDz0COQJNsimzKvO3n1Kk+XG3eEzS0aueUycg7Zv24viU2atc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam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T/VCLgex1wKnMLk9iwr0g5qvF2CS6a+9iWhFZz9hZBl0aWveg/lO7ed/JrYBdBAGRxJ3y4ijVSnXK3mLX1OAtsBjKODd/S9ylCbOYcksFwjnaTPn+W1czYjTfP92uGyt0Bpu65Z1slA8iJ9vo4HtbVu89EOLPR5WvgBBwe0f8d2eaKzg9k8C+//7AYfqrE8iAjxNw1o8jwv6w5uGPc5+qEhpiLxBDwF+RK867I53KvIWjbCK3nH8I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd133ce7-1a9e-4958-b67f-08dc8f21c564 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:03:58.9440 (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: 3l4XOVbGNUuaX5jRtZKqyE6IZ7T70A0HCqXlOnFIzMOrNA4gfmO6RB9eVb5NrdNGNrObjjXaZ6SWmG+9v6LmthBCgkHcfhXbKtgT4D+2eDg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-GUID: Pqvd6yV0degdt0K2BfzMLcblbFw2BbPi X-Proofpoint-ORIG-GUID: Pqvd6yV0degdt0K2BfzMLcblbFw2BbPi From: "Darrick J. Wong" commit c0afba9a8363f17d4efed22a8764df33389aebe8 upstream. A reviewer was confused by the init_sa logic in this function. Upon checking the logic, I discovered that the code is imprecise. What we want to do here is check that there is an ownership record in the rmap btree for the AG that contains a btree block. For an inode-rooted btree (e.g. the bmbt) the per-AG btree cursors have not been initialized because inode btrees can span multiple AGs. Therefore, we must initialize the per-AG btree cursors in sc->sa before proceeding. That is what init_sa controls, and hence the logic should be gated on XFS_BTREE_ROOT_IN_INODE, not XFS_BTREE_LONG_PTRS. In practice, ROOT_IN_INODE and LONG_PTRS are coincident so this hasn't mattered. However, we're about to refactor both of those flags into separate btree_ops fields so we want this the logic to make sense afterwards. Fixes: 858333dcf021a ("xfs: check btree block ownership with bnobt/rmapbt when scrubbing btree") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/btree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c index 1935b9ce1885..c3a9f33e5a8d 100644 --- a/fs/xfs/scrub/btree.c +++ b/fs/xfs/scrub/btree.c @@ -385,7 +385,12 @@ xchk_btree_check_block_owner( agno = xfs_daddr_to_agno(bs->cur->bc_mp, daddr); agbno = xfs_daddr_to_agbno(bs->cur->bc_mp, daddr); - init_sa = bs->cur->bc_flags & XFS_BTREE_LONG_PTRS; + /* + * If the btree being examined is not itself a per-AG btree, initialize + * sc->sa so that we can check for the presence of an ownership record + * in the rmap btree for the AG containing the block. + */ + init_sa = bs->cur->bc_flags & XFS_BTREE_ROOT_IN_INODE; if (init_sa) { error = xchk_ag_init_existing(bs->sc, agno, &bs->sc->sa); if (!xchk_btree_xref_process_error(bs->sc, bs->cur, From patchwork Mon Jun 17 23:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701534 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 D213B176AB9; Mon, 17 Jun 2024 23:04:04 +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=1718665446; cv=fail; b=IPhVR0O95sqlIutoKZngW8KCUCTIpLKVp8p/tDzuT3nGzsOXs6nSgWYz0RvoPgyYVrTZLKhU4V/qdinNROBZzNkdQXm7oTUy/vD0yB54R2bT0Gak7F32Sz+wnfDGM4DHpRC2U/q0yi3LsAgvw/KBURqFtT8/vlbY0QqUFQkRCSo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665446; c=relaxed/simple; bh=4NypV6vQTcfaBg0v6sjr/ENzVRmgXvXyau8nOeNmef8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=V9Ep+vhzQZNsPERxL1xLdvRNpHlU4nS/V0xCWII4rrf6oQT9Bql03RxdcaDq3bFW595SroHqeT4oHZKt6KsbqRjMjfOEq22kjBTcDck7X2iOLiO8CEE7hSAkX2fRhitqZ98bJlessoDbz4V1QtBTOIyopFcOJdwoQejaBINNZog= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=IoTCUU1/; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=hiP3HtEK; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="IoTCUU1/"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="hiP3HtEK" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMY2q1010689; Mon, 17 Jun 2024 23:04:04 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=S46iQvJdllqfPwDoRxNgNCm274X+LIaeZ9fZn/Jj9wQ=; b= IoTCUU1/2qgzcibz6gZ9Ettyp/IlQreP60trE9IXOJswa2s/lORjVxMKFLeexMzE 8rRGQH8arcOiZdM/aHqXsPxrU2eRKkjg32GBjHHQ4jMcPfZTdM/LfkmmCjp5+03T 4n15h+11k3FZI16nNi5KwGdj4pdomRaLPQL7Dkfl0EstyXAZHe8WlQ9Q074YZWyN p634SjnEJzog9hwCYQ3q0z/gm06YLuHniIvwkqzYAogevisOGK/QP74m8cauD4bZ jJXczEJddefEklzBuZD0CCcv7RkBHeGempg1DZIxKnmOHFD5f3Hr3eFTzX4z/DyY CH04Wc/2EFDYSGMGuyOC9Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys2u8kpyk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:04 +0000 (GMT) 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 45HMFgo4031869; Mon, 17 Jun 2024 23:04:03 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d73jy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kr4Njur2LI0otGjawuHtHk04O4yFHXwXhkHa2Ii1qF2dltUgQolkcm82BcvNJRWwKjpuRaMTaKlOPxCeq5yMaNp8/ZcGVZpR1E0HEfioQ9o+lwBBVUI3FCLD5I9Pra2nLnc0l47hEb8wTER4n0u+bMcvnAT7M6WfAjTXRS1t8pvgEoxOkijJSAkKiHhvcQjUeaEVqVhvwlXBPtufXICTbTGOuEr7nM22PihWVdBHYbHv7ArflbqVEv8Sz40zYEVuZktukHNFj8BVlyVohfckC4DDPdbflIjKUPSlBW1IaL+Bhq6bnRZqvdH36p9HhiatHCqnKmbK3DiGA27mi8r8BA== 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=S46iQvJdllqfPwDoRxNgNCm274X+LIaeZ9fZn/Jj9wQ=; b=cxKCZgn+MKEpwNW08BZPpxjP0bZX0Jdd9EeOSXLrQ/LhG8x3Tbp24q1xqiiQIf4QIOmigK8utWgAOGakFW2QII28Fys0Nj5pOeqVRqD4vPux/HlvB4Fcwoj3JYiLLMCRHLeyp2mySOSxEkxnG8zutmj1HjQgBJRIOschBvZopsZqQz/X49ZHzOhNuKW2lVO5hkBcSoHszxb3BMwn3xah9AETYhE8EuCiPEM6BvwOQjVvUkupDDAZpgzq/p6UL7YNHZXN9OvwFmG94wha25IdThx2XnexxsH3LX3j+iXV7alJA1g3NQHVn29zEEZlOQnE/pCf8zVW4Oex6l/WtkVzvw== 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=S46iQvJdllqfPwDoRxNgNCm274X+LIaeZ9fZn/Jj9wQ=; b=hiP3HtEK3mm+xvqNHlWl6XH+UeEND2CrdKSpsU/9hFNlT+R+W1Xkbc/XyUET0G1E4ycNxwT6fjgEuQ25k7+RMFq07350yRtHUXybamtgdHqaCJMt+TQsTV89YPXDOXjM5GSXGJsKL0APCwaRFZEVBvUXv/ke4e5svqp1b2NO3tQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:01 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:01 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 2/8] xfs: fix scrub stats file permissions Date: Mon, 17 Jun 2024 16:03:49 -0700 Message-Id: <20240617230355.77091-3-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0355.namprd03.prod.outlook.com (2603:10b6:a03:39c::30) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 7414d64b-af2c-49ed-a14a-08dc8f21c6dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: +tDWtWtCR7ZIR7JEspfaWFIGcNpRFnU2RF1qxypJbOxHcHTbhWbLcQM5Zh1ttR9QuWCgy8/JryucRuMAOZ6hX3mkf77K/MNVfpz/tl2CFm0V/FV+kQwhuSD8VzhWrEERMSS8H1VdApzxoAB1VyXd0ZdN13b3WTF8ns4nMm/RGo8hB8FNMOTqh/aX8QB5mZ1ElcswKeastmS8pdgcRGCEEZ2dtsiDMmE76b9fkhNfdjwPSgHoBakqj3v7ZPSpOkChj7SqcEDqIw6RVBtBFIDcM9WbWfqSc0e9Mk+QeZL9AGefB0dPpHeD/mjpyGYOjJacoLUOUI3ztXtgnr0HYAA1Nl9YdsfMXyAZWR8J3/jYxIu4qLNFaWLXFNt/luNPUeiR7j0vyvklS/i5ZksUilmwsLkq4geQ0xFvoszmhZZbA5/hAR2iqmXTM4sep1jypP0wsraCkf5cKMAmpI7II9/0BhtfHPoZ8a2DXAFhR922zfIvqQgZANKhFKXpePnarCf1Tg5pW34mSyEHjD8i96Ww97poedyf8ucgGcHwdXTFwM498UjHd9QN4U5n9hLH7CX12J1vBi+s/iuvwGOLNBumo/50+MKCRDrqnGkLgGmQR/TduK20kn1hjDwzPJlFqKWJEqZFPFxepkRHHOh092t2RmrpDsli4D/tnwBHVU0b6ibhirK8z5rWd0gce3eXKwAGuHNC0ExCXzgUriOnXCJd7fBgm5yxFBNOJw6JcRbWgBO+yqpl5KvEAVQQBV12jcUYCpI7fGVJHf0eaJFuwSA82Jie5bt73giNf7iLZf58rlfYpdweIWmvfFNnAPqZWTnibokleYEXlTzpGeYISdbKIWYLZPZSyqGqWvgFwzymNsxwEuq6ldhoK7zH2ZAFYpC0Zn8OvOuNUqWtl5DWRu1UcofQRvCTpvYXc4pyrOZBoZVNHejgDoWiX+Ep9i/sz+lPKdrRXqr7YQ/Mm8XtPaTHVyPZCneNAxpKwywTSAU6d3m3OwMar6RNakTxWptvvb6pp7ZbGX3X4+w7Yrbsr02FWqXr27Ug4VuuOnuPWfDTyeJXOo7hGoA1FEoBW6q7LAaWGEeJTmsQcd8wekkxBM0/ERclYon1BG5hjZ9pIS+KC3lyamDiiMxmoHs/RXb9guOQOwajzacgkdBaWrR22CewtdfT/gPacB26QhiRiUyC52QFloM7GCJyBHRVFNSVc8TnbPNndGeonNEHHnmKNnLmV78cFB+RuSPXc/p736kcqe9FTABt6AXvIbEz6zjf1ma4zcWwXW5iZ2hE/V+JDoZm5dTbT8LGGnhEDzl/+6Uo0gAoUOdFeydqJZ4ZQ4XKbkqw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C8UWFohBldwxVnO9b1fwQ4purTtNeM7hW3M1qkhb8QIfepn7gdPfvSJY3TIF9UsqdoDt4NJjdJR7FdrAQQJ8eMldSlhcqkrO2H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SnA11s3e0CTbCNrzhpjGw2GzAcGLW8UepagtWz0sDVkft5r9Xq9Z1PTh3mwD0gKKpyzgKzVJnZBXe8zW9B+vKlOOG0ceb2hMOus86j9/QJPWrOnuXWmpd0AvaXiRpYY4JXc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7414d64b-af2c-49ed-a14a-08dc8f21c6dd X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:01.4431 (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: 11l5+QIuLRnhudXPf0j7VBbxlVS/L68nMtnbX57EW4+qZmkITnOl+nZ5Gp685b4rFATFO8feuYtTSjco1kRyjPlG1V5mh5nn+TZVc5k2jx8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-GUID: yPWXas82jIlmx2LlbsEfdlt_9QIF5Pnk X-Proofpoint-ORIG-GUID: yPWXas82jIlmx2LlbsEfdlt_9QIF5Pnk From: "Darrick J. Wong" commit e610e856b938a1fc86e7ee83ad2f39716082bca7 upstream. When the kernel is in lockdown mode, debugfs will only show files that are world-readable and cannot be written, mmaped, or used with ioctl. That more or less describes the scrub stats file, except that the permissions are wrong -- they should be 0444, not 0644. You can't write the stats file, so the 0200 makes no sense. Meanwhile, the clear_stats file is only writable, but it got mode 0400 instead of 0200, which would make more sense. Fix both files so that they make sense. Fixes: d7a74cad8f451 ("xfs: track usage statistics of online fsck") Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/scrub/stats.c b/fs/xfs/scrub/stats.c index cd91db4a5548..82499270e20b 100644 --- a/fs/xfs/scrub/stats.c +++ b/fs/xfs/scrub/stats.c @@ -329,9 +329,9 @@ xchk_stats_register( if (!cs->cs_debugfs) return; - debugfs_create_file("stats", 0644, cs->cs_debugfs, cs, + debugfs_create_file("stats", 0444, cs->cs_debugfs, cs, &scrub_stats_fops); - debugfs_create_file("clear_stats", 0400, cs->cs_debugfs, cs, + debugfs_create_file("clear_stats", 0200, cs->cs_debugfs, cs, &clear_scrub_stats_fops); } From patchwork Mon Jun 17 23:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701535 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 6C362176AB9; Mon, 17 Jun 2024 23:04:07 +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=1718665449; cv=fail; b=DG3Ucs+yturexQ2QBXBhJJ3jBATrm1FO6DitAvKOuFt2qNNqAvSsW5TBWuSGti+zJaaprqDU90ezXHBf4ib4QXEyyV89FXK+s4/vvAmIco7FE8cZwsbDyDpPlZF7KNGdEHlxS7J7O/GcCgJzLSbQ4n7gUZS4iZRWSE8JqUFDYn8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665449; c=relaxed/simple; bh=Is5bJ7ZtIx5oMZcZcNOrZeYFCePaUIkFRaapgO+b/0A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=i0lxFJeBtRsqrYT+ldGT0hhPzELPGsRhPTN905tv2tOBmzLjTnw5/ZgfrKwkxmzpT8VJyar+k0JhN9oEdHanMPG8GuSUGpbFVu8a2H1CxgE23NijRrn/we1c2plt320IyIa8wQsq1ycYVl08uF6rvI2qWF+mxMbiq/wq8qXcBBo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=EjUcdCMh; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ha8SRBIg; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="EjUcdCMh"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ha8SRBIg" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXiXn030327; Mon, 17 Jun 2024 23:04:07 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=tNQjQr8KWuQ1YZpEYgOpt/sjclv3MX/ZA7bZQtDjDYI=; b= EjUcdCMhP+aLwpCdWoZXTp/rg4V6X+YKJLrNeC7u97zdmxbS7iVEgE1GsBxUhLu+ P/kk+XGIV4quAI+g0jCquvvu8tdzlxRoaUJC5PUKwOtoEjT6u3PgJIBwyFCjYRcd ejYvo6ePFaKPIGpUbaNfOJYtwZW3Me5J+KBkLrQEXPJIjNRH9yk1+HYfh8zzQwWw JfMGd11d3urY1wQfNokqgAZOl8mPRS9sKymFHEZREFyzoujr1CcdklkEZ0Vi6DDX lEOqmHTTlSgETro16IS5mWL96x2HNJ7HPXW0FW8qlxeZIrHnPkt0wJIVPxMcTmfa hATtcsT3gxE6geEUatwRXg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys1vebt93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:06 +0000 (GMT) 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 45HM0rAt029434; Mon, 17 Jun 2024 23:04:06 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d77xnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cjaa/vqp1tlTyMGaj8k9ZpiRPxjwgp6OpF2qGfDX7kZcL83akfXh0WvpFr+QvUKG7i57HsLlnGxjNChs4GA76eRxCs6vtc2P7smCHhSmDHWg/svXz7s0Sro+KriFM3/27WlIOAue7He0oVKjioo4LGfQNE0bA0Q+uHyLdzwvsLKwD6i1wTEcTruXQv12jj2d1DT36DiuXocJfnfnXXykNvzxIGT38DefNrEqsIGhWauRbQ7MMxQfqhp7yR90UQh0ZvSyHycEGILFMuAgzawqF78xbZeth7Weq/KYRQtkMp/inNubT2qdYtOR1vZieDowXQMh76sEUdTqhzmd4zsXhQ== 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=tNQjQr8KWuQ1YZpEYgOpt/sjclv3MX/ZA7bZQtDjDYI=; b=XccpfTZtzNDMS/8KnR/66QHZdAb0TF1OFNJYp6TiOuHwOjkCKWvsjleNKTls0oG+2Jn6IwXtnRbe4SoJ7fZqr7AAzLlGfr6jwi49d1IoLD+7BapUcptotuYgUjXfcwSD1v8qMUTiQlP9pkK2V/gCRG2u0lKjnUea+KOQ4vvgPKIsfyiulfd08tyICsxAwXHMv1gJXDmApOQqTWpipwkK7Nql73ECa3NduIvGnbArRseo7bqG6BzvpBXWUAq6ifcQQ4ejPDQjygmRr0xLeSFqaY2bVi+FtY62aYhkT7XTTC9UiF+dOCHifCCAV159TzhcyKabsnXjt+qybn2/H3MsSA== 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=tNQjQr8KWuQ1YZpEYgOpt/sjclv3MX/ZA7bZQtDjDYI=; b=ha8SRBIgrVq23Vf3JvNco1wAfZ5XXgiNNPshLHf4VNcm1erMKhcgttagnC9lm1oDj+L2NwLV1CCI7qtGcbXbd7xo3x5qg3Ip55+3TKOmFmrpA9hg8y3mImvrRcahbNzOXHpcW9DWGFSOodoKKr4jZVSqLrJUIuW7EeYEIXw0JJk= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:04 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:03 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 3/8] xfs: fix SEEK_HOLE/DATA for regions with active COW extents Date: Mon, 17 Jun 2024 16:03:50 -0700 Message-Id: <20240617230355.77091-4-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0356.namprd03.prod.outlook.com (2603:10b6:a03:39c::31) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d130138-1cae-4b79-5cd2-08dc8f21c864 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: g28a7K5JOBOSaVnkDJrLmFBPP61p0WKkeej+Zx6DS5nTicwyb45eD+fXidm7Qu6Wa7PNMnSdAmJiBLEEkxLA3Hkx+RcVLVOg1Br7xC4pqEGVdnO6owci3Hns4EzfYH+WYplL1QG9lwb8bsCw9qJDdJiX4FrYRk8c3QnNKZPlGo9httt4A8TWGdaRd1NnajGPVpliJJavv2YcP1Z45qcRPH284LzHTEIoSuerF1Vdr7dH9v2xa4VIvSwOYbIrNkd1hJ0jMh9i3FUf/2wUg7FVr8c/xXwZ1RD23dP0bdo0goSS+wVpaqwhvI0sJdvia0yGF43fJ+cAlOQgDEvKfFqmqi4MTEtRcCisK4QYxJZxAWNy6DRQBaREIG767JIAu8qq8bV3kELnV5aZw6su17UNkOCBpG/suR1HIreAobJTYK6rH5EG8gtQRLpY2fBepH7u/JK0TUYcWSl+qlzQg0d3lyqXSCmLiw9gOjwAfBvnlwjbrXM6xbi6OohQbX/g57DdHtF2Xwy07GPY6qNJ2eymJG13q56CrvUoknGok2nRMwzHk2DNy69halizKfH8DYZ0YIfP+qHF37ivhaZVLqjdNgvJMkQOkEgQI35FXPFvWNtXIB0/92PQq9pkEL4rjim6xDSXDxaDGA10sPrySpiCOTAsT6W5rh3ziXAqZY1r8zfPiluZwJOex3Oq/a5XvyuwCEEAWiIvEK53GuWUq8FD01Rv/P5OTnCd6X3H/EzwpVMQLGUSEZMJNK0N2eWDgvjttVjJZw5HRZqhHdJGg/RKLi8iSmMpP4Zd1i8SGhsu7J1aLt2Q9H5QJPwR4KH9hYicLNxaSgo94cmEK2r63Cj109mZyndrQ3ILm5bRWm1Q+B0Y/KoVPMNcERtgf96nDvOBA+ElcwfN3JE3LCZp/MfhEKyeyOQJOFekVKj9n9an/9ly2H+xCN5/q+MDXmcBtKUQjLq4oWY+OGu4yKiqORw0vgIpw5lyDxtF/d5YbOyZIBl9rM1cDA0NAOV9HqxrNJyotO17iKupAfs/sJi092kzYwyOqX9M1dEDVR0XmK5xhzGqMdQk23mFm1WCS3DjDCau8nOmYenMmdW7Vizgpn8QKwx3+ezmck8MXD6hfKN5tjUh+AlOUrgIvvwu2qx8xO6hzHX2AuzVk8B6LpmpUGDDeqUgtr+c5Gq7EYV6w4UmbxzxTZAUAeYi13VxKtn+GtPh/P9bONp9dpqpFsy6NEOZ1kxbCqOn8Xc1cmyG6/8iQGI9Rc/TKYZYw8OKJjaptRrY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +2KTy6ZVpjQFmhHlE7KAfdUs6sqBi5D26XcOFLupt3DWLqvXBUnsPO9LRq9YgU5LBJLcq3cAF24GHINPdkcm9RpOBJw84XoH9j1pZFFT2tOt3pCrWmAgNMLpbAWPGGhU6fvLMLhERzgAHDsMKD4+DQF+EP2tAOyFBJwcnWKhuie2ILOwvzblM8jj8iAneuLC8eZRO4KyyXPe1OrAFjoAwdEGHz0EJh9+xuw2Y7CcjuZtNKoV9PmYckIB6XJmmLcKcgXdqQndQnK2XduyNVmkLZYtU1c87jikTeE9Yc070mG+8IBOX9UzRUCQX3mFij1rqOFT/xQqfaJVSLEaDP9lZuhjqOEst6kKb4LAsIj7HfVut3uIBrBjdYdpPJJdvD1Sq2Qu7GTaIdzJb0ZOmt+zJHQ/RVJMujp/iAIILSzND4QrY/9X7LMonK/LsDUHDjtEGciGG3hryFN4fqf+fiQ6XyQRZPkBpktnfDMeNigGG2CY5S6w8P++0ss8pi41mRPdt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l0qDCPiKmOdYvFhcUhN/Kovt5tSXkwvlQZ2cael2vhvtJ0cGSrrxuzAKpwfm/c4nt8s6WfAsguKo7MVvJRFJpg6xbGQ32ejDjH51CkQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: f8LOPMu3BEybCQAMgeJ9wsHWd1XObGe3jCiRwHozRGoKR52eqq0j6NQPyS6+LeQEdxVQhO2ZYCnjUZWeKrJd6g/x8Pl6s3/L87d8o/dVtDTezHX6Ml5+mK4sqiowdwJmFuUZryg5erqTJfe/bERYnbo5IqWVeGLxglJc9elMulLBAlWPzHX3yAGOfM5uRMbw+uVaVxp9RSpzaAdQkjDhht1ZS5qCeoA5KG2XeiYBRIvLggqdbbtktZ3yU+vUg3iZDYrgItZRWjQwnJ4uQVEUDPquZa8mqJbO+UTzS48zfjd88huBRfTLuTuI0a5+fm4aUgMn1LV2LDYkZgfXYnRwgzaE2TDs6pac+ELog1U548Z8WXcfx8pzX19T1iJC3mSvey9zhI7OJn0qlbGvnxWYFXIjuWAjHxlY3Qv7AmUG91HNYSZ+97UujE/PLUv5ZIZJqQTLsD+OS5jYp1v355jOMq+C4shnJ1lJJEX4ql7zJGXX9XExFitLw/CUki09kfiHH/pLe8lM6DES2sBc3uSxqk5DO8VA4Dcr0/UZTIHV9nNlQZ4Hn4fQ3l2qQrmlI3LcSERgXJKPDrUZIelbfxnikhOysHzozcqM6CRkuYFOq2Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d130138-1cae-4b79-5cd2-08dc8f21c864 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:03.9358 (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: 1NeEUby1xP39C5zcRVBG8Vx7ayB3fbTT67JXkQnrjo29/NcfMdUBCwdMIyR3AxcWPGa2TApAgFdrrJiwfy0X2yEq6khp1HFxMImLsn4Bxdk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-ORIG-GUID: WhRX8xzvVVmQ_ydFcFqdWj6CH0Z0BDQo X-Proofpoint-GUID: WhRX8xzvVVmQ_ydFcFqdWj6CH0Z0BDQo From: Dave Chinner commit 4b2f459d86252619448455013f581836c8b1b7da upstream. A data corruption problem was reported by CoreOS image builders when using reflink based disk image copies and then converting them to qcow2 images. The converted images failed the conversion verification step, and it was isolated down to the fact that qemu-img uses SEEK_HOLE/SEEK_DATA to find the data it is supposed to copy. The reproducer allowed me to isolate the issue down to a region of the file that had overlapping data and COW fork extents, and the problem was that the COW fork extent was being reported in it's entirity by xfs_seek_iomap_begin() and so skipping over the real data fork extents in that range. This was somewhat hidden by the fact that 'xfs_bmap -vvp' reported all the extents correctly, and reading the file completely (i.e. not using seek to skip holes) would map the file correctly and all the correct data extents are read. Hence the problem is isolated to just the xfs_seek_iomap_begin() implementation. Instrumentation with trace_printk made the problem obvious: we are passing the wrong length to xfs_trim_extent() in xfs_seek_iomap_begin(). We are passing the end_fsb, not the maximum length of the extent we want to trim the map too. Hence the COW extent map never gets trimmed to the start of the next data fork extent, and so the seek code treats the entire COW fork extent as unwritten and skips entirely over the data fork extents in that range. Link: https://github.com/coreos/coreos-assembler/issues/3728 Fixes: 60271ab79d40 ("xfs: fix SEEK_DATA for speculative COW fork preallocation") Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_iomap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 18c8f168b153..055cdec2e9ad 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1323,7 +1323,7 @@ xfs_seek_iomap_begin( if (cow_fsb != NULLFILEOFF && cow_fsb <= offset_fsb) { if (data_fsb < cow_fsb + cmap.br_blockcount) end_fsb = min(end_fsb, data_fsb); - xfs_trim_extent(&cmap, offset_fsb, end_fsb); + xfs_trim_extent(&cmap, offset_fsb, end_fsb - offset_fsb); seq = xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED); error = xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, IOMAP_F_SHARED, seq); @@ -1348,7 +1348,7 @@ xfs_seek_iomap_begin( imap.br_state = XFS_EXT_NORM; done: seq = xfs_iomap_inode_sequence(ip, 0); - xfs_trim_extent(&imap, offset_fsb, end_fsb); + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); error = xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); out_unlock: xfs_iunlock(ip, lockmode); From patchwork Mon Jun 17 23:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701536 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 589BA199E9D; Mon, 17 Jun 2024 23:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665451; cv=fail; b=FredASxjERzhCNa4p+kOfKgxoTcYba7PiMrRA8J1Wp+MSUU0iJtNaLiglMexcxuzkTWzVDGrDRwSIfZmvSq8MOD8L5/FVbMegnQKxjiDjjCZvKhM/9ewpF+lhnzR/rz+lAf84++eOornwPpMMbXS0+YT3+eKdYjMB4LYlwxO81I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665451; c=relaxed/simple; bh=d0HIIN7iVy7HE8eykv6zoTGaGbsgPsacrbMsPaMumFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IqDQGPQy08zF+mtDwfxTj6XC7UWKQID+tbx9oxNB/16vDwlkoN35ML9P2Oq+2t+TDqzPhYj3+qEmaUbCkI2Bq0g9vZuEi5xEfK+DrFubR9kDc2PGurKzzbDjq/TzgwjFINYaLDf4yK8bNkZcpvBfxoHylOY4lZbdOlkOdFcFn6w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=NiMLUIVz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ib+tz6xk; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="NiMLUIVz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ib+tz6xk" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXSrT006546; Mon, 17 Jun 2024 23:04:08 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=WpsAtZfHGLIJ4+cK8VnhETlFMJ+GolOU6LlQ8O69tNY=; b= NiMLUIVzFZJ2B9EO2mxDfZ7nuZnwp7RpQC9OvqrJzOi/xtX8z+vvNmSGVOsKXecU VNrtg/GsffXIIoCQMqfYef4x95ilsqc3Y/vC2vyLNISI6IT16XGd5PMOOsRHOMMq 5Z7LbmaW+h1jiWRQsSlp/uNwURUEBLwgFDxI0LMBFmItISqw7LMEkTETGy27zH56 4g/KD1e+L3JKtg1lI72ZRQ9FSf7mIAXNPGI9cEJrzelptilMVsy2aFS5ZZmYjvje 3yMPPl83jvzZVC9f1SCf/x4ifs6MYEOgp2yFcV1nj8zO17E8w38vvLgMp8ZL8xpA QcuCSBx3NNf2gnBuYFTQBg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys2js3r8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:07 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45HM0QCB007268; Mon, 17 Jun 2024 23:04:07 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ytp8dmmmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DX9PlMXbmAiMIRf9/sYfaeaz07oHEYJ8cuuDBMlhUCKFglWoYtI5MIJYfoaJPHpu7GpUuToOjpVS1CoxcOWBlBd+jcswOQ0XK5joFQE0cF8s+N4rhvuXNAxPn2GWvwLqiQyNvf0+xxfbJ3JUSJ52rxCh6AtHoibU/Wn2WSqTW9ejzpU/tYOAcyiK93Osx0ujeaXnnp1lmlVSpZ4SXyDO+NYQwI976G2dzVyw/grysQy3j/I2txgzOkGpbJ8GENxfxDVNqbpCN7X5E7jonJjXeb72mhR1vZFXNpmWwN4Nz1uVadLh3X4DlZ4mbPmnzppU3eZCaxMXpZ4+VAjxSCIL2Q== 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=WpsAtZfHGLIJ4+cK8VnhETlFMJ+GolOU6LlQ8O69tNY=; b=Lm7Gw/ZImeQLFZkvN2nWBE59bOi6Ya9PnTSO37MJ0+qWZwklFIprJmD/ihKFHVuJwq1ULTi4u15e1TnyMVtkzaD7iJLgNVLBI5i/FTKcAXx+9u61nWWJFseSTIDGIYDucQ9LTC4wwRZ+aXxNJAs6MN8RcBM15nCC8YjBZB1viv2Y4G2m7l+HkAs3y55vmu2T+GPsakDtldsmDihDLnV9gduSIwU+GiUa1AkXrONRMyVfSbB/aSqfwVsmCvZPnb/0ofEz+J8EffroAI2JL5I3SrnGSz45I/gtlFGtw0glGn6yu6SZwQAW3hmF215IkrAo7rGg+zFVhz8lc8Xajml40w== 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=WpsAtZfHGLIJ4+cK8VnhETlFMJ+GolOU6LlQ8O69tNY=; b=ib+tz6xkUo1QmW1db3FgAHsW+x56J9IKKdRxyaPln8zYyvonWkBQOjDqOMULCcLMVa7s2rQPLHGP/RApRJP2DArwSUfr7yMseykgExs7WyRo+9xCjZYzs1P9XZ9TaGCKhbjqfHZ4dXtNr2XAVyq5dx2aBD3aYsYtqYR7aL0UcAQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:05 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:05 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 4/8] xfs: shrink failure needs to hold AGI buffer Date: Mon, 17 Jun 2024 16:03:51 -0700 Message-Id: <20240617230355.77091-5-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0359.namprd03.prod.outlook.com (2603:10b6:a03:39c::34) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 7546c6bd-66a8-483e-8691-08dc8f21c952 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: EbHwvtx8G4hgRTDiv6czH1UYOImLWo1QuyHEmF5Blj0ldDyXRuCByuqMPlOd48uDCoGcPhvhxGqDGlskWpkjw00dJX99N1mDs+s8xLVSYfE6pBut+S9jNdyTMTKWKXHuwTavVlo8qChTP1H1mQsBEOou045q8evICE2BeGiXmp1gGwIBkyhJtpC0Goykf3WyDGbgQnicu/toboMKLQYHV1PFchJW9jHkfT8qxCIqJg6wQsiKsC7lXQZDqb37gI4OmHlDYxbz4LyTAfdms40eFtslc839ZN4KgOsz+LpLtY1Rhvwq1vtadVu0vDLg7/j2R14Im4IHhQn4Z7/9gMou1+CCkF2T/yGBzLlfpOxz44c6h+ylIBSIZQ1RQ5ux1oZ26UyEVp5RjodyjIjmTtNC4O+2ZkoEMwsr7YWuiMYicrQhrkAxM4McCBhzODcOB5zxtQlDHDHrc2QtE1tA0DUjkzU6AAtEHSBslKgXPzyJWZRSHBeKjwa8BZDy2hZf7vk6a4Fzo4S4bRAnT8y6tpuFChLckbEi1Se5fIf3TXnZLE+aoRNBt67i/XDbb983TF72QyQILRqsvAf5CMzU759pRxOWSew39QggD3xJ4QSrkWhnv1mvM29JXmq9JxR8msY46tu+JIzh44b9ISmJtoY/BXW5MgT9vrsEO1fxlbf8LnOUTx3HJ2peqNSwseETx2n2rlaT6pKBnN+NopujPgCpb6o/jE96pPhOSkBsMGhMed6H22ba/8z09UguwggBTe+nTHEzaRj0V7R/oLt0vQjPxMoRWXikUp3lAmqxwAhE22PQ816vQOC2i7YfkNoBQyKwELz9y3bQtJF9kr/Rnu1ltD9BSTqVGeea6Ai4mMgRZERLS68gR6XSLtUCTn1B1mkSmCzc52szwZhiRxrFrhiffVgE006bS0EbJbhSHZFTDkEbt7smbrBCKQemPnr0WpX8brlUILWvnTo+3ss9fTEkoxd7IEwNkYvBMY46nkE6+7T43ahyERshYEjU62tyjeWf4G66oE8QcLjqcVvfTkTZxVuv9PSfnhJsaLTNKHdmIyoaJ1NVJMiMOdjWhQR8ujEECJHGIh6V0d8UktojSZmNLXAroxwwL66wo+JMjpL8gsJtCFvTsKQ930CxMXLIuvtHMnvg0xL5Ag6p3jF/CgrfrI0XBUwceEVVEUBHO+eNkTK8nQn7AxyG/9RgrYtfc0JM+gteM3dyvGapf0qLqM+jyDI5QSVs3vwcuws7kk4l2gZeMi/DlMVbRaLYiUYgWTCihrBgblkevu0wpdekEg7B4/7GhvWPIvN0P//v6FJFwEZ1rJelO9w+nLZO/uiNsHfZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4/UZKaGA5p2fJRNdRFr+QqXSZ8yXPTAKMtaS587Noe8+xMXrqyFZwonF+t/5eENOpsk2emV3K1mBk0MUWKhcvgLj/9eh+3PwsbIb8MFR9lsO5ak1l7O/s4WAAXUJ5yvMxMXQVSJT3bZ/Vdi7tYDUILUE5SRpcxRFqWecqVQjfQ49jfJakgd9jsbf+R55N5brN+pweKsIoa+0d7OwS8s2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GWIfTFUbKAZhIHBptne59NXjTsbKYAKFTOg//0O9tGglWJwY0PjzjDsw0iJyOvahoGfjyTglSiuegXYX1eagqsYrYvaN6popGaxuVXHxSbp9HIMQeYz0ScGChNSFgT/DQHe/Uy+K+6gz6/CRDJfuQwIaFOrRLZPhUGZHuaXvpG5AQwoEuzy2h2s21mIrHiz1oPhJNusJYxHtgUktHBMouud4EZXcUz0su0U59hCyQZcipJ7uQnvtm4dYwmhMrJ1bYX3agSRIvoTizxMl8oFj2q4cXyKhK6lsC5duFC2SIpkwW0A4mO+J+bSdBCaKYf38WKsASno1tAwUFKd14AF1A6daYgI//swbBEuzVDHzOXolJXOHUQMaO/lZ5f6XWg+++5EiA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mJWlxlJif7jhlMSFMJqSphfKg6KhqSoPaih0duEYEQ2OUum3YbzNNRUaTU9t9PwqetHyi+bOdYVxYp0uX6am/GnHzJ2R9sKQiEUt7MNtCTTE6GOMwPfyun5CaqarPcean8ZugW1HFodqBPjnlnoC9JgrWJACScQ37ODwm0KMwkhb1a4LpcQoHVitbDFD7d83KMdn9H0NV88htz8IjKV4uUh2ygpkUWy22lXXLzRkx06Hwe45jw1XkcyW0DNLxkYFsVM/lVht00jk+XvOwBaTHMpCikzC4um4J1bzsPDgl3AMH5nN/Yk9+KaF6kEhF0e/duhFyjiWEHns3fjcejZI4y+7AjZ0n2D3kDyn/Q+l07BO1qjjaiqP5GIQWXKmSqkToUyTgwnpCdlLXMa3uCfiWlsoTm04Ydq5aBA2VSi+fSZWkLKSNap5PfUK9HCt9fsh49HcCnyKLVwNk+juFCWp2z7LzgCkcyELYYRLLBZmfrywYsKZgwvft2N1V7xgXYTwWWyv8W3/m4/SvUhkNvQuFfh4+FjiHQhGd/8U6YSDTduogmWfAQ9n+HG/MKjgDV/jwfMiuyMLzGyzaIz7OBFW520WQsbdszMM4tu02m3apBQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7546c6bd-66a8-483e-8691-08dc8f21c952 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:05.5443 (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: Q8i8YVFmrNCUsXBHIlilLoAoRW8394EbRNPnjHUyxrJPWhPl/0hezTe1A9NtscLFXV8L6V/e9MEAgwGcLcwMNRDE6D5PdbGIq/yA+cHm5zw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-ORIG-GUID: BX9ms_jEOwGmAyRKRXxozAvrdMNHt8oZ X-Proofpoint-GUID: BX9ms_jEOwGmAyRKRXxozAvrdMNHt8oZ From: Dave Chinner commit 75bcffbb9e7563259b7aed0fa77459d6a3a35627 upstream. Chandan reported a AGI/AGF lock order hang on xfs/168 during recent testing. The cause of the problem was the task running xfs_growfs to shrink the filesystem. A failure occurred trying to remove the free space from the btrees that the shrink would make disappear, and that meant it ran the error handling for a partial failure. This error path involves restoring the per-ag block reservations, and that requires calculating the amount of space needed to be reserved for the free inode btree. The growfs operation hung here: [18679.536829] down+0x71/0xa0 [18679.537657] xfs_buf_lock+0xa4/0x290 [xfs] [18679.538731] xfs_buf_find_lock+0xf7/0x4d0 [xfs] [18679.539920] xfs_buf_lookup.constprop.0+0x289/0x500 [xfs] [18679.542628] xfs_buf_get_map+0x2b3/0xe40 [xfs] [18679.547076] xfs_buf_read_map+0xbb/0x900 [xfs] [18679.562616] xfs_trans_read_buf_map+0x449/0xb10 [xfs] [18679.569778] xfs_read_agi+0x1cd/0x500 [xfs] [18679.573126] xfs_ialloc_read_agi+0xc2/0x5b0 [xfs] [18679.578708] xfs_finobt_calc_reserves+0xe7/0x4d0 [xfs] [18679.582480] xfs_ag_resv_init+0x2c5/0x490 [xfs] [18679.586023] xfs_ag_shrink_space+0x736/0xd30 [xfs] [18679.590730] xfs_growfs_data_private.isra.0+0x55e/0x990 [xfs] [18679.599764] xfs_growfs_data+0x2f1/0x410 [xfs] [18679.602212] xfs_file_ioctl+0xd1e/0x1370 [xfs] trying to get the AGI lock. The AGI lock was held by a fstress task trying to do an inode allocation, and it was waiting on the AGF lock to allocate a new inode chunk on disk. Hence deadlock. The fix for this is for the growfs code to hold the AGI over the transaction roll it does in the error path. It already holds the AGF locked across this, and that is what causes the lock order inversion in the xfs_ag_resv_init() call. Reported-by: Chandan Babu R Fixes: 46141dc891f7 ("xfs: introduce xfs_ag_shrink_space()") Signed-off-by: Dave Chinner Reviewed-by: Gao Xiang Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 18d9bb2ebe8e..1531bd0ee359 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -979,14 +979,23 @@ xfs_ag_shrink_space( if (error) { /* - * if extent allocation fails, need to roll the transaction to + * If extent allocation fails, need to roll the transaction to * ensure that the AGFL fixup has been committed anyway. + * + * We need to hold the AGF across the roll to ensure nothing can + * access the AG for allocation until the shrink is fully + * cleaned up. And due to the resetting of the AG block + * reservation space needing to lock the AGI, we also have to + * hold that so we don't get AGI/AGF lock order inversions in + * the error handling path. */ xfs_trans_bhold(*tpp, agfbp); + xfs_trans_bhold(*tpp, agibp); err2 = xfs_trans_roll(tpp); if (err2) return err2; xfs_trans_bjoin(*tpp, agfbp); + xfs_trans_bjoin(*tpp, agibp); goto resv_init_out; } From patchwork Mon Jun 17 23:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701537 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 1099E196455; Mon, 17 Jun 2024 23:04: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=1718665453; cv=fail; b=MbNvhVERhiLPuaRkVGh3c0kHVPMUonll9FUhcxh+lNL7pS+CZTFPPPKzKTFIu9BFJtp92RRHjddKg9JSJlmBON98tE2J6ZBu/38Amyhz6EdVvqlcAd37ZcRcAcSTzBUrsGVCQSXXTnOvpKerbvQvFoq5ABler5ECugKZf1jcp68= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665453; c=relaxed/simple; bh=6YDLqBx+tKqWfK8VvpXaxyKJjGgmNYvyu+607u/sQs8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Nb+6P8HKmZrx/wD7cZ78cEksOo8APMJ9hhTJ4y1YembypazTKSN6MpF3hVoAKRhO6v1FNDfXWglYhG9Z+sz3lInl5rxpV3urkmOhmYORO0PdXtWghaKMxCCyGEDmjFiwPdyuHz5e8N113D7M56Yaf/i/TP0zz9NI0UL9JpPL1ZA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=Q0NslNs8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=czIw8qZ6; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="Q0NslNs8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="czIw8qZ6" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXTbq010519; Mon, 17 Jun 2024 23:04: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=TMBZenXHmNrZJ3tRTtEcmvKpcixYc8k0CTDmCY00Ae8=; b= Q0NslNs8w0Fd1XojkVdQ58CqsHRshNQLPro+AkwFm+MATHG8ngqbPrrw6bjMc8af EF9K+7ZWtLiSRqxX31NK13bq68YNxIOns6cuHPeZub6g+zsT4jOzjf+YspaQZwvr R/JvKtvl9FGohSXE71Jci8Kmxbo+LxuXHvNo+WHDXf+EbLKZDhsdhDh65CDxBg5l /nE+mxUVwMC8TpLJytyY91VFFSS9lwiFskAm62EjTOeoZ3okjPV+1iey4fzKWfFq RapyAtJ1X+Pj9C2PRSylu7Qh7Yc+VjENPQigoKUfxV7rI7bJ+nDM+d88biluo4Rd rIGWsveIXELFFSgYVQZBcw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys2u8kpyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:11 +0000 (GMT) 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 45HL4G4I032868; Mon, 17 Jun 2024 23:04:10 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d73k30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U5tIG2zrmTfMhidPmgby0Kxr7QnxQA8RgXZkqqfUz2D6h9F5Qqy3H17Etz52td/7HgwMdg3DqSimWjPr5eERmrziR+di7eFQ/O0lTV8G+nj3/5A4FGV26NxafKDzrOB+YEamAxS8wP18Vvd1pHN3j/3Tp2d1M3u1nAm58qjiO/Pt1qhsDTifgB6iaGzLeW8VIuKkF7ZRFHLjDMnL6XdnwyKtOnuy6utWw/Xext1RXzHzsAjWA/w3SsspxLuHn/MIzePQ8nGMcgPgAE1y1I72nV1GxNgn41+QZkLKijURmJxWmr9YgpT1E6g57wFXdT+U82yNi/a6d2uTfTpD1JoFIw== 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=TMBZenXHmNrZJ3tRTtEcmvKpcixYc8k0CTDmCY00Ae8=; b=mIipxdcpo9j238CKOdVPzOyTi1YZj2tUwJ+/qcZrHmmFabialtNzOYfUFcPTNC+O0DAUvkw5vhe3/GTN7f8hsLinCLOZoLOjpJjOI82TRbH3hEdoquOpvmpUuXUZq8VSZQGleqJLE+83mgtTAC0BRsoZ7h4C28PKVzIAVE0Fx+R+MPbjqv7kQM76RlEUnRVzErvRleqFZYzllHkyg5hY9NXVvUii6SekL1iDhtuLOq5zHpfG9vaPtaVqvSx//Qhe1TlH0RWj4xhXjFX+tXXZ7aai5TQ3LnJ7+FteEaB/u6WQJXiR2MiZh4CsU7MuouvmFoWRhSpOT2OXzHXnw9E73A== 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=TMBZenXHmNrZJ3tRTtEcmvKpcixYc8k0CTDmCY00Ae8=; b=czIw8qZ6UuzySdKIc+9Bl8ppyBwYCegEeeTWUu1OKt5+GhcQRgvM0SKJ4RFLLjQwxRR5zJWR+VWILbLyuLwkntwCDt18/HBctvGpAB7ACzQCoS3cbWwO5kweI9PlInAKBIAkBFAlKpJrgwjHqx6dQetGEt0tvGaZkmYzivZLDuA= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:07 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:07 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 5/8] xfs: ensure submit buffers on LSN boundaries in error handlers Date: Mon, 17 Jun 2024 16:03:52 -0700 Message-Id: <20240617230355.77091-6-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0336.namprd03.prod.outlook.com (2603:10b6:a03:39c::11) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 156f35b7-06f7-43db-6036-08dc8f21cabb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: zLhuL//vxcItJvf1DMtCQRC1NvEmx9HSf1Lp2vCdAUEKN4t32IWxf2kdcTIFVB5LXw3G76pPtRMrfLWA5awkDwVsmy8Nlnv/Zk40R6pAnBrytaJtjQGKv8wMTQmEti0CbVQRfbENVwVdbVnCKkiuZ8AJCoeuH9aigEe3yGxlv3sYkpJcjrRNrODo6dYd+Eh2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vzvEihKDJxdkAquKcSqotkmLVxiBPxE5wwovn4pPeyw8yknrNqgCRw0g3tWXFc7sF2S68RQQrMB98 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nm/LSiZEyGY7OKH1yTbcMByOuydSSi522UC/HsiMhgivfUknoXt98NqJpWFXpHiPv67vwNRNC1qiQI/arz1EBPWDWxrSqZkMUaTRm0GxVdZxmRq90CVdNE4gump/GtlyNrSpTctA/zd69SUT+5Bc2N/q2WS2mYYz3VJvGfF0RdiRfm0Mq0mnRsV6O0j8LshNLjrrsPCRTO6Ad02eDvjHsXxcKT/tyS/t+tMcPXj0xdiF0HMj8eo2PQA+QXn7A8vEC1qw98qkgbaeJMVPU5ud9gUU4NuvLIe2R2Rp7M0B2a61Y0gPRp0Us2MBowJM5LtjhCoTT19+qaxMXfYiOSyVLBKoHu3DQuHu8iwIKdRupTVuy5FR4dxlS+QENh0+MhYtibVVdEHz06HdMAf4S9mcHketRUdcR7IaNsNDi9pwgYVjPqF+6lwK/cNuIZwPxSgnyGjJGiPEpVAhcYdcwx53OQKIrLRAQvaXEAfMfSUD4XeVfJjlSDmvdgAs+rY9sVUJ8K6phtXAPNMHpVYaLzeNs4Pa8dqXUW1iZz0/u5PIq5ULFu9KNTeMpSZFDsImoiOQAnPssDisqfIvw4sZZZk2KLgg2KJm+GanU+hOBXsNX8QI+c1EHTbpk6XIodxZiSD4bjh0/c06N+0vd0+1Opk/EE3R5MiDleILlYFS0RBBd8cnaWxJHd7coDs9PHoRk4KRAFXlGTSvqujUQTp+BQJXJ1x0CGZlp0MtFRash+9vKwMsxyK3icz+bowhI+PIhcq0idKo4YhHgAnNQ382Yq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DwGAwmSirDVW83/p6ythK/HW4ays5OIGhkBqU7nFlkqTQ8dAlHhuNkNP0U0Gdc5StHdK+k8UlokYGdEheKr3x/uJsuGa8Wr40Ovu0/d6STJTKc19dgf1Jkd0c/m/xrR1Zo/CCtItU8Nzul/W8wEzROh9uAYB4ADal6LCuTCohhVBEUkoc+5go/M+vwXEUrFZM8xOG11YGdggdVjn7X8JrC/O6cULDGOak0TnWLQp7/AH4kr0LkgJdbKEiWzskbRniMAdcbySZLgsxCFYwyS1HYIflxiiL7ZkjD6sWn0IEeb6rc6xJN1M/pj8UoZ1b14ufikGpzRl8bT4nVfKiUQZ04bT0XB2Iv0qkr1Kmua/ZRnFcojNAltqi7r7yItTsWLI/thyACUcxmYggSFsrX9hTmAovJsgz16gkIjNFFB5OSmg1AMAubW3/n/eqS9R+XDx4icl14IKiyEerRqEgkwNqbI2zEM21a594uD/smHJgi3H54QJfZV1EJGvQ1rvbrTwzMjcj0nw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 156f35b7-06f7-43db-6036-08dc8f21cabb X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:07.8988 (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: Pna6w+mXiwsD8bpdOHvNOVGvHc68Jrw/ujnkTCvYiG3S6oQcPVuZJf6MZyhiH59T0nI8PXIjF7l81sA0sC1w/H/Sw0crYBWVak4M2bd9YNk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-GUID: mtc4inRGYYEaeaky6qIUquEzij5ctPCH X-Proofpoint-ORIG-GUID: mtc4inRGYYEaeaky6qIUquEzij5ctPCH From: Long Li commit e4c3b72a6ea93ed9c1815c74312eee9305638852 upstream. While performing the IO fault injection test, I caught the following data corruption report: XFS (dm-0): Internal error ltbno + ltlen > bno at line 1957 of file fs/xfs/libxfs/xfs_alloc.c. Caller xfs_free_ag_extent+0x79c/0x1130 CPU: 3 PID: 33 Comm: kworker/3:0 Not tainted 6.5.0-rc7-next-20230825-00001-g7f8666926889 #214 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014 Workqueue: xfs-inodegc/dm-0 xfs_inodegc_worker Call Trace: dump_stack_lvl+0x50/0x70 xfs_corruption_error+0x134/0x150 xfs_free_ag_extent+0x7d3/0x1130 __xfs_free_extent+0x201/0x3c0 xfs_trans_free_extent+0x29b/0xa10 xfs_extent_free_finish_item+0x2a/0xb0 xfs_defer_finish_noroll+0x8d1/0x1b40 xfs_defer_finish+0x21/0x200 xfs_itruncate_extents_flags+0x1cb/0x650 xfs_free_eofblocks+0x18f/0x250 xfs_inactive+0x485/0x570 xfs_inodegc_worker+0x207/0x530 process_scheduled_works+0x24a/0xe10 worker_thread+0x5ac/0xc60 kthread+0x2cd/0x3c0 ret_from_fork+0x4a/0x80 ret_from_fork_asm+0x11/0x20 XFS (dm-0): Corruption detected. Unmount and run xfs_repair After analyzing the disk image, it was found that the corruption was triggered by the fact that extent was recorded in both inode datafork and AGF btree blocks. After a long time of reproduction and analysis, we found that the reason of free sapce btree corruption was that the AGF btree was not recovered correctly. Consider the following situation, Checkpoint A and Checkpoint B are in the same record and share the same start LSN1, buf items of same object (AGF btree block) is included in both Checkpoint A and Checkpoint B. If the buf item in Checkpoint A has been recovered and updates metadata LSN permanently, then the buf item in Checkpoint B cannot be recovered, because log recovery skips items with a metadata LSN >= the current LSN of the recovery item. If there is still an inode item in Checkpoint B that records the Extent X, the Extent X will be recorded in both inode datafork and AGF btree block after Checkpoint B is recovered. Such transaction can be seen when allocing enxtent for inode bmap, it record both the addition of extent to the inode extent list and the removing extent from the AGF. |------------Record (LSN1)------------------|---Record (LSN2)---| |-------Checkpoint A----------|----------Checkpoint B-----------| | Buf Item(Extent X) | Buf Item / Inode item(Extent X) | | Extent X is freed | Extent X is allocated | After commit 12818d24db8a ("xfs: rework log recovery to submit buffers on LSN boundaries") was introduced, we submit buffers on lsn boundaries during log recovery. The above problem can be avoided under normal paths, but it's not guaranteed under abnormal paths. Consider the following process, if an error was encountered after recover buf item in Checkpoint A and before recover buf item in Checkpoint B, buffers that have been added to the buffer_list will still be submitted, this violates the submits rule on lsn boundaries. So buf item in Checkpoint B cannot be recovered on the next mount due to current lsn of transaction equal to metadata lsn on disk. The detailed process of the problem is as follows. First Mount: xlog_do_recovery_pass error = xlog_recover_process xlog_recover_process_data xlog_recover_process_ophdr xlog_recovery_process_trans ... /* recover buf item in Checkpoint A */ xlog_recover_buf_commit_pass2 xlog_recover_do_reg_buffer /* add buffer of agf btree block to buffer_list */ xfs_buf_delwri_queue(bp, buffer_list) ... ==> Encounter read IO error and return /* submit buffers regardless of error */ if (!list_empty(&buffer_list)) xfs_buf_delwri_submit(&buffer_list); Second Mount: xlog_do_recovery_pass error = xlog_recover_process xlog_recover_process_data xlog_recover_process_ophdr xlog_recovery_process_trans ... /* recover buf item in Checkpoint B */ xlog_recover_buf_commit_pass2 /* buffer of agf btree block wouldn't added to buffer_list due to lsn equal to current_lsn */ if (XFS_LSN_CMP(lsn, current_lsn) >= 0) goto out_release In order to make sure that submits buffers on lsn boundaries in the abnormal paths, we need to check error status before submit buffers that have been added from the last record processed. If error status exist, buffers in the bufffer_list should not be writen to disk. Canceling the buffers in the buffer_list directly isn't correct, unlike any other place where write list was canceled, these buffers has been initialized by xfs_buf_item_init() during recovery and held by buf item, buf items will not be released in xfs_buf_delwri_cancel(), it's not easy to solve. If the filesystem has been shut down, then delwri list submission will error out all buffers on the list via IO submission/completion and do all the correct cleanup automatically. So shutting down the filesystem could prevents buffers in the bufffer_list from being written to disk. Fixes: 50d5c8d8e938 ("xfs: check LSN ordering for v5 superblocks during recovery") Signed-off-by: Long Li Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_log_recover.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index cc14cd1c2282..57f366c3d355 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3203,11 +3203,28 @@ xlog_do_recovery_pass( kmem_free(hbp); /* - * Submit buffers that have been added from the last record processed, - * regardless of error status. + * Submit buffers that have been dirtied by the last record recovered. */ - if (!list_empty(&buffer_list)) + if (!list_empty(&buffer_list)) { + if (error) { + /* + * If there has been an item recovery error then we + * cannot allow partial checkpoint writeback to + * occur. We might have multiple checkpoints with the + * same start LSN in this buffer list, and partial + * writeback of a checkpoint in this situation can + * prevent future recovery of all the changes in the + * checkpoints at this start LSN. + * + * Note: Shutting down the filesystem will result in the + * delwri submission marking all the buffers stale, + * completing them and cleaning up _XBF_LOGRECOVERY + * state without doing any IO. + */ + xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); + } error2 = xfs_buf_delwri_submit(&buffer_list); + } if (error && first_bad) *first_bad = rhead_blk; From patchwork Mon Jun 17 23:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701538 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38A02196455; Mon, 17 Jun 2024 23:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665456; cv=fail; b=VYlx+f7WVucreZqLFvvRfz32ghriXV6QV2hL9rIv1DxfmC4Rci8XjYVDpasqF57uQ5N2FmDGTWXc/31LTVfIrmUnqjkg/CBxVbaq3jtsJ2PMvwSOuZwIMEniewsfIZNhJdO5BOpGQNZfdhvjQz6DUknAdhASH0Vdi9UPs4JYt2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665456; c=relaxed/simple; bh=nDC3bUj+Mt8NJRilcPLi4FbhySkxOLKWNI5go5LklVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=fyLpPCdrAlGXti7lfxGCHvfuaLvYpLjLlr4AEe9t5JEJgOmIyG4ugwLzxupTLtIvKBlU3qgZfXxVZr1HHCIL11WM8HuqkrY9rcolTHigLZkrNHTYLRs+dEsjjfwgLewDHfH8dXorfEErdX1PsMY1pCLOF9h9unw5Yy27HcAARTQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=dTEsawd7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=pEgZfCs0; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="dTEsawd7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="pEgZfCs0" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXX2h023622; Mon, 17 Jun 2024 23:04:13 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=xRbeq7bNG51EHGx5h3o5Ighc2Is5rR4P6AlM/mnylWU=; b= dTEsawd7HCfk5jSxiGpg6NPdA2/iiGOSTXEuF9zxS0dy3dpqDzHrEBj4jItZMA4e v6kK0NhFAN5LXJzzeD6ZbgPd3lUicTrtf/GvDo8BBYdLcuM1AIDiI+dMtDm59rVq j6NtvkI9PteR/X9gpjnQdwQh8Ou87T7PaZ/GEZlOqbpaFA+QIlQLp5hkHXpKKqNz Wt9UgvrDl9r66/Q6h7/tcCFK5E1Hmuj5VORk2cQIdduX4N6QWAlJLgtkOeC8pYcz zeiDEWVLHT9FPCa7+qJh/9b/MQyEv0QguU/wsLUjaNXL+AaSjN5qcg69xr4Rmifl 0vA+dTqWhXe8YcbzMbsvnA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys1cc3sb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:12 +0000 (GMT) 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 45HMXQMN032918; Mon, 17 Jun 2024 23:04:11 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d73k3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WGUGgCsHYk8jZS/lJOJauxgr7nxpkorPuTdRqbxUIp9mHdCIJ72bJzNV1hI1egvfqYHbpvvZUWgjLnF56sxIYVRaobgmApRTpaIgdAjfqVVcVfprptECpsXV4aGeQpxqQgP+sjmuo25pj0euzG2pGObtwiSqRQEJ6xA+h3dsW6EeLb5FMgV38SkfePA92miXxv24j5VUSkWLtz6nPqhhqvYEbqUYHy55/Q+DdcR87Praf30Zd09+wVd9QeahZaaaQ4WjGvjUuvCdJ+VZ1d6oxmyBziO+mbXT1Ulds4921FLw0RBuVGx8DaftkTA9TWC5fg41YRodlloZq2x1wpgYbA== 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=xRbeq7bNG51EHGx5h3o5Ighc2Is5rR4P6AlM/mnylWU=; b=Kq7fiVyCL6nrdVXcO42V7xiSZhfrMItb2QULsR8m3diVoZ7F+lnfydnjH0L44sUiniu4C4GKJsmdbyDSMBBRFwai1g2kuGVNSreyIg5wBr/GqM8HnMGhGyHDPFxnJmEP1u9Fx9F41KqPqHL16VNRIYR75d+8R14uACktp9HLMpnGPoGVfYpCGM9jTVX7ANHz1OTnltMLz+CB/4aPwYWw1sKznNPi3gqQfxIilZeD1EgD78r7iaurNA9/a9zHvsf0PAI6oBHqK4Hm+ndfzhRwKZqDuZKVuSCn3E4JYxT7n643Jlg1/WFVNuYQiGgDtOFoqIfmc9lHf6uwG9XK6pD1OA== 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=xRbeq7bNG51EHGx5h3o5Ighc2Is5rR4P6AlM/mnylWU=; b=pEgZfCs0Qjms8hsTvyHWgYBAwSIo42TxcqU/OiM9bHkFkdEBjNk/PSLIxlEBVaFR3A4A+8aVuqh2+fw5HfV1C1PivPT33RhDQvmLB6Hx83/53LOgjh2pTQkCQq2D4bve0ZdXgiJOGSFMIN6tODY74g1Ahtxw//Oj8XWPJJeoVtc= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:09 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:09 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 6/8] xfs: allow sunit mount option to repair bad primary sb stripe values Date: Mon, 17 Jun 2024 16:03:53 -0700 Message-Id: <20240617230355.77091-7-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0355.namprd03.prod.outlook.com (2603:10b6:a03:39c::30) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 72cc1d04-9299-49c6-1902-08dc8f21cbc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: mcqJkIq9AwKNmUAem/0SwqRQaSaQrB0odMPC0+ciY2t2S7VIdzNtLWZk6FCV9wCnQ1iQjyAKy1AkXUt9khLvN0w5ZfKHKpjcLXX38WGkXaHGhVjV23i3AKpk4W4cL+kuB3Dp+Am9cP7xff5OmRjABzW2LSM9aJ9A8k9VI0kNHUmqkxxp0Hcv4oRJ/Avz5jQlDXiXSsAL5gAJhUAlqW3W1wAveQddeezPAceDQqzuZ2vEO3oyg3IJcrSEVamz4NRlb7xunvCfFVEu2VbJb77li0B/cfNMRfCSWbjjFFsNZOMfOSOOhd8qY4Im+T3fQu+YJIZOTthPELIHuGPYW/Tjal+uuLOXCkkRFElVRFPkBZ9PX2vs5HrfUwikekQbt01OU8Kqe4yN9GQA00n9+BlGkpgC7ZJzAUyrl6ZKB/mwEOSbZgQRkw5q1EGMMWkiZ83OQwJa4buIgJe+L1QVD1lZzGbut6NBDa73gIV3Lw3Vf6pMw5EG/YXPUPKsdfNQapJrG2XIoNzeLzexn4unQWeRvBMPKS9XqaTDTeDzY9mafcA3gyM5Ax/EezT58wRYsLG3wk+SdqkKaAO7FlA7cc8/1hlEnIG7ePTAiP5lssmSHQ/0Bgkc4/FI5NscA/CifmT8qakhAuc+E9proXfUA9tOU0NtLhxREyu4oTSIQ+uYdpTr53QdEtgakOf0vSJ6QCDZLLPwLd23GvRj8Kbs2nE0PYyMRVnq7LHAX07JVtgK7kY6HDuwpQuxCUR2mLxISten/ffJvoSknaiZ0H+OCFhIrwo0v8oM2o7Zfz/TP7iaeiIhQ4GNjD1vAs8FS6lRiRLuPl4NMDzmdMh2UqBNe6Dd2pt8+NE13h/SSfew5jmdJlZJupGYeDMsbxirf+1Nd0HJbtLsIKL+l5MK5BDo+6zSZU79rzZTUkKW96ayqJ24FZ7PykoZDPRmoU2eXzJT5XyiMbDXJKTw2O9TfOvN/iRfQOH/yf03REaW/R9LiCgzxhy+YhFaDuoEKcnQO7msTdtVchSee0rSJEkH0bxh3ENahzgfxsdbHKQCmwtF7y6Lo71dBNm2+d2Q6dn3It4deVbAhDIx2MwTD9vNpCpXeZJEL+1p9G8IIW9L6LDhw1CL5q/bmDFVy5KapHvvRKgncBW0U4kZL4bJy/f50yYARnXiKf4DKgOJlejTD6hXQbzzc0zKEYtxA/MlAHOj2d5E311S0iDiu9TukgF6Ducw/jTvDbceSlXATUW2Y6ARSzjBghlCe8B7NOGTVs5B0TNG9qnvnjeIA5m46d/BMnwZNjdOtV/FAeuw1j3I+zAtC7nAeJ53JOFGS1ffEMRQtT+XLnKL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k1xljW7Xoh4JcsM6gaaJfWec4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W3/gE5cpuNxvfc5nHQj5bsCeaKXS3EqxRLTNDAq2C0yPtK4GLF1ZHVQ7ZTmTBasujnDngL7L279iCyCXccdwZRLvwO1xORnCdJfDlyRWwuHX4rWzaH4585IjsuzkAUPjf/1LmBhaC4GVb/wGrf50XnQGi/XmGkm4dIolhkDJKlZrOI135OSGdNiQsmPWhBkkaicYZL3ZhDcnKWoAcl0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72cc1d04-9299-49c6-1902-08dc8f21cbc8 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:09.6777 (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: 3qFgMiGpS6vBE2uZWAhcKbQJuYraz+k29xTT5A6UnuR0aYNP+PlPfKAOvNTxEpCZJxbrMA6B9x6qnLe4UuG75tqbjyZLPQrs0o++4Y/rk4g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-ORIG-GUID: 60hzcz7qFKTRMtuNdVP_bn0_kHTeuw7s X-Proofpoint-GUID: 60hzcz7qFKTRMtuNdVP_bn0_kHTeuw7s From: Dave Chinner commit 15922f5dbf51dad334cde888ce6835d377678dc9 upstream. If a filesystem has a busted stripe alignment configuration on disk (e.g. because broken RAID firmware told mkfs that swidth was smaller than sunit), then the filesystem will refuse to mount due to the stripe validation failing. This failure is triggering during distro upgrades from old kernels lacking this check to newer kernels with this check, and currently the only way to fix it is with offline xfs_db surgery. This runtime validity checking occurs when we read the superblock for the first time and causes the mount to fail immediately. This prevents the rewrite of stripe unit/width via mount options that occurs later in the mount process. Hence there is no way to recover this situation without resorting to offline xfs_db rewrite of the values. However, we parse the mount options long before we read the superblock, and we know if the mount has been asked to re-write the stripe alignment configuration when we are reading the superblock and verifying it for the first time. Hence we can conditionally ignore stripe verification failures if the mount options specified will correct the issue. We validate that the new stripe unit/width are valid before we overwrite the superblock values, so we can ignore the invalid config at verification and fail the mount later if the new values are not valid. This, at least, gives users the chance of correcting the issue after a kernel upgrade without having to resort to xfs-db hacks. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_sb.c | 40 +++++++++++++++++++++++++++++++--------- fs/xfs/libxfs/xfs_sb.h | 5 +++-- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 571bb2a770ac..59c4804e4d79 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -530,7 +530,8 @@ xfs_validate_sb_common( } if (!xfs_validate_stripe_geometry(mp, XFS_FSB_TO_B(mp, sbp->sb_unit), - XFS_FSB_TO_B(mp, sbp->sb_width), 0, false)) + XFS_FSB_TO_B(mp, sbp->sb_width), 0, + xfs_buf_daddr(bp) == XFS_SB_DADDR, false)) return -EFSCORRUPTED; /* @@ -1319,8 +1320,10 @@ xfs_sb_get_secondary( } /* - * sunit, swidth, sectorsize(optional with 0) should be all in bytes, - * so users won't be confused by values in error messages. + * sunit, swidth, sectorsize(optional with 0) should be all in bytes, so users + * won't be confused by values in error messages. This function returns false + * if the stripe geometry is invalid and the caller is unable to repair the + * stripe configuration later in the mount process. */ bool xfs_validate_stripe_geometry( @@ -1328,20 +1331,21 @@ xfs_validate_stripe_geometry( __s64 sunit, __s64 swidth, int sectorsize, + bool may_repair, bool silent) { if (swidth > INT_MAX) { if (!silent) xfs_notice(mp, "stripe width (%lld) is too large", swidth); - return false; + goto check_override; } if (sunit > swidth) { if (!silent) xfs_notice(mp, "stripe unit (%lld) is larger than the stripe width (%lld)", sunit, swidth); - return false; + goto check_override; } if (sectorsize && (int)sunit % sectorsize) { @@ -1349,21 +1353,21 @@ xfs_validate_stripe_geometry( xfs_notice(mp, "stripe unit (%lld) must be a multiple of the sector size (%d)", sunit, sectorsize); - return false; + goto check_override; } if (sunit && !swidth) { if (!silent) xfs_notice(mp, "invalid stripe unit (%lld) and stripe width of 0", sunit); - return false; + goto check_override; } if (!sunit && swidth) { if (!silent) xfs_notice(mp, "invalid stripe width (%lld) and stripe unit of 0", swidth); - return false; + goto check_override; } if (sunit && (int)swidth % (int)sunit) { @@ -1371,9 +1375,27 @@ xfs_validate_stripe_geometry( xfs_notice(mp, "stripe width (%lld) must be a multiple of the stripe unit (%lld)", swidth, sunit); - return false; + goto check_override; } return true; + +check_override: + if (!may_repair) + return false; + /* + * During mount, mp->m_dalign will not be set unless the sunit mount + * option was set. If it was set, ignore the bad stripe alignment values + * and allow the validation and overwrite later in the mount process to + * attempt to overwrite the bad stripe alignment values with the values + * supplied by mount options. + */ + if (!mp->m_dalign) + return false; + if (!silent) + xfs_notice(mp, +"Will try to correct with specified mount options sunit (%d) and swidth (%d)", + BBTOB(mp->m_dalign), BBTOB(mp->m_swidth)); + return true; } /* diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 2e8e8d63d4eb..37b1ed1bc209 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h @@ -35,8 +35,9 @@ extern int xfs_sb_get_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); -extern bool xfs_validate_stripe_geometry(struct xfs_mount *mp, - __s64 sunit, __s64 swidth, int sectorsize, bool silent); +bool xfs_validate_stripe_geometry(struct xfs_mount *mp, + __s64 sunit, __s64 swidth, int sectorsize, bool may_repair, + bool silent); uint8_t xfs_compute_rextslog(xfs_rtbxlen_t rtextents); From patchwork Mon Jun 17 23:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701539 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 616141991BD; Mon, 17 Jun 2024 23:04: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=1718665457; cv=fail; b=LJKnaW50aOlPtba/FMNN/FKZqFotiDMj/J9clj/7REyeIAhnZ6uUYgQgi04l2JV96HAkw0tjqeJyImnp4XNAUy8xHvmn6X74CSyBKD8EVbzwew3CRuqQA0QcNjl9/kCw54bAuQP6F0mzxqUqSi6gg1MCjGhSFZgHy9r5Ih/CUFk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665457; c=relaxed/simple; bh=GZ7fsWG6av+uKO2BXDoLA0ldlQJRIGNTttAv98c/OSQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=G9zU9JEUk8w8mnr1GNeXbw9Q44ns01iUitlcRXsPvftuiWCJnLP0ur6mBpCmSKZ6dpozBVVicLkSOemfAuDlTDoGR6xiw3g+wSI9yHO/43jnzi8w4eD+OAhzkU+FQZB99RsNsDuzrjiZ3LHi4Ipv/K+k/Zd0xup5NHkBOvNzIaI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=cWeBOI5X; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ga9Vi2PS; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="cWeBOI5X"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ga9Vi2PS" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXaJ0029899; Mon, 17 Jun 2024 23:04:14 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=gVypnTaKZJvWNwjsx/5K+y25AldJzdJ/pSaWSiwvAhQ=; b= cWeBOI5X2P7uvfFJosP4WariuSVu8vYqTGAwYtmu8LMYu7ovHinY4xZil9L2LCkm 3IdKPbqqd9C6POkmgyden5PY4ili7Wf0FplGndGLXtcbDfwbx+ET76YeHG3mk4b9 R71zHCFEj4+PQqEJ06jW6WFhA6gaqWS1GoaHFfGQ+rPO6utnO3koh4s838bA8ksa Hl+2SytkvKP6S+ECfSfSTRePwupaHuDI2bDlQoyS1HF8CvgELjQqT2sYuw0hz3BV SG3KBM7Jj3eL2fs0WjJloE5pSp7vEQ1dxY1/BcHRJAAjIcY7WtMs2RYxXJuymjKQ ccfsFjrpF5ETZakeUUfMJQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys1vebt9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:14 +0000 (GMT) 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 45HLO1li034800; Mon, 17 Jun 2024 23:04:13 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1d7bfjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CORrY8aOA/oOjipJpdkc5L/JRdEqWIsUniGN+xyKUG/8fPoV7HiyLEbYXzfEcjWy3RaDnBICvVDJD1BC0X33HZhECzYE70YuBsxYPJZWhRYu4egXESU90gthJBMfhdO1iZaERqjUH1Gz4FOSeDVsYt71rQxlhtlUuVVc6XwvqEdCcQVSr2MwSNt5bi5zdMVYfGn/D3ZnwWc/pQ+yEWml2VonWZ3eqXDi8j0gP+fKIJKVwlmGzjWeynx3ts3DwYwR545WqLdO9S5rcdzhPjQ2PLPefLzJ3TNJ3Q39edPrBhO1eO3/hIez5wL7oCp7/zaGDpylIvvATYwA+DA+1/bnzg== 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=gVypnTaKZJvWNwjsx/5K+y25AldJzdJ/pSaWSiwvAhQ=; b=ZqsWvyVxU+3G6f/9QaJbWYIuZvUg1e+ycgjmM6vI6wNNKjqU3lYVA+6BSE0gGkBhY6LXApCJzpAdJEPmuZ1cdLBxQCFl9jL9AfNpWAo8AUnc/g/Es1OxMoebN6AI91xnnzl2/RQ7q3DiMijANRjgsYI/uOMCL2Bx4ZGavMpwc8GFrvrlo67SQDmvNXTHmdsXISPpiko16XO24XBwRMMZ8jEyZXTEs1kHIfw7BxC0R3FhIYFZ/VbxvSXIKeV19l8Z9V1Egel0orUpeJ6HJE4vzzIHvHZOy8ttwvu9JTA0G995eWEfcrX8Jv+2ncNwPvxLoVoIPSXY4VF8brrsomunTw== 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=gVypnTaKZJvWNwjsx/5K+y25AldJzdJ/pSaWSiwvAhQ=; b=ga9Vi2PSJk3IWw8JIgVc/7cbuP9yE3UEXtvP7af8KaLo+EuRE/8wRIjknxN50G9uxxXNjw7S05F7YNbyXyvNzPc12H+UOzLqW0Tw4LZKAijvzRSHBxPX5Ubb5THbXn1EOMLMg5OZjp971LpYQpNDo21tY3BWk/1Z7u4OJYRah7A= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:11 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:11 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 7/8] xfs: don't use current->journal_info Date: Mon, 17 Jun 2024 16:03:54 -0700 Message-Id: <20240617230355.77091-8-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR03CA0348.namprd03.prod.outlook.com (2603:10b6:a03:39c::23) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 6405d972-4272-426f-99e7-08dc8f21ccbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: j5qNj5BltlzqA642/U80eFZEnZuyHhAnEd5AyC8mEElf7p9V8wX95qntFc7x9XHRJZkR88zMlwIPbO9jJ4HatrIdPSs2zw1iPPSGS8OJhL+PQbgtqitoDb3LYUctu5Nx7nM8N4sCMf4MsxAphkHBR6npmJKt+0e/vU1WJKD3Ki2H3qx8Dw5/yfFXq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x4ldKWEaOEe/ICsN46Jab4yU0Eh2D/mQXgRIQznkrfDI167dBz73HmfQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aJ5Kj51BlwVdf5eF2QzRG6cXVFkvSA1x+/8GSrfKgTysxzEv3U4Lcg0+HAODmEBms2y/ml7hGSDOpnK2heAjeDBrZj6itoYgRxuyZzlmz2XMYOZKPV6IzVL8DkWntWsjEsL8K5fOWaU6fFWQxnvDF1iep+HK+2Ux+pgFjuqYf6NN0qHYijUjoNPhDcEkAgxusq+ImC5/be7bz/kwdMWMdsxSep+k+TnYHsP7BGsAOV3PQkABUn1hwWJu1KgogHPBX343JgNN75eyN0CuDHM+TGZ04aakqeYWj1OjyZrIubIx6Hmr4GGwOWGaApfESW6CzKkU0ab2HG0g0gK72pYE30SfCWCxmqu9VnIlOBsRh6UMJYgaGqbL+l6liwIfApH1BZWqYhrUVrupLtZvsha/KycspepAOJXKLo9sCzFt+c4QTTCO2l/4JzAkl+vIzwpvnH7KCZXr0k3U2DypaUJS2oJOAeG34anR+MUcsOV3uctGLsqFH9X0D+rAN6J+2ZwlKf7My7hIsVhXoB5NwUCsWqyI3quSmh88xg309Biuhn/Ouqd7HjnMCKuQ/esiFkBx9vlbyvtdv3eRpAzyDgrglH+MXCWJ18Xue6txhAE6HVmRQXupDxoB9CAbiukqQaD5I9zOclRCb89E4syYFZNPCF+Hdd5eUL5+NMyoaEi/FwPyKVLEidnhhKrgK7yEI0R7tJyhcO+Lprc0H41KWNVnT/YRhcipblvX6YjTxzcYgc3JMamj7vKW3gTh8YnbdtLfPjaq4ZEyvI4khE3KT7bfBzWRy0jqR+ENCScdsKQB7JHtH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URPFXTOxNp79CksHgvwAOiIJag0IaQ27Dn6ODIYbQh2dAmI+62WvfaF/AiRMO5mHfdd1J/SUc++id1a/XtZMPRMftKqg63Czd8yjPzZKWDcWil7Ggu/8aB7hc/p4thfo8DCG98vb+IMzdQPoA5TYQBjER0+Mxl/6C66DKMJBT2MZtCDGt4m8qSESSP+VtefW0swyahy/bHz/7yLklRWta4N42OxEl/J1YIbZKE/r+wWwbVd10GK8dMJucUzutHVwm7/FjvWyx/JeKC9ytlQFoetf78J2l1dsl7cVWQBTvVa8HKM6oJ9ng/HfQcrlAEadEZrLwjiDnKDeunKz7AhOo52oHEAcxPW/rP/sSx6NEnXfOHk4C+9Ok1tJBq0Gntb42cRNrB3pNOvpJFp7NxIRGT8E6qHyr0bdIKUSQbtQW1QISWQ1XAy0+/ta+iq6PKNv9edPLW3H5pvZGsY3k+KVhedSzn1+AQF+QZbmjMkhz4Z8m7wMuk6h5e5DnG8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6405d972-4272-426f-99e7-08dc8f21ccbc X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:11.2834 (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: XNcP6w5ixmyEsDhDc5fg7ju4JFMB6/2p92SyBVKQId/m3DqCHGoTjBgJXbmQ1IGV1bcBtfCGgQhe9QuRQSOlCntfP/LtdnOlIYSL/5nVe1g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-ORIG-GUID: QkUDpUMFNNeKJaPe70Hn02a7A4hnd5aB X-Proofpoint-GUID: QkUDpUMFNNeKJaPe70Hn02a7A4hnd5aB From: Dave Chinner commit f2e812c1522dab847912309b00abcc762dd696da upstream. syzbot reported an ext4 panic during a page fault where found a journal handle when it didn't expect to find one. The structure it tripped over had a value of 'TRAN' in the first entry in the structure, and that indicates it tripped over a struct xfs_trans instead of a jbd2 handle. The reason for this is that the page fault was taken during a copy-out to a user buffer from an xfs bulkstat operation. XFS uses an "empty" transaction context for bulkstat to do automated metadata buffer cleanup, and so the transaction context is valid across the copyout of the bulkstat info into the user buffer. We are using empty transaction contexts like this in XFS to reduce the risk of failing to release objects we reference during the operation, especially during error handling. Hence we really need to ensure that we can take page faults from these contexts without leaving landmines for the code processing the page fault to trip over. However, this same behaviour could happen from any other filesystem that triggers a page fault or any other exception that is handled on-stack from within a task context that has current->journal_info set. Having a page fault from some other filesystem bounce into XFS where we have to run a transaction isn't a bug at all, but the usage of current->journal_info means that this could result corruption of the outer task's journal_info structure. The problem is purely that we now have two different contexts that now think they own current->journal_info. IOWs, no filesystem can allow page faults or on-stack exceptions while current->journal_info is set by the filesystem because the exception processing might use current->journal_info itself. If we end up with nested XFS transactions whilst holding an empty transaction, then it isn't an issue as the outer transaction does not hold a log reservation. If we ignore the current->journal_info usage, then the only problem that might occur is a deadlock if the exception tries to take the same locks the upper context holds. That, however, is not a problem that setting current->journal_info would solve, so it's largely an irrelevant concern here. IOWs, we really only use current->journal_info for a warning check in xfs_vm_writepages() to ensure we aren't doing writeback from a transaction context. Writeback might need to do allocation, so it can need to run transactions itself. Hence it's a debug check to warn us that we've done something silly, and largely it is not all that useful. So let's just remove all the use of current->journal_info in XFS and get rid of all the potential issues from nested contexts where current->journal_info might get misused by another filesystem context. Reported-by: syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com Signed-off-by: Dave Chinner Reviewed-by: "Darrick J. Wong" Reviewed-by: Mark Tinguely Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/common.c | 4 +--- fs/xfs/xfs_aops.c | 7 ------- fs/xfs/xfs_icache.c | 8 +++++--- fs/xfs/xfs_trans.h | 9 +-------- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 23944fcc1a6c..08e292485268 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -978,9 +978,7 @@ xchk_irele( struct xfs_scrub *sc, struct xfs_inode *ip) { - if (current->journal_info != NULL) { - ASSERT(current->journal_info == sc->tp); - + if (sc->tp) { /* * If we are in a transaction, we /cannot/ drop the inode * ourselves, because the VFS will trigger writeback, which diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 465d7630bb21..e74097e58097 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -502,13 +502,6 @@ xfs_vm_writepages( { struct xfs_writepage_ctx wpc = { }; - /* - * Writing back data in a transaction context can result in recursive - * transactions. This is bad, so issue a warning and get out of here. - */ - if (WARN_ON_ONCE(current->journal_info)) - return 0; - xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); return iomap_writepages(mapping, wbc, &wpc.ctx, &xfs_writeback_ops); } diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 3c210ac83713..db88f41c94c6 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -2031,8 +2031,10 @@ xfs_inodegc_want_queue_work( * - Memory shrinkers queued the inactivation worker and it hasn't finished. * - The queue depth exceeds the maximum allowable percpu backlog. * - * Note: If the current thread is running a transaction, we don't ever want to - * wait for other transactions because that could introduce a deadlock. + * Note: If we are in a NOFS context here (e.g. current thread is running a + * transaction) the we don't want to block here as inodegc progress may require + * filesystem resources we hold to make progress and that could result in a + * deadlock. Hence we skip out of here if we are in a scoped NOFS context. */ static inline bool xfs_inodegc_want_flush_work( @@ -2040,7 +2042,7 @@ xfs_inodegc_want_flush_work( unsigned int items, unsigned int shrinker_hits) { - if (current->journal_info) + if (current->flags & PF_MEMALLOC_NOFS) return false; if (shrinker_hits > 0) diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 4e38357237c3..ead65f5f8dc3 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -277,19 +277,14 @@ static inline void xfs_trans_set_context( struct xfs_trans *tp) { - ASSERT(current->journal_info == NULL); tp->t_pflags = memalloc_nofs_save(); - current->journal_info = tp; } static inline void xfs_trans_clear_context( struct xfs_trans *tp) { - if (current->journal_info == tp) { - memalloc_nofs_restore(tp->t_pflags); - current->journal_info = NULL; - } + memalloc_nofs_restore(tp->t_pflags); } static inline void @@ -297,10 +292,8 @@ xfs_trans_switch_context( struct xfs_trans *old_tp, struct xfs_trans *new_tp) { - ASSERT(current->journal_info == old_tp); new_tp->t_pflags = old_tp->t_pflags; old_tp->t_pflags = 0; - current->journal_info = new_tp; } #endif /* __XFS_TRANS_H__ */ From patchwork Mon Jun 17 23:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13701540 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 B0CDB1991BD; Mon, 17 Jun 2024 23:04:17 +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=1718665459; cv=fail; b=scjl1hvTYPW1ec3RF+ObWo8LK8LN4UzXUEmcNSAhWA1sMJ7GCV9AN8fUOZkZz8H7JjOnc44b+m0+v6ilrNUtnUYzaSC59s712eUtkYRjJPxiNHw9iMmFzk/wSLVRDyV+iQxP2yTrzksesFuIcgZPLX50CNhFciwI6RtUqNXZsrE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718665459; c=relaxed/simple; bh=wwfWuopV32vj5By+ntrnscG4kVn1vvGvwbfpHqKUGpQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=CMXSJ7d/Gl4RkdctfZd+fPieDqeAtUx8avFloYQAH8EVEzMXgpAmYPvsFptcj097e9J2+hUs9nypipPAWEK9JUSnjTfPumE+yHmyqZS5weyew2hADF32nw1F9UGTDqhoIY+4JwU9s5tUkkX5VyB1nnzsTYrHlCC21+HFI1v89kk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject 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=jtzwuhdn; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=KWHGtIUr; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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="jtzwuhdn"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="KWHGtIUr" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45HMXiXo030327; Mon, 17 Jun 2024 23:04:17 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=PKXadT6kTHh6j2GcIw7WKn9crtXhXVHDHzzKzWI8krI=; b= jtzwuhdnLT/ykD2hestf49aAdg3f+qOUQlrwK2WPiK4WHR67P3I3GAHAY0KiWn+i vdYoAKHAHtgVgs/Y6/Sr28ddflqfWtVwhjDDzkI5Mc/7dTKyyQylbkY1M/XLNboY 13QldYmjQeMBaOsxHOdUVFCq+9vT/B+TibmksibJuj2FDcB0lFV9q/0ovgPcz/ph JlWXz/hrFCfWMC54JPZKwDWS9EUbUsf3hiZ5lujJjMKg8NE6Pvv8gXh2vaUspCtL znuYST4SCDKPE8BmS9bshCXK32aGVaB11ljdJ+1932ARhB7CmRWirCRn+C6R32Nh rKdBOr8XqE3FE6RKfiSPkQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ys1vebt9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:16 +0000 (GMT) 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 45HMoYkR015557; Mon, 17 Jun 2024 23:04:15 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1ddcc0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2024 23:04:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bLYT+ST1dYhwkn9HoK7sgl3qQwho8Qs4JxbPCJJ/Kvtf1T8iwb3UdkP/d4sc6DObMtW1474ucDVfSCZxgigTYw9GHVd1PZ7WzlmoC75O2HwA/nA+3QWYXk6iX2uhJZ17qQ9VjxvWyl0ELU7nW9eeS+hDp+Ch67L8s71pGYY0INh/QOYWsgn7jkC9N95vqwpmD/QdWKiTT3znAVbQVuXJQu6+ZSwN/O9YRmBoDtzXNOKPumn/m5RkjLld6Hg8Qd/spp23nFnk+ZZQ+E6bNbMuWdNwlg42AXKFh+49nfdux5sI2osWUeglTIj4Tc/VsXboaYOagRPSXmDH0Ldf4cpkzw== 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=PKXadT6kTHh6j2GcIw7WKn9crtXhXVHDHzzKzWI8krI=; b=Ug1teWZbFMWNMViYjwQCgERLucGHyZPv1SwrsMLvFgV7vpCr5un9/BG1jGyq4EFjeDZ2Yyz9teSZrse/QxGziiMs+v/RMMgmG5SMOhzZuNdh53kL9Jg+QAtrqsvOG+kaPkJqH30pE3BzP2PmDpXRBeAnPwkTBpOKjFv49kugMlmSxL2pU3rU9qeI6eQWhomWN+v2wpUIEhNPiSmNguTU+0ihUxhLkkEXFpV8qfXRl/r9fjJTzD8oupoxtEcHaC0CXwx178ooVvKz5/SsV9qqO3WIp/TLpLGPmx/UZ8sgq+5yVPXrCSzT7G5DqAfb1iqTlpYHB2X0jyxowCT16YbpQg== 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=PKXadT6kTHh6j2GcIw7WKn9crtXhXVHDHzzKzWI8krI=; b=KWHGtIUrOwJrBWScrREE4mfX0iBKYpULijrKJqgxA/7ZvBJOn/onUVf8UVRb6Ni4W10eLEw/qamdxQmcVwxCku9kgnYzlQ3RmG+1r9OwLL8QKTA9oopmjv7oGAtu8MvOhmvDCjYHKnYP8y+sP7ADMv4aGoGIx3vXgnjN/COk/Kg= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DS0PR10MB7398.namprd10.prod.outlook.com (2603:10b6:8:135::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 23:04:13 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%5]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 23:04:13 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 8/8] xfs: allow cross-linking special files without project quota Date: Mon, 17 Jun 2024 16:03:55 -0700 Message-Id: <20240617230355.77091-9-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240617230355.77091-1-catherine.hoang@oracle.com> References: <20240617230355.77091-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY5PR03CA0022.namprd03.prod.outlook.com (2603:10b6:a03:1e0::32) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|DS0PR10MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 17318047-9822-4eee-2dc0-08dc8f21ce00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|366013|1800799021|376011; X-Microsoft-Antispam-Message-Info: xUQTM9uaa2K+thFe30E5BneH2YNNFHaOZdxTkRA489bHCyTXzKZbh+ApxX2uuUPQdX5hGABZgma3/h90BeJHGOJGPBrYB61IOCSiIYI+vWDn9tCDyBApvrYAdB8mNbuYywnMPWdp5rBKl4hjeHEzHLvREfVboOsR+12N5/Cyf9w5fmFrkM94vVgR1ly0g9BMf5abe98SO/TEW1bY5i93tV0TJy39f3l8A6ge3uQROYRBdkW0+CfF03sb1YvUJAUAYG8f0Ck643NExFa4PUzXSTvhPJYlzqtdySAs5XY91/KwP9YJw6iGiLBWoHekbo6R0h4kxbGLQctduMoR4SqCTw1IRvq21XRSFUjDenWQlo1w28Iu0TKfvowPIVNJwOSD/RGfkk87c8Md1pRuPYTc72fzk1Q5TTIt2Upi7pO06nB5suH5YnfpRpBKSEj1y9EdqnSNx+f9gCIuUFLeG6nujdr1ZhofEDvtdep88jpHhnalFu3H+zfrXxbZ3qtSeBeV9IYpJlVvGYrVzVKQFMlvD5yGMx99lQ2AL3n5gIqx+CEQeO0K8Wq1NZwVpHlZHTyRspiP+qhgBnOOs5sl6HmKIkM4nVy8dYWeDby0xgL1AMUN29xDBR5ffACs6f5tQicTrI6SnivVo6FZ+oRxnnp5Z3chIC7WJy/57FLGuW/uDANe9Qm82q3DAVWAMqYTqk6aUFz65RNbW993iCw0ZOddxqETX8vg/mHagIks12LfrQzLq4RfyxUuz9HLPo2sMCbiURFkERbj4XdY+hW9XqJ23KxMraqZVncLpClsPJESSxQcgDWaiOIDh0D0oavq9jNEprKbUQPhb1CfuzTkqqMeWtdY1y8dh7GdGhlcrZTTUPwRyq1GkdzYFawsIS0K+cjtCp5W+rnj0dWxTzE2mWKSrIwgD4gk5aW40ZD3bPAd8myfAa568Sbnrhu8NH8NtyEAQOgOZ1zKWpM0SlepVTch2KG/5alen4w7g/Kchsfry5AeYrdDJomAZlavjDIEiHL1ScdjeI69cJ24yohUEauosocGHxAXvyYCgFT4m4zypRKjZS3MMKl3PLqgzd0zoWOh19z50qo/o9Itu7r2NQAw9uT6rqtccvsNc3xB7J4fuXa+6ScUk4GMKXs7rByMzXz3Tb9hHo6XX2MRWrCGhP32xFFpRqZU6IMJSNH0dkz9nENFluAYk7MyZ2Az+H8t4YYn/x6S2gZlM3brkge3aUBgww2lOnTyebwFAXVByO26RMtZDqYa7QoJDrPnmixZ8BFc4dJcJptW/3DHDt/hOAxaUkNDkSigR+U1HAkytPKS8QOSpCSfONCIFWJPy/VZ3MeO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(366013)(1800799021)(376011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qqx4aBpAH9fRZOgxmoKMOp1xOwhO3Q+noJ8R7JPxYSNNXUku3ru38UX0D+r+0tMz49IS7Wea6q91NGWFmPFLXpHj0m+PJr7GKuMYITGaryyv8POMCTv7q+LUaXDU1dgQEJkNzB5pAZIxaH5KbYB0LF6/i6MoJ3auUE9OZ20L7t48dhRr5F/bSC46BhpeTZFi2DTZPcRpl6k9BXWz8/WSjfX3jjxVIoTKzJOwp3KzBpFTVhgRzIsTO9yXsEJeRgnnv51dMNmQAiPJOexsq21EaIvAWqmWSyQAj6ue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/obGBW4bIH5YFgA8/VTXN0A9YVBrlURcWifNfqxjUCdRoqYBc4YoW6p3XykQnEO+KPC1mMRHJOurUuiArXUoofhn74Ex6jyWR6M1+1y6lABhYrlfN6n7KtdDjRiolRvMsGCTWNj3wi15jmMgMKfHwM6IIDuTUEgSI4pA4DcXlFqY+Tj2elb/wn8rl/vVOpYlhSD9JhckCKTce2l+ckhdNVBaFwu5wdicjXMYhgV0tNPSVsU8vP4YMXpxYPAmUiQFb8OCwYFhassdfIw6gbtL90fFAWUU/f6Y0FyZpAazfwCFCOotI7i16/0R/0g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZFAbR14if2gsF2KxIOEt5e0PyOn6DSp5JDW8H7aT9kGmwg9ZDLDWYOkOj6T6AEMqRV4LZLcKV9XxNcxbic0mhhvSpUjOTzUhsr42uJzbchG/gutqCDFzHvGiQzFo/hlKjwqTlFUe07GjUFs6WPi1leqNjHbkHCwgZl3r/R0/+k3JwZM1LgVzw+BRgIsszdhF90Hhge9rMT9Uq0bPQLNyCwG76k9Hz32ZCW2O4m+yCBZf28yB1HWBxmsodkjbW3yxt3gO0GiJ6hYOg1mWkF3aMWYZrXiAYM0fsi0qGnxZXYAZOetYj2dbDEBWMmtD+O5xpUWEzaY1bYTx9FWVs8bHD+CbsSG2EaubD/dTs7wCXQacrPYFlfdzkAvqqSy40E+7gowXQO33y36N1i4UgcOSP7E5+UqMRjpxprWSn3Y6hztKiX4diNdVcIwFlidrBR/YT8vK/WbhNmlHR8ErCUZKV7APRGUV28kSdxrJtYMMQ419ZV0Ktr7gu1fRvGQ/VGYd/O+FqCg0s0/52T616Hf0sHjXmp9kxNnPy4z+4ne2NMeId7rUl39ODsI84XTHPczw3Htfy9l6UqhdyACzIRuU1F9ZD0RjTBa21aLpFSlOxXg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17318047-9822-4eee-2dc0-08dc8f21ce00 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 23:04:13.5333 (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: F8kuEh8AoG87bm8lO97jsdpH4l+amvlX8PdNMGBYCCQF0rrPozTQ+IXa4qPfkKhdu5G1SQrDBIFbd1R4TTuCCpSPeBCRe+PKhHpwNcJ7Imo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7398 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-17_14,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406170179 X-Proofpoint-ORIG-GUID: W-Ya57xfg0D_9JOO1efD-M6L3bYcOIPP X-Proofpoint-GUID: W-Ya57xfg0D_9JOO1efD-M6L3bYcOIPP From: Andrey Albershteyn commit e23d7e82b707d1d0a627e334fb46370e4f772c11 upstream. There's an issue that if special files is created before quota project is enabled, then it's not possible to link this file. This works fine for normal files. This happens because xfs_quota skips special files (no ioctls to set necessary flags). The check for having the same project ID for source and destination then fails as source file doesn't have any ID. mkfs.xfs -f /dev/sda mount -o prjquota /dev/sda /mnt/test mkdir /mnt/test/foo mkfifo /mnt/test/foo/fifo1 xfs_quota -xc "project -sp /mnt/test/foo 9" /mnt/test > Setting up project 9 (path /mnt/test/foo)... > xfs_quota: skipping special file /mnt/test/foo/fifo1 > Processed 1 (/etc/projects and cmdline) paths for project 9 with recursion depth infinite (-1). ln /mnt/test/foo/fifo1 /mnt/test/foo/fifo1_link > ln: failed to create hard link '/mnt/test/testdir/fifo1_link' => '/mnt/test/testdir/fifo1': Invalid cross-device link mkfifo /mnt/test/foo/fifo2 ln /mnt/test/foo/fifo2 /mnt/test/foo/fifo2_link Fix this by allowing linking of special files to the project quota if special files doesn't have any ID set (ID = 0). Signed-off-by: Andrey Albershteyn Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index f9d29acd72b9..efb6b8f35617 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1239,8 +1239,19 @@ xfs_link( */ if (unlikely((tdp->i_diflags & XFS_DIFLAG_PROJINHERIT) && tdp->i_projid != sip->i_projid)) { - error = -EXDEV; - goto error_return; + /* + * Project quota setup skips special files which can + * leave inodes in a PROJINHERIT directory without a + * project ID set. We need to allow links to be made + * to these "project-less" inodes because userspace + * expects them to succeed after project ID setup, + * but everything else should be rejected. + */ + if (!special_file(VFS_I(sip)->i_mode) || + sip->i_projid != 0) { + error = -EXDEV; + goto error_return; + } } if (!resblks) {