From patchwork Wed Oct 16 00:11:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837456 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 0B9A1AD31; Wed, 16 Oct 2024 00:11:53 +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=1729037516; cv=fail; b=CIXdenDn1v8Y2jUqODyTYPoXyOMk4ONp5xNgM0/hizBkOGqGB/gnxZAPobctlAy5crxCRrTW8ZilqjTvMiqkR1bd8Uq1+9g3t777c/iNMOB+lNelV5Bf0Z3pgmyJUTKJaK/NJ5J70GavUj6BMsNVASOVsyTBa4xi9fXIFeWap1c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037516; c=relaxed/simple; bh=4PB/xfDY+Y/6SrJPTBASc1v91Ryvnf1Sc6zqjIzAvWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=M0PmK+vw038Jcet1ePme+0YKgJwqefiwxWCVmi/dpCW/EUPYnMJ/g4DMn1GusSSjm9JuvTLLp9UqPT3ZtAoTh9QYWN7pRgnng3He8X4aCOvUqPhDsJ0vQTMEG/A2/bvKGD82/x0pSzj0aJSKEJJlAyw7MuIAyzHAL3PBkjvoy6E= 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=c+BXSj5a; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=fqQvN/zA; 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="c+BXSj5a"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="fqQvN/zA" 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 49FHtgWP019350; Wed, 16 Oct 2024 00:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=L9UPSOEoKnhh6tf2DU773pm8/ov9rui1NHaRdEVH+Vc=; b= c+BXSj5aYdxK9KR5ztcVWH+jgrXtHyoVs0O8ZeQqOgGkyHpRSVl7CYip7iarG9j5 V1BfQakxJ1YhAzsd+tTGYlyYqpgAs2wzCjsLxmpCAznJKR8mclhQ608pCyrKa+SE f7H345TVf1HvVxnFj1KZTm6FVd1ehx40lcYqRY1Euq7aF9rEde6sF585/CR07uZY 70MqsEs3t2otEo2AdClNyVLQL+Qx2k/CUz/FBzDRNblWflE0SFCk9qlCkZ5nMCpE xdtJAbYaL3LnVTKvJYB6ar+mfO+ymMFrtfehcAbqYp9aCtP+LDu7k3gw070FaxBE zqDbMz51MbPzyNB0U0Htpg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLKOWT020102; Wed, 16 Oct 2024 00:11:36 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2043.outbound.protection.outlook.com [104.47.70.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85maa-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l5zMwxoTEAd6WOndoRrsx9V1mCrE6U0uVxXvwc+l5j/7yQ3fBeQqDrwQVCRBkoCm3cU5XgCgXIr5adM3xXwr6Td5Sb3Jme5Fgwte7VZAaqFsFax8SuuaVCfaKQWxRP75+EocC7LbiMUGkoexL1/7BT0Uh6XPRGbf8jdvSzkYaKBFDITKPwi31T/1JHqpGdsylCMxcPsk948CmBGOs/onVtg3NTx66EBy+HAm8SZ0RbmD7qd8fzYeEYCm8KN3npHlMb+MYGx59eIWz0n4q4Q0Xi2VHk7H4TeWHdOI4j16zt1uK9vRgQaCIV0rXdklURut1ZIRghwX3FjgMDGfLcauBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=L9UPSOEoKnhh6tf2DU773pm8/ov9rui1NHaRdEVH+Vc=; b=gwfSKxwdHb0ShnQz7Ef0YHDnep8PnsWodgXPlU6YL/vOXzUdJJAeADMkEJAZGBHlmPFupUg02G42nubAXfklVZICeAOAshAWpYwG/vOJ6Q3ZHPEo0OD+7H3Cd6gmc6w3qsLTSSC7YiZZGC+oCP9CHdYk2+FZT9/tfsJQt9MlgtldN+L/Rt6wBKuOy2xgNAu4bNMXl7ysf3p3JKu+2xQZR50fzqJkmesOP4vajtKi3nCqd2PFupl+igTlH33Sd9aOj4COtRO/o+zlfLBE2WRJ/KNZ0lCh1XYC7LxOy94aA19WymCWwA13/hJoq2b411oQCP0B3oR7feG/4bedc52atQ== 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=L9UPSOEoKnhh6tf2DU773pm8/ov9rui1NHaRdEVH+Vc=; b=fqQvN/zAEHMM3MnogmxpjBckVp0apaM26baH2GduAl9QSClNJ2MSKgjI3f74/yEjjmXazHhyjoEi7XUPKdkYZOmGS3V2pTxyPi3lTYRcNW7fZiqXMGfxLtGyrhtPp92dOpJTvwSFfgliVKKVfmyOUJZBL+c95MqqV3h4zQXQTNQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by SN7PR10MB6977.namprd10.prod.outlook.com (2603:10b6:806:344::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Wed, 16 Oct 2024 00:11:33 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:33 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 01/21] xfs: fix error returns from xfs_bmapi_write Date: Tue, 15 Oct 2024 17:11:06 -0700 Message-Id: <20241016001126.3256-2-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0056.namprd06.prod.outlook.com (2603:10b6:a03:14b::33) 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_|SN7PR10MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: 51e14aa8-b83c-4eba-f0ef-08dced771785 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nhhTM1/T5OT4vJK+gqcQjkUkncNirPb?= =?utf-8?q?6pKAcvAF/v3Cw2B6d0rkj4/bZWUT8Uf0CrEVY6xX150bnVsGBQFxqmp51klynMe8E?= =?utf-8?q?cGpakVDZJqAfqtLOtgWpfMhQn5UEQjEM5T8LSX/k9ZhvVauRi2wv8rBpZq6ECZOsD?= =?utf-8?q?msKL916huhZKrC5bjcfWbqZz/CJkAgrTdk/A2J26CR6x0rt5b4oxY7QzFny7Oszxv?= =?utf-8?q?soyJSwWgcVvbZcVkUP35bfSdWWMyEp6Q4X8xKBZRs4p/oPW6g7ROIlJQ7ZYbAOaEg?= =?utf-8?q?CCzR/tVo0n+HZ0HjaidCyaQqfALsk06WFxRtuAPVwl/l2qvFUSbqPefBdj0JP4ff9?= =?utf-8?q?3mB8ZiUMP6az/9FgwJPnbr8+DQHTmUtXl3q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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:(13230040)(376014)(366016)(1800799024)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?11HUU69GdDJFdoutN/jbeyj8509x?= =?utf-8?q?dVjLyXZ+4aWF7EZO2Vrioa9k+tsagzI3lWhg4sQbAdsPWiXj80XDclIVWaNhPuhJO?= =?utf-8?q?zlydZaWX5f0xxPcjybd+bjKPkEMqp5bGWqvPHKyBTDqKPQPfkF1oRkIOtAKhq4rDg?= =?utf-8?q?V0X3FFqgaOMVJ6ocU32bMsI1pcY55elHNTREzkiodOOugUztZFfTMCUAIGfNvbYgW?= =?utf-8?q?+J4ebrbQsnPXnvj8U4dj1r3gKaK0lri1y4Sp6+13tm7EREPU7aJZSqUHLya6uJV+x?= =?utf-8?q?rsaDxlwvv5e3Zt+j6/dUfrb5IrAwWflQhUthdxfskr5r0WrDZYz48y2qbMXOnx3TV?= =?utf-8?q?k0cdXw/H0BuNA5GppqTxk8cm95HulLvZARU6+oAiLpOsSxdWrp4X3iBQq9UFPhSX6?= =?utf-8?q?JVi46eQVt/7/lzMHm+8qjq7hAkjdG5IoXe0N4zJYNCmYqzd6rWBAy/55QwYSEFqVT?= =?utf-8?q?IN2paxBcCXZ4ySlTcUMSNWwK5nVlCrYVktgCydVty7N9GU9GDktyGzdjp6hO8XmGt?= =?utf-8?q?DmW3y1RdodJSGY3/j6pKmpdPoAJuvhGpX5qMWXD62w6bjBwk0/7c++X+xiy78OkBj?= =?utf-8?q?T0O+gTrPk+YufKILWtgOu5KFEKEPckN/QjWdp3xCMSfRBHd/T4AgQwEHWUYjpE1Xj?= =?utf-8?q?iyhUJwQHCdN2WnysIMb75tNronoZrt7EufRbsNecSaaormpSmjnyXHBhq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t?= =?utf-8?q?r6HLYcSHsLySCvr4xwqzfBjV18eSfTzWQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HKQ6REozXZjcAIonIjYsBurHa376KRYN7MZ5zOeo3ReiKUOcD5DLSqHkULk3BMl7jYd6MTTuaklnpDZboHiT9qwjB4xRrEX9ZyGdKTz3vVZ7l/uj39RwDdbdvcAZaQvP2Tf8x4Xo7PJVFS3dD10WRXXrmNEZrkIMzupEtQMxDJU/kt1OeKnmPnV6zQFmZQd/pbksftTVvZz7pmKFMHOiHqsRgotTDtp04PftJ9kbIJqe2WuLJsza4gLuSIJNvcEHDFxOV3+C5kAnhH6/J68sB/k3uN77d2v9dpddsiN5HcU7E50iwoS8Eja0CPFzbvhOGf5DhVGpSoLDUE7VqAxtMHbRDhjYHUTmgXO3PTUBPI8fggJkcZlM+ZXXMke9q9fgoj/DBeEX9AMFfGt0iYiaJ41lF/hSeD7HyhmReTyIgMsrsPXnU9y6WvH6g6W5spUmHgzf5wdqORhjX/lBgu7Ryj1hZGFds4t9g/4likurRKHHg0JHAGUi0FVoif5UYApARMSRSVBuf8vMCgd2XH6Z53kYvV1Q9wKprUP0YyZIYqrZ4NXuJNUeNzf/eql+hcwxZofxkWJSbaUVNIqgqSTnalc2B57AhxeiGZ/sLm30ufw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51e14aa8-b83c-4eba-f0ef-08dced771785 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:33.2799 (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: eR97kEHXM4+uJe8LyWjhFRX9o2l8jIBoEfyEPyqHa8Zyp6R2omt8ta6F7VVuAf6/VCwHmg5BmWfuLdQgL/0ex6xTuZtadDPon600mR9LiLM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6977 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: ZfTjKls6cHH4Ir6OGPK_CFAZEnG6DrRF X-Proofpoint-GUID: ZfTjKls6cHH4Ir6OGPK_CFAZEnG6DrRF From: Christoph Hellwig commit 6773da870ab89123d1b513da63ed59e32a29cb77 upstream. [backport: resolve conflicts due to missing quota_repair.c, rtbitmap_repair.c, xfs_bmap_mark_sick()] xfs_bmapi_write can return 0 without actually returning a mapping in mval in two different cases: 1) when there is absolutely no space available to do an allocation 2) when converting delalloc space, and the allocation is so small that it only covers parts of the delalloc extent before the range requested by the caller Callers at best can handle one of these cases, but in many cases can't cope with either one. Switch xfs_bmapi_write to always return a mapping or return an error code instead. For case 1) above ENOSPC is the obvious choice which is very much what the callers expect anyway. For case 2) there is no really good error code, so pick a funky one from the SysV streams portfolio. This fixes the reproducer here: https://lore.kernel.org/linux-xfs/CAEJPjCvT3Uag-pMTYuigEjWZHn1sGMZ0GCjVVCv29tNHK76Cgg@mail.gmail.com0/ which uses reserved blocks to create file systems that are gravely out of space and thus cause at least xfs_file_alloc_space to hang and trigger the lack of ENOSPC handling in xfs_dquot_disk_alloc. Note that this patch does not actually make any caller but xfs_alloc_file_space deal intelligently with case 2) above. Signed-off-by: Christoph Hellwig Reported-by: 刘通 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_attr_remote.c | 1 - fs/xfs/libxfs/xfs_bmap.c | 46 ++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_da_btree.c | 20 ++++---------- fs/xfs/xfs_bmap_util.c | 31 +++++++++++----------- fs/xfs/xfs_dquot.c | 1 - fs/xfs/xfs_iomap.c | 8 ------ fs/xfs/xfs_reflink.c | 14 ---------- fs/xfs/xfs_rtalloc.c | 2 -- 8 files changed, 57 insertions(+), 66 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index d440393b40eb..54de405cbab5 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -619,7 +619,6 @@ xfs_attr_rmtval_set_blk( if (error) return error; - ASSERT(nmap == 1); ASSERT((map->br_startblock != DELAYSTARTBLOCK) && (map->br_startblock != HOLESTARTBLOCK)); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 48f0d0698ec4..97f575e21f86 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4128,8 +4128,10 @@ xfs_bmapi_allocate( } else { error = xfs_bmap_alloc_userdata(bma); } - if (error || bma->blkno == NULLFSBLOCK) + if (error) return error; + if (bma->blkno == NULLFSBLOCK) + return -ENOSPC; if (bma->flags & XFS_BMAPI_ZERO) { error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); @@ -4309,6 +4311,15 @@ xfs_bmapi_finish( * extent state if necessary. Details behaviour is controlled by the flags * parameter. Only allocates blocks from a single allocation group, to avoid * locking problems. + * + * Returns 0 on success and places the extent mappings in mval. nmaps is used + * as an input/output parameter where the caller specifies the maximum number + * of mappings that may be returned and xfs_bmapi_write passes back the number + * of mappings (including existing mappings) it found. + * + * Returns a negative error code on failure, including -ENOSPC when it could not + * allocate any blocks and -ENOSR when it did allocate blocks to convert a + * delalloc range, but those blocks were before the passed in range. */ int xfs_bmapi_write( @@ -4436,10 +4447,16 @@ xfs_bmapi_write( ASSERT(len > 0); ASSERT(bma.length > 0); error = xfs_bmapi_allocate(&bma); - if (error) + if (error) { + /* + * If we already allocated space in a previous + * iteration return what we go so far when + * running out of space. + */ + if (error == -ENOSPC && bma.nallocs) + break; goto error0; - if (bma.blkno == NULLFSBLOCK) - break; + } /* * If this is a CoW allocation, record the data in @@ -4477,7 +4494,6 @@ xfs_bmapi_write( if (!xfs_iext_next_extent(ifp, &bma.icur, &bma.got)) eof = true; } - *nmap = n; error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, whichfork); @@ -4488,7 +4504,22 @@ xfs_bmapi_write( ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork)); xfs_bmapi_finish(&bma, whichfork, 0); xfs_bmap_validate_ret(orig_bno, orig_len, orig_flags, orig_mval, - orig_nmap, *nmap); + orig_nmap, n); + + /* + * When converting delayed allocations, xfs_bmapi_allocate ignores + * the passed in bno and always converts from the start of the found + * delalloc extent. + * + * To avoid a successful return with *nmap set to 0, return the magic + * -ENOSR error code for this particular case so that the caller can + * handle it. + */ + if (!n) { + ASSERT(bma.nallocs >= *nmap); + return -ENOSR; + } + *nmap = n; return 0; error0: xfs_bmapi_finish(&bma, whichfork, error); @@ -4595,9 +4626,6 @@ xfs_bmapi_convert_delalloc( if (error) goto out_finish; - error = -ENOSPC; - if (WARN_ON_ONCE(bma.blkno == NULLFSBLOCK)) - goto out_finish; error = -EFSCORRUPTED; if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) goto out_finish; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 282c7cf032f4..12e3cca804b7 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2158,8 +2158,8 @@ xfs_da_grow_inode_int( struct xfs_inode *dp = args->dp; int w = args->whichfork; xfs_rfsblock_t nblks = dp->i_nblocks; - struct xfs_bmbt_irec map, *mapp; - int nmap, error, got, i, mapi; + struct xfs_bmbt_irec map, *mapp = ↦ + int nmap, error, got, i, mapi = 1; /* * Find a spot in the file space to put the new block. @@ -2175,14 +2175,7 @@ xfs_da_grow_inode_int( error = xfs_bmapi_write(tp, dp, *bno, count, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG, args->total, &map, &nmap); - if (error) - return error; - - ASSERT(nmap <= 1); - if (nmap == 1) { - mapp = ↦ - mapi = 1; - } else if (nmap == 0 && count > 1) { + if (error == -ENOSPC && count > 1) { xfs_fileoff_t b; int c; @@ -2199,16 +2192,13 @@ xfs_da_grow_inode_int( args->total, &mapp[mapi], &nmap); if (error) goto out_free_map; - if (nmap < 1) - break; mapi += nmap; b = mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount; } - } else { - mapi = 0; - mapp = NULL; } + if (error) + goto out_free_map; /* * Count the blocks we got, make sure it matches the total. diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index ad4aba5002c1..4a7d1a1b67a3 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -868,33 +868,32 @@ xfs_alloc_file_space( if (error) goto error; - error = xfs_bmapi_write(tp, ip, startoffset_fsb, - allocatesize_fsb, XFS_BMAPI_PREALLOC, 0, imapp, - &nimaps); - if (error) - goto error; - - ip->i_diflags |= XFS_DIFLAG_PREALLOC; - xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - - error = xfs_trans_commit(tp); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - if (error) - break; - /* * If the allocator cannot find a single free extent large * enough to cover the start block of the requested range, - * xfs_bmapi_write will return 0 but leave *nimaps set to 0. + * xfs_bmapi_write will return -ENOSR. * * In that case we simply need to keep looping with the same * startoffset_fsb so that one of the following allocations * will eventually reach the requested range. */ - if (nimaps) { + error = xfs_bmapi_write(tp, ip, startoffset_fsb, + allocatesize_fsb, XFS_BMAPI_PREALLOC, 0, imapp, + &nimaps); + if (error) { + if (error != -ENOSR) + goto error; + error = 0; + } else { startoffset_fsb += imapp->br_blockcount; allocatesize_fsb -= imapp->br_blockcount; } + + ip->i_diflags |= XFS_DIFLAG_PREALLOC; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } return error; diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index a013b87ab8d5..9b67f05d92a1 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -333,7 +333,6 @@ xfs_dquot_disk_alloc( goto err_cancel; ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); - ASSERT(nmaps == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && (map.br_startblock != HOLESTARTBLOCK)); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 055cdec2e9ad..6e5ace7c9bc9 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -317,14 +317,6 @@ xfs_iomap_write_direct( if (error) goto out_unlock; - /* - * Copy any maps to caller's array and return any error. - */ - if (nimaps == 0) { - error = -ENOSPC; - goto out_unlock; - } - if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) error = xfs_alert_fsblock_zero(ip, imap); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index e5b62dc28466..b8416762bb60 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -429,13 +429,6 @@ xfs_reflink_fill_cow_hole( if (error) return error; - /* - * Allocation succeeded but the requested range was not even partially - * satisfied? Bail out! - */ - if (nimaps == 0) - return -ENOSPC; - convert: return xfs_reflink_convert_unwritten(ip, imap, cmap, convert_now); @@ -498,13 +491,6 @@ xfs_reflink_fill_delalloc( error = xfs_trans_commit(tp); if (error) return error; - - /* - * Allocation succeeded but the requested range was not even - * partially satisfied? Bail out! - */ - if (nimaps == 0) - return -ENOSPC; } while (cmap->br_startoff + cmap->br_blockcount <= imap->br_startoff); return xfs_reflink_convert_unwritten(ip, imap, cmap, convert_now); diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 4bec890d93d2..608db1ab88a4 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -840,8 +840,6 @@ xfs_growfs_rt_alloc( nmap = 1; error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks, XFS_BMAPI_METADATA, 0, &map, &nmap); - if (!error && nmap < 1) - error = -ENOSPC; if (error) goto out_trans_cancel; /* From patchwork Wed Oct 16 00:11:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837448 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 B9D773C0B; Wed, 16 Oct 2024 00:11:38 +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=1729037500; cv=fail; b=C++K6zwxGZOUjJae/sw59zv/k9z1FO3aS9GR+GELaZ7PxllGF5r309mfL+f5Ta3uPKdNuCQCBmGQ65/76x4j0nukzKVPZRXjbMUzSHY0yU/yMSM+LF+xaSDyq/ywetjDg3kbctsJJHhoBGS9uPQJHlNhaT58S4frDN3l+LtiErU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037500; c=relaxed/simple; bh=SoqskKKncj9l0P0o5EifVXAAp9nHXsBkjf4Av5FVD+U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cOImy+Hjn5NTt1TTgRwYB2YcawDFznCaH/MdIIxC5IuJ24YLkgw3SA54W7ifzk95mr+uzUbmG9VRk8lM2K6DAPCzwxC5UsfROPRz14JatVRrMYEUofL62TqpgNN311gkYTUqBHL6FsHVZtj7znl3KJjyvXCZYbWAzr2FO+xQdLE= 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=HCP9d1ty; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=npqav+0y; 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="HCP9d1ty"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="npqav+0y" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHtf2o008287; Wed, 16 Oct 2024 00:11:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=yPrKlroy3mFa9Th+wAuiayds/9dutHvEz7KvBXCbRF8=; b= HCP9d1tyOFXE3/RcpPXR4eaaODFuRUnC/+SSyfNvQlqiRrzObDyMo5px2LKoZdY5 n0YGizgRFXyGxsZHCuSOMELVxa6PTX9/5zmhv2BsI3sGiTkpzgkcP1RKqzh6VijE Pkn4OnqX0ANWTIbYhZt0BzisSzcGCbzTqdKFcpwlvbfgTpxwdGoJkSvWdZXFYesa wVWzHuwKsjD+hLjW7X6pmJhlsx6i9vitTaBvB87Z5EjMF4IbxJKlPAMOn8eBpUjN VtPKINcEeJSRzuViyqw8opuGLL71izcRIh8SYpa3oJb6qcjQ9M9wxuGAJ+Ymkc1Y YYHV8g6pztOUfy633XUXdw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427hntaj17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLKOWU020102; Wed, 16 Oct 2024 00:11:37 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2043.outbound.protection.outlook.com [104.47.70.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85maa-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xyLVblmqcLxRMm88+fcn3ZpvQwgQKCc0MuEwzMsNORR7PlfDHMXr2QxLYm94Cj8WrxIyLGWQ7a28xOloZ27IPKQgvio53TWqEPQWNfMNEAx8ZyOGCKte7h5QIG4J3eTUfPJPC6QwfSWJ6koZ1/qJHCjTc4W2cgaG/HMUYA8nnf7AYP9fq2KYEmyjSytEoKd3+GxWjXY5BFyyr6Kj1N2UwuK0PUFUTx4lCYMzUpJIcXYal0TNn3ry7Zl/qchjZTuXMy3AaDgEG8rdVIEaF2PncBzGuBbbnrWXGvT4S3DKrI2yRpVammBcpkAduZKU8dN7pbgwKd6vyXntYqGZ55TVrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=yPrKlroy3mFa9Th+wAuiayds/9dutHvEz7KvBXCbRF8=; b=R4ZcgtzTvuSKDUfSP2FoMoJOdX9pO5SiUlFm0pgZCRIufh3QKjAH/BuhTY7vhRlbIaW3sxjS+9DP9LRcRRFE8Z0ep8BFLINGv3VxZcGJP7RoC3D/2FHeo13DgNX5iLYqjOqfCPOblB+XEWwBbFWA7kWdkSTUBrYYkwQZBD4LGzonqj2T8iNBIrpCjAOpoUhk5L18geYnL1u9dhPur1hFYS0xOOoWct4kmnrDh2rsieXp4BNs+Dt5DE+JpUGX24WiMnkjo3dKmYn6cfYl0hwWamrFsxwJzH7pM/ApZQTiUXxNs7PZMAkPlbIz/U5bgoM1+BdbCzBoDLgKXwnkL2RZiQ== 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=yPrKlroy3mFa9Th+wAuiayds/9dutHvEz7KvBXCbRF8=; b=npqav+0yNZbn4vQ4ZpaF2wY/HHCBhHI+HEssaq5rH41xigl1MWMS5R7mX12R8m1priHLoIcCccValwQ0TBq1NQNhclPsJ/Fy5diOb3WRFIBeO8eJfRbQk0wK+75J9wN+hjVZ0hl3udu9jXBdgDjwMpFk40QuamVc3Pw4TZbmDsY= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by SN7PR10MB6977.namprd10.prod.outlook.com (2603:10b6:806:344::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Wed, 16 Oct 2024 00:11:35 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:35 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 02/21] xfs: fix xfs_bmap_add_extent_delay_real for partial conversions Date: Tue, 15 Oct 2024 17:11:07 -0700 Message-Id: <20241016001126.3256-3-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0061.namprd06.prod.outlook.com (2603:10b6:a03:14b::38) 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_|SN7PR10MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: 04637e0c-0c5d-4dbf-f215-08dced7718ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: gBsDZcHasFSPs9xtRpMFPEQFgKmoWAWjsOCJOYFTrPXGVb6OsrDrlmvUjSIOAMOdFNxt3QhKvYLB1YpE6zKlGe1cLKBCVpipxNALjG1NKoIG5Qvh2aKuqfiSgqmlKj9+PH0H2XVoyVb9cexnGupx+nEHyYfNGkXrJY23zK2A+EXiucha05Nh5D/zopo3paBsP3o8mvdL3DNjJ7X3LohNHL6dx7/8tS8/MFRCQTqiOiX0PwuuHkPZBz/lXLeqpTn3J/UGaYnqZ5f6v9mihUi/JD+zNEH91AXejV0z3awYWYp2uUIDJUSRxjs+UbgGYZfNn920wpzvQrUHuPpa1/F1clgT63rWdothUCFewHoNYGtKSbOnxJFNhpfd0A0T/nHnoYO0ubBULhH3g1h6VI4dPTIVLXtOCWb9yC5WZVgWp1O1yj3uOc213gVzcw8Cls/YIqhr1tYmvviRCCxOvF9f+K/VP77WnKii43g/DrdmuQIN93I6fowaEmHCSJbBG7sNogkcYNFlgug71U2M9ztFtjJQgso2qbk2eubNYM7fkGp5FrFAc8B9n4PJq0ToAsOkg9Q0a53/rJgUt9lmcySB6JzI/ihHpTPJkSUONt0/K+Y1dRhk1pqb+MX//d9MV2itHInoq0ag+/d07gPeyObPttOYkGtD2LaxSmaAJ3clGUif16cRzhrETrMhl0uZApTlC/BLVYrAe884vRuRF+cWofB+sgfh99s4tVJbCiX5mOrrH4Gt51qklkNtq87cVmewGnmbLl3kr7YXqyURGnSAAekr/vwqhZQumVRpJw4uOQBEFjn+/y2DRUP5pt2/MTBQNHRa8PFnGdOs6Cas2bbPR0C7CIO9iAPIYuIpo2WAWn4RJCz20ijvvEkS5JID0KK0AFGJWufb95z5Ngw63jcl+5fHE+ZrisgyY0tP4iGgPXOVeZRyCepXpZaLEX1pS6FT0JjQ+NTzfd/LbyJeUBUv0+JRLDLptX8inm4aQtqdQrHf8TYHaxXY8EAf8BvIyStq4LwvqJENqYRsobkkVf52/6RK/KO43Ufrib0Ex3BUqV19J2Hlc5P6Wb+p+UFud/9dRWpGx3vzHk+cy1cszY7X2IC8j2bag/iUvJc2FjDoVHqnAJFaDEg7n104/U2bOPb4p4E3HvVXY9mqqmlYtwV7iRATUKuAfjq70G0MfvCYZSUYEy4l3Gr1VxIjvStD66MkFesI/YZpLXwiAGSAfck2sHDzT3bjSgNxzdUoMi8dmuDGXkWUXY7GzQGYTuR1axQjG77h1rPWHr76+FpCa9nkQQ== 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:(13230040)(376014)(366016)(1800799024)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oeWfPPQz6438ybMos3NrG1lOI92C2MNCffJHKv76zcoTA5gwkdXdcRqsGbM3m7x05DCp2OCt5e3TznOZAX/87yDHX4it+wJCdUqFmTt/2LzfVgLmA1wYaSJU2R2tMb37aKZapa7xDo4dgVlIMiFNFv3GwSZx7QCYMt+VLi5EWkT80dbKyirgjGCGXuvLryl0WB83mfGcA44K8vGgOD5NxdEnqWyXdJypjlPKAFzVYHk0RnZ9dyX1M5eWyhDWCcV67ehrI/xoLs/uJbobhBdbJeJCG8TyTP1ZaHqMKTogR14HjMQFt2Qn3lWgwLYkWBVU2yHTp4KraVGX9dOM2ZWSyY9hLKSW4Vs4H9g5KHeI/UUBMMW9goYtyuWtTOYnMXJjwBpZ9Ge1My2QKNOZq4Ja2Pf28mdff8NPhxn4kaF3zGFkZdhSZ9xt9XJtfrAKX1WWVP0nJmFHEbOLVcnXyaXW4VPLh9GxtFuYkRu8P/0Ca+6bWqmmYllch0/ssDjm3CxQjF+bFvQiEm3ZeeNO4E9eLy9WGYRaDoagw0VTzgSCyfBTvEJQjAQG6Oh6ClMq/O8tGDb9Jx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TUtVnD7CLMvsc/VyMtZrryROnk7gVsQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: O10nQ7S1wOGLiGsLVwiOmDuaqmrAUqVOVWz/UUNqUwOdcC2NeO+4U8cr5UHqug9K7Anu7jy+dwgqjQSXU/lyW7tlqlCYvGm+f/5x4asm+brWdjHim4FspfHaiYz9hMqURNz7bEVs99HLRXpDD84+ABha0MRIFgCCWBTd2bG7AkjFJIJgsbGAHEezvJW+adC+d6YH6zqmZ9E9OFajl5I1i0ybWBc8ErCylwLygUhyysJxkiAEMzU1YatRHd0bYrQwT8NrVO7xdEu3vmxqoAKsBKfMbzSjMvlES4cVrg+6wIQz0oZLKP0FrE669PQG/kuuqrv/OL6clplBEMW+qqM+8L1SR0Mw23IhVhtWftjbMJ24JRogY/OmDi7q0S6E6LRZSlgMFVwEKFe2MmLcND5pWIm+hz7SB/J4V0W7RB3Ufd1NO8rR/pNE7zPCYaEcD8hz/5Sxp1cccqMnl4Mx6FqhXKKuQEcvWoOJMh1z7HZWaHYBFkV/U4g5luzpKBOsuvFayVBc7fqANnJb+X5hRmR0C5eBvRyQjoNcazP/bkvNx1diItAiRo5zV99jKds7kCAAwQjbkJ5DxUcJzyuPkXc6AnZz74HtFy0HioPxumdmAX4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04637e0c-0c5d-4dbf-f215-08dced7718ab X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:35.2038 (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: rNyA70Kr5iwLXNvyb+7L8MfTnVXAjp5GM1E3OzPduaQuXoqnpBZjOuRTIZC1JoojKKk4MpEP0WfmZEathpedt3v7DBnxje9QO5nFjMfdp/I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6977 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: rkfUa_6vhFGehIxXHZ6loTKhp3UvPE3X X-Proofpoint-GUID: rkfUa_6vhFGehIxXHZ6loTKhp3UvPE3X From: Christoph Hellwig commit d69bee6a35d3c5e4873b9e164dd1a9711351a97c upstream. [backport: resolve conflict due to xfs_mod_freecounter refactor] xfs_bmap_add_extent_delay_real takes parts or all of a delalloc extent and converts them to a real extent. It is written to deal with any potential overlap of the to be converted range with the delalloc extent, but it turns out that currently only converting the entire extents, or a part starting at the beginning is actually exercised, as the only caller always tries to convert the entire delalloc extent, and either succeeds or at least progresses partially from the start. If it only converts a tiny part of a delalloc extent, the indirect block calculation for the new delalloc extent (da_new) might be equivalent to that of the existing delalloc extent (da_old). If this extent conversion now requires allocating an indirect block that gets accounted into da_new, leading to the assert that da_new must be smaller or equal to da_new unless we split the extent to trigger. Except for the assert that case is actually handled by just trying to allocate more space, as that already handled for the split case (which currently can't be reached at all), so just reusing it should be fine. Except that without dipping into the reserved block pool that would make it a bit too easy to trigger a fs shutdown due to ENOSPC. So in addition to adjusting the assert, also dip into the reserved block pool. Note that I could only reproduce the assert with a change to only convert the actually asked range instead of the full delalloc extent from xfs_bmapi_write. Signed-off-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_bmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 97f575e21f86..18429b7f7811 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1549,6 +1549,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: @@ -1578,6 +1579,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: @@ -1611,6 +1613,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: @@ -1643,6 +1646,7 @@ xfs_bmap_add_extent_delay_real( goto done; } } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: @@ -1680,6 +1684,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING: @@ -1767,6 +1772,7 @@ xfs_bmap_add_extent_delay_real( xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); xfs_iext_next(ifp, &bma->icur); xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); + ASSERT(da_new <= da_old); break; case BMAP_RIGHT_FILLING: @@ -1814,6 +1820,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_blockcount = temp; xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); xfs_iext_next(ifp, &bma->icur); + ASSERT(da_new <= da_old); break; case 0: @@ -1934,11 +1941,9 @@ xfs_bmap_add_extent_delay_real( } /* adjust for changes in reserved delayed indirect blocks */ - if (da_new != da_old) { - ASSERT(state == 0 || da_new < da_old); + if (da_new != da_old) error = xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), - false); - } + true); xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); done: From patchwork Wed Oct 16 00:11:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837449 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 ED48E4C98; Wed, 16 Oct 2024 00:11:40 +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=1729037504; cv=fail; b=QIykCXgWMQs3z8vhqZVKJ0PdV/hF+KWjAK57AJsX2H10YVwBluNKpPEjSFiMts+gcr3Z7OMNpDxj6gRjCsgi0CfmWR/dpqLxs1xn0vlAo05xKmkokeRFv6tyLPjpfAFDcTVfMI7RtoKkPe5uVCHO4jQD/Z9iT54hDCJpzeMR5Oo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037504; c=relaxed/simple; bh=DsyZJplEZpoY3Jj46DggnsDJxzthPU7hUmPinskqFMI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UWzNaXT9hkEMtbqA1mM3Z36W6SMAXy/ERYXKjgNBnyxCtg7vXTnqbCaI7mBP0wGbP3kc8tRXEvhiyeAQUzKWgwfSYl0E7FH0qUOtllq4nxGReWjk4v9EZJnz4QOZp7Gk8JHBGfYnFxuTEAHPKSFUYFO4uXEPS/04wk6d5fI7veg= 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=oGW1DP85; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OL1ULUBz; 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="oGW1DP85"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OL1ULUBz" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHteR6029022; Wed, 16 Oct 2024 00:11:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=+kpUmVNkgKFIS4VDQoC+mzQCvjHXfIqE/vQfQkRsZ70=; b= oGW1DP85T+EKn1ZNfOBLexQ3fDjpXGrxWyGOQ0XoGVRJqVO27jngNLDH5V8dgBbw nhgngH6M0pU7Ni30EGSWVGLiDdNuMTRLe/H66Dr65ApyIHi9YnjA3iw/QXPY77SI DG8M7cscHdgyQpD181AlAgPogk2pzCy4f01K8cnKab6Lo+9Sm1ERLkkSq6YEZcqa BT6aOP/rcd1GwwhtsAocuG4kb/YDpw7uQja6zI7ICPhAFyuoFDGOi5WehuKylfOR b+n3PAeqZIHwrz/f9X41J7VC45TiUwhAZ5GzspiC4ZhPfLUlyO1oGXtZGX3aIJ8t QGPzY000zw6qXTVMGEdz2w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2jk3c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:39 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FM5Qw8010401; Wed, 16 Oct 2024 00:11:39 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2044.outbound.protection.outlook.com [104.47.70.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjef0bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tthZaT+rmXj5PXO8JE7XQjc7ypSNGeghhgHrUWCPaCP0peVeHlrtWbBT34Ps7pWej8hkkF/TAOXIp33/qsGawOcZjkPpkwFWyhXdkDj8wTC3gX+asW0Q5BduZGiVSGnS4wrcy5d1h6abpQQ6VlumTX371JwApapsB5bdDO3sy4TTdjrK2nnOtknAX4JJLNV1EsDS1KzfVmnKh3DPR1Yl/VZEcV1M11au3IHAhJG+ewHDQW+Mim/XokGFRKbLZ50SYRn6TCjdeV3HwaCSQP4QvSktuUAkjWUsJB7f8VcOkLNkzli5b+w967VRbuRTqAG1HqiDvzFMymyxZaAMZiX2sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=+kpUmVNkgKFIS4VDQoC+mzQCvjHXfIqE/vQfQkRsZ70=; b=Kq96UWpliV1MvR7KUITdY5YzIz8pr37krdbozSfPVCrliu/nWcNCovZfAcZNRZe+ISZMpErFBfCIkvDok5rK0yu94QqKhIMFiyz/Z3jbA6BLaZAbQ0c0uQqB+ytJLgYHoCu/hc4TIqMesy5h5KeyqSzDhrl9/uhmqJeOSvCxrO/40p0DHNn3wURAZzPH0+ljt/PE/1/3H2vPxrNBwHp1/pkN8NUgD1R8O1jXKc3DQ/pBUh711A7GBlEeM8JivoAMWw+0OmUOKH0xdFrq/E6ReZPmWKQAfNmOdjXQZUhoZdaUMz7uL8TIVNYjx7rdnNbuLniwgwJGzfQwm928s9mVrA== 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=+kpUmVNkgKFIS4VDQoC+mzQCvjHXfIqE/vQfQkRsZ70=; b=OL1ULUBzCVyyY2aPSa3AdDc167SZFvr6KZFRAgr7aG9WGYlcwFqileJoQUSpMxzDa3i1BRObqviynIaNOpQ1X6/c3GN4aWpcYIH1ekVxFkuzPte4WTUgh3w9ua0tYzbcm41MFlhbaaJfvYo8X4kkRa8JxTIK1c/U2jmDd5+626c= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by SN7PR10MB6977.namprd10.prod.outlook.com (2603:10b6:806:344::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Wed, 16 Oct 2024 00:11:37 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:37 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 03/21] xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent Date: Tue, 15 Oct 2024 17:11:08 -0700 Message-Id: <20241016001126.3256-4-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0047.namprd06.prod.outlook.com (2603:10b6:a03:14b::24) 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_|SN7PR10MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: d812654c-848e-4ad6-323a-08dced7719cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: L2P7arbFtYYbUa0rkak/KJFP1C78jyeQBqqQoEqT+xaPCqWOlmwrYnssqupvfnnWJvuMcR/rQxwtDSbw9F8w/3ccPSDwBsGxTpuQ3dEuI6d83hLdo+5O0oRGgiG1hMhFGtO/+w88cjMlrXOSDPb5eyfSMCjHFTlVnsbXbiFwZzBIdrxYW7MeA6VX+hkL/gjQHDmhe0tg1sigocQVmFiV3ml28k9CTuD7d7XEDZ5PJI4wAU3s2dg1XY53hh0bToUybQ4D8JraH9yen4GlwnItdsRc6cGbsYP/Iucb6r7KxSkZ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B5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kGGmtiEDqVD9FuHRnFUo6r/yuynsd9padfcICvye0GwWZX7k3BaeGvlreNvMx+sXbyg2WNr/FSgowDx0U8c11z3h72kAnxwrE8YI5W23bqWli2boT//7r0294dej59wNOCpka2XB3h+ZkiYHX6vx9/Z/M5YLK6sEdi/wijIMGvBvfC959uPvMkU0YDW2v+cxXeSjgjWbUBRf7QCTxQDQ7Hl9bZXyjS00pLQFjBAfU/kMzf8vFm/T/+tRcphzYIunGXkc7il6/7fgCN+BXchnNKdi2ZbIFNt/hgIVX04Su/rEWTO+7zGMxbjuZB81yubIasCH0BoBt49zlH79vtOiQypM2fz2SW3G0rKlDuJmUdyH0ZoRz7RpVwl/FeZ24NejJ+VbiUctqSRrfA7x8lAMzhSkqnJ2UHqQXeuvmaybjcTNrNtd+senuCnMJqYhxqlZVEX+4ldUsHSRtbo+Qvfftk0LtmBZriMWqZft0mwkYVrQjJALXSqlNq8kHp8qfg4Lzk9Sq1rqXATL57dAaAT8kNb4NE5U8xk8Tjm243VU8SfWb19rLkqKswpTDO0gnpOEv3uIoxEhcaO1kgOeJif1+V2dgkgSsp/ZZkWRYPQL6sIDF3pgKk6DBM4xIoNesP9tSvGlkKVY5sEuAjoX7jQjnYkUZC1W2HQNzSmEzZ/9yMJhehWgsRaziLokbHQaymy8wTTOZ4KFJLB4POhOss/cnXnhk5GJeU3g4l1yfJvNGVaGjrXDvzav0SQ0chSD80ZxTLFFjV7bDyD0DPg5dU64ioMAGn3ivh+0YeujyM/FSiSugHKT/UcQOqnU8EHP5WBaeDp9rb0GodOq2XMhrzGT5w6lMFK73YQ7INKihlf/Mald2h3gF5fwoAUEcYbTQHkJgHXDOv8tSGvQDaXwRkpSREJtty8NfdJ85AAwj2WJ9OKE9jz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eVeZxdqXqwZsAjYtbidoz0IvN8kKW/Zcsu+qrQQIiIDvGFNuqXaozPcwKDHlC+XWV4ZlK83tSdpK0K5W2LrToK3NRxDTtp4nVLazO5madht8ZBWJz+0O3FQFNMhlytiRf7E42GgEvLVpy/YghL632wbZVbpXGXMuLo73GQzK3fknIodYHBk6thGhz96rMpCDOR2NvyUawl6E3P1Lia/NJZGRjnhrAYTgHx1T6wCj4rTEQfB4PM6qQmrVUWbTSgLqq4ggSOlG/fRtSa9Yg0hdP6KiNbeKcuNWulBOknrVJRwaEN20EFSIPt4FAV0oaYsXjXHtwLLgYTqLGFuK/KTxc9veWARK9zMfphNUFeBO2qZH5XxT0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d812654c-848e-4ad6-323a-08dced7719cf X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:37.0640 (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: 9BWOPUzFUOFbctzdKFH0IRTySzCG9/0GkCV1Ucw6zTv+WaoSBBk8Dk3Iv7ii3NQfcB/RJxlG6ybfCRjcCZwIvHxIHt8ryS6Jyi4+wZAwpdg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6977 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: K8UVRQxymlF7b5YX9tBp_Bn9PGVxtfz5 X-Proofpoint-ORIG-GUID: K8UVRQxymlF7b5YX9tBp_Bn9PGVxtfz5 From: Christoph Hellwig commit 86de848403abda05bf9c16dcdb6bef65a8d88c41 upstream. Accessing if_bytes without the ilock is racy. Remove the initial if_bytes == 0 check in xfs_reflink_end_cow_extent and let ext_iext_lookup_extent fail for this case after we've taken the ilock. Signed-off-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/xfs_reflink.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index b8416762bb60..3431d0d8b6f3 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -716,12 +716,6 @@ xfs_reflink_end_cow_extent( int nmaps; int error; - /* No COW extents? That's easy! */ - if (ifp->if_bytes == 0) { - *offset_fsb = end_fsb; - return 0; - } - resblks = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, XFS_TRANS_RESERVE, &tp); From patchwork Wed Oct 16 00:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837450 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 35DF95221; Wed, 16 Oct 2024 00:11:42 +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=1729037505; cv=fail; b=AxVFVlci6A+/lnGASjocpBSwN34jMySSahIkV2F8Cr9DK2HLy8GJqyQeV20T8RPgXjchAWT1ArkerOG8n6Gw9ldYsy238XYDUWC4Sk7Iujp37AZNz3JzTVRbHLftnvAqA4wjbv9xdTojQXO4pShECECeIe4rQ+sA0SDQkPK/Jcg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037505; c=relaxed/simple; bh=umly7riNLcdDqdBRU/PaCgb1KsxMQrTiKgZltORBLmw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=njJNJitk54VPSf6DwFycNSPpBCTeepWFpQVtKuIm9X6ql1lKOxPYznIKDeXCT6Df0qcjm9TMTN7oRwNxsxVLQkHnUjVuMmBetlOJiGo2gMudwtmewUf8jabcU8v5nnUF9qNYDhNsPvIfFmZQ85dI/l8WMhyJHXaQ3YqV2YIB0Rc= 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=bvmjAp3N; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OZz7whws; 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="bvmjAp3N"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OZz7whws" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHtdOT028914; Wed, 16 Oct 2024 00:11:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=11hVGg5L4lvJVHrNcWrLSMRJohPyP0eMmedf5y4VMfU=; b= bvmjAp3NxecwQ3wrw7RhspOGc+dTJeKjfvgR1Ax6+CrNtiPcksnUltbet9FNq9Xx ENrSBqXyQsPW83fUkR2fs5LE0NsSU61IhPOiYO5EglqRMFvLrJQN4hFDcgYamBXn qsq0yKDLf2j1mcwpNR6fPuP0qKn5eaC24VDnCXd2BY8vvXJZMXQpR04Oqds4szM1 YnAB7RilvCLhAEqVNDQ0t1HdBqjLT+3glOPf3D9mUHq0xj3vkVuCzH0uIor+0+bc sLkWOrjcSvt9n/i9TjUiiyD7iFqNwiPm7aWfRCLaj/VIwuZrBMqKj51J7kjUKBtO USrZt2Cycub1XfD5NYz8rA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2jk3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:41 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMxP27035993; Wed, 16 Oct 2024 00:11:41 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2041.outbound.protection.outlook.com [104.47.55.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegwq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QPtRIPLW4yqw59Kmzd2+4Xyxa/E5j1e0tXNBMop6wh8gPS8tpthe53M6jPrZnlCVbwZiyGJEwf2x1curR3Oo8xLJvjVkHyfcQTV38MxaNtl50MQ9Wj83u04rv9L2Q7CtVkbjjfAe6X8Y72u4Xmutnt5XO+Jouipcis3Bnb9UG45ie7FzlEMWXG23NOtI0iId7B5yBGLtImtNs5/MkxIXrz3pT2qhsrJkRmO/tDuRT17hJAizPff5WEzExC1jnWeusKXvDAY32EfwBHSemE2J0rRlFRojsVCmnmSj4J+01zkdKiyo7vt5mQFBPuUerO1mGW8NcZq4ocPk/RHytOEb0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=11hVGg5L4lvJVHrNcWrLSMRJohPyP0eMmedf5y4VMfU=; b=Tb/8c6HsAXPRinrr2QIXcmSjLDSGMXELx86O4IVEAOUy5KWChWLUjazrsjXs3sjr2EoXjKjTVki0A/We5jjqF311NHOwRtoLCvS1FaSEhQlAVog7aZe4BGyfJtAZziYr2PbAvjVAeejNxRvabeiVSkwgl48JuzJkShhXhgrjAl03PzJQXABKqvd2DPV8tYQ2CPwQYproB+c9I6Fx5fOvzr/5ntVRKdMGJMogZ0i6Pe5s2JZidNXn1ayH/z5oMbMHbWGWASvUEC24X8MIvTwRifGHqMqd/iPytnoc6380PuR9pD9+vWDoTCmIvPjC1JJ7rj5/3x3ofLVO5GzrLXBZtw== 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=11hVGg5L4lvJVHrNcWrLSMRJohPyP0eMmedf5y4VMfU=; b=OZz7whwsT/I5t3FnDYFuVwSNKDpSpURP3lWGgzzIMPpqGL9Y2HVxVPMCk6xDHZjMqkivPqorVIxlUTLddlBTCklaz1i/hEexBRpij6F76lbjZbTAVUF2acnTTsswa9ejrKaCFQwJoecQJlpg3uPAyqaYXT/1bMqYjBDl6XhfIhw= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by SN7PR10MB6977.namprd10.prod.outlook.com (2603:10b6:806:344::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Wed, 16 Oct 2024 00:11:38 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:38 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 04/21] xfs: require XFS_SB_FEAT_INCOMPAT_LOG_XATTRS for attr log intent item recovery Date: Tue, 15 Oct 2024 17:11:09 -0700 Message-Id: <20241016001126.3256-5-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0061.namprd06.prod.outlook.com (2603:10b6:a03:14b::38) 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_|SN7PR10MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: dbaff427-078e-4432-e093-08dced771acb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: frW6snPAh1hfi0EwL9oo10uPROqG38Yqy3xDu5KA5ErE/rNzCab0H8dvd8mlEMZH2DaOa/1CDMqanBOQhgMNz7FTRGNz2FCnHo6crEDtcB/nrANXSHDbFMNX4AhYZfq6/sJpdHYIe7rff/J1JllzvW71M/r8yfSIblq4FDdFK8hy1dcUNeB8EX7iojwaUPY6R8bW8xH3GqC2lnfRzBcFneDTEJXmFldk45MVDR2owfB4/KnzPyVtxp04qhI+AK25wdJURgKDGeYnaSB+A4Dv3C9xPqR8fD7ShMvTILck1GO6PoTMv5qQOPvwWKbdyMN3PAENhSQ0jTql0BG4pLdB7q0igOKF5nu0/YXSWz+OoL3ptTv6gP0Vv96tNUUXPGzh/6AZ4/3hRZABpuc9uOUSs9oY92qf8+7nExlhRyRVlXIwqKkd/aUeecKgwHYpA7K246y0vyhltfAq/qsMXM8njvnw3GYz0vS/ra2tHhJ/YcrCg8CucTVY/m6f/JQ+3T7Lb2I0O4P+qSeQiivTT1NtMM35QhjY44w7fGP1Vrf6c4PKHtIzv7uhdNGC6i+aPBERkVPLh/8rTLPyFaK0bpy0RsxlOLusu8vKLdOW3hXEYI81c62FzBEfpcw7cqbgA2RDkScnm5AnWx21kphC+ijvUSOzLNGBdwuEwHSCLMYEj9XSXCAPuD08NPg3v5wuhzp++ye5IzvzkZoYFdwCPqOtYJ1Rsijwm9QTS5IaSHv6M1DgIapgKnEih1rbf4hk+gbMJ1gYutvbQNRsWjgfjGdyjpJZg02bo0ZxnF/eskZSgrR78zx1IaVJkEPQetKLG3Oc3/+7GcfU7WuoSlx7BMf3i10Wp0qwBEhHhFgdf+Wc7PQ3aJ5y9iMH4ovN5EyB4KycDj+1thqGhEf6CBbb0eQDina1AVw51mlt6syqAq5qodGVzFd5M9f7k/tAJOO80AEhcrnfubjA0cLWIKs438me7Z0djs4czSPE40biKmkj+/OApA9fHly2+HpcAdsLtIuQ7X/DjaCZ7orrE/1+xwly7dTpBKzp1t1KGblqK1NUzevJfdYiF1beakXKOSQ+oXzgEugQZis+OroqqWyqZNkziMJa/9Izw6QezhZWq4w394GOmPQjqJmXDy47+QOgoi3sU/1jRMc8a98oBN8ERjXUATh4Eua87iijfHiuxelxsuV2Bnu4mSjJid5gvUi/hkuVgKWg605rWgv0p9N0hT4YJFupfj0ncezjalVEc2Mo6ydCCGJxjU3R0d7PgA1Jj/VCNgMCZdtpfSzTe3XxTakbSg== 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:(13230040)(376014)(366016)(1800799024)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RvEC4QTzAI00yPFSlAfqeco7WDpzRlZGLLVFDXR/eNptKXMHhw6Pv+/3k0XPNwrCEOBekF8kOM0Y+wK7iUgNm5QSUeAnlAt3Otdjlu1lGJbSMKgYUHg2OoYpwj5QkdWDFaLQbl7bIHN81jpjLKrizmLacRB648RA1gryBcx4+AEyARD9eq5rvQXq+x2GECtmiK8rPZlcpfNp/0LbVAxoyobjLU1qhGJWcIDYp8FRwfBZ4WQEpE1mgWpzLRDQaqS3Eag9zwfbLYOcIpKNKGLkTHkcJGVXoJLdHPoI7I5wev4adI3Gs73k/nxJbroB42Qr/jn91iZCzzTL6OQpB/xKtPco5zKhQQMxyma5+qen+52rSrWvbrEbdlINaVPkGuK4fDoVLqGqfEgMqQQxTs2U1mZzmZ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Ok4uMCV5rskrrWmosFJ1hCh1aghxaU06Ng28R8EirI9xVYEuVAAb17n9i7DLaZ2N/YNgRwGaVbI+K0bJLxDdA1p6Ajkxhz3eo5Cpl+QYi97reB2urfVL0Cs487LtJL1ZUgSoe3ma3JNu+M4oj5LedmFu1HvcnlcY6munz2LCiDtT/S4mFjJKdv/cWg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NEgw+7nhtVHV8t8+ePJ8rIHR9E0/n+4lFLQ1vt1s6ykZLHsA/QyS+T6WEpizlEETQCH65oAI/lkOL0qdfR98tggBIjxTlj0a5GGe7Nobuel7jVKoQBbziqb/5xnj8g7AyqFGu2bzLCG9+YPqBDvoQyxlJVnBUMb1Tpnp+Hs1OGPTbNVrudVZXvXeaWWq+4TnLnMX7bgHWnm756rTjBWYVFpOmKXHUlopqVPRp6AdptNDrJfU/Ra+KxhUak7Fm6fsPydfmnPFzsH3wDfMhDdR+BMxBUVJ7B7+q9DfV0QJEA8wafbx9ckm0eYKgTzw0HpAVApis3HXVqRJUa/n0OxSo6DCt2KtmCqBbrGntnXOaXW5bS+joU7dOzjwoUuaAYymSAFryT1ZwIAkmHrCjv4GBzzaZkT4DTZ7d3tlsS0oxE/P9kXfkHK1PjLHm+zqmj7WRctf5/3PA1krrZBnNeOnEkx0wFu/4ZTWRHet30DDsAINhYDmlMH77LUqWiaSEiHhfs1MngKKGWC7pvgigEao40yi0DzXOGDBhzf66Ezj48NTV2Bt0oEJZ7NMjgNkTDvPepDm1pU5TaRT2zGp7GYo8ERk6qWyi7CD/XGZfl5NBDM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbaff427-078e-4432-e093-08dced771acb X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:38.7604 (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: RpdXurnibUulsiHAtMb4FR196T2y7KMBDzvqk2+gtMMIcjuqoSCQE3xdGJysGFhXx+UP4baSFCo9tmAT13VbB+bxZtnYll5ghPJSXXEMegk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6977 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: GC6sdNJSJa2tZtdacwt8pFeDHmKA4N3Q X-Proofpoint-ORIG-GUID: GC6sdNJSJa2tZtdacwt8pFeDHmKA4N3Q From: "Darrick J. Wong" commit 8ef1d96a985e4dc07ffbd71bd7fc5604a80cc644 upstream. The XFS_SB_FEAT_INCOMPAT_LOG_XATTRS feature bit protects a filesystem from old kernels that do not know how to recover extended attribute log intent items. Make this check mandatory instead of a debugging assert. Fixes: fd920008784ea ("xfs: Set up infrastructure for log attribute replay") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_attr_item.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 82775e9537df..ebf656aaf301 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -510,6 +510,9 @@ xfs_attri_validate( unsigned int op = attrp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; + if (!xfs_sb_version_haslogxattrs(&mp->m_sb)) + return false; + if (attrp->__pad != 0) return false; @@ -602,8 +605,6 @@ xfs_attri_item_recover( args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED; - ASSERT(xfs_sb_version_haslogxattrs(&mp->m_sb)); - switch (attr->xattri_op_flags) { case XFS_ATTRI_OP_FLAGS_SET: case XFS_ATTRI_OP_FLAGS_REPLACE: From patchwork Wed Oct 16 00:11:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837451 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 9EA024C98; Wed, 16 Oct 2024 00:11:45 +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=1729037507; cv=fail; b=K/8t6mtYnCq83DQ8mfWqVmuKsPY/nG3dPPoOfXSRi+QsWV0Q7lbCEYBZKUHITCM+PnwEFlvx2zD8QVYqSuPgp8pw4e72MllfU1fYe1vI9v0iCbDiXv4eslA23nQ9hjijbES+bz/tWlriQpb8uvnhTxeB/t3oWopf41kNDHATF3I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037507; c=relaxed/simple; bh=tXbw7aKcafUetUImBYhASRERU2SRiCTUl4Td9+dKIKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PQHIOjey86ShmTYVKzoWILmwq1s1uEsA4enF1SmFstZXyfNbXPggHv/ALRdLuhyNbJMbSSnRlO5j+mUYevyVVGaDyZY9SulJMYZ5tnxRMm6qynSIc2+lsl1QOKOxCEaRacRWurNDZ7cvtGRxMWAo5DpR/twn3TlbHAAg0grf3X8= 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=fhFbuDFx; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MC5pZuXp; 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="fhFbuDFx"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MC5pZuXp" 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 49FHtecc011676; Wed, 16 Oct 2024 00:11:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=V5WzmjmwsGr5EMT+EBfxs4crY4xFtkfdR3T2is+OkfM=; b= fhFbuDFxBmU+oyztvdYyE/Y+IOAz96SxR6CWq0v6XyLjJUE3EW1wY34sQkADEyPG f1KRdvqr6NXzeAZ4NL7vS8MduYqZEHvio7Za5I7sOsG1W96QV5UGN7NLocacLpr2 xWmyHmDzxOVZeHShZ/kMRZDTLC1TNBMAmDsT8HdI4J6RMr5d4TKX+WEo19nHW6CM JK4xgRZNnT9QwfV4DgZJRbbH9QyaBRayoztaaYukbS3dTnaL62ACPaEppohrn1Z6 b/PQ9Kw++Ar9kva5tidKttOb2vZrLKF+e48y6K8Dnr18elVLlb/+ciA5krB7K+Pu UVGthrygY4kGscYd/FIIQQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gqt2fny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:44 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLhgwE027269; Wed, 16 Oct 2024 00:11:44 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2047.outbound.protection.outlook.com [104.47.55.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjepym4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HqV9KOVopVFrqco8sCRDr82I7xHqzI010U55P+LeZdl39ltVLClkKCQLbdnn3IOz8orATgY29VMJKK1Y0ISAe09IFjxOEh8N7N/Kod9RBEQ6HZdTuEsz8Ex0PYIfTz4gzP5WOUBZty4qivRu28oE/iJUzxCaPQ9UDOPmKrdWWQvQqy3acUDxzpFwosOZRaf7p8hWPj96lHBXol59JyCuSQgnv9AEM0AOVjOm5iio8q2igL1QcdUM8AFF5irc80JIbJqp9oJoSJ6oNmEAjUJJTaSgU3b3m+jM3ZrmHjqq+KCSmLoEyB8gwWxu9Ay7hvjTuL7Tll4nfdyHYb/YeHJHuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=V5WzmjmwsGr5EMT+EBfxs4crY4xFtkfdR3T2is+OkfM=; b=ZK1lubN0O59GHtSNjcmlpgREu2Wr+zYG5dou4GlXuJpKfJS+98bIchpG/WoW6GGSkDpRwiHTVz+WXK85OK72ie5ebgpPHLGfE6xwkFnpZgsAsVd+ey1DI7KCh/1runnlLv4AoMdSARMyf3Y+sdOADuImf4sxkAzsoLr6egphgkrzNV4v7Z9ghHPGVsxlCveSi4sO97fnRE3l0rQanNAoU+G8pnYzNhcrfm4L3reeYQK5iLqvcN2VVH9AoDZiy9i4sBUrACOp1EcHDyn1ZLk2057MWsartAgaHNofmTBGURENamlcSEsUOra95E2W25D2ztT63w0jacogglZKQuAjEA== 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=V5WzmjmwsGr5EMT+EBfxs4crY4xFtkfdR3T2is+OkfM=; b=MC5pZuXpcD5TajNF5JcD+mXV1QIEYHHNfOw59KMpOW56XESPtj5lazOHg1j9i4ymbDBH0cX49A0RzkU10a09UZYZeMj9ltrsyuqgDYiZd3u5kKhJlf6jsURBTtmdKaAo+/dODgYY0lerJtjaZIOzrDIMpwr0GF+iU0x5TWyUqx0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by SN7PR10MB6977.namprd10.prod.outlook.com (2603:10b6:806:344::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Wed, 16 Oct 2024 00:11:40 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:40 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 05/21] xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2 Date: Tue, 15 Oct 2024 17:11:10 -0700 Message-Id: <20241016001126.3256-6-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0058.namprd06.prod.outlook.com (2603:10b6:a03:14b::35) 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_|SN7PR10MB6977:EE_ X-MS-Office365-Filtering-Correlation-Id: bc1af901-7f80-42f2-7be7-08dced771bd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|10070799003; X-Microsoft-Antispam-Message-Info: Z9dQsCWwqQrFIR37zn041i49Ct9r91tpwVMLUyo4pXTDpI6t2z/ReuACQJril1++0MOzptTXBBCUTyfEhCDC1CR6TjwV0TQajBp8UVjBocuvUJemLk5mUqwPtfvOZKd4gcwTwRpqpPbHuZNu8tXxdAgj+0ByjeAy3T7n5xmXjEhsLx+rXKoe5Nl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DwvtHB81a0OaZHPjXJvprb4SxClg1A== 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:(13230040)(376014)(366016)(1800799024)(10070799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e4xqupXf/xtVMD8bK8FSt5U+wDKEStX4CNbQTR+90/acb/tlThr43XbkUzd4JCgsTtgNhujbT4Z0lXEbnLI7Iw3Qp5+4Ub5H5nl8iQVQ3jMvxRYY23f4n/jKKdkZKuMjGDXnByRO7l+HdllAWwfCDBZnjyA1bqqgKtyu+9piHMtp45ojTc+F5Cg6twIgVYb4xU2r2PMrCv1eMFsxC6pUDvjMpotLGveYETqKCXpCeUGmYKI1HWEgjLe9H+vDQHkBY1ErO75/HCkC22Uve8VFeIqOqFGZJKHHiNy8ufhv75kobFe5It6HHdeIAouC8T25oKpec1UCcDwzLguszR++rRgBzuZ6oxB1dGL3nHxh1v6xVdRyTp2Cvkn9jtPgkT3crMGE4/rOM3fUDoa+3zu7gd8ReKa/jDHhK5Qwgd/1lH18rybDN3+OkymxoG6T983p950uqw9KsLyWw0HyKAhdOUkiIV+9X6lgOwUi3cDCwWDURyzwHqbUo9HEPI9qDXbuSTdP+Uo6i9EzQbrNjWaCy1usiRnvS2XJ3T5BPq/X0Iu/ew2YSUL5q4S7zNL3UFBmX5j3xffOFwY6fvHNaETQBtoBOgj3T/THig7vMZF+1C92ijcq9YQl06tI+p9hBzlv1+CPFA9XywiE2KTuBVY4sTH1MNqZxgCDOyOclHS/POYlNbjl3RI1HZl+3X98P+oyT3F9X6K4OUNRbfuiTWqPou+Z61yAM+4JZnefiL+PesE1TckSHfvfeQZEWJkLSjwTkcpQCo8duL1iLVWEEans4Xr4ty0XM02Y0pUqAdpexk3hpKzwBKsBNVfElPG0TZKn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JL87Rd4vVhJ2xuj/NDLAMk3ChrthrYGyaizqA6USZRBXkGVljpv4TRl96GOy2J/wVxA/q0nVCU2Vx83D6BHNRxqB8Q8s1M7jYTAH6eis5jhhZBY+kj1IHSdyeaJNtVPplhmADyyavfS5hXBoRMk5kjDQ+HmpAIygGQr+0ZFwD3YSTjb51Ky2xIw3P749kiXk4AKx1fEHP4UegKcuZKqbZ8QiQRMQVZEFa+NK2xNbXoSET1EcZGTSnKi6iNZQOkU9wz9NT3y5G+PtQDjtcsEZ8GrcXP3BCOsQLQb8nXYpHSjqxriug8yS1RYZbYQuvEk0pOJuzaPDbbonhraeh8ziV7L0AOLbh85rCboUkGNQDWiJQIzqG/l0IZEbB9/YKqbsztl7Dc9MyhXbcjHehGzod9FnyIMDplKs9XKc5iHL45WSDyAUXt0nfsIHjYrv86wEVLAdRWPyglNqQHrhR9WWTZs3e0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc1af901-7f80-42f2-7be7-08dced771bd7 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:40.5370 (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: spgfCuuFCLKY9TTbbT+O2FNurVZ3ix/K8wAPeuTesiCMUHLSiBJyAnWEV1T8M0JI00jSEia/+DaPu/d+OX042Eh5USrdZX2ZtbzsDwoh6nU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6977 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: IO4drJLBbdD0uhRUZaORmKIe0HNw_67P X-Proofpoint-ORIG-GUID: IO4drJLBbdD0uhRUZaORmKIe0HNw_67P From: "Darrick J. Wong" commit ad206ae50eca62836c5460ab5bbf2a6c59a268e7 upstream. Check that the number of recovered log iovecs is what is expected for the xattri opcode is expecting. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_attr_item.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index ebf656aaf301..064cb4fe5df4 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -719,6 +719,7 @@ xlog_recover_attri_commit_pass2( const void *attr_value = NULL; const void *attr_name; size_t len; + unsigned int op; attri_formatp = item->ri_buf[0].i_addr; attr_name = item->ri_buf[1].i_addr; @@ -737,6 +738,32 @@ xlog_recover_attri_commit_pass2( return -EFSCORRUPTED; } + /* Check the number of log iovecs makes sense for the op code. */ + op = attri_formatp->alfi_op_flags & XFS_ATTRI_OP_FLAGS_TYPE_MASK; + switch (op) { + case XFS_ATTRI_OP_FLAGS_SET: + case XFS_ATTRI_OP_FLAGS_REPLACE: + /* Log item, attr name, attr value */ + if (item->ri_total != 3) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + case XFS_ATTRI_OP_FLAGS_REMOVE: + /* Log item, attr name */ + if (item->ri_total != 2) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; + default: + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + /* Validate the attr name */ if (item->ri_buf[1].i_len != xlog_calc_iovec_len(attri_formatp->alfi_name_len)) { From patchwork Wed Oct 16 00:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837452 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 976C0259C; Wed, 16 Oct 2024 00:11:47 +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=1729037512; cv=fail; b=i80Ph9LCyJEVAFeCzProY92sGJB7fFUjvK5RljiXqykf/JSRpxqEDmSMb08qxzJnYgpUsn2RHBuGlACyJhtIuojCPJjOBu3Y6XEZNg00ihaRwj/WY3svS+HZm5l6XtZP1Y/m8zdV6SbQfH9w2qdCGgm1ILBcQpZfPSVSjp1D1nI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037512; c=relaxed/simple; bh=MdUmciKtoz/QqrY+nukznfsBi6zDTkQCc5e2jbSGwlc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=WMxyZyWcjOxb2IVrlA6lS/V+xj7RKC5ExiNhSvHeqNHsdpJBvXt6O7eLLSLovUA9uyi8b3oHZHxYD9g6afLlRTQexmEwP1xYUZNWTZQi3C8FVPodqZE2jPWf0fX3Prs7Q32GWFihrWBIWEQE6UrekP+yp/O9Fk4NFrZjS5+RRYU= 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=QZUJ0hXn; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ngB92oiR; 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="QZUJ0hXn"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ngB92oiR" 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 49FHtiin001646; Wed, 16 Oct 2024 00:11:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=vToyfmovG9qXzauVdmCZzg3AazJ2tFf/23JNbWxg9v8=; b= QZUJ0hXnDWWgV0VQyyIjUSbrFGRB4GIQD1lBytVrOJw944PjGfi4NcGXxGmJdcpf Ra5/KZSIl3WcBOA3kZeXoztFv4i9hCSlRMdJKNW5LVQUrUDaElaPGaNpe2Jt3x6I sXm5lDMkgHLhOq96Dze0IeMU7ke774k0QvWfll75HzPgcjwT2+luBsdZo+tQ5ThJ yYU4E6yCKXoe6JPVRPdfa/qPKk+pOC3cQKebpcCw3rCBkT7Fm3uG5wN4xyE0WqP9 WByB4DzFi/DIqG1MWNB2O8mcMv54zkU0J7ORQydfhWKBK5m6Fjg+gcMS2AHlroho tYWfWvcTpKoUzDpsiKyCLg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427g1ajb0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FM6a1D036660; Wed, 16 Oct 2024 00:11:45 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegwrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F/NpjRWB+0bKBIg/jwbTFtvDbD5xBqIHpTpo93Wt2g6wrI2nr1C0TIaL6l1w7ZQUMkrfgQuUbPhWcaiUxWTo8htoBx1Pfbte9ti7xIBcyIPzpJZm9H2EprT5s8uMQKWl8xnNypBXa2O+ih7PXYUAUUIn8+lyEt3ypB+C4UV9t3LOF+Tyb92M6w1Ua1HRH+eebuh+hf/Zh5bH5Ty++XCji9qlplXFXZgbK3nEl2NpuuV6UNZYm+n+TQd4fHoPILY85tTaUIWDxmeKqpofRFCDVnsnL+M76r7nQemY945ukRnEwVTr0G5BbmdyBgxZ0G0uo4c9qju2h3Hfrut9rQ6tOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=vToyfmovG9qXzauVdmCZzg3AazJ2tFf/23JNbWxg9v8=; b=Np5N1v9t86Gxro0DPBUMhlQ+kXCuZSFktdJSY114YG9WpodfYSZpLEUDEOVFOypbLm1zfyRQecj7ICkfJ0oCQrf5Xyq6uQd4R7VLk4PShFvKS/IWkQKNPI9vazALvGa9fApfkMvUGX8Jp9kZ8JjreBPxP8IQKJkZnXHtlQuAXArMX8B73IGOXupQGy3q9t6ciIg6gLDmpoWtSk/top+xiXjPrApKS366Pkx7cZFL/3MdffiB8oFsOBN9SgSua0fVt10pdpRxcy2coVTulStk5UUWNYKe+8cvZ+Ry2ln3PJDt76Pd4JjpArTz9BDtelsaWmiX9hbkZwLx36iuVW0w5w== 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=vToyfmovG9qXzauVdmCZzg3AazJ2tFf/23JNbWxg9v8=; b=ngB92oiRBz6xGFa0mWrGlHPTXF5KmTrjklLHIv0D8SxeMnyTRxD+TUNW0Rvb/6d2YBIPcanq15AhmU1TAbzChBToLmOLiO1Y5JAxfU3mlS5oVtK9/8ooQzoW7l2TBhzWaOqMpr69T1BgnJY2Ffr94u3KtwfowWMOWqpdVv5LD7s= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:42 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:42 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 06/21] xfs: fix missing check for invalid attr flags Date: Tue, 15 Oct 2024 17:11:11 -0700 Message-Id: <20241016001126.3256-7-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0066.namprd06.prod.outlook.com (2603:10b6:a03:14b::43) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 45767afb-7201-4412-7cdb-08dced771cf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: pG3bquysINDHUFA6z36hHcgXvL798nWPp+iok9oU5TgWlxUxgvGkop4f8MQbFbLSABQwmY6JtrrG0kZHCm5Ses+Ee2JII4GocDTOGqyirsGzRoqzVVCtrh8aZX6FxApKI5NVRDW+PnZx9dpz8+q7TqiHwa7NPy9jeci0smPwKWw4BWi0HR9o1THvRtlpkfGD/Q+RtVgNn+MDet3vMD8G4003nqz6RqcpyWc0aAKJHzGa29MpRQuKuwcotSx3ZDuXlxfXXKPzHRMRhD1/0SBr8vcypogXM77QJaqVBRkCHw/JYpMEQc0xqe47hFsxBRcjQB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com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i5DKoUmXSAd/bY7RMbw38KSJIcvolmiF7lE64deZMNnlBjxHfrK446ypwuZuoNkaxI99Mamc7XIwL6EYSYA25GjjVHMnxLJCT0ASINLdWdJ4wksX/wGcoIcOA4bev/4P77tCtjkNRfdZ/4zkDPFr5NSr5KlEVl11T+Ly1NP26DpKiu69W00JRYNIbUTYo7IKzbWk39co14xrxeK9BP8EVzjJTBD2TM3ddSxcxJiFq92/qhdERJrwkRINE/TBHUJjQJgh5u/B7wQQftLpO7J5sUXm0B/pHcwgHknJHD9zC7L0IoeiILQ93zKEanzMPB7ov/4kgGYzPIPzEqFn1wp5WWSjX/F4XawXyIalKvifbFJFDjujWTYKXgtxVWD+21hi4f6jSvY+z92FYRXo3fjACb7q8KBcpXF4g+c5Q1ORBunAuPXSklM9f+6NdrViGnhq24JHbiZpeKcjTOpxce4vCC4wSSP/vGBwDsh1PeuxIl2D9RTAAoGNQ04S74S8SL00n5oO6a2F12ztwLZcTxCtt8Nl8MoS2yoTgQpt5Yj4iE5Mp5fM3ItqdT9ZRGqhwaZTHGBqMFmnDeE+xaDo38SJs+0aqoKgjQC2HvDZbg1y0ycXlGvvBTJSp0ioRRoso31CPc8c3p8bdqHCmPuBoYLiKwUROPFpgdXNusuG68pc8H+yO4yMEuyasOFD04U8G4aDeX8iHaLWRpTBfDakqR0mLf6rWmVknu02cycH2LK+ZBwA/Qdm3Jfr75JjPDD7Lw0hGHkdIHnD8aza1KltOTaikF5enFwix/y6AUOhvWWh82Myd/AUoOB76S3SnXzbB6TKuzeWovGHIQdP/D7KRMRd6vpxQF39YjvkT9zvVnsa863nDAhpLvt2UAfFfS70lt4LXLrygRPGHEv0NfoczKHcQXixLLSIUdNckUzsJi5g9BnA5l4nj0yLEOT31XM2hNiqrf6FJ/d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VYSR10kRDmw9+ml1ZHZVdd8cJLTTzUfDbLIka5r3w71S2LwIjwxK/jB6uzhttfA78z6qEgcr1vHtHl9CbpNrw6k49PyO3+je50nNVdN6RLIhozvXgHG2a5PVXiKj7z8JJqAzaJ6u73Po6JnJgQHE6yGvL1/L+Yc1+IwGuVsdUipau5Q5E2UdWOsCWNIgWz54kaHxeDMxQ94cpodGWd3lLgonLNgaT32c9hGbuZvv5UA1Q4JTc2Z+8DMmPemB8C6WiRY4/Q7EThqAdwypQkjery42sfcwTj1rDIf16nNuiqNuBhncxE5gOCDzvmFidU4P/wrhtBPKLWk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45767afb-7201-4412-7cdb-08dced771cf6 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:42.3500 (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: BvKlQue7muQ8Ljy4b3cClWSn//AOGtqYeqyrBKYcFW/A83gq99/rEQdwso2Knze0AX59TaK/vVSRolmdPhw2KXg20oGsfLqT06zhCiCvNgw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: tGMPqmQ3B-ouWNzfKbwWRE3kuiIlTK-q X-Proofpoint-ORIG-GUID: tGMPqmQ3B-ouWNzfKbwWRE3kuiIlTK-q From: "Darrick J. Wong" commit f660ec8eaeb50d0317c29601aacabdb15e5f2203 upstream. [backport: fix build errors in xchk_xattr_listent] The xattr scrubber doesn't check for undefined flags in shortform attr entries. Therefore, define a mask XFS_ATTR_ONDISK_MASK that has all possible XFS_ATTR_* flags in it, and use that to check for unknown bits in xchk_xattr_actor. Refactor the check in the dabtree scanner function to use the new mask as well. The redundant checks need to be in place because the dabtree check examines the hash mappings and therefore needs to decode the attr leaf entries to compute the namehash. This happens before the walk of the xattr entries themselves. Fixes: ae0506eba78fd ("xfs: check used space of shortform xattr structures") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_da_format.h | 5 +++++ fs/xfs/scrub/attr.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index f9015f88eca7..ebcb9066398f 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -703,8 +703,13 @@ struct xfs_attr3_leafblock { #define XFS_ATTR_ROOT (1u << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_SECURE (1u << XFS_ATTR_SECURE_BIT) #define XFS_ATTR_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT) + #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE) +#define XFS_ATTR_ONDISK_MASK (XFS_ATTR_NSP_ONDISK_MASK | \ + XFS_ATTR_LOCAL | \ + XFS_ATTR_INCOMPLETE) + /* * Alignment for namelist and valuelist entries (since they are mixed * there can be only one alignment value) diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 6c16d9530cca..990f4bf1c197 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -182,6 +182,11 @@ xchk_xattr_listent( return; } + if (flags & ~XFS_ATTR_ONDISK_MASK) { + xchk_fblock_set_corrupt(sx->sc, XFS_ATTR_FORK, args.blkno); + goto fail_xref; + } + if (flags & XFS_ATTR_INCOMPLETE) { /* Incomplete attr key, just mark the inode for preening. */ xchk_ino_set_preen(sx->sc, context->dp->i_ino); @@ -463,7 +468,6 @@ xchk_xattr_rec( xfs_dahash_t hash; int nameidx; int hdrsize; - unsigned int badflags; int error; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); @@ -493,10 +497,11 @@ xchk_xattr_rec( /* Retrieve the entry and check it. */ hash = be32_to_cpu(ent->hashval); - badflags = ~(XFS_ATTR_LOCAL | XFS_ATTR_ROOT | XFS_ATTR_SECURE | - XFS_ATTR_INCOMPLETE); - if ((ent->flags & badflags) != 0) + if (ent->flags & ~XFS_ATTR_ONDISK_MASK) { xchk_da_set_corrupt(ds, level); + return 0; + } + if (ent->flags & XFS_ATTR_LOCAL) { lentry = (struct xfs_attr_leaf_name_local *) (((char *)bp->b_addr) + nameidx); From patchwork Wed Oct 16 00:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837455 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 5DC56B673; Wed, 16 Oct 2024 00:11:54 +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=1729037515; cv=fail; b=BnRyE0RYQ7CtTwMxjSDm7tInRP+n0RsYnrb9B3y5TIDNze50vLAJ7kBxMQ+y+FMGSgwY7MK1F20OQqHDAuSOSL0kpfcqSxOyANdJf7imLP6jDounH4GI4x8CVdZHKQxw3pICk4Ld78AzKyLRyTctey4EQKKqpVDJTqLpnV9bvSI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037515; c=relaxed/simple; bh=IKpHs/vcpX3tHyXAAHi2HLlw5WIbbG8K4GUF7lETtJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hhwNv3a+GoYI0LKSkk7wqqI1Ku1VE3w9lX/EYVSJU8w1LQCpvtON+TUeCQdAgyOQCFLvQGhu4NlF8hm0OZzL0DPJG/NrS2wATsNO4eFg90aaKgbGc/mHYeZHCMR0GJUz07cEK08fy3wxJHjUfxp0dn8xSXRXd5URfY5mJFnRHUk= 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=nNNNzUB3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PeTLC//K; 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="nNNNzUB3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PeTLC//K" 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 49FHtik9019421; Wed, 16 Oct 2024 00:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=AAS2J1xnl/M1O+Vhx2m8stCKhpDUIkJjCKDURS+6VCY=; b= nNNNzUB3Ps3Yzn2B3Iw3+XCj/rql8vp3rnLsY+yAJblIu3Br/YR/Bhi8jd0FrHRC oh5n6b0FmX0ptoVozd5xV+nDiH9iBjjp99j8A8hwcNadahZgUh5OyNS5ztp3tCJM 0EDUiIJzbs5YVJ+hHtyFYbM9Oj4smkPLdvWYKlSEJyHL/ooaBWWdsQVMpvnOhr7m i8jQyZscSVE8z4ieIFK2N4Esa3hI72wWWVl7kQXGNKyEqI0T1Rm0FmPsRb3pD91V WKHGtvlRX7rCJq5Z9fnFbamDMyY1E4xIOwIgzYg8elV2GPOL1ixT67eFHku1nk5Y SmpyMgRRhlZ6eUbm3a9gYQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FM6a1E036660; Wed, 16 Oct 2024 00:11:45 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegwrk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yagkZpeZ/QzjnWZCPII3IDOUWFqlY58qW62+/S0NiZGTKdn/SPMRLl5INYpqhrXRjD5MA4NBGfQ7m6at6b+40wo7bLmJAY6oVMvJICpqYPZYQUwWpdUXJ1hiYOfYfQvDLcGtdOAEwJ6XOoAhCuKcIHinxNjH29cXewKIDlPI3nU488rb/42jOF2VzGS4FSTvu5gcAo5l80PAiZu40ZLFmAK/6A1R25Gwd2Fobx316M2RfveouBWtSg2xXY3IZu+upYsXxqRNOySewZmSK4prMIFMcCwiKpx3XA/Nc0NqL3ZvRO2a88xYSj2G9Z3RKcLPhEI0XfVO0DpBS95NIKutJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AAS2J1xnl/M1O+Vhx2m8stCKhpDUIkJjCKDURS+6VCY=; b=FGMKJGQkE0Ae5fgoxrWMwXKRMcqrK9Uu33ip9ztgdq9Q8ObTIQUCbyjqhdOgTjdM4GJZh5v4oGqazE415fM0f8OvIDozh+i6W0RJzGerfi3uzbEwmmUGPwqQ8h0KESqRN/zxwQNXkxISpSvoO/4yLLOzHAWVg5YQdnERo8I9CYdvVzRX77pcbJzRbITpKuIE6JCx4Z7vByoPTMuc4Ptd4YElerGiqNESuOqu9H3pcKOh0D+H9Q9h9JvSaMCN+RGe6CKuw7KtZ4Wb3bueYHG4ACHOAOieDa60y6JqaYlvX/iX8LzGK0o/f4jzqvx1vlxVB0NRN1mwY0+CN+pp+TEEPw== 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=AAS2J1xnl/M1O+Vhx2m8stCKhpDUIkJjCKDURS+6VCY=; b=PeTLC//KEbuemduMD3E8qZOp2R9L4qz72A4tQQ6Hh1InLBI8AnUo/yP+23GeZDQ+ceQ8YZcNDma33wI4o7uWctQMuTwlQ5sCHbLvQm30TrfpvxL5S8i5lmW+mkj+/7lRWd5K+h/6BavUUG1sOtH9yi2eydgfpWPZH/OjNUbtsc0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:44 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:44 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 07/21] xfs: check shortform attr entry flags specifically Date: Tue, 15 Oct 2024 17:11:12 -0700 Message-Id: <20241016001126.3256-8-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0062.namprd06.prod.outlook.com (2603:10b6:a03:14b::39) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 25e0b8cf-a8ca-4337-a518-08dced771dec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 6q8TrxJZxDugCOvw2jFT3pYWsSukbHcD/BKsPhee0P9chR1I+AuBTw4jiJUEKgu0/qhe25QvSesJioBbKWrohHHVd6h2c+RY9Vfmm+CZW9XRpV240Wz1pXhRspTlx9kBB6QoL+yVLwPhUhZEoClAk1iKampjdUp/hOcx1QcGtCFb1e8FAa91Kd1TE9UfiU94JubPrpHe6lvD8H1/0UAe6h/AjLhfptwSvz39sxNtsJsAGnt1nZFFIWKPhXy28IOLrDR5YDnvmnIlbTSUEkUQp+hUccXB7mmr31IpGqDLGyKoQE61nwW4iQeZE1YTicrTi3WC4+6hB1cugMZWOx0q8A6XCI0GSSJU87m1H3pF+vvJfiKq1mN0xGUOYBTwK5eWdX1vJirslag0uco67umivRDHTatBlM9P70HMIBzl+fxV7DKcveyqjk50VWxNaF/ZINmAKh5JstjQ3FP49QBuaNdat8CM4aPlrkCR6sCwzxYAKAhhTUzK97eVA6q9dYnIS3rj0cldnP5T6D0ciO7/FQ+N2LCUNDQVXTLueWSdLKdlzjf8LKtnAslelW+tac1m4vnYjYxGRcLAzeWHXSLbXMZFnbHo/5VMeKzv3N4XoC66lzm2yrE3lpqDawAs9Je9B5LhoIMxfrEfd3J4XnXYN0uRx5w3kUWLdK0rinr2xG3cH1HCb9gcl/VQmkaF4MZj+eggXaGl2pIZkvwEM3wa582hxMV5/ON+ih4b1YtlFlyYUygCFCALx/lNZe3SlOuqHqT6pzJOFwd97TAcbAuM5/tFwFAKZflwGkUXvdTlPpgpHxulCRYyn+5jN98n8nB9RpFeeME7Baz8fxKRQJyODZ7ljkfiHwU0UHxDcn/9u1sD0nGRkGurB8wG8WTpUbs2aqSxhXvT57ANocg1oVO0Zd5joQEM9fo3McwZLHfgZ3dEJHUk3NwEXm5N28c2kZjY0GPMJAkNkV+cWJxqU4SOdyClIjfxy9QNVBsRQf01YAthAXRCqEiFZQO1jReKoyzrrCK6BAIJVfk4Y/cgy1RyBNzuYUkolbZ72qS0ovFv+OzOouj35nOGNP+vkQ2x61hVwxWyHIgmMKEcm0vBzOuNJ0G4AfPTRS3j2Gv095IZ8Errr8wMzyC7Co5fuaDUnTAlTyrbKma0+maMFZRRKw+NsV5sRE+QQp/QfqjBuW4XaHc0JLv6vsMHZkYVuZPnBESG4e/xP2Oy2BCRR3W+mUDwwN8HvOYCKhSchgsJxi05MfozCbaOIl5LHbWbLjAAqKnIqwgW+FotBzJmkL6sP70Ryg== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3cstph/rwnorCOOd4jv1rCxzDxKo5FV9zEjSsrQRaxIS+qnsw7ipdcXbUZbTB03zhJjV02P5dJ/ua6a9B1hW4M+hiUYpF5CmiXRCDxgjh4DndMbIf0b8+jZ7TaUZS0jM90xB/B2P8u9EMoClCldXqdYEQ2rATe170VJ07S1KfETmNWhDkkZLU3d/4hAGKWEbiNNYN+cfI5WRuttvupwAJhnDN8K2ZNnhqccoPNPkMwiZ4ZQRUdfy7bVEh4QAME++u0T7HhO3Zcy6QAr5TGy3coXdWEBlCNY9NZdX8cLeBd8WciRqrcf/vQdEeYVQOBgjVfrfqZ/RK77ZkXMcIpfwzD/hs8JMgQQPWF3Ij9npK8FgRcfRFeC0MUhrhoiExMuOd0kds6ytoHnxprCREXUx4siEwZaRynqharSb6QfOIOiKgEFS0mTh/i7h89xJKAl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cGKZ5OHOOCg5eZTV19cTAd7dDyidORIpSpQGSrYdNsNu04qpwnanzcfQ9EbMRtLmAHQWWfGN9iWhRiILXg1jMH+KM22wTdZY1rhRi09gJ3p/HZYAfuxNgAZuDuGnKGnUPjXs0jIrhr6FSLND3Y9AeswBTmTO9vQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ek/QIFq8ECo8h9Iva4dlCypnMFqR7k1ELKrC1VsbhHYMJMSVE0PxP32C4F0ktdmoTEq4k1fxCf6rotd3F5F62hsdQ9yJDxNqlB91fffnCCPr6RcJXvYZ8iB73gC7ZnW2B+lC6KqKDCYmb2I8LDqBrJvsHTQUvu8qJRSrIHdLU46NcPcZjX6/Tfu8ZLC7kNXjnbX+/4x+oxRNPhl8cO6e1T+rhjZk1ItVtZcJjTwDLGCsWtfPvtwAcn7Kow5i5/iVnvXl49mYNpvo3vREok4hLHOcxBrZjlM0DvzXHsZfnAkED/JmoKcTSIhSn739LCyiL32mmkWcwWYKiUy0dlv/vHxLWzlQq/YorCXKvNeQBZZM86lWsA33iG6KDYxOM0hP/xFkggQ4wvXayfHT8jAAz6S5fqwYq0bYGe8gxrZwpOSMhI5LZiiI0BDn8a9B463hAcHp6oq4H4SNxntVsdGYgZTOYxLLcX9QxnU9ei724OVig2F4+w9awyJNBX8Qi5GBSTtOaxnQi9QMOeScbRZ16rFa+sEMI/VSSODe3yMLsPVTqoNggIjdBidQoO1dFg3b/JWq5bOjlfs5SF1ODsm4CeUfqvKuMzayc+hvIXzotyk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25e0b8cf-a8ca-4337-a518-08dced771dec X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:44.0250 (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: pUE7A8Unh2R/upv3qSxcyFyzPmo26BX2XfeRXiT61oX3Nj81UWOBpi0lfh7QLSM9F2EsyGQIaJtBp8JZMkkYO1lXcjxxfM0fY5VK7CJOI+o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: hEcE6qJ6yPQND4E9r32dmqrbXbS29cMG X-Proofpoint-GUID: hEcE6qJ6yPQND4E9r32dmqrbXbS29cMG From: "Darrick J. Wong" commit 309dc9cbbb4379241bcc9b5a6a42c04279a0e5a7 upstream. While reviewing flag checking in the attr scrub functions, we noticed that the shortform attr scanner didn't catch entries that have the LOCAL or INCOMPLETE bits set. Neither of these flags can ever be set on a shortform attr, so we need to check this narrower set of valid flags. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/attr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 990f4bf1c197..419968d5f5cb 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -566,6 +566,15 @@ xchk_xattr_check_sf( break; } + /* + * Shortform entries do not set LOCAL or INCOMPLETE, so the + * only valid flag bits here are for namespaces. + */ + if (sfe->flags & ~XFS_ATTR_NSP_ONDISK_MASK) { + xchk_fblock_set_corrupt(sc, XFS_ATTR_FORK, 0); + break; + } + if (!xchk_xattr_set_map(sc, ab->usedmap, (char *)sfe - (char *)sf, sizeof(struct xfs_attr_sf_entry))) { From patchwork Wed Oct 16 00:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837453 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 E5B003C0B; Wed, 16 Oct 2024 00:11:50 +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=1729037512; cv=fail; b=P/DN6vnzf75GAIrtnY0FSfAHTzQCJ1pzm5lBAuTZLOqji/AkraFlN0m1L7Yrx6TEuMIfOBrnqvRP6oSui6qr8Brp2VsF2jhmNEziOC4fp1Q8NzEzR8obpk0m0OoBggVKo/F6r2kuvVuGs5ic+xIA1eKnrDajQ+qvzFdCffeLBCA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037512; c=relaxed/simple; bh=9O7WeMDlEcG9jizvjDG2IbD7DNKi3oYqpEKhLtCpeNk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XS9//05dX+rFueiZVwVdNpDAN55nNzCCQKPePLad+rRcsE0xQF8qWSLaLcTJG1CJTQnfke1cr4j10q1I99bFzeRQTGdiIq7O6hVVGRZlV8lwSSN2mLu1xXRcoaiZ7FdZKTk7+vL3VPoVUC6jDSXTEi9RFg+1DFphkBafMlithXU= 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=OJYK7pfB; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=TrrVxGPy; 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="OJYK7pfB"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="TrrVxGPy" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHtdP0028999; Wed, 16 Oct 2024 00:11:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=F7gXWRnz/FU0XVpEB2URtum4ABl4v3V9m5/M6PYt230=; b= OJYK7pfB0ylMVofhecn1xo2VpthmtP1ZgS09BjBdvN6EkLvSU6+nsMirfWNLNP5N 8r/k0LGNXVuASqpPaQ8JistlzMfjJxZ4dFYTDZ6Y8Bs3rFDZrId+9IgUPbJ2RKEN Y0cdRL/h5QG1bI5vRAHa4CoZK0Ri5bepa0foHRzLxyLkch16EsyltF6KayWlpJIR qFwCPpeTtO2CUzoE7z9CMXryngLl7/SgfNYt642EX76lBLnapY7VGl6/rg7ksVoN eygiQJUPbroMdZ6vE+WcAooLlO8/SJFhDnyH6oqGfYO6us7m5y8zntgWfPUXQgnt /Ksjo8/BJh61ITAKJl8Xyg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2jk3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:49 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMj2LS026388; Wed, 16 Oct 2024 00:11:48 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85ahj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FVMQGOnfkf0EbYhHEIzOpvCaqa9ea1sRroKyBdsaPVzj3izgCZJk0MTNKfvAAXTF/VK7KCdj7+ujvYZq2gh69RBcHsbeD3XwqRiUEYA6qLuHp3INlVBCiiWKLyjqaPuZNJihmWMauxQflnhs/2TN2iVBfZL7i2rtwyMXnKf7+/vv8ikLF5Jprq4GaZ613NqJC+/QJVLnsOZbVYmJN2m22NOAQF9pdA4peevlggZhVmwkhWjqx2Jlu0mGQlN1ag5n0JgBfW53lpw/rtF2iT0bdExDiu2SzstozOAy04kE8kLgl7QQG4xFisvFP9YeXWqtC0TOt8VJh8ju9yz0KF24jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=F7gXWRnz/FU0XVpEB2URtum4ABl4v3V9m5/M6PYt230=; b=nByFiA24dO+5nzXctTwygk6ghAwY3UvPYmWPvzBpaxD0OUL0YjrTXKIWzL6amRGO6B5IVfsNU18GkyE8SONJT5OXWU7cg0GEianSCOplZDUoQqaq2l031ePxzgDgBEmsYGwLv0l8AAuiuz2qbEhR2rWq+b1xiu6YMM4omCZYWLnW/75dq1G63PGUCveziIIG0rw3fQO5mlmezQRHVRk/oSXEPGndRwc7rg3jFKk12ePdi+CQ7xzeBCJ0JZPRNbYEY4pjVcObBEfK2msdvVR6kf8UJHuL6VHz4wo74i0BLXPnXagtIk/8plbBztoMXQx2JMST/82J9wZrcgzHJYEAJg== 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=F7gXWRnz/FU0XVpEB2URtum4ABl4v3V9m5/M6PYt230=; b=TrrVxGPyfMkK9NTABAk+f9DIKtYQU62UWemHF/+AKeAbbGXbBg9Gbh6ViwIRA+yFIcXTlGxQwV5VIxkCvifbG+tnas135LS5suSvAk3e3/FCGbHtE4rxY0l18TDghdSn5HJtc6Kc4rBuG9FMQrCvz4m4dCGkSvg9jTJQD8zyBRE= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:45 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:45 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 08/21] xfs: validate recovered name buffers when recovering xattr items Date: Tue, 15 Oct 2024 17:11:13 -0700 Message-Id: <20241016001126.3256-9-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR06CA0062.namprd06.prod.outlook.com (2603:10b6:a03:14b::39) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 28d006d2-d596-42c3-ce9c-08dced771eee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: vASTANdl9fPgZ96n4n77t6G8i6Z0FDHsKWjocRNf570ryONh3eCMTyI7tMvdDi5FwGoJJWHJzFVu+Xr3x60ABecVuCXkRcso2ylVx/D/ZSqountlNbCEE8lUOgLUB095+Q7+ileVIra4TnJF3z/FkmIcPD+EWQGTd42+/BR/Ir9PcTuX/ee+VD7l/rKgYbTF3PZ74H01CzZ3m6E6r5UMyZFj/M0i28ADC5OUGpJ1Dds2DNoGeGabDh090oMH3BZZL/3jR56kKtPy11voiMlOsHesRz9RFlhSv1zp+7J6LK+10ffXgFHIMe7GLZcon4VsaUbv72gh07nJoANuCzHn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Lkl7h9yoOJ3jmQuZBjRoXNQSY0Y8k+MBPdVfsopd2FKb/lC538vomfIeGXwkH/xgxU8otQvpdTu/NzZV+WwnBxfyAJSCswX8Dh2yWgy8E9VoO6FKlN0KDiXM6k8FPkgesJJibYoEJpOL/eWEAYn0FvyBOkb+b8/4CjlmOaS0aMZtp7je7oxSLvyuMnG+EKargAF7HKkAYL8w6LvF8bGiGTIgsuqG3Fs5enFVl8CsVlpo187zORLHRlyjenJLh4W6mZDxVYu00xcx0cxOtoUBch6MPiB7gM+ahuQxbHr0cFwnH/4+oKT21Jw7fNbbwCY6VJ9uet9/6ls3eSLwKHo+XCt8Z4cRf5NnY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28d006d2-d596-42c3-ce9c-08dced771eee X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:45.7040 (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: qOcui/eL/5wl2zq5M7MT/3B58RLfM4GGFyPjh7S0EPWcwl5VJLTzGahL7KB0+QIH/xGwaslgPnLYzhC6ZpNNLEEL1yQ8BW8hCwvZEx6Utqs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: KqKcBViwiwZgHUs_ovCslIIQc86adHsf X-Proofpoint-ORIG-GUID: KqKcBViwiwZgHUs_ovCslIIQc86adHsf From: "Darrick J. Wong" commit 1c7f09d210aba2f2bb206e2e8c97c9f11a3fd880 upstream. Strengthen the xattri log item recovery code by checking that we actually have the required name and newname buffers for whatever operation we're replaying. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/xfs_attr_item.c | 58 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 064cb4fe5df4..141631b0d64c 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -719,22 +719,20 @@ xlog_recover_attri_commit_pass2( const void *attr_value = NULL; const void *attr_name; size_t len; - unsigned int op; - - attri_formatp = item->ri_buf[0].i_addr; - attr_name = item->ri_buf[1].i_addr; + unsigned int op, i = 0; /* Validate xfs_attri_log_format before the large memory allocation */ len = sizeof(struct xfs_attri_log_format); - if (item->ri_buf[0].i_len != len) { + if (item->ri_buf[i].i_len != len) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[0].i_addr, item->ri_buf[0].i_len); return -EFSCORRUPTED; } + attri_formatp = item->ri_buf[i].i_addr; if (!xfs_attri_validate(mp, attri_formatp)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } @@ -763,31 +761,69 @@ xlog_recover_attri_commit_pass2( attri_formatp, len); return -EFSCORRUPTED; } + i++; /* Validate the attr name */ - if (item->ri_buf[1].i_len != + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[0].i_addr, item->ri_buf[0].i_len); + attri_formatp, len); return -EFSCORRUPTED; } + attr_name = item->ri_buf[i].i_addr; if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, - item->ri_buf[1].i_addr, item->ri_buf[1].i_len); + attri_formatp, len); return -EFSCORRUPTED; } + i++; /* Validate the attr value, if present */ if (attri_formatp->alfi_value_len != 0) { - if (item->ri_buf[2].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { + if (item->ri_buf[i].i_len != xlog_calc_iovec_len(attri_formatp->alfi_value_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, item->ri_buf[0].i_addr, item->ri_buf[0].i_len); return -EFSCORRUPTED; } - attr_value = item->ri_buf[2].i_addr; + attr_value = item->ri_buf[i].i_addr; + i++; + } + + /* + * Make sure we got the correct number of buffers for the operation + * that we just loaded. + */ + if (i != item->ri_total) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + + switch (op) { + case XFS_ATTRI_OP_FLAGS_REMOVE: + /* Regular remove operations operate only on names. */ + if (attr_value != NULL || attri_formatp->alfi_value_len != 0) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + fallthrough; + case XFS_ATTRI_OP_FLAGS_SET: + case XFS_ATTRI_OP_FLAGS_REPLACE: + /* + * Regular xattr set/remove/replace operations require a name + * and do not take a newname. Values are optional for set and + * replace. + */ + if (attr_name == NULL || attri_formatp->alfi_name_len == 0) { + XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, + attri_formatp, len); + return -EFSCORRUPTED; + } + break; } /* From patchwork Wed Oct 16 00:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837454 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 70A344A0C; Wed, 16 Oct 2024 00:11:51 +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=1729037513; cv=fail; b=t30SEbxWXUlDK21L7gvOAp0aUs4OrHQcSV2Dsg7iZ26nN3cBrqXyfWpTh1dulO+9ML7Yyd+QbcDrhRK7fRldJyG0R6EnzUwrg89ZT6JMlGxzQrfIeEkt0FIqwu9fdmRgSESG3Wnhxr2/KNj815RGjKB4R/yiwPaM27p2FLgk7og= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037513; c=relaxed/simple; bh=kKVIWG0p5QgolIty6snB1psL8oE8cwVDu9CfFy1FJYg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=vBjQyI1V6GQwqMMRVu+tHMZCpQWFxsRBMbF14vNliNQ6NRLhts+LP3Jm8AH/nQsnByfad0fuXaVPq3191Tw3qDgqAjWFD3spe0JgI1+6du+W71KReCNyrJWCyNW7jQW2MsKSFUvPsgBTTcWbF5d/eqRW2R21ZIV+Wogqc5C+h/Q= 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=mPuTobEh; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=N2ZXogkP; 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="mPuTobEh"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="N2ZXogkP" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHthik024661; Wed, 16 Oct 2024 00:11:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=aTP9xYoMQ1jWUeM+IytL6txn5gwzIQnsk+HG7tNwKbE=; b= mPuTobEheCqHQpL4Df7ohXLjkBJBfH9qCGIXpfn0IYHg0kwU0IJhI9y3oJY311w4 HTrPrIG1wO75X0nenUBV+lcesCr3NxEl+BA/8k2DjvO/duR3GOLxeuZw2fwS7QEt 8ZHL2cqKTBu/L9dy85MBNcS4ZrM3d7/RkxSDAzhxaYLyKWLRb9wWfppdnN6bzqgr aRSSZAXRkQlY5jsmV4wbkdYkMJ5UBJJyCXwUPppLgpjTJzluvm16r312xQtYFRfY EEW6m78aiMXvkvMCWxe3619A4csiZ9COgxvpv6yxLxVHy+GddNCWaWkqjWzHUsTP XEiygaclfK8t6nMPW1Wpsg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h5cjtm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLXJGL036084; Wed, 16 Oct 2024 00:11:49 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegwtd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qTfwnC0lF0yzkgPr1Lzw18s1Fb8k8AyxEhv1p8fpb/zrrjxJUNNcEAUaJlboK5YYqYnWlLGYQRlux/L+LFzm95Y2IuFa8p/s9HxSEbC9xO81FRAYmHnGvKC8uwcnrul3TudOubiVkkh7CiuATxua20J566y7gPvNLh0WOZe8n2o2th/5oey5zNa+SnhZ20nLM6ZuyKGAoBrS/dCQkHdiId+9kotsq4xi9cixe/gl4fDlgLZ1wk6Sb4tFFNW8lQN2OkgGHojEF+JMW/9bmO0vYmRMA/g900+o3IHx0rCT3UYRAHTdszJg1m1IMJOuDWFiCUFUTZMAi30Gfla/zW2Urw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aTP9xYoMQ1jWUeM+IytL6txn5gwzIQnsk+HG7tNwKbE=; b=F+8cnxv52ca4NSYm4WOOW+y1cZ+oTjuDWoiQ+2T5VQpBAgA9Sq/fEEH1Q3dX9Pxqft6/q//AFHXrFsdJSNKeo9SdJJJzu4B5YSzAqadEsGNdHkeg5Gdnb4zNT8zdoO33t5bQCe9Vj4mfiBXfM38pAtPftqrPGp39dmS1tI4b9h5ya/Gw3xD9Pzw2sMDavBMs1lxtsmcJOATNUW9maeMSokPtM9KnSAy1ZKPoIhuikgeP1uvm5D3ORbAL+/7EeIsc+vA9cCq54V55nlv57IV7d9M0OYcTsqr1SkuMT46f08qvbQO7QvxJX8DVlsqqyOzKCnpkZ328r/bCUmkWB6rJLA== 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=aTP9xYoMQ1jWUeM+IytL6txn5gwzIQnsk+HG7tNwKbE=; b=N2ZXogkPiOPwdaLL7bZ02Fpf3SJlNX+5ME3HqbWgemK0YNQkymX+kqwhCUBUt19AGMHddn+T1BOly7kB/+1Of6ZT6KRdzw2W5DRA98EqgjMKBXI6AjLkUu/jc4ZJ0UNyYulSBvxuKXvRjdpEp8qcXqP22SEMwl3vi9H1oJV/S9g= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:47 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:47 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 09/21] xfs: enforce one namespace per attribute Date: Tue, 15 Oct 2024 17:11:14 -0700 Message-Id: <20241016001126.3256-10-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0187.namprd05.prod.outlook.com (2603:10b6:a03:330::12) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 870a758f-c243-4835-f7e0-08dced772015 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: D1jbpWnUEUxnHlC+fQoXmyNHpeYjoiJWf3pyiityaZVlW0dt6cmdrEn3m2uAYjj6eNtaQQWP75oGpruioEFrdZ19ZeBHZqYlsCX7kRkpM279IyPayeCfdpJF6z5R7xJ/HgS/7aBFSAOnZTrsoJq8iqreaYgF/GASBARZKnX9gHJVVKZCrXAlnqud3ctQMPFI+s9qYC5WWAEDZmMSPWPzLGHAXzYk7BiyhkRFB0Y01JMIOHv9ALjuw4yPXJO+tl6HslUAcZ6wAbJC2Ura4XQ7nOJD+WsfVsoXHZ6G1zJkVblmFuJcj0+7aqFDup8F5jMR59FsZtTeLX+mLVM/EFoGHzkcl6jJgyECWHN34Gfuxu1kbPoVf5QXkAGVJJr+u8BrPvHgkVxm7cc7OMVzqOCZKhxwE2Ztw/3cCXJ5DWKvESdBWnmHCp1MWRR+6gnhLkb4mIDS3fThib7Y9VHG6JqkU4H0cPV/c226p2GqQxM4vSEf0YM033TnWPUYE+rUK0/XRyDsDV88CxboJIRbTKFyu4IsZu8due/x5IRestIIZsigDjpIgcNUhKXpYhgLNLvTSbUbZyUeDncSZC4j9MiEPUTClYAw/Xu7/ODG6Pzr1LEgzYiE3i+1D24d4oQqFOrLST1n65TvwYABV7Cy2tFI8CTrMNMBvvf6zZfQllIziX25PYZnkgkNA7YaxfOihWOSCVhQt6vmLXjLib2KtA8WCpRvUmZijDJxLGAwEBviTQsf9MoCmJ/2EqlnzQE5NYBpWTMRsqAooz1SBEORK5gxyxFjSlOQkJJNuWy/dIjZXJBaGtA6eEPKdCBse+0glEAnWeh35lP1y3KHUGoLYKQ7li+Fcs7Q8sgEeicx5OM63ecN+NkJ3CuKYcC/OrcUxgfUqG/XTVwDSJCfd7IYxPjZOuY5zkvu/kMwBYu0F4dC7MFTq2Q6gTWJD84EGU88TgBsc284DUsKLvagHgfqOfAh5HhbCPQgIN9PO/JXqbYiUn4gHAVNQNAHKBuyRlDCIdLR2LILp9AAw8thgciXpeYhSkOfUTl8yX2xDBkEnbBdlbw3kFytn44m9XEo7Tb13uK39Bv7/dZ6l9V1m5+zSDPF6tzh7gfzhFZlfwpLeNh0Q8pMnBtg7CCuag2oedrIeZm5wR/fKqYAyo25xB2JW8qNqv55ZC3wfNUzC37W+YhkouZyW1U4gqJHH/dmqtE2Y0lI6Jt1Smukipx04npbi5ZPMhAlkzlj2lnPeEHN+CfX3826sv4vu4yOOyy+UPhKIuBaGluJx96ZvkFyA7oSasriWA== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NyvpN6rNbXPZxnupAJvxBSo7HTDnU1SKUQ9G64mC0Fiy51nuP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U5rrq9S9FGFEwLbX5c0D9fqAZkt/SAMh0lvjsO4ipbno7+lvVcsBBgb9rYjihFzFuqMJ+mbfqEBznQC+F5v1hyiiwBv1X6qGV7vJLFc6lC+C7caVscoSMCVrxEGIfd3IoMEeGmy4C4teKgyOPY2pJO/70Cq/9PIl3r/mnVTj4WyGO4QqJ7JM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 870a758f-c243-4835-f7e0-08dced772015 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:47.6659 (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: rejgugnYHCdvz5YoSzd7ifzsXBOKcrnJjVGOS8daLGblqINtfSgwI0JogACl50a8Q/reJ4EDX/qv5Gqnz0e1pEaeU4V5XCdrKpVg3aFn7R4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: v4R17CFdqHcVMoFXDWgkciQIX-5-WUTh X-Proofpoint-GUID: v4R17CFdqHcVMoFXDWgkciQIX-5-WUTh From: "Darrick J. Wong" commit ea0b3e814741fb64e7785b564ea619578058e0b0 upstream. [backport: fix conflicts due to various xattr refactoring] Create a standardized helper function to enforce one namespace bit per extended attribute, and refactor all the open-coded hweight logic. This function is not a static inline to avoid porting hassles in userspace. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 11 +++++++++++ fs/xfs/libxfs/xfs_attr.h | 4 +++- fs/xfs/libxfs/xfs_attr_leaf.c | 6 +++++- fs/xfs/scrub/attr.c | 12 +++++------- fs/xfs/xfs_attr_item.c | 10 ++++++++-- fs/xfs/xfs_attr_list.c | 11 +++++++---- 6 files changed, 39 insertions(+), 15 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 32d350e97e0f..33edf047e0ad 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1565,12 +1565,23 @@ xfs_attr_node_get( return error; } +/* Enforce that there is at most one namespace bit per attr. */ +inline bool xfs_attr_check_namespace(unsigned int attr_flags) +{ + return hweight32(attr_flags & XFS_ATTR_NSP_ONDISK_MASK) < 2; +} + /* Returns true if the attribute entry name is valid. */ bool xfs_attr_namecheck( + unsigned int attr_flags, const void *name, size_t length) { + /* Only one namespace bit allowed. */ + if (!xfs_attr_check_namespace(attr_flags)) + return false; + /* * MAXNAMELEN includes the trailing null, but (name/length) leave it * out, so use >= for the length check. diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 81be9b3e4004..c877f05e3cd1 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -547,7 +547,9 @@ int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr); -bool xfs_attr_namecheck(const void *name, size_t length); +bool xfs_attr_check_namespace(unsigned int attr_flags); +bool xfs_attr_namecheck(unsigned int attr_flags, const void *name, + size_t length); int xfs_attr_calc_size(struct xfs_da_args *args, int *local); void xfs_init_attr_trans(struct xfs_da_args *args, struct xfs_trans_res *tres, unsigned int *total); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 2580ae47209a..51ff44068675 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -984,6 +984,10 @@ xfs_attr_shortform_to_leaf( nargs.hashval = xfs_da_hashname(sfe->nameval, sfe->namelen); nargs.attr_filter = sfe->flags & XFS_ATTR_NSP_ONDISK_MASK; + if (!xfs_attr_check_namespace(sfe->flags)) { + error = -EFSCORRUPTED; + goto out; + } error = xfs_attr3_leaf_lookup_int(bp, &nargs); /* set a->index */ ASSERT(error == -ENOATTR); error = xfs_attr3_leaf_add(bp, &nargs); @@ -1105,7 +1109,7 @@ xfs_attr_shortform_verify( * one namespace flag per xattr, so we can just count the * bits (i.e. hweight) here. */ - if (hweight8(sfep->flags & XFS_ATTR_NSP_ONDISK_MASK) > 1) + if (!xfs_attr_check_namespace(sfep->flags)) return __this_address; sfep = next_sfep; diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 419968d5f5cb..7cb0af5e34b1 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -193,14 +193,8 @@ xchk_xattr_listent( return; } - /* Only one namespace bit allowed. */ - if (hweight32(flags & XFS_ATTR_NSP_ONDISK_MASK) > 1) { - xchk_fblock_set_corrupt(sx->sc, XFS_ATTR_FORK, args.blkno); - goto fail_xref; - } - /* Does this name make sense? */ - if (!xfs_attr_namecheck(name, namelen)) { + if (!xfs_attr_namecheck(flags, name, namelen)) { xchk_fblock_set_corrupt(sx->sc, XFS_ATTR_FORK, args.blkno); goto fail_xref; } @@ -501,6 +495,10 @@ xchk_xattr_rec( xchk_da_set_corrupt(ds, level); return 0; } + if (!xfs_attr_check_namespace(ent->flags)) { + xchk_da_set_corrupt(ds, level); + return 0; + } if (ent->flags & XFS_ATTR_LOCAL) { lentry = (struct xfs_attr_leaf_name_local *) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 141631b0d64c..df86c9c09720 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -522,6 +522,10 @@ xfs_attri_validate( if (attrp->alfi_attr_filter & ~XFS_ATTRI_FILTER_MASK) return false; + if (!xfs_attr_check_namespace(attrp->alfi_attr_filter & + XFS_ATTR_NSP_ONDISK_MASK)) + return false; + /* alfi_op_flags should be either a set or remove */ switch (op) { case XFS_ATTRI_OP_FLAGS_SET: @@ -572,7 +576,8 @@ xfs_attri_item_recover( */ attrp = &attrip->attri_format; if (!xfs_attri_validate(mp, attrp) || - !xfs_attr_namecheck(nv->name.i_addr, nv->name.i_len)) + !xfs_attr_namecheck(attrp->alfi_attr_filter, nv->name.i_addr, + nv->name.i_len)) return -EFSCORRUPTED; error = xlog_recover_iget(mp, attrp->alfi_ino, &ip); @@ -772,7 +777,8 @@ xlog_recover_attri_commit_pass2( } attr_name = item->ri_buf[i].i_addr; - if (!xfs_attr_namecheck(attr_name, attri_formatp->alfi_name_len)) { + if (!xfs_attr_namecheck(attri_formatp->alfi_attr_filter, attr_name, + attri_formatp->alfi_name_len)) { XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attri_formatp, len); return -EFSCORRUPTED; diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 99bbbe1a0e44..9ee1d7d2ba76 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -82,7 +82,8 @@ xfs_attr_shortform_list( (dp->i_af.if_bytes + sf->hdr.count * 16) < context->bufsize)) { for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(sfe->nameval, + !xfs_attr_namecheck(sfe->flags, + sfe->nameval, sfe->namelen))) return -EFSCORRUPTED; context->put_listent(context, @@ -120,7 +121,8 @@ xfs_attr_shortform_list( for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { if (unlikely( ((char *)sfe < (char *)sf) || - ((char *)sfe >= ((char *)sf + dp->i_af.if_bytes)))) { + ((char *)sfe >= ((char *)sf + dp->i_af.if_bytes)) || + !xfs_attr_check_namespace(sfe->flags))) { XFS_CORRUPTION_ERROR("xfs_attr_shortform_list", XFS_ERRLEVEL_LOW, context->dp->i_mount, sfe, @@ -174,7 +176,7 @@ xfs_attr_shortform_list( cursor->offset = 0; } if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(sbp->name, + !xfs_attr_namecheck(sbp->flags, sbp->name, sbp->namelen))) { error = -EFSCORRUPTED; goto out; @@ -465,7 +467,8 @@ xfs_attr3_leaf_list_int( } if (XFS_IS_CORRUPT(context->dp->i_mount, - !xfs_attr_namecheck(name, namelen))) + !xfs_attr_namecheck(entry->flags, name, + namelen))) return -EFSCORRUPTED; context->put_listent(context, entry->flags, name, namelen, valuelen); From patchwork Wed Oct 16 00:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837457 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 4113AB641; Wed, 16 Oct 2024 00:11:53 +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=1729037517; cv=fail; b=BwuX73R1NINaiRbz9kLYzxKn/Vr0W/6meaFGbD1cV6t32IS/vkeHoQqNg4bYqQFMHUbDvjdBoN+UmgwWaJGXrIbs9a4qEo/lOKbUMZcZVS1FNM7b6jyq4P6XEGr4ZJBhAE+qCug7p9WAUuGvEuUlul0B/EcsmAXzopbqGO4rH70= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037517; c=relaxed/simple; bh=R34B86ZjNpVyTeQojj4NSySj8Bsc7ZSRsXOV81CBfew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KFuEZ8KmfrRwhN6f016I/rrPRcFu7T+ehwP4Gzybysq/7IdVeSPycSHgoi8VIGDgV/AQhDDc7YhjaXCha7pF3yEbpPhj9GGwG2AqpP+FmZr+wbJ6amrR0xKXNIdDuRpKcU7d/7RpHRzjMl2nhzziWfKCizJIqiYPy5nEMmeFZJI= 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=lY6v0MVF; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=zdwC9Cej; 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="lY6v0MVF"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="zdwC9Cej" 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 49FHtd8U011655; Wed, 16 Oct 2024 00:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=0z53B2e9mVUBPLsUzaF++kg5VDFpnCDXMWGARmfnF+I=; b= lY6v0MVFeS9VDchlrffRDZPL3gvpGO1BO7mT1j20NZfDrtcSuWpInWiTsygE4FA6 aeYvifliOs4MUjJw+3MIzEWxeIto+/RTiJmpy4efHXRggwFxuOCBsov2z3ZhZd2P LElG3xZfWmqTT4Zjvjt1LV3qqUEA9Kh/q6g7oi+I+m3XLIiBI2zmsr5hobfV01i6 JNqGxxG8VS88mG4OiEFBQTLakM+RWcgq2e8Hl58+lkjt2TwjKNvU9uVATcFFiAvd L/VCG9/pXzpObQvi0109EvtVyw+B1ooN2HZX3PGtVCpkIemdQd+jYNW8auEp/ix8 1JJtRi2jMst7Aok995bonA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gqt2fp2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:52 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLU1Pi026220; Wed, 16 Oct 2024 00:11:51 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85ajs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eEU+jj96YAfXj1PeTI9J9pY0j/MuQnvtcWtf1G/N8moChWL3Z8LZ/Ab4MMvuYp6vj/gsUXSndAZy7kgCFmZx3i/kZt0yvn8uXoxuOy59+NWQp3tBBK5zomC4mCFVdalWvbJG1zsUzkfQWZqNeY2395NbVmFzvoA6yd9US1z0HOGB/2AGnF8jTS3lJzGS+zfIe1zu4Iced/VDcPaStt/s7QERvacpxseMs33QwSYjJxxvZ5JwwOB1JhWbkpzBWVMR9QuQCrUOBnT0N/HRswHeWSnpWEPoGzYEInxlG2wmfZwSiIzuu3C2IcvGDybOAiLsd8ylCpcAxGwyobINMuVmEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0z53B2e9mVUBPLsUzaF++kg5VDFpnCDXMWGARmfnF+I=; b=EKL3n0EAORAYvtXJ9BUk1reptklizIEw6XTQ7OsYSLwvxNq02oz0C6FaizbXALTh01b5Uk4EdKxXDh7EAuq3Ss94BBZVqmIyKeU6XmsPG97DpOcOwS2iLxD7DBBX3Ay8kAm2epFXHI1iJ62kkeoFoWyZnu6MzBH3yRx12M//g4pwdSfnmS4sNVtXWiTQoGQ2H35/wNRMceVRqktAQhCs/ZIFnJhCz1V76elNLpb4Pf+cpx3jQqstcqautC5c3/UZAJGa3Oxj3ryJtSChQqxW6GZ382GgGLpMJjzmIEBRI1agyVSmyuXpgyz2CcA1leGYt9yTGFmR11OkXHMOIkCEDQ== 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=0z53B2e9mVUBPLsUzaF++kg5VDFpnCDXMWGARmfnF+I=; b=zdwC9Cej7t+sF5NbqdzBJcFUtqntLQ2svg5NQnPisrOJTHv1LWsgggk6BUuwj04P+iGmCE2OCo89vtTskyh5TTjzBGhXUje93OwPoOghWPhTlipe6r/T8Nu6xILy/YWKOa6ORhSPxfw7AwCYGoHSI/MFOlmuIXW0GUbgYFdiyeM= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:49 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:49 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 10/21] xfs: revert commit 44af6c7e59b12 Date: Tue, 15 Oct 2024 17:11:15 -0700 Message-Id: <20241016001126.3256-11-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0194.namprd05.prod.outlook.com (2603:10b6:a03:330::19) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bf23861-186b-4b98-0a5f-08dced77213c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: IV/gXU6YBQ8b4qrNSphOaPQtrmIbJeEZXcHzg2Rm3IFeIYFYgT0vOB2bwO6+VNRV6/qEXpSgiTRLq0UZwwvVungmBXbTE1y8ubwaa1yHS7Q2QWSASNFHXVfWHhX5OuOMzZgYDUZXqAyUgdKKy7geakTyNZ2aUquc5VkqiTvhuBNq6DR0uWi8jSL9DYi4fONnYRVolxjj6sGSUnljrcsFTvoCAGvzsKj/r7sS+gY4T2lrB5kypApEYJJIxpSPcrqifAKEzs2IvaLDqa5h52gNkiljNg+ITahSd0xyfjaJTr6i3/eWhfqjVe+Uz0C/N6i9vQI4OcsKKyq9mLKe0bSFCG8RAlvYuk5cRML3uIrlIT0ON1xDKI/ayPsiRt4mp8UNMMjrxaBezWdiGC7oQG5VuPk8Ld8a32Xv+CGTFvnMM9lNtj3ZXYquYNw0z6YgIReXRQFFcmLqD4JeZw5nJThtoYAWxmPY/wxyGI09rvESJiPr3/oWPtSMNT3zjAm576qNX7b1lH1SjZgefPkTC0GKSsyk3TnOPkjQ1ILABjXoDlPyvAK6/ZaqiUzsvZkS7fR7xW2DFWZ2vSgGX9skWXHiLcBjwdC67PA8GdpOlCjXtT8UY1wT1AT2TcpYzzTpimBY/o78zg1hu1YOEaBHfDAts2K3+t0a3CLZagB1K5lrN1UW4FTes2s+1xdSwNTztsIYmfJRy9iYIrR+eahDOXfzJNciKx5fMoe8CvUV6g/gNP0WcCb5tDQd3f3LXK8rJBie3cQMet2pOiDmsAHlmaXzSlIDCfOD1gjiN+XsPhjQhCr3BTrJjMq65FmkpoEDDctnYDYNF+pFk0sGn+z1Akmkx3oiiPRyl7YD0vIekClYJiBDlrN+V4l5SnXeRBUG7kd4RZ/TH0f8u47SRKVoDiv/P8QOzo0JC3KT1+gh2RYqpNKCw2bJKtK028lnYG7jO+11a075qPDBJ/a5nXIhfc3SjYaZZWavb9lxOqBFvxhHu0vNaKJoDzVlrlKJYJwUmrYOhhnSSOChdENa61qqc3E2Uwt5T6lVQVhQOkeQzJWGOjO3D0yLtZB6KcPPKJYPvvrv/CjSoZfmnmkPukfzeBL5xLBv2AiW3LCC7XbGKGrgluhr9b/Sv6V7f1ImdwkmBCaYFdt7v1aruClNgfyt6uOLLOXHZuuu/bEuw4aoUtE4KMH8Qaca9MhgtVQdgmF7q2hQNRJ1JCPkh9U9wP8+xBx66Ao3ortBUKZYp7sQVY4tvRdJDMbnp0VKjHdtWbDhE3SbkKxkicID6kP2duOQssuDmw== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +g98dB6YWVNPEoF2Fq4I0rbIh/OfWyy2LATPEUwNRcccxso2X6fUXsQRrP3lMDp36BQOz0VSbPRcl4O2T4j4xeVCs1vmMRmNqEApZl21QQWix+ZrxmBFMtT6yeiFm1/XJsSdTM50bjB+mhfzGAMgdCT5Jw3OGxLh5FpmHyS/uqYU7Y2mGy+SJcnR6ukBVFqeKLLg2aXBSfekixw0rNnHsHqT+T03WMKL+TnHEtPJFQcVrp6+8M5KKPnd8io5iLRZMqmvBKvSDs6n39Mco4LH4CoUC6u1XmlitXvDIpELapyi3FrZkLPfK/04eRjef99uUmmyf6Re5/dOTteXwlPBacgqJl07zOrhcJu4ETio9OnWL2FQUM6f/aKbLo1b08dDgSxNHv2E/zgR98myxHf48AUw8ngUvXRTY//cOoyjFJyTgw5JWMaK682OjAMhMAdKbInw5OU1dMU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Y1XiVXtP1mGLvvn0qIelP+/mhpvXGXP6nKlXkzJbltu8UHqMUoEuWS8RadW8Nnw51CK2aB5b/9jlt1Wi+EWe5Y+LlKQdC2YSROfik4JvPZTDVP2GgiKxlOyNvM2AtQvW6g8U/rv25nhKCfbCfFJrLTJ/gxmef/pFA4aw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QdNybKDYGDaxN/DmwgmrgZdqCP+QdS6bLLGoWZQk1H0K1s8InMG9HMuFC7UUulm46LkZ+Y8tK3J8CtzQI6f7WHwUXwOxTuNdL00zWH7/OQkeTC3zqREFyMeTyRGlmG7CyZTW/3sDXOy1v82soAEHjq5/OHyuz9QTH1QDYGbySS3WPIubEQW7NyIFbHrfor67n9u1BOAtGQmrhmFZbsRWckHxRD/I9tglVziIP1xAIFTKKFkjZTfXeI7HJv2q8f7yw/1/c6qjJeNfpduboVov8NKRFIxZP1NlJGOtCJcvG3HlqhrPrcUh2pT0MYUTuDOAcwSYrcZinahLZXWlRPdwtzeAibhx0nZQVCuTayxV+0GphH7Fw1xcn0cPhtBCoOFkPNMQyOdMNd1j+cGpEeF1alr2cDHvsFt/XyQzc0TsXDvYT1xJNvHeMTfV+NlB+s50L1JqxcmlZjSDBkfeM9alrXeWA4yREVHWzzbYy7cuW1v9Gj5O5JrvWnTaJsgO6HPYVk6DlBq7tN1IChL0VFx29xwWlkOnN2rM46ATOAtrwHoZw25eg5QKPmp5XmcxhedQU98KExhDW9Ln47VERdqxF2Qz/u0BMBvRET5wGeDr1+A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bf23861-186b-4b98-0a5f-08dced77213c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:49.5719 (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: mkezYNVnyapp1kD+UgmPtSWNi+IbknceLIETd8trywz5O8/aKpVmmn6VBf8SsgYbcERiNY1g9dzIQ5egRElN9j2pPCi6ccflauaGKyKxO+c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: nJkDFpaE4D0NCVXmNUjvtfFni7MaZm8w X-Proofpoint-ORIG-GUID: nJkDFpaE4D0NCVXmNUjvtfFni7MaZm8w From: "Darrick J. Wong" commit 2a009397eb5ae178670cbd7101e9635cf6412b35 upstream. [backport: resolve conflicts due to new xattr walk helper] In my haste to fix what I thought was a performance problem in the attr scrub code, I neglected to notice that the xfs_attr_get_ilocked also had the effect of checking that attributes can actually be looked up through the attr dabtree. Fix this. Fixes: 44af6c7e59b12 ("xfs: don't load local xattr values during scrub") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/attr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 7cb0af5e34b1..147babe738d2 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -199,14 +199,6 @@ xchk_xattr_listent( goto fail_xref; } - /* - * Local xattr values are stored in the attr leaf block, so we don't - * need to retrieve the value from a remote block to detect corruption - * problems. - */ - if (flags & XFS_ATTR_LOCAL) - goto fail_xref; - /* * Try to allocate enough memory to extrat the attr value. If that * doesn't work, we overload the seen_enough variable to convey @@ -222,6 +214,11 @@ xchk_xattr_listent( args.value = ab->value; + /* + * Get the attr value to ensure that lookup can find this attribute + * through the dabtree indexing and that remote value retrieval also + * works correctly. + */ error = xfs_attr_get_ilocked(&args); /* ENODATA means the hash lookup failed and the attr is bad */ if (error == -ENODATA) From patchwork Wed Oct 16 00:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837460 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 76F444A0C; Wed, 16 Oct 2024 00:11:56 +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=1729037520; cv=fail; b=LTKz+AYmgQqk7cddVqSXFWD5SMaTrNoWLpMo4pNrzagDQa5GcMcazZY9jLVqNWgDdkwyCpzwdumaqImKmK18n4fYJ3Xopv33NodIkgkvHQcIp7nfYbSwtz7cnf1zVe3yz9jkGMn8R6TpE//XVg6tQx6rFLcXsvoOZ8vJjJadUpo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037520; c=relaxed/simple; bh=C+pIhWoelJI1EPAzuplYKlpklWBu7elT7ZEhj1i0R3Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RGEgovzJjt2WqARRgDrIYI2tb03W5ApT1g8TVOPQhRHFAcirOyJlmuCXv/hp6yQ1w5kV/0Tqc4ASzkHV4Af99e0k5/DYIzP53tLf1AhAEhDC0fmXDXXLbj++MG+kqOfJZCO4R1j7a39qPlS9BaZCb7YZBbpoZ1DAL8ka+YK/Z6s= 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=bitKbUMT; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=g4HVavCx; 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="bitKbUMT"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="g4HVavCx" 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 49FHtejU011672; Wed, 16 Oct 2024 00:11:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=7y1+i1Y2dgMCLROT7pwXwTtseKVvwAZ8jqUHJDtlhH0=; b= bitKbUMTDsS4OIYyVDd0nv8WGxVeaeHvMg9cfG5Ss/U0lpT8mGGACb2mFszlJDmK 3E6RZhJM7heaLcvJgbuIQNN/ndZhefCP62ZXFqr3mVHPmKX06xEB8zmS8x8uGWMU KlNjAIhET/af/6KbatxwPdo9OMAP2MwORGwuoDCnGWoD11KIcTKnhomWVtdJEgER +iz7wvdSTtpuydClEIxkqaclGp+AnkUz5SR5NXyjh6Bfau/PBj48l1UkinINn7xF KBjJ7T7jC6TG+rMzzgSwMQRAEQIx1/Vh7VbyL6AuuJoguEnSRiXRGACnbh8Jczax bM3wWvPwHKk8cLesaFYYjw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gqt2fp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:55 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMHfnO019918; Wed, 16 Oct 2024 00:11:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85mf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wsldP4Zfxd90cdkREmD0k/7JoxgAmShEXAbGaSwV8iFWHQogS+SMjGxqLTr3byoNX4sm6u7fp3//n5KysWKOTHLirMFu1Bjydx9HPhvt6MCa0aT2E6qeaQQA1tEp8fLtRUwQ1Sv+A/HP3MpJAtJNgctKIZyLdV6UW0PrV3oDpcGBp9U/jIPjQm25998koe7JZov9BHlNHsA/BGIoOt+4bkSab4cpb2ia+kIuGcw7BW/ZIqyMhBGFgQYXCDzIGO2JmYNiprMU+AJcY8pgK3i/pGZsBBGqYLizNCpHnVVbtDvfoEl6BYKhDKQgDbiIZj0BB+o+cA3PaCYVToZaKjhEnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=7y1+i1Y2dgMCLROT7pwXwTtseKVvwAZ8jqUHJDtlhH0=; b=OPbE6Kv4bF2Q8fmkpKpWlnNK+TEWONSJga28Neeod+1+3aftB7MHn0ooUheIy/OoV6n/4WmXhewBk/p14Hvx+qsrGmDRW/bTc/yDKGXfP/2qmcKAWhKqBK6r/IK2V//ibESq8RUeGaynz3sEJs1bZ/N7L3ALYBSRmFdRECIKmFp270WWmp/mfzSA5kqZI6Gv5RYo0TVIv7Cr4wIGSh6CTfBAY9i04qNZdGOuAZGGaltJRgeV1QNn8uoawhXdRrbv52sy6AFSWb5LoZh+wO4Umb0TLFLOaKl/YWv6/JobXpNmdw0FaC4okJkxdbQzfuUy85VH27/6TumzAiucLyNgpQ== 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=7y1+i1Y2dgMCLROT7pwXwTtseKVvwAZ8jqUHJDtlhH0=; b=g4HVavCxfYWf/d27WIBi3dw3W1/QkieeSlKUT89awH1grbjT5nXa2tljXLtsEt8FLj9Mr0pA1JNBQarEr7kZ7+qvHm+K/EbgMIdcl9ll9tp5PZXhe/bFue7xzW9IEFB5j9X/pNo1j/nGgXm/GyjgSQZS+Sb3Vqtw8N63GoN4Z3I= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:51 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:51 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 11/21] xfs: use dontcache for grabbing inodes during scrub Date: Tue, 15 Oct 2024 17:11:16 -0700 Message-Id: <20241016001126.3256-12-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0209.namprd05.prod.outlook.com (2603:10b6:a03:330::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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 9688d855-1ab1-4893-0ee0-08dced772235 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: t21StTl2+d2X/g3TaqRk5w6W6a8ak+vKbZNyqJjSjsgUNHmwzjgV6NQxq78KsfvujN9PsPxQOJqqtq9pQAyoLAL6cC9TT6EKiiYf4WgdXs96cHuirgvOlc/88yaFO4XssHyNpMuuzIRxKTomHq2HDF4S2j4Nv96J8Lt5MSR9sy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vG9LS58ThX75CuoeHPmHEY/APFnmbRsuwWxP8/BOmwJWS9nOWkNhMcGmQ== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ciEdlDVnUj+2in1k8w1JapDAPMHWmp+dYFhUiWYjV0UOkqHSYbLwpv9Y6V8ME9rEUQt3A1VuQNcRL0wylS1j8Dh6w90x86S/Ay+sgbmR3ApmIAsavUrck5uEaRCHypOEtgAHp3KB6NQq44AgRPj6wT4YQzKBYXXawGtnnBxG/CglfRqx+hqkHmTaFD29Wrckcu3gPOuXPHGywvx4wqDsUhbKKtJlnG4sl3PlTD7PchYrfHDpqd46TtXqyeLaJUoPcGBaDoqMgYDUNAmrrt4Ue08E8OJFQw0kX7TxGf+zoMIiHS8pWkxr2/Bv8NJNCDa9I3nv+S/7RveIz5MU23O0fJpM4Bpuevyldh57XjdfNyIyGs02c6D76KNqOFv0P1+n0vwJSJhwu5u00/6uEEaYut9kxgVso1+Q2loYKnNxVtJPhm7Pl1gjA8q0UrH49mUaLtQfjFNOx4eIrFIFS17wgZCrvwSJGOdYdOBabAYO0VzEzhUKgx9xhEbiIiiTT4R1emSbRMA8IWagmm+tDkB9yzKyxlfWXd38DXzdIEWzW5U0PEiKPrkagONufGZVOdVUj0unuTZRCtutaj2wMqWUgEDMXwzV6v59mxuP4B6eVBpw0tJQ1q24XxlZmGDdiMnmFlBj7LJgEB8YX/PKgHN1hEFFjj3IM17dggTqVa15HqgPs1a+u74jA7j5OSN98u7sCs6umMcN3ZjHHfZX8ckMks1gElCcJEFcAAeE/PyOLKcKYfbtzweBbQ60AjrIACIDo77i3huLCKuqVFf3zfyq8HwTLoFDpwd0A+62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IucY5ut99WCOA/oozu+CUry5HihNXfcHP9+n/GKP9DB3a3BRN4Gl+wasTlqy3DMklJym7hOdlaeTs4Vg9ThVbWQgzo/cE5A45xjZjkgS7NpJNmPn3GuAFIyz2wmZOpLnhlGhpT95W7SxRVX6sBW+8QMo+ADIw/pvsLucauQJqWi5Dhj1DlsAZYWql5X7wZEfSzINSMmWL728Vk5TbssAq9ZhDSNlHCwD5J9VwZV0A+C7BHBExnUgQkKK1DxwwvOH4WJ4vQ4IKNQnmvodij7ASaydC7C/WiXW2IbNDCsWuKgkSMa9lUEtRZ+/1RaD0bEzoa4WeneUNyShRhODmXcbHMJxRhaKw0oWNHbdGKyrifuMBinDMJJzUTBYytkzCm4bPN1b8A79l58YtnhyLRaYIciTw74xZP3n0FcSV+B5zOza7zDl4tv1cDrjpgCOwmZuybY+jPPVTK1us+GZ1zrqap0LCwDvthSKU8rJiuP1Crh0i5LI4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9688d855-1ab1-4893-0ee0-08dced772235 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:51.1800 (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: mc2c0DETJlrl6WNZTi6BZkTBFV8UwiS6C1I2akidwm1ermMctHVg3y+Rd8BhpLDziejo1/T/QmXTZq+ci6K9DVPJ7dVTKyEIASDLyhvtHuU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: b9fnZghc_V9ei7mcuznvRO_LaK2QJcbz X-Proofpoint-ORIG-GUID: b9fnZghc_V9ei7mcuznvRO_LaK2QJcbz From: "Darrick J. Wong" commit b27ce0da60a523fc32e3795f96b2de5490642235 upstream. [backport: resolve conflict due to missing iscan.c] Back when I wrote commit a03297a0ca9f2, I had thought that we'd be doing users a favor by only marking inodes dontcache at the end of a scrub operation, and only if there's only one reference to that inode. This was more or less true back when I_DONTCACHE was an XFS iflag and the only thing it did was change the outcome of xfs_fs_drop_inode to 1. Note: If there are dentries pointing to the inode when scrub finishes, the inode will have positive i_count and stay around in cache until dentry reclaim. But now we have d_mark_dontcache, which cause the inode *and* the dentries attached to it all to be marked I_DONTCACHE, which means that we drop the dentries ASAP, which drops the inode ASAP. This is bad if scrub found problems with the inode, because now they can be scheduled for inactivation, which can cause inodegc to trip on it and shut down the filesystem. Even if the inode isn't bad, this is still suboptimal because phases 3-7 each initiate inode scans. Dropping the inode immediately during phase 3 is silly because phase 5 will reload it and drop it immediately, etc. It's fine to mark the inodes dontcache, but if there have been accesses to the file that set up dentries, we should keep them. I validated this by setting up ftrace to capture xfs_iget_recycle* tracepoints and ran xfs/285 for 30 seconds. With current djwong-wtf I saw ~30,000 recycle events. I then dropped the d_mark_dontcache calls and set XFS_IGET_DONTCACHE, and the recycle events dropped to ~5,000 per 30 seconds. Therefore, grab the inode with XFS_IGET_DONTCACHE, which only has the effect of setting I_DONTCACHE for cache misses. Remove the d_mark_dontcache call that can happen in xchk_irele. Fixes: a03297a0ca9f2 ("xfs: manage inode DONTCACHE status at irele time") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Catherine Hoang Acked-by: Darrick J. Wong --- fs/xfs/scrub/common.c | 12 +++--------- fs/xfs/scrub/scrub.h | 7 +++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 08e292485268..f10cd4fb0abd 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -735,7 +735,7 @@ xchk_iget( { ASSERT(sc->tp != NULL); - return xfs_iget(sc->mp, sc->tp, inum, XFS_IGET_UNTRUSTED, 0, ipp); + return xfs_iget(sc->mp, sc->tp, inum, XCHK_IGET_FLAGS, 0, ipp); } /* @@ -786,8 +786,8 @@ xchk_iget_agi( if (error) return error; - error = xfs_iget(mp, tp, inum, - XFS_IGET_NORETRY | XFS_IGET_UNTRUSTED, 0, ipp); + error = xfs_iget(mp, tp, inum, XFS_IGET_NORETRY | XCHK_IGET_FLAGS, 0, + ipp); if (error == -EAGAIN) { /* * The inode may be in core but temporarily unavailable and may @@ -994,12 +994,6 @@ xchk_irele( spin_lock(&VFS_I(ip)->i_lock); VFS_I(ip)->i_state &= ~I_DONTCACHE; spin_unlock(&VFS_I(ip)->i_lock); - } else if (atomic_read(&VFS_I(ip)->i_count) == 1) { - /* - * If this is the last reference to the inode and the caller - * permits it, set DONTCACHE to avoid thrashing. - */ - d_mark_dontcache(VFS_I(ip)); } xfs_irele(ip); diff --git a/fs/xfs/scrub/scrub.h b/fs/xfs/scrub/scrub.h index 1ef9c6b4842a..869a10fe9d7d 100644 --- a/fs/xfs/scrub/scrub.h +++ b/fs/xfs/scrub/scrub.h @@ -17,6 +17,13 @@ struct xfs_scrub; #define XCHK_GFP_FLAGS ((__force gfp_t)(GFP_KERNEL | __GFP_NOWARN | \ __GFP_RETRY_MAYFAIL)) +/* + * For opening files by handle for fsck operations, we don't trust the inumber + * or the allocation state; therefore, perform an untrusted lookup. We don't + * want these inodes to pollute the cache, so mark them for immediate removal. + */ +#define XCHK_IGET_FLAGS (XFS_IGET_UNTRUSTED | XFS_IGET_DONTCACHE) + /* Type info and names for the scrub types. */ enum xchk_type { ST_NONE = 1, /* disabled */ From patchwork Wed Oct 16 00:11:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837458 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 694C4DDC7; Wed, 16 Oct 2024 00:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037519; cv=fail; b=V5nv4c+gCI2Vb9+2N6g6YtfxwyGWQg7vrW6qhAMkyzYLP+8M6c9KloYXGqCvDQ4YypuJglzMK0Ft33wmj60jGlSpdXy0MW02M8RW9Wkubo3QVx5UeqUD5wLgIUqclW9imlrrDV2SnAEl+IfxfSl0Lbly2hBne4BS+YCEWJBs9+w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037519; c=relaxed/simple; bh=pMzfDEb4dWfTWt1Ua+gWRB4Gn4CV4MOeMOuLB45XCXw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QBw8SmmcK+0q4FShQyjwNp9A2Ni6VlxdXCMs2h6nsVA7s6gYZ3xznxWPNf292BLhGR2U1MCa4rhiNAhN1YDC+2d6bVTF6mrZip/ndwo1fr1CTIsGpd/X8HIaUvqGa7s/nrJ+T29V1RHMctgoLtcxYanRnAsLENWGV512TP4Vlvc= 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=Jxsw82Bf; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Anz8r1Ou; 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="Jxsw82Bf"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Anz8r1Ou" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHtf90008307; Wed, 16 Oct 2024 00:11:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=uOQ7FfHr53ANkr9MDtnIP+jDmPhdB0XKZY1GKBaycHw=; b= Jxsw82BfOISj8x++eV6gjw87dKdnSg2OFl+cK+SIRTJgmZjC8DJ7JfAeIkBAQ6V/ SfBfY13PprBIpwivoeZhj6AqYTsySJnII/QO/1Ngbw52RLHrlM70h8+tZ/Gph+bq oMNj00S43f0HHMqY6FRwv0xKLEwdFU6TVDcD6nYKY1yxJ/9Z7T42WxWrIlHWomB4 hNioLZsetnDnQ5dCfDGqTBn/uLn6LjBuHaU2yFdxpP8fkjK3IbsZHOijiqYR4s1E hyDdgD2Vbg+ORmBLDy26qjVEVmIqlRMoJBaMo2tzfQqGa5wTAUF0J3gTpkhjPq/R DSu7e6kkrm13NexAg/ZJBQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427hntaj1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:56 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMbLDI026319; Wed, 16 Oct 2024 00:11:55 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85am5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ioLN6NiCv/YkQdROUvFf8tj0qnDyEXIGOKPOJOcy3SKo0zN7FFTEAcltNKtIljkqi83fSzRYuhqizeBO601rphNVyYd960z/smYZOsP75DxDQAPJ3c8VyZBsS7GmJtcAsdneQ9MQBbsg9+0GSsXrJiX8h43PIAx1ArO3bJuU9sSmYZLGzyRP2USfcLLV2xVV9bnrTBL1/zdIjO9z9wkc0cdJfWBF2x+sjxWp6JCRj46GfuWdazGZEzujGHTiYIY7SfcctusCPZy3dR++qUCgIisaZt57vJnsmcrgW7CUyrr21aBpQr6UWRVewyz5yL9Bw8npWG9156Xt7v0cr7GOyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=uOQ7FfHr53ANkr9MDtnIP+jDmPhdB0XKZY1GKBaycHw=; b=Spz78Zb8SMfmcXL+EVTlDd22sDAQKhi/L1L447C4DMDj16VxcY8eKpXNPoXF0rcclxWG/IQA5JEEdCA9aHpRddDYLtGV63QzEA/JsofJr7XAQocFsOLgtks5JVap/T4uY65SaWv2DLVfRgBFmDdVVw4PfDSYawL/1m7SHNMFF5gyrAZVoeP4E1bPg6i0Ywmud8qwxL9MCVTK+1k+Tkzzz2BCbQ5rmZPLZB45B4GNem167tQm3kUPqoKP1WPJyLo0me1GaVdrqFLlTNiR4Wr6YJ2vygkLHMDAqWfnEjptfGIahz3HAfNw9hDowpj9+tnoaJRxpax2Q6K67Uf7yuMYTQ== 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=uOQ7FfHr53ANkr9MDtnIP+jDmPhdB0XKZY1GKBaycHw=; b=Anz8r1OusmiMcsA02LP8BLy2icJ8Tm40IeWpjKXRNtCnNfliVRuB+IP1DRDSGDrIsw7S6JqyQGos1+NSSimw7SKb/3uqAlqEFD37F/GBmTjatIMmZH11Z4O6Kx4SslC1LiPX0Tfea8L6i9PMrp0IZOA0CHEo7Fj/PSm9oC4efmI= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:53 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:53 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 12/21] xfs: match lock mode in xfs_buffered_write_iomap_begin() Date: Tue, 15 Oct 2024 17:11:17 -0700 Message-Id: <20241016001126.3256-13-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0204.namprd05.prod.outlook.com (2603:10b6:a03:330::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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 75ef4024-6084-4c16-bf4b-08dced772348 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: z7Iz7Qa8sbWGFF4ykL6qVOjJAvvN7lNBVDpE2hiLMQVTUIKct0EattGWYh/rlqHTc9tREYYmlHFFs6PxRbB+8+KtstklQEVb20gAQiGG0Bkl8LQ4SRd74mpgLam99cJJq50Ww+UtSH/Gihd3h9uTRJTbsZNpHMTDG77HXRUTgwtoy0KiOQgIK/2imgRBzNiOs97hNPaHUShwMZm3WJhz/kPoY6e++wD+JvLcqSmWLpkyUHs85Sk6YLI4jjlgk3oQdkTO2YmUcO038FQdjmyNfuVi/Lex7B7lPWsj6xyfgrnq86IPs3BrbQvveVj1VjWyW17e5Ua+tQrKUuzUdvz3hKzCBHJBBUnALw337dJl1fP1bVFogDB1rbetdCX3TZ79fmXy5KW+BmQZNg9eP8IlLzCaIPNltmBzg4Wcud2k6UpvqP6v22PTSx3bTTEqR7JOXldwDU3Fhc0aQ/uHrlD8Rs3ia+3SVx1h9GZojhX8ZOBVlTuzjIvx7eybrwFe4iQqHmIE8YnLT0EeurXcFkMwTSAvrq1e6z8C5C7+9CT5kEIFV9hbm3oaMFm8cNz1X3eL3ioKdLzCXTx3GESN1Jxhzu/wPLPgVwOZwwpi1MRrp73fzHkHZwV1Qn6ogJe+F5RDkxtwcZ33QAdKGpksi1l1X9EVuc1rk26/+sJUXV5sxE4W39FPLPfuEitMum7WBwYw7rxblZurShd2pKfjMPpTpt6tnCz0n2oIQQnIop8NT5RhSuVdQqnWpMrxD+XXZflX98sMhuI4qjtET/BoQOqJjD527gK+YQDStBjwXkHLWenAM1UXOTti5hQ7OO0KWRsf1OE4e7MtFk4qZQXrHDcHidfpNZMWQGT31QEHRT07sAj6Xd/jhftGMmrJCi2AlrUqDN6AVv04jiT0LWGJMO6hJx3LD/IwopPKTXuNybkj/aRly+GCPc8kX3g+XfMeR/G9oz1R/dqiRZHbE4FmY4HZtSi8Yu9hIGtEU0jhiogsIJktlud8dRzNt6VPeR1PrL5noAOD0tPteH6+svfcnBRNsDNP+cjHO6iXtVlsBdCGAFD+GFHaN+n/nHsXZQL4PFbYtmfT28T4b4SHnzrDWSK9gcBJTM82SVwf8kJSFDSgOjK57BLegYJSKHoDr74eY6MZGJgYdY0sqqPpsSI+TZ+yzQwD85OaN86kvlJpU7XjPQhvZ7qmEUKdMftslX934mssPO7kGFd/v23pnsa1PY9+wUickt2nWFCO7cl/I2R0r/zVG9HgWRqSTrngMNwjpbLN9vgOrRfOtZIc0HILeYv6Tg== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-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m5u4voJ3kCoin2y/6+JwbnRr6hg1kyqQ6LSGpTB/ELpFzoUzyzJu7KFsYIVnSZIPIWUg4+bqf2Ucbc0vJhft+qxsWdfkiGufv+ad/VaR4gCUPBnDZmJch8BYaZH7At5PUwpMQsGv7ADnMuBHDuxn4wQh3k6O4eNZgfHPNOiUfYpDGhhE5TnhnyWe4ZsUVe9E9qR/MCkNPnubkzJhOdJE6rTnl7wTrepzdesPDBRVT6pTJRWPf/zZMAv4EzHjX8dj/WRMSvvOf03h866ZHDeSpNe0oFnSyIIMztEYo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75ef4024-6084-4c16-bf4b-08dced772348 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:52.9898 (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: VhptvPHInHNSA6owHV8kfhgMdXcO4rU8CAKgkf3DfSoA4He0JlSj5bYj94TgxR7QjCBFEz5FwCTeyez5Usv2R6b/B4fBmcPFlju0FtMrguY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: ae1QCKhtPPpxgIAfXNTCra_Cwb4QSvsl X-Proofpoint-GUID: ae1QCKhtPPpxgIAfXNTCra_Cwb4QSvsl From: Zhang Yi commit bb712842a85d595525e72f0e378c143e620b3ea2 upstream. Commit 1aa91d9c9933 ("xfs: Add async buffered write support") replace xfs_ilock(XFS_ILOCK_EXCL) with xfs_ilock_for_iomap() when locking the writing inode, and a new variable lockmode is used to indicate the lock mode. Although the lockmode should always be XFS_ILOCK_EXCL, it's still better to use this variable instead of useing XFS_ILOCK_EXCL directly when unlocking the inode. Fixes: 1aa91d9c9933 ("xfs: Add async buffered write support") Signed-off-by: Zhang Yi 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 6e5ace7c9bc9..359aa4fc09b6 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1141,13 +1141,13 @@ xfs_buffered_write_iomap_begin( * them out if the write happens to fail. */ seq = xfs_iomap_inode_sequence(ip, IOMAP_F_NEW); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); trace_xfs_iomap_alloc(ip, offset, count, allocfork, &imap); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, IOMAP_F_NEW, seq); found_imap: seq = xfs_iomap_inode_sequence(ip, 0); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); found_cow: @@ -1157,17 +1157,17 @@ xfs_buffered_write_iomap_begin( if (error) goto out_unlock; seq = xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, IOMAP_F_SHARED, seq); } xfs_trim_extent(&cmap, offset_fsb, imap.br_startoff - offset_fsb); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, 0, seq); out_unlock: - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return error; } From patchwork Wed Oct 16 00:11:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837459 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 AFC2A9443; Wed, 16 Oct 2024 00:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037519; cv=fail; b=HKkQwOiWoiopI1efv6UIkANxXWBbwUvsvBDqAcPGIQhuTI1tS8alHZgROocOq1TFDNHqmh1rA+C3yIfrs009K4FxSzvVIrcw048bibBoGdlT0Q7thmfaQFbogKzZ8Zg+bnZAHNtxTUqNgP4MBt9km2HTQvCa8W90En8zOk8pLgk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037519; c=relaxed/simple; bh=B0h34weELd0p05Ox0LuvE7CMfqtoQzrzye78I29nRKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=YoUfiVxAGCSwjS6qKgY5TVf4CXbphOzX8kuoGVAzIUaF5SiGsZNG1yKS7lXcyxJ/yrE3qMyGhUqfd+k7V2xMITXoFGzF9gs4MYt25LXbXNxwiQz1gnt1qzSULk8Q4/6GsM4o6ZJzzllTRdY8uOqbHVarxywGNR5Jbfb338aYdmQ= 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=gX0k1Hep; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Y5uzQ1dh; 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="gX0k1Hep"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Y5uzQ1dh" 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 49FHth1P019381; Wed, 16 Oct 2024 00:11:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=mvtjWTiAL1Xi9oxyFCQGngt00d3w9ZhdbMPsaqffMOQ=; b= gX0k1Hepq6mtucnAjpg2MSMXg4w9qZDD/jjFhLJol+deWFGpIJQPYEQWCdDK0p5v jfmMtTH0SI1m10Dh58rRPHXObV6BkDKBZCw/jAwmhr9gIYNgTKciCe+cZoiHZwYU j286OMgAYcmP5JPR8C7MJeDMpVicOzGZXlv88kwTzUjcQjuGHG/MWXeCDMkYGRZB kqZ/RB4Ztjp251sjnPxxi+jKXNldcnluwWKyFkOHEvZ5jKIVS43jd9nth7oE/gVX HCq3eM7EATtVfJ7cVQWBcgjnrUso3aek6Mj9AM/lAqdaTvDf103YLKZe6WqOPMys qqt1bA8q1ujWTLCu3493wQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhqd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:57 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMbLDJ026319; Wed, 16 Oct 2024 00:11:56 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85am5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aWwh7UYuPGo2re6mAHldEf35vL5GeTE9r9DZGgs+AHE8XHSeMUuqiMFBYU8oEUzg+L0o3WCsfQMOHMNsM6W7rAnCXwi4gnZps7BfdBUVPt5P2wNWkEM5HS1EmXndyFsBZ6MQRRTdYP6PHsIm70TlqSTGRGloH6SszaspzAL9OM2FkxhrVYlTO+F41WMZXPTcwsovQ+dsUXfNCTo1zhY0771cUMdZgjRLPnHyQ9neyonFb+jsWvYBROR1wwRUPFqHuZcdtMQhgbGNvEttu1GUAVPQcNZap9BU2x55Y07S4mGwp5YtpGLobLeeWwHTRVR3Om1A+nid1Uf9m+Zsr6O6bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=mvtjWTiAL1Xi9oxyFCQGngt00d3w9ZhdbMPsaqffMOQ=; b=StBkaDBpGNMPe+Nk3d3Lr2fvQFV01qxvE4ZyHKrFgBQDO8VD8CTm2V6hwXZidDxQc5uEp27UmPL9jf/EZTTQdzUawOyKodS79p8RY7TuvL/bbI/PPKdLoLkzf0LjhvbqN3GtqEUy+YK9opFJ1J7kTcyZYfXDqcrO1NCMx3s6LIZX8aDN9NMpZsJauE2kII+OayIUPyvtl8rG+CNncZY5QO7F4uFe9Dwx8HudO/lKP1YFbnZ0K2dYTSocihDlESxkIxcpiaIwM710MSTKDwlIQzFxnVOIhmHgA85fH+kSewOY0nhg5KCrJ9wqSsjekRYK1uBVmMzGTfDpW2GWyqxYmA== 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=mvtjWTiAL1Xi9oxyFCQGngt00d3w9ZhdbMPsaqffMOQ=; b=Y5uzQ1dhGmuEhlBqkRl3gS5mwxb8UUn+055z+Q+8+WEYiIIOvFWynzVhDeWM7AX38XOq1H2viUOXBQ2faF9ZM5RoEefG3Fg7rV7KiCCc5B4tdijr5FmtMEqvp/uyrMm6T8/2TvLL7Ud8An7TyIVlHq+udmkxBrXNNwDFWolYhpc= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:54 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:54 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 13/21] xfs: make the seq argument to xfs_bmapi_convert_delalloc() optional Date: Tue, 15 Oct 2024 17:11:18 -0700 Message-Id: <20241016001126.3256-14-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0206.namprd05.prod.outlook.com (2603:10b6:a03:330::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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: c7496325-2b27-4d68-215a-08dced77245b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 6ld7aYMQOygdzmDlP6VZS7Brry+AeDDcvuaS6lQ4zjfNvTcURhUpXBhsu3e365iQ0kTk6bpHE82WS9Kqe5ZbDsEmZmpkkkQNuW6VSlFuVd4O7A1w9K/j5+N+3k86Bw9vq03j3QUVKYWrP8rw4Sm2c5W6i31WeYp0GhpKiUUhx39MeDBsb43pTWMFZgJcDIvAU7FLxsadgOuBLOcmd43XXuJpQujIzqJpeRY9p0ZAvnlZ1V3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255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FkYIsC7I8p1FpepDiibiKZ4/EqTG8QqqEGEWwZ7hzTJwoZR40d2lzVzI7M8XXroO8Gvjhr2M2Ut6teqOCOd1B/yinE7t1fR7gDUiZQ3gOPNu/Wvsc46ZrWbdfRtCT48FYfxIQ2ntm9sG5h30LQSkA7HuXAg+fg1egMgYzq18io9v5fooegAiLm6xAzGuot4U9QNBtOZjez0TLkAcSDAPfCOwOKvR6kiYKsVjHs8H6bzmNPT17g9nPQaJhwP9MEA50iISpcgRYkOzak0sguucybAFzlJaTKSTiuYeWAB6eIk9Y+gwJsZiWd50/4bddFZFwzXqSO/tg/6na5+LKNsE6TxPUffKtXHT1WXCZp6T/0SDdUTmBHYn7HUYD7glJmUuDW01xy2U9E7V3zulS5ACdIzVDW7LU/g9NAP14e+jfoazB81vgccqTihcCajhA3oKt4QQlWZG5iY1UxMiwadKceqH3Sq/XXH6pEQ6PfApzOs6OmTi/rQKMxTxIMhAvkAAL1fbbGnl/Mn+novjAyfAssgCmxiV4J1TdOrj+ynSr7S490YYmjls32qougL9dXbUizTWo6Nm2rBhbvxWYflVtoOSiK2Q3i1QsvGEFwLMHq11VV1xApsLHBhk2tC7FNB2rIMTTt3XV+ySPkdChj2AKlPayvhYwCes+MJRbDJcGf/40sgke5a5YLv6OhQx8e8DsSnusL4JidnufSrgYOG6L7P5eRv7nEvBdXlcxxCdEg1aLSoQtjvooAjA8zbUvEkDpN9+PwHEQe7Lj2OZlSKJZ40xFAwg4o/RR9tIVZb/H/PF+lnIcCEPApJekBvEp1zPkldOT8gqF5v+TkAUt/KNiv1aS2pVuW3Goy7boxi9O+ms92tbWs8mMsLtst00skKow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XKiyu3LwQbRDfSVWtI07SXDdWTSnZzjeFwczD2TBTekcLENRdugSq0jpC5rSSZ6fAjRXqSvxLGLPtT1iC8cBrRlX01m96R0jUoGAZbtMXxa5F90fKO8gUyWj53vzQvSjziQ8Qdb2+W9iv38S3G8Vua6z7otz1R9Z+7DGuELNvx34IFBMwg/xHarFj0WQl/9w3jXz+dWP70SLjGeG4Os+Yva3i0KoZYJFX4pNWlozijgEg66cl13QXCwyxiIfRFQLVAwa47ifMw3iJwat7kyNrZNeQETL3lJXTaF0P31UlQhcrcU/7r08y7Fvi0L0RaBuBKUqFsRKzYlXnPN3Uj8vbJZQtXKaNYsiaHmOFF0h2r9kexYoRsDKl7OsoUdIA5uvC35Rx/IVbACCg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7496325-2b27-4d68-215a-08dced77245b X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:54.8055 (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: Tz/pOB3AZtfEpzbxy49PX8HRK/dKLzeGV9N/MXrX4/+SS0GcJE6uICcH35zy4KFXeiCVI31wjO8wXM5m0Am7gi9MNY8/MlTO6eeyiYXM9tI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: SFMEgDH0zo1eZ9KQXUIVom_KY8o7fIrW X-Proofpoint-GUID: SFMEgDH0zo1eZ9KQXUIVom_KY8o7fIrW From: Zhang Yi commit fc8d0ba0ff5fe4700fa02008b7751ec6b84b7677 upstream. Allow callers to pass a NULLL seq argument if they don't care about the fork sequence number. Signed-off-by: Zhang Yi 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_bmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 18429b7f7811..6ef2c2681248 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4595,7 +4595,8 @@ xfs_bmapi_convert_delalloc( if (!isnullstartblock(bma.got.br_startblock)) { xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); - *seq = READ_ONCE(ifp->if_seq); + if (seq) + *seq = READ_ONCE(ifp->if_seq); goto out_trans_cancel; } @@ -4641,7 +4642,8 @@ xfs_bmapi_convert_delalloc( ASSERT(!isnullstartblock(bma.got.br_startblock)); xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); - *seq = READ_ONCE(ifp->if_seq); + if (seq) + *seq = READ_ONCE(ifp->if_seq); if (whichfork == XFS_COW_FORK) xfs_refcount_alloc_cow_extent(tp, bma.blkno, bma.length); From patchwork Wed Oct 16 00:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837461 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 ED8474A0C; Wed, 16 Oct 2024 00:12:00 +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=1729037522; cv=fail; b=rV3amQnkc9mtEuisndvIDNIHOQvfEW8MlmNrVJrL6O43+pYV8LAwSwJQuEcbvHmKYSXxhmpRRUFLGKBi0Aw73qgv2Ts7O2MzwOtkNDzZBzlo7Gp80NgTaY1GmPOJ1jM7TPlyIy50bG7z010eHBxEvZW/UtuS+ByYA4mMu7VLd2c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037522; c=relaxed/simple; bh=hsSZ8suBUmIFNtNACOSDElXaGVs76z4OghNjy8nD210=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=o2m1B2dccSeeQmEHn2r+W91uN+gUvD+dsDIur0Xf2xZfQHC5agB1sG/+wRGFxyvYqjkui2pEun8Rmxd4kuiqhKspJVwoOVEwRgKWrkdQ8sRr9ar2JjVNoQ3NurUfJ/6BabkqfGt1OMZ59zm1HpV2iDIrNXliZ4T/XjgKGIPSrks= 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=JCZNTbI6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=wRj+bdGn; 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="JCZNTbI6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="wRj+bdGn" 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 49FHtiip001646; Wed, 16 Oct 2024 00:12:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=JgXlRMXzxzjeEYPySLEQ/BSfhz6kuCWSOss0RSqAVRw=; b= JCZNTbI6/06VTuVGntgVrZi54lUQkAq/2K1hn7kP1a9yt8nSu3nlYNWpkkTAGDP7 U5v+YaeJAGcmKf7wfjMVXzuWmmtghFPcuSUfnnggC52+7W85soqVq59RcBtp9JK7 llxo377j1VneiF3NwdsuSaPLT0Dp09B8TzffT7N5rbrC5lj2dnBPDgU68/EZuXzV dac2ObhrP4S3OFyd2/4FA7UZ4hnlIWXFTbzSVqjs16KdG4rTZP6pU6FmgMCgkuvI TUcYzaDAmx5Lm5BNb6neC73kXoa0Nbb/lxs12viN1FONlJ8xfWrtXcUyF1EdoFMH vSYySxBQDuGb5KLOCjjsrg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427g1ajb18-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:00 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G04RAa014014; Wed, 16 Oct 2024 00:11:59 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj84v4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:11:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ldPAMlZpqK1H5vXUUaP9fLyR57r5b4iEyxW3hmBA/HZNrxclNxl9OmjphxWVUpxOa0mSlP6zlPB9Bddm67v5snKYqvQ7B0iOYoPVDQJln3NOKKKy93S5SFVUSbpnZEQOiYln9QC0jQ7S5Mjhn0TrVPx3a7FIzRIQ5dk8S47uCE3Ye9h5YgFYgiLpryu+AmdoH1TXSEx7lU9bUe7LSmrDr7oWSvB4AAIAde8+7DYD5hFZLR8qft3a1vIpJmbGxwaY0Fp3eMErl86encxSn5Zg9AxIYGBage5fFthTsuQa+wg2sZW0fs5mgWT1xVGZbINuBH0g9KMpOc6A/9TDFzkHRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JgXlRMXzxzjeEYPySLEQ/BSfhz6kuCWSOss0RSqAVRw=; b=AOAg/edt8fZ5sl1S/WwZaJEiSIJe4fNsT1rrkxdwD8khS7w+tbq9RsTYEsMiMdYLIKoyaWB5ZQEXGHnIQ30QiHReAX9mRJxPZ1v1XMUek2BI+Z4ZilacMZoWaLqK0IASkmt99zc7YzNruk0R4fUUT32h98wf8XLthWltLQ7Y9oIIzrE6DaBQ6ITCT1Ttw4TfZVL/Y6AqeOtrfz00ibxMAptAZb136BWy8WhhfvY0lvZF++haLLfb07gW1alxKjwvioWiQZIR2zD3Sh99HT9NsbGdGJQkrXykdXmjGQ1eNdZIEuEwSwaSfIVDTiRIGZSHzRBRb8aQwE6v5cSYlqLRmQ== 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=JgXlRMXzxzjeEYPySLEQ/BSfhz6kuCWSOss0RSqAVRw=; b=wRj+bdGn0Jpf05A3TyGGhu1Hxsi8oz8RY78lXj6gnO5/l2bbRJYciVfeeB/heTeyDLIyhEc2cmBSzXohFATWEdfCD5479QRCaaiR5NYBX1PFAI6ih/pphv9mCAlO3kiXvpV1uIPRVlIsQFeCEOpfB5+I3NvaIuZiwARAGsiHDyc= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:56 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:56 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 14/21] xfs: make xfs_bmapi_convert_delalloc() to allocate the target offset Date: Tue, 15 Oct 2024 17:11:19 -0700 Message-Id: <20241016001126.3256-15-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0210.namprd05.prod.outlook.com (2603:10b6:a03:330::35) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: d67bd84c-8590-4ae6-4cfd-08dced772578 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: Fk6SdFkOCTbXsxBVzT+SJXSss0GBBfPWC3/KLsXKvoFms0snDyVUdusKIugopp1rMDpgMGZ7ZiR+DJNMplLPK78vTfn9zzk5WZ/hS+QcpCK2wO+bV70mwig+2IMSWfhgF+X+8r+KfZUuLuKWYagLcqcvcxdX6j22Bq5JPa71rQ5hv3b0d24byCYFHuiWl0nnI6SFbUlCpkcrIidcYzkYvXPtuUTXptPQTNxn96tddFMn+46H7OXNNK0nIj7m7Oy+s0VkRIVDOdZBfW14SKv2J/N67I1Zet5f8CKFSMLF1Zf0wQMbYVI65thw6QK3dzN3SlkeYgoJqyqINQ4/QjrNuLaVZxfxZ3qOPPyDTgqcpwezZKfcDurIcAWA2Y1sPQA1J0yK9siHIjvZCHUYuQLF2ln94vENfnasiJDBt7/YIXZwyRjJhRnFUI6PfZ67dI/usPBepVbi8kE2qq7Y462ezxGwgowoG/6fqVkwH7+BpbwTz9Q+qTBMv0eqpm50iIHPifBmVhm4kt0oGbMr4JhS4bYzUgFiwV/PI93/NBt3PvXzla0KtYa9o/xMrOP2Dl47iUd2boW8SXIGLZLkPR4apqcTFN4GPvHB4h6tom7gt5kToPkQLNHVC0yBWFgIT//qMOaYqUtXADAzDTbUd9sqK/2Z2elqemjqo0RODa1/WeQHIwsad//Y/iVeoeMxvmnpNRn4lch67TfjJbiUUfj5RfehtiCUBXjYvBham7/XZf8ddy2aVgdusEihwuA9kU28pFwrXkFcOcJsslz+ogHs6danvQn9h61pXsADBcnTTomZ7I4FH6sj/YWfDW3M7tVfmh656zAPXyV6wYI8L3frbHMMLAsl+ghHmw6hZi6aSqjvA51g72G+ivygmu2taMoFT3KiYNMYy0qFrD8mMzLtC2bHN8MvXNuNUkWrNghJP22oQMVGWyp86rp+3SiFLDOFK+XVhWh/lAL+6aVxnBXdVmJgXOOt1xWzgDMFh8UwllSbvTxmSx0DCIMwq4PzLLWqNHMdP37LUy8LGww8qJgAnpOeg4CUkyAGeGHby6CZgkkNLXt0Xiv60nGCwj4UKeFz9KhV18glReT3+a/LYRj5qgBAeGa4jRDlRBx7bmGNh8DM8QGesueB2saXeSHWGrmTSFVXXyW9VvyGA5EYF+7iToxQ/xyjwLeUqWGYv7qVxrs42oMLQzWxi8XyF8yiBMZ78o6z8voytgwYVwNP6rSg2xxu6ykxJOB+auAWR/Yf5xOx6clGxm7czlbOQNKE4B8/AtQN+F/Im2cbPZ7GQ76qlQ== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CISjZJ6RUeB4pBqF2KQ9iry2RM4K8Tfqf/8K/E1FI1E2NLeFnKNRCzYLlLqOjxknz2xY7KjPF8eboLaQnO6m7cypM4xjVqo68wWDsY9j9iQELrVDZaJR2lDCxxOGsiTyztDQ/b1qOhV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M+zDR7BkLwJBMtqBj1ocAOuII4qhwGUCHh5dtMe1/9JJ3EtkR9C8y87Vdft7Oh87cb/XQiaMHG43VSXe1qjik= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d67bd84c-8590-4ae6-4cfd-08dced772578 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:56.7072 (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: qabp2UdKIURJVcVJ3ApJYmGHlBRdu8PCT14JvLu3z4TRhhYlCei2jwir9xcojkRl6fnkC/osVJCH0aZ4KThtJ9oaCRS/7x1dPshv/yAwLYU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-GUID: zm5-N4zoivh7yRbrMV1vVwESfjOQsreU X-Proofpoint-ORIG-GUID: zm5-N4zoivh7yRbrMV1vVwESfjOQsreU From: Zhang Yi commit 2e08371a83f1c06fd85eea8cd37c87a224cc4cc4 upstream. Since xfs_bmapi_convert_delalloc() only attempts to allocate the entire delalloc extent and require multiple invocations to allocate the target offset. So xfs_convert_blocks() add a loop to do this job and we call it in the write back path, but xfs_convert_blocks() isn't a common helper. Let's do it in xfs_bmapi_convert_delalloc() and drop xfs_convert_blocks(), preparing for the post EOF delalloc blocks converting in the buffered write begin path. Signed-off-by: Zhang Yi 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_bmap.c | 34 +++++++++++++++++++++++-- fs/xfs/xfs_aops.c | 54 +++++++++++----------------------------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 6ef2c2681248..05e36a745920 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4537,8 +4537,8 @@ xfs_bmapi_write( * invocations to allocate the target offset if a large enough physical extent * is not available. */ -int -xfs_bmapi_convert_delalloc( +static int +xfs_bmapi_convert_one_delalloc( struct xfs_inode *ip, int whichfork, xfs_off_t offset, @@ -4666,6 +4666,36 @@ xfs_bmapi_convert_delalloc( return error; } +/* + * Pass in a dellalloc extent and convert it to real extents, return the real + * extent that maps offset_fsb in iomap. + */ +int +xfs_bmapi_convert_delalloc( + struct xfs_inode *ip, + int whichfork, + loff_t offset, + struct iomap *iomap, + unsigned int *seq) +{ + int error; + + /* + * Attempt to allocate whatever delalloc extent currently backs offset + * and put the result into iomap. Allocate in a loop because it may + * take several attempts to allocate real blocks for a contiguous + * delalloc extent if free space is sufficiently fragmented. + */ + do { + error = xfs_bmapi_convert_one_delalloc(ip, whichfork, offset, + iomap, seq); + if (error) + return error; + } while (iomap->offset + iomap->length <= offset); + + return 0; +} + int xfs_bmapi_remap( struct xfs_trans *tp, diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index e74097e58097..688ac031d3a1 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -233,45 +233,6 @@ xfs_imap_valid( return true; } -/* - * Pass in a dellalloc extent and convert it to real extents, return the real - * extent that maps offset_fsb in wpc->iomap. - * - * The current page is held locked so nothing could have removed the block - * backing offset_fsb, although it could have moved from the COW to the data - * fork by another thread. - */ -static int -xfs_convert_blocks( - struct iomap_writepage_ctx *wpc, - struct xfs_inode *ip, - int whichfork, - loff_t offset) -{ - int error; - unsigned *seq; - - if (whichfork == XFS_COW_FORK) - seq = &XFS_WPC(wpc)->cow_seq; - else - seq = &XFS_WPC(wpc)->data_seq; - - /* - * Attempt to allocate whatever delalloc extent currently backs offset - * and put the result into wpc->iomap. Allocate in a loop because it - * may take several attempts to allocate real blocks for a contiguous - * delalloc extent if free space is sufficiently fragmented. - */ - do { - error = xfs_bmapi_convert_delalloc(ip, whichfork, offset, - &wpc->iomap, seq); - if (error) - return error; - } while (wpc->iomap.offset + wpc->iomap.length <= offset); - - return 0; -} - static int xfs_map_blocks( struct iomap_writepage_ctx *wpc, @@ -289,6 +250,7 @@ xfs_map_blocks( struct xfs_iext_cursor icur; int retries = 0; int error = 0; + unsigned int *seq; if (xfs_is_shutdown(mp)) return -EIO; @@ -386,7 +348,19 @@ xfs_map_blocks( trace_xfs_map_blocks_found(ip, offset, count, whichfork, &imap); return 0; allocate_blocks: - error = xfs_convert_blocks(wpc, ip, whichfork, offset); + /* + * Convert a dellalloc extent to a real one. The current page is held + * locked so nothing could have removed the block backing offset_fsb, + * although it could have moved from the COW to the data fork by another + * thread. + */ + if (whichfork == XFS_COW_FORK) + seq = &XFS_WPC(wpc)->cow_seq; + else + seq = &XFS_WPC(wpc)->data_seq; + + error = xfs_bmapi_convert_delalloc(ip, whichfork, offset, + &wpc->iomap, seq); if (error) { /* * If we failed to find the extent in the COW fork we might have From patchwork Wed Oct 16 00:11:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837462 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 C5B92101C4; Wed, 16 Oct 2024 00:12: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=1729037524; cv=fail; b=VH/bAjTJU62hyYcmHujz3tK0YyhM+/wTLX9nooHVkxIADtcj1J3kEQJCHWZnl5P+6dpLuvRuI4ti8Gu7Mk5ppw6jiMFIwo8LXX6UlnHc0MExA5dd06JVBA+7juqJAWqDPi2Fvo4v6ozrdb9RKKCvs2x6PdBqhMFh6Kv0ZdfgBkk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037524; c=relaxed/simple; bh=6L0jvtfSM8EfNvpnzEaM/47Iw3u2R0/6/e3TkViILS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=k4u0MdY1/ziddbUU2oVp5z1qOfP8+ZLPvRFdU/oVYer5jrahhDWo1G6aE8tfw3DBSQ7JiZctXk7AbzStamMOrn4T9tHLeNresNdZz1IDUFdBpJFYlDFyb0k0zulD0ot30Z8SX4yYdtHHufjaDnbZt0njy80ncqDccU98Sa2xLDY= 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=OK/61KF3; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=u6cTrCxK; 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="OK/61KF3"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="u6cTrCxK" 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 49FHthT8019400; Wed, 16 Oct 2024 00:12:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=niMUj2EuowLtLXsP9tPrAje9fq5uathyL1/OoyXzizY=; b= OK/61KF3PosllQLYwitxH+erKDTL/YsQMIpUld2cogOZHX7ZgQ4Hr4s4d4l1Lih0 9wmg31gD5s6nVW3syPLzspRp4uI9gtj9tHCTuAl69L/sOmgXQV4xXl/kuRaTBlSv CAf5CVPtEf9RJ+Fk+tPTtXfzMI7fZjfRikSxKcYdO0r6BB5vh9juqR1CBpqFLXeK lRZvJ+UGnynVviLXPe9ollYjgsveuzchRHslct0P86MzbZufBPkOBj8qlokEtHw7 7QUt4h4irr/B4FjsbL1LEsOExEALLef3KSsU3QjFiDmxq48uK5jU3iCV+7jVZ5+w +Fp+TWZZrHq7o8bgPsf8nw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:01 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FMBPUi036115; Wed, 16 Oct 2024 00:12:00 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegwwd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JH09MsuvnjWahBo2YufTbqHVbPCMUSvPMN0QafLgbQ0wpl4a2vXa7++wcCbBlWFqHUblpl2OXfGTSOKaxfbjq+QcghQyjqk/dXatfUYCi1Z19hQ6fYdtn+04UAxK/tBZvtYgo5StN2RCCbxQRJ1PoMGx2VFObQgH/+rT5AQfbwxpgxvR8N6You8BrTkP2k1s+0xfJGco1KwGH/WvmJb1gTwfOopisoaeNGUU9k6bNKl/+bODYFTlNyC1RNSSml8WmL6iAxRt8qpOBwUJ/GgA2LCHzdc5OVv+a3SwIh17kGT7wBErBshMHkTUsQGyW40J67B+vYV2kxt6SYPc7q9euQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=niMUj2EuowLtLXsP9tPrAje9fq5uathyL1/OoyXzizY=; b=J0mP3ClwphhOSQ51TaMigPBf5/+kFauvMY8xWfoX5NXokGSmm++X6HHVbEqJCfnnPNmpPIMp2AGzAGi33JLE0SbuhDnJOHIv6xTvuK6OImQyr0ex3Kvl235750hjZopZjM5NFV7NWO00AWSCRnZrviCeHZcUiLkrOouqN/lL3Lyjp1wu8q/SfbXLdrmRsia1dRc4bJRvpNMvgZ5Fi57Y37P/1z2IHGBMVhkIcYOzwBgyEu77GmMmD2xqw3nYnXAxj6iddhXC5U0ced268PnrDLXuRDCabqqf2aQsFEZuI107hwq3wSr1/EiwhpEs+mwixWYHdf10gssh063fc3j4wg== 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=niMUj2EuowLtLXsP9tPrAje9fq5uathyL1/OoyXzizY=; b=u6cTrCxKZ1A6DVcLGh9Gl0m5MSaERvZTqWikY8hzeU/BphSeSR1bhIyAmPbrdkbqOyXjm9bzbGIY4Hu9E8/xs7jcZKepyTd0KgrJLPiLtBwHuGA5crm+vkYncPXLEDx3Z/xmEcMJ9Tc6FNHO44vwMeF68koSVs3P+E1SJ9o03Us= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:11:58 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:11:58 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 15/21] xfs: convert delayed extents to unwritten when zeroing post eof blocks Date: Tue, 15 Oct 2024 17:11:20 -0700 Message-Id: <20241016001126.3256-16-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0192.namprd05.prod.outlook.com (2603:10b6:a03:330::17) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: f250d672-5495-4071-88fd-08dced772689 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 7ljtZXS6Zua+j3RsVJ9erjAY/6cJK6NuFtPkO6fEhjSs5OBgGjQJzqdjyEO5sEUYTW2cqww8r/lYrBKRhjvBTTI1LWtak/1P02pP3N/GGxqXmTrYSQJIayviuESCysuQ5k1C6pjozzHPGZO9epCRTAQpKo7cUPxn0u4HWyqdWWZueN/3DaaWrpNSZSJhDZ04VFo1uFd+1xPz8wF8CzO+Wffj0VkXQNOn9HyUJjI5wWcSVLWbDdRo3ZJAj+yXgt/KfmpHdom7WKd2cVCvfT7h1SoQCz0Kjo44bseyudqbqJZP34qVGkJ7ceu3e1VxwyQUCkzN8cdakHRPSHCxBuxAzD7oBsUAArHmIqSzMpgRoKord3JduDj57/w2u6dZkHyrW7+FxUhejPyFrB949XEJf5R1rXSmmCSuu9gxFT/iUnoe75dZxWZygxxHOTenLXk9NAvcX+hLbx+5ABdeOQ53tlsr6hIqEWFfQwBUHoLOltMCbK0zxkNXInwBV9+a7goDdy21OyIYJFcLyFWLWvNWMy6R3D/dr9YnUa1jNS4+CWR7xxTMKXHND+Z/U+Vbs3W9e9a2ZJnAIB0NUQLWsaHl7mX0mUjmlnPbaHPkjuCoSAoU1nQqgfIK+Y3z3YKWhRYEsUxf+QMewQvvY2XCTqvd4LNe/8dokmisfd8iKx2Lp4/9DCvHvkJIyO0TBMANwFjaEH2BypBrdwoMHYZsrLMUYSYgUjhE0sENh4VxxMv5OQBhN+phSfZ00IJKjAM7P57RZ+QLZ7WZiWbR+xHL9iybQuCuSLLsqQsJFI3pruU3oBVM98alSeVu6thifHb7jiZl01WRXAT+xDuO76Ud6d46Mw/SmD8UfDB4QvKj6kRqPZOY1d0SB4WeWhujW/NElcLjwMdl4EOi2F1aYuu3BjMPVdtvk9io6FOUFHJWaiA/iWkUn7hDIOHGD1AdAJ1kMl5YXnxt/NMNB/NWu0lDP4IogzP+TFh+XABhIEkgKOMe6RtkuccrjDWi29+UlOL16keOc/i6SH12HOvwHOWF+pGQJlQU1PCqWKFZC4cmjqTszYkUaCqDxmMHtgVrszBEeJdTS7NzMKJB/In7eVf9ANYE3beR1G3EZB1JY4zB3Qk92lbgUI5Egidn78qB4F8A0pjRD3KzieS4ZmmIahPw8Gjhu71g2lgWbebAqN7R7wdTGnXF51DISTSCWD9O3LBWyacCfalncANd3zNI4u8L1ydTbFeICdTUxpZgEgM/UF4OwTNuqHSPDs4sNUTbZyIFv5kGvVmW8FemcFNMcBudz/zi4Q== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QseqVimldkjhGzU7w2ICJH1P2+J7pMiv/Pwbtf3LbLO/0YwOjBz5Koikx4L+rYLvMSug6NjJBbWTVqHjK6gy3Iqfugf6XUrdeQE3c0ilXhhaEAntOU5OdOar92k27i7m1YxKQQYvks7BRCxWdmXXq9R95W0d8mNTUu2rsZoPNkwWwJC4DO6OL7k49m6hKVBtBXr0/IogwwAWJm4fabBf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MMhqPCw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f250d672-5495-4071-88fd-08dced772689 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:11:58.4660 (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: PwUcN3wdyu4lsvZsNKVrPOKaZb1Bp3K/TFkNMD5I/sPSI86q6/nLz1fLiM7EVd4svlqzl2mI1oDzwXaDv/0GpUElmlx8kG5sRzkwp+HfbkQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410150158 X-Proofpoint-ORIG-GUID: vFDwY03bwDBdPRIqv_jpifJvL0P3Sq2K X-Proofpoint-GUID: vFDwY03bwDBdPRIqv_jpifJvL0P3Sq2K From: Zhang Yi commit 5ce5674187c345dc31534d2024c09ad8ef29b7ba upstream. Current clone operation could be non-atomic if the destination of a file is beyond EOF, user could get a file with corrupted (zeroed) data on crash. The problem is about preallocations. If you write some data into a file: [A...B) and XFS decides to preallocate some post-eof blocks, then it can create a delayed allocation reservation: [A.........D) The writeback path tries to convert delayed extents to real ones by allocating blocks. If there aren't enough contiguous free space, we can end up with two extents, the first real and the second still delalloc: [A....C)[C.D) After that, both the in-memory and the on-disk file sizes are still B. If we clone into the range [E...F) from another file: [A....C)[C.D) [E...F) then xfs_reflink_zero_posteof() calls iomap_zero_range() to zero out the range [B, E) beyond EOF and flush it. Since [C, D) is still a delalloc extent, its pagecache will be zeroed and both the in-memory and on-disk size will be updated to D after flushing but before cloning. This is wrong, because the user can see the size change and read the zeroes while the clone operation is ongoing. We need to keep the in-memory and on-disk size before the clone operation starts, so instead of writing zeroes through the page cache for delayed ranges beyond EOF, we convert these ranges to unwritten and invalidate any cached data over that range beyond EOF. Suggested-by: Dave Chinner Signed-off-by: Zhang Yi 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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 359aa4fc09b6..1a150ecbd2b7 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1005,6 +1005,24 @@ xfs_buffered_write_iomap_begin( goto out_unlock; } + /* + * For zeroing, trim a delalloc extent that extends beyond the EOF + * block. If it starts beyond the EOF block, convert it to an + * unwritten extent. + */ + if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && + isnullstartblock(imap.br_startblock)) { + xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); + + if (offset_fsb >= eof_fsb) + goto convert_delay; + if (end_fsb > eof_fsb) { + end_fsb = eof_fsb; + xfs_trim_extent(&imap, offset_fsb, + end_fsb - offset_fsb); + } + } + /* * Search the COW fork extent list even if we did not find a data fork * extent. This serves two purposes: first this implements the @@ -1150,6 +1168,17 @@ xfs_buffered_write_iomap_begin( xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); +convert_delay: + xfs_iunlock(ip, lockmode); + truncate_pagecache(inode, offset); + error = xfs_bmapi_convert_delalloc(ip, XFS_DATA_FORK, offset, + iomap, NULL); + if (error) + return error; + + trace_xfs_iomap_alloc(ip, offset, count, XFS_DATA_FORK, &imap); + return 0; + found_cow: seq = xfs_iomap_inode_sequence(ip, 0); if (imap.br_startoff <= offset_fsb) { From patchwork Wed Oct 16 00:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837466 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 A54791FB3; Wed, 16 Oct 2024 00:12:30 +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=1729037553; cv=fail; b=JuWZmCbe1frvj8PquFLT2ASoXPivsxmawANxwS3lhDbEZ7eIU96NZ3xlrJ1eQMTtabcYAC8dmksjwEvFFa6fYkigif+rhmB0JBM6so2VGuQHh1HvQKXSl43cMAOqHArpHBHm6ksoYkV3J5HXw/0H057Xxb6YupnJXONLwPTWcXE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037553; c=relaxed/simple; bh=d0ggKECF99AgCaY9bUcxBwcJzx6Jp9uCOItOrgd4/7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hi/KD38Cq+FwRXdK4PxPE+GirfjV9gfpUHwbLISO/7Lj6SR9Rx4UNvq+9q9F+mxKGYIQoL27LcCLZPqYK0A4DNiw3ZlwvMjjwvlnvCjzO3oB87Tgfme2jyCUiordp7FlY37KKLLKqtY7lDky5hqhW4qGpKbmRx3AqD4s7jE5/Ao= 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=XczIjTI4; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=AsgsCcyP; 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="XczIjTI4"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="AsgsCcyP" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FHtguG029134; Wed, 16 Oct 2024 00:12:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=dbCmQhVOFmJZyundu4Fp8tTbhMSMAExhM7lu7PXEz9s=; b= XczIjTI4gt2b4hYImcRknMmvcwSVbb27ndFDUAt5jR9ZwmahmMnIVzWMGpqItKZI +bHV9VseWrbi/byCJu4slsrwpNwZgYmJgqNpLCY7mNZy5QUkNWvplkeJ1yd8coaC VFLLkuBSXgWO2WJruBXRtD7F3TAA8YFzPgrXptWKkag8W3jGOMDMV6VACYhPlxYZ o2TiiAnHHku1W7s/UiZ//oUb49uOCqn80FxBP12USC/nlzXuXQ5oDsw4BJCFYuwk R3KNPaCqv8zYKP+4AZxW9eJ8qqa0PLybqulOi/P8ailBhLpDk9caISbBj6LnLYoI zp8YNqnm5HSlXFKAKnzlzw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2jk3w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:29 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLkLw9026369; Wed, 16 Oct 2024 00:12:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85aps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M+z3njoh+vEESlLE6mBDIlcoiqkY4O1EJyZsHK27Sqfd7V4DuYXPVFE/SCCoOU6sHXVx0N2zun7YPWOgS3lgFJdR9YENsBMqJ1rJNpbeAQ3DEf6Somc68KgqtiLtQUBhbFrAoQaZaWYcpyRVEBFPpEGGDWg0wR3WwSu72lgmntd0foSeT4VYOkVa1g3wbtrNtd6zRfM1K8JJEhI+C0U0HqmtbIZAXU3L6m5Dvsu6P8K+DueF/8ARIsW7+02A3eWQE+JxLej/kjyql8TP7xTI0TJRs9EToWRHyhqwl2/cHWxUPrZ3F0ApUgZ8VDjp29Qi7w3S3w57ks6COCSPds7stg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=dbCmQhVOFmJZyundu4Fp8tTbhMSMAExhM7lu7PXEz9s=; b=wLibElH6FvJyJ0+IthV3WS9ZWcfWZ3X6ttF/9HSnYLbACErTRhxOaZvFvXFgMUn9LAeq7xzVzyqxhYMAMtcrX1MjV2B0N4W9WOSVMS207Zlwb16/6pRRHPoardit+Oqnx65bQtHpZzQrPfDFBhjQABpDqnF2SakhdLxMrvsyXuzhKjvouQ7rQSB0li1tGKg/folzzimaiVlHgIQqLcmo/uFv2wrTdhtWs45AySSWMAuY+AQWl6pctsBAhZsI2D1B0/lGvy9lU79plSSpDowtNCDqdAtXbLYZG3VPir/dpvpdq2+JVDmbuxv5Ztd3dqP18+odMqnhZ0+5RHdd/lrTNw== 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=dbCmQhVOFmJZyundu4Fp8tTbhMSMAExhM7lu7PXEz9s=; b=AsgsCcyPqZkW4JYjWm6NaGF+Oh2jjyARlEVLa4v+/gP3UF7lTCuO/Klp1J+O9Oiem2+JNBDaXzfObgRXJG4LLpciKEmA1NeB3SUUDZfL1Sb8AFu5MgPXc/r6gx/dJMrG8tU97rzck0XRK/lEZNqjfbL8B9i5D9oTmoJlCoyBv50= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12:00 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:00 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 16/21] xfs: allow symlinks with short remote targets Date: Tue, 15 Oct 2024 17:11:21 -0700 Message-Id: <20241016001126.3256-17-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0196.namprd05.prod.outlook.com (2603:10b6:a03:330::21) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 5150fc14-5d0a-42ca-9047-08dced7727b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: F1FQfIuVCA9evuXzq+1aX351WtM1/Vaf6CX3FvY54xiEgKhhgVVE1yntsZXdX6Vk8TJF7aRAwFy1QjY0ylewkeTfjF1Ra+1TT/EfaIcxR0Gso5MgtdLCN+gS9QGij50Y2fAKLmTLRaxxQOneJRypYaovxTYwr8w/w/F3ibz13UX/mH4qvZbiNHFkdTI6JT8WDhJ1gCyK98OXnoUk9FjE96G4suXW2IYSNM+e2IckJhaFezZHmjF4FOkQIbWWmS4WFlAEVX0gLyisDvUKTRrf+xk9FxtKL1K8uCPUKL+wy1f9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LAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: moZLrq7nIw4i5TgA43IG/eHE6GBNI8SJcaPEwzbkliYdawS/Ew3ptI4ktgpVVCD75CbS8WYgCjW6J3JOqHuV9YgfJBT+PzQLjg8Mp7PT4wJk6q8kMf4wNA5ohmwAXOjWVbP92JCh2or/EnFi9C6V9mBtVbrSTLTT3VZxHeWMMeIT7DTWZfGqPaom2WepCJNSgdL1ZfN2KLROAkPc5U+vZA7zpCHhCfH4Ez5SLOQPCCTMdJHdYC1kj1uUwwHmc7zbQR0Z0zP99jmhfsTV1ULEsQ636qJlgNHLcsx1GwPU+sWKQlAcUg8Qzbsu/Fgj9L+Wki80sSQnQ2zYyiAcAPzAfYbp6I5wdAhbhkbi4n9Ee6jijl7/j6m9BHA8UF1aEkDYDGHvvZDPHEaaC7e/9OcYMj0obCCzr+6v9XuSjUDURZcDQ3h2CECQyLjPS2/Jkku3Z/TNClgX69gBZoRBFLgGmpm2P05TCeMFtjstyQJcNP0xN26twkLSFkM+/7QIgYWLgGkT4kKqcor8dPEdOQcB3z4mzbLcnwXqPlzHkCIL/0ZFQo2rW0o8WxHBhGGuvls8HqyhbEA8F4KlEMNeMOQqorV8Unv/pGFQiWS0FlDpQY9dTJujtXZoz8T4RvBaTP8ptEkfPy3oFhCiuUYFWGz8ChEM7w6AIX5631BtZwpwy8yr7fPeQZF3Tn8hdVuqjePOy/g3h21N4mn7EStNShKSRUXAeCIJD3vkIpIKehjaW7rrBdpAvTILhF3pdQWbat7xbhrRvZW+CNW+MG5HskO3W1bpcqfGwerQKGj/TzPB2P4F4ampD+lbwj9l2KjhW8wvqZwy4s9EV9aarMalxq54urpDaRNzo9z9L611WHmA5vlweWLPFJi0RKG62gKRBK3LoIQ4haUlFiARUZZG5MRCAvrkqz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LraaPgXKclOtPLC4+W4AoeaRMaGV2i/ouI/bjJk4gF/GVPYUIvZqzGLuRFy9gMi3s8rU3ow2M+4fhZDSYxU62zBLfKkGwWY80LD1QvnlQrl0RhWdrVFXhnxXGyqGI94HP2nv8hibQupknWP/gV343+ctKvvt+tbwqLevb3qz8SECAKG09ldlj4Yt/dCWDORLtRioiU66zlxr+oGZ7utXemoDPXLLctG4dWH28OwP4E2uNgYvD661fVq/eyoNvm8oil74lYCqdYYpbm/XcRZnVAtu+otni54ef0YP7shOwc7MJnWLB3UNoTfwdbsqxtlYKLl5HDp7wuXNeIYZxoRUsDILnDR4/r0/ksGorDhVENA2ER3j90sWYgcyrcyAp0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5150fc14-5d0a-42ca-9047-08dced7727b6 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:00.4354 (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: E4FHqZfc40dOURIxjJpjlnEB2f5gyMGUowltMtNwDKq2z1UZkgQnoqUUdSxN3ytEmlixmYBMvL2YuZgUlSin2zXirzYarp4KxxlNrJ5MVwo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-GUID: fCDjEi73FFPsMrZtTukL0n-8VBO7522w X-Proofpoint-ORIG-GUID: fCDjEi73FFPsMrZtTukL0n-8VBO7522w From: "Darrick J. Wong" commit 38de567906d95c397d87f292b892686b7ec6fbc3 upstream. An internal user complained about log recovery failing on a symlink ("Bad dinode after recovery") with the following (excerpted) format: core.magic = 0x494e core.mode = 0120777 core.version = 3 core.format = 2 (extents) core.nlinkv2 = 1 core.nextents = 1 core.size = 297 core.nblocks = 1 core.naextents = 0 core.forkoff = 0 core.aformat = 2 (extents) u3.bmx[0] = [startoff,startblock,blockcount,extentflag] 0:[0,12,1,0] This is a symbolic link with a 297-byte target stored in a disk block, which is to say this is a symlink with a remote target. The forkoff is 0, which is to say that there's 512 - 176 == 336 bytes in the inode core to store the data fork. Eventually, testing of generic/388 failed with the same inode corruption message during inode recovery. In writing a debugging patch to call xfs_dinode_verify on dirty inode log items when we're committing transactions, I observed that xfs/298 can reproduce the problem quite quickly. xfs/298 creates a symbolic link, adds some extended attributes, then deletes them all. The test failure occurs when the final removexattr also deletes the attr fork because that does not convert the remote symlink back into a shortform symlink. That is how we trip this test. The only reason why xfs/298 only triggers with the debug patch added is that it deletes the symlink, so the final iflush shows the inode as free. I wrote a quick fstest to emulate the behavior of xfs/298, except that it leaves the symlinks on the filesystem after inducing the "corrupt" state. Kernels going back at least as far as 4.18 have written out symlink inodes in this manner and prior to 1eb70f54c445f they did not object to reading them back in. Because we've been writing out inodes this way for quite some time, the only way to fix this is to relax the check for symbolic links. Directories don't have this problem because di_size is bumped to blocksize during the sf->data conversion. Fixes: 1eb70f54c445f ("xfs: validate inode fork size against fork format") 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/libxfs/xfs_inode_buf.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 0f970a0b3382..51fdd29c4ddc 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -366,17 +366,37 @@ xfs_dinode_verify_fork( /* * For fork types that can contain local data, check that the fork * format matches the size of local data contained within the fork. - * - * For all types, check that when the size says the should be in extent - * or btree format, the inode isn't claiming it is in local format. */ if (whichfork == XFS_DATA_FORK) { - if (S_ISDIR(mode) || S_ISLNK(mode)) { + /* + * A directory small enough to fit in the inode must be stored + * in local format. The directory sf <-> extents conversion + * code updates the directory size accordingly. + */ + if (S_ISDIR(mode)) { + if (be64_to_cpu(dip->di_size) <= fork_size && + fork_format != XFS_DINODE_FMT_LOCAL) + return __this_address; + } + + /* + * A symlink with a target small enough to fit in the inode can + * be stored in extents format if xattrs were added (thus + * converting the data fork from shortform to remote format) + * and then removed. + */ + if (S_ISLNK(mode)) { if (be64_to_cpu(dip->di_size) <= fork_size && + fork_format != XFS_DINODE_FMT_EXTENTS && fork_format != XFS_DINODE_FMT_LOCAL) return __this_address; } + /* + * For all types, check that when the size says the fork should + * be in extent or btree format, the inode isn't claiming to be + * in local format. + */ if (be64_to_cpu(dip->di_size) > fork_size && fork_format == XFS_DINODE_FMT_LOCAL) return __this_address; From patchwork Wed Oct 16 00:11:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837469 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 BDC6828EA; Wed, 16 Oct 2024 00:12:34 +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=1729037556; cv=fail; b=KRr4IiVRPXdi9e/A9rG41FA9nuWwF/p7kxspEjW9nGchMiTyAj0oiyFyxHV3vyxkf/R2MgDKbAxUWTYIBiFYHQ22OYXLkJF4+sSvhfxzYQukKYrKP7wN+RSIm3th5pf+DqkfKEO6ogdOPqSecwqLdgLFTNeXfmvPLJbYhPHyV+E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037556; c=relaxed/simple; bh=GxAV78xrXb5VFtPb7uhEU6hh49QGz4myY6HJwVoNBMU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=M2HZaAbDP5IuJI6TJmcgrqJl5iDp7TjS9/wLpjFpVb4J5kpkTnMQHy6zvldkuKkp1Q99zaioiW2qzGiVxxWUPDM0LG1+OpLM5rp690fPlPrKecUgTNEEjmxzAwwoPaB7zdOkz0CWt8b1nCQbz0TMeG71E5YwCqL8J+bQy0ZuxZM= 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=WwiPBoXS; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=zlB7A6i6; 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="WwiPBoXS"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="zlB7A6i6" 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 49FHthTB019400; Wed, 16 Oct 2024 00:12:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=vJpW16RWffnWrxwm7CTx9+DCrBfZOJOIUVHgmkpTnsA=; b= WwiPBoXS3bVu+zi9kHmn2LoX7z05uoaxap1KQfwyYOTxL9hRLs6gparxTJrtkx1B dYavGUpvwBt7vuXmG2h5QkJ1tUYzSC05CKYKMsh5oGda2BdBaRwSpuVa9yK8G6xR RxobnT1C3ARP8+zWsN0o8DGEpQVlNBSyYqrxA7lpW878Uswrst14imoGfnK2zw4x KgKK3XhnWgFBB1g7U0tTr60baM31Cyhw1sOA3pzZ+UA0N54Eix+dkccZoM+N3Ykl yRaLcgYNrU858m8u8SaBzK3F4b+TT22pMIbDvBU6tjs1po5hDlsb6AOVJKeWa1i1 jMx1OlWDYj4StcisbY3T3A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:33 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLWlMP036099; Wed, 16 Oct 2024 00:12:32 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 427fjegx2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cg90yhHWoQ7b+eLVqgcfMx9dNa4BJrEL7WUuYSjktCl9tZ7tVRxPJi8ao4LcJZTDZNlwCBpUNAy8dw4uwKEheRt/Oq/V3t6uD+OG2kqjcyAz8PnaiSWO3VAsEiryWfX2KHXglMlpHq4avjT0zZvW18+G4w6teSbuqu9W6R0wMV6TxmnsDR8w6Yjf0pzg1ZigNRe/GXUVjdCGvuNr2WVzMuPq5Rin2nnmfGYdhNV4b4WtM8OL1wPQ+5NizJQdaPfs1jwYCjmXuh5aqbXs8mooqLFtwgkFbi9kKLyLLmAtfN6jA6uOhTXOSyzKuBfys5eDuIbUxam90WhMj8xhaWvY+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=vJpW16RWffnWrxwm7CTx9+DCrBfZOJOIUVHgmkpTnsA=; b=Buw0121QYX5+bO2iOpsTtYEJwwR52aNC7+AL1bEsMGd2YD6SAEZv4EhpZkNIf+wYYlEZOA0PDOtVKfL59gPHT1X+dEPHr9Jkk/wKicdMVrPuJNaDSusTYt3rh7RGgpo5hRmGLdieKhg80tY9xfsUNxPTFvgwZpsnahlSSOXyQf7n4vhTaLjSc0cBzeAeTqnpZssejAgFkYWVMxR8uerHk8QKUdu3V+gUJtdWYXIYT+OhCcgEqCARm+lINfAdXKkCYl7JumxrSXIekE3VG95vdD6mdHxIaVFjcJBj77hCLdan5z8cXnxqtw7Fwy7qmETPEtXmyQWQSWNaVmDb5n3q5A== 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=vJpW16RWffnWrxwm7CTx9+DCrBfZOJOIUVHgmkpTnsA=; b=zlB7A6i6YwExdsmlo/bUzgm3sGppjAVBGAut+YvCJczzy794XHQKKWhCFhtSUocVjEtCkBXZT4ckYa9CLGB2An2LBfKOmKmy4x5HF4L5uJA3cz8ybNMcREFspMj3qG1a377VFvE6MSa+ju8xn2ANvwLShKUBlCiBdvdpXzDOck0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12:02 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:02 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 17/21] xfs: make sure sb_fdblocks is non-negative Date: Tue, 15 Oct 2024 17:11:22 -0700 Message-Id: <20241016001126.3256-18-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0192.namprd05.prod.outlook.com (2603:10b6:a03:330::17) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 35fbc1b8-abfd-4864-de54-08dced7728b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: zyilV9mpUhTqVIBOcX7wXNNB5aIs1LBRu8hU7+vrtnR3DjLk7HoDQJGr6HommUREeIm2FqrNIMiZtmnOLIibybQ/eIlQeOKf3KTdVoyrIMUdllStl6xBGeTElF/oj//lT9Wh070sX+iiBPOI1YDArPE3Cx9qZ03jHxFpqHVqwJXSg8bYWfl1YpXwaGL83VOX6Vzil4y/dUhbmlPD9Bu6o8du1IK96jPkYK9b642dR/2EvTGi37nFJt1kc5iFxUGxPIKAjC50jeZC66dyFmVWPOVBQJ5Xz0rXn6azzlPgs7aMAsM8GgChRbQv/Yo+lvQcgPN0YnwwZx4TrwZ6TdmOk3jJ9swlisgkhmqVRVrPF8/9Wmp8+yNvgT3+HRtm+4SJQZvVNWCdwWkIuTi5F+Rr3tGRf2TSUz3itCQWGsq0SiTxSqgMqL4v9Rym5FuiguQlKP881ddW/a44Q/FsBOXYSXVOU/XvmnOrR3M8pJ4zLyNHVLqeJwM8Qo5F5eJGA7zyNv3k0IFoSx0HR/NfoXWbyAukxtUnE60h7+mlL10lJW6nPGyCMca04tn15E66tAQBkZsPvfKHfUv9aBSw79ybv37Lvsp0mlHzCHdwTqr5g22CwqSOIzM3D+YTvWZaSIuM4XyC/m+aw7PMfimSb0Loyy3qKXcLOIs9YTt4DH73RxVHaJOTLoJNm8OtGpax0br9MjgrsEARnaiH6BO+rc11B9p3fP+t4IeGGHkkA+gCcHFXhvV8mR5NsNwFhazlEa/oVcwlT00Bd5QhgrvENQTlfL4v3IZx09GpqkP+u9mJ3vASZAvPcOF3Qdv7liA+akQg+J2VTm7ie1WZl4+DfnglIB4e6cZ8vb/BOxWmFmJzF+qf9IxSGwXmV/Zjgf6w3vuPYpEVh++X8BSotvD78wjc23GHCaapPBby74TiI1s6uUZ0evxbLPYKnw58MBB9hO5cGx/iAGNUrFeRkFBArys7BGHHUtSGmig9ydQOhejnnuNwMhujQ26E1E3IaptrldH1/wzr6cCU4iq0/X/0c/7pbfoLj+jnPZoh9B+aTWmIMBmeuVmoOdfNCRpPv34nQKy70bsUMZ/z02r+8rq8ff+xtV9A69BAJq6XY8lpoKHk7Ox2J1UJt4FzEu5vCTrvhwWkyI3MBmTZqBhvam3kX6hYMmVR7D6Dm68gHA8S7xoCQ5ZFqN0YFig97hV+cLKlRSCwOY5BfPdD91ubqysMNKi3p64Oay6jGXsxturIc24oH14pJDWz4pHGc4HZd+/rP9xVpOnuC2wCc7A0vIl19Fr6rQ== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vW7cV/Lw/A9ULTbreNNUuGXzD3CKDYGXIqHIjeyyqKXsoJvaA7yiCz1cPfDYXaXWo8dWblonQ6mJFqSc4BSvJCLT0HFQ66dQoaD/L9YV0ijRfaQrTpvZWNwNkz5Ob/F8EpdXSO2MP/prE0+obJv3t+Us+AjGqjQZ58aXEOPxLmurOQDCe6LVwEuEZjWagmSvjkYFDHpRYaybFbIKYevyJ/6qS95ZKxUth1n3tAgD3qkMDCKScBTXFIvfFPmeo6TYigitnaJSXGAtQ/KpsLt4io0IUD/Je5tcuVgIv1hVcrelD6LPUnadqUMFCma258p2GMFFM+sIiIZgiO8vFCD8LUomitaajG6/0ap4f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EOnUzx44bsG7SqXIo1BQ/oaiul6R9D9I5U7WowJK36eAOa+KdPeKNjEY+k4rKYZWN3DlleB6maKimcz0ee5/ZOTHFGWM0qKllFORNdsLwNmQRxpcOw5mgPevgf5O+tHPJ1wzxzKkI5OvAJGmtfEZuM82PFCNX8OCj8rkKp519qD+3BazfOr8CiaALIGnVZwac5urtItJqlFQYtIIFLD3nDR7iXdsc+6ObztaVgpEMh+DSWmS39bNSWswmTy9T9AtdEpya760yMpg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: fmGDPWIWB8r+FHRVkCzfhGGLJ6AQSqX7addHHyZPvzQJgm77a2vJkDw1agkIll44g82YV3g//Ripgw5T3xH03Ta4qmHqogvYKXxEh1+JZoXO5vj0aGxSltThIHAXL9t6rYPDyyol6SMmM8gAQYidkclLV8u8MynAYtmcqQOuI8wcOdC43UsKJX18ehjyO3j/winQeCSuWw52TNWL+o7fXt/s2dTaKb6REY8xkqEe14XXfdaEMaLOcpM5Fi7T6YXehAO6AZGt6syK6R6Pm3gOVSLaaM4+2A+Ey3wSzMiJtPoN2wBXT8QwgkI+G2PiH0WvNv2zoGKQmqA37Zhj9+IPYC1QhDw8Wu07IoPj9Qj4rgw4aL9KT6CluSnCaCcXqgaVRF2duLgukjJLcf5SB13yoDLQbAKKHRK9zM2ri9uY+EVp8T1YHrsoRYrqa2F0YY89bcDXAKkKd32Qv/YAzSX2LUkYkghQzLW7n2l32Fwl9nzULfMoPGhU6KxAPkjIcitAi92ohcs3kmXn21U+RWGYj8JNwucZP4DFdGekaBHEDdHnsQlAHopPjKV5eaceXOW8ATyaogFW/qvPHMHYDqbWPB/MD5w7P2tcSGObBoNMp2Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35fbc1b8-abfd-4864-de54-08dced7728b4 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:02.0623 (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: s1sHMSC/3ApnvUBRQCKRoJjnWSdYoCRttMHOxmhN8qS7CAPhywPT26luAIyzuoc7WDWVRZ/gBoIOKpp017XCL99Pe6HE7syN36HwsLnkVEA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-ORIG-GUID: _Vpp0qKUr4MXygaDeYxY4W17EdROJJ-R X-Proofpoint-GUID: _Vpp0qKUr4MXygaDeYxY4W17EdROJJ-R From: Wengang Wang commit 58f880711f2ba53fd5e959875aff5b3bf6d5c32e upstream. A user with a completely full filesystem experienced an unexpected shutdown when the filesystem tried to write the superblock during runtime. kernel shows the following dmesg: [ 8.176281] XFS (dm-4): Metadata corruption detected at xfs_sb_write_verify+0x60/0x120 [xfs], xfs_sb block 0x0 [ 8.177417] XFS (dm-4): Unmount and run xfs_repair [ 8.178016] XFS (dm-4): First 128 bytes of corrupted metadata buffer: [ 8.178703] 00000000: 58 46 53 42 00 00 10 00 00 00 00 00 01 90 00 00 XFSB............ [ 8.179487] 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ [ 8.180312] 00000020: cf 12 dc 89 ca 26 45 29 92 e6 e3 8d 3b b8 a2 c3 .....&E)....;... [ 8.181150] 00000030: 00 00 00 00 01 00 00 06 00 00 00 00 00 00 00 80 ................ [ 8.182003] 00000040: 00 00 00 00 00 00 00 81 00 00 00 00 00 00 00 82 ................ [ 8.182004] 00000050: 00 00 00 01 00 64 00 00 00 00 00 04 00 00 00 00 .....d.......... [ 8.182004] 00000060: 00 00 64 00 b4 a5 02 00 02 00 00 08 00 00 00 00 ..d............. [ 8.182005] 00000070: 00 00 00 00 00 00 00 00 0c 09 09 03 17 00 00 19 ................ [ 8.182008] XFS (dm-4): Corruption of in-memory data detected. Shutting down filesystem [ 8.182010] XFS (dm-4): Please unmount the filesystem and rectify the problem(s) When xfs_log_sb writes super block to disk, b_fdblocks is fetched from m_fdblocks without any lock. As m_fdblocks can experience a positive -> negative -> positive changing when the FS reaches fullness (see xfs_mod_fdblocks). So there is a chance that sb_fdblocks is negative, and because sb_fdblocks is type of unsigned long long, it reads super big. And sb_fdblocks being bigger than sb_dblocks is a problem during log recovery, xfs_validate_sb_write() complains. Fix: As sb_fdblocks will be re-calculated during mount when lazysbcount is enabled, We just need to make xfs_validate_sb_write() happy -- make sure sb_fdblocks is not nenative. This patch also takes care of other percpu counters in xfs_log_sb. Signed-off-by: Wengang Wang 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 59c4804e4d79..424acdd4b0fc 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1031,11 +1031,12 @@ xfs_log_sb( * and hence we don't need have to update it here. */ if (xfs_has_lazysbcount(mp)) { - mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount); + mp->m_sb.sb_icount = percpu_counter_sum_positive(&mp->m_icount); mp->m_sb.sb_ifree = min_t(uint64_t, - percpu_counter_sum(&mp->m_ifree), + percpu_counter_sum_positive(&mp->m_ifree), mp->m_sb.sb_icount); - mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); + mp->m_sb.sb_fdblocks = + percpu_counter_sum_positive(&mp->m_fdblocks); } xfs_sb_to_disk(bp->b_addr, &mp->m_sb); From patchwork Wed Oct 16 00:11:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837465 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 ECD19259C; Wed, 16 Oct 2024 00:12:30 +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=1729037552; cv=fail; b=EHZPh6SHn17Pey51peLyAgvPz3n6auu+LGWmGndD59+lpDIvNPRJCu/KAjPw1r4bfXj49VOFWqxkKHXHI+PbUAkA4dvQ8MtgaOEGXsMEqWzWwgDsqN4/3EEng6FvuaZOcPnzZQzF+khy8yu1XleJCLm3YORxUPVwt+ubwkMiJzg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037552; c=relaxed/simple; bh=Kh0BagGJNGvBs8fmT51DDOBp71gb3F/wa0+mOCo0sAo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=LKtuCxhkkIyYSlGeshJ8M/TrLA7N+JxtE0agmuiKNvoP8ctoJRrC1FBHXN14tBT3XQ7ODe1s252Ukid75/qq6oPRhJ9/G/2MdE1vxDqS8DuzcIRWB4SnY2KXcr1pTwEpg6/qK9s/ERP+BK+SWJ04wEEl8q5wCUDHgEvwYNfQcSA= 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=luGUEWZp; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=VTIUX6KW; 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="luGUEWZp"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="VTIUX6KW" 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 49FHtd0Y011654; Wed, 16 Oct 2024 00:12:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=f6pO4oukCU5P/fkoPAL8CUuRf49VRR3M2BWC/wYQwMg=; b= luGUEWZpojXMJLjjZbu6Cx0NIny/SLvD/pXlUm2HCEtiWiixQgjvV6x72mEvHCp4 Mn/En5cD9BBObnSWvlBPrlrfEk8O50PPZXYojZzgEEniVp6Z0wG50CgdadIYCJNF gQuyW7wb+UnT7SB6ORIfrnUvegJmoo1NBeA2iWmIvSW8rwMk/2TGDd4lB9YgKVU8 V9+47F3QIU1RWgabO45OyaMCJL20yM78+tOumKMvulpR/POuha7QG86QVLMKna+t O2pBySGh/pjZpPTlBKLg2Az6L/F+GJ37wfVsEoLIQNapEjs9J7hL/DlI1+K8DFHO 8SKz34k0k05b42hXImJ7/g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gqt2fpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:29 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLkLwA026369; Wed, 16 Oct 2024 00:12:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85aps-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C8HtD9Scw4TJeOkQlQKu0GFf5hzOLk2WwyhQgWih8IyBjZX9R4ZWwuS9JWnhydqNr9LIV99QllWW4h3gGkmP0/oZ6Oht+DGMK1pBvcn9Gq+RlZQZmlZ36I91GHQLTjc1EN+ZY8+xLcoLViFu9ZMMtlPuLYaLe0ugkKDWQXyQaNTitmgJX5zXtIJaCImBg1645mClx0biF7f7nGfvF6BDI55JvAIykGBgK4xx6SD+8a3RM+Q2/Xwit/1Ada32EJFUvJHypFXvnf8rheyv8IcDGd9V6JmNMu+DX3HXqEIf/4CWyhK3+bq5HcMUYeDBYWsGlqNfD27VZM3SDD9mg88DbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=f6pO4oukCU5P/fkoPAL8CUuRf49VRR3M2BWC/wYQwMg=; b=uaYZIobr7dIWKjqJgpOXllaeaC9W3Vy2a6Hu1fvaUKW1M9U4NmHEl4SPztVS8PjHKTCgjxAATqMYKdUbc0gGBvttWVbsUZJM23TUH9+HI+oYFoZcr/CXprFqKyU0SiMSTVvDo6MFNyt940XA89n6vcMgyeQtSRt8pyR/KAhdPRS4DYtFxL0cX5jNB6OPXPzR1TdyChfDuGIfR6vuM6xs8IzTKyutGdRy7qp8V3JlPwLvIcwZeGfvb2GDoR/ntT8qmncAkwiSVwRFahA0PKvQwnYm+lZMGj5yXgs3KbFyqvYfdvtisWFQvblwT/ksn46/CIDEp0MLGwxw5RVFge/qMQ== 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=f6pO4oukCU5P/fkoPAL8CUuRf49VRR3M2BWC/wYQwMg=; b=VTIUX6KW1wezC+gp6ddkJToxtsh0rlsDdYYXzK11QJRnSL+cJ1h8aAQYDSKKpey7Kxvmigc6CMvQ5ZPbtzSJp2lyFOmfOGVjgTJWNgYCKMv+wIwzURVPA+5ifldhLavfjrb4TUaovTLMm4UkPhe+uYPnQxxaGiBfBQR01RC+OoA= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12: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%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:04 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 18/21] xfs: fix unlink vs cluster buffer instantiation race Date: Tue, 15 Oct 2024 17:11:23 -0700 Message-Id: <20241016001126.3256-19-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR05CA0029.namprd05.prod.outlook.com (2603:10b6:a03:c0::42) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 236b6a2d-693f-4044-78dd-08dced7729e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: cO6bwDJ/tKe3RZxwjRISwboDv2rxmDUHJFMaX1qvP++8F0qnjofl0J/yQtF6ha+CuTdj4p2lSetY/GRRJWXvZv2knq8X6vm1JLH8ec7pSk0tue21wCQWr0i/TJOvZ/Ss4yvl6nXrnavjhDqN2H79CzJBi0/h0tungddzfPEA4I9nAJAIpqqEoRT0ckb/sHcKrnbJbUjAfwLF60pbqRhtkDrK6nv1SrzyjHyQ+iXGXqKSghtChylF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CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 10blD/bPh6ffJfXmdy4MM1DNUTJDNKSaqk9YutBE5tF+GEZeEtd0exq+brtGFudjXLThzwY8r+Yc3d2CzC5bCyXoIDNop1RGjKad0HTduCyyQq+el2gwAAJLMvmYnuqR+Mgt/NhhJ+tfKxeNwa53yPh7VhSx4w3DzpQOgpvzLnbJHne9FmXPc51BkVnaY3mZO3mFDIhFqBfgdlnesbBssJTMXVCgDIOye5DcA4WXGWZ/SERhyZJWSZgtwhaWP5Bj3DRXkBRFrrkVm7r1s55kE6uVjb8qLbrUZY3GBotXs6D4upk7/HyrCqr0Wm2EvYbT2ovPGnNwu9mcX8azUhLzeCBcdor0A8woui1x19ubqOvOmfYjdOPB6I9ISFJOPmGbYSm8IuhqxH6UmR47sz5a9hL7YkTR53II6T5rQuBJJa+iynsUKDwjQMamuQUwY6sAJ4jXKLLbnj+hw4P7dcgHEXPGMf6sg30N13Lh2i5QFRi5QUnNbodaxk50CKeGQwMGppldlkpjtDKc8eHHvDQt2Fl2SY1LVEQ/GKoa6hx2sKxcwd0NZxm/V2h9jPDbqwopku7/ZxRwkDssEl9qY5Mo70jhnr4C9dQYzD6A0DDXjuQ8nSyLWd0cOKJsJ1BntvJP0N/ONRBclJrheIXK/VqxY+IM6aZfn/IQ27LupV1MunRyx8dbYnmFU+GOvkfeNakU9C5KxCcbAxLDAyo+G0gdwLkClPoNHQ9uO0MqyoSbvxQMJWXso0dLg87dLXdRXhv6ZmuAU3jFdGWRe2zvDmjE+T6nQor79w/D7FSeJ4dguUxKrS/ObpzNPjS3yFFSacnE6aeKSXV8tOKSC81y2UZFAHFxNmnbst37qbY8Wc94d8wz6SQqLrx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TqlTalfuBJyS24k6BSmfI6Yj4rjscLJn9xuRSiqUlHOBpqWQ2FBCrRmtN/EZ65ASN3EKW2AOaCxR1tZGw19GysyJfv+oGV2BIJJUB3fOg7bwhjhsAZf1mvpMvwuRsOLSGu4dejk5leDBg7j8GFoVhmyRIoyQPxzzkRAqkBbN0iR1adTIOH8arI2vSXrNLSltuQ+PQ518YHYjrnb0Q5rur1QQJjIFzcISA+TAElER/NH7NEUV8T4PysnLqRDGg8MJO+pBNfix8vCRRfB54rCZMndJXODGEoONvR9gjYj37kqRbGDhL7+moSK4EwCzS0uTTFQVpM7G2HQMF6ifxG7JEGyi74lOaqn/G/VQPUJ39QRFmKFTTK+jbdpcB6hTLh37wjGHtv5YpTH3f4t1nnGfATFqvG6Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 236b6a2d-693f-4044-78dd-08dced7729e8 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:04.1023 (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: oob3EAYJlXWMU9CvlIG2sZUUf8x9bZwbFo80FJK7Y7SISloClckSwjxxzf69/q+rzRcj789ffj0tRknw90aTWx16x85+dJTuuLeQONY+bXA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-GUID: J3M3AopMJpDJT17054SYj9sJNon_JR4a X-Proofpoint-ORIG-GUID: J3M3AopMJpDJT17054SYj9sJNon_JR4a From: Dave Chinner commit 348a1983cf4cf5099fc398438a968443af4c9f65 upstream. Luis has been reporting an assert failure when freeing an inode cluster during inode inactivation for a while. The assert looks like: XFS: Assertion failed: bp->b_flags & XBF_DONE, file: fs/xfs/xfs_trans_buf.c, line: 241 ------------[ cut here ]------------ kernel BUG at fs/xfs/xfs_message.c:102! Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI CPU: 4 PID: 73 Comm: kworker/4:1 Not tainted 6.10.0-rc1 #4 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Workqueue: xfs-inodegc/loop5 xfs_inodegc_worker [xfs] RIP: 0010:assfail (fs/xfs/xfs_message.c:102) xfs RSP: 0018:ffff88810188f7f0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff88816e748250 RCX: 1ffffffff844b0e7 RDX: 0000000000000004 RSI: ffff88810188f558 RDI: ffffffffc2431fa0 RBP: 1ffff11020311f01 R08: 0000000042431f9f R09: ffffed1020311e9b R10: ffff88810188f4df R11: ffffffffac725d70 R12: ffff88817a3f4000 R13: ffff88812182f000 R14: ffff88810188f998 R15: ffffffffc2423f80 FS: 0000000000000000(0000) GS:ffff8881c8400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055fe9d0f109c CR3: 000000014426c002 CR4: 0000000000770ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: xfs_trans_read_buf_map (fs/xfs/xfs_trans_buf.c:241 (discriminator 1)) xfs xfs_imap_to_bp (fs/xfs/xfs_trans.h:210 fs/xfs/libxfs/xfs_inode_buf.c:138) xfs xfs_inode_item_precommit (fs/xfs/xfs_inode_item.c:145) xfs xfs_trans_run_precommits (fs/xfs/xfs_trans.c:931) xfs __xfs_trans_commit (fs/xfs/xfs_trans.c:966) xfs xfs_inactive_ifree (fs/xfs/xfs_inode.c:1811) xfs xfs_inactive (fs/xfs/xfs_inode.c:2013) xfs xfs_inodegc_worker (fs/xfs/xfs_icache.c:1841 fs/xfs/xfs_icache.c:1886) xfs process_one_work (kernel/workqueue.c:3231) worker_thread (kernel/workqueue.c:3306 (discriminator 2) kernel/workqueue.c:3393 (discriminator 2)) kthread (kernel/kthread.c:389) ret_from_fork (arch/x86/kernel/process.c:147) ret_from_fork_asm (arch/x86/entry/entry_64.S:257) And occurs when the the inode precommit handlers is attempt to look up the inode cluster buffer to attach the inode for writeback. The trail of logic that I can reconstruct is as follows. 1. the inode is clean when inodegc runs, so it is not attached to a cluster buffer when precommit runs. 2. #1 implies the inode cluster buffer may be clean and not pinned by dirty inodes when inodegc runs. 3. #2 implies that the inode cluster buffer can be reclaimed by memory pressure at any time. 4. The assert failure implies that the cluster buffer was attached to the transaction, but not marked done. It had been accessed earlier in the transaction, but not marked done. 5. #4 implies the cluster buffer has been invalidated (i.e. marked stale). 6. #5 implies that the inode cluster buffer was instantiated uninitialised in the transaction in xfs_ifree_cluster(), which only instantiates the buffers to invalidate them and never marks them as done. Given factors 1-3, this issue is highly dependent on timing and environmental factors. Hence the issue can be very difficult to reproduce in some situations, but highly reliable in others. Luis has an environment where it can be reproduced easily by g/531 but, OTOH, I've reproduced it only once in ~2000 cycles of g/531. I think the fix is to have xfs_ifree_cluster() set the XBF_DONE flag on the cluster buffers, even though they may not be initialised. The reasons why I think this is safe are: 1. A buffer cache lookup hit on a XBF_STALE buffer will clear the XBF_DONE flag. Hence all future users of the buffer know they have to re-initialise the contents before use and mark it done themselves. 2. xfs_trans_binval() sets the XFS_BLI_STALE flag, which means the buffer remains locked until the journal commit completes and the buffer is unpinned. Hence once marked XBF_STALE/XFS_BLI_STALE by xfs_ifree_cluster(), the only context that can access the freed buffer is the currently running transaction. 3. #2 implies that future buffer lookups in the currently running transaction will hit the transaction match code and not the buffer cache. Hence XBF_STALE and XFS_BLI_STALE will not be cleared unless the transaction initialises and logs the buffer with valid contents again. At which point, the buffer will be marked marked XBF_DONE again, so having XBF_DONE already set on the stale buffer is a moot point. 4. #2 also implies that any concurrent access to that cluster buffer will block waiting on the buffer lock until the inode cluster has been fully freed and is no longer an active inode cluster buffer. 5. #4 + #1 means that any future user of the disk range of that buffer will always see the range of disk blocks covered by the cluster buffer as not done, and hence must initialise the contents themselves. 6. Setting XBF_DONE in xfs_ifree_cluster() then means the unlinked inode precommit code will see a XBF_DONE buffer from the transaction match as it expects. It can then attach the stale but newly dirtied inode to the stale but newly dirtied cluster buffer without unexpected failures. The stale buffer will then sail through the journal and do the right thing with the attached stale inode during unpin. Hence the fix is just one line of extra code. The explanation of why we have to set XBF_DONE in xfs_ifree_cluster, OTOH, is long and complex.... Fixes: 82842fee6e59 ("xfs: fix AGF vs inode cluster buffer deadlock") Signed-off-by: Dave Chinner Tested-by: Luis Chamberlain 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/xfs_inode.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index efb6b8f35617..8bfde8fce6e2 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2329,11 +2329,26 @@ xfs_ifree_cluster( * This buffer may not have been correctly initialised as we * didn't read it from disk. That's not important because we are * only using to mark the buffer as stale in the log, and to - * attach stale cached inodes on it. That means it will never be - * dispatched for IO. If it is, we want to know about it, and we - * want it to fail. We can acheive this by adding a write - * verifier to the buffer. + * attach stale cached inodes on it. + * + * For the inode that triggered the cluster freeing, this + * attachment may occur in xfs_inode_item_precommit() after we + * have marked this buffer stale. If this buffer was not in + * memory before xfs_ifree_cluster() started, it will not be + * marked XBF_DONE and this will cause problems later in + * xfs_inode_item_precommit() when we trip over a (stale, !done) + * buffer to attached to the transaction. + * + * Hence we have to mark the buffer as XFS_DONE here. This is + * safe because we are also marking the buffer as XBF_STALE and + * XFS_BLI_STALE. That means it will never be dispatched for + * IO and it won't be unlocked until the cluster freeing has + * been committed to the journal and the buffer unpinned. If it + * is written, we want to know about it, and we want it to + * fail. We can acheive this by adding a write verifier to the + * buffer. */ + bp->b_flags |= XBF_DONE; bp->b_ops = &xfs_inode_buf_ops; /* From patchwork Wed Oct 16 00:11:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837464 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 9F8DE1859; Wed, 16 Oct 2024 00:12:30 +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=1729037552; cv=fail; b=aIONO+/EcYs8fNL9JWDBeUObGjIqLIXHey5slfSjRa5ZMRmgf1FHRDmZKPaO2WfrgapgfqsmIHaWPfeVlpGQQhR3G7va3updK/Qi7kReup07a1BGHlT5xFqZ4FqkiXJjBI1mCNdRwwz3rktZt78mcnCmLlqY+KCmCba/KL8QlOs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037552; c=relaxed/simple; bh=QzPMIzotBrczxSqSMi8BtEqNXdiFkSkAeE9L7FNGvBg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=LqTTGz/doRK0RLNbozckSLAK6AmBnNfecXtf/8tuqiTzGliPsCK4eKsW/iY9dVu7DycCNoIXS7OO2JXAfw8dXWLT20esDv8i7Jvc08GAzAhsayAQGXCKbZaz9WhDGxH+NomnhN35AEpJZgU8OCfH4vYqK8f2IG1St9Cc2gwJMHU= 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=GfN//Xpe; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=zX0f7B1Q; 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="GfN//Xpe"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="zX0f7B1Q" 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 49FHtikB019421; Wed, 16 Oct 2024 00:12:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=4yKK90hFvHiC2ND2k51QMNfbbckh0+U5eQ7ymmFQfA4=; b= GfN//Xpe4lmd0MdHYLmOTMSF400s4Yl1elpaEgkxY5oRjFygPcgjYQLJvWVGY6p9 4+XIjZIkvaUeMkwq2YD8Sj5sZnmbZwaZBNj/AlU0NDMe34P7FbGnoRH9kFkIoI4F 6RogygSNfZQppgI1u7GluSny17waaFbUp7hPH9OGWV4jJx9goBP8hNU3zBIBIvHb ekES4gPugDqtuOR0h+2U2RA76SmHXKqGl/fRHO7Qsl9YGQrG+ddivhRP4Cny7g56 eN7DQLT55zMuze/vdqyKHjFFBFF2Fo//iCwXKJBLCWVrVp1T9FSm13/vGfJw8Wvo SiwEq62Dyca9im6OujVidQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:29 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLkLwB026369; Wed, 16 Oct 2024 00:12:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85aps-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=en39S8v07A+savMTpy9K8RPvjs8+MPNWgflPN310PcTvNFNk8IwaBpWDUBqUAWobbjxh7icOcfYK7owtb/4rt1p10gCPWAypiX8sl3k+yBBVE1nnijCyhlp7JAUPagoOvI4GUGett+FlQLh1+FKDNljZJas1FwKc/mai+ntRuDATKpSSvsP/PLV8cSwAivj29pAKCjzQPgtSEg1rWrAhDUA2pdSRPcpXi0noLydyKRTN1hF50kIyfQxcHNBHl6G9d2uCSM7s/f7y39B6Srx/85rygkOxwnKLeJ59vP3DlzGBwZBAWawVYUyYD3xZ7QPkN50C9PQGlS9S/NJxdal93Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4yKK90hFvHiC2ND2k51QMNfbbckh0+U5eQ7ymmFQfA4=; b=UU4gOvFb/qAwUTKPAXRYwHV1MjQZIrt5RmWnLFvEHGsjBlpZeyRVR+EvzcZ/azxpdD+WN3pl2ydPwc6bz3LJIU5ahI8ItCO2wel+1+rrhaC3tHS2uXQZ59cuWlwMQNBwR0/+sapkk3p0WTqpJPduWHYaIdvJgsZBO8viw/4nQ1eg3qKjeqLK9GHZ7qO0YCO/ttRHtCWi1G+9zjUw4S3S5W8Pf0/4KDDQweGYZJD3/ykuXRUA2xOoHCaD1hM9KM8df2kdH/zKA6i5w3h0DkiI8huW2HdSLFjyGVhdw7cyx9pJEUYApxPeB60Hx1SLPtZdftZ4sa56R5B6n/qGo+Euqw== 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=4yKK90hFvHiC2ND2k51QMNfbbckh0+U5eQ7ymmFQfA4=; b=zX0f7B1QC804EMPa/bdrskvdp9syNX4IaitdQIhoc8RXOhz1riZaRe35QarNyyPdGwqA5khhlhPyCb9EGude19pcpevZcIol6kuXJlaer9YSWHdSVrpkPBAK3xm8UuAb/85IwqoFHfUXWArJiLuj3/5pLsFLjdxGn1ruWrp+r/U= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12:06 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:06 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 19/21] xfs: fix freeing speculative preallocations for preallocated files Date: Tue, 15 Oct 2024 17:11:24 -0700 Message-Id: <20241016001126.3256-20-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR05CA0033.namprd05.prod.outlook.com (2603:10b6:a03:c0::46) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: b3c94bdc-d80a-4700-de11-08dced772afc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: EquHdzs0Pzofk3SylLM2VrUwkx9ZqPUF8IGpep1CzE/yhcitoo3xrLkfSLROrojfk7fse/eLE0D3VUt6d3grN7vdJKZUwSkq4x5DcNaZ2Nwfae5uqw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iPoBnBkp3SJE++lTQp7nk5VODL2+EtyHmyt7fNT8SlTcyC18c0+s6fgW6s01m7wIMlO8agMDSypHpNIT5n6ediF7VofRamnHXelzAsJCtbnUW3AOna1M/Qoxo+/6H/JQ== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WxLyntJLOLYvNPlh/OijhpdAZNV/wqC1gjE7vUXjyBu/mblA1IFAtUQFUCwkl9o1PICk9B7dNmYVbczLtPWJ+yX2fC9CpVAMhsiFMP5nV+GCcspOtjhO7SjTSCH0SsW94ObCwqhD+I5rT/dRy9v0pW5tPjwNEv3QHkaAnbXCfi8Xi94Rf5ew6N44sUD8gVmL5NP+AYA9SvdhpALl96ktNHxC+DRQVPzXEeEhSo9HCvMGfebq7Wvky51BPN33yjbVgKSi4TQm1Tc7EIxxZ0DdrIzcx7rNxE2C9PtIy4bKCimUzoDHdbO/a4zuGIT7o5CN60AZ3Z+NOT0gNHGxK0s3lLXVUQcQ1w/WJPCYwrz1NXeoHH/8aiJ38aV/Wnkv/pzykoM2cN3f5siCpp3eIbedyAwL25QVcCEFNGh/tl0zHEM91iSoPH04/q1BymusUNKZg2mk8uMr9bI7M7dfKjtDB8+Ka8TxNKwlih+mOdXId4KD7H2ZaiL/HQsIbEaMIl1JxF0fEWF+900zEY0jQMPNFAEZKpiONfaaX3HKoZ2uiz1pZkYelA3MkEPbm+6BRjCfxjvbxNDlB65UTfVZ2mdkX95BiNKkWdQEmlyc0DOfkdQBzEpNYiz/AW9SADmBgmfxSPIldOl7+jncAEbjwfLvy9Vfn2pRNDzbXAd0tDkdeCuRGzidn7nYyAY/jdOcRGIfHuu7g24b9VHwob1s7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uRCHfdKSPForli1lOZrHSY4v6dRzIojM88tCJBBGWCz/i9UROW3K9LO0GoRtuX08HcLvNYiizVGOm+OCpqF6l/drdF7CzceFOiDZ07H3WdXmeb4mFGlx/DKXlEHiDRBda7UpItKkvylasZ7XXFrBTvP3WmEKrfBgBSLOF9ZcxgeDCWDlZ4cqLBwaiI07FBmyBVptSunxsVrhtI2ME8s13tqATEGrkZu0LA8tSvoLcNgQj8zoN6KYXFibFtzmx3SttcQbv8mYVJlkcM6mUIdFXIFdRhu1GacqIyaEP8Y9NU8wnCiT8zZHF0Tlxb+pr1zsIM0hNDAn1X2AgIn6A9l+4qHdI8L6ksGhbyOMMLRZedzNHM38+DUxsXOck6uWUHijH3H7f89urRcXJIQRebR8zOr64wUGTw+zcoK1nFboR5rRqg+xB8g5f/zI2b/vkJPsCe0Sz4/WCcd44S2Uo2LshboGkkMQAYhCu5NAgXSvSZOm0v1MR8gHMwu24gc9YH6/oGCf9iDzRRupguKaFKE8pErEVcAGQQsn6T9lqoiVH9O1d0RBYjRS2VeMi+yWmVGmVDXs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3c94bdc-d80a-4700-de11-08dced772afc X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:06.0848 (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: a/lDt1ueyhOZQ4YUuyHP+iEtzXhJxvexSYG2Nn6Lxapy/nB5G6lWsW3nc93YqzVIwbH9vGi6S5MhM8bRaM93fVqp091nQ6gdB3aadmVsF80= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-ORIG-GUID: Ouoqn9IgAHKB946_dpMLn8_dhoMnc2H_ X-Proofpoint-GUID: Ouoqn9IgAHKB946_dpMLn8_dhoMnc2H_ From: Christoph Hellwig commit 610b29161b0aa9feb59b78dc867553274f17fb01 upstream. xfs_can_free_eofblocks returns false for files that have persistent preallocations unless the force flag is passed and there are delayed blocks. This means it won't free delalloc reservations for files with persistent preallocations unless the force flag is set, and it will also free the persistent preallocations if the force flag is set and the file happens to have delayed allocations. Both of these are bad, so do away with the force flag and always free only post-EOF delayed allocations for files with the XFS_DIFLAG_PREALLOC or APPEND flags set. Signed-off-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/xfs_bmap_util.c | 30 ++++++++++++++++++++++-------- fs/xfs/xfs_bmap_util.h | 2 +- fs/xfs/xfs_icache.c | 2 +- fs/xfs/xfs_inode.c | 14 ++++---------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 4a7d1a1b67a3..f9d72d8e3c35 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -636,13 +636,11 @@ xfs_bmap_punch_delalloc_range( /* * Test whether it is appropriate to check an inode for and free post EOF - * blocks. The 'force' parameter determines whether we should also consider - * regular files that are marked preallocated or append-only. + * blocks. */ bool xfs_can_free_eofblocks( - struct xfs_inode *ip, - bool force) + struct xfs_inode *ip) { struct xfs_bmbt_irec imap; struct xfs_mount *mp = ip->i_mount; @@ -676,11 +674,11 @@ xfs_can_free_eofblocks( return false; /* - * Do not free real preallocated or append-only files unless the file - * has delalloc blocks and we are forced to remove them. + * Only free real extents for inodes with persistent preallocations or + * the append-only flag. */ if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) - if (!force || ip->i_delayed_blks == 0) + if (ip->i_delayed_blks == 0) return false; /* @@ -734,6 +732,22 @@ xfs_free_eofblocks( /* Wait on dio to ensure i_size has settled. */ inode_dio_wait(VFS_I(ip)); + /* + * For preallocated files only free delayed allocations. + * + * Note that this means we also leave speculative preallocations in + * place for preallocated files. + */ + if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) { + if (ip->i_delayed_blks) { + xfs_bmap_punch_delalloc_range(ip, + round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize), + LLONG_MAX); + } + xfs_inode_clear_eofblocks_tag(ip); + return 0; + } + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); if (error) { ASSERT(xfs_is_shutdown(mp)); @@ -1048,7 +1062,7 @@ xfs_prepare_shift( * Trim eofblocks to avoid shifting uninitialized post-eof preallocation * into the accessible region of the file. */ - if (xfs_can_free_eofblocks(ip, true)) { + if (xfs_can_free_eofblocks(ip)) { error = xfs_free_eofblocks(ip); if (error) return error; diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h index 6888078f5c31..1383019ccdb7 100644 --- a/fs/xfs/xfs_bmap_util.h +++ b/fs/xfs/xfs_bmap_util.h @@ -63,7 +63,7 @@ int xfs_insert_file_space(struct xfs_inode *, xfs_off_t offset, xfs_off_t len); /* EOF block manipulation functions */ -bool xfs_can_free_eofblocks(struct xfs_inode *ip, bool force); +bool xfs_can_free_eofblocks(struct xfs_inode *ip); int xfs_free_eofblocks(struct xfs_inode *ip); int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip, diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index db88f41c94c6..57a9f2317525 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -1149,7 +1149,7 @@ xfs_inode_free_eofblocks( } *lockflags |= XFS_IOLOCK_EXCL; - if (xfs_can_free_eofblocks(ip, false)) + if (xfs_can_free_eofblocks(ip)) return xfs_free_eofblocks(ip); /* inode could be preallocated or append-only */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 8bfde8fce6e2..7aa73855fab6 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1469,7 +1469,7 @@ xfs_release( if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) return 0; - if (xfs_can_free_eofblocks(ip, false)) { + if (xfs_can_free_eofblocks(ip)) { /* * Check if the inode is being opened, written and closed * frequently and we have delayed allocation blocks outstanding @@ -1685,15 +1685,13 @@ xfs_inode_needs_inactive( /* * This file isn't being freed, so check if there are post-eof blocks - * to free. @force is true because we are evicting an inode from the - * cache. Post-eof blocks must be freed, lest we end up with broken - * free space accounting. + * to free. * * Note: don't bother with iolock here since lockdep complains about * acquiring it in reclaim context. We have the only reference to the * inode at this point anyways. */ - return xfs_can_free_eofblocks(ip, true); + return xfs_can_free_eofblocks(ip); } /* @@ -1741,15 +1739,11 @@ xfs_inactive( if (VFS_I(ip)->i_nlink != 0) { /* - * force is true because we are evicting an inode from the - * cache. Post-eof blocks must be freed, lest we end up with - * broken free space accounting. - * * Note: don't bother with iolock here since lockdep complains * about acquiring it in reclaim context. We have the only * reference to the inode at this point anyways. */ - if (xfs_can_free_eofblocks(ip, true)) + if (xfs_can_free_eofblocks(ip)) error = xfs_free_eofblocks(ip); goto out; From patchwork Wed Oct 16 00:11:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837468 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 3521F28EA; Wed, 16 Oct 2024 00:12:30 +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=1729037553; cv=fail; b=e6QcuBqFe1oOPVL+4JuUJ9Ym+Dw2bYcDzgpTh2BcvRlNm72jlrRsWYxC9mP0TiuasjEDLPOJQb5noXdRvFv4xQEM+BHHp5ofF2LANzOHVO/S9ceSiWrRR29LjvS7hAMAWdKubXCT/59W3SGeEIkTL8F+eD86GWVJnRUp6WOLZvQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037553; c=relaxed/simple; bh=mtpjIVhfsL1l3oMw330XdUzBlkGACqvqJ4kDACMGEEE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ShGQxAIPWO7NRIxnhlq4rP6pBQfmIrE2RBoJ8g3UOrw6MCDlL4yVrAIL8+wXcAxMg4zJzuq0H0BaUOYazml+1TlC7PPcLp/qV3eg3sjnstHavZvE/23UVVUgswMKk7gaeIJYtn66Q300QnhZrNrNB47nukE0MQM8BNL9/PRsCpQ= 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=gv0XUgrV; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=0VO+5QBJ; 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="gv0XUgrV"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="0VO+5QBJ" 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 49FHtg6N023479; Wed, 16 Oct 2024 00:12:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=c5eAMquoqAeTKaod4nVoasZvNuBWSs7r1zSh9UHGUcg=; b= gv0XUgrVA4w4Tj7nTIDSo6aerepuphXlZOmXgxMQNxij6tpGdbFhFs4t9ZR5xtjh 7UXSbCnACXcXjVINpQkCPABfLABoD16VkimTlDYvGqe898ZRn66JRhsuRtpkpwde OXqKdKSaudsuZSgVgQxWtfOKcdWjtnFJm7Hwsr4rWO+gmae3BGv2MOCfjSRNDjC8 OkjRBLxGiCsvXLHM4pl/Qk/c8fFTrb1ad+OoADUdX9OnNhQLDEd7vQugdMZB691P Rgt7skMtaBG62A9Js2bgoCDK/hZQmAouCoLLzVAXS+ahO2zEPPTAbkKZ3M+KS9wB dLY5uUFV3cDcyOJO5wEckA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427h09j16m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:30 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLkLwC026369; Wed, 16 Oct 2024 00:12:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85aps-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=snA9bkixTegAflxZTbxGbH2InkspevWP4FCNrgfU06jwYzV33OdhPHcDPnu5gTt4mT1WatY0XIRATrxZp6uB2PLqG2ryp76fcLoXfTJG5ApqFMNyNd1xBLo6ZcdRx6+t8DAZ3TD2npa39+PvUk7IyJOhGit2YmminpeD5ab+A92jC4s8Dqv/jCXm/nZd4NI/f1S5I8krw5tWlg1KJURxYhoRk+D4cIJ7VQBnY5PvJWLxjP4a0NnTkYCI2g3YVJtPuhYB7B2E1oLeMg5adKLYn/XJ7NYJI4XaaWXBtuayAQAfrV2H2IBk5BSIE5LCxtA//2LW/UJ6F3UiwyVpur6Ezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=c5eAMquoqAeTKaod4nVoasZvNuBWSs7r1zSh9UHGUcg=; b=XVLxGcVVyC31BCUZtalobth82eFkNPJ/67722L/il2ZyfBX/p6QMOPWTUh/jzDItoaQwBziS+iX7jiwTDqHC/UdelfwKx9TlMMqqGIVpNmMuZO0KjiSOjDY3EeEN7o1M2HadfXFgZJk8Hw4al/msz7p0TuccNXVF7K//RIQ2AIcUyGtJ7hfOm7VlicdOIVE7GTyQpaVykCw1HOI0Lgssk2dlfIpQ5m/y+PZ7ZMwnpfbLtzTShW9ref5ZlyEllVEfTUdNRaxtbrhgERxMUN+soHf8yU63Fud10pnqUDXfjP4ZENQfPEg+yLNT66LbnPP/1cNis41A7QT2YWgJY02oFw== 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=c5eAMquoqAeTKaod4nVoasZvNuBWSs7r1zSh9UHGUcg=; b=0VO+5QBJLQimqbPzDadmsc2CM+OLdEx4NqHbJPCQd4eU0NbaRCklSQw5HTwgH16swguF68Cs7DjbGAN11fTb4f2BWu6qsAcdnaTS8uRAvi3rHI22ysNXT+OTIF+DY6a3HwcqjWP2+t/dIFKQKf7hQcw1bsHi4QvNgXANyDzMoQE= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12: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%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:07 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 20/21] xfs: restrict when we try to align cow fork delalloc to cowextsz hints Date: Tue, 15 Oct 2024 17:11:25 -0700 Message-Id: <20241016001126.3256-21-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR05CA0018.namprd05.prod.outlook.com (2603:10b6:a03:c0::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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: 50489eb4-225f-4b05-18d7-08dced772bfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: OfLd6Qqxi1lIsm1A9Zu8AggfmAHmhHJr1BS1WBpxrS2EcVYst4u8C9CrXjfEEmeXqvDhFxEApFycMCbdSh+lFDXaS+PysE+38C5rMIc7MGKeerjaDlZUjjZP3f6c1R11hPCrBakFxC6xr7gOiwKHV0G0IeLaqNa5Z2ZIbMQsCwgPuKxVfAwqJBtQ1K/AyaNNhL+E3CRsl/wCBxV1BOPuHJWwxCf+C3/eEEOLv/ZOiLkSwLR04OVEAkkx9cM4Q6/t+oySx9hav/8zF+KeK0p/yr3l/AqfJqFUYY6AZXENmz4erHjPUr8WDZJCR80lIohLPHc/pvULzEyejtnd/1RJRs6z8zBSkAxo1P/t6iO9tRA9nRqogAXTbMOdGu9rGen/+je3T45EzuL2qVRp9/xP14X60vXOySoinVKzsoFkoSUPAIsu7wCHMirp+zFC4KqPL1IA7Z827p9B2YNnyktZpgd85kd+9E3oRG6GR+dlA0qoBt/deLONIdfjgh6wkWCKrGUDs2J9rRcYBgCE30k5P/a7cvEBxHq0xZYYRwFIdnkwJfg9YLtNEjhgc58xDvi23Te2DVZ+cncZVFLfGkfdEoVh25MDwJ5rQG+UVVUCLK9yqrqJ5EP4HaWF31/ogheIBvuRq3EnevTTv1BuxJv3BnSP6ItZ9sQjv3o1cevcjg6WHoRMyBd70QE5e8cQBw6ko3XK0g/fOi8kkR+TeBYRxtf2gHuSZkHALYBVlkhzKk3Tjr9Aq4ckNcuc2eGGQIWFGxYVWIPQ4GHhQp6FdOVb/WrPjYv1Qb0am+vEXp0YXcquQzuja6ZYh4GyjmX0owvsimhATMFnfI/HB7Q8N3qrvNCyqH+NDb+Xu3ruEScX+b8Y2MtclBEoZSd7x3eJgABBH95+SNiHI5hGaBxBkVV2vC+WUjmTmNr643UlyqL5QYTOcO7vdrfC8KEypoLKF3GZL0dYkRVBx8QTvsr6m3nCbHTGMb6IccOGQVScNT8mDmrPAalH9Laiik01i/O0rzUSk912UwWARDa3Cyrc2fvEB6TlLTaWWPHLpV1/FbEZfLxJ7INUUeo1AoiZGXj7kyH+T74mytaqxBsZGsPu28dx7/FViFkqbsvQiQWoXYUwpCvizJuU2tB4z2yj2y3xwwuDNbxKtCdORZWcDRxlYXbf1GwhMTOYQjOfN0x5t82xE5y99DYouRtLzQtr0C4mQjsvR6pU0z+OPR9CpzvGLdY9W3R8tvjoK/VLJmc66zsXBKVPtcNSpdM+3jCTl5OUtWk+W4lyXx2PVaG05YU+fAOdnw== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xwxwIa352qOkZ9SmuGYBdsSN6RnWOWIDTjK/CtGDC+bfPshJUNfwd1iJapjdttMjLChZjTsr6zfnkzJkse1VWQXRJAv9eqVfMJAmBjcc6pH9KpXlb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xgw8FLZTjmQDleeTyqN+XrvW39RSerH1aZD8NL7WFDVaSl+r+arZTN/eyxk1jLeMIaFy/C4CTVrrs7GeeDSU/QgRwmGZHxxTwvCgFc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50489eb4-225f-4b05-18d7-08dced772bfc X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:07.6621 (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: T0V7WbL3fpJplplWUh87Poh7VRKMcu2X62cZI3zhR5TsMdwNeuFGKUlzgOHmx/Kp0+UlFMoNINarV9DEFXIqgKJcZO8eVz1IJMXcQJ+KLFw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-GUID: EUNxwMPiw1BJhzjgknpEkmcoLjF_4dJV X-Proofpoint-ORIG-GUID: EUNxwMPiw1BJhzjgknpEkmcoLjF_4dJV From: "Darrick J. Wong" commit 288e1f693f04e66be99f27e7cbe4a45936a66745 upstream. xfs/205 produces the following failure when always_cow is enabled: --- a/tests/xfs/205.out 2024-02-28 16:20:24.437887970 -0800 +++ b/tests/xfs/205.out.bad 2024-06-03 21:13:40.584000000 -0700 @@ -1,4 +1,5 @@ QA output created by 205 *** one file + !!! disk full (expected) *** one file, a few bytes at a time *** done This is the result of overly aggressive attempts to align cow fork delalloc reservations to the CoW extent size hint. Looking at the trace data, we're trying to append a single fsblock to the "fred" file. Trying to create a speculative post-eof reservation fails because there's not enough space. We then set @prealloc_blocks to zero and try again, but the cowextsz alignment code triggers, which expands our request for a 1-fsblock reservation into a 39-block reservation. There's not enough space for that, so the whole write fails with ENOSPC even though there's sufficient space in the filesystem to allocate the single block that we need to land the write. There are two things wrong here -- first, we shouldn't be attempting speculative preallocations beyond what was requested when we're low on space. Second, if we've already computed a posteof preallocation, we shouldn't bother trying to align that to the cowextsize hint. Fix both of these problems by adding a flag that only enables the expansion of the delalloc reservation to the cowextsize if we're doing a non-extending write, and only if we're not doing an ENOSPC retry. This requires us to move the ENOSPC retry logic to xfs_bmapi_reserve_delalloc. I probably should have caught this six years ago when 6ca30729c206d was being reviewed, but oh well. Update the comments to reflect what the code does now. Fixes: 6ca30729c206d ("xfs: bmap code cleanup") 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/libxfs/xfs_bmap.c | 31 +++++++++++++++++++++++++++---- fs/xfs/xfs_iomap.c | 34 ++++++++++++---------------------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 05e36a745920..e6ea35098e07 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3974,20 +3974,32 @@ xfs_bmapi_reserve_delalloc( xfs_extlen_t alen; xfs_extlen_t indlen; int error; - xfs_fileoff_t aoff = off; + xfs_fileoff_t aoff; + bool use_cowextszhint = + whichfork == XFS_COW_FORK && !prealloc; +retry: /* * Cap the alloc length. Keep track of prealloc so we know whether to * tag the inode before we return. */ + aoff = off; alen = XFS_FILBLKS_MIN(len + prealloc, XFS_MAX_BMBT_EXTLEN); if (!eof) alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); if (prealloc && alen >= len) prealloc = alen - len; - /* Figure out the extent size, adjust alen */ - if (whichfork == XFS_COW_FORK) { + /* + * If we're targetting the COW fork but aren't creating a speculative + * posteof preallocation, try to expand the reservation to align with + * the COW extent size hint if there's sufficient free space. + * + * Unlike the data fork, the CoW cancellation functions will free all + * the reservations at inactivation, so we don't require that every + * delalloc reservation have a dirty pagecache. + */ + if (use_cowextszhint) { struct xfs_bmbt_irec prev; xfs_extlen_t extsz = xfs_get_cowextsz_hint(ip); @@ -4006,7 +4018,7 @@ xfs_bmapi_reserve_delalloc( */ error = xfs_quota_reserve_blkres(ip, alen); if (error) - return error; + goto out; /* * Split changing sb for alen and indlen since they could be coming @@ -4051,6 +4063,17 @@ xfs_bmapi_reserve_delalloc( out_unreserve_quota: if (XFS_IS_QUOTA_ON(mp)) xfs_quota_unreserve_blkres(ip, alen); +out: + if (error == -ENOSPC || error == -EDQUOT) { + trace_xfs_delalloc_enospc(ip, off, len); + + if (prealloc || use_cowextszhint) { + /* retry without any preallocation */ + use_cowextszhint = false; + prealloc = 0; + goto retry; + } + } return error; } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 1a150ecbd2b7..9ce2f48b4ebc 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1127,33 +1127,23 @@ xfs_buffered_write_iomap_begin( } } -retry: - error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, - end_fsb - offset_fsb, prealloc_blocks, - allocfork == XFS_DATA_FORK ? &imap : &cmap, - allocfork == XFS_DATA_FORK ? &icur : &ccur, - allocfork == XFS_DATA_FORK ? eof : cow_eof); - switch (error) { - case 0: - break; - case -ENOSPC: - case -EDQUOT: - /* retry without any preallocation */ - trace_xfs_delalloc_enospc(ip, offset, count); - if (prealloc_blocks) { - prealloc_blocks = 0; - goto retry; - } - fallthrough; - default: - goto out_unlock; - } - if (allocfork == XFS_COW_FORK) { + error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, + end_fsb - offset_fsb, prealloc_blocks, &cmap, + &ccur, cow_eof); + if (error) + goto out_unlock; + trace_xfs_iomap_alloc(ip, offset, count, allocfork, &cmap); goto found_cow; } + error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, + end_fsb - offset_fsb, prealloc_blocks, &imap, &icur, + eof); + if (error) + goto out_unlock; + /* * Flag newly allocated delalloc blocks with IOMAP_F_NEW so we punch * them out if the write happens to fail. From patchwork Wed Oct 16 00:11:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13837467 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 B49114A02; Wed, 16 Oct 2024 00:12:31 +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=1729037553; cv=fail; b=L3XWFy7O4esElLGf/aIFz6cDEepdP9P+ZiIyXwvHJ4JV0wo3CBxv2UzkBw1eU74GpZXZOUKk9Jr7K9BRJBycg86lnRGMrRAaqFEACW6JZvPE9vOLbcBUkSL5do2b2WL6jPe404dxW4PrYYscV0O+Q1c6MRJRiear/VpzBh9mLS0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729037553; c=relaxed/simple; bh=bMs9POWWT8A4VqPY6+TEBD4nLIZk9Dmbb+DFLgl0R0Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=LIKkYKycC67L4znQIM2OAsOyYxJX3dE8GTB0MPxFK4EE6mXGrrMrTlS5DQJp6yTXNHbUtktW0BqM/d1b17Pb57YZ88D1yq46IPVRShyR6Qlc3SHj0ohVq415JtmCiHrcJ1J/+DPpnKH2lRABVvgmNwo7avcn8xJAvcr7TIl39nI= 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=VSzkn0Jb; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=WGUA8ByP; 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="VSzkn0Jb"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="WGUA8ByP" 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 49FHthGk019386; Wed, 16 Oct 2024 00:12:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=RiQy61cg4IOXscrXaj2B/dDq1lsiNj08aDRoY+n+3Po=; b= VSzkn0JbvoaYW2FCPXrewgF8WPeWjzQOoBoGlGusYbVGUzF0Fk0TMFrpRi/bunuW OLSoLwZugZjnjR/BJEB/F7aX32HkPPuM4kZHp3MLMesY1JULKEgTSY0pci9cWhH9 A69tGc3fIL0MqBO0FP4AmDIXkCyjwnnKtPx6JE7HKkgESaq7/bpLWsKG1CsanthU JfEcHb3S7/zVjSCFgxjkTwYEvVkGDmPBQCHhUdPxpnhyL97Ko/PUG9FI8ArS8ITR uX7o4hpN37Ig7amapaxnWUusjbQV4NTpfNMIaYmAnTCM8PUT7rtxh2s/9SiDr80x TKNYcPWe0MPa/BKBXPZRog== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427gq7jhqu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:30 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49FLkLwD026369; Wed, 16 Oct 2024 00:12:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj85aps-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 00:12:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n/UepInOFNM+0AV3De3t25HgEGkWvbIChQvlNH4NABy3cdk59z65QxdMSqsxB72N8O7DMdpZjqugZZ5ROBleMd+f4oZIaqQyg3t7F+A3ctCuRRnztYdeC75xkdF+r5zZwojLSVpCkri6GjeHf1JPVK+yyABG2ZsiodyA7dGFB0EDTz4C7D08HgIvtRINhy89SoPbQd0A2qjC5JwZ6kIdPzNZIUd0hqjnUUzC9vAmv3cHUyb7WcakwJNoiFA7yOQ02edZWLKh4/UgRbu/SQR/+qNkq1hNRiYF78YyzG6QCjRLL141rwQ0iJLi7hT37mNT7K7wtcwKm02pL+AtY6veTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=RiQy61cg4IOXscrXaj2B/dDq1lsiNj08aDRoY+n+3Po=; b=Du9MuwTtHNTs1IWfjBbQa8p8Nma/lfTV9oQpyfR66ncV+P+FMyNThbRrcl2wiI0dteoIHGXfQu0H/oiWfNVxFS9uaClGZ3gbFJaaz2FjGbdQOIGToevLG8FCVXCcnEaRVEkvI9e0ClDDMLTqn/SzWb3nY4AJazqjVW1dURaxYYu/HLpCiEflySPUEC4SbCGi+ZeAw8qoSJTrUMBBWzboCGObvJzOpRy7eawpNLA6R+1c+bZ0IdZE3/LaZB044a5MU1ITB+8RFGy+nq0/mGnmozz4HIbeHGjFEdEXfS+UvCMcaW0Uj7vhKZ/Dip0V2V4iZK/MnEhIav6X/fPkGIinaw== 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=RiQy61cg4IOXscrXaj2B/dDq1lsiNj08aDRoY+n+3Po=; b=WGUA8ByP22+G1s+qNJdxtUYikaIOkw0QTWXB+1i+Fa46pHJ/T3HEX6ERMTS4a+5xDkIWtwN8oPbGnWhxUXX0nveY2OtzgLbEE9aGjWlqOk+SQrmNnMj5yv11U/l7lWCOLFm/pS5qEuHDZtgmIlK3KlbohkhTruTXoCQ9LAybeas= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by PH0PR10MB4727.namprd10.prod.outlook.com (2603:10b6:510:3f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 00:12: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%4]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 00:12:09 +0000 From: Catherine Hoang To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 21/21] xfs: allow unlinked symlinks and dirs with zero size Date: Tue, 15 Oct 2024 17:11:26 -0700 Message-Id: <20241016001126.3256-22-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241016001126.3256-1-catherine.hoang@oracle.com> References: <20241016001126.3256-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:33f::21) 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_|PH0PR10MB4727:EE_ X-MS-Office365-Filtering-Correlation-Id: e4eefdd7-7f07-4805-fcb7-08dced772d0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: p48IadxsqXjdroksNRkJIHXLXhydZxHY7m2oxytqs/3eoZXHGFT7nEa+S00MbwaZuSZbIpK6krqDCY7EQY2LQZUYsG/sLDSdlhNApb3sH82WQVrijg7hPVY2rpnxb+Fj6S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TP821fBB9+AZQWrGnIfs71h+wzCwGaQ4znIB3agNq511JNeg1h3WFqC6R0/USc8ZGE+PlBcB8vD93rYojAJ07LSK2zjhcBh1/n6+A== 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:(13230040)(10070799003)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oOtPnDkaNMGPBJyd0e7chrBbavlXDjBw//Wh3wBWInB7vwANQSzqujobg9ngy2fTWk1OzzgBl2tayT6bEycBtZEY5jj207UFxUVgsYU4PB6tpWDApH3Ye3tZWqnlqjnKPeIGyEi+X1GUK2I269PmHfdaqigOwxlX1/AGpRYS4fi6XtjyiJBZGK37fJ1bZnCc9ZqS4u6/tmFCCAJdVBIChW9EJt7ejADbm9L9DdNIR+W+W7S5Ip2oi0roJJRtzpVSJ3/KBY/mYByqhhPDPpv7REYWXH35ceLwbMzZrIxwtNuRtjNulBST7WmfVVlaYhrVdM2vQOiej/VLAlljpdT46RWttZRht+LYwd4aku0MBpeM3UeEuhDCe0OC7pRwV0yX5v1P1zRtcjg/ybzMyHfqTsSu5hJbbnFyeqn7OLNMLsKzz0d59fTCdEpmdZ4irlKSExGxxe2+Phr81alF9L9l2PA4OvosXBsQdd5PHBOfTTozdzRvUsO8LWUMKxc8aXcfZyY3IwXCYqV3S1PviwBhLdASO1usVOIl4Oa7jLr7KW8ijx4z+DfRm5xs5bRj3WyWPTSc+QzwgnPRqMASOSsD/Amklj+Arhor7pXI+gkomGEunnJBGnzXDCOwnBKiokHHPYaLyGkh3UfqgXScK6fzMIHfvCHScliS64epkZPJXMG2FlXyrWYuI91zMlcAbEHdFhRbxZuBrXdSfKpvRCq/f4MdmYRgUeYC8wit+FQRCx9OjADihxGmwgOy9ofVo9W06O6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FUrD5LrSoFZ6Hkp1wjEHt6LeOH6lzrJm10cIg4Qdvq1tRPk5Ir8OAoQRZTRLIx2U4u+hmf1EDVID1ETCjoLehcfdoa0TlFh2vOVE0l7HOQEquwJL5gxEmEzZRZQC50v0A3c8P7L1mNyxLOLSgmHUaVM6+fqO1sLGncDTpXL6i5WNdCtiK0jF9ktRCDXSdBWadvNMuIPt90skjAMk8RA7kUi7WSPSxRSGR9vk2FnVsyk4z8EUhy+/GzAkyAibISHkEDDz+80nh/4ZLRuR3REPs8zEL9F2q6IbTb/aJgVnQPbAzfDMBcKW3NVwzahiewk8ZYo7/OZKSybupfxSiYytJOY/BaEjTUBdks+fL5l+2g3DQ3DzE3g6ldsoG7mNopX8726iZBw6J+wODr5O/EywuSSO/XI4saixkp1KiyNu9/jxSSk8nnnS3flTJwwdAGnl3RsESqtjMll+sRyVFegYJDQ3QqJ8j7SKVxFQCfEjbPGxr6K19i5OpY3vK5xKMphb+C61n2sv8W4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4eefdd7-7f07-4805-fcb7-08dced772d0b X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 00:12:09.3966 (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: xsFBhvKmeJ2PpRFe8eXROVkwUHMWfbHaA4yoU9dmKils/4VbNmR0bz7an/LVkiPErfcrN0aDovXRpg6y0O22AtAa5EQLkU+9ElEUrzpLmXI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4727 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_19,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160000 X-Proofpoint-ORIG-GUID: 0EUpfKVqUjQFsM_qZuIRn-E6fQe8KvqK X-Proofpoint-GUID: 0EUpfKVqUjQFsM_qZuIRn-E6fQe8KvqK From: "Darrick J. Wong" commit 1ec9307fc066dd8a140d5430f8a7576aa9d78cd3 upstream. For a very very long time, inode inactivation has set the inode size to zero before unmapping the extents associated with the data fork. Unfortunately, commit 3c6f46eacd876 changed the inode verifier to prohibit zero-length symlinks and directories. If an inode happens to get logged in this state and the system crashes before freeing the inode, log recovery will also fail on the broken inode. Therefore, allow zero-size symlinks and directories as long as the link count is zero; nobody will be able to open these files by handle so there isn't any risk of data exposure. Fixes: 3c6f46eacd876 ("xfs: sanity check directory inode di_size") 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/libxfs/xfs_inode_buf.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 51fdd29c4ddc..423d39b6b917 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -371,10 +371,13 @@ xfs_dinode_verify_fork( /* * A directory small enough to fit in the inode must be stored * in local format. The directory sf <-> extents conversion - * code updates the directory size accordingly. + * code updates the directory size accordingly. Directories + * being truncated have zero size and are not subject to this + * check. */ if (S_ISDIR(mode)) { - if (be64_to_cpu(dip->di_size) <= fork_size && + if (dip->di_size && + be64_to_cpu(dip->di_size) <= fork_size && fork_format != XFS_DINODE_FMT_LOCAL) return __this_address; } @@ -512,9 +515,19 @@ xfs_dinode_verify( if (mode && xfs_mode_to_ftype(mode) == XFS_DIR3_FT_UNKNOWN) return __this_address; - /* No zero-length symlinks/dirs. */ - if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0) - return __this_address; + /* + * No zero-length symlinks/dirs unless they're unlinked and hence being + * inactivated. + */ + if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0) { + if (dip->di_version > 1) { + if (dip->di_nlink) + return __this_address; + } else { + if (dip->di_onlink) + return __this_address; + } + } fa = xfs_dinode_verify_nrext64(mp, dip); if (fa)