From patchwork Fri Sep 6 21:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794742 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 92B4C158D7B for ; Fri, 6 Sep 2024 21:11:49 +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=1725657111; cv=fail; b=Mtr7tSQHzjtOmQNn6FIxfsmTiKX8dwqURhHcKxZV6pcCpPLy4IJXRv9PbceXAofqQ4SrZjOFhG6C+viuTyX7qjgFs/mIa8Jr5usRTOzFrbOjyIqUe8XhREdzLEnkpvuiuIg14/ZoIBPsZWpoLXbm6PirH8ZFzo1G+p0ePeNP0pY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657111; c=relaxed/simple; bh=X2DnA7ZC+DoRx60TbIiXRACpsYI11z5HLsh3cqWuPc8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=WvyxwM+1ZHubtR9/dLvSY+t8dV5RilgLqC0r3ANuRZAvwHJRg+Hjv40OVLKbaVkI5XBM+SrTg0kxtZaPq82sJAeVLak0aeuZGbcoyb/E+TmxdCHR7sOoQxt+1da5r7UcV7U+/eaXMw7rZR2tmoHndDDv9TPLGx1bL1K6cGd2gY8= 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=Kbs5ODcB; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=QazZj8Pu; 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="Kbs5ODcB"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="QazZj8Pu" 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 486KXV0O015021 for ; Fri, 6 Sep 2024 21:11:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding:mime-version; s= corp-2023-11-20; bh=6d0nsBvi1FRbFaqVbRM5NAAPIbgj3sIou/pOldgMldE=; b= Kbs5ODcBBW1rkSmqdYqOOUflItjzfuZ/eADvV53orjTCRTjbp75iShifPEEIDxqQ PGqFm26SD2K4W0NqHDN9yV+5PkMNM7LjDFNmgNjzjLD2XSZqWT3YjF0ztgipZJKp r0MDR9EZMAywjncxuIjs6JZCigp7XRdO+MOj7C5cB6Rvx40J9tr0J1Q/jRwUWVwP CtjDG7WWMuLf62pKcG8udMHCExlSQTfroxbWiCLG/wtkjoHnBh5uISGL5LmOHEXo oebBw081KJLTyIfrlTNxQ5NmMxM94X4+GHvthGyz1xMEQ/Q6EbwZyGvsO6zYBwgG bZwOLOB7WvR/tMg7s91mgw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwjjmxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:48 +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 486JldpZ016162 for ; Fri, 6 Sep 2024 21:11:47 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeyqy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OGJkxZrDp4FNtHQEO2VzzfOT7g4dSMCfR+OMUoLUlKFo2kNjtTcRTk73uVx5pVtEjB1iF5AWjDn6TsnFlLvLVcnLo9/iHZZgXDeehuN9Cwyja/BPKyf9czL2xF5exEhBbkumm/thdWk0NzX/ozbtz3zE+P8gXjdd57MURlXf08z4QC5cze3jm9k1mtrdnNWILLFlq0+ZUBu0VHozkcIz2Bt2X7tq7vY512kWitePFVvs7l65b84hBRsKNr3e0c8JsGLFzebhFgt1mGPYUeZ3w0Ff4IC+BFv96c8luAPwp6KWagxwB6A+Np6roECviUWlm62MVq/bffzT++9INrQEFw== 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=6d0nsBvi1FRbFaqVbRM5NAAPIbgj3sIou/pOldgMldE=; b=ysvA5LRrCeeROBAPj8bxot3eh2G2D7nshs6imfoiWxPPz02HLWKuWOZhWtrofr79ec/dh4qMltxwXwiw8RhgxVafWOXWOedvMxRz7voMxhMQExS0XPj2OT3BPBNNIQG+v5mmR/O1bmExWrIo68kdW0+u6y5acQL441NuikhHTGulq3Q55kFQyqbPDTdaPGKQo+LUsozjZ2NnRWZEn7a3ymL2TtrUeG0AZ+CTflznwSTvPi1njUhHkVXm+ej9K0XF+3SwPPclwDEukWQpw6ucNG56JlYwBYbk2X/pmgbysA7iCeuG2ewDNFri0qc7YZjjC5dDEpuzomPcOmhEisMfdw== 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=6d0nsBvi1FRbFaqVbRM5NAAPIbgj3sIou/pOldgMldE=; b=QazZj8PuQTxgGRFCXl29uz3nyl5LoDgoy9clVEMCGSsXd+lGk0sCbWLExZnMZQR9Kj6QTjCtY+AyZl31/iG1micCPxg0MBFUrMhT9tOL1zrXP5PUbLpInFuKt5YkR4AK9MZ8+rVsaF/7AefpuwLRhuEauwYSn2qxh55GoQ9biVE= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:45 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 01/22] xfs: fix error returns from xfs_bmapi_write Date: Fri, 6 Sep 2024 14:11:15 -0700 Message-Id: <20240906211136.70391-2-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0127.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: fb7cd463-43b8-4908-3c27-08dcceb8836f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?usjxFtwwWrPPM+8I54moM8gNLOSB+xq?= =?utf-8?q?Fgc1LfrYXfI1thcZS4yzysv6VL+CHteOX5adycZbBACoSjordUHS/utYBU6rJzZeC?= =?utf-8?q?zeTstrZJ+0c9j1ur07o42jJbhxBKz6n6PuOx/ZKJXGqYNAjnOxwi3biTiY077ELrU?= =?utf-8?q?MFWxEbcEI/T0FAOTEdLGrCkbQwaugpct2gOzb3iGpc5m9Qu7hqZQGmnHYOQ9NAAWE?= =?utf-8?q?Bk5EN3lGULl6CG1Ys4QbnktDyCjBHNPiQ7KKhiXP+CJg+kyaYScSxvJ7lbrS75lVY?= =?utf-8?q?XZDnDHLUgN5GKT3h9vTj1tD/N54M+Fnk+FsbeJGFtjvtbBKyN/Pmt2sQPclYEjBMd?= =?utf-8?q?jrACcxv3Gly8KCjP+8hXu9Z+DPfnLYYWoEDxjD76OUKS/xRanqTUA+BqG2LM3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y?= =?utf-8?q?ku/yw4/envktSAIwv1ZwzI9pHFcDO67/4SA=3D=3D?= 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IyJGtQe0YWj1L3nXyB587S+bBhco?= =?utf-8?q?COfrwVoPkMUMDPLa2xOU6oocTPprIfSPQzMLGAhjnS9bHxexJzx8KGzEpaE07M1Lq?= =?utf-8?q?hv7LPeUSjyUG9OYE8LDok5OEqyaWeMcpM/6+jEr32myBNbr7SJPUsu4ZKV7suq3Uq?= =?utf-8?q?vu2bbPRvaTwUIbzQFomeNVCHPf/hsGauO5NGH1c6jh41ZqiO12uy6n7Nlob9Gnis+?= =?utf-8?q?C5ODYkWaGdJYEK8ZpMkpsujKzuUQTcCW+It6jvrtCBKsbSK5TrtYu2wGYQnj94hyh?= =?utf-8?q?eq4xoOQdaXDiHdemJVVE+VdqzZm7wiQ18IIMSKILRn0kpugs4xhhrJUXuwS7daDlo?= =?utf-8?q?kTJHzHawT/iWfijV+K8tVCj1M2VEAsqkMi8Yx0Rc7LZPC6zj/+z8qdrz78iR0UugJ?= =?utf-8?q?td4YEkdSium+VNSYP4+EA/2VQfOS9zGfPBcdGs/qAXLYnL8AVHj/FGrcCDkYqu19b?= =?utf-8?q?OvfgDQPePP3neo6imtTDBzddDN7RCyLv6zhYstJB9+t8RVXfZJADfHG3JX4wWg9br?= =?utf-8?q?Knm9GogHii8LpK0Ah0W2Lsc2PDMcLNVwNVAbNqk2hK6SNa8mgMh5dCVBw2h0Bsugp?= =?utf-8?q?obfQUJd81I895cBiYPCEhUVHLFAiTK+KeQi4zrZ0RyxyS51UCdAuYd2bAIqLyzJ//?= =?utf-8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?q?CQFqFcYqVoup7YEz8Jo2HN6YUEYQBJZa9g=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: N4/dlk58uWUTLun3qol+uraqJiXyBZ1gTnD4urjB/WJucmYcArlE+NqwhYCzWFXeJcaGUEK6PfO1tug3uuJGx6C9wZIu9Hh7ZOtwiksQFUJfcS7yggnLVxk+d4qL+8M0JEzFraN38DDDSCL1SVARn5pyyJi9hwUlFRoF59x/o52ymJZj1aCeipffllxuM0jP9mA1CqSr/2l/JpYtgoefFo2r16cNZYqPI2XpYMzMdfkJ4AJat0i+/mZYk4vgmSy23JN2e5eEw8mW0fv8hsLM2xXcaEfVo54yqcCo+uaXeErHuGb9XOY4f6ix9sz+ok4JQpgZpNBr5DatcXpLvxWRPpBMTytEgTJ92RAj86JbG+bD0DA44m2mFvCrAxtg923IglqEGn1AIp2Sw0qBrOSeGzWO35jxhReCEebR+MYuUBV31CDC3+IzWUqvAcmXUlv22RnMZY0Hav9Gj9/aAeP9Qc81VgyilgjLbUL0HXik9TVwQUKYNNkN/j5qVJvbRqB4EV/YQVyIGBruQ+sRQr37pZHUQEIMQIeNVCKsTtPJ3xriUPU4f+e8MOCa8/5wS85OtAhSLiJA367z984JAnc2b7pkS0hekps/WwFpx2d74AY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb7cd463-43b8-4908-3c27-08dcceb8836f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:45.6416 (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: M7Cs+xmf+I0pVCiZO0IZsSMHSWSq6IHN8YgPaJ5dA2NoGB/vqY5ZO9MwxQCN0o5jI0V/pPa0FkzJyJwjovwZPpIhiRmsvzBn9wOFDMQMLlE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: jSxmJAqNUExwZJQ6etHtdHEC_K9-e0Y5 X-Proofpoint-GUID: jSxmJAqNUExwZJQ6etHtdHEC_K9-e0Y5 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 --- 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 Fri Sep 6 21: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: 13794743 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 7ADE11B85F7 for ; Fri, 6 Sep 2024 21:11:52 +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=1725657114; cv=fail; b=pUi4nUaMaExxwnp9OadPab02wps0pf55DOh+hIWSjll2e21RzO3H8O/CJiFndx4VKqCxArUFR09DwytNQBKvfRUTvOtxLC86eXEobPYIVImIqS7vMfKKt6MC8REQqGHRLGFZokGESIp9J9OFgqSgcdG8CANHpKlG9I5hrSTl+v0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657114; c=relaxed/simple; bh=i6A5B2q7FDKcCbiivNehhmApsAyNwsMSFC7r9o4sIsc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bznib7bth6cOdnB0qqmdJ10J1Ez+uchE5X/8H/lsWix4Gdv3bg5wqg6zpb0hIOw2gxMOCbBCAl6p4cj7vTVQZZEE2D6ZvIGWTFdKz7FGdPxpfvuRSO5xFWu8TtbuMz0Gl45VWpeVutOF6haj12BJW/Jja0NW+JVDz+eZvqZmMU0= 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=i7EQT2Jj; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=bqrZ02X1; 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="i7EQT2Jj"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="bqrZ02X1" 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 486KXiAA024739 for ; Fri, 6 Sep 2024 21:11:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=igsJLVh+Hinv+NGDOSYNfaKzQNYzdyLwwGAJbHHPu94=; b= i7EQT2JjKMjuMyXikfSBIp0Lo0zwd7sZKajBED7bINAaiv4envJjo2aPSDYvslHf PTXzoO6c2AhcmIAuT4FJEkdovjF36dhx3tsSiHe5vlHU7oITyqErOEOp0kOtxLAo Axpkq1hFtWiLPdPfIDoKxkVfbWLUDdOJHKgSTwwe4uMQu4MtR9LPmZZEj9D6rxyT VwS6jN3g3H3iXhYOW5tWj831FreRksiYqXt4pKjltjfzTewPP3TpJVh7oMdoUUX/ KIdGVkNkVStjtJsHdD/pXNF7w9PyteeX6baS5hfh9tTV6ooLUD/mL5Gi/jXVpyRh smsckklp+Rl+KHEFr7VjpA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:50 +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 486KC9Pp006639 for ; Fri, 6 Sep 2024 21:11:50 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhydehu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=deNYMwlpR4jb+Q51i1F0fleOjsfjOxjmjY7HxpKPvivwpsCc3wYjMx6m12vK9IG7ZMPVEDKtzTXwE8DAjQVtmIPgdqckz54D/o473H0TAAesYVBDn+j2CAeJmQwiH/oHZRFPsgU4D0m35LOSSSgu4ffgqpvh/fVw6IUU+WyUHNEVhbPFKpTjvKlHcV2+eM7NjNy2+RW2mSJAWStC4yweXMU6/vdgbRhcJfmi6IGR/2Bq7l8iPjfvb1RdOZFsC2AnoC5wSQiMEyLcL9LG5B03PNbcsouUJIy1kWHnGmbIK9pcsznypnyHfxUAoFX8yC3pNyPJCte672+fS2lJXqADpQ== 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=igsJLVh+Hinv+NGDOSYNfaKzQNYzdyLwwGAJbHHPu94=; b=uwzlAuj3g1iuXYO0wYJqczCn4GJgDy1ZmM48pphis5yfAqXjAYOKoEnC65Is6qTmSIr9Xg9jK6MZNMJApuvlRu8vBqhL9QZiOM7wryeBG6y1vU7l5wQ3IxLhomjaK+x1Y1ksP9aLLPCMHe/2fGEU/IGSNTFTj3WVY9Irbz9W9XkVMzDqnE0BdX7HoWbVKRNVBxZNbdMH9L0FZAi0SCYoNqtJapkECfJ3Op2TfQUsXvnHds6KGawKiAx1Kwqx+zHskLDeQRwEbD4cThNZtVroHwMiimdMQuQkZoo6sjUW0tOky+WyUK1aMkxCh479z951Y3D3LebFnIGLniJ9e9lkWg== 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=igsJLVh+Hinv+NGDOSYNfaKzQNYzdyLwwGAJbHHPu94=; b=bqrZ02X1Sa9yIgcvtoQ/vVutYSlCtIvpOBc5eBkfGlZO7Hnu29ioRlFP/8ok3GxlO9aIM+Rc5gttd2FTJ52BWX4bC/mxnjzRQLfNI/tg7z720LRxHo7tIBC9ELSntQKrhRAGlbeXEidwVAfYiCg/6wP6DIlerooNkGMDnbhNYrI= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:47 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 02/22] xfs: fix xfs_bmap_add_extent_delay_real for partial conversions Date: Fri, 6 Sep 2024 14:11:16 -0700 Message-Id: <20240906211136.70391-3-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0143.namprd05.prod.outlook.com (2603:10b6:a03:33d::28) 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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: a92107da-5f38-4608-54d9-08dcceb884a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Micro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2uI1z5vE3WC6bw3NXr/N7jmt7rvToW0AQ87VMnDL1oxDnmJVSzvia1HUhoqd/ztFvEfwc5rRsP+MtED1dbPA0MwZQrMJOglE6aj2lNKk7g65QuIs6CM+Q/Dvn0dJ6YkrE23Own+wDCda+i3cM22Of3HiavNR6x45nX2ljjYYnWSZVgM/LUSysEXPahRz/DbhhGYqJNtvjI7W0EynxBgqaIEA9s5S5XbOcJ9KJr5YBsnlrxgTJwu9FmSKi63KewT7HMV/VsleFWqVAZl/1qbVJ/QY+ZoOdrDpbL4xcvp6f7g== 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D0xWYkqtqWElZoGwCjApoVb3qyvGv81m5nd1GcJFHk/VMF7bVN8XjoNPZX1VnFCOiwJjKx7u7MKuLLQVUeVkLnzSymisfn6urfX6nT2QKO1Ttr57FjOKRg71wI7ySoHVGsud1cHFoqfChn/bmjr45dlAJSjGmd20cT7JgreMsMv/jN6xfj18bJg77JgZ1YyRe0x+r6XNhxWjEJifIfKJQrKHi9GQUVenXIlRVK1/JLZGI9OfMeLzQWbgpx9rPfIOsdZqBetS2w/zyxQSiEjsmry7UwojAhr6YXeAQSwu75w2XGeKZjJnZPN0b1toeH4F96qP75ab5QH5Kbi8hAG4SJRrwz4mTAkLs61BJW4oQwcuouY43w5tLV40u7BOI3tE79HwPcSWWvz4Y1pjCQrme2M95+J+CsH6ZHjAHEfqvpkDkYWyY3d2UkDqr0o4nhZVsGmR7u3FYLbg1ygBPNYsXqiosX7TyLu900UvhpWsrJTaRupg1Ods5eUXgi8fEIdA/Rrqg5n3e7xry5f5fcPidCdh/USnEae69zG1KhtqFP09LsXWoreGW83xIBL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-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qu2/kpXelAGlaefLaj9N/lokvSCssb2hifIq5ldCabssDAfATNcCPImDr5P9GEunA8sMFE6eUsTHlruoxs0HErvg1gSaAGbj6pQHVNPJn7Q9Pqd1WqqwwRfqo6gHSyElaJETFHKLnB/zQmRFFBn8UtlHIE25jejcu3SCZxHiTQQX+uSiFVdGv0ybxJc1tZVGBONH26VZdZLRobR1EbTPIT2jikccBf70N6fe/45wh+2WaxwYNWzMlK0768U/jrbYM3B3VyzWYGrZgF2zzDkcRVxrJhxUG9/reMS+M0yrWstwj8iptDgJlzrCgaStIhGWuc9JHM5FMOUhzUfslS/Bqw85nTLoutE63KnetxKylAvH3uFHbeR1JFQ92t7JEqLb76j15whjeMHwr+RVO142pNFJik1iqJxjDsjpyrIjZneIfpwo/LuKpiOjfQA1U2CThshyGMdDye0phkYjvel5xCHlfy7mXkwAzJXCpTjdnvRwiqiXxnPx1P+YdNMSjC5dxGO9+31oufL5d2ZkCwjW6CB8QvdFvsm2gq+aZK/e4xTOL5ek7AH5g8kUToN4rqkT7NMLlRi6fffxiAqNOjBrw04J6heqLjBIVIJ2/nc0ots= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a92107da-5f38-4608-54d9-08dcceb884a0 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:47.5604 (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: Q+33uW/sRaMI048voUH/ZgNxtL6x7Hxo7HAXQQUkwG8SHd5f/OP0eM9kSq6ccY6MbgOicNViV/dM3t+Tp1f5a1vGrP+b456R9/RLwiaN23k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: USZSOy-HQ9l1g97vchfPxN5sHyTry4Iv X-Proofpoint-ORIG-GUID: USZSOy-HQ9l1g97vchfPxN5sHyTry4Iv 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 --- fs/xfs/libxfs/xfs_bmap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 97f575e21f86..0ac533a18065 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); - } xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); done: From patchwork Fri Sep 6 21: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: 13794744 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 5D35A158D7B for ; Fri, 6 Sep 2024 21: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=1725657114; cv=fail; b=TZXHFZIN6iG6LdSAf6XHtE3UMFdpNiggih6tGDneERcXoL0wSnvpfWIMXZcHBwLST3cpP12Hqe8oNH3Tc5EWDfECFsuoKvBPNVawJWyU2DZct0CYDEjWu5+aDNCqTAyd32wiBhZAF4nTsvsjRZVsSiltj5S6dHMY9e2DwJJ6WZQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657114; c=relaxed/simple; bh=txLAS/N9lLdbjqXdES6+b0GzWGRw9hrIiRePUb2ahN0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=U8HJFQFjhxZNWtlRRKi3or8yIQfww2dOSMgCGfJoxK+p+HaN+U6V1cZvNrnWkgXQvSE++Ru+sQmS6ygcb+pUSpJdN+skHpwIXP8TztW6vgy7qm5E93ieG/7gwBBBr5lwclwg9/0RpMjc4GbwnObhMyGSfj5PKTrDo8ogYC/NhIo= 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=QRHl4H7x; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DoSuX5Ub; 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="QRHl4H7x"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DoSuX5Ub" 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 486KXUGX015014 for ; Fri, 6 Sep 2024 21:11:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=4Ne7nV7gGlq0QWx2ARdbtveP7rOCPWkZ36WayjiV1Nk=; b= QRHl4H7xSxRx3FfJH1N54xP6lm9mbfVow/h3H13ZqNxOYGevkLxeUUWIaWkfKzJY Pu2xjb1UyuH+TixsnYmIH/Ku0LcN0w0mQ29GBw3X0j6Whfy7wZoP36TJq1h4i8vi u+FRs6/LnoJSj9r5fyzYJCby8mnsFpzmrsBGWiG8chQvEIQQB2iXe3RJq2228faJ wha/hmDUJfJS1a2LeT10GxbAbup9gRkH5qME19ZUJKUjIwP3Hri2sb7GiYojMwKE FNUphMZ+ITapGvDJgy7u75/oBM3ttwqSc6aUur7D2PFKakIms1jLS04RIWM7EFc9 V59p+nVzCsDDtJHGLTczsw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwjjmxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:52 +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 486JO5K7016327 for ; Fri, 6 Sep 2024 21:11:51 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeyt7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RDR2FokH/2nuuNrFuzGV3+UBAVKrNHIav/BVPs+uoUONLD1MrU26jaye9S11rVn5zC3rn/zcKpBvJoRZvCCUqJfDswIS34uZB4CeWR9+hr9YLNbVb4ZGRDUWH9xRmzL3jytSCQTaha7RSNrkuEg5wIIuRuzD3rjDIH/2g1JXnglNBrSHlzWRoVO0++la0hhX+d3JlaNodOfMCLnex+NB2osiBxCIX58YEtFmnDY7fjZC4JTI4Vv14CgEQZeCXIRkbINTMi6+DgEUdPGfqOLIuIPq6q6NjOOA++qOruJc4MCun3GfY3+52FNPRiZqJQ89X9pinMBpvYfEHKh5U73f7Q== 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=4Ne7nV7gGlq0QWx2ARdbtveP7rOCPWkZ36WayjiV1Nk=; b=J4Pc8+i231hgqyGu2y4oc/Vg/Q14DohYUsYFs+C4uWMCgA1s3pYDmdbUcD9Y2ckJZcTkqZHBzJZNPTBkZfv24Ia4HmuJPzJE5rigyUNHRKgKkZca1To1PZuqU+FANDnqF64UNPBB1XduLxQWbxkN28g1V5oBDHt4tGhvupPPxzq3kZLNba4LaTDnO0xCImJiG5Ax4jcBoCDDxZv/J5CMNqNq7Gg5HWjQ1aEYtU72c7VGX3gqf00Jut3TKKTuvrz0pBkXljX/0TB+jrfEyWlCqQ8MLEGKeidUZh72015D2c6g6sYwyV0za8LRFPnr1DOVsS8jJPh/OIkvvnUN2bcnwQ== 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=4Ne7nV7gGlq0QWx2ARdbtveP7rOCPWkZ36WayjiV1Nk=; b=DoSuX5Ubn0Wzly05Gc4ab4pJodZRJSPSwUcBQoTYtSgo9EEnXDPUPAcXV7J9jpdmwLRtnnHJjUeoKresKj2S1D9q50AvXu26VF/z+epjrrvdr9mJSn1FKXyykZ46gWvw3yHGHTJFiqS8Bn3BhnwGemiC1CJpZ5t9MTZqrvFe34E= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:49 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 03/22] xfs: fix log recovery buffer allocation for the legacy h_size fixup Date: Fri, 6 Sep 2024 14:11:17 -0700 Message-Id: <20240906211136.70391-4-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0127.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: 88cdda18-1ccc-4f82-bf02-08dcceb885b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 76gF/sw2aVvzRKNnPx+pHE2HZk4ai9eFrnYnmRcKJPFFDm7ihsV8B4wiLOnN6MiQ1bORdl1ctPHVp6QF/OApfQwnhj7UFEzeENk+338WX5ncHLRpIUzcjoSzgd2IRNPZMM+fRUFlx1NGFATQCVRvl7pvKe11vZ1G3Q44V3SY23ixYkfzHJGbv09PEeVql8L6Z5yTOWaFN4CPIHMMcIUT54Zi10Wz4YvHmtRGFsKSIA5t9NNI09YbtxPAp2Vo2WdRtthbqxHb/xAuCpYMI6KudtqrJ7uqAUpKntA/tkNz1NewWDpznDWq2znuQuOY3AqHVlatc0IzsYizaJ94klbq+f1JhpD7Xn/JjiEfSM2doj08v3pf+wFb4+o9srdkrtaCApURPz931THnHgQyEtEElTXCb2CFsO+N5CM52eFp8p0Dvi2LO904pqHlsZ5m50BtiXrytWiKMjr8w9T5ByV3s/XDANbqYimJ0/hR+qNV6C4ya6da3iqwAzU6zSaJPc2TuQOrF4WuwA4klVtQ8HHJMT5/s6lAZFmeNiQ2244Gk5g6FwhA+PsBtUfRaW4bhIHkK2osdUx749KVp6/HLXRVdabAv/L3AIcfoG8k1GXODCyoSey//XHFIBlGSh0vwxupHscjE/W5X84J7oSmQuq5nTtnKHHE10sqAWCc850GL543kj2pcoWZkRFOvpXPhZlgP3vTkT/4MGdwNzZnPhsuXBPfDeqG4T4nQvYhUV2ik648cb+QuwJ0j2qy7aLW++mbxWVwBLPVnbeMLHrqflKOLrkRchg75vXvPbmT2/hFI7KmvUX0iT34V6EIKKy7nctpmC4ZTuMrZ6vObsuyZSHatI32GV5JYVqJG9BI1ShfKFJwS6bzdqmGtRCw9kax5WHqlTGYKOs0BXgc8IJqDKoz55EMLnw0SQ011nlX5/Uet7eAj4XXvVhDMhc9VSZG3tfh1FVFWTBO65hlnZJ4x78RYSZeiRY3XkOTzkrgbhleaMHlHMPAHGE+aLWgl78EA3+jnWM9PW1B40svjZHZHXLYpyj2pTGTu1IdGlZzwjPSp1SgoDzowANMLJFuuBimJkp+INLtbnbIrPm+gwgu1dLiymhNkYYRt22KbZX0EqBAwiLDDosXSC39kw87nVAQsOZXmClXegm6mZ2N80jz4wMyGT59r6D3FfJHBs8oRGOxBO7LFuRvpb0JHxyUhRbuTK7Q4fJIbvbU5eU9a1lfZJwfosUtpbE9swgKr352NorydeDG06P81bCImKvHGE5BqXTWHLA1nZs6s0asxJ0zhacaUmHl04A5nFRHELczYfok6vB65jjPxSBpoQikjOzZK12UfkysJ1lruqXtTdnLU6SJFA== 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)(1800799024)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7DvaLS+Bb67Y7lhOleMmdyy5LPRuE12a1cIyIJL9YUbmSjWfKKKD4MmLZ1q3H+jW1cuIDzoSSWq5jtO8WKpsk1Lhp7wlJjD34jp3IdBii379QlHz0LpcjA/4zX765BVEY+01tI/2pr1I5xsfXcdMZEZnZERpws52rR260O4fZJbubhRSSeZon3IrVK7tbZTWhUuYoL8YJR6/evLFg8nMcY9fy51ncX5JOVQ93q3iS2hQ+pyONu5xoJBTMB0ftMUfjtPvuPxYEpmMpJdwiu32zl7Ot9c8diownYCN1kRysXBPtbZFPqi9sGcqJ31OZ+jZulJG2nGPJnh7WBSr6m21bu+Nv0llMrMtl1AuN8BjMI1UnG/zvBLGfRueg3jghCo8SYQev6ezafZe9jHCLOkUgoJID89NZcqvxdPwFx8ikT3TumfOJ81FblzgUTI6EJjwVZAk5r/PHY5xEOCkYbucCNPLXo9ycd0BXbZLDLsI0mSSo1DQV0BEmTYJrIGHA4864FEWJr6dVpscpqbSEWIlEGTmH/t9L0aaA6IPNC9O8yAYC6wccqP7B1a/1Rec5RfqloFGSS4JEdRX+z1YoIHzQMCBGa2rlqddAdacs2IBTypWGm2UyRBxTBJvmZuedfgaQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VAW3cBKQey03yT0aAE65ZVW1aDh72OrHjzkPOAySc1NHCJfpIipTnByoC9G18ZhdAEef66BvB6/pgk33je/EQ1y9Zwtb8a3e83p5/0fN1e7OsZbgheh0GlwDxSANOUi1wWOWrSar/4QBkDn3/58ZDXjxYUGebttee5Po8KaNAAt/rWnbgPnx/WsuECoF0DUeGyGtfLhYNwWNtdPJBqQ1GFXRrEcP72gxjj3oXw9V6BkkmkaZ/8JrINQglByWQql3sy6ALF+FfYbnq9uVY9owV/p587vAMFWadaPxKS7AWEpwkscFtUg7dtIVf2ZSkrOTY2d1jSp7U+4XTXTlZ/BSa1sOZIMp/du4PyONB9uyDfQnMaywZ/d4bS2oSqZN7FjPLovGdacQRn9bVtYBfSo/LEbbTLwv2Y8CJsuWCBiMW9yicwhrKUrJX4dEIy2A6sod/5jcg0v/LATiYdMeETC0YdpgP3Atlx3dhZWT9jvbp+UoN00AS/T+8ufk2eXKwbFTFkS7KK0gDguNipUMAwIWoCEVd2Sm84bqQAbFdFyBod6YaEUOgWT27NJ+gTBcfwPXVn3X1EmH04y5uohUNL1TMu9SuxG4GJezpv1LGHRmfjo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88cdda18-1ccc-4f82-bf02-08dcceb885b3 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:49.2904 (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: dUR/R7C1VVnWwlyb8uPBHM6N5MHqBINvb7aN6uM0S0OPfkQqq/C/P2LiDDko0T+57lbVNj4yipFkAQPryNjRVCNRvGjNl93LN3ycVFmQR2s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: iwkXGLQztVkhgH2dfb-Ut1cnSPy1nW_e X-Proofpoint-GUID: iwkXGLQztVkhgH2dfb-Ut1cnSPy1nW_e From: Christoph Hellwig commit 45cf976008ddef4a9c9a30310c9b4fb2a9a6602a upstream. [backport: resolve conflict due to kmem_free->kvfree conversion] Commit a70f9fe52daa ("xfs: detect and handle invalid iclog size set by mkfs") added a fixup for incorrect h_size values used for the initial umount record in old xfsprogs versions. Later commit 0c771b99d6c9 ("xfs: clean up calculation of LR header blocks") cleaned up the log reover buffer calculation, but stoped using the fixed up h_size value to size the log recovery buffer, which can lead to an out of bounds access when the incorrect h_size does not come from the old mkfs tool, but a fuzzer. Fix this by open coding xlog_logrec_hblks and taking the fixed h_size into account for this calculation. Fixes: 0c771b99d6c9 ("xfs: clean up calculation of LR header blocks") Reported-by: Sam Sun Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Catherine Hoang --- fs/xfs/xfs_log_recover.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 57f366c3d355..9f9d3abad2cf 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2965,7 +2965,7 @@ xlog_do_recovery_pass( int error = 0, h_size, h_len; int error2 = 0; int bblks, split_bblks; - int hblks, split_hblks, wrapped_hblks; + int hblks = 1, split_hblks, wrapped_hblks; int i; struct hlist_head rhash[XLOG_RHASH_SIZE]; LIST_HEAD (buffer_list); @@ -3021,14 +3021,22 @@ xlog_do_recovery_pass( if (error) goto bread_err1; - hblks = xlog_logrec_hblks(log, rhead); - if (hblks != 1) { - kmem_free(hbp); - hbp = xlog_alloc_buffer(log, hblks); + /* + * This open codes xlog_logrec_hblks so that we can reuse the + * fixed up h_size value calculated above. Without that we'd + * still allocate the buffer based on the incorrect on-disk + * size. + */ + if (h_size > XLOG_HEADER_CYCLE_SIZE && + (rhead->h_version & cpu_to_be32(XLOG_VERSION_2))) { + hblks = DIV_ROUND_UP(h_size, XLOG_HEADER_CYCLE_SIZE); + if (hblks > 1) { + kmem_free(hbp); + hbp = xlog_alloc_buffer(log, hblks); + } } } else { ASSERT(log->l_sectBBsize == 1); - hblks = 1; hbp = xlog_alloc_buffer(log, 1); h_size = XLOG_BIG_RECORD_BSIZE; } From patchwork Fri Sep 6 21: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: 13794745 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 CD9A01B85F7 for ; Fri, 6 Sep 2024 21: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=1725657116; cv=fail; b=gNguUPc4Eidf5UsWHF9mF2Wzm3f0Za/E8NwCOoGROOO9fGS9XA9/OOm4ailiQIkgiaKm/DVQWurIRAvOQPq4D9mFJkkm3EIp5r5QF7eUpB5ByI8pYjl3F2FFxWglH+W7Iyyf6Qp0hM+st4Ceao+r1+1IH9dMcu1jIKt5n0b9Zx0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657116; c=relaxed/simple; bh=KSjrrTGrhQiHnnlmkki1cmNpGsCdMSYJQT7e8zwxjNg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=RNKOOedU79b1RZ3mM4N+sTwwda2XQOm2fbgk5DB9PI8Kg9HJSVVT7sK4aTd7qbZsnRo5IA0XBJ9Fv5EA9GXh3zs5u4h2e+l7ZJWeQFirK6kHDjkzaVEnStiCxY2SDfzcI+9DaoSRiktiZAd/e70S2rvesqfY53Dzkw9uSHHVeG8= 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=HBO4S5lI; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=pJj5Izc8; 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="HBO4S5lI"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="pJj5Izc8" 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 486KXX0A010226 for ; Fri, 6 Sep 2024 21:11:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=hW1UoPWZ8Y1G+XTsn5QdpDYFaW+S8YoUPr86Rd1W7JA=; b= HBO4S5lIFHvZds3qyourLKdQYIz+9Cmb0tyR4GcEj1iMeVb/3Y9wxSMY2NsNyXEF ChyB+7e/CUX/QBdvTNJA206ewPudY0YBPZCPA3B4yDC0Rge+Mj5CiyemhZgwMbDY Xnr+AQFsawTTjyuC0Mt70JWWSG0znYR4gz+AkT+4LPtVr23j2GMTJuxUYVV3NXKu b27uULFS6c+v5aPoXMBWj5CClj7jp1ppHg15xrlz4OXYzHHLJLOqSD/Okhd8qqAp 7g7zW58xmAcpQTpdiHoyGrWC/cHklMSnCZb90rFuhsKMtBWLnB+FybYHDKn2iNyv H1T0GY0KyJS6Y8KSpvlJqA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwjjmsu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:54 +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 486Jk7gB016238 for ; Fri, 6 Sep 2024 21:11:52 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeyu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qDCD4ZkVer2vkUk61n+IIWuEd+e6Cem/wI1BYGHk2TimuBZPo8OHrXRQzesXhtNSCACpCxrAvANG+X2LYUtfXc+iWLuWtCkYy3ZkRyJ/L2vZbOdmidapgqc0z78JPvS60j+LI8u1GXfKH4qJXFddb8GTL4lbB7wO0dd/8XGh6MWWm/YHWuNywU0c6BCdAkMZLv5LLWrZcdK5f6lKfPDq5TPUkT657TaesdA0SLn2nmbT0MZ4cGrSm4ZG4qd19JuEcqP3KmgwIaaaoHIL/vlN7OhbEjvLTl0USZXr7eSdW44wDbT2wvjLUanLrSPH7Yg5Vj2y4U47+5OUU+kjMFlDnw== 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=hW1UoPWZ8Y1G+XTsn5QdpDYFaW+S8YoUPr86Rd1W7JA=; b=n1vtExj5rRqpeOSv2w1GRvm3AAHSn7NeGmeCYJ/Jr6ItyZMb7aDZ2rfGmBHjNu7iGEm5FmNF+LFZt6jEYO4bX5u/VLR/GYOcSNijgmx6gHt0gVIJBqUUsr2QZuNhgkB+FwRpdc2E98KfcdE8OjgGWt6HB7vsZXdtIO1BeIc+5SLaBOL+++gwh+BJC7k0gwlD+rbpxdRZLI56GQZKZABMdQCBIpJhq6WrGCxs0BawdlH4J7Mz+6uPwXjpNAW5fdNYKvauFkjZDpzVObs1R+mQKzQLDqWuwboz6z47+TN/teV0TXJzeUM7bTAuYSELEOkfk+SAQzt4IGyoRfztnYpYjg== 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=hW1UoPWZ8Y1G+XTsn5QdpDYFaW+S8YoUPr86Rd1W7JA=; b=pJj5Izc8LrFXT7ZeIJe9s/Ow3AFxCuPUVfAZdcM+W/9SLHdZlablBfGJJ4Dpc+sFgiJ+cI3cmSlgTgW1cvys072n++YzutdDfCzivRhTOG8/wQkRTB8PDYUjoyskl2bigNLbE10106Sb+CEyTLA+kd/qR64Bs+steqQmUE6t9LY= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:51 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 04/22] xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent Date: Fri, 6 Sep 2024 14:11:18 -0700 Message-Id: <20240906211136.70391-5-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0127.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: d57694f8-1fb8-439b-d62a-08dcceb886b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: BJXBJRvWxd8KBWtVuOiCBnFxvM5jEGpaN1NbGAOVLJqXXA0EFVkIIJBITIlUZ8rlMtW6WDHuE8e/F1wAWePyC3OUEn56E6tR6A87zc5BhXqReS7jikjyE3n19r2F8RgcNK+z9DyYd9YiNEJzT5sX7aPF9h8KxVH5M+XxgOacxPlZ2hq+A/YrqmuApuKiLDXOuaYkplo8hfc2kcyooO5adf/SrgrQkXe2+DqKBtlaXadHAFvezcGIouB65Xa2n7R0e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EtvVNzbE3JLaK3w3Q== 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jZ7oOGpYrQdAyucRq7TEOZkyd2NkD/4yUoSnw2r0cM487P0YC84nGGacJUACvfWJ56lC1URhlHpcl5LlHjjrOh3hJ/ysUalTqgN445R1kJEtCgG66ZvQoadtgJM21i0EF3i+DwVoSfEq1wo/NfbrTMmcP2U0ko68EHZAHwtqDuej3Uixc3qs0dQTeqZk+k2WhWuDhGHsMjxApP9qfCEqK6/Ri6/dH+J8/NWW/VzkQxc78NQI2YMS6/1kSAI6OAFyEU93CpRyhYPI/Zy32cNI9ww09TmmiRxE8gOG37w+MN/1owrIOHwEdST3Z/u3kfSHNjx/iPT6cOs4ULaBgDsvra+eV0PoYbhNmToY53OUuCzRsLoauZGehjWKepgXcBw1vYHDpTjLo/MTVKy6lss9glLlrLLwez27ZEu29RnwYkxNYkkQqfRQ9i+hxecyqBdf72qO+lI03T+LfOObfSzY6X7+i0NjW/9kId+SX+O3CzylHTNNGHwGtEwzLiqXJikYKmrEt4k/LWRxtuy+gZ5hZFjtbGF4wuf4ln+NAlxO8ROyHRWmrAzXNC4EqLU9sdIJotZisE6G7IurvSVTfxtBfOqVp88xAArRA3LueYb3Xqns59+ZNCTTbdn11PmgHde3IWEI3GLktIUQlgWdJ/FanQREwQ89xT+/bTFrfzG5sGQm5xbog1isxyV7eR8z1RWHpSns2iCsSy7zz4OwoUorQ++BMhoh7uGRyhvLUvYyZUZRAiXavtA3LPLq/QRRPYDdsG7w19QDRyeJKT8jSLiEqipTHLdg7uhSwM7OwvGjqdGaxwg+wAjLCIgeYQKqkvVuT3goT+lTbgSdPy44c/NTlsb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7zbYj+w6Kw9HmX1EnFqVj//4ygU97Tr8L+kRFAA3b8A4E5dBgcVv+If2OnHkOha2s05b8noEe490+beSZvslBb9I+kQ6AQqnXrOT9TOO2/Bv3ILl1n5f3A6/dYdZ5LO9zFQkJuSRICDNeR/3P1XHj2XoL6MFdfPyxikO11hXwU3azoAdYE3GIN6FvTFb4dN2rai+roqiNV1EnB7/WWB0UzNJaJ1ZsipBWLZMoq7ZOmggi7QsfZ0nt345QVpV65DO44d+9txe/nMjNXMNeKPNyNJrCLWB6t3KEvftBb5JXq9HtSaSejsHaBOqlTrjs29gBNWEtqZ72rx3FWhcynrcbtaxvgyJNpU4lGd+wSZmmkNT9sUoTlgfBx2/3rM8s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d57694f8-1fb8-439b-d62a-08dcceb886b8 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:51.0284 (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: eYdSwLPTbQhmCvs6slEUNFBygI7Wq6IGVDK2yk9sxgCxL2g6ykHWA4YoD0fDq5c5Wcy1eA6WQMpV6mSb6r/uXPutKhpAkJSi/K2hoW8cF8I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: 431ZKyb6P0rgPPFHGDm-2IV3LiB2uWe5 X-Proofpoint-GUID: 431ZKyb6P0rgPPFHGDm-2IV3LiB2uWe5 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 --- 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 Fri Sep 6 21: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: 13794746 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 53B511B85F7 for ; Fri, 6 Sep 2024 21:11:57 +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=1725657119; cv=fail; b=ApT1X6qt1LyUAEfMUirZvNAa4NwVQlscmRkza0X0t7ArShgpOnPTpkuwbBAtvc7nkjXyxnOCI/sfEU3AbC6QUIcC+kLCI1lFUgZdYthmO7dsoZm1wCJUY0mEIM19Fp7alwj+krfioIASVMtP2LJer5yvXUzcVwWg1p8zkylnOFE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657119; c=relaxed/simple; bh=h+A3XjLW5V2in+XRiAX+Z6/TmV0YYYrjgg6tM43WXRY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Z3wIP0+yd1hLdXlmSVZ+0QGEnEhHxSGvgJB1b4Y7AzZkOaw3p0CsjyYwv2HOhPTofeVE+hIwW4UFiv1wmhcyWeMs2l7BfSnRUN16N8nMwGVdh6Gt6lXyzyiU0TOae34LIH9FeqMWeMWBG4V1me5PhLjRQnMc5bbbPXkDtc0XZHM= 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=lBXA1eIJ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jjOqmkgj; 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="lBXA1eIJ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jjOqmkgj" 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 486KXtQp024757 for ; Fri, 6 Sep 2024 21:11:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ReTU5xy/PZ2n++XKBRUdtbNySBIwD/r8vX1vpCP53uo=; b= lBXA1eIJ3YrMa+2gnZ0pTrsTwatsdlmG06ceIv5bHO8Ur7daTbm/3amS+lBOSQDb UJ3/nj/OOBK0hZNFoUGR8aGV7mRsVoHRmunTPEM5ILN6yVIM/442vqquBkFfKr1b 7LBVW5Ywde6KVWBBT4/xcpBRTTy+nhn3MWgT+ZicWfqoot9Ia6CcwzIGZj49CadB M84faJ8v0ipa6scev9/VXAK/G7EmZmWenB1HwMYvWhLpBoelaJlRIcGlq4EurLZd 8ZNcTFM1a1PZ4XrMkzpV5e4fRgbXPC7Hr43MAvMpsgyohSARbJSJ7Z8HPPseTUtv zU7dYpRKJO0z+/eN5BxBMw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:56 +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 486KQeI7003339 for ; Fri, 6 Sep 2024 21:11:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhybs74k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sx8tftF1M4TudqBZNBdMPgS7qBYbhGjB9j15lVO3ibdGqqCcXzqrQqp9E+PH1CwVwsfj/PCJqQiHIHMnQHKKhhbumptkgJeLULOUe4AFR4dvUYPl44D6qrD/uiYkLjBcDDiUUMF+/PRc5Og5XFLvMLheZkGVNyt14IGQQEiOBVajtsd0/NU3plvyN4FjL7Qz4gWk7Dd1kRfzNqazXgxq2boG+uKz6q68faYhMbtiMVj2JwH9rApmY4oFrPB/OjsboTwLly6Iy/QBd+p7IEqHS3e4u+Rkp7kqtlDxNyKh0X/V6U6umb1V3ceWZ0RXv9ZmKzrri+rxU3hB/oRH2YsnFg== 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=ReTU5xy/PZ2n++XKBRUdtbNySBIwD/r8vX1vpCP53uo=; b=Te34yFQ/7vS9QSpBzRmVuAp5LhAYTrWMdB4iyDJA5daMGojurbuZ5HPJd9BjQysWyKXi4o2SdaTnL5YrBnH0r14uBCYOatSnzaIlChHPm8qcDIoBIusHaHKJEWn4QUpgFwXdmCgKM8fwgIrpOwZT5gKD1agLEAA2luwS1lnJgH6apQ9IhAvufwCBfVAhFbOIF19GTGHaXdNBvHD6dAVyTUtsVpPqvr25fkJxEnFcXXzvZ5TDboQ9uLkgiyPoWCGfZDhIN/rJt7DhM+IuHC+YN0B3aCyTed3LuWI1yAYOXOoMXyne/Rbn96T0Gk4ufIgJZzSeBPGCiIDs2Xd0wA6uvQ== 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=ReTU5xy/PZ2n++XKBRUdtbNySBIwD/r8vX1vpCP53uo=; b=jjOqmkgje4g3L53fWyFU+PIt2b4+gnMZxxZyMMAw3RKWMTaoAxi8IJWcg9vT+GsArkv8lMdvHK4/+iBdqxQWiAPc/i1XeQchtq/A0EWG79w9Ny5C0PiBJHaTJVvu5ow9FcxdeT1Bo1n8X98ViOGLj4A99y7SXxdUPgw90SwjVG4= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:11:52 +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.7939.010; Fri, 6 Sep 2024 21:11:52 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 05/22] xfs: require XFS_SB_FEAT_INCOMPAT_LOG_XATTRS for attr log intent item recovery Date: Fri, 6 Sep 2024 14:11:19 -0700 Message-Id: <20240906211136.70391-6-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0125.namprd05.prod.outlook.com (2603:10b6:a03:33d::10) 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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: db5ee8bf-5165-40a1-fa15-08dcceb887ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: qC958ltBL9Z3WiFm88mmxN5U7LXEm57M3/cYE4J3pQbH9uadh1FWdxeCWAdPdDWSVQAywjFcAeJHVfMb5Q25wFe3a+bH+MgnX0ZxtF5K/2W6WR0kXsZgiByMbH3iMOR+8n4kcwCQfGaH/nVycO1JHPVxy0Tc38P2G/4ihcFCGxjM5sahsiyfiXdliQlv4CrDbmo1VKzAMJ89PZR2xUxgZ+pAy01i3mZdWRVEq9XmboWi5MawCyqVT+pTKx4/fSjjw8w1H59ndBSlxmYFQZWxDmU9aZw4xlJOVr8lrwPcOJwofcmcOp+2gLY+Y5U9/2dobbvWSimfCDRGAMHOgGPAsqIDP/9IY9UcjGHNWm3OJL/DMLxMkcZh7hzEGd0X6dYqgzbmNm1RmOHDJcQqQ0KMvOjHyy+ircOKvaplO3XZ5Gjf7YgXv9riJClQFG5uLuHWx1cf9G80RkABlvjEFMAsXXapwk+lc2DKMV7sujgBRyWaPxihTjdNKntYx7/d5/8ETDpxSlH9kqX8oDQNov+gPmVtZsZfVdy+k5G6eh7Vo2TMBprx4jOG3jYwbu7jTis7t2egXu6EtFphXt+XoZvJPibX6jyeCjg3vPCxMBmOOYLGDZ+KayumEzQYPvJHKIi8J91SdzUGZLQk+OsReOj0DikG0mkG2sJAP9snoKiuD/+Ea5Fh8HKzDg59AFNJ5tEjSvIOSSug0mLwjCC8Xhsoq9Mpk7wYAwTYICBFGAfpHbXIs/FO1wsFRIHfeujNiJDRvl1uGUiOcBeZna47FE0tQCJiGQsoGsLUZrwzvOl0782ZHx1Ts0HHYs01TSbnvtOQAgTv+T/IU6UJdlDKO3twqCyOkgIBBW5vaGWDtyCr6NHdxegbn1+I74tj/8fo0nBFGBKzs9ShVq0Dwywa5EfWNJO0Whx4p5Rufo0X8NXEwl5IHezTixM5FxeHtJTAutY16S85swLe6CERLZwZkxzKmXRTjbsDTli8PeVWrUXDS1Lhw9ujx/tkAeEiH/+/0L9S2qiFdCN24t2oHD0OxGd+xuFXY/w+WtZ3F5dBVMiPvfZJWZ4BbAo6S07tB1rdjWNtFW/MLy3UgSRVrs3KrU/fQNmPTGysd5UDVOo+YkUUKd+x5NeFnYthmrDWoTsYOcgCe1X+7RZDDTpCcb5iXvBT+xUtDd2uUDgFQbLi83+dJf6XgeZwMP3YHb7+V5J7rpWGrYylHYY4jI1oBY5UkaAUKB5CVOGR4qvdbH+iqIoJbJVQQHpB4MRYR90swUkOyhzmDv1uDd4/P4ZBgAA5CAoaLGmbfCNfM78eQLu55e5iIOgxO1MDRfuqBVaj4a1ChR/rhd0cn6naIhsKBSCuvl9wCA== 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bbnW1nNwJVMXJ9nIAEPTnAutjgrEZvlbTm2BI8u/GW4U58vUHz6VJ8icN8b+15kS8C9klvOok10BshROTG7mMQSFaSKcyXu+lDQHvq6UXmISWf8EyALu9iJNTF/Wl1YFFqdLLDYgMhwHoorBuc80OoFErfFUxfHTjfyArNX3438erlyN+jnVKKY8iu/gs36MNqR1g5TRfhUNjPwbCCye01foTuSdhFRjvdqJM0iexjmj5D82vs+c7GrXGyBwpYIEcPLI53TCzzpVhCM2a8MCr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3192E5aUUC72WyRz3gRttm8Ij+V+ayARaVky5v8fbpplHISeOXKykWoAv4FzL3tpwHW3TLCKEoaBnEKwjLHfbnN8jBP+cRg1UD3kAOlYQqFTW+tnIi0Kcm2oblsmS71S0/EnjCSrkMXrxvMMaIYsVQ0FfBqN0CnEZNuWdp7vs5AyDnbU7BF5Ab+xiUoIih6YEISV7CYpvbTNLFRaWw9TDgIX4A5heFi4Zh4EySY5n4yWOL48T+WriLz5C+GPexn/4eQ5tGw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BD/zVDYTzk0KCNSZ3jzXgiZQYAw3xCqEaCKlkHo+U25yBrrQCkDTtlccNSagDrMl8Wp5+M6i4TTuFnXO4+4SAUaDZCq59Au3aggOXYklBq/OF2QBAQwAClqieR5WLCZW23WZ11HEa9kxPvTc7jUByd1I6ng6hp0EvYh2XZB5n6ehdU4K9gSPA8vdUEbElCbEu5j4lyPHJ3VP3d7HNoAJoxCheDXne/eN1s+IVNAmaVPFGmEGo6scQlL47IlyZUGT8vqV8E/StRaBKHdLJzmCPoTbETrvUk/CvwElqOuopU89Ap/Y7dnzmMaeB1VcV44cBYrl0PRIzLg2GWfnadFKNMaezorFkxgWZop2bgff9b2zojpw0QPTqY7DH1tSVyq+Um4XCT5O6yQp1Jt0Xt0eYYYMTAsCeKTPJKQaED3OnuG8JMxG7eobtx5pQgLGtJzvi+SQMrxrxgc4qyhKw/Lv/GXr0toUTv83OopffRrSiVua4U288ZEkiS14Ke8aopp4vi4OUzZOczp2LBD38Q5Ch3eNDm2XOt0KGZLnbNnn8v6btkkJYR/dnmgYV8mjGCgDbAxkcKl3QnprVmY61hvtFArmXtpEKkhkE7SPOd1r07Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: db5ee8bf-5165-40a1-fa15-08dcceb887ca X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:52.8557 (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: WTjkFTeopzlOkD7DwIuHTbLnKBkxNdEfTu25/GfLaW9tqNLxkJHQkIWizdQLWJuUCvnrcoSSy2k1VaXZQZVtq0vjO/bBSrfxmrs90zY6V9c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: 9hM4qyxsRF_d3XN5L_iOt9Degs6naPtl X-Proofpoint-ORIG-GUID: 9hM4qyxsRF_d3XN5L_iOt9Degs6naPtl 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 --- 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 Fri Sep 6 21: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: 13794747 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 F0C111D6DC5 for ; Fri, 6 Sep 2024 21:11:57 +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=1725657119; cv=fail; b=tAhHMkIz/en8eRTp+sU26pCofwdNDQBzfhA6e6Vdah+qoOQi/HARj53VmcohS5yJD87NRtpSwMlyHE4jYnhpWozhq/5106eeNdHf/rITaVBktN3NovM3z+Fpcj9wWDu5VRfvgTRgOmlLcXJbhuRRrTuNhfaW4yt3YM4RK3LZYz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657119; c=relaxed/simple; bh=/yFhShMsiZQVVKJmf10L3KPPS3o67lLMjGLP603145g=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DzU1ilzI+H9sFt8REqfuvswxZ6jfZKvB5zgaK0kvyk5FyNYp3Ic0DmkwRS31/cgeAxu0kSwCHo8YcvnANA8IVT6AWBHmjbinRcZdApwp4ghrA7O0754dpccBXX40auBO0+Rh1pzMi3vH8AL2ReWyyDnzpRvMU6JZyHgEYDoQUGY= 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=b7CqCm/s; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=eSZgWnAe; 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="b7CqCm/s"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="eSZgWnAe" 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 486KXWIq011342 for ; Fri, 6 Sep 2024 21:11:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=uDBlipRV5kDf3e1tqFszGfF5GDRdZRdYIlu1u2QeQA8=; b= b7CqCm/sncL3LYleTVP2doy5tKdooZcFlv+ywBhPJO0Ly8htQMp2fqEZPq4lJrB4 1LHEuio3nDRkiEaGB/+FD4GxuPulXQA0MSLzuDAJqHS2yi0L22MzaUTM61XBEgG3 81Xsr6IBCspbFHOmTvV6keQVeWHelcQQxbzejduKQkysJK42FLiPa4xT9P1fxskU +2S35YqPeJKsomsf6IgDxHSKR0xQQ2cZYJlXwjDGFOwx9UGGGO+44hyMa7VHTKQR nOyfytOi2FpsYSAMakZSi1ZWMpaqxQPpzHEpcOoxnCb0D6MMOG5pKJxzVuUx34r4 pVjufjNuXEsqkI4xi2QCWw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkajay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:56 +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 486KCuR2016252 for ; Fri, 6 Sep 2024 21:11:56 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeyvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RF4eNK9YnrXY0sJ15c+UOMK1LrMCQ+Csbz54RGkLjrBmtpB2OAb5BnFMMaR2zRydMjn1jx0kKb5nVvnY4Bp4KNMQKW8C2gj1WJyOaDOiCb7U7lPa4b5z5om1dqSQBG+mcKJ0iw0/y89B1peBrBjR/VZAh7kscB6V/+EgPZuXqU6zj485L/Op0fhM/P8xPpMwp11tAzFiUNg4UCsfmo3POZmT/GKSmsKUqPzqGvxgX5gg3tVcsVMRP6HWLX7W+UZcP0LwlF8h0uOPcG+LXFUNdAgOUj3bGqtYJWvPsTqY8ZWGBmToTDCT6VePQgKQxcuQjGCxRY8Ig8MD4iXE1OoTEA== 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=uDBlipRV5kDf3e1tqFszGfF5GDRdZRdYIlu1u2QeQA8=; b=KEaweLfXv+di6sLsUsOHcGrevHQo6UtWceRRyhF3lN7ljChX8fKMamv3ltxd7uaPn/bXdGSzrw5N241PAfJfcXjr7LqglskbA+iez+WB1i9UjTAZDYTSZs8YFV4zg6aCJY0mFv3zYFUNNDOg3iX83Je47MuJaAFZW6e+HSV69sbw3mkBY9+/udCMWsS7QzI8mmyXggl3xZ3jusybhc2GIsM3UbMMU33v7R3KeRDYPil+5nGw5hLEQP3T6Vv2UxcDlJS/LaPCPky5Z14cfEL5cFAPvL0VCVnyD5RMkcKemxzkzFbqKujVr6NKBPR5G3l5z65y4QzO2S11ePESjETydQ== 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=uDBlipRV5kDf3e1tqFszGfF5GDRdZRdYIlu1u2QeQA8=; b=eSZgWnAefi6eE1+xyV48fAl4LX1CHcfqvehVjrXkHYcCpAtAnj+ZTxQcXnQRmfnsWpQH+hgkf/qgI5xMst5IFu5W093rPbzou6/7jL6IHp76TgP2VmnQQTVBXZ6MTwsGwyzO8KNG5OIMNlfb2r2qlsmJxajvDHOslbPseh2ir1E= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:54 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 06/22] xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2 Date: Fri, 6 Sep 2024 14:11:20 -0700 Message-Id: <20240906211136.70391-7-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0132.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: 54939de3-947d-48da-418c-08dcceb888d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: UJWuDyxQnKxItNpxRAaxlNa92KuSr+/cK4IehuSR9bwVIXcwZRwbAbeoUWyg5Ysmtk34uSkE/d/1Jgq83uODGmLLLOuZ/fANrqcmC3cs6OY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hRhI/ATmY3SV1fC1B01xac31cBWY52N5FJfpsCahUtG8atzzn3Agd2B37wQ+rm5MyCexNpbkx9btZ1UkbasTeTTFp6qKdrtSCwoJNl48dD3Vw6p2PYAUwRWzOHZ3NaV2sTEqdrony5G+OVO+aDHqoj/pbF6zudbBX9eAYYzy4JnCl2Uheso+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)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T4ZdEzcVIbOKzTnAimZzHLU7tKBXY8IqBioV05FOGyNGoN0wqHnUpQOgLO75wQknrIKtSjW/9G0p1GMlTGj0MPK4PwD6ikI+vPuurzlJLcjhP8gdsGxRMQ+763Wae0BpFwQWee1CYxFVlWveSV9pZjj0MlWOXkuNLYIdoAumn9QVrYCO8roeZA5SPy+W7LyFb46Q69ibYj9ul1qpJT2kAR2yvsTDLEMD+1uBuJ4WAwQXAKc2q1TXYdNJqI3nbNV2OF0rpUkS87utSCUHfHTZyzpjNaKoRNmMO+gOyybfPShRwi9ltFAyYWxHZVa1/tTTeM8N8L+m0oZsNHqETkg2hrahWReBYppzsFKG5kuzfxAR+JnGERuBhrj2DTIKb5tjs5u/iaGbxto6nZ9KEr+4RRfXgolpqq25MleOvauWLaORwZ/WZM2GrVt53avir9xVzeI4y0mv2RF5NUoLTgJPcZGhl4af3QpOjjUJIFuUwIjBT61bNk8HM1sS3biqUh9tzv6lYNsNzPnSd60WjmRV/ZNoATMxUQtW/GHpBty0sb72Oqb1hzasdJu2a8FIOm1yT7/SM45s5tLYl8IxUduUGPwt1ihl9d5V0x7GLr6TfRGG69vKJhtzMumvJ93VesoBhBRfBy08mGUIe0jj/VDefEHdwADV4eZdA/YPcO5D2k7aKvi234dZfu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9lrQ+QPmETLNuOjlsKrpRhNOnuRulEHXa4w/1LWuwS4nu+qHArplzTkHBtPOaz1qtWbIb6MbtAL6gZEyOTZ6lPSfDH7JY7dRTFYurq7lEgHUj3rPIH6aswjE7/GBcg2QucIWSD8X5+vykkIRClD9LevRW0Tgi5Z5hxS5Y30tCdoAHJKtR41r4ct0qa0EyPGNPh7SImrOPpy7+DyoI+W4QpLoKxAjzC68S1811HgqYSmtTYZK5mhKba8YYXXerZSu1tJpcSUe536laDR5NK8UzMky6kCDZ3Nqr602gVwpXDl6jLGCIEgAwdZXDL8Ie0yYBndgLlffhrms6ad1IIRXzU08mTKkqIlwdBBSaIneULcniq4U6ANEYCqPIpk7fWOV7lD8DgZylC5EjINJy3qglW3UWrjtn1BT3o5uQVgsPiW8RSP0cmchN4vWwcdKjWBl3jNeydClG6zH2boDSK/BKCnmWPFu1VGv0FjSSCL7DEX6WQWSqz6XnlHBVJ5Bj4rx+mu722HfVZrKzc2kShzC1Qtw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54939de3-947d-48da-418c-08dcceb888d9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:54.6361 (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: c4F72VvpteOAiuhpI/7ld8dRUcq7bAtjafe2xSL/eo2ENwEAA6Mvnbqc4lcO9LLJLbMhR3vv04rKFMETzbe0kQ0dZRuo5jchBzzi8fcBERE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: QlmH68SvBIhR59dFHQA_eSJSlyeOaPLZ X-Proofpoint-ORIG-GUID: QlmH68SvBIhR59dFHQA_eSJSlyeOaPLZ 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 --- 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 Fri Sep 6 21: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: 13794748 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 39EEB1D6DC5 for ; Fri, 6 Sep 2024 21: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=1725657121; cv=fail; b=LNIV3g9o0Jl1XBRabDdwsC1GyvyVpN1EFSeWYiYYu9qyWugRDn2LQyyTpzcBkDm9iLjLi0UwpTGM2RbEjrWMtNXGfwOpzT491AzK26YjQd0fI0FXfHQt2I+hiHDXaO8SdVMN8rIZQrZeBORMe4gNVkPu71eJ7faNtVgE6hYvO2Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657121; c=relaxed/simple; bh=q1KYDJ4Qhh0l202v9P1rrQPA/UwJyuvLLDKrkFTvPBA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=s1epQkN83iT/DyU8+IrxDalhQ0zKoMytSmxlG2ulOAwM3/RzIg/OkvvY1ZvCPlDzxXNWyuOXFjWbeONhofBbat0DjfK236PD6uNqkMYF7sfoZpvSeOIvr0ykzqXQYS/2/EH+NtZF+yNBOQzAI1wyJQ7UwznvnImlxTCltIqLhjg= 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=QXaNY5Bw; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=OgBB0Kbu; 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="QXaNY5Bw"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="OgBB0Kbu" 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 486KXWsY015083 for ; Fri, 6 Sep 2024 21:11:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=hiWHMHNsG3ZBNMvlOpBnBgXotx9Rm/EMcIDZTYzuxFU=; b= QXaNY5Bw7y7SOzotwfxANl6UfDC2whubl+k/AqA5wE2bjMgbSHUJM15/A08m738w m62xEa94SxFT4uzOkvccruQVQTz5YdKZnsfoNVU41xhe2VFFLqZLeh6EZZRWmQvS o1jVcwSMILI/AJ6l1diDN5leIQ8O3LhTgU+kmH/jZUPCXcKW0RIvtcqyM7kPRY5M j8vvJ//+ydz25jKitGeH6JVMM68G0ST6ROQ/mwpHKA7swDoUvvDq38WY8QmD/Ok5 3CfbT+EOkmdiC6aJNa83Ckqgl/oikMjv8H1Atx5UcLj/ASc4cb7vKgH7ooPRetqd 63C3jjL2jyNe/rlfeqWU7Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwjjmxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:59 +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 486J6I1t016283 for ; Fri, 6 Sep 2024 21:11:58 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2042.outbound.protection.outlook.com [104.47.70.42]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeywt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fREVuUbWD4upAbJV4cCCdOHyr8MmpCjhLo3IrP+Uag9oF65gi4UEuRKCRfdKjQlAN+9RdU91WMenySOb+LGlAgDGY1sNmFYgzbZvcH4enhMDTIi9Z8OFmH+HuWxKghTFwRSLiQQFcxUx7BmA3v07xz8xoxKLxqEirK9KQyXv1tFAR18r9typoRtRhkaD3P/LVB7+wpNyQFYdBUjE4EJ4EjlAGyseTFoa3cXBi+9W3MK9hEXR4tot2jkQw6oNKFN6gKcsszad/5DVJigSTO5Md0ptnbTcw3Z59BPQLcbbeMt/7rEFyVDfy06LiNtNPwieMur8uLwJGyCzAoxuH/ZBKA== 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=hiWHMHNsG3ZBNMvlOpBnBgXotx9Rm/EMcIDZTYzuxFU=; b=Mu1zn85qymBodzQnBgvU2i7gC80WNhkFnNJkbKn2yxsFqX3ZMBOIjswNVvR+g9mBvTcrr2fZiXo4kyRpqebf2swlnS85MGgZ0vCNfyqlfkecATJdRDPOCpUaZL6ol7rqRLfa2t2wV9rSUP+9y5bIjXFbUqKYEfgiLVdtK2FZWZO0OkOibK72wsPeSOB2wwBlAqdaUH8EVxIuj0iYelNkj/9sVeawzP5pbOB8AUC3YSxeAbA0s9WVvhWQEuT4YTy+H0Wq0SJcSuVOhGnU76hntZJbCJ1exYhQQqrVRZoKnltxZACxPTmgyX81D+xq18sfA5/xg8ejcwbPsm68nqhkGQ== 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=hiWHMHNsG3ZBNMvlOpBnBgXotx9Rm/EMcIDZTYzuxFU=; b=OgBB0Kbur/8wCRUCez8X4IyvG2Xjxxn+YQSAxeIW05gc/G0WYHDGNiiqJb0ljPNSa+Nd6NQByXMQolIy0fR6GLGeWsB+D3zDtMUV1bH10h4Lt15AiSjeSssCBrYm8CbFAy65nwca15nqR8DGYdhf/kacd7Efhg/eki+Qz0JeJJ0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:56 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 07/22] xfs: fix missing check for invalid attr flags Date: Fri, 6 Sep 2024 14:11:21 -0700 Message-Id: <20240906211136.70391-8-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR05CA0141.namprd05.prod.outlook.com (2603:10b6:a03:33d::26) 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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fa0a33d-e465-4ac3-9655-08dcceb889f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 5oEAgHnIpjBH0TPRRiefSwmiG7v52Pg1CBA+sgYrbK5C1bNCKP2wjOG4ngnajTZlcVNqiLNM9C5ZJ7/+wzaFOGUoY9SW4rjMtKa3ioRuCWmNy6kWfmrALwEjluHgIm2KNm74P0Vc7JCbkSaX3oC64LPIGFmXEpu5s0JizXkcgckV5QZuSIKvYL1kQ45JyG3pgZpoos7DuFXklHqEun0uWbUvF14DIEi9rkyq3Z/3kDH2ZRpiZR6N61YUErw08x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prarO8bMpKakcHAQNzFwPJ1TGH3ZA== 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AU+evbFlA+aSTGViSloXo9V30XrL7CeHNTPcfDURhF2FZ2wALfpnUnMxn3RJXgIjlehpTPgyUHkEbEKrGGjg0Jit0QZ4uIzR7L/9+c/lS+BAb5NxElOqvfsiY3nKuP7vQBJ7kY0vmOwspLsLSSd7ezZL3mLcQBEoV71K0Mvf88YYRTEanAd2W1XPDcqonMVuBt8CfgH5yO8BOhd/espSgMMwQw7uMqbAPzQ5BwzwQNA0LIdlax7dPHbme9jVRyWw3u76gnz+ZC4q6N8wzWUV7Tp/ynn2RXiT6NroknBCqe6tCB6s0DTJup6WdFUA0z4rzz+WpgojYAr3lpnfT0x1t2VtA7tyWnW2hm/40aIYwAqmxOsbJX5oQ5SxDNMc4H7Sw5N3cwAioem5/6Nf0rO/FYyCuEEB06KkUzZ7l503Ry6wrZ845nc7IHz2AJjwSoOaqyM5PZmERA9jkBRuH4ejo7DRmn9o88AszcUPuJD99My/hfHffeG1xqm8BSSc2seYGccqzlCt1tQMIMUbQCjb51AANC3q75Bd44eqOpX/mKPor0Jph+7g/fH2JdTBSmTuu1iEQOl0jBwI41Vyt0V+Q8zGcEoTFf8MUkmRjO7s9rOmdfD65hqTGfh51E5TpgpHULQbXtVO/a5CPCVddOteYaIms/RwaomlALIK8yiXB7mGHG6kV+RxXVHUmAwjlOXG760xjspNYIcHiw4hgWfCuARR759gqcYWkOlE9rnynCd95cObXKz8nMTy24aq8+E8tia9OKpXMrAG0FgfuPlb3R86dl9efFkNznc5pgYfqenoetJ7dECkg5tNyMOaSteNOGGVisLUDYOpgZo8sCXk6UiJncooH7NDWbea4M+6stN35NU+2s8JMe/aCf7b20m/uHFFt3xe5bCg4+F36YBcbjsdi7G2NppBNI7p3dCr9NwlZNel+VdtStv5oWG76GHpbMRYErQ1awn01UDozX8aTl7rsySxMgb1VEy9+h/OsuiGidfB3NUmKz2MI2v3vv9qi5ZJ3JmT7QfTP0eTsilWxkFaXCwCZA8H15y/9jh3XthGencZt4l8PCED8nLLNZYCxGVnWO/shj7u/o0HSBxgpaIVr0FWL3mlCQzSKMw2yaThhB7URtauoxRqcOxj9GI7zOc5hO1uJfzwYsGMZBElwE1SW+Fw7OYXk2ojNLBre8lD6KJ0+Pq+tPje7tUlQWcSr+7DAtRR9T1BYMH/Mo656y9aXzUeQ78P03M39lTb19nmw7Hr/F90/XqSZd2ye6Oaod3AVgSYVKciXeMtZDjoFOqm7G/yYlyilCRkxoCoXhGi2fANT5sa/lX50E33kEhdlAk7iMdKoaeyjfQtgQdT4pdAeHVgStSXL+8XJepwJsviHJBVg6mkbIQo05q+RIPcCJLnd+UAhnpy811xXBRsWZdoZWoTyuw6u8iyu6IXc0lYPg+ClUu7B2E4+bI/1PlnERrKQXk0/bX8WhcgQy/Rn52t8Jve3yHi6TkzqSqjjIh/7QQVyiFbJ+EAa/vWm4juEeAPSH5ak0/J7ipyNtvBvkcaiSmR74x+nYV8t6vxrP8Zpj0S+GenMteLJod7FmBiQgYt2y2GQzfxS6fBLuxs2g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YPBSxT8XvFSqrYpVD5EV3EigLadwwN2keiSVo4skK7Hb8p/83HjGOcZ8hCIjeToal/YQLcIwLylckgwU71BumJmWIHsLZJRmCdwhFidmpZoU7pMd7XSB2rujgQO7WBTxIg4ag74NR5MBpc1JRtj9H1H2K64jr+zxsLx/t6QL85PgJw3FIf5dKxeeVGlm3i2t1TKpLvfkoWp7CSyqbGa/T3WLmTSli72nm2A6AYHVMuRpLECNqdO5+laADM6oVt6oU2jiOdOxkHS4QW3IOaqkyT+/FaAWBK/+eEdY1pH6qv2S99ClLJjyKJhlW5jhY3qvyDOH82tWAa8FKKFk9MGST3NQU3DYDB/1jXAbS7M6rbZKvOCAtwoMn/OkE/eEwHNrOn9t2guA7tRZL8sUREuZNIZ+AUkk04tKdhjW/8lk7FxWOSwzEvt8oCltLXpULYm50AXfIzD5n23QKWV6A+KmwGBO29HrtZJUcxZRhqidxmGq2gjYaB9XymU+KIETdNdo+vOREStmXW4RMuYchgBMTDgrA7eq9xhgqsop7LHOgUNjWi71/JqEydIB7R5C57Yu9uiZ2MdyZdd9FT3TSO7BBnJ1p5Mkq6NY4pSeKspaMIs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fa0a33d-e465-4ac3-9655-08dcceb889f9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:56.4546 (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: 7GEMfXc10YemKVNrpUvrfkLS039tpUzosR0QW8pg7+l2TZ4UFfPmN78LgL0UqOdnbvYGBBeAbFQBfQ1V5V9FGg5u/F1YkHevpNm9Hl0HLGM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: lRqHYH8uaLyHAXzHHsld81l0zZoGYtKu X-Proofpoint-GUID: lRqHYH8uaLyHAXzHHsld81l0zZoGYtKu 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 --- 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 Fri Sep 6 21: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: 13794749 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 339DA1D79BB for ; Fri, 6 Sep 2024 21:12:01 +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=1725657122; cv=fail; b=XKF99+ZYN5xUFAFukQmM91NQzTn4sbNBqpHhcbrj4+rGzfRP4sN2v25jVTEoSDHKWOVWVZtHPgypJct6AiGppDDOqSsfp6Fdf9iuBRSJUuBQiclw/ovinZYkur3uu8DMQLDj2+ouwVRv9M5FDrCA2MSyPUvKWBKqvb0lCETGKfQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657122; c=relaxed/simple; bh=jLmafBpi7O5EXAWPspNMqPsJ6hlU6OP+qeezPN0mwPo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=g8xJqMCUUFHBMk27SreQiAnYNEBNR1HwGU+4cp4V8dTfvTCf9pHRTpxdorrbfrlElqzM8ZC7Izn6im23tFPQ3pgV8wxc+pV0M3xYCBJI1AUG73WkuaykkGNSAE46Pe9U8eO70s6rkIJextKZnB5s3Jberwb7N6dMLSDASV5ISwE= 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=dDDJk5I0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=qYUDe3t3; 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="dDDJk5I0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="qYUDe3t3" 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 486KXWIr011342 for ; Fri, 6 Sep 2024 21:12:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=PNkjkwkY6oPvrfr/q5f8WlFIn3CkAlLQ/6Hu83Tf/3o=; b= dDDJk5I0qka3anw+wbzO3Gbz9d++8xD0AZOQp8U4Iq6Dqu93NRDWSi3xj+utiISv 70QiDY3y+FJoVOGOrJqEmEZiENaZnn+IgxCG+MIqfVx2M4DqttwEt6DezC/eMD/N zEfCdWifaCIRvia/3SoRojjLZ0U+8WpwZFSnh6QWsFx0OzU3l6W0J63nbOVw86GH bbYFPl6t68LMsaPEP+Dt50NpHxOqlvBAlKftiXOytrEcCy4/dW6amEHmDbQNxsYC ZFs8jacfuUqiQ3FvaMsYZ/N+4Nxl0BHNTUi5m+m99sOSPUZSKfethZOFOHwtu8ZX hYK31BRcbUl+0hSRIPt2wQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkajb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:00 +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 486K64cZ016219 for ; Fri, 6 Sep 2024 21:11:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjeyxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:11:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o8/EQ3LV2Q4AdUeDd1+NF1vDzGo6A+0BmH7LUro6btpGQcyd8uLjVwe2TvIUBci8hZqcV9FLk43d1FWkErmPMg30cKM0Cfnl9NnQm7Y7zwLExzsVo27Sj9fcvkkdqL7GPGG53VjiiXlqKb+xHPnoV/e+omtkUyNhGzZRgXNsWfbsmeJckBpHgSyFW8hQEnrPUR2eW93+pNjAJ65F6seZLDXQ4ATZZE+T4EcWa2WiKza9tgTZNvbT1s2P3sk2wIJUunNHKDKFFSAp4dI16cotvGYNWNNUjbHNu5d+qG0xgvEAEAkQ4uram/uyX1hrgyOiN0qE9tfK9fJpAT0KqPovjg== 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=PNkjkwkY6oPvrfr/q5f8WlFIn3CkAlLQ/6Hu83Tf/3o=; b=QmvYDog/S9UPJeXHVno6UAlVBmKgZY+VCXrJx7kmCX6sI98R/nuTvBl5v9R0ZZqSATNQ/z4rZA5eCxdNkcUDH/ocoAwqSBIZQBbY1zmPhu0RIrZD8FTVg+xQt9DPQRuN+FaSs40O89LkjEpxNaToNEWfyE1ou9fYMvJYT5JopzT+Ys5SQD/OfS9l6YBW7tyqXq5QmNTE8Q1CsWsj+p12Wk8/MxvVPlDvmO0EAwunu2M3FDZ4gHb5pRW2bdja4dTYsd5FdJenJNjNwN4nfmF30Pu7giuMPW51m5/7Y2hNV0tBt3LvGoId7QMy6+rDLGOmvkIPxp7uJv0OQNGwlfbtYA== 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=PNkjkwkY6oPvrfr/q5f8WlFIn3CkAlLQ/6Hu83Tf/3o=; b=qYUDe3t3alnzQeVcqxMlF6iuQsr523uZApkOlBEJohBBuSzWqrOS3NQMjrtKSkdiXiT1xj89a+jEKhMFIJsovJvMkY3055a0H4QcHZ5rNAILR6EqPuLfduqXyqRgmNJrGv8omNLxqGHfELNBmpIDJkT4z6D2xGaEFdOAPpVGXUQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by DM4PR10MB6765.namprd10.prod.outlook.com (2603:10b6:8:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:11:58 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 08/22] xfs: check shortform attr entry flags specifically Date: Fri, 6 Sep 2024 14:11:22 -0700 Message-Id: <20240906211136.70391-9-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0113.namprd13.prod.outlook.com (2603:10b6:a03:2c5::28) 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_|DM4PR10MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: c9b96877-21a8-4ab7-3754-08dcceb88af9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: LOHRn7gPDrf4JzcQ4rTmC0TI1TFSlcnp3HQCvYQLSwEeQIEvQOxhlkBvBIlXLzPmngyCZqqNNRr6YQWBaDEkEo4g0fbmcxWUzWenf++3N9GDS9T8liwT5FVRVQkEySnJntq4ReUkSEpG3StZuvMlnPl7D6ERpTJ6ZXRqHBIVtILxNQjnisAj/wmcdhwTUWsiEUFk/8yIykSL0OaUxddqYaKw0Bt/uad+i0y3HzJ9ofIMvyU8GVONNWVeTGGusV515OkUSB0JLTbVEw7SdYcWhTPAdefCpy46NerSvTMqasSF9WnlfFjZlJYJuRfjZGa2vhuCRlQ8ERb/n24oi7+9hEJBLAhtTT20tdZowRLyxNlNsJdTswmOgxTATa4Vn6t60vu1586C5YKMMB+u3Gv+hteT2Y+jnOlc/c5sicjzn1UoIPvBKOnhsPEr65T7jJLvc+d/OBe7rEpY+sU7oSd4olP1XgrYziptzXu25f6Qxm8O2a452pciGhU1Uco2IcxKqv43o6eGP4UhDVRsbYAOEMzhhO6nLK1W6XiO8UwUY1cf9SrnUil7a4cpdTv2v3iZXjlaAAj0p31YxFUi7C7ynTWcwbrWT1bQErMQilzEk1gqUITByNmXyKbPWvzDLjf82EzJpuQ2FiIuD3yeXgyyfEJzlZLHW35UDQMoTEY1QsR2iIVCdn03q9a8BH38YZjc+ZTwLrU+XW/LJyZCJBoeT6+YfOr0Oo6A+K4OxYd8OS1HGw02v02Np+Xw4NdRJcZl7OBq9/9VmaAWltXFaw9Cc415s6LhxZNthCq4QkrS4kxJHpxbHC7cjO+QQb1aj/z4MndzUiZUvUM31qHO/GfxVt4ko+CAE0rTwOM3ZFtxDervoefq7YgfWH8h5jwfrUhr8B0cDBUUrWo+xU/ZOz+tstwxXJ4yH525nF3/A718gniehfS8fhDwhMCllawrefk3we2s8Y9SbgUbtk2mAxJGBg0m1RK8PLotE1qTHkVOalUzieSDez9eJiRCWnY75Np15Co99PMsWvyp32hhjocmb52zMwZZlujNz1fC2drA50ITG5JqlQviF7dnZ7FOP/nhK6pP2J9dQ0jJ0owVua1tPVnuKcktIFvaF+orZYAL1Ctf5ROSjCBYO29gwzWNa6ffsKUDEvDNS7wGIQ0FcBq20d0e7XPJV3yryEXKZTcPESiwPFOGyPGpo89PN+CBACmVKKH4w9lX7AePDQO2AEozoF+CBN5Bit1Mt4ZHmcS62A2bb4U3QU9Uj5Nl3ennh2CfHzbot8Um+FMBugZ1FYGDMSfQpYTY3v7U1S8jl7Yh8CYrGGbucntJCIv4bBZA6lFxRewMaWBcIa05t6WBF9nw2A== 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)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C//138tySDaKtNWGtnWHaBFYVLN7MyRyJZs4Lz/yigfbpyhknvT812poZLmwYwAvVudg4pDBAz8HXHfStKQuN+LKE/Gc4kEbb176iM8H3hrL6RF7bAxHcpiaa7Oo14KImx5Vi66XugKgj08ksIODrzAI4nYft5sJ4KYJ4K8QQwOwlf+vuWRr595ipoHBVXB8oKGwQ5IFBlKwK8nHQxTGm8N7+/Bao4vBMSQF95R9nr4QtaTWrFxcPqQzgekGox1u1n2q7VUVmJihfaq/E8P8fhyGaRxpahShZPFYeakvlu3qk6hcDdEZqnQzZG96r5ySJlzcYeTX9BoxK/FRZi9COkf+zHS3m+Cv/IXwlQeuuBrd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+VRxQr3LaJCZCVVoQuqjCOZb+rmUUje89k9YTROZ7vFZX6RDdpDZ+86P/1dJIDMPWtGM8+4IcX8gRaG2uTt1++QFimhiWhaUsjqst0P1PhEOdjuGqMx72s8j/OLOLGZN7FViNYAuPFMs9ngIKZf9WdsU8zSVhLojK+QGg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 784gLYCmlq9xx9eAQSWkFGzuQFSP2Vqj/wYPq2i75Z+5gmQRHW/Qw4lgBPnygR63fAfiojjwaN+Xg9tB9lEpDdEt/h3G80SnjcPSqwq1CR8x8PfsjX88ZzEhqfwanh1tjCDOF8w4Us/LOjEYL4MrdooEfNDH/9emFn7MnVtrYah1hDAVq9G8sSSdycfv3MZ3HO6L9lBEfqXzlFbCZj/PKNgs06k8YvtVqXL+Oe0CsHT908x2rbgZiuPi2sb7yqWJiml0cpgSadUuJWq2c78CwPYpEc3KUI8RJiPRLRu79jySvhtiVrAaH6bEvzIeDGGAYdB8ljFCjnuW4PiwS9kI9PSRr9p8FuqjrZ/YIcAodUOXQVSXhs8vLJ66oxG64WYukzxtq6Ftl21QoDYVfV4Kf6O2C2T49ue99dtZlFFXJ1V2HPkYAQIeJmpyjE+MpiI2b1+5GnK6ZlxqOsSP6dFYzi4u/tKdTh7b6SqESW/JuconYzJe0llIAupPazF+onprklLmWbVwOl8VMyHE4edxeuza3M9gDM3zwZKYWXDviL6A2cTIBIqx85Rr0CL/w6u7aoxqZ+j6W2QBxDPd1YXa1D/jiRmo9VXKP1OcRDdP9V8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9b96877-21a8-4ab7-3754-08dcceb88af9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:58.1698 (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: BItxP7WT1GhNYpmWp8CJ4Zstywc8zHd1nC5wcHudl71zgWVL79IjIDS/aZe6ou9uMGyKt+4HpqNT54aVL8tRzJL2D9ZkhjZ1cYgM82wWpdU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6765 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: nS7YAL46KxmKazJ_Lh7tOpAbE5MiBjOD X-Proofpoint-ORIG-GUID: nS7YAL46KxmKazJ_Lh7tOpAbE5MiBjOD 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 --- 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 Fri Sep 6 21: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: 13794750 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 674FC1D6DA0 for ; Fri, 6 Sep 2024 21:12:04 +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=1725657126; cv=fail; b=ba3frJ0WYzhad6hi7jpVJsVLh5iC//frRxzxnK3IsMdJdMztMk6mtQo0phg/2exseCeITkjtGyuDShQ6+A2HOp5R8Vmb9z1QJ6T64mgo19gwgcaWE0tJQlotLJNU9viylAaMkbi913oI9DBbnVvDT+mu0GXcom/UR3cnOyJP414= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657126; c=relaxed/simple; bh=GO/FDL+UYj3uZlQGMrB/2CKdekfe7KyVHKMCK/eZz5E=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=lh9k49/tDFh0m/Hrgtt7+kLcpDFkmZqHn/lFkGvTUcZRkWpvAt34Ch6Mxk1MyoUnjgZKTpsvd0kbol3Fqfni2YCOKL9izmHQveaG7qKOhToT6D0vociBdBob5B5nYoeXbMNW22C0ul3tMx/OaFv4dAmvwv7aCLqWvRgcGbb0t3A= 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=Y8vhC+C6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=U/orUzpD; 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="Y8vhC+C6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="U/orUzpD" 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 486KXU2d024511 for ; Fri, 6 Sep 2024 21:12:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=JfVAJ1s4jlNXvn5O2XfmUxuls4+9rdmfFiV4N2Pn/fw=; b= Y8vhC+C6xPxZ/68ZxASuADazGvMMVIkr49yW1KPJ3Um5xBltu1hNCfmt3HJuSJl7 YNMmceGGhl+VXJH7MhDp911gHzHeKarjJ38T8SZUPGPYVcWYN2iv8dRgbEZI2O0J y1/8V/lsyJKM9CHjR/6/rF5Sa04mBjfvYmp6YBt94H8savFvvkLN71sn6qBHRi9U r1wE9OX94LcDdTBKZqnN4ox780I5gN63rTliwPt0XQ+KFU3+GvjVeNcAQBwkJU4N 85Ew5wZgT7BN+71fIbm3vU0kKRBygSb2uUPMXFIimlsvA6ivGqhVjZHxL2nXzRid 0AHwDDLNiABPwBbCdfBozg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:03 +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 486JUFKm036958 for ; Fri, 6 Sep 2024 21:12:02 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyge9sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i+Cp1QXrOps24zivk2n8/QuxXMz5Fn/jHXV+7hiUavL5vt+1fdU5CfCdcip+HBLDZFz01Nveka9wUt4ftjc1ulfVMjouEzuKhzOGDeU5hu4GhC713fXdM+nZ/FQiblKkptES5H41e+nFT+8wnWn9lpKKchfeX2u8QkjFRcyavFFtjGPM2LDZdveM3gyzrg2kRQSS12Y+70WS9uwyLyfAeD/92nEwN73O3oHRQ8Kx6JnSjIBdsVWs6sqIw51Exb7yG47FKSkDFRopZRv5DVwVFSfNvzxA5Y3gGc2JJmMEJRFt/bGSLdwE43w04F/YK/ZBglM7R3PXM2AcLrjOHQIQkg== 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=JfVAJ1s4jlNXvn5O2XfmUxuls4+9rdmfFiV4N2Pn/fw=; b=ht4KFYmOpuf00GEJnfTj6vNzGtKlAV85LWAFuZs3MLYiE4hnkNTvjj/gpvVWlkbR5mKF0Om2dUxmvSHZ5lxWfWwqV5juTEjk31GclEI9PJpcq+fVnqUKNxBtgF0usqxDc+i2rl6fgdoTxlVfHsXx9Q++q9tpR8RNh5e5zlNAcitd76aXHZvkDZGy2eQXJNxKiEKJX3/Mhb4ySOf7og7SqJmZNzu8DDOnvR7P+MwD0b0tEZgKxCKlQHVnfc6koWhWn3/mRTM5f4tKuIzMX1OOIRscqkYBf5U3MCd9WJKgqhAdafHhQ9ryItYHKyJP9Vr+nxCnxtHoGdh2B8tDi5FFMw== 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=JfVAJ1s4jlNXvn5O2XfmUxuls4+9rdmfFiV4N2Pn/fw=; b=U/orUzpDckkOJaPBrHg43dqrDdLlnh+tqwv1XKXRi/apVX9g4f3ZUWX2aA0UMLtoexd6kxDy+fwS+fipdXjRzVrErvT5sdZSnPJpj4ikO3ejrYUyqsuCfTBHvHMaJ5YOPaYsRNQ7U1xrlaUqYd+d06c4PI2dC/azZsblyViWTMQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:12:00 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 09/22] xfs: validate recovered name buffers when recovering xattr items Date: Fri, 6 Sep 2024 14:11:23 -0700 Message-Id: <20240906211136.70391-10-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0091.namprd13.prod.outlook.com (2603:10b6:a03:2c5::6) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: f2023ff1-500f-4685-cb57-08dcceb88c0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: iUlWhkOHYGxB11dml7cFlC3ZQkuL8EOX/TDDMqlJk8e9/OxehVp29Vn82XrLfVjeP45tekJ7m8SeLdvKWLRI6inrSLSA+O9skr+skoMkQ0SBlLipjpUqSXSDt8dHpmItkn0hBaHXUV12petjta010SVb3piRA/n18aC+vtgesZI69eWh/PH5PVW2/ScU8UBzD4utjYZk/VGfqP8dPGAC0wS28/5LX1Li2mKbX2BdjzApxziaaqqEIYdbFnM/4mp5N2LHJl3zzGi2zV72wTzMDSm7BC9aDFFGBElMpl5N/uzsEQsURnl58GMmnx3sTgsUhba0nT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:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dUJST9WKByOLoXFSIwajp7ZwDsS1VjxbfVU7KiB7xu3qowa5kIrMGprFpLU/OXtvlu5TojySjh/KdjMBEfyuw+yMgSiwFL35of430+/PLcW3KOTldXSWA5ljwNh3+QlJj9HuIwRkS0xtHdOH8AmHY4cqsKLM/wVIcYpmMKs1+dapxZQpGL+BqimufUWndD92hDUYkfHOmconmyQsWCCQWmdIjaCUwcrunZMna6UE4ZslobwMwva3MhIYs7MFGg2ozYgP+W64nuQ0NJBEzSvyuCP/l5dOOZnoa5l0m0tRGypHmtf22dpEqLmWUP9hMVgQN+r2Qw7Y/hom6Mxcop6qUa1hpsT7BWY59LnBmJ9uAC0KPA3AdcHioYNQxc7QRbIBZcCqe/6lcuF+lY7vfS/+E+O7hUW2iLzOjnkBHCez/Cyy3dl95yDHLFd8n6bMrCia9gIc6j6bc1LZNxCvvZ19aDUjBS3bMvR8kcQTb2+b0i44P4JloEJwLLVwM1d+gHRx1q1LQn3TYABjKQx0O9dq97LHh2bUfv0snFACICNskBjg/80L5vkTR4SQibApK2zTVm2VS02g5dFbvumkdc6xmaOMjSflYBdY6aqCWpqkJvDc6KLDn767Og0FMY2XEDewHungwfNkFyXFpkxuyAcbf5QxuhfdEIkRIuPRGd6Z8ZRMplo2DZE+/IBa+xQhtbvz+eQZktIsPRMZi+fXt7ziDojI7JSIKP5X6hJ9AMOPdwkjUa0imW8oqqZuA0CRgCYwIsxqp2kW/l5xv3+MLmr9VP+Sq8tyBY/y6Rf2l1BBFCMlZj1klokomrDb5MDI062Blyx1iooaH4Z7cR8ItLt7RBeQt5a6p/wtWu6sPyaCPMAJ6txihk+4y3AH3sQKgn/ChbcvgshAn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BOAYLFf39A5PR+5Qt2A10iHoLA5yWp8FO5+uvhamQKQBrSQ3As6GH7d2ZY0RCxxbhYyYopbernUWa1fs/x1D2CRkIwbYnnX+2PjTy+22/EnbqZw3S3wWyTzw764VAEAKgivLLnqqE01P2o8KWS95YmMGiWRjELcoRIaACK6bBaIQ7QJQkB5hI2pYqnpdZ9f7feVd06mSFivuTn/wVC9xn/YNgJyJg4cIsDDIDfs1SKwjyJYCbQ/HXFJ3vVxphGCYMydA45Y1x3cMgjXuemhZBE5v310gtcCtzwm2dt0YURvASG8qQNm/IqBPG6NQq2k7evfEsbDnMDwtTkCETH837E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2023ff1-500f-4685-cb57-08dcceb88c0b X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:11:59.9934 (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: XsONzHPR4uVHW2F9k/k9ThpFgn1WwXIvklVdjTnE1MFpvPW2YCPLUxx6oN6tI/Zs1dcstIeXjtZiJTkVUycRWwTeRT6z+fMQC2y68rNHqbQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: uzao9JgrP-T3Pz6D7lWWBqrX9piN_5_h X-Proofpoint-ORIG-GUID: uzao9JgrP-T3Pz6D7lWWBqrX9piN_5_h 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 --- 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 Fri Sep 6 21: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: 13794751 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 859331D6DA0 for ; Fri, 6 Sep 2024 21:12:06 +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=1725657128; cv=fail; b=VT/itXHd1uneYz/lsABssJhNUI+urbtTZrZDLTMWDjQFVssFyS/jkKXruIoJ0ReXN14CloFmwHfdWbEBgn6egcPM1EWU3Z1V8MpT8HHeVvDTgw4OpfgvFSKGUxHF1c9/lzL6DP0SF/2Fx3tq6YOpAolM5ldj1uW8os1rbp/R6WA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657128; c=relaxed/simple; bh=1OFV9iN5b+0ixNonCj5IHEOvOEoapRpl94u8VsJ4TEs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UVOoaDP8iufVG78B/zsKx3GU5vyFUjTkv6QxObVYF3HKIoiZ3AwmRC5e0GFh3b8uR4SbFGm3uGmCLnAvcAOTWTAWTztc9kUH0d7cxQhDBu9RHhhfUVDjUSHoj1tGw8x/RBhsJaZN30PS20653+rPTpISTdPjQP95dgAMwN3oJX4= 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=WZbfunK2; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Z6CTneAp; 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="WZbfunK2"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Z6CTneAp" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 486KXWhE027369 for ; Fri, 6 Sep 2024 21:12:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=HcPmlUOKVP2YRDMye9Q8kLU7L6SZftb2eFQPkvprW7s=; b= WZbfunK2I4Ma+6Kv+P65Nu6jg8OnCDvUuB5YysXWSxSyc7FQ2OmOWwyjI24Y6J9R hjON7+qtBu+j+xHvsh0ywb3d92FuESnLOLIg0Huxl5GM5oWvK9sP6N47lzk+/qKr nlrcDeNz9Hvg2ThUhDozgTy91OCWWR9iqpGEwCT7/C6qC2Cl06rlapBAnurYlv2w Vtdv80EmL/IGVztx05vlIePN3o/TxAciArtL2t7s1zPbEXKGlnurlhP83zZFKzM1 F9LQSGKYwK9hJEOVE+/Ca5rgzUPXY8GyDm7iEawwYedq/N1/unQ12eS+6bJ2ePht 65Jz9Gbu5ssNUhWMQDCOdw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwqjhc9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:05 +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 486JZTM7006782 for ; Fri, 6 Sep 2024 21:12:04 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhydej34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=upRqmh3M/EM5XZdQ2ivi/5xaohK5NqG+ZT9XFuH+U9r0d82rfjz6F1UjiuHuIq6KibH0gRm6Cr0EyT8oCT6CC2qUb//U20pMHMKQQ6ZXyY8Mj6O03Z67SSoFXP6BeBfcKCqGh5/UjLn1+UY8szjQLaqBJ92v5n9w3O8HKGNYhDe4xQfPvqruUtBE7LQ3ZHuvvEo//CCZn36nQP00WU/F3c2FHIYiOlPwhYJRlq5W6cK7Scuepcg62JFXrcc8jeqZ72bs1GIW9tE3M8RG6l7i7ielBVZHJr/W7nFCQ3vv2xrSlKJPMJC1WBfF8qrinhNi3TbVQtY0Yn3wcd3EHaMYWw== 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=HcPmlUOKVP2YRDMye9Q8kLU7L6SZftb2eFQPkvprW7s=; b=B5lqY8OfPFCpX2kgRMutMbLNIOj4mrXxdYa2j2x6VMZ6az6FYBVA0TgUEu+xB9PywVKkrh6lI2FCeomzA/CEd3qwyyyOLkgrZRKJq5HWwFoVEhIwbAhDfOwO9hqzMeTLlArwcZqaiVGYihcCgk+UdzTHgHBLh3kE4Amdw8PA8QcLWQOTh8qegwqnUcnWO8/KSz6PEUrBgcMeef/T7LaFwrjp5EnyPbzpiM8/RN4ka27j8ZDn/wFNmrtohb30zrLvS9jDj+sOHd5Bh6VrzwXilwaCCEiy6FwDIJvzVHUC0ru4IT1k/OYN/wnZVZAmqtccJSr2XRpjm648z/2ctNGfJQ== 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=HcPmlUOKVP2YRDMye9Q8kLU7L6SZftb2eFQPkvprW7s=; b=Z6CTneApRsoQkUN8UwkPOUe8mdm9yjRFcctgSpfQEDGg0sMUE+mbK+LjLxoGhEeBMzWSuQzzyk4PSHxfRmhUDVJicJ6BH0vCTG8SAlQ8caG+FNRALGiDG9TkR76N6LZt+Iq5ah5zn2Xg+Rn+1fsp+cyZeLCwPCY4x+OTrGZUkaI= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:01 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.7939.010; Fri, 6 Sep 2024 21:12:01 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 10/22] xfs: enforce one namespace per attribute Date: Fri, 6 Sep 2024 14:11:24 -0700 Message-Id: <20240906211136.70391-11-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0119.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: cd23e5ba-e7f0-4487-a87b-08dcceb88d0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: T5+Cn6l9OTsVU1aXQUemap7MwTMDr9G91U6nLH/eFXLypkXF/9RgPc42HoPVBsj5MwAoLfbsFblr3i6qpz7Es64HbxYS7U/zK+m/jvF2y1WozkKpCM0T9JPBZuLRq08sQku7C88CLOldqA5Exj8/KhNAIx+B6Qns2utoBlG1hAsrkHq0YLx/df/zrzT4+lnc5Lk5J3zq2sWmtAajem75gC/IiD7KNqoAR6FAxD6uwdj65VeNo/XkajVaJYF0ylvt09SqmcdLlkv6wK+U54wMCgDtwdI90K7aC61SCQ3mKSH4ZL/k7DMoui2jKfvlDruJqzPZhljWnRFY4XialPv95+a/BWR5WNgLakTQu3zOxVtz/cqO1jrAHpFzIt/qWZAXrILvG+v8EtCnRdeEZLZEY+htCCAooNxbb8U/e5pXaJ1BiBTMWPYnatECSYNzKePFTyZxN8raGY983BVYbZohVkLUN7D6nTiV/SrbaMcOcZRTgdvl6c8bqk1qQ1blybxO2BBJwZo7IbD2djCR3omFzlI9HlNke9ckQKtQkdz4X9R0nHvnDmOb3Td+UQS4wxwm2kodBzwfpXctG+JWkUGRrhpLxEu+VSboApOLBrzfGTJYPwbccalLjh5orGzPorXvKqV3k62ZhiIbxR8yYFipDhevz7DYm/HlCvY6q8bwUnc1tTwpJ9cUUhZDuGBaze9siaGSDhQAxuVHq7lwdRoj1oUBt/TXueEJ/NHb+tDRLkAmEzV2z1e+vyh9/4velN9XAkRDRo/DhPru/iNh9d9oahv2O250yqO+eMKtu0vL0+PwwUPOATIHkXSPJWIWRntARsIUTFBu5woyf1Zq8syHXW5+zSeiOL1Ms0pOnMWRZzZz2B5kkNkUF+t1uBBYcefZCcwN/tsPuQipCrGpwgW73G/e08SdFZTFE/ydPBYhk6KDgznWPC/asM04w0o4MdbJLwhz2ZL0ytzmmljA4tErlzg2F2oQnUsMw1VYAv9U/qZhEqTsJPl1jacNkLf63mrEZ4moYUKHxBpc6mS6MWxbXwCztJteoIEKDFNdzZ53AiVuKIwfsukjfE3oEI/uaCh9VBmn0NoEFbRPR4NRPwFj1I+MN41Uio8LKn2uGUWGq/0Nas0X2clGJYnHV/i0oi6AP6Ei0D8BiA2/7LjAECjQQ1XQPmYKwh29r4awNLOARnnJ6zX+7HimLeFS6CrfBuO9Hv9h5HplsvcuqjpYK5SmoxjvL49Dr6hY98URDG4jERMd4vi1BC2YM5EUa6KEcbOZxdnHY8wYs2h2QzN2F8xuqtEXkq603HXeIbMNazmFHDWDR3RjHn4G6K55QzklSmsyBZ2SYhmki5HUxM75WBnVBg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fuKZCn8R4prxjs4fUgtq8VUt7VzCB0aegyGfbM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Fj6glniALBPc0WSvRYR7PBPXriEfAbhi0rEEat+h1zEr6jQWuxi00N1TNyVNUtySeoCMDvWQyuS6wI5jloUL9r1iviQc4I+yE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd23e5ba-e7f0-4487-a87b-08dcceb88d0e X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:01.6993 (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: +vCGbvepOf3e2XHMxilCvmEAvFNhJlzpephs98pWVq55GEI4gL/GWEMUDXIy+8tvPGkHQMQBaboMYamT6NH/8O3iBzrwxAK3c1kuZWkeM1o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: AnGxYkisi85ly-snAy9l0paJIn4NPIWy X-Proofpoint-GUID: AnGxYkisi85ly-snAy9l0paJIn4NPIWy 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 --- 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 Fri Sep 6 21: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: 13794752 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 628191D79A4 for ; Fri, 6 Sep 2024 21:12:08 +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=1725657129; cv=fail; b=ViAp//aHDLbAoRnolZW7qZkF8f3ORbuZtxzco1tdX+mfBK5tzSIvKOSx0V1G5wTysdVHwhmUBN42aHGbVuL32jijztgSxgFV3Lsycr/4akWeMcYv0oDVAz6+zW0s0xm6SOKIfOBP5o0f4E6MVNzYuHThrtN7SDTAac6vYyY/dIM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657129; c=relaxed/simple; bh=eRXTCtBtXvCBu7/qEje6FZr53o/zmKldRfeSYgKKdXU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=SAw3l663CgKrdHenjVL9LjKru6tn/5sgmjUsSQtdSbGgOaQJYp5sc6dm0/4wocUiSDbGJPnhbGXkKJSUHIV+pHAgL4d4sh2lOMeg/qOwiHsMqzDwzXUgtNH3HidgMmg+OZ478Aar3O/M0EMsllHjGgq95K2LfqbJRcL4AAwFmEI= 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=WVY8KK4D; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=nUGTVh4v; 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="WVY8KK4D"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="nUGTVh4v" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 486KXW3e027379 for ; Fri, 6 Sep 2024 21:12:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=VDjT6l2To5Jm1qeP0e93E9Xc28A8PMY+mIabC0PgSBc=; b= WVY8KK4D7K9ldpW53Q9YgQrc/G29UV0CNLFsKILttV9oXnutzFt9+hSV8xWgTmm0 4T229jhMnEYcBoeQ7zIBzYKlCdzrppXuYxECmecFOYrqTg8Q9u5GLtyXZVJ8J9Le Ou9O/6eb1daOL8UiCY0S6IS8dZAabb4tdvGq4ziicg8R+FxcM6NwrQnqjmkDKyyc mA+QUkKjVTaXJfPXgdnX5tHhi+z7ECZZUPIqZuuSCv3gOXuWN+7r02yWmTvIaZUJ nR5GwNR6eRLXMBT6duaVX0ueNXgKDn59FMTN7Qee4BLyWnvcMnmVwyXfYRzdupQ3 1aFQQF/5vl8a81ZoRBWJNg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwqjhca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:07 +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 486JZTM9006782 for ; Fri, 6 Sep 2024 21:12:06 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2049.outbound.protection.outlook.com [104.47.74.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhydej4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nfdyQ/FuDrT0N7/e3zCDcMBk29P0WI+XRemzIzk2ckZ3JCqcCpyNnz9UBC9cgOZ/t+bCekSO0j/jzZRkEwQEZxqTN8rSAr2wpwsil71tyU42o2VRGyEVvqXBHIuMQNclXM5NALAD/AM9l/V0zwQzXs8paoaUUkr4NNIFgBOoG/Xi4VHeYykyh/MK2UCvTyDRB/TwwuwjEU5G/LEQbEMg46EGKqxXqFvWk7Hemt2tjWKBPMJqMJTPpCm/JOVnH7Z8M7VtlRZAKYkrR7pcLidrEaeHhsIc39/8imLXqcBeZqtm1dnBSqi4ZGp4ZBwcXs/tDAM3sr0qX+pNGxhhkj1cTQ== 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=VDjT6l2To5Jm1qeP0e93E9Xc28A8PMY+mIabC0PgSBc=; b=dvV3ls7VDJ6ssxbD1CLgxAi7tKiMHQEbkwekUFWqi87h8cPlPDPvUXNBDhrta7Ihc7oZdg40lJM+3hkklKYL5Xs7txwZvpE4lhId48ag0uFGKeQSnUzJ6Ja/2PlVc9ne49aS5Yh+KkYay2E01WlF7UqZrxe4czZIdNXyeHUlr6Cfsm7/KpUu/elWQThP+zCWrv+jsUr8EzGIl2bLFT6rQUbUNkpjMKRXurEPHNSY4OXOS6qqyu4GVFElfOjNxw58ykDioKujqsqAuIKhLzoKy4qPGSYxjp5MwL/oUcBpY+kpF5h9y6d1IBu0zA5tPVaaX2ySMaSV7KWGkwFWx6UYNQ== 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=VDjT6l2To5Jm1qeP0e93E9Xc28A8PMY+mIabC0PgSBc=; b=nUGTVh4vDV2INMq8qVDEYth0+AjlqIjia9AZo71I4EbYQsGJkZOuSEc5qfU2ObsZssiuKhru3yB0u9XvRNnHi+0Lc7JM9uDZCF63uFhAx7f1iOt8cf1pzjFn1xaG09BFpWa1G418pV1E/+hsp5A5OSmuWmJuwRQwgXOxzDNA2mU= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:03 +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.7939.010; Fri, 6 Sep 2024 21:12:03 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 11/22] xfs: revert commit 44af6c7e59b12 Date: Fri, 6 Sep 2024 14:11:25 -0700 Message-Id: <20240906211136.70391-12-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0093.namprd13.prod.outlook.com (2603:10b6:a03:2c5::8) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 64fc27d4-2413-471a-c8b9-08dcceb88e34 X-MS-Exchange-SenderADCheck: 1 X-MS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FCezNBrBAOWXuWoiOJ2yhSPjj8nqKqop3+vjHxYtOwzID3FXzDquCGDCpqeZe92rkG/fbnPJs7w2NrGCzXKmPsiwyZ0fBlJGIngUfGXDB/V5oAkZ7tc3JMo3K/COhllYHkM5T+ZACEPyIn6dj6GtXrqiqvI3yPGoZ/zmwWruBs8cET/ejfXJ0HD6SeRIwNqakL3xhh/uG7p0VfYL8AU+RpU+pGBhfBINIrAdtltEWkH4LsEfxeTZv/yhuuo2RLBY9oMb8PKP/FfAbuA95X+scLlZf+rUgfn22hL3G7SHD+ry0T4Ge5fJykwYs0p6362IRoV5rcYTeyDYzybI0Kr2sBI6c6YtBmGlVAvK9Ys78hL4r2olXrg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ffqXUEnzdWhkeCIXA6j+OV/0yBwChLdw8oQ3Pu8immHaLge5SkIirN+iS71LIZ+KvyPv0AZ9gRIi+Gamjf+UDBWwIIhltbOVy4CzLwZjPhXe/SejXeLIDAxmUpNNqw+ZgfIWG+lRctrkFY7jbqJiwPd9xMprWrojEiMFAh1GLjqnqGy8vnzkdPERUjSVNDdzIlalpLNXcvcbZNP6ow8WKZxA6gFNRyw+auObYFRAu5ZwGbrGj9r8njeoXYSmcmUD96ODBBC+Bjrfo8r3qMtCLj0wJLfZQmWsF5mnG5TsPP0+GG98mBRsi84omMhXJfdlWX4Qs8O3UkfcgCJIpbqKayJQX7FBCkEgke2ERgF1zA3LYLG0bxiOXVvNcfisb3OThc76Rfbq3aT/gOESzJ6PaulKzWL9Nsglw2dfZFiKwd5QBDPWXPW0IG2KZu7+QDtWoEniL+Q76liZOvkl9dkXnZ0K3I0GDalQt/B5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lW1ABEj5ADejCfph/5ed+dFGdMGRM83KQMbdjbGUUb7Itj0qnm+BjQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LPP527OociU8IEFc2tpQA1Ez5V5Gi2z8oYuGHrRSev8ELMGpnw5vFrsyXDm3hVgrOH0jNBSvbGYbeN2vyibud+ng0fMJdXbRZCBYo966Aw7kyK8ZQHsjnJuR3v5GVOIoJdwSW0SexYgprY1QjiG3BHWf2AucjU1gyRa3ipHADCMfskUGI9edVzlMgu8/1+dnOxh35SnzzQpYF3t0ew5tqNTK289iIMZd0zcu2f9V6AfQrvO8UX95vAkZl7HfmZ6p06VTdA5DUFBH0jylQn8YlLk0L1eDLCA4Ya3FSMMzQRnLNL1VNcAT/qTd9N9p6PhWcfVTen5E96TM94n21/bBkF93eGGd2bpnBiyTJblOlauIbpbFYAJ16/vauo2IaEhlAul1OU2D1o2eKlZVriJOOQN6lP6fIME5Q6WliBQ0K2jbcd97ki2Qqw/Pf1lgJdUrlMbNBaqdBlTl7JYut2HqVK7fAaPjX+Qxc9RW7jrYnyx2bnEzr5oCFWCeasED9qow/at14kuJfGbcAh0xV1ztt1SNLnh1hkKLyKhJ/8EXvzHleDA2WZuMaUZiK2E1ZE/vyxVuijwv4h3SDkpolJQNvzIS+6Dnf6UVLvl7S410Plc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64fc27d4-2413-471a-c8b9-08dcceb88e34 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:03.6400 (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: 7w9H/v5Ap3GXDFdgsQPaiANjBk7yAI47xTUQfJQoRh1V5tuOV1pUBjyq60aZavvu8x09DMuob2MeswGRyIB1xFiDC1P5VOqMUY5INfF3TYA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: mGna0PuOkSC4GzFB3Xi_qmvng2mi5Oca X-Proofpoint-GUID: mGna0PuOkSC4GzFB3Xi_qmvng2mi5Oca 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 --- 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 Fri Sep 6 21: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: 13794753 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 71E6E1D79A4 for ; Fri, 6 Sep 2024 21:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657132; cv=fail; b=mjqk/bR9BpPBsUfhev0CDPqdgukyOomL37rCLxB8CAI6eN5BJ6ipjQRuvIs0Y5HJMjIW/xqmq+Uve6sJ/xiRH5vsVVmiJNe/Mj5vp9vfZGGth4mUSCWnECBZUuOYHHn/86WUpTVnZufNgZ/imiGxYvwR1qsuDp9GmLNsQhxF0K0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657132; c=relaxed/simple; bh=/q+tEr9kbY7kGyTmxdqdJ3oV/ODKsw/QKNy0C1nTQS8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EA29bIApZSXPRMD78mwiaDb8ktqCxQ8imhcKA29tkfQoI2n9WfY7oLjMGoO7kkWC2Auovq+qEQeqDJI2USvX8fcj2PikrFNBN2BSyrAtFjwsU5w/sjZ3EHH823Vr+Ht0wcP9HGJKSTNOQmfMsuuGStJ6jaiDIBfQ8x8/H2ySb3Y= 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=Yqw3Gc6b; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DGWl7Hft; 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="Yqw3Gc6b"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DGWl7Hft" 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 486KXUDO024509 for ; Fri, 6 Sep 2024 21:12:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=+y2+BJE6vvwRyd3KeDqYlmchKlFZvyXO7xZqvOG9QdY=; b= Yqw3Gc6blZf8ZIRCPZP3lO4LtD7yceoo3Ef7NfiIjDYN/iV/l29cf595Y6LUwr8c UWSaepwTH9WnKpz/2SDY7RSC3MvAOeOspSR1gYnY/UdUR/nqBTuLJgWlO+IEVF9E hx5Z7kO2CeQoULp0aOlA1iwn1zkOszDLvNw/1IqVoJB20NpjJ82yFomPAuRAsXH6 ZiUWHMKL4tl24FYeDp8+eCIdCPFrSJXmVv/oAmbaoZ4Z08E8rD2uzfwSXxkv8p78 H2ZiRWE41lYigjZKkYfz+c0bREOVgygXd3WM+HOPqjASPkqpFb9ZzTrrTkOCdYqm YnwlHUfZ/Yr4ZT3SekaP2Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:08 +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 486J64Dh040880 for ; Fri, 6 Sep 2024 21:12:07 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2048.outbound.protection.outlook.com [104.47.74.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhycf2d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qyPrvLSPTxj7gG44lSYskhs2ekzaRU9kepWh4qcxhXgZXK8eNhDpYLP0O7mzxTTPp8gpnyULo5ANRPo7kEMBdURolu76mWRt7l6LvE16gDJMUqhBO+u3EKf7mGcbAN5dEf/qMNoRDUeu3YJGf+P+aL1CdnbEBDC6kRrBNPOeeSGOG2T6ur6yTS24lQFpORWo1mjsLwhtb0/SWAljWCV3sUuPA5HFFblvnRY5ruOyy5FkcPj3fDaY0VsST+MU6Ji2MWjvcUbTnHh5PeUUaperXxayW74YGGtoMC2hmfRg6xdVBLlvum1P9KhG5CQnreH+SF511mcdQs1yabkKbCDZCg== 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=+y2+BJE6vvwRyd3KeDqYlmchKlFZvyXO7xZqvOG9QdY=; b=q+X7Hzu8tj/QTy2w4gfWd7iaUmxII7A04EhVTreEKamcOF1Dcfqs20LkDrfs4tUnzy2RmMBbuphi4r53c/O66v17vIg3SskeCjnwf+1lplKCqKFAkzFp7kPY75So8td8o6I++tV4DfOor1FTtMdHIpy1nVjF6qCZaiMjQTJMe+jOJ10MJk+UWLOt1PqfhQfTp+xfoJLPwAtWZVHymIoQ5tbJcecuwYDPMxMGTAMDkvGWZ8vlPbv0OCddIiW0TfyaP24g+K5U6WeRtsuOoUz3oIdVgKcgc55PXJeZd0yWTpR24uPX/a6znbReBlGo6dCZQh2M5VgqLHq1gA6ZbAw60w== 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=+y2+BJE6vvwRyd3KeDqYlmchKlFZvyXO7xZqvOG9QdY=; b=DGWl7HftBecd55gyzwdKa9ckxKsdxNBA6tAzVdeMO2UDV/R7aucRQ1H+2gM3iSgFeGgHLvMe3zCy5IwzLGPVLJ694noIIfKDPMGdecqclvdRMtRaI2qg++bQPssDhoHhlT0llOEdgl+WQvXfDd+yPHgF4lqtiFDEWqaz1LM6ZR4= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:05 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.7939.010; Fri, 6 Sep 2024 21:12:05 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 12/22] xfs: use dontcache for grabbing inodes during scrub Date: Fri, 6 Sep 2024 14:11:26 -0700 Message-Id: <20240906211136.70391-13-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0118.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 562a4b3c-3416-4386-420d-08dcceb88f6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: BCzpmOihgboXzjjQ51JxNJ5Y1lLX0lRLY3i7fXxVVZWMnYHPyjquVICFwGVfG/MbJIKk02oTb3NgUCOAHqiNeKqOk4y0FVmrEv8XD614bjCdoT2/e1xZ4gt8adDMea1sQ7NJnTNGhQFfczd7SEin6GwdEJ3jx89LzlfHmNh1Zx0KJjuFOBsawJe9XXdHC3ORwe2xdiyVXTivsvbEg55OkVSIevRtunNJpoGsx8Mh0coFIAJ1uSHHHAeX4C/NaHGt1H+XcDngmzmd56f5EMk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VasA== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gxeRj0eadmojAR+vcUhfBqRr1oK6yjLO+Zd7mq+TdHjDgmICUjNmPMsF4OlvlZRO3LGlcJ+VOr/hYKPOULj/38A+EstZz3dV8fqHKezt4UCX4wVA2rWoqGvckrCeXyZGB46Y8tnOdsS6xpqBFEVtR55iFBds9fohFWzVY4qttv9OcX3rQBytkDTNuo2i5GF/SWy2R0EjY7JJJl5WveCRMO3Y3GuNq8CaWx17REikLDgcup2pX/OgpaMIoFDagNiyC1IZD36ruBJJtKdVHLG3x85WHBL46ZZK0MQxwqo0/zkGdEzE7wy8BaG/+O9wkzbWZPbpv0DJYVcygKuP+WEaJxoRZRJu381J5eUDk/zfc+B6PVTdUG4ovEkHZ7N6mcC54tABe/kJSAzlmLWqGvW+e5Y0nidi19APYJs2tYNw+eIMAZ9NBqVdM0NWEkmtZ1UOSG0g5B5BLQxcFnmv1AZypcHGmIlpCU2S6lMpC+iivJA7lysblXqQ9tWT5O2tYu9mDjqsJ6j0I/W5yq/qwLakcxOMHTX7F3hVpxOCjwNbamyvFSah/70a1yye0O+gy9834rjKXROVs81Xt2p66ABeklUylZ86mcWCef7jOK85UnLJ0obWmuEgbJLB0PqPkBW/bIi85Ot4tHKo5FrsxZwrR288grzdzsHKjffAO9HLO0XvD2hWDYTfqW+wnT834F7kKceK6BPj85678o7kpxjIE4NDL2VfFhYtu5Coqd7MEF+htwzd9/AIsOzT8JM37/tD0HR4xS3GwciKBiM6zP59u9IOysXkjxOeaLvLN/wFOTjRYMfqXxYWMGGL8Bg1jgrbR76mZ9mP5edw9QQBd5eIwJZT6UJWi/PiQSGSf6G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EJzCQdtDC83sUPyDPOOxi5m0lgaZK6nIZ/x40of+3VhQL/XPpFVuEs/LNzCBmsaJhR0AU23DqStcLksP0Qb3nBy7GVZgd12PLzcNYTMcsuBK6DmBNMipbUF17fWC9g1JS5r8zyFUOeD+mwvsE/gZL5ds8/eJDhBpsXsfGoJbLo0BAWwTN/VBb8nRUOLQvoN5rsv2P7/SVz6++bn9odN4koJbdTWoDumThDRBk7cmnSO6R76KMEmoYzpH7xs5Ggf473LlzXxmQnLb2uyXf1+fwvhLIm7shc4G9wg/j1OjIP7+Rz82Y2aK7vYDQmKlGbiOUd11fBZ4o5X7QFxjQWhexhkN2PfrLARWjSyliK0WLjBYU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 562a4b3c-3416-4386-420d-08dcceb88f6d X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:05.6040 (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: QtnSJun5DFs+uyvLUA04Pn4r6j88Ce+RKOExEEPqGLeYjBs/I9dsQfR1TTf/VSNHsXBAL021TKGg62NqXr0PFdVgG+qw+nG/2mlQAd54DsA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: Q0KBoF8Ds1Q3sfHjlAl5NbTxg3BbNULa X-Proofpoint-ORIG-GUID: Q0KBoF8Ds1Q3sfHjlAl5NbTxg3BbNULa 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 --- 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 Fri Sep 6 21:11:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794754 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 826721B85F7 for ; Fri, 6 Sep 2024 21:12:11 +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=1725657133; cv=fail; b=aQITTyY6P9KLqyUw6e2M9wuMlhU2bNQG2+/qoa1iMsxrbJOt+NoOJ/MGKOJPraLn3OxQBKEoXN66NAokhsb0gHP3mLpJsSDhVlfY3qvYhP+F3aJpRbwpj4ABjwWybE7GzyqQX7ZTgxANe8RSIzX4D7i/lvfmBlLxZoRSHd3Z3nA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657133; c=relaxed/simple; bh=SL6+Msyz+8nviJDDpxeh0RA6u71TsjB5MgQWo2b/poc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ar0T9nUcC5DOVuzixOzihPg7sgsKnbyOkHkS2Z6nEE5LRDSqObgaUEvCXuGyLHAYgPTbY44r08iIuMmsbWliKb6qrV2T3Sk71iTWNI6YBDmmHD9KCTDPxGIgL0fPS2o9utl7RxbU92VVo2s9c0SnWYJYxlwC7VZ839EcMq3tVts= 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=Joq/TL7n; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UKf80qPI; 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="Joq/TL7n"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UKf80qPI" 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 486KXtQt024757 for ; Fri, 6 Sep 2024 21:12:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=YkE3aVU1/jQ33Anan1qMlYt8quah4VIArtEQh2d4/50=; b= Joq/TL7ntH6+3csQFHyttBE1QvWFY/IC+/FPUyweSE7vL0lUcZpl53H8jA9PqEx5 Zuc/twUN/Dm6yoctsb+9kiRFA2fV4UfwgVJ6OZxGw74fHoNf3NX+HPo1uSTx462u P9sx/kP7H/nT7jWYZGtFW1vHEVQu0NLT+RElfsX7sZ69Zq1R53QQ9q+1NtIrSvDq vGmM4u9wCscxo8etIfl0PmM7DuQF5kvnwYxNbLlxkSXldygTI/yI2h3OltHTTzhX XgdVFCzh8p5AsdWCKMciUi5b727E5NPijcnsNmhFBmXQla/2Cd7s+IHuA5cOHGW6 +UlSxn0Hf2XGb/O0VlW/CQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:10 +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 486KxM1C003353 for ; Fri, 6 Sep 2024 21:12:09 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhybs7e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lPL3wFE+czPs0WOhoq7FVft6JIxrtLvLZUZ+ID8+uyMqqVjy+Z2qqcVSQvfctbbPpoh5sFlmP2/wLqDplruRDGjVWruwWtEoMzj7c0/o75CF3+E/6cank6bTxJXQiLTBARYAOsKLaMpUyx+PWC9mBdn0HVPWFFfnqovD2ze7MT9/6ham4y7YlbO1WYb1mWwHFpiUQn49kqyhqwKNDU8HG21FTXqtgFiUyJSK2iA3zINmBcicHI/TS6BSVzJb8Bkb3hUK6hDdhpgqsrGxkRlzkftXGwfbj3J1CndUHUJ4DcB8w4SEFPbaLDiuGUsaTIViFx1RIBweiTuk5CQIvHOh8g== 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=YkE3aVU1/jQ33Anan1qMlYt8quah4VIArtEQh2d4/50=; b=GAtS2MTjBOmZuRi97gEx8Y5TEN2zJrlREQc/HSa0l9YmX6l8Bcvglk+olQvENzpP/G9B/9MHyG0g3z/BGlFTfDFMiNFjZGAOLq7OsEySAXp3iPKay9tV/yk7xm1U98KARHCK9VWr6XA99ZZXuLXPP7n3BsOGi2leI3ZVNU7DIE9dJGCHlQVDDlqhCSY+AxQdWdHBTUKjpMqZht7G4ho+rmU7yavxvo3Pk6TQ7LBVWQl5zaXNbxZ1clIKNvfrDIvdqKGEZ8gJY7AfB+Vfq7R+7nCJatgdpxSz1vRqdKmR4dgWVhsuEYajL1iVgYbBIX5EKWeU81xDu9uw/MCALEXA1Q== 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=YkE3aVU1/jQ33Anan1qMlYt8quah4VIArtEQh2d4/50=; b=UKf80qPIFS6a6Mf0XJqoUEuuh2kPJyElh9gljxftCLVh4LHUByWUMkCXIHKI57HjwKo12qaVjd7OZHn/8eQV3aEXp0MMizy8dXErqFkGqW4qH923kdtZojLUK/NsR7RHryJNS3Tr1HYKFjAgE4vB8JBbOQPABSDi25lUD5APuqM= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:12:07 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 13/22] xfs: match lock mode in xfs_buffered_write_iomap_begin() Date: Fri, 6 Sep 2024 14:11:27 -0700 Message-Id: <20240906211136.70391-14-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0108.namprd13.prod.outlook.com (2603:10b6:a03:2c5::23) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 49aa274b-baaf-476f-405d-08dcceb8906b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: ir25Mqzm3GLCDf09O55mq2MRi1e1AnIh8KvUY+E8p49v0s97ivdQwKd6TbuMaYXqx7D7wbI53GH/AvVG1uge8AwfuY7Nl+yFgkDkjy51u61B2OW2dDdB6fSOFiEENIcqK70pgqANbqgfOpxRl8NyhtBORi1YOBVHaWpMKg3H2kqihvkhGgoR9UzSMtvNmAh/r8F5s/4Y6StI4WjBR/iCJWu+UbDyJVfL+P4KsnrE1p/G9RlgCG4fmfGCFCgWweQWJ5Znr0WC7wtZKtahof/nw5C4WHQsA59tnhMBt/k+VJh04vzcyhjWMUedDoCNsig2EFw9ZDpnTQZSfk2QWholXx+PI0A3QXe4RFtpyzXquiG3k8pjs7eG7wJkHoMP4EaFi7c0g4ekRQeC4njvvtY49SWx+es6F44vZU7zqyquo/UrKszTo2w2EXE7t+VZMMNss7BvbxeHKjH1i1kHFJcJhWzye4YML/U3QFfulQdtPIvUjdMoxQg2LOOMZblDfPHQVRaw/X6ZzrnW0cXO4xAfKCEhflfVSyc8SPSjfdh4qymJ28VI6QBIKCxlgzGQaPFoUaSFeW7aEfiKBcqxY4c6J/uDxljyjF9iuEM7LeguW0XOTqTTKzxLXGuJWDmERp1p1eGjXGEjpEvX+Lnxmd7/ivbwsAVX1QaPSvWCGqMVCQHKDNwjXjZ+cZxEFVL8k6mteJ3/VEAL7hSmjQVpWTaoRkpnrVmHigdGKKM/CKHbOfDYVdk4hjVShusYqM7Qg863T5UXp2Liwvqh+cysW0QmKc5LApDKB8RXVAr3Ma65DMmC8TaTmXfCFqdh+xRFcqZ8usBCvILhaYZ1hTEOKIvBvQpCyG75mwwGAOML4qFZUD1hvvgaCINMHRFfPuywETu3tiyf+6IotwilNTF4ZoLUGMvj9tc6+tVYSIu2qoMAJOhJxUqudvgc6MNb6r+f1/wbq9yaHTGNLY9PRcF2hl17Obr8we1iDiA2HUBaC99JGpwtf6Wbd16P8NegfOQ0JiUZLPhQx0f1DQ/HFLDUxmyblFQCO6RvtQwMyjiqRSc2hjBwMgaJ5mUe+Wt5BT9II7kx5F8ldCO12ihC3oW2thoLQJ/KN4+wfk/NP8T97cJ3lLuXWKQmKrPqau8Dtht/arcZYRSsM4nl4pOWF/Uw5eA63NH+pAOdCtuCeSpCwpr5NF7C+V3GASLRn/8S3Q3vIGDs8fcOTPJEikE5fTG/+NUhivgJ9uOtW6MEqVqa6KYZxMc5bGFw/FnFflU1005zstvH0PcrgV8BBMbjQytUrB+1gj0sDJbJYcR/O1VQ9CpddhYHtg1+exaq7NuOaM+vC9cJn8AmS+TQcL4/QeMoSVGtjw== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WHPfhztfyjv0ugINtaaWsUKs579OBNqzTG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paOtS0VpjMiaDpRlKE3KTryFI2KhGXg842+1nPrVmn5il0420+iaOCg8wwCw7GuXWXk/k73pdJA7JPrm/5Rur39SScbS91EbrKpEHcH9UdLzgdoGFjLiLjfT2Ne36ENng= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49aa274b-baaf-476f-405d-08dcceb8906b X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:07.3366 (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: SSzDjTeBPJVOQ7aCGDuJMiq1eNBGozKUZhs1NNRRxCBqdgz7rBBcGS8X3TmCgSGlBsV+yGg6DSjPejXHZr27S2NofeAJIbbTigDFpliEy8o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: cW5Keq23OCCDzgyeu0UW-d4DnrR6u1xM X-Proofpoint-ORIG-GUID: cW5Keq23OCCDzgyeu0UW-d4DnrR6u1xM 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 --- 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 Fri Sep 6 21:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794755 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 B68671B85F7 for ; Fri, 6 Sep 2024 21:12:14 +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=1725657136; cv=fail; b=GcXqjJr7ioE9efrv0LLNKUzK/TpcasBgqzAxDAoR8+p3cy6BhJElCYDApvnwecWjTAKUC8YZgKk9xpHmecCDdK9nAvjUmydBitwwvuC6OTLy8lkad+vnu9C0acNl5Qwb31G2vf0LaNSMva8bHfu0HOHFrW/avvYUCm55RbJsghw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657136; c=relaxed/simple; bh=KfHg2Eep2tRf6yH+r3TTqOaY6IuLS3vc1tTzNaPqbJI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jt+2DFpnnDkOcNopmjUUZXnSI/i3zUQFEglkpBPDd8mXAqFagzJ98N4YDgwvB3Kb3U1e+4I2cxiBA0KAwLGnMWguqjnWNA+3qrcv4pzMw4TvKL1gKUGeyzgHQW7btfVfyaMXhspIL365Gc5F3h/2nRO6twHX7Wq9B8WhIlfqR9I= 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=Vq0baL9S; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Tw0nBBWl; 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="Vq0baL9S"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Tw0nBBWl" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 486KXW8L027362 for ; Fri, 6 Sep 2024 21:12:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=dWqzcZo+RPBn7UkvV8UiSUVMdHx1G0TBHeopD+Q3nQI=; b= Vq0baL9SRMhnjlScKiVkNxzzzpign8aM1zfAGAMOF+0Pf97Nt8tGQwGwMiK8VeBq r00ANpRyOsFcrPQtwWQGtdA/Nyp6AEJ+sFiIPBYz5DxBR0+f8fHDCJsKyUof15bO WAHsZi3gXEfcpQWiq+BVuhk33iEA/WB3v/FLRPNSkml1wyfCj7gTMVn1peKeJdkJ gSeZP4MRYQ9A1u0ejt5zOL/+012kj60MQSPOod16cLCRp0FYIDLXbeu7vK9Hgu24 mCjr1l8TAmeEguyYs+9IYugXH5d1p6Iw9iMEnNpcpUON/vUbhhiCxxjVU8PQHJda q00uABYDjyYmlnb6CwhWNA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwqjhcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:13 +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 486KVjFg003260 for ; Fri, 6 Sep 2024 21:12:12 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2048.outbound.protection.outlook.com [104.47.74.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhybs7fe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UlKVMH1IP6yarD6E13vs6A06MVEO5VPxlLMTz96cQZF/D0JcrxXwds+XIC8cu2l+ZRPSuToe8oOc+/lJ3T+iJMdi2qp4pvMXgfJ+30Xfec3ku7Wv2Wh2+4Dzkg65jMxPiXNS14yBsuRjUXn2pTp892fm6WZ7oRP53orQtsP4+mUIzNyNK3jL7+ooVgyZrHMZ76Im8h3FQnmQFm8RTEG3rx4O0C2TsajDdOPKiuzvVWIDe2Pt6YrvjCwtJvyrXGLlkb+W13AiGAOhOCRY6WP1gpH0UqqJyryQ0orTDBOJkszO8QLxyhfpFFrqePoACUFwJg1f1ikIQSSc73euaekJIg== 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=dWqzcZo+RPBn7UkvV8UiSUVMdHx1G0TBHeopD+Q3nQI=; b=AXRqPqJZBTq0tGTIoFBiXHhPGOR2jQxaHxU7DHj6PrlXlanTDKS/w6wmA0wI/P3GcigNEyrcCxv/HTA4LTSrr5E19vrgCgWEvGzna5TpXnw5FvE0lXavT2EwYig4qDhPz/KxHp4/PULr+xyw/SoQj9ZNoRqDhbAcqivSSNUXrX2AFrQz6HiDtfHwA4NiEtiwhjUdj5A1563SVzzS0JGbzreH9MskQX+PPScs5s7NskG6dxoAp1yAzjZr4dVyjXhI9aM+yjqJwbtSFdqTVv9fCg2VIqYhuYBrf9zA5OsGru8U9mKybtSYkil27o6JRMcBfYA/nZ1jtV8YoS+d83CtIA== 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=dWqzcZo+RPBn7UkvV8UiSUVMdHx1G0TBHeopD+Q3nQI=; b=Tw0nBBWliTlsq9VT5sfY7OZ+7toH5WUchTcla8DTr07WiXLJuwC+wybFR+sVETeYrnia8bXw43XQMjMJqziwNITVpDV5Ah0j1slVgJHwQ1XT6OHzg/Zk2iLix2chD/0w8+8CJvfQ44va96eICj8gP1Xqr/tl3czEr2h5ddamYEM= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21: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.7939.010; Fri, 6 Sep 2024 21:12:09 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 14/22] xfs: make the seq argument to xfs_bmapi_convert_delalloc() optional Date: Fri, 6 Sep 2024 14:11:28 -0700 Message-Id: <20240906211136.70391-15-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0120.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 07d1e585-f811-429b-d5a6-08dcceb89197 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: Y+meNWvHzeaN8kuP4obLd7VzULbYAtNFM9Okv4tbwqfmmuPZtMID59n73BfePpN+Er0G7QtiShn+jX1yEAeLWdNVgz81sCaJByKM6kAjW8T6ketGjLgnCKPmU0qi4bsr5+GychdbKWoZSM6TjoeBB6xnAyKTd12o4L6pj3PBVYEgIj1+ZllGghRyF3nXVVfl9gy99Hr5uSof/qoGazvIJUPnK25Hvxl1Z6Hf8dUIihGIrceVB6AJnDdizb63E1IXcA0Ve8QP0TF5x9GTXqs4zr1bhRbk003zpEBooWhuBuPqXrWndEO4+ZVAnm8M2OyInCFCGsX72N8yHCv9lYozD0Ao8R+pSNZjN8AofeM+1iJ36uNZlJTzlDkALQ0+JCrFhU+B0iYyOGt2H1WQc7ILQWaHp7ipOxvCs4AhI7wOurdwHs/jJqGgRrvaZaM5CSak4Z2SGskI0IEm1ycvfLqCJNObHZbflmCzfYGhSrIU44zcc1dtXmqARLmKIOpMWNaFIN+SwayyVf3URPSmJlaoKbXbYjQz+QT4vadnxetDAf++agj0qSkMeRcxdX07ORaclJn3IbIkNy2PuJ+G+5/2pd8IcBGr1SMlH9uWRr5iQtJtuDgZzUfDRTMSLWHD5EkZ4r/HXJUl1VR03TToZFYb0hjf34xW0EyIknF9ks+Y/lvnSjrv5bPgELUwCgmEVdP2gwm9FLPCo+JFvBad2L4DLzqn1JbiU2JBefvDvbY385svGULLJHEBM/nIT00qhIIgGqodCQXfwiB6gzpaUZYFXiWJJENhf2sqF3iUA8EbGnThisudp4tfne+3K58E8lMCoYI+Mmzl9tlWUZFWJ47p67xyjsXfXty7K1U8yDPtntVl9rkcbOpLYTewfbGSCYV5J45atIi7eGIfOdE0qmA2TTU+RUgjLd0Xnl4bCYFi7IJdyg2HqwPVyUsSuDodvs64HeUC4TmxPBugt64DV97cszz0H8uEF0zHUzV8LUmCQUfhHcgC99i6Aatvl3pWtqmxFg3g+uayOCAb+MxkbHyj5kFCg1n5ELu8VVzTvw8IgkCyUnvJVQRGxghjq/y6eG+CSMJUaJxwfLHIjk6zO5OMIM2PRcUi4vXPi3sb/qS/u1naaRYtfzsSaxiXLda3hEhzEsHC+c2SUvwKbxkuwFIpI9HLM25wyg1GjXF3WRoQOBQkBgNlph6hMMqkkz4Dl0TFUiwTy10K+Ghjjoon4nZD/HdCQ2+deZy3EtLmoFnGc40urDE7lIsoOvOavpGOAgk0keI3lpP/xiH9Ov5YnQ2tJc85jM4it/6UYktUuVNDiduptqObs2POhklUm8C7Oy5uD7B0M70867tFzWvMm4S+yg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-Ant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Hj8XA64NGOntnBC/6GYbGbE2e2qfqPbfEY1vZTeVDqabRZO1GJM9vzOhCdZrF4SHNeOgCm3ct+TQvyMt7NwCd8GN0TmxEw5u1cxS5767j+iyz4STBswlWm27iu3dI7gIeCgP5BTZArU5GATb82xkjUwngHgiSxFCjxtjWbzehQM9Y86+sHOf5E1VLIyCXe9F7b5pQZdtDRMR4NGJDhDVG4d1gpYbTFHOIPfJNkCpoduAni7NUeX197nQCe415K+J7XmFJvYSpDePw1wxCk909cvklLzAiY3b58AuayabEtqp4kbdGGduOyxHBmsn/53htatXx1vQNfoY6soaiaoUICjZZUxlluGNHKwVia0IMFOFZeI8EhWNei6QnLWW1nZTclb998VZ8qALZQNRo6psvQ9JuVTZRIIzOWqyv9tW4rE2GYJTDSVv3GdX+bq5gAOtmPrFqD75z4Y5nbxJLxmq/zE5LmsfkJuqUMSRa1BUgS2X+EXSSbIJ7jBifRGIAM0LEmghLn9zWAEGF0OmgtVZ+kD2lC1FqFffz7KlcOLoBEnXfcBydbRKMiMjm33liwA4g986QQzsAcEKWVA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7+FNDjPC5265MUVmDtFnXtfqZEag/btq4Nf1oi56op9UiWKVXW/S5czHoQIvJnOBtt3Z7sm4WKQji3oO+v3EE9w7Qh4hvDrGBKS6TX9yab3Vh/dkoGlzihNlbHPvMmt72j4txv3CeTTGkAFM0nPzDWc9KKxDwnpTM5cX98ufZVDSz9gL1KjbAnhfG1jjkFTcll7PjtrU5WUr/VVMpUhM4pSjQSRdb0V/adWRNsOqk0FCx6l1mFULI48FT7MmhJbF2yAd86B3sgaZ2l3jat7UcGPYhhO2KUIlbtITTSJ1PBs14SOLtuwiX9X/n27eiSVYGZEbgqn8i0ulN3CnBk3gbiDZmgpY1UjiLPK5QcT+wJNkftUMDQxHFObp6kq/pfVbebY9xaIX/hXFJ0P2HolZre/b0D3HoxF38PVMOkvTcVCs22mVcSOMQIb9QRsT5kVXcOAZwWijd7CKCY/T6od6u8RVpYe1Hn7YdGoh2dFwK90DZottjz1X9FaPHxP65lDIRumsQ70Mt0F3epRErpo/qUsgJ+LzwnJqS6q9i+IGvOa7eJUhP6vlKj2pS7lJZLjQQQLToQ5OWdR160mVDVtzUyh2K65TzoBJ0QP+cEulAGs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07d1e585-f811-429b-d5a6-08dcceb89197 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:09.2908 (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: f/MdpFBVGAqNk0sdZSQVP6cVY854pYugtwTomB1e8QeWtqJXB61KJB86i5XGqerNefNID8IQnxX7LnZzQTXVJJo2G2Z8jE3baAnyy5th24o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: EDDZfY9UtNBiOWN237-RUfV905wxqbOr X-Proofpoint-GUID: EDDZfY9UtNBiOWN237-RUfV905wxqbOr 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 --- 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 0ac533a18065..eb315c402794 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 Fri Sep 6 21:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794756 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 91EDD1D6DA0 for ; Fri, 6 Sep 2024 21:12:15 +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=1725657137; cv=fail; b=plJGtnnc+3+nGNn/PeGFZTBdkocuAAHKlBChVSeaM2tsI/FbDyEFrXO49aIUnKsfpgSfsMq9fsoth6fkN6P7LbvX6WIO/FYFdwh1eblhyoY9w4oxBUlA8hnmsz5e1GnwNetRvOjKsF6aW7nzWdVWye3/5DTxupfsV/L1XWoEk2E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657137; c=relaxed/simple; bh=nCZ/+Qoq3dPpHMJLAKJhWk49L3MEfAkm+zPG/DFAyhA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iSgJ1uFGmV8KlsETVkP0UltiEHIjkVf3VPAU2TRYtdyXyDiDizbRoqebMDDJtfOXSTAewlMjsTsMQyOMGfXnrykMePDPdElTKfyNwLSBa6kjPef5oUp5ttK6S9DzES80hd8zUmdhWG241nbpUS9BZ2PcFfo8BYao1N6BTs+ZnJM= 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=Wb3XZvzS; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=DX7lxEqG; 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="Wb3XZvzS"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="DX7lxEqG" 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 486KXbnI011424 for ; Fri, 6 Sep 2024 21:12:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=IOTWp1NXFwEiaJ94OYY6c1j6PA419LIhJNDHKccFivs=; b= Wb3XZvzSKAmXhAF7vf3TSFzqFRK870x/dUFq2lMuTVNZ+bYg6FHTM1GbFQrGkPxA c3kSf/JZlprhVNs+m3tGv0MZryAeMp3v5teNJrP2II9taweusptBbnrv/u+ZMaiX oJ2WffsNJlXHbDYtFEuZK5eZfdPtD4R36orknEa5xots68ye0AY/QV4VD0Ortpf3 YRxj+W/7Vg84TTePToapBShcgavQTgoMg62NQXpzknISNDJ7+GsfCK3I9nBmO1rS COjWmKPxjy9qXWHzQF1CGomR0POFs91y6K/j4eE/Z99p+M65Wdg/Wmk5a3/Z707n tpOak7ovf15TlEXT7A3TbQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkajbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:14 +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 486KE4vV036884 for ; Fri, 6 Sep 2024 21:12:13 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhygea0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q14ozpi8cDk9XiBt82zSAqmqr/OOvWhcEkYcOWLjQLJyXnUwYeH/XczFzcpjNBH4oXyXL6c/DTQMfSZLzhan2GbC1+vFsddI3srkCB5oH/J0sCH5gUZYiWPiegKpgekgKBu/7Wjb8pXlTQW6VavgJHvUJFc/L+ZxRjZXAEgn2/2kABOS7nMtG5ivIQWXfrE5B4CZnh11pBpbNgJp7Vkb25DlU1rOxORcWkLm7WUYqRqBfmIxagQxPcG8n/nAT2CxnBuQWTaHgehuTt3xJpxUqusSZC0v6T0dVyqzeIxQh/Z4BR3zFJXt8Ot1k75QhIgXxH1mag3fEdYSXDVHqKL99A== 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=IOTWp1NXFwEiaJ94OYY6c1j6PA419LIhJNDHKccFivs=; b=JSr0jEuF/sUmdf7HFPkPUN7DtY89aOG3xbyu9kRl5y8YkYSs0YarHeOEDyOGz1gJn4AcxxqtR8qN456BmAiD3aPz/MAKWhtpbUzuTW11qtasYl9o9wUgXxQlmyi1zFEkotWAwLaUO1erc5Sg8rS5XEZIWYGPcHi7kPxVVzqkDiWyDxz8V9/fxzaODX/moDo1jk6xNtUxlf3RorWjt1ycNaZE8BBPkEfl2mXIYg+2QmgZs3b/5eBBO2tACGLXy3JvpAq1WnMsqVDiu29zaPeb1ColwOBH0y02Fc+4FD7uR+Y156FJfmDossa7i/jKTxHdno0dr07VCDupsTatf0H/eA== 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=IOTWp1NXFwEiaJ94OYY6c1j6PA419LIhJNDHKccFivs=; b=DX7lxEqGsCgBfN2Duy9bTNbrGjvqde/QS65ZWcz57gnUfykFAN7y4nSZg0NDsUSsHguxTGt5fstQfVwYWPnZe9AevdT5Qytg27K5LAZAcc67oQiPfwnz3RqvBH6aoOao63TsbIw2ZjcqfX9ISbympw1XTyj3LWIGbnYyhc7WPLA= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:11 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.7939.010; Fri, 6 Sep 2024 21:12:11 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 15/22] xfs: make xfs_bmapi_convert_delalloc() to allocate the target offset Date: Fri, 6 Sep 2024 14:11:29 -0700 Message-Id: <20240906211136.70391-16-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0099.namprd13.prod.outlook.com (2603:10b6:a03:2c5::14) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: a33a3df9-467a-408b-ab6f-08dcceb892c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: N/MW38McTXBlPh8udNW5kJFcy+EebZ0e3qd9slmFih9WyAQcfzztPPo4Y8EfBsA9o0peadmyS+mFevYgSWVH5f6NKRK70Ks3N7nuv+UCKQG6aVw1N8uDn0VtTofhAj8RO96ssezivoNAryB9oD5NAgVDchn0/KOWHX4nikuWFnVsrps+XXYROJf7Jcv7Tz/bRn/RppqNB1PIa3m/8PYsKsYSS/awBEgLcUjJHKV1qedkLwHoNQHm/07OYWQsI/U4oqxJq50I39/SPjsqp7kvgT9eeyUlxMxcc52gxLegsLu65lyoci9aOguzDAeC5G9j8D1AdU45I3kK9TX/yWQH6PBlGLpk6x8FQHjJZTJBB0MdlEptNlbXxz8S7OG7g9Lg1cG159ZPV84hX+1ikTHj4G611j5dN3xkCI4JizbP//dBBdpsru5TbescIdFjR5gF/9Tk0QEJIvHfSlFJRCzBuvfDQk89VLqNP3pinklwpCs1cah2tOjyVIxdtB0UATYcN+xFZxfDskGfVCIFogOdqZ6SsTFhYB5yC7g89otnTvszXNDlQcoax6gDi4IkOZ0G4IgoAOF9C5OBWwDk8mt//DhGrQCyXCnBWaXZEGBOiTcx2Tr/djTXnCVcbr5bjJx9O5oq/xEKmqx25yQWMj/rBQvZWMxQjheteiDIUgtp/s8sTLW9HnpD4SmCAo8nAeqNXj/SPSrgkeA5YmgUcPWZkZf3gy6sJvB+fiROC1bj/A7nBBFJQDTek9Oo/JZSAbMRG6X2vHvuuDWT8xWxps6jBUeFp9x0uC4PrOO3v5zlZJbrCCeazJw/ucDttS4a2I+T4PulyvHC7hp5GmSSBl8fPRE2Axjg3AJTcdDC6EUGhCz8aKSKftQPdX8+Hi27MxfWg9dm3GPlTW2RIxpGmCk0uXapD4nE5iNagB/c7ah3d/Df0yRX4+kRwDD6dz1oD8ro8mDUiN+C45KCI8O8JV1yUDSEKaNa8TwXcipcm8tqn4Za1w8e2JfsGV0zFeFcCLwSV+xFbMY4OfNz0Cu9QVHUVD3I2NWjhGIiJnZdZ4YTxLOMGH/jCptmvkuP0qL7mpiJkdmEarcTLIq1Pl8VfDDJMrFZCYlOhAfy9cEODJG8ZzqwhAElKBlZl3ow8ciTo1b1PhrgUAOuEQGTbg63WmQgRrfJBf6WJJw2R35/UMNgo33dHpwDNuM6XkGNQ+vAIywtuTr662AHyEGEcQAVb/VBGmGSBSWyzBUOj6/kY1XzGrhEfugMMNPfAaS5IqoGyPVXLTBdP0H7VYSejwLaPKUmRXQXVa50X4bzYLwhTCbiu7j4FUMLVGfK9t4UIN7x79bfttdqXhL7Rd8+u+tyl/XVbg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7vI+fOwcC0V44CmBvXUeGLS9mSNuaHx6O91e0ul7YKZs1Kx4X8DHujeCir44Pi7wLVhTdqDbI56hVEboxz9fcQPziPwL/YGgSE9adDhSjWtRE/EwvqpoHjrxJnHIKfNQhyCigcKNJL7EBgfBN/Ek74XIZF45UP+7bB1fRlTyLS6ylpmJJV84oXsRFV65ny1aF5yTHPVkbLzb4nLNa3jhr7teSamP9AjsFABWzSHqYq/NhUxTC3Qsl5prHFh3AWJaaTwHxLUqDA26iNv5rE8dlxOILNcgYYzpCpHBuFOXLCYmrwfnFchKNiCA/ZDFQg3lPaM7jtbktECfbO9R90K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UO5uyy2CeCSKeSzMLsD6rBIgxjaymeDH7Aoxg8IQShRaNU34UxHTccx3dRV/yTW6Hk3IFHwewDariBpwukfK+aFAQ1iq/AuhrPwf0/rz7OU9OFv4kMscw4+e5J4EKuTHuB9mPPbbZ1SUC2Ep2TKCOYqg1vCg+Pad54ralozUQlFoYzZgwVr8Ev/zpRRJqEYK5RxpQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ytQpYja+14sWVpTmfpyNrZl/7BqlkF7BhFWNXY65KWOVzR+lqJjG+5gIW5m67UGNn99SBDZL5Qq55vCRmQWuqHOakuJvV7lJDUas5aJWIvhI/yRDxvkzWRziu81p7Rvcn0j55uN0p6D9AUNrACn5aDP2DID8fueB3tHPzQe+bn+oNKK+2VFf+pH+21CcjNQvs/3wNQ9Sfqx/o/OoJSNyGR+WnX0pggFRcbGrphQR3+2jgTGt6UhIIm3c/A3+R88VJRcisOE548NfsJ5c4YI5RYyLBN5Qx7dst7qGfWTCzpFaBPeqMWJ9DeCrZYIzcW/QzQVyMgXZ1NhBqnXyysuWFnyNkAl61wimSFB2JOGPCNtVZIRSAzyVEDTh3gJp8wGWXjyObIyW8CfeeCzSpQt5g5GTuCEpofHaN1GShsktwea7ar+N+vzKprqxsHBUPycZzeDp84lApYOoyqQ1y94fOA/zB+mruzl9eyUeOj2rtArOlEpBYx8+Q92wv24mWRhLe15nDhW2lKrO/XQmTojuyrjtap3SvlrT2PxTpSL5ca1qHyp1yzhh33VyssbusZkJDKVsU47dYG9XwLBIU7MZ30/ONJ8f2IrlfvYAqoDmyhM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a33a3df9-467a-408b-ab6f-08dcceb892c9 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:11.3003 (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: EhF4iVOrTbsawQBcNSvmmSfBQY2GMJF8yZqfGogcCLJnJHtDwmBhH8Zr/udcpTtIudfVTVv4FnnOTL9ICB5H4x8g8E68T77tMmEUYtCkqK8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: vocMCXfQHJGf0MQc0wkCWh_3hZ388LOM X-Proofpoint-ORIG-GUID: vocMCXfQHJGf0MQc0wkCWh_3hZ388LOM 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 --- 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 eb315c402794..f63e7365b320 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 Fri Sep 6 21:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794757 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 A862A1D79A3 for ; Fri, 6 Sep 2024 21:12:16 +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=1725657138; cv=fail; b=QUP+Q8Pd8AOmMqR5BhhpaYvjE//ZoZ5FCkTD1UJucHxgP+C/iW5aZLT/EbDVTwLOZ5NbOVTJ14Kkn3woMN5j1DNpnmpXpMLPNvwTFhiQvYt9cj53V0fBfP3urKj/EJmjiAH1Sm9v+s4QbDF+IXfZb3rzzVpf9GIa4W3hMAZHUaM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657138; c=relaxed/simple; bh=ycqVZMYkC+dfKiRhNiIV+c/Ng+x2368+xfWSdAgBamk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ij+k4V8HLmqa3waHYCbkyVpns0zaeE1DnUhnAe4kx78QJP0L4df8tQN5zkELU3LVTk84XMWvRy7NDAbubSkqFtOB3iJ+TzRTSPPLQ5e4cMiwHfDewqoswcg2L3ouRbYaGKk71OMQ2Z5umZTa/GeoK1AQ15HyDJjVx/RIFVqTx5U= 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=JKd2WnVW; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Xsjye/7D; 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="JKd2WnVW"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Xsjye/7D" 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 486KXiAF024739 for ; Fri, 6 Sep 2024 21:12:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b= JKd2WnVWIO3UM1e2XnNNXERkJTKcVI24gsFD1+lQZOfOpYRqiaYftCYKR+8bEneY n0PmvcCMDsmxkhqUCjtbzComk1rq/qVLAAFb79dGCNl6jw5EemXSJF4us/ZkA33X vzq3tUvpMDTU7D/2DEpXMOJPO0eEiHQsaczCdVYZDBxEm/KmEwYHpfyAoAccRRys WPhdIiM9F7nPjcjFPyy1wZkvceyDGp+W4GC0DrcPjvidSKCbxuXeCMJS8Y5A2p3y jIbmn/1Wp4qC85fEVcLDV7LGbFi/r0h8mZ7208qPM1nGEX4mK+vp4mzQpUDsVyi0 jHUk59E1uRLl5/MxxJOTXg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:15 +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 486Ix2xp017932 for ; Fri, 6 Sep 2024 21:12:15 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyhf3vp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AjeBErN3i8JNBhonLqu5HR8tiM+bGS1yDfJ4Ip3dcqlw7JlDP8kwj6CyFjime9sRcTgoGxQp1cWWkEDVbGik+qwolTiKiGli9nbEU8nXj1RxEuBYoxyLI2mT9SL7tmCgKBIg7YDjfWzPmWOY5XF57938PVwukeoh9PFS62lEb76uFz8chkKW+BEnudOep/dhr3U74ZrX872yeDQ/mS/E3atFhCz9yhsN/G2USxkOR4TLj2q9Y3EwAVVxh5YHCEuG3X8Whsqie5oM1TuWzXGBLHAwcxnPr1AyCDrbtXtKap3fAWQQ/6rVJquFKi23RZVSTOKVLRAZsegPD11uyL/2pQ== 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=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b=BzuNHXetWjHUeGZR6wDlKBeLvYehzddyRpxKFVWsl47sDIBHomqtuWs7+ey+kHh9YgUoQ+BWrbMagwaann19/Xc33xbSsWdPdkFPVqeWXHWhpuRH/AzPfz7PbJW53Co0JFYliMvAaBkdOS+80eLOOi0U4is3cnTR5seqsZs53ovgoM8XZlZIZ0U2+4pfYLdOxkt/ErvPKFSh7K85C8OttFrykmvU4TfsKjs4CpS36vKNtv63gw5tCbBc3Ldfi3YPckBSvEcSA2VQIy/Mn5/Xx43vw2Ri9T2FyG+Uj2yAnSiO/yGWMeK46ENoQMXU1imoThRUdC/Kny1TLPPP3IQWxg== 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=rCA7hU3+yeUZe0sFXXScc90o16jiClySCAuoTOnlkRU=; b=Xsjye/7DpQtjEF4Y7rO06DHnHyyiV/zLwRCdf1rs+7+t5yeimeCLyYv08Lm7zm6WRb/cTNlPOLhgeBz6rBXS88PcM7HrPd8QkC3CvsAYoEgavqnhK/mEw5Vaa+O0GIVSKyYol/+Nkn9yCw+EWm53fz0Snn5/Nfryr8umdiS8JD0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:13 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.7939.010; Fri, 6 Sep 2024 21:12:13 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 16/22] xfs: convert delayed extents to unwritten when zeroing post eof blocks Date: Fri, 6 Sep 2024 14:11:30 -0700 Message-Id: <20240906211136.70391-17-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: SJ0PR13CA0120.namprd13.prod.outlook.com (2603:10b6:a03:2c5::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 77032a19-ab24-4f76-6f29-08dcceb893c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: x2WDbbSxgn/RVAY3MJKOPCZ2lkNngajrzidS2Zp6bIdw646AMtMH/L0XNqAvtsTPen19loc67dWtzGhrnatEmQNNnNSgzwpQhyua5Y+86ew+uvAYd1FbyX69JM7zWDy3ih8rjsw34CoiygM8IzAg5DPyg7raLAIL+wHaUxmJbgAI6qRLpO2zQ01h3zAFDmB9h2TYoAzA5u0FSsGrC4vilb32u0POrnd0ZRzrtyqvG78ilGwhDNQy/Bl3t56qVTEKSH3VT/6FRCSnArSDG41OVVhmCSaw03phKGPO6cRWoeFHq9bi1ji5dlG2xwK7cnyrYQCA9khwy53XG1/BKjf8EbUAvqV9Km8Hj3JGzaZNJYLEpuKY2QnM97x8yVPcz4LTWKxHhTQ39Bcm4A4UAE6ZRSOwlzMK/0DRm8kJK/TYBGEx4bNYZE/TF25pEYiSZYNeEM8XS4YUMekpcz6P1lW9oI+sHHj1Rsk2YTOOJ4sHBq6D55yRTAzegdXw4yWOL5Pcfuts33SxjVFh6XO6XwcGZuWBT7ZzAW0XBWBzV/8x8CLDZ8tbS+aO7gmGRmpYZqxOK7EIL+4N8hGRVCB8URjNEftDlFB2KaeH3SGOHldTBH5HCLPmrlsLGFbUmValCa5BjhPg6zdfgpxhoM1olBPaIpj6K4FnXkDsND/db55+KI8woTfl//1doyk+Q+g4Jw4ENpp4SYeyolXMj/7UAQuRB7uVBK3lgLqByl1GPYwD1fDJyeBNPGWdBXTOD94xNQfVC7z5voRabbs5vmXRHWph8y+KwzMrrRzYgAWbYZ3cMJuWX65HoQwZQf3eyRM015LHgCrgq/Vli7XJW0i5xlNlr8NuXzWLbVwxX8Zl9MSkd7IFPTxP1pRMvTbRKUag6+eXH/XyJO/UUmnOIkUXRU5bBE9uAmm5YM5v+GW0Um2avBgUvAOEQBceuOkpr98JrgCPJdk52HaaGNrZgFHr4O/dDwKH8WHpst+NLqSjtr5PHj7bOzKXylQxN3MwoMVie9ZnUgXLsKgoqxxZW5lkYFXK++pZrJny1wDRxyW1+kCYl8duZDtlIpXKzrgZMjdTssmop5etFNNHJxNjT3XzUGVy57QqzmIKt76mSbQBCYHQnqXr7iBVdgami32GqzqUserdxudH8Nj09+XCiMo0CpqR6W/qK06eml7KJkuWkUzHK8A3XRq4h1G54J3fV6AOkWaR8934Uf0Pv5I9stB6+EVvuO5C79UADpieWhTf2XzibZqtnWdFD0463iYUQwPVHzdFCW8xSapJhPxSgXo9nUdhmRsCKa/UbEhfs53GZFGBcaWUdL0YVuciKoOqWxy613rbdAxGk2lw21MX+aKgT7a+Wg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a+N8ecsVYUV9cJoQPXor5gX2m5uw/AILr23NVmq9KeFyV4LMIX3JS1sKkN60kVz6sdBayTFOAsJgbvUMpdpJgqmdpXB8hlQ2TOCS4k3hXCrcrHvI+SmGyKQJxaN6nDT+cUR305zBlafX3Qmb81ZANNdt8RG5TjydozqiTCOWr/R3Rzy5+MM+MpeI7latmiiIy/rj+7DFfowHFM8/tyI5sCeffA1hKGAphzfj33eAQA1Z959/WDngPet9FU3BaORRaN44TuXbfzrNP3EVOu5XVAWkrjcDG2IUMgq+tos6U6KiSK5XN9B1lA1WdWd2pErVFZCnNQYu0zDYBUnn9Sd2InaPnSWWMwPaZNgXfZ47iEPZj3l/R68z97vTXluewMJre4K4xPfcDEELn8D5UVAdc18K0hvWKgv5l61pb/CDank1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VGP0BakPlqdddiYg0na3bPUQMGPHIU9aRJsgXhResWaOI3P1lPvCK2y+qguZ8up1GpWu4vSEARf3kr1Cth6ty6ZwjHwalhwRM92qOBGxy/w9jHAcu2eOPg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: cFPS9qZNQwIXwOPfaq0PwwcafEuZwmuJiom4Z6QuF4mbwrBr6nfRu1lPWq48+8vYTgoh74tSiyqvJCr9Nii3Uzj12X2YDVuRD4k7n4zhcHjTsEnFpN0gintC1EFyou8UYuSVvbXmfTXlPoHHw07IMIwXLc6H9FdFAz/TgqOLTLG2vnOqrdxJHo3AC0x+y8kmbGmHphtwsuQ0O56VKRmVpMNJCKmaS/ucVnA9QTJnnJSlbQR9UH92NMEYpqKNfKkqeBn2dV1m7Vtj4TyonNtkeXzYtCX9aVC0AU8lBQeBaEP7oWsW0smvPJziiIeLBYdiVwuktp1Nr/zVXbbAyZtokYuWaP8PSERMW3E5DUvCokHMgc07JFeEMmaCWr52WURbknZWdUN7T/XxWuxf/wB/fWL0QxKc2QUYIcXIDC/b6hqmbyPHqEhs2qZK+1yHnsrWOltnQV4anQ3SSlk0PSaPfZJoD28gq9SSQ6CoSXMiDagOrqh1RgORsTn9cB2BGulp+NTetXySdz3DMwjjLTdBTc3bKCkKqw1IQ+um+NZq6YiPSAUoPjS04GtBuGJEAnWjSp6kEWdny4zw2r4+ZcxnaoD+mh0gb+/C418BLtWOMbk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77032a19-ab24-4f76-6f29-08dcceb893c2 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:12.9464 (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: /pFj9oJoVTBAgTkmogu3X05cdAQsOwxbZS8/6gNq/HitiWLD7pk0GlQDONsjJQ29NjRxhJtW+hH50Qx4k4kNTOEbl3wgxnmoeimtGyZSOy0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: 5XWHwWy143qklS2wq7KNsjIatwpIC5W2 X-Proofpoint-ORIG-GUID: 5XWHwWy143qklS2wq7KNsjIatwpIC5W2 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 --- 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 Fri Sep 6 21:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794758 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 9F392158D7B for ; Fri, 6 Sep 2024 21:12:19 +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=1725657141; cv=fail; b=dRdQPe0p7cGDKKri67OL4oX9NjldLke2GZkZlOo/kcgYJsu6A84bQaMq7ME+cfTpv0q9mNX1VRvVSEJlkixVL/zWMKAD3CE6a0WhqEp4e2Dxxhea7vmf6YNXAf+Z//DpFWM/tKDC4rhso/tJ6e7rfB+EUuym7GE2NxzLz/SNmDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657141; c=relaxed/simple; bh=Zt3oJ/twGwGOQRVa/bsuq4wiLF2dlb18fQvxRTuynBQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZW6kaMNez6C9sxesV1IOmloo3tJGNJI7+iE3XNSKdmRUHphfVXa4OI/6WrPiKRrmlC6MfgkT9jldI8ScX5BZP3DR6L7fVtkcVFnJ/pZKkdTNrfmkuS6fv4oKxEdTqH5cyj6sAYC94Z/xqldwdMjkzD9FIHBzLOa1k+E269emSGI= 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=BXxAd8Ja; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=sG2QqdWe; 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="BXxAd8Ja"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="sG2QqdWe" 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 486KXUDR024509 for ; Fri, 6 Sep 2024 21:12:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=BQgt7dGNuqV73VqoKy2M+ySGGJZUx/rhgtelARpS6sk=; b= BXxAd8Ja9GuciJNMUMSDijG1bfMJF2OwOu9n8OZiknUGOAsVJ/vuasqeFo43ALHg tifEEvEce9buu0KpiK6jhb3KZRY/thkXUfktFI4m2LhO7k6nO8tQfCLy1VcbfSid hog604e3OVtawzogC6nwdEk7UHzkf3Py+VoICBhSJZmgx5+ardHu2Y1Q1BNGc5B9 gaiPTiHOOrSa5nk62pozLxnJ2WAok5CRuCtcdjAJXsRH1wUhZBJTc5hMK+Aphphj o7gPsOQwfYFKJP4P3msQMHM759Ck/ViTkz+sLWC0CtGz/fo3+ZOYs7+HEYlBoTyF RTrffvH01wpUxrrMyNGUuA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:18 +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 486KC9Q7006639 for ; Fri, 6 Sep 2024 21:12:17 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhydejb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cLl8z7QByydPMgYGxY2NS0G8J40I2tb5leuwgX6rwWpGWWuBYTcGHDNfkART49D52dPLdrTkoSj6zm/qxT+hyLbSZhZBUBreIgPpDutBka/A6NLUHr7TWVC6beEPzOSWpQwNSb99Phuk+/rC21e6LFoutnkBJSIAzZ99xpmYXKpVXU1C3nE5luKVr/JFI9QzF++GxzTPTFjmuuVZmV+y2QWyHRxelxGrToye33CZIkEREncc9nwjltg1LiLfVMgdeZVrMuNXVe8iloUIgb5LrtsJXbEr68N8iCyP1vJvFiTmRgJlEyFjWXlgpAAy/EW0ixiuyRzEGtWvRk8hgetxDA== 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=BQgt7dGNuqV73VqoKy2M+ySGGJZUx/rhgtelARpS6sk=; b=ZAskOWJNVleRNeCYBooajBwfusVaCp7Fe9wi9GW5EggRxGqnqTG9rQpNxzLH3kVNnwVmLL5na5AM3ayFmlYhyDQQru8th3Gkv9hXXLg53syYhaDmr0++LKq1L2Ftx0lMdctrIz7FXAIipKn8373yg6SnLIlPypOoAaQxAGDETY0DiYwrwqNVd9KBGZmbMFPX+Xih97PoNX7mu8i4T35INoIYIdVn7KBV9wKv+MU9ZOSRVAn8cLv55dH8+3I6pQDNKbEbX9voJf+TzBr1ZUP3qNTS/zvjxSm8FSJAzTgiKRdLrCgZrPET3hyW3Ai5kQ7Jf1JLhjF7womOmgxklGY4FQ== 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=BQgt7dGNuqV73VqoKy2M+ySGGJZUx/rhgtelARpS6sk=; b=sG2QqdWeTbqPXeWOiSyuPWTfI1jePnFUAoy+UgR670BZgqDsjtpPT/2Ru78ye4kyW2xURDmGyN3Rp4mfr/Vs18F+aOH9361k85u9rjIa8Ina1DQ8bmMg1npzLy7WeA84/00Vi6QeQc3Ir6TJSlUXdGKiEDCNVjCyxwFhwU9+4tw= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:15 +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.7939.010; Fri, 6 Sep 2024 21:12:15 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 17/22] xfs: allow symlinks with short remote targets Date: Fri, 6 Sep 2024 14:11:31 -0700 Message-Id: <20240906211136.70391-18-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0024.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b43e736-0a1f-44e1-26e4-08dcceb894fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: wd71DwiqmMhqB6YIQ5nD59RCzarfmh5a/QhOfN7QxX4zWeEvBhlHznhtzIvMQf6f1OS+vITnPp6b7ycQ5WJ8anTYG7SslT2ldQWqdmns6mYO3TGj+nrBwIjM5aWJuqNtZ7BNX5s/6ea9R7+xB/Xny+OhbOA4a206I1fAksWIjaTPLAqcp3wFrcyNHXFvseJX1fLn7IEiff3O7HYwxQLgMHA+6fwqFhg0+lOLDlk/3pAbSl8yDZmP8d40rnniUP4bcwHKbK32SY7CLoIZ6mDcypnAjky3n0J1iropNDej8ylTsKgtnzUiSD+/4lGu+NTw311iZfUmQo0BNGsgL+Gu91uuCUctM7kxseoGLiSCaV3wQkiuLHKcbZ5uYC37krox5P1mtl/vfjfJgirSPfWv1BqopiMdXQAue99FHwm+UQpmEX68J+780ihqafAXYTOS1EP1Oa1H3XaX+JyfzO4TWhUVGVIHyR0lmZ6GGuzHUIFFnX4OHnhn9FJLlvgx/7+jYwN5MYK9EmRJJ+COZEtBp7ubt9gg4l9bbGUL6XmG5gowqLYqUpdGsQAGDi9SY9Q/girLJuaurq42TOXSFfUfe8MbdJH6EaTlyh26yIqibuS/FF0aWU3m/Hj0pRB1uhNEUA2GdNgQol6ZGfXP0m1CMuat9YdMq6SZ6LhZChfd3uCmm+4Zkaduwd5PzO8DMfd1ea8sEyOzhAyaZgCIBqGwRVUGU97MVNwgR5sdhPTwiI8T4WMkRRV53vxUJ+reJ/otBXyWesGBZv0L0mVROacSuSwc7r+sfDE75BCFC3DOorWEaOIsTqFFhlQLZtPg5v5UG5kmjUd22xyMvh6XHt1wrDcFzZS5CkBCW/NMu+94ly2N3e3sgjc+lb7GZwGNsvtUCYA0h00GCFITMzFwPJRM3sO0+WD3WUPtquq5/YZOyF0GauPeryrbF17ok5AbWqnRybiSUUj1dG9ThT/D3zQIqwi2d5vTaY0+JaBspi6I2+ftO0VYgWUpvf0WYL5t2caprht1Xi6VFdd6r8cEKMk8rExGxLGV3M0PPKMP/k2fCF3Wxb/w0ZC9HHql9+j2N7wEV/d31LRZFAHDGt0spDjleruLgmRHz6qGLo0ejDf/JDRCEtok2ytGHQYy7BLD8V/xCOX+SRR/28BYX3ee7Bj23FWS3dtstlaYUejADjlReGoEvIIQmoxe3YYk+vzfpAnQF/DIdIwFDfetRB61XzcloybDvDLeTUmhNf2BZcJsT72Y3Sx6MuQeJ03ks8CvMnh1v9O5pyx0/ADC3SWXRxxcElUbCJDBwLF5gUBmxfiyVU+RiuSUQmnNl7tJN6UUIkPjl4ljuAUThXLYIHa69YGsiw== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jQwjBs1BzWlnfTUXmfQKLWtZ9fStTAtDFsq765MXOW8Ob3EZ4r54BUAvWtfGEOR4HmT7loS+JR4y4I0UNlICrMuG+2qaOqD41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t7yEHfk8Rz0EzBRILnwQ0S+wfBVSJiz8SYacArS17uAQae91N0VxSaQXy44ceyf+pgchwWDhVgYw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b43e736-0a1f-44e1-26e4-08dcceb894fe X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:15.0135 (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: 4PRohFVrg8v/PNfp/HXmphDDdWFKe0pcxIHONgfmYsYbNNM4noWjgkzYnz3C8nkcbi4MXPzttXRIcdr2Sm+1OVr5GRFLyXGCYntq4dwVNpA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: HJpce-WDxdg5a0VpUYmw4gmA2sRLQLJE X-Proofpoint-ORIG-GUID: HJpce-WDxdg5a0VpUYmw4gmA2sRLQLJE 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 --- 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 Fri Sep 6 21:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794759 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 D8AE31B85F7 for ; Fri, 6 Sep 2024 21:12:20 +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=1725657142; cv=fail; b=LLg51RxYd4Nu4iAfM88yMNHSC67/nhj8QlzkGOOY2VKj2ccDjVhaPjFTpbamfl+I5HFpjrdE8KMVigaV/I4Blr4CqbTEUbJ1sAUGBuY0HGvWZKILaKgyadyhhJ3NpjIe18+J/C9dY27VfCqdIeBOtm5GdC2MuQ7d64LCBj3pGqk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657142; c=relaxed/simple; bh=M6DL+ZjWoqKVdhXdC1VMwi4eKdfrkr92ytMtejOkJsA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PtCEz/cufEMaOpsbqbKgTSXbmRcUjilRUf8mq+SQrHvVeS3gy2bWaX8Ow/m67LPH8brdWW/Zvnbcz+rgH2GBj9IiWTxfJRhbZNv3nPSpTIr04+iIkMXh8vrmib/7VTghaV/Q4NZWsj8Y+J6z1QKlAFtsmuZj+K1Wwj+mOCCEOvA= 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=VWYBC1aD; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=J5sh6T/I; 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="VWYBC1aD"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="J5sh6T/I" 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 486KXVCc011314 for ; Fri, 6 Sep 2024 21:12:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=Uatsv3U4h//Lyr+45u5swhKlWe9gpm4sjgpRpFqXsrg=; b= VWYBC1aDACSMiz6vVFNfDtLX6EhwHf8F/keyMxwZ4oMWTviw0HChEEo5TT3YbvwR fs07nFc+O5DlojnZPf0VcwQN1YQNt/+bixM5lxqsvxKkhNTV9Upm8vOdNtp2SPfu 1hgZj69ioC94VMyje6nPw6lPNn85fUkDK1xpBNQOKQMGaUh2+kqThq3P3l2AiNCK Qke+9jz9Ksw5OA4Q3J+yfY7NaZ2jDnrD0GAjffTPfdSm2AXgBk+r64kyKlhpclZe bdX+iM0HQc76jJC3CncQ2q350/f54iIxnmSQpJIs26eSFq2cafoK7MnmDyLBUUm6 RnfRIsaHZ16Ve8L2hXHcUg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkajbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:19 +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 486JYu9w018017 for ; Fri, 6 Sep 2024 21:12:19 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyhf3y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TSCNkAEoHdQxR2PJO1NJzyoqfzkXH5J6ZHDalLaoLK43/IgiAj5g/gusjEIZxTxt+fizCas96ozMHj3Ij51GppnnJgGbb1OFdRKRnRHrIuBC0OMfNejC/ltJm+qwek1rbvAL6d9rq0xamLn2ERiQEkY3m82LpWNgsPwipyVI8vuIsmF9ZhL5lOwpNASqdlhEsI5BpIUx04NCqwtzRHpMP2mKJqG0WwMMFUiaC/F6BybnY9NLaiteJN++CERmV2tZnP0029Rs0Gaa32IyGbG/X1YBAKGgKvuO1ysKmYvZnhbuGXxRxGyZQRuexAEg08c3s8AMigRSgM8VJ8b6DDXdVw== 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=Uatsv3U4h//Lyr+45u5swhKlWe9gpm4sjgpRpFqXsrg=; b=GjUdb3ulhCMjixcjb3kE1HFSm5pvN1HhI0ZjxF7vw6WnJEtTDQAMMmecVLPt0yl6mUuTQ/ncbEim+a8FLKBfCMr23lioOk26wEy+opjCHBObz6eMG46E45ouV9OmF1p5mNwnBQZh4o5nap3sqzhmriShn7Bz4Y7a9q734txWxNDiGO71r13HsjQ/Bln6mli8/qgAehwbYBgpPMfMwTxQexg1MvM508aRMRCmYcCpSAv4rBvUE8fPF7nBoyISuJjtmSt6ulRQ1/odnt6v58HIhgyr68Pz0+HtS69a+C1lzC81hA42e9TkJ3irBXwNkjySuQK/dAkWf1RnNesmoQj0Xg== 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=Uatsv3U4h//Lyr+45u5swhKlWe9gpm4sjgpRpFqXsrg=; b=J5sh6T/IYRIXwAwWmncGjZJbyeg3s+SM5DmB3eV+kyj/pwq+MZnwEXthQbLtcWjJl8bQvzFYSKaVMKFWT4dCHrVF3RTtjKC0Ddp65iKso3GSP+GsVbrT9zx5r4NfX9wrD/FawFb4HR9tF2ZVdpRH1wMPzUfjkNUAr7byNZcjdPQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:17 +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.7939.010; Fri, 6 Sep 2024 21:12:17 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 18/22] xfs: make sure sb_fdblocks is non-negative Date: Fri, 6 Sep 2024 14:11:32 -0700 Message-Id: <20240906211136.70391-19-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:39a::8) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: c3a90f2e-eb49-4d4c-1235-08dcceb8963d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 4OU2haUy2CBVsoBwpMZbd77HSTti4A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XKedsdBR/hNC8ua0J2Vpsl60JyYcsFNNv6Y7+GNtZQSUQsz4dqLY+/H3OAfxLc9MBaagSSLyqsw9+Th2974RWXffYELNWXOvGNvwq37FhkTzAC/2ZczR0JRlNqaQibK1yUgDxdFZEVYJHLxGcU6g5x5stps82csISYL63jGmA1CmF7vmhHCSRE94hZnGjqxTUhu5KRl3ESMErhIvx4egRl2/ZujFHPh/SEaOdj4nHbCOBhZVtF93UpmX4ti+ailNPUVP4oRc+mMA== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3w1AYC6cTVip8F2uwww+Ube225BaMfGtt6vpoZObtiL4es+LV80dPqIA+pWixLZch8++x3J5cNL5WkXo/vqh1Aul4kwqKjvHzrTvytSJa7cJl+6wtqaMIJsnApxaPGsPwoE7sTSAPbqGWHQnHkI6z5WrAFsk4w7qBSZudGUpnaUWVDHwvkH8HpEXdwv2rPQC8mb0FSQcFae/5m9F2EGue9lHhexPzDIL+GsH9CbdVP/nU1PsU7hW14v1IKuczTusoxXXTb5CzkU7QAhftRbhNnfP6HOSIwdQWGj/Yv8lK6JAQ7HmsZUwSnTFsH41mEkEehK4Xz+TCdkD/Iw3sRPhq9M+9SB1Qwzu4xJ2qyy+69XU4h3o8Yn9gF+xnL0uKXIFmjjyC+5g9KUlx9+mYCIIjhWuznJAQhpNP2FQHjWAcHvFcRMnXLik5d5cmIxGvA/mpQOXEO57fgP5kAnFIICmmMCZcOozW1Uc39M3dNNmWgtlwhxGxHN+zKzlb4TGI9Neu00rO7Tzs4DbIozuQggVuI985+IxJ5jMvhVBkPlslPZPTNqI7br7rLsk32WWh1ds27Fw+NPsOkoEmYxIG6x3E+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pam-ExternalHop-MessageData-0: PwxIxFsEMe+N6a/uI6VTQz2XkZcKSDrTsxP+S3dn7oXY1vK35INpoNU0jqyFA9mVHI/fY3BCt1JN5noACnElfbpwg3U4KPpDKm3FXsywux3nNyC/jiux4V5GCDV/nyoL+ZwGf9E0EMElK1oWVrPlpoipGpkV+aBlA4MLpVRQohvwlvKgAozQpRzGY5d1+nJV8+Ucm0eMX8Hs4c3H8OnhJyZELyJmbcht2m90vdWYfEiasUYfCsMWtYICVSChmwKHevlE2siQYL3OPY7+De4hgA5LK/h9v7c3SsJsBJH9xQ5/xVTw/6iiOS6rO8liXHF4DLWTwkyd8cp3TjWK8tkM5qH2fniLfL5v+SUMF+NI1jKD/7vY74AjTTPBYTY6iHyHWxHwrjfOKTa7wZi17f3OCB4FrpLD7GZo4gcXEqMh3ZZANFLFRpufxVdGUk2H15GCeVPc9KebZQzRUEm8JzFeiGFV34wqtf5dj6ddxAKstpI3gn0kVb25QT9QbhVVQW4/k3wsck0jY9MtYMgPJ+rRARcSpPOC2LGCz/IFB5iQwyvvzaHC2PErCgoY2yGjv7DeLsRBxQiNUsv5UJTbVbKtFYDN8ktI8RT5MYeoNHajktM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3a90f2e-eb49-4d4c-1235-08dcceb8963d X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:17.0278 (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: vi9br39kzuouQrw6+fTp6tp8nma69cXST7WhWdKHSdeWA/mwavPImj6ugaAlSw4pwChYZY3zq2BYD8NCxF3XrEUek3ycSe0B3/tl6rE8svY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: 5d1mwGNcqHsgjINnSXUQWS0Jj6WqXKS_ X-Proofpoint-ORIG-GUID: 5d1mwGNcqHsgjINnSXUQWS0Jj6WqXKS_ 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 --- 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 Fri Sep 6 21:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794760 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 C9E7B1D79AD for ; Fri, 6 Sep 2024 21:12:22 +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=1725657144; cv=fail; b=gSsnUJuKvTj66ij8Wq3XL/DFouRQ0DEAlVjjcCebS90pM3QCvU9bAppwwDswKMa3MmnyCDeV8M/j6DusHtruJKg4BhKIKsAVwzjZu13+EwKhE5I5eXP0fvobWEiZZIKdI2Wwh40MemefZK68ei7YGfwAUm3NNO0gB2Vw2KTXhTY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657144; c=relaxed/simple; bh=SRIlL4xgXmRXiBOwWWi1VsEk+x3iHxH2LFfvZwedhAo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=LetEZTF8wsp+VOE5tnQy8OHak+YNXsSyp7BD+lvZN2bldeXhQXW7P6EdxPrNPrVBU7UalNbItqCexCYVOyfm0uawPNIvIBhkozQtnQ7nDvsFGUt/qOwVwkA7HSGsTfvuBHrPz84UDLTv6ytUKFIZylWvXjpSRKig5pPv+j7g6dU= 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=eE0Xay3K; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=q9eE0y0M; 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="eE0Xay3K"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="q9eE0y0M" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 486KXWt1027392 for ; Fri, 6 Sep 2024 21:12:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=daYqU5HBP1jUzvPrbHscg9YPGF3bZmAUiZqYxWk+Cq4=; b= eE0Xay3KkOLpDMx6WjWCLb+Z4i8tfvDoSvwHDNqAKnQr36VGkn6wupcxkZItB01+ kfvrtxuvvGaxHK3PmbGqVdpztPgGFC/KjPzTckWadGohqF7YFQl4Kvs149NLgT6U 28LPFo0pblOM+fEetHVJ0vEf3GVx/0dfDfsKNepk3zmuE5pZ2tH6q1u8FIrXYVVX yAE/045BlSBIAZu1RqhrJkYMYA73k5R9DjF+Iz9OkXD4bnoael/tWW3AtJhYd6md ugOtBB9mbaQX8Q4r7Sz8TXFmV5svU8q77lqLM6nSYRxm0Ruc4ZGV5ZOmQGuwR1IE FPamJ9RF84OiK3Qb2Pb/UQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwqjhd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:21 +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 486K64ci016219 for ; Fri, 6 Sep 2024 21:12:21 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyjf0ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SIHNguGhsqcvjUlFu00d1bpOkNTrXzg3lI4BPRD6auRZPFYYeqx3L03Mwt2hrTMpbIqGMoKyjFfPgNRjbE4WGPewxYA/2Oa7vqYiWPNfiG+A2pEJ5w/Tz2Qf7cNTSWbyxk24r4xADYBtP/SjCeQQsiV8OB1/1DNrB3ERZQkyJh6rsrlmOfS9KOyZ01P8V7kgPhummnOIwK6AJqvQXTtzlF5UmkQU6Ja4Fb5zJMUAvPnqFeXWTctP4o3IqC+GSLXUg5CSW6IStTgl0tHjrKd85xU8p4PZ1kbxr1jHxl69Eky2QiXi08wcU9Sry30CEK8WOUUk8ohYNdLI2Np009Y5Jg== 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=daYqU5HBP1jUzvPrbHscg9YPGF3bZmAUiZqYxWk+Cq4=; b=yKTbKGUf35DsAtIL/hrpjx5p7v77HFV59iN9+sTuufrt2d4FhPt0bSAnIxSNagxyp177NUKuhs4gE2wyGpcIcSyu6Elr3y/QjVq5pR3y7Nik2SMCLwxEVcizXkMbQzI6gah/5NZ6XLink9ul6kHsRZPzW6elmC5hZB61RYmoDcU923UaOVHFV+Okwy35tCahHP1AMSwBMxbHwYuttD3lpBSkoKvBfqQ9A0ZeN63BhQ55/VuRoglGSlmbDpzyhvhHiKXYpiVcOUl8eDLnD4qMdG10R5PTBhlpywr8YmxPoMmn/CP9ibawTXzD23pkVwrdWnZ16PvhfzR1LnCYryZuUw== 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=daYqU5HBP1jUzvPrbHscg9YPGF3bZmAUiZqYxWk+Cq4=; b=q9eE0y0Myfwj5OpWtp7t+RYiEkl43WnFYCMfcvjRy8n3iewQzexksyb+uV7TnJXslSgkjCDQR7rmIb+TpG88fYRZj4JpKH3XgRFzfXKDHAb+2p/O2khse++DZYMqP7F6VHvpLfLIBg7Q9NjWbBzSuVAorywEJAgjqJ65qlBXD8U= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:18 +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.7939.010; Fri, 6 Sep 2024 21:12:18 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 19/22] xfs: fix unlink vs cluster buffer instantiation race Date: Fri, 6 Sep 2024 14:11:33 -0700 Message-Id: <20240906211136.70391-20-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0001.namprd03.prod.outlook.com (2603:10b6:a03:39a::6) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: f421e939-6698-43fe-2825-08dcceb89754 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 1pIJ4ztjYq4ILKPzezUf4VfBhhcBJN7GlHTkluJksD3jaHrG3PsDACjJZi/p2WfybSRfRZDc1kPlEISQ5YJmpwDMpPD4eZHsdv2kD0i45nzmDPv2DImilYUQxqaN14EUC9Ftcb3yWpaNkf0iwI4bVHNjzmKW38K37D0lJRmpBFaI6VVsOqLNqY0tCl0MWCejgbzPRhXrtXJKUAOMEMZ05WVkdxx7eJsUO/d86Mz+7UdgMpnmPVpI1iL3NenOJ+lcv7se8hTv8XFvA61zxM22zOwPQMN7LrmqCUfnYoD4yA9YOflgL47XM8DNcBI48cevjyPloyXtU19i7nlcsWkZaPmUUDV6Slu5gFdPQHNUCp1DkGUAig+ZaRYKktgV0J2nSVtuvn01M0J5dWgi/7E+9jt9pERdwoEdyeczZKIgAEoUjAXlclGHJLDlBSxYmuTOq3YetcAA/TyUCEQ2ZrUdoQAyESy31KydvXwlFPWftOxJYFeaaWkjVxQHLmOMvdbcBhSV7b5pubArOsXs79o86IEbYNAO6iM5EWkAkziCv02vzNF/oUStPmQMs2S679CnskBkqLGzILgdQwY9UhFpsfYpUhClzDZNyp93yd/yv3F4Y6R3lzRxf9apAV9b5IUcPqLtf3ofPqI5fpCKzWInQjOUTj+xYZdyR+JtKlpjH0OA+u4WOJBKMeQm45kGHHj4aajpR1sbOQxnwqSid/AHZV1zqxLJbArWFkTPT5QKJ+6AI3L5ie3jz28SNbHQkYqASaiBKNqa5NpfR2tAMLvjjNXi6DtuO00Tzz5Ej8RkqBmYS0pA60jqWspiVEKjRYYAh+LRL2YVVbtG3yublafHdRA9uu16bJljvjXXEncLRFosxQKHjVKQbcLhfdLtXK0p5pdQFdaFWDVDZ0O6INYkB9OUe9xgTIKp9w66dsTiKmoLBdUagjs7cc/BqLEEOqRQONWFxi23v05V6nq7Md+uZtwV02u8DBfnWdgw9Af2Ns8vgM3jS0C9l4M65B/WFGXEva/B2GcAIT/beZzD6rn7zj9XKdDVDwbzBwTMcuuXOaOmDBKqfvpb3Xw6o6gPchEq9vSm9Nt1gpK2hW0H9SdXK+DJyoFoY/Q9rnreZQYKPCzGXkFYBz6Zh3QPL7Nj1TBx0CSUYtt4e6TUlDQR4c5Qd9LhkKkhkad56iFgl59aEUpkfh7jeiKZaLxtJ3b3O7ktLTC5mrl36n2An5Go4pK+9FXPWs0Gw1oQhaup0HLQqzPCHZoXJgUqzZViNZQIvYqtw3fag//TP8ycE+XLkNc3QNhxUGpHMOrCT9i2pRq/ci9rxm90ACrEFqfLTWLYpC4MZtttkIN498fz7I5ZUL+3WQ== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DyRd4ipMlQ86GAP5im+61ejmeTSnisuj9RtfTHBgzpVZOT8gMIqoSrz2ni5Wz8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ES78znQTUhKxIXjpObBEGHRvLV5WySETkykegOiaZL35YzN4hMEHEz1GY03Rx4zTAy4Kb6eaW0Y9expmgVpPIyXts3ESYY9sO3k9XkpGFbuvsA9uyx6nuPJ12FUOk+sUpCFwkJWEoaIceajWK4uE0fr70EdsWdJKZegV4+6CdcF1TvjqPspg6OH6+KaHoNlR6O9I0SnGWtdfx9jnN/B3qbwq8kHQ5B7eOqqAxKYKQYWHBNwTTlk+pZS/nEVR7JKPQviqMtqxT5izDBRjN60olHkAWqLtOq3mgtgloSJJErQ8hRuLJM+oW0yWZ8Q9Fd4N38YhOPJfztl/HVOyswGTiT0a7bfksqrGtkUmgym0k+wJ4GDofXZF4N3kOvgzk8fmHt3+nufm8ErmN7qHGDYWSrjSG77FRGGhUxoUovSnfoA44VqJcf+inEjT6+ecV39XOtSsZNy8SPxmmktl5KIbljaa194w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gcr1lg2thozoAmpz8xEshFRkfyp8kuhKpLpgVf0fsE/rNf0G46Fv8hPrRI4Sg5HpijoDj1hwMf7QxB2qlOTREUL/WSDMS17KiEgl2SXgR6xaNkJ9tb6VetuxauNXhnYRl+8re2YSo+qk+FzbfuUUkWA31Eo1V2vTpro2v2arr1aCrFMv2XeI6JnpyD8rYmqnQTL/O17BvfMV7PjrZ8WDVPq99qxbYQaICoGweauk36p16bV2+nSAcecviL82fubkENRnNPhP0hM9rToza0at09v7FI9j+XlykdZEmrzDML9dZ6srzabDxxXF3ORF7TrBQI0NHkYLqLnsV897z0bNJS5KHUroBmWAsChH8NA3NX/J1XG0jrwZF/lA1XqlLO15PFOrtPupTP4K0rkEUsfX8ni6pujKLewYK8YlmaPIv/YL0s8Ytl1g9yXIhtBNoRitOY7KfBUbUg8TfLy0S9FDhJUwPkbnuZO0RoTRnNLhOkzUAyGj9LkRGoZV3bs7ECxAj1/3A6y4hXWVopDlbJypEbtyzN0cMlNMxTHiVCWt0XLFHrC4fMHFc251u9lHtu0jw6Ew0AcXJzeOKwZ95ZPEI/fG8ADcmXaMTJRe7WVPfrU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f421e939-6698-43fe-2825-08dcceb89754 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:18.9228 (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: J+YmITaicWv0f31Z2IWcBZzZgZyNBfsxvZei6dBhJOu9N8rIab4VLdB7RWcRnAG5SuoN6tqJRVq4BF5FhXhVtZd8ufP7EON8iX++NgfhIN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-ORIG-GUID: QXNrR1v9F7VFxfF-Hdwd6Tac6q7lC64p X-Proofpoint-GUID: QXNrR1v9F7VFxfF-Hdwd6Tac6q7lC64p 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 --- 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 Fri Sep 6 21:11:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794761 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 45914158D7B for ; Fri, 6 Sep 2024 21:12:25 +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=1725657146; cv=fail; b=VJiWbg7u0Fen1umD4hZKa23oljdhL3dt99RzwVrUlfeBP81/OOsnsP7/jaGEHC3VWUbhqTs6IgzB4H1uv4A8c+8Bs5HlfL3/8nMO1HltQPrkSCF5zQneg0B/ZnDjoIh1la6w6TFNJbPwd4yNdCJqmf6SnML6eDpnFNOsxDtJ7+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657146; c=relaxed/simple; bh=9R5gDYGRkD3zuEAj6D/OwgIiAtThfu1pQPpc/dE4v6w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=CwLLrDaIHmzaSvcaGuWCEu/UU6mAMADr8hYk6wi56ortwUXtfO+ellL+s6Rnx6mZ03/99E0Sj0jXWW0zTfGkwPry3YsLmWZ9tQy4m/nbD+jrRskoJizi9J1G0AGnRtI1Mjgpp03ktSPQOJgHaDpBHyp0jKlLZXnupiPy1YXy9M8= 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=CnGJTo6R; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=q0I4mBg7; 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="CnGJTo6R"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="q0I4mBg7" 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 486KXVVw032154 for ; Fri, 6 Sep 2024 21:12:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ryNP2/BUEI5XGaNMf5mCh93xxASKGerHyr9sWS/BFKk=; b= CnGJTo6RrOt28m+8f4keCjppie77pmh7elm/y/Og4L2NnvWg7svOXVoIxCRUp665 GkTFTuPz04cXazEMD7iJclOq6T0IhiVaOnG083QHc9d5y0ch1o/DMcSqotgyzCNL VnOlZNIQxL7pbq4lwUFK7QTAKXTDiCxs8rTxT2m8DignhU44K3o7A+nbCz6Lv9md AARyNG0dnjuNxvnx8Wj71KsGFclRh3b4fWEDHsz+O0RUZzBT7ZHQ2i8l7ulm0sKQ cVUnoIOujaUoYy6GXkPo7jvKWQojWz9ARCY7yjJkMMhZNVVaDOtmj/ApcJdTPS1Z GHmV29p3AsVmPaIz94qvRQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwntkr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:24 +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 486JLXGm006826 for ; Fri, 6 Sep 2024 21:12:23 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhydejdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gzPSJtoz55umnEY2funkeYwCTmZgkTF5gpBWHC38tPHzBr9U8fuTIvmmtPkG1c4v5jY69gXvGyGrVvWniP/H8zZX/63PYVAgUtNJhLupPZq+87XhASN0IdK/0Ytf85WG1XFYWboREueIlU+Zad+2n9xnXHBNrKUgWhU34uFaGNfqdOs+5jdU2Hco2qFW8iew+osaYibYkbpm/1OoZ/cBIxsFEz1S4oJ2Gevdp++doHht9+dPfcK+2UVx8VUmUN0WEBRVhdHf0II06xo7GfdyOW456ijpqS5Sorr8JFuOvpT0E5X56c869QgWlFCO13VU6OUEP4Vl1pWlrRgGCd1/rw== 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=ryNP2/BUEI5XGaNMf5mCh93xxASKGerHyr9sWS/BFKk=; b=X1+VWztrOzd/+6JLDjz4za/MLbqpeK1o7cxObM7EsMcJa1NVvDZ0bw4WZjVL7s4K1AoLSn2uHdKnQameEpoqxZLdjPtHksOCUI+3a8YF1tqNVTHZ22uhKOhDqz2IAQeSkhWWrhIhnLU4nQN8AwGtPnAqxirUPCC/nexul1QnOeNMLV77+KYp0ECa+owx80HaDrj+gd7UYG4ZiFaqNXZaXg7AONZWB2eMTDl8e4JLrGZJbI5MkhyDXomQ+H6knzsRqjGVH39EpZ17bVjuPZLthbAfRdJrIrM+Iu8EBKcKOFsVdUzEmkzzkVNfGlB22dPiLGvkgeuU2HDz6N3XNiZ5vA== 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=ryNP2/BUEI5XGaNMf5mCh93xxASKGerHyr9sWS/BFKk=; b=q0I4mBg7p56cYgHeCfNhPPaxo8RpeAVgXJXKZBbfjJxzjdDPSvg/dd4NrJp+oeEW/wjY5bez5u0PIzQ1rIFxSCe5apgaU0XUGOws/EjFHf9nIqXTd/t64/iKdJ8WGhn+WDirbXCgclmyIDi9gmkHVBQzXgwAKM1uC6zKYti3KNU= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:20 +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.7939.010; Fri, 6 Sep 2024 21:12:20 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 20/22] xfs: fix freeing speculative preallocations for preallocated files Date: Fri, 6 Sep 2024 14:11:34 -0700 Message-Id: <20240906211136.70391-21-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0023.namprd03.prod.outlook.com (2603:10b6:a03:39a::28) 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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: d67d837d-0feb-40f8-c9b5-08dcceb89874 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: zWEUPVw1LS1mHTbtrcRT1bvusmTgWz4GmQB6UefYueoNZH2JE1/FXz2Ru/ssqx8SI8BIph59j9kbVgSL4dCWTs4OTjxnjVxc4q8xJEiQDOuSijlzhHl3rN9DPBnlLAPByVke0/ZQPPC6prEB8HmasR5SXjYJ6Yw7WN1D4K2VDm05id1FoMlnoAy3hBpQE/OhVad8BCzJokiTMnJBtuLz0dHzIelM7rcmN7g9xH9Y4O0SE88uWYPLtzNJ1RROnv3eSG/kZGb1Xcj3gNPKWat7gpDrvT3H0lt9CovHOuvGEgsi+zZZrFZhgRQ6G4UIHiQej/FLXc+vIGOQOwpjXBR3btChVfMMw7O1NZ2ZjnBnvRl6vUe7P4i7NhcrAv4Ad941nE4KNB3pi8Eax5+dulC9FR7bn04fy+3t6u7iP0AHdXJq0WxXlEanES8NkrQUd/L4bPnlH5uZLZ4oAi/6IyXoySkQ4OqdV2i/v2xW4qdD4FW5cppt4hWevtnPGlCMtnbx9VBUgZiTxf6hTakyEW169ACisQaPm7ZRtkDAzcbcXa+TkAXGcFr3gAPWbAEmtkUCvz0jJFZZYdCkewHbU8rdGt52IOlUM8XjngDhLuI26E7DSrwjV12P1yl5So/OxDbsHWPr33GzD1Lt8feo+/D3DpMN86CqeI+Y8cCSkSjE3gggAdP4tEsUuWaVv1+clzWrDnq3Zu+V3TmfpKM3simcYZDy88iQ+lUPjGEVhhtxtPG+QRx6XtxlzcFMd7JUxlEHcS3uBanvW5t+LUlcortVvcx/vZpcQlYLQ71wNU+XBoSRynsa5BB3yzaiextj70v3CnAsySKvob6WAxZuufaFvC2DpV+tkfEBAZU3cwBGQHpTeoyAt/k7zJUcS83w1G3Jis/LEQWytdJsW4SLD3NX13Y3CZ2aerixNtrEy2FuSxgN59yDEvXfpnFgNFfS+hlOh5+tmRSgOkvCPfGknVK9j5g7KappV6lfRp/ZLuoYWWN+HVfibYf4IFOY+rAkGvU18r9PrPni+l/QoFcvq4x9lw/tNFYJ151zZ2M3TbMlc/XMOTLNZ3yNA0nC2zZww5vWMHxxkT03XYPIpX3sL/uvtT8B6N7DEF6Ix8WFtgQvcCY57aWlOTz1NcPNNKLkJq6e3iSQQ6tBaSGHCcA4kHSFbfwkSsAdWkjB+dJf0y8xSyyw044cre8EsLl+1BU8OPW9apwymPJgo1f1XLE7VtMFeuR0LTgGfoioTo4k6f70Mjk2Ps7jcxCEzU3hnEF6UGNRAp5MuFYxT0LhUcLpO8vgvBJwX+pA1hOXL2J/ScXH1pXy4GSK8lK1lQHTZJdruMhXdmo1FGCdgs18yWjX76B3CA== 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)(366016)(376014)(1800799024);D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R21rvCTQ05r8TSMBwOucwRUpmjxhZ5gySWI1FUfNp20oAxetV+IppWRyc3WYH0SsfIIyW/73vBUEhRCgEZ55hWvQ8LUxWS5CQmTD30jrJfeg5w+S4N5gxVsq3SDxz3YYiXKzS6j3J+TE4VB9HFXADgn8xIpJ21vQWUPb8qlS0xNNW4vCrs47ekCPbwVq/Vn+lshdd7cBf4Xg+J96GqB+n7+ihyc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d67d837d-0feb-40f8-c9b5-08dcceb89874 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:20.8150 (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: j5dgPS4CaFymMwMQsYLZ4hRLUc6koHwK/PQFG3GoBYSAOMq5imJ2tqf5pDD1nfGFbFUif0jUFEi/BGkmqgJwG5zhTodWR30LumW1JSdhFSc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: B62xc2MrBBPrLXOZqIMaGNj-lT_3wumC X-Proofpoint-ORIG-GUID: B62xc2MrBBPrLXOZqIMaGNj-lT_3wumC 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 --- 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 Fri Sep 6 21:11:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794762 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 85FB5158D7B for ; Fri, 6 Sep 2024 21:12:27 +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=1725657149; cv=fail; b=i0oV5/uN0xdncSwKGdgtOxcWpxj+g8jlxkHxwcj4m/bVhxk3y8pgIGU684N/9qsWFTlvUNEv3e7tU6Lm3j67fwZyOxoumfK6HVipNx/70JaOI3AFipcQFoy1UYZuX5Nx5xhCEU6IcwynvHa1njNvpJxAfuo5Vae0KmHzfUINOnE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657149; c=relaxed/simple; bh=AE6wEh+v9e73Y8djekuwFsrp3sa49969EM0ozv8FRXU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=qGFUMeuDFdt+u4G9aLsiHkNj0fxRHiWB11ItxQHaDic0uPRohZZ7b4VihKcJQWnY6VBNB3W16kZwS5quJ2TefcdxkRRKh9tNuolP+SR88o2XPnaMYeEnxB/ZMy7vdnlplnpOP2BgNKfyBPV4RHoIt7UZ6onyiYQdb5DKdBaVqA8= 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=AObzJj9T; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=oKYR2Vf3; 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="AObzJj9T"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="oKYR2Vf3" 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 486KXU2g024511 for ; Fri, 6 Sep 2024 21:12:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=YEUG3n119LVEMUwUVMBQ5v3OPk4cqTIGB3GuhKOQq5c=; b= AObzJj9THYcJyJUwgKW4/kyB+lV/xF3/D79f/byEAuTQwrXIJ6azy589b8/Alkvx 1Hao3MtkqPoHJ3LrPDWitxEhxNH49XZhXS596L4lXj6Apw7ddw3wP2koQcgj0muJ xHyK9Y/TzLmy86ZL+YbIAmrOjzahmN8pli+v1r969Wtrxgy9giK+AhLUt5yKcv8+ 6/RcChRC/JQgUcaUOMuVAvYwocpRUtqFrevHBfjwLZK4zv+10w6LDC9sMd1dFszf ivV3o0nChZQ7y5X/ZZAcdukAvTBQoNWeL91ldFlG2L7f3vy0Zlw9pLkmUJLmIw6/ 8gAW8bPpfC5FigYTGIrcng== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkak3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:26 +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 486K2FuB036933 for ; Fri, 6 Sep 2024 21:12:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41fhygea64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v3fEUC2xHmXoAzolpWzYeD2kh3qoUy1r1sOqVmxjXHPGs/sy6IlpgcOmqtnGk9Z3m7ailQ9K2vSpXSOr05P0AIOxExsT7aBEBrYK/8FubF5LIIBbkDSSUkFMXIeI6gfBeYn1fhhfizFrhxcfcoSezk2ccJBENLB5HqI2RkJlV8umTkQ2uINkZ0ykwmEeZOde8ZQi5CDE0xaaH2Wz7vSB4Pj2AD/jsx1xIsfwtTQvQbsR5CUTrHSHsI4PGAWmrx5pfmsHT3aZ6h1a4WfInSJU0RWmLO2Q+OCXaUbKOHlcKnMDWqL4DQ1Q1jX3ZrX4S1XuZZ/1UBK6/qmP9KK6LeCPzg== 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=YEUG3n119LVEMUwUVMBQ5v3OPk4cqTIGB3GuhKOQq5c=; b=k2Xz9MEfZKz3VBL1fitrbYb/wkicMoz+YQeBu2c2HQNWpDBMgRURVL6I8jnZMR73EuTdNvr9DvpIb/hA6SFCKuwILSRKNoCBqNjS0ngvEMTAb49doexuPqS6RTzS4m38ABYAbVs572tmJceI+vx4hTCoM+I273HwLYEw4bva8VixAcB4V6qFt07VxAiCQgz6YggEWA7bVRM8XciDeP24aeFKx7z1U/c2ywpHi9yNKz5J+GHULJsIpiJVgAgAyxIxrpY0r8cdWVPrLv4nNRK+7ggshdSe/IBw5RP/Z+WUX3yr6OkAWDVjVb7Np6/fFmQER5SeiRThg1KPMbnzQAkVKA== 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=YEUG3n119LVEMUwUVMBQ5v3OPk4cqTIGB3GuhKOQq5c=; b=oKYR2Vf3eRrAw+aeFnQ2CHk1smGhLUn2oefykU9oC/NfMK5Zq58I0cPW0SClAesuzSqg3fNfM/wKGPPYSerwmFV7uxeOJaREh9qfth1y/G0XUeIab47Q8Lli7OSUPZqyy+1PXOOtO7fM67MI7EgvpPZPk7fFvz3th50gFNXyae4= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:23 +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.7939.010; Fri, 6 Sep 2024 21:12:23 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 21/22] xfs: restrict when we try to align cow fork delalloc to cowextsz hints Date: Fri, 6 Sep 2024 14:11:35 -0700 Message-Id: <20240906211136.70391-22-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0007.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: e93bd36c-e173-4b12-ff3f-08dcceb8997e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: Ao+a95RjfEgda4uNeghYNDOSebe/JkXQRru5QVgF+jpBGG0ZZNR9PNKLbP4zawAu0ONLJW6fr6gVLwggTa6GImlonClk+1ZLLHUWPDb5vtSLJUwZBNCKh8P3y5Au2GWlK6U8O77tkb5dPgj9BMgloX4Nh9Yz+IiH2s15uLoCefS4aRXDUHDXxC5rUpGLBnF2XsirZXaPLIWCSGqaLihZ6hvf50VgQJ/iH616T3xjBt7MNiqYUWeTnmdAnBxKLuVGpDPwA/mI5CEeAuZMv4qlGc9F24IG/FKpbFiBt/wOzPSypiLZf6oXt4MhakeuuxoJ/dRv66Hj0uGsv8m7W0yy4mqDc+3AKFK2tNG1eOEl2EyRt+WmSFHPpYPVKg9+GlE8u60DN5bGOBrPCNxawvFo0TcJxKAat1ZITkFZs2qCjwfa5q5tfXZoOr6Ibfqsi6EwIduBlnyYse9xfiE3SjveNy3k7quxfwoCD4S3yKA/q5zkf/U+o8yjyHz8g8pFD9M3xqpJh6LQorQBXfRDDXKVwVAYlkB+oQYCRgKizAyWWW6v3jgwOHwaQiye8RgmIlWscr/spQn9KX9Tl8inssbyXvcW/z1I5S2G+1fr2DpQY+7ddeba1QUAPxqqetiHpL8GKqpkCqM2vZz0669ARgv49dHbIKBLj5kQepUj1xqyY1oqW7aH0jzYit770tnhDe7mOnmPR7jvrEolkpWpqDGVYspMzKX6dDEhWZVKgsf5xjbS/wd1rzFOJdItDV4z6l9kg43p5QjK3zBOH1zWPGGzW3j4nGO/dIqdqbU5JHLQAhHXVlGBH8cdx2oiWyjLRY2zFfxjQ3mmJzqvdGMOAlhM4hIfDF+KwWGVahJLAf5RvzkDNxJjyG2cB5P7l5cOw4dwrsx0+W/0u/Zp4bNi2wOlRQBLBMgLH7ehMl73NfVi1WAQn0qUVwbb1rGv3v5xbGO5CI7F8kr2h0RGS5ETmLYehzRiz/IGVMM9XUr8MrbtVFkc8Iru+cHLWuLG68J7NEXBkrZWJRdsxByEzWmO0QqGWKElto1BSKIGMYDJpILjgT2hDV+OFeWksjn5rcKWfjJlgZ2ZEHvzNltWOMg5uyvAA4VfEGs8Srm3XWn0X0q41jNHrHIweQL8te67rezqzMm1Uq+WNXq8D8Rp7i9H94cCJwOR2WSx5318Fl8to7QQA2YR4z/WBA0++AGKkDtUoSR2Pbm4ld6mSg2Pt8ZPA17xi60nVKBuhTQncrcd7QIdHoen20SKBNipgH1pBc2xvGmUibvCLKFp/fq9rKIUz7Z+blKe8N33oWBLZbS8n41+59irbgxK8f1FnFc9RA9a3/LPPgG7b49ZxMJsH3F1puW2Mg== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Uc6A8X+fMhyvwMSi0RQE3zqg89gklKIpsJjP7SkL4GzOGTdxiGoSH1PuIfQa0uaif81A+VrIwBVY4eE2m8MU75XuRiJYhOY236RyF+L7A8I5mnBeJsNmh8fWj2awH4hWHKU279OBeQd1P4XIsOQ0QtGJWlV8gE6QhwAaFPR266hmg47gPo4VAnJnqx40Igwrt84953XbO6JVlX046TTSACIyMA9AXkhWkucFdho5UFUotBWPN+CX3UaF22qJsxK/yzUo6QmPVj7AP4HoCellqikgmD+isWwxvdmwkiZ7W6/jpxJP4+yt3zgiWDe1j5amZKLwsmRc8q8hxoQLkpCcEyuXrWsd1+doVzma1crcfWzcQDUHW2857gv9BCoPU1uPxzx46L0dZyGmT562Q+cS5bU3TXCLHsYMjxH0Xu1pzopQSRy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hroGYi5XQVVsIkM+uw6Kyp7G522Lx/9JYDVJliv9lgISJqXMBuwQCOmHiEXW1J4Di0axGXzuquF7JDr9EuWG8eImCLDti9TfjQdnRULnhVhx3eukzyPVJHLhrw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: brQwrgOyQ5chjg3b2/qzmz/AO7WKc8Ak6o0EiHJMBA95o6mXtRxgJsmbYoFmJoD9xnLdeR68t4evRhdKJ856stPcEbRS1ybyS8rJ7hhY/dHHoQgEhpU/R5I6ZrsOZhQBu/yHTLmlXdLUidVNTmAoe49XPl0t2hnxvuMUoRsnsiEPnDSGM5J6yZSVE/XR08bGZ+tsJOn69XFqhoSgUGO7A3cDy8a7m/Ocm/N019sJF35+JrYkqp9X1PyydNN58xAU4/oUaIzJ4KJzDoDTBAsCCLjnekCZhd1cS8pZe8fCvXAz0I7k4ojr1aNkYll12zRhYe/+guS0O2PCPawVYM4k4qqq7SmGq37fqIh1KpzIivs3W0qi/pq+1Bv2sSdc9PYrThyrN+cW29mmaRShYLINt3v7KhnNa0AfPO9tcX6LhE/twpsC/niSQtFJAFPN2CgWP5whvbGezKE/oj7PWhAcJaWOovcO3leGDYWbi5QgoEDDJN5xuHRD+T0gWNFHs67EKvSMZIIH3ckfCD+cH2JAyL8AbZBrkpqQrlmNP2jzOaRoV6ogfzjdqdQMZvzjmRROlaijL6khKWR7dG8ASAZO8N8kN2gCG2vanw9uvEsdoe8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e93bd36c-e173-4b12-ff3f-08dcceb8997e X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:23.0837 (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: AeFaTPVeEE5y6akwbAiAf+G2llslfRDn3SI41Ncp6DvgnkA1zlVCp8bzo2cGxMh0WnsO84CWROTyahObyEH6jqL4CBLOvl/+0kvzw5kH25M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: TNNz1sbBi9qr3Rlx6F4afmfAHZkme51j X-Proofpoint-ORIG-GUID: TNNz1sbBi9qr3Rlx6F4afmfAHZkme51j 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 --- 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 f63e7365b320..164160529159 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 Fri Sep 6 21:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13794763 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 9F0801D79AD for ; Fri, 6 Sep 2024 21:12:29 +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=1725657151; cv=fail; b=a7lcJgdNDDnyLS7m3N9MkTTJKolvUN6daSUhCefWmPpKaSCGycMl/pnKtPL9SqHmqNaIMMz2OBta9/LFlJ/FUmjZksuttfF66aDOdCxkMavJIVwFIKdGAkld5TLXJJkUNLlGhnoSivFzrQKiqfuj+L9Bf5wtoiEHZRQOGbAd2AE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725657151; c=relaxed/simple; bh=pTvhCsPdBqd+3suk9JeashoDNVt3VxpLxDmgHu61NwA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BNQzZVgT6sTBCc+L+bSTE2VpRhhpDnYojXcEzNpImWR2j9MJkjOkDjCE0BMWd3oijdTYmsBB1DWY6b8vVF8NxK482gRqvcxtJlRT9F3gISFOkWYyanDZ1030Ky3SinuClYu46jgB5MfWsI9yGFFaIqsW+CVb5YeiwleYndEGCfE= 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=bTrq2Z/F; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=nxDsttIt; 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="bTrq2Z/F"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="nxDsttIt" 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 486KY4t5012800 for ; Fri, 6 Sep 2024 21:12:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=evKcOv+6Qp/Niv2wKcPN4j9qJ3CTnZ+LcLZCqWEjlk4=; b= bTrq2Z/F85MrxD9238/E2KA1f6YvOaGzPnQOqO3V7fHAucunebc2D92IURfOM1M1 /1WiOn2zYi9kupegn4KnRn08LMiDmf7nQMDedmlOWw9uUpWrt1R2k/lbsiobTJO+ /c3DAZoiqnGjWnngwhw/wCVRZPsYtm8SyE8hOT9DPSz6DeNmBGfuUfebl8eMvNzB Tpxos3fxShgtAAdMLp2uauNmmtPxSbSOSo6H/YoF6iaVDdusEFw3XmMh6Xm7TklX AX4L8JO67Qjq15Fu0ff2MRCHdEJpDFlYNWKTSKpsfyuK1WnbnsfO+w6eEtAYySBo Asjqdb26SLhTnd2y6mh4hQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41fhwkajc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:28 +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 486K1VjF018007 for ; Fri, 6 Sep 2024 21:12:27 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41fhyhf42q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2024 21:12:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KjMteMv8FRM1G+lfnBeOkzJqO21AoFWpNfGj5tDbQGzyp5sppnK+SsBREFF1C6qkD/AsJNjo69RTla/wcKxDBNpaumJL6UBBLb5zMffuaA6Qb/wcy1woRtWnr6hnYrD1qsJW4r3sbrCxDq0FTy7Q32lGcReF2//8v5FGdFXOGKsxCbGU7ASk2w0pThI7oqzhZ03Za9xkR+IScDzV54mZ6dvtGoh7HO8SrXdb/BTr1894xSw4+PygmAUr+lki3otyfJ0kK3Zhvmtr5i5Lyh5AYzl2CJhrV1OSRXgiNwypRdST2qVAt8xxheWGW5CmMOARXX8OL8MIeZ5YAA52MCH0UA== 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=evKcOv+6Qp/Niv2wKcPN4j9qJ3CTnZ+LcLZCqWEjlk4=; b=TwWjUle2v7K6A76NSG08sytkRJkiEV2MO6vxVdjQqBaIxICVk5t7Mk6LJH4ypNTmGjWRug65oY5flm0CiBGydDJ7Tj+thcTkMgqKUdC8D/337/149fIX8jMTkQpuFz7/VoshXSGAxL1fopx2u8/zX8K9gCFAWlAKNkwb9zSZfrfoS0aCb4HBoIUIc5LFr07NqE0Sm8EJo9ol7YMck2RtMSzer8I8DuFz9fhgkTqrlhlPHpFzEjSHyEkRMtgYq5aKf2Hh8gxVtzgVCF5xeZvx99TA8uq7mqB14S0SpAd8rXHq3HDHGBI0RqpONkosK2vqAB46zcByfcmg9u5EeirRHw== 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=evKcOv+6Qp/Niv2wKcPN4j9qJ3CTnZ+LcLZCqWEjlk4=; b=nxDsttIt8/ODs6ubS/2oTagRNDO8cenOd3VWlTTtP1QE+7TBtgbf1PUBECr8w33TF+kd1VoHcLAkj7AdBrxxn0Kc0RcUV3ETn8zjlvBmqOwIMXPQyC4IZDD0NiOqSSIE5JCJ3gsersNZD3+en6z1u3VydFaycBAdXlZQ57VqsJc= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CO6PR10MB5587.namprd10.prod.outlook.com (2603:10b6:303:146::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.9; Fri, 6 Sep 2024 21:12:24 +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.7939.010; Fri, 6 Sep 2024 21:12:24 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE 22/22] xfs: allow unlinked symlinks and dirs with zero size Date: Fri, 6 Sep 2024 14:11:36 -0700 Message-Id: <20240906211136.70391-23-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240906211136.70391-1-catherine.hoang@oracle.com> References: <20240906211136.70391-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0029.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|CO6PR10MB5587:EE_ X-MS-Office365-Filtering-Correlation-Id: 7af1ed50-b8f1-418f-3bd4-08dcceb89ad2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 8kiuhPjeKvcGVSs2GMOhS8TqEExvIMeXG78YhkWZQs+TQ1UbNh7TsdCPuT6NRODT4fYZn7t0m1Rph6yQxCEzI8/YaDT2IBAJ3Aj8dnrlnX29PjR58HZMBHOruI3HIhhoeagTC27A7joEj2LYcCgESTHvVqvOoD7Y98mXCiz+PMlAMgYnVFElH0BE363XwDUKQOR+RoZC/UwEddJAWAHp2n3wuMVCRMm+gfb8la3IOEkUiczSoR9Syo0I3eCDmUO5R6L94UwaVFdEd3PrnnjGvzHv1MrVWNee5ymSRpd38vb27Zot5QtbDYPcdROCTWBEYqbYBjxMrsn/dSx2oY17CcjkDSfAZqmDiQmDqZycooyjUHYM26PZccXxALQ3//j79zs1LVHeUDSuc7uBTNsd2nTDKpcwtWn5gY9Hz+K3fPOqbaJV3d7YbQUAR2c4q5F00ZBzYD+ciV3iwxFuKmeiSvsmzDkrkjmR42PlvmsH210erIrhyuKmTE0KVp0Dv3g0Gp3TG0ipcRRQG5Hdr9Yqh8l/LcLLjU7S7KFFqrSrjFem2Zcw27OC6aza3NsFhtZ7RLsMLSYLUXL95QjLgtXMozO43jp8md6ohwKkb3oFbCl8sdrHUc7rahLTvM5RZYX7sEjocsRVWI1sZM+9LGcoshsvyGsJgodR3JntOoogOqMl+VQ9WxylWb2vy6vzukTEqmemtxAWR4tbNnRUxYlDAvVLJTmpipaUcIhdzNxEIFypqlR0FYzPg+c/F3kr/hcLQ24oScNgdHr759kLYUhA7ZJ7TNOa5i7SgBJ0njfWEUZHiLl/eYMkcUE6P9/LlCuoFNIyapn/IfOjmqP8fSM0U72e1vC/92MWPdZAqaUD7dR7mdMzVvduWnHskrvlLNhjYWRI3fw7dAcN/wQfg4Zi95INr8flWpqXv3YbmViAshvGZzFgBSiPjkj2/1Addl9fOENnmCDWQAjwRvGefDxs/p8P5zcKsRo8I5Tsmp5azZ03B1dFyQdO+aKG0s6AJso13y9aD8GUvayWDZCWW/yjfzJXX1/PGoyOfNWm0yiuL/NvmDV8Db3u1rGMAxkPKwKrNkCG5y2g62OFUKwlYZVBn6AeAnyO22iV/CGJrfLQr5PW1nH4LU86W7u6b5S+3WTF/17vkxGoChMgDcALszRlwZw1HbwCajqQq7ReOdjaQD4u6mUB+KJPsYGzv/4qoIeWflEiudMLfX1P9k5h6rZai1/g/md6ajUhMz1uXKS7t8ZQIgle7S7YqrtQznm+19n1dlPYNqtLudG5q+AJ4Vahxtegq2mZswItBjgjAOZDjCQA0BIvksVZUibbabGHILGcFy1Qe5VKkKv0+EBUi5n6Kw== 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iKA7bufyRUy7dkV230A0w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NGhfsozxL1Ge/H3L877zm7UwiJZAwxRX3K4Jv9eQYy+w9A4cb/AaB2uNvKN2wk7Lmdoeh+gUXyI/gcZjUayown/VVpJjvL0OXO/hJ1t70rVU8K1L2sjqQLi4uYdZqSlrADPinb6n4GkCjiSmJE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7af1ed50-b8f1-418f-3bd4-08dcceb89ad2 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 21:12:24.7719 (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: T7Qfx7cOupSHluHyFLoXQQ6sYR9TzjO8LKFsW96/oZlsDVPb9aYYgwqhGUXR2kTZwkf4BJhQEugqxDteejEg8c9ks0KsiVcxmOcJH0PSEKM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5587 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_06,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409060157 X-Proofpoint-GUID: zzBQGJjnNU-WnxSunKGYt5PPURoC_cN7 X-Proofpoint-ORIG-GUID: zzBQGJjnNU-WnxSunKGYt5PPURoC_cN7 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 --- 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)