From patchwork Wed Oct 2 17:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820174 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 977DD1D1752 for ; Wed, 2 Oct 2024 17:41:39 +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=1727890901; cv=fail; b=j6lA/pFdblKVn3TVxmMIGVzr6cppWJ/Nx6poLv/G+scpCF5kqSODyLeIROHc2oeuNNr5HbIRqQgm6wuwLhQWVeZEInq4iYei5Y1eh/egO9PhiLF+cZbJDcE+1ZKfF+zJDVxzOBwuFsTjS0NaH3Zscm/Kc5cBohwivj+C+QA/2nI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890901; c=relaxed/simple; bh=X2DnA7ZC+DoRx60TbIiXRACpsYI11z5HLsh3cqWuPc8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aiiYRyJT6gzap03U05aLM6sjvamZTdH5OwFJFAoszIbD7w6REI13W1o0ybvzZoXdsW8ObEb37yQI1kniZy3Gn7/01pfaW6CSceoOanEPkjlOaoTO/qQmGyTFl5N+9tZeQMAt6QOhsu75LUjF/e7yh+UBfN0h21pbWSM9LXBcTSI= 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=Q9CU5IdI; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Q5YEC+31; 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="Q9CU5IdI"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Q5YEC+31" 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 492HfbnD027433 for ; Wed, 2 Oct 2024 17:41:38 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= Q9CU5IdICEHqwmy4AY0FzYJIzmQn0zkZZzoRbgNwsJ8B0lEb+aqutOvMdAv40JBP dve/v/WZ6kIm9CSxG1ciZ/flWJ+fr1NYs6buO503/yyhP3huywpxFy0su7adqOtG FFG342awpxALqfd6FiyEWNi6wYCzacqMZYWciJshV77wi0rpbx/nffTcgj1HGDdO 4zUMwvvYTjCnhT+Mu5Kub1JhWL4HH1L2CWnwapcsVsB6oMavNua9Ukd2y4qDzfyK HHQFrsNwua3m6sDMN5PCrChCUik2ofiv6JZtXM/dqWlPP0nLvBT3H5xn/VVqpLBF zxWhkOpDzL2jP1ZlPpmkVw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87da9dy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 492H0V4I028390 for ; Wed, 2 Oct 2024 17:41:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d3wh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q2vfkcUJ8yjkQvsV6YOVUJp0NTUudyEumWRV7a16XwrcA7gPtFtHT2LJXmHTVjS9MH7V9lDXb+V2I72fKgqPQRCGd1jhnc2jE2tZJkOQWGBI+0lhl0j3FXwmIinJ+HYrPLPHiJmMEVLD94XXcmpduxkQ/AG17+NXhavuvbdMdq+xyraF62YFBjiZ0demcDY6uaZT2UtQVxc1cMsYjexV3l7OhU8ixE+UBGlWGcsoVTAuiKKSO2eV8g8O6Cek/+qhJSyeEMr9SGcVvjwcju9oHwsbffq82/lEg4QkVuTdevH1O3OirZ1qLY7kVzMmWll1wh8Y8HU6DoOE4xf4ntyJbw== 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=CJdDxl7lBgb7fhWBKojOJkyYON2pNDLsRrE6mW8fPKSFkdskA2TdZhihA/tSZS2m499VNmUQday1LcyKB+7utgxNxBkAzF++ccTe53hp1hJPAJFvQ1KygNm1Cu85als24//oCTlrgaZjvFsqQgO0XLmpZDCIdEOO75BWp7pdPC60xDV/5yFrHZ2xaSPaX3ZutRep0N7tenzefns+6Atze9E5JnPd7ds8yDx7T782GJtt4aRqypkKWewIMnY2tY5iShL5fGbqfU1n5B5PSJPnad7QwWVluiWEBI1GH32JJ8gWHAdDYJw/+fGdeDbusLnyFPTC1XW6EWzTB9OT4vu/vg== 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=Q5YEC+31F24c1CavSGZzNkSNR8keLVW5dknKt0gTEW7UPm02ZAiCHvhhctY1nY3gFr0NISkqTohbFG0eLn6ujeKigriIec6GH92nHM+Kb5WKwx3ns8kzJ48RJQ8kxAeb3Rsx5vM6LSBCeuVksRNSMv8DE1zNF72m3xZtUW7AFQc= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:15 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 01/21] xfs: fix error returns from xfs_bmapi_write Date: Wed, 2 Oct 2024 10:40:48 -0700 Message-Id: <20241002174108.64615-2-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0003.namprd08.prod.outlook.com (2603:10b6:a03:100::16) 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_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 98bdc83d-6517-4386-fbe2-08dce30969f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HwfCSt7x3mY8Ea8I1G6NlKeWPGeERKH?= =?utf-8?q?g482V1nGUH210gfx22R1rKyzxqA3ruj1xAwqpASgRXeCRoNC9kAlLEPVBGZ7y3UIj?= =?utf-8?q?rzulBbBhW8e6Y/IOYL/7xq6LHaXoSypg0i5Y5rrieJLkuHg9tAhSRwJh5UcaT/fqC?= =?utf-8?q?T3V4PrxK8jU6apYgLN0AfHN6E9k+ml6fYAIV0zVOCcwY4CB6Fve+N6WdxUh6nGSww?= =?utf-8?q?xoZ3CmNAt77bImp7fHI4Jml64bgoTrZhpYDESVBMhVDHENLef9D+jShZjFvO4AK3W?= =?utf-8?q?skapo7XOT4FLo4j/eA8ejO5ZmAh69bCGCgwIKhfOv6TI2vHWgNhvHezG6MaZ6XMiO?= =?utf-8?q?LNgDj1DwT2xkpp9e5BP0bFJm66dQTjUWufDH+S5o2IalsblaVUbYRGT0ukmw7W40q?=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forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xhI5Q8tg5SuJKRgZfxgG4dAtxDMk?= =?utf-8?q?R+ioZvk0b5bpYIrVrkO5dRdmm2vCDnB+lHm4RN0aGDuTnVkjK5bcnd+28rVR5vBZ2?= =?utf-8?q?sZQggoBfEZiAvNuWvKLJ922lYiwD0MmV2Q2BFZohFaULnNHig6ywH6IpBvJ0DTTQJ?= =?utf-8?q?WzbHgStHs/6shGxIUHmepIfPUIixQg+oYrwaPtHu/EZh7W5GT4ags6AOKehSOlJqd?= =?utf-8?q?A/GLbCAtn6YF9a+Z3OWVopcZUyhOcG/ger6/ln0JkcLUllMG7l7E0ZztdEBUuQ+gv?= =?utf-8?q?33JMtsCoyB2N1tLYABEmXaQLBH3/5fzkBsmnSOypkGMbPnFV/qLYWeYwt1Row7RUS?= =?utf-8?q?Qa7rCy69f8P7Vb54k5L8Mvg4Md3e0BCd8BSDBWlgbfMfrxGZxbq7oCcVTvsvtOC2n?= =?utf-8?q?q5v47zXRFcjNcqs0gffRA4fLwU/CpTMuMuZsh/p/mauXodDxnjwZBPhWIdLPn9civ?= =?utf-8?q?qS8X8/yxTcG6gvqSq4TVIpCgTMXlJWygL2xT/cNeau90WDtMXdijHkkJD56Z7fgKq?= =?utf-8?q?0VUJft6RF8NpFY5KVqH7KEsMznjycTk8B6b4MHUVGkES6MoMDvK60aY3NXnh+Xzv9?= =?utf-8?q?ki9Tyx8UlwBVvu05EAL/OOO/iV+qKVQnKX7DBggesX+ogtb4EGTDYgqtdI8XDZzer?= =?utf-8?q?CEoYBAXECojLGReUaCyPXeM3fSP4glomJk/PU+be1RGx3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rqA28GQ5cOTmLGR44L3nzxSmseLC?= =?utf-8?q?6eLMQN+BqT6um+GiTYzFrQ74GRpjNV1FQ=3D=3D?= X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PuAueHtsfXZhCaXSZy6GZl+cU46VN/mSLS+n5O96LDQMPNmExjftOa4FQZFKjFc+lVk3pjA+akXf+0jdhQ+vhvBG2xVpylUO+d2ZBa1DEz9vrZwK0XI3egd9+Hzn0G4mXuzpbil5Soya4ZgOjL3ipGuzdNFs2oD2DIeZ+dLBBlcRrpessO9aYdYo2pXLD11dlMFsMoAU7clGUD9ckZMeaAK2FheMRYP5ChnUqETvgY9vit7nVH71GY3suhUFZiKAB+YFnu6g1gswEHospCxeYaDSUwv26obi5jhkCbTEK2WWvgutc2OZCVRNT5MF2h/RUWWtQwxF/0T1k+agFnF3vVM9OakXlLCYPQ6RxcRirhl6k2HmXUX4xGfR4i+E85xbzHgQYzHsJZ/7WMi/2rriHT4TKwgpv6+L2IHLjkrUqRCCeRAzp5KmMU1nBq0h53hhXi2wpPWlrV7GzPlBGCrMEzagMk3C5IU3R792fNYsZ792V7/fOKPt7I6Ek55QxBRjjVHRJRlmvno7O6Pu9AUeMOV+5A7yHGBP/D0DBVr7JfYD7yguGykV29M2d5dPMf/MqxX/dsynpEMm1h6BDpKKWhp9cntiVEsHkWP/3amTPFs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98bdc83d-6517-4386-fbe2-08dce30969f6 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:15.3582 (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: 47vbyuDUsssK7jKWk+YWzHcbVC49QuF/QC1F9DeLDbhm0PQG03dnyabbkaqTLS9OPR6Y/sufKfF3CJxv9EJLnkkB7TRgSnDK5WhXB6A24/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: eXRO75csbwJe3mOX-hUbZcsxPNPh9S9U X-Proofpoint-ORIG-GUID: eXRO75csbwJe3mOX-hUbZcsxPNPh9S9U 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 Wed Oct 2 17:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820172 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 959841D1751 for ; Wed, 2 Oct 2024 17:41:39 +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=1727890901; cv=fail; b=kC2UfALxxysXadD90xbeQ340BahD0/gF2iQ7VSdY6Eg2DLvAfjJFUgdK0/brZaJR5BCFo4sFcUF6Zchxty1d3TCCk48uUQ+EtHhvb4IrTI0QlJpwvpKYi2JI0k6cJ1+lfM9h3NPlHSlsZbkOm3uuHocsf3CgapaSBECEIqPVF48= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890901; c=relaxed/simple; bh=xEtIUHQjOLDvesOD/Kk2rAj/tWg0GheOV0XvuWh9EnA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Pf5Zj1j3E7F3D3lE7/wVJT76Ci6Wujb+UDbUSOLd2ACsUrm/92MHZvHEDlRYlQcGOrZQA1wkNo+q2MZNB9Ok+2nZnYONAzhqQZ3ZiBdjAlWw6gwwdbwB0PvB3DL4dOgH2CJ5qU5lVb2S/3gIIcpMW/xQj4PEDhEPeSlUUbTxioM= 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=Z4SYUd4R; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=patOKyD8; 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="Z4SYUd4R"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="patOKyD8" 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 492Hfb5d030327 for ; Wed, 2 Oct 2024 17:41:38 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=h+KSSixwFXpOhmJfj5g+CRkOuvuGK4Y4L+TaHrWOv64=; b= Z4SYUd4ROfFPZHtBNeKuLRbGk/FvZ6OT/oqHmEE5x3IZGrVAeX6W2Z4AzdrLb7Xd fQ0BQzDE81NK8WKlMWwzg0mUAqi7JlCP8FWJL+CABTy30spDjcJiDdfN6ucdHszw P2/ob2YQkHV0ZRC7UseOkk9J6G59t6X/NFM8m7HcnWyvh0zUyixjAGdCLwzH42UO 6Mn8iYV6E4uTMH4NWp+NQR93nXr30L5Po9GsZ4C9LAmlND+JnJtpjc6TFchcaF/1 lYmX/YqliAdZ0CsK0tEHT/sE4Op8GK3YYpFV2s7D4M1IgWjaV73CjCVlNBTPTwmw 0NYm9BnfTK8u8JtZAqVu9A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8k3aear-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +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 492H6NYV040603 for ; Wed, 2 Oct 2024 17:41:19 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2044.outbound.protection.outlook.com [104.47.73.44]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889565e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cdL1zzsMUXoD3RvwiqWUwbLL5CGG/bHrN20EkyvXNK57P3OoyIUIXxalqhaAkaI9IFX+TF8JcWxodzfDtu56nwmHq0+GkIvY1QE728JNa5lcE4IHIvYzY0JYwj0GlOFD+PA6d+WGy9oG1N9aEuQJxRPdrLRLMqJLI+aPGa0ucZnCJAze2gz5FJLQbIk7G+/5q9kR8Ay7ZNUFpy8xjdyxaP96KkRwhv9koWAM7kKwNOt3XezDLIIgZ/z3vdFz+v/JSibvoaHvdgksS2SRaFRcte0cNn3RCtgqJuDJ3xFHa9r1fR78cI6NJzBaLT7OugCpCWS7AUAhcaTiWM1HR8TXXg== 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=h+KSSixwFXpOhmJfj5g+CRkOuvuGK4Y4L+TaHrWOv64=; b=zL/PDu5oChdJdDqxUHzVyJX8B+FnRk0nWWJ+n/LWGTFbGLtJcKKbCbXzdUzfP+e/7P4os9+snMwWYxooM85F6IeOFB5aVRUn6NA/KjjP8+3+MI8UrcFot6zotEBa9t9xbUV1ZxNoAw9phx6wrRCkOJyifHJc0Pq8ViU9tWvy6pbSb45JF0iLZKJ4G3qQOqgYyH16fpTZRCyS2lU8nCtcB9fMPiQ2mf9ij/y/YCb4V/qQw0JVxBLxThZj6OZSTsDLTorYBDCZ87Pg++lEWRmpelg/niHFRl+9ZgDP5wRtlRaZ37n6wvmMZnGqcJlmmg9NPY8/cDF9GSWOdfMWBOw4JA== 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=h+KSSixwFXpOhmJfj5g+CRkOuvuGK4Y4L+TaHrWOv64=; b=patOKyD8acuO2TxQZh01naO+9d8CcRJFAZFJqwtPCZPmuIV/+rAj9GPMH5rHS7Z261NFe9jqwzAmP/xrPQUAaWbY7qjQx0hUkQ3aAjRGtwSYBN5lH1FnNyKYUcQbEqgDQ60R7l9PIhJTmqEgL+RodS1R2QeyDbup/0aZZWKu1tI= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:17 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 02/21] xfs: fix xfs_bmap_add_extent_delay_real for partial conversions Date: Wed, 2 Oct 2024 10:40:49 -0700 Message-Id: <20241002174108.64615-3-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0031.namprd08.prod.outlook.com (2603:10b6:a03:100::44) 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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 3253df93-9258-4bb8-fa05-08dce3096af0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: 6pmjyQbIsvNxWcmCey8uPCG6fs/xUPsJPmTnEuUGch0gHs/3b8T+ZrB1rM+urUW5qe1CpxRXS+CR4abxkcyB+BwLEi/uJ8kFlkdlFYDSD1TtI//UMQFHptsmFserc3p9rHf2L5gK5jdpARUSlSVLwRPHw6yTKImEXwNlEYfqofGtqF97O4EbCxaiaZ6uI+K2dJyuaVTXPDHWlCQo2tjtaXm0L+PjvUOJ5RTUMC1H+HskLttBmt058Ev3MM5yWTH9zTriOsN6cK0u//L/t0X0KVfW815a91dOt1ladtZk4mAfu9CrC4akWMeNLPY2tOOgM5sgL5e8yyYQtwz73sQHQiRejTv4sJPqxHtuSKWEtc/2Rg4dLTW8V1akEzL/UFYB9MtcPxkINI1qeFcEPTAPmeC8Tzp+2IAf37nR77wWiHYJR/mXFWObeF+wvufa8gA1PBvZ43uYtNKtUSi6kf/g2G7OZg9vO/O/1oyAmzEJ6pwD3Y9jFlf6JYv0y2y34K/6w/7Nl4kHSbeB7NX3FJEU77MZ6LgVOctQo9xqTw+k3hwL+IE8o5afOkNsUKLzH0/rw1xocx5Sj5N9YaQOMLzepuHtPJ7f2sXQjrfbSyvL7qXxBjuEvjhnl2V3IHScx22YECfPurcZwR3aiiSWFMCtGWCgSdU7a/07PxntCTN7fvdoLSaZCh932Ker1T9+PcrEPxTCRb991x8rIVdHZcZWNaqD+TZT4WbTGyhxUuh28rL58B/aUFFBtTNZyARPMIrrWlhOrRCzQ1/KBkVmcvFOtpqwEl4YJLN75w8blIGJvgdtZxqisynRde9XXIAcZ0ObnaVNPpkZcQRD47RJgsN5iVhB/HCnp/tGit3KOSapHJIe9m/9wHccH5OGjIfiJdp4sogBNwIEdud8DdT9mRHoY6KNeKBqnF44gTQcUDiWIQUq0WJOw4AFIBjEeghKB4GL20x6Rub9g8KFtT9LMySp0ECsBrdkLXpt5KDE7NEnezMt6cKEaCr++YR2vzb0s61dW8Rrfqs/90wspCenJUuCsGWjKTIqZdwVaNJmAvXzqoWHoFC7OeJKarA94ndJkTYKg3SyQ20D5H/2quOLfgHZL9cmjqDkm/ZEvbTaJoihtsdj8GEroKXdW0AZr/SG8v3AWneKuGGfqhHFnx1mHQu7uiAYQEOzlBtddZzNLieNZV4jnAXFDK3qe4ayOviHXY60tqHI/cKxB84oCXWYVIIMvH8w2z94bD2sSMEtXzpLGTN5EIqLBjX1q0IXNpu66P7rPlWsCbvGp+PepX7AlYFBBg== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vymWIroQt2PSDGT/4jAAWAyq6uDpjg5L22NI6mUy+wiuY6DsZ1/egpZs7bGRB9buVRDjUZQ4sc9G+g3Ho+gBLDjRz3iy8N3OLCCFNvbfRqBlFzBDfH7FWXuhu9kUZgwcv6cuSotrMhhmyGotjPmYgQTPukoWPzxNP/K0SrFH3PYI7ihzRSlOchMjj0gPPkJL4TbE9DpcfyJPKWBGYUIV4dKQNpuSiWEmACGY4jB0Mw2Zjc0zJ9nrYyhbZG6zoauB/UhbeD9ji9/AkFSLuiUnoycZhQ7ZSE1Fn1k7ffwOcaraGMtwtojBU+RS4UCh43cNwlsuHvAMg05qRH8N5c83FSXv77nJkfwZJh4PsQ1D06w/0EvCVNFAQ5JmBIOd8K7AXM9Cd2xXqlLv+GBkR3GLQ6DC0ppwROU/8XOQs+vTtOHqjJvIdAd4ZsoXBlnfPPQ/GViQMJrPBDjz4YrkVG/Q7weTZozd3N2s9hBq2oiYyI7+DF+Vh4+l85NnDUOyK5QK+hbHsisUlkYYQ2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90sOzm1baeAr3PW4sRETN1X0EykBYoF4JiuRq2YzvtDZmGOHIlE2LAmh60emEmL1RLaqc3rlXOytA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /vg/2hc/co4RsjxD2CKpzVlTZPU2IfmsbpJR23HrP17k7Wim1bfDkFtbliOC/duEuxR0YmK4W1KI7JH7aKrwd4oDrJ8KRZ9xjFp/p4RHc85rBI+TKiGCgHRG02qBFWqDxBEzsSj7ufVPmPgz+h9r2TdwKVmHxcZ/5ZkCritCjMvnTFuWNIHxPToF5mtPTR4/XlibyVfSO6jF6i0jY3o2WuptXFkluaA5luWZDKagg3a3OiW7pnXDiWivVexkWrrfQxvgeJ4B7kq20PDa6ZBADLDoGtCsCTiqkBkd/vor9bTuDAFLXwy8cX4UbzOKAjI3ogeoOiIY46zCQeHa5mJ1CKtz00CjOSHdxu+qqXIre2TnRbufI2tHSYRWrrIkRKLX+d8yJL+knChT924OWzuGQm7yoz6YvZoJnY9cT6EfNC5lr7H6mPzHfP/R+WmIVhWMX95Dy6KNxkGwuG5l9Yf1cCbzPPeBxPybxa2eTS2qyNdGU73ePZlVlfJmu3EKPEe7xrlu5ljtVB7QmZLk0UBkoe78HneRpqt198TEaUxn/nb9dDtTAw7lvCS7hBGoTV3buw5bhhziUCKfUyKf5iatsbqWcn4i5CX6zmF2jIwTfIU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3253df93-9258-4bb8-fa05-08dce3096af0 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:16.9778 (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: QgHMjS8Tva0BA5S2AccLR1o4QQHrjr2eGyx3fvd540HT1w/U8uxhtk8dA/IsGoiVA4kMTWS+sZoeBG0NWiuSMUhptOZ7Mg+hlmHFQx/MZIo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: zyhKuaZJEeJ23dRyOGaTOb-UKGIrhw3F X-Proofpoint-ORIG-GUID: zyhKuaZJEeJ23dRyOGaTOb-UKGIrhw3F 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 97f575e21f86..18429b7f7811 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1549,6 +1549,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: @@ -1578,6 +1579,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: @@ -1611,6 +1613,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: @@ -1643,6 +1646,7 @@ xfs_bmap_add_extent_delay_real( goto done; } } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: @@ -1680,6 +1684,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING: @@ -1767,6 +1772,7 @@ xfs_bmap_add_extent_delay_real( xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); xfs_iext_next(ifp, &bma->icur); xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); + ASSERT(da_new <= da_old); break; case BMAP_RIGHT_FILLING: @@ -1814,6 +1820,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_blockcount = temp; xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); xfs_iext_next(ifp, &bma->icur); + ASSERT(da_new <= da_old); break; case 0: @@ -1934,11 +1941,9 @@ xfs_bmap_add_extent_delay_real( } /* adjust for changes in reserved delayed indirect blocks */ - if (da_new != da_old) { - ASSERT(state == 0 || da_new < da_old); + if (da_new != da_old) error = xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), - false); - } + true); xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); done: From patchwork Wed Oct 2 17:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820171 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 3BCCC1D174F for ; Wed, 2 Oct 2024 17:41:39 +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=1727890901; cv=fail; b=VECWlVCwcbx1hOLlIBkzVRkPHMte/BMN/Ux/UjQU/yV+OiaplvkbMmwuesTCyyB9GUZunDn0Mzn2PyrllA2bOM1nhy5n856m/6ujvaJoPDbXi4uhCt9IYJ1I4x0Yt93rfdHenI7btnqQ2fueWTJT0cpYQXaITz8WLCF/gIthe4k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890901; c=relaxed/simple; bh=KSjrrTGrhQiHnnlmkki1cmNpGsCdMSYJQT7e8zwxjNg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mbEZ9DZXrpQ1bIVW1UOknq4oq7xwGRX/qUF1ka4TZ0n8NDbXlGV+YdCZc9XlPGkZ2XGuKvtS0xikojf87QjU7JY+R3wkj4AX2vOzyTklBqbVkESMDbnH8IzHFksV3B912Y85QdAtAQmK3SZQmQntpNxdx24txYC2ZVP92ny1E2I= 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=cAs+G+ni; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=UJbt3rhw; 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="cAs+G+ni"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="UJbt3rhw" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492HfcNX025762 for ; Wed, 2 Oct 2024 17:41:38 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= cAs+G+niDvlmNvgjl3UJDbrVUfec4H9x3K94woXsOYby06rcNTv8XrUZIbi5Pdtg FD9gbhTnB8L18rVp8UZQsT51v4h3UWqX8OmDN+4ZVhTYrqZUbYPPbCdo/eYJ1oLj Bpu9eOhkd27/8o/vX2YE3ToDWQ8sJcgK9ElyPpK8Zch0s9V25W2CZtHev5EaH89m D5/DhbC2TDwh7f8U+hquaHo2C+kHTeS99ZNoOd5RYnJ/9kp7AvWB3kpSUpTb33EM 5Tkr+yxQNuZr33TfjkpzU2E81xVbd9KbJknRgr+BG6q8GQuoafI09Qzcdxhpgiiu 4PHGoX0jL6HHmnBoSssQgg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8qba83x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:38 +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 492GFKLT026202 for ; Wed, 2 Oct 2024 17:41:20 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2047.outbound.protection.outlook.com [104.47.73.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x8897f90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PFdwsk0nl18qaRVIZONdkk3FSQ7CiWCapDLcios53i08PVypGEO16XaEfwuPqK3WZ2KPI6aigZtYtojeHwYzubQXAAayCdungRkioqPskMXcPrVHEIV0YsLCgchn745A5WCi4f1KjtHd8zE1hXjfClzbbKQipbZ3UK8bMZytx2T+jWdwpsK2Wxxe1QKFkJ47QTfBRQNPktHsyF36B+iuh70OYUDfTVmfj1BoEEHgSJjclUDGt9bXInRTnz+8tnubheOOap+tY4S+TuxGTDt5yDAo6u2VqaZkvNiXJ9jWjopD5/famhbYnER4QlDZmHPgunhwbnqPd6X/joUAbAgheg== 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=bpSbwnPa8WuxupwwbYiZLUvJwvPZ3aFIi5TQV/kMlBpupGQbwaeGQrcwEPYjZBVS56NizRccWZ0wtXGASTxUn08FCoEzVth5rsyIKgnY5ilHbbtOSDPfma8KE00UjguQEtgq2ZFoox2qBGerqESYFPLcdd1udmDEuqL5e5ghGxX8bulGCt+M4rYKz/OP3ZcCSkVIybxuhgTf2t2toZGSBfOgoO5WK/zpIWCH9RENIBiQB00dkdT0Dwolt95/2uWYkRUEV/qqtqeCbC6nAyI4TZgYokL9MXO1k/TYSIAb9fPRfqfFB5UQUjv/2A2MYLbTmwjFT529R6sFPep5/mdA4A== 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=UJbt3rhww8CD3qJANNWwN8ptGRVilKN5Wn9xgrvD0bs4fo95R7928V0fjWVRcI/1X+oNvqwPqciFQso/fFq7IuaF1iU6oOsCWSaysov13NvnKhhJ1WpmGmibfEnkaGW1tHzePhkk3jGvVfousgyMGsyO8fodjPHmztmv+iYLNM0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:18 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 03/21] xfs: remove a racy if_bytes check in xfs_reflink_end_cow_extent Date: Wed, 2 Oct 2024 10:40:50 -0700 Message-Id: <20241002174108.64615-4-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0026.namprd08.prod.outlook.com (2603:10b6:a03:100::39) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 09dec03c-246c-40e2-cc47-08dce3096c1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: m5s6Z0umMplyFu0bboV205uKNxkdnpfzzjdAmkZ9YbB8uq3VHg8kPvz7O3/8Oh8HoS36EGVoeTUCPCDuO0cdQhF5kK0wysj8lYXGQ2U6KNO7aI5kuZgO+BqzmBKC5HwnY8C5mrRKTrPGuRWQXZ4oOGz/OtZRL6IJ9NipRv2gAlD3/kStrj3+UN8xe5hcmWd+XaS2oieM84S0bMWX5K3XkT2h2h3/3nWLJcFgJLEqA9YXQDlsWS5+A9T0qMX/1zXMPFnWjmcB6fasVyJ17yRH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;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y5oQ+nOcYGk2NwZaebgpbxyjA0j/8q5rSyb4um5Nvhytz08VrCTnajq1bvjdNvkQn3DTnZnhuwkUZ2Ca7BYUjXNQasnz6k5+lAbnZaNP/oru4sZNumilJ8CWZ2e9awl1ZGTvsS5dG3PktjVj6TaHqLX0l3cEig5DvjL1HhCWIatR4BfDSHcG/jGDKnHYK9jhK5cExb28Pn13Q2BQEMiGfVSI+P1y3x1vME2iMNcUpjiF6YgdEUyGnHV4SPbTmDeGao7S2/8NVa/FLuqjatBPM2Js0G782j8IkuUpdTuUMQ/vkRBhhh8/x0vYA93bwB6rQ5e0CNmLJgjnLIlvIUulKUfvIM0UTxSs4iHb0Hbrf6oKc0ZBqJsiumpsue5UlXmrmaXu/ZuLD+wVACK4Qsiwbpe1D+vRCNfm2Hqlsauf3PYrG+NFR/UzvHgpQT8i7mIy5kGdZKR0lXZBgj8qhetxVeCFWcM3YMnfeIzoZChQvXEPOmRM6un1oPM6KUY3JI3GNkjxlilbXMS1Kob19UeusJQJCChj6oPDFWlhNsvCnjOGBmW7s644huWI59zjBmS1976FVhkCDCYHBkq2sDMrDNl+4KiAro/m/qTY63WWMQaiIo02DJPl2wfNlaYCaQv509VZ1/8afhnruglKkdBRzTUtzYcEtEr7EwmOgIf75WGOUnjafnbzKbRi/fPuGKp8l7UQggPiM14LYdQibtLTOJU7232Vhts+0gxKYnaxIbN08LhMXYO2M67te+9vI/A1IFJdJNykQ3nW1ndW7cXluTFwwDAsuEsJ722QfAXPMJSQ7LQAk+q8J7WU+I14UETye05YtCBb1fXPF7LFt9MZgypSDyDzHbvJ9BZT0tQL8vqCSW5Uu2UEilHWK3KqrI9wW6B4orG9hrWswCWDW5AEBcqWZU0oObcLUmf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0+piEPfz/A+dM3UFGxp8oRY5rAnuN8RK+PZYvLhQN+ASmI4DMkYjuT3Bnn9B8A9NKKQ4F54+VWRjl3SAK6LfeHR9fWV9RwzA0IGDNLv2NQpBkLDXR+Jhc0lEVPPKp25ZtlgkpLOaBz7NvwxotMn2GCtRR8ULch5ItDf3ggYcr1Ci3nj/NDCjPkDP5jGbRTula8hB6oQen/VX+QofgpbzZiiRnDMs2Ws1YtWg6JrZOCz1Zs/KAZNkQT5qgKDvrQZLwh00luLm3ntgRPNmwnLQwCjZoska08ZJ82fVjEwNUqpBfCka3RpB/XfZ++qV/ILT2B5QxuOGFriTqOj59XnwCyFR9VdaesB2ykA5Pdk2lG6hz0DbbsCoar+O3A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09dec03c-246c-40e2-cc47-08dce3096c1f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:18.8776 (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: 2wZEA6c02gWjtehDxk5cEr0NysQpSHbk+JNKzIgMNrSgUuBl6xz+gsLKA3RSO1b1XMn1ueEhhXZH8uUEhW8FcA496BYqJprOGfKz/BQ3TOg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: UO_MchnrbKDSNIQ63e_wOPoA370uXTpi X-Proofpoint-ORIG-GUID: UO_MchnrbKDSNIQ63e_wOPoA370uXTpi 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 Wed Oct 2 17:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820168 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 0E2ED1D1743 for ; Wed, 2 Oct 2024 17:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; cv=fail; b=aLQvfd6ftuGzZKFQxUb8otGG7ddWZ7HCPdbwfIUfg0In47sxxJPP+/XooRRoOVVANguXr2k7ChN5/zfthPclv/lKT2Tewn+xOMlbEMYPg6IOHGTCexXZb/bCp/Ikn2UN7J+tH1k9XNEcAsYbA/mPPd/ITDmhKkhwwyWsD6rv0UY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; 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=kNmGQcTOsENh8UtPRjL37UFB8YIbTfufdkR4UvmDfPVa+nQ2FTpSwlp04scmKFrbXymSMSoWiGw2CPdzDXRkK7OfUEaZa1Bh3busNmIUkUOIT43diCG+QQClyTbBexIccG5S+vthwxTC/XqnvFRDdFicUZMP5fxl3rbQPV+Y2dw= 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=nzfPg3xE; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=S4KN+qQE; 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="nzfPg3xE"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="S4KN+qQE" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492HfbMo025722 for ; Wed, 2 Oct 2024 17:41:38 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= nzfPg3xEEJQ601Z3+z5AbEv7N7JmBv3Yq+dR1Wf3Bz0Sr35ZFy1gb8vTbG1+gkyc wT1dqtrwwKAW+CJoD3A42Uc4n0HUdnTB9kIsK6fzfC0mJCDaBP9R9nWwdWOc7Q7W TeERx0dC0SDSHiPralbvkYegcaaoqQ+FwLuA8uj2AJHeRwLam+ShVGQwdnNmdWbY 3GyBcfrYM2c0DOOZwHHVLeKJY0xqYAlKANgxPDv+nfe09/+aeTP5A7XMhyHN9h9g jTibJJtjJNBQVtUkcwwunfGEs7EzJvs9swnxOA+Oox3TstkPIzU6ckiOGT2sLWH1 UMcri3JlDxnQ3/jDe98dvQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8qba840-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:38 +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 492GLoe6039128 for ; Wed, 2 Oct 2024 17:41:23 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x88977yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l/c9tWfSBm5Q74szz2QfyVbTZJrj6wmmlJ9pMxgARZMGtUspljPM5FXh67+YftSa1nY6lIAOC+YU+JcxRvxaRhc6iH2QjGQzlP4n7SLq0DGU8/cx3gsckcAXa/KUv+Pr+GKca8Q+t6mMr/FrfbERQvEDIwf245tB9nt4Ke6GcSyhIK6wkOagPc9xDSYN3rN27yvhuC7DO/+BfT+KcVwnTqnE2rVAn7TCHvgjypTPw4PSguPmgTh9iJcBGCnRsz2J/72XUQEkMaBsNrJ3ZNj0/vXR5g+U4POmmJBR3bWkW6MS7JQPJ0JJzsEV8lBAP5cOZvwggQUOT5M/KlQppolZyA== 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=Ks4xgj57ZSz1bcl0F5z5bLjWZPpsytYza0q2e1dS0hdRehhelZ2kf+hEuKhK8aAFEhm1fdbA5RD5QVwKMo//I0YyMl6boHaKlmfNbh2S3K1vX6li6QakV76amNKBf/kWZqgPXKW3qIccQaLK96CA4i35G06+I5K0247Ndt6gmpisTvYkBVIVlikjL5a89NmLmc97Kif7WlUdErKRKCpOUEVRFscw4p2oymbZ9u8b8yWlmI7FVL8QIKqLCOBw0UIzNjhM29Lp91yMdtQfJk2ObcQ+okP696Fgg8Qz94v2IclSvReOkqS5YXbLoRVKIei7KhMRZ3JDWGfcxFN0VswB+Q== 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=S4KN+qQELVPRbPp3vGiQrenh3H/Pw7pnquWhBh9/lyuWS+72+BVHo74Ao2Q8PUkxGvCrIuTcVJ/8SYesKRSF/we/eyLUTDPgPt7vjpnfV7Hmb340Z/aQKZnP3GGVTbJNYFBtSp3IKSYoXDOFPoaoaqwp4GYST616G3althBucfY= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:20 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 04/21] xfs: require XFS_SB_FEAT_INCOMPAT_LOG_XATTRS for attr log intent item recovery Date: Wed, 2 Oct 2024 10:40:51 -0700 Message-Id: <20241002174108.64615-5-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0005.namprd08.prod.outlook.com (2603:10b6:a03:100::18) 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_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c95f3de-606b-489b-adb6-08dce3096d0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: lOOQkElLyiizxTvCNTz+wmNSRuicpvC1z2xDrKxPU+rBmtnLwHwSYBfbdLre4BkcB3EgIx8DxcD8adkw7ainMLQlQJpqGlXq/3NnpRHpmNNqLciaG4pyYW6GQx74uBQnaMeBVNOmQ9Fx3AS4gjz8ZuD9d60vgGxiNHtOlMDX4xhXgbtDMQWWGIbgmLLnPige33xT9UgwGMz+s0ngtBL+dBrngjKGm1pi3TFEY73Vp1IMKTkesIoRnabckAabvExwsdXu4l31/12gCB3VmSxeAUzKfUYTcmUq5PzrDMfsoLcoyRd9hHu/6zW+iMFoHOuII4obkJQpqO7FM7nCT0fABm5992SvJdzm9huk0P5hcVfXXzmQ6QvU7iispnAquDCcWNCn8UDwDU8OC6mI+ILpFzzsAdoc+TYHztY1CArEWK7nIPQONVse2uRCvXOcmmyKqhEXWSkCv+h5bDQMfDADtLHBuqNdA3eRWvT7niClMoOrJ4qPYx1oSi6wVydWe2B0MJf1cqwOizNhfc3vYskCg9D3jUar9qdKI4NTEEiqntaW3AGc0+pfcNij0RDcFDkdBDhTP4/Vl8po34nwFtJxRaeSSeaZMij4OvVH8C/lWBljN9mTRtp9hwiRxAqmA0cCyIca3MO/a9UUeIfFDCgRFcePby3diNdQ4kchqejqpPco2msTwDXLmQu68eG/khAjSWJGiaajO7cVyzQgiVM12R4GKXfN00Ebj2i3g+bErbLa/5BJmJ9ZSuHJWKbSYKVG5YmrVysYqlkzlvjUziCvuvoJfBSKkqgt4ekrFBQ4WV/z5kwTpjkxbEVu/DGdJ8fMq0hUsXCo59LocdoASzysJhhHQ7kpvsoXG9RJemyUncMGhtXOJY+4EICsZjogiLpjNwZ7R1Mxn3adYmnYBQhH76QOCGF6tHskoF3nyMBd9spbB+NhMiLBSDTMhUgMTalqeuY1kVWB1viixYhclzPW6d2hWG+eK+h9gLlIBqF9U9/bvS/4wweaW1MFH+vDd3JkLQpq0jR7soogyUxhDjTJKGhsPs1qA1/uk9e8ejqm1LyjdB8yfKZcG4Ro/gFJ+cGbeFxxxexAOlaeZICctjYvXf1Zq9kenp/P/Tk4mf7J+WQBjw68wNoVQFJrXzQaIBo5CRHG6nKpmlQCS2i/bS79kMXNxK2VGi4jVxUlBF/toIqrYuhDkkeNSLPY7SNp3NdSd6zsS/XtgaJUpP3SuTkw1YmJkKcKSRRE8r1MpopjtkGMgm8s8QtCCE5Wsbjvw/swKcmU2BvxHOZmV3hfs7jRxg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kWNic+t4SMbtYNjeyDz26lI+nvQFvtiek5QDgXYX6onGLjCi98BjzNh5lSl78I0otBiZdaqZjIPwQVlsGDeVllpf+2GJO6ECIURrjSYGQYH+wbFhspIqCclrSpMI36LTZ15IcNec07pqDbiqj57BUoogu7v3mge3/+DmBHdHrv3zEcGvSo2qbmC3IO+zYLXCK120om7fPlkzA5yzuyPcG2Gv1lgejuuv72yF01EOGNlyKG0NNvcHHRskoTCbEfkZp6uxfBB5f+feRz12EVI41lRlKntvEo9XaZkRU42nbL2CjHGbQ/DEGsp2lzFUKqnlMhOTgnV4+Ox5jQ3NPwlfzQ2HYbwdGiUTXA8h6T+jjxVj0BYdaLeyhcGtK72hXPO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ihyzfG0yHDI3D1XpD0/jvpyGVakuqULzjooW9GbW997weYVF/3CmGExMybXIrgzUyGH7Lhs8ME41e1zXHaVIbB2f4tjOQUYtKQEnFhYlsf/5L1id3KmyyB4GzQXyG05EHKAytQ6e+0bWA8QrUHJnxGRWBJv1fgv+ma6qFmBYx1SQx8fM5GwKIC+v9MxZmpeYoDqTkt9YW2b0u5VsAl9J1xPOPF1um8fU1DNOrBu6ALg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mRKEGHP3bOoBILcMrLmASU4BW+0cT23fEGoO4ev0JKekOQeRBF1l8JKPU6ZEuDUJLeqjv1HCcE9dsrKUVquPK/19VhIPTzIXIcki4WgARwwv+ovABR2A95j9Zyyxowv9cLqUP+P0NX+ueHO/2sfkQ04G9/Jb4OzHyTtOCC8vavys0Oc0rHr9sY3Nu92MCxzeIxyPw0AOD1zcCFGrQ26KkXcx3fkixKBBl0E1waft1VA0W06gHPfx+JsNCEF3bS53iTnTot+apNK3Rq4jZY4/4mx2WquCnJQOaQVA/T/yJX/vb73acZ8TT65cduEtNK8sNwVs3tf0gCGyBFkgPyFnRPfttcyBmdxASQ6c/whCBbELrif/Cqbr/i55yEAfoe44RG4Mpb05FKjJ1KL5lYqVWfB5Cxcr5j0l/PJtuWifiaYvwf+K6qs9qn31tXc6vi1e0lkfS8J36R51mXz0ShE3B28xtMKoe61UY1H54tMYU4LG6wTSdUyn931i01AFBYBQPwWI+yDHHvXbJ6dHsXc3rVvlsAv+99MflMvdzVLptMhVM14s5aZ5ZBkRi8LWWUGyx4E88tdYqBEXg+qZ1tu9+Uaw6s38/4EC0OXpoIUqHto= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c95f3de-606b-489b-adb6-08dce3096d0b X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:20.5086 (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: mWIj6qIsKRnmB/4s8sPvHLqwI8j2gwXL73qT/CM77T/8DY2cjP3A/X8jHm2ttBHvTRV8KuLSiNyjE1M/KC9vXjmTLkVxevNyhKB4J/345xk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: gHI1QMOoxbPGfsGAbu2551vdDhl2bg8I X-Proofpoint-ORIG-GUID: gHI1QMOoxbPGfsGAbu2551vdDhl2bg8I 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 Wed Oct 2 17:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820169 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 3A4361D174C for ; Wed, 2 Oct 2024 17:41:39 +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=1727890900; cv=fail; b=Cqqbo6o0UVds2sDhiQA6PGSG682+Gqd9KrPvvesaJGtVfWLJaV+zYsHBcVocAarQK+llq54Bl1DM+to27wu1FVqDWnWi395CHEWLJshP5dGiSREkcnYY+zthR7ARYIAqFV7jhiiQjozx/bXJ3zTcBHZROLSA9VTAOiFf8q1q/WE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; c=relaxed/simple; bh=/yFhShMsiZQVVKJmf10L3KPPS3o67lLMjGLP603145g=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=B4YxugGBIRzKg4btvLZXTRuqL/Xrhcp6uG4TByrhCMoj2nUyQ0dfVdsvvn6P24zMtoahcmrNN2nGBLzT8mM+/Lp6skNnsffyDFP4VRRwObuWjjXttxqA/ez6Ml2owxYg8bDwjPomo7VvjUWj/k7LjgQxm1Na89W6tks8lXM2dho= 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=Cbwq3fto; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=GZNQ9J0c; 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="Cbwq3fto"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="GZNQ9J0c" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492HfcNW025762 for ; Wed, 2 Oct 2024 17:41:38 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= Cbwq3ftoFcCi3cp91k1Tl/rUhyADoC+09DKBOwlktuTbKLqB28fQuo935XvWMxZn lzKWFXzT7EU7vlipDgGv4L+MRBpBLj2tAIzFeewoFVCKp0AvIxM9cZ8KZU+5EFSw ZAilLgHnZyOoYbSpwbVAMF8H2SPWM7ZuK4kZCbdIjTRGeRZtcqXLK9AXufiKAdUg r9ntY8PlZDs6ck6ZhHs2X59dMgCDu0KQgSO0iU+Ag6s8jVRKsvN7SaOnyQQhhNuT QNSOyHWtEK/T98CvrIV8VEFP9TVTd/awoMK+R0uedk+UqqYKE6OQgKqCMv/+KQ6+ KO2VnE9+5lNEs3SCrunUVA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8qba841-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:38 +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 492HFebk038677 for ; Wed, 2 Oct 2024 17:41:24 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x8897808-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WHXslsyp8xcYBQbOnyoS4taFiSUezZ1C+s+auBdJ+wIDxSxfgn9io6jDop+uSRZpOA1q3gwSAektL0OtDLZzobrw+UTV07KntnIe13OrPspSzKzpra0kWPfC6l2Gf33PUMTrauGOP5zbt6gHFHhPTlWi+nKJw4knkWyjz0Y7gOVlcky3QU6VYnzWTIEsLuyd/RJ5CaAg2VHUWhwFjevWvCWimYIsN3vRvkh5WHPxCJEJqa8SJy9o6W9AOuaMwtahvcddNhAfahy1+OeA+tverYjkrBxPKrFMePu2Glf67Hpq9wA5z98nS4OZl4LWsTNl+JwniHj40myKKzTSQIJRAg== 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=Z6Ncwsv4dPc3evZUjKes0A66egSmvuSKmB2bN38pPOeuCllXHlI/gveQddTwflQizYaUHzcojrgW8WRqFzL3fJcCm9obAHyZE6jOX0FXAxRBQmLC+lA5haYD4lpjgI6rsviDaWgTOzl3/Wa8bDF8rTLZgL73Cs4lPrxzH11OJJ5IYKe7IYm7qw3zM0inj3ZuAnfQG1SykV0c9wrxYofzdKuLm9SLNEA6lOkV091AVg8kUzpxTj1cVucn18iXAiXIJ10AX2b+paYUZQQMsolRfU1E1Dt8k7VHcnMTFPSlTDZZvv0afpPgqtTYsG8W8r4mCGOoO7vDihdBjBoqTNlzug== 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=GZNQ9J0cc5+oqdpclS+xzXPAGjFbqKP7CJanOp05D24QyNXSCmv37EUyH3DYx3lnIFFTTXMgw/n+16Chm0GKbyLkswzNWMeKPITNmCShpCuW00sj+ktqdDhqXBLm5Vo9ESyJrQmeCr5tBpuoIZiZ26V/QSNr8BRupSbSTy9Xj/0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41:22 +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.8026.016; Wed, 2 Oct 2024 17:41:22 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 05/21] xfs: check opcode and iovec count match in xlog_recover_attri_commit_pass2 Date: Wed, 2 Oct 2024 10:40:52 -0700 Message-Id: <20241002174108.64615-6-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0006.namprd08.prod.outlook.com (2603:10b6:a03:100::19) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 5525ea68-b34e-4e4b-827e-08dce3096e06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: HXmbkPGrGe7bO1YYmVo4MUqj5LV42aakv7TL7O+e97aMmtFjoUYHp2rnG8OkZy7msAVv9edXWlQtJiueKV4YEVOAhc0RWWQApNYCAuJpIJu51I29gT80VGaV99zlM4xFAHUUEnMIcWf78Oh/x6dtHJt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IE9YZiv1JKAxjkL2YCOpy7JOnFM4iSnw60GxlIz07btTd4lZ5GWIxuw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mLK6+MA7pOSuw8RJNNykl/tS/86JpzKP49CQH9goWslgd9EX5ygd0ZQTGP+nS7ZzjTP9Sz5sDFnEw+JQ+sjbCI5ldyouBLhY70VHD3cT26PRjERUUkMFvEK84RjCZyhrFVm1R32JUqyLg3AYVGSHw7nWV1t/Pi8SwgNPrIiBENKmuowmsvh/+V7iTNOXye+5pn7slmNBRm50Aoc5qxjQgchVp2mWjyqb1UFyoGfs4XDcl2yZJ238v1POJ+cSsrIqUZBjIExvd8qlB/DX6ixGuLA0VBm1+PpmBs1d1ArymaOteQ9WugzVOo9LxyoFr1V+9MuW5VriRJNC15xgnrzrDdxUydzfzAHpEJH9veTNnDtkaO1tkl+7BrLw3p5HGfPnIBObD9qilNfMWexAglD8qhNfnMr4bWhlqzuKDoXQnz3O5MBUA9EaBs2B8Yqz2pRkpwE5jn8pnmqChA3DeERk5nWmftvMaOKjdPLtYRAayPTCIxmbXgTkHlIDD3DLLnac2R1CBiZH8bj03hGxS4awAIODmGXGLrPcTUBbazacfsSxso49QPGWopCkBzi3EQmS7QLOp8GX+xEFPs0y7/KxvJxA4Nc1vi+ZEDbzDB6G74D2q2EnIBT4JRrNgkSFp8LO9x94H2NCVg9yMVMxF2kaFHNc1pyVkel/UqwmYEgbD71dSH9BW3okTogEOO6sk+sBj5dQ6tSCcypJYExGaXw6L73ImsF94tZMb/yl02GzLRLd4hIbX/vUejW37Pmqmg1V4FXkPO2rN8pucBM1d9+I+KIwZkBNw1FBSKWYnxVgbrv72kv6N0aZ7QyNR1+WHrf5PRh/jFDF79fzC8yN/2EWdWx9XlXBoRfdRGWhI3fs8+VJy4s5uxkN0eBq750Ons6Km2OFSpCkrd6kVlgUxMfPIOBXdQkLsPJNK+Gu7oij807DqavgvJBaYCm1ugzZue2nSQiccV5NsdsGWC5Q8Etm0oIwCmoL3MQlsmmaMbmf5zpbP9GaEURyhVViLgXzo8NErcnbBPM3f25U+R+hee7a37XTAcBmFQB/9Opm7vNIQ02+ongxBc3z/+hRd7znzUhR5ErYpDmPV4pv0lFw63ghamtgYWM9s0zPTHJWglblAMPxedWBRNqiit7GzclJYXfnHG+vhqzdVhJgSH50Tik7q6Je/yqG0/UzOfWLXhqzcmOgzu7WDbzmKUUePQfP/24f6bht0GknTi1pN5Q4LeF38j9+AC+BTDsToFdx5udlRcE4tW9Whok+F9c9Tx6IqVieomatMe81YhQxHq0ZBJTWdTuU3Cxo7V+B4LmXicyTah4NwrMf/48WWyxmRRTX35mEZ+33XIs2OK+vnPRpcisWkuOhIWcWa/8lHcfUht70LVxUXESeZyWnJdeZJrDot1quTHIm9bWtKaG1Ggckz9Ljhrb3xSHCkeHvuhccYNaYFfWVjtFMuG1ms9Aku11F+VS0VqZM23KIgsoT2nqddDSW4tyPDxhgRgPAW3NbY3ugRhYKhh8YcvRqg/VhE40Zs6SLYvU3tKZdcZyird5D8Wi1WoP95UH+zfC6uiDO8CYEi2VLT7Y6OXlCZjjvzoXQS/D9vmuMSJt6KkTRaHPaV+xRa6oktDC4KKz96Bv+khSH4Bfbmcna9Vp58PDRqzyQkz13tssnOXTqhdzTIdr823RPzQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rngIzeF61Qrf2LtzhJkM1yByz6qpWYFUnLg+JUoo6TC78my8zxTSjgukBWJRv/LWYzR8Ivd1areCkGOaS3k0Y2lnyDPLF/3asr2WzcOY8fyH0+cBWht6risEdiT6RFRFewuWxpE4ceUPYGCB3g+yeWn5IV6k6haIOxFFTtzYVzuAJFsGvfuADeYALNK90TVU5trpiddsrHsmyyjAKt7eT2yHv+acR1ZkwcvOiFXkspr7j7URenkDSgU3D+sQuALOSx7A+3ZQfwykBh24I0p7QolMwqFLcrc0rZivVJ3G/GBoXPInL6RrkXZAVEL/r9EBbeVIOj3zpvCqW1vUHf3fwvN4lrzLYWR6VjDKq8K9mzbH4ucbtc60wIU5MZlD0VPAsxU7Fc6zv7p1xD4RvEVmDV2weUYQZEUZaSOurdDV2belKGiaZzKp8ELvcZkpVIzTltkW8kFT6ECc31WqFO9+c75u7SNPHqRmKXHkZbp37/3VUWiDL3jqTq1GsNLmnWQhkuaMM8PkiGIzug5l1h8AHSCd0kPXfO7+gBqwKAJGG3MQ5XhddygeJmOFdg9jmuoZkqz5hHNtcvLtv8wPatIxIjpuDucsiFpqVq4CD+Hzv0I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5525ea68-b34e-4e4b-827e-08dce3096e06 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:22.1123 (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: 9v41NBKnYT5yWMFXFyLUzh6tMMYFLAbfpT3bIleeqjHgbhEe6R8gVsv6GXIvK9TOUHGHRDszYMGV7S6CUTvm1Y/uIyNEkdmeApgfbw2u87M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: SehoT-kErW7xFmbij2gT1TrFEbIaGe4z X-Proofpoint-ORIG-GUID: SehoT-kErW7xFmbij2gT1TrFEbIaGe4z 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 Wed Oct 2 17:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820167 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 B554F1D173D for ; Wed, 2 Oct 2024 17:41:38 +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=1727890900; cv=fail; b=VC65a6ugAX3XiXNA/UrTH3qvYIkp5n3EcUM4kploiwhBPT+mE2doMwHXW0aIgxJR+T7vRhwEB4F2j9WD2oWnh58Lm0TIt5B6Zsnr3kZgXOvpeeFWEPiRAm2LFxhr/XXbAsxpT7aaWhtGBjN/n2G7+2fCQV6koOeHsCyi7lx2Dbk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; c=relaxed/simple; bh=q1KYDJ4Qhh0l202v9P1rrQPA/UwJyuvLLDKrkFTvPBA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ja5lx+nkyvRjVSZMZXhj1c1xd6DYZTz+cmXX/t/1+598e61X4wjXWYSfyQoX4ECoGJuJTr1zIfmKVnpFMpkDLqEu+TpkLVJR77szDU1KBmrXH6a31r9zBPdWE4qdY6H+OWts/Sz8JJuG6kiaEaY6drpbuvZLT3SJGSh6g44ytWI= 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=nAC0HLlM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ZWgYv9wX; 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="nAC0HLlM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ZWgYv9wX" 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 492HfbnC027433 for ; Wed, 2 Oct 2024 17:41:37 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= nAC0HLlMdLwcgFjlLMr3RkmUbuPgs1jTrWmSI4bv3WBdjGPunKUvhFyTVCX0pcst p7yvvSZU4b9BuWhA3ws4LcVPQrlxwj4Bo+GsJojcG1rmMnkDG0wBz20gdN1fy7v4 r8sIoN+++i6oIN2XPzV6TcIk65jJzJotg0lc/C4MIMxmTiA4krCoqVozyhP4FGiu pNC+kxy4Ec6JCWw09svF0plq0VgQKdi1f5+YWDU1BXYEn43uUlXJesTPwQHvOW6A afZQ99iBrswyX8CC9mC80wRr+sPSz8Ax30cWIR+h1J6HzglJOwdboLBRzAotYHdp Yhs399NH2QdKt6k8iSg0DA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87da9e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +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 492HUb1C017337 for ; Wed, 2 Oct 2024 17:41:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x88951f3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ySvL5KNp18/gY/Ry7Mhgd90JcAthLy1dM+eMSIDlF5IDKU16DQ2CRCkiAjhZiWVbcfSe5YOoJeOARPbTka+nLvgBxyRzWWYKBYFibwZFUPtJKwgkLbFYr4W8QgS6vooeS2cXwV+j9LY7Q2A20cFz/Lu2yIa92wQ/1mhHOKfqmnGntjHqH850+VCXQiOgkEtfRUVYEO95qOEAC7VAtkiVPWeWWrsGBRJ5hC3XYW5PBfbE3+3SLcyPDq4AxRrSGDtYCSk+tFyL//0bdm7QkA+jPcadM9vFjlp4Ks2ffF/XkwwJ/Cw4/nVJ8/kV1i9aeeBYUV5IqjD9UNJksy7UHxMk3w== 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=jflI50wG1jYwPtUZCODxm5zHZifTMudfhCXglIdsnoRg5gsWc1WwzHIOTPC3Oze4tXpmHa596nFbihhQgZF7fjAokFh7blzhuXw41wFxIw8P+rnx0tgZYnYd9ruiRVq1U+k5r/zbQ1wH6DdF9Gb83hm8rlF/+QZKGbk21MbYUfoS/wFNv0HChB5qfC3MeS8NfM2lkHLQ8uh/h56o3WE4nS5gwHEtB38aVomKoTwa/yp9LeUfBN2YLsinPizUNEnQqVCTfCjE9u7IaacjOhvoD8rhRbyI+QWkspABCx00Hb6x2XNsCeJBWBN4zjBjYLWojUpPYmquq3X2eB1BSSqzMA== 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=ZWgYv9wXE9Fxkwg7ClPjHzfIKBzbBxK4Qp/2NuamrsBsKGa4aa84E5f1NcMsbUnQKlT0EkzQfepmzHCpXDynUW1AdWJBKPrcmoXlpsvv+lwig3I3iBwcY8uoIP8p2Re68uRv/zj01zYo3M0MgMOXp+wUxCvATWHB8bOM0oLFaag= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:23 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 06/21] xfs: fix missing check for invalid attr flags Date: Wed, 2 Oct 2024 10:40:53 -0700 Message-Id: <20241002174108.64615-7-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0032.namprd08.prod.outlook.com (2603:10b6:a03:100::45) 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_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 109cd6d9-f346-4926-0c0b-08dce3096efd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: pcMl4+OctMtbwTRyghL3S9WIrtghdClrl6NO6Ap8b6xKJoBKxDUNXXdQ9M9FvpmqnKp0ZR0Rt2QW3Rp420qXLdJHg/3MjU3g1GBEvZfsNAeSNhGbCCX0drtHlweirW4Koe4dwpE0NA9CGuPRsVLGGEn645YEE4NeUGaQqtp49aH3OQuzqX3PbvQXfvFyDnoRraW3kucNANTRTLy9dL84yVOXAqA7V0RbrD9Lgcwcv07zDsU0hHvWkGwJFY7ZwLF6q2vgFyGqK0rbebAlHyYFZ7m/AdgBeYZu4KJ9ajaA9zJ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B5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9kS6NiUusppa8bNWtXbcoxxClGq76ATU2Da3OaTqpJrFGX9ObYjt6Um0gJkYkWgQZ/speeoixBcsdLvuHQ4NIn4xyU13wt+Ro5RJ5QGw/8ZXolkEz3FQ1zk2ZE4Zhwgc6IITsVcmd6HN6lc/4Hfg3YcKH8CuF5KHJpKqudd8527R8CVDUIzO+necdxZR1eiHcnMqG8XBhMyoT2yYw8FiCe4HP7+QEpXCrHOOWX8gbN+H1mERzCB4EItf9VoPo39OZOzm32K7ubyl8xO7Raf+RX686tb4vVqbYeuNdg+D543pNjoIFJ2rDonuUQ1To0L1VMr9ijP92M+g8Lzy3afedg8JX2abGXOl2LKCohHQRufYtvSrWuSimWyHB+fNkvihdTJ0FmulQVsAQRgd+dBMLZymzP4xqqYISYI+z0lt+9jm1f18v6pRB+7Spd4QS/IOdKYn0Awn2sP3dtm5pTngbdwqo9IK2vfxo3LRytLQ/Qi5dl8i4PZEkN9V+/qTKusEci5bUyWRVJvkecyqxx8/hagVceAgWvC2JVhdmGtXS5FEaURMU82OnLP8L3gscorcyARxwyorZRF+i9gcosv0x1xLTSA7RtcvFp3GPNjSrkKo8hEPM73O5AQ/T6gCX8N6R1BVAJsdegiham0eYzY2C9njRCugi7tqA/qT7PXj6htmMQVAzpDAokdO61WcFHnsoe0jnB161WnHHnE6fmgMS5xF+V1EXdlDoAu6SAzZEuztldaEu2A+I8GtfX8xIKfOIjWNXbYYaHTOhDZYLpaYqzOG3Eo/Od+b8Dddp3iHPdVethiznokShQivBx/+cbLhRxckrkNpNTE9cOOs3U0uMN1N9PDrESjh3LQ7D6qjkLVeMdJiJJG7sRpsobgKRc4Z9gdn7FriPhY34In1TJlTuth99omlY1GIN7twGvEuN6bz76Bkt+Sc7mZ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P+ctaroM2a+s3dK2zvsKHdv4KpAtD9tPSlNlVwme292aY41wC10kpnYFkoSb026k1M8K3lDNgNbj7WSS2VxSFSExmB4BArx2377c7y7pCx3rDRsBCSeZ3zee/Z3ku8nK/cYUdfcVHI0+WyR6FQ1p1LoMphXqJtzyomevt5ctdt6CpdHNVdOM4jLDAKOgJjKf1ZEAMF9AEsVMi7owC6Z4iOXFIX9EkEqtn8mLBR8jy4Dtk2pBGE2DGQTRa7lPgc9Iikw+WjPELbVDYVg4CMBUywysJYKdnS7118vyU+Zx6jUTg72ktK6kYLItbyxhKCIhpbpX54cqxAEOseCs9BZuvYh1VvaQvcgkKc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 109cd6d9-f346-4926-0c0b-08dce3096efd X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:23.6821 (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: gy1+v4FOudN28qy7e0SmIHF7fqc3gEaM+ic3DVa39rkYQdcI+11k9KZg2CJDRiCBfBacDBRwZZfNlzpD4ko4Xeezq/MeSJ/XNySEFTSKsz8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: 6ouCSRm32hhwXAS--vNnPIvjEnz0JHp8 X-Proofpoint-ORIG-GUID: 6ouCSRm32hhwXAS--vNnPIvjEnz0JHp8 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 Wed Oct 2 17:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820164 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 DDC751D1738 for ; Wed, 2 Oct 2024 17:41:37 +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=1727890899; cv=fail; b=AJ/zEF1bAAA5YAUcQJBIAmQVWv+fVoAroiLCUP/NgwICMIF6Of10YKsrJ+oTTOcxc3ozwR2e3jv8XKR3Z6xPoPoq3Ta9+Lt5WIYlImrVb/khIK9RXaX+ANIMAR6BQcBRDnh0RbEbgghfr2mU0ucqryJzv1o7iHFW8e8vAN97dz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890899; c=relaxed/simple; bh=jLmafBpi7O5EXAWPspNMqPsJ6hlU6OP+qeezPN0mwPo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tCCeiSbPjfrAR8yzLrhJzF6IVNIkUrMXkd52Nc+XEetAskPqmg2y9whf7UVEl+47VhBCZpDfmd4qZFOvlaqxzG7zc/uaYkRxbCHse4knwY6cZsgbyIQWyZyd9Ym14zUpytaPjm+TpJkwEiJ1H0AtlsHzQcZ6w08Lg8mdbD1Q+vE= 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=FqRiovgT; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=lLrKvTbX; 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="FqRiovgT"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="lLrKvTbX" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492Hfan4025055 for ; Wed, 2 Oct 2024 17:41:37 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= FqRiovgTPd07I+n2s0IcAi3KRw2Y+Zmhbp7lQZmreUsdsEPfvImRSzkNd5kLiGtE jmI3Z1VEuhK1mQDLXhd5N7ULAYMT0ZZxkUbRBdNJTqpr7TUozb+n4sTJxl8do2Ne eU9dRoI/uupLuVv8wt3XYOi226lnTC13H9C75QHozGJhGpnwD4qnJMFAzXNaZaI/ X9UWzw2VT+p6hfXsn3LCg3Bpw8bL0GG9ZWAbSQPIDbRyqKU7t/VfRCyEeniHn2W0 3mXxxNOgpW/iszd76Qp+I/OWl1pc3RexQqsVPfh8SU/t+LSp8R00ole+05XDy9R7 lBJ4J7UYH2xs+qGR+uXAHw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9p9t3dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +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 492GOowA026192 for ; Wed, 2 Oct 2024 17:41:27 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x8897fbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lucv9/fJqNkK8zYpjgSRu2DEvlFTx2QTYrybX3wyKuE43o5oH5zYQylVOqPiWEqyDs4BRcBm7P/9TTsOh25zjLlCzGyeLmVkS7rh3QfuE1OuIlBWnJnK7pLNVdEe7BkUeDOdrn7NX32KOQTVVX0QYdXd/nvTQDJZgR+dTQ93RZp2T8tve4rKFQg1mVlDjzPn8cf6dM1J+QdB1vWuDVL0qR+YyPydP5EMjUB01lefvu+J/jc5XVWJaPJu6CisnttdM1M20LyKNOUym7WhvDSIfMbZAhmESQnd50YgChqyD5vTUWgm7UK7QqWnZ1BikOfAD4I9uabKTFE8Vxa+ox4JbQ== 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=TRZC0CIZVfmE2A+bN44ineOSy4K2gjMXB0ls1VMAOVc038thFK8DUwUwuyPR2JuQtODkDclb8Qv5YdAJhagrGd/15bqjFQQYx9EUZ2VvYEdhoqcX3ll4GC8Y8VHqaE/wWnnqHZyIrU71yeK2NZY8osZd9BqIvgNl8sevhaHUF44X9akeFwYyYLrCKNmQgTPcyuX3zIxtXnwxbEXw2c/zX76XUu0dZiThUQeQSIT2gBbtpcx435Ld6ZZDdPKvUWZ0NbvDPUN2cLVdiQqA9E+WANouFnA2OkhjqVr0BUcukE2UCBDfPbl35XKeYogfeoLP3HRTBpHjc3+h8UwEaUeq/w== 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=lLrKvTbXpuNvkHwxy0CGf0iwwPujlPoMlxJs6emK7Ug9cQNWanLnRaE+ADUVmTgp1jqGTR1XD81FBfwmFGgGcfIaVCIpr0D6SClnnRkdOa9pd8qtdfz5M9oAej0Clo7Hg132DqmxvB2gLcJocImuAaQY7AXQbNTfi3wWYqO5cUo= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41:25 +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.8026.016; Wed, 2 Oct 2024 17:41:25 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 07/21] xfs: check shortform attr entry flags specifically Date: Wed, 2 Oct 2024 10:40:54 -0700 Message-Id: <20241002174108.64615-8-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0033.namprd08.prod.outlook.com (2603:10b6:a03:100::46) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: 67dd5ff6-b7ff-47e5-ce6a-08dce3096ffe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: v5NPuxfMMFmNLfYBU2+9Dq+VJkE5pflOWsKzSmwWbt15hhSqyKOCyYIWA4scpT0RH4VH5unHn36ju3LZzd9m3b7b6J6Lcx3rXe4IlX8w7oxQnWs+P71QErLym+xIuhINJbV+Uid//epjXcLdxUQB9cp/unZT63Vsl/NNc3q6EAanfiBpdBk7Lsb2KlGdCzU2vCmDoeJuEUVNM+LvuW7u5fuCyX6AnpnjXWMRN6Q0KEOfRScOz1b1s0kTWrD62GQSNXSeQAWURSgWjXO8VIKxBCuY820ssMH5H/ekTZxvLi3rK5SsVe7oMhYlTY1m/tQRUSP9W5rIzf6CZXKslYoOJMpPCObVqbmJHxP9/XEFpcxKxITt80WzWgn4PUFexgma01Z52lyI7CIVNaDJjQwWas7SjT90J1Te3rGLcTDE/j0aykr7xAnbKXFS9RsrDV6af+en34ZxRGNIE25o6tw1y8Su0qQqMgV2DxELx66i1rhz5aFyYTMdPTCeFYAiGU0Geqvu2c0wjzwDNmu2twNL+HkvWCdBDIqv1lXHDLfn9S2LooEuqf76h04KM2IpSiOAztmdqmul1nvnne/uniTSB42ZZ0ThClLJaFHW9lZsyEQqr6K7DAKBJ8CchYQkNxNM/yW7qSjhjF+XrFMZ1h1UsUHdyNKGMJH0fg0OrKGgTA/wGzjZpbd6g+MQrUZG3leg8u0ugcGWgRHRzXCUuLass8qJI68MQRhUqChIf8NgM6uN1cuEOoujmlNMAfRy6QTPyNrgxdJ/eJcMSCvf6cSp82/EJJwnzEgtWBHNOaEFH/8vLFLFBOH/jI4e3vpIugfRUnxg4c/kXF6kSg8DmOECl1cwAmK2Jd+k8CErxvdGaiHWoHtdvb3+LqrkGvpPhG2NBzXzO7V4XgbjnG9Sb6zNvpbSny18ip78ih8xZh51mdun1LFqLmEYCSi9OBgyFBCLv2jnqZbRRKfkd/uUvM03L9XrUpGH7tCzoch2ua6u/iojRsssJrIr+UiMLPe2joSmar9rp2stow/GidRgvpPPBQc0mQieLHWav7Sb4Fvq8IS1V/pRbsGq8DpqfhKeSId0Ds06azxcpsurDud7xeF3HnPENrceNuEh+KxuW+8HYalyfeO4Z5IuvUPmQlc5z9J8/5H7juvU9A/tZAwlmgYk1JLApf1R49viJ0ks/7Y2Z65r63FMYkBPOltIgkCDEAUSTA2i2E5KHM7QZ17Pwtx0wasVdStGurBZ/cCnLNyNx3RdVLjEB+46K/1ivAEGZcSeRi+tPcCuWAGUMGgkm9KBTA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4zqaQQ2EunlmyIcKL8h0CIWI9U8eLmSqmegI4CPv3hEy6sUEvwXBnT4oZFEgLsrk1al0m2oF1E/oMPwspW6UWPdfMFTJeMcK+Dmovi8qYYqUIJI+8lCLXpRoHJ4jb7xzeW6ONWLRP5UeVvv82lta7N6yROx0uT9mzAvQSo/39/Wtsnljx0ez7NOHwsbUuKqqIV7jMapftVg5KgdJnFXL09HoPiLNETRsvoltMsrxgVbWnHwn5RxrXBflrX5xOgtsKaTamQzbDHzD7X4CZAw76nZTIiQbCehpKGuByP9VzUfk2kk1nXtHmAanxdK3MLL1X/+9RRc3ZcNarVQrVzSA+fXKF6hiYqpioZHpc7rvi3qI/+Bl5ZG92d8TwvrRvtXN08sRmnvYhXE3iO+TpdvAKettbEEOqCnSMwFtasMS5miXz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MG+e2olQVhFCIX/ZBH8TzOSE1e5uYbIrS+ODbmUn0iQU6E/OoLE9AvELDHhu+UdGt5e6KeVUjoepA65hUfo/GwdOmvf9l/IzDhY6n0SzZPNM5tX1dr1IMuUsexMEZS3CPR+LjKHxKxgXDhQqZ6E8Xu0/qGXQCDi2/pkXyuCAIMYJOnbhsC2rqK4DenQYqg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HHBbI07+WJiH7p784pKC9lFK3TUe50svc2KqSZ+R6laRprpZUDinL3C8Xv+vcvwtc1odReKmKLUUT4g0Xj/bwkUXbKYHo/AuJs/lYiyLwIg6dxxflZHRM64riLPdY5+129evFKi5ErMhZkqlJT2jNsbaS0Z/MrVT6ctO1rKm52i6y/ILMekij9syvKIKWDTB0gugzJxXe3MJr5lmSZ40D+q3it+g/ocZTPt2pdp9IgOdUDL2bBsMQBvxYkaep6ecXEjUNzU0ck1tcpb/BAJBcu6aT7sMJYiJQeXlDRmQSLB9JL8A0J+bb/GOOoTGqiEfqe5no1tRdn7coUwIwCXwByXop45G5lxMqWyaWt2W/uGY6aFT0SQ1jW+a/vnGDqVq+BGGJMMs84yAHlaDvHta275WuNIfcIfAYAshktUhUySn/GedyfWJf9LooYT7rfBTHFtkC6QH6IsDBJHRCPydR7LUKkDn2ztUjvNuNWP6OyBFbxfT5uecupmDZPtTAfeyyAqyHY2J+JhLjGROpopjnBKhANAEXBa7r8TmseSXg5+V8lFP5sTwxVU6dvQri9mVpFPJNWvIzN3wlpWolGD12ggMvMOY7uXBRj08e5ewRSo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67dd5ff6-b7ff-47e5-ce6a-08dce3096ffe X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:25.3723 (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: jQ1dt6NQfCBJRZ1zgYTIvkrHcHHkQTgxuwmykLKpx5hPFVF8lKGniccMpBTfEPQzVukDqipYSmq/GGuC7ZOMbtfev9mfIW2n6fcjiuJYWYQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: kTdyyu2pcY6iA4wi8Ug4-5erGtUOeS2l X-Proofpoint-GUID: kTdyyu2pcY6iA4wi8Ug4-5erGtUOeS2l 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 Wed Oct 2 17:40:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820165 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 24E741D0F74 for ; Wed, 2 Oct 2024 17:41:37 +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=1727890899; cv=fail; b=GwDUzH3yzpP2yJs9lx2UOp9RBMt4i9ZT+7vp2qnTkQtI9C5YnVhgWcSxHtKQ9a1cCXPAS96QRd5TAavdw+ikMBLxZy+KJ9mqLAvjHLsFbQd46oducv1Q7y6fBsWMrdO5ytazZbB7G15GkI0/bbxDE6YiYCOlK8b2brE33VK7wkM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890899; 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=nZr7k32jZWrq1kIE3oV9fSbcTQiZNqa+41MYwZFCSUu5wi0zhb2FgKIVVQkpqU4zRO7tUqiyXGKhpI+poTKlynQHGqDal+igPs9YE251OVeWKySaBqTGO8OxCD5cqG0ZUF9SqoB3FWwejdlpdxFAHZLYg+Y0/Jww7X+lcZIfcjw= 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=ekm0zhRD; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=GgCx5qAB; 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="ekm0zhRD"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="GgCx5qAB" 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 492HfZnd007356 for ; Wed, 2 Oct 2024 17:41:37 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= ekm0zhRD284SqZQ9mSWdT6d5XvtF/HdbKyz7jmpUYYBfYe2wJkTHwVChMmCL43q1 TaYiixy8tC/bwKT/1x4STG687UVjtgXprbmAo8MnK5ztTQGhqq/2GSB2gZLCPZEC JiBl7aHSB6m/mU+dIGTgxyShIiLKfx0fNLpganOUGKaL7sK/cJhp0VAoUgWkrPX3 ecCGHTjbybBZ95Q7xDTiwA/+4SbZ84jMAbClg8BiZoZOtjHSj6dK3MPWXyGbVQLa tyBWZgNupjOGvvk0A5aO96nnbo7D0GQaJFy+NuAus9TVO5Gias6MWiXX3fyloNay nNftYXZZNyLQK5crijRydA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41xabtt6yp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:36 +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 492HDTIQ038719 for ; Wed, 2 Oct 2024 17:41:28 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x889782d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZcrW7QT57t+OyHv+wocVXoRBV4u67evDE8QYglny1adWyiT/bgr/Rm+jiGhLbNiVidlijJ0bxvziSvCZtw63Hq6fVvGMZbBDc1RwJhApREEj7mnBc/zem028bwJECAbWy0g9KCDLjHWs5Gvn2hj0EXx0c5TzHxKSZhFlZeOoj4Zij20PIKQUMYgEK+oUPBSC4SYebgeePPXPzpqEc9oMALihmsHSfTBZcNyXPfQte9yyWClwbzfOAt7QG1V3TN2ZLQIt2RCh7ppARKl2KDnx1/dpj09FqSC6++sHVFNsuwgj/7UhNJlhYy8AzaMmlKIZeN7BHgATw1HnAnG5Q8Ad7g== 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=Ex/FyIGcuPKk5z0vQNuMLhEpmlAymmbwykI17J17AK9mfFkZqN0FrWfeiWg9mU7MsJ5duo4/VviWU/DidTZlQpqg3czFNCHmz9O9alUaAJNw0mPon8cOM5J3T+MCSRm9Xy5W/QtXA9jregdpSdmNmsE1fXvZzBCYyqS4wLjGaL+M+Ztq7W/xvGWA5KfacZEmO0ppSBHvxKDv+ngTDXeB6WrQvKYLF332LO2DjsYEg863ycZqP+SRvoHsva7n8nkvh85oDffQhgUNw16WmLDEZtTc2Gt3vbmp53Hf1UpYBkTyYP0o6VVC708Krwh51mMg7juwZsFubPpH5jEFzrBxcg== 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=GgCx5qABf4oSIAimBopOYUokiaFd1Ws3ruiMaZY3Erv399hcdwfNgg+9p39OiewRnKSCd3pbNnrENpckvbPs5dsdU8rUmlz3m3n7BWifwkj7GIUydEb5JDSIV/X+NCiSlDNd/LKJRMSAs9yRLvoIMquG8/EYUrfHFzQsg7t3c44= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by CY5PR10MB6047.namprd10.prod.outlook.com (2603:10b6:930:3c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Wed, 2 Oct 2024 17:41:27 +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.8026.016; Wed, 2 Oct 2024 17:41:27 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 08/21] xfs: validate recovered name buffers when recovering xattr items Date: Wed, 2 Oct 2024 10:40:55 -0700 Message-Id: <20241002174108.64615-9-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BYAPR08CA0027.namprd08.prod.outlook.com (2603:10b6:a03:100::40) 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_|CY5PR10MB6047:EE_ X-MS-Office365-Filtering-Correlation-Id: dd5702d7-bca2-4dd7-fe8c-08dce3097100 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: nffQbun/1srpN5TE+RakLs+JNQqhQvFVNFis8fHD3//fPuk4NVneM3k/ZgBTDEb4zsJpDGIzlGX1wFrbGeWztKydz0Ye8cOlCLI7U9oJdG/GnloE8YfKO7TSsDFn9GSGuzA61sx/77Xz7rs3zSzXX2sWvLSnvXRPhynr/do4p2sMZqT9ZvT9y7eYzJbGPL1bAhX41/KaMp6FNZ4wZsye8UARn8t0ttC0vBNvO75/3thlRAyXAzZgZ3WXIz57TUPQkxWZ5d9NaZN53eFAyL7e7qgUHBW5ar8XpuEFC4wddF1CBH8qz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od.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4vylG11uYyBmxbIAPrk1Ziiv9ukwL2mVC4iNuiO+wbdRtz2ql9pnLlJz50Krp0TB9JF+yhCHIWpTD3ltteD93xq+rEjZ2vOly/BL465jB4JrOUeCuQlGc/ZnIBZh8PZR2m19N4J+CB2j09qdesqx4+K2besiY7hu7GeZTnl6PeOT7vV6M8CGyuBvq/gwZnaCgMy6cAs5pfYpm2XxIM5OpVNQq2mYyQENeHrf8gLCej7+KJ3bbm3p6MF/zvZeAnD7irlGCrAuQIZJdQ31geGLRo2iDoeyKS+MCFAvmBWZCLmSV5+EccEhWghwJ1lZhWJ3t87nd9zzKDhhqUXVDwBUFIUNr/61An6hVVCzCXnqoTsDyohUAL9ARX30vBojI8RRwCSN5rmnv/kv9gVEH/u4uR/ycK6qoxOesZpTXXMwtRzALDXIAANnBseioN4MIeHXlQqHM1xTbjXonvtbmprijDVYcGNvooiE13CgMRUg5g+4SzO3k+iKIHAwawIjPGjCSmOBE/6aeTpqi+J195r/D54WGr5eXA/r8agtON98fbST6paqu0aG2E/ZDzxrCzj/Yd0DLsHZJuLzDHnDpefp72dhaBDQNQjAZB7DpbUnQ89VJMptoYCOlJJO7ytz9R7b/yAMSOHPDU1+ar1eTxHoMn3fMwN5vR8NY+kHmxsN+f3ZvdWzwUPMoVtjnJtddSpWFs0z+sKfvuQswaZZ1qdjqEynJTQZ3kdITacmWWsEH6acyBJwnIuuDDgeb3mH/easm99bw+bJoC0NaO6tPUzWMGaPEKX2UkyTim7jUmkMpo0+xPNbyzxjTb8sOtHLH4IZqCAZMAd5lMy4FI6YDubXbggWLmyVIrGBi7g7Y4KjrEfXhvkceo/BU32NMgnm5iS57ov6h5FGqlDMfBrierLoENKucyLtfVRmwAr08wxO26pcVGHRJl9UK/ccgqH0B7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0CatCyShLiSqHEH1aPWDFqVOV/vfSgJYl8iE4IYlBRLHPtF2qbkZhfv6/abvn0aLpc8F8FKGyaxZ/q5JjOetZNYIp2UwIafc3pKMByX86325RGLOGRmQ3ofW5AP/p3q/sRizg4GDHwFLj0yFgjTbkIDY/4AnV05FSzAcO3Lzd5uhbrnesfm3ugz0l22N4zNSCtmVr8m9hHR4CDC8q5OOlwuCPfhmRbVC/NDHrpyaQAx/OjVKGaDFbif8yTFwvETyQIdpaoRrzGwRIshh1Mtr/ZhcEjQatxpoGAbUgQCpjfk/gN+XvF6bb4tIyanWNzOdYM/h51ZaF2nUoYQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd5702d7-bca2-4dd7-fe8c-08dce3097100 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:27.1303 (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: CxENKvbSF/JSphGbPHsJFkFop/t7WnrWbkhA7LpIf09YsSbKXfTUuhUbzO3vHKV28xrpbQGDTE/DT6ffIaodZHh5/9vJsz47FCHFfiQsbwE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6047 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: kB2CPiuApyt_joqbAg0aP8fHyxUlOM9a X-Proofpoint-GUID: kB2CPiuApyt_joqbAg0aP8fHyxUlOM9a 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 Wed Oct 2 17:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820170 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 1720E1D1747 for ; Wed, 2 Oct 2024 17:41:38 +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=1727890900; cv=fail; b=cB8EV3G/zltTbOh/RZqOZ+JNz1yEft0rMyyONEzT1A/HJIqsATLu7bg4KHeZeNtPJwsGZpxmDGBQ62sqo2FdeYBWsu8sDVMweHyGnkmudWONeonWdv4lcL+QRXbTTpkVemYS8qWOHj9zRPtbFZB6Z+Z/znjvbaRk6pPm7xpx2v8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; c=relaxed/simple; bh=1OFV9iN5b+0ixNonCj5IHEOvOEoapRpl94u8VsJ4TEs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tJelSo858L8+bEKFz6H9SbdB5CXDInMPyVNCdce+x7Vr79FHNvf/e8ACUj8Tg0tjz8U1jJ73518OZgwQUYNMcdimfCmcnvVNZlY4cnfLvIgpp7krZCoCgofn48wxI2EDSQlPxQFfLRxZ2FQ29pxdLnaMMos6tu8WOoMWanth8Io= 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=CHe7P2Hu; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=O9Y3Lbps; 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="CHe7P2Hu"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="O9Y3Lbps" 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 492Hfax5027404 for ; Wed, 2 Oct 2024 17:41:38 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= CHe7P2Hu+cCDDp3zfVx6YAqQUrkKDR/i7/lMh2eY+tE2duBteU5w4w7rhkkY4AkU JgqhcIf+jiRHHGOtox1Aq9CEbpROl4Ysgt6+s5CTX8ntQ1PQ0a8t0k5QHAketoP6 ssNhtslcIdMcErKuJIs8WWWU6nEtriR8TsasQ+p6tBXYeFGFIDPHX9DmngW0TCKo SNnBwZKvd5/PxrIrP21qomKVxB72Bace4HQBWjju+S6iE7rBLk2CD4RUlRX1QB58 0Tz/pOhqmXFcYPFT9DRBBLmLjM7qTYNvdnhYLIM7Vs4t0nF7h5r6AZPmi28YWW2Q CqNyBEWiLvlJQ9ez7KnWqA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x87da9ef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +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 492GskhQ012527 for ; Wed, 2 Oct 2024 17:41:30 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2043.outbound.protection.outlook.com [104.47.74.43]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x888xg8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p/SNOE1/vudf2RrRku9ay6qJv3xV/+O1g5bvLGFDtbXo0zeiWvU32jG9FbE9Vsd2CFoxUntrVEhYqZPn4uBZFIf/qzAy4qbykxD+LAWHd7hRvpFo5B6M+u+F+fQlH//ePk95NqV5BqxmVNo/V1M8cfVVqXmA+SnpAyfA+h0BmQmV9PaSxkD3LYudwQRTUwhnAhsqYaBmM0NiI9cglyzwHjsxxJdVtfm9kHgohxNIg4mZVeZVxhV7enN+/e/0a7gIKM8BnaURqqBTmzcKLQr3SCOfIXTUgI4bpOfUuz7oZjcqCPM26nKPOd0BVPUxttD5XzKOcoJ6yaSpSagC3Hex/Q== 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=xUWo8OU2eOW3XMxOIcXcvpsmFmPLxKzAB9/8wo6l/QBFmPKa083HhdpDBf8SONTpWE8oZ375G9XlYlLZgvHdUpUL4aaAujD2gBeUPjlPP051ZxcdTO7V2TOhFmjyklRBOzZ+fmBFRf9VJTHrHd3s+IDVGtpg87ovaYn6DVd+PNgEG5rGqC3uli8K0SgETKRfE9gJ+MZHBRR5uJXnNqq8mV5kZaGYKX/W+xbzng8OyqSGSXFWbiO2FHX/K+mi+859YLN4GtKyvTAHvxthwzvU8JKBd5day+7W1jHVbwWAmW+VexcebClLKUtz0bGoJqiyM3pc/Y1uUVQ/4c0zAQOY9Q== 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=O9Y3LbpsP/5V8mLiOJi/akTW1tOIQIHVeMJG6keg9Zvx3nLuOrgE6qZvRbs4/DE46M0EFjOOIXDwVIRdfUyToXwduYUlzAoHQwGsrmRFC/8EQQRYd9Ba0TuPvxeqx6mG4Z1yB6tLDlvRtJtxxSt0bVB0E5ou+8LTfOvu1lb5Kec= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:28 +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.8026.016; Wed, 2 Oct 2024 17:41:28 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 09/21] xfs: enforce one namespace per attribute Date: Wed, 2 Oct 2024 10:40:56 -0700 Message-Id: <20241002174108.64615-10-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0027.namprd03.prod.outlook.com (2603:10b6:a03:39a::32) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: a1118040-2930-4653-039e-08dce3097204 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: sx8jasY59ZpNlmyxVSc0AWgVPLhc3+iwpUNyhRyGcWTsm3+TzqNMkNrFz+XUFOCyyPhGULxrgjnN4IdkEEMbl7rGWSMTNbKqQbwj2ri85jZE8pLB3/TSQCpsLU3byj65VLhSVu13hbhjfFOvD7xKEN1vMsl8C0FB3jTWdXWwRf0FYF/0cFW3HGK1vQ8PFkwEy+rZxsObn6UyspttYm/2PJpqjO5VuTdqVVtc8Ryd+XDmeuB1VHytu1BLfCaFo0M0I1y5cdL7QDGeBnsdXgkPG0UZCLKZ1io1W0fXkEILdjwJ7PPPBGySJ44DepNB+J0bPNM+sOvGdVcec0Yja0HbejapV0G4v1zhGxzJ9ud7G7SJV7aFlOg/SYqnCTj4Zbk7VydhatPKLiSPAJST438wg5yeF814wuVm/ATXnUofA81tit9fiUs+R5FGf7CGyGh1cTkEWFnL/sdjS+Y63pyXWRbm9UVmpyNWxI3oWNh2Zh5N/wshkz7qs0o1/buzjkpCzvYUFgAw0Xs3aB+QiRGWB+JaRzqV9wXFs3lV4l/pmJKYaZ5QaT0NcPCMrgKg1RVvh3AEp7Mgw9rJV/3CfE5tr7SSORwwPtqC3IOePqPNFEgCkchZHj+zHKyLJGaK+/9W+lN3pYKzXfI6tug0KaU3xTICXktt/iSSy6yFdXL5nVDwOiCNMyOM7lLK0M+20Z+jWlyBqP1grezaIMu5zcc7LzqG7oRKWLJVvqmhJD/spWlFbLAX0wPoEIb/VHJL7fK0MvuB3Axb+MNidANvmyUIok1F2IFNHled82cq5KFHa3PcSjnrxeijK7bE0sPRz39AUR3EjN00lrFjH+kPtAf7rxSwU0w9ufBIv3jPHODSKI34afkzbSvpLdAJYW9V11xBWM1daqLSbWQxmi9B0iAUIK2NNLBCD+fowUoR3pGYTfDbgzfSH5QDPyKDdl9CY+vA0gxy7zhYr0AqACSADPFdr9TjgfXSAahHXF2tIEKRkpMsYm3H96d8lE1Qech+kpbbItssVNEl9m73bWgkOh4Kjxfjyykf8d9WvgnoUUjxW5UQAYRiLzMbZ8lQnfMiZ8lCQeuwB9GBP+z+efth+Q61OdpyMLHhfNl+Xm6tJc6b9KR6DUwL16aBfkjBkQZIyzPRphnCx4wU9y2d3xcIq/PKK7KVpvg/scVrqVOmzSWsfmwc9nc7SfvxtJ0WNAF9GDq9lNVneNG0g+/axxaUGJoxEPKcXfq8zXx55YqupmAtviQG26VBI3z5TJGxQAvfRvS58GQVD4zYVwxqSHotYCiMeQ== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VVtO0VZ5CdnQFdzRTYZ83JJxoZvXedi7gcSsz7/KGz3FbHBNBRcTNo7Nwt0leKnojCkJJQufA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VXFLMvuCBK6YcKOlYErKkOqqzHi6JwUdJ2QO7gNcPBjs5xVb4ktvd9O976fJYhh6MahOMoXc+exYLx0E1OYep5phYIHbntd6vCjsgI0yHrDPXqmsN4NId3WgAw2M17X6rPOtO6/uJUMSkl/D6+SVBwGRI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1118040-2930-4653-039e-08dce3097204 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:28.8274 (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: ASkTFWWsI8v3n+uALCdzaLwznr8fNmBOJ/Fv4t60L27INYxzXQrjDqcIzg+COjkVz81BsAm/98Wo3xNUgNQ38Kx73K90dO9XkYCafRd2V1o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: yVcIGgYZjm1dMnNERbkGIHa4y9IzwP7t X-Proofpoint-ORIG-GUID: yVcIGgYZjm1dMnNERbkGIHa4y9IzwP7t 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 Wed Oct 2 17:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820162 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 999FF1D0F74 for ; Wed, 2 Oct 2024 17:41:35 +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=1727890897; cv=fail; b=fIviiUy+1qdSiEPlEteFYERBq2KYncPOgCrnvtBzFGXOvCdCQkiPHSxUIWPm+hPIuPIAAPGbHbvTRUbMnkhNhvcfcBDcnJwENFpIYABXPwV9M1w5HqEInzdoms4b8abJ2yDEGpalw5X+KoLW3beD7jLyqiXQ3cTDvBT0XUtaq0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890897; c=relaxed/simple; bh=eRXTCtBtXvCBu7/qEje6FZr53o/zmKldRfeSYgKKdXU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=eVOMRu+x8ZytoAlrWQRct8rNihL3IKcK5CWKOVkeLDBByVRZ26BRU6psgEow63fXR/KjjeHH+1WdD/sUsM0NhjMsvfXEJJz0HNi3tYj3gze3hgCihqReo1ZnJ5HYu2NI+ZUR8SIe9Vfsnd2sKA63MBuMMS1oR6/IkB2RTiGVNzE= 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=J/a4Fet9; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=uRUtKobE; 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="J/a4Fet9"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="uRUtKobE" 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 492HfYa6013221 for ; Wed, 2 Oct 2024 17:41:34 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= J/a4Fet9hgzf7qdT30ej7ZqrrH2YUTczLfMEsfVb7Jygjf78gsKipq0nsp6H3ge4 hfSk0F0n8A5Kh+PRfoECqlM6QYAGu0Xu08mSprCgVesuaiXCcOB6uEnZztycT3Xu jHlVyykoAM2nY74zXVBEWZhScawKv71zcV5PCU5VS/AA2cLeyiU3unrYt0KWbbSQ 2Ti79RScJndsyoZ+9J46vul6o0Vb6lNAkRJXRwDNUDydyKN39sprnpqFaONPj7WV gBPhS9G7dtdGEWQG3URq6laYHSdWdJ2jhIYrxpyHiiBv9GSNU4+FWHrw5NNeMfno Ua00+2yvDCJn4jm8ABYzgQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9ucthqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:34 +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 492HEKWL028477 for ; Wed, 2 Oct 2024 17:41:33 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2046.outbound.protection.outlook.com [104.47.73.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d44x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XxL/VYgb/XubSLZN2XhOaL58hbck23D7C01UmgjipRzYF80NLqdcagqdL1OT3JngILZLtZXY65iK7QnsaWCCnwW5afqgxJJMsZu3axTHIjeFvxs5GALR5dr39SkP96rfNSm1JXcwojS8/DtCP1huvR2gpWMBe+u9ZMHsrhdjd04sCUnS/DQaCXil+sz+GlBgxujapzlxVkDF+BPniKJ0rh+KY7J7DydL4odw2CADwNC9hAI06IRBftj5xm7xelLJDUSYLg2xz+CiM6DwR6Nk7PijXEcfmRu7noCqwrXeWCgBxhumJt+u8WgmTOA9BZGZSwUQ7nlFpBIcZjBEh0TKZw== 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=kVYO87lUu69bN9BBsHiKxxZYrG0SMGrajtjz+KQZZVFkwE2D9rpxO8bfMv4tdN/yCOJicIPT4I0MZDASQjjEiyi2JNQ8aX6mCnpp9FlHzpWJcuPY+qG8lE9ZUNWOBbeD3k8qz5wteD1hogzQlNu4D9rarpCPJMVdpnArNIN8PBJ9kYWTDyBn8F5EknCJtVWRLqGAC/VJgQeem3wTiEw5C1T5DhGuPGTy74Tz9CGp8Co9dYyCxr7ZD72Y81kiFXHbdUlwnSElcGgGmYP3VSVH8U2p3KOb7ZnmMapsv7vLoZ7Vvrmmej/H+wu6JDYmqyznV5WHdZ5230EgTkGfnNwDKQ== 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=uRUtKobEu314r/PxlMCx2cyU60G5qHQbwBZ9nUydLJ0CFm2LMSTi6YQJhtw8zdiZyc1BrVl8qbVvpBZN+PcFDv0YzMij5HGSpTOUio3evPfEEPeH15I7zwNDrr9vpGMlso6RB/Kix2sUWd4+FHV9LJNkaUYYTXhzzjvGXOA+A00= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:30 +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.8026.016; Wed, 2 Oct 2024 17:41:30 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 10/21] xfs: revert commit 44af6c7e59b12 Date: Wed, 2 Oct 2024 10:40:57 -0700 Message-Id: <20241002174108.64615-11-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0017.namprd03.prod.outlook.com (2603:10b6:a03:39a::22) 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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e62c707-af3d-474d-4779-08dce309730c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: lnAujW0pZOzUJh1Qc2v7htn4z8mb5xp3C7UoeDzaIsoTV9ch9LPNiIC/sElRusJfgevdr6vk86I7ebJYplrhNDkAeWoyV8f1BuZaAjQWLcjUB2pVyYcSRJESCJ9jbnn/zNWtquz9yLRFzsmXo2ar9M+S/PO7O2zxVQrY0uhxakfU92WmQRWcfBV+bzlFANRqc1kGdkSRo0bTODyiK6U3bJ9eCkH51qUy13D6z3PB8FuDOmu8lPyHl8pDn9k47HyIOuXYopAgy2OJOhvT5Hd4Ke0iB6oi+2OM+WwPMQGj1thhbnE6zlQQxrhcsT9GZKMmwAVhoGzoxqBSWCSISahWg8/9apLsIOHWbIXcxPClc1AGr3eGWc8T3Lb4eDssaPB8Zm0DErvP3dg3lSv3D1QWEwpYv8qm0KAEbKZghFbyARKudHak8AA007Dky9IIINNyitMXGlsJNc7mWrosccF8rEmzr9iLktdlwMRhpqbYY4xMSnLPfJeF4H5YaUloa+jsh3kxxIdsE19bBuTW/SqWBKjdtmYjzbpxTO1ttlPH5hSIfa53C5BLfo+PI3Dg1k8IoxA9pJdGKg953QKjRHXe9JYNuJLa56GPcwUrjxPUd9hUhqkEDlKSPIm8KFJIg9/uFMaGLSHipbNkoaZGAy83Sb71Gwu4g5qFz1B2fpAE9pajcE+8mNDjd1oHW8sZYEEN6LUL70Hl1dzR4gZQ4S19lXpo6BcYbzc+mDPcofVaa47/OP913oWUfqE+wzxYMsd885ScfNwxLi1rJ1SV+OLX/fQYbJQYTR99Ce09hoXnw4oVVc9/rDsoX4HlXm3PcFmJSmCj/l9UZ6Ai2LIEo0d6U5Olui2GaWTVxS10R84lv3z4b1XTfWd1lOAefNf7Ht2aixACdRt9vy7Cii3JARKlpmghvtHEo0dFQ9fWpyuSPHeJJB4RCZDifd8FxBp9jxcj8TAhTg0DaQpPWIrqXtX+zPvgGWeqmQce1uZFpkMbkFl8gUryj8nTCY7NVWj3lsVk4i5nui1aIKi7LfwoPSTzXA2F2HrtCK/SAClRbrqD1ZPrZLtSPxir2e4lSVsK9zHzWmwASkPRqRsq+jFqawpjBHsSTEG1Ri7W1qXG9+02zCGl+6nhv3uD6CoqLt6VKR7ebiDkAnNhN9OoXbH4Li6xwOWUGcFdyLs/MaY5e/CZ3K11Plv4lr0DWPWBlgBCxGmR0yWGfKRxCOxyHcQmkiraNGVSbHUWJB9HE7OcXAj3CdeNBqXLt0BqmvEMH0KKuEALDXWN5i5/N1A9JiV10b6lIw== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w4WPO11uL0Q3luGaPMMIN7hRRgcOtu7rbtYqzJJGJmJ4vUiCxTHApOq8r+rFrVW24rBSFhCiCpMi0g1zLLQq9jKH8MeZwVUj0WvEPjQkFywO1BFf3aU4I3cBUjQMbDBO202suXQiPYG5AyO0OyYkPQqKeI+PVBrw03rAcWxkC51+zn/lizCdT1igqT8NLlm1K0Xsorbh3EYyRvyzoSXGOtaMg7FpIGVlizHAemQ3Iq6proKl6ATID46xzS6w8TGat0q7QcLdi1j+88ZiX2r5UgnrrMM8Fy/R35aj3bT2yRIZ6kuKFPcacfcgrIMxGKYLC5K601zv/tIYvM0yHJJS1JaV6gCUgHb8XzVM8DRCJm5HcYFI7ELdeG2f3NMTgUmM4gkkZ5R1ZACM8v8un0Kx5F4bUgXPCyRaC8lPLNRhbam//GJjSqRIF8VGZjV4dQX9HEYAv65wTFk4pkTtTA4NEU3p2qfHtxQTku1uuH1oFC6gCdq8VLlYQOsBgk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TWufZKb8zXAShtrFlhuEKRwzKTtIlUV9LFs6H6LNl8+KBv0E+h3+YI7TdlRaZQ+UoFlN8Pre4FlTr5RI7s919CpWYER5MQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: G68mROuPH1NFpOTHeWgKNfht+efn+zGEy7M/dgsY/94ljdyG72HHADC+Wx2J5z/YKDRI47RJufopqTVVuqDR/Fp1SfpA22leswfrOVjHfcP18cVULLiwcuIHfGQzCI181luxg8navA8vof+HmrVSeQs+cfPBiSEG41Yl1iJgAooX3f+agqKDurNXE970pzuBLuS19v4spdqvwBfuW42T2u3ayY/CZP61LA4p2ba6DapnEoljjqP21HSu6vsEZAF6RPrrGcUt/KHIQUaN/h3ZCtzw4dKedtfj2IJV88CluJXG4dIz6zl4FG3dFglDbTfMl/ljEM9rTbCqcqyOJG5VSlZvTVvIYuoSaae+RW2zMnrfXiEZBtAtsjrZpE8oyxG68o8dDk2o+A0NwBmG6UV4dYNA+yXxECGyTGShObQhqLLI+bM1C4q4cpccq/3hXvFXbX2NkbBIr+iab8cdLFqSokGNeoISaPSk/j6r/pvBtgGWWcXVeeaAaiIBoSW52cgxSs+fsUx9H5cAXaH3n2l0alkl6szwdxElbomIFQJv018Siqjx+dtGGwte5UXt0NSJv9jAl/BXifG14l4+4c35hmdgqWFhBtq3DPp1xwbDIJQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e62c707-af3d-474d-4779-08dce309730c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:30.5627 (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: kbBCBi2GAApvtrg1whLCKmlHTYFJEdGfGMAUB7+7DN2KbB9ZSbC6yihCe0ce/kkozUv3XBsb296qx6zYy2pZkX0w8enJdJ6uQ5F0WYZZYeU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: TICPqz68NwuSo1lZyMcBkCPIhtiHsEXr X-Proofpoint-ORIG-GUID: TICPqz68NwuSo1lZyMcBkCPIhtiHsEXr 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 Wed Oct 2 17:40:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820163 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 04FB51D1510 for ; Wed, 2 Oct 2024 17:41:36 +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=1727890898; cv=fail; b=ABhL9prfijzanig0gPJjjkMMgYI4HVvqZ6IfDwELk1IgMYCLA6CYid6lGInGtKFSGbe471bke5o0hy9HpjMmZm7FXirpEg1+DPFpjw0hCHjidW2I1KR3b1+jFsYeYcKwHFV6FLKhi4rm3a5vpWTG9d0KVcRNIUdB+caaP692b10= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890898; c=relaxed/simple; bh=/q+tEr9kbY7kGyTmxdqdJ3oV/ODKsw/QKNy0C1nTQS8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HGPSwpt7jLTiLZiulX2ZyE+bnQeuCz+LZt2x+0h/d4cHPjIcr4kAxoIh0yOknzV42tas+qUr1JTez11lZUxTMVmGXXXzcUEsjSsetf3vg/IFdEdjcwu+k89ZQSLv3EeHxg7uFD6gwovX+b4xYCAIQtS19quPau23zUSLyxQc1sg= 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=Fw0yYq7k; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=pV1jn5go; 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="Fw0yYq7k"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="pV1jn5go" 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 492HfYa8013221 for ; Wed, 2 Oct 2024 17:41:36 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= Fw0yYq7kaJlRIszqtfEWY7o/WiNyMEBiPxjwd1sULdhWS4Rt94KPvmUjDytVsBBk lMeXrUesVGGorLJFyDyBvpknnwPcKsZ985dulOJ8yoUrz0bou2ZzHoszxJWq4phO OjdBizR8acYzZ4JsVB44PRf3Uyn1gbwXijA6dT7leraqUigVePlM2x+vfjI4SrVr XwZ/ihTJwROai0dHBfcbhteNRJLkZrgyV69PwHv+EU5xACQE8+KGQhATIs0J3tog pAYyzdJFvmiv/F4mZYamkAN9qQ3f3o6zROzvngULsUOamjyh8MtkObHxaEsaWvbe ldlAK/Amr/BT1+NIeXooJg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9ucthqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:35 +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 492H7mVA028453 for ; Wed, 2 Oct 2024 17:41:34 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d45q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H4YuxvlXOYPiUrE6BcnKXfjN/eQQZ4A/oL5pNo7BiGDLPOIOyQvCrGgKOoB6aYSagtBaG0Wq8P0WFVgLzkPy9ZZWj02Er/abmUe7porZGGDqJ2XGeufmnjHQd4DbLw5EdVpWdFT0H4EVf7trYXNoEHI5/7A5MF9XXKykcUsFg1wPyzSH0KgtZUkxDsngZ4s+hCqFdAIvJz+VQ3Tn3D43xY9h3+Ed0weIWpS3EMtmhEsbL5jDl2dccqY/ik8rbeTHTB93l0LTpquAXZMqayX6rLq5gMua+cUy0ENKuBb6rcENER7oJIz3PhMasgizY4HF9PZ4rbPDLG81QSt4w24fFw== 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=pBaxG9s7+koG1juI5xLwtjZofbFDkDEfXcRBY98TG7w61EchLEXVvpzmhJeRRkBOsAuZUhlRKPtGgp4vuIOpEz1AD8EDmYOYMKHrztP5tSZ3Hnsh4IknOkvghNCVqdi9q6+QpR8sb+knBzvRPbGTPHkjqNVNnCZeaAmBqCh/qVn+xNCrhTW1OKiIAjjnp9FTxdPiOl0iW+hF+64xOWqpuYKqU6gyd0UtMvi73mDlhEc9H+XngveSQx0RsHIGvXYdhA9LoJZklq25izAbTJUWdnApgLaeLPJ6mj35Vlzr8KeqzZMcHAF93ymePnbiZUe4mfnkLSFhjeQdydytfg6Igg== 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=pV1jn5gofHd76clay8/LZCkjttTOfaj7WxqlxEU1PiekFJiDIo6J9x9+o9ZSvsJ+p33u+Z+D0O8M0+GMEdQyL5XcG3JFyntXrxDtiRvyQcjeucr29fN9KS1E4zqzVMgmhUppLIqEV6iZhJSBmXy1IPkdGQ4LUvyPBwmoQCr5FTQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:32 +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.8026.016; Wed, 2 Oct 2024 17:41:32 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 11/21] xfs: use dontcache for grabbing inodes during scrub Date: Wed, 2 Oct 2024 10:40:58 -0700 Message-Id: <20241002174108.64615-12-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0018.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 6784ab97-cb2f-413c-dbd6-08dce3097411 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: nkmfKmuHUE/hOoMchYIVYGY5UJuyekpDl4qu/Vr8WDJkxmxJfP4XIlJSQkX94ypYqS4CskGSMZEJ9fHk2cM2aJiIlQqTnTRLSgwd6g7HClnmYBYi7BYbiJxGaJQOT02opFi/V984jMjm0wKuRB1fmPgySSJ1riVvC7nwlpRHo4HN/7O0mieRtZCqliJZ68w3ZVp52AtYivp9x986xHIc/GCieBcyOrCfvrp0WxCQESjcW+q2R5BVlztkcSU8tUKK34/MLBsWEKmxgnO2M8bHGHfCPLJowwf/Kc3h7/8VWS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:NSPM;H:BLAPR10MB5316.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iJE8EMaXgXqG3Vy6OwUXwVehHbkFNkB1Gs+Z7fkad5T6BjmXk/tVp+2yz7nIxC4t2c8eoR15EFocgIb+fzOq+otRXw8NEwBgGHeJ/3DQILOCGfAY5+P4Bi1yHf1RsVFVNITSpsghDyvTO8B7pWsxJVLA52MnmI5rdp7AyZx1L48+PS61J46lZ0wxNcoRQiazKb2RokZ0KXTUR+gS7ZX2BbzTchGH9C/P0mr7vOQ3GEVihLz8JgRgubEvGs8v1zHQTjHlcojnvkjtRRvnvdJZgY8UfloTjJkE+g8GS8PVtEPm5EIHb0q+YokddrHOYRB/+XmP076m7JrMdw9Zlw6kGkWmiJ8dugL9e3bKV0ZPwOKsrfYaXcTImr5XxJCPKdNaXESGfGWnp16VWjxCinmbyIZ/plIelWK3GVhHNouWMo1KNwqshq3BWr8xtEE/Uvop/jkeAY1H5ynd37av+ux1JXTD8awAYad5+7jVhi3808ySOb0f6CZifpMYpYBIU7fAihaZ/Vld5wklOuKTXq2h1Nmd4okoHeIZnoPTPNLLkVyMjhbne/F9OZcuJdNQU6cWO5Co0eIeqdcAmcIxqESNRq92VmkbvozPvBhctYQrc+lCAwltYZ1raOS44danZt+5rowGBhCSsrQX2r8jF7p8zauGlYq7v1iwv6xD8AMKD8C52GLLVb0cshsrMwyBmB7Vkiz3NnfNPB8NADZqb296kM+hOpsh0CELgZEWvFEnJPAk/bvdlYB60UUo8w5qgQQtji2B0uyoCtdzlB9WsyY8a2y43bdjhO0thoMuoF3QQGE0wMK1gXpsq7Sl48RmWhCvGScXCMAQH9Qk3AYUZMI8dbijzx/JHlbyt/+tP/XlQWjQRW6WszT5KNt9c2LNh45hhK5a86sTXofBtpiMUKLtP2ASEVovQxOWyT72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ohzoXLtloG48m4/p58s2l4/zA6njitPXyyMaZcVoKQ7yKIiTuRTLj7u0aEBFBf7G971kjz7B0EoaXM1AF21/+q2O6oCm8GO3obCQcaIPsIAvEAwq+ovAyj4CMO93+xTxrpCxUUq06QtkS4mEurBfJ1YFxGeIPtsVGJpslB0cjlD60B5RMJ9JV6HD3X4pLyxKURmMHlFfTX++57ujp2QGGvFMsSGoUdQathjvzyQdJCBmona2gkKWrdDeaM4CbykdjiXDZB764bssbTp3fL0BRkhnH8QQ1ld4sxuHnmLnyaIOMZuK6X38b0XJfqeevJoF2L6AkBqTtUM/35mYlQNEqxzlhp6iNTNuT8VI0AKDXoZc3w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6784ab97-cb2f-413c-dbd6-08dce3097411 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:32.2544 (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: zn+P7o6zBQqArKFCzqOUORY8QKdmfnjncKRE2LhT9us3/kToy7tQ+vKIaCYCbCKXKItdrOd9zKmZ/710956E0k8rOPnabsNNHW+oYkYYtuo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: _3pwPq13L34BYX4MUNjlQhVbpDsIvOot X-Proofpoint-ORIG-GUID: _3pwPq13L34BYX4MUNjlQhVbpDsIvOot 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 Wed Oct 2 17:40:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820166 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 A85431D1739 for ; Wed, 2 Oct 2024 17:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; cv=fail; b=WbrcxBv4dsRotecyaAwMHn2Nin7pdwz3Vzp7233pX4W/wJWkvXuvf4WXu2h5AcDqovOhH/VCyVOYFJaalHSrQ56Kebbp1xBeoTJJzzCJgmaT/xd937R1IkWkc9gluRoOjgS0cAMgfOsnBkJCSvmyaz8l/eZvUw2X5Zl/H/JQ9sQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890900; c=relaxed/simple; bh=SL6+Msyz+8nviJDDpxeh0RA6u71TsjB5MgQWo2b/poc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dJ7auOHA+xNZ1bS/PwEiVDZcF66Fqo5HOHzm7cc1b8J1C/zxkxvecg+I9ssZ2R+yWR9QghMstM4TQScU1ymRPOKGBCUvoLJ80QaRoo5+Ul3lw3rKUJcKQrBLg/mLQ5VRZ3B0LFb+BbfH8kmLV1GewP3P7dtqQDc3+FTViFWDwG0= 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=Z3VYR+Uc; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=cK7qXXlR; 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="Z3VYR+Uc"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="cK7qXXlR" 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 492HfbFR007549 for ; Wed, 2 Oct 2024 17:41:38 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= Z3VYR+UcGz67IDBEz75muNSxqR2JAfWnNoO9QsoZRhV3LUtXWuYsv/PRhQH3l73l du/XKayVanRiCHAYaObzIsv4Rne5cjg3yLVPYgGsTholx25STs65oHHg9YqkvR6s jW5ItJwyTVjb8qfqQK/X0Cl2cMqwB228c7y/AJDajuyNdbes9rZG9jYUshbINzvA ycUhTdpyxaOof+z2l3sbEGc5AugaqNtFbycuUGIjUMbXwi57suEl0s8nmoLkPyuC PK2q/4XXPnMJzTIiDGpu4Nfyz2aT0fHOxySU84LZQme4Vk6d/s0qqbPMMzCrQUEM F4jg3nEAZ6Uooe+rQ2nrMQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41xabtt6yx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:37 +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 492GtGhe017512 for ; Wed, 2 Oct 2024 17:41:36 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x88951m5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YZPDdtDoqJ0xmxk/f6LzG7gRej477CrzfsiVFQF24CfxGCXjKYXEVvClJLJnqfqsD/jNPNTQDwVmyVhCCzEycE6vgkcwCcxWmkeVH2HVQCC2NpFzWX7QS8I4nv2pDVDm1PM/eJ9dwOd5CYyLaKawCdrOLqBI2V4aFGqs7p1KXsPr2m40WuBHL9Zl364GMuZVZ8U5eM8sYstcEN37Tj5KxILjleGe/94aMjod7FmKjmiav0JRpt77M9pYaGwWSLVIgYdSgF0q+oju7LlG3vlHAs+Dzwfi/BSWCqszYZIiu7gO6FoWi7v9hj5dxxXNkWdkB1+S0r6IN6mX/gKRN8vF9g== 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=iJHkQTFTuJycadKlyvzhtV4KPiiSqWLLDNh/+jl3EkwQsg3vRzXJjGaLnJmWBaZg801bS8bSzI3T0T1TMJ/Klrcp3p/N8ns27ULas41dc7mtZZ9EFlVS9yBG0W3+HjHdSrpjUnxaCWLlHGkVaM63GJvcoDPXU7kdIqQYrpD7/f1SYhTWmzO35lMnQgEW9Gw1lIp5mTe5x4z6Z+bilZr5gGLphCE5njWwgat4ejtIR635IRcxYpPsl2aVlC0/tLt9bLbH7OuRu9lSEgqjlDtrqs/0d1iJiIttU7pIbfesu+m0pra1ANo1NZxcWQ0oGr0LKdS6pgDNcP5gPMTXhNg7Fg== 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=cK7qXXlR8BItzY6xIlvgQocqR7D8nA43eHgHLvWhAqog6wXNfFh+Nl3v8wxfUfToFSF/baw5lHJkDayJ228kg6zxkjAWueITzdMw6V+pmvTlNkm7YV2lU8z1HpGasW0CDGYS8JmWxNhq/RnMII19kCtfUXfmQ79jgZV7UV40MhQ= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:34 +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.8026.016; Wed, 2 Oct 2024 17:41:34 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 12/21] xfs: match lock mode in xfs_buffered_write_iomap_begin() Date: Wed, 2 Oct 2024 10:40:59 -0700 Message-Id: <20241002174108.64615-13-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0028.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 838bde9d-78a0-4610-e1f6-08dce309752c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: AzpjnNZzpBVz/02C+Y0noHoD5EJdSxcdDzYmy4pDfGaIW9LbOumR5+wbElZdxKA4uasf/OwcHE6lwr39dZpMloowslzM5tObrCjwEYAkP0r2u8QD70tO9xWc0QnDXXRuzjjbUCGw1zsycWr6bnY/RK+455dWjAkj2HI+rH9sMA1mpjdzLo4PFeF+99XYCXgcTuXHa+k+BQnFpFiFQ3dvPzLMA54E2FatPFTeJKry8r4Mxxauk8v4Q4aKpekOI1bXZehAKfLmjimmG6xmvKCDH0dJkODRN+LTBjgpNax1SqoFYyoiq5UQjLvx8YPcbMMvOtymh1Oi6YeNH4pQx/oB06g4pkjPjejZ/BNZ2AcDWSk4kJojq4+4/MAST7i+XYmwkAUZNSajwkuUdimxLvSomp9TiVpiXaurbmj0xo59rajshz7sgKyBj5/DO9dvEM2f8Bpv8+M1c3TCKeGm9p5w8KnR1KJATAI0sXhVwvoSO/k2x72ul63BzV3AdTfQ2dHF6Xuay2AL4BzTrz3rYkN1VYzYp0Ht6Y3p7fRoSbiq8x+wyaRNZjJL7IGsDS7T6GfMYcg3oh8x0HBch5fLL6xVszqCyjw+SRI5cV29QabzE22apATHzLXJd9GKuakgGZ1aKcJQ85FCpuWcMZue2KYuLDHT96KH7cUf9brB39vy9bOL8kIkmsmOQVjuKvLm8vh54sDZ+kDYvxJPj/pF54ATlhhbf8j8/Q9hUquDQ6xuxPROdBIVl9RV09tXBwXPR8hCSuI9zHs41zfkmRqalzyh+zBZk/KpefArOfIMqLYyVumajD7WUKgobqlhVxUwfTid0MbFTyOfzQd6u52u/PxhKuJfDZM/LXsjOhbhDHimzilsKLd4/QH9GlR1hw7avAVOTgdd1ShVPT+2wRvd4X5Z+C01VAjhjMINw88DwwIjy4vOf+XT8YdXOdSUai9Gme/UNEuKIQ0GS1w5LdmU+gH0hxDKLLthaT03L9rJBR9s8cKu01kFwBV5NvUgQNm5dMUMoqyhemeeA8ouGHod67oeQDiojVr5gO7zUfIMQc2bdvVGH3FsE3l4lt2qWdh5MROH3DunWUX0n/sbAh/uhQR2d4vgKbiR1ymJf8luCjOel35rakNGfWlEBxBGa8iL6WhV9Z7Vjo/qBvUFfjxdpr9QMFfUvHM0yy0tW0w4Qs77qFAtlI3XgJUSLkgE/goAqlb8G/1OQWYk9wJfXKJPMaZ1EktqGgpmErl1IV+HzL/bidt7Q0UtGMtTVr4zj0mjsZ/u6HtmM9AQA+kMIZQMgoEM+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)(366016)(376014)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9GH8M0A7BA2tBbN8Q8ZdfRTxHMyENwrFsHH5+cOeF8sjwKuw9EwTeECbj9HvSMeoZioXnTG3ubZr8xzmAuAdGSAqixuzTAkAy7gWz8Zij86EXlbM6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8dAOYlSqLnqR0CE5t6TLt0YiFEt1PWiLo6lFOBz4px/0bZNkhn1VNAxFWVvO85q3mJ8S/dH3Da3H8ANiXVnkAYCzG2x+P+roIbIqMD8ochpwBMjBixqNJy4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 838bde9d-78a0-4610-e1f6-08dce309752c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:34.1250 (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: 3sFS+dVeENeenf9Wg3D+G+xkAvIst+icacTB8g41f6mqDwXQUp+hf8lTFTLj5BBa4Fudgud62YjYC7rs5eoeeyYO7OjMBL2752Jq+MdBJHs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: sXCcO4QTGHcSxuyrM1o1u9Ut-tTHxnnz X-Proofpoint-GUID: sXCcO4QTGHcSxuyrM1o1u9Ut-tTHxnnz 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 Wed Oct 2 17:41:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820173 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 BA8951D1756 for ; Wed, 2 Oct 2024 17:41:39 +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=1727890901; cv=fail; b=TzR/MNJ9u9/MlXsZEBH6fkF5c1vzPBu6e9of14IEPWWGH59zvwaqdkGlRahHur3HZ/7hVXE8iIx/MTQmh5KcYgpRek0AMwSypZ9r7stm0X6wfNCNJX1GfNkJBOuB8am6YpKbDsiejJREp3w4b9c11kPLIrLn7krlOoNMwaVtycQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890901; c=relaxed/simple; bh=dA7Q/1PYgseBra+f/5uRSSWKHPAy+tVqlspHr72Kzfw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=XGJ1dvqydiy59pBuyYtstlwh3C9HaVVB/dSs4aa8dBqq0EA8n5Ek8g++Iuxs/9mVK0y+H8j14RjZvHZNjM4IrJVgYr6iFGyE04i9M/yFLEr0ugK4QY1onNJo3ckmkyR2QDDo/FsURksM2qCHSKqWzkryRK2ZPjo4D2E3YFLmMRs= 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=ggibXHrT; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=wzttCsmP; 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="ggibXHrT"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="wzttCsmP" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492Hfbla025084 for ; Wed, 2 Oct 2024 17:41:39 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=6si1YAYjj9O/s2iuLd3L25kJZNC/XDVDvrs5DfiN+0g=; b= ggibXHrT3ye59iHxIB8q6OInEwM9sQ+tMgVOPp+wX5Kk13s29imLlO4c9TuGAr+b jZ3lynMLZ1Bdi+Y5b3BUyHmG9AdCJ6FHlCm8+MSEYt7wBunrjduV1e6J1lYVb/Ul UN2Imz83MLlWp3Tb+E9T+KwTdyX54ZiTbKsDMQjEprfWzayCwA+iV+NbV998M47V HmlcRy0L/ZUysgV3ZJQf2pC0mgzgMml9Hv4r7H2FGW2MI0RbzwkzvYMJBVow6JpT zfZUnudVp5JISRBtVdCqMo3a8PoMzHzB7NBSIXklBdQyW+qODsqY6WlrTf6lDzHE 47x+CbY0wnG5DwoUWQJ6pQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9p9t3e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:38 +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 492GSYYL028430 for ; Wed, 2 Oct 2024 17:41:38 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d47m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bqDL0roBuV02TpUPijNrJwIlVaurVINuLIWLias5oFRQXL7VbTld/nhkKlajsyk8QuNPl5Jcy5AM+Qz760rbIspM83AMvMzkQ+yU/BiJcYyCMWM5TXFq+5/c7hk7rPXFfdBw0jQsaWOgx2q+pJAY9QPpKmF0noOqpvQmu29jEut0SFdA86IpN+LepwFmt4h2cqsuH++VtlHydEQEgaSx5GcoTy51t4mcJhQg5HXNDKwzMQbKfF2sI29cLEdY1Tyt9aTbkVFb/pXAUg26iaef9h6W2uI6sgtSUMGxqSRj16JM1dg5pIG+S8PkxhjwfQUaOCJ2MTRqLVQpkbUYV++lJw== 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=6si1YAYjj9O/s2iuLd3L25kJZNC/XDVDvrs5DfiN+0g=; b=D/ospe7SByWQ0qFbIuNjgc1EiHqOPodyI3kFVa0FDL/gQhJgLtiWaTvG2+/APa4zy6Ag0ATALLq0dfm7B5TN1dWOpYXox4QR22M4jEN5rO5SIX7oOtTJSVS6omntaoNngOBll9UdV0EyRa/XXnvGKg1HrFmt7EUWD1BDMalgZc7PeWtl1XnwXt1hr6QgS15yjdf4xX9EmyoTNdyO660GpO9FEE0qqZOqkrWaVnYdPkbISGftUh9EnGmMnecohA+N80yE4cU73c22S6r3BQA0FWWdq3gf+h64szHvvjIkrsbPCzTSa4syG8Xl6CNeSRVWNxyFhARV/JHpxFS/cBXUFg== 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=6si1YAYjj9O/s2iuLd3L25kJZNC/XDVDvrs5DfiN+0g=; b=wzttCsmPK3KhXm9WRRWOgwxpK0whMiQXGkcYyR9fyFwXFefrApsDdQWLIvwSH5rIcLDMG6RpjLbDeUfccwjJqB+pqUvX0xFQ/mw3DxGvQce3Lk+fK5V9Ff6of+cDVsH13VBJdJVQfPm3zMx4AKoI2BHv3l6wi11iF3sB0oEz3J0= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:35 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8026.016; Wed, 2 Oct 2024 17:41:35 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 13/21] xfs: make the seq argument to xfs_bmapi_convert_delalloc() optional Date: Wed, 2 Oct 2024 10:41:00 -0700 Message-Id: <20241002174108.64615-14-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 345bf2b0-c19b-44bb-479d-08dce3097637 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: rFkO6eseV2g7zxAYRTJFduLOrUvXKRdgsmHwRtmf7wj9Zbnu0VBU2cyt3mcdGAC2oyAJ0kbx5QqYLj8WQx0K7u6/+Qr0zTEfikhjH8i6xpg9uCeXaXgWq/f+gHQm/BB1aNFDO9SaTZyIxWJkvHQPVSmmlkCygdWISHlDkiSu6E9R6j2yEcSK4dVCrRPToEVFC6uSnB9yQbz5CYY990gEPgj+D3+/FWllHMy2i3c0rh8o/UWd9Ukf97oQm7bCgfsv0Mxa5IpitmsRxfdglaV5RfGH8bTlVq/UAgEdaJBmQ57g3WF+Q8m4Dyx7/zJrKAvt/Q/7PWRQEMOH+cDNq0Uim3fbFGsRpPXbW3vFk5h44LL58iYjfIvXC+lR2o09eVjAp9tkVWl54jyUOeXHnqHhpYcZA5Ct2QEtRhZB3YTla6k8JWppqAyHqzfiSO0Q6Vnhy8j/rvDh0H+EpHcN0Ab+vnTO5psu50DfEZ4ZhhLr03zlhVjtPvd2+36lYf3fSrFVI+FtpigBwfl7AQ1bsi6KXFWN858iNBEkA+QCQyGgzOarCU3dElqA2MqDXaRD0NZqEb9A35/KDHALrXhBrKcUE5RGXro2zbiL3YxlF/pONjA0nvmCEfnBCgidSXDCxCeQ83qqOd/b38ix8YD9HVbSsTsaYpMAJxUHg+B8mBX06BZBO2iB6RS9tSm/S9+NzvqAWnHTqvVwliHOemcxKxQg2gMUjvfwHfNnBTiTjH4sCA1BY/9cMAi1UFR/sCrw5jUQCEOw/MPAsq8WQkvwb4/dk8+HPOtX/oLTZwdpAdoShGhIdUa3qmIWvn1C7JEx4PzlN5IsTgrdL3f5anp3+jr6YocgSQE/atY56nVwJ7tTvM6KKP8A3YnWQXplgD+rZbFFQrK5zMV9aDRDVzsEhW8mNxsKX0I5wk8dr8rPXwo1HQV4OlYrexbuQigZSkKzmAmxWBuIq4gRblzBO+QPvI8V6PeUN7NNXoezJTzmpQenTKiNO5DtawmobFMTbqrThL7gPNw7cQsm6AUMyrmFbaa/2qYPE4LuQDKNYMdN+Ksr7QU344a7u4wsic4k4o7UdU/dU65XKWHMmxDaP6sz8eTLypKAOMuM5zQ7T5/vSBvfsFil0yVefpw1cQHsMIHVpese2W6rfegkbiqPqur3Z2lLctEHhkMz80GmA5GXz9wy4PVz/Y6gshY21vh5hsM0M7voDmnuGnOJOYk6PA/q4ww6GjXYVpap6fuqH7Bjw+NcA5xjnCq3/HyhisskEL6wO0NoRE2Hf9+FrHlcBr2WT2HsIw== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-A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7ZO9trjlIxec2uHy5rlTj/zahciGg0uThYMZC+N25rRIcTMILaeZDqrWInUGnxfpR+OuCuXtKpyZVciACWJS0rCh42KAScsK1/m5uw5l3dsDs9G8Jfmi/LSPTmJumqYEdJu2QcvEmbiLhO3NY+8uoQIwrZh5x6W9aOBJ+fdtA1cpnKJ51ySvjWsHIfJSUrJXQopWEt3lq3GHDoC3KgRy/gU/zs2itkxvb7Z6IA6vQwwDvOerKPoGMm7ay8c= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 345bf2b0-c19b-44bb-479d-08dce3097637 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:35.8777 (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: mxeJTSiXuzgHw2yBfLFov0zme2XoIXe5Sw7pBdHg/Q6xzgS5Cb1ZNhXkBjieXWsyFcPlHeiA9A6jamSpOm7YdmLgt0i2XTL8QX9esqNkOiM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: oJJHBNFu60LUgqQ5nq06PG5rGAQuS4uW X-Proofpoint-GUID: oJJHBNFu60LUgqQ5nq06PG5rGAQuS4uW 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 18429b7f7811..6ef2c2681248 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4595,7 +4595,8 @@ xfs_bmapi_convert_delalloc( if (!isnullstartblock(bma.got.br_startblock)) { xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); - *seq = READ_ONCE(ifp->if_seq); + if (seq) + *seq = READ_ONCE(ifp->if_seq); goto out_trans_cancel; } @@ -4641,7 +4642,8 @@ xfs_bmapi_convert_delalloc( ASSERT(!isnullstartblock(bma.got.br_startblock)); xfs_bmbt_to_iomap(ip, iomap, &bma.got, 0, flags, xfs_iomap_inode_sequence(ip, flags)); - *seq = READ_ONCE(ifp->if_seq); + if (seq) + *seq = READ_ONCE(ifp->if_seq); if (whichfork == XFS_COW_FORK) xfs_refcount_alloc_cow_extent(tp, bma.blkno, bma.length); From patchwork Wed Oct 2 17:41:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820175 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 8C8941D1E74 for ; Wed, 2 Oct 2024 17:41:41 +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=1727890903; cv=fail; b=DTpzCU/mtEfPvHap7ZwjNnxa1RJl7AaYZmPymWkQOqpgq2jnF4wxokt4Fig9XirqUIKMMUj8zJZlf0YP5MFYiddfTBBW+8uH1E8zE8N4B5dhYtWImk6UU8LUe7XGFK+UPN+JsUk/3e3a96uM8CTOs55AvQ8Knlc3bvXFzIRmh6s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890903; c=relaxed/simple; bh=0pO8LRFYcs3eC1IL/tC92mfu1i0wgVsXqRQuvkdhc6o=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=HIkYSy76m1bBkWKv0C1ZOBB9+nDdsMs/OpsL7HpdDdLsPpPsp66+syLoujrDOlU66rqzED7NYaz8icKBymX704W/PEIDYmZaYTdoRVq7PXV757VDq7+CNSRsrIyOzI2Rh9C3eFkYn6xc41CCm4ICZQ6QS72IFDmmjscKFmsm46w= 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=G014u3hp; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=giQhSD04; 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="G014u3hp"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="giQhSD04" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492HfcNZ025762 for ; Wed, 2 Oct 2024 17:41:41 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=8vPeoGYpWBPk6nMZYHMDQuBtB+EYkoFtitP444h0jg0=; b= G014u3hptTcNX+XcZH5qh34sbkZyqWBtm3BYCKjr08ihdmBdm1brgntnNt2DADHi wgjgYgSNrtlILE9oPnRg4CSm6k9T5GmFyoDOh8+tQ4CKI2TmOjMbXLKs0tkAALX4 84AgQji60vZVuSktUUv3i4AH1gMMqc6FTxQw5KzP7CMkDm7Oj2MeLV09hpDObid0 l86dbQBz2aPwNWJ9wREOROIF9GtNEpT+nIyTmFuwdZ0fgizzUJwKe5ex3wQazyP/ qkuxZ0mGIXjYvts2U1FvVFkcliIFURALDrbYMaf9h8RROVVyLae/mqPRF4d1uqDX dP3zkMVCNdSwC1Qy41w90Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8qba84f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:40 +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 492HKrad028403 for ; Wed, 2 Oct 2024 17:41:40 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2046.outbound.protection.outlook.com [104.47.73.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d48j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B88NvnNPAWkw8JC3xhiB86yPoGK+c3qHXKSRVjPe7oo50qO4Z8JMfyTT171LqzPCqaDp1m4xBCB0tHu8MRVj3jmwLJNPa1Cl09d1b1omHboatdBVbnyHGtB+4l+uV7nq+YeHx+TkOPovh77/86B+bdAKf7PUY+ClNVy8Rcc5ZmtCMeyaFDM0puoQoLnzmds50xIQKHk/rNibWbYVztw7SO+u/hvyv+KZ/CpOMMjkS8eS2JMl0EHiYa7n5cCuy0nrTv5prUsXVe7M1DM0IrGXwdg6fJCA5VUON9KfkmsFEES1xsFqq9/uTUjZThU1pfddT2cSj5jaexpOe+z28/eUrg== 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=8vPeoGYpWBPk6nMZYHMDQuBtB+EYkoFtitP444h0jg0=; b=NafNnMatsAkFAWpCJdG4T62OD5drK2yLuXirDledRY0JkflSqSfQ3C646WgkgcQ/YlOULjd6GQHBkxBvftv79PafbbvAxmqk8QxM337hxI1bxjHfbuAUB9wbfjrwsMnm94WFHpbr4MgiJxAAhJ/qcu1sLNLgxvMcG1mi4DY0+BNObs1SHLbC6EEfdNiIhEMC0hy6SkiJCGTxwmm/JxpRfILoNRFlJbxy5MpMkuIJiJSOjNT8NqK2EAT2MhEeyJffmGQ/swzIditiVlnwMNV1vcIqq4JgDFupB0n1JbQiHGdYBYLAjaAbEmwCsJubXvrAZQwNEJB/zzCk3uVqz0wdiA== 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=8vPeoGYpWBPk6nMZYHMDQuBtB+EYkoFtitP444h0jg0=; b=giQhSD040Yx/q2yvteyS0pFR6viwRWlkF+kFKJfROUgn/3QkO6X9Cd+f8w/pXKRWjOL0ZSD0E0cQHNsPijOXO9Wjj/cpSf6w8hmWAUhU3QgpHgvheqrRKN9mGnuMZk6YtrySeLcNhqANKG57bNQW1uDfAmzkasICR5/QxNJU68U= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:37 +0000 Received: from BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142]) by BLAPR10MB5316.namprd10.prod.outlook.com ([fe80::a63b:c94b:7ed8:4142%4]) with mapi id 15.20.8026.016; Wed, 2 Oct 2024 17:41:37 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 14/21] xfs: make xfs_bmapi_convert_delalloc() to allocate the target offset Date: Wed, 2 Oct 2024 10:41:01 -0700 Message-Id: <20241002174108.64615-15-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0028.namprd03.prod.outlook.com (2603:10b6:a03:39a::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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 204bba56-3fbd-4922-2085-08dce3097741 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: AV15+I8YMPT0XG3irWxOXc2aWx8iVeR1Y/LYP+cST82gvdQf3+xWzZ8Thk5XsaT6PjlB+ryisLaPRPg1bnzO8rdJPEtfOTC52dmG7U9s4RDXP1vckY2fWnnneaWQJlu+fw6yLPqfIzHqnnEU24Rl7lVzMzgl/H0npjxGJ43HBA8+3tJvBLPTKhcuT10y/XIFeuD0VbgP+1PhYSUYl8qaqTyj41A9R8E92GZt6bex+puU4Yx1Nm4AKttxvoAC+PT0GOe+aZTfL8WdB4Bou9U/Tq0oDQ76nyZIACCa8SSiIAHXgRDFHzA2Oy1q/LXSqN5uq+C667u4ZNZZwmhSahtK/zxYY+C/gseSXM83fIOqDURQk766a2luRBcns6dsNnSr7E8vq0o1uBMwN1I5QXqHyiG1375WNd2rEpeRrhXUUsgOQAmCcdgFIMjadCZT2GQBFVmWb6gyPl5jC+BDkiQD30mlHFbpSWqUk4TjnkhzyQInr+HuKFkXxNhq0iUhoDPvcOnLOVsDWku/35eAz65GGJGrFOvZY0alYnL9AK/lvd1XXfrDGJ1+DWVK9MnUxpRJCeXHdYzdp1S9SJQ8So01gYe7Fd3EbAnSu2RJR3RHB+gF9paAZBxTOIMT7YItQia7wqWhB1/yF6Ku2lJfeOqFSG9eEz8qziBbJZ8z8zu72h4G6MkI8S/gWPQUXbeDNRXtwlEYH4YAIloruEz7bz/69k0z80VARxqV+4fZ8I8T61l8SOIDuWhlT89PTK3ghnNnxKE8HIoFEIRwIXo88KJUho59U4Ja8snDC9JDqr9OxHk/jXmmVB7OnPPcesb5Lyz4quKYVuhZop0RD8u2gIwLcwtS4duDxAtzLZ0a8ZhZ4yEI6wdBogA8CkRV2Hd9ir/Jhbbg4h2SSRXQLdLm3qK+XZJICF2N4HAJ6oHztxx0R+hntuKHtKJzcPU3pT9kLScCXGFiYQ5UBfm9HD1fsRuDLGN8zWZ5+c3jF7kC7VR2jHIaNrlQ4glfLEJJrbnUIAa8C1So22kTVVMHtLnaUDBklb+2B6WmfD7QCTQ4CkbBzDCmMRqIQPRSSS1yomPKBfQdgc5U0+eqHHzXAUDwZnG3GStXiT5e2pTvVKrbI8K7lLnUaHpwLSvLwVVbrPCa/cTmDfnILjChukb/lCriW62xCXmuwrGOVBPVF6/9s3Uc7Yg56NPzMXaW0vXWVDMyfZIzmzQGQ7n369WWRdm2mf9BKosqOchAc/u3zLanrGseJeanTo3sZ1ehssVX1I6pl26dB4j7w0MGBSXqOs+UzCAYfA== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KHMSeOe+0TtFraa3tqBj1r4Hpye1jhJYqUJqqM2R5Re9C4xShMSuji7prc2njOWclXmhVWHJc/4AYwUTzz9TLizJe6plTnTUdmvHspqiKs3bO++U1zZqi/IV00Sjaa3IAqGgx3q2YAeej+jVNuBapmfm+lUAXPxIxMyiVCwxVil9bMumSL7iO8H5EWxRpxIkHFYVtbnvsEKRTThoiPfj9IZ8HlrvDOX1BfwuKfuarrJ+L1ROmdQqRdN+/U6LpBQbLfdyUq3aGCVSNjpf5PoXV2+7ROS8oMWJphkCIOC4TfEI/zNduxeeeZJq5+yPeKBe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UnT5IcpA/zdOJEFIHeO0yVSetKwvRVCOni27T7PeYvUNjYWeihTgzqgIkyPkGaIQQxsWF86uV7cNjwLj4t+qtTV0wpQAWv+vNJt/XWumUYtUgqmpKnbSiz9NKC7vXXTbgWqp3WcWUzalbr5uk5vVm+Ig/4n+mrRks/zAWz/H+uZfeG/VcUanKCKdOlyjPT7JcP5PMPF+ZjUVb9vSQu851/Xplg0pTfWTzvhsjSDUbdn2O9aslVH+Dr6qEWChXpZtoHtrQXPlAGrz0X6pUFNtJsbFdC4QVG/w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: l3gXwfXdI5PJHmmbRPOzRtgZcuFenEY05iZw6NwAiG40f5VbxJd+THWzAZGooaC3fS+aAuSB+GUbkYf08j6fDrv9BrCaK2Z1j1NdsnNGrMa/T3eRo/YRNsPsIsm0Dc5Cn7t5Xc+7sjKjAjm64Ml+bkSogFzcHmbYRr6eOl8bU5J0YwJ0ipVA8Sca9epcX3296Yr/GjxL+YCjB79FdTwwgjM6sGkTqHFYlelOvfOCvp7rdhjXRVzH+Npc+yveBgBF/xmu1TinQ1X0JkYlz0Yy5DdhTHvo2dS7lFeLKT1xdMNN9YSv/VAZJJA3YDJWaGitPDfiSbvRzLuXlzSpNBKp7p79P5Ilp3RdObKpLPBDslpaLiVcsOz/bknJmoCPeMllSw2BOifMYb4iyVEDpiSht8NT8Z9pEoW+H4qLQ6HatYLW+5QLt0pGmqyYUVKbSq6SpgN7ar/Cnpyj1fWna4t6IqvnKX4L89ixhD0TWPwvH3cP7IsmyAnJJb5vh0wu5eP5SdQgWMYODdDfe8NVMyg8GevzxVYCLtZdKowNManPajh3uroFkkxkyObFYF3HYB/Ruts0VByvdhzlFsL26kZ2VnpDPNmMj9ddAN6ru3H4YFU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204bba56-3fbd-4922-2085-08dce3097741 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:37.6129 (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: S9FeiktBpFHN1RY3LfxerGSYHexXYZt9rKYIZRYWYoF8vIRB1xCeTeoeUs6e+5IQjNQCuqqptYEfHtnadBbJgkAafXmsRyNaCWPKnAg8VCc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: aljiIYu1mgwxsf30l6uZ2BPrhXQtkFBl X-Proofpoint-ORIG-GUID: aljiIYu1mgwxsf30l6uZ2BPrhXQtkFBl 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 6ef2c2681248..05e36a745920 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4537,8 +4537,8 @@ xfs_bmapi_write( * invocations to allocate the target offset if a large enough physical extent * is not available. */ -int -xfs_bmapi_convert_delalloc( +static int +xfs_bmapi_convert_one_delalloc( struct xfs_inode *ip, int whichfork, xfs_off_t offset, @@ -4666,6 +4666,36 @@ xfs_bmapi_convert_delalloc( return error; } +/* + * Pass in a dellalloc extent and convert it to real extents, return the real + * extent that maps offset_fsb in iomap. + */ +int +xfs_bmapi_convert_delalloc( + struct xfs_inode *ip, + int whichfork, + loff_t offset, + struct iomap *iomap, + unsigned int *seq) +{ + int error; + + /* + * Attempt to allocate whatever delalloc extent currently backs offset + * and put the result into iomap. Allocate in a loop because it may + * take several attempts to allocate real blocks for a contiguous + * delalloc extent if free space is sufficiently fragmented. + */ + do { + error = xfs_bmapi_convert_one_delalloc(ip, whichfork, offset, + iomap, seq); + if (error) + return error; + } while (iomap->offset + iomap->length <= offset); + + return 0; +} + int xfs_bmapi_remap( struct xfs_trans *tp, diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index e74097e58097..688ac031d3a1 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -233,45 +233,6 @@ xfs_imap_valid( return true; } -/* - * Pass in a dellalloc extent and convert it to real extents, return the real - * extent that maps offset_fsb in wpc->iomap. - * - * The current page is held locked so nothing could have removed the block - * backing offset_fsb, although it could have moved from the COW to the data - * fork by another thread. - */ -static int -xfs_convert_blocks( - struct iomap_writepage_ctx *wpc, - struct xfs_inode *ip, - int whichfork, - loff_t offset) -{ - int error; - unsigned *seq; - - if (whichfork == XFS_COW_FORK) - seq = &XFS_WPC(wpc)->cow_seq; - else - seq = &XFS_WPC(wpc)->data_seq; - - /* - * Attempt to allocate whatever delalloc extent currently backs offset - * and put the result into wpc->iomap. Allocate in a loop because it - * may take several attempts to allocate real blocks for a contiguous - * delalloc extent if free space is sufficiently fragmented. - */ - do { - error = xfs_bmapi_convert_delalloc(ip, whichfork, offset, - &wpc->iomap, seq); - if (error) - return error; - } while (wpc->iomap.offset + wpc->iomap.length <= offset); - - return 0; -} - static int xfs_map_blocks( struct iomap_writepage_ctx *wpc, @@ -289,6 +250,7 @@ xfs_map_blocks( struct xfs_iext_cursor icur; int retries = 0; int error = 0; + unsigned int *seq; if (xfs_is_shutdown(mp)) return -EIO; @@ -386,7 +348,19 @@ xfs_map_blocks( trace_xfs_map_blocks_found(ip, offset, count, whichfork, &imap); return 0; allocate_blocks: - error = xfs_convert_blocks(wpc, ip, whichfork, offset); + /* + * Convert a dellalloc extent to a real one. The current page is held + * locked so nothing could have removed the block backing offset_fsb, + * although it could have moved from the COW to the data fork by another + * thread. + */ + if (whichfork == XFS_COW_FORK) + seq = &XFS_WPC(wpc)->cow_seq; + else + seq = &XFS_WPC(wpc)->data_seq; + + error = xfs_bmapi_convert_delalloc(ip, whichfork, offset, + &wpc->iomap, seq); if (error) { /* * If we failed to find the extent in the COW fork we might have From patchwork Wed Oct 2 17:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820176 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 568561D172E for ; Wed, 2 Oct 2024 17:41:43 +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=1727890904; cv=fail; b=DOOK7X8WfB58Wxuwd6fJWyt6ziZ/Po8Dt6GUptVaWh5RUeXxv2mQ9DvsgEvXlId/b7vcf84ocjL6vDf54xOGA83nfdrFgkzVNqqk1uwBsDWUE3SBih3ojX73Gev6RsRQkqtunNKIKAG/FUKDRURzamH8ff6jzdwdAhzP7eYoRzE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890904; 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=COWwTyBEeJeLa9tyCBgddj0Z2p33b+ufx5ryBwUBMF+AexPSPIEjjnyjqeB6r1ofhLoJXjGW4Cz4oNejnM6f4Q3dLNcWr+TSwI91ruWrYEOYRkJFzOih1tiRifJizgF7wYW2hviqjcQwy1rQMpaQQImZtqJCmOOeDVgd0MwMaj0= 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=btcFBVyK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PQE0uqAS; 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="btcFBVyK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PQE0uqAS" 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 492HfZng007356 for ; Wed, 2 Oct 2024 17:41:42 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= btcFBVyKizDQlI5yMDSAsQ3afONUYHsDPO73G1q0jrauA/3QXqNXLcJ3FqMOexzY ZceiQvzDZCjL2oCYL6GPFOBVEfoXglC2EGeE9rGXizGt9NiuiLXFA1FTpNpkZPYs +iQeeL01Nxmwi13tpFfbryBCzxJ8PkPA3wN7KcvHFRFV7KHNOut2mJ8erYi5f9qB xsWMxdP61DKEJ97zXbS5rpXUtzd/2xItMOEvcXYBMpaLGUxahjpZXMyPADdyqYyu SE8Jhrmdz4WwS450SR2TmgwqAgVGb6HpBNQ00AYI9nT+GwO5eTljdymCAQ8d1a+4 Es52kejv1Wn1xdLFl0R4jw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41xabtt706-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:42 +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 492G2Asv012512 for ; Wed, 2 Oct 2024 17:41:41 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2044.outbound.protection.outlook.com [104.47.74.44]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x888xgec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NYErH2dWNPNzsMmkp5ipj4r7J5MWbBYVUOuRSsJ2RxmBQgX2onU8yMtv2iNL8CC8/f/LGqq4U8pg++wHpWsYNRn9wR18nJcZVA9udAQG7RFSpjZ9WHoBPpoptkeK6h9KSUpz0RtHutrO5aNm+AX6lKwlMgsRjcDkbBSvHz+Lbz7OAUIGyMvmVUiaPzfqr4NN01VsWc5Hs7wXqP3LP72zGv2oqBKecHNN5IZDdK1evAmMSTviXg4hQJCu9U8Oy62lPPjfkVt0gsibgg3ovxYClSuU4mlpb/5kc3NpZwR8a+Iiss36fm0zMmY02fOyxOU6M53A22ni5Ugf2Jjbjairug== 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=ZKhLoFdXA3z7+Ufyd6V2qcsRxO+Zs9kemcfUr1h0iOW+jCS93uV/7HoCm7QSs2MwengCrMVlp8Vrr3KSViOMpkHDuJ0ifIfexrxVrR0RVmiKbsvklZ9KuygbNGou6rAS58lUJCJphiBwb8dshuwS7PdBbUROuMBrGIhelpEgxQt6sTX3Azj6elNxmHhAwNeu7r0KeJOvGgRTGXA0c+9CaOF8nGveNz+pA/BhaEgFLQObx/QSptZv/m9NjHpOrkGLefdPcisTL0NeExPM3RB905TERxju8BIM8hrrwTaIGj1WW5wpLXC9szqopyx9s0enzlHTgzNRqR6BudiuqYHpQg== 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=PQE0uqASb0U45XnzKvSAA5IKlC27DjmhfZd8YUEsdzMWlTgswRB3qC6KC33diY+i2LTShYWVEmoh4zJ3UeNGGoVmSoJE8OMkar5JIOQWqoE9tPqx8S5d6CVGYrfN076g/xsGVCFRRuu/5Q3pLPJ9o7Sdufcc50ihpntczAjJIR8= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:39 +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.8026.016; Wed, 2 Oct 2024 17:41:39 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 15/21] xfs: convert delayed extents to unwritten when zeroing post eof blocks Date: Wed, 2 Oct 2024 10:41:02 -0700 Message-Id: <20241002174108.64615-16-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 2869a3a5-4c35-4f20-da28-08dce309785c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: cFrg9GWvn4hRbXixkYu2N1zh8ZSV3hwP0o5sm/WUV6E9bCvZolQOCNRtQeUlIghrwXireDe/XFdib929GndqkhL36/ADpVr7hRritIWvhu5TEkkinxuEdZu/qsUt+J2CYPiAQUy2tY/38M63k0NjpqhZ1R+cZAt7PRmuAZaiLvaSxhnnF5gdM5UEj6MhgESmFqwUTZefUDcSCJBExc7f5KLWWyeidZ3AMgUpb+3nsEXTLUvce+sJJIevA9SbB5AhYR0oJ9Iow4YSEKi94cH+ICXwGHXTZyniAlY381yqVRyWsqYzlJmezwN2DhE881wnpDuOMViVRkdEP4XERRm7VLPLgACkXqi/3EXyxnL1GQ8CK81gNutLZwuAvdwXCTU3V3h851+ZsyqDnjB4GYul/GZgvob0YtWTERJy5uM8odtnfRU8FR5HzulbZVlkHyjK2uPAlROG2sk0HZGEu+dkD/y3TjslfBAg+nE0j/OA/+FV/ua+zH4BKwumhtRlrmcUj6wVaF2NAMM1iA7kN2NXNGx6be/Aedqp8O0e+Wk0wj1fpt9xOrvuMJ7c2LuogdRaKba6jh+a8J+AXO6KSTY0+X+JEwmIbPIpGvj0ofon0QqmxbBkxi0p4KZPTZ4J0Y/GN83tGE/fHwboEd9JIz+TLEJwsBCIpmdT41Spl1ehV4AhGl8q8VEVmKNZIWR0NVIA0HGw7uVPeYzm5S8SVfjuUzv/2dscJVr/GNzouGv/nGYOeqSSETXKOiIDJjA0W1mizdJIA3sqN95+75J2iyFkYFX/Bi+6eNCL5YQ6M/SLLSlzMpob/ohDUBYVeU+rJuhBLqIwnkJKeUNS3f/BLrhD/T6V8IEMlbOA6DpyHVvNTcwrl/TPoQ8EeoX/QAeZAMkxFHSKK89ERGFecW6K+p+N+a9Xuz8oum1iJ9Ht7VxJyXw0Er8GHGd6EWmiBvAkf1yPJEDD5zGh0XL6XMhA+9V3QqPALZWUHLN4LsNWx4OocSDzED1BO0DRD0bCTHmQAVMwOa4fyHSNAYQ5OtMZhfIl0E7ruE5pIIv9RxpUYkoa1nQuHGrDWxIebE0Y/j1TLGheiQn2YD+kfTKTNep+I1xSLyG4V8bj7PBqmxhKfAvM0aHP2s4pgmQHlPS0jvQlTKEPUevzYIBkRs+GcnP22az9rfpQ1cLz5B/Z5QLQMQMzIxszg3AbsacFtVf9BhZ7crmCfib0WdvmJ1qHu/X3ZfPwsnzeEJKR3seFHSac+JwO931j+GPyYEWBTSvb1xtmVmilUJj93UXexW5Cg3FHADeAhg== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F+zQmYyLtOBX/QxBDovXDxrqLlwvb2dKqpx7mThLL20305IwGzPvmrj6p6667N0C0lj7nVahE3adZKo2dgcwNaJj8y+qhBL5iacrzXd/2unVqL9iZIik5RszcSGJvWjqLj3A+iSw2FBgwMkC2izNDdFrT2EsHPlPg/iO9lWmrx2RTZBbdDa1UugKVaFPnQQPgSQtrVrHXd5jIqeWo+6fdTBlYaEh3ssQD5KIQw9Fmaoi8N9wb3cPnb2v/vAFY+bYSbt1iDujFUhAPqZlj0fhyrR5UjCCfFZsyfDCKUfzpuDrJUoLIuSdEkwlevG8+m3xEcPQj+BOpRG6P+II2iPyqU4i5h5Ws6fcHZx8cRF/ZZaTosugu1bI6FfDUdp4/+t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tMHVH506NZ87UAW1iCTJRmlJaH8MGj6EoK4tR5yNJ/pdPzsr34bWpsgjZ5fVGXmdCWJCvEkuNGz936+uCG/7jnvHxAT8taXS/AY5fjAH6kEeeC6PaENXhJ192RnNNE4B4nX1Cr5Ort9SOP3GY97lzUl/N3so4oINJCPzVjUAKHXreHdUK80Bd+gqjXlLB4matNUVmDAZ7VcUK4rBo2k1n69H5Iq9Pc7sriiN5bXXDzizB1ydv9g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5h+N3U+4kLV7kXkum8anXFQKsKcMby7AkfbIat9y8TVQX9ELXj/aDtw3zRFLHi9NxYqfEqaezwkiA63bKCgFmAWGTGLi0ZXWoq4GjXNV5TSTMS19GPb3k1g4y9I6KAVW+pBeaslGMVwJE5vc4gECQoGCm/kqqZ/fq0JnawWy3XR7c+Vu0tHAjl6qGk6goWerftJ8wzM+v0WduWjPrwEha62QDUCqLUUiJjj6XfwakSNRq0dbk0S5ru+hVMIb6AksV980moBY6BAPG0aFlycURoPeZXFYRVNwsT0yP0SqBahi1odFBJf55cUl69JJUsWqR7hfVVu69u43rVxDVbMAbsIvEGtwZalmDNT9f3qTKSwwGYl92QUFcN1YBWk+MSNq+2gi4iF6rv3MUm6i3t/uJfuVh4y6R4hnd1nLycI7KS+1eT3xB9GfTL84mmqjwW+UY6r3a6vleKvLhUz7V+6GY2D2Zteg57Lw5AucTKwwbPlstd9Srs9c15mAzlgkeYkqwI+vi57cbB8efQyx3Y/cAJ5k7xmzyShj0MhEg0ArYF/zLu4/KSweAg6d/Fr8nTsCJj05u3adVK7CTy/D+uaXJFOHKFBf2dJN2jXCMO0qTn4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2869a3a5-4c35-4f20-da28-08dce309785c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:39.4870 (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: 0mBNMRSgW2pr6vw97SrH/T0ICWDirduoPHunhnT86uoOX8kqp+8gnUy0/5qxsRmG2KskPpQZt8RO/DOvBLnyQbHACct+BmcVOJQEpewRFVY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: LyC7gY-nyBiMIcK-2RhE9TbdQZuMCypm X-Proofpoint-GUID: LyC7gY-nyBiMIcK-2RhE9TbdQZuMCypm 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 Wed Oct 2 17:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820177 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 9ADF11D172E for ; Wed, 2 Oct 2024 17:41:46 +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=1727890908; cv=fail; b=XAQKt6QOXaWiuQk40MhiZ8VAiHRCC1bYvVxWlaLXLU497HIEZwy7jLS8Lx/iIFsLTeROkC8uG9HMQjXGcJJZ7koI3NHnnHU8MmMTVjubl4RcSTbBDfUf9nP2xh0MTvJ8rxgbHVG5IGcezPcCOvI1IhujOhRwVdUpkM0k1Zwmdd4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890908; c=relaxed/simple; bh=Zt3oJ/twGwGOQRVa/bsuq4wiLF2dlb18fQvxRTuynBQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EBTO3ft4+RoSuRH4O0KtdoBXvsaN7dppUe5KN2gthgPMOVyIsyeL6QCsu8W5Z1hUp/CtfNqWCGGoaZgXjHH9Mwp32AtF/E7hpWhaDqPAOda2/t1ZThk/zDBcmumni3zoG9e6O/I9gzpQVQwPmwBCVXthu/I4ByPKg6VwfXI6kmQ= 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=koUW/4pl; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Dy9LkDFS; 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="koUW/4pl"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Dy9LkDFS" 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 492Hfb5g030327 for ; Wed, 2 Oct 2024 17:41:45 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= koUW/4plLp79r+fUg0qCfe5nCOzFian6gDm9lzz9qXjuG6xpX/thwtTxVwsb1GMt GtnGGcFhFYsbpzATrVz4tauV9aQumOzINA6tQbRnHALH/hKQPY6U3jiV/2F0YrH2 /TYw0Q97BP7MZ3zY1Xu/S7QmgckLkb3yF5tcBrzC8zN/i4+R14D/hlS1pBwuwzn6 fzAZFgXHTlxQyaQIwmST354Bxm6aMm5FtdUn53nK1tmGjZmAY/yAZ+Gbf6ZqPsNF WruwAtwS1r5YsZDQkWu0/cvYJlENck+vC8DMW9gaeXYnMTggD9EYoss7hmHa3BJ2 8zGfb05qy+x9wQdU66Fj0w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8k3aebm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:45 +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 492GiOUN039265 for ; Wed, 2 Oct 2024 17:41:44 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x88978a3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=djtrlGsoruD8eGMabplxvvuu9JQHWQ2/maH9447oaWiUqX1BtmE7YMfMSMYT+IRcShv7H0xHHpvHTXMdD+CCfctC6w1sH2HtSRJyyDoiNP2oauXGIBb4yqI0rjqFG7nwRyx4c0VhLSv9gtlh0zKlvK5lb5x98LGnsTVWyVGfClIunTkvFTDy+uQKoqd8CYYbcT28aXquxbmetTM9UU241VwV7pLb5KOLPHzm0b5lr0wxuNfo4/jnFk4Bj6J3oJuKXLa6pLCYqoipXc3SdTer08W60qF+mFVxImMUHM/uEgrLajdZGsDSQCOQYsCITJpwIg7bK7gFqVq3uTwWuKdmzg== 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=XA1jsaqTNJyu9rlCH7cfEVbby6ljRBJVQPpgegee1eB2GSE+UU53qhsF2eCwcrthSMaWx4pjTHDl7IyzeENIBKX/529YsjwUzmtkKMgtI4wbz9BMwoWRHmvbyFDKdLLgS9ofpInQ3zgXdPhlL7VWslxGA2vP4KcyjBvqujX4/xnL9FCHhmMU6FEfVX9NVblHPGOoszUIWhGpAOYSuLbslKqxknWiMDh/2wJSk25hRyGn6XMArktYAC3AOYj9I7HoMpp2IliiIXTZZuykdDbHFWcCQ5xbf7HKzJPvMUWBtphuplyhSxB7u+4YNrJXhVmlbAnyv2SNKZM9ADJ9IEtc1g== 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=Dy9LkDFSO5J2v5Y+lkzijOzjSkkB8F7KAm4sugTASK510Mk12vX1rdQOLx22MaxbtX9vDPdkewczErYpi+szGBbayvzVkRpDPhCdnQPMRq/ccwCZbh0mKeIB0B5Fec8ChNoA2U0OUpRqhIquDiU8kXqN3W/PTk9hPZH7RPSm7K4= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:41 +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.8026.016; Wed, 2 Oct 2024 17:41:41 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 16/21] xfs: allow symlinks with short remote targets Date: Wed, 2 Oct 2024 10:41:03 -0700 Message-Id: <20241002174108.64615-17-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0020.namprd03.prod.outlook.com (2603:10b6:a03:39a::25) 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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: d87975d9-a34b-453b-fba3-08dce309796f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: IN8AZwB6tbxjmpq372RxhZc9hb+ES/GUQm4p8TapZx7lvOoDb2JurWqwqdi952iSUFElhRiM9v05NSyspxpAwQpgS7OZy8yIadWouQ/GI7LB8jInCwSFu9/7gr3+Jr5cpxpvpL/0VIxf8N3iLhv1UpCbPmpoOYkynW5rulC/oI+H+C1hXcLPVFCe72UHCMJED6huN7CC+JSZx07pdarhA43gV8lba4MzPhaGVSa2A18u0r7RkqyVqnCUbryflrz2OYexxlrvEPicEzkReKx5jOtBhzPRl1QDYHUocLC4P7bOCXfHnor2fZ6Q+bMdZTPP5TIsLEZj4NwILz+HXR7CqgTKx59xDQ3u3Oc/3Z0Cj6lfBFEbC9xuAJ+eQFYhEkZ69kIWLEs012jiwWVhL181CMwjvYzPHMvyUrtQ1HBC3qiuNvJiMK1G0hOi3sHKyqvpOjFk2SOPw0n+f7JDemzngwyiksOzY5BnqfNz7TCrJsKw12iWqjbyd9MfVNspNrHUFlZmz6GI1Xev9Y45uqCNQKMCBQvZcenyq6V7BiLwQ2ovKT2kAFcA3AXOKDBnF+8NRpHzqWxaJWRSvGl0eRDVNZgvd/QpwNrwUWfvI8aaWdz04/9S2fu+RqjteZZO/iqWhDSAVGjQarDKlGBg9l03/Vqf8L2UgzisW8z6TklP7yZ6qsBfOQyP906dXNuSSOoh+uixdmMoSSgLdhbBGUcVIdX9kvN/lthqnTjDDUK9Qz57nhdmSKJlACuY5qHNdN6TOrnZtR6t3H31Q1PzDuX0Ko5I7/tM24BUnsy+B30KLNe/RicltjkZJfTSUdYhWmO+r/Y54GaYSeb0QzAbMFZv4vaq9voPhKn2ZDF4MAEpehkFN87D8khBRSnSZtYDywAwVuWGS9cyy09YaG3NJpeLjVMxoQ3uKGOj73Pby3ymsUpmM3fl7DncaXldUN8yxkVkExD+qzJcz0FtKDRabs/HPZQ99VDxuWdLR2Hs3MpYZaRO9nFHulInJiws7pfrH/tV1GpJTHdLD+5eCmelohnpRD4LbKY32iMWBVWVL2hAxL2/sRx7MZTkUf6PWWLp2ANH0mEfgFtgPIilChT8mphVfy7e/XhlDsv7NCd6VGSDXRTIxeGWozjOXp7MmWpCMWnB7Saik136eB4kV7pnuAYBF/Hk9BG9U3nS5Esdc/tLlXhkluXSOLVy9PdkO1OJZl/n63RliWXJlxPJ+ibBvzxhJhWkjxPuRXBc0i50c5O3SGkAWz9FDFS+TMztsIrB4q6+ZW//ZDPAQs+WzKy4V9h+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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cOFkZWzLQUqSs0do43i07TIwnPq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+Ka7DFe1uYntHHeVIBzJhQVFcqo5QyR1ryLuPt3Wy7gA0d2qwobACwpF8p+4PjxE9okE7iyOA9Qh141OGmlqkpA8+hcbclkJKSdTj007meECOvaUP98/jmOMaOMH5Dl4gbm9LsYcMU8njAqq3nG9gehu7onIDbOGVMJ1sChJS3E5g9pCIrObv5dwMUH345jQMxw886fDzM6bMYezk2Sv/0w5OUkOecAKjPAKoYbQbN+aPmFnpHNMuV0bVd3Msl8+KqhH8Rf4aryvpsyCAlrGzTqHVSmnwuEJVLlhVg/Yr6Hfj30u9q14cnFmDeRxv9fBM2aE8c1JcqrnG7MK97spW09dXMy8NdIijPtkJVePIpxX3PbFmbGoLMhaI8oBiscqk8xfqbKU2p1xjm9zcuJLnANDTJXUMcYhSuc8s4mXko9CPJXx9IikWEXqwy+iA0a+J6oECZ0jaeec60akC/OJLG4L8C2B6lNna+bVLDyJphokOIMOfzYgn4KRVTP5g/4dp7oK7SuCRZOgVLDV/PVFBj+eUgO/UaIJADhCUKyn2RtErZnqtqRtkCXePfmtks+2Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Rhse3Si05Vxh2HNQMyELgUeyBJM9GDT20XaPEL7drUNBt869V/zPBMJJNvSElND/1v9i+qKMHfbEp27qo0FeJZp5Qtsoe25k/nga5jpg6jEHMe0+/awD1ePi03JtxNeJbNbCZz6gWp4yp65OekRD8oRDI2q25ae/UKmIdkUTrm6fC6OWcKuqs8RlY29EHwOpgeNifrjpJYlJKrgzZSsyDC9IQlIjsUbHgtYq/knoLjjDNVRgIvz/Zxc6iyNIIMMbl8/QFqkkr3/VRqGhI8MQWvT4h5RdRoUYKvkBLMTmaXbjYZAv8BR932DPg92Oi/KKdttF0kIBSytXMzCNcUFZsY857OXMMjBoNHZTbT8zvTsYbRgOUWxw/tdgnvj+2OmeICL590HfUdwc8XhMY2xnwNdpNikkagGNfZPSAJrIdxqGAFCEmrp3FyeWSFHRh9ubyStk2HDH1ExD8fwXX+w0U32W4tj65KIAhSt/EqY7QJOa3xiU397ifYy2t2Lp5fG7cAT+VgrFSNEKxVTfR+aOP3+AIV+1nyzX7hqoM5MNnZTonvJqyjvgKBqJSxPBESeKgTsx/uYTB/XTZjip86cPnQ9hIiMT0FneIyyfwRccbQI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d87975d9-a34b-453b-fba3-08dce309796f X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:41.2679 (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: TgCjTlndTLxLdul5Z2KqQQnQQrYWEOPCzMOk6AWokUV5s8loEIUQh8KpogzX/Q5Vhj0g1X3ulvi1wPDudM4KKOaRQG4+WbVP/nYMXyY0VR0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: aSChuWXs2PRWVRxUe0h1JMD6KrOR3zIp X-Proofpoint-ORIG-GUID: aSChuWXs2PRWVRxUe0h1JMD6KrOR3zIp 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 Wed Oct 2 17:41:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820178 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 E87661D173F for ; Wed, 2 Oct 2024 17:41:46 +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=1727890908; cv=fail; b=cs8bL2WMly1JF+akpcRLNKnVjbSEQ1ibsjVx2Wf/yHEYe4Tk7EfahsfdT0F5/1AH0kicn8WYK9HF1qTrdv6B5WXiM0eAvhTGHvcOThxIFYtwO1v68exztPWSrsbZQxmeS98nE+laIaNx3h4Sgx8N5VciHpGV6652k+kBqDhiYNM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890908; c=relaxed/simple; bh=M6DL+ZjWoqKVdhXdC1VMwi4eKdfrkr92ytMtejOkJsA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hP4t6ZMHYpxjRzrMs5pufWyev/Iongf7ZEmSFwBFbUcV5Q/+SEkSMpuWR1QUUwaW7UBD62Cv7KqPLYToCbxQJC7wGrwIs8N1mjfrPpR29veEMzqrC452HAP6q/XLk0KtScKnnt/gCNMHfHz0kyq1yXA1oLkE/5mv7LGGUd/FN9E= 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=Zg1BzJ5y; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=C7Uy1B96; 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="Zg1BzJ5y"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="C7Uy1B96" 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 492HfZSN025427 for ; Wed, 2 Oct 2024 17:41:46 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= Zg1BzJ5yGfz/e1XOWyRubhqDb8/YIDD6v4LyFm9WWZgKKKRqf0O6aGzIkR8b5NVL o5qsXu9NqHQikBptIAdW0regvCv/QXxbuWG7lDu4YedcafKzt3iA/r2Nfe6IetZ3 2Q1z0nti4miJbabrDN0jRWGGdseQvN7fRSoniy8+VJ0y+R+ucB73qA7XaxKoXWhb Ak28SI9bEQoGjELgscpr/65KFpVam5lRe3YygoevqmtxX85x/LyrODx60S57CkSN e/7kgSc4XP+Pm0sG1CsV4IIUeeRFjfbtomV5ZtQGnmq8IHYQqb4W5hcGmUi0gW0i Y7QDHlWsnG4psRe0TRA0PA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9dt2cdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:45 +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 492GiOUO039265 for ; Wed, 2 Oct 2024 17:41:45 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x88978a3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s2mlto5/SCp2uUb3eByAYXQZ1VcCi1vTM6LgiEtO2jQaPF7eojIFw31MMjPALsprVuZsBrQYik+FmIUSfKFIHPTfYMpSJt5/wjNT0VVEpRLkYyCVGJfaqBS/3NwQs7NFl27EtwpYwxEiO2AzXfABraTJc1yAGrdMEHBUtlvPAeFyRzvhGUJ1ebthoAwnADazN2iaEoav0pocyNwlZGB/ihRVROcZcv7sxqk5Mj5fzLRjBgUZVL/I/cTB/QJGy6HY7KX8CJBJJohb0lBo/tymKphZbeEYSxx86d4+dCV8OzUsrbBvVRkbFuLFP1wS0we521RfYStTE6HsBRfLkdUIkw== 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=Yi+fBervZglCNn2C93AM6EDYPzNiYg6gRC46lvS4kyh3Yv7F5gk+7qiZMeyb1VSa2tH4oWL1LdfBz6YBySIqnjpTibY34d8D+mULWaWaKGgs3iFRXEYuH8b8jObvY3p3NlAGxKf4P3u/BEwBvFL94dUeLVja3pvqJp/pn3pPn5ZwizCGLgO+jW4dfOWUUCe9nQFoV8OpMSQ6KA8GRcCuNuiy/Kq9ErEHyJQFccqX81Fw9/Y2jTH7BYRNzQBmewscJHCeBH7HFaSEgt6BfxGYdpES8UwujiSLuI1EejgJ5LZeEkVx1mDOW6WWfI8m0pA4gH+JbURL1NTG7azKe1Sa8A== 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=C7Uy1B96ffeHlCpkt3JJvFEXO2s+0/8Nl+ZiYFDBAx42y/3E40SI9yp6h2vd10dADP9S4MgQgcygv9c737lT9uZUAm10lYv+PgRRt/Prd+mx/+w79wfhwl41s1Ar6Vn467IcnHzDQqQZYN/ry88BeP+Vnl+Ugc9Hz5YEtR9+CEU= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:43 +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.8026.016; Wed, 2 Oct 2024 17:41:43 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 17/21] xfs: make sure sb_fdblocks is non-negative Date: Wed, 2 Oct 2024 10:41:04 -0700 Message-Id: <20241002174108.64615-18-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY3PR03CA0014.namprd03.prod.outlook.com (2603:10b6:a03:39a::19) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 79cdebc5-21cf-468f-c537-08dce3097a9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: 7ugEKrqTLWyTFsHJCMofuiDYc+cZBHgqMja9O3n/reDQUqGD+xzIn3R2frUf95LUHTuIjpItWGqXejp2kiHCuuvqh08ZiGC7aV4shyXPheZVbVT6FvOSH7j/hxteMs4/FquTjc+cWuq3HdXeiFNhc8QaMeMI/BY1Mku2FiKI4fs3vPGAqysGsklKVi0mtSda1A5HlahyEgLh2NQc/ybJiAIR2i1jIfGdJ6BSiUopZ0rrsIz+NG9WJNeC49IfWtTByo0Mna8jSmC6o/bXXLyGN78/PF4iiVbP2aQd2e5uOVJU5YUuzMkl/Ztga6CFwrHfySAnunodclDaURatA1GMkrZgMNBijuAUUVuP3MoKNpvRh6vDvK3CGdfeFkxVAZzZPPH8pnSyrTC2g33GVen8aHCFEPUOtv+E70ndQDtlrK2M1xhz19GzD80OSky6l8zini6Gbncomk/YnZ7Fx/e6asiwgbLaVNYIg1j5EFiG1TgpEJiz6ULLZcEuP9cCSJB/i9PQ9QnIncLL44YmfdiydMNi1AqSAPOGQq6a74wZ5UIScNuWg2Tw3cgo6vlswzBkFqO+xddO2zPoLpwoO9wcQg1OUdS7VcJJfMshIoe1xZmn2hu1SlYQbNC/RwJjcqT7XZzMumjomdPnwX2/faiE5HTaNbNw0qGOw6oSB+8i0Llvmvt61ezI/TJahgCLWxgrOKO0ICn6SvC6jp6r3qD6b0Av7zsvtOApYGAlwZY4OKm3C3Q9JXpUYiWF9iK5YuhjEJMHaanDYaLYyDY9OYAwUV7NLTYEKsACa/GS+pq6EcaPAe2eXwA1wTNF0qPhioUSvfJ7WUJghEJsata1qupj86cedVYL9QgwgH9uz9SdQCjU9qd9EKLLqO7TH6AOnTPycMeVc6jrxTIu0S0oDiYvl0ny/8NMvbKumGmpJFlBse6FH6fiBm0Tk/n3irW05cx4SIiTPM9MwTB7DgQSEbv56ddt0m8IcWv+PWeCaHf52OMZ+x+Fk+9YBNpw4wkWNRUep0vG/DUpbOJgEzM4Guxf3mzZaNS74dxwZ9oQeLAnfpohVQv/bgDWCcs0iqsHP1bFc+gH3eXRFyCU6UgWkcQFPFOURtCUQEADu1JnGfIT6EWNtINiufOvAnSqj2TFC8Z6qxnTqPwi5EKYbGwLU32MizA0r1f6NiPK9qWX1pLCFgPH5TYke8TNpt9YWmkoHsBn0gFdKSg6aXdbJ2SzGtoNf5AkmWDiRd2nm8hHEudxFpoHvqTRqv/tGqbLpjdkBCOpcQfsAjXl+KEx4UJm/Kjw0Q== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y3yRxT1i1CMmmFaw4jxOKuMg53UNWgmFVJzuzp4UoKhZ9wgBdAXv5uI+0skhNC8vdHmTIRwESXNyMcLoJ4fYa9K9AtstwH2f8sIJnMN+cbRoA+s7MHyvEk6rQ5NPNgUQsWxK2EF2IRGcH9mywCSkLpXv9gTWU4P+p6/IGljdzz1q3stv5Six38LhgNW7Vqrr2NMin9AGnlDPr6sFtQ1DMbvZ9tRZj6OKsqxx2WBapEWOTSUqlsGhSgyP91MzZN5OO4VNaFZzHT7bat/bDn/r+pFzfmtg3UBCp7h+v7ZANUQfjIY7rEEuW4ruhlsKBYnMc29uTiWYKnPLj8kO2t7kyzHvZzWZIlK/Mnk2dL61BlDhHYEmo4zZNu+Nq1ULamJp5V9Bx/7BHLecuK7RyG+Ybo8rQPWSBVynTp66kuCVprhOh0BJezouFPPqHH2Bo94nAVfT5sbBh34LKM35Sv5RUmVKoJ3AqcpS5JhWU7Vkkz/vy+oSqLeChmOJpxOYH9q+PGq5etA3QXI6fV4oCdUsgiEo/7XR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dnJTKO5AP+ufEdFIeEuz3ySbtJimiXmpQob0rJgi51RHSqexsyj2LMfhjEw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: L3uOaCtvIlpPYuYdZV+UAiH8JgSMN1nAFPlmVE6dJn7hNo5PJlC1RTyPTy0uDbdKrF1vrUhVHNQ0qyEusxXa7Sd5mEaQYv8S2WYfnYISpR0SQVYVBjH9nlKjZvsjThkNyf9IbUX1RIXODK2b7OKwvyuORGQE/5QlscTN//fnqPinhOJLA/ER9zBDql1ZcATpB5fi5N2J3PtgjdDnuCe1+vID2egFpXKWqVRjDMvtTRn0D5zDLuStb6siNI3c12s2hrtmxf6uR+NeeqMXwRwPrfA2EL+OX2iMnjk9GIR43woGpaXGBNPaYvQMdRKDJf1b/zrs3OyP6GcQkWU2CamnMykBrgNfG8xJu7ykICpf+zk1qMtnv3yDzgvgnRnpRlEiM44J/AJ/IarHEpZLuq8MJ1OF55FVp/zS5gquBxRBo3w1ywouHvkM/rzInooW6/nvjSrR0+MwAoXohRnc4Ub4MS4AcRhHJgD1WdT2aHOsOQyzF7K17f8usOlXLg6FpsOUVKtjgYzuEQYx4gceRj/5t58G8VcTjnhOg7TFb5zihrJdAmXSNB5+Xzqyo9Y7TNe4hHWNH8CGi1XpyJr0d4tu5Dh20hTkCOCVndwhJn95zAI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79cdebc5-21cf-468f-c537-08dce3097a9a X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:43.1554 (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: N97QEGuwFElpfhuieGY3UyX1igajKg+pCOU8hB33QSBQBfnNpeMnXK5mb84c4+Q/E9ZfpCDT0agVnYeVaheTsF0aOZoTwR8FmAvYMfv7Jj8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_18,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: pIqsECmZr3QxTXiaXq4DOv_yukSx6cUj X-Proofpoint-ORIG-GUID: pIqsECmZr3QxTXiaXq4DOv_yukSx6cUj 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 Wed Oct 2 17:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820179 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 BD3611D172E for ; Wed, 2 Oct 2024 17:41:48 +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=1727890910; cv=fail; b=TCWBzBO4QMx8GvNNv26C7iWPKFFPk4WlC2bN0N586uR88SarR6aEnl0gacigUlQAxCMTTBkeeG8N1cwNyaRh4ZyncDFQGtSbf+z9rE25O+djUwLMU1JttxdShz8wszaVoX4rDwI/aihHBftRecT33IB9eFzB8uzK8qDmjKDa9Fo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890910; c=relaxed/simple; bh=SRIlL4xgXmRXiBOwWWi1VsEk+x3iHxH2LFfvZwedhAo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=X+amOIjjv2MrFJTpiSXdloTUpZNS9nNUAhIJuxfiXuU0JxmdVES6wrcZOLwEHfUrYDrZPtwS37G+1autWXgFaEwJKZrf9iZT4EPKNUGDf5I0O6vr9KlokmJ5RGBlk3iFnTKp/M7tDK0tQEKCYVM1xJ40adwaaoOoA8jFo00f7DE= 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=Iw/fMsuz; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Wn+cZ+Eo; 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="Iw/fMsuz"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Wn+cZ+Eo" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492Hfan8025055 for ; Wed, 2 Oct 2024 17:41:48 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= Iw/fMsuzg4ezg24H4yEBi+NqrAo75t6j3LClR+GTdTCH6c7O7YU3WsZF1nujFEyf JUQejtN2O3VeFzOEswhS/Lm99wucb3zR+rK6J3h5v6V4ED1tCmLPmR8rsE8RIvXr c42IBQKTF3hMRJnRr9dJLE40pHBPSMuia7W2szociqme2g1VhOMN+FkeDeBhkeHl dr51ePQeAdhGNGosPqCEkxv8/Y8kjrPKk3mqLjICR7+/v8w1L2aMkZCJIzk4UqLU 1O2UBnuCgeU5LNRDNe8QwhI+klXJvrxkQvxtUmvpR0DPfOXNK57Ap+3oNzufzieV DMUcsCu6JvBlDSH9wgfnIg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9p9t3ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:48 +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 492GSYYR028430 for ; Wed, 2 Oct 2024 17:41:47 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2042.outbound.protection.outlook.com [104.47.73.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x889d4cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TyZxvr9tHkQ6bSthTJtvz41qnHtegxfBzu/VG9p7/O25MVenr4GabOlwpXMxwfREvGVunKCiHEKqe8cszLrGcr22KzXxQ3m8Hg+sGMhwvPdXUMmKFBt4SC6WeZlOm+2h/xETMzqEImjQYOwZGQiINQePY8lwzpPMkoRSzSJTsU2fiNpoAuavUa/tU3HWM/5TbnsDI8A4E1YyYECdNlLl6wxgSHr7rCJC+dSq6pdH+5pbwDNXyTv0XUEhg/+THL8qsQ55sFRvZXxfKzp5LVX6InSM042eJ9WPedmkf8we4NT9XcFBAtBeKuh6pBLuD5vyIbDuf/XH4bOhoCynG2sDXA== 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=qS3H7ipFKsAvews6v9BEqDYiIjz7Du8E5S4tGxQEAJ/+kEKPSMmuFPni8N2NK6Q/pDQuo28mkP2FmhOecC5KnL/MyNdw1YbGvTQUiEPATwZ+841EXDzrLB7kw+wV9xeCmxGyUMtoRGVPHnayiR3ZT7qpNsIolS5OJTFcHvmn3XN5W3NBMp4O/nhdLBsy1OTDV8nAFsUo4oS5QsgTOkZoYRriWVArBorwN6kF7B9xV8Uw0zGVNViVgObHt1y7OtIB4OaS7xCQnfFt5SM+Fs5YHIKGkLmmjzBb47/kwfjsK4LgjCXTkLRrwIjVpIHVuFK0w2/2OaaOFbQ4+cL6zTEllQ== 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=Wn+cZ+EolQ6GRJD5quRHC0UyNTATqStL+zE+gPWQv4mBJA0ioor+5ShLEcol5zpnML9lzf9nERcYkLFbhO8B8VAOY3P8/SbbD8Jjwy4ukcH2dxEVcwBji197VX6IxofDCvuRO/PNglt8ELDEfDGWL7T04I2iQecdvTp64DdaPQU= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:45 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 18/21] xfs: fix unlink vs cluster buffer instantiation race Date: Wed, 2 Oct 2024 10:41:05 -0700 Message-Id: <20241002174108.64615-19-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY5PR17CA0038.namprd17.prod.outlook.com (2603:10b6:a03:167::15) 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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: fcd692b0-eb80-4753-af1c-08dce3097b9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: NzO86ZI5OiVaR7yxSIOLWysKaACjOZsRvXjrvOUhwz77GExisy5p9Qr0Jkl6D7MVnlpVqGGhv89vXsCYEq4fM0Ha92YNGyU0cy3I4ub8lg9blTElY6RD26QKI/oVC9DhVTIAwtss9VZ5Ywiv7BK9KoT6Nlmgn+32MdhwMYnd0vL25etn3JreoIjo24RlLHboZfESnZMJmFsEAlJuOIqXu8jvn29gCNpFTEMDyE4hNqXXpWRKN1jhqWAAkDE/su/JvFUAH7ISbU7uOHNERKyRCEitiZQyHxfgGncS/niEo86Hc6MwtuQ59ltvSJAe/EprsGUTaPtSeg7uZ7cWlplM4Xx3zBCb3Vjnntt1JYNkVfEO27bUtVg3NJVBllyqiFRuVISSLUPEdw188aMLmmUrFzb3raUJbZ8i6SgNoynk0WTpvPsVdj6GoMhCvTezp5oqzai+PM/tC21hVfyyzlWzQ9FfeVxxojidqFdAB75pVY5vvdAY2NaEVaxA7S44UHH50JehWkC8al4HCKv8WQfmVoAC7MrYD3s3tuygKAYXgtTzgL/juLBeraArRqH+aCfSMsoGE2Duu/+1QR+YgSloNetFE9FH6Qig2uZAoqvuvaoHTKvXBn0LfvMOb5m9D6KA/CzGYjzxmPyfuA6O+nIhMFyTevmF4FdP5xDnwaSNSUlmfMLfCIGJJ1/IRvbrvkftgSIlDAyjCLHDbmNqrt//pZoUI56ZurXHqyWeh+M2wu1FnKoDzQJAAVkzwTIE+s/H+oypVN5grzMRggu3fM8AJ3FHITd9cwy85SHoE6KmyMPdeqz+Z22aB0flDnMVowcFNtgvCy3/9fDZbdTyiBSNYEIY3vqAQwZ0vl8FhuZUOZNpeTuRpjrfBzd/V7ita6DPG6YRG7+v//n09Rt1Q6TSf2wRJw21g1BowI/2ZevCUoB5ULA5VyXgfmBj8vHfJFl8IUfA08nNWRb/LtN7+4YBR5olWB8R2wNcIc55h5M+5vDnJ0P0x2pYobkxQWi6Xz+e2W1F8vgixzYjKPRKhnnTVi7bisWBiBhwXvpPT7OXbiukR8XthlFlJKlXtN2LjTlU368oqHhufQeOBlMrpLvKFY5usOssWt+6mCCm3dNNqlSs05rZzX9gl6eCzZ2H8EmlRUyTrynHm1g8FBYoQhJRUFFuWs4ADp9VVb9XT35ZXpsFLDzix6vSZLUQRXhrTz1WVMYIXcB3BKZDTpWrI9wSpdcs4xzIgkXi4cCEUWDyT+kaXXcfjF/Fby/2d2XGPjrvjA8d4SRJLcrvc0LpSnTb4w== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2O2v2f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ZEL05+B4Yv2sXpHboIcCzGaxNtJefblJD8QqTWRNoK39wmYhN6Qg0g0R6M97IiOW9KiZnHp8r07ZnxVQE6QzFJIQb5sUo5etwtFufdwyBk3IxpVc9knd2CETZjdT6d4P5jwl2AqlAGcchH2Mbzod580B7FPymee7xRIbYa3lcuGGezVrkgzAE/yaIkHQ//O87cTuDlq48ETAjQ22Fic8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcd692b0-eb80-4753-af1c-08dce3097b9e X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:44.9566 (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: FHcEhz4rQ6xllMrJbz5og1BB08A91wakqMlSDNKv26kEv0eIUNeXXWQf2AUHM9Rr/KGg+NTuzIu/S1O+pwWiXDwtTl/bt9HC9CXqW8fjL7g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: EipPFftma8J9WQaAYGMoj1sS2mDY5SNf X-Proofpoint-GUID: EipPFftma8J9WQaAYGMoj1sS2mDY5SNf 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 Wed Oct 2 17:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820180 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 719341D173F for ; Wed, 2 Oct 2024 17:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890912; cv=fail; b=Z7jd6W8FL0bDSWaNKIoQEfL/lRng1hCZCWMxxudY34DhgMoHYUkGOQBuNB4i+SLyLjPM783YgCe36QuXvihkBwtJzuPS3qFbu/VMN2GTuKIk/k4P77/iq3CFAPYxDsmC2MgaTh7zBaG60M7/GwqSAaYfnMrF3joy9T4iuXlrJy4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890912; c=relaxed/simple; bh=9R5gDYGRkD3zuEAj6D/OwgIiAtThfu1pQPpc/dE4v6w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pSWkGKmQC1uGgiQg585lTjO/JlfBbgqSvvHOjr1vJiQLBgRMmZcEvSrgSwTwQXN25zMt8K26ZerVA3NVyHJISs5C5BsabYuZLcJmR0B0ROm04sh7dFTcIAWwhZhPLN1nHoV55NA8YMDE5412KIvMOTLjZjnc4dnt4qLqwo3x2c0= 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=n784ZDFK; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=n4sYcpex; 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="n784ZDFK"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="n4sYcpex" 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 492HfZSO025427 for ; Wed, 2 Oct 2024 17:41: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-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ryNP2/BUEI5XGaNMf5mCh93xxASKGerHyr9sWS/BFKk=; b= n784ZDFKvg8DRfzcsdfhmrRKTJOD6B13RApJ5vHAw1l6Gn//2ukGyRm2L4da73+3 nhNaa024POSDukHk9t5Udw+TvooAeV/wILH5M3ZZ2vmC47oA/8bbCB+R7d+EW9qv PoL6xfB9zVcDusZmQpGYgTBcOZV6IcEcx5/H2bTpL5hJPwa8u1NYVliSv+u1XLgY zf3yosXa61n9xkAcuO6FR/LKyZlxISiSNrbrPLRvvcKCfJQ/Dv4U5H6Qwwb9JyRV ERixpl7TU9G8sepdOTvH2HS9crWrS/a2JO8e9+AnS3FcXPMro3GSw3oAr6/0xQzQ OHrMKvGHW2JyUs4y6cWsMQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9dt2cdg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:49 +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 492Gj0Ax012532 for ; Wed, 2 Oct 2024 17:41:48 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41x888xgju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lNgDTvTMY8qcZNncPLox4hPs1FsHSIUGNp5sdqZ95XHQmureEyorfkd+HsRX+Dy/9rnFmYYuwxXPcjue203nUcD5FvCtrx9XCWrwwsHG5waygNLhQVefjU96TGK58u62EztGXEvmzKO1DIBdrXarMN04FNIiawW1/BxXMvwTnyTE7dnFCeHHLMM1puUEnkJ43dD9TlksRmgpODGKbsmR420y49TftzYayKuKZlbjU7QT2Zj9LxVWxl3jsk8hVaDhwe9MEdsUOMc9CIchMcDCvJaQ5GjEouwpdvaCX9/SwnbXzvA3mJ2NuYG43ra5Xc0ycTZiAQEx1aJeJQTU5IF/Kg== 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=HDfK7AlRs1INcrdkJuufu2Y9JGJAw1CL8TGaT8AoYfm2X82jodrNx6BgqygAjAj9H92AVd63HjcKUsGdGEuVxYwBNHkZqMvtz5lInneFC53hYEiO/t++YUoLVc5PZGFRxc3X6YCpnJGfcvfWYbKSWdtbXFXh3ZCBOIcpXRPSyMi7NxgCvs8ukZSxBlangqslccSok5rpGf4Cxf0PMLWpyhMWh4duvIsvSwjBdM+wNuuobiFBvS6kwkpLLCe1zVki3aThz6kNRGhod5kCpJRBwfRZoL3Za0ET/q3pD8sqVjWl1W0VNaiQCHNG55gU+WzFxt/jcLDln/bUkGqldKuGIw== 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=n4sYcpex1nWDn3miB9pdmjKHCI3brlFMr+9mtgJ8D1aoH/pKtbN250xtlJgOtj+opi6yxK+MMNB/p4w3NKyUHpk7fyugzFIVv4L0+IA1ODLJw1uwlBkZ4+1b4FmWyC5uQqhkwevS4yw3N4naQ9ufjcHwQTADMrEXHpmKaS+FS2A= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:46 +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.8026.016; Wed, 2 Oct 2024 17:41:46 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 19/21] xfs: fix freeing speculative preallocations for preallocated files Date: Wed, 2 Oct 2024 10:41:06 -0700 Message-Id: <20241002174108.64615-20-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY5PR17CA0061.namprd17.prod.outlook.com (2603:10b6:a03:167::38) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: cb3745a2-41db-4339-9a10-08dce3097c9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: A/WRo8QG2YmiV8U6uJXyihKRATXh4ULauHWMF6cXRUbFj+7kDwl53FMR+qb8CEwVpkaCzU2NvPRyd7OlrJcBYWB3KL92lveCovEa4EMlcxdqtMlqb4mzz7fQMwfQ74tdD2ZUzBjhHEdMnQFm0j6hkO1dBPbQto8V7K/7Cq3k167JMWB2hnh16htscLvG3oyT5PW6jQFjeOEFH2y0SBdyUGV6OIuOOk7+m4NLwMCLJ+Z36KaLZOB0wb0gWCNGQBqKvLGfazHguypi2XZcsLGpFinkdM53zdjeU1/yw7Xiwnm+cVHZLptA4UFZCe6lzLTtYEN6xwDKYVHwOHgninuive3bhqw/aY9qV/763ghzXt8AthwmbrzNm6ZSKH6PFU23w3D7P7mnsDYvcl0iKJi/lsjgZ7J4RnLhAvjr3GjZ0q0f6xPclu1e4O6wuZHys4jgLGq2qrFKfg5X1yG84t2PBiJCqci7MAB8d4GhJxCxz6Uo0avbGBBxuT9Om5ZfP+pi0ReoVoblc6xxvzHGZYxTUSMgIuFqQ0x9alPbw3EomPCMYMB6H7X4iJZwok+kh56v+5k8aOmwhCb64ZeaNddIyKGIBeF2kE83l8soukfUQDe2wroodQI/WfCr6vUuC448/WrPlKPCN3a5SC9vJpOoi6HtybyxozDeqYrZQYePsmD2BB6xLyqArMxY2Yxlu+TBamIW+kQMB1n00xTJxZMAeIOIqYQUa5BVpSNO3WdUXiKHFuAPIt6Ofyak0DcQGglqUKogEUSQV31La4XNN+O657v21d7pIyIyYGf6YURWDKaZyRJ3O9Gw04ChtdiYihagiWH/bmyn6HPCnCcUgCWzWz7woY9+dS/D8bpSg3e9y8pnn/aBJNY0Rwh5lwTLbY99RfAzt9Bou7boG77DmvBxuuzgyDGJu0yQwqZHRASE594oNnCiuHWx2rcgXUHkiOJW61uxK+bGKRSkAYA1pmSPplpk7lLEhS67sBB/jXhXu4qbknMdCURHjkg/Z6cTbLzvynV++Gnxb3MR6OlfGVbeQJx7JenV3vifY0fwFIlpuoPMKDWg8VSQsFWqHJrrq38o7Dqy2jD5EqD/dy42fsVapjMqd8wIqekBjeDW3B7TSf/Qkagcvsaf5xzOb465RoaBIyfMSGnQulGkQcZWUGBrItOqWcf6PV+oaTbskA6zhF6lDXmrcaFH1tdQSfTJPMOONyychw/dYMggpvEuXxsfW89RhxtV1/hAwx9ubISWdVpBxe9sFVPRXzJxDcZBfxIT5cvLjkD2azRmYtzl7p4m3A== 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: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dW8Xz2yKcL/CXdFj89kvOyueHAkhFcJGuEBkO1FoXThvHdEuhcxen2SUCJdX5cfwr4WeW/ko9qHJIx9yy77DjJvk2EDLujH/AhWYXSZafv3/NZM8itThkiXn+qX6OnHzqkSOr6cO6Ex00RRkjXLS3FL8Wjf3LqyFO8pHHKNmCoJ3uwAl8Kx+zd1E5g1h44reeK7HpmOsFxuozkCscktVcal6qk1xUqLtNL+DVTlrWDROr59yU1+DEe30ECZbazx1v4OxmZR7+mE25c53QbD9xXXAL32bWzmDR4VZf0JZNwmT6ZYtYNYYfnu+Rcx5mlxy9NUdHv9cTfCl2i16vqnRn+cd1M8HH+uw20kxYA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb3745a2-41db-4339-9a10-08dce3097c9c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:46.6133 (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: M5epKkgRO1FFNSBvBXwS0LnoNlKfDbp5yj63nMuy0uZIyiegP9vo3VOsACISMIcT4HhSspkyLzkA2KiiJ1gkqVOfoWALDjOyojycvC/UlTs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-GUID: HkrIJaycTa8S3RrAYqB9A1NnV0Ou6f1k X-Proofpoint-ORIG-GUID: HkrIJaycTa8S3RrAYqB9A1NnV0Ou6f1k 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 Wed Oct 2 17:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820181 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 8B18E1D1E6A for ; Wed, 2 Oct 2024 17:41:52 +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=1727890914; cv=fail; b=cNgRzvqmgVYGKO/gWfQGdUQeHV1FxAawSMWn13TNoeOrlpS1nP57ZBTB6Ahv7lYd1z10tJXxl7ViWBNNgrUXfLgF/F2IOhhvfg8C8pMhNzyaIfBBLwZxeCxD7CDh2NzncKGPk4oFWgUok9uzO3qfEU/W+YU+HqeoipOcmRDoNx8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890914; c=relaxed/simple; bh=ikiGPzyv3cbFoMlSM9kaj25Yx8WNQmDcKZY5vp2Fw28=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pWaO9ewiaBClWRvoHN7P00/b1CbHDY9UQiSM0rfT4OiWUyFn6tji7VbIeLRJdWskrwqnhqg5FkEd8x2uNToZYYx7JhPYxVYks1+aTOBpOazCN+QX2PX982rPM3QBgSdypAK+LDQSYwdMfQ3CjKbI2KcNviGydJqWqLYxlupiOXA= 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=a33xtTf+; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=HnEu7eKH; 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="a33xtTf+"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="HnEu7eKH" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 492Hfblb025084 for ; Wed, 2 Oct 2024 17:41: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=kOxBTx7oZBdqH/0gdm/PfoegPpR0p8bAeh8gliR9s10=; b= a33xtTf+TnzTsU6kpRi9PHQYpNWeENW7gs9rzMGILN1tdvjRkX9CQcMaOuj5LZ/5 EzvFAnStZp5GzULnQCNjqXFPqtL57v0XhhBkbBjw/y3n5DEeMjmC/4n9cTsZTRP1 ul7RZy+xEZb8zxHnrtmOeDSwvR4TRLmxBG79b4N7AgOaQSnITRJ84o1pX6dndUCd Px7QwdCKKk8qPEjz+DM+yds1uEVBTtQdWzt+34mURXKi10l8iPLm47h+6NAFsHiz ZJ/duQA36LXY9I9LuE9sOmF8auyfHII755ZP29FdIXyNgoGnHLfsgvBzQX6qHDxM DnnyN27iWb7bsdQ8mTnSEA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x9p9t3ej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:51 +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 492HUb1K017337 for ; Wed, 2 Oct 2024 17:41:50 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x88951u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oaqifazSrqscp8XmcN+qTvLICeVq4IEyKLU82KgVjzXfm6fn4mL1h+OV/n2MTfQgFFoMBL5fkgPxM+K1dGzrxq+nH0xNDuzjDokYwlUKnJzKF9zmvWQb9iMCkdZUi4zBVIjR9cOc4dvzr7Ds3nSXnK8MaO6E9vZGZriQbH/8LcseNC+R8Gfz3yChPzqrdmTt6iaOKnkq3sdkp77Bf0brW7DlJEFMqtyr6yjKPnNZZqUhEVFMToyFcYABTsDuQKeo1iiuzuazLy/1FBSVgUR2rofLa/agejpldDK9E47j0atzF18kMSIjPIyjts2Fl00OBqLdZOpECFNUEWP0xh/aMg== 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=kOxBTx7oZBdqH/0gdm/PfoegPpR0p8bAeh8gliR9s10=; b=DxL7zSJ1AT6+qJyQlA5vnmZxZvcoR4fOc/3LtvmXm/4f0CdQafCDeHLBDiQbnSZf2htXYszk94Wvf9b8Jq/Qioz+S8IUDUKesF/06MiwgWs85vOGIqY8Ryl+mWdlTQe91Wfr3G41gpnM4lQjk6m62XiIaS5gds0cgfZhzPv32X74hCS8lq1QnISaTueoQKa4rfZSU2nzjcVhbjYtQdwXv9p2p6JCVCJy0+UVfYxQjd+qmLgHO+uu+hJFB7I1Qp1sAx0POxaInu6tFRxyrwA7m3fyZGDYLJPg3pt7cpkb+COSmTLaWXNo+I1N2Wx9DSkILMPFreYrk/QunlhU20m7zg== 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=kOxBTx7oZBdqH/0gdm/PfoegPpR0p8bAeh8gliR9s10=; b=HnEu7eKH+i+WSo3JM4C/KaibtRIPo43SBgdlV6M4L82zyBzy10Pxnqio2bWFYgQGJFrGHcT+P1SzKV4xNcQb8FTQRbXKKdr2L8b2TT+417TXiWWZOyQSS8YnVL/BNMa9tVJ+sejEQvD/GtLZz4ihH6ukHCycifuosb58J4vfqis= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41:48 +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.8026.016; Wed, 2 Oct 2024 17:41:48 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 20/21] xfs: restrict when we try to align cow fork delalloc to cowextsz hints Date: Wed, 2 Oct 2024 10:41:07 -0700 Message-Id: <20241002174108.64615-21-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY5PR17CA0056.namprd17.prod.outlook.com (2603:10b6:a03:167::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_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: a830e704-c963-4de2-e066-08dce3097dba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: 9s8O0R7A4douykJImVUtiUbKCM45+0I9dsma5tZM9DnNV6g62oRx1CRI1Ajy1HU82d26R9Fbky8iI9hgcm97TITybLzr9NHqoWkfYTNTj1LCLQVUfl1At/pidbOVvTVl4DhcMHpQ+X6YrElpufxN+kGZakFA/AhGbwMn6GaCF+5iJGpa+Eq8KViGgD13p+qvRFPecw5r+TnWvs4rMY22QMXs+dNhB6AK63e4xSfcoDHVI3aJ84VnUadpUa3b60gIPmXS11W3Cy15Q3W0sacevmoHTYLsIOkJBzHrw6dnWv9NrUsDjF2669TrxEAhrPWNDGF5B41f8Oc0O0Ec1jCGhKZJpWNMNadhsniShaewgpB7fbaqZqOvomlh2DbFBCKcnz4jZ0YDOlfG54keLeha3ZVNkNJiqnN3mECxtK9l3seUw+XTW33KiagFr6HwgWwcJrjhHxiZw1wmXtfm4RwW/SkUTrDeKD71ICtIIJmSrVIxUWUL8W8YYzYU6rLN5p4kr2vSv6pkQGHsZCsbd324UEJrNey6FcZKLFQSROtlXKl5CLxzbFMciIamaUbJDzHtLBJ41eHIp+MY1IsRBt1UKTfM7kUCyaCH2z0hqkOzy4tB8Ripfe9ujXqaIjdA3mcwpTIGmmX0ks1mWG7hB5Fm8gCye/3sTO3F01dvwgRd7+jVM7HLbfk1RRCm3dIuRKpMujYFZsaaXxkWgD51nosQMAP/GvPCVvgUdaTYrMba+R634NaMA7LhHavdo/2DGMnpooDtNPWK2LMMa1MqyJ1ruJT64xypsgY56YziwdT7L33GFG5uzFL4ORDlHP/8yG0IewGv0rccH79UEYCFZTffd0PrZoyDPweOPRKsNJxpQ439tKXHIPgWLH+oM4UWn1iETVcZYfClPGq9tYEVt6pPGnAsRN5Fa6SK1XOi8GChLrloCSWXiYlbyLOyS8i8+jGaI9N1K4unTVcNsnKpvv8icMd6FTFqbGIip8V380RK5CidAaWhjAkGwUYKPmKEY4cAdV971aL2uwsSZjMCA1KLh8LLTWM8xffxgZmg/w+dRymCCngKIMo0Hb1LishOa46evZkd6t25EKO1kNRHE0ULwIS10l/lOnrDtBmcDRmQ3xzuH0a8ys3av5e1gYDaEwcql6o24GX2F5pKUDLPIV4B8cNe9K2bkjmSZMIBT02DPVaRQfC2w4DjqLPdo2wOLVeh99JEbT8q+PxZ282rrCIZlUCWjtqyEfqOs9c8cZku05DTB8yX0zZO2oAhnILcMI2CJB/Imm/ePY3DrYAbgaLOnA== 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)(10070799003)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +WG9NoIC+k8HsZncJKgi8I3tPbZIICQRvg+VtACFtyj7hXPeeE5qn4VvdmsKpfoVCv5cNhzAcWDE1EzdXjCpcGWJ2dG1mCrpQK83PJKDdRLZQS3po3OJWIFdBcyUcPM4vFNbP6wwSaM1UMG8xhWaHIC67hmIv2bmbw+1LVp2ATBogZ4OIrF11kerwjltTvHWkwdVFbR1Rk8LVXuEzrSo4/wFmJZgE0AaWYLOtZ+nEcp/ILgc6sTFRLkyj+Y/9scswYAHlPwxJgFJV8lkqEe4RjKJO9X/b86L5ZGULuDn3wYqsRPd6KarusSoRVjJ2DQoHobKgVdbOlyMVFB6v/rtdRk2bfihUEPgqi6TR8kvBfdwWXHQLh0cuOzp6hy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JfQYeTHdnQSGCaV8o8lG6A0uAnmJ54A9AoleC2JB5/SNF1e+V2l4oOelJUbJ3rn12H6kpdiGE3cq4W3+yC1dAhEY34bdr2c6prDMZFYmyFW9gfiDc3ebf2eXefqZqzG95ZLE5APWhCRj62XOPhoaJRPtqoNvaJDpVLghn3r66PM2RKv9KeqiiwOg6RlR2a1kSDtvnt/rxi8O+wH8RpwuIfj5XVGj/4jEBKg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XOFDhO+mtGgObNHAIGY3veHzQYbLbFyMJGIrYG5J0Uvml+1IAShppS8r6wccm0MGRgC8pndy67Qlj0yGQgXxtxkcdnacOHawwnDyG93L1RIBT7EKGGBallV8R2jMh7sVRwSABf6tQMfckpfbrEaVjkUWXHb0hEgQ1agAeSYssB4hBhq+CrMb3ytFpcWMbyNCmhbdau+Kw6AVVPSwywjgSlh8HEZBeAnlT30qJmrHUD1OZVGuWrDSV/LaH+677XiEnfNfkPN+2G9q+90xa+FGPoA/84kO7/SGv8l1smDI8NojrAkfR6PfU4+GASHrgjXkMJyT9/I9gRl0BWH51MYaMXRBM1H2er0pdmK6+hmfVueBAcoTutCl1VRl/XRTLTic7YEBuKbNA7cjLNgMexXtotlki593yAU6MkqtLaOeWnJiie4LNMPwkLEFgL9aEUjuZjjsnZu4ewNEBkntZyHmb4qG0fiLSeoEA9vwz53QudNV2YTWrnTx0FSlqyx1uLOH25gGAAnDuJhjRE3s3mRVMNsi1+TCwutkeu9NKCyWMoStbjgYg0flxcNDjP8YC6ubzC3iuvnkBEih2e3yuQLrWdlLeYffOiu8frX09HztT/E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a830e704-c963-4de2-e066-08dce3097dba X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:48.4549 (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: xuP0twWUJeqXAzJJygc8Td8r7z4aqnm+xaqLgLBdIJiPRF7FE2wab0yySWyG+lkg//hU7gaUA8GhirJC6kJ5mYmEXrdpi2L+RogXcifqlWs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: _hEu-PtCjQe3x9ZIsScK568WRuQi1WZ4 X-Proofpoint-GUID: _hEu-PtCjQe3x9ZIsScK568WRuQi1WZ4 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 05e36a745920..e6ea35098e07 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3974,20 +3974,32 @@ xfs_bmapi_reserve_delalloc( xfs_extlen_t alen; xfs_extlen_t indlen; int error; - xfs_fileoff_t aoff = off; + xfs_fileoff_t aoff; + bool use_cowextszhint = + whichfork == XFS_COW_FORK && !prealloc; +retry: /* * Cap the alloc length. Keep track of prealloc so we know whether to * tag the inode before we return. */ + aoff = off; alen = XFS_FILBLKS_MIN(len + prealloc, XFS_MAX_BMBT_EXTLEN); if (!eof) alen = XFS_FILBLKS_MIN(alen, got->br_startoff - aoff); if (prealloc && alen >= len) prealloc = alen - len; - /* Figure out the extent size, adjust alen */ - if (whichfork == XFS_COW_FORK) { + /* + * If we're targetting the COW fork but aren't creating a speculative + * posteof preallocation, try to expand the reservation to align with + * the COW extent size hint if there's sufficient free space. + * + * Unlike the data fork, the CoW cancellation functions will free all + * the reservations at inactivation, so we don't require that every + * delalloc reservation have a dirty pagecache. + */ + if (use_cowextszhint) { struct xfs_bmbt_irec prev; xfs_extlen_t extsz = xfs_get_cowextsz_hint(ip); @@ -4006,7 +4018,7 @@ xfs_bmapi_reserve_delalloc( */ error = xfs_quota_reserve_blkres(ip, alen); if (error) - return error; + goto out; /* * Split changing sb for alen and indlen since they could be coming @@ -4051,6 +4063,17 @@ xfs_bmapi_reserve_delalloc( out_unreserve_quota: if (XFS_IS_QUOTA_ON(mp)) xfs_quota_unreserve_blkres(ip, alen); +out: + if (error == -ENOSPC || error == -EDQUOT) { + trace_xfs_delalloc_enospc(ip, off, len); + + if (prealloc || use_cowextszhint) { + /* retry without any preallocation */ + use_cowextszhint = false; + prealloc = 0; + goto retry; + } + } return error; } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 1a150ecbd2b7..9ce2f48b4ebc 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1127,33 +1127,23 @@ xfs_buffered_write_iomap_begin( } } -retry: - error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, - end_fsb - offset_fsb, prealloc_blocks, - allocfork == XFS_DATA_FORK ? &imap : &cmap, - allocfork == XFS_DATA_FORK ? &icur : &ccur, - allocfork == XFS_DATA_FORK ? eof : cow_eof); - switch (error) { - case 0: - break; - case -ENOSPC: - case -EDQUOT: - /* retry without any preallocation */ - trace_xfs_delalloc_enospc(ip, offset, count); - if (prealloc_blocks) { - prealloc_blocks = 0; - goto retry; - } - fallthrough; - default: - goto out_unlock; - } - if (allocfork == XFS_COW_FORK) { + error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, + end_fsb - offset_fsb, prealloc_blocks, &cmap, + &ccur, cow_eof); + if (error) + goto out_unlock; + trace_xfs_iomap_alloc(ip, offset, count, allocfork, &cmap); goto found_cow; } + error = xfs_bmapi_reserve_delalloc(ip, allocfork, offset_fsb, + end_fsb - offset_fsb, prealloc_blocks, &imap, &icur, + eof); + if (error) + goto out_unlock; + /* * Flag newly allocated delalloc blocks with IOMAP_F_NEW so we punch * them out if the write happens to fail. From patchwork Wed Oct 2 17:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catherine Hoang X-Patchwork-Id: 13820182 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 9BE5C1D1739 for ; Wed, 2 Oct 2024 17:41: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=1727890916; cv=fail; b=kSDVWc00KuBCuV3Gt5gRrOrXqOZ7qfl3VV0Rqo5TmjepzAWfhAzSRJgZYsT63SA/2qwxwmRf89Yr7rMih8ODwLl1e8VE7JGUp24ALHlg6R6immbMbvu4LE/xsTJuRCY6q+ULq8RFOr6skiCBTOsCoiGM1yRtLr3wxMSht+Bet8Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727890916; c=relaxed/simple; bh=pTvhCsPdBqd+3suk9JeashoDNVt3VxpLxDmgHu61NwA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TSNgC0M6uzLsqX7yiUDgS83cA3cPE5DBFKFFdTmOTyrH7mI22zv1p+xJpej2cxZwVywZ07Ehq1oPCCzbsDBRtjxXt7ngvicHFhuBQE5p0+0n0RsPIm/9Ml1EG7D95Un7tBs+CASdch8NZh7nJFNpFKcyPzkjHH+o7QuvEYM1I9g= 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=jQ0INP4a; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Dj7aDCJm; 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="jQ0INP4a"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Dj7aDCJm" 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 492Hfc3P022784 for ; Wed, 2 Oct 2024 17:41: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=evKcOv+6Qp/Niv2wKcPN4j9qJ3CTnZ+LcLZCqWEjlk4=; b= jQ0INP4a1LTQTT+uU4bwT+mxXxDI8wodIR/ANn1+qwbV7tlI9VQkZnZ2ebynOUrR Y4bsrkpTsxAaO/v+peS1Q8OpUrTC29oG2kUNiLUcee1CbxleQgMfuoYjhWpbHXLM YZR6WiD7IwXXSfwSMYhz1svbv5oLsZUuuyjelqUaqOq/Ac8SY92uNx4gzKX4ZMOS NGCaHdCVea+5i804m2H55G8iZ5LGC/at7SonKVirUt5iDsLUZPKSTtudrXzXQ5o9 RkMDSQgSVoWx4IwF3GQg554OuS5GJSNcWVuUMmJV7RfEG2rZsvH3HfWJ4ZeAtAmr Ps4fqSd/DjTXHrtbnZXQiw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41x8d1j87f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:53 +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 492G3fHY017452 for ; Wed, 2 Oct 2024 17:41:53 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2044.outbound.protection.outlook.com [104.47.73.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41x88951ux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Oct 2024 17:41:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UGZlpGZGR+nB+AiyzOfrZAiXCW49N5aHjgAL8Kh7EZQ/BFi6SrE/0ZHXwYWVY0fBFozIdOR5kB9Xa2kJXCM2OORdhQLZ9DL9Hqgs+VIit6bqOczauRn/oCLTy3FPZz02OAVSKGWvxTlOsuTH+zRqWx5LOZGRGyuVEbwLAjAptfOnjf2CDYi7C7Zlat+QfSw111IpOXEexaEC8Mk5EVRL/XdxoBWKCjuMFrkjMUTWDML6g0gqLcgVA1TjMMu34Hp294mN1vNNjG2XgXKxs8xLV2ww8iXC+mwmlgIHvx0oZDEjZBKxOdy5RGzwDZ+NdTn1FTgBesrI5qzmyuFNxMp0Vw== 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=HmRSaW3ac5CordqSiLvdijbkg2ZO2RSJFpFP34sG5SwDBfLAhLCJ6qEZLFedGwcnGcvPlGM+0jwKb8Q3nJtChi5Q9vuFZSjbThNuFxJU9Vg83xDngnJ+m4Z4dllYi8F/jUxCq4tDnVWoJvLJbf2o1T11qqd7iSE6xyhQrCFcUeUqqdEed8bO2bH4tOecNL2BEcfgOvy/sQGzmQqE5EQ10JDygKvmssw2TFdFQ042pJQsW/pcQp6omZ4Q0kUPiHbWeAm1GsRNbPhoWB54eyHwGzsYZ5pYlVXvA7w7trsW/BJY4+BEgfrgCf4+wX/G/VZtFOlG6xNLM2Gy6bh9YMZqRg== 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=Dj7aDCJmPMyJPj3d0ZrncIjJdB6D+I95UvGKAfr1p+mYhyCnFnArUpwPs0fCPauxDThR7OOSkSm59x75pcXggyIoIu4jobo7LLI+cXDW8ouKkXIs7qjVQYMhUZUKpQuR6wfpW3MsyGAO9b2taB11xIWXrlwSUGrH3ZxY0Lt/lYI= Received: from BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) by BLAPR10MB4995.namprd10.prod.outlook.com (2603:10b6:208:333::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Wed, 2 Oct 2024 17:41: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.8026.016; Wed, 2 Oct 2024 17:41:51 +0000 From: Catherine Hoang To: linux-xfs@vger.kernel.org Subject: [PATCH 6.6 CANDIDATE v2 21/21] xfs: allow unlinked symlinks and dirs with zero size Date: Wed, 2 Oct 2024 10:41:08 -0700 Message-Id: <20241002174108.64615-22-catherine.hoang@oracle.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20241002174108.64615-1-catherine.hoang@oracle.com> References: <20241002174108.64615-1-catherine.hoang@oracle.com> X-ClientProxiedBy: BY5PR17CA0055.namprd17.prod.outlook.com (2603:10b6:a03:167::32) To BLAPR10MB5316.namprd10.prod.outlook.com (2603:10b6:208:326::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLAPR10MB5316:EE_|BLAPR10MB4995:EE_ X-MS-Office365-Filtering-Correlation-Id: 0360ce46-74e3-44d6-a9c5-08dce3097f4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|10070799003|1800799024; X-Microsoft-Antispam-Message-Info: R82Eqdr30gUDL42kd6d5ntUmYre5eYRX63RtzEoYJDfh5AXDDVg7ybhDI/Ih5ObkLR2IzSHCTWah6DM5VMj4D7Ur6esKY3YBWLrDWKgpmd+9nhRNPaj3WQW1gdyMUpyBrAQ0Fv+IllCWV6O8S+Zs/R6F7WbiIAQC+Gqw6g1njRZfEY1kH+RQdwZtnFJX7+YkG0acAxFOO4OdbNOSWseDCyMOh8vWVunfT+Z+E+8WFZn+40+OIoDWTsqucQ3B7lIhFE1W7oADMjjrasAJlF3fq6gFZfpoN6zzF9UdcDuqjd3sjExJ68+V+jPwz7fL9+WDMQ+v5y7iYg2w9ufIqfO7bwteRIZPstQXN0kUQngasfCj5wgz36DxIj1loOYLd6MIn6Z3m0t916ACwPh/ESBaGZT7JJ3qptzEtMtEuwWB7P08gYjeV8ldOqjRI6hNyZgwjV2vzXNaMebqIb4My4BLvyH6FN1wmdvpeKjozNdccuvZUnMhx3q2xnUneTAAY6ruEixtmVcCAnsaLDOlVIRAhvqSVzjhCRWuiTedInpP/O1WJ4hqH4o0qBXXE2nUlsFB2vGZ8BZUBYG8O4AKs/pGGz3WSwGpeqGFsMmFCQhU0kr2GPLOQWmwTzTyo9mFb3Ig+i3MS3ZILef2OFMUWEo/vcOPLnkbA7oK/nn9lp/aZggYG03kfh+IXgxYsFWVIU7JGNrflsKjmm6SCljonFOr546070lLss5Vhp1Eom+Q2tgacTIATxRTob/iQ/NIe59vRiUfkEdC4UA6BBu587sTggej4v91J+Uz4jLkd2uahZbb4nOkRhwyiskcz4UOWo51mI5oNdihjIox+n22HU/rWzDRthj8FmnkkWHqIo4eZZGhb6fyCIwlOanpli4rcjCuqpIet/yXk2Nk0GrQjsHdbPB01iKhG5NZhEDapbL8/zHEuGT9a6RkiBDL5USuA5mautNOA7BFL4j8zojmxkdXoCP6rU1jK81RwS+rifpTfaFuJ4UlZoyCdCf+aqxkGAJ9HiSym7d9wH1R0u975GIBowVb6asI9LTqQiIIO6kfqbfzuyqg1igLj2MYVIEXkxCNZlQgDAg6W4zuekB/UjB7Vi3tbN2oDvLRLchCXCzp7wD1lSb1crVO/hVbgOJSf5J8PFouU7jr5/edsPL8Y5+3LCle4v01mmZSPlRJrfuVv1xRwIS8woS3HQbJh1Yu/ywy5POQoCoje0VOhovw77NWE8LEitkhEQfYbeLyKWmEI4w4+0BQ44nLs5GMR1wq/jx8lSWnF4dgryf6wRnshylOCA== 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)(10070799003)(1800799024);D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/0j5owSMhORV3bnTTBpnT4QUhPqmOzTI0e3AAFWs+MdgAOjtO++cJiZ665+ER3G9/mUKE8gj69ef7k0mfzw7t2Vm184AbcFAdMwOhNt9TFpWxXNoszXJ0kjZ6CXuCWQlCGjl5RK2N0eB7LDVo0t3AvXjxytQfcr/Lk/jojjzm5qOzer2Dz6wLdgR04wHv4k6byTFNXAXOHCqqLz8nvdocLr0axHYzepk/j+Z+fFLGjxatt9u73FdqYEtUaRlHP+HpzHsO/LRz0t2HIDTs9X1TwLOPAsy0SodoYEJR7Va6w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0360ce46-74e3-44d6-a9c5-08dce3097f4c X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5316.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2024 17:41:51.0967 (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: Vma+6ufTzKK6Ac9LcjtbynKlZmFaLsXEKZKT5pOh36UrOB6Woq6/GP7r8TOd9TZJ87lQWJdwrNpZJbubwWgwvNTs459oMT45qnGj8zzFmIY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4995 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-02_17,2024-09-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2410020127 X-Proofpoint-ORIG-GUID: 1C5ikbz6gg0IkBChvwPPqR2W5bB_cnyU X-Proofpoint-GUID: 1C5ikbz6gg0IkBChvwPPqR2W5bB_cnyU 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)