From patchwork Mon Feb 13 04:04:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AFCFC636D7 for ; Mon, 13 Feb 2023 04:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbjBMEFN (ORCPT ); Sun, 12 Feb 2023 23:05:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjBMEFM (ORCPT ); Sun, 12 Feb 2023 23:05:12 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF55DEC58 for ; Sun, 12 Feb 2023 20:05:10 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iH7Y018548; Mon, 13 Feb 2023 04:05:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=nvZj4BgeB/EP19oo2qBvJ161wCiOlGb2L1Sym0y98l8=; b=zzgxFoFa9bUjq9UY97N7qI0a08ySWRy6cqMEebSaInWh2CphHPrb/Cz5lDrqtWu+2fyF Lq/Dfp8vE3SsiwTDHsvTiMihoJ5lrZIy5RF23quAe9TcG7p2ZHGAdJhkgBCD60pogsas GSlfSetK/82n3NNLXA+uabJoNrhrkSL9NohbTK1Aaw+O+ohDcwRMmLdiKgVT+jedwGaK gQwYR3GkrrG8yxr1GsCqEehJ2nHHdVZh2mWNuNE28XwB6VrkCKze63Ukyyr9Ym0Yf9ju LL+FZwpDjqu1jkvTMD/EhrkRUykvuv7BaTn/nlxYxXxOR97mndUe04zxRRLZi76EEil/ 2w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv1d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:06 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D30H51028784; Mon, 13 Feb 2023 04:05:05 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jwvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cg5/yRh0E/Y2SYOhpP+XmqNOq80d1VewI7e2jKeqMmNVOKgrwQvwF3EybaH9obLgDjiCDu0oHT4++9K5qc5i7rwFZpKoSfpKZPkFAX3P1DDw2+3myxywlUJBHToe7bi4O4QoMXBln6sXgWRuCoiUC60Iuow8Vuu0+4XFuSJQQse17CothCSes3POv+5Lxy/a/a2Uk0kb6rFmmRLKRGtfA/786tz3/uc9Zof4AwEwvykB2l8hH2Ozyg7RelOwGcmHQaXw9/COfWlNVyjB4z8+ehyM0Q5BBhVGVdmpkHNo8x7CIcN+PBZjfKC2Fw4Dhfk5QmxJBBj9/n3unMPQ28Qyqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nvZj4BgeB/EP19oo2qBvJ161wCiOlGb2L1Sym0y98l8=; b=G+8NN3dqthJtQ/WF5iUdSL+sw2VSMwHpv/cbZJaZvSfUrWaS6Z9Wf1jgoDdjIcY15YPrQqgr3fblVdEJSELo8njPQZf49Up8aVEZv5QsCGYjhX2ATqq+vECF4UCYhu/iuI1xInC5V6pbxOcKKlUm1uAfZh/fbN5vpvwAjLC+Oyja2sVrV78+37detmQLC4QKcr7QnBnQqVZPuZgqECRrrtgnoX+d69ws6h/RCNk3PXbs9IaeiRAXye6ktSi56GCRTGaJb6Xz/3YHQzctQJcUSLEzHnjJ+RzV4HF+GbYiwZq0as+a6mtNx1URx+TLi53py6lV5JN1fW40nozWmvNKOg== 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=nvZj4BgeB/EP19oo2qBvJ161wCiOlGb2L1Sym0y98l8=; b=P5ZbSfkMNntc8tZmDqnivIQMuBCdlPwceTN7Oy/93NpbN/chMEI107W8JAY9eaqbvax3kmUANt/WfMpptW8VinWlTnjR5BrTLRfH9a1gseyB9sLTswlCOv6JiQTcWZiJcqrirPw+IRisuaWPkEFaUcY04u1eI+OqovU3KuZaOv8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SA2PR10MB4492.namprd10.prod.outlook.com (2603:10b6:806:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.7; Mon, 13 Feb 2023 04:05:02 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:02 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 01/25] xfs: remove the xfs_efi_log_item_t typedef Date: Mon, 13 Feb 2023 09:34:21 +0530 Message-Id: <20230213040445.192946-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR04CA0018.apcprd04.prod.outlook.com (2603:1096:4:197::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SA2PR10MB4492:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dcd74a2-e894-4d74-2eb3-08db0d777b5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JmU2ZLkHRgkAKY4OkzDblFh/wHR5x6i/KJQIfADpC+jufEZZW9KDJc/QvletrDZYEm6SjfoKofEiLMh7Ptl2gfBafQOOnh4NfznEdIu2FxmllphbGyZtJj/J63OwVao03CSFmBkeMlWrHwaAWO/Xm+woeGPNafU/6TnKO4ivcA7EO4yWDB9x8qlTH3LlFrsSJcOy5vASoAzcl3SKLPWqGsJbdxvqB+54tScD9jJn/FgxBJSwfcD1ZbKYvVXtBrHpVEJ4Zdm1nZfN4pF8FQiwmRVB54nLQNO+I3lBDGczVUTCsrTh9TH+v1jdg7xc/wWr1/l6dQHcNpIP9SdrBUILqW0hkLaUTGV8t2a7JsZ2FAz2T0coJAU/Oo4a0e7FLIWr6h4pRyF2wDllYSS9PP7A3OL1J3CDWTly15lg79qxcCngo8n8DvL5hqcqjGTsoug13SEobBV0hqpy/p2I1ovASxMZCUu2LLVZWRtw/QqwGlJc5fRtI625ofytBQK76RXDQ0IPS56DpwXbkXiZKfKMTuK/UlBgx36bppyFYZIMy2dFJOCi6LTb//CoCrjhL1U/1hCYAYb7Rnr+nAhNapjCVG0qbXT8toMyaFybwIcPDthtAAvBT70ygiGUqvqUKi+gmAvB+wrMJRxyQmzlsXLjCg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(376002)(396003)(366004)(346002)(39860400002)(451199018)(26005)(1076003)(6512007)(5660300002)(8936002)(6506007)(186003)(83380400001)(36756003)(86362001)(38100700002)(2616005)(2906002)(316002)(478600001)(6486002)(6916009)(8676002)(66556008)(66476007)(41300700001)(6666004)(4326008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tCQ4AIc2S1BtSTcOiJaTZXxLdMuPMxcM58XWnvi96Zr0dPA8jkVaCFX4X1p0DAqM+0xHXUH2ZLNFxsXr4nfUrRTJjeAWFqGaZVPXwV9QospeyjcRDQM110lOxwte5gZAMx1pfJPBfyE9ONy5zr6iK1CgmdL/qlREb0dkPYfkI1L6VuMJthMzeBZp6Qq7UG6OVG0P9yVBtd5uN55Wvt2aPx2dqdknykGOVbzEc5YjYtYuWLqD4GqeWbhezb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ffRDJA3VKzysv00P+bRvNqucbafvIE3jQBs3Jjtg1YZ1DyoTmJzNsaxvB7g2+3UTUCLjNlnWEthhZKlQqjgb1dl0Ar7OdvBt+H+EyYW4jmrmb8OQKivnl X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dcd74a2-e894-4d74-2eb3-08db0d777b5d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:02.5968 (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: R+Udf33VLBgBhbMRlgriIsAYDLuJzJLkki8z2J3ivbk4u6NEBfvGY8v1l7qx326T8oETnKK1EVTZwhbvjBc6GQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4492 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: pCoyzw5hJ5AQMfMf6EmIBQpW0EykyO2x X-Proofpoint-ORIG-GUID: pCoyzw5hJ5AQMfMf6EmIBQpW0EykyO2x Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit 82ff450b2d936d778361a1de43eb078cc043c7fe upstream. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_extfree_item.c | 2 +- fs/xfs/xfs_extfree_item.h | 10 +++++----- fs/xfs/xfs_log_recover.c | 4 ++-- fs/xfs/xfs_super.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index a05a1074e8f8..d3ee862086fb 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -161,7 +161,7 @@ xfs_efi_init( ASSERT(nextents > 0); if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { - size = (uint)(sizeof(xfs_efi_log_item_t) + + size = (uint)(sizeof(struct xfs_efi_log_item) + ((nextents - 1) * sizeof(xfs_extent_t))); efip = kmem_zalloc(size, 0); } else { diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index 16aaab06d4ec..b9b567f35575 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h @@ -50,13 +50,13 @@ struct kmem_zone; * of commit failure or log I/O errors. Note that the EFD is not inserted in the * AIL, so at this point both the EFI and EFD are freed. */ -typedef struct xfs_efi_log_item { +struct xfs_efi_log_item { struct xfs_log_item efi_item; atomic_t efi_refcount; atomic_t efi_next_extent; unsigned long efi_flags; /* misc flags */ xfs_efi_log_format_t efi_format; -} xfs_efi_log_item_t; +}; /* * This is the "extent free done" log item. It is used to log @@ -65,7 +65,7 @@ typedef struct xfs_efi_log_item { */ typedef struct xfs_efd_log_item { struct xfs_log_item efd_item; - xfs_efi_log_item_t *efd_efip; + struct xfs_efi_log_item *efd_efip; uint efd_next_extent; xfs_efd_log_format_t efd_format; } xfs_efd_log_item_t; @@ -78,10 +78,10 @@ typedef struct xfs_efd_log_item { extern struct kmem_zone *xfs_efi_zone; extern struct kmem_zone *xfs_efd_zone; -xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint); +struct xfs_efi_log_item *xfs_efi_init(struct xfs_mount *, uint); int xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt); -void xfs_efi_item_free(xfs_efi_log_item_t *); +void xfs_efi_item_free(struct xfs_efi_log_item *); void xfs_efi_release(struct xfs_efi_log_item *); int xfs_efi_recover(struct xfs_mount *mp, diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 46b1e255f55f..cffa9b695de8 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3384,7 +3384,7 @@ xlog_recover_efd_pass2( struct xlog_recover_item *item) { xfs_efd_log_format_t *efd_formatp; - xfs_efi_log_item_t *efip = NULL; + struct xfs_efi_log_item *efip = NULL; struct xfs_log_item *lip; uint64_t efi_id; struct xfs_ail_cursor cur; @@ -3405,7 +3405,7 @@ xlog_recover_efd_pass2( lip = xfs_trans_ail_cursor_first(ailp, &cur, 0); while (lip != NULL) { if (lip->li_type == XFS_LI_EFI) { - efip = (xfs_efi_log_item_t *)lip; + efip = (struct xfs_efi_log_item *)lip; if (efip->efi_format.efi_id == efi_id) { /* * Drop the EFD reference to the EFI. This diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index f1407900aeef..b86612699a15 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1920,7 +1920,7 @@ xfs_init_zones(void) if (!xfs_efd_zone) goto out_destroy_buf_item_zone; - xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) + + xfs_efi_zone = kmem_zone_init((sizeof(struct xfs_efi_log_item) + ((XFS_EFI_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))), "xfs_efi_item"); if (!xfs_efi_zone) From patchwork Mon Feb 13 04:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4505EC636D7 for ; Mon, 13 Feb 2023 04:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229477AbjBMEFT (ORCPT ); Sun, 12 Feb 2023 23:05:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjBMEFR (ORCPT ); Sun, 12 Feb 2023 23:05:17 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C85DEC59 for ; Sun, 12 Feb 2023 20:05:16 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iGSc018536; Mon, 13 Feb 2023 04:05:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=AOn59TvjkfXdWSD87bZHEcFddRAMA0hJ+srFR3L9UzY=; b=YWeHP6A6qG12PABj5MF1pn8q97lS7PEAQs6I5rCavjd032LHrTZLTGAl4V2m8zSoLevW 5w104Rp24fRMS3K74s/2SJcshxLAgoa+6JV+kYHwmwjoJvAfc4P0tKj/SdEUgE5MesSr Eo4w4Hbz57l2z92Pp0v8uBgHsKmPvRu+1nfZp7dbi4xMS5Hxxej0uMghN/bjcOXQVDMO 8+fxzlzhZ8bp3smrFv1akhVBEhnvo2IBSeU9GsOfnIwmaVetnNTddO4IBFpT8qXBjUnp Nvd4rvdMU9Yscs1NW1o2kb4yyrkMlg95Cu9HMRctfrPzACyySPKlqjNd3qXFt2Dad0FK xg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:13 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D35gkr028859; Mon, 13 Feb 2023 04:05:12 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3a90u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fQj9WXmyeTnZBoHCgDRymkVvfxrfW+c+O4CR3gomyqs+qnpvQx/S7neLRPp/iNdt8wT+Nx2aVHsKFUdwXK9MYjSigJGR6NK96m8WpfRJs3CHkAY61de+sMSi4ZvRdCr2BORCZzLG6YcLAH81kmylN2mZx9zY3rN9vKjYWSgD4WE0H5M4CoRoWLlmz4YbARXIZpKlsmMv6HHJIB05MV38yoOk5oS7+qdZ3BTO5PCJC3mZl2Ry/b+DKxB+Dmi2GPZAzDPoYqj0/ekeHkhQJHMCo/DFhpeq9rqrIqRWICx7A4whBRe1OwghRypDRpmCATCAfo3R+Jdl154HjvE5LFckzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AOn59TvjkfXdWSD87bZHEcFddRAMA0hJ+srFR3L9UzY=; b=AO+SjsD8t7b7okkhU3mzKt7Js71qjG02Zww1pkQ/HmAP8EbFD2Ehl6Wcn6Nr37ioRSFIhvF7ITdXaszwIxQP7WbIM1sbQZ95m1c5QvR1g2i5o4A8m3WJoVKImyteL4Pvl0j/a9jjxpO4b5pSCnDF3ur87DhqdjguJws/btRH3OxrcQD8+QhmXq8AVCmcYoPnBWCOxXu5lpfIAC2eLYOeBlKKVz9oXxY29S8gheNqSXJzwYiSIwFAvxUT7RQnSzWMkqCDwRTzmaey3nyqIokuJqhbu5jha9ndoWvclLcuoYLn6KYf44jY8/UbP6sPYiDahAZaUEc5rivbzvKbvXtLxw== 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=AOn59TvjkfXdWSD87bZHEcFddRAMA0hJ+srFR3L9UzY=; b=jmwpGuKv6w4h5JsmH4HdmWEYfPjsyVlJVxu6F8nQNxkwvbojvanxCLexphOA0Che6mHljFAmv+S/8neL+H6PA50BLDcF/pgkUm+WZcyZh6cpEcx0JMkXM3piiqrZWMlXKo2GTU9O4Fdx0Y14wEKYJN/lg7xsYCR2D5vGqPGnFmg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SA2PR10MB4492.namprd10.prod.outlook.com (2603:10b6:806:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.7; Mon, 13 Feb 2023 04:05:10 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:10 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 02/25] xfs: remove the xfs_efd_log_item_t typedef Date: Mon, 13 Feb 2023 09:34:22 +0530 Message-Id: <20230213040445.192946-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:195::18) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SA2PR10MB4492:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a23c9fe-d29b-495d-eadd-08db0d777fb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I73+EFkbx2hZbg9LQjI98CZG9GuPwrvuDzVE19agwMz97Unevh7gUtXykqD6Hsip3MIgm3TPIu/t/KJkF6OBHLLICUMpEPV2lA01C7NHGjYrLgkPH6A1n4C/zUBBbGPecJdO8rhD2B2ifXu9ZM6kW7bZ0YxJ4+gktRqpCKB+2QtVIfSJtsYbjGlV3EEckj8RKv4SrKT92S0DrBtgINSUp7lBqzBcKPndEHxwWQy1DqnrJkzPvt01LpIOJpmxhGsqiJxx8FZFT+L3VgSr2OjuDV1/VxQL2XsUbB68aOXuc/TgqGKXOo0zjQyf7Xmkw80WYz6lO8ov4kmwalYa6pWOtEAGrsPF4AqH6jaTR0zd7kYidpqbIKPPRx/fzwUbtiyHfWwdSlx0ez8Q5/g109oA6YMhowVjdQIAPxo/v4wV/0di7/9z+Xranmaw74OKMQVE1MAEclJKYdNb0IStUyngkpG1hALXyRGTO9V71x0Uza5PUBxqHBFmKsnmPsAwVMYo5n5H5BotGP9ajyF7J1ibYeGA1Xz+2f0IEjBLUgZLgJllmNIdBLzyirPNtWEA9NwkPcUOQ8gPLY3BEfoq+sUrDpjD8lbt/lK/0KpDSTPkYU85ej9IgjcmhzQb3HoGuKqs/zH8ZqEdXOnKESv+wupRiw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(376002)(396003)(366004)(346002)(39860400002)(451199018)(26005)(1076003)(6512007)(5660300002)(8936002)(6506007)(186003)(83380400001)(36756003)(86362001)(38100700002)(2616005)(2906002)(316002)(478600001)(6486002)(6916009)(8676002)(66556008)(66476007)(41300700001)(6666004)(4326008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4t8W0HrQY/0D3CPZF492541xEpljpOWadyKC721QyYiDC5WeLlClK5i9e5YqgqCC7yLu83umMSkHcFzQFp/wud/ONuRRF8JUV9TUa9xe67UHYkzgi/lz0qGCxnzg72WBc/HlSFRtNsmdTP2SYnVJ4HTUA693vXA61os+Hl1v3iYMiEyRrcoRVOIE0VxbRO5jFOciJ7RAh0hAYjVOqTeefj2JqGpD/kHE6L8OPJmKXLK+CRD0TmAyX1hgk6WhP7t0bPqAZtTUezsErJwuaiqHtMRo81CNlxiDIoFoTO97ip6m0FZC5rx8OMjHKv0Ilv2YHVrFE2U7iX+Zg1wFpK6GQNpVPwCV17Xqi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ifq8fY1zpgZsuh3D18NwEOqZbG4bFFnP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a23c9fe-d29b-495d-eadd-08db0d777fb8 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:10.4244 (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: 2/25wfjs06Ldg1zeLYxhRoPSZlvvbYrJz3i325pkupwV5pDeUghvAfT0iHy+oDDpu5bP11rUGplWyHrT7PyeqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4492 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: EUmlwmh7xQa64xVaXqz2CikhXMvb6xuB X-Proofpoint-ORIG-GUID: EUmlwmh7xQa64xVaXqz2CikhXMvb6xuB Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit c84e819090f39e96e4d432c9047a50d2424f99e0 upstream. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_extfree_item.h | 4 ++-- fs/xfs/xfs_super.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index b9b567f35575..a2a736a77fa9 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h @@ -63,12 +63,12 @@ struct xfs_efi_log_item { * the fact that some extents earlier mentioned in an efi item * have been freed. */ -typedef struct xfs_efd_log_item { +struct xfs_efd_log_item { struct xfs_log_item efd_item; struct xfs_efi_log_item *efd_efip; uint efd_next_extent; xfs_efd_log_format_t efd_format; -} xfs_efd_log_item_t; +}; /* * Max number of extents in fast allocation path. diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index b86612699a15..9b2d7e4e263e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1914,7 +1914,7 @@ xfs_init_zones(void) if (!xfs_buf_item_zone) goto out_destroy_trans_zone; - xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) + + xfs_efd_zone = kmem_zone_init((sizeof(struct xfs_efd_log_item) + ((XFS_EFD_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))), "xfs_efd_item"); if (!xfs_efd_zone) From patchwork Mon Feb 13 04:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F7D2C636D7 for ; Mon, 13 Feb 2023 04:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjBMEF2 (ORCPT ); Sun, 12 Feb 2023 23:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjBMEF1 (ORCPT ); Sun, 12 Feb 2023 23:05:27 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFBCEEC57 for ; Sun, 12 Feb 2023 20:05:24 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iKMS012067; Mon, 13 Feb 2023 04:05:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=/vVC6OqKYPVOcntgWydM6vwQAwRiqD+nv526KHY190g=; b=r06PlduC9b1PGRAwFHG/qqlZRd7vqEYh+QsLD5rEF3pQqytqYEvTX//Pncg3dxH2m+Mf hegyGnD4jxtAEvhLtv8P7TErUaOTVMw5mikbglQnLRUjKeBN8kapAic5tS2a9BIXA8iB OzpMYp91GMFzkc5SJ+nl3paESd2riYZMk5xTkRgiwwMh0ky83h3VlxpaBAfpCztmY8vD f1JBrNSfghQlAyIAutFYXOBqfZ2WgHruTYrVc5wW2Teg6wzNTBrPAOSHl3MGM+kCXPJ3 nULtAhKH0hfUXuT/2bgVIGiRbCNk3TghM1aC5CkO0/Lcn6Go3jAtrbWnbkjziwnXJIvH Sw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:20 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3hEMe018082; Mon, 13 Feb 2023 04:05:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f428k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YSRRdr97HtqnJm9pc+qfWFSXnMhF9xzGt0lr5MhytQznTYHfP0lOXd2mCZxdoHcc/gbY8dnxX1pLE2PcTkyBVPTPx2UO78cEopg19FCavedDQwCkQEwaFIY6hLlt1tylQLzmS5v74tcWAw3ck1Fk/XDElmSdwbgYwENcd2xwtE8fCgy8TUR0FID6kxysiAamREo259uGfd58F/lU9aYRTvXKd0D6/2uYKPDbr4WyyzoYUq/5U86urVQmhSL77DWNA4GWMzE1loTU+kiY0+bVjhOMKj2rekBKC7jPgduDjIsr3tBUtOkm6hEWS9ISi4qBg/oiEBgYSDVioQC0/u1uaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/vVC6OqKYPVOcntgWydM6vwQAwRiqD+nv526KHY190g=; b=TXfV4Wd5ln+QSdXMVHwNrDao5RfLAkMNNGiYndUZYp4MOzqMlmai8ipdknGspuhVjVFe7G5NGKo926aa9teWlgmHu6+AdiSWkB8tbF2UJETmslmV9fQVL7PZvboXFp7bvYEdN9073I5vmrMqCQgHQVKkef8LkYo+J4D/yqHod68dxi7JdqX0iT3VLHsVi9ffYK1E/LpYO468sZQMosLw8zmv/oeuhqYwC9V0XT7/bF9ec4KHyXvst4StLKyRT6TreguPyQkm+9+I4S/zbPhge4GLHB+oHvD4izEe4M0h9mYgznqXKXM839tlNw/6bIUxsqE4MN2yIfSNMRevrwUdrQ== 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=/vVC6OqKYPVOcntgWydM6vwQAwRiqD+nv526KHY190g=; b=fxsQUD6olfTzLUQjuqffti76dntlbkjGdCZP4Oykr7iHB5K2BD9F5wN0wj/g6SxNLMlxKUFiYJ4BZlWd1YpcE4ymwVzCDkwYawvoRUs2YnBXvjOv8Ptbf+/aFMdm7a0Oq5TGSJcRtevCC9uC6J8r0+ybwuCGmPT75Ox/UFKbHDE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SA2PR10MB4492.namprd10.prod.outlook.com (2603:10b6:806:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.7; Mon, 13 Feb 2023 04:05:17 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:17 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 03/25] xfs: remove the xfs_inode_log_item_t typedef Date: Mon, 13 Feb 2023 09:34:23 +0530 Message-Id: <20230213040445.192946-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0027.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::22) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SA2PR10MB4492:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c1defa4-bbf2-453e-c84e-08db0d778431 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w7Gdw6P0jTdvtjERDSGDh41jIEa+EhYd3A9/IJAXJgTSjwd5CB/GA+xblbh4J+TLytgUB+4WTDEjPFTa66ezObfXWxlVooaoJB7cAkSx6m3ukoxCXYK68JVBEh0BmNf8KKP39jNaza+f5dugGMDTxyrf8BbB524HW6eA3PA6nyTiMgfPCoaVhIUpZAOYCsgGuok9iN1aNSaOEyoQHcSaZKd//Vnfryo//KfifbS460z00QpCiCs+p+XcMasUWYj5+AEf2Enc2x4KSMSytK0fuA3mNymUUAo1vNdq8dlHzQr0Ide4Ty+cYTc/GdsE4mcnc5OL2aOUAUnJanabgn2/h5b6mmX9bKAUF8/2SQhwMmdMtNFVRqQo/RnsyXq6J5WnsbbHZRmPn+1sCzb0w251sP9RosoYyrPoh1K94NRMnLbh62gMfXX7+vGfnfK/1sMhMk8mDfvyR/qjT4PSi5SoqHnqIpoU1Xf61jdQcHHzqiMzbuDWYfvNqMrRnLShPtgfcQIpCIIRkMvxXfrxe1muEuIyZxPzz9I2bt9R3b45TvSblHz5EeeVDU1uZsizMEzsMS+fnu3fLF3g7f4+4ydJpYlEufPc3g1XPU0SvtTCyd1BtSaNOgVMCKe7x8IaImcpweUMiCQx9J3THRLLzCMp+g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(376002)(396003)(366004)(346002)(39860400002)(451199018)(26005)(1076003)(6512007)(5660300002)(8936002)(6506007)(186003)(83380400001)(36756003)(86362001)(38100700002)(2616005)(2906002)(316002)(478600001)(6486002)(6916009)(8676002)(66556008)(66476007)(41300700001)(6666004)(4326008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LpbMTOF+0bc+RujanVFhizKxPdjQFN9q5sXlrwO1o86CZ8V1k1QAiT8yaD+I04F1M5Y1xkHvavg6Nlma7arIUGBEZP6W4uAQNbm8ceuIMTPxOjaBjM79+OMSdpe9lQ/cq+Jy8MWu7yBfdZ5FY/Uo62m2acRmWjQOCQ/nqNnTekOELWlIDXbfW92tXB2BMYDEPgJC1NcEpnwnWZVkNiYWWDbNCfVy2IaOlSkHvybC/TFNIaV1G99jN9M9CcGwAlsOO1SbYcpkVs9nyO1W1I14TGPnrietkNZ/2AAaKheMLC9EQhhBc9dByKRHg/7Ap5c0t7d6+/OLJ3nJXCddWej25YLt01If+JH8cn9XL2XO2RwzerzP/HLnEwfRf8UWlZ6Bq8EIsDvWRqHe78QF4aYwQ1U0w1qkQrMbTB3mDg4/hUENSaAlGPFWoGJXm1XY02JyRVoaf8iYmoSX0687f57mRlIV5fu7wEtTBTBBhU0rw7ZzSF2YLmMU2dFaiUlpQN2EnjilCMVe9OVINwm0Owh0Rvzof8xnVp1B3Cl11IYMFsWdodDcZ/S9ZNmjj0Lu3rLyrsAoy6CdTegLsUmNua5QZfxPd2+0rB7Uz66RS7rF7zYLdco5q+mc/E+MMUisn0Wf/JlH0kdIQ+QHBk/uBorOi8603ZdPNmewFn/r+Uu9UVMGcTKFNbVA3DmBOEZnGph/yExzj939opRfwUShZgqtZ2ALTXtdZgpDAbRtzCzQFpKFQzCrGr49oYyNt/F/gnXvuWv/X89QvqxAGGTL6iCeBMhvoGu8h6OBPnM8awe19vhZDWRZOOoE84ewiBu6xpGyb5x1SvM9HYRgc0oH+07XvJiUXYsHlyJvFxAOVdAzVFeK56t+7CE8VzIOD2Fq21NEj9iXMIEfYjO+rJjsKZ9JFbP2x+ux3FGnAPmNJuDQLhPnybMKl63F/f5esZhuihfKFpeIJ+CTPlYFM7hX5a0ZhSdbWrq1gHLRDP4f4bZSrYrJHZY35h+n+JRhQBDDieZOVeM4HBP7rIAd/aGKVHVyxhk3Upw/tQWRp8E0x4SekVwA7wNrJ2TmBWwGOUQJsYi/pWD0jVgUxRqpj+2qOyIlNkWGWs5w2+n0uxOAqr6ZmrbM5MPK9EVH7tqU0146OMoGR7AWENK48JGWOhFMMLBUPJMilsEJojIWniW7MvToQCox3FJvzVrpmtAqGsI2Qea5vK2JmpJOWADk2qsKMH4resSdVoAS+iFC97eT0PjCosF81CDT23HCaoCarxtVhzX3KB4C/EVIxNIgXUGShf7mILwbzSsTmEJpVi6gVJjdwNUdXalzTBa70IYtv4Fv5Nscwfyu2ayz1vCgb/n503ZJubL6sIpFvQ1ZVY+oX55JofQtusYxKlLnyBMLSDizc96HCOnwsULl4559fOtKPoErWyhrv6CMWeaIuo0fjoZqOOoUxzUVaE9fN+f7yOXrcZdll4yWvr83cHy6q/juUk9XcrHUZTKUey6nRR376R661ASlOTneyDr26m2Gqzb4nlR/GUTZrUUe6q1dtwLW70jTt/bZ5G+SERPYsJb1FMsvHkqklnaXJRbJOeBtXOjhx9MO1XQozQw6hLLoEglllzpQCQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: EQ822hG1jF+QMVtpy50l0QiNcaLU1VoBdmkk0TXYqLWe9JaVtGzA4vAfphMWXNG0/JJgr4niYXNZlWC34yMqTlUCFqLMV2yHOghPRV0gTY2nCR9fUngMdFNkxPepsiTqdYFH9LEn3jvZu2q86JaGG7kJbqw1c9PKuQaUZ8/IiEAPO7cT/B11XS/GBM6KFyDYWVcK7asQACxXyq0bIN9AV14KEvWIhCOk0ZIA2R7HEbpPfkL/G1zEvIb266+sgS/RvnTaobrukIbvadVQ1IyShsPrz9OC0gvVxeK6uzK+nQV4cI8z7jUfNbtL2tZcPhYIw/AQVuI3yBnoJ5GYphpF67j/M2lX2Tg7KPTAmL5n7/qd02Rvn27dt/UbbFcXL4F3ENzwKl4ylbTsLHch/ZUmCkgsSma9DsVKq9rtmnZOnUdueODxSbzssYF5eRSfoeP8MhovdkW1JOaSDEq1+QgDF+d0vHDCDyPgJ7Unaz4wUHMi0BBiMgMaK64OZpBWwCzj5XBdlmCduMmI37/vVhCinIchc2r6ZVSyh2X6SbpmyYKZq/Y7Pr87t4LAsraaTSeYRAGv4OZoWvHnQtWd54BmBJ9Rn48HtqHUEFYOZcuaIXYUShEVzez56xHeBJYZlw6V21ELiVvspt1y0QVm4LeCSZM2KHt1RBrlgkB7fEITz1c9sD1nz+Cde5nXRoQmOzdZ7ErW51AXZYylirhBxTtQ+jnTgJZRjPmAnb6DmDv+iHNi8MDpNKdh9hnZNqCb1RbLjnydb0EcI0VCgR08eMXedSJ99MG6VhgcvF4fhIkM/kLwjvnva6FrlKVW8OQhalo1 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c1defa4-bbf2-453e-c84e-08db0d778431 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:17.5837 (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: 26YOdCfIqa1ePXlmw2cZQp0ii5Rgc771bljtEehZKbkVp6rZGDEky3BnbwKwkqv+jcWsb21Rw2jKQGL/FwAUvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4492 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: cnTmPdXotzATtO9oDV1OfdT-fZydZtc0 X-Proofpoint-ORIG-GUID: cnTmPdXotzATtO9oDV1OfdT-fZydZtc0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit fd9cbe51215198ccffa64169c98eae35b0916088 upstream. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_inode_fork.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 2 +- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_inode_item.h | 4 ++-- fs/xfs/xfs_super.c | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 15d6f947620f..93357072b19d 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -592,7 +592,7 @@ void xfs_iflush_fork( xfs_inode_t *ip, xfs_dinode_t *dip, - xfs_inode_log_item_t *iip, + struct xfs_inode_log_item *iip, int whichfork) { char *cp; diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index 0ba7368b9a5f..1d0e78e0099d 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -27,7 +27,7 @@ xfs_trans_ijoin( struct xfs_inode *ip, uint lock_flags) { - xfs_inode_log_item_t *iip; + struct xfs_inode_log_item *iip; ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); if (ip->i_itemp == NULL) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e5a90a0b8f8a..02f77a359972 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2555,7 +2555,7 @@ xfs_ifree_cluster( xfs_daddr_t blkno; xfs_buf_t *bp; xfs_inode_t *ip; - xfs_inode_log_item_t *iip; + struct xfs_inode_log_item *iip; struct xfs_log_item *lip; struct xfs_perag *pag; struct xfs_ino_geometry *igeo = M_IGEO(mp); @@ -2617,7 +2617,7 @@ xfs_ifree_cluster( */ list_for_each_entry(lip, &bp->b_li_list, li_bio_list) { if (lip->li_type == XFS_LI_INODE) { - iip = (xfs_inode_log_item_t *)lip; + iip = (struct xfs_inode_log_item *)lip; ASSERT(iip->ili_logged == 1); lip->li_cb = xfs_istale_done; xfs_trans_ail_copy_lsn(mp->m_ail, diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 76a60526af94..83b8f5655636 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -781,7 +781,7 @@ xfs_iflush_abort( xfs_inode_t *ip, bool stale) { - xfs_inode_log_item_t *iip = ip->i_itemp; + struct xfs_inode_log_item *iip = ip->i_itemp; if (iip) { if (test_bit(XFS_LI_IN_AIL, &iip->ili_item.li_flags)) { diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h index 07a60e74c39c..ad667fd4ae62 100644 --- a/fs/xfs/xfs_inode_item.h +++ b/fs/xfs/xfs_inode_item.h @@ -13,7 +13,7 @@ struct xfs_bmbt_rec; struct xfs_inode; struct xfs_mount; -typedef struct xfs_inode_log_item { +struct xfs_inode_log_item { struct xfs_log_item ili_item; /* common portion */ struct xfs_inode *ili_inode; /* inode ptr */ xfs_lsn_t ili_flush_lsn; /* lsn at last flush */ @@ -23,7 +23,7 @@ typedef struct xfs_inode_log_item { unsigned int ili_last_fields; /* fields when flushed */ unsigned int ili_fields; /* fields to be logged */ unsigned int ili_fsync_fields; /* logged since last fsync */ -} xfs_inode_log_item_t; +}; static inline int xfs_inode_clean(xfs_inode_t *ip) { diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 9b2d7e4e263e..9e73d2b29911 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1934,8 +1934,8 @@ xfs_init_zones(void) goto out_destroy_efi_zone; xfs_ili_zone = - kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili", - KM_ZONE_SPREAD, NULL); + kmem_zone_init_flags(sizeof(struct xfs_inode_log_item), + "xfs_ili", KM_ZONE_SPREAD, NULL); if (!xfs_ili_zone) goto out_destroy_inode_zone; xfs_icreate_zone = kmem_zone_init(sizeof(struct xfs_icreate_item), From patchwork Mon Feb 13 04:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12F54C636D7 for ; Mon, 13 Feb 2023 04:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjBMEFe (ORCPT ); Sun, 12 Feb 2023 23:05:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbjBMEFc (ORCPT ); Sun, 12 Feb 2023 23:05:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B12F1EC61 for ; Sun, 12 Feb 2023 20:05:31 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1i72S008818; Mon, 13 Feb 2023 04:05:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=OQsMGyw7/jkyklzbYzOfelI134nOYCLGijUmKHg8Shc=; b=XAjxd2MiaU5AgPSOvd4KQepKTJHnCxsVaXhR3f8VHCxkJ92sTLNWyLz9FCzA+22a5BfR KQagWCR3rY4CfgrTmob+JfDPf3acuSPivIAF3S99ZBwTH6nplOXN9ZFYsahAhEMjZJp3 aqC5Yn6O4DyPlc48ZhjRWg3R1JS8JDY3cvynb0PBmN5/ZbuIKJ69HJM0683AVqdlybcU x+zepdzRIes07CAad6GJ3wt8lAon1/XxXrHsOjUmFR0QLS4D/98yDO1KXpcNPeiSCslE 2eYxo6WTzydttcu0WS6TJMIjDCd7TixFq4qIlw0pgs4uPzQvdJwsaeuYvUDkNkI65Vrb cQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1xb1wpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:28 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3UIc1017975; Mon, 13 Feb 2023 04:05:27 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f428nf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=crt8KPAWUIMaXsRipPOBOlcGpSuywHZACvca0yk7pJSBh9hXM/aasVcEhh43GExHaNSupu0MR0Yq8xtUHtuQl7N65QGMI0d7L8mDQSVcDUgJrtg+3saybra4LXfw9YEId+nIdE5T7ZvPgihTSRKsMw2E/ijs9u2arenHFbDcC+p49Or/tXBSq/9L8I+ziGk7wzWZpVEmiFgrEjaLfKNJ79vGgw9Pb9J/KjA6Q81OzAKhLgHouUiW44hoZ437vKEO/EADgb/QMSSacJL4t2FVVod4TMS7yAdrF58wmnsiiFuR4B1dSRTK05DH85cG65i6cyXJurNuSb9FBc6QXSTP5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OQsMGyw7/jkyklzbYzOfelI134nOYCLGijUmKHg8Shc=; b=FwyHc0xS/aJ5jdVCm1cZb5v9MPTxTaI8eiLy0/bglcmRHSbKLt0qt0UohLPmFyD+//QtCzkCfnAbURIZjVWYRDOu1e7OXCeaCBh+OGJL4ADjYqVJC0pA0bFDEaxSf/8Az0EWUpxTn1qIa32Hvb295gzw3p9p96OaTG2Ks60cmpERkwro7bduqoe/9QD7LhXIU7iEqiYrZBLFYKEpApv6sRrn2Gmj3MCRucqnPcP+D/Vdr8nm73VF8LyQzJv7m0bsxayxLQckHDsM1HloEUB4PTLtgPphefcMhRYj85cKuZLeBcyyCoYA2ypjAQCWCEnYXCVuPY1mxioeYg+Yc4XP/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=OQsMGyw7/jkyklzbYzOfelI134nOYCLGijUmKHg8Shc=; b=dSUCnElY2dU7UjxLd+ky6QXLrKVklS5ydjaRTtbRdnxo8jtpdkREcnIWrA9LWTvyagyrLigYbV5tYzyl5SAk3DhxBVO4Fa6Okm2XyFuh7Bq2j8lpvYsq9H3SxTFPAlo1Rwfm5KKSqwT/3dJl171MHHBgIPfI2awdS4wn+eS0UOM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SA2PR10MB4492.namprd10.prod.outlook.com (2603:10b6:806:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.7; Mon, 13 Feb 2023 04:05:24 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:24 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 04/25] xfs: factor out a xfs_defer_create_intent helper Date: Mon, 13 Feb 2023 09:34:24 +0530 Message-Id: <20230213040445.192946-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0032.apcprd02.prod.outlook.com (2603:1096:4:195::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SA2PR10MB4492:EE_ X-MS-Office365-Filtering-Correlation-Id: 86eae2e4-c379-4a0c-ce94-08db0d778881 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IiukHnPZUbpwEoH7qCCp0cPo2q4ETCbQHOR5xKedOGYB0Rua/Qpz0youm38ts3gqUcBrd3wpCh8TuPDPWyxalrKxYNF9a1SmobiBGFyxvX59yFWaAloqYP6c2JQIqncjcTp0fpWESVr6gwNgmURgtWJndvzQavfDgfyoxUKHJytSfpv3NgLpShRgkp2TKm6JmXAR6Mt0vEoRaB9hCQ141TKrHCbacy/zM5FUr9SnltFEZUNwXmX4k9yPQNfPmiMOaXFPogs0k9j+TxsqNJAEQbJ3yz3IBwlL4J1oSF2GsqiK90kKaWnpmPMIvut32/UaY2MhvD0PFanPpZ17iUd3YYosBbzuZajj8DHIYVC15T3wyGD/y4utytJHlB8wmFos8JBhyJjZC+0JvjBZoGIdC7ZYCAelhYcWygjXj1iblv63tG6BHv03/HHIdhLhWVF1NMtqpySfrYrmDh7KV5wgvofrj3xgteiR0WuRsOjXLJ4hMIOrpxo6IViQF9N/VqcRSCPPw4jk4wsx9lfM9dSI6JGAYf74xOxgyMGw9+TEC20oRigw/TkqG8mdRgW28N53pUHgN5F8yUqlxtjL0JWpKarNNIeL1TSsTY9tOXTTSKjhMyBDJl/P0bx+6tUhyKzFWY/Vq/RcR70RueRmSsyaFA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(376002)(396003)(366004)(346002)(39860400002)(451199018)(26005)(1076003)(6512007)(5660300002)(8936002)(6506007)(186003)(83380400001)(36756003)(86362001)(38100700002)(2616005)(2906002)(316002)(478600001)(6486002)(6916009)(8676002)(66556008)(66476007)(41300700001)(4326008)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0hL7UFIGdsBDqyrUBtge1KSxGnsyyZiHfSxF6Wo0qKCIfdc8W4EpwBURWdJi4ZBE7XbMpN9tjY+TM9qzqw1aMjuDZMDo7ToPh7w6zGI55SHuY0zeCxXDwEt8qBVWPEZmccJPzTi9Bo5GTGp5SH5f86TNjwjXKapxd8mraLNyM0tPhxKB0bzTVKeGCIWDY9jOxYsMfyzLzX8YJDOW2xxG6Q5tMYhPlbe0I2sa7C4wEsmClbsxObrr8/XoOCAt/29lSEDdzD+T/XPHLXLSlM4zBaW+LnYUcgX+JKRlosSm46lvcnCBtbj6qzKsxLTTsQ6uYOY1+XhzqNPDoeI3/CW2t+IemcRcj2P48DH6rK+gSXD4CJQaZiu2vXGsA6mxPLOLqEgHyXxYXTnW7j7FQxJMrMpYBI42qnBrSWUtP4hfjVq+N0ASj84qMs4XcF/gW8qZfAogtLfARirDP20TThvpMuvxGsteKXqQJFWMzahNHeFwtuSMOoUiIIYdDbeltC/lizq/h884zu/TLSgcPCEaP5ZDh99UHjCqWI+oaKwpqTed5d3wgYAJCABrwxE2/2H3U+jhCrZ48FTgcu5tgM9f5hGP2i55oLMf9RPpYU88sbU6m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nbx2rwfP4AecnxraaocPoJ2C7+EFK5wtvOnlz8Is+gDM6LGpZhn/mbyfaAM5Q3e933TCvbhZ4L8zWk3XSZu4UbiP3Zq+xz/E/a8DRR0maOBr/GQQFIg28NTSdnzJzJzRA7oCCtn+UmvtCVLzJv8vKRgcSj4t/bksJFZkT130WmCYvPbqe1zFXPSGVKC910c3VvVrI31vMfgwV+32WIMN/nL+wIe5YHyjLEpknUy2nbnjZho2lq/6ESzFcyr4EOTnPgOtHTJOYQQfA4CUnzizFgMScgjl5is4P/lCAMeitEV+XnvKIiJh5aweq7Hf2TGk89VKE0au1TzVgm2J+Krndbc65kNrxdqdaXAnNynIc1MRuVBfqLUQF5rkniquCiMIHDscRfY2aJ/l16iVvfY03xvX5rvLF7OgXGjOzBRlj7T2cVXqdEvidNcW8g8YN0WXfgYWg+T07Ko6mo7k/bfPWBFm55+87BZ3o8xX2Kk3Cgj3Cm6xQvQvP8iTyspzaZK20fIQ2orMDw13aFpG7JhZvuz5XROnSR6daVvpUto5svcAHTJlbh7l4vpJvDBGdRFjCYV1iRNtfI9KVtX8ZIul9uuYlyp2NCTAaxgjFXypaAcRJpcs0GItOEU+T6TpuFFurH5WEs6JozWm+f3kBi3DRTTxV5HRq21r4zqsbQ89bTmLmUpJls8JBZiYZDFo8MAGto1PRRb1QCmVNPmEhX+oVS7hTnxZVi0BPgrHQPiu7snjzvjeU4JrQm2HK2mSxqTTvzu2cDibBaxRPdxjNul6/fGUjvCPi6sxJUbQefk+YOHdi6/wptevP1iy X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86eae2e4-c379-4a0c-ce94-08db0d778881 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:24.8659 (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: YPe09L/A0cd+z5/DldVP4/+wdmMvZZnBpMJxjpMl7Nxwl47KHvXcICje7fDE3l8LkoYi/KTqgmgA3kjvSmHkrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4492 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-ORIG-GUID: v4pgByfswKdXPlhizvHsFgrbbzyy-VJK X-Proofpoint-GUID: v4pgByfswKdXPlhizvHsFgrbbzyy-VJK Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit e046e949486ec92d83b2ccdf0e7e9144f74ef028 upstream. Create a helper that encapsulates the whole logic to create a defer intent. This reorders some of the work that was done, but none of that has an affect on the operation as only fields that don't directly interact are affected. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 8cc3faa62404..a799cd61d85e 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -178,6 +178,23 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, }; +static void +xfs_defer_create_intent( + struct xfs_trans *tp, + struct xfs_defer_pending *dfp, + bool sort) +{ + const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; + struct list_head *li; + + if (sort) + list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); + + dfp->dfp_intent = ops->create_intent(tp, dfp->dfp_count); + list_for_each(li, &dfp->dfp_work) + ops->log_item(tp, dfp->dfp_intent, li); +} + /* * For each pending item in the intake list, log its intent item and the * associated extents, then add the entire intake list to the end of @@ -187,17 +204,11 @@ STATIC void xfs_defer_create_intents( struct xfs_trans *tp) { - struct list_head *li; struct xfs_defer_pending *dfp; - const struct xfs_defer_op_type *ops; list_for_each_entry(dfp, &tp->t_dfops, dfp_list) { - ops = defer_op_types[dfp->dfp_type]; - dfp->dfp_intent = ops->create_intent(tp, dfp->dfp_count); trace_xfs_defer_create_intent(tp->t_mountp, dfp); - list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); - list_for_each(li, &dfp->dfp_work) - ops->log_item(tp, dfp->dfp_intent, li); + xfs_defer_create_intent(tp, dfp, true); } } @@ -427,17 +438,13 @@ xfs_defer_finish_noroll( } if (error == -EAGAIN) { /* - * Caller wants a fresh transaction, so log a - * new log intent item to replace the old one - * and roll the transaction. See "Requesting - * a Fresh Transaction while Finishing - * Deferred Work" above. + * Caller wants a fresh transaction, so log a new log + * intent item to replace the old one and roll the + * transaction. See "Requesting a Fresh Transaction + * while Finishing Deferred Work" above. */ - dfp->dfp_intent = ops->create_intent(*tp, - dfp->dfp_count); dfp->dfp_done = NULL; - list_for_each(li, &dfp->dfp_work) - ops->log_item(*tp, dfp->dfp_intent, li); + xfs_defer_create_intent(*tp, dfp, false); } else { /* Done with the dfp, free it. */ list_del(&dfp->dfp_list); From patchwork Mon Feb 13 04:04:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05B7BC636D7 for ; Mon, 13 Feb 2023 04:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229678AbjBMEFr (ORCPT ); Sun, 12 Feb 2023 23:05:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbjBMEFn (ORCPT ); Sun, 12 Feb 2023 23:05:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 254E8EC59 for ; Sun, 12 Feb 2023 20:05:42 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iP1Z026123; Mon, 13 Feb 2023 04:05:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=5dgcZNiUWe9vg4m3rNRTUHGkWht2woznPM4wvCl8LTw=; b=eNglSKoHb3uRIXO1inXyxn8Yr6/hM0u9gXFEAqaShhFQ7ms95dqNg3oYcTlJK4GInfS5 0j6jL7jqXff5An8B0bOKnBAxoItby/cfWt4OIZrUc7yQ20o7seBnJ9IIsI9de7LD+ks+ wLTCEX9qsnL8Fbr4Ev2TNRk324Vx46/Wb24IixpKUF4f+ZuP/CVj0vwf6lroXtY1s1oh QBXTFNsNjhDBOwVpsUhFQDAXKNLnzf/PRL+QLxD5ek+usZqbaHUzF876+3zaxwr6UlAE J42dBt+WyrgQuMRtkD0B42dKyqWU5nA+ADjwvg/4hGl2q9U7ek2jPOwJYM6eA4/kY9Fo SQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1m0swqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:35 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D2iUUi028784; Mon, 13 Feb 2023 04:05:34 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3a987-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3hEefCxjQolkDh7tygb7uldmYbKCNHKwV5ZCBDMSVZ+QlisM8r1S7r80enb53YQH6j2Og5Lf8CAk5UqNoAg+N3NZ3dhPMUC08zhq0miSuhYcWbMKXU77z0H3TlAtMUawrJGyQRZKk59vSNM8xMib4ry8GaLZKta7GMTswSm9EdZV6miP1eACIOcRFTIGDDosGkGaq3TtMDscnGk7K/LQ7GO+IhIyUiusIkEh2X4PiKfFFIUw4wiaPljk2ei96dpvthhfv36gd/FGW/AtkcoFbe2gwagnASbULRs89XRtUufbLV0dfj+FUIFSILM//F6ybROIiP8ZbabHFRc1Kxlzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5dgcZNiUWe9vg4m3rNRTUHGkWht2woznPM4wvCl8LTw=; b=cyAMoD8OXYk0Yku3fXpuBD8/zLfLHVMqVgTb94vuQlhAq2aQsBpQ13cTRv9ZPNbve2g2OzQV0pno243+9IHzky6uqq/uMKgUHFHLJmzn8Y7EJyJ/IX5bcgw5CkCa5/CnyzfRGyA252OfBz3M4mQXMqIEhWnfYTUV9+TOObR+ERr6YS55c2OLzCp0NCra3j8M6VIneUbf6LrXDprNLtNbc3cmhsYO49oge4MHaJOktbzlmq2wA2JuqulEXyvbD1HvIqeiaUpY6h/Xaq0OWzgimnjV3a7xLHgqzShI6q3VoQcNhY72c0QbSnDFg1chx1wTk+gjBfGQGZrii6vxb4yR/g== 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=5dgcZNiUWe9vg4m3rNRTUHGkWht2woznPM4wvCl8LTw=; b=JsJml+PBPLS5SkMUNJvlXyz6iBcjfKv6n4K4/c+FuNo0OfCDY6kVkUnzpZb2yLifottqEB2ibJSnt4m9ItKH9iIwq9AqMORX3W4C3jQAFWUfd6nQHCdo9pqmiQQfjqfPezw3yaEoXHve8NolLnnlT4K43U6MMnY+mhXQzVdaLBs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:05:32 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:32 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 05/25] xfs: merge the ->log_item defer op into ->create_intent Date: Mon, 13 Feb 2023 09:34:25 +0530 Message-Id: <20230213040445.192946-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0008.apcprd01.prod.exchangelabs.com (2603:1096:4:191::10) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 83085a61-00e7-4f0e-4860-08db0d778cd4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v/AVGiAm9vEbT5T2vhgZ6wNeTJjvZU3dptGXJ25ADLVMsZy3Rq65tcWecw1uDNAIGucKxG0jj17CG3yiU96DvZrddqX+kNkvYcv/Os5UV2/OrYupACPhbmVeG8k8vXE8bkl9XeA0zEX922oPRbWyXc1WD4GwFTTXgPluO6rlyrmUXTmVIXjW6bDCIBJWdP5pDW6xrh/9QoI5NuD0Nd9kHS9aVukZYD+FouTZ7aC0RdMwqCBehjAn2J00qvD5WdH0y22TiXhvys6hhoIqxlx8K2ur5LkhJDaGaKet8ewLPwaX4jK08W86f/hhbqIwJ7EyJFRMsR8Le4u8UGb8S+3b+onsIUFnf8sw27FkI1T+OiVyo0Ttue09K28PyEOwyTwbYsjZmmHnWSoIKERFBvL4hEH08EkwLH7rKxfit7E3+Wu+ZErDJaft18UmLrRu5p740ybWLGCGCisN6wIlaQPXHKUArDW9TEkMskrqpO4zQ6+18/ZyoH3BoLTFUGJHXyHSDGeVA153CBX34VyPH/BnaQ+gkArCWTcPw80SMtece1fQ2nOBoVQiFs8G9YFsdzW9vsSTMopo7lAwwXsPO3Bex2fRxXXDh7PVgh/yw4GWpfBV+UOKgTIIO1yqmlqobmuYWlwAGt6gmCIBXSFtd/fUug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(30864003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yKGB4m5mfrtx2go/GWYgQlfyGzJQnb8nZAXJ19toeCM/8MVyWNgDp5kAH4T7PdgkjNz+DZ5az3sGiy7eDdUM+agnTKxMJc2InWhnWjqBHum8T/HuSdEcX69xwr9DuTkVEL9xxS1NeJf1SsFVCcO7rQ6bePJxnNNIozLRIrTO5vIQJDX5wDg1EQFN0i80baJHae8mm5Bej6CQQSOSRZ/wBnaJ0nBb0xWj9OTGn3eD4vA/d0sMjngs+p6QSQFmdMqbdVSHxn56gUm88l58kobWg6tN3iOsPnlW6Q65lwN2INq9AIZkHI7E4gTsnxKq0iy+bnesOeUZm59Vv1SME8ar2t5JwY5GrO/DGlma8U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vJi5R39naMHdyKu3DkecsQ8HSIuvYEiUFRODwnJELxh+XJtxvrJGKoFPmqccccT6GGNiQDnuSxjZKADSigMKJwS1aAxHdZ2deuMpye3VVNzzIBUPgN32e9dVLnQseWs96+5moPlG0QSYBpr47RLkYehjvWYZgABQFkBsNaqDfkwoq8MYOX6Xgx6iTRpbg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /vU1FbrleAxJ+9DMfDDPKg6yEFM7ISAhqdKpgv3F0NTCQFc6QHcye0MJ2bafo50p6BSiMBQgREdgaC9KuJpyb8r+Yz/ezTPoqH5SFgtzxDo9/F1x0Lb3JgevV0MVf8clRDfuUjpMwvMWEsb+4+72pF7DAdpx3sb2pigtvT8xcdllBRbqdiV6o6gKlvwjqw7UOFFDQPDR+fLrDDG+/JMyJzR72qhuzOusw+zZAPlpLhrjM20pLThPmiQWWX7EiLy8X3az7ochbmrp3xvdxizCwBnm6qZgOUiLVIjV1T655MogKnaHoq/7w0lMabdQzwvlTsKCiKbGtnXHMallHZu1mXayowoLDyQf1GTTwQlYB83jKM6KKhff2426E/9QBVgFUenr6yG9AJO6kwBNlXQYRHN47qBYm6PYTCV/pj0e/0frOA9rcvhAdfJgYmeOqsv0nfZlDVezTB/qO9XFATTF63NNpNct9Vs3XtV5WO3GXoEzj6bqSONDjyXCm5IjtrUgDGEzB8NbCriky0NZqU4h0knztIOfiY7iSE0T/vhj7Ph2Od961QNj27pLNtKf56c7VsZnOOHnJoEOdC0y/ppRmxvDznSHJzvhnW3TXeIbgJFWNZVH84ToTyfmcoRfC4kH1sz6imAdHasiIGAjAZ+MyxCxG+PsYnq4A41c9mEhJtbqLy+58/AGTFAm4RDxEunhlNmx4xknt8u0yfFk9PJFYSaXN9LbUqe0GegZ1eD19xhA6WmOEooz2PKV8C5dmYo+u7Lx6HzGoOtp3Ij5d56eLaAIHKTCxRaYEb2NYJs9KWA5bADku/hb6db33zqRHKiT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83085a61-00e7-4f0e-4860-08db0d778cd4 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:31.9767 (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: 96c2kKrUPc8a5CG7RApNLRU5ZSdvbskH+QnblZd+yfkr6OtpjG60em6uzo883GlNT4BVGIpNlFidjRyOzib5jQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: jaO_bAJgNKKFZaSEuEO7438s518Un6DJ X-Proofpoint-ORIG-GUID: jaO_bAJgNKKFZaSEuEO7438s518Un6DJ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit c1f09188e8de0ae65433cb9c8ace4feb66359bcc upstream. These are aways called together, and my merging them we reduce the amount of indirect calls, improve type safety and in general clean up the code a bit. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 6 ++--- fs/xfs/libxfs/xfs_defer.h | 4 ++-- fs/xfs/xfs_bmap_item.c | 47 +++++++++++++++--------------------- fs/xfs/xfs_extfree_item.c | 49 ++++++++++++++++---------------------- fs/xfs/xfs_refcount_item.c | 48 ++++++++++++++++--------------------- fs/xfs/xfs_rmap_item.c | 48 ++++++++++++++++--------------------- 6 files changed, 83 insertions(+), 119 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index a799cd61d85e..081380daa4b3 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -185,14 +185,12 @@ xfs_defer_create_intent( bool sort) { const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; - struct list_head *li; if (sort) list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); - dfp->dfp_intent = ops->create_intent(tp, dfp->dfp_count); - list_for_each(li, &dfp->dfp_work) - ops->log_item(tp, dfp->dfp_intent, li); + dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, + dfp->dfp_count); } /* diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7c28d7608ac6..d6a4577c25b0 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -50,8 +50,8 @@ struct xfs_defer_op_type { void (*finish_cleanup)(struct xfs_trans *, void *, int); void (*cancel_item)(struct list_head *); int (*diff_items)(void *, struct list_head *, struct list_head *); - void *(*create_intent)(struct xfs_trans *, uint); - void (*log_item)(struct xfs_trans *, void *, struct list_head *); + void *(*create_intent)(struct xfs_trans *tp, struct list_head *items, + unsigned int count); unsigned int max_items; }; diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 243e5e0f82a3..b6f9aa73f000 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -278,27 +278,6 @@ xfs_bmap_update_diff_items( return ba->bi_owner->i_ino - bb->bi_owner->i_ino; } -/* Get an BUI. */ -STATIC void * -xfs_bmap_update_create_intent( - struct xfs_trans *tp, - unsigned int count) -{ - struct xfs_bui_log_item *buip; - - ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS); - ASSERT(tp != NULL); - - buip = xfs_bui_init(tp->t_mountp); - ASSERT(buip != NULL); - - /* - * Get a log_item_desc to point at the new item. - */ - xfs_trans_add_item(tp, &buip->bui_item); - return buip; -} - /* Set the map extent flags for this mapping. */ static void xfs_trans_set_bmap_flags( @@ -326,16 +305,12 @@ xfs_trans_set_bmap_flags( STATIC void xfs_bmap_update_log_item( struct xfs_trans *tp, - void *intent, - struct list_head *item) + struct xfs_bui_log_item *buip, + struct xfs_bmap_intent *bmap) { - struct xfs_bui_log_item *buip = intent; - struct xfs_bmap_intent *bmap; uint next_extent; struct xfs_map_extent *map; - bmap = container_of(item, struct xfs_bmap_intent, bi_list); - tp->t_flags |= XFS_TRANS_DIRTY; set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags); @@ -355,6 +330,23 @@ xfs_bmap_update_log_item( bmap->bi_bmap.br_state); } +STATIC void * +xfs_bmap_update_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count) +{ + struct xfs_bui_log_item *buip = xfs_bui_init(tp->t_mountp); + struct xfs_bmap_intent *bmap; + + ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS); + + xfs_trans_add_item(tp, &buip->bui_item); + list_for_each_entry(bmap, items, bi_list) + xfs_bmap_update_log_item(tp, buip, bmap); + return buip; +} + /* Get an BUD so we can process all the deferred rmap updates. */ STATIC void * xfs_bmap_update_create_done( @@ -419,7 +411,6 @@ const struct xfs_defer_op_type xfs_bmap_update_defer_type = { .diff_items = xfs_bmap_update_diff_items, .create_intent = xfs_bmap_update_create_intent, .abort_intent = xfs_bmap_update_abort_intent, - .log_item = xfs_bmap_update_log_item, .create_done = xfs_bmap_update_create_done, .finish_item = xfs_bmap_update_finish_item, .cancel_item = xfs_bmap_update_cancel_item, diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index d3ee862086fb..45bc0a88d942 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -412,41 +412,16 @@ xfs_extent_free_diff_items( XFS_FSB_TO_AGNO(mp, rb->xefi_startblock); } -/* Get an EFI. */ -STATIC void * -xfs_extent_free_create_intent( - struct xfs_trans *tp, - unsigned int count) -{ - struct xfs_efi_log_item *efip; - - ASSERT(tp != NULL); - ASSERT(count > 0); - - efip = xfs_efi_init(tp->t_mountp, count); - ASSERT(efip != NULL); - - /* - * Get a log_item_desc to point at the new item. - */ - xfs_trans_add_item(tp, &efip->efi_item); - return efip; -} - /* Log a free extent to the intent item. */ STATIC void xfs_extent_free_log_item( struct xfs_trans *tp, - void *intent, - struct list_head *item) + struct xfs_efi_log_item *efip, + struct xfs_extent_free_item *free) { - struct xfs_efi_log_item *efip = intent; - struct xfs_extent_free_item *free; uint next_extent; struct xfs_extent *extp; - free = container_of(item, struct xfs_extent_free_item, xefi_list); - tp->t_flags |= XFS_TRANS_DIRTY; set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags); @@ -462,6 +437,24 @@ xfs_extent_free_log_item( extp->ext_len = free->xefi_blockcount; } +STATIC void * +xfs_extent_free_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_efi_log_item *efip = xfs_efi_init(mp, count); + struct xfs_extent_free_item *free; + + ASSERT(count > 0); + + xfs_trans_add_item(tp, &efip->efi_item); + list_for_each_entry(free, items, xefi_list) + xfs_extent_free_log_item(tp, efip, free); + return efip; +} + /* Get an EFD so we can process all the free extents. */ STATIC void * xfs_extent_free_create_done( @@ -516,7 +509,6 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { .diff_items = xfs_extent_free_diff_items, .create_intent = xfs_extent_free_create_intent, .abort_intent = xfs_extent_free_abort_intent, - .log_item = xfs_extent_free_log_item, .create_done = xfs_extent_free_create_done, .finish_item = xfs_extent_free_finish_item, .cancel_item = xfs_extent_free_cancel_item, @@ -582,7 +574,6 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = { .diff_items = xfs_extent_free_diff_items, .create_intent = xfs_extent_free_create_intent, .abort_intent = xfs_extent_free_abort_intent, - .log_item = xfs_extent_free_log_item, .create_done = xfs_extent_free_create_done, .finish_item = xfs_agfl_free_finish_item, .cancel_item = xfs_extent_free_cancel_item, diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index d5708d40ad87..254cbb808035 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -284,27 +284,6 @@ xfs_refcount_update_diff_items( XFS_FSB_TO_AGNO(mp, rb->ri_startblock); } -/* Get an CUI. */ -STATIC void * -xfs_refcount_update_create_intent( - struct xfs_trans *tp, - unsigned int count) -{ - struct xfs_cui_log_item *cuip; - - ASSERT(tp != NULL); - ASSERT(count > 0); - - cuip = xfs_cui_init(tp->t_mountp, count); - ASSERT(cuip != NULL); - - /* - * Get a log_item_desc to point at the new item. - */ - xfs_trans_add_item(tp, &cuip->cui_item); - return cuip; -} - /* Set the phys extent flags for this reverse mapping. */ static void xfs_trans_set_refcount_flags( @@ -328,16 +307,12 @@ xfs_trans_set_refcount_flags( STATIC void xfs_refcount_update_log_item( struct xfs_trans *tp, - void *intent, - struct list_head *item) + struct xfs_cui_log_item *cuip, + struct xfs_refcount_intent *refc) { - struct xfs_cui_log_item *cuip = intent; - struct xfs_refcount_intent *refc; uint next_extent; struct xfs_phys_extent *ext; - refc = container_of(item, struct xfs_refcount_intent, ri_list); - tp->t_flags |= XFS_TRANS_DIRTY; set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags); @@ -354,6 +329,24 @@ xfs_refcount_update_log_item( xfs_trans_set_refcount_flags(ext, refc->ri_type); } +STATIC void * +xfs_refcount_update_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_cui_log_item *cuip = xfs_cui_init(mp, count); + struct xfs_refcount_intent *refc; + + ASSERT(count > 0); + + xfs_trans_add_item(tp, &cuip->cui_item); + list_for_each_entry(refc, items, ri_list) + xfs_refcount_update_log_item(tp, cuip, refc); + return cuip; +} + /* Get an CUD so we can process all the deferred refcount updates. */ STATIC void * xfs_refcount_update_create_done( @@ -432,7 +425,6 @@ const struct xfs_defer_op_type xfs_refcount_update_defer_type = { .diff_items = xfs_refcount_update_diff_items, .create_intent = xfs_refcount_update_create_intent, .abort_intent = xfs_refcount_update_abort_intent, - .log_item = xfs_refcount_update_log_item, .create_done = xfs_refcount_update_create_done, .finish_item = xfs_refcount_update_finish_item, .finish_cleanup = xfs_refcount_update_finish_cleanup, diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 02f84d9a511c..adcfbe171d11 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -352,41 +352,16 @@ xfs_rmap_update_diff_items( XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock); } -/* Get an RUI. */ -STATIC void * -xfs_rmap_update_create_intent( - struct xfs_trans *tp, - unsigned int count) -{ - struct xfs_rui_log_item *ruip; - - ASSERT(tp != NULL); - ASSERT(count > 0); - - ruip = xfs_rui_init(tp->t_mountp, count); - ASSERT(ruip != NULL); - - /* - * Get a log_item_desc to point at the new item. - */ - xfs_trans_add_item(tp, &ruip->rui_item); - return ruip; -} - /* Log rmap updates in the intent item. */ STATIC void xfs_rmap_update_log_item( struct xfs_trans *tp, - void *intent, - struct list_head *item) + struct xfs_rui_log_item *ruip, + struct xfs_rmap_intent *rmap) { - struct xfs_rui_log_item *ruip = intent; - struct xfs_rmap_intent *rmap; uint next_extent; struct xfs_map_extent *map; - rmap = container_of(item, struct xfs_rmap_intent, ri_list); - tp->t_flags |= XFS_TRANS_DIRTY; set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags); @@ -406,6 +381,24 @@ xfs_rmap_update_log_item( rmap->ri_bmap.br_state); } +STATIC void * +xfs_rmap_update_create_intent( + struct xfs_trans *tp, + struct list_head *items, + unsigned int count) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_rui_log_item *ruip = xfs_rui_init(mp, count); + struct xfs_rmap_intent *rmap; + + ASSERT(count > 0); + + xfs_trans_add_item(tp, &ruip->rui_item); + list_for_each_entry(rmap, items, ri_list) + xfs_rmap_update_log_item(tp, ruip, rmap); + return ruip; +} + /* Get an RUD so we can process all the deferred rmap updates. */ STATIC void * xfs_rmap_update_create_done( @@ -476,7 +469,6 @@ const struct xfs_defer_op_type xfs_rmap_update_defer_type = { .diff_items = xfs_rmap_update_diff_items, .create_intent = xfs_rmap_update_create_intent, .abort_intent = xfs_rmap_update_abort_intent, - .log_item = xfs_rmap_update_log_item, .create_done = xfs_rmap_update_create_done, .finish_item = xfs_rmap_update_finish_item, .finish_cleanup = xfs_rmap_update_finish_cleanup, From patchwork Mon Feb 13 04:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 503B9C636D7 for ; Mon, 13 Feb 2023 04:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229663AbjBMEFw (ORCPT ); Sun, 12 Feb 2023 23:05:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbjBMEFs (ORCPT ); Sun, 12 Feb 2023 23:05:48 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43237EC58 for ; Sun, 12 Feb 2023 20:05:47 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iH48018546; Mon, 13 Feb 2023 04:05:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=918JEHYjzlNg7G/dzhiM5/gAixijvinBQBAyeBjuQE4=; b=fvCLMHJvh9I1L0cghQLriE/45THaKzZF7ZQWy0mUeRa99c7THsrf9/tF2VaRN6bpFWN0 oFhRbwhWJ36UGYT1thUIyTRCQ1otmtYoWBKx6vT6iUT6jk0hHBp9zj3HyIbZMANip5Tv cxSx/HL+3r30o3EQpBVdBmobjEoC/jkS/BglD6h4w8aIge/0gLnH5qErfq6OCvHKwiqT fiLvshfjEkJPUA6zlQk7J0xHAJMI/q/DmjirlIlQN4leXBy8cdz2DnjWKsZecF6o/uqL 059jp9cV+TL1FlqkGKlvQJLC4oFQOHlPsN81TKwdh9IEhlng8EQPsjS2P6rVImysi2Ql oQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:44 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3BIXN028987; Mon, 13 Feb 2023 04:05:42 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jxdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MbgUKWoK6HQul+x2Jh6g7l48ooZlDESUpD/XVFcJt+3eV+Kgw/aZzaYUNHcJvCODFiuUwLbeMIln0R7yNFVdBqmQVxlKZ1y/Go58HNPmhR/c2nWL/jlDp+0tIDPT40v1E013YKSWz1OEPs7X2JO8GqekxWVlL1n5sQJRA+I62CFkMVDbG7nOhyajsI4rDF949nPR9+L1aGgk3dM9XscFFEFO/0hYRFmY681spDv8q8JmynLdP6ltr9vi2GX9iy7t8KQQvdhSZCPjybZgSCLZxrQwxnnxLGcS6ZXBg9WXL9utDUoY/BgGl+RH6J0RT9z0j0H4Ge6CxEMjaiBAROSHYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=918JEHYjzlNg7G/dzhiM5/gAixijvinBQBAyeBjuQE4=; b=LAM5MlY8VKPQVYEjECEbGJV1b1kbQ5qwH1zPWus0zv1Gj+fKJDWWhdBjH8KpQ6v4KzMYj0iuc8MlCJeheFk9Axo+4czE2OesahzNcQKwDiMfJTbTWdeVXTpcy/gYDl/N1ZVTZrZPwi7IEKV/XZWXfpdWg7+Y64SBXdg5is7D42Xqa2Tq2a387QPIsv2xShXpKNfHAgqAPrzWIY1df9ggKKRV7ynpn5JseUos7rxyjVvgq/Pu0vlBudC4/S6LNestA/gYZCDS9O3X2io2oh6JtPAQ1PX2dnA8ZEfd4mjI4JmR50bkrT8N2JQu7iiONHCDpAU1QTB4xlQ//Tm+K1LWxA== 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=918JEHYjzlNg7G/dzhiM5/gAixijvinBQBAyeBjuQE4=; b=E9crCUnRufo5/X4BYq3iKpSCgpni25nmNtqgBeQ19utKfjMEKhiq/BENLwzEU5sP2mcExGlOaNYETLvEI/RLv6pHGh1k6oGFdT2WEWwP6QgM90yQGc9bg+azF2Z7gg9k3dVV8E8UiBaRvTRVZxRgpTCQ1T5WIYuUB6D0cTDXQoM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:05:40 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:40 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 06/25] xfs: merge the ->diff_items defer op into ->create_intent Date: Mon, 13 Feb 2023 09:34:26 +0530 Message-Id: <20230213040445.192946-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG3P274CA0012.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::24) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d1b0e44-8fb5-4f9d-0e5e-08db0d7791f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Hlls/R8oUmKTJWLOwzW9Vf1X4cTuKblAYWlv5FBHZgFYato7UMKfzRmW+4w+AzRV1TGbpeGJ80oTJk/bsAZHckfPo/KiJAdimOetCv+dXMyfweBvKWmNUTdXqcslB9cuNsYbLB4cfINJVNt00iuNrYwo8JtfmWVTjSMG2C3GcB5sx8Le6RssHOCrxJRRQ6NB0cPkehQX07uAEW+x0sIpjeXI2VMAusUmGEYY8XE50F9en4r0duvrjnsM4FZ6k3HriME+hNrE7ePkm2w+KTkhRffs9I5Tqd5D5vHGfXZcP1thJa7pboYjVBLO+KJrWMoiCoU3CnZsB4seUowGGdhBD6iqWcDwVOqD1yxh88mw99yeIkgV1MUs9s5A8IHnD/CMob+wuZirtEZYybUvgI/EuECBAMwydmgvNkVTL/IScQV9s4q5bZ/MNnCDBkOOvDweqsZv7ui9Rgwe/8d5qbzi7uA61RH9juTHrHjAk1E8+YUY9RCthElQ2uqWTEXDFSb6Tdb3Mn4YamHOUkbr8owbv8LSAMNJCTB6THF0fzL0Ilf5iUbdX4aPEs500hqwudj6UPZBhE94YzZkbkFpifBykKQmW49jvHtoovyBathLHowrK5h3PL5441towCfSr48N3Ej2oVCo+lmUR6XnE6lxA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: upzLLWI+y+bpfAudDX/kAV6VURLS1PjhmsGahBqFPiuEmgbdvJJ9A0anrHG2gPVETv3hfWqivjGVU2vBOTTNQ8eqFzMjFy9pAoTMSPuq9wzs9EUQIAIpfqguIvoxJAbhxACzsetHReygFLGmUz/2ZgJCTAVEiVR7y1vaG4szHABRiy/Ap6+KD0g96tHBJOyDlSOGabYgqAjqeEHBoL3EKhntaBblo2ia1Xvx+YzotzJBqdYAbP90yyE89ALFPJvpL/oEnTIr0z5TYlSuqiZ3AjOunO4fxY4tHDgPYSjDeIi2Gxtttw4qG0FTi+nBCxSKhPTGwGLXRxWTf6re5PxvmjU1s9JXocPbjYAOfXA7eH1G0hyCrN7/V4gRWVgfVaEHyK8gp8GOwggfNH+tSNQDSyWdLwRHNYKuIWQu/z/BNFOsV5rSxnfoITcfbQeu/64xnH8uaWQXhoiAFZE/LQLUW1B8iHqa7R84Ymku7qaMMsco75trTucBxNWT2NdtinUvksgGrCaUdRSPpIrg5Y2bnlKZH5KNqmYyPBEJNaarq8TRbrCobavkZN2Z1z/fLxMzX/AmKCjoZbROoqFj8CQo7ujyUqIE71V+f2RQNQ1R7nS4im0VHaDqmi2vmEILWUTuY4Axki5hhx3KNWbbsf4csPLVHWrMlWAvsMpWwQpOgYWq7cJAPE6Dte1j0sQZbgWxsOr0RN8unc3pl04ar7y63jm5qhb3gAaAyiFpcCnrmO3t0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ay8++WCFdcRljPsMfPvnH31q/4PzfU/xM8PgQLAH7u+tDootjx9tckAQ3HDB/NLJNLmeAKX7j51JpiXQHRabKxjdFGQglDRhIg7epjbLT5b+zQJMP4ElsUjZRhzEBgtYU70PcPCZ6stxfCyI7+LWvVDvivgsrVT+jXLXevFDGuwCScbr64Z0FozNlZ6hdeji/3QAuW6KzxGEiJHuLJkH0XjfsOcIGIBasb0VCQ/PC/yLvstXr/FwEqq+BE5xpBYqbpm7YZMGE6jRXNpbb5sGO7043NhQpn8hpqNAnYPuThPXmIBGg7CmdbjwXNM5xn4sDDupWNXB47cRzzQJ/dATD9Gymuoug0J4BAjYRdu32QwqzD9+fOM8bXC0zLWiheZJ02pIOts9nsnR2SlP9NWU/FPg6U74qetc6/2zc1wnZ1XijNIPieR4gQGYZC8ZaBwcVAToepV6E//w6dEOAJMt8hTbX2ioC93S/sj3DUgQNAZwCxSpfe+3DscT+6WDSvPxV7ShpiZJh8Y7diKftR05w0fZEtsoJ98fAvK9W+h0FsBpzvdh4/ZbNOs3CrNikNCWli1kofb4a8r/RaI3lnoNsMGtBnRprwwntqN2lPB5vf1KiLPHoKIRyj86RYu4zZK9ZqEsPT3OrYrluOWiouT6P4lrN38DTI8PF6mRwR38CHS01JBmRC7P4SVDW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d1b0e44-8fb5-4f9d-0e5e-08db0d7791f6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:40.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: 8/jG31BZtsLJ34DZ5uUa/3go/XM8naz24DgG9FVVT7KLAU+Sa3xs8BJasmDmWqvEMQFn0+hLOUCMr1zAPFDdsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: 8a_9UnjY0gHYfPTUmq-RxDa68zBFUb5Q X-Proofpoint-ORIG-GUID: 8a_9UnjY0gHYfPTUmq-RxDa68zBFUb5Q Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit d367a868e46b025a8ced8e00ef2b3a3c2f3bf732 upstream. This avoids a per-item indirect call, and also simplifies the interface a bit. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 5 +---- fs/xfs/libxfs/xfs_defer.h | 3 +-- fs/xfs/xfs_bmap_item.c | 9 ++++++--- fs/xfs/xfs_extfree_item.c | 7 ++++--- fs/xfs/xfs_refcount_item.c | 6 ++++-- fs/xfs/xfs_rmap_item.c | 6 ++++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 081380daa4b3..f5a3c5262933 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -186,11 +186,8 @@ xfs_defer_create_intent( { const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; - if (sort) - list_sort(tp->t_mountp, &dfp->dfp_work, ops->diff_items); - dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, - dfp->dfp_count); + dfp->dfp_count, sort); } /* diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index d6a4577c25b0..660f5c3821d6 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -49,9 +49,8 @@ struct xfs_defer_op_type { void **); void (*finish_cleanup)(struct xfs_trans *, void *, int); void (*cancel_item)(struct list_head *); - int (*diff_items)(void *, struct list_head *, struct list_head *); void *(*create_intent)(struct xfs_trans *tp, struct list_head *items, - unsigned int count); + unsigned int count, bool sort); unsigned int max_items; }; diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index b6f9aa73f000..f1d1fee01198 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -334,14 +334,18 @@ STATIC void * xfs_bmap_update_create_intent( struct xfs_trans *tp, struct list_head *items, - unsigned int count) + unsigned int count, + bool sort) { - struct xfs_bui_log_item *buip = xfs_bui_init(tp->t_mountp); + struct xfs_mount *mp = tp->t_mountp; + struct xfs_bui_log_item *buip = xfs_bui_init(mp); struct xfs_bmap_intent *bmap; ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS); xfs_trans_add_item(tp, &buip->bui_item); + if (sort) + list_sort(mp, items, xfs_bmap_update_diff_items); list_for_each_entry(bmap, items, bi_list) xfs_bmap_update_log_item(tp, buip, bmap); return buip; @@ -408,7 +412,6 @@ xfs_bmap_update_cancel_item( const struct xfs_defer_op_type xfs_bmap_update_defer_type = { .max_items = XFS_BUI_MAX_FAST_EXTENTS, - .diff_items = xfs_bmap_update_diff_items, .create_intent = xfs_bmap_update_create_intent, .abort_intent = xfs_bmap_update_abort_intent, .create_done = xfs_bmap_update_create_done, diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 45bc0a88d942..6667344eda9d 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -441,7 +441,8 @@ STATIC void * xfs_extent_free_create_intent( struct xfs_trans *tp, struct list_head *items, - unsigned int count) + unsigned int count, + bool sort) { struct xfs_mount *mp = tp->t_mountp; struct xfs_efi_log_item *efip = xfs_efi_init(mp, count); @@ -450,6 +451,8 @@ xfs_extent_free_create_intent( ASSERT(count > 0); xfs_trans_add_item(tp, &efip->efi_item); + if (sort) + list_sort(mp, items, xfs_extent_free_diff_items); list_for_each_entry(free, items, xefi_list) xfs_extent_free_log_item(tp, efip, free); return efip; @@ -506,7 +509,6 @@ xfs_extent_free_cancel_item( const struct xfs_defer_op_type xfs_extent_free_defer_type = { .max_items = XFS_EFI_MAX_FAST_EXTENTS, - .diff_items = xfs_extent_free_diff_items, .create_intent = xfs_extent_free_create_intent, .abort_intent = xfs_extent_free_abort_intent, .create_done = xfs_extent_free_create_done, @@ -571,7 +573,6 @@ xfs_agfl_free_finish_item( /* sub-type with special handling for AGFL deferred frees */ const struct xfs_defer_op_type xfs_agfl_free_defer_type = { .max_items = XFS_EFI_MAX_FAST_EXTENTS, - .diff_items = xfs_extent_free_diff_items, .create_intent = xfs_extent_free_create_intent, .abort_intent = xfs_extent_free_abort_intent, .create_done = xfs_extent_free_create_done, diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 254cbb808035..2941b9379843 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -333,7 +333,8 @@ STATIC void * xfs_refcount_update_create_intent( struct xfs_trans *tp, struct list_head *items, - unsigned int count) + unsigned int count, + bool sort) { struct xfs_mount *mp = tp->t_mountp; struct xfs_cui_log_item *cuip = xfs_cui_init(mp, count); @@ -342,6 +343,8 @@ xfs_refcount_update_create_intent( ASSERT(count > 0); xfs_trans_add_item(tp, &cuip->cui_item); + if (sort) + list_sort(mp, items, xfs_refcount_update_diff_items); list_for_each_entry(refc, items, ri_list) xfs_refcount_update_log_item(tp, cuip, refc); return cuip; @@ -422,7 +425,6 @@ xfs_refcount_update_cancel_item( const struct xfs_defer_op_type xfs_refcount_update_defer_type = { .max_items = XFS_CUI_MAX_FAST_EXTENTS, - .diff_items = xfs_refcount_update_diff_items, .create_intent = xfs_refcount_update_create_intent, .abort_intent = xfs_refcount_update_abort_intent, .create_done = xfs_refcount_update_create_done, diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index adcfbe171d11..2867bb6d17be 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -385,7 +385,8 @@ STATIC void * xfs_rmap_update_create_intent( struct xfs_trans *tp, struct list_head *items, - unsigned int count) + unsigned int count, + bool sort) { struct xfs_mount *mp = tp->t_mountp; struct xfs_rui_log_item *ruip = xfs_rui_init(mp, count); @@ -394,6 +395,8 @@ xfs_rmap_update_create_intent( ASSERT(count > 0); xfs_trans_add_item(tp, &ruip->rui_item); + if (sort) + list_sort(mp, items, xfs_rmap_update_diff_items); list_for_each_entry(rmap, items, ri_list) xfs_rmap_update_log_item(tp, ruip, rmap); return ruip; @@ -466,7 +469,6 @@ xfs_rmap_update_cancel_item( const struct xfs_defer_op_type xfs_rmap_update_defer_type = { .max_items = XFS_RUI_MAX_FAST_EXTENTS, - .diff_items = xfs_rmap_update_diff_items, .create_intent = xfs_rmap_update_create_intent, .abort_intent = xfs_rmap_update_abort_intent, .create_done = xfs_rmap_update_create_done, From patchwork Mon Feb 13 04:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C125C636D7 for ; Mon, 13 Feb 2023 04:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229676AbjBMEF5 (ORCPT ); Sun, 12 Feb 2023 23:05:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjBMEF4 (ORCPT ); Sun, 12 Feb 2023 23:05:56 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 286DFEC59 for ; Sun, 12 Feb 2023 20:05:55 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iDvX009542; Mon, 13 Feb 2023 04:05:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=TM+8mDqTJxnVOiWeER1ckheUMBC4W5kb+tu41Ake6/8=; b=vBIkTtiJ13tiOA+wIAp+xoNTmg+Bcitb5Urb97AfO8n2K1if9OHt1un6rtRPAdWTH1u8 3h0rkNUjsxgpegCz3F6bQyS32l4OFGPYMCLSRFpJ4gYxTr8Vc+bQx849IRmQCuy3BF3Z BSClFHW6yb3H0XNUIBMTCSo+KgK8ZLh0+/txWnnuvaxYaG7zE+w5HzPV6PnAQrvvXFtU i9LJ/ozzc+wfh8YKh6fGUgFKSKRQlcAw39QUAMO3iqCa+xjdG8kkFkfmoIwDuaqZ51am C0bitJMjRLxdQk7TlpOToHx0arItd0AcPlyKWlNJcw6gpfkQM9UVTixN5JcEAglgFKUX Wg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1xb1wrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:51 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D37K2Z028870; Mon, 13 Feb 2023 04:05:50 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jxh3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMIq0e/m/5X3mmZWn97XnYFv6QbxZ9wkOLR2MsqneR6xVzmDqWvYtEtGB9h0sxUtSZFSY3K7+LiiGwx/MK1275VjpwBsBx3lFZMFzv+V1Tu8+DS6t+I8FzfUi3/bmxnCT99IwFA1qdH1XaP4k2btNW2gz6oxAIX+kmqsVP4FunzabeA2IljsTf+5VWpo1BhDbOvourloRu7Vn2nmMvlnfn+vyT/SlNOPLF6VBFXTh2mowlLqECFEDliq9IMYAX5Wcqgba590F6TRLYxBXhfzzvLQ0BIzUPPRTXhfdfY3s289umrkM4RiZQ+VOfsRa0Hud/ZTHpooQjJsXJbo8tUCHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TM+8mDqTJxnVOiWeER1ckheUMBC4W5kb+tu41Ake6/8=; b=kEQu5Mxk0IjFUdp0c8Ii7WDi8xLViOao8z3MQUtmNaVl3TDO7Dw1nPoud3qJCOR2HTufjPLf/jhAmkEdYTk9zAXqL9k23u4vNFvJJ8gU8HS9i/I/5kGKtdGarcmIlY6StRRShYE844ZVMDjAKKBfU1qQJSHYQz5UTWshtB9SPxpIVVVoRcfHatTYrihxGbimCaOHBTBofPNYOvplSDHLAd5fa3sBiw+4LCd5jF97lhp3qq9CBOsMB0BRwczhy0GBk0fdKps6BeiQoMIngb347jx8+ozMReEJjye6V7j7z7q6y9DygvY2wo0MElV+46n3589ikSAUGOovOD+wua1Bvw== 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=TM+8mDqTJxnVOiWeER1ckheUMBC4W5kb+tu41Ake6/8=; b=Lf1HAg6Rj1pSOwQ3zpDXcPMe5ZXV5g9PvYhDhRkF+sXbIOiy1WXMIu3GC4mZUOOjpLPsgxXy7r9difAcpQH8nXTj5p93WhaDO1xmTh+Tt6GwPOiukNMUVJDGAEuX/HOn361wt4NAhtdRsMoMvu35t5BKA+DiPKdbct91JBCnzTU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:05:48 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:48 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 07/25] xfs: turn dfp_intent into a xfs_log_item Date: Mon, 13 Feb 2023 09:34:27 +0530 Message-Id: <20230213040445.192946-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0006.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::22) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 198844ff-31e7-49d6-65d2-08db0d7796aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YjbZIsUajvm1MkD1kXzJYb73XN5ERdRnYSb++ODIaOuEBuYPq0cF45hAppzMyWs3Hv6lg1Ae3CauV7WEk2bRUqwcdFy2oI+ocrfq2pjetGvf7/zt30ogp47HQS9JSkl6YrimEbLtiET4aVk4h1Tbns9hVnKd43JIExfEDi/wionf4OoO8DvoDctj8uu7FCXUss0+aBVmy3PGUOA9Wje9Fhjpg7SWZMX4Zjh8b05hznQeDuJ4ATUlMoboNRynI68Esrstc8O1KWcel64N7tE2x+oAJglEw8S4Sw9JqDO5V2vbqVv/ZAVDnzCVSFZ2jh+8FBxtG9mZqBv/FPXBulstgErDVYd9S8z83tRfcPMB/DcKQaHV0OUr1ymFdLFZdlsuTv/Us3Ohsrtj8rrwLZfwu/L6EMBg1mKiOiutLfIgqJYgKnmEFgu9Z9XS2DjLNhVQMBZSk+nR5KQEvMrZ5BV4YAxbUl5D0R1PaPYjQ3HtHmUYV34OAV+xpQIVBDGVFMp2jTEf8gZAlO4oaQ3FeVq5aPyKIFGUkqs6DoDdTMK33nkwSgBNxI9zVxDXyqwbCAsS8GYhyo1KvYUnpObusbBOiQgVblnCH65fJAIhUzP0wv17JkZUINUaQArW3a/DC3mflFGoJ3y2WOOU2QOwh/1a/w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /HTaCginnSgCb7qo2uk9+/cJSOOtmX+4Wc5zGlBowdaOlQN4KV5m1gvUVLQ/6fv1mclPObpq0IND4eyFUjmDrI93JoFqhw2U1/E0b+J2NBj8bPBjq0TnJN4gF/yuJgNJnZscL1TvV/1upjuySyoWhFSboduldxYwfT3dn8CIPhNw6/ohfdDt1GTUrhtWQ4L9KhTlwJQTpZUp/M10vtQIJCRn1UJI9XbMw3GsmnB76yO/9CYtbB0GDonGg4bQLA94A/Lyast1YQi8ddHO7ZAsTCuudTWO1DcRIFO17xyD+hrmFKDzKM4DLOHITG6nOi/YgOuQ5cAtqudgIs3NX2cDxYBGP28KyvtaVGVAMPv1ATiK6rZmrE0joNli0rMWlZId2V1Z7BgaYuPh4Aq0STLbwJopMSBFndM294JMn5SnRc+IGZKa/i0yP9+LBle+qlMbyTA0+2+DT/BXRbRZRIp8PQhVAFXcp+PP+izuNWw2/ECVp7cj1x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6T+Vkug8Cqz2G0NMhqd3JPO07AKMtAmyd4rCI0Apw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QXSeWXR1CZu7FEb52AKDuPaA0IYUjYbB9irXlZHSXJ2xKvq8sTsDeW9J7K/zfRjHNP+pea1Yw3PipUjEzFpgs7BcX0Xu9YoImbf234dJC40lc5bqJtxeH9Rz5/cOb1ta0/6OWDVYF5G2f+KuRY+XHGnvIJ4hyanIo7q116MKyhfwLlcLLbXFFaAr8vfCECIHWSUoE17FL2J4QhOczewpqVqPdB+lf3426PvRTNGHwfNrdv6yMx4OSjA2RpaJwQrPu6+h3bujRP0OyDqVau9tdmUTm1rNuM+AnXgKn1ABnemvCLsIKwXJLZLYk7A4Cai+qPXe70hOjZTOkyNy08dUkgw80LeqGp6+zxnSeUa2VQLSFCQJJrECtOiSVj+q8WqZVbFnM7lm4eGFpUHJNaKLURL8ZAMYMp0yBIBJlrik4xEhxGHGYXb65ff2xg4TKkGkmZsNOMaRJMqfXx4+q8MvktYS0Qj9v0EN7TxMEbqj/aZ6vkMY1Ux1fHTy1z8hNBtZZiGf0xFARUya4a6XH3VUjMf0EdfhV8vWd+0sxcsBRkhbrueK6e453K0ITr766nAIaFTPpbc5w+8E+q8asS3Ruy5g8Hxi0Wg+PGlnKdROW7MhR3mqGHUliKilMXGAIzj1IsddZgBc96bT0YBpSsl6PBmQEtInnCYK07mwCJQgMjTQdoPLAKqhXuefwqHJx5etkGXCLDaGJb+R186K1DyeiZTgtWYGL64Cm7XdxbF5oFY6oXTwbr/rl+nj7h1DBztVBsLIOLh7uFjmFjptABFLBTCJmcdUPdU/F9QtKuXk8LQTSE/4Ytp0QJdurhvqwUFH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 198844ff-31e7-49d6-65d2-08db0d7796aa X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:48.6024 (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: t/W6sGnKVShh5tNpFmM6j3tjjnHOUvqyZ/STjEudCOfLilbtxg/vuSJMZ2zH6suPMBqCTrY2FpAcd+4GOPIkAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-ORIG-GUID: VU0dDex3RkFcmT1uokS4-exdWvk9GQqC X-Proofpoint-GUID: VU0dDex3RkFcmT1uokS4-exdWvk9GQqC Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit 13a8333339072b8654c1d2c75550ee9f41ee15de upstream. All defer op instance place their own extension of the log item into the dfp_intent field. Replace that with a xfs_log_item to improve type safety and make the code easier to follow. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.h | 11 ++++++----- fs/xfs/xfs_bmap_item.c | 12 ++++++------ fs/xfs/xfs_extfree_item.c | 12 ++++++------ fs/xfs/xfs_refcount_item.c | 12 ++++++------ fs/xfs/xfs_rmap_item.c | 12 ++++++------ 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 660f5c3821d6..7b6cc3808a91 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -28,7 +28,7 @@ enum xfs_defer_ops_type { struct xfs_defer_pending { struct list_head dfp_list; /* pending items */ struct list_head dfp_work; /* work items */ - void *dfp_intent; /* log intent item */ + struct xfs_log_item *dfp_intent; /* log intent item */ void *dfp_done; /* log done item */ unsigned int dfp_count; /* # extent items */ enum xfs_defer_ops_type dfp_type; @@ -43,14 +43,15 @@ void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp); /* Description of a deferred type. */ struct xfs_defer_op_type { - void (*abort_intent)(void *); - void *(*create_done)(struct xfs_trans *, void *, unsigned int); + struct xfs_log_item *(*create_intent)(struct xfs_trans *tp, + struct list_head *items, unsigned int count, bool sort); + void (*abort_intent)(struct xfs_log_item *intent); + void *(*create_done)(struct xfs_trans *tp, struct xfs_log_item *intent, + unsigned int count); int (*finish_item)(struct xfs_trans *, struct list_head *, void *, void **); void (*finish_cleanup)(struct xfs_trans *, void *, int); void (*cancel_item)(struct list_head *); - void *(*create_intent)(struct xfs_trans *tp, struct list_head *items, - unsigned int count, bool sort); unsigned int max_items; }; diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index f1d1fee01198..f4d5c5d661ea 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -330,7 +330,7 @@ xfs_bmap_update_log_item( bmap->bi_bmap.br_state); } -STATIC void * +static struct xfs_log_item * xfs_bmap_update_create_intent( struct xfs_trans *tp, struct list_head *items, @@ -348,17 +348,17 @@ xfs_bmap_update_create_intent( list_sort(mp, items, xfs_bmap_update_diff_items); list_for_each_entry(bmap, items, bi_list) xfs_bmap_update_log_item(tp, buip, bmap); - return buip; + return &buip->bui_item; } /* Get an BUD so we can process all the deferred rmap updates. */ STATIC void * xfs_bmap_update_create_done( struct xfs_trans *tp, - void *intent, + struct xfs_log_item *intent, unsigned int count) { - return xfs_trans_get_bud(tp, intent); + return xfs_trans_get_bud(tp, BUI_ITEM(intent)); } /* Process a deferred rmap update. */ @@ -394,9 +394,9 @@ xfs_bmap_update_finish_item( /* Abort all pending BUIs. */ STATIC void xfs_bmap_update_abort_intent( - void *intent) + struct xfs_log_item *intent) { - xfs_bui_release(intent); + xfs_bui_release(BUI_ITEM(intent)); } /* Cancel a deferred rmap update. */ diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 6667344eda9d..a9316fdb3bb4 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -437,7 +437,7 @@ xfs_extent_free_log_item( extp->ext_len = free->xefi_blockcount; } -STATIC void * +static struct xfs_log_item * xfs_extent_free_create_intent( struct xfs_trans *tp, struct list_head *items, @@ -455,17 +455,17 @@ xfs_extent_free_create_intent( list_sort(mp, items, xfs_extent_free_diff_items); list_for_each_entry(free, items, xefi_list) xfs_extent_free_log_item(tp, efip, free); - return efip; + return &efip->efi_item; } /* Get an EFD so we can process all the free extents. */ STATIC void * xfs_extent_free_create_done( struct xfs_trans *tp, - void *intent, + struct xfs_log_item *intent, unsigned int count) { - return xfs_trans_get_efd(tp, intent, count); + return xfs_trans_get_efd(tp, EFI_ITEM(intent), count); } /* Process a free extent. */ @@ -491,9 +491,9 @@ xfs_extent_free_finish_item( /* Abort all pending EFIs. */ STATIC void xfs_extent_free_abort_intent( - void *intent) + struct xfs_log_item *intent) { - xfs_efi_release(intent); + xfs_efi_release(EFI_ITEM(intent)); } /* Cancel a free extent. */ diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 2941b9379843..a8d6864d58e6 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -329,7 +329,7 @@ xfs_refcount_update_log_item( xfs_trans_set_refcount_flags(ext, refc->ri_type); } -STATIC void * +static struct xfs_log_item * xfs_refcount_update_create_intent( struct xfs_trans *tp, struct list_head *items, @@ -347,17 +347,17 @@ xfs_refcount_update_create_intent( list_sort(mp, items, xfs_refcount_update_diff_items); list_for_each_entry(refc, items, ri_list) xfs_refcount_update_log_item(tp, cuip, refc); - return cuip; + return &cuip->cui_item; } /* Get an CUD so we can process all the deferred refcount updates. */ STATIC void * xfs_refcount_update_create_done( struct xfs_trans *tp, - void *intent, + struct xfs_log_item *intent, unsigned int count) { - return xfs_trans_get_cud(tp, intent); + return xfs_trans_get_cud(tp, CUI_ITEM(intent)); } /* Process a deferred refcount update. */ @@ -407,9 +407,9 @@ xfs_refcount_update_finish_cleanup( /* Abort all pending CUIs. */ STATIC void xfs_refcount_update_abort_intent( - void *intent) + struct xfs_log_item *intent) { - xfs_cui_release(intent); + xfs_cui_release(CUI_ITEM(intent)); } /* Cancel a deferred refcount update. */ diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 2867bb6d17be..70d58557d779 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -381,7 +381,7 @@ xfs_rmap_update_log_item( rmap->ri_bmap.br_state); } -STATIC void * +static struct xfs_log_item * xfs_rmap_update_create_intent( struct xfs_trans *tp, struct list_head *items, @@ -399,17 +399,17 @@ xfs_rmap_update_create_intent( list_sort(mp, items, xfs_rmap_update_diff_items); list_for_each_entry(rmap, items, ri_list) xfs_rmap_update_log_item(tp, ruip, rmap); - return ruip; + return &ruip->rui_item; } /* Get an RUD so we can process all the deferred rmap updates. */ STATIC void * xfs_rmap_update_create_done( struct xfs_trans *tp, - void *intent, + struct xfs_log_item *intent, unsigned int count) { - return xfs_trans_get_rud(tp, intent); + return xfs_trans_get_rud(tp, RUI_ITEM(intent)); } /* Process a deferred rmap update. */ @@ -451,9 +451,9 @@ xfs_rmap_update_finish_cleanup( /* Abort all pending RUIs. */ STATIC void xfs_rmap_update_abort_intent( - void *intent) + struct xfs_log_item *intent) { - xfs_rui_release(intent); + xfs_rui_release(RUI_ITEM(intent)); } /* Cancel a deferred rmap update. */ From patchwork Mon Feb 13 04:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C4ECC636D7 for ; Mon, 13 Feb 2023 04:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjBMEGJ (ORCPT ); Sun, 12 Feb 2023 23:06:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjBMEGI (ORCPT ); Sun, 12 Feb 2023 23:06:08 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A08AEC58 for ; Sun, 12 Feb 2023 20:06:07 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1hv18013414; Mon, 13 Feb 2023 04:06:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=FR6tF5TtJM3v+akPzWFacrvBj7M6PZ4HqEdSoRgPAxQ=; b=QliQshga9MBnJcyaM5JVUV4YSho36xzi05pkthD3fTjpPnDu6QPADYeD3hGQQUaSkzhY g0Zmc+9psBf3l/u/+jiYout3ESxRd6EI1wcKTDlCncAx2AaeSbs75AXpf/gTHODBBjqD ibXapm7zk+Mc3yEJI7Hoj2xHOyt+bCIYm6pp+G70bAbJvUucM1W0EwdhwC5M3xjA4fCh +rS8GiVfe4XuozhgQO8B3o3lDgzNJTniN8XRrlHPfVL0c5+x9YaY+pZzhhtBDxtQ3lFw aDITn72YIeM+XYN8YL+sAZHZdyMRGxnCwrqU4hedJTLCIrjCDgMXP9wQmn1TJXsgx+eP Uw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np32c9ucq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:00 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D2iUUr028784; Mon, 13 Feb 2023 04:05:59 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3a9gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:05:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BNd0WzBba/eb5NQgPjSFUm2Y+WEHvYMHZDHExxuSAgeP04nLfVJ9uNjXYqNqoWEnTysnJdDiHrclLtE4sWkAAmbpr7XM7oSdWOUxqOTPI0BiR+f1H5Nu/LvpyPmaHUJU5zyh8tV+WSc0rNRaaZ1iecIyvqMA0Uu7GLte+k/I0O1J2ZXgdO4oaBfL58f8ZFNwwx0mZxtCnrrw08R4/i26DkW0vXu9ELl7g3s6U3/JeF7lD+zR6Y6xlAmxzz279DNG94KAMGj0gbO/DjB0TSzgKhWzHVq4OpDbUXxr7i2tfkR2KAQz8lp97ntnq+gFCWskrwHHVPHDI4VYHMyTBR7W3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FR6tF5TtJM3v+akPzWFacrvBj7M6PZ4HqEdSoRgPAxQ=; b=Fr8q68veaQhveMTEk3bkLxIRhV+F5HEJdZ6sTHtYeM7W6ONepb7ifG7X0CFj0+nEmvJ6zpbW70sEfaMgxiDlf9wHt9BVPfsELETqdV1J+sGza20Wbb8s2EB1S5gRrZvUYjdTlemiBjNT3mRMRZm1hmCd9XyLe5OmlbnmbVq2AzdHhkkgC4ORdTEyyXlDx+TBHIhtcbMsRE05QPuDYi7w9uqRWyrfNfzO2g089XksKdDF9kAcH3I9+WqQU1neHwQ6UmXoVhpGyqKnwlFYLAtA4lUOOG+wo630tPAunkwD9xjpg2cPnITddNMH7K9eOUU2zU3ObhApz36VBZ6v8B4l5g== 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=FR6tF5TtJM3v+akPzWFacrvBj7M6PZ4HqEdSoRgPAxQ=; b=Xa5nLl7bgbQEoZUoXugQpE55BZdUsP3GX8PfHDKAOuP3zwyqAqKjm+SZUqIxnWhwiK/T/GKA4T7oFJE7+eL0JT1+emm+vXwqKaSNqUtD5ivpQuWlLu857Ud7AzswwyV1EGG87n0F6ZGpzr5uJzZHNy2fmueCrK4jXdHfUu1x0Ro= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:05:57 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:05:57 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 08/25] xfs: refactor xfs_defer_finish_noroll Date: Mon, 13 Feb 2023 09:34:28 +0530 Message-Id: <20230213040445.192946-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SGXP274CA0024.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::36) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c5d1ff8-ba66-446f-7b36-08db0d779bed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m5yiWkcLJmaDcMS3Chu7PDLCaOncD1KggxQ7C0h4hgLCGh1TdWa3emEWo5h7fkZlscIzt9O3NGR1Xk7eMFRIH8UoZKW1Xj4S8f/d7bSJTtOJnJyAGDE8CZF5OELmm6Fi3L2+A2Zeq+dH+AhiYLQJrGAULsBxeY/+OpZWWB4ZTBay7WyE6PIFaFT9PRGdTNfYq0QFuwuSzDMUVzw0KHRwldEqocbRq65P9tQu84aHH15UAvcK9u6wLx35eYegFaRxc+5gvynN/3+0TBMANj159fq8DGajeS7UZeoxtLuAPyvKG681lTZYzyXN6IO3ZZDCq0/AShtI5KkiRs188XPNS4E+6odLZ/w98RV5AB97ePy6L8Xg1TkQaNtBeFOTnv5wWNAUzp+tl/dG82cvVl419W+QpV8/YeMrdC05jl36RpPfciPSYh3XbpP7aTUN+0jP79cJyN5LuqMIY3FEBH24cMB3te44S/F2jOWNyBber+/kBodi6FwZsHQwrgQ6kE8i2T4TBHTep1O0Vld4VBI5Rwt6JNhZRR3phJ9AccgjNzP7ByFpj16+9S7TtEX4qm8VsZbufl30J+8b2KCjwZ8n/drazPCkWCV8Z1fRqLo0DSf7mTahlwvkJYqlNJjpLFYRn2c7eiNLkMRcS1IYV7omCA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ntec+VT12FfwBxfbLc7vHSHuJn0pXFdjxpdciE4e3eSeO3xpRAdT8ybSZt7B2yLWZU3ZeMij/Vjpce1t8jto7uSenx0SNYbhf+v1qAFGJ9Y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zYv+ZnXM0UxkJtAseACFlpmjYY7VGV+uw4LnB6vxZpZ644ht3mjcKSprBW6AWxIctg02qJD3HE1Izjg5KYICcDkxQ+YbMXVPPDUFnRofZN9dtS7lS+7Q/EaF4tJu0rtT1k3Uz9EpRXvQH9NcnV4iQFI+sBGJbwromeHq1yAUFJFaUa+/Y8HyagDxE8bKY8R2uaY0YsH8ogRveKu7UNX/vdBnhV70eE4nY4wsAXvO7e0hd3EOmN0T4IvSifoz6GtWzaXEI X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c5d1ff8-ba66-446f-7b36-08db0d779bed X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:05:57.2295 (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: bgl9E5AtFWcat1ghw3ZoTp+ytzK2SyUab8FZrT3xeJwQg33P4wFK2tXgxY8HH1CIjOecIYaO/3scrH6T5ftwOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: NxtXVCJu2VfxkacfsVDJoA6MHSovjxKY X-Proofpoint-ORIG-GUID: NxtXVCJu2VfxkacfsVDJoA6MHSovjxKY Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit bb47d79750f1a68a75d4c7defc2da934ba31de14 upstream. Split out a helper that operates on a single xfs_defer_pending structure to untangle the code. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 128 ++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index f5a3c5262933..ad7ed5f39d04 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -359,6 +359,53 @@ xfs_defer_cancel_list( } } +/* + * Log an intent-done item for the first pending intent, and finish the work + * items. + */ +static int +xfs_defer_finish_one( + struct xfs_trans *tp, + struct xfs_defer_pending *dfp) +{ + const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; + void *state = NULL; + struct list_head *li, *n; + int error; + + trace_xfs_defer_pending_finish(tp->t_mountp, dfp); + + dfp->dfp_done = ops->create_done(tp, dfp->dfp_intent, dfp->dfp_count); + list_for_each_safe(li, n, &dfp->dfp_work) { + list_del(li); + dfp->dfp_count--; + error = ops->finish_item(tp, li, dfp->dfp_done, &state); + if (error == -EAGAIN) { + /* + * Caller wants a fresh transaction; put the work item + * back on the list and log a new log intent item to + * replace the old one. See "Requesting a Fresh + * Transaction while Finishing Deferred Work" above. + */ + list_add(li, &dfp->dfp_work); + dfp->dfp_count++; + dfp->dfp_done = NULL; + xfs_defer_create_intent(tp, dfp, false); + } + + if (error) + goto out; + } + + /* Done with the dfp, free it. */ + list_del(&dfp->dfp_list); + kmem_free(dfp); +out: + if (ops->finish_cleanup) + ops->finish_cleanup(tp, state, error); + return error; +} + /* * Finish all the pending work. This involves logging intent items for * any work items that wandered in since the last transaction roll (if @@ -372,11 +419,7 @@ xfs_defer_finish_noroll( struct xfs_trans **tp) { struct xfs_defer_pending *dfp; - struct list_head *li; - struct list_head *n; - void *state; int error = 0; - const struct xfs_defer_op_type *ops; LIST_HEAD(dop_pending); ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -385,83 +428,30 @@ xfs_defer_finish_noroll( /* Until we run out of pending work to finish... */ while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) { - /* log intents and pull in intake items */ xfs_defer_create_intents(*tp); list_splice_tail_init(&(*tp)->t_dfops, &dop_pending); - /* - * Roll the transaction. - */ error = xfs_defer_trans_roll(tp); if (error) - goto out; + goto out_shutdown; - /* Log an intent-done item for the first pending item. */ dfp = list_first_entry(&dop_pending, struct xfs_defer_pending, dfp_list); - ops = defer_op_types[dfp->dfp_type]; - trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp); - dfp->dfp_done = ops->create_done(*tp, dfp->dfp_intent, - dfp->dfp_count); - - /* Finish the work items. */ - state = NULL; - list_for_each_safe(li, n, &dfp->dfp_work) { - list_del(li); - dfp->dfp_count--; - error = ops->finish_item(*tp, li, dfp->dfp_done, - &state); - if (error == -EAGAIN) { - /* - * Caller wants a fresh transaction; - * put the work item back on the list - * and jump out. - */ - list_add(li, &dfp->dfp_work); - dfp->dfp_count++; - break; - } else if (error) { - /* - * Clean up after ourselves and jump out. - * xfs_defer_cancel will take care of freeing - * all these lists and stuff. - */ - if (ops->finish_cleanup) - ops->finish_cleanup(*tp, state, error); - goto out; - } - } - if (error == -EAGAIN) { - /* - * Caller wants a fresh transaction, so log a new log - * intent item to replace the old one and roll the - * transaction. See "Requesting a Fresh Transaction - * while Finishing Deferred Work" above. - */ - dfp->dfp_done = NULL; - xfs_defer_create_intent(*tp, dfp, false); - } else { - /* Done with the dfp, free it. */ - list_del(&dfp->dfp_list); - kmem_free(dfp); - } - - if (ops->finish_cleanup) - ops->finish_cleanup(*tp, state, error); - } - -out: - if (error) { - xfs_defer_trans_abort(*tp, &dop_pending); - xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE); - trace_xfs_defer_finish_error(*tp, error); - xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending); - xfs_defer_cancel(*tp); - return error; + error = xfs_defer_finish_one(*tp, dfp); + if (error && error != -EAGAIN) + goto out_shutdown; } trace_xfs_defer_finish_done(*tp, _RET_IP_); return 0; + +out_shutdown: + xfs_defer_trans_abort(*tp, &dop_pending); + xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE); + trace_xfs_defer_finish_error(*tp, error); + xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending); + xfs_defer_cancel(*tp); + return error; } int From patchwork Mon Feb 13 04:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27ADFC636D7 for ; Mon, 13 Feb 2023 04:06:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjBMEGN (ORCPT ); Sun, 12 Feb 2023 23:06:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjBMEGM (ORCPT ); Sun, 12 Feb 2023 23:06:12 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 739E7EC61 for ; Sun, 12 Feb 2023 20:06:10 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1icYL019814; Mon, 13 Feb 2023 04:06:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=rxXruwHuzANIGORStyi3SU9LC+iCWUB7RmN7vVCLR6Q=; b=EznuZ7jbVMaRdny69aZjJrWqOuzYwwAfWphK2u+QmiOxT71zy7FGzjHN35pTx9OUzTKf 2+y/gj+aPjfrNpIo5PtBzFkKZLrZXe9hOBWHTjJuJubyfDtc611OLytST8ifJB5jFdF0 GR9TgWE2f+M9fqDahwXbkO32LPMeeEtVVpe2FxNhLdpQEDpeFqor8OUUHS/ukTss84eA bvV7Sf1t6C4FdJvAQ2n8TfP726tRbpXsenSo0lhMhA1h6mu5kkPlySl9K+INe4s6x8Lx ruA/4Alikj/mcK/CIUh4ChtlreaxYAD48TjyNvjRDIg7QmwGTJtIY4dLLDDdihv/4X6b cw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:07 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3IKaB028861; Mon, 13 Feb 2023 04:06:06 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3a9jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4FBP0l8E4YNN0IYGzb86/sS0RKtIAEQHQZnzuBZ0tnWiUNs4PAyVruJA8UE/WuhzHr3VR3suNJEDRgT8NTgqmxHhnf+qeGlpxc8r+Q+cY2fdgG0FOWQUXDeXgZpM1xz+tVtaf0TDQkUg1jbaCMaorVnMyjTy/WbSN9uPIqATjPHnanxzY4enIGKJj2bOJkzWppglc9G2qOFsXx4GfKS26T9/Mz0IL/+8rz3bNyyBMfllKTOpufZHs6LBjqJVVeYTOTC/GNf04rAOsdcQEsEkfZBPGJXU4AkWNgam7lvdXG54ma2XMbi74kSqQ5gr/8LayUpmnqgJES3dA8yKvBKZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rxXruwHuzANIGORStyi3SU9LC+iCWUB7RmN7vVCLR6Q=; b=hfZiDLRohrSpRay6SgtR67dYFcT13P+AQ+LCThpay5pC4w40mA3DRTFdEsnA8y7JJnF9QRemkWShSNj41fn99YnGBmC992+FH1KPVSYmWFfPm57qoUClpS5FrSam8dvjsYJgVpw7LT22DUnxb85CpfnNCvqyFGfhupRucmCwZEHHfDxiNhPeWbBwRu1Cl3leQLmNj7H5h4Q/xEDB+GFfeXdJ3mevDpf1UbNFR2AM3VI4YvbLbaynd88qrsxmm4bqdqfwbWpm9S/Bk/964xBQptqOJTegv0Y0kT5pgHomipAnYKC9dKWxnCiBwLzhhZAIIl/A/0XoJtm8vfkOh8gaPA== 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=rxXruwHuzANIGORStyi3SU9LC+iCWUB7RmN7vVCLR6Q=; b=yp4WcM0dhPjafk9RpDrSvw75AUue17HHOUb3z0Vl4Qi3XSlNKXalo7RBLMXfzEuVTXbvhotoqRDHmMnS+hyKKbxItfa5ALjR7KSiu1O2M/oqWkRLdua3M4f0t02TV2buwtukz4XkcrTdC8kh4n+i31WQ78zMHtDpaDpUo76Rl1M= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:04 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:04 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 09/25] xfs: log new intent items created as part of finishing recovered intent items Date: Mon, 13 Feb 2023 09:34:29 +0530 Message-Id: <20230213040445.192946-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0039.apcprd02.prod.outlook.com (2603:1096:4:196::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 658ac214-dfc5-42b3-0972-08db0d77a047 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RNb6moRnP0FTn5sq0FKTLg+3q2jHPJe8On1ZrWJxdf1WO9Ea1rn6/Lpz3JGHzZ2i0e39zU/rv5MJ0sGSf2eTG+np8wZeFnBobKUQBQPqXKl+wiPFAuq8tS0HoWo2jInuDFmmMVp1/vTpP86CmQ1oJze1WYp6lfIOFW2WefAbq3hKXLsDi8qDDXlPUPTzaQ341aptsQRLqAn/4GaceeKFCUozTqrhBV+OS7JefRkE/gfkK9/il2j+JVFBowBHUZ62nNjrMpLGecGN2HODOt9EEGcRilW8naHJbvujkFMdxdDgr4PjRu6g3fgn4gnXZdOjLYra+OVWlPHzm5elD6pispsw16nscWDCBUZHojGMwSkswgSi/np8rC36gkCYgYmzOrOyby5MkfGp1YUozdh6SBHt6+tODynBBjx7UItfIvA+MV2I9n2fOdRHxIP8prxkW55gKoK1LhT7uRWgJbkBPrRyzui1Hczt8nIpoCzDdDu3MXm9i/0+jBF2EXqdtW8yeb2SmFX4t75C8rYgpuHo/ZY1B6WJSkQx48m+pWa5SesTEA3HhHOoKJS0Dn7g/XvbikNeNHVP3cIJwzXmCaUwmA24xKRPtcnUJtm/gsEaUOeWvx5lZoWTGB/1YQwJFaIjLOjpHVAHVeqJ914byyaBxg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(66899018)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CwRIGky1mOq93AmvJeGM3y6DDmLdu1HhItkwO+y2vMMqJ+FId8vnbeJ3H+b5eeYAPHT0yTuXX/G7Pol6akirZb4EmBilp9OJXSc68b7uqo0FN7h6GJy5qptdTQxQKhdv36NlUGLZvvgFWggA2cWDhyGZ2NdzAABdwv8kC8slN89HaMt+GdHZa6EBgt6f6++vfOm5zVcRVet6aD6ZnTD8VFL8aG82jI2l8EX+aShGSAc8M10YhemmboyRBTqdtrhudJ/K2IXeO6wSjD1qnGiecW7Of6kLqF0pf1PSkFC8tHx+CZdorbm2Zi2/vEh0qLgT2hUZPvghCxPb3cyZZI4UdTtBvbYXYI5tbn29daiaiKWcWjW3n7uhNH8Q6WgrI3wOpR5Fz0+fAHLIMggO5u0KTPZK+7812yTFHzYDOO9i/Ymkq8RaOdQYOWV+y2N+bdr6zFZhT4oCr9n734QqRgLoxZnMfjftG6GtVZXaRFuQZSWkbj8AHf3PBW3lIkBAYw2uKbAeoDcdi3a0SKeXt1sD1V8PWR6JIAVgz+y3pVbunSjJ8OLZU9Lo6L+nZWvj5CimNUTjGqbV65+noOz5MPYROBXbzqRcY4t5Op+ln1/8euFLmjA8laZ238ManETAirmClQ8XEli9b2ibE1XlxjDjVbu/EBmDqX8hnPNkIqqeUdwKD2KLOd+Fhwux3UkHlhAamc5+BKBMTjMwU/LEySwnztB0CSLVVIouVepUwGtNiPOvgV2mCOEStKTUqqA46DIHvdmK9Fn0b8dVznhEI40+6/B9M8AjqAAvURe2KuCTY9H+2PRZP4l99SO+WPMvEKzRA0VDLL6vDU0qkcvQOEjTOqXFuHbXwYq4bfFaZwSgqE/J933vOIWQ7X3tZLJgAy0IfSxynlXxKbIlQvXhbHztz5E9uJcsEvr/RETkqY381XeaTANenM/O7Yb0/x2eN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5kAQMPEolfX0/NPJqN2DuuEq5A8KLEpY83j1KNtf2RbM19SNzaLgjytAzdc8WaDJFpn6AZPfwaRVQEae25LJxujNkMPU5lWUi4HuQ8tuWu+Z7wt9QNBUkr+k/i/lq+m0y2qGS2bRUabZfQwHiXdpc1zP29VcV6IClvaygJTFpm5gxGU1qhP29a1/25cXVr23Hi59UVO3HPn4p9Uk1ZKcmozHxkkOyXJr3vdECA6uPKr/JwlPN0KLIo3CL1Ntlh+O+rtGX+rUKfnaylH3NDeJ5NrVBBqyLKi78qRvzq6De6l+i5txP151JzyUYHFe+i9fHB+2Mrf4dEuMz+5NmX6TvEiP2D6/QNtAmTysCG54YBNON3r5WLpXqZUFvAERxCKkHaEJ9czTdgXRedcF1xTsToUe1cuvtrYbXRAjW0YVWCq9hnsnHU1yQ30LjA8TLyYHDNxKeotDO6yelaF8K5klY+IPrIiB8Vn6p2zg8Qoab1uyv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 658ac214-dfc5-42b3-0972-08db0d77a047 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:04.5273 (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: QUbDNBhoiPMJMNktMwvedg1/JWzOyKCcsk0dBbNg1oAS4eURJ848tdArAHtE/TZ+EHnmzoKppJ+y9oJvv71LUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: Tt99OGdwYz6ci5A-Is6ZCgOprr9Q7x68 X-Proofpoint-ORIG-GUID: Tt99OGdwYz6ci5A-Is6ZCgOprr9Q7x68 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 93293bcbde93567efaf4e6bcd58cad270e1fcbf5 upstream. [Slightly edit fs/xfs/xfs_bmap_item.c & fs/xfs/xfs_refcount_item.c to resolve merge conflicts] During a code inspection, I found a serious bug in the log intent item recovery code when an intent item cannot complete all the work and decides to requeue itself to get that done. When this happens, the item recovery creates a new incore deferred op representing the remaining work and attaches it to the transaction that it allocated. At the end of _item_recover, it moves the entire chain of deferred ops to the dummy parent_tp that xlog_recover_process_intents passed to it, but fail to log a new intent item for the remaining work before committing the transaction for the single unit of work. xlog_finish_defer_ops logs those new intent items once recovery has finished dealing with the intent items that it recovered, but this isn't sufficient. If the log is forced to disk after a recovered log item decides to requeue itself and the system goes down before we call xlog_finish_defer_ops, the second log recovery will never see the new intent item and therefore has no idea that there was more work to do. It will finish recovery leaving the filesystem in a corrupted state. The same logic applies to /any/ deferred ops added during intent item recovery, not just the one handling the remaining work. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Dave Chinner Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 26 ++++++++++++++++++++++++-- fs/xfs/libxfs/xfs_defer.h | 6 ++++++ fs/xfs/xfs_bmap_item.c | 2 +- fs/xfs/xfs_refcount_item.c | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index ad7ed5f39d04..4991b02f4993 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -186,8 +186,9 @@ xfs_defer_create_intent( { const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type]; - dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, - dfp->dfp_count, sort); + if (!dfp->dfp_intent) + dfp->dfp_intent = ops->create_intent(tp, &dfp->dfp_work, + dfp->dfp_count, sort); } /* @@ -390,6 +391,7 @@ xfs_defer_finish_one( list_add(li, &dfp->dfp_work); dfp->dfp_count++; dfp->dfp_done = NULL; + dfp->dfp_intent = NULL; xfs_defer_create_intent(tp, dfp, false); } @@ -552,3 +554,23 @@ xfs_defer_move( xfs_defer_reset(stp); } + +/* + * Prepare a chain of fresh deferred ops work items to be completed later. Log + * recovery requires the ability to put off until later the actual finishing + * work so that it can process unfinished items recovered from the log in + * correct order. + * + * Create and log intent items for all the work that we're capturing so that we + * can be assured that the items will get replayed if the system goes down + * before log recovery gets a chance to finish the work it put off. Then we + * move the chain from stp to dtp. + */ +void +xfs_defer_capture( + struct xfs_trans *dtp, + struct xfs_trans *stp) +{ + xfs_defer_create_intents(stp); + xfs_defer_move(dtp, stp); +} diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7b6cc3808a91..bc3098044c41 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -61,4 +61,10 @@ extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +/* + * Functions to capture a chain of deferred operations and continue them later. + * This doesn't normally happen except log recovery. + */ +void xfs_defer_capture(struct xfs_trans *dtp, struct xfs_trans *stp); + #endif /* __XFS_DEFER_H__ */ diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index f4d5c5d661ea..8cbee34b5eaa 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -541,7 +541,7 @@ xfs_bui_recover( } set_bit(XFS_BUI_RECOVERED, &buip->bui_flags); - xfs_defer_move(parent_tp, tp); + xfs_defer_capture(parent_tp, tp); error = xfs_trans_commit(tp); xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index a8d6864d58e6..7c674bc7ddf6 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -574,7 +574,7 @@ xfs_cui_recover( xfs_refcount_finish_one_cleanup(tp, rcur, error); set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags); - xfs_defer_move(parent_tp, tp); + xfs_defer_capture(parent_tp, tp); error = xfs_trans_commit(tp); return error; From patchwork Mon Feb 13 04:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137830 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 951E4C636CC for ; Mon, 13 Feb 2023 04:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbjBMEGV (ORCPT ); Sun, 12 Feb 2023 23:06:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjBMEGS (ORCPT ); Sun, 12 Feb 2023 23:06:18 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE858EC59 for ; Sun, 12 Feb 2023 20:06:17 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iQwk028487; Mon, 13 Feb 2023 04:06:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=zybiaFhdstfZVltvLoEsI2kweZwDOLwa+Pw7XrexuyY=; b=g+5uGSaCnnIk22k4Wa6WBm1kW0S5JTS3sWbGWW4tPINe3tBi63nLzWgBOUU2eL0hrqkV m0rLFJaYrkECOSxozhkW2YdvkpN597MGBnjK0C6rOK8G51inX8GZ0MJfnauwcUVHgPEO sOcWfQ+YuEpE8Qorm21q3m2SRsERuFknBmW8eynMkgu9oTu5War7tkJ4lhw3eUNO117e pAnXFS7I7kTA6S1PNL0YlJU8WRt5qnwPlZ45ErMdxt7ZcFqNs0G7m6Vd1Bl8YsIf+0St SCtcav25NxtWrQS8ZDMXRgT3eDfBixdYArCDSJpjC87Ak0ovr+L/KSsQvRfGMoXZ+qcH xQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np3jtsu9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3BBRl017984; Mon, 13 Feb 2023 04:06:13 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f42946-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d9lwaOjo04gF1+1whIbRVaKFmruc/o7Cj9R6S/DDbIrkOscM2VhzflSVCVwXu0u+/3G5iolEviDZDien5KmZpNUZt7c4buajB2XWYFRfUcl9+lF0WysQNiRIjHo1mbcJaFL1LWBtniUoHXx9GT41ZX632KRrtutcixO79ocmVgciuv+4LvDYr3Ft7YFvQ/WzrOXhCXqmIhnFhFZuzObCDLazGcUmshrzpbjjAoW+nBfV7SO/8eghl1/Agk6w9pvI697v7+1WDJtFUw6jDryveUHrwPFXDh/4ts7NHqG6lqAoiwSmKHcBFmbX2GdBdHSyN2Nl9nEijXJUXAfckIQP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zybiaFhdstfZVltvLoEsI2kweZwDOLwa+Pw7XrexuyY=; b=WSr44K+wmW55vcaB5agZjnrUQnnGr2zvuUmUiIXg9qiWrbrw1qcA01XD86xySo0eWG4fVg4YSZXtwv8yYdZKBrmhJliOPK9DZRzshYI2JhgpifPMai06mnkH9TJhrYZ6E6aV74aRwrIwDEvauOEgeZrajn4truhiqZpHNGETVpF/ZHqpuMltbUaCjKkTTYYrAwmg+ftWMNJO3sRVYuj837G9idIPGyCvcU22CfvX794D/+vaIg8smY1yk+Qn7XzKl55RKgOC7e46pN67umoaRiSNM9rDZ8ex9yTNK9bLi7A1Ii5JFL1Dvb3sQ/a/d4eYMGFHfuDwbpaghClfOS8fvA== 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=zybiaFhdstfZVltvLoEsI2kweZwDOLwa+Pw7XrexuyY=; b=Mrztvt+DHUiSG9TV3wJhyqAM9n0/uRXQwT8hSZbC/3c51Oc/4avz4ZsShhXFg6NrA/M6tMEXQG2mC02XH7UJTfX2GQvkQAfkzSzdXlRL+6kRGjozJK51dM5g6NYeo5ePASx3R9cWEuwlE2rQMg7Q6LXpU7xAkuUllWuOMgE+6Jk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:12 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:12 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 10/25] xfs: fix finobt btree block recovery ordering Date: Mon, 13 Feb 2023 09:34:30 +0530 Message-Id: <20230213040445.192946-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR06CA0017.apcprd06.prod.outlook.com (2603:1096:4:186::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: aabb313c-a597-44ff-bed5-08db0d77a4b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Q+B83zvA/hg2Dd0r0WqxfoDIPopdVVi/Ec93O+RJTlPQNKD14mI93rp5UoZaD6yRorZQb3IRmegk3pUCkJp2isKOG+todG/7iic6tbYz6Eb8iSyKfIr/a3n+AkMbZgyFhMxfB7aYfik3JDhXEUBcLkIUvRo+M2Nojx6brY06k2uZsmG12GJZymGX514OUxUXqrs9AEtmeTT4IA7Qo3v8bM1io7Tmu/tKlZ+sU6BwBhsTFKTVAdepr4r15APxcTXSe6NRJSavWJsjYHMFShGS2EUQJiWy1b8anw6vpccXp2mYdPWzSrDywPU30Fyq6yAEEn1Szo0lfvmHAuldmX7Ze2g8dori5hlTU3PMkCF2VoKO9yeWrOdlJ/nn2lC8rSfH0HAkI+al/HsRJCQ/OPfVsIFEhTe5Ih0QnFRLUvAYhLwFAeLhvbXpwFWlC7TTAROJgroCLMMocDPzHjSVATOuytr/VVrTuqOMS04D8uSSSws9zCT+ZzzwmwyZDYvu3+aY5frp8bT2EyCuS83rFZbTfv1RlISE2jkWcMWtixFYq2RAH8s+3Sd4cdofdmx/ADuzYb49G+HYDtmffyApfd3yWtV4yB27Cfh6qzJKIhYRQGiuVwS8g6xqviPjLCoowWLjf1+n51Upj2Y3d4VZlkAqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UhInvgwAg/9fVkpH8qUhRqloaqBxCngpkm0aqc51ke1DfEYplWKGmufbKPcLNKz/vsnCaTJwlLwkHTOgQ/9CM4GA8OxnhO2rEgtHArUAEtjoS3XZfOpkJeXbVD78GE0u21k4WiYDsFaKW1UqiUO2hlh2j5WhGgvJXsep1iOHV+l9+9+4tJp4AF7i8evPrm15fXi2qbflp9xMVlUi1aMy87FnIsqtLaZYEFN88l311wX59cLJUGj7+mS8Dm2ET++A3dsnF6GzY6gTPnMjpROR2W61hz1mwVmguEM13z3EnuNiLiw/nYH13OyZNdvwMok9Xh28TxZ6bVZoXy5CxX/ZKQrZr9fyim0kZHKqIYdBfRF9giPfQysAegiD9SkjWDxSJtZ6oCe0OAYjEYpHgwQsXXt0IWxrNdverEIWPVvLGi8O1zJCE1VTx6CWhPw4RPzhgmR2/HtrDKkWIjsC5Ozs5dOz8GaBK2l2qf0Sf6qoMVKsUWkLGVoPSGxbYbiyl1zL3Xxtv+NMYSbFVLTwRUb1CBqG6FJ+oHPv1+3Hiti0qv32BM2Zy4pg/k2HeGtDAixL1Dt+AO3CU5jVCPt2/3DuIwRNwEJKQrt3tP6T1y3lGph0tCtKfOnyvFh89b7uDxzTQ4CYEGtKzHSug5t1lFDGW/UC8JDqTruoPVEVpnQ4Poc0RVVXFKxMBuQT4/cZOqTmL0jJwPNoILy75WbmjZzNIbbXUlCkI6Kk7WxdGi0SEd+dRpJpvF5EVvEPM9MM9219WvV0iv/eLtqrf5nl3N7sKOwcAswdCvuJJyOHKR83/+AlUt57PTfAllusKZ8fCVU/RIm0zQXlr7N/62D4zJHSRwr1AZ/dxME08Y2CoUt2zS1R71x7VwzR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yO4fxhIFAVKp9AXVmgnftVDPvQaIVukqCUIp87e5VXOsU8YLGZuZDygJI3trCZWfWtyL8FwqhcseCXAaOt222dh0uZqFJtOPOtsa9pzIpAsSt+ecHM0PGK/zhokl9yz9HgOBSzCO1CBdrawG/Mrxcw+jHCQzGTkjmykONfOk9VFvHYDamUHJtaW34SYXs6bV7LiuG87NjtNsixUJqsAEO6bKAjCJm/3zKizXiHfalHVi94QstERZjUUGOZ3Xz7BfjzmwN4yHmUQrtWTK/UmBbmyQ/UUPkAKHJxRwrSFgfsC1tqXotbfT3+WQJnLXvw2z1RGwnJECkfueBFwCCLYz7Q7Bdx15UKEGI6areJkbGRpUG+vbeniabJg81s3T6Jjhylu8EaDeKgW83Yhhpypfe+yQ6CnY03J9cxub4Wvo1Cqe2TmS62fANQFHJfT3M+WOi+Ac/PGttVLXRX16YUHFqOCq5RN8p1SLUIJPfI569CWSGdyuk3b7Sz0Pw1jOxgtWU1mDpFw0c/siskzwGXRP/CQO+bngwnkh+gKlMvzSoCUFVXPioF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aabb313c-a597-44ff-bed5-08db0d77a4b3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:12.1381 (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: cnd0zNOMTlnJEkzBJaEk+RuLxrixGlnhJKbVDMZRfCFvk+llwpeEzp/oiwXPKXJ/ztLFB69Ca6I0KAQ1l9swxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-ORIG-GUID: zRtcPTeVxBYzTZCyphbkmJNVKrbcc4QR X-Proofpoint-GUID: zRtcPTeVxBYzTZCyphbkmJNVKrbcc4QR Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit 671459676ab0e1d371c8d6b184ad1faa05b6941e upstream. [ In 5.4.y, xlog_recover_get_buf_lsn() is defined inside fs/xfs/xfs_log_recover.c ] Nathan popped up on #xfs and pointed out that we fail to handle finobt btree blocks in xlog_recover_get_buf_lsn(). This means they always fall through the entire magic number matching code to "recover immediately". Whilst most of the time this is the correct behaviour, occasionally it will be incorrect and could potentially overwrite more recent metadata because we don't check the LSN in the on disk metadata at all. This bug has been present since the finobt was first introduced, and is a potential cause of the occasional xfs_iget_check_free_state() failures we see that indicate that the inode btree state does not match the on disk inode state. Fixes: aafc3c246529 ("xfs: support the XFS_BTNUM_FINOBT free inode btree type") Reported-by: Nathan Scott Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log_recover.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index cffa9b695de8..0d920c363939 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2206,6 +2206,8 @@ xlog_recover_get_buf_lsn( case XFS_ABTC_MAGIC: case XFS_RMAP_CRC_MAGIC: case XFS_REFC_CRC_MAGIC: + case XFS_FIBT_CRC_MAGIC: + case XFS_FIBT_MAGIC: case XFS_IBT_CRC_MAGIC: case XFS_IBT_MAGIC: { struct xfs_btree_block *btb = blk; From patchwork Mon Feb 13 04:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E64FC636D7 for ; Mon, 13 Feb 2023 04:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjBMEGb (ORCPT ); Sun, 12 Feb 2023 23:06:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjBMEGa (ORCPT ); Sun, 12 Feb 2023 23:06:30 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDDA1EC57 for ; Sun, 12 Feb 2023 20:06:27 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iGSt018536; Mon, 13 Feb 2023 04:06:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=XpPF42QuC/PJzRnZa8d1wUXXsJIzcc1x3E0b9GAGNjc=; b=KWbqaANwNvAHIapuLQe8FIjZwS4qra0hROPS1vQB6EZWH0XnGWeq/XvmuGZ4b4gjccvJ M9VMiM/KmdwOHiUnyibzorJiyCNoBqHBjfXCtORQf272JOqJbFBIMH9Igh3YUOEaKnOj nxYOssrTJab/Mr1ReNq9sSW9u19jY4TD9W+EgXeg+2FaYKIVQ+JW2mfIfWLBC5i390cm I+QNjRLzK5HvKA3nQgwE6CGQyFDnnZwy+vSx7WmF2IvnhHzMkRqqfLODp1h/p4RIwdih 9IJIcsVjnXwBrwY/gXRPXeXAawB083qVsFbiNkwgMN8+lcrjU/oNdMtEIxexrfDvjaxL aw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:24 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D30M95011564; Mon, 13 Feb 2023 04:06:22 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k0ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gLvc3MI5PU0c5aOQgnUDEJz5+GCeDny8qbI7i6P9dS94feWOKQIq7LaX4lEgOCSBE4FB1e++dRWFAMZc17JGBpifDWIIeIg2QCDLBx5LPvf4lJXPnm1V2S3MvgjqRbd+Ljjt5ILZE6eAnopDQXMzUbOT9Estl5uwxtUgYgPzsyruPvWUnvllp+bxilWLErfQWWIunt8vymR1YiUVqjlOotw1ihfxnmR3AT4hCDe/okwbrA+2DVEI7iplw/GWvoshcoKYt0dM0NEY6G2Iw0ZdpTVKR2FrAugjte9LDj5MwD4r3Syv0U2ZQcy7JIPLhL//hEYT9wEuX7zKnInlzPiDVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XpPF42QuC/PJzRnZa8d1wUXXsJIzcc1x3E0b9GAGNjc=; b=CrW9CSJ60wa0CR64gf2d5UdLo/v4PwRekFGUZCav47KCva8HHT5w/81Oyarh/pzmiiDBkXdNDOlhzkiIa+Hz8zK1Vy+rdgRAt93on+Ol30yyGk/V70Wb4Z3wuvACTuIstq3Qq49cz1itJv1zCufL4Pn3VWilnfQ8Wq+i2yP24tCopvt44B6R3iifyrpDJLp/b5pd6ye5FXUQvuDrhsTa5Yq55OKZN4SUHfV3bZ4YTq+x2nP8rbGBr02eVil/3iK9xms3lD0/F4g/aOyBYKVBhdhPz9t4+o7ob1aOzQg/ut5H/PbsHZ9wwk8qID0Gr/SWx16hkbLA2qAbzNiMIR7NGA== 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=XpPF42QuC/PJzRnZa8d1wUXXsJIzcc1x3E0b9GAGNjc=; b=dPf8GoGqKUj2pCjttS9sQjtMbqBS5EFFY0nouBsZPGGeWJ/HXgkwRewFxtHleBQZjroG8jE5tp5xo0Qo7X6WSEF+agzLN5itz+L1TmFjsAT2iB8lOVIAAIGv9gTyrawmZBo8d8xsWjFkEhcbOZ/BfdNCyeiKHqZZcphEGz9xt6Y= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:19 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:19 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 11/25] xfs: proper replay of deferred ops queued during log recovery Date: Mon, 13 Feb 2023 09:34:31 +0530 Message-Id: <20230213040445.192946-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0032.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::23) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: b2349417-0297-4e81-098f-08db0d77a931 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5RYXO4Ze+/s/8xxTbRvjjgrnjX/BBIzjqVMBkkdC8Kp8nPOutnAxbbENvgHYEW18rorEH69F24M8VtqcsjGUVACwvtC3djE8K71bo3L1EkLBmsDNhomubpC/vq46ShwMDRIp7hhjKd2lhI8DF5Dasrbw1GDQmPv/eMHDd6Qs6YtnwizUKhGKy8j5Xcbn207JWgvcoWSek/opg9u2wg+438cSMKMvrpip+WNh0eqPVyGFoaN4SAPLOgGh6xJoXts+ZrTvkO3EV/hj5gEz4ySziEPjLADXjnF35ZZP+grjTY/HOmYVzI20qWGWMaDXIwo+kPUTpbuSyKbeq0hy6z+nO/HI/1Sz4A6Nxk2h/Pht36o9p3AT2lbRO9g7p6xmt5Jpuq7lQU9nP7gvZlVol2xU91BhOUryi6Tanm1NliEjPceqJ8LpSTw6/Jnmor65Dvcsqrgl/8cmM5i73K1f3YDCTsEJ5fKlCD0bSUmQ45BoKgNe+my1l2r5H21hWsnva3H0+QMbzhsDsE7LPZ0FI97tanUcxOHAIvI33iS6527HTWEVkCyG++YN56ndbgHhCQgpuCdgnpwkwRynla/fl/KlMPkqfZlay38E8KJ3Tix/Daq04nTmOpc91QPGv9oukTbmLI8K8ychcd3NZ/ertxlVRg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(30864003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tCy0ItMDWyb68DuqCXlMI4+wxx7nJ6Vllf28jBf73rzvZ7kI5c0gIiyBrjOnZu3bQXKw8ojmaGmlpAL5F6v5uNZwtG/7RSKQYglDLePCIgcg+7UCkH23R+kJ9mnKAOJoyoJgMm3ZZgKflsvsLJW1xwPHGP/PWfLuqQF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V51nsE7I/C6yuZoaL41a9yCHZ0R0Ua9wisL2IIUtkkEVaDhJFhMIVD6bEsy0BeLy9GmGnonxHD+LgUQ77k3XCXljxE6//xMzdt1zaHa6WJ9FvZaYqw+GauAJJyHIZef+Xh2AmVVapa17TVKgAlbKVowdT0TP1kZhSJDz/oAeaghg5e0KlsLbyQrK5wz1ksfTI1NgILBvF208/C9jsUNO4wWNFdR7325W7dLqEZ73KxjmbSObxg9H4LF1dlPY4BI8/z40zQ02+6AjoWcwyumsy8a1CJGkzX6ljPL8mmM3MYAfQnVWCW3YtSrekHRBjo5Y1IKgGc+JW3rBTblpmMJ6CwqcsYtof0wOMX8rjwxmhyfAini6kxXothSrZlal7qz5k1tN+h4h5edCeYkpCrNow== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1j9d6R8nY/RSZSejdSH1bhPFXMTQZXebx+/IeLhEK4u08hSayzavIbxs5f88ipQNESoFWJUPTbl7CKnEqCenVXT2p9zLXLnz/NSuKvHDnOFRO5dDueuUKf8g6YDbUGGU7TiBn/t6szfCuiRWbw1WKeJmSc3agJnjOcU1Wjskd4/TitJRdcVDDG0UBXmDvXQ53XkFGT+Ayq1CG4W8zkVf0YUnHgID7sGhJDmqkHNYuZPIJLcaKwXS9+F23L1+gDcykB29505kj7Q/AwUjQFNSfE9eHXSHl/EILbg48Bvfr55iSSkOHLP7G0y86O873MkE+7AHm499TOP6NWIcotGmEaYljPY869p6M7dK9kzYyR21H8MnMqt4akRR98yovxJRHrPg8B0Ril1B4mMqVCvgiy11A1zxt85hCuk4XRwhxyDR0her4eKUZSp9dAzWoBiFJaUsxv2h22HENguXhwott0GP+iq45EEOJt5jzvnvq104+22DAekGJV+Nkrj3Qg9OSF04FqmyE7g6Ex/Jm+N7+2dnH9nFOS4oSyxmQxPT9+Ovf0YETVcEcIUkTnbjE+AeDSETdGC9tmTbS0pYXhfZkiJP+LUx5BMxak8zLm5WSQxfPTN2U5eRNUfcWWA7bQZF1LejjReKm69VbMmZVEL+tZUIxxkXkA8KQ/PF2VJjb3Rrz2KmR6DP29zfphvUZCZcqeLAsCZsf6PPmf/798rn8e7/ieI5NhrTG13AW/TBwkyCMksZL+FvDE4p2KswjQA1dvvaFHIDByaCWeR8cbAq4vF9Rdrb81aAT6PwUmsr/pHAk7zETStwC0XRpbGz3VIi X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2349417-0297-4e81-098f-08db0d77a931 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:19.6701 (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: cG9ZfsZw1uynqMulABf6dZ+cCy2l5cLTns7KbxbAxloDv2W76NNbsj/pCxcD9Hyjq/pODdwaOZ2gvWxpouIdTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: Ey656evpp1ZMtSnbIhtANi0-koEuHI_3 X-Proofpoint-ORIG-GUID: Ey656evpp1ZMtSnbIhtANi0-koEuHI_3 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit e6fff81e487089e47358a028526a9f63cdbcd503 upstream. When we replay unfinished intent items that have been recovered from the log, it's possible that the replay will cause the creation of more deferred work items. As outlined in commit 509955823cc9c ("xfs: log recovery should replay deferred ops in order"), later work items have an implicit ordering dependency on earlier work items. Therefore, recovery must replay the items (both recovered and created) in the same order that they would have been during normal operation. For log recovery, we enforce this ordering by using an empty transaction to collect deferred ops that get created in the process of recovering a log intent item to prevent them from being committed before the rest of the recovered intent items. After we finish committing all the recovered log items, we allocate a transaction with an enormous block reservation, splice our huge list of created deferred ops into that transaction, and commit it, thereby finishing all those ops. This is /really/ hokey -- it's the one place in XFS where we allow nested transactions; the splicing of the defer ops list is is inelegant and has to be done twice per recovery function; and the broken way we handle inode pointers and block reservations cause subtle use-after-free and allocator problems that will be fixed by this patch and the two patches after it. Therefore, replace the hokey empty transaction with a structure designed to capture each chain of deferred ops that are created as part of recovering a single unfinished log intent. Finally, refactor the loop that replays those chains to do so using one transaction per chain. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 89 ++++++++++++++++++++-- fs/xfs/libxfs/xfs_defer.h | 19 ++++- fs/xfs/xfs_bmap_item.c | 18 ++--- fs/xfs/xfs_bmap_item.h | 3 +- fs/xfs/xfs_extfree_item.c | 9 ++- fs/xfs/xfs_extfree_item.h | 4 +- fs/xfs/xfs_log_recover.c | 151 +++++++++++++++++++++---------------- fs/xfs/xfs_refcount_item.c | 18 ++--- fs/xfs/xfs_refcount_item.h | 3 +- fs/xfs/xfs_rmap_item.c | 8 +- fs/xfs/xfs_rmap_item.h | 3 +- 11 files changed, 213 insertions(+), 112 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 4991b02f4993..0448197d3b71 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -563,14 +563,89 @@ xfs_defer_move( * * Create and log intent items for all the work that we're capturing so that we * can be assured that the items will get replayed if the system goes down - * before log recovery gets a chance to finish the work it put off. Then we - * move the chain from stp to dtp. + * before log recovery gets a chance to finish the work it put off. The entire + * deferred ops state is transferred to the capture structure and the + * transaction is then ready for the caller to commit it. If there are no + * intent items to capture, this function returns NULL. */ +static struct xfs_defer_capture * +xfs_defer_ops_capture( + struct xfs_trans *tp) +{ + struct xfs_defer_capture *dfc; + + if (list_empty(&tp->t_dfops)) + return NULL; + + /* Create an object to capture the defer ops. */ + dfc = kmem_zalloc(sizeof(*dfc), KM_NOFS); + INIT_LIST_HEAD(&dfc->dfc_list); + INIT_LIST_HEAD(&dfc->dfc_dfops); + + xfs_defer_create_intents(tp); + + /* Move the dfops chain and transaction state to the capture struct. */ + list_splice_init(&tp->t_dfops, &dfc->dfc_dfops); + dfc->dfc_tpflags = tp->t_flags & XFS_TRANS_LOWMODE; + tp->t_flags &= ~XFS_TRANS_LOWMODE; + + return dfc; +} + +/* Release all resources that we used to capture deferred ops. */ void -xfs_defer_capture( - struct xfs_trans *dtp, - struct xfs_trans *stp) +xfs_defer_ops_release( + struct xfs_mount *mp, + struct xfs_defer_capture *dfc) { - xfs_defer_create_intents(stp); - xfs_defer_move(dtp, stp); + xfs_defer_cancel_list(mp, &dfc->dfc_dfops); + kmem_free(dfc); +} + +/* + * Capture any deferred ops and commit the transaction. This is the last step + * needed to finish a log intent item that we recovered from the log. + */ +int +xfs_defer_ops_capture_and_commit( + struct xfs_trans *tp, + struct list_head *capture_list) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_defer_capture *dfc; + int error; + + /* If we don't capture anything, commit transaction and exit. */ + dfc = xfs_defer_ops_capture(tp); + if (!dfc) + return xfs_trans_commit(tp); + + /* Commit the transaction and add the capture structure to the list. */ + error = xfs_trans_commit(tp); + if (error) { + xfs_defer_ops_release(mp, dfc); + return error; + } + + list_add_tail(&dfc->dfc_list, capture_list); + return 0; +} + +/* + * Attach a chain of captured deferred ops to a new transaction and free the + * capture structure. + */ +void +xfs_defer_ops_continue( + struct xfs_defer_capture *dfc, + struct xfs_trans *tp) +{ + ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); + ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); + + /* Move captured dfops chain and state to the transaction. */ + list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); + tp->t_flags |= dfc->dfc_tpflags; + + kmem_free(dfc); } diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index bc3098044c41..2c27f439298d 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -7,6 +7,7 @@ #define __XFS_DEFER_H__ struct xfs_defer_op_type; +struct xfs_defer_capture; /* * Header for deferred operation list. @@ -61,10 +62,26 @@ extern const struct xfs_defer_op_type xfs_rmap_update_defer_type; extern const struct xfs_defer_op_type xfs_extent_free_defer_type; extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +/* + * This structure enables a dfops user to detach the chain of deferred + * operations from a transaction so that they can be continued later. + */ +struct xfs_defer_capture { + /* List of other capture structures. */ + struct list_head dfc_list; + + /* Deferred ops state saved from the transaction. */ + struct list_head dfc_dfops; + unsigned int dfc_tpflags; +}; + /* * Functions to capture a chain of deferred operations and continue them later. * This doesn't normally happen except log recovery. */ -void xfs_defer_capture(struct xfs_trans *dtp, struct xfs_trans *stp); +int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, + struct list_head *capture_list); +void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp); +void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d); #endif /* __XFS_DEFER_H__ */ diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 8cbee34b5eaa..e83729bf4997 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -425,8 +425,8 @@ const struct xfs_defer_op_type xfs_bmap_update_defer_type = { */ int xfs_bui_recover( - struct xfs_trans *parent_tp, - struct xfs_bui_log_item *buip) + struct xfs_bui_log_item *buip, + struct list_head *capture_list) { int error = 0; unsigned int bui_type; @@ -442,7 +442,7 @@ xfs_bui_recover( struct xfs_trans *tp; struct xfs_inode *ip = NULL; struct xfs_bmbt_irec irec; - struct xfs_mount *mp = parent_tp->t_mountp; + struct xfs_mount *mp = buip->bui_item.li_mountp; ASSERT(!test_bit(XFS_BUI_RECOVERED, &buip->bui_flags)); @@ -491,12 +491,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp); if (error) return error; - /* - * Recovery stashes all deferred ops during intent processing and - * finishes them on completion. Transfer current dfops state to this - * transaction and transfer the result back before we return. - */ - xfs_defer_move(tp, parent_tp); + budp = xfs_trans_get_bud(tp, buip); /* Grab the inode. */ @@ -541,15 +536,12 @@ xfs_bui_recover( } set_bit(XFS_BUI_RECOVERED, &buip->bui_flags); - xfs_defer_capture(parent_tp, tp); - error = xfs_trans_commit(tp); + error = xfs_defer_ops_capture_and_commit(tp, capture_list); xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); - return error; err_inode: - xfs_defer_move(parent_tp, tp); xfs_trans_cancel(tp); if (ip) { xfs_iunlock(ip, XFS_ILOCK_EXCL); diff --git a/fs/xfs/xfs_bmap_item.h b/fs/xfs/xfs_bmap_item.h index ad479cc73de8..a95e99c26979 100644 --- a/fs/xfs/xfs_bmap_item.h +++ b/fs/xfs/xfs_bmap_item.h @@ -77,6 +77,7 @@ extern struct kmem_zone *xfs_bud_zone; struct xfs_bui_log_item *xfs_bui_init(struct xfs_mount *); void xfs_bui_item_free(struct xfs_bui_log_item *); void xfs_bui_release(struct xfs_bui_log_item *); -int xfs_bui_recover(struct xfs_trans *parent_tp, struct xfs_bui_log_item *buip); +int xfs_bui_recover(struct xfs_bui_log_item *buip, + struct list_head *capture_list); #endif /* __XFS_BMAP_ITEM_H__ */ diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index a9316fdb3bb4..2db85c2c6d99 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -586,9 +586,10 @@ const struct xfs_defer_op_type xfs_agfl_free_defer_type = { */ int xfs_efi_recover( - struct xfs_mount *mp, - struct xfs_efi_log_item *efip) + struct xfs_efi_log_item *efip, + struct list_head *capture_list) { + struct xfs_mount *mp = efip->efi_item.li_mountp; struct xfs_efd_log_item *efdp; struct xfs_trans *tp; int i; @@ -637,8 +638,8 @@ xfs_efi_recover( } set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); - error = xfs_trans_commit(tp); - return error; + + return xfs_defer_ops_capture_and_commit(tp, capture_list); abort_error: xfs_trans_cancel(tp); diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h index a2a736a77fa9..883f0f1d8989 100644 --- a/fs/xfs/xfs_extfree_item.h +++ b/fs/xfs/xfs_extfree_item.h @@ -84,7 +84,7 @@ int xfs_efi_copy_format(xfs_log_iovec_t *buf, void xfs_efi_item_free(struct xfs_efi_log_item *); void xfs_efi_release(struct xfs_efi_log_item *); -int xfs_efi_recover(struct xfs_mount *mp, - struct xfs_efi_log_item *efip); +int xfs_efi_recover(struct xfs_efi_log_item *efip, + struct list_head *capture_list); #endif /* __XFS_EXTFREE_ITEM_H__ */ diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 0d920c363939..388a2ec2d879 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4587,9 +4587,9 @@ xlog_recover_process_data( /* Recover the EFI if necessary. */ STATIC int xlog_recover_process_efi( - struct xfs_mount *mp, struct xfs_ail *ailp, - struct xfs_log_item *lip) + struct xfs_log_item *lip, + struct list_head *capture_list) { struct xfs_efi_log_item *efip; int error; @@ -4602,7 +4602,7 @@ xlog_recover_process_efi( return 0; spin_unlock(&ailp->ail_lock); - error = xfs_efi_recover(mp, efip); + error = xfs_efi_recover(efip, capture_list); spin_lock(&ailp->ail_lock); return error; @@ -4627,9 +4627,9 @@ xlog_recover_cancel_efi( /* Recover the RUI if necessary. */ STATIC int xlog_recover_process_rui( - struct xfs_mount *mp, struct xfs_ail *ailp, - struct xfs_log_item *lip) + struct xfs_log_item *lip, + struct list_head *capture_list) { struct xfs_rui_log_item *ruip; int error; @@ -4642,7 +4642,7 @@ xlog_recover_process_rui( return 0; spin_unlock(&ailp->ail_lock); - error = xfs_rui_recover(mp, ruip); + error = xfs_rui_recover(ruip, capture_list); spin_lock(&ailp->ail_lock); return error; @@ -4667,9 +4667,9 @@ xlog_recover_cancel_rui( /* Recover the CUI if necessary. */ STATIC int xlog_recover_process_cui( - struct xfs_trans *parent_tp, struct xfs_ail *ailp, - struct xfs_log_item *lip) + struct xfs_log_item *lip, + struct list_head *capture_list) { struct xfs_cui_log_item *cuip; int error; @@ -4682,7 +4682,7 @@ xlog_recover_process_cui( return 0; spin_unlock(&ailp->ail_lock); - error = xfs_cui_recover(parent_tp, cuip); + error = xfs_cui_recover(cuip, capture_list); spin_lock(&ailp->ail_lock); return error; @@ -4707,9 +4707,9 @@ xlog_recover_cancel_cui( /* Recover the BUI if necessary. */ STATIC int xlog_recover_process_bui( - struct xfs_trans *parent_tp, struct xfs_ail *ailp, - struct xfs_log_item *lip) + struct xfs_log_item *lip, + struct list_head *capture_list) { struct xfs_bui_log_item *buip; int error; @@ -4722,7 +4722,7 @@ xlog_recover_process_bui( return 0; spin_unlock(&ailp->ail_lock); - error = xfs_bui_recover(parent_tp, buip); + error = xfs_bui_recover(buip, capture_list); spin_lock(&ailp->ail_lock); return error; @@ -4761,37 +4761,65 @@ static inline bool xlog_item_is_intent(struct xfs_log_item *lip) /* Take all the collected deferred ops and finish them in order. */ static int xlog_finish_defer_ops( - struct xfs_trans *parent_tp) + struct xfs_mount *mp, + struct list_head *capture_list) { - struct xfs_mount *mp = parent_tp->t_mountp; + struct xfs_defer_capture *dfc, *next; struct xfs_trans *tp; int64_t freeblks; - uint resblks; - int error; + uint64_t resblks; + int error = 0; - /* - * We're finishing the defer_ops that accumulated as a result of - * recovering unfinished intent items during log recovery. We - * reserve an itruncate transaction because it is the largest - * permanent transaction type. Since we're the only user of the fs - * right now, take 93% (15/16) of the available free blocks. Use - * weird math to avoid a 64-bit division. - */ - freeblks = percpu_counter_sum(&mp->m_fdblocks); - if (freeblks <= 0) - return -ENOSPC; - resblks = min_t(int64_t, UINT_MAX, freeblks); - resblks = (resblks * 15) >> 4; - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, - 0, XFS_TRANS_RESERVE, &tp); - if (error) - return error; - /* transfer all collected dfops to this transaction */ - xfs_defer_move(tp, parent_tp); + list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { + /* + * We're finishing the defer_ops that accumulated as a result + * of recovering unfinished intent items during log recovery. + * We reserve an itruncate transaction because it is the + * largest permanent transaction type. Since we're the only + * user of the fs right now, take 93% (15/16) of the available + * free blocks. Use weird math to avoid a 64-bit division. + */ + freeblks = percpu_counter_sum(&mp->m_fdblocks); + if (freeblks <= 0) + return -ENOSPC; + + resblks = min_t(uint64_t, UINT_MAX, freeblks); + resblks = (resblks * 15) >> 4; + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, + 0, XFS_TRANS_RESERVE, &tp); + if (error) + return error; + + /* + * Transfer to this new transaction all the dfops we captured + * from recovering a single intent item. + */ + list_del_init(&dfc->dfc_list); + xfs_defer_ops_continue(dfc, tp); + + error = xfs_trans_commit(tp); + if (error) + return error; + } - return xfs_trans_commit(tp); + ASSERT(list_empty(capture_list)); + return 0; } +/* Release all the captured defer ops and capture structures in this list. */ +static void +xlog_abort_defer_ops( + struct xfs_mount *mp, + struct list_head *capture_list) +{ + struct xfs_defer_capture *dfc; + struct xfs_defer_capture *next; + + list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { + list_del_init(&dfc->dfc_list); + xfs_defer_ops_release(mp, dfc); + } +} /* * When this is called, all of the log intent items which did not have * corresponding log done items should be in the AIL. What we do now @@ -4812,35 +4840,23 @@ STATIC int xlog_recover_process_intents( struct xlog *log) { - struct xfs_trans *parent_tp; + LIST_HEAD(capture_list); struct xfs_ail_cursor cur; struct xfs_log_item *lip; struct xfs_ail *ailp; - int error; + int error = 0; #if defined(DEBUG) || defined(XFS_WARN) xfs_lsn_t last_lsn; #endif - /* - * The intent recovery handlers commit transactions to complete recovery - * for individual intents, but any new deferred operations that are - * queued during that process are held off until the very end. The - * purpose of this transaction is to serve as a container for deferred - * operations. Each intent recovery handler must transfer dfops here - * before its local transaction commits, and we'll finish the entire - * list below. - */ - error = xfs_trans_alloc_empty(log->l_mp, &parent_tp); - if (error) - return error; - ailp = log->l_ailp; spin_lock(&ailp->ail_lock); - lip = xfs_trans_ail_cursor_first(ailp, &cur, 0); #if defined(DEBUG) || defined(XFS_WARN) last_lsn = xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block); #endif - while (lip != NULL) { + for (lip = xfs_trans_ail_cursor_first(ailp, &cur, 0); + lip != NULL; + lip = xfs_trans_ail_cursor_next(ailp, &cur)) { /* * We're done when we see something other than an intent. * There should be no intents left in the AIL now. @@ -4862,35 +4878,40 @@ xlog_recover_process_intents( /* * NOTE: If your intent processing routine can create more - * deferred ops, you /must/ attach them to the dfops in this - * routine or else those subsequent intents will get + * deferred ops, you /must/ attach them to the capture list in + * the recover routine or else those subsequent intents will be * replayed in the wrong order! */ switch (lip->li_type) { case XFS_LI_EFI: - error = xlog_recover_process_efi(log->l_mp, ailp, lip); + error = xlog_recover_process_efi(ailp, lip, &capture_list); break; case XFS_LI_RUI: - error = xlog_recover_process_rui(log->l_mp, ailp, lip); + error = xlog_recover_process_rui(ailp, lip, &capture_list); break; case XFS_LI_CUI: - error = xlog_recover_process_cui(parent_tp, ailp, lip); + error = xlog_recover_process_cui(ailp, lip, &capture_list); break; case XFS_LI_BUI: - error = xlog_recover_process_bui(parent_tp, ailp, lip); + error = xlog_recover_process_bui(ailp, lip, &capture_list); break; } if (error) - goto out; - lip = xfs_trans_ail_cursor_next(ailp, &cur); + break; } -out: + xfs_trans_ail_cursor_done(&cur); spin_unlock(&ailp->ail_lock); - if (!error) - error = xlog_finish_defer_ops(parent_tp); - xfs_trans_cancel(parent_tp); + if (error) + goto err; + error = xlog_finish_defer_ops(log->l_mp, &capture_list); + if (error) + goto err; + + return 0; +err: + xlog_abort_defer_ops(log->l_mp, &capture_list); return error; } diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 7c674bc7ddf6..c071f8600e8e 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -439,8 +439,8 @@ const struct xfs_defer_op_type xfs_refcount_update_defer_type = { */ int xfs_cui_recover( - struct xfs_trans *parent_tp, - struct xfs_cui_log_item *cuip) + struct xfs_cui_log_item *cuip, + struct list_head *capture_list) { int i; int error = 0; @@ -456,7 +456,7 @@ xfs_cui_recover( xfs_extlen_t new_len; struct xfs_bmbt_irec irec; bool requeue_only = false; - struct xfs_mount *mp = parent_tp->t_mountp; + struct xfs_mount *mp = cuip->cui_item.li_mountp; ASSERT(!test_bit(XFS_CUI_RECOVERED, &cuip->cui_flags)); @@ -511,12 +511,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp); if (error) return error; - /* - * Recovery stashes all deferred ops during intent processing and - * finishes them on completion. Transfer current dfops state to this - * transaction and transfer the result back before we return. - */ - xfs_defer_move(tp, parent_tp); + cudp = xfs_trans_get_cud(tp, cuip); for (i = 0; i < cuip->cui_format.cui_nextents; i++) { @@ -574,13 +569,10 @@ xfs_cui_recover( xfs_refcount_finish_one_cleanup(tp, rcur, error); set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags); - xfs_defer_capture(parent_tp, tp); - error = xfs_trans_commit(tp); - return error; + return xfs_defer_ops_capture_and_commit(tp, capture_list); abort_error: xfs_refcount_finish_one_cleanup(tp, rcur, error); - xfs_defer_move(parent_tp, tp); xfs_trans_cancel(tp); return error; } diff --git a/fs/xfs/xfs_refcount_item.h b/fs/xfs/xfs_refcount_item.h index e47530f30489..de5f48ff4f74 100644 --- a/fs/xfs/xfs_refcount_item.h +++ b/fs/xfs/xfs_refcount_item.h @@ -80,6 +80,7 @@ extern struct kmem_zone *xfs_cud_zone; struct xfs_cui_log_item *xfs_cui_init(struct xfs_mount *, uint); void xfs_cui_item_free(struct xfs_cui_log_item *); void xfs_cui_release(struct xfs_cui_log_item *); -int xfs_cui_recover(struct xfs_trans *parent_tp, struct xfs_cui_log_item *cuip); +int xfs_cui_recover(struct xfs_cui_log_item *cuip, + struct list_head *capture_list); #endif /* __XFS_REFCOUNT_ITEM_H__ */ diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 70d58557d779..5bdf1f5e51b8 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -483,9 +483,10 @@ const struct xfs_defer_op_type xfs_rmap_update_defer_type = { */ int xfs_rui_recover( - struct xfs_mount *mp, - struct xfs_rui_log_item *ruip) + struct xfs_rui_log_item *ruip, + struct list_head *capture_list) { + struct xfs_mount *mp = ruip->rui_item.li_mountp; int i; int error = 0; struct xfs_map_extent *rmap; @@ -592,8 +593,7 @@ xfs_rui_recover( xfs_rmap_finish_one_cleanup(tp, rcur, error); set_bit(XFS_RUI_RECOVERED, &ruip->rui_flags); - error = xfs_trans_commit(tp); - return error; + return xfs_defer_ops_capture_and_commit(tp, capture_list); abort_error: xfs_rmap_finish_one_cleanup(tp, rcur, error); diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h index 8708e4a5aa5c..5cf4acb0e915 100644 --- a/fs/xfs/xfs_rmap_item.h +++ b/fs/xfs/xfs_rmap_item.h @@ -82,6 +82,7 @@ int xfs_rui_copy_format(struct xfs_log_iovec *buf, struct xfs_rui_log_format *dst_rui_fmt); void xfs_rui_item_free(struct xfs_rui_log_item *); void xfs_rui_release(struct xfs_rui_log_item *); -int xfs_rui_recover(struct xfs_mount *mp, struct xfs_rui_log_item *ruip); +int xfs_rui_recover(struct xfs_rui_log_item *ruip, + struct list_head *capture_list); #endif /* __XFS_RMAP_ITEM_H__ */ From patchwork Mon Feb 13 04:04:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D965BC636CC for ; Mon, 13 Feb 2023 04:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbjBMEGe (ORCPT ); Sun, 12 Feb 2023 23:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjBMEGc (ORCPT ); Sun, 12 Feb 2023 23:06:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1CA8EC57 for ; Sun, 12 Feb 2023 20:06:31 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iHcJ018552; Mon, 13 Feb 2023 04:06:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=PL75Ge9RYCZ5dOJ+09kknGX9yy1pfcoswPlNoIuQO54=; b=b0Nrui35IZnduBF9jZlvrMRFVlK6K8vWZO0/x3PIjpPZjeGubXqRBMLrJE9eYIVoKcBs brnzRR68HtJjjqiLV0HfQx6gBn/alFT6QqR2aZsM718oqcGtom2WTAIYtVHomwr1e57Q ptN0ko8qmCkH4RqHPMeI7hLE9us++a5N0kF3PYIyKF1V70PPliTC+gqF0Hecv4Tn1L4b RUFeKcy7ZSTzij7qOWbP5EdunFFLdi4r1iq9KdoSgfYyQ0LAziJ+JnAWOTqGx0DE4l8w Fj6g25INelouDVsQfxju74+5t79ihD/qgdhITqxcsBjEjBUXXYot8ncdTivJwmeF369h UQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2w9sv5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:29 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D2EoV0013540; Mon, 13 Feb 2023 04:06:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3kgnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WqX/jHLkzf8UJkMjChI1M6SMXPkkc/pQ3yc56dD6R1i5k61EvU0iwN+y6BIW0UnTdkttEEHyyeqtHHq3l6b7BFO5wtdAdLfsxibqplYXApydM9N9TFYrrXivW3JnrO3n68ixcSsbVGpTZEpz/YiPFJXw7HdYA3bT3Q0DatLa5DZz5s0YmDmGOOE8shaNqbx2LclOqJeJbyT99aKB5AZOAWZ2K2NS5goruOhhyNJ7LPuuDbzwlvCuJnp/KnCILFYT7PjjLlOJmilc6qZJw1UZ54IcxiRUh65m3wi5irjkSdzPJYbL/Gbldg/loU3IxD83lLPe3OAfCd8t/XJsS+w/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PL75Ge9RYCZ5dOJ+09kknGX9yy1pfcoswPlNoIuQO54=; b=nyJ3KRL6gVdbz9Pi1efy57fx+tyJjImo/JQH/r9mcs/X8kAcnKMsGcgBW5iOgXgRfsaq8Dzq8tKOYjectk0pOsLIRNMxUNzmbfhP2b4S58tdsOu36pyxCsd6WUIZjRtURC12Nk1wCQPVho/y6eZdIdcANw0d5Xo36cokJ127hMASV+6pDUJBEieMxrdsW8l9tzkvV/kFKESQByGgMdcNeHAmXRm2w96zZ59cXUiO1plqrj1dSpW5CCH4HqD80Q3PS08a2IuvNk8CpLUgxK59iV7DU4Xcz2z5eKDrddx3bJ2cgtKH/ukL0F0348RjxbpAMkgjDROmrZxvEsDvi+Hm8A== 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=PL75Ge9RYCZ5dOJ+09kknGX9yy1pfcoswPlNoIuQO54=; b=es5i+LRoUT0evaxkLoqU1p5BqkUBXdKKAVgGOOlVIexwEu0/MH4eoR+O32ii1XofkFhTD06kdO3UMAnXcln9rxF+Iy//Ft+hbrZhy96fbCvwCB9H3AFdXSWA7ypbObAowFbIarfFzp7Spds9qOPh0sSa5PoufF6nQ0x1V3iV08A= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:26 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:26 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 12/25] xfs: xfs_defer_capture should absorb remaining block reservations Date: Mon, 13 Feb 2023 09:34:32 +0530 Message-Id: <20230213040445.192946-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b5d7c09-ffe1-46ee-687d-08db0d77ad1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 59MvBtVvI4+42YpUIZaQRYzhtgBQcS7zlXubVGmvxKoZ8tLf6WbSTbo5EuqRqaFvKMqyYvrdHEenSIO9MiNXpIIrRLp9NFTuu2Qx6wQPAaxRezLwUQJ8xGe6WIOQQ1oz4JpBokDDYrWxjMaxD5DYA7JVu/CbWTXNoWD9L4Fm1yCL4kT9l+OIpL6Tpldf85lmZovcWb/NN8HAOUQZnYVHmIExj2htj5WIY6Ezgq9uDFHSC8c2S+2uwRXRHf2URSSIITVmMvamr7nQhDkdpi4OT60sz4WUJSOzhq07lHA6/BMcXyoVnxpnJSDhVfo4II06R0NS6onZuI6yceUQTjWd4nxfO43947x8iwJEE1pdsJt8gLmkHuHWKn+2yCPGCTy1PIUXZT0RTJJPY/PpMR7pU8ZkbrHNgVYVrmWX3UFI39QOuiAFEGRVq9aEpITxajCKxQUD8BIw6nUawcT3z+GjsEWWt//JSIkjxyNvUSjGsLe5V1ty0FwRUbyIy52IkDWxK0O+A5DgGzYGEjkRs/rr4gw9Ko3YTBsd2EaeoqgS5oq4t0gmJyOhi91DNXKAi77TdF1oyzCFdAdYBUBjqRZWRLOAUlQfDwfdBdezZVLkPc+QNX3h2mHA0J67mxuIxsZ8UkDOw3IiQjUWfSXIys3/Nw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zl+2f5iynXl7ZwhlHjO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/YXpf2aSH0JOcsx8Nnnz+Szh/aLndbtOCcg9SBKznQVFG+B5c/gwMC03Gimf5C+cT5al76lRdKG1UA7H1VMFJiccHdf0seqbgkV6IQgH9LZcuy+deSvfU4QMhl4kUjU6qrRP6wA+i1UBpwUjnwF336TpaigFK7zHe86XlLod9qRWQHXDZfo5QfUwUy0AFws7DndCsOnw31LntSoIAjceKQu31wmZB5YHpNaeZST8+uoFXptsf3WDJDqFLVPvVUaJ2BAgaQ7t33ZuzJkw/HPZwEmvH3+SVC2oZL6oFP8lHzIF41ozo+3VI38MAJf1ClDFfyZ6nHN9UMkwUGqbDrz27lUH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b5d7c09-ffe1-46ee-687d-08db0d77ad1d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:26.2680 (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: F8S7+7gCevHIEBGpVikvtfwpapYf9CUoMg+b5TNMmOX2g1mcJXBcJ4mKuIT7/OvvD1Iv5hng9CnJx7xosFgyOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: giJ9qGV9wLfRDoq0qom5bLVhLmTm5Lw4 X-Proofpoint-ORIG-GUID: giJ9qGV9wLfRDoq0qom5bLVhLmTm5Lw4 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 4f9a60c48078c0efa3459678fa8d6e050e8ada5d upstream. When xfs_defer_capture extracts the deferred ops and transaction state from a transaction, it should record the remaining block reservations so that when we continue the dfops chain, we can reserve the same number of blocks to use. We capture the reservations for both data and realtime volumes. This adds the requirement that every log intent item recovery function must be careful to reserve enough blocks to handle both itself and all defer ops that it can queue. On the other hand, this enables us to do away with the handwaving block estimation nonsense that was going on in xlog_finish_defer_ops. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 4 ++++ fs/xfs/libxfs/xfs_defer.h | 4 ++++ fs/xfs/xfs_log_recover.c | 21 +++------------------ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 0448197d3b71..4c36ab9dd33e 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -589,6 +589,10 @@ xfs_defer_ops_capture( dfc->dfc_tpflags = tp->t_flags & XFS_TRANS_LOWMODE; tp->t_flags &= ~XFS_TRANS_LOWMODE; + /* Capture the remaining block reservations along with the dfops. */ + dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used; + dfc->dfc_rtxres = tp->t_rtx_res - tp->t_rtx_res_used; + return dfc; } diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 2c27f439298d..7b0794ad58ca 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -73,6 +73,10 @@ struct xfs_defer_capture { /* Deferred ops state saved from the transaction. */ struct list_head dfc_dfops; unsigned int dfc_tpflags; + + /* Block reservations for the data and rt devices. */ + unsigned int dfc_blkres; + unsigned int dfc_rtxres; }; /* diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 388a2ec2d879..a591420a2c89 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4766,27 +4766,12 @@ xlog_finish_defer_ops( { struct xfs_defer_capture *dfc, *next; struct xfs_trans *tp; - int64_t freeblks; - uint64_t resblks; int error = 0; list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { - /* - * We're finishing the defer_ops that accumulated as a result - * of recovering unfinished intent items during log recovery. - * We reserve an itruncate transaction because it is the - * largest permanent transaction type. Since we're the only - * user of the fs right now, take 93% (15/16) of the available - * free blocks. Use weird math to avoid a 64-bit division. - */ - freeblks = percpu_counter_sum(&mp->m_fdblocks); - if (freeblks <= 0) - return -ENOSPC; - - resblks = min_t(uint64_t, UINT_MAX, freeblks); - resblks = (resblks * 15) >> 4; - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, - 0, XFS_TRANS_RESERVE, &tp); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, + dfc->dfc_blkres, dfc->dfc_rtxres, + XFS_TRANS_RESERVE, &tp); if (error) return error; From patchwork Mon Feb 13 04:04:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C592C636D7 for ; Mon, 13 Feb 2023 04:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjBMEGn (ORCPT ); Sun, 12 Feb 2023 23:06:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjBMEGl (ORCPT ); Sun, 12 Feb 2023 23:06:41 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60029EC57 for ; Sun, 12 Feb 2023 20:06:40 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iAAd009303; Mon, 13 Feb 2023 04:06:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=IpFtZNqJQx+KVXhORLOyrc41NXdOK2m3SvDVRYqpHvE=; b=aH6csOba/ra3HuG+wmWz3zinAc0MkJ2AEDcqcV+f5RhftNN7r3BKQkPETkvExGwfY46+ 6HFkcvvPrDdVdROLEZ2kHBuw6bHzSuw5czmqzchD56Zf0JySNZwnCrNwvEWqyjm4Y9yy wBq3Elmw2hDNbDl8mbK8lk3u4LxrzgOcab2+EALwmZPsCZOQ/6VRo0XEHfoctSJiTRU6 Ni8CKjAfCZauSOyNCuwnr6ckcflO2YqHQDXIl2JyXdtrLH22r5EwU535rULk4EO7cMnW L7bzQiD3Jme179mFFXGw9QSgqwssfF9MZFN09OEM3DZcbosvV+/XS3JqIdAgNa8XcZIx XQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1xb1wty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:37 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3Bp7N028986; Mon, 13 Feb 2023 04:06:36 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jy27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RqKcs0/gik3Wtx7as9Ls+WGkaxGCxWKPqJcVqW0jbJvK8POx1tAJ9roMVnb7Ti8lpyAbTsj9kO7xQEy2hwU4bx7fCCYYjkYv/Z7vmgxtGd4C+5TsLnUBdvGEzJ3SFVuBvY0ov0r9QM7wIZndR6pLqW3Ds0fs2FoO/QNcTqsrDpI+tadvfM4BmcCx/QeId5X0JyNuP/Jv2tMNSrtRc+8eo+PPeLHm1/G1m/cu+iyueILvmstbFuuFaOr0dTE7Rk+TwVwrNXrI0UkEG6FkwnsUzUg/0UGcrIhqz/ycjeIply449r+XCA1dJDJHAMVk5FiAP912/aevEkA0Iuau/eZQeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IpFtZNqJQx+KVXhORLOyrc41NXdOK2m3SvDVRYqpHvE=; b=U2KbLGwe5NbNl42nT7jqmCHEJRZMiOOJZqeO+8QJHirA0sOVy8yC3tWTBhf2dgvoJ6B9igcXfjHumnOxC2Ct66LR3AYftP8jpTYo7gzMFqcjF7jr8cfHpR5gCdAJfVoY0FxNIbMqfBTmubiEANVnltl0dB4FQaDRMzj6LKMAmH7QHbtOCM7QVAxXdKRTvp2mfEincRN3cIAYaZ/JkshvbM42JFyyaMxnTtNBzPbDM8/xhraz91n5yJlsnqHUyXZ7e+0lRBc5gDUFFexZ/D/Mkg3idLthLD09MEm5lGq1IAQpeYFORx8OQAh/pUWaMC1dYfNV/f9EdYef+xpFMrp43w== 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=IpFtZNqJQx+KVXhORLOyrc41NXdOK2m3SvDVRYqpHvE=; b=RWLZ5YIXswrIgvw70TzF20E2IHnsJH+gAqEJ2bbU3wR17X9qAL7iE6zgpT+ywERgfOWWV86wONZbyoEgyPw1ec3dUWQI4fixWVICCRSY4MS9Dm/sxq8D5wQJ/hqWMHL3HBWSJlYM+QYYw3xSEfKik5lX0dNQXtRfIdwbgxxtA/U= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:34 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:33 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 13/25] xfs: xfs_defer_capture should absorb remaining transaction reservation Date: Mon, 13 Feb 2023 09:34:33 +0530 Message-Id: <20230213040445.192946-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0054.apcprd02.prod.outlook.com (2603:1096:4:1f5::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 97468934-f125-44de-b899-08db0d77b1ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Nm3vLYsPmAP75vM2LMO/UIiblutlT/eEhJ5B2TjUV0Y5vXA8FQXfQf2cvndBklw5XKpKg9gqFlChZuclaCvHgDbzFORv9/X3MEwdxhw3OjignuPa0jU9t5IXK9zGzvZEL03SN/GRtMb5SACg4GTSiGsK5ktyvnXcy1a8NWPqLYs35vIR33SqoZxIfb3LbCCqT9Ud3t5fwgmrEs3FtgKTbAyM1Zkoef46ih6iuIUjmKsg7Xu3pcmVDX4M5NSAMDUed1N9JjP8BToPcWkhWal0pNY9eQuB0XPT+TlC7UUabRqweoLiXQcDC5yvZbwdH5Eupy31igcL/S1RJ4Ehhi8Hp2Hx6FZpT9htDkMrPh15jtgOORF6feePbvcu0ipaar1ppTcFiW4UN3Q7XBtPTRzFVNyMhHVoXNIRxp+krBQs05rwVZs0eSWU8R1m1soAGcTMKvxvMsP8VBLUFbNcP/MZqJvoqyxDoqoClcpoYlHh3x9E0bv98/SsT5qrxF1LcNBRZ1SRThEAVMeo1qHRAqWvaOyFV6ZebDaPh+jfwvOOUB+OCShH9bdX7WoOkhlJ4JDGWFcDc9w9gCEkOarfQjLeQUegKJdSVg5DH4OhJm/oCHKwtMVRpzhc9cs5knD35V59KRCOZxOLwPLgpYFEmNGTA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HzQ+xEWzy+Hw/DXPwVzwNhtkaQ+DJHQFanxJRVmbEn3kLXG2rgihuARCqGiTZCQmVKnIOOpJGhyL+e43vyJygayNF/4Q+KLMcI164Hkw20hcBAFyt5EO3woAvzfEgsDnAVZPGonn8y1VrU3fS60ZyS/Rfuzb9lSpEZeJNxRbYRMj6uuoMjOVUJJ1alHpABeJTO7/GuuMPBwus0svudzMNyNAitBUUWViXUUj/NW0f+PsGgohlWEvAvhmh6LT0WDrW4LqWLYJSnRRk8F1zhh/+Gl/areVXq7Hsu3NNmT9IF4rqntz8QvYd7+LhL9lcwAZiXvNhElNFaeQjhA55TBDC2dw1b6cPWrsy3F1VXVRHX3+abmpZF0FzVkCmZF1nrjcrRbzvn+1PuuoRG5uSj9eH9oaV1MiiK64MSztkXsQcF9bbl8ZLATnDhOYYkO8T8yxWkwq/EKt2ep70yKHB3mXm3dkrYbBwWbSI9adiDV+VETavbqAJYmTAyJtWaJhOhTDj5+i6jVV0YPrx5IBesmRoSknjlAx2kxzqHN24KuFyUJ3laKUEQU224AXlUthj0mZy28yWkDWLhYfKnLFFEl/TAu8p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op-MessageData-0: Oax6ULodUkva+xVKNWuZPvjtlaIcHFcAHdyRoPyoYJKqxv07tX0bQDJYn3JrrGTrVfMaOVAKn3aEcANsvYwybTvHcVieUoYrbvSQfRZTh6D9E1pfIrNDUqgFxwFAF++WB3FjnD6PL9a0u1FVeKav/TBJNjgbkqZ1Up9oTr6cGMoxoYVyS23SHTfC5B2msDtLb5o8i8h2HPicI84O6euqdV78u6B+QCVr0i0vMzdZ1HMVcuJg7nU+K+rqAmlaup6pyO7MtndMONsFwKm238dfUbZjccEQWSDABK3r8Mk+itv+0N/1XwpJtJf6MmzUk6e5G2ZoxQoojQdWKMMJ740lu/nYoaBv/E5FMbCzdyOQ/emqb7XXMvQtERMIj2JFRq9dNjuE6hAOmQBXzY7P1Avfd7HZY/Z4kfi4/cdfj4k7V9z9mmVQco/LxDMJnE+r3lW7PQwIiCpbGzicuDxgHdzqg1V0jqYKMhheTL+FtN7+fd+SmPBShVjX/J1+6VuXcE/PQ7o4MiofAAROrcTviUjsqxG9DbPn2nPdNHPlwoaZTaozg61hTuQW/5iG1Vrs1wHWwXNpI3zbtU4607jR3/kWJx3MTl/G+oSjUSUsLhE8z3ko6MUY8bIczfzyHsOL1Ed/TeppwmqpLKo8DUQSmAzhOsUgZ6ex9IyBJtA7L0CqJhebOcJhXxYmbMPPXKqhmSIOqu9FccMHip4PDZgNhQ9E5Ek5ZClVfuoDf9QScQduRsNAp7PfNPbV9HSvhmvD/Q9BHH3ioBWswgptxhTVsobNFT0jjYMm/Rghj3fHzFvrwjkMpP0XjXY6QQCTEGn7Mojf X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97468934-f125-44de-b899-08db0d77b1ac X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:33.9194 (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: 3CEh32KJwK3P+hrW9PMDowJX3/+lKK3Hf7fhcHDt1btta6CooksRCjgeQd+oUkguULZWZxk3QAuLuF6A/RlRMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-ORIG-GUID: dEkTZt5K0AuxjxtNGdbqczYTd1tRccu4 X-Proofpoint-GUID: dEkTZt5K0AuxjxtNGdbqczYTd1tRccu4 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 929b92f64048d90d23e40a59c47adf59f5026903 upstream. When xfs_defer_capture extracts the deferred ops and transaction state from a transaction, it should record the transaction reservation type from the old transaction so that when we continue the dfops chain, we still use the same reservation parameters. Doing this means that the log item recovery functions get to determine the transaction reservation instead of abusing tr_itruncate in yet another part of xfs. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 3 +++ fs/xfs/libxfs/xfs_defer.h | 3 +++ fs/xfs/xfs_log_recover.c | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 4c36ab9dd33e..d92863773736 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -593,6 +593,9 @@ xfs_defer_ops_capture( dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used; dfc->dfc_rtxres = tp->t_rtx_res - tp->t_rtx_res_used; + /* Preserve the log reservation size. */ + dfc->dfc_logres = tp->t_log_res; + return dfc; } diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 7b0794ad58ca..d5b7494513e8 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -77,6 +77,9 @@ struct xfs_defer_capture { /* Block reservations for the data and rt devices. */ unsigned int dfc_blkres; unsigned int dfc_rtxres; + + /* Log reservation saved from the transaction. */ + unsigned int dfc_logres; }; /* diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index a591420a2c89..1e6ef00b833a 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4769,9 +4769,20 @@ xlog_finish_defer_ops( int error = 0; list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, - dfc->dfc_blkres, dfc->dfc_rtxres, - XFS_TRANS_RESERVE, &tp); + struct xfs_trans_res resv; + + /* + * Create a new transaction reservation from the captured + * information. Set logcount to 1 to force the new transaction + * to regrant every roll so that we can make forward progress + * in recovery no matter how full the log might be. + */ + resv.tr_logres = dfc->dfc_logres; + resv.tr_logcount = 1; + resv.tr_logflags = XFS_TRANS_PERM_LOG_RES; + + error = xfs_trans_alloc(mp, &resv, dfc->dfc_blkres, + dfc->dfc_rtxres, XFS_TRANS_RESERVE, &tp); if (error) return error; From patchwork Mon Feb 13 04:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1503FC636D7 for ; Mon, 13 Feb 2023 04:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjBMEGu (ORCPT ); Sun, 12 Feb 2023 23:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjBMEGs (ORCPT ); Sun, 12 Feb 2023 23:06:48 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74577EC57 for ; Sun, 12 Feb 2023 20:06:47 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1jUdO028861; Mon, 13 Feb 2023 04:06:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=mlQ7XTH8V1AAd8Au6Ti84A5yQOE4NoF+z2kS/An4LsM=; b=YSQ05BVO5TRR6QO/zvqoHfQyYUMbmW9RdxChVDvFiOSMZ1DeRK1mEXoDBTS0tA+M2+8s n1RZg3FE6x7nLYFDGJ0+jOLHpx5+CDrWY8JrXeYN8jNj81I1mZKO9vTTzi/oLXm7/HxI Nni1KLlC9KMTFwgzf16zB999NJetNjRtEwVJ0sbYRBZuPAANfcuS4vHUg0fcvSzL3f5c TjSekeo18LDtURAzCFKIzWs2HqGnLeSjtxWUUKvPn/YBj23La1YFT+yEFnFtcoVcsx8n YM3sNWA71+s5YtBzcB8+Hbq53dM4Ens4l/jAe6EEIS8oJETlEh9u+PpVQvHv9dp/1Vu0 7g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1m0swu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:44 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3D1p2032611; Mon, 13 Feb 2023 04:06:44 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k1hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zc8ETCIE8ksJRS69ekfvCNJQEq1gThK1zb4OGC3IlqSVj4ic+TVxVBF4kO2547BM1fI3xIPVs6BBUEaR6mOEIwpENGz95u+7yZs0ERSEiPJHQPJlfLrOwX+/eDp4My3MOMY1FdHOHNDZXy42a29zzjPaWcFxc5G6+950EPkpWdEziKWXKpfsfIAdWLDqzfCfZhtJ7CPBIVoeOkRKhDxECSxaiEF/aTNkiLR6u6Mil8SkTZSTVn3cB1UHf4k3fRtRGpzpp+ILyclhzDJQWfybfer4bJelQ+3vZDPLFfMpMG//pu05ObSaBJz+neuxBzjF2NSbgm0PdenzQ9tat0Pt/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mlQ7XTH8V1AAd8Au6Ti84A5yQOE4NoF+z2kS/An4LsM=; b=gi9pNfllHwg/xpXF/gzGb0dGbDPx3m6a3NXvFsUJOymNZFF7FVmLi7AKvBcvlH6Cxpbh2O1J53Lukg0K+5wNsgaALEFkE2S2yomzDBPREPD7chGoyjDLUnGKYalA29RwLup5U+MOSJEqT8mmA6wjfsV4RWeTFj5kiKZ4CnAgL9WEAyrwBedKrn8R6xMubBiGbC1wclKezcya0cDbjPmfcNiNpfYPdIJWp8hJiK1vZQX+Ox46xH2dYbVpIPe0scpaoLD63SQ+CumR3bho0jZF1SqEV2vouafLIJXlI7cSfYUILq+ldREkHDjM41tFFU2IUcaIEoOlgbEixHxqbceBKg== 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=mlQ7XTH8V1AAd8Au6Ti84A5yQOE4NoF+z2kS/An4LsM=; b=WvD4NmMmywNNhk/iOLswRhfOMjrCRSBUXb42m0MtIkeKuVtGs2uF88x7Tijl4EylJuTK7P78t+eAxkBxkNlS2p2JN4saFXRAGm5jJhps4fn39BJGMEaTuhGyglYgsRS/Pgy5VavDOZwAJjfQ6IO1Ga3gRot4QNuDFPKgSZVAmFc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:42 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:42 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 14/25] xfs: clean up bmap intent item recovery checking Date: Mon, 13 Feb 2023 09:34:34 +0530 Message-Id: <20230213040445.192946-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SGXP274CA0021.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::33) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 2949744a-6541-4146-1bc6-08db0d77b6a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y0cFhErnX5+F2/Y9L7XaGIor40ak7/D7OCu+Fs7acxV6NqUFy3me8lNfdbPXZJ15ndI+eioHMRj65pwHmxM57LjwMxiv1AmQnYudnkvN69ciJ9iMW3N9KQF/fWETNe2rx98Gnj1ffFoVMKfj5EPjB29LGfhIjYCTenX5her4buWRdPyZCm47apTAYxSfU2/jgXBaHFZvJ3nqPRLQhQq5gGqycdviGi6nMVEye0EL882zEEcXMl62ZYyijakbXLiALPr+TX/hmJF/cZsbI5pa3MePYBYeJJk74ee6wGPg80ZtYj25dKdloOMZLx/vxtHMBfVFHuQhM7VcUlM0Lv+89qx9mdgLUmk+apI1LJm9CnIDOLcQedx1coDBXRRQTPnXA9Un+qsjYbyCA/Zlk0QeNr4Uv4g5etzKCCKPKkSTWmx0xTnWGhUgY6GMafWcTk5QPFzZHML2Ml8m8b+BXUpHx1EivSAGVciNMll4IEDYgQMj5Ls3P5ZKHi+jx06RzeVklrv6wkjlwPA78KtupDg1Aga8PnRoaw5owlOP42EdoV6nlYvhgTUFMvPk6GB9MUux1a6NeRYJcSZ4/jyaXmBWPwQFRtdcZ6sn3wzwwCVJhmkCiHbj1KQ44XPrx91eKqHNeKWwgmTEZlHos6/sW/IXzg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V1pROvtLG4Wp4p8qUoaWkOgEoZwxx+Wb/mVl7FNK1MF/HZUqdrUPhFPVTPN+bjyFuzJTXMZmYERptH85N4KFwdewAbKoEEQ7O5bXKsqtZ8rJMiiLxn495dVgiC+DznQRf4I4ANCkxAqUAo7Jp+kaqju8tNxRqtVGeh8BU7CjJdGqasCQoh5X5yOr81T5D8O7y6ZSp2b5KA4JIhmp0lXIyJUi2WT96tQRbeI5I7b32fxiJed0dllky8biix4uhX3AbvnCz5ZbNbtJpT5Xe+M9UNszf1IBzAwTSLfS6XYvrnWqZYhSJt32a+1dY0tbigFhe4jwcxwes4z4sAUoUSXS89IdXWBunYtU1EMIgsc9+L5RTnDFo4gy9G8NIpJ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g: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2949744a-6541-4146-1bc6-08db0d77b6a7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:42.0824 (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: pq/cmgtWdPGFWcYDZmwQ2eMFohlDgLylXgug8MqSKPWFGxmBmlhvjs8wvSwoOo6RIOmQpS5SkHVLbRjAXIuYHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: z2JSpgTbhNVyijsro-Z6VxjIflAG31qQ X-Proofpoint-ORIG-GUID: z2JSpgTbhNVyijsro-Z6VxjIflAG31qQ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 919522e89f8e71fc6a8f8abe17be4011573c6ea0 upstream. The bmap intent item checking code in xfs_bui_item_recover is spread all over the function. We should check the recovered log item at the top before we allocate any resources or do anything else, so do that. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R --- fs/xfs/xfs_bmap_item.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index e83729bf4997..381dd4f078b0 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -434,9 +434,7 @@ xfs_bui_recover( xfs_fsblock_t startblock_fsb; xfs_fsblock_t inode_fsb; xfs_filblks_t count; - bool op_ok; struct xfs_bud_log_item *budp; - enum xfs_bmap_intent_type type; int whichfork; xfs_exntst_t state; struct xfs_trans *tp; @@ -462,16 +460,19 @@ xfs_bui_recover( XFS_FSB_TO_DADDR(mp, bmap->me_startblock)); inode_fsb = XFS_BB_TO_FSB(mp, XFS_FSB_TO_DADDR(mp, XFS_INO_TO_FSB(mp, bmap->me_owner))); - switch (bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK) { + state = (bmap->me_flags & XFS_BMAP_EXTENT_UNWRITTEN) ? + XFS_EXT_UNWRITTEN : XFS_EXT_NORM; + whichfork = (bmap->me_flags & XFS_BMAP_EXTENT_ATTR_FORK) ? + XFS_ATTR_FORK : XFS_DATA_FORK; + bui_type = bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK; + switch (bui_type) { case XFS_BMAP_MAP: case XFS_BMAP_UNMAP: - op_ok = true; break; default: - op_ok = false; - break; + return -EFSCORRUPTED; } - if (!op_ok || startblock_fsb == 0 || + if (startblock_fsb == 0 || bmap->me_len == 0 || inode_fsb == 0 || startblock_fsb >= mp->m_sb.sb_dblocks || @@ -502,32 +503,17 @@ xfs_bui_recover( if (VFS_I(ip)->i_nlink == 0) xfs_iflags_set(ip, XFS_IRECOVERY); - /* Process deferred bmap item. */ - state = (bmap->me_flags & XFS_BMAP_EXTENT_UNWRITTEN) ? - XFS_EXT_UNWRITTEN : XFS_EXT_NORM; - whichfork = (bmap->me_flags & XFS_BMAP_EXTENT_ATTR_FORK) ? - XFS_ATTR_FORK : XFS_DATA_FORK; - bui_type = bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK; - switch (bui_type) { - case XFS_BMAP_MAP: - case XFS_BMAP_UNMAP: - type = bui_type; - break; - default: - XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp); - error = -EFSCORRUPTED; - goto err_inode; - } xfs_trans_ijoin(tp, ip, 0); count = bmap->me_len; - error = xfs_trans_log_finish_bmap_update(tp, budp, type, ip, whichfork, - bmap->me_startoff, bmap->me_startblock, &count, state); + error = xfs_trans_log_finish_bmap_update(tp, budp, bui_type, ip, + whichfork, bmap->me_startoff, bmap->me_startblock, + &count, state); if (error) goto err_inode; if (count > 0) { - ASSERT(type == XFS_BMAP_UNMAP); + ASSERT(bui_type == XFS_BMAP_UNMAP); irec.br_startblock = bmap->me_startblock; irec.br_blockcount = count; irec.br_startoff = bmap->me_startoff; From patchwork Mon Feb 13 04:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24040C636D7 for ; Mon, 13 Feb 2023 04:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229468AbjBMEG6 (ORCPT ); Sun, 12 Feb 2023 23:06:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjBMEG5 (ORCPT ); Sun, 12 Feb 2023 23:06:57 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75FCEC57 for ; Sun, 12 Feb 2023 20:06:55 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1jPoS012953; Mon, 13 Feb 2023 04:06:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=5C5Rq9D/7tTl+aWG8NM87agwDJKLIoHB/hXmF749SqM=; b=qHcOSalPsxDKrb6N2uSSHRH0HQF08mAVSyooNJaJECMVDz5W8qqcegAIp7ztnl6GOAA4 SVCxHYcBdJctRwQagrE7mr7GR9fT0hUgOzUJHaCH2SkBvoswyzDyIIwMBOldn12dUczh B7ERD0NQWQAaCQPq42Urfe8/lsQ+bpfLyKF5O3hlpBgt/H9Xv9SG0uy5vyjWVl5eoMHR LUbQgpaVxqtNvIO5Ui2rPbuhZ4XGPH/4oBFbC8VDRB8N+p/9YBDa1zb3W02Wx2K2FL7I NmP1LSoMkyWHSqld+rlTPmJKDAkW7Gn2px8B2CnqeBKErGNj6rgY6kk3jpdnxDA+OSQt FQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:52 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3q6xY028785; Mon, 13 Feb 2023 04:06:52 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jy6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:06:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IgMBTxlcGuDQzParWDJnFo5HBb4yB2luEIsVAxdFc+jkk/9SHEMdcHdN9IH4K8A7CmqfVA4DjcaqyaBXPJqJSHzKTnPWZzY2Psa3X9p0EjoQ3hL3RV4P4TnMY/MLbOzac/MfglYiRdMcRWz/GwbtReGZiWs1SsXeKn+F+OYtoSC8P0MiRvYHZRU+Dm9EnvzijqkBD5Pu6aHwf4QlMtNdkOindUvVbUOCY+i0lEyYAziF1TO/bp+1pTifIoCPDCrZbXSx8gp5l29lwNiMcUgcFbd70nH66qg5wow3a8+nd7p/eNiuYSkPw8l5VdozxzLxLGx2mGycB0gV1UdIcc1avQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5C5Rq9D/7tTl+aWG8NM87agwDJKLIoHB/hXmF749SqM=; b=FtqcapXdN7MIvt7Xro2SI2TcarbIFmwBiS1Rjg+8XUDsL9fR1TxISIMohA1a3U6J16dHBJTa34rMW14eKPe8Kmap325tAwNSx08Z4B/lmuw2/tIXlte/OVQmlHmUSlyelEHQ1M5rhJno8vEMSzv5bAUqHTejIm3TXrMiVCB21W+7PJ3s7ioAoVnfHqDjBvMpSiqIZsPids9ln9u5vVtZezB0gGrBUe8a+Sra7/cQT8SblwZJYx1AYpnpsJz8ZyOQBbJuaSEUaXny3H6z9ktW6qDj9/BNH57JMD10jZ4q4jW08BUmd9ET98HSxEo/ATph0nXzRMbv3aN/S84xmxDFSQ== 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=5C5Rq9D/7tTl+aWG8NM87agwDJKLIoHB/hXmF749SqM=; b=qIdt7xNP2S3QtWkki7y67iqGmrJedokTxBZV31YhiyMTDG++E8W0mnem67X/H7dRyQcI8ZkOvLfscZWBeiBQX4mrd0EITmwbjVi50XKf/vDKkNml6fmFcFJCEhakI9LQalzrHfy2vWB87a3DumJ1yAl82iWZRTMRonu541QxH1c= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:49 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:49 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 15/25] xfs: clean up xfs_bui_item_recover iget/trans_alloc/ilock ordering Date: Mon, 13 Feb 2023 09:34:35 +0530 Message-Id: <20230213040445.192946-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: d8ea5014-b632-4586-3631-08db0d77bb05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BPqx3lcpKcxf58EB4BH6wzxD41XqRa1WVHVO5WjOTS5rZZPi6DLbup51vCCQzGifkkZ1HwzDmrxWHwx8O7agNlorZOm9if4iyK9ZzHgtYMixKPoOfrPmJWpGUyfcDLg53yC4MtDl6sVhmTB46f0FH1CiDyJlMZyWp2y+HgvUuD3xCHFD4D6zdr8j+TYN32XAD0cuIQMubBEQDC3SuN6LhN6CN2+4jXelUfOqx+ImsUDwW+zW5zWikKPhwIZ4kGop6D6fPqV4HCPZYS1tXxvs/vJJrU1GTlenC1O0j+sFGUHiFruJ4CQ5wvn16CDikLmiJm0Ilv0fFvQbNMd8IwTgAcMo8stD6GTSREJUPX/9sFRg0xlpvIeZV6nbssuH5ekBL8p4nVl4sZ+8YUAh2tQKJbHR2vOOhyKdZ1DG/VO7CkzbbcKmd2PKC/lwjYnoqBm38bXR/8AXpfMXFj3GXRZQEgmMMAXB3uHhrNNmydWZsqppf4srPX5LlLD4RtsQx/7FgTZsnwqlAULTR3jrxzQiZRdSVeoFxmWG81emZFmM7Demad3suRcA7gM2aJpzTc/skWPRGEc90q4BvbR67CnGj4Vo6c9xySBUybBLsnPf2AyDhbiiBWdQhDk6pPmXhHJUcq0gwPi7fLb56PDS0CCtXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F8K9v/qzHXsO4dGZiU9HvMnJUGrKpX2B9te8LTlvXJg75H49wE4iorPjXIgWzEiSbpTNSsPQ0FCl0uISgzhmuLmfnz2FWbj5k4tLVConns0X8oITPcQmT9765+pGFmrS9B/5fXWjtiMlAffyHFeYx7yYRnXH5RFbfIzUPkZktHT365oXZgKvNYIUzfnRcIR2svUGMYq/qt81P11Z441HbiHOb4uQl08KMU33tAJJVhnq+kRYmTLdiJKc5g3+cs1iQOi1WsT+k/bXK/JGw/3GCVnUMoLKXtiu99SQ1pkY5ezLkzFqRxDOko0yvdRx6OERHjPrJEL+zJ1CL+J6hnXl6SaLs0r9o3pvO+I3S/hAs9uACjjRtRNDRyBLGevlTvQfu8AOFvrlHmXyapKBe/micMTC/ZU8MeVokmFPJvTpd8OXUYG5sd3QtA0aZlvaNYVpxRpPCc7wqKNxSuCz1ydPf5MYAAkAIjFDRyIn3zzbk4ldzIvTACog3QTLUKkHhx7CH546vML36iBWooWofV7jXavuIyAYyNZNnu4xw3JTf6r/4L7eIEVXENx08r8jmWZvnZW268X29b6T+cwRUmgvpIxCBDm4Vrt+wz1a+M0Z4RPns3H0ULPxnke1Y7F8g9mCU8Loctr/aGP7EZvTXrMKa4rVU6IbaIf2kBhPPEdbD7vCsrxQ13eK5wZqjsltwVREtpafhbuUgBVmMIjcDRgxVt242QDLhBHNLN+kaORcIOIz7+foqF4QgPdlCWXeb9bP2aMNJv/zv+Ap2zzqdjPsCh2H2yzG0l8EXm+YLeCogmfvoUxmyY0xmXTePAzoBpxbJdL+r2AQuCj1YH74qtQnsfv4lI4oXTXCsGtOzs07HzYI41TDy8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02g6a344u5MQbbrKkxqi9f93Y02tsn3P1BzDzuzI0nXkU2vL7VPSdB7u0O3qtVnjMkOID0Z4iZ/mco3f8xdcOnybTcthhpSz5O5+sNxQYRHPplO5ipgPBXbY3AlFn6TAlGHAZ7cyrNHPnuVYLPBGHKPqV4PoMXa+RYFNiV/lRwsnOnigsr0gb/n1GiAE8V9EMJj3Q0HWIkaoYTbbE773zZZPvECz+2KL2KbKBVqeJ2ZTb5gSGC69hzDL3Goor2t21cKeA5CetfvDRRDBBJN9iwSTcvBF774fK1vFJXUjwZc1sNEglpz2DEB765030XdjGISt0hTzhHTyr5xr+cJDpFWELjU58TCibO1ICBy1qyuEQr+NZYbBikxCvkkm0jPcAoEwqRIlz5CJDelbCrLRZkawTAMRt0iwJI23mz7xksXIPPuj6DFgGE/8wuhbpjUnv1fbBLpJNb/S1zoACc5L3rpuIRDgq8AajM9vI9QQqC89XJpBxAqOGKMnntyoudte5dxNMXNrS1L+fcTILKByIQ/4D+9YOpXGYIXezn70YH6M6dojeeoWksCsFhQQHE X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8ea5014-b632-4586-3631-08db0d77bb05 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:49.5975 (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: xLLjeK/q1x9vTq7nyefcCCa07fvrd9qKuntXJV9+c6VA3JLQRF9avqU987pckOViGhtjVeSDgbFWGqGRwlNl6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: CJy2I0aKmcSawWyTYUr4CegnGcHR7HB1 X-Proofpoint-ORIG-GUID: CJy2I0aKmcSawWyTYUr4CegnGcHR7HB1 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 64a3f3315bc60f710a0a25c1798ac0ea58c6fa1f upstream. In most places in XFS, we have a specific order in which we gather resources: grab the inode, allocate a transaction, then lock the inode. xfs_bui_item_recover doesn't do it in that order, so fix it to be more consistent. This also makes the error bailout code a bit less weird. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/xfs_bmap_item.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 381dd4f078b0..f7015eabfdc9 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -22,6 +22,7 @@ #include "xfs_bmap_btree.h" #include "xfs_trans_space.h" #include "xfs_error.h" +#include "xfs_quota.h" kmem_zone_t *xfs_bui_zone; kmem_zone_t *xfs_bud_zone; @@ -488,21 +489,26 @@ xfs_bui_recover( return -EFSCORRUPTED; } - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, - XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp); + /* Grab the inode. */ + error = xfs_iget(mp, NULL, bmap->me_owner, 0, 0, &ip); if (error) return error; - budp = xfs_trans_get_bud(tp, buip); - - /* Grab the inode. */ - error = xfs_iget(mp, tp, bmap->me_owner, 0, XFS_ILOCK_EXCL, &ip); + error = xfs_qm_dqattach(ip); if (error) - goto err_inode; + goto err_rele; if (VFS_I(ip)->i_nlink == 0) xfs_iflags_set(ip, XFS_IRECOVERY); + /* Allocate transaction and do the work. */ + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp); + if (error) + goto err_rele; + + budp = xfs_trans_get_bud(tp, buip); + xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, 0); count = bmap->me_len; @@ -510,7 +516,7 @@ xfs_bui_recover( whichfork, bmap->me_startoff, bmap->me_startblock, &count, state); if (error) - goto err_inode; + goto err_cancel; if (count > 0) { ASSERT(bui_type == XFS_BMAP_UNMAP); @@ -522,16 +528,20 @@ xfs_bui_recover( } set_bit(XFS_BUI_RECOVERED, &buip->bui_flags); + /* Commit transaction, which frees the transaction. */ error = xfs_defer_ops_capture_and_commit(tp, capture_list); + if (error) + goto err_unlock; + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_irele(ip); - return error; + return 0; -err_inode: +err_cancel: xfs_trans_cancel(tp); - if (ip) { - xfs_iunlock(ip, XFS_ILOCK_EXCL); - xfs_irele(ip); - } +err_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); +err_rele: + xfs_irele(ip); return error; } From patchwork Mon Feb 13 04:04:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62919C636D7 for ; Mon, 13 Feb 2023 04:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjBMEHK (ORCPT ); Sun, 12 Feb 2023 23:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbjBMEHJ (ORCPT ); Sun, 12 Feb 2023 23:07:09 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68656EC58 for ; Sun, 12 Feb 2023 20:07:07 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1i3h5011963; Mon, 13 Feb 2023 04:07:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=c3YiIWAbHBsilshyAQOZCgzNyIykwDSbTTXEJSiojTs=; b=1hbmqWaiUMV1jOrbpaH+1Y6+emrUWkjNTVlJlTF/CdYHVdDNrkExyHy8MAwqfUfr/uQp lit4YABS3V47KXzQh7cx6t3JfjLDb6F3mF02lmUqHiI0e2N0H+hWQjlakAkVI6Nb4aq4 GV6SZngeIFfnWN2avP+XkQhZsCQDYDPSHGIU+aYDvFDyhFYwttMYLoF92gavUWmodlRO Zj43fFGRuG21Tg1AAffDp9H4WSmzAs50SmNLx8JXpDOUJL3xrgrE0S4CJ3tU+xqDZF2p I8BjC49a37zHqpHhwC4/ADVC+fRmHWUgfWK268fMagR4SdnBeWAan/EDsg0qy2pDRrRR uw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:01 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D2SXhg032602; Mon, 13 Feb 2023 04:07:00 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k1rp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKFbaKPbpd1h9S1pLvxvayaQCTPgKtYLu+jrtB+z/UsT84eNuV/blmAMS1ObA610n9OjRgWhn44UvwxGdGk7j/BWVO687gpFG5NYqdpahQoGxHgWuGA0fqe+iFzGE08+UV/IWgMlhMyGuf1MZGfPyN0V/oaNaRJFZUTBB4rPt3y63MDMxaTkX1hqhcR6TRJmTEJhe7vHRW8AHLgkcbjSgrcmkMAYlyTJUgY6QJdD3N23IOuQb3Ejsy/RivaHSmkifhxBj5I1UfdL2fol45hbtLXD2LyvxbEIIDkmNAUD9k7ZALHCKPWnJJAKatyLgM0hLSj0sxkDoCWxGLEl3kPcuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c3YiIWAbHBsilshyAQOZCgzNyIykwDSbTTXEJSiojTs=; b=Lj59StV0DSKpZRFpiHnSHcC9ZLZ7Gg4TnsZlD+uRb3mK6pmAkEAAhMPCGnSf/Kn0WEHzaTIv1hrWHwHH+nAGWVM0bMyOWLvwnR1cBUi5iiOhypnY5tcSzfjn0BLXKb2rFfo3s7/pJZh+VM81kaDRBowGpsUw4uk9TGQOU9bi2NRCP5qE4BUbDUpBYgh8fhV2kIqX9KeVE/uWXmvTIeOpVpf88P3+X+uAVKnM23AesXTbQpJmDfpevtqCVW0zVyqQmrpB03VhiJwTxJwrpqwfUpphknnczA0XXXV/oU+jpWSFSTTG8U8UTUhkYTzEcc7770H5SGbWFDpurv9K3J0JVA== 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=c3YiIWAbHBsilshyAQOZCgzNyIykwDSbTTXEJSiojTs=; b=oIjyi+f1QNT4kRhmVuSXw8F967qWlXz4tEP1hUM2fr/8kKlMenYkYY5j3QBdJYp9b4vvGPvKiVutfgJeP0gmx6pVaRoqe8kHLslKl5zOhPPWno7VVt3h1LAN4/qN5HikcXX4GTFuRTzpncAvrfloLc7WH8OrxTm43U8zdMmC1zI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:06:57 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:06:57 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 16/25] xfs: fix an incore inode UAF in xfs_bui_recover Date: Mon, 13 Feb 2023 09:34:36 +0530 Message-Id: <20230213040445.192946-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR06CA0013.apcprd06.prod.outlook.com (2603:1096:4:186::18) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 23af3ad3-25ce-4a85-abd1-08db0d77bff7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C+Kzk+aJ/86jl57rXydUC3XpeisPWjdpNpEJjxOq7IXlWw+ZPR90qLJt5GWG07c3ELVZTt0bmKY+g6MZzMmspsd7JauoBgr0TvbIOs9HjB1dJgzjZ2Gv7Svly3Zl2YfnL/t9fCNDwy462LoXiuleg/mtgEktPHtnS95OdyzdvhUfRhPjEEQvYIevBP/LWxBc2ErLodH6Qt6hM5tMAkqdMQqZ+aYFTmTSz7aguNsbD+yMU3V60n+/1cGzLuTHZNkq3QpWiLBt6py0ibgO8+sTZMLJL5JBlgbjlxZiHaFYM2NPAoTkiNuIaL3QMO3FgDzbhIJqSQctCzNHkLHDWoDifmSeRPi2B1ZNzMDTJFtMeB/8egXKJAHeIqseNsCI9Zk0SmYwGgXUJToPcadLYljtNb18tKo/L5ldD96l8JeA2MyMagastAqWaSRFyiwpB3e1M2cdDbCq4PpBXBPwyIOkxx9xGUb/PjFSdiFAXtov5c38Wrmy3y7mcgucKhbqW7K8MPjbDxih3GpnBu43FoydIowmueJevvGIcTNnrBWnQreSAOAmAepJKWFsOgTKuFHRMENb5tpAn4XYiYOXd0mmQWEfcwDllLAuSfFqdv9Bsv9O3PqTyBToJ2XOQ/w7+BsfsDZSlQds6wK9XnqRDeU1/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3nyM8X2ITcaJYUINzqwFDpXaLF+GjMofK9NJmPyKfvDudIqKoYBPRJVRwzXYYP8jNheqqGH/DeqyLy/c6Z5+7o+nUZt66I3sQvFVMA1k+E5XN7AG+Me57S8rO0ZSrbZ4Ndnp6k3M6ol5w+iYjP6vgaZ/bPViu5EOY2gJA+FaX1es7OUS/bqc+2uqEtELGKalwBP+LhX7j0wl/vmChFaosEu7f2aAANHlFabrRvriqmT95ivuv9gcwoddAW4oHuc2X9Z3YdAyoL6BsNDHFEnJ83Ks7IPVml9EBkcyiuyPuIbEkOfdGOtfbSGykmnX8Gbpjvf+TVQX9A6aBwESxo32r180vlhHqNGZI9/ttjlFZtZ8aKLE06jnZKi3vYnYYiymPGcsNyG33DOhkWL3/zo9IHeSJrPhAz1jAtirrqNd4XX3e0CwBGe8mE79Lm0MOur1aUeoXGWzzBNi+d+Prlur874SKtJjKZ/pfb1vjuddJq716t4lZ7c/LqDsC1PpSAMO01hH5B2tRcLBUbuL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v3kKmMmQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nq3QbMij610I/+73VKZ7fVBXvEEpv87HDy4/yBTMW5dn1h45AhU2I2zGp5cJvHM4b/NHS6bZGmuMtGGs3gT2q5ZzlV5TMSkEPitcCGRFvFZqUHrWKVxfY+YnNSB9rAz21hxZdzDBwUYhp1wH9CsDCcBR4NgrtS8B8Ni4MgvRlf6koNbYwTz+eU0474hyO3r6Mrx4cFYy1ZH6rafuqt0BGgsSyxy0K0BgoS3zjjiiGFjA5I3nMFMWf3bS54wO3Ag7naDc4wYMzbsEQawWOQTcS3R80CdlXhG11eKQppvt6dd8hrjOcGwmAq1xYgdY3dkeAKoqFws9x4NpMDN2RihWYnal0RKUfTGk3Dj5CLyFekkAzObskwUyv6DC6AD5hXqEwxlMMiVVZPnFVmVrZV+nT1YT4NrNzxX3zyoqfKjjRVbh4qyTKz/CrBHmP8WceAJUaQpL9wGdKYk1bPZBCdtS/7PMTkBbPFU9kj6UZZxMTY/1ur+jUTKsiHkDb59rc8kmTg5eQDL6OzdCi78dNYXflHFFJNpx5SLlmTg9jz5ks/Ruvg/XqtU8Le/mhl8ljJzbF6iMexri3UMQaVOai1X9gZ4QZGGRdBxZrFE7fLjk8gxLKFuxMtGlUsVLiwuJPnJNxmINqeSmoBfcd1rk3fELwZenPPyOTWBG0KngLckBx4w26SK5nZhuGO50C2//34HV719ZYn4yDvnWQShYHhIZmDyYe9EXpZmz4oyHDKoGtf9re6gFXjZF6yI7dKWtieH7xx6ZLOCkf8ixirWDiUGe4PCRhIVBvcmzpdJyGMieMQucNFLW1no+B0YsMKiFf7N5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23af3ad3-25ce-4a85-abd1-08db0d77bff7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:06:57.8818 (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: w2D7GCkQzxjHUG6JIltx0xJ9Nq+cYHOsC7dcaRHh9pSR5IK/d7sjh7EO6HJVmX2FCbWWxhuZjvc86cvNGBKZ9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: NnuEcL-bW2_hgrUUTKhpn2oFl2HsXQ5B X-Proofpoint-ORIG-GUID: NnuEcL-bW2_hgrUUTKhpn2oFl2HsXQ5B Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit ff4ab5e02a0447dd1e290883eb6cd7d94848e590 upstream. In xfs_bui_item_recover, there exists a use-after-free bug with regards to the inode that is involved in the bmap replay operation. If the mapping operation does not complete, we call xfs_bmap_unmap_extent to create a deferred op to finish the unmapping work, and we retain a pointer to the incore inode. Unfortunately, the very next thing we do is commit the transaction and drop the inode. If reclaim tears down the inode before we try to finish the defer ops, we dereference garbage and blow up. Therefore, create a way to join inodes to the defer ops freezer so that we can maintain the xfs_inode reference until we're done with the inode. Note: This imposes the requirement that there be enough memory to keep every incore inode in memory throughout recovery. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 43 +++++++++++++++++++++++++++++++++----- fs/xfs/libxfs/xfs_defer.h | 11 ++++++++-- fs/xfs/xfs_bmap_item.c | 7 +++++-- fs/xfs/xfs_extfree_item.c | 2 +- fs/xfs/xfs_log_recover.c | 7 ++++++- fs/xfs/xfs_refcount_item.c | 2 +- fs/xfs/xfs_rmap_item.c | 2 +- 7 files changed, 61 insertions(+), 13 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index d92863773736..714756931317 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -16,6 +16,7 @@ #include "xfs_inode.h" #include "xfs_inode_item.h" #include "xfs_trace.h" +#include "xfs_icache.h" /* * Deferred Operations in XFS @@ -567,10 +568,14 @@ xfs_defer_move( * deferred ops state is transferred to the capture structure and the * transaction is then ready for the caller to commit it. If there are no * intent items to capture, this function returns NULL. + * + * If capture_ip is not NULL, the capture structure will obtain an extra + * reference to the inode. */ static struct xfs_defer_capture * xfs_defer_ops_capture( - struct xfs_trans *tp) + struct xfs_trans *tp, + struct xfs_inode *capture_ip) { struct xfs_defer_capture *dfc; @@ -596,6 +601,15 @@ xfs_defer_ops_capture( /* Preserve the log reservation size. */ dfc->dfc_logres = tp->t_log_res; + /* + * Grab an extra reference to this inode and attach it to the capture + * structure. + */ + if (capture_ip) { + ihold(VFS_I(capture_ip)); + dfc->dfc_capture_ip = capture_ip; + } + return dfc; } @@ -606,24 +620,33 @@ xfs_defer_ops_release( struct xfs_defer_capture *dfc) { xfs_defer_cancel_list(mp, &dfc->dfc_dfops); + if (dfc->dfc_capture_ip) + xfs_irele(dfc->dfc_capture_ip); kmem_free(dfc); } /* * Capture any deferred ops and commit the transaction. This is the last step - * needed to finish a log intent item that we recovered from the log. + * needed to finish a log intent item that we recovered from the log. If any + * of the deferred ops operate on an inode, the caller must pass in that inode + * so that the reference can be transferred to the capture structure. The + * caller must hold ILOCK_EXCL on the inode, and must unlock it before calling + * xfs_defer_ops_continue. */ int xfs_defer_ops_capture_and_commit( struct xfs_trans *tp, + struct xfs_inode *capture_ip, struct list_head *capture_list) { struct xfs_mount *mp = tp->t_mountp; struct xfs_defer_capture *dfc; int error; + ASSERT(!capture_ip || xfs_isilocked(capture_ip, XFS_ILOCK_EXCL)); + /* If we don't capture anything, commit transaction and exit. */ - dfc = xfs_defer_ops_capture(tp); + dfc = xfs_defer_ops_capture(tp, capture_ip); if (!dfc) return xfs_trans_commit(tp); @@ -640,16 +663,26 @@ xfs_defer_ops_capture_and_commit( /* * Attach a chain of captured deferred ops to a new transaction and free the - * capture structure. + * capture structure. If an inode was captured, it will be passed back to the + * caller with ILOCK_EXCL held and joined to the transaction with lockflags==0. + * The caller now owns the inode reference. */ void xfs_defer_ops_continue( struct xfs_defer_capture *dfc, - struct xfs_trans *tp) + struct xfs_trans *tp, + struct xfs_inode **captured_ipp) { ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); + /* Lock and join the captured inode to the new transaction. */ + if (dfc->dfc_capture_ip) { + xfs_ilock(dfc->dfc_capture_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dfc->dfc_capture_ip, 0); + } + *captured_ipp = dfc->dfc_capture_ip; + /* Move captured dfops chain and state to the transaction. */ list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); tp->t_flags |= dfc->dfc_tpflags; diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index d5b7494513e8..4c3248d47a35 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -80,6 +80,12 @@ struct xfs_defer_capture { /* Log reservation saved from the transaction. */ unsigned int dfc_logres; + + /* + * An inode reference that must be maintained to complete the deferred + * work. + */ + struct xfs_inode *dfc_capture_ip; }; /* @@ -87,8 +93,9 @@ struct xfs_defer_capture { * This doesn't normally happen except log recovery. */ int xfs_defer_ops_capture_and_commit(struct xfs_trans *tp, - struct list_head *capture_list); -void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp); + struct xfs_inode *capture_ip, struct list_head *capture_list); +void xfs_defer_ops_continue(struct xfs_defer_capture *d, struct xfs_trans *tp, + struct xfs_inode **captured_ipp); void xfs_defer_ops_release(struct xfs_mount *mp, struct xfs_defer_capture *d); #endif /* __XFS_DEFER_H__ */ diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index f7015eabfdc9..888449ac8b75 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -528,8 +528,11 @@ xfs_bui_recover( } set_bit(XFS_BUI_RECOVERED, &buip->bui_flags); - /* Commit transaction, which frees the transaction. */ - error = xfs_defer_ops_capture_and_commit(tp, capture_list); + /* + * Commit transaction, which frees the transaction and saves the inode + * for later replay activities. + */ + error = xfs_defer_ops_capture_and_commit(tp, ip, capture_list); if (error) goto err_unlock; diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 2db85c2c6d99..0333b20afafd 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -639,7 +639,7 @@ xfs_efi_recover( set_bit(XFS_EFI_RECOVERED, &efip->efi_flags); - return xfs_defer_ops_capture_and_commit(tp, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); abort_error: xfs_trans_cancel(tp); diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 1e6ef00b833a..6c60cdd10d33 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4766,6 +4766,7 @@ xlog_finish_defer_ops( { struct xfs_defer_capture *dfc, *next; struct xfs_trans *tp; + struct xfs_inode *ip; int error = 0; list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { @@ -4791,9 +4792,13 @@ xlog_finish_defer_ops( * from recovering a single intent item. */ list_del_init(&dfc->dfc_list); - xfs_defer_ops_continue(dfc, tp); + xfs_defer_ops_continue(dfc, tp, &ip); error = xfs_trans_commit(tp); + if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_irele(ip); + } if (error) return error; } diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index c071f8600e8e..98f67dd64ce8 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -569,7 +569,7 @@ xfs_cui_recover( xfs_refcount_finish_one_cleanup(tp, rcur, error); set_bit(XFS_CUI_RECOVERED, &cuip->cui_flags); - return xfs_defer_ops_capture_and_commit(tp, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); abort_error: xfs_refcount_finish_one_cleanup(tp, rcur, error); diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 5bdf1f5e51b8..32f580fa1877 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -593,7 +593,7 @@ xfs_rui_recover( xfs_rmap_finish_one_cleanup(tp, rcur, error); set_bit(XFS_RUI_RECOVERED, &ruip->rui_flags); - return xfs_defer_ops_capture_and_commit(tp, capture_list); + return xfs_defer_ops_capture_and_commit(tp, NULL, capture_list); abort_error: xfs_rmap_finish_one_cleanup(tp, rcur, error); From patchwork Mon Feb 13 04:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0604C636D7 for ; Mon, 13 Feb 2023 04:07:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjBMEHP (ORCPT ); Sun, 12 Feb 2023 23:07:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjBMEHO (ORCPT ); Sun, 12 Feb 2023 23:07:14 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50D97EC57 for ; Sun, 12 Feb 2023 20:07:12 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1ipdM026534; Mon, 13 Feb 2023 04:07:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=JfYCvhRw5M7kfNVVfhxoZ3n3xeLGPVu/dk6zQd3jrEE=; b=qt1K4mMYO9w+TZyL/iiQ9V/qWyzwOgs4THddLKnuQgRFUImL3Mw4ztGB4gVghwyxWbla 1rtcSaQDhUUKRAuBsi+2n0OODFRP92FTZh3kujfAgcsmJPROJmYHMIeu37UNfTGF74L0 6OyeBGDEWH7eJTTYacbo+FyMNM0u5KaOMHdkVMZ1WB9+9B90k0eGf5V+MnTLSct8CGa2 7wqZMw80Sp0jU26qqxFRBaXJj5dDJfL2D0JpUvN3nXO1/2Z/+EMXlOLd7eDE7XjufrQg e6p3IJTX7rVKQi/njgOHO25PVbmT3V1yKJz6iSrnScYNkRwGfdHu7hZJERklBOUDc72E Hg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1ed9w2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:08 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D2UNRX011581; Mon, 13 Feb 2023 04:07:08 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k1by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+gtmyOiLfyY5VgbL2wg6/bOkxCJ9u88Iqxq/eT2ydaSGedEaQM6ATObooDAepviS1uEIWWVBdEy4dGJ0vkMNTC3bOj5NXTaXP1VrRCjGLvRzBkQ+kiEyPfUQu5XDam6ljCPl0wFY+btlOgoUegefpmrp0/AXIsGEjHtrGrZiQiK+gPg0aOgWhMiwaOjkN3gHYfHAZWrQZzE06XHS2krnoVtmI771JtTTFzPcgOrct2j6lU725QXYOSZxxxGaT9pISXPyld8Mt1mjBf8bgFqCieBUWoqaZDRTubTivk8d21sHW01HLfGLNyAZbGtw2kklVZCWACzsGaEc3Vd0pltpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JfYCvhRw5M7kfNVVfhxoZ3n3xeLGPVu/dk6zQd3jrEE=; b=MCenpDbgvYcuevGvNFK6N5j9MLIWX8LoRMkwmVKTrB0IQk+Yy5v2coczyRpfHAkpBdY106k4pVU5xJvtq5kOnTef2zwf3NTWQYmK10y5i5BVyZnV+j7HxgafNJgoxE5jVoXCzr8JYhvh+yNJFm7sdd27h8SoO9Igydpbgqla/gWHhz/x3wNfJLnNnExYtKkHV2MqetxUAPS92aod2zmr6HWUYd5o/2fTtVBjv9g8s7Bg56BuSmO10/lWl12SG9fwudJAJbHWSLZX0lMA3X00ctyCYpabvkwGt3nit/NaLoF/Uyg4OjJkwbGw+9gS4u8jMqpVGd40XrEIqMBi2jKufw== 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=JfYCvhRw5M7kfNVVfhxoZ3n3xeLGPVu/dk6zQd3jrEE=; b=lcf40b6Qgtl66Gx0aWKBiOagBK1CNuU/Z4m/rkq/wxGHtEXpJ2rsPbnheOgYdPqdgwfdHuAt2J1h/jiS+ZusaxD9+YbqDnsGYqeFaYXKcVWfSqj/cg056xI5MXnecnIj8H1Lglb8VVLDFEBY269r/Z+rUThc3jIPU7AvKLXG7gM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:07:06 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:07:06 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 17/25] xfs: change the order in which child and parent defer ops are finished Date: Mon, 13 Feb 2023 09:34:37 +0530 Message-Id: <20230213040445.192946-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0006.apcprd01.prod.exchangelabs.com (2603:1096:4:191::14) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: fbbab0d6-9e8b-4614-3f68-08db0d77c536 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bFWfJWvA/25iEpghwHJx38nHQ06uNisaVAJgCMl3dsON/8fjQ0/gQ4ftMk5KRG6Cmm9EJcdXRBKz/q2WBJcFV7O6gRDfuBrKkQqOUMvwuIPNqtCm7rSleBSxbvxU2CX4Ak3hhI26BPnJS8gJytXTtkxGK6GYUUtv8esDHSQpcIcLgktqXazEno7bo64LNS0yG1ERrkCJAMH3dUyQsHG7expAv/l/xUo8X7v/3peK88iJwLqEXwyfjE2T1HeHadxZbxZCrTx1YAxeVA1XzPCi6aN/hgSn6PJ4aeVXGf0OTpWJtKCb5+Wbk6s9Cj2z1tQLUftmSIPT38O6XIx/T2oKZHoh7kxU9hAAe8lEYo4mHsojkbRKKi5NXlXbncACB6NXiPB2f0UyuWcsw89JRGq+vsUskazl+3NIglq5v3re2ZOQORnJlbz1DKXR23i3q23j03ygxVBqklb3eA1aZ9Zv4snUXETwaFj9Mv0/TLbCRhpka9m2R9GSriYpsuQagvbxiNGEKmf8usJ0Z/eyfP/aTBL+HUA5iXJTyshjDEqlSmgZBuqKphMKhgHgu9RPlY1Iu73OAn6LFpj+uO4GkHw+w1D2O1wds7wWbf+wTK2SZY3SHgjccnRhQ1e3yXvMP/BFOVPYCwvepVC1dq2oMN4R0A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(66574015)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ku3sqQpmdkPWqcLCcOXMORXcJixno2p+u8Ntgu7O4F76RGJebnv5shAG6f9tS75PuR6x5i86OFF2xMjBojl6DTjoajyjLGee273lMv8VpZ6pXIksSwSrr9YTcTP4QQDriTD4MRwnjYBjukZ1mHzuDM7PYwO4fy98yohw1pMQvXlQK064vgWv26qCww/E/xHm2pv+TAEWRquzzvmHYM9OWVCjHHzJNoNKzp2Iz/o0IZrs7u6bg9wIzPl9ABAO/jT1poBAc/1oYIdgN48dsZBNNiQ4pU/i3k42SVeR+MXLzesTdBNgxJ1iDRGh7wDXf8zdjF/eb4Nhrbr7Q/LW/kBmsn0seOPN9BfivgD2Idcikwl5QGLf3C/8PUt0ztXaewcF/pq2vSq2vMGYz9rR+sbWsruPz/NxZRnSKds8IhPRgKHYdaNyd8V1fzx00/BfWFsKU5sIhK0IYTT40uWnxDT3HMxOLPUxZMNohWhuItNnDert3yRYB2UVd+rk+H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/ZP65rMrtrnD7Oq7vG6muTc3i6S35bMrEwv4w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SLgNnrYHDQdPtr1vzUT+A8eyUpamE4X7dCpZJ9kbqFJuK/htPsnL+K5Tl+Kc8vYvmdRkYNrrsXkH9YoA6n+0eWj0c30dOyxMPP+OFrFQS2gwbfzyBYZK02vKgvkXqPN2JoiC0gZN4HQP+3F0bFy0J2AnP7QOs46cAVKZgG8pasP01eQnalnLlLB8R6As6LwfXkifX/+EuG6/5VhNcftsx7jvWQv6JXzqKypLUyoaIe9/Vp3SQjANMVKePg0v9+MVhhyVaolbTZfMf54QVRks5aRy3KrGHXWX4nIEQ6HxJTLNuvIq361vevl7iFQvGfkSuKu46BVkbSqGeyoVpvSubCFgmpYyjA+0mDRT0MLI6QhdSOfgQ6Y942guxVS1ddmcJbJ/vOjZ5ACESy8n8+XWSoiW/gM+jwr6irXnYDptTnvAJs5d0h1JbmYK7Y8Iykm5sprHcPv5qRDCJuoXghb1cORlnsn38JWkUl5LkpZNMPVR/AKeTP4W9lRhaHsd2jC2n3XW7z5N7IIkbL7e65yPNXZwlhTZ65MI5nmc+U6WFTcUrbW14lciV/IyJuzT1wqCH3bAtTYy9M3FOlrU6OP2Z6gfb5b7xuKYapLcJ6mAxv+kbrgC/mJbtd29bzNFSXYTryiObCtD5FGcHBEWLZde6yFqLuZF5fOthk9Dey0urLZ8bM9V5Lk7Ct77nOEEu0Tc00n/wM7gWl9Xl6au005nNO+KFvlst7piFznJMd0q+AlqABn70T6QzUceO1d/gbcIHVvlSL87pc10SHVhZ4fxNqyccmjw9zfJa5JUitZ8mGp8bBJpyHmo+josDiYaTnn0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbbab0d6-9e8b-4614-3f68-08db0d77c536 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:07:06.5399 (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: GP+2mFF7qUZPN087sabVaTrmAV3ba+NI3vzp27dD/RC9BTPXq1HLchZ/eMEu8+WKbhCh33UAME3yDPLUOqewKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: Zxg5O8_L_IeUHI5P2dJxHTfp3qHtJrgn X-Proofpoint-ORIG-GUID: Zxg5O8_L_IeUHI5P2dJxHTfp3qHtJrgn Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 27dada070d59c28a441f1907d2cec891b17dcb26 upstream. The defer ops code has been finishing items in the wrong order -- if a top level defer op creates items A and B, and finishing item A creates more defer ops A1 and A2, we'll put the new items on the end of the chain and process them in the order A B A1 A2. This is kind of weird, since it's convenient for programmers to be able to think of A and B as an ordered sequence where all the sub-tasks for A must finish before we move on to B, e.g. A A1 A2 D. Right now, our log intent items are not so complex that this matters, but this will become important for the atomic extent swapping patchset. In order to maintain correct reference counting of extents, we have to unmap and remap extents in that order, and we want to complete that work before moving on to the next range that the user wants to swap. This patch fixes defer ops to satsify that requirement. The primary symptom of the incorrect order was noticed in an early performance analysis of the atomic extent swap code. An astonishingly large number of deferred work items accumulated when userspace requested an atomic update of two very fragmented files. The cause of this was traced to the same ordering bug in the inner loop of xfs_defer_finish_noroll. If the ->finish_item method of a deferred operation queues new deferred operations, those new deferred ops are appended to the tail of the pending work list. To illustrate, say that a caller creates a transaction t0 with four deferred operations D0-D3. The first thing defer ops does is roll the transaction to t1, leaving us with: t1: D0(t0), D1(t0), D2(t0), D3(t0) Let's say that finishing each of D0-D3 will create two new deferred ops. After finish D0 and roll, we'll have the following chain: t2: D1(t0), D2(t0), D3(t0), d4(t1), d5(t1) d4 and d5 were logged to t1. Notice that while we're about to start work on D1, we haven't actually completed all the work implied by D0 being finished. So far we've been careful (or lucky) to structure the dfops callers such that D1 doesn't depend on d4 or d5 being finished, but this is a potential logic bomb. There's a second problem lurking. Let's see what happens as we finish D1-D3: t3: D2(t0), D3(t0), d4(t1), d5(t1), d6(t2), d7(t2) t4: D3(t0), d4(t1), d5(t1), d6(t2), d7(t2), d8(t3), d9(t3) t5: d4(t1), d5(t1), d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4) Let's say that d4-d11 are simple work items that don't queue any other operations, which means that we can complete each d4 and roll to t6: t6: d5(t1), d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4) t7: d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4) ... t11: d10(t4), d11(t4) t12: d11(t4) When we try to roll to transaction #12, we're holding defer op d11, which we logged way back in t4. This means that the tail of the log is pinned at t4. If the log is very small or there are a lot of other threads updating metadata, this means that we might have wrapped the log and cannot get roll to t11 because there isn't enough space left before we'd run into t4. Let's shift back to the original failure. I mentioned before that I discovered this flaw while developing the atomic file update code. In that scenario, we have a defer op (D0) that finds a range of file blocks to remap, creates a handful of new defer ops to do that, and then asks to be continued with however much work remains. So, D0 is the original swapext deferred op. The first thing defer ops does is rolls to t1: t1: D0(t0) We try to finish D0, logging d1 and d2 in the process, but can't get all the work done. We log a done item and a new intent item for the work that D0 still has to do, and roll to t2: t2: D0'(t1), d1(t1), d2(t1) We roll and try to finish D0', but still can't get all the work done, so we log a done item and a new intent item for it, requeue D0 a second time, and roll to t3: t3: D0''(t2), d1(t1), d2(t1), d3(t2), d4(t2) If it takes 48 more rolls to complete D0, then we'll finally dispense with D0 in t50: t50: D(t49), d1(t1), ..., d102(t50) We then try to roll again to get a chain like this: t51: d1(t1), d2(t1), ..., d101(t50), d102(t50) ... t152: d102(t50) Notice that in rolling to transaction #51, we're holding on to a log intent item for d1 that was logged in transaction #1. This means that the tail of the log is pinned at t1. If the log is very small or there are a lot of other threads updating metadata, this means that we might have wrapped the log and cannot roll to t51 because there isn't enough space left before we'd run into t1. This is of course problem #2 again. But notice the third problem with this scenario: we have 102 defer ops tied to this transaction! Each of these items are backed by pinned kernel memory, which means that we risk OOM if the chains get too long. Yikes. Problem #1 is a subtle logic bomb that could hit someone in the future; problem #2 applies (rarely) to the current upstream, and problem This is not how incremental deferred operations were supposed to work. The dfops design of logging in the same transaction an intent-done item and a new intent item for the work remaining was to make it so that we only have to juggle enough deferred work items to finish that one small piece of work. Deferred log item recovery will find that first unfinished work item and restart it, no matter how many other intent items might follow it in the log. Therefore, it's ok to put the new intents at the start of the dfops chain. For the first example, the chains look like this: t2: d4(t1), d5(t1), D1(t0), D2(t0), D3(t0) t3: d5(t1), D1(t0), D2(t0), D3(t0) ... t9: d9(t7), D3(t0) t10: D3(t0) t11: d10(t10), d11(t10) t12: d11(t10) For the second example, the chains look like this: t1: D0(t0) t2: d1(t1), d2(t1), D0'(t1) t3: d2(t1), D0'(t1) t4: D0'(t1) t5: d1(t4), d2(t4), D0''(t4) ... t148: D0<50 primes>(t147) t149: d101(t148), d102(t148) t150: d102(t148) This actually sucks more for pinning the log tail (we try to roll to t10 while holding an intent item that was logged in t1) but we've solved problem #1. We've also reduced the maximum chain length from: sum(all the new items) + nr_original_items to: max(new items that each original item creates) + nr_original_items This solves problem #3 by sharply reducing the number of defer ops that can be attached to a transaction at any given time. The change makes the problem of log tail pinning worse, but is improvement we need to solve problem #2. Actually solving #2, however, is left to the next patch. Note that a subsequent analysis of some hard-to-trigger reflink and COW livelocks on extremely fragmented filesystems (or systems running a lot of IO threads) showed the same symptoms -- uncomfortably large numbers of incore deferred work items and occasional stalls in the transaction grant code while waiting for log reservations. I think this patch and the next one will also solve these problems. As originally written, the code used list_splice_tail_init instead of list_splice_init, so change that, and leave a short comment explaining our actions. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 714756931317..c817b8924f9a 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -431,8 +431,17 @@ xfs_defer_finish_noroll( /* Until we run out of pending work to finish... */ while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) { + /* + * Deferred items that are created in the process of finishing + * other deferred work items should be queued at the head of + * the pending list, which puts them ahead of the deferred work + * that was created by the caller. This keeps the number of + * pending work items to a minimum, which decreases the amount + * of time that any one intent item can stick around in memory, + * pinning the log tail. + */ xfs_defer_create_intents(*tp); - list_splice_tail_init(&(*tp)->t_dfops, &dop_pending); + list_splice_init(&(*tp)->t_dfops, &dop_pending); error = xfs_defer_trans_roll(tp); if (error) From patchwork Mon Feb 13 04:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B589C636CC for ; Mon, 13 Feb 2023 04:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbjBMEHZ (ORCPT ); Sun, 12 Feb 2023 23:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjBMEHY (ORCPT ); Sun, 12 Feb 2023 23:07:24 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A93B3EC58 for ; Sun, 12 Feb 2023 20:07:21 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iPAJ012119; Mon, 13 Feb 2023 04:07:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=0zBZ6uOY6n7+yAPcdjOtUIqvNSNqoH3VZIRIGBp137Q=; b=npBbvTnotjOZ2c0VBW5a9VviMTV/sr1pRGb6xfLaRWsEzffVRUmqp4JkoeVf+LESZoMB mbWO/Q0kIYcP3EX/ntB3b0A1jw0WCoacBpb+eCLF1Nf2eSaa5WLTW3+dPf7J+HNFldYV 2b86R+RujvXsRApQOH3wQ10710YKKQ2Xtym7sk6oq2tiOBDlArzeiE/m2fiyV92sVHWt b3RM/gVTnjPM0wHu6SwcKyr7xYIxfNJsH85tX8UU4RgRd0798dknDRCDp58/CHWxUQdU u+xtOeMf13ppIrfQCXjIj8Ng8hR62nEsbWaaZCgsE3QtYRkN3Q+eX84Txj1Fz8EZ4TfT hg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:17 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D38RIB028887; Mon, 13 Feb 2023 04:07:16 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3aaag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V39Oqxt9iPKW0D3re/t0BAmU8vXA2XQpwEvv0eLrmOc1KcG1gHeXljc3qsQ8pI6+AtKA+zdoc1mE7qJFlJIdahyPPQ/UyKUCWvDObwtLjgiJZNoXpix8UBk2Os2qkxnCCQZCElNzwIXL0gO343ccTD394WTivo8xRlWc4zcH6jPsacwdAvcven0RopYQojdWkoDviyQwoiMQoDwqfucpSTYv/9ZU81y/sEL0dVivEtKEIxBrYbpCl9V/nHKbpb1KotG5iitftRyqZMBSeLMRXxATchwipbZ2w/E1OGqYq1WrTkHTUZsCJlF/YEm6vMI2uPROIvIPYko24/XF6Wiq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0zBZ6uOY6n7+yAPcdjOtUIqvNSNqoH3VZIRIGBp137Q=; b=UiBWJG+FWDkQIgBpmAT9hQHaIR003KQvFG1z61B9Wz+LL2Lcn+527XyIZDEludO0mU1uK7wYh0AkethYi9qbTlOj+RyTj/hTg6i1XNwRi72M7I+5owau6Q3I9WBsAcDPuVedokQnH6nnfBGLqzWMQkNOl5mrj3xR7dJ8dUWTAaRucZ19ZaLbRXBk6/vV5Us0Ge5VNQTVLsdgaHvteUnQBDRmgjCMEABQbBPKFsxnMyegVTL6PM9EatDzBw61DEiIZst5xBa9DhlgwddoUW+JzZKt93UBOH7sYcTmVG1hHHC2dZEybE0sryjtXq0Dbr1FQdNWgsi7moFw1FF74j5Fpg== 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=0zBZ6uOY6n7+yAPcdjOtUIqvNSNqoH3VZIRIGBp137Q=; b=nyoih0H8G8P7v0cmgLhrYOT8dj2jm4siEG8ABP0/d4VZLOgvDIFtjnLxQ5KbnMkN1VFd8BkzONCvi5Qnrw+PXxiqnxek0yGAA18Ix5bkXDRqVrg37yNheNNtbT6OxwKlNiZmgPN0qkhS+LBN9o7AzNL8DCx6CqC4eujU9eoz5Ao= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:07:14 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:07:13 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 18/25] xfs: periodically relog deferred intent items Date: Mon, 13 Feb 2023 09:34:38 +0530 Message-Id: <20230213040445.192946-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0003.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::20) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 3da945cc-155b-4259-cfdb-08db0d77c983 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LusEPWysLd+rQdWw6jDWbwVhD1ShxFmkROuSsWpJxMKS+jE9LBJWcph4TCI1tHGIhbEkd2OXEAyZBoGSxSrDclHWZoQPAUw5GKcDL0yBF4mHMRfLnJUtG5yFOPFV5hRSi/4kF15cZLrIuUue/T99KNJ6FuD14qStElhM7ORGxE9UxZonfZ5FYSAqAXVxP4T0yI1HvjixsEL2KQ1EHA/pkujq9n8lw3P00Z1wh7HGuKfWbmjrTRss1jXZ9w78M7SHHx52YguYg/G/BHZqmnO8hWrhvHBrE8FkO09bQAPOaxkEbhyf9D8SY84YIZ5yoqjAYAzs5rzFPdkciYy284AKEuAJ472BuGXKGaq3Nobt6JroCUixAJaxyGrspqfyH5eQoNTR9jizMoT7jVYLYOC6wCmyqBQ8AIHpEu1HDH1XQHlVIQAkA5Liq+OZNNJslbHLfVzJfqJq41rQDoX9J4myrgSBsBfk9yWhFWV/rQ9UY/3D7SNivNz66rF+ZMuQxK1IscdS4mszn6mYBEpxyeVOICFNhmBAxS+J74uOyG6ap+0WHODVDZC2IlcWOtj937fQA7odVbefR+UVAF6aa53SX7d0v8rS808sog4nbUAce+ArtWDggaYEO4HzAVwEaMpMHd5AJuCQguWJNrxoyuphyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(30864003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u9GvW0bI2MEW0uqqS1Sur+yW96qUWU6UcqsY3/Zt+4AQC7qlc6gilOs3ZVmRabThpmv98ZBLLTbuvsn466qDDZxD+A9LzPJyI5F2ULsfKz7xAKnT4vcah21E39k04y+keCq1toma96OZVz/3MPEhgagh0E0gTSk4ZrudqBSCH4slS5jf9BIS5Y/eIFKJnISUaJPr+TaCyb6aY7jwKcoBLhq29vMymdD1YPOhrKflXZ0siGUsB/f06kW4Saz4mZ5THj1fwJLzyKhB+hOBBoEtr5R5xAQpaUT4al7G0v8mrua6jgpwY9kftuHWTb3Fq/TCUXexiznerwujuQdOCSKICYPZDn00rzQBCdlJDsyMu+cbPd4J2cU2Fs1x7CDJVNqbJplbmYkvAQAYqo1e3VGKPzQHK8J9cmZOCSxmQbFILzQL1v1s4rWdpWIQkaYLbvXfvWU4RDJmFLdYH9hTrvWDk0jdw3yP4fI2p3ETlIW3iYCvIZjtX9nxmFn2ZpzIIn65lMlAxTn9WlIApd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OZYWgeA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ll0QmXbgMU5PhkFQDcJIS6JzJr6nMPknM8CCrtPSDSVyONP71K9SV68Nz38HnZQOPCD4OxVNX9okGge2/FsRhb3BFXEriLIJFULZd8nn8eo1G8jp0HDI+e2+OYL36LWL1/8AW4swiEuWXHc+SYutneXdB3JxFK4qG1arU170yMbJqpcNQm5Y04SRoFyEbSIiSYKWhc3gxD/zUe8iCQ1dRhFKhJY4CnhjPkriY0iyf2GR3HIdB8FORT0X4gtXWZwFBZo/Au0LzcKMjZlyE/q3QmI82J73oTRFKTtw/3mtxyi5w8QHBgTbzxUzop0fKT8X3A04ZsvzU8hAeetsTeSvnNmQCK9qopr6naklZhArNftiiYScvV44KBzePbZyBija9I1QLpxhlcWebh1tJ1L2w6vBT3s8mbq1V4NSip9jmPnxExQ/NSkPCdpq64z43A2oH4312K6t9+tEWVTlOjSuTilEzBzI53K4mTtq5xTwZy/DXdV30zrD8hKuFbjUnrUBuY/yVJx7mZCiXFAW0KbG2vAEJ0wBqyUt0uwIngTe0uDPFMy1OEMcwRVSYCN/qYp+6OELCVuaVC7poXw7nJ9H6UMNT5Ndnzc2gTrHyKUKjDiyxsliTUOGPJfbMXSPANtL0L1oMoRnb6BOsuAhVNAuczRLOKEWkFQebEEzTcInKJnUtxIU7Y4wkIeLXDMoLsIa3vHF0pa4lNHjz9DEtozTLhFnVlGK3S5dP3esnHEXovaXpN2C7SrUusAoaHdoYh7Gscz3uPGfENWKS7LRW9x7a3q1ZYJssPxYnY1mYzmbuRmYkmOusZOjK/0zPRWHiYRK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3da945cc-155b-4259-cfdb-08db0d77c983 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:07:13.8997 (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: D8QLgNDy9xL5lvuuSqnc3cEHDCkmD767xWpVZW9cxq3JvUYrAbbza7ufcPnEr7/aSqil0XLQWjplamQ4YOxFLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: VMXpaXPdtg1tEQTNH51JB6Z7pfh_35U5 X-Proofpoint-ORIG-GUID: VMXpaXPdtg1tEQTNH51JB6Z7pfh_35U5 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 4e919af7827a6adfc28e82cd6c4ffcfcc3dd6118 upstream. [ Modify xfs_{bmap|extfree|refcount|rmap}_item.c to fix merge conflicts ] There's a subtle design flaw in the deferred log item code that can lead to pinning the log tail. Taking up the defer ops chain examples from the previous commit, we can get trapped in sequences like this: Caller hands us a transaction t0 with D0-D3 attached. The defer ops chain will look like the following if the transaction rolls succeed: t1: D0(t0), D1(t0), D2(t0), D3(t0) t2: d4(t1), d5(t1), D1(t0), D2(t0), D3(t0) t3: d5(t1), D1(t0), D2(t0), D3(t0) ... t9: d9(t7), D3(t0) t10: D3(t0) t11: d10(t10), d11(t10) t12: d11(t10) In transaction 9, we finish d9 and try to roll to t10 while holding onto an intent item for D3 that we logged in t0. The previous commit changed the order in which we place new defer ops in the defer ops processing chain to reduce the maximum chain length. Now make xfs_defer_finish_noroll capable of relogging the entire chain periodically so that we can always move the log tail forward. Most chains will never get relogged, except for operations that generate very long chains (large extents containing many blocks with different sharing levels) or are on filesystems with small logs and a lot of ongoing metadata updates. Callers are now required to ensure that the transaction reservation is large enough to handle logging done items and new intent items for the maximum possible chain length. Most callers are careful to keep the chain lengths low, so the overhead should be minimal. The decision to relog an intent item is made based on whether the intent was logged in a previous checkpoint, since there's no point in relogging an intent into the same checkpoint. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 42 +++++++++++++++ fs/xfs/xfs_bmap_item.c | 83 +++++++++++++++++++---------- fs/xfs/xfs_extfree_item.c | 104 +++++++++++++++++++++++-------------- fs/xfs/xfs_refcount_item.c | 95 +++++++++++++++++++++------------ fs/xfs/xfs_rmap_item.c | 93 +++++++++++++++++++++------------ fs/xfs/xfs_stats.c | 4 ++ fs/xfs/xfs_stats.h | 1 + fs/xfs/xfs_trace.h | 1 + fs/xfs/xfs_trans.h | 10 ++++ 9 files changed, 300 insertions(+), 133 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index c817b8924f9a..b0b382323413 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -17,6 +17,7 @@ #include "xfs_inode_item.h" #include "xfs_trace.h" #include "xfs_icache.h" +#include "xfs_log.h" /* * Deferred Operations in XFS @@ -361,6 +362,42 @@ xfs_defer_cancel_list( } } +/* + * Prevent a log intent item from pinning the tail of the log by logging a + * done item to release the intent item; and then log a new intent item. + * The caller should provide a fresh transaction and roll it after we're done. + */ +static int +xfs_defer_relog( + struct xfs_trans **tpp, + struct list_head *dfops) +{ + struct xfs_defer_pending *dfp; + + ASSERT((*tpp)->t_flags & XFS_TRANS_PERM_LOG_RES); + + list_for_each_entry(dfp, dfops, dfp_list) { + /* + * If the log intent item for this deferred op is not a part of + * the current log checkpoint, relog the intent item to keep + * the log tail moving forward. We're ok with this being racy + * because an incorrect decision means we'll be a little slower + * at pushing the tail. + */ + if (dfp->dfp_intent == NULL || + xfs_log_item_in_current_chkpt(dfp->dfp_intent)) + continue; + + trace_xfs_defer_relog_intent((*tpp)->t_mountp, dfp); + XFS_STATS_INC((*tpp)->t_mountp, defer_relog); + dfp->dfp_intent = xfs_trans_item_relog(dfp->dfp_intent, *tpp); + } + + if ((*tpp)->t_flags & XFS_TRANS_DIRTY) + return xfs_defer_trans_roll(tpp); + return 0; +} + /* * Log an intent-done item for the first pending intent, and finish the work * items. @@ -447,6 +484,11 @@ xfs_defer_finish_noroll( if (error) goto out_shutdown; + /* Possibly relog intent items to keep the log moving. */ + error = xfs_defer_relog(tp, &dop_pending); + if (error) + goto out_shutdown; + dfp = list_first_entry(&dop_pending, struct xfs_defer_pending, dfp_list); error = xfs_defer_finish_one(*tp, dfp); diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 888449ac8b75..7b0c4d9679d9 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -125,34 +125,6 @@ xfs_bui_item_release( xfs_bui_release(BUI_ITEM(lip)); } -static const struct xfs_item_ops xfs_bui_item_ops = { - .iop_size = xfs_bui_item_size, - .iop_format = xfs_bui_item_format, - .iop_unpin = xfs_bui_item_unpin, - .iop_release = xfs_bui_item_release, -}; - -/* - * Allocate and initialize an bui item with the given number of extents. - */ -struct xfs_bui_log_item * -xfs_bui_init( - struct xfs_mount *mp) - -{ - struct xfs_bui_log_item *buip; - - buip = kmem_zone_zalloc(xfs_bui_zone, 0); - - xfs_log_item_init(mp, &buip->bui_item, XFS_LI_BUI, &xfs_bui_item_ops); - buip->bui_format.bui_nextents = XFS_BUI_MAX_FAST_EXTENTS; - buip->bui_format.bui_id = (uintptr_t)(void *)buip; - atomic_set(&buip->bui_next_extent, 0); - atomic_set(&buip->bui_refcount, 2); - - return buip; -} - static inline struct xfs_bud_log_item *BUD_ITEM(struct xfs_log_item *lip) { return container_of(lip, struct xfs_bud_log_item, bud_item); @@ -548,3 +520,58 @@ xfs_bui_recover( xfs_irele(ip); return error; } + +/* Relog an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_bui_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_bud_log_item *budp; + struct xfs_bui_log_item *buip; + struct xfs_map_extent *extp; + unsigned int count; + + count = BUI_ITEM(intent)->bui_format.bui_nextents; + extp = BUI_ITEM(intent)->bui_format.bui_extents; + + tp->t_flags |= XFS_TRANS_DIRTY; + budp = xfs_trans_get_bud(tp, BUI_ITEM(intent)); + set_bit(XFS_LI_DIRTY, &budp->bud_item.li_flags); + + buip = xfs_bui_init(tp->t_mountp); + memcpy(buip->bui_format.bui_extents, extp, count * sizeof(*extp)); + atomic_set(&buip->bui_next_extent, count); + xfs_trans_add_item(tp, &buip->bui_item); + set_bit(XFS_LI_DIRTY, &buip->bui_item.li_flags); + return &buip->bui_item; +} + +static const struct xfs_item_ops xfs_bui_item_ops = { + .iop_size = xfs_bui_item_size, + .iop_format = xfs_bui_item_format, + .iop_unpin = xfs_bui_item_unpin, + .iop_release = xfs_bui_item_release, + .iop_relog = xfs_bui_item_relog, +}; + +/* + * Allocate and initialize an bui item with the given number of extents. + */ +struct xfs_bui_log_item * +xfs_bui_init( + struct xfs_mount *mp) + +{ + struct xfs_bui_log_item *buip; + + buip = kmem_zone_zalloc(xfs_bui_zone, 0); + + xfs_log_item_init(mp, &buip->bui_item, XFS_LI_BUI, &xfs_bui_item_ops); + buip->bui_format.bui_nextents = XFS_BUI_MAX_FAST_EXTENTS; + buip->bui_format.bui_id = (uintptr_t)(void *)buip; + atomic_set(&buip->bui_next_extent, 0); + atomic_set(&buip->bui_refcount, 2); + + return buip; +} diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 0333b20afafd..de3cdce892fd 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -139,44 +139,6 @@ xfs_efi_item_release( xfs_efi_release(EFI_ITEM(lip)); } -static const struct xfs_item_ops xfs_efi_item_ops = { - .iop_size = xfs_efi_item_size, - .iop_format = xfs_efi_item_format, - .iop_unpin = xfs_efi_item_unpin, - .iop_release = xfs_efi_item_release, -}; - - -/* - * Allocate and initialize an efi item with the given number of extents. - */ -struct xfs_efi_log_item * -xfs_efi_init( - struct xfs_mount *mp, - uint nextents) - -{ - struct xfs_efi_log_item *efip; - uint size; - - ASSERT(nextents > 0); - if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { - size = (uint)(sizeof(struct xfs_efi_log_item) + - ((nextents - 1) * sizeof(xfs_extent_t))); - efip = kmem_zalloc(size, 0); - } else { - efip = kmem_zone_zalloc(xfs_efi_zone, 0); - } - - xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); - efip->efi_format.efi_nextents = nextents; - efip->efi_format.efi_id = (uintptr_t)(void *)efip; - atomic_set(&efip->efi_next_extent, 0); - atomic_set(&efip->efi_refcount, 2); - - return efip; -} - /* * Copy an EFI format buffer from the given buf, and into the destination * EFI format structure. @@ -645,3 +607,69 @@ xfs_efi_recover( xfs_trans_cancel(tp); return error; } + +/* Relog an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_efi_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_efd_log_item *efdp; + struct xfs_efi_log_item *efip; + struct xfs_extent *extp; + unsigned int count; + + count = EFI_ITEM(intent)->efi_format.efi_nextents; + extp = EFI_ITEM(intent)->efi_format.efi_extents; + + tp->t_flags |= XFS_TRANS_DIRTY; + efdp = xfs_trans_get_efd(tp, EFI_ITEM(intent), count); + efdp->efd_next_extent = count; + memcpy(efdp->efd_format.efd_extents, extp, count * sizeof(*extp)); + set_bit(XFS_LI_DIRTY, &efdp->efd_item.li_flags); + + efip = xfs_efi_init(tp->t_mountp, count); + memcpy(efip->efi_format.efi_extents, extp, count * sizeof(*extp)); + atomic_set(&efip->efi_next_extent, count); + xfs_trans_add_item(tp, &efip->efi_item); + set_bit(XFS_LI_DIRTY, &efip->efi_item.li_flags); + return &efip->efi_item; +} + +static const struct xfs_item_ops xfs_efi_item_ops = { + .iop_size = xfs_efi_item_size, + .iop_format = xfs_efi_item_format, + .iop_unpin = xfs_efi_item_unpin, + .iop_release = xfs_efi_item_release, + .iop_relog = xfs_efi_item_relog, +}; + +/* + * Allocate and initialize an efi item with the given number of extents. + */ +struct xfs_efi_log_item * +xfs_efi_init( + struct xfs_mount *mp, + uint nextents) + +{ + struct xfs_efi_log_item *efip; + uint size; + + ASSERT(nextents > 0); + if (nextents > XFS_EFI_MAX_FAST_EXTENTS) { + size = (uint)(sizeof(struct xfs_efi_log_item) + + ((nextents - 1) * sizeof(xfs_extent_t))); + efip = kmem_zalloc(size, 0); + } else { + efip = kmem_zone_zalloc(xfs_efi_zone, 0); + } + + xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops); + efip->efi_format.efi_nextents = nextents; + efip->efi_format.efi_id = (uintptr_t)(void *)efip; + atomic_set(&efip->efi_next_extent, 0); + atomic_set(&efip->efi_refcount, 2); + + return efip; +} diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 98f67dd64ce8..fa1018a6e677 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -123,40 +123,6 @@ xfs_cui_item_release( xfs_cui_release(CUI_ITEM(lip)); } -static const struct xfs_item_ops xfs_cui_item_ops = { - .iop_size = xfs_cui_item_size, - .iop_format = xfs_cui_item_format, - .iop_unpin = xfs_cui_item_unpin, - .iop_release = xfs_cui_item_release, -}; - -/* - * Allocate and initialize an cui item with the given number of extents. - */ -struct xfs_cui_log_item * -xfs_cui_init( - struct xfs_mount *mp, - uint nextents) - -{ - struct xfs_cui_log_item *cuip; - - ASSERT(nextents > 0); - if (nextents > XFS_CUI_MAX_FAST_EXTENTS) - cuip = kmem_zalloc(xfs_cui_log_item_sizeof(nextents), - 0); - else - cuip = kmem_zone_zalloc(xfs_cui_zone, 0); - - xfs_log_item_init(mp, &cuip->cui_item, XFS_LI_CUI, &xfs_cui_item_ops); - cuip->cui_format.cui_nextents = nextents; - cuip->cui_format.cui_id = (uintptr_t)(void *)cuip; - atomic_set(&cuip->cui_next_extent, 0); - atomic_set(&cuip->cui_refcount, 2); - - return cuip; -} - static inline struct xfs_cud_log_item *CUD_ITEM(struct xfs_log_item *lip) { return container_of(lip, struct xfs_cud_log_item, cud_item); @@ -576,3 +542,64 @@ xfs_cui_recover( xfs_trans_cancel(tp); return error; } + +/* Relog an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_cui_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_cud_log_item *cudp; + struct xfs_cui_log_item *cuip; + struct xfs_phys_extent *extp; + unsigned int count; + + count = CUI_ITEM(intent)->cui_format.cui_nextents; + extp = CUI_ITEM(intent)->cui_format.cui_extents; + + tp->t_flags |= XFS_TRANS_DIRTY; + cudp = xfs_trans_get_cud(tp, CUI_ITEM(intent)); + set_bit(XFS_LI_DIRTY, &cudp->cud_item.li_flags); + + cuip = xfs_cui_init(tp->t_mountp, count); + memcpy(cuip->cui_format.cui_extents, extp, count * sizeof(*extp)); + atomic_set(&cuip->cui_next_extent, count); + xfs_trans_add_item(tp, &cuip->cui_item); + set_bit(XFS_LI_DIRTY, &cuip->cui_item.li_flags); + return &cuip->cui_item; +} + +static const struct xfs_item_ops xfs_cui_item_ops = { + .iop_size = xfs_cui_item_size, + .iop_format = xfs_cui_item_format, + .iop_unpin = xfs_cui_item_unpin, + .iop_release = xfs_cui_item_release, + .iop_relog = xfs_cui_item_relog, +}; + +/* + * Allocate and initialize an cui item with the given number of extents. + */ +struct xfs_cui_log_item * +xfs_cui_init( + struct xfs_mount *mp, + uint nextents) + +{ + struct xfs_cui_log_item *cuip; + + ASSERT(nextents > 0); + if (nextents > XFS_CUI_MAX_FAST_EXTENTS) + cuip = kmem_zalloc(xfs_cui_log_item_sizeof(nextents), + 0); + else + cuip = kmem_zone_zalloc(xfs_cui_zone, 0); + + xfs_log_item_init(mp, &cuip->cui_item, XFS_LI_CUI, &xfs_cui_item_ops); + cuip->cui_format.cui_nextents = nextents; + cuip->cui_format.cui_id = (uintptr_t)(void *)cuip; + atomic_set(&cuip->cui_next_extent, 0); + atomic_set(&cuip->cui_refcount, 2); + + return cuip; +} diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 32f580fa1877..ba1dbb6c4063 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -122,39 +122,6 @@ xfs_rui_item_release( xfs_rui_release(RUI_ITEM(lip)); } -static const struct xfs_item_ops xfs_rui_item_ops = { - .iop_size = xfs_rui_item_size, - .iop_format = xfs_rui_item_format, - .iop_unpin = xfs_rui_item_unpin, - .iop_release = xfs_rui_item_release, -}; - -/* - * Allocate and initialize an rui item with the given number of extents. - */ -struct xfs_rui_log_item * -xfs_rui_init( - struct xfs_mount *mp, - uint nextents) - -{ - struct xfs_rui_log_item *ruip; - - ASSERT(nextents > 0); - if (nextents > XFS_RUI_MAX_FAST_EXTENTS) - ruip = kmem_zalloc(xfs_rui_log_item_sizeof(nextents), 0); - else - ruip = kmem_zone_zalloc(xfs_rui_zone, 0); - - xfs_log_item_init(mp, &ruip->rui_item, XFS_LI_RUI, &xfs_rui_item_ops); - ruip->rui_format.rui_nextents = nextents; - ruip->rui_format.rui_id = (uintptr_t)(void *)ruip; - atomic_set(&ruip->rui_next_extent, 0); - atomic_set(&ruip->rui_refcount, 2); - - return ruip; -} - /* * Copy an RUI format buffer from the given buf, and into the destination * RUI format structure. The RUI/RUD items were designed not to need any @@ -600,3 +567,63 @@ xfs_rui_recover( xfs_trans_cancel(tp); return error; } + +/* Relog an intent item to push the log tail forward. */ +static struct xfs_log_item * +xfs_rui_item_relog( + struct xfs_log_item *intent, + struct xfs_trans *tp) +{ + struct xfs_rud_log_item *rudp; + struct xfs_rui_log_item *ruip; + struct xfs_map_extent *extp; + unsigned int count; + + count = RUI_ITEM(intent)->rui_format.rui_nextents; + extp = RUI_ITEM(intent)->rui_format.rui_extents; + + tp->t_flags |= XFS_TRANS_DIRTY; + rudp = xfs_trans_get_rud(tp, RUI_ITEM(intent)); + set_bit(XFS_LI_DIRTY, &rudp->rud_item.li_flags); + + ruip = xfs_rui_init(tp->t_mountp, count); + memcpy(ruip->rui_format.rui_extents, extp, count * sizeof(*extp)); + atomic_set(&ruip->rui_next_extent, count); + xfs_trans_add_item(tp, &ruip->rui_item); + set_bit(XFS_LI_DIRTY, &ruip->rui_item.li_flags); + return &ruip->rui_item; +} + +static const struct xfs_item_ops xfs_rui_item_ops = { + .iop_size = xfs_rui_item_size, + .iop_format = xfs_rui_item_format, + .iop_unpin = xfs_rui_item_unpin, + .iop_release = xfs_rui_item_release, + .iop_relog = xfs_rui_item_relog, +}; + +/* + * Allocate and initialize an rui item with the given number of extents. + */ +struct xfs_rui_log_item * +xfs_rui_init( + struct xfs_mount *mp, + uint nextents) + +{ + struct xfs_rui_log_item *ruip; + + ASSERT(nextents > 0); + if (nextents > XFS_RUI_MAX_FAST_EXTENTS) + ruip = kmem_zalloc(xfs_rui_log_item_sizeof(nextents), 0); + else + ruip = kmem_zone_zalloc(xfs_rui_zone, 0); + + xfs_log_item_init(mp, &ruip->rui_item, XFS_LI_RUI, &xfs_rui_item_ops); + ruip->rui_format.rui_nextents = nextents; + ruip->rui_format.rui_id = (uintptr_t)(void *)ruip; + atomic_set(&ruip->rui_next_extent, 0); + atomic_set(&ruip->rui_refcount, 2); + + return ruip; +} diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c index f70f1255220b..20e0534a772c 100644 --- a/fs/xfs/xfs_stats.c +++ b/fs/xfs/xfs_stats.c @@ -23,6 +23,7 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) uint64_t xs_xstrat_bytes = 0; uint64_t xs_write_bytes = 0; uint64_t xs_read_bytes = 0; + uint64_t defer_relog = 0; static const struct xstats_entry { char *desc; @@ -70,10 +71,13 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) xs_xstrat_bytes += per_cpu_ptr(stats, i)->s.xs_xstrat_bytes; xs_write_bytes += per_cpu_ptr(stats, i)->s.xs_write_bytes; xs_read_bytes += per_cpu_ptr(stats, i)->s.xs_read_bytes; + defer_relog += per_cpu_ptr(stats, i)->s.defer_relog; } len += scnprintf(buf + len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n", xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); + len += scnprintf(buf + len, PATH_MAX-len, "defer_relog %llu\n", + defer_relog); len += scnprintf(buf + len, PATH_MAX-len, "debug %u\n", #if defined(DEBUG) 1); diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h index 34d704f703d2..43ffba74f045 100644 --- a/fs/xfs/xfs_stats.h +++ b/fs/xfs/xfs_stats.h @@ -137,6 +137,7 @@ struct __xfsstats { uint64_t xs_xstrat_bytes; uint64_t xs_write_bytes; uint64_t xs_read_bytes; + uint64_t defer_relog; }; #define xfsstats_offset(f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t)) diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index f94908125e8f..4b5818395406 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -2418,6 +2418,7 @@ DEFINE_DEFER_PENDING_EVENT(xfs_defer_create_intent); DEFINE_DEFER_PENDING_EVENT(xfs_defer_cancel_list); DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_finish); DEFINE_DEFER_PENDING_EVENT(xfs_defer_pending_abort); +DEFINE_DEFER_PENDING_EVENT(xfs_defer_relog_intent); #define DEFINE_BMAP_FREE_DEFERRED_EVENT DEFINE_PHYS_EXTENT_DEFERRED_EVENT DEFINE_BMAP_FREE_DEFERRED_EVENT(xfs_bmap_free_defer); diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 64d7f171ebd3..941647027f00 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -77,6 +77,8 @@ struct xfs_item_ops { void (*iop_release)(struct xfs_log_item *); xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t); void (*iop_error)(struct xfs_log_item *, xfs_buf_t *); + struct xfs_log_item *(*iop_relog)(struct xfs_log_item *intent, + struct xfs_trans *tp); }; /* @@ -244,4 +246,12 @@ void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp, extern kmem_zone_t *xfs_trans_zone; +static inline struct xfs_log_item * +xfs_trans_item_relog( + struct xfs_log_item *lip, + struct xfs_trans *tp) +{ + return lip->li_ops->iop_relog(lip, tp); +} + #endif /* __XFS_TRANS_H__ */ From patchwork Mon Feb 13 04:04:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E00A7C636D7 for ; Mon, 13 Feb 2023 04:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjBMEHg (ORCPT ); Sun, 12 Feb 2023 23:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjBMEHd (ORCPT ); Sun, 12 Feb 2023 23:07:33 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C265AEC57 for ; Sun, 12 Feb 2023 20:07:32 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1il3J012223; Mon, 13 Feb 2023 04:07:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=WZqkiQMS4D2unAFlzPzEHGvAJc0a6AZwRJ8NGlKO1Tg=; b=W7uGwOUXqORST5kYcOQA1x9coVJWqGseE4Qud5vu0hZvpVvSOJfoezgS3B5D92Zx18Pg CE75ZYIxx4ihJGNESynszmCE3qYTFtuaGqNzYr/7j8E+3zqh+MOIHZSHiO3sgxtuAp7J +ElqfDWECSDXnMXujRe1auhYUhPFhNht3z+8g2PU2eaoyM8W+ncz9kSwAsb4RjQEwY1e TZE1sD78Y6vh6x8QdUiu26y2/TEMNAbnimWZOuA94ELt6KWIGqZDSv0XhUUw58KLzIEc DI6nhJshvSQWqYvlzSwUdDExBsiKvMXzAqS/0IXBgTxjpuWwyW0U8BLCsUvm2bPqlmlo tA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:26 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D40CEN028884; Mon, 13 Feb 2023 04:07:25 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3aabc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KB+GdbZmF+Y8wQfQqPXT6c4xERTXXa6AaREe8zeb/QWAmbZ7wBUWUjRyQVrYWVnyRPvMnrAgrgiUjoF+kVyspVhoenW5VBcCaOg1wAKvs0/dwhe5FZ81jIN/deEC+FZBHzsWSXJW7vg9Fl9uy89wyviTU2ZYZl5UeSPlUSXwu6DlmQNyCJ96oBi9qiSu/cBMQTZCvQZDHz8Irife6ucvGbF4mf2UuarpDku8BtZz/K4T0DBpIiyLDekAiz6URWu2fFKGtYz42gmgkezHdqzfgBSVVvb9gqmgGmq2u+CPCZpjNZgaeKA+3tdH4ETfK15NmFDjTvBEv+YyA0AZRAjjtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WZqkiQMS4D2unAFlzPzEHGvAJc0a6AZwRJ8NGlKO1Tg=; b=L20lJ7YkpW9HFeVM6qhUaFxGOKFYimHywyC73qLHxH/jOX2Bqa1M+TXVLeFtFJPZTcDLbMS8D0Eay8AxS28Hv3tM+gPvWtQssK+K82B/jIsC8RNQzoykXWizmoRjGdIdRd7luIuVZn07tp+rBjqJW8ZS465nM/371RQm0zjDZgYPOcQor+6kyuGVjVPM7jJNib/K9uOUxyyoHXyjG5OYVf27ZOBDY05naWIw4L+f4oM9863QRxOwm2u/kAkal5QfhJTYlGEIDQhJtJDmVXPVCkDMX/tqE8LspcYpcauKThsxPKXPWE8Lufg5ZLBJgbc/s52y2rGt33TI+0WMh+9oNw== 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=WZqkiQMS4D2unAFlzPzEHGvAJc0a6AZwRJ8NGlKO1Tg=; b=j/CYboU2kYgr/GD/3KHlePTQrvLQxqnPJItGBFScAsYZQMgM5hmn/cLsxQ0BodqvGq05Ww7wSUy1GZENw1d1T6/wf0GtMY/1SmhIUVGKQu5954eMw1+7z9/C4AM9zOcdwOJ/cXYGkMHx/t3U38gXQ1IkJLuUcvcP2suOkx1fMWg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:07:20 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:07:20 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 19/25] xfs: expose the log push threshold Date: Mon, 13 Feb 2023 09:34:39 +0530 Message-Id: <20230213040445.192946-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0009.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::7) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: 392da61e-f4d5-4edb-ea6e-08db0d77cda1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kpfSrKL3fecIugWXLXlqj/WI5S3OK+pYRAUN06pwAvuU+7347zrBK7lERDV+IS3WOsFZO25eddz4wrmco5i7vTib20IVpDkzreKOdyVayt1Lt+dOE8ViTGWnwOEHnOnexQt9qMVHBkfbS/ZzKsLQIgh5jF4/jPxiPS+hnGs3IL4BRTZMzZBPW8mqe7LazoAj+NTsIWSIXv43kDwyly4Ik4hSo7w5DRwUGOuuFfpSxMvDQkrSdYO4KS0z9LPq+VaaCP2VhyoHQr7kW1rrZOjVN4+s5YlJqsmeVI8v8ZzMnLzK4xZMvVskwncTqu6ZfEseFFErJ29N2TDSxSWz+Mb4MLWpkYYdlN5wjWgAHeKIARic+CycBX7F9g5Pb7pK7+eZqDTh1P7TJgmNztgqoWRCo5J/EIrqZ4n/ngvjx5RnJ0VE4af2+lYB5oH21+n0sGDKQ4L83o86qqEce7KMisJ1zscikPzJcSLgkBL7X4iLGhqhRtoF4yA4lDXEEU+x/H6hrzb8u1RNuSBfRy9cYm0IaEavKtHrWSybe4ZCrujt7Eck2nwAmQjdcNDCQVbU3nR2gL2jlVkRUaW648ZI6XUP22BT0Mmrw1wqlfOyA+Gq31kt0Zo5mZbKCW6VQ8g8adGSaHjUKrWG1g2wamyid5goXA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0QeMcMI8NvuvHFWyhNQAELn/G8t+lpECXZdF1oQpjrQlCZnZLs9syrLIyFpYeXDajDVJK81pjYGAT84zzTVn62iKutoYaM2oKhVuJSXux8enUoSfGhVZxkqgt2VbjOSFQGzcOQpzQBk/HoWy/djMi+XWJcxtEf9SW2r/e1O8z88An43RC5n2mnGRm5zwk8q8lpbJ0WZF8h/PdcSJzFgWVMZZHxXDD6lRnUs5pUpQ4lJBa7Z0b1WP/DugVUcdyhHFVBZYyOAbl6p7k5f8ljRZ3q2cwYrHElK28i/Jo160836UQi2JxgSBTOXr2Q0KFBoa0NNP/znskFz0HDVaAltG+iyXV/jabYG7G0IS9/fX91B/amvC5sNlrz9l+bAq0jOzP1OJZ4jg3QurQjZ91TckgdZVDOIJE1++ULFcA1FMtoav+F+keFdQc1YLlYHZz/btrh5Tc9jaaIWE4Jxu0myzmMZYnnHaP5v36sc09p6b3J7ZJyEZrgwiEBXFi9dGC6Lc38A1pBuIDKkoO2u97TCzD+SUvb9Xr9agm4mmzMKkkhBPtafGwTKQ0Vek7P3HKfU3X0EfEDtfkFzkOM/mYPCIRmff1TAXduNfgR6Qib8tfx5EdPx744VJy8zONx3Nxxyxd1WXUWWc1ZZOJxIdkomWgFCqQl+c73IsR3arZ8ZeEhXUqEPqwF7Qz1yErvgVzAb4WmCTQaVMHtMjRX/Lt8ZP755pwuz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bfo+mio5H6YaPPVpW+31gAu8iJM8fln0kNxryddeggosBVN1C0ck0zdlRL6daHUPYB24AcUmYz6eUMiRvfMYjz2QcjfD14dUvEboTjA5mhrCutVX+A8iZJ7QAfI8w1TzvxBIs/OVHKC2cOtlZn1+FLJpI+KDI8rEGKhZQ6rEzxBkzCBcGyUvfZLxOrCLL48P29DXg3Ii+mckspGYax5NSSrjxJsACClUsURFk+cnLzzRn2cq2dCzQhArqtMHvXJnAfLmjKwZbyL0HO67zk7apwZff1DC4X3xnA6LeumAvtSN6b3W9RtVCpjUKeLjQvJiioXF+LHe4U/mPf7NMdp2PgkLdV+BxBbG/fdJWy9syxZGqLnzeVAI1bFAHR1qB+I5V8yglkbkwEfIQ9DZpErecvlaABAOX+2z5BC/XU4SwS7LXEqqx6+QveEpT9BcS3roVFZlpN1mKMODrqvPZu7Cwj8u9XQvaJjYct2J2R5dwtJjiE9sCgn4rKNAdiY4Apxop6MhBhDGDMXzI6w43AqboheJc4C2JE+sf44R3p0CVCqOnSoPGkyszqVyReZ3MjZQQAAK+RQuLHoZANZQ403xcGWnA/tadEWL0RxvhfTL9zp81sL1lwent+G+eWJHggDbCriI3PkSG5s/Kq8OuXshLUMhqLbFBjMdbOhKCmkTvY25CxTrHwTiG4VXFSI6Ca+nQQ0O6WdPZiuBxtY4o2IZWHiwZxGzO4Fi X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 392da61e-f4d5-4edb-ea6e-08db0d77cda1 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:07:20.7454 (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: 8L7qa7mTwh32zrlhyz41jDLH7uhKYj/qwMfaZqCeWg6hAjEnhQ2Qf2wZm5tTulHa8Sg1CbLzrgZqoB9EjLsnig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-12_12,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130036 X-Proofpoint-GUID: 9Atrs8HzTQXwO-ronmbZ2ZOGsOFwVE7G X-Proofpoint-ORIG-GUID: 9Atrs8HzTQXwO-ronmbZ2ZOGsOFwVE7G Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit ed1575daf71e4e21d8ae735b6e687c95454aaa17 upstream. Separate the computation of the log push threshold and the push logic in xlog_grant_push_ail. This enables higher level code to determine (for example) that it is holding on to a logged intent item and the log is so busy that it is more than 75% full. In that case, it would be desirable to move the log item towards the head to release the tail, which we will cover in the next patch. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/xfs_icreate_item.c | 1 + fs/xfs/xfs_log.c | 40 +++++++++++++++++++++++++++++---------- fs/xfs/xfs_log.h | 2 ++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c index 3ebd1b7f49d8..7d940b289db5 100644 --- a/fs/xfs/xfs_icreate_item.c +++ b/fs/xfs/xfs_icreate_item.c @@ -10,6 +10,7 @@ #include "xfs_trans.h" #include "xfs_trans_priv.h" #include "xfs_icreate_item.h" +#include "xfs_log_priv.h" #include "xfs_log.h" kmem_zone_t *xfs_icreate_zone; /* inode create item zone */ diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 63c0f1e9d101..ebbf9b9c8504 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -1537,14 +1537,14 @@ xlog_commit_record( } /* - * Push on the buffer cache code if we ever use more than 75% of the on-disk - * log space. This code pushes on the lsn which would supposedly free up - * the 25% which we want to leave free. We may need to adopt a policy which - * pushes on an lsn which is further along in the log once we reach the high - * water mark. In this manner, we would be creating a low water mark. + * Compute the LSN that we'd need to push the log tail towards in order to have + * (a) enough on-disk log space to log the number of bytes specified, (b) at + * least 25% of the log space free, and (c) at least 256 blocks free. If the + * log free space already meets all three thresholds, this function returns + * NULLCOMMITLSN. */ -STATIC void -xlog_grant_push_ail( +xfs_lsn_t +xlog_grant_push_threshold( struct xlog *log, int need_bytes) { @@ -1570,7 +1570,7 @@ xlog_grant_push_ail( free_threshold = max(free_threshold, (log->l_logBBsize >> 2)); free_threshold = max(free_threshold, 256); if (free_blocks >= free_threshold) - return; + return NULLCOMMITLSN; xlog_crack_atomic_lsn(&log->l_tail_lsn, &threshold_cycle, &threshold_block); @@ -1590,13 +1590,33 @@ xlog_grant_push_ail( if (XFS_LSN_CMP(threshold_lsn, last_sync_lsn) > 0) threshold_lsn = last_sync_lsn; + return threshold_lsn; +} + +/* + * Push the tail of the log if we need to do so to maintain the free log space + * thresholds set out by xlog_grant_push_threshold. We may need to adopt a + * policy which pushes on an lsn which is further along in the log once we + * reach the high water mark. In this manner, we would be creating a low water + * mark. + */ +STATIC void +xlog_grant_push_ail( + struct xlog *log, + int need_bytes) +{ + xfs_lsn_t threshold_lsn; + + threshold_lsn = xlog_grant_push_threshold(log, need_bytes); + if (threshold_lsn == NULLCOMMITLSN || XLOG_FORCED_SHUTDOWN(log)) + return; + /* * Get the transaction layer to kick the dirty buffers out to * disk asynchronously. No point in trying to do this if * the filesystem is shutting down. */ - if (!XLOG_FORCED_SHUTDOWN(log)) - xfs_ail_push(log->l_ailp, threshold_lsn); + xfs_ail_push(log->l_ailp, threshold_lsn); } /* diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 84e06805160f..4ede2163beb2 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -146,4 +146,6 @@ void xfs_log_quiesce(struct xfs_mount *mp); bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t); bool xfs_log_in_recovery(struct xfs_mount *); +xfs_lsn_t xlog_grant_push_threshold(struct xlog *log, int need_bytes); + #endif /* __XFS_LOG_H__ */ From patchwork Mon Feb 13 04:04:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46F40C636D7 for ; Mon, 13 Feb 2023 04:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjBMEIA (ORCPT ); Sun, 12 Feb 2023 23:08:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjBMEH7 (ORCPT ); Sun, 12 Feb 2023 23:07:59 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3560B76A4 for ; Sun, 12 Feb 2023 20:07:58 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1i8Cj005947; Mon, 13 Feb 2023 04:07:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=+d2OEA5D8zzmQqTHndTXtQxQyBee+IWOB6KdQmz/buk=; b=VZQQT7+dwioyfds54HpZL+rybNUHu8yl3PXBUrgl71TjWsKIBnA0tghjUwUxPB4/2qaC 3n2XjQ8k2eyQVwF8NYb622Ec+TS4lhaPydA5ANlcXS4FWw6R2bnMSXIOSCVYhiM2Ci5z Qi3PqC2o40jnzYby6P0NFwVzcRp6icC7LDmX5Bt7Fw7rEJSlllc6O6pbpZtUBdiqf7xC Ps/07ix+waaW5Fx+S4q55Br1cApFeBfxglC3s6OwFpu/TGI3KR2T3KqJmikOPPpexoaH FEqI775MP8ZrWC2lu1+KJlXZnJxwVGCOgz114TaAPi0ypoj8eY9CFg3FR9AIo/uwGSo5 Qg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np2mt9udc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:54 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D38RIN028887; Mon, 13 Feb 2023 04:07:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3aajq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dz+huMCXj4xOXYjZh6I1EzDA+50RQ/8zYwnp9x9LVUbLU/XpoDPfMRdcOBIVtVfWTsIBZLMbB3gug6ZBMCsSnTSgKn9B6ezJcoAaeBu44/TEeJkDqlmvSNXmOgy0KLYFoPfjgJIdDakBoTjZBLBImEl/v3CCpsB8eFeTzUTeFiOrA1rV9dz5Kql1ny0CYyJv+QGcwe1Gj0plctSCtbYrRtsEVthsvp3Oqa9ihijjHkUl+V8Y8EoGbvAcT558lLM5lF0Rh2FWYMxQsS1YyTHggRsXEpmTL/71zgR3NfMP3CyRmez/o62bWSaWTdWEJosbkP5/SR6MyrKpn0gLbc5tUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+d2OEA5D8zzmQqTHndTXtQxQyBee+IWOB6KdQmz/buk=; b=LoxP4DRnJaEdvqD7uU51esKBkuvMhVHchBcbXkWtrRvQq4EBSh/jVmyvFWosw2AO51kAw5T1PBfCNauEnRQdCim66BR3EBgclXXCygDCJ1QfAnRMVaivtBU6U5XSvEwtjvb9V0sVDrso0AxalOxtBSYHOvGFP5+ot3PgefI50mP5COnMqVkYlXRyPdifNad/nL/2C8eDz/8MNbdHoX2Z9cyC1x2/HiTrE8zp/LRDSH412B4Iu2E4JDTrSzAmuoWB8mbUEXxfRmaKYsItEVnEo63MH683O6V042ggqxLotvyZrFrPsAd3n0cHd5QiiBY+FLbr+dbgE6PsDHj9mdKEPg== 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=+d2OEA5D8zzmQqTHndTXtQxQyBee+IWOB6KdQmz/buk=; b=D5GW4vqtXV2zMTtvfHAanNYL4VQboH09OLH4/U/Pxq3lwqWLYeio4/9TjODYBRYzRZjJqenCWJzqC6qsYpZxzSIsRxKRVGs9bePDGvIneCq+XhhvjudqhGDJSoYdhzy6SEaX2l1HeDcLcQKfnIjLB7fu3dQMXRmQiRyo3SFv/K0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CH0PR10MB5225.namprd10.prod.outlook.com (2603:10b6:610:c5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Mon, 13 Feb 2023 04:07:48 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:07:48 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 20/25] xfs: only relog deferred intent items if free space in the log gets low Date: Mon, 13 Feb 2023 09:34:40 +0530 Message-Id: <20230213040445.192946-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0197.apcprd01.prod.exchangelabs.com (2603:1096:4:189::8) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CH0PR10MB5225:EE_ X-MS-Office365-Filtering-Correlation-Id: f022f377-3297-41df-93fc-08db0d77de43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nhe7ZS7udMJ+gMIBsHLcNnoDjNUAXDIaGYgPpuhzRmKHMQ4UXa0s1KuPRr8JcR0V6QW2s0rkQoGXCqLkkXCFlJEUI0xdhYY5p8cv7DuXkVksGopUa6VfQX/BI6czFjIJ1+XT85c87m2hVuHaSZtqfilpsEM/ZXmOQ7cxHHKhVtIrYPIduMRbCDMa8B5ZXyj/r3Y8Vjpw+lK/RZixPIdPbhL1k006vVQIvXWg0tEMoqpcbfZV9m7YhrdTY0DX8g8UDJxV60JMYolo1NAV/UbufpnSN+/lSJj5XfO9UiEc6GVnU+/el4mfxDuYhf2gEROlQQVUnLSZJ0gHKjIY9xWNf1DCLgxva71Wtk/goi6FgFce+7V/A8jNEXpqYjgBXsiyGliJ5vdoLwq4JVyYsKqIf1JPn4wdR5+yzIsMw7MLdvSvUiYPVb34w887Ft3/mQoDuSh09Sshmy0Ola7mZkAUS3XtDoP1rE/8R18YC4HLWPudw2LNCfTnd8D/qxYNz3jDOo9neBzi09SOsXiLAZZqkYHqpOSKUqrEnNas8yWs3Jc8n6h8yesc56Yf5gtDL/TE26KdHOdV3D5FRwRN2sbM+QK2NhF1WbeIBC8e3+vLuxUkMQF/DCUQyn+rcCi5xm4OM4tukrcO+1QVc8dL7iiO6w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(366004)(346002)(376002)(39860400002)(136003)(451199018)(2906002)(8936002)(36756003)(5660300002)(86362001)(2616005)(83380400001)(6916009)(4326008)(316002)(38100700002)(66556008)(66946007)(66476007)(41300700001)(8676002)(6486002)(478600001)(6666004)(6512007)(1076003)(6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8GloJiZ4XZxra6J1mSHdSgJgdw0eY+V2VyqWdpyOUN2A8Trx6zRBCCsmD+JKrcmElZ6Rcx93wIxCaCmAL4ROlZyFRqc6HuMKqmCuJBtU8dGtSaZFxgQDSBl4fCuwRaoBbT9cgSuXCfosymSrrnKpvka1HxFlZJXAHjKRg2KupsziwTV9m8N7T/s0yzkpN64pAu5zQGxqnUW1MpqtVXJaOLq3q7oeKfqa83gASlhn0qw2FXSgTiqeTfXTwJ+Yc4VI7BP6g1BxRJymiOPjxEL7oMGMihZfKl+thCg5OVyS62fG/7pLYvvmIkgBJgE8VRuw5DGqX6sUt1JK5harzqhCaoUrEhD70PQQF8e2v3HIvpxLR075EgI3gObJ5Gny4pzreSq6iN/4+nP+ibQmyTZi5Z7Ah8HCfeXMzLEa8Wc5w+noDNwnWnn0JuD00+jDNXAUYNDmrcE3GcMjP2FfPxO50mqzGgRYACYeErMUz7g2taa1pCEYwaMUpDnrCNw7n8d0fYZ8oOl0PRdTOKAIqFCo0kZC6144APq8qU4kL9sADpaq+wTJo2ZXUIxxZl9HZjH1asqjK0o1pptY7tlbK8ZytUjie0AcTrW9Nr5G5naBZj3lOYS13seGkh8Ichqg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: BhSQZ3eYCymMtQMZUCN4KIiLRePbJyLtyLuNYhrxadenaMny68eU3CUqQTWBazSLkO++ku9CkdvGXptY3/eyOuLn25IyPPww8IvnUgDa1BcV2nIZntajRVkrTCSwQsFeJMH2K0awT8K3unC3CsJ7maafky7YJXaRCm+jYIs6u+d1HuOVpaI2WjgivS8nMyhQhWgZubUHTlSbluV12wiaB30kR2/VKIEmiVHhUucSco89cfs7eItZt90/2m0sjmagRJL5dQVilOasYfeQPyC3JylmoqDcuC21RdFnUuerpG78BEg56Eg8pqNC+gbW5B1v6vxqVBOkQ2Ma6LHG7fgibJfyuOVJ207WW1+ktMSZML8Goj7EpQCli144SCb0XfMMKsuz8HIFniYp2N46tVA87qweMEqcjcrPZMODYMaPw5tLjM6K8YkkQGRXtz74HcQKNtSHpa/ks/VXlj5X38V59RBidWlKSOGZ5gH5OpPqNLR+oNH3hCRqQH2aN3UEFon5NeOr9bHzsVZrs8ctJNLtP3FbGqNMPLDhgv27tYXKxHVbWer2B5X4dQUYr48HwXVr6K3gXc93zefvOn+uQekndCv81bkstsH8NZWwH95PmMqbhvafM+CJGxUkQ4XxvGq9DJmfh0Py0mDRx7Y97BxTFvKGONukbDM9vdp3Gu3hVs0SIF3Ii35PzUF8MckHMAy4aSmrN4aN8HUZohR4Tru8baWKD+t2zFQDql3FW6smdrn7XfO2Mo0eayZmd5ssUvTUktdN1CWNDk8o2xebnIZGoinde1SUYPdkPYLMhTi5fkB1t/nuFIezYCHjJ5h4Jug0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f022f377-3297-41df-93fc-08db0d77de43 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:07:48.7265 (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: Haw+l820NH0/LzcugKSiJSe+BSgx65WOCPYdMS68a/HAjC7PBUt+SeyW2qw9rAYiujlmhYp9AaDlABdRNVmYjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5225 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-GUID: q0CPvNpjGcQMzfmq5ZHAaqu_1OixyGib X-Proofpoint-ORIG-GUID: q0CPvNpjGcQMzfmq5ZHAaqu_1OixyGib Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 74f4d6a1e065c92428c5b588099e307a582d79d9 upstream. Now that we have the ability to ask the log how far the tail needs to be pushed to maintain its free space targets, augment the decision to relog an intent item so that we only do it if the log has hit the 75% full threshold. There's no point in relogging an intent into the same checkpoint, and there's no need to relog if there's plenty of free space in the log. Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_defer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index b0b382323413..3a78a189ea01 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -372,7 +372,10 @@ xfs_defer_relog( struct xfs_trans **tpp, struct list_head *dfops) { + struct xlog *log = (*tpp)->t_mountp->m_log; struct xfs_defer_pending *dfp; + xfs_lsn_t threshold_lsn = NULLCOMMITLSN; + ASSERT((*tpp)->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -388,6 +391,19 @@ xfs_defer_relog( xfs_log_item_in_current_chkpt(dfp->dfp_intent)) continue; + /* + * Figure out where we need the tail to be in order to maintain + * the minimum required free space in the log. Only sample + * the log threshold once per call. + */ + if (threshold_lsn == NULLCOMMITLSN) { + threshold_lsn = xlog_grant_push_threshold(log, 0); + if (threshold_lsn == NULLCOMMITLSN) + break; + } + if (XFS_LSN_CMP(dfp->dfp_intent->li_lsn, threshold_lsn) >= 0) + continue; + trace_xfs_defer_relog_intent((*tpp)->t_mountp, dfp); XFS_STATS_INC((*tpp)->t_mountp, defer_relog); dfp->dfp_intent = xfs_trans_item_relog(dfp->dfp_intent, *tpp); From patchwork Mon Feb 13 04:04:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB4A4C636CC for ; Mon, 13 Feb 2023 04:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjBMEIF (ORCPT ); Sun, 12 Feb 2023 23:08:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjBMEIE (ORCPT ); Sun, 12 Feb 2023 23:08:04 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 650EDE387 for ; Sun, 12 Feb 2023 20:08:02 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iCI6028397; Mon, 13 Feb 2023 04:07:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=fAs+mGZ0OLDGRqmYJ2gVVpmVFQwiKIcl1w4R0We1r+M=; b=y24BYw+ShaooaSTJ34Xo0NTMq/Y9nkf8mIKVQAQy15DQjUVcD1scuFiG+t0Fp+Hn9xsY ndux+LpPlB52MwzPqGghD6qLzV1eIba+KiIcWmyE2HK3kzzbBQQ+pbLW5V2Pw2BqGeq8 PsTu4L3y71QRxXdSZvf2gNy0wMIDxeH95+c2K8B7Fj8aDKv1GtkAMJ8qP3su5j3Jrnw3 tJvxtPtSWcHE7MaHP3a8BxhUGYKW2jHZkvN3NdCZCSHiBApvAD5jBq7Cdm0A6A2FyEoV tGQzH4DfhBGm39RwVRFhU8Z2bUBBPNI+BUXRI5Yxsg/3RlH41yQnOPjhh+8tSJz5RwJ8 vA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np3jtsudb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:59 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D36Df1011685; Mon, 13 Feb 2023 04:07:58 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k1sc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:07:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLwBfzE6Ddp1v2agoI8dtxldduI/OjyPuXr2RD7WOA4YrqXjcpUR9m47dceOxzHlts1DcBck9HVniOkBaz0b/oekUS5R2uMiYZZQBcvjC2gU9FXn56Tz/EUKcgDPiDBJZ93O2LTEDfM5a8WeVj7hgi1doM4/w+EOh9rSY6iSqOdR7nZKrwBJUo9MUYJfVGEHX3z0nMGDBwGQ66GX4yt6b/vdRfAcmnTdYMreaG5ic+5qvxbxZ/bkTY8wogCnBzCA+BiQzlR2uXcYHJ8dsmQotKHZwwzUc7yqd501yH1B4eC4+vUHlLVpSUQaSdcNlwaSeNHjag5u6kZo/vTJDCkRlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fAs+mGZ0OLDGRqmYJ2gVVpmVFQwiKIcl1w4R0We1r+M=; b=cq7cNBT9MAWAeYx0S1tLfb87x5TiHcauDcSBt8tdqo/5JmAdxrb8/rPUo/SMuhfE9nRREjhWNfW25QJhRnI7M26bHyRzfvns+OGDONm75TacUNXmbVbQWjpEu/5ToTg/gK3r0m5t4OeSHlp5kcu3xZQpUoS8JNCnESWPvpgQMkCMKZOdpnHatFwgTnULFgXyW3FTTd5yUL2ti/oIlMSPbLc2fh+v48ckwTRUg9E2y+7NA0JZQjtX3hGBMlihW0A7QRGjqH9s5c09grpHmPAZxz5UHDDYzWmVnq6TGIHDdKLd/moG5nkKoMHz31fGM0YX+Ben6HW7G6PbTmsJw1WY/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=fAs+mGZ0OLDGRqmYJ2gVVpmVFQwiKIcl1w4R0We1r+M=; b=MYkz6V3iBj9csEFsnKSi+XusGqGaHzNki4uOBNbp4SHmgL1uIFIO6QXqf/GRU2P/SnbeFRq844x9U7ZAH6SYkdv0kDRNLC/xGhHROonMxp4IQn+wOk61hbAWfiFpub0UVLZaifCr0wuIc6V8gfPo0gXCEHgasTkJ9cP3eWvNXNM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.8; Mon, 13 Feb 2023 04:07:56 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:07:56 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 21/25] xfs: fix missing CoW blocks writeback conversion retry Date: Mon, 13 Feb 2023 09:34:41 +0530 Message-Id: <20230213040445.192946-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR0101CA0019.apcprd01.prod.exchangelabs.com (2603:1096:404:92::31) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: ff7ed880-d944-40e8-68b3-08db0d77e2c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dbeduf8Hyhkk4Vy4bVxhVIG+NHe9n0/Rt9wP198cxnxAZun2oQXBjDOtx1eDgQ2TIYXZLR5ctS1dd2e45idOMEVs5XtOVhcsiqhH9IUuPdH9+YDDIaqrqCrQ3GhIL4PQEiY3CtvgdTWRwgdmt7bOzX/rZUdFtU9HbRrc/KjPWgjcVftUlcDPwZ5D+Ul9rEM5JAe9fnlKwtOIg9LcU/sPvvaJ5Hfu4YchS1H78H8ea5suoRsNCJXOm5sDIw9CSiAMsqbaUcWhUtVWv5p4OxIo1NOQpr4d/hAi9f0eEQhCAPjOWttP/kgm3wRKCRHToLdwP1fFUdPHDKtckfO0dOtnhjlUoJoepdn+Ou8MFr5j9+aK1HWmr+3EjPG+RGEMdwZCUo8sFnUH/KA9En7hILLdZ8uObaZFH+zWF6wIYedfAspY6A4QAGqKLh53RealiskzMi0Uhlb2WmH4TI2U12P/csVbKHDlEhBo2H/5YLMCJ4kqOFW1oLEoSsQCAJ5wRW8YwXHFs5Qz76GUwd5QLdDp+msQ7VgYUs5CQ3y3qe+PdGZgfGizzgp2+pxm18WhxLneWLICKsNSMATr34kGsIDx+KJ+I40DizIOGT+MtXdv2iqjizqsW/8jWy4Ef9/tlVzbRdUWakjPlH8reFoJnRusJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199018)(86362001)(36756003)(38100700002)(316002)(8676002)(4326008)(8936002)(66476007)(5660300002)(41300700001)(66946007)(6916009)(66556008)(2906002)(2616005)(83380400001)(478600001)(6486002)(186003)(26005)(6666004)(6506007)(1076003)(6512007)(66899018);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q3obJYMordSTsOVv3T5A5quzJ8r+cEmIyIrLlSsPf91VbURNY7r2ENqzrx/7xVAPlYBz5lJ1wQWGlflO5C8hNHSoc4wO9LAp1ymhFf04QtvbmCnGCKEU9Xykvf0gcE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P1jEnaIg9BUItmaGhoZ4Bf78Yq3gjzjqd4RebJfN+IORJ4XwTGiR1WHxPCb0ux455S0cf9UBBjoaDIy/JRh6dD6hfHVBM2mIGfK0QlTbaJvZiRV4JbQ/ZRtsOfhy1BYbGerJ5l7gEQFmrIuzAAk1NugkdJBmHHbvbdf6EjRok2Du5pcTIW26HhqnnMEZlRjEtOS3dxnMd1WgN4awVeg3mtDW2xgTEn6JTtP5BwNjbJ3zmrL1j3f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff7ed880-d944-40e8-68b3-08db0d77e2c3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:07:56.0732 (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: Hm99taoCb1nLUA+mngz34GUKKhDWzabXvHzkrBbrGDgjggCQ8bR5s6GJ2Qyh+9gRFfV24M8hbsIS8Xg9lyPU5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-ORIG-GUID: rh-5k1bXD9hvRY5tzRm94kJNyKXcNpRz X-Proofpoint-GUID: rh-5k1bXD9hvRY5tzRm94kJNyKXcNpRz Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit c2f09217a4305478c55adc9a98692488dd19cd32 upstream. [ Set xfs_writepage_ctx->fork to XFS_DATA_FORK since 5.4.y tracks current extent's fork in this variable ] In commit 7588cbeec6df, we tried to fix a race stemming from the lack of coordination between higher level code that wants to allocate and remap CoW fork extents into the data fork. Christoph cites as examples the always_cow mode, and a directio write completion racing with writeback. According to the comments before the goto retry, we want to restart the lookup to catch the extent in the data fork, but we don't actually reset whichfork or cow_fsb, which means the second try executes using stale information. Up until now I think we've gotten lucky that either there's something left in the CoW fork to cause cow_fsb to be reset, or either data/cow fork sequence numbers have advanced enough to force a fresh lookup from the data fork. However, if we reach the retry with an empty stable CoW fork and a stable data fork, neither of those things happens. The retry foolishly re-calls xfs_convert_blocks on the CoW fork which fails again. This time, we toss the write. I've recently been working on extending reflink to the realtime device. When the realtime extent size is larger than a single block, we have to force the page cache to CoW the entire rt extent if a write (or fallocate) are not aligned with the rt extent size. The strategy I've chosen to deal with this is derived from Dave's blocksize > pagesize series: dirtying around the write range, and ensuring that writeback always starts mapping on an rt extent boundary. This has brought this race front and center, since generic/522 blows up immediately. However, I'm pretty sure this is a bug outright, independent of that. Fixes: 7588cbeec6df ("xfs: retry COW fork delalloc conversion when no extent was found") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Chandan Babu R --- fs/xfs/xfs_aops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index f16d5f196c6b..5d9f8e4c4cde 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -495,7 +495,7 @@ xfs_map_blocks( ssize_t count = i_blocksize(inode); xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + count); - xfs_fileoff_t cow_fsb = NULLFILEOFF; + xfs_fileoff_t cow_fsb; struct xfs_bmbt_irec imap; struct xfs_iext_cursor icur; int retries = 0; @@ -529,6 +529,8 @@ xfs_map_blocks( * landed in a hole and we skip the block. */ retry: + cow_fsb = NULLFILEOFF; + wpc->fork = XFS_DATA_FORK; xfs_ilock(ip, XFS_ILOCK_SHARED); ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || (ip->i_df.if_flags & XFS_IFEXTENTS)); From patchwork Mon Feb 13 04:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ACE3C636D7 for ; Mon, 13 Feb 2023 04:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbjBMEIM (ORCPT ); Sun, 12 Feb 2023 23:08:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjBMEIL (ORCPT ); Sun, 12 Feb 2023 23:08:11 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94D3E396 for ; Sun, 12 Feb 2023 20:08:09 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1j38A017538; Mon, 13 Feb 2023 04:08:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=SxjZvySD+XoKCl80iBM0RetdJ1lhBRKLBipN/AvwbUg=; b=p/MKk4EmP3K7enycV52gvZjragMxYz5minOvQiRrd7hy2wRNiNSlcthaheH4WoMQpptL hWRHBdd10UJNpY//20UXI5PsyfeuavMx5jyJp3T8cGuIBhvoeKDYbe8tI+DKQC3EnbyI aX3KxW7z+PLFkd0ayZYWou1QlCT0OsCU/H+8DHF27l4MAQccrwg9XgjPk0Uu07q+FYsE hY9hJOxRvmsAUXPI3RK1GKJOb2EnhE/Gz8BcJ5aMtrEsxCuysf8NI2rZ4id1SMCBremJ wM/n62uvDuK0ndoXn4QqNcZ1VXB7SNOJ6RPLqCTvBPgj7Vte2R7gl2yMe7qzk2Nb8az3 Tw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np32c9ukf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:06 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3APAW017976; Mon, 13 Feb 2023 04:08:06 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f42a4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YSK/gxUKkPTQSJtKI7AxtmkyywGKoRNOTUMNmSXh/3IgMjzbFPh9pOp6dBl6RshFUTACyHWu0fByg2Z8+EUzB++vpv4gJtTQE15hkwiGr6hBu1fDuDm+BdhA25cbQ2ANDqjSmmKmHZsSgZGg8Uv3SFZgZdivAKmND1H78O6ScfAbsajJam19RykDVg6yfWpcTvNwIt59LihIhqbwPoiWFKFUoJk3SgHxlPac5Z53SSFuNDBroXbiMabhSZ5smrpaPHjejtfqHyk7Hmgmi7CaWCfywWuKQNKZWVdBAR0fOLxP4T7jwo3rwk2tfyFv4l+r5sB4RhRq+zzWZD7jaqJcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SxjZvySD+XoKCl80iBM0RetdJ1lhBRKLBipN/AvwbUg=; b=ImB0j2FV1pJAry03jpI32vp3HRcCShzPn4o1RmZBqaQYImOFjvKasn6AT6yOuEBZOBNnCDcpZwRaOr8FiahU+tIOdiJDVrPTPHhNX2txFgZvpwmEs48Ufv76MU7M0pa/+syZNbLfyWjUl7iZtvFSjaKaDJHksBCeTowsn2xwXDSULWwzRIeuN1wNDeQgtgQbcAIV7Bd7rlajmbBEBjHHxjX+4CJTLDcKab3/k3J5NejSvcM7afoHSe8yik5mTS8d+QQDTIoi9gGdaevTYavWltcJWPQnxssXb/FpMU3EtE6wGUmeEbTa8wM7o0iasLEte4jvkkZjfcK/mXBrwuzVBw== 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=SxjZvySD+XoKCl80iBM0RetdJ1lhBRKLBipN/AvwbUg=; b=cOTjNR+HHZArklp4hP85P8zE42bKhp5ZeNhmG1ve3M1nz4D17x5OOOjK1M+3ID8cunbgaQ384u3/n0IFDrcKKCPrBDNdAJNGLGrlTPm2SNaI3AuLNzUhjFH6t+f3kLmavXqkhFwPTmbhHOOA3P/i9+GOoM2CDU4+wGyP5cPbJe0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.8; Mon, 13 Feb 2023 04:08:03 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:08:03 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 22/25] xfs: ensure inobt record walks always make forward progress Date: Mon, 13 Feb 2023 09:34:42 +0530 Message-Id: <20230213040445.192946-23-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0015.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ec9b9f4-6622-4900-07b3-08db0d77e703 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HTs1gjxm0womG6bibD2Smkrlh3zo/cDoJaVZ5G4KfW8F602cth41HBWoSamnLcZcqgbtEV8bLcEs81lsUr0sMSEvIj3BrAs2lpXx+6sOWDEYCaF/GMUmJvOXcRoau/aTn5NRi4dgvhjfWCcEyAYct3lL2DjsQJiZAeA6CGaIQKKx8SJSiD4J7cAmFPUSb7CBpi+C1FaisDFB9AqJNkNxUifv6FfJsOK88TA0Gw5nxFElZ+h86zIWTVP1ogb/vZWvSZwgrFYI2e/ohIoGWt3iN0xwrdq+fCqB9KIRWxQXJ/DIMShlqFq0aDcKE5PbwtdzrcQjnOaamUrCmi0/4eAMkMCBjHQYnJPmxrN3f5uxrSA0F0vj7OpekWJUxthjWtfONGjIG3NM2PzR3bg+9HrHULJSyJ6EWi7iVI48Ia4mhyKsYl8Jdp/SnYXod6/0Ygt5bHAr0iIMTBTjyg8BBdWUaFH7GwK453slZhipldfhYLlumQhk1TOxEQbMwkWB3am4wohCKqrTVnJ++1fc9119rKVYAnuwu91buyZLnNZ+i4Qs71Y5S2DwgbRl7YXlE6VY6gWjSpSX7TyJ0TbL8lUTBAM0VHvdsdv9YLgRYxcWQsBrcepQkoCIM4gEFmsdQM8A0x8v7VBE6LqAtQBkD0qvPw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199018)(86362001)(36756003)(38100700002)(316002)(8676002)(4326008)(8936002)(66476007)(5660300002)(41300700001)(66946007)(6916009)(66556008)(2906002)(2616005)(83380400001)(478600001)(6486002)(186003)(26005)(6666004)(6506007)(1076003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SeAg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yRSkXUcNZW498lEVhIAARePGtBCr3YKyWc4IqeCd3oC6X1svMcfpDI9eBgB31YnNv2GbFeYluow0X4KcP1EBLnJ2qNpGc8t9tBcEkYOuhllsL1SRX+8xI/zc0rJK2X90UV4Vdlwd6O9xxCbfyz3bSQS3y/UVI32C5nT343YN+KOovEcCj37TjKd5c3g45KBXb3v7Wnx3nI0pgfcmru9/jIAyLX3nCanPZCB8b0Wn2KLzKIDXQuaVcYUtlXyNH0v8R4m6LP2HtFcFs6wwAODpHyk9yuhjxPXLh2XM5sGQZHGqTgWCAzP1k4uhmXTBkZdTyX4GRExe861zYPDOndD3XkIO1cUFv5mqo8+8ygFpz9WY8I4qU29HeSKy8AzlCEwznT/xKxnNVfvbwXy4B4oGGfIgaKkgSpY9NJMNd20rpcja1Vx25+I0jBFv442RSV0OvCdVzpf14XItGIWG3+qHHIXBaPTRciN7HJuawSo3GVY2/RgQPZ0BLVmaN5M7DSg2raakAoKTkA631B1wY9dbMrfKf5yA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: FnYCnFZCRg2beymv9EYqXrErEueKNU0KOGpvVl9M8ysKFjQkqAHHZKEdk4M+/QYhqxnmnz/jWyngN3+1v2MOUTpwJ6grHNjrw7wUaW1u2sgxTvoNm+gah6+5UXcczJVDdQoiifnkJPg75HZrlANnkqdRHD2drDhA7N3HH81jf0qkH/3lV6OuNm6lUcurVQGM/4j2dYeh7FHhaKTAMoYz8B70I0fnciVNYNNtCl6/zRNiPFpVBaCRzlvQWk/nT20075VJyHHJjGlUXIHnfYAF1Q/q1/fhPGGKGIRk9jwDS8HoJX3YeYN/PlZpuBM6qMs/c3F14pQwMyXxylbbUZOCgYmPZsweLIyfE8dzPallBHukXZuMyROQMWFOPzO2MPBSgKJpKeANbaz71K6d4W7j5DZPziQ4/8Zt3dH2WZjlM6N2itVNoro3Gsd9/jnTdOUMnacbIiNvsKjaVjmf6KV16f5ooDilaxmKCCXShmQxsMqU9hO0lz+7Sx77QebO1Q6Uz7RKuqas8r1yvUbpm71zGVuvN6ELAUS6ISi04oT92pTULqQutBJlgCxZl5lnvdtHvPdFviyzNnWmAI2uZN99hbhAWSJejcvi1vwDzSAGRMbYLgcX1Rqlf7/6Bq7rbsNV0eUzLpGmV5nMmWUfNxXBKfE58IOTZ4hzrox7t2fbHX8nYhNONR5RYsl9xM8yn9ss+JO6nhYo7rNYkyPte7Embk0rdO4e90ydTqnEGybaZwgHhA194aE3IDnF06eLtmN4yOYk+AGpdN2eRoyhX7qQ9s0U193kPFc7he13cdpaX/nlMg2z/+zeTL9gqOTJS0NT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ec9b9f4-6622-4900-07b3-08db0d77e703 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:08:03.2155 (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: QSJXd1ABbzw/rtiqMqdgnvcbAsB8B988YCJ2lhZ/g5l22TnRTNk1NCqzUh7nn1lIiwVJIqSlB/FgzJOXQXr4dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-GUID: s9wxYrhe1SsveIw1W2UtrWUMtpxwXwwQ X-Proofpoint-ORIG-GUID: s9wxYrhe1SsveIw1W2UtrWUMtpxwXwwQ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 27c14b5daa82861220d6fa6e27b51f05f21ffaa7 upstream. [ In xfs_iwalk_ag(), Replace a call to XFS_IS_CORRUPT() with a call to ASSERT() ] The aim of the inode btree record iterator function is to call a callback on every record in the btree. To avoid having to tear down and recreate the inode btree cursor around every callback, it caches a certain number of records in a memory buffer. After each batch of callback invocations, we have to perform a btree lookup to find the next record after where we left off. However, if the keys of the inode btree are corrupt, the lookup might put us in the wrong part of the inode btree, causing the walk function to loop forever. Therefore, we add extra cursor tracking to make sure that we never go backwards neither when performing the lookup nor when jumping to the next inobt record. This also fixes an off by one error where upon resume the lookup should have been for the inode /after/ the point at which we stopped. Found by fuzzing xfs/460 with keys[2].startino = ones causing bulkstat and quotacheck to hang. Fixes: a211432c27ff ("xfs: create simplified inode walk function") Signed-off-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Chandan Babu R --- fs/xfs/xfs_iwalk.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index aa375cf53021..1f53af6b0112 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -55,6 +55,9 @@ struct xfs_iwalk_ag { /* Where do we start the traversal? */ xfs_ino_t startino; + /* What was the last inode number we saw when iterating the inobt? */ + xfs_ino_t lastino; + /* Array of inobt records we cache. */ struct xfs_inobt_rec_incore *recs; @@ -300,6 +303,9 @@ xfs_iwalk_ag_start( return error; XFS_WANT_CORRUPTED_RETURN(mp, *has_more == 1); + iwag->lastino = XFS_AGINO_TO_INO(mp, agno, + irec->ir_startino + XFS_INODES_PER_CHUNK - 1); + /* * If the LE lookup yielded an inobt record before the cursor position, * skip it and see if there's another one after it. @@ -346,15 +352,17 @@ xfs_iwalk_run_callbacks( struct xfs_mount *mp = iwag->mp; struct xfs_trans *tp = iwag->tp; struct xfs_inobt_rec_incore *irec; - xfs_agino_t restart; + xfs_agino_t next_agino; int error; + next_agino = XFS_INO_TO_AGINO(mp, iwag->lastino) + 1; + ASSERT(iwag->nr_recs > 0); /* Delete cursor but remember the last record we cached... */ xfs_iwalk_del_inobt(tp, curpp, agi_bpp, 0); irec = &iwag->recs[iwag->nr_recs - 1]; - restart = irec->ir_startino + XFS_INODES_PER_CHUNK - 1; + ASSERT(next_agino == irec->ir_startino + XFS_INODES_PER_CHUNK); error = xfs_iwalk_ag_recs(iwag); if (error) @@ -371,7 +379,7 @@ xfs_iwalk_run_callbacks( if (error) return error; - return xfs_inobt_lookup(*curpp, restart, XFS_LOOKUP_GE, has_more); + return xfs_inobt_lookup(*curpp, next_agino, XFS_LOOKUP_GE, has_more); } /* Walk all inodes in a single AG, from @iwag->startino to the end of the AG. */ @@ -395,6 +403,7 @@ xfs_iwalk_ag( while (!error && has_more) { struct xfs_inobt_rec_incore *irec; + xfs_ino_t rec_fsino; cond_resched(); if (xfs_pwork_want_abort(&iwag->pwork)) @@ -406,6 +415,15 @@ xfs_iwalk_ag( if (error || !has_more) break; + /* Make sure that we always move forward. */ + rec_fsino = XFS_AGINO_TO_INO(mp, agno, irec->ir_startino); + if (iwag->lastino != NULLFSINO && iwag->lastino >= rec_fsino) { + ASSERT(iwag->lastino < rec_fsino); + error = -EFSCORRUPTED; + goto out; + } + iwag->lastino = rec_fsino + XFS_INODES_PER_CHUNK - 1; + /* No allocated inodes in this chunk; skip it. */ if (iwag->skip_empty && irec->ir_freecount == irec->ir_count) { error = xfs_btree_increment(cur, 0, &has_more); @@ -534,6 +552,7 @@ xfs_iwalk( .trim_start = 1, .skip_empty = 1, .pwork = XFS_PWORK_SINGLE_THREADED, + .lastino = NULLFSINO, }; xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, startino); int error; @@ -622,6 +641,7 @@ xfs_iwalk_threaded( iwag->data = data; iwag->startino = startino; iwag->sz_recs = xfs_iwalk_prefetch(inode_records); + iwag->lastino = NULLFSINO; xfs_pwork_queue(&pctl, &iwag->pwork); startino = XFS_AGINO_TO_INO(mp, agno + 1, 0); if (flags & XFS_INOBT_WALK_SAME_AG) @@ -695,6 +715,7 @@ xfs_inobt_walk( .startino = startino, .sz_recs = xfs_inobt_walk_prefetch(inobt_records), .pwork = XFS_PWORK_SINGLE_THREADED, + .lastino = NULLFSINO, }; xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, startino); int error; From patchwork Mon Feb 13 04:04:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66753C636D7 for ; Mon, 13 Feb 2023 04:08:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229545AbjBMEIS (ORCPT ); Sun, 12 Feb 2023 23:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjBMEIR (ORCPT ); Sun, 12 Feb 2023 23:08:17 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34E1CE396 for ; Sun, 12 Feb 2023 20:08:16 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1jFA3010497; Mon, 13 Feb 2023 04:08:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=trhfPZ23r+skcnoaq5v9EvxYo72XODS8/LIMe7VbhOQ=; b=l4139g/ijB+jQzu98vDxibSDjWSq0OdbP+DNE93NGtAWfHAQomy/ewwJOshe2DwByrxd Yex3GfSnXdu+oAZ8BVt8HFb+w7RWNUbZ4L1KVuZpZ3yO9bI6fPSZ7vOaiWxFUg4YiKYN Wl6UzCpvRTFEnj2a5vzPpO1bf80KjC0OmYxQFHZ+9PmRSheOA1tjJ8sEAliKHdy1sVmr 7wtc01vMXSkvywc+D5OnnC/bfT2GZJR5Kp1fZXqN9tBElcIk3YvAnhHG1ItNd5n6ulRc vPuCeNAdTbQGebuMNMBsJogJMYowWm21uMiTFCB6SrDyeUHwuY14v3qVCv1TsOHdykPe QQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1xb1wwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D41lP7018012; Mon, 13 Feb 2023 04:08:12 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f42a74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+Fy5/fkEbPcWOWwEfytAYnTOBh0dLSG2R7NoX6h3UOOiqFAdjU8PM0I/Ix7SEIbV2JiFQdkEdWs1n4/LZXhjvAQJjCx0zlGcG0Oa+/lzLhm7pF1RUvsQLpkv0ah3mhOh32ukj2SPbduHGNjCakYeT/2CelSxNLTNbpHABQfcRVCqAWvDP1R2DESAwf74kNqppOpZSaZu3ymAGOqbIWZLapg0J9tq6Onb+ABsbsFoOKJzDUpG+gtG6xy+/rJwDFHZVK7+cC82zKexTpIWtAQI73ZUqQbsSeiyZjfm5MNp9RWdB8QGkva1UIka9Cn9gQHrdEcHPxJFiUQbUROOokp3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=trhfPZ23r+skcnoaq5v9EvxYo72XODS8/LIMe7VbhOQ=; b=fOqZT/OKf2CD6N7lNGw8Sk4Yhzx5uTKO0LKchqOnw258Bvtj1Q4UK+ZvqQEJWywFvDhu+CLZhETy0aWLijjTIjYzP0+4OWiWTBDsSl0W8eDrAt7jxN+6yFezq++J3zZzqmW8rp1RMJWfoyVQTiPLYO1Fr589Gr5tON+oVeCjl3OH5K1D1f5w+iHfCEb2h5/48YKjmrdQBJURKmRn6dLPq9i1MfhNvMobkWy09A9S/2YyYLVPyu+kMGkMCMsvw4cTOgzP/gU2X+tJwZYEU1mdHibAud1Fz+UQkcAomgwB9CDUFBmcAB9yf7E5NgoQHUgtZvTN2IFOWfJvcbI0/bReYg== 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=trhfPZ23r+skcnoaq5v9EvxYo72XODS8/LIMe7VbhOQ=; b=xgQCio4XX4VAWOvd+tQZXfpdYNk1AZPk3uyuAewVs1BubOcDfc/zTf0AejrnK/OzsKKPrqAQsEbhRiv2/2X4jj3KZCJ0KQuB8YztMKTuVt961KJ5UyMFmGJXOWvTMrFVjvwREMxDYNRsefi4orG5T9kHcGv0rZZ9ZoBDPsXB/cE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.8; Mon, 13 Feb 2023 04:08:10 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:08:10 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 23/25] xfs: fix the forward progress assertion in xfs_iwalk_run_callbacks Date: Mon, 13 Feb 2023 09:34:43 +0530 Message-Id: <20230213040445.192946-24-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0001.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 07a5efd2-e649-4aef-ec5f-08db0d77eb59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KPHO2YvecLOjeiKC6dUrPZqwbzkP0Fg1Oi3rFG4ERelcAHNVumdiNlsJJVNIufio3IUwQk5VTYrLnr0l/Klqmqkf8KxilO4xdvUULFHyIGxAmrGKE810nAhsYk/zpBhbrbkyW0nHLLIr0JF2ZL/3c1JMbov9isHQmVRbBF5aU0gvsriEzvOxlYuevJOcHjBzfp0+DFewskrdktaAdNheRku4x2sc47Si5nfauvABAWCBVq9yJ+qq1+cN3fQYV+6/j316Tw1fpRiz53I6TZ2M0ZhSF7tNvzEtl/dcvCy6PX936cNmW0DxN+bge6/O4mpBkuq3WyILAFpksPGL85exRe5xcE/HruDxVufLJHsjy9EY2EB50RsXt9NWJkH1jQ9ONZJm5TxSvAUDqsm3ktyDTrc40RFTrjeK2qghFH7YI/MOaX43HEU5hUcoztf85m7cE7DTc7dYWIw802SB8SHgWiXEIA24HPFVzNib62BVAAaaYmwnKhw/CgPInh5muVybDFWGh7HI6KAIVUpYae2LTmPiqfZ1Ob8pDNXNTXJRKFXskl1vy8ZAnum88jOBYLZ9nLDOmdvOawPcF2ZtYrIByfuEv5eI/a5JmuRlrA8vnMC3MYf3MNnkP3AZPwaFVpH0FwicsAk5E0IOuS6K5HtiQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199018)(86362001)(36756003)(38100700002)(316002)(8676002)(4326008)(8936002)(66476007)(5660300002)(41300700001)(66946007)(6916009)(66556008)(2906002)(2616005)(83380400001)(478600001)(6486002)(186003)(26005)(6666004)(6506007)(1076003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: beb7k7pew/AlR0pmTuPAVqxvPwgt4MHrFrnVAMgxlk2MYOqQN3TekAMceKOYdCDEdvXiK1AhNn2op4OBPaWF+GezKujIiNwrAyTF1xzkBZQbnpvnMgPMGAOJcbMB6mD+co/LQ2qiSM3ZTtdW6UVqseeDNs5ccZKWrhNOiImNRaPvAR/eUQUPJssNDT6tslyFrkPVW2C7gCrgwMHVAaF3ibxpMgoFKDVJjnREALxkpd9Y5DhA1tqIc2As+ySVgwvA0T68ri4n0pNDMeAXN5D1WfNzp7+1mD7UAO36Ohv81Ho8HYeIs8bsK19u5CeVCeUSQ9OVo5lDxT6TBeTMlnICY91AmVlvFynPYSpbfuyw77VJ5/Ns3veJTMvBO327YrSA4IKuO7AYdK+5oWyfUUD7H5YmSdTFTH0mQPUaKxHvXrkjPxOCLuxIiXWw67Lut/g05SpBa2bclSN0Uqtleelm73gWkQ97xpCKSMlF8IJEw4ZzUwsK1Duze8RFPOA5zASyjjtSf8QlTzIc7Z+Wh6N98FE13v4gycdkTMnIi6glFZdZAbxUs317VcKC+ANmsEXXnKXfLS2dAPpns9IMW7CGxT/+pZGYpM7SUYNEb6u1QM49nJNvO9QlAqfy1CkLFszBd6ndSABE03qN2InKCZTxgVTdBv94wzkyFn7R6gFtPbgLQV5SabqWJaPUVdLpox+lQRSzEKW/GUgEly5O3SB1fJhkAXhhe7RYCQbBtSmyaNwinnUyBVSRPwHhcCO5PMQtvdiKEa2+zbt+u60elXj17QZlCks9nc0qFt8Zl9fetvDxVwe1GouqFACIR2NvsZYlkeKaIOe2F0Frg5MNIELiByyyApdn8t9ilHVQJ414zqbY1wA0tCqHfoSP/B25bYdqmFL4dZDK+AOlzIsFdk+aVIwFHFPZyV16xULyHiGDG3qaRHMBBydMC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nsSW6AhWLXAJPAT3vi9ySdDbzmPi5k8XRU6jsVSVLTlbkxC2/xmO2tYki6ZLXwdwJne7Ve4kXXfcqcQkDyQDs6rH/Ew95ejJiwOPIpO5dQA2grfUsybTfhtSXXLkk1ESWzEgahp/iPFsq23Ag7grgLw1DmPdcPywr6Fuwn860bUMfQ3vuGvvwjeCR8S51skJTEGBVHK5HpdgxzVoQKYxc1yVzHzwwKjv3lCfkHLWGVQWOmLoEHVp2QYlO063DG73KWax2+fed6QDFRat02AM+x5jj1yLCcm3MUr9334MFI8qfH1o0FtSd2AQekTZ9mh2XATOLCzl8xn+c/engq8zfIo9K+nkxQAcACHsBDBCC2GsvBVKFkW00RAChIopKxTuFZjC4yEKt4OtA0jkcHDSPqFzowIc5tBN97T3TzXlhGqQuPRjyidHqptj6Wl+KvZSFC5xVkDdKlcjhZyzAQ9Ysx9OALADSyB3Wx68LZJEboDvZIrYNZzjjx3huQGArEV3HY72Rh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07a5efd2-e649-4aef-ec5f-08db0d77eb59 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:08:10.6052 (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: 2Dpr/JZM4GZNkJOQjymqiE+buuiB3StTLTnC2pS8xUK92wUdQ5imVtIM+PfuFbEdTplYol349zpLKSv1Wl8/wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-ORIG-GUID: UptAKOmPXTHVS7rrC7oB35sRd0NQtaX6 X-Proofpoint-GUID: UptAKOmPXTHVS7rrC7oB35sRd0NQtaX6 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit a5336d6bb2d02d0e9d4d3c8be04b80b8b68d56c8 upstream. In commit 27c14b5daa82 we started tracking the last inode seen during an inode walk to avoid infinite loops if a corrupt inobt record happens to have a lower ir_startino than the record preceeding it. Unfortunately, the assertion trips over the case where there are completely empty inobt records (which can happen quite easily on 64k page filesystems) because we advance the tracking cursor without actually putting the empty record into the processing buffer. Fix the assert to allow for this case. Reported-by: zlang@redhat.com Fixes: 27c14b5daa82 ("xfs: ensure inobt record walks always make forward progress") Signed-off-by: Darrick J. Wong Reviewed-by: Zorro Lang Reviewed-by: Dave Chinner Signed-off-by: Chandan Babu R --- fs/xfs/xfs_iwalk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index 1f53af6b0112..cc5c0c835884 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -362,7 +362,7 @@ xfs_iwalk_run_callbacks( /* Delete cursor but remember the last record we cached... */ xfs_iwalk_del_inobt(tp, curpp, agi_bpp, 0); irec = &iwag->recs[iwag->nr_recs - 1]; - ASSERT(next_agino == irec->ir_startino + XFS_INODES_PER_CHUNK); + ASSERT(next_agino >= irec->ir_startino + XFS_INODES_PER_CHUNK); error = xfs_iwalk_ag_recs(iwag); if (error) From patchwork Mon Feb 13 04:04:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7190BC636D7 for ; Mon, 13 Feb 2023 04:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjBMEIb (ORCPT ); Sun, 12 Feb 2023 23:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjBMEIa (ORCPT ); Sun, 12 Feb 2023 23:08:30 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E692AE044 for ; Sun, 12 Feb 2023 20:08:28 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1hws4013421; Mon, 13 Feb 2023 04:08:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=QXHChvJf6S1B1vkjlfBdI3n4LIWXm9pb4OEYHiw0koQ=; b=v4FaVZiJLkKo/CYZILpNCHcIA4WVv62IUOjYk7uvNU7NdrLAd//QmXxYT3COwPGHBveP Viea30ZonYQRhkUk6Md6owQAeB+D/+gkgod1BmhQyuWE2vhKjgCngJ6gwBxioWqe/Z1X Lb4kUIfBBqHEeCtYbu8QoQ7lAOHBRUVyzizXDH2l/v4cYlci5VqH/Xx7yilRyoBdGU63 902+yK6Gs/1SayoZxBM4hKTwUIwvhLkYNSWCAbffKSTy8sFq5ex6E3BW3X0T1rGF2i49 DGqBSPeKGnQVckauUW39Uz1uDtOiwpZos0KARDM+Qw+yfi9xfXIYyVb21EKSawoyOd++ xA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np32c9uku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:25 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3SK36028770; Mon, 13 Feb 2023 04:08:25 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3jyt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nmeX71f7MfsCWGQgYnRs47TTxNt6eDIJ6MbDUUgzzNXrWsWtFhwSBu9OKvWEX5Rdwo1EiTLov6TVeUdEyuNQYXuhJtcfRiCFsRuEjph8jHbVorxTDb9Ned86z6Qpl8E2+szvlewo773rWLhWkg1+Rd13y2saQWXlB0OsdUj6T8gkE16D1MWugdr+55UyxUpMIkQqcoOfcNAUrDYuMGUQaBZtngZGpqlpv/8f1ZpmvMrvmsghQFqfkcSGJ0+Uj3ETFsOc3Vr+s4JMmHgQnbue2SECOTeNYIlkjSWFafTMaKyBgQBgOKT+cVvqjTsgE+7Xhdj69tOyhVMuwDrE6TS9fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QXHChvJf6S1B1vkjlfBdI3n4LIWXm9pb4OEYHiw0koQ=; b=UuR4vGzLHkx/cBJQCnp9KtqnMVd19rbDdo6v5e/JR5Za81VfMpteNhy8l283rZFs+LcLOjZT20HWkcSjqh/k15Y7qGWa8zk/oV7kLHeD7UxskmY+3qpPjeOCY6b0uGHMCudfinz1Iclr73Z+HwamJYqaCWRZGjqd5apOmFAAn1kPUcXo+X1BVfaI17pYsv9kjL7+PlvwL8vS40j/48xHVydPntyvn2PqG67ahxkz3D56dqRWBkaFuNWYI2MJFWGUIZ+0BtDI5EE+6Pjzkt+hYQSf9bni8B1vZfbz77doXsuUSX72LJIAa01GN/G10UIIHD25k/RRPnCuKZFVy+/nyw== 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=QXHChvJf6S1B1vkjlfBdI3n4LIWXm9pb4OEYHiw0koQ=; b=zhauJ6hORecFT61JQ9DDaTD5YaIoY21OO39Di2+qDQITp2rv+XfqAREIWuGTLz7TsC4AyE/Uz7s8AA0a/i+veF4cGaF78oKcqMarpEAV04OjV1XSCfr/DMScr5PAi2J57Pb4FEWXZVPLFXRqm6SK58cB3soccDcaMCqWHAIAKLk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.8; Mon, 13 Feb 2023 04:08:17 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:08:17 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 24/25] xfs: prevent UAF in xfs_log_item_in_current_chkpt Date: Mon, 13 Feb 2023 09:34:44 +0530 Message-Id: <20230213040445.192946-25-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0028.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::14) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b4949e2-42cd-4bab-6441-08db0d77efaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OORa2cKYPlTvjeyPnntCfayDqzhQ7iJc32zZiLXQUwQBewk/H+gzjlE2/AkPGlVIcJC2GlUDI1/YbYTHiDiRepoGW7KXWsJGiNJ2i77brukAUGaibYnddYuZLdfo6ZFJXludSc7RZcfgZLQJM/t7W4/n00JkYsNZDMdWLGvsqaPKlp58FPqKrPDyQnCuMLcPt8kb+TNuIkvOvn0MJxRVKHEhY7m7B0jiJBTtNcN3Bt0jkOmpFOo1H3mvu2WlBrsHgtU6EeOZ8ocwGWQjnlm92r7yVaANW2q6bs3THRzeBsdWJTpJRcRZ0DNdzxF8uJAdYg4R1GZpHPsAjHQ8By8qVfY3IJbK+PhBrLysO5h1yFatjHNbwaxXuXCBMC5EjDSBK17y2BQJ70thx7echqvV7w+0UKlSwhHYTDGynt8WvQSjFE88AVzYe4rSsvX7MqiYxnkySVB4U1JH0cZaAwkgnC5+nz+WsyPVKsN9vv+stsoLqG24/BIVVGR1OqanG/xjBY8I9lRuGhwsEQQSznVrmJQJmGJrVJ6MBawzrW8Z7+oEKulSs+cS2xUzCkSTYKpD6eUth0CbzjGBMkar+AjSVgHvUAQfdTvLOHATXlyC6tUNZQy2HUsg09+02NfPCXllpTCLJExcZTbtkZOglZsgag== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199018)(86362001)(36756003)(38100700002)(316002)(8676002)(4326008)(8936002)(66476007)(5660300002)(41300700001)(66946007)(6916009)(66556008)(2906002)(2616005)(83380400001)(478600001)(6486002)(186003)(26005)(6666004)(6506007)(1076003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ggb21CSR5/jiDqA9xS02cjhf0WUFhDRr2750+KpDJH4XfQss2Qia7/M/2oddzQKz88pbRjimwQQfRdnnAq5T7yaiXV8yZ1S9aS7CHMzaYSmsJ3wYdwYt39z7yQjcKG10y/+M6xEGwN1njcXqX6ZbsZgUsCYDD/DbdQTWHtR4IsLB8nYLF6XWS8oBTZ44LPM60ICglHTAcYpRfOfmhRh9Wi2TMRDhcEHtCYXU049us9oKRaK6Sg+2rq0NoI4/gvpTP5pmjHp76lnx3C8ELWehISML1t9PCEi9wty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yzKvkjd6GWSFQArV7tlrdatpMPAN3Upolmy0c7DHtoI8LP0TBxk9WjMeKLk+fxYGSwbKgwT4XkVUkcuAPx2SV4N+IRhyxI X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b4949e2-42cd-4bab-6441-08db0d77efaa X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:08:17.8434 (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: VwPjLjhf38sYPpVYMXcSOYmhKDzDhb8WoaX6MS8N1WejHGZKBeK3zYuRcknleKqTdTwWeqMKatTVx82SJN6IPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-GUID: U9Wm_PoEoOcLfBFqGiYi9xJ1JQWZxRL8 X-Proofpoint-ORIG-GUID: U9Wm_PoEoOcLfBFqGiYi9xJ1JQWZxRL8 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit f8d92a66e810acbef6ddbc0bd0cbd9b117ce8acd upstream. [ Continue to interpret xfs_log_item->li_seq as an LSN rather than a CIL sequence number.] While I was running with KASAN and lockdep enabled, I stumbled upon an KASAN report about a UAF to a freed CIL checkpoint. Looking at the comment for xfs_log_item_in_current_chkpt, it seems pretty obvious to me that the original patch to xfs_defer_finish_noroll should have done something to lock the CIL to prevent it from switching the CIL contexts while the predicate runs. For upper level code that needs to know if a given log item is new enough not to need relogging, add a new wrapper that takes the CIL context lock long enough to sample the current CIL context. This is kind of racy in that the CIL can switch the contexts immediately after sampling, but that's ok because the consequence is that the defer ops code is a little slow to relog items. ================================================================== BUG: KASAN: use-after-free in xfs_log_item_in_current_chkpt+0x139/0x160 [xfs] Read of size 8 at addr ffff88804ea5f608 by task fsstress/527999 CPU: 1 PID: 527999 Comm: fsstress Tainted: G D 5.16.0-rc4-xfsx #rc4 Call Trace: dump_stack_lvl+0x45/0x59 print_address_description.constprop.0+0x1f/0x140 kasan_report.cold+0x83/0xdf xfs_log_item_in_current_chkpt+0x139/0x160 xfs_defer_finish_noroll+0x3bb/0x1e30 __xfs_trans_commit+0x6c8/0xcf0 xfs_reflink_remap_extent+0x66f/0x10e0 xfs_reflink_remap_blocks+0x2dd/0xa90 xfs_file_remap_range+0x27b/0xc30 vfs_dedupe_file_range_one+0x368/0x420 vfs_dedupe_file_range+0x37c/0x5d0 do_vfs_ioctl+0x308/0x1260 __x64_sys_ioctl+0xa1/0x170 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f2c71a2950b Code: 0f 1e fa 48 8b 05 85 39 0d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 55 39 0d 00 f7 d8 64 89 01 48 RSP: 002b:00007ffe8c0e03c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00005600862a8740 RCX: 00007f2c71a2950b RDX: 00005600862a7be0 RSI: 00000000c0189436 RDI: 0000000000000004 RBP: 000000000000000b R08: 0000000000000027 R09: 0000000000000003 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000005a R13: 00005600862804a8 R14: 0000000000016000 R15: 00005600862a8a20 Allocated by task 464064: kasan_save_stack+0x1e/0x50 __kasan_kmalloc+0x81/0xa0 kmem_alloc+0xcd/0x2c0 [xfs] xlog_cil_ctx_alloc+0x17/0x1e0 [xfs] xlog_cil_push_work+0x141/0x13d0 [xfs] process_one_work+0x7f6/0x1380 worker_thread+0x59d/0x1040 kthread+0x3b0/0x490 ret_from_fork+0x1f/0x30 Freed by task 51: kasan_save_stack+0x1e/0x50 kasan_set_track+0x21/0x30 kasan_set_free_info+0x20/0x30 __kasan_slab_free+0xed/0x130 slab_free_freelist_hook+0x7f/0x160 kfree+0xde/0x340 xlog_cil_committed+0xbfd/0xfe0 [xfs] xlog_cil_process_committed+0x103/0x1c0 [xfs] xlog_state_do_callback+0x45d/0xbd0 [xfs] xlog_ioend_work+0x116/0x1c0 [xfs] process_one_work+0x7f6/0x1380 worker_thread+0x59d/0x1040 kthread+0x3b0/0x490 ret_from_fork+0x1f/0x30 Last potentially related work creation: kasan_save_stack+0x1e/0x50 __kasan_record_aux_stack+0xb7/0xc0 insert_work+0x48/0x2e0 __queue_work+0x4e7/0xda0 queue_work_on+0x69/0x80 xlog_cil_push_now.isra.0+0x16b/0x210 [xfs] xlog_cil_force_seq+0x1b7/0x850 [xfs] xfs_log_force_seq+0x1c7/0x670 [xfs] xfs_file_fsync+0x7c1/0xa60 [xfs] __x64_sys_fsync+0x52/0x80 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff88804ea5f600 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 8 bytes inside of 256-byte region [ffff88804ea5f600, ffff88804ea5f700) The buggy address belongs to the page: page:ffffea00013a9780 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88804ea5ea00 pfn:0x4ea5e head:ffffea00013a9780 order:1 compound_mapcount:0 flags: 0x4fff80000010200(slab|head|node=1|zone=1|lastcpupid=0xfff) raw: 04fff80000010200 ffffea0001245908 ffffea00011bd388 ffff888004c42b40 raw: ffff88804ea5ea00 0000000000100009 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88804ea5f500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88804ea5f580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88804ea5f600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88804ea5f680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88804ea5f700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== Fixes: 4e919af7827a ("xfs: periodically relog deferred intent items") Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log_cil.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 550fd5de2404..ae9b8efcfa54 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -1178,21 +1178,19 @@ xlog_cil_force_lsn( */ bool xfs_log_item_in_current_chkpt( - struct xfs_log_item *lip) + struct xfs_log_item *lip) { - struct xfs_cil_ctx *ctx; + struct xfs_cil *cil = lip->li_mountp->m_log->l_cilp; if (list_empty(&lip->li_cil)) return false; - ctx = lip->li_mountp->m_log->l_cilp->xc_ctx; - /* * li_seq is written on the first commit of a log item to record the * first checkpoint it is written to. Hence if it is different to the * current sequence, we're in a new checkpoint. */ - if (XFS_LSN_CMP(lip->li_seq, ctx->sequence) != 0) + if (XFS_LSN_CMP(lip->li_seq, READ_ONCE(cil->xc_current_sequence)) != 0) return false; return true; } From patchwork Mon Feb 13 04:04:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13137845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A657C636CC for ; Mon, 13 Feb 2023 04:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229560AbjBMEIe (ORCPT ); Sun, 12 Feb 2023 23:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjBMEIb (ORCPT ); Sun, 12 Feb 2023 23:08:31 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B66E396 for ; Sun, 12 Feb 2023 20:08:30 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31D1iGnT012031; Mon, 13 Feb 2023 04:08:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=K6ZwHjMAiSpLOg/v12vlTkxXTpInbLNMk4BTI8Pib0A=; b=p8fDc5+NX8DiaQ84h/yjrKMu7NZIgBDDcPDHRIqyrWcMRwJb7afId4HbYqMcHyHErV0N bJVfpWztt0SEk2U5b+0gBkFTINm7ZrdO41bc0mZy0p0Cbf7tNjDgwnbB0RnQMQwHVmAc dYR5+XHHwTdKwgZBxYbGhuW/+xzmAfRjc0IpdVaEJXBrRJnS5kg42LJGlELZTgqEfhSb Ag7lE7Gs6osgMlS0lwHDHJhNsYluR1pWMLO7kYj22GiILFlRvLVDKEcz5UQYFtyvnmQK XWvOrIhlXjblz7BkACyrZiiWc2Mfq7Sen1sfpwCU5r8OHsL6PLH9EnsZIL4/GlMiCLRS UA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3np1t39v98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:27 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 31D3k5ha011542; Mon, 13 Feb 2023 04:08:26 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3np1f3k21e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 04:08:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOdGzygn38YAMfftqUXxTQijgnRedjJYlDzt/dFYSRywjjIWkXgTYqCdQEMH6eTSqO7DeP2HXivXaMn37eQCLyxOk0JVwil4ZQZL7YEHKSlL1Mg/cGxhpNDzfuhB6UzK4m8O7udQpsky8LmXALEjrwqqN2Gd10qw2mlxvE9AYPHTC6H5dZSEHMAMOngJDZLCCyXxu6Km+y3eT7NLjiFJ/OxvWKRVI6W3x8IOY0FyRXPJ9X11ys2UexwIbTEQbfLFpHCxjnGQtCGlUSx1JYH59K5t2hgg4+gyU2KG3JPOv0Qq8nuOHDYsSVlMQjomwSXEBwi9ggp41Kqfm4e3pH+Kfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K6ZwHjMAiSpLOg/v12vlTkxXTpInbLNMk4BTI8Pib0A=; b=G6DpaNtIOoSGFlHG8Mo5wgyTBAzELfLVrqPR0I3uo46nA3t8NIV5knrZ8Et7VHjd8vzgD8q2hfiSyjyJO+cnQflUqdwae8DDnoYDYwNcjiYX4Ci/abU90/RQ0TKfwL0eo4pmB4L/fFQZzv+3uTeuzLoX/fuT3ZWEd+9MdH22omFv6xeAq2wBnnDgfYldNdFvXQWychuLbiBdXP3dbckE6I+JAedpbJoxNpzujS1/Ls7M89ASWp3EPfWIuc+Z6VktZ1N+TLXdRO5B8V7dQXw01Td+CIcTEOMH+QZV7/hWpeOVhV+s6PK7N929pVIZWSktl5/sP6uqFgE/rTs92DJZ8A== 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=K6ZwHjMAiSpLOg/v12vlTkxXTpInbLNMk4BTI8Pib0A=; b=kxqOxxSmzEalxP9qyJ/2rssOQWHseichYe08h72hdLJ/s3j3timxMSbovuYAVOjWAtubZXi1zB1Kho/EDmVQsAOziCkTY5jlho7jRn7iqwalmBqbFfkuIAzlNCMFZ5M2Ltiw1skfXsMSlHen6JAYXgCj4BYfHtxpZNBYFDGoXk0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by BL3PR10MB6089.namprd10.prod.outlook.com (2603:10b6:208:3b5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.8; Mon, 13 Feb 2023 04:08:25 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::6d82:720d:3596:839c%3]) with mapi id 15.20.6111.009; Mon, 13 Feb 2023 04:08:24 +0000 From: Chandan Babu R To: djwong@kernel.org Cc: chandan.babu@oracle.com, linux-xfs@vger.kernel.org, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 CANDIDATE 25/25] xfs: sync lazy sb accounting on quiesce of read-only mounts Date: Mon, 13 Feb 2023 09:34:45 +0530 Message-Id: <20230213040445.192946-26-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213040445.192946-1-chandan.babu@oracle.com> References: <20230213040445.192946-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:404:a6::35) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 9062b231-2449-4a04-4695-08db0d77f3f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e0DvC22adkGfqjWsjmEmx+Ey87YMZv5T1T2nMMOCUt25e+VSZjL0MwXxDAwsSvXgxzAPfH3rPNbC163ZBVQUjPu/+dj/8hgTuho6eME94kXaBXd8/vpCw6Z2wHj5zRCbXfAGveJlSDfBQ4FSKLMYVejqyGjf/7XJ2FIbldT2Fis8aY4r8EPR9tDcvbi+rAvgbbkhJ8Foj9FO4+Grg0KksU51b/g0rI0ZLry4+j8VHgOszaF099KK9gFaKWXNs3ZyAA4YMn+04EpEM8dWJQrmtK9QwCzexFRKkav78unBjdiPRKSH5FIjgVA9TcJ6C9RPzTCHkIiuLLyE3ijATqLggkX1DoeJG7xfPhbjNMg/haSRRLALI/xpXd5NkzCGRrKMMN/dj7zgIqHnz7qd5ncfa20dHUcA5BxGmW1tHI3xEq8jJOyMOxx2kUeysF+LW23d4yOTPkeEKaKb04fyjOdzeR1UPuRFpTBuD9k89J5cMggyEc4lorfWXq9d/Dfp9658ca6Ip+xPb8m8NCaKjKEhzGxM0BkffB7DyJH+ggVKU4ymcKrfjUQg9/500F7NsTyW5VbzqU/l7gdAfKXgazXIFQvGYxJrySKxewoNPzXEF+8o8uX5F8Y6P2a7mQzcnREMLAmVlYr6VFAquEVV+wKdYg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199018)(86362001)(36756003)(38100700002)(316002)(8676002)(4326008)(8936002)(66476007)(5660300002)(41300700001)(66946007)(6916009)(66556008)(15650500001)(2906002)(2616005)(83380400001)(478600001)(6486002)(186003)(26005)(6666004)(6506007)(1076003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bKhBXmBI6nN/F7v2nLTSEzqLnqg1j3thbmQ2msDaxJ+yjSaXvM1XhtUkou+B0GzCw13L6tPFDWLf6rVbgTwqR0bKCpWJfhN3J4MsdKKQXHVbAx24A0gUmdgVjDdfADE5DrCsb7RqTLHlIM61U1duRUW7W6eBzC47qJArfec1hDAASs7bWXIXrpyTepX2vBGDysIImNunu+i0xJw72+XDSEqwaLs0r/twvLq7rVSqfUCL9uh8QV9nvDD4tbBairNKrpwdvRodnsskm2B59CZBMftvDs4v0kvnrWN9YNZWHoJ0oCcmqdwnBSEb1GNW1T/re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Bv6F1Bt7No57slhy0N2+PnZgAGBc5BGkW88gky0ZP1aixf3EsaBmgXBSKiszDw8dWfwBk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9062b231-2449-4a04-4695-08db0d77f3f3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2023 04:08:24.9070 (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: simadP4i1vVeGTmMSRfQZ52+NSo2hOuWwsfJPp7H0JSuoZACsbuLJJmSH5vuEjdrnUKafUsUODaFD3tvd2JZSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6089 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_01,2023-02-09_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130037 X-Proofpoint-GUID: iGymu1Z4LZCKjc5MNmc9vGkynLvRHX4a X-Proofpoint-ORIG-GUID: iGymu1Z4LZCKjc5MNmc9vGkynLvRHX4a Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit 50d25484bebe94320c49dd1347d3330c7063bbdb upstream. [ Modify xfs_log_unmount_write() to return zero when the log is in a read-only state ] xfs_log_sbcount() syncs the superblock specifically to accumulate the in-core percpu superblock counters and commit them to disk. This is required to maintain filesystem consistency across quiesce (freeze, read-only mount/remount) or unmount when lazy superblock accounting is enabled because individual transactions do not update the superblock directly. This mechanism works as expected for writable mounts, but xfs_log_sbcount() skips the update for read-only mounts. Read-only mounts otherwise still allow log recovery and write out an unmount record during log quiesce. If a read-only mount performs log recovery, it can modify the in-core superblock counters and write an unmount record when the filesystem unmounts without ever syncing the in-core counters. This leaves the filesystem with a clean log but in an inconsistent state with regard to lazy sb counters. Update xfs_log_sbcount() to use the same logic xfs_log_unmount_write() uses to determine when to write an unmount record. This ensures that lazy accounting is always synced before the log is cleaned. Refactor this logic into a new helper to distinguish between a writable filesystem and a writable log. Specifically, the log is writable unless the filesystem is mounted with the norecovery mount option, the underlying log device is read-only, or the filesystem is shutdown. Drop the freeze state check because the update is already allowed during the freezing process and no context calls this function on an already frozen fs. Also, retain the shutdown check in xfs_log_unmount_write() to catch the case where the preceding log force might have triggered a shutdown. Signed-off-by: Brian Foster Reviewed-by: Gao Xiang Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Bill O'Donnell Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log.c | 28 ++++++++++++++++++++-------- fs/xfs/xfs_log.h | 1 + fs/xfs/xfs_mount.c | 3 +-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index ebbf9b9c8504..03a52b3919b8 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -369,6 +369,25 @@ xlog_tic_add_region(xlog_ticket_t *tic, uint len, uint type) tic->t_res_num++; } +bool +xfs_log_writable( + struct xfs_mount *mp) +{ + /* + * Never write to the log on norecovery mounts, if the block device is + * read-only, or if the filesystem is shutdown. Read-only mounts still + * allow internal writes for log recovery and unmount purposes, so don't + * restrict that case here. + */ + if (mp->m_flags & XFS_MOUNT_NORECOVERY) + return false; + if (xfs_readonly_buftarg(mp->m_log->l_targ)) + return false; + if (XFS_FORCED_SHUTDOWN(mp)) + return false; + return true; +} + /* * Replenish the byte reservation required by moving the grant write head. */ @@ -895,15 +914,8 @@ xfs_log_unmount_write(xfs_mount_t *mp) #endif int error; - /* - * Don't write out unmount record on norecovery mounts or ro devices. - * Or, if we are doing a forced umount (typically because of IO errors). - */ - if (mp->m_flags & XFS_MOUNT_NORECOVERY || - xfs_readonly_buftarg(log->l_targ)) { - ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); + if (!xfs_log_writable(mp)) return 0; - } error = xfs_log_force(mp, XFS_LOG_SYNC); ASSERT(error || !(XLOG_FORCED_SHUTDOWN(log))); diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 4ede2163beb2..dc9229e7ddaa 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -132,6 +132,7 @@ int xfs_log_reserve(struct xfs_mount *mp, int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic); void xfs_log_unmount(struct xfs_mount *mp); int xfs_log_force_umount(struct xfs_mount *mp, int logerror); +bool xfs_log_writable(struct xfs_mount *mp); struct xlog_ticket *xfs_log_ticket_get(struct xlog_ticket *ticket); void xfs_log_ticket_put(struct xlog_ticket *ticket); diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index bbcf48a625b2..2860966af6c2 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1218,8 +1218,7 @@ xfs_fs_writable( int xfs_log_sbcount(xfs_mount_t *mp) { - /* allow this to proceed during the freeze sequence... */ - if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) + if (!xfs_log_writable(mp)) return 0; /*