From patchwork Wed Oct 26 06:28:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020187 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 9CD80C433FE for ; Wed, 26 Oct 2022 06:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232903AbiJZG3H (ORCPT ); Wed, 26 Oct 2022 02:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbiJZG3G (ORCPT ); Wed, 26 Oct 2022 02:29:06 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD8A78111F; Tue, 25 Oct 2022 23:29:05 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nbxW017465; Wed, 26 Oct 2022 06:29: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=CuS5xwhzrGiDYNrEZC6K96sMt0jPZlNlAqj+Qp4/0UY=; b=f6gKPcdGsZ1v6gGE2NuiWfoeBKAEBW3cWGLQrs1kLDw5vP+XszUVdCKkrTtgjcPwI7wY prylM7FvQ0lKo4YLAMjCvRXbl1ift7NxbeIIwnOKOn1SZSnjTtLZvcd68puDEZe2J/LI ezbFlFV9evYOOsThwkLSMIF+7zx6XWnuE+H0hJrLon7+z1yOFg0O9U20EoU8AzJnBZzz pW9kQEo6Vvu7PYKAbaitb4WoTavOnT7dckvNAf7gKhzYOd6vN0X1KK8yLNKBG2c4Z6ps wRM6y4mhTHT8m3qvuIzX4TXS87GaKdOSnX5HKhvmBzUb0dwKcu+DwIc69eBx8EeYQdY8 Yw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e5yc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:00 +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 29Q368wX031888; Wed, 26 Oct 2022 06:28:58 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybe72x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:28:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbeRmJKDLxeLPXppC5XwzvXqFQZmjJD1BaXJZdag6NHQ7HSMuMtC+blsh1ZeuzY4yyrKhN4WM9kBuXxpId4sYNQF1rLA3r+IIkvBgQaJeIVHCDxl52hT+pelVvqaI5XKdUVk+kp/EW7FY80v9kHguvrnQ5hWFBcxU4GyZ/fSIheFPvK1wSrPNPyaebvFk4YW9GIk8hneKUBnfQCvzj1KzOSIk6l47A46L+seOZvzUInxgnedQxmX4141QAplXBKidJPDbrsbRWBtlSStBpogNkFRPPxpY6E7rPAKL4o03IGUWz+ZamZuEhs+gmt/cR2kbsAaUdmFlQcVw8VZJvINYg== 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=CuS5xwhzrGiDYNrEZC6K96sMt0jPZlNlAqj+Qp4/0UY=; b=RwQjRA2j5URuUsbmGrVGWusyiO3aJ7vjkMRz8+BdISlBIcg0zm/0e+zskpf43oORWhvZ+JyvFcIWBgmxkVFHSgeK/7h/IBKh8lnDLtFasWRSm1zUvk4VbRMcYgQUrb6pflr7GA8Jp4lhTyF93JI2ANWhP0FYWno4SfFo5x3nsN3GV9XWBr9yPO55TsmFVT82tjujw17/E6xtXikDUunxrITAXp/4ZGdOQzAX4zb9LI+CBg5OxJMDxSF+VmJ0SBwYomc8P6mAbLeSLRr87xCynd0s+vYy2Topi2dBpZ6RTx0lyHsn3mBRl2tbAtBtHWNvYabPKlqbuRegb2QrNYyTmQ== 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=CuS5xwhzrGiDYNrEZC6K96sMt0jPZlNlAqj+Qp4/0UY=; b=gRsjFDITko9pfrsT7KEbUWdB0UzYirsrHuZ0konekLcYnrXns7IouPOsaMsGBCX1GJrL0X6EBRVpsRohUyW2fKJVGh/8Nbecmw1t0gjMF09OxhGnv0GGTBxOna3gpqGepBi/1LL2S7kYR1wUtVeIPv8z6Fz5AJeZPkPVxhe6fuk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4498.namprd10.prod.outlook.com (2603:10b6:303:6c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 06:28:56 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:28:56 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 01/26] xfs: open code insert range extent split helper Date: Wed, 26 Oct 2022 11:58:18 +0530 Message-Id: <20221026062843.927600-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0002.jpnprd01.prod.outlook.com (2603:1096:400:a9::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_|CO1PR10MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: e354fca5-fe53-430c-fa74-08dab71b5c03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fQObL2MXhXKj9mBFxFGGhAF/6SQq4/iLu6s4b8kE1qv9s6qfNH8aXzKD1/oXAL9bicncnt9xg2G7MEEQLbVxuj+VhjaNVAV/y3Oxrpck4yJeOQZwgXX55Yi+KpigUbSlRrL9kgYdqL4tgR3wVHKUezLbg5AagL4SdPK1Dl+4DBv7h8jaIZWIrohT0UC/pgGZNSXu/fQhjla7IYC1aqYCdyYy0i0fHzQrmZqjVaig6C9zBXGZfksTGxCpAM2ceVROD9iELfbioxhROSGH0oQIYghJVyGF5q0gS46tu8pRk9RwU3fY15bbsbhxJfu4Ip3d1mh07vYSo85eD4GTkDSHRJE2qiaZlfNa3lbwaag0iR1/0My2lqQOVvVtR6rnUwMexNterEnXNuNLNYJzX3MBYgeMDBE8AhYLddbESs4pT8fQcfuxjrfOPPKMpAgl79wYsbN7dU5TlgMFGERaP3lW9qwshVg62EaiGx7j839tR+FsMuBaKcs7U3niUlHhOV3VUWxUM75lOmyHig3NF8oeyB+zkQGFXDvRnfE/mtL9lJLs3ZUdG0ZfE9ZK+af2kmbvz5M4iUfrwPst91JCdG5srD80PeEiutgqeVtfLPxfPPb0iH6dmAZOzef048xvRMJwFTpUdkFV3GQD2zXMZTTKgtABipddnkl5IcyfcuxXjQSsZjt1gmV7lkJkOWnM1ZhKavf93LzzVznhAL6Azm1Izw== 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:(13230022)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199015)(186003)(66556008)(41300700001)(478600001)(2616005)(66946007)(1076003)(66476007)(4326008)(2906002)(8676002)(38100700002)(83380400001)(86362001)(316002)(6486002)(6916009)(6512007)(6506007)(6666004)(8936002)(26005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fspjqld80oYbefSCRlyrhdZLC+CaG6rUy5Q7XhzfYJAByMXm5vCXL+hj9gY/I77DUGtb252QtTTkxGO0tnj/Bo6ZO6hcpQiubP04gL7MWXgTCaSY9gOlTHCXEiaY5E66T+a/ygQMsLReuwO78jhozpBlY5M3ct5oemipEYlSsKgggW6aboD/wQa7hOPhxERqjvrLEZ4Qm49d6Qd3tOKGzKajEpkxl3K0pJllk4dXuqtd3QVxjhfihZgr267JrjWhygayDfFRNBFbPFu7ptOJvfOTYu2+AQVOZliM5SGbouO0VUsAOXQ38Zrk/XGoDj5IIcjtbdtOsiaB0Gw8G/On/2u4MX3mrhzZu50pAfCwLnB/A1Uz8SON3SJdg7D/XYMHI7zcQtw/7f34Mt7hSVpxxDZq9dn2FJY9eDL6CYJLzZ0TF8y59dcN21o2d2MAC4DwWG7HiEICQ+6emt0XhSUX99LSKRxnm+z0yKBcwqC4YeRZXQOiWuEOi84Dh81/1P0Ot/P5C1JmJJjSmdd7oXZ4K/eazrwbj1yb+t2Yfd4mmsuTShRwrC6FvH8ysRdAR5Vgz6qYC9awGbssgselOjCuMxTNcWT10KbDVxbnkguGX+rMGJHjlbb1LYI6zVhkiavM2nvPQByYWfNxgiKWYAn3C1DnEZBIGDMHCTL83qgw5Wll1Z1gnyYb8v6bk/bAqHn0mTHkx3mn7Z4L8TAjSkcXRu3u2xN33rPgXdHD54J9JPOBsUwm73PaqOqSvHz9tKuxqcRn2IyGDHIHSO/kfzyycfXLQoFDz6+P3NMJEZ3vB+tOLfMuUHFvkUfgEaHTMKNehrBcst5e5xXtFOEW5Dnjn9szMP3RsvnNFZlF3uRKO4vWNlMAM9Fclgeusl0EL+3C8jnIhOMB3MuKvZXVP5pON5Q0i9DQTv0YFJQUgX3doSrXRqnNEO6HN+W35HnK7ciWwT0aayeQl0pErtc4dlSZLC2rwFzqMs08OHAL1P0TTpaTGfEeuim575bMF/lTRX5Kxe81TozhBzlkN+yIICd6Knv4TeVAdd8MmjLHFkU3Q/BZ00uJF+4zsygDRspWoLd4isqTGf0l7MwCo24byQp6I3Xat7Uxb1X1lpKbyHx8k4v47dlUjKGvzNTc040tb6Jf6NJvNFoC/ypKgE+puKvLiAWs2nrovwYAQ9lspWQYk5fCZwZqkPFdFoq99trIgrY0HyHNUG+AYCApiSvauvkRD2RU8AdCcVufY31nsRScAhVsOJQMd5C87YI0L8BkKbkFMjZNyDWRHRE7d98oCuRTKxI4xmH6HLgrEEIxy5DUnSB/mT2iOKXzT7RAhSL0fV4q4BPvmo+Cl1KPO0H0IOu1E51Nh3o6uhmYQ4TTQPw+wuQb0YXwA9Z8pwHOPX0/B16nA40+8QFTrAClskasdVnPQErQHKAYtwLbvAZe6enJiJlyde6my31Ku1Vc0xdfyHzHdacgt9GYgClS7gtHd3u3xj6QBsLhrvjt0pl428YUICGdBxYb1+U+zICiCCCHpTWnnQOIJnGy3lBeY+6yYHqz+WsmOz86OmXX5Q42FmgLaOzWC01mX8mlKxzB16160Wiv9U5iNUhOBVOJfSV3xMMYEw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e354fca5-fe53-430c-fa74-08dab71b5c03 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:28:56.4297 (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: Al86mhScFM0vkr0vq4+yefyK5Gf7hG7By5FXebi3AKMl4Ol71xxhgJuTOV1h7HCJBwmEip3y/AsXvR2lx3ROLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4498 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: oaiI9gpd-z3oZM0rUSBFAwGYdaNVvQDz X-Proofpoint-ORIG-GUID: oaiI9gpd-z3oZM0rUSBFAwGYdaNVvQDz Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit b73df17e4c5ba977205253fb7ef54267717a3cba upstream. The insert range operation currently splits the extent at the target offset in a separate transaction and lock cycle from the one that shifts extents. In preparation for reworking insert range into an atomic operation, lift the code into the caller so it can be easily condensed to a single rolling transaction and lock cycle and eliminate the helper. No functional changes. Signed-off-by: Brian Foster Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_bmap.c | 32 ++------------------------------ fs/xfs/libxfs/xfs_bmap.h | 3 ++- fs/xfs/xfs_bmap_util.c | 14 +++++++++++++- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 8d035842fe51..d900e3e6c933 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5925,8 +5925,8 @@ xfs_bmap_insert_extents( * @split_fsb is a block where the extents is split. If split_fsb lies in a * hole or the first block of extents, just return 0. */ -STATIC int -xfs_bmap_split_extent_at( +int +xfs_bmap_split_extent( struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t split_fsb) @@ -6037,34 +6037,6 @@ xfs_bmap_split_extent_at( return error; } -int -xfs_bmap_split_extent( - struct xfs_inode *ip, - xfs_fileoff_t split_fsb) -{ - struct xfs_mount *mp = ip->i_mount; - struct xfs_trans *tp; - int error; - - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, - XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp); - if (error) - return error; - - xfs_ilock(ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); - - error = xfs_bmap_split_extent_at(tp, ip, split_fsb); - if (error) - goto out; - - return xfs_trans_commit(tp); - -out: - xfs_trans_cancel(tp); - return error; -} - /* Deferred mapping is only for real extents in the data fork. */ static bool xfs_bmap_is_update_needed( diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index 093716a074fb..640dcc036ea9 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -222,7 +222,8 @@ int xfs_bmap_can_insert_extents(struct xfs_inode *ip, xfs_fileoff_t off, int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, bool *done, xfs_fileoff_t stop_fsb); -int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset); +int xfs_bmap_split_extent(struct xfs_trans *tp, struct xfs_inode *ip, + xfs_fileoff_t split_offset); int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork, xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc, struct xfs_bmbt_irec *got, struct xfs_iext_cursor *cur, diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 113bed28bc31..e52ecc5f12c1 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1326,7 +1326,19 @@ xfs_insert_file_space( * is not the starting block of extent, we need to split the extent at * stop_fsb. */ - error = xfs_bmap_split_extent(ip, stop_fsb); + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, + XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp); + if (error) + return error; + + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + + error = xfs_bmap_split_extent(tp, ip, stop_fsb); + if (error) + goto out_trans_cancel; + + error = xfs_trans_commit(tp); if (error) return error; From patchwork Wed Oct 26 06:28:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020188 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 9D970C38A2D for ; Wed, 26 Oct 2022 06:29:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbiJZG3N (ORCPT ); Wed, 26 Oct 2022 02:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbiJZG3M (ORCPT ); Wed, 26 Oct 2022 02:29:12 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C07D8111F; Tue, 25 Oct 2022 23:29:10 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1ncWG024731; Wed, 26 Oct 2022 06:29: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=Z7PTaza7wdB2aNoNRBP5aaPMA9zmPa6w+sXq7X7AEoE=; b=nJ4R9eYDgmtHzmLZyAQY5pBbOWeTsvju1eGD4M6P7C6rsj9fHkzryVXsBp+9h36QR+i3 68ree2zMj9aSH2gZiPni/zXClWrfav3T9eZToYbvoOwclmkUC5psVjytcRzhYcyGtq82 HcqlEe3YVkGf3Nq4bB6kKWr7Nro+WtVl2IjXuuWhUg74i+TcN3riNgK928PigWKUCmDe USxsUOn36dKSWv8l3pPo2Ye3QgjivjV1E64TbCyepkG8OmbCJiKtDduMlBQPQdgHJvQT Z3R2dQS2m1JwBBuF/We2Hz71HhTyFo+Wwh2bgQ0C5hfIEJqwIjZZP3PxgmQnAMCMjPFn Mg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc8dbnbfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:05 +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 29Q6A6jW013363; Wed, 26 Oct 2022 06:29:04 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2046.outbound.protection.outlook.com [104.47.51.46]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6yb716j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H1htDHE4wx21GqmGA34elXlpywtWZXwLqi3HLM/Fve5XKf0Dxogt3FfSuxp/WqaTJhqgi05LCd+i4Occ0Ruq2NFC+aTRs5CAr4pnR+ChkkMqtnqsOQny3ORgpNH5LJB94AM4vKLXODm7XNIlK6iAHNznFm5jBLDgbpvUuUtsZjMbk6oeRRqhj0V8LAmsUPFs9RilUtN4kOoor4Mh2bw+Fs8u+NGC80HiwdM1CYOv0x9sLDDjaNyP43BGYH+MPLOl0L1b8g0fDrr4XumC/0MUtco3+Dy0gCMkM+S9Bf3iNu2/Bw1ckAbUv+Ppv9cF408AU+VfSZuRGxx9AnF6ufoI7g== 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=Z7PTaza7wdB2aNoNRBP5aaPMA9zmPa6w+sXq7X7AEoE=; b=nbm0Ye9aiNyw/GkW33y6jfLXue6d2Q74ysYtyjv+sHIzt+8SeE9UKogQjjBM3nWZelESyHdvsXy22BP9dJvDHY8mYGkFw673zp2vNSvafPdXaV8O6507kEpoXDIP20ip6ICwNMxTmp38Q84f4fB10WoRHFute4fipCsL8HVUcNaj0VBstVkQ9Ws0jVC5wNjf5Dmxns1sVkz69x5b83erA4YSR6zJg1wkYFCqNTcw6WrqHX5hkWDkoDzfQh0I8T2H3c2lAv6Mc9cLKs/TtNPtrFgQXtuQ4PO4bXrNfcRJxHoYsBm+jeODop0yDPs1pK2wCMTiu2c9pjjHC9+29H3y7g== 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=Z7PTaza7wdB2aNoNRBP5aaPMA9zmPa6w+sXq7X7AEoE=; b=O9YnyAOqZ9kLdo68dfgcRW7sdNB5kueg1/T2qwNaOl0mjybQGh5y844ScobFqBuVKzos90kjNBAW+HIu2ezkk+8rU+ea2S+48r4NVHJLQtMDLyM6MuYe/QWJxHPKlaPoJ69qABSuUY5bausJH073anO6v3Ve3vYkMicaPYXlQ/k= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4498.namprd10.prod.outlook.com (2603:10b6:303:6c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 06:29:02 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:02 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 02/26] xfs: rework insert range into an atomic operation Date: Wed, 26 Oct 2022 11:58:19 +0530 Message-Id: <20221026062843.927600-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR02CA0007.apcprd02.prod.outlook.com (2603:1096:404:56::19) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: 744d8e40-8cbf-40e6-9ee1-08dab71b5fd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /Tri2OpulOXmbxu1JQFeWLNi+VBpoutCh4wGhOOwQMF6wSOhVV6Or45QDhwyQpNnO9DaLVVK3BQYZezUp0AfDCoipdh2dG9/2eDgF4ygyO5VJAdSUIIGv7z+Ev2o4iIZB4oAovj7+JXB/yNpueIhVu8I2kTGQVCK15CcO4K8vc+HRv++ruYFSuQaXwzMMFNx6kIJJIlU6xyNBf+IjPBMDSRsfA/VPWA71XkF/OPm9JJ7nOrjsZiNRa8EupQxM20buwQvflhLOpSsX13DA7E7hsFWYtg/WEx8wKRvFDnzkyfEaQRtMIMZcMQ23C3VVa16ke9SE9BrI11UHdlvdxOsyPIZJ9E41Sg0W/P3zZKMoiUqywgt8k/AvYLaFZwbcb3kM7KRfnuDjSKtwq+VgDJyl/QDky8Iei/GJBmfM1x6KWTv3jMQ2Bdmm96dTF99tE1GzSgZwAz7Ske6pEgb7ufQzNSJmX+8fg4PBSoV89aVa5VWhTrVLuC4SD88TTMkZkCqhc7U6CHO9ehYffqhNOww2m1lo7CuMs4dnmvMUDHuOTHumoSHdfjcdTBhNTrKi2s/n2OgoCWF05JjhGrvosFgpsHiOpo+CVI5Ifzypk0htupnNFjpVvkIe7jNrB/dy6twLhY/PNn5ngA+jlIWMCYDjWBg+BgSvLiztYYIjoR6CvbqZu700LPZ6V2xG6+OLt5dR7RGvwOYwGflxWFHRAj/MQ== 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:(13230022)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199015)(186003)(66556008)(41300700001)(478600001)(2616005)(66946007)(1076003)(66476007)(4326008)(2906002)(8676002)(38100700002)(83380400001)(86362001)(316002)(6486002)(6916009)(6512007)(6506007)(6666004)(8936002)(26005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3gOKLtSrqxkSBM4blwjL+kRrZtUwTJZyj0HvKXWPlufZwGI3IJ3NFyPKM27cRqk1pGDuR3g+m2RmPD9VW/vKenc2Mf9c4iBFskx88SyLaesoEnvfAjqfIF/EjrUfTy7UTt3w3u4Tf4mj1IqfQ8WsR6jjMmDi4Oj0Rh7HdP67UXQ8lLMUs6d8mEgsvWtLdeETffuTEn3+IwhvP2ZUAftyDLAUyjlECWEV5VpBq87ldtEVUFbsAX+rj77EsoPRNK2Bc+s0cpzIpHVUQyklskRMQCHB41e17hPq9oHQooIisbBfUl0ldFhVTVhqnRd3vp8WhtSI7YpqIcyRMvT2G1zUZbLIZZBYZL8cnU4ha+n0nwHVDXy9Ok+4IjGdzpO+RaAgRoxQgNCq7GOJs06jKbsnjua9TM+r6D1O8PE3FCCZ+WRbrd1KDjF1JRZrsIQx+KtgGIAQeQvcnG254ZwyjbT9YRxrnj1gdRV/GxR0qU4GmaWF6zyvB7dNIH+WcNWROYlvm8sr5CZi710GKfGjTuluu4FmrXBWZhmAwfZGC87jX55hjljzkltG73iZgRXYnLYDFUShCd0FZ27wSXnYqjsnZLgjs+OBHIlVEDiKv6IsoCbUVZCZ6ilMoCeUPA6gFHwkfCGbOZBGDsFeLsdUdKpvaimqCiPN8KRKgBTkyAJnRgXhURpu3lPjQxtFDzXIrIaXugcJS0fcujpq5nz1XziralzmD82fKmMCGLnX7LgUZXr6lRwAS2Eau6HD3JD31Ki5WQ4KEhqCWhkv350Tjo8ip5mwbKbH2sq9PYOS5xOsMFlM5KGiFnQ98kl3WEpN6ZhtIWcGauSGfWJ73OnT4klIW6xMeTw0WgOZwgMWnP2whXZpTNdbYzi633aWV4FZyd6ZMke6v3ICgAfRuK6Yo9umZzjKELDjCI06bvH6lZrKvvyImNeA2DItRyev/DhqOhzDOdS3SdMKi0QOnXtg6Gf2SSQk/mqZcnGX/iRvUocolT9KzTm4ls+MZFG7/moh+8ceq2KSgEKln6h0qNlNDhnlT3ukPbWtz+fiudEusxV98Q8B+TLzQFdSmTMk/B3T0oNPaf3gmChaFuJqtTjBlsbgbmSOr67lvg9wWZgDqgvHCxyeawwEgGQTsLSHWkXouC63sXtyYE99Qe99XuVEPppYbfdSsiiFVm13HxmJq7ksGmHzIwmx6JCDLOqcYzzfobq2Qo/6gfUO6yNbE6WH7qAlxzuuQgyfaUcBtwJcn17IcDn8mHPBY4F75+En9UPZEbd2cNObe4/fZqu4iOmOyk8Y68+CchNMxchJeanrJYu8dv7GJmRqKGIop6xhoo8jNvUx8pKV+iLXgMuM4PQkNT2D1OAad/JmcnY9ACT7u0Hq/3b8Kl7WWt9ht2zvroL8r4OrLItdL9GpVzMyO2ASm+Il8prHSut2+BeEgFfZ/PtmsxJHiRPlFdWem+aczk0sSoN6b7y2SOTUsNfuYTUYOksICbH/2/95pYTKOYUrXYekrG950JwVRTF1NJrD1xdXzo+Dsbzv55KG4rQVSxuW7yTMKjAHK+VAc+5z9Efz+6/zweVaxqH89rstJdaS1nz+JvfY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 744d8e40-8cbf-40e6-9ee1-08dab71b5fd3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:02.7144 (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: DZK4NUIALg6NeAiEVAia4iFdQvIkFJP8tFWQALKopxM6IKYL26wKe1iBj5spSFFzEh8eujCZV1wGyBQYWBu0CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4498 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: OZ3776P1WaFo4B3Zt4w_dSGSjhkNqkTy X-Proofpoint-GUID: OZ3776P1WaFo4B3Zt4w_dSGSjhkNqkTy Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit dd87f87d87fa4359a54e7b44549742f579e3e805 upstream. The insert range operation uses a unique transaction and ilock cycle for the extent split and each extent shift iteration of the overall operation. While this works, it is risks racing with other operations in subtle ways such as COW writeback modifying an extent tree in the middle of a shift operation. To avoid this problem, make insert range atomic with respect to ilock. Hold the ilock across the entire operation, replace the individual transactions with a single rolling transaction sequence and relog the inode to keep it moving in the log. This guarantees that nothing else can change the extent mapping of an inode while an insert range operation is in progress. Signed-off-by: Brian Foster Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_bmap_util.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index e52ecc5f12c1..90c0f688d3b3 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1321,47 +1321,41 @@ xfs_insert_file_space( if (error) return error; - /* - * The extent shifting code works on extent granularity. So, if stop_fsb - * is not the starting block of extent, we need to split the extent at - * stop_fsb. - */ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp); if (error) return error; xfs_ilock(ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + /* + * The extent shifting code works on extent granularity. So, if stop_fsb + * is not the starting block of extent, we need to split the extent at + * stop_fsb. + */ error = xfs_bmap_split_extent(tp, ip, stop_fsb); if (error) goto out_trans_cancel; - error = xfs_trans_commit(tp); - if (error) - return error; - - while (!error && !done) { - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, 0, - &tp); + do { + error = xfs_trans_roll_inode(&tp, ip); if (error) - break; + goto out_trans_cancel; - xfs_ilock(ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb, &done, stop_fsb); if (error) goto out_trans_cancel; + } while (!done); - error = xfs_trans_commit(tp); - } - + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; out_trans_cancel: xfs_trans_cancel(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } From patchwork Wed Oct 26 06:28:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020189 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 AD4C6C38A2D for ; Wed, 26 Oct 2022 06:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232733AbiJZG3S (ORCPT ); Wed, 26 Oct 2022 02:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233068AbiJZG3R (ORCPT ); Wed, 26 Oct 2022 02:29:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAB3A81117; Tue, 25 Oct 2022 23:29:16 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1ns9H018188; Wed, 26 Oct 2022 06:29:12 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=jZdQBzRUMj12m7lYoQnh8mJxlGjNkgHEUHfvoyuIOh8=; b=Wd8bpdhzAvZkUqjHuY57j9sgAWMmmx09MiJVUkaVYCrS0OUziye7PkRXwJFb+xFs3fXT q0Hl3bBFPStQh1brqCNXNLQIOXHKfpck0bxUPzGWhtV0zTUjunUa0VeXpPQmlIYE3WHy S3NpXBlh628kLXzUS5+NWpm7VO+JWQsITA0hueNtGnOiL7ISkbb0LmE6tAMqb3nV2/YT 18blySs5a/GLpSBxI/buRe2/p3zDr776zRCaWwt3hCBhUWuE3gm21GOUamUa1EtS+hBz g8/6ejnXFxfELuOZe62moci9/7rvBtdz3txJ2igI8EzZ4al+2X94RKTPVGWU9l+Ht9VE yA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e5ys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:11 +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 29Q37949021975; Wed, 26 Oct 2022 06:29:10 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2048.outbound.protection.outlook.com [104.47.51.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybpqe8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIsulB5XhV0cOPlwEE6L/3lbsp7jXpFor01ZOn3mhoI4ugIO4lAwQT/W5Hhk5hvCyj/YlmBSe9bXaGT7g762my3OFSWAYkgYDM+yF+tzNiqMjJ9pI9razWPES5dk37LpG04YXq4K4JPAW2k+1TOOKk9l7cp9e6GKAxhJv+WxNRUyPzaoSZ3hatPG5ExcLLFjOQ6QL7Hv+GNCoO/ak1Ccas/wIZWSLFAZAlmGcffHsQ8eVN6sFKtxdsvM0lU8qcjzhFx6/pdBp+JJKyCyLA0UPXMi7awQHZzXyAiECv71/+JYh7dOPkW1jVLqOdW4ZWcRsoq0RHxl0g78V1AR8l4wFQ== 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=jZdQBzRUMj12m7lYoQnh8mJxlGjNkgHEUHfvoyuIOh8=; b=C4+s9NDP1i4b9q5iAH/4/uPDvF1bdFh3Lu+I0RnTN/i4M9R0HRn2+cVHNiBNpPfyEfLUxaugSKLO+PcqiN7DmRSg/35OUsZNPTUyr2sMXJ3xcT64FnDwAGrazdMaW+H4Dpf6RaDP5eYEvVFb3HoK/R37+S21DFHxYC3aJfUEgwZX3hz78zph5cmFWpSDMl7LLbus6+6RAnu57YelKFhaiOSvtbpxxVE7hB2bHtvId4yMh8pCPSCouJIKBiNknOpv8zfrMoGvwGUwwLX0zVyfhmavl3LvUpKDVKxmN3U5VPzCY69LM7+RWmLACjJujTByLnLrLXCOFA1MPmkzpjYEKg== 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=jZdQBzRUMj12m7lYoQnh8mJxlGjNkgHEUHfvoyuIOh8=; b=DrYgLfodevLJDBcS10HrytbLvutb78zp7iKEEsA+G7Mtz0yev1t39QGTuzXbP6Dc0XJ2LQ7G53kb9PMXQIIXGMX12LrJc+FoNSSXTRnQoejQTfafLn8xPNyijj36AjvjBs3xqvwcIL9ftnB8Bhw9EL0PnmK37Ushak4fhnPIsUM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4498.namprd10.prod.outlook.com (2603:10b6:303:6c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 06:29:08 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:08 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 03/26] xfs: rework collapse range into an atomic operation Date: Wed, 26 Oct 2022 11:58:20 +0530 Message-Id: <20221026062843.927600-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYBP286CA0027.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::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_|CO1PR10MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: 75ff6c64-07ba-4235-5c81-08dab71b6352 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oZk6GYFR2iyXbc6RK3ULF3mr+7spFanIn485HpcVRpCkY3NP/o7SsIiG9UiQ5zeB/0cfhlhOnYf9YVBsU0Vj4ohO8ttBp4O2LY9Zv5OzDgR++R+VuYywF1IxEsz9ynnVbEZmQ9JU6anU7Tk4ErhqUqMJyvsS4WiHWpcw/6Nua6elRaI7l53IoTRuIz7jO16+FNRJtJ3Bz9a8kGdbHBd/8ZFwd7zcAisErdKsGruSgC82uHjjqp06I9xNM/JMUSFCjCMKlWr2ItPkPl/XDRh79YFfEtPQ+LH+++KflaPFZC6SIKwXtceUaAAe+hAk0jE2Ghv9DQBbQgIpHxzI6edUNiGys8u7SQ/mi8F6raAdz/M7NKLvq4XSkLwU1UbnR7JMG/dyqj2cx3ty3JFz4OxDpfCCGGwf7rQwrKim/Hm61nIDi/6DNMUv5+VWJNCgU6SiXzlUIPfE0PePHkuo1lxquXbnbD/DkFLuMC+45TS1u8THhAe6mtBTSBvsYDjrEHz5Iktq0ElJOPEDRtwQycZ9unlolMwDLTwLWcT8tdQPUWYP16EHotq3v2sNhbGhvJMxe3GIerDd1UvPiN7BLRygVyB7ycBypu/CUEXOMP6c+XQABOtPeVYOIf7T1bQVZ3VJSbl5uZtOXAQhzKs/jWen2PWTYB1ekGfTpqm4MgHKecgsQ70o+FNs+CcRromOANEyrSGvHQRlmnYvHv0+9TGsbA== 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:(13230022)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199015)(186003)(66556008)(41300700001)(478600001)(2616005)(66946007)(1076003)(66476007)(4326008)(2906002)(8676002)(38100700002)(83380400001)(86362001)(316002)(6486002)(6916009)(6512007)(6506007)(6666004)(8936002)(26005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JaBm3MB1wa0bSNpLje0o5mITXgfUleCVEcq+qTO3POfsyIqOt0Qlqx3hpqO5H6+VcQBb/As/ZAzgquB2I7Qg7cBT6m+3mCebbNUUhLVLa6Xah1tIk7LdaQPHRhp43HHrAmOdp4YnHi6ILWRHH6MYDcP+5whqAilOSom4kTJ+Mm09Hr975ulji6MinFxl1vgB4jANaxtP500ViULiV7WmwJJYdfx+caVvcSlek5Dy95WsQ7KItOnyEhaZIvjpkPDGM89foau6KTXoraHuq7Uy28YPO9ZrnWpZmBZownrJa5wK/jQ3yy6MQYj7pNk+t+ZSDcvhA0/ke9GOnRXxb9NrHIXIfisTLTUX/VbJ4c+RWQj/VbVTuFAuLGBBl6Or1OEt6x3D/O9j7i07DUBg9N6map7WDdGZBM/UEWRoSGy68DMuCtiofDsULMty2w72NQmmzv+0A3CmRAqQ6q/4Ji1CsoI3bRG/kvHrZpsPhWqJ2oI+bLJhxgyQctAApqAI8SBWGomXR8zCAqAK0dvkg4YnJXB5JW/7srxigWpgZuZLPIKoE6ZBftOWEXh0kewigcUxrjee7vkmLTYtV6i8qnRxjRiNCiKohsmJDdQ6Osl592mktVZzb/ohJhOkxDWMFrwo57deYzMC7exsR0rIKJiZsOBQGxGECSd/t661T+zI5bmzaGGm34TdEfYYrHya38TVSmTG702SUG/r3nBdBGpAwKV8mlOsAeJ4vXOWvNfcOFmCIh681C/m9yXUWtnsyrm+HMTYIL1AyiFLPW1B2t2ma1q3ri5Y1CxkwDk6GT2sOXZGTsdmYcetDxp+YFAGxiXutv7pCl4CunUeZ5O1OAgelRlFejHqT6c6ZMXgLpp6Af6lf5fMzvfgR4HhXrhD+M/lssYJZk/qA5mGUIbOhoW/yt48flk+3gRPALzqKCHXUaxYVyTk89NR0njqW+40VQOqv1c1ZKnauhkZrGWXwYnU1ItuGaZwy8mFFfmuS4trGwYbuvTREQnz8sQ4IYnAK7RtvmvlTr8TRxd5nNa0C+yy/WWt4zlVxbOyFSIycFEyGPCq4GyREeqA7a0kROGc9mV2qE7iJvI8RoQ6OXpafbdxAVeTuotFpG93rKUngk/5YhIn9vzywqsPHCJt7pFUrgG+HgtlQrW+7CssKg4lSzc0s6i6cgllo3mRsy+XC+tYPEkqQum4lBXWIUZzZVdccW6JkxMQagZ/6Oc5E0cc6Mqkb8QqrNJSv5yRvL3eQeho2HN8TK3hV1XOS/5RWiyXt/tKU7WKtg7aLiSjj8CNstJtXPtTFSBbMfll7PIn0q2R+Ipx6tk2WZz8DRk2eaogpcDqmwFuJYCyzzIYCFjjVoUjzez1K+PCg7Ff00JCLrs1QbLeGTlwa50a0wu1wkexK2BUs2hByKVdpkR2xryG4DDUdBlnAYMhAFZFxzYSja9QN9qqgoYwd0iBSCqb2YHuLk4sEUwnJ87x0mzpQJWmfeGGCUFGoNgXTZBf/IwmnpfOgojB/aCJviq9EklelC77UwGNwJULywRquUE7RtCfmJmqA+DtWBDn9ZC/5F6X/keaCJcXQHEWkq67MTf9y1RmXUwj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75ff6c64-07ba-4235-5c81-08dab71b6352 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:08.6866 (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: J0+2iZYOvo/rlS4tzPn1ZEvfDW5nqzCpIleWKClZTbuQCCwT8MamkIsEeYj72+3Wv8ongkeAQpCcTt4BJBlXpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4498 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: Dw-Jm9VIlhUY-isxsB7dgK64MgLA_3sS X-Proofpoint-ORIG-GUID: Dw-Jm9VIlhUY-isxsB7dgK64MgLA_3sS Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit 211683b21de959a647de74faedfdd8a5d189327e upstream. The collapse range operation uses a unique transaction and ilock cycle for the hole punch and each extent shift iteration of the overall operation. While the hole punch is safe as a separate operation due to the iolock, cycling the ilock after each extent shift is risky w.r.t. concurrent operations, similar to insert range. To avoid this problem, make collapse range atomic with respect to ilock. Hold the ilock across the entire operation, replace the individual transactions with a single rolling transaction sequence and finish dfops on each iteration to perform pending frees and roll the transaction. Remove the unnecessary quota reservation as collapse range can only ever merge extents (and thus remove extent records and potentially free bmap blocks). The dfops call automatically relogs the inode to keep it moving in the log. This guarantees that nothing else can change the extent mapping of an inode while a collapse range operation is in progress. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_bmap_util.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 90c0f688d3b3..5b211cb8b579 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1237,7 +1237,6 @@ xfs_collapse_file_space( int error; xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len); xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len); - uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); bool done = false; ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); @@ -1253,32 +1252,34 @@ xfs_collapse_file_space( if (error) return error; - while (!error && !done) { - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, - &tp); - if (error) - break; + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, 0, &tp); + if (error) + return error; - xfs_ilock(ip, XFS_ILOCK_EXCL); - error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot, - ip->i_gdquot, ip->i_pdquot, resblks, 0, - XFS_QMOPT_RES_REGBLKS); - if (error) - goto out_trans_cancel; - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_ilock(ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); + while (!done) { error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb, &done); if (error) goto out_trans_cancel; + if (done) + break; - error = xfs_trans_commit(tp); + /* finish any deferred frees and roll the transaction */ + error = xfs_defer_finish(&tp); + if (error) + goto out_trans_cancel; } + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; out_trans_cancel: xfs_trans_cancel(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); return error; } From patchwork Wed Oct 26 06:28:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020190 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 CBF75FA373D for ; Wed, 26 Oct 2022 06:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232447AbiJZG3Y (ORCPT ); Wed, 26 Oct 2022 02:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbiJZG3X (ORCPT ); Wed, 26 Oct 2022 02:29:23 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9621780E89; Tue, 25 Oct 2022 23:29:22 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nC6D023389; Wed, 26 Oct 2022 06:29: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=mLyRTUxWLzsK9l+p11J3vAAMydBHTPTyQhGcQLImiYk=; b=IH9djKL93JPVknbCn0xl/6YzBN+LXBZyl8eibbalibqa73kzo+TkhDKSEbEy/PXfQwR0 S9CASqkFymKZwhAMk3ITFe728/tYuPFGWWshmDwjMELwSQlj35zp/3qDH3RCq1Y+ZUpK PX5MuWF6kEJpPhgufXg99ON8axBXLB9JeWpN1HyAZL2mAzPghRf85lKcb9deET4vqEvz uGjwbXVdrb9OvsdCWKXwqO7R9CeCUQCzNfQi33fQlJSFGe+6qQLpnCBK1yL6wZv1FgF8 eWE67Z0M4Kcjr+Bqa3xfKD9fxpy1FlZb5yl4FqojZe3U64p9iyJviMuoyaPQ7tEpe1ic dw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc7a35nnp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:17 +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 29Q320Ps011113; Wed, 26 Oct 2022 06:29:16 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 3kc6y5d7y2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nKwxVsmnS7v1BLuFdAc1Y5XWR7sTJEhgQLKtoAqODnHIoCYvYnLYUnt/syOvkp64+8ypHSE7g1eFAt+505pVDNTYDeeupZTmxQ9jB9kclH/0vSWJRSDAUGvF4CVbby6E/pBFCKhDoG8FjoxbLEZOs6+M8tOVyij3vaYNuGQd0jIkRp6ox8BKDGr7LG+CyCmLdckAbLv/c0NqShNKOvNYIz35rCS1GlerQ4ODtytWz3ZIJFi+sbItLXQUAwEmCV3hL4B/2ozDuEsDpfi3ernqTUP1/uVOUy9PVwyr3BODdLiipfv2xdg9Hh2/LNkVfHXqZFs4LdVAjD/z4GtLcPqxqQ== 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=mLyRTUxWLzsK9l+p11J3vAAMydBHTPTyQhGcQLImiYk=; b=RaoXAv2z+QcXlWhbzgZCritT6HJ7C9mM4OR2GbB+LfjLLtpgJX9EgUNQkfgmVxt9EBghIFsx7IEkfsr7lECaFMFfr7/aeSuwB22qfHIl8M2Ec5iR+9Ur4wrmo8B34wD0dGzK2o8XfkAsQuytwFTE2hYhjzCQkdwK9Rlg6n1+G3CVxvsuUTN5RRKdiO1JqqmS3/WY0Awv5a96sqp87wLxpsaXgv6X+bPPcxdEcti8zajlIvY9LKMsWtHABf0gu2zAhtFa54+QiVE5OUVDlXl4xcNxZcprsiFoi4rbblqgifzE8rflOLsbvqTAgXXhTT+eQCQyCEF0STZHap1H1YvYPQ== 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=mLyRTUxWLzsK9l+p11J3vAAMydBHTPTyQhGcQLImiYk=; b=CHB4ldYeTJezbN3p+MNoDzXKaq5Bdj7/wElAxzk/xwfpKFAQvykA0U/Yp0TntpjwVv6FO+PcRwKyhgEzVUlblMS/bnJwSKKqJEGbW++LQn+Bqk7Q/v+66gJ8LMF8fvBgcEP/WXaDh7nPOr/l8dU5uwJrlY7dazoNOGBrlLipkrc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4498.namprd10.prod.outlook.com (2603:10b6:303:6c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 06:29:14 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:14 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 04/26] xfs: add a function to deal with corrupt buffers post-verifiers Date: Wed, 26 Oct 2022 11:58:21 +0530 Message-Id: <20221026062843.927600-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0047.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b5::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_|CO1PR10MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: 25137eb3-cdc1-4f4c-e4ff-08dab71b66cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwJNupSXivwqbBjcv37g1kp3GF2+PpJVK73QE8+unBoQBuxsQjxAB9nwk2jgupVQfcmr6cpnCRawXG1vpneQfzbr+qBmij8m5Qd/fcPPjppXagGtuZJyHLNJWb+n5U1FJAC9MAbu8Px5LRk9rlVPSlRKdVyqEmFNk/rPQSdvMJVlhfVkaPzHhe2Am8xGdkkIhl7MfW2UuefKxeHqjUbgzHz3ytES9eDjRbgRrylAb4Nk66r6cjjnbX/t1Wfirefunj+RRO38bEFoCCPy8GOuY1H76d0M6owxQxMxq4BHdRuX4RkIRvFisDaqm0Sqo9F3imM6PkGHbI9aXYBj1Rc/dzOjA9aYvxqYGU/hIPpzGDxw1NOoDHp2luy4/CNl9DgoOZH+m+xLuXLr5dq9Lcn6BIjovZutrj11b9XjZz3HVkTwTIUfeUrjDIvg62W3iZYs+kJ1l4/CH8pmBETtaFFYqWgLif38fKAXTgWwbdYxAMGXPXc7namcBrOXdbR7qBLE3v+1kvk8HN9LJQ0qVysYrujr3hPrPDMqb2CAkatg0kkLhHGVl5BrNDg2xTrdkF+RDgNw4wlDSvn+sbgZhxViSqICl8TsFxcrHh6DuFA/w8KiMn+6XWgi+BKlJAr1da+weJI36D5TSy4EFMz94FbpzofyZk+YaHWzeO+03lyYxPSrmP405PSpaQOqicycXTB1zSfNkadH0z5FRYNX3BDgEQ== 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:(13230022)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199015)(186003)(66556008)(41300700001)(478600001)(2616005)(66946007)(1076003)(66476007)(4326008)(2906002)(8676002)(38100700002)(83380400001)(86362001)(316002)(6486002)(6916009)(6512007)(6506007)(6666004)(8936002)(26005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aERK2NwJ3z1OImIimTWPH8y7LO1bcMsfmBJTXi4BTTX4M3l8AbloIJEw1vo/BhHunm3IEUfMv1MQAxAjWhf13X6z3B1Rxg0xjJfmrQRN2aGnL1CONahXvNLk2htP0Ub1cFJqJDbFH0z6PBr30vuRE2jRkSw/OCiu6Bp0nE66c4Kk2KURN9KtPPCHqD/P57yjaOGtShfAmeLGLpG8zmH0l1J5kNvSHeePVKQ2PlbcvwRXn/CHmVxQc8wudNf8Ls0KGHWOVZCENnNvCzApTNK/yfkLj+wOqtH6DfelXm03TWeb3f2LSSmYDrrnXmqbNdnqzlGgX0seY+d4hF54nRr0p8DfTWNFNhL6zV/X9GbAjK3IsXMrufQh0OdvhLl50QFFM2IcnGh1ur4U+yufrnMj3tzUuGGEBaQOU71I319MfG7ibprrczTy9ZLAhSx7Tv+uLgzucWOjHmWjeHpMcLn6FVhMgwbPJbFc3JAWyjTJr0PkBxV0hVWjYHMw1wlQE+f5fRla9MWlPp+84mndlPJ/W2DY4J4TqVzfGmxzjNb4QW41Fiie/jguK6XO4YF5z4um+P2owDy31UlCxJGtl7aOpbXY9+1rBTnxrUKv9RkYOOj2A0Awut2C4aBjeLffkliRo8hnkJtkVeEkTTlhIbH0IwKyfG1Xlu9JVmiv0g9WpyGAGPdpGBefrE54LASZD5LBo4gIg09tVvu9nQAM9yr2bF9CCiOvzHKhJyRrfMP530Nwgz6ajuluQG0w4FwBYd2ihuE9onrCllsf2f2STWyyzk2upRBoo7COYyNoZ7W2bBZXSCxjJiiqkl7X96z13RKDjJWtErdSnTKRmn1nd/quzcAG3jBmQHFE7F5j+D2g3PRmoE9ku7JsxPxi4NU5rkXKBMVwzN61Tnn4e7sUE4oXdXvvjr9gNfMOOEOeQst6YT3lgNERhw9QpOGHDxIlx3dmx+ztuCPYhsD5TSHQAgXgFLVsQQASEVaNOvuwHO1opjrgjkrk8KygSx1svmWNYBH6OHkM2svdGuE5zZSMV11T7Ve6wm3t9yauEgEK8Blf31HSRHOhjvkfa4OKgsE7FnTSrSicchhZB4lkBr/OQapg4k1eSgnvFPCAWOa5VAOTbI93UZ3NjVfVOyErLhEeF3tT894t0L51PCkYM07z9NgCiR9HCl+G6c2nZh9t/eBg8vbRc/RSHaRf4AEpEtfZ9D7zVvbMUcvcNypPZo4kxVbFG/bQr5Ys75iP4QWtvcojk+p6gGFwmllgwSPhG/s4Kn9CExNT/k6fXNbnn3jmSGtynJKbjuX0Ut7yK8LoZMR4afE03IjMl/1QLlo9iaCxo8AK3rsoZnJlwbLSx5F2UaR4VxVxV26QxGcRAX7Wn8qZNTjBVmbUoN73ornq0u/Ivp2FxZOlO6BWk08tvrRYiXCoXJXgEukib8GHeBO9m9JqWo7Fly1XB9esME3DPyBtkGGXSZqVsAp+ZikVMzF0Nb6oblHOpJhdVcpGqMVNktT3D3Xhqni8vvZMkCDRAMQc0T0OHyruydj91pFZRYKIk7NHBH+LwyXA1Iztf7vM0oEPWgr8KXHCUa6PxytVH5G5xTmU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25137eb3-cdc1-4f4c-e4ff-08dab71b66cb X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:14.6890 (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: Ci0YtTUPzLkupXcBt3FROWKPTKq6ElEMLB1vCaQ5OJpc16uAxZMZfRfH0vHn4PO5ma09xYl41vLJmrsM49rXhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4498 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: lKR0JCuafZ6zUYAgo0tDGqWZ7hDD7JRg X-Proofpoint-ORIG-GUID: lKR0JCuafZ6zUYAgo0tDGqWZ7hDD7JRg Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 8d57c21600a514d7a9237327c2496ae159bab5bb upstream. Add a helper function to get rid of buffers that we have decided are corrupt after the verifiers have run. This function is intended to handle metadata checks that can't happen in the verifiers, such as inter-block relationship checking. Note that we now mark the buffer stale so that it will not end up on any LRU and will be purged on release. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_alloc.c | 2 +- fs/xfs/libxfs/xfs_attr_leaf.c | 6 +++--- fs/xfs/libxfs/xfs_btree.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 10 +++++----- fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 6 +++--- fs/xfs/xfs_attr_inactive.c | 6 +++--- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_buf.c | 22 ++++++++++++++++++++++ fs/xfs/xfs_buf.h | 2 ++ fs/xfs/xfs_error.c | 2 ++ fs/xfs/xfs_inode.c | 4 ++-- 12 files changed, 46 insertions(+), 20 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 084d39d8856b..1193fd6e4bad 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -685,7 +685,7 @@ xfs_alloc_update_counters( xfs_trans_agblocks_delta(tp, len); if (unlikely(be32_to_cpu(agf->agf_freeblks) > be32_to_cpu(agf->agf_length))) { - xfs_buf_corruption_error(agbp); + xfs_buf_mark_corrupt(agbp); return -EFSCORRUPTED; } diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index c86ddbf6d105..e69332d8f1cb 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2288,7 +2288,7 @@ xfs_attr3_leaf_lookup_int( xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf); entries = xfs_attr3_leaf_entryp(leaf); if (ichdr.count >= args->geo->blksize / 8) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); return -EFSCORRUPTED; } @@ -2307,11 +2307,11 @@ xfs_attr3_leaf_lookup_int( break; } if (!(probe >= 0 && (!ichdr.count || probe < ichdr.count))) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); return -EFSCORRUPTED; } if (!(span <= 4 || be32_to_cpu(entry->hashval) == hashval)) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); return -EFSCORRUPTED; } diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index a13a25e922ec..8c43cac15832 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -1820,7 +1820,7 @@ xfs_btree_lookup_get_block( out_bad: *blkp = NULL; - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); xfs_trans_brelse(cur->bc_tp, bp); return -EFSCORRUPTED; } diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 1e2dc65adeb8..12ef16c157dc 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -504,7 +504,7 @@ xfs_da3_split( node = oldblk->bp->b_addr; if (node->hdr.info.forw) { if (be32_to_cpu(node->hdr.info.forw) != addblk->blkno) { - xfs_buf_corruption_error(oldblk->bp); + xfs_buf_mark_corrupt(oldblk->bp); error = -EFSCORRUPTED; goto out; } @@ -517,7 +517,7 @@ xfs_da3_split( node = oldblk->bp->b_addr; if (node->hdr.info.back) { if (be32_to_cpu(node->hdr.info.back) != addblk->blkno) { - xfs_buf_corruption_error(oldblk->bp); + xfs_buf_mark_corrupt(oldblk->bp); error = -EFSCORRUPTED; goto out; } @@ -1544,7 +1544,7 @@ xfs_da3_node_lookup_int( } if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC) { - xfs_buf_corruption_error(blk->bp); + xfs_buf_mark_corrupt(blk->bp); return -EFSCORRUPTED; } @@ -1559,7 +1559,7 @@ xfs_da3_node_lookup_int( /* Tree taller than we can handle; bail out! */ if (nodehdr.level >= XFS_DA_NODE_MAXDEPTH) { - xfs_buf_corruption_error(blk->bp); + xfs_buf_mark_corrupt(blk->bp); return -EFSCORRUPTED; } @@ -1567,7 +1567,7 @@ xfs_da3_node_lookup_int( if (blkno == args->geo->leafblk) expected_level = nodehdr.level - 1; else if (expected_level != nodehdr.level) { - xfs_buf_corruption_error(blk->bp); + xfs_buf_mark_corrupt(blk->bp); return -EFSCORRUPTED; } else expected_level--; diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index 388b5da12228..c8ee3250b749 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c @@ -1344,7 +1344,7 @@ xfs_dir2_leaf_removename( ltp = xfs_dir2_leaf_tail_p(args->geo, leaf); bestsp = xfs_dir2_leaf_bests_p(ltp); if (be16_to_cpu(bestsp[db]) != oldbest) { - xfs_buf_corruption_error(lbp); + xfs_buf_mark_corrupt(lbp); return -EFSCORRUPTED; } /* diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 35e698fa85fd..1c8a12f229b5 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -375,7 +375,7 @@ xfs_dir2_leaf_to_node( ltp = xfs_dir2_leaf_tail_p(args->geo, leaf); if (be32_to_cpu(ltp->bestcount) > (uint)dp->i_d.di_size / args->geo->blksize) { - xfs_buf_corruption_error(lbp); + xfs_buf_mark_corrupt(lbp); return -EFSCORRUPTED; } @@ -449,7 +449,7 @@ xfs_dir2_leafn_add( * into other peoples memory */ if (index < 0) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); return -EFSCORRUPTED; } @@ -745,7 +745,7 @@ xfs_dir2_leafn_lookup_for_entry( xfs_dir3_leaf_check(dp, bp); if (leafhdr.count <= 0) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); return -EFSCORRUPTED; } diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index 9c88203b537b..f052de128fa1 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -145,7 +145,7 @@ xfs_attr3_node_inactive( * Since this code is recursive (gasp!) we must protect ourselves. */ if (level > XFS_DA_NODE_MAXDEPTH) { - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); xfs_trans_brelse(*trans, bp); /* no locks for later trans */ return -EFSCORRUPTED; } @@ -196,7 +196,7 @@ xfs_attr3_node_inactive( error = xfs_attr3_leaf_inactive(trans, dp, child_bp); break; default: - xfs_buf_corruption_error(child_bp); + xfs_buf_mark_corrupt(child_bp); xfs_trans_brelse(*trans, child_bp); error = -EFSCORRUPTED; break; @@ -281,7 +281,7 @@ xfs_attr3_root_inactive( break; default: error = -EFSCORRUPTED; - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); xfs_trans_brelse(*trans, bp); break; } diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 8b9b500e75e8..8c0972834449 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -271,7 +271,7 @@ xfs_attr_node_list_lookup( return 0; out_corruptbuf: - xfs_buf_corruption_error(bp); + xfs_buf_mark_corrupt(bp); xfs_trans_brelse(tp, bp); return -EFSCORRUPTED; } diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 1264ac63e4e5..948824d044b3 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1546,6 +1546,28 @@ xfs_buf_zero( } } +/* + * Log a message about and stale a buffer that a caller has decided is corrupt. + * + * This function should be called for the kinds of metadata corruption that + * cannot be detect from a verifier, such as incorrect inter-block relationship + * data. Do /not/ call this function from a verifier function. + * + * The buffer must be XBF_DONE prior to the call. Afterwards, the buffer will + * be marked stale, but b_error will not be set. The caller is responsible for + * releasing the buffer or fixing it. + */ +void +__xfs_buf_mark_corrupt( + struct xfs_buf *bp, + xfs_failaddr_t fa) +{ + ASSERT(bp->b_flags & XBF_DONE); + + xfs_buf_corruption_error(bp); + xfs_buf_stale(bp); +} + /* * Handling of buffer targets (buftargs). */ diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index f6ce17d8d848..621467ab17c8 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -270,6 +270,8 @@ static inline int xfs_buf_submit(struct xfs_buf *bp) } void xfs_buf_zero(struct xfs_buf *bp, size_t boff, size_t bsize); +void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa); +#define xfs_buf_mark_corrupt(bp) __xfs_buf_mark_corrupt((bp), __this_address) /* Buffer Utility Routines */ extern void *xfs_buf_offset(struct xfs_buf *, size_t); diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index d8cdb27fe6ed..b32c47c20e8a 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -345,6 +345,8 @@ xfs_corruption_error( * Complain about the kinds of metadata corruption that we can't detect from a * verifier, such as incorrect inter-block relationship data. Does not set * bp->b_error. + * + * Call xfs_buf_mark_corrupt, not this function. */ void xfs_buf_corruption_error( diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 30202d8c25e4..5f18c5c8c5b8 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2149,7 +2149,7 @@ xfs_iunlink_update_bucket( * head of the list. */ if (old_value == new_agino) { - xfs_buf_corruption_error(agibp); + xfs_buf_mark_corrupt(agibp); return -EFSCORRUPTED; } @@ -2283,7 +2283,7 @@ xfs_iunlink( next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); if (next_agino == agino || !xfs_verify_agino_or_null(mp, agno, next_agino)) { - xfs_buf_corruption_error(agibp); + xfs_buf_mark_corrupt(agibp); return -EFSCORRUPTED; } From patchwork Wed Oct 26 06:28:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020191 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 E114AC433FE for ; Wed, 26 Oct 2022 06:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbiJZG3b (ORCPT ); Wed, 26 Oct 2022 02:29:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232906AbiJZG3a (ORCPT ); Wed, 26 Oct 2022 02:29:30 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01930C64; Tue, 25 Oct 2022 23:29:28 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nQqM030372; Wed, 26 Oct 2022 06:29:23 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=dEvIrjhmCC0lYyPS4woWX7pYOSXBBMZMTgztOIxPhHw=; b=SxxjaZbPD4hNJtHRtsIcV9rKCixxUnXRE51nhCVVO0stDNnSRIzFKuO1AMOSdHVjoZb1 JfCzmy2D3m80QsjS1Uf7IKEKcJ727UpVooG952mjDWO3eU3+8QxsHt4us+4gOBLRGHwv V5E8ojp77rS3hh4MPmC2orku5Y8rMSnRU3B3Pkg/4BwqGQMlS3STlfiute8LbEcdKsky 2cudpMU2R1d9+ZUxm6qdfK6+XlXBnFXAIZa6caYqP67wGSTxpwowegj7iKNTAALD3/iN FbNOdvEzgHsUBsjBIEY7WNbB5n6OnL/EqFDWn3MxMRJKSus8CPOl0TiRTtt1UzNvmd6C Tw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x226-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:23 +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 29Q37APL017253; Wed, 26 Oct 2022 06:29:22 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5mwju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0epNaveLbLU9Ev8KdtxYPqzTnDUee9UIq1XyRrubv2aFzu68h7D4pR4PQ0eq4mONkRDZe7MqiJ83Flqa5HXg+HnhjMyUNbN7jEUo7R73yZ2nBlPvJ0dbLBiSHfTMZvFNqGBLpImfLa3imvAefrehRtXjKVrXN+B0HRMcfyuPuurjbSfDo5ezoy/IlSfw4p2A4ffGoc/T5HvxL0lG0s2w7QKjRtzAmAaPHCIti9OMlqrC6Vf1buQv2ro5SZMOExTUnBRJMffRf4L30iaoBDalU9hxD0PkGWOVocBJJ5HFDqwmT0NL/FXZY5lqdiNFdC5/w7SsjW97eUvPxCeA26HoA== 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=dEvIrjhmCC0lYyPS4woWX7pYOSXBBMZMTgztOIxPhHw=; b=JEu2A85FEyCoOnp+zHA7gttslyYN+JXOB2dJYqorU+CBeZYOl/y+1P9BgDsD6NXj53jfxBKIecZBCGSVhTyCM9c6zcKA5HpBcd8gAuRN6t6BFurxz5ObrJ4DYTY2adKV14TQon1GG7hrklTBpOd13iE6B0JFJlM7t6KwNsvn2GYjumEfObptEeOSc8IR4Fkc/SuS/3qDUTGhgD88ra5OjWcjc/bd4pGtlPy3Ex7Lc2pVl27oQdK8KTpjHQedRbOSRYSdZjBEYWDCFJyoZKoIr7Fg5uqzEZdGi0HOAxxHS7WVd8farjkExGuhTH1EI4K+pY+wcAETD2D+jTZQ2FjGcw== 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=dEvIrjhmCC0lYyPS4woWX7pYOSXBBMZMTgztOIxPhHw=; b=MphHJr9cOjAYYwOk7/M/i+8H9PvEP5wj4HF+WAlfxe9UIfCUUAjfLQuSyp3NbbzvP+g3zV70RYYcQAFmPhD+k4zYRBCzlLMcBuZoOIgsaz8b1oiB495eZxEMiV7eldF6QfIw4jibOYYQeg0hQ1pDlsEQXJVHPCDn/D08YTguRFs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4498.namprd10.prod.outlook.com (2603:10b6:303:6c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Wed, 26 Oct 2022 06:29:20 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:20 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 05/26] xfs: xfs_buf_corruption_error should take __this_address Date: Wed, 26 Oct 2022 11:58:22 +0530 Message-Id: <20221026062843.927600-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0009.jpnprd01.prod.outlook.com (2603:1096:400:a9::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_|CO1PR10MB4498:EE_ X-MS-Office365-Filtering-Correlation-Id: 1103078d-3ade-46e0-1487-08dab71b6a99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Em7CFEO1yetBJzNbhKKF0n3k1n0pdm7pcNMl0OEv6FEu1akEETo5RUtV4Bgr/L6ODG3CFtMai5gl3lNOexs7Nf8pGkXny9FNOLx/wDBgup5oDxqSDeUMkIc0c5/u+5/m7HF2B7YIGmhLbkPa4IGUUIiuYwxcX8eTclqnmCkm0vQ8sxvMRsTPiV6ZUO0D5SWP9DNRMqBMJsaRJ4AQ7aK3N1o1rnzO+9gSDpalTX6prSbZk7zic35eSc/5LOASJ4DAsoEUw1Af7EO8dQIkBKeTS6MGcX4Bs83fNDh3Nx/artORhSB+hiW2IH+K5j6QKaidpSDxOagTeggY7hhehRUBvjyQe6fOISkvA52V7H5rYaG7FU166DU62NVOxVgurF2euJL26eXAZgPzL5Dwzvb1HRefRzBSHN2Sc95dkEs4g7F8hApvvshtCQQRpeypLnVOYFX+K6TxPbfDKq+Yflf4EAzp3nvGWp+96DnExZVC23udbuyXI57DVBXNNmoRKR1WD8nL66KYcj5sgUQvTkqRLQbRA+zMFn1oX0ixwroisApK/A5fIOpPwKLqaUT2S+KaRq7QjJg7RV26meSTvojQyVerqj1PWhF097jHzNihNbAPTDMfr2N/XnnjXYbjJvIpX7Q9px55iM+G9JlHRKSdnsKR6zL2FmSSjSU1VUMqMiu6tcg9TtLsJZ3evlXXdqH+u7K0Gv98uWcw58jSRm8nDw== 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:(13230022)(136003)(366004)(396003)(346002)(376002)(39860400002)(451199015)(186003)(66556008)(41300700001)(478600001)(2616005)(66946007)(1076003)(66476007)(4326008)(2906002)(8676002)(38100700002)(83380400001)(86362001)(316002)(6486002)(6916009)(6512007)(6506007)(8936002)(26005)(36756003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lQ4VFKnuVxuviAAl0kKALJMnK+Q5mooOL7xFoe34WxEpRPEL0tSMYVPeVyPojQWhXCk4I47b3DZrbxx+DTm0F7vkuKm2Dxxbkxfj8QsV5FK/SrzEGPeJAMbTkhdsOeVGWRyb3pb0wtoMiZnDPfH6QuDsrAdVfjOY/fbdiQLpmqkxTcAQtAAQ4S5hBclcccgF1rA3G+zyP4q0/Ppd8hlRdAk3H05FRKRg6/IXybrOZQr1TRn8rE3gTS66lumuKPZY8HdfdoxzPHAbQFrvYMh973Xwt+cfxRDyTGY2L2Tr1mkqOUlJlPM0cF9U9ZuyZNReVf0dlPPH8riaCD7yIwzhoHsRjdJCofj/z+mpi9i6qnTkuMlHell4ZihvcJCpcAwhQA916+sPwKYQTMw20A7mgpeoZ1VlVKw685JBthuQ99lO+Zgje7ve1Q0f8XLeXTHy4VSvMeWhYpRn/B5XMUUuumLpc0/0cBR3collDIJiBr6Ah2VxugDFQH592RL5+rJ/fJ/VMtioVfv1kxNV6RU/fG/WE93m70E3twm8OJlqJr9u/QD37JRLV5the8LpCPdVduOIOXUd+epPrbVSjDA9M5gxlMp5fwzg1GhesWI14jYvchXn2QZg9iRuxN9kbCXsK8AlauJVx97AXmiIC7tXhC/BQLzuLkRo6ni1VAtnri4aiV/7bEzSmYGIyxAAGJPi+pazotNd8tncXfOidbIUtGMLwNqbyZZVA98f/k5dDcMmAClUnFdmXSyndM/QZ+Cpa+V3qLm3W3YofbFufYDVx8diGkZtKvmnSaJrPYVtIplYNu1/LzvQJmkJWjNZxvmaBvTTCZfEb4n8f/NI3ycIp01TvSiwWrC7bTrTqDUK9kAzmSxTeBKXoPoH1DsqfhImfVyyI07Y/2cGmgNW+zxpR82dXUMb1e0tDi+etkeVeXERHxBt0YZl7+yr8FkahW5gY8mlDyi2rWuAsOyDhNm1L+L++v3WDWE09MtNzB+8hXElPdaWTbQ2yEm76ak70GDd8nJuGCEJdFtFMvj9+9mCAfLLhssihENBQQBYT5Cgc1d3c/XfEUu68ZXHAxSdVhv48/VnycYfWt167dA/gQQWkOXzpdHdUV6XH3L1qi98wEItXTD0E2lEbwVfwYXIV1M3Hb36zO1Ks4AtlUqdsIcazXVQqjCVPbbl63/7XqrXUOQ09kMoBMv8Rnj5E4YfysnAr+sAYLGkvPES39KZMr2G0H9Nvj/F0Jy5EInYQHb11ama3htFYoR7ts6Bvyglx5y5/lSqjDP+PG2Qi38/1BjNNVT8qfW2YOangYqbvpTm3bE/Rcp+e+HoPcGcTtSrltrby0R2X1qnax5yqojipEWjsjQ0IOm0bq4i//7gZtlBZ9vmorBFAHmtl3peb/Ot9Kim0gZpfcZO29SH8l3haNge4bxUbiDhSWYVlX6sve2VcPixE8iH6CU8s4Gc4Gqtbqu6ZjDxAi6Fg3jgu7wZBIsIlZsb5idJpNf1E8CfQuzkxwN0kFQ0ogDJnuLVIaPzQ9RtSFizgdFZMOqlhSE4FAZHBmF7uL84AN5PQjgwu+5mI73HMscWbYaDW4HALd47y5RTOCMDJD1sOtBWzbuwXV3G6Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1103078d-3ade-46e0-1487-08dab71b6a99 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:20.7700 (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: PRb5kDOM3VPrueF7pjZOjlMd6uFY+N2unaFysDjBc76hufpS4a8XvNpkn6ugPmU+awiT1fK631OW4jgKyFyttg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4498 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: KljJvCi51mruatka03hkIaQYpEWabE7E X-Proofpoint-ORIG-GUID: KljJvCi51mruatka03hkIaQYpEWabE7E Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit e83cf875d67a6cb9ddfaa8b45d2fa93d12b5c66f upstream. Add a xfs_failaddr_t parameter to this function so that callers can potentially pass in (and therefore report) the exact point in the code where we decided that a metadata buffer was corrupt. This enables us to wire it up to checking functions that have to run outside of verifiers. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_buf.c | 2 +- fs/xfs/xfs_error.c | 5 +++-- fs/xfs/xfs_error.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 948824d044b3..4f18457aae2a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1564,7 +1564,7 @@ __xfs_buf_mark_corrupt( { ASSERT(bp->b_flags & XBF_DONE); - xfs_buf_corruption_error(bp); + xfs_buf_corruption_error(bp, fa); xfs_buf_stale(bp); } diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index b32c47c20e8a..e9acd58248f9 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -350,13 +350,14 @@ xfs_corruption_error( */ void xfs_buf_corruption_error( - struct xfs_buf *bp) + struct xfs_buf *bp, + xfs_failaddr_t fa) { struct xfs_mount *mp = bp->b_mount; xfs_alert_tag(mp, XFS_PTAG_VERIFIER_ERROR, "Metadata corruption detected at %pS, %s block 0x%llx", - __return_address, bp->b_ops->name, bp->b_bn); + fa, bp->b_ops->name, bp->b_bn); xfs_alert(mp, "Unmount and run xfs_repair"); diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index c319379f7d1a..c6bb7d7a2161 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -15,7 +15,7 @@ extern void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp, const void *buf, size_t bufsize, const char *filename, int linenum, xfs_failaddr_t failaddr); -void xfs_buf_corruption_error(struct xfs_buf *bp); +void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error, const char *name, const void *buf, size_t bufsz, xfs_failaddr_t failaddr); From patchwork Wed Oct 26 06:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020192 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 9A433C433FE for ; Wed, 26 Oct 2022 06:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233088AbiJZG3j (ORCPT ); Wed, 26 Oct 2022 02:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiJZG3i (ORCPT ); Wed, 26 Oct 2022 02:29:38 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8C5A1B0; Tue, 25 Oct 2022 23:29:35 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nVkt030448; Wed, 26 Oct 2022 06:29: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=4geLziDcMCIM2wjykWi7uqPe+448JJutxxTPdP4lXvE=; b=t7czbmLK/SwWfYZ9EyyW2zjExyjQuhqr2SDWz/RYMcE1FdXZuDLKxa9ucegs+s3RqQt3 NlVh/kFkAg7BJjBpeSAguovxVntQ2y71K0b1+t2WkptgmK2J5I8SEfuneJNyqjTTJGIm 4Un8EQKbgW/q9ltFS5xLZSrPmzKLXfslDjtIudcWBYX2JNx0u3nS+JbIWRVQcoY2+zfO QQzc+A5fENW8f61sxqQED0/QdCLIR67cOyT2jcuWGded1zZu7+Ji6GGejjtkrcl3ZarA K4EB6i2uZeJdr7G0mvSMZ06VpUsDWFBB6tk4LY6p69R0L1UKGJTj1X9f5lWowdRVq8M2 Rw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x229-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:29 +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 29Q336rM031838; Wed, 26 Oct 2022 06:29:28 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybe7cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oGwuEJv8jbaTFFMt7FJzAZ48bUfEw2WDYw8EY5PtJwXCERvWLdcTdEqSsBGWAw/bPTVXYqMB/3HxiWf6xrkJTZkeR2IzSElm2tB6kccPQyMhUhDAa7IIHB909VNtC6mlezzGxGldrp5nF57qqxqGVlpmHL6ibD0SmmAs5tkpPLWMFVY25VhKa/ZSpqw8bAoL9DXYQ8NO5zMcI6jHuFmn6E/fPNsf1LB0LXmUWrzcCS6F6uwOX0S2rQyV7WzNiqNPYncGPtSNkfEkSukg21e3U/OJjCB+RxPsDlponwDJ3Z9xtol/MmN8wC3TbHc1nyYsC9VzKZyIfgPBQ++AOIpkmQ== 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=4geLziDcMCIM2wjykWi7uqPe+448JJutxxTPdP4lXvE=; b=arF8KSd1vBXVpq9ghTMgfmy7ntc9LkGhu7Zf5TfwSSFzMs3gBWlfveAGc9ceV0/vVFC2olLdcNpqy4/oKt+Ct2Q5XCMbvQFKyA3excvoDR4g6GZoMsY39ftt36TsH3CchBiwfm7V71YwkOWwn0j+OgeUKpdVBoEXI6y3CPHsiPqM718Uz67FecKIqC6AvomG2YQiLa0rRVRbB7RXDFK8+wvzW4SNc1+LPgZxXS0p9aAE/kCfKoPjTgrH8CThIndeEoJJVNd4Edjpftqw0en2eQEykbWjN0RxOwhYdSqaGySciQMZP7pHIGA9VNDixbkPGIaMGojlPa9nyaLCeufB9w== 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=4geLziDcMCIM2wjykWi7uqPe+448JJutxxTPdP4lXvE=; b=DpjJcamh+teKb/BDYlwOKQTgPRXajeCb+eCp9qT+velW/k+KTCiDCv/FRDXrnK65Dk9Qhqr15y/oSnTPZlkUnC/fcZ4s53cIGOnH60WGEaZnGvYDdSwK7J77DobnXpvlL8xirf4f6yZvGaxa4wcZKM8CtvWe4r65hWkLx6YP4uU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:29:26 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:26 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 06/26] xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Date: Wed, 26 Oct 2022 11:58:23 +0530 Message-Id: <20221026062843.927600-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0195.jpnprd01.prod.outlook.com (2603:1096:400:2b0::17) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: bdbc8a85-d001-4281-26fd-08dab71b6dde X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rzU8lZ/ZhVLaOnfIiE9ydPLTODkpuFrGinu6erjWTBxD9SC3KZy3FI7tIJnZCd/q8F8Dl3dlf1yr3BosglZImM5/QPS3YCIvuxOxZFhuelkcUJPN1zu4FZJL5j9eGFwhpek+SL3QIxKKiimWub440+WCFDitsfKhtugss+lJAUKvevTkYplYYNQwCPuLNu4q+epdj8fbzxxo78jTSc4Li9yFMhe3+S7bYqBuikHc4aFHaqcnvR7Uecv0VQkakdEWWquWTCRGBTsv+qTumqDxF4iMr5eGJuZcA41E2eBsEulvgPWaLF7jxva8SsfQ7rFETZDjEF6/Afl0WFne3Wn19qHCTziBanqo9DHTbiuQGHlOsjaeDlvJbyGjPcTCPDgZ/iMwYMHXAHvOWt4ziNnzfXAR4lOzCW2IrL/4fx0E/Az7Mv/JZ5FFJUM0oVLIk8cNFzRjWC/4+rfA0jMjc64/hwE3GqoCLlCIYUOMEvpDinNtXg9w1/xwIyFpbq0N/p5KWtDg73GAMHHXH8DR8jkotZtzLrkbWEiN8qBjcjJyYVsmGAu2uokT4yDxbqpB9Ks9oXebzNYwlR1LiuuJxVyBSmD8TZ5mcz9H5XbpOYrTYN2IDA+jHjcVRAhQgNBTFBiUKs62pBxWEhcCvxwvocXil4Q/8wM2TAzfYGyua4GbSatWzyKJ1KgtpcAY/GQEIHQ76rHA9nrTX6wPRBadWh4BvhiagxayfaDxjVafNHxUlSQK1v6m4Ke5hY2sZ+61hzD7 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jakwv6QL4bQdmHmfavzCkLzbroxWdyA5JeCNB2lYrGZzIST+vsdcbVLcrpdmErkfbKSYzPx+JO36qCZKZeTF+asDy4UDqTxb91azTMMlqQNfGIABEG6SuktvyU9gijHi4U2GciWR5t8vFwZnN4/ymuIb0LuLWc4KeQRdNMM0YULTTfApm7wkQTfTno/jLqyExlZwtYCw0ifvz6UZS0XFqfL3uYc+Gn1XiOu34G5vqBGRvWl3qN1WIY9e8NZwXoo5II2vInE6fxHDyXSAkpVMKLfALYh6WBDenjVTKVDDkpghwWn3+k9dw7wnk/UtyaCwayzHgrwRvw2nCz5KzNKJG+r3QBmziDgCsihCcEaoPJPuL4RFhbGlZlVLrHbohhUCzpcFiXGLTrQpPWrDSr+61M9u50yR+reFSRIdX/9IBJ4TWc6EOW3e/c8gjGzFrVKUEsaibUACTX430hk2gNdWWhglCNpVnweKoep+qe/W5X1Wy82s+vGeKbadDlAqbPKg3IogX3pdquRvb2wHwN5sE4muFVmTpo5FoP//JB4/g5NljTayqMrXzLbi/sLDaeBdTg98BF1q8+DlFOQo9C7tVmgZZYI1hlEPCPxnFItcWEyG+B0xSey6kqWOYyfONff9bOMZ7Oq+EZrOK3dRheGPJSXpjg+81lDrLSjWNNqaL1hWUU8+myAlafNYvL2czkJlx/DsPm/aI6U21135yuy+bW6KCJ3IcEmcKG9w//qDnEGex/gC0PWgfA9C4EQXozmSIjVAL4puYFADv/9m+DgeypCslNjHtE+NhSVoFQLi4qPexY2M1QxgTMsnRwXhH+NEIwHgUPpTIHYe36PgNzfiL2UqPH4wUzP863fkhGdeuPCngVeXB3sbXzawAXT34m3H+9pDJIT7tmtTp7O+CmBDS8fQy4WHXILQUQ4WRvfSdYMscITXztGiTTLOiXl7x4lL8Ncvo9LNWbgOaK6w+gWvyMPz0uHHYW9VENlZU1b5u5oQh1pekxbJ3v8918tbKigebb1gGFtDUboVVonKi1NMrwXESOy1h/BpVThoyX+bHYleOmkM3Bh7mvmWOIr8vIL+esXb4SI0lFMi4D3LgtwYFgSHf/RHiOZptIigNrycJlWmkp/G+L69RLLImzlFUMghju38txXQ7VxqpmtjgWVGURClTx8VIoCpQK15N446ITT0hGrRCIltTlZV3lsTeTplU8MknkZAFvMQnm+t3uFGLknQPPXL0PX74oPqbehBD4OEI1MwDP/tSwl4WbTDb9e2xMhi/vgBwPUSwejLehHdA9ZlGVb18fzf/skccvGmmoiUlgs9dclMkrIW+E63wM6K9+ls/HzQC8bZiZuouImt4Lx3UINPUDJkybZCBknsTwkpxTkFEhsLkS2licAdbCByVaeOVbaE0mIueqSoVWWsoFYNIOGz6JMrungyaKjIFTUCS+8TG8fwnhKgy6Ijv6V6MsJ8t0rDuyHsF6jbiw7S1uJp46oxDzxx4eq43bssf0HXfyPUyeSTQgFTT6OyBgSE1KCAByDooDn8ljBFOkrO5ixEn1eIZHUY8479c7/QB8wyxKUBPLba09Fc170EAq3hJJTx+JrJUnvpQ9WXZJKB0w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bdbc8a85-d001-4281-26fd-08dab71b6dde X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:26.3808 (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: un3lx7vc/CYsCbROJ7iAe4gvfdDTwFKmXSquG+5+bNNAMkrBse4yQ5BN14fVbkgI4UK2Lpi1U8z2TXVNiorXEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=961 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: DrUtxVc_g3GwnPYSohTBJwyrF5iSVzBM X-Proofpoint-ORIG-GUID: DrUtxVc_g3GwnPYSohTBJwyrF5iSVzBM Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit ce99494c9699df58b31d0a839e957f86cd58c755 upstream. xfs_verifier_error is supposed to be called on a corrupt metadata buffer from within a buffer verifier function, whereas xfs_buf_mark_corrupt is the function to be called when a piece of code has read a buffer and catches something that a read verifier cannot. The first function sets b_error anticipating that the low level buffer handling code will see the nonzero b_error and clear XBF_DONE on the buffer, whereas the second function does not. Since xfs_dir3_free_header_check examines fields in the dir free block header that require more context than can be provided to read verifiers, we must call xfs_buf_mark_corrupt when it finds a problem. Switching the calls has a secondary effect that we no longer corrupt the buffer state by setting b_error and leaving XBF_DONE set. When /that/ happens, we'll trip over various state assertions (most commonly the b_error check in xfs_buf_reverify) on a subsequent attempt to read the buffer. Fixes: bc1a09b8e334bf5f ("xfs: refactor verifier callers to print address of failing check") Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_dir2_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 1c8a12f229b5..c8c3c3af539f 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -208,7 +208,7 @@ __xfs_dir3_free_read( /* Check things that we can't do in the verifier. */ fa = xfs_dir3_free_header_check(dp, fbno, *bpp); if (fa) { - xfs_verifier_error(*bpp, -EFSCORRUPTED, fa); + __xfs_buf_mark_corrupt(*bpp, fa); xfs_trans_brelse(tp, *bpp); *bpp = NULL; return -EFSCORRUPTED; From patchwork Wed Oct 26 06:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020193 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 CDFD1C433FE for ; Wed, 26 Oct 2022 06:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbiJZG3n (ORCPT ); Wed, 26 Oct 2022 02:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiJZG3l (ORCPT ); Wed, 26 Oct 2022 02:29:41 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D5B365CC; Tue, 25 Oct 2022 23:29:39 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1naKt024687; Wed, 26 Oct 2022 06:29: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=hGeajXiJmzJw+C0wcLKSWZWKF7gzty0zx76vtcdM3kE=; b=GdUCZ+yE0dM1CEvhJloDbULlO0lCIgToupZf9UvEYtt2qIGG9a35Tiy/dxHGJKFVLTco fkcDG9ua9LI2tBry7QUh2/N9d7LhWWeDO2L0v1erB9gn8QChqWTjIvea833xa05dej2W Q0R9DhkOAxffYPEEjbAB3GwXzW5MSCC/DmYQ4d3EqF+BkbntWSTYYVAwcsyA8he/8aR2 PyLqbfCLtZhh3I0SVIzJYEqIFrI1yqE99+WLNA29vmlLm62bHFlbntM54gnC7BRoC+wr z5Em9paiZFXr6k2s4MWfeZ9n9aPiv4nIInAPjwEooYEpEC1rljAjYP9brVU6ABCcx6Di +A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc8dbnbgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:35 +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 29Q2nxLq022012; Wed, 26 Oct 2022 06:29:33 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybpqpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KY0Bkl3/kRFUEA2mZUk5TyjlnjRG8H1nqdO3iRvOOUooKrR1ZwfHkHI+iFuo1kzPmjsK2ysdVL5CfhslgquImaUerOd2kRrk4V3PH1rwDRQl9b4VHldnTaYvy0hfDls0FrFZqiVbJfpQ4kT6ylFVbzrqbJp3umir14JZgf6wV2r2MMQYdDWaZUh3fMV++FeN4rwlF12gF0UTkAwRAf4EMhUFGJ2XKFcRBEpXggVgod+QyL1Nb/NS2n0ivIFz3aRLxADuBgNLMj7e9WKhROHuafzMuwV1M77hDvFUkAvZw0FI9Mvv15Pppol5UmlW1w1Zw5LZB4vkHy+2jQfnge1ZAA== 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=hGeajXiJmzJw+C0wcLKSWZWKF7gzty0zx76vtcdM3kE=; b=je2vmycjzCGHGrWXuKEz4wWF6tpZYFFFDcB9TdIWC/eiG7mVh7AwBEO+IQlUpppW9iGZlhT137KdgABzh+Rsyw2XwO/e3auUa/h6he5rlKH1fwxxJQyEx88FK/wwTZRLeh3KoRthiVnuRRXQnKEpg/9+6diOSyTFkZGHjjdjWZuuhBnkXC8YyGX2VabLi1OWXRs7cAnNaMz5HTEW40pvjNrAWy6OcDxUPD6SX+j2/RgpgZNr97tJCqZpBkem1G7HV+z2o9bZ9GRwHHTVU6g65noVu9xPTNxSgQ/+JWN4tpMs5XsF+knbyDkSVm+38yX7foq9iMgybUrzgbKw/wA9GA== 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=hGeajXiJmzJw+C0wcLKSWZWKF7gzty0zx76vtcdM3kE=; b=DKLp8LhIEFuHvqAU2UQQ9oaRgtjJOPosm75pWLGh6oK68Z8o3KwnM+U3czeGbS8Ur+MJ1D06nseGl1M3813Lc6oTFRJ0uViFgnv9+7K7S+Tz/NHfSCiY5pN62CWv8dAWjsdAiVN1b4HkD9Yqz1ytQyoF0bJGwDbIIqN68lxIIAM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:29:32 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:32 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 07/26] xfs: check owner of dir3 data blocks Date: Wed, 26 Oct 2022 11:58:24 +0530 Message-Id: <20221026062843.927600-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR0101CA0018.apcprd01.prod.exchangelabs.com (2603:1096:404:92::30) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 0581b569-fb03-4e7c-4051-08dab71b7161 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lKz6rwTzCgbGKP0ucGqahOA47/5IhXxpexC5qewAUYZlqOaCA3mWTRbAPvEmmUJa/gT7NT+3PjHhw/xn7zjkJ23Tut+9pSr4a1SXnn37fpuoRG6ZCKiTHkb6Su6InfAEqyrHn4Am11IRkEoqDiUwEUr+IQtW6Fble6p42dDIXweKNJQBAtwZLQEkRWeqyVtdQdZHbyLhUOUfj+Y8sqoIDqDyhTa035IuCAS9w6K8mIXJvN/jJG70+/YtLQxZ4D3Mm88fx7hJMuC52CUUDsvhW8/Uod8BNVG0eRPArBLItGkKCvNYUuElFsIDXC6pWRUVds1/TJFRwmVHj+xicjWcwa5M4dHsrCjV3LF8AwijlPoacmbxDHZejsOyII9IC4WZ+j+J0Pk+fZD1G3oIOGFJcJqJAAiJW380TH2iwq2yCDX1aj7hTGPw2VyFRBr6sykSz5o/yj6ghE+5kkrYetb49mkKOFwdO1/NcNUOvs44DKSLmPNV6CmGk0ICAe58DSiXQ819/8BaCzQrChkIUHQNkeSNJuu0ustgvjd49TcqaQcmioOKg/0dsOGHTz9nVLNgKKBL0DqKtHtDzeqjT+AbXreeFRJS70Jnib1GvqipdQgFBdKK6Cgo9mbyIJnekFTTVLzpls08NjUqkD02jPKE/f/oMfxW7PL9ROj2aPbi0wjSsiO90hEtCOdJX97qJU/KN6LhRIepqFryG+GsgY2Dq31nroy+6Kc7nXfaaogsxPwoTrytl1yqmYNiOoD1xtfd 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /et3PfXC5s+1/cYCo0xb7IH3JBw9F/5lzifKn7bbA1PJVttdqE5TtUYpLgJAla5xbqdq/uy72cFlgNbUpQdqkGr6/WT43WcvB78M58g4OhwRQ5K1fLH+59mW38ptkkj+Tlq1MVthvgSFuiEruSh9FwMLIXDiVnXJztCj1r9EdS4DnhxDOi/RUuliDlzhGhZ7Zi9Qk2qgv64niZ681h4Vfe2Oh8kt1/jj3Qh2jZXBlChe1DIe9iEAV2+XQYdMI+aQIPI5wvbe4TJjan/u1BFF7hscDMllsGg6l4MlR7Dix9RFDHj6wUxtX3aQdPt78nBouQdrekJs5C41stTfc8qIuP8YN8vyWZVhi/Y+8PRfQhxxMPUtollfb7kNB48cLQs16nU5UBriQBt2rqJlPSjEcicEKdMlV24vxKKMF9lQFnc9xyCou6wqHcyH5ldPiPkvH7j8/M5eDkoLFlLGqraTyJvauLeaJwdTwBdcjchxSxcuv0KcDvP3ueTpnKJSQwyvoUmhvxXcq1gWS4CoUkrtoGeSHI14O0fsST5T2zejNE35B8Y1Du6hkMGKMVvH5Mni1rSOQieHq8oLfJOIksjm1DOtmplKB2JzU4kAf5xh+uvTxmJNTFTc42uojZiBMa/xJto4K+2gvQNydPmLf0kSP0BosTh1mBPISzatdavL2ztY+X3HSX1FclIuNffzrqD4nK62WWm6oJxL0AiwFef84tV1fC1PgYvbStVxOOBkxIv6SDpYhL4djlbVXfahHD93bPCkL3eceMVT9Xt2zp9Hs6dcd5wFClusFaDdqIWHlFD2NMYaLDCST51TP0LaMR0LbWyz++MvCfGceJAI5reLquAcHoCn/JpvBZmjGx7CX6EqYqrxXBoHRVmouroVGhm2yoJWbgWdjQL8iVS1zNNp3fKBy+4yn0yRmlU2f40ExgdXc0TXO9aQZEaom7sNkJJ/9EF7z9e/3cqO5+T/2xAJeDdglx7bhQeDqooGOJ7VxIXTgpBU1cCFE6vZNtkN08jGY5bgs3QIJO67Fn5E/httw0OWV2GGUtLmqvDfRER7ZBzA2Webeluh7H9YyjS6fP4FWi95zQ5OtSIvv9ntmhYTSQIhKoQk7L6ZEtpceImGd6ja+BlZTT9YwgEWuy3qygiEWbeZvDRjd23OOYG30YNKmG+9v+WZEL7Ft4Yqn0xNO9XltyMRfmuBrylZsApvBxClA9DooceLaXnyYVXYjyUa5KZFQGpKdnMdGZwSXtkeXM+1UQj6UolhC8bsmPL8Ov4fLDdvl3pNK2XTCKclu9OPlUy+ulBDdH5Nqq6Zf19d8mn5Pf7Re+qrZAQfuhZtmqEevhIH/9bvX9jGPjIH1Nvv+ZUYWop7zdcsKNpA2zfPWFx78NIJcqrYAj0ofM/U9SrRdVJsx6GJw40uSsyXbjaxWgCsK3/3Ccr6rgD42N6/TgExVW7lO5k5s38ur0kgESVGdP7AinE3WPjM13o8ZgymxlXm1jY4ddKQjU+u65dPe1EtOO7nQoEnKeaggDk769bYONz2K/rjUBIMCVADy5h5stbbjaHbCsoCkp7bAEL/5riRIGf/I3aAYbyamiij9Rlzz0MxfGZpcNMg6yxIwyFW7A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0581b569-fb03-4e7c-4051-08dab71b7161 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:32.2575 (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: WfdQSvUCvXbC/J17jaDht8kvuL7CYrwxPNcMty++G+rXeRceSVpt61dBkp/EgaVkUWIRQFjjA9u5LJIWY4xsxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: iT6twhD0T63pdQbx6X5-wRS4JsHtaTVw X-Proofpoint-GUID: iT6twhD0T63pdQbx6X5-wRS4JsHtaTVw Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit a10c21ed5d5241d11cf1d5a4556730840572900b upstream. [Slightly edit xfs_dir3_data_read() to work with existing mapped_bno argument instead of flag values introduced in later kernels] Check the owner field of dir3 data block headers. If it's corrupt, release the buffer and return EFSCORRUPTED. All callers handle this properly. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_dir2_data.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c index 2c79be4c3153..2d92bcd8c801 100644 --- a/fs/xfs/libxfs/xfs_dir2_data.c +++ b/fs/xfs/libxfs/xfs_dir2_data.c @@ -348,6 +348,22 @@ static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = { .verify_write = xfs_dir3_data_write_verify, }; +static xfs_failaddr_t +xfs_dir3_data_header_check( + struct xfs_inode *dp, + struct xfs_buf *bp) +{ + struct xfs_mount *mp = dp->i_mount; + + if (xfs_sb_version_hascrc(&mp->m_sb)) { + struct xfs_dir3_data_hdr *hdr3 = bp->b_addr; + + if (be64_to_cpu(hdr3->hdr.owner) != dp->i_ino) + return __this_address; + } + + return NULL; +} int xfs_dir3_data_read( @@ -357,12 +373,24 @@ xfs_dir3_data_read( xfs_daddr_t mapped_bno, struct xfs_buf **bpp) { + xfs_failaddr_t fa; int err; err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp, XFS_DATA_FORK, &xfs_dir3_data_buf_ops); - if (!err && tp && *bpp) - xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF); + if (err || !*bpp) + return err; + + /* Check things that we can't do in the verifier. */ + fa = xfs_dir3_data_header_check(dp, *bpp); + if (fa) { + __xfs_buf_mark_corrupt(*bpp, fa); + xfs_trans_brelse(tp, *bpp); + *bpp = NULL; + return -EFSCORRUPTED; + } + + xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF); return err; } From patchwork Wed Oct 26 06:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020194 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 47856FA373D for ; Wed, 26 Oct 2022 06:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232906AbiJZG3w (ORCPT ); Wed, 26 Oct 2022 02:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbiJZG3u (ORCPT ); Wed, 26 Oct 2022 02:29:50 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22AD3AE; Tue, 25 Oct 2022 23:29:45 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nbxc017465; Wed, 26 Oct 2022 06:29:42 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=OFVT115MFHUIDHpSuTakzBw7/XiBRobQCx28kmy3LiE=; b=NGqnlyr6ZvA9CeqblIy+xjXBqyfw4TFOisCmA1LhaQ2KOjM4oY5UY8/INK+SE9Q7zfWd LZQNs25fnW0yE/ioQW/DZ8c02ggcPWXUjhwxfZ1Cekity7bSnWSjtKEODNoHolX8m4ck omeR5cYmXQ1KD1M8HVi7gkNb6R6mksiqGeYh7jLAWtbpYRMOJkEnWs2bhlYwm5SQGstF TsQy/zHBOlZmlyo0+dM68v3+dsPmeBzHWoui33LJ7CuxelF3mHHN5tWQJ3T0ZLJP6x/W zpdjowR2UX5ODB6BqA4uFestiM7dCCXK7C5x5zo9CnNakSmUMXkZ49dLbLMoJP7VGAcF 5Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e60k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:41 +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 29Q35rxW031899; Wed, 26 Oct 2022 06:29:40 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybe7g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CmP0gUuFdbYnXh8RxiD+nl5awZZD8Z8kSTPXjJsbKNIqRqXB1kKNoLHCyxfuE3LL9jDPfNUfFLePZCWeJt5VVOTPsNzWFDEIbgKUC4F0WMk5EF1hwswvbRjKBH/7Mv2Hj68l8g/ekiDuC5w7y81atWCf7/K1FY+mcoMGnGPYJLYHO46a7rWru8ninJqr9S/MkmYE7bl5OcGvnAhhPbRemiu+JWIiW1uRlasC0azqibh6X8wv03qbt3x0Xqr4KEz0vxgdcPz/PCWjabSfZbw+NnmEDX00kNhdpgdve42nWXNkVsOwhakXOlKVpVzQnXSX9RX78PlJybKb9aeGFz/JzQ== 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=OFVT115MFHUIDHpSuTakzBw7/XiBRobQCx28kmy3LiE=; b=Ircbrqyo6mMNB75ekdwzaachSZU/f0iNYRnFVYddMsmOQSBtTzsROQvUK+ocJZn0Z+d/a2rkr/9iFoIVHCya+RJrUAJx/bd+YGpwiooxZWdeqwqCWBd/bklDOECxG1DgOyq7KpVNShHN+zq6Yam2HJgBp2kagdoXgd9PBZQQhQ10l8Y3n+0AOHejc1rKBmQUsn4fFO0OC4m3C+4bBidNASqI6qE+O3gWL9fn6UTwseF9kqv7Vzhiaezxci5LokgflgOK2Osp2BAjoa9HYFVGnBL4uYZNNPFmytUtk2cPAp+vUjiyIL1M0yCUol4aRwNMJ8kcP6WSlFXegUCsC4F2HQ== 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=OFVT115MFHUIDHpSuTakzBw7/XiBRobQCx28kmy3LiE=; b=BROhEFyq38d6ZDDjxEuaxI9lU3tvQR2MjghvZrVvEvHEm++uwuNj3zFj9zCpcUD3jz5wej3l/WqMJoMjNDMaA3XfqMt5tVq3eYf/jkk5JkNV7z6qh79VKe7owJRxUXVJGN/u2OGcpY1+gf1pAYJ6ROckTnmMReZbfl0ajFPlY/Q= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:29:38 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:38 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 08/26] xfs: check owner of dir3 blocks Date: Wed, 26 Oct 2022 11:58:25 +0530 Message-Id: <20221026062843.927600-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0073.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31a::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 447e8d16-6805-4f28-2d88-08dab71b753a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7iwEmX9W0MOe+90o0TQ7/jRja7yH6a5HwMdpdIQQeoJUSkxgv1h13A3AKgwnPRwsr81FQHe9cGYPSISQIMdd91/WwmRnaQUaW5UOdGOmUzptU8qEs2gxBkpXBrMz26sd4+ACFPyZ1acLp6penM50+dA6jfaa/6E0eDazlCSG0KexLYbr1vE6dHsWmqkdelS9gtzMFZzWCmJHuXMfPe0Jve/mE0w/S2DFTKg68RoAPjYxNtQ8tal5FcpwSNQWg1yCGpH+fB5Lt9Ik/Teiay+8PeyiGkYDqQOV5VUwbZHTSHvrGWGz/BAgl3VFj2Fd9dFsTJFQ01iWEM3Ak7V3SClsQMuLrs9PP9BF/+GU/v/P+JYlHdO+Y9VYysDg2fSnCGKUSoQTuxu1auhkDYP9IViymldh5VGPX3hgkaWwodVdKaZFQQNnqdmMFJSYvJgohwKWZ1s1iwVKfiIu4cuNKo54/z4vRoV0ut2n2HcLmgT7sSjGZH5ACyFVB23wIPFpyBaIXSTnYuit79yjgZT1G1n79Drt/ewfIvnq077YZ88ooegYyCbWang96jQTVPsZPSZHx7t5pTw9coDvE1/4gpLRDeH8gUKVx1R9cfNJZeilygScE3WDRuS41D2wTdRiov86oJWOE4aLM7m8KYtx31ys7RxYdDvcgYb0i99sfHyqwTi2TRO3bOozT8rGNB728oZhSqLV7L2HLQPGTF8Pqu4qWMgIfNLuIsZmc5/sXh0vC2JPST/dhdPxfQ6hbUsXkC9O 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CUHnziIPhNkhHA1LShZjCiudCXsoFjZIbTry4c3GjvrVljLoqn3DxzMc1OjweBzmwnjm9JBomyRiAsj2MfFofIEMVtd4arRQPQF6L7ebcTeYMx3+h8ioIOzgazYJsdm9HFBcUf0ftkXZTI+hbmAQ+gutF0/DH25kr+Hx/+xnj6TujNCX09ZF/uQ3fTXvSbVghgvL989sWX/nnRJbJNVfQtCOgAnwQWrVPGLlWFcvwth7t+GR7r7rAum5JCapm6XpOYOGG4Dy6LSp2aInStjoYZJvTiqo1pBdSCdWbAOLvBzz9Ta8MPCxOaUdUPkRTbjzz5o5Kcqr7s4HxxtXUVxJNdFxeFXqamYxu7Q/zoD+bY8hTvZfAg1ed5+XvZG7D4meykDx5VkgCznwIGqAArY0NyhL9Yno7nsebGFh5gIehLQGqJt8c2Ulc6edP4zzzfHuZ4IKujXP88a46Rc3iTRSYxoRfhDev/0sIsnj5e5N9563335l5DzVTNlEN73V7jtt0Dq+ArvJNMvt8sFjKDaev5Tr8nAFM8TYj31NN82hlyvYoRQRAagNfvbkvIGlON0j5uil1rF+zXQca/a5fKFIx6Y4ibZtXFzat86M014bG9+yhMjkm+0LmLzd52zxEafKqRXFHRqxc9AN8Z3I2wgcd1zZ1ttgmdNezJBusO7OTV9De5j0HpyUsag2RNOttllf7/ck572sYhhzZT1DGI+DE7xjusBJDqTTgf6YlQsBzZnLWuwXSGKdMPzodukCvNurC/asiuDvAoqqfRV3M4TKhSnPX77a7d91d/GsHqG+R+DFfYRErMQdcBLVn2SCsKVcrlHn/9PVcwj6UiW9r7sIsom5MqR8tUmNIAnYXIEER6TtioTI28RpKxhOZYgJ75vZICbsxTaccQzeB/aQyyFX35sKdYFIbJzq/+kggCZi1G9CYeye3pWTvq6B3lxaLORqboH4fvkWyzg67DzI8zFRIIdUNlEHPWaltBmaocUrTQ8gMBaC4jvSOmm7uAA2I1SO3+Xqx3DguEbvo/Yql4g2XSY64eTOeQR54RHean0d5DyZvpPbxChDnUKQUrDHu/4V76Vwel9C32bv82AYd+jatdvAoSIBBtijCadV7f01MLdNXZs8RDEtHVxwuOEotK2TRbX33Zq/vDlEJGcoFuzKQWg4Q9yYfXTEEXbvieG5cDrFxNc+6KntlqabJMZAKvFCWIUDkiESqZFvN9SxA7uCbl2CO0Ffiy+0FiO7gXxCsrDpCVkncx2R0CeQGPyL6YGsuEG6dk1VXxh3T1wKbzqKDOgJV7yW5NgkdBvNMkpOvlNkF3CEO6/gMopxHs987iRs7tU2ggqZRiexuq6IahDwdHnLX7CGCLZosshNJ/jYaN+8F32inYB5vH206YAmr+uv1xJcIzSPyHH+GRaN+Py71yLuimoDtIP93JEOrLnMZiEupNnB0ZoM1FGmlfETRXGe42jEeYmu7FP0kH0CV/yHFhVQh1J+cmC8uP2PxBuMSDWoJ1Og2t9QRvrz5a8ZxI/IDyreIxcYZ/w5KX6bFwnrOXT6jZVzXBE6HaCkpzfI8ls614jNKKproMxB6QGAzuxm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 447e8d16-6805-4f28-2d88-08dab71b753a X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:38.7426 (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: ZrYL++CCJdvCWcxTNduIYzu42gq/GPv7U4Vm2HqnP6gWgVXbVlzN4Uc1RvIDpVPSFLKtjxByCvpFHnzAhevOGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: ZONPDpSnTc-IugwYIAS02-0y26UgusY3 X-Proofpoint-ORIG-GUID: ZONPDpSnTc-IugwYIAS02-0y26UgusY3 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 1b2c1a63b678d63e9c98314d44413f5af79c9c80 upstream. Check the owner field of dir3 block headers. If it's corrupt, release the buffer and return EFSCORRUPTED. All callers handle this properly. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_dir2_block.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 49e4bc39e7bb..d034d661957c 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -114,6 +114,23 @@ const struct xfs_buf_ops xfs_dir3_block_buf_ops = { .verify_struct = xfs_dir3_block_verify, }; +static xfs_failaddr_t +xfs_dir3_block_header_check( + struct xfs_inode *dp, + struct xfs_buf *bp) +{ + struct xfs_mount *mp = dp->i_mount; + + if (xfs_sb_version_hascrc(&mp->m_sb)) { + struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; + + if (be64_to_cpu(hdr3->owner) != dp->i_ino) + return __this_address; + } + + return NULL; +} + int xfs_dir3_block_read( struct xfs_trans *tp, @@ -121,12 +138,24 @@ xfs_dir3_block_read( struct xfs_buf **bpp) { struct xfs_mount *mp = dp->i_mount; + xfs_failaddr_t fa; int err; err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp, XFS_DATA_FORK, &xfs_dir3_block_buf_ops); - if (!err && tp && *bpp) - xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); + if (err || !*bpp) + return err; + + /* Check things that we can't do in the verifier. */ + fa = xfs_dir3_block_header_check(dp, *bpp); + if (fa) { + __xfs_buf_mark_corrupt(*bpp, fa); + xfs_trans_brelse(tp, *bpp); + *bpp = NULL; + return -EFSCORRUPTED; + } + + xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); return err; } From patchwork Wed Oct 26 06:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020195 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 71152FA373D for ; Wed, 26 Oct 2022 06:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233118AbiJZG34 (ORCPT ); Wed, 26 Oct 2022 02:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233126AbiJZG3z (ORCPT ); Wed, 26 Oct 2022 02:29:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBC241A070; Tue, 25 Oct 2022 23:29:52 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nEAY023399; Wed, 26 Oct 2022 06:29:48 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=bnW6c8exk16svsRuIspMgoYceKSnsQQTUifrmtM2ioI=; b=2IrxgfFOLOaT8Qt61sL9iTMWXDn+XFZVZIen38+zB/APEAh3kSMYMNrx/W6mzchi289l M9zOY8LE95zfPMg3zIm/JwDXPpb/99r1sZolWB07JlPqdlpRkqyDeVIV218So9Z9dfxz ty3fnRI0Yk/m8QVXsohbg3N46gF1Uy2fS9qCSBxM/pmvv2eabu0BOOgFHtsg+Nim2dyP eeTNIFLQuZfZYparU8M8DSbcd/rH4eoXmhloXT97tfIk0UrNuYpMy22Xh1CNU8M03o9i VHH16gDsUcfMwG0GAzhNwibkJ21s/pDiH0UCuRJg65MzDu5RmsQ9QodOyIssY6Xodr8W 3g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc7a35np9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:48 +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 29Q33Vl0017308; Wed, 26 Oct 2022 06:29:47 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5mwty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NC8/dBznevDKHb4d60oDj3OJ0Jw6jC1i5F2Wmf5qCnd6eAza0sX5x7dMG57wzL8dlF9DCUaq+ZqJlaRZojXIWhn0rs4v+Nt5HpQyNCuc6Pkv1WJNQ0K1596VzQhjA/8tjdPdDoC6FMQ5U8B3pIuGsYtFJGD9nnDD4XwCnOyexL4Cv4hMHGfaG+X7qZtdysBaQbWJ5LCOcvLRTkafvEtADHeqrIjQmY7/OniUXLxD4D3kfoQh9KLgDf0OkBD4pKwi8+aC1HMU2Xmt/oWvYc6X8PMSqyVPQfhv6s1a9j2UeGqVeebtqgKcctxxuIE/px1BhjjkiyLHBXvIAbC5a1CEPw== 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=bnW6c8exk16svsRuIspMgoYceKSnsQQTUifrmtM2ioI=; b=KekTtV20rbEfaNWeX0UoIhxHMuNPI9rDuYyZxbymbCx0XAJ3TAdCD+Wtm/2stXRxyPTzCbpI+RItmrHWD30ofkXYGl4C1iHkQilYVpzgzOW4Pic9JG50myQpU3UK9y8OOCJU4WYv7ORQODGu3V5lsaWig6onNDSYwFynWDk6rv6eWlW5W18WCPP12vjeNNvjaHwNVzLpniM+LJtn7nY2Ifd9gTPJJQViBBMr6+WQjWXFcQlwhds2setgXiBFGMHEqU0Yk2AkLOsGhTyaCQJ+RvKwrWMU97cGlY7Ipucri84mqPLc4D5LNsQJ7Cp0SGNU1aPizr939SRxN8cAQciNUA== 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=bnW6c8exk16svsRuIspMgoYceKSnsQQTUifrmtM2ioI=; b=R6/q7yhHMb20UPR8jurp6P/x84GIabNhLvwEU4xk5SZOD2l6X6gymbCZygD0729yAu5CDv6CalvGrxXm/+PegpFDCPwyJhDBGqXA/DPR0CyWVljFNOksmSv2OJ01zuZEcUDgKLxSlzk4tqAolMRsv/8XkzrthrcoXh+wLjBTqdc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:29:45 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:45 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 09/26] xfs: Use scnprintf() for avoiding potential buffer overflow Date: Wed, 26 Oct 2022 11:58:26 +0530 Message-Id: <20221026062843.927600-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0216.jpnprd01.prod.outlook.com (2603:1096:404:29::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: a28eb0b0-2420-4744-d338-08dab71b7925 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GPYnj1DPPLgZmGJE4fb9YS8Heo3FN/tS89Vp+H5dkd2zvKuPEJlLgZ+oLZe1m2/erqCRBn9vV395LULkyTNwjqjeXPRnsK+0mY5hOuRIUQeBGBkDVxXLYXC7AopX+2uAgP5wwc6c/JwKlLgiWvO8aIRG4u/w4tU2YVBhwUNNECVnPeIUw3xtFLx5Er8t2oN4RHIV5CMz6ypPj3z43AYg8AzM6dxa2B2K1t2aGmGXCj8c+K9KbiRaQDRdahzwAsxrwzkz3L94QuTmhlbMOSHEsa+VbBcqsJYGGbvzF2q104Ypf4/gxKVZ8MkA06J0tJP2cagSf+aJz+5wVousQBGBfr3B54Qbmvnwl1FlPLfVAHxO45z8gHSG0bFHsPRYQ3rSkvolUURqf4djV2TxSFbSz9FwK+ciUleEY7SGqWd28H7OSrTqPmLSJxt7FJOrWWUc/CWuQqGo98fcxfmADoF2lMOmJsCzTqpFsoF38p2S03ya1lhQZSjPT4ffyJ17erO5gc/d7ACxK3Yu1L9haN1AULOX/WYXXlmhoZVGp7njy3UdaMnKrhfuTwZZUZ1RH4mzAloMQptWs82Ug7R9+CoHxGkFvVq7n7x1+w/LFr4ysxWetHX5ZNlg4CJ5Sqe2GasgyXs2kwIrC+6O3Jzzrxd/xmdrtTGbgzPnQIEIuuQ32H0S7LHoSM4mcJEwm7u3eP99dRMxKws77HD9Pq/X9FNlCNe9CUnn4hBeuU7zf8cP+Z4/bA9U9+FOzzRDN/JjPcVA 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gVltrkgP3SUpnxwK0Dl6quVErCYTxfF/NgIue8qZBgYulDNdZdPUP9RVFQOscI50vg3QMR0Hs7v8qPzC1pHUvwQwI9IfwWP3UZhsLf09JdNJzlG6FhCLLOJkdTAUpflq61YPmAQxtRTPyHs2CBmYtTQknzEGq8jQ4v4P0N/m0t+FMsII4406WUbPqr0d8VHHJlPdXRAZdcyWdnGqO1H2o/LbiA0QYVIZnpZZ9B5lrXpAfHQ5+STYWRrcDZEdiVoReoFRUkjQ0fA1fSnT9WXKIJbnzmQmxXgP8n99JKmQWVWO5J4LzKM6/x4foozHYP2LzBouyEE/z3XQYfnLv+BY256dtxKraJiguQUjQ+1s4a2BBu2fDpnltMKS5fF4s8mespI1ejp2i+Jb1UxuYtnD+F3pKzrQNvZa1+HUKrlk9IYg7dNa7oO0JX50i46cZ/K5xCutHS4kRcGrXs3e+NHWDM17f4f4lzuI25eZjVOoNtIOMt5gxiOV3Qr5EiK1U3jMPmh2wJN553terq57MBzBOJDSR7QVhTWcHMDDqsfHHKlpRvpZZCP6txmeGvakR5QH0WWgJDMNhYOLy5aC2sWOfAcYih2Y6FOXTP+6oVbTa6UyckI6PuvqoQgjfMUUNpk6zKvSXEhVjDaon5amCByTYi39vrI4darAHJo/vuXJc92DFIwFNG/X9TBjzzt+M1QPDTHdYMkcpyFjbthY+Bhu6LEW+vrPG9H/B7V1fdU7hcSxq0XbWzop5ptrZNhuwLB1/WBCAZweme0MWRyzKuCOwaoU73HzCu9uTIUZ5I4HStMvGpbMsO2zqpcjxY8T05a1OypWC11+GtCOHE7pcYKSWitDIIKjUvLUwXD+SECYJrEryvyAx+HwZzHJaV3DP+MMTUMQYu8r5kIigSft14tXkDf7IPpEKyxLr7/m/+nbh4HkBdVBE/HKcVzPcaqZaI3i8I3pkeMzt6hx0wIemGdaaHhCQGnVrGtcNom4NJ90wZBDT3XvCfe5A1Nq/kzIrOi5VUuphhFfOz5d1Iyii3ZU/rj6843qr0D6T6K7SkL0NeRtg0XOyim1MIi1Zy36LYBwmepcwAn1eLff3pTzXkxyEBD9RaC8m1aGgRTZ2+3nlhSgPVzdAvT1BEtijCCfkjIrdiVWdVxPmxHyM59lHhUF6lQl95GjXZ8O8aDVHRM0P4UaokhRX0HNEhCkSpnbUl0m8avZcLHL5GKjKVeebE6qNoMt3d6m1xCLvH/+YRVTvX8hwVG0D7AEGTQlGdQzUwOpY+LwGBGxKx7AMCPdGZf3Kg3GHbqIqcehpMwPlwXN7dyQGB2yuw5NN25Kh5okye6tuGSy1B30SGmu+Stttz8s/xZnfeMALR/d0YHFfo5bpQq0twDK1lNbyHQfzFRjUvMK6Sm8sRYGyp8hq8tZQt+jjCOJh1AiXDQD27nlUmWMacNJ09cFCRza9TO0H38JupDwN+xzZ7OUhxo3Wy6CWQzaouPyOps04w9wj760vg/NUcxDF1b899Wyr3fPoj9sUSv12fU5V0ChXGomSi8BQ1EXzqlz/r1hyU+dW425sP59BzQYLetfDK9uVOBKkjGJ2ud4Gy02pqwytjH1i06ZF4qwWA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a28eb0b0-2420-4744-d338-08dab71b7925 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:45.3054 (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: OGVS86ru9io3qoxodOyRCb82TxGTjODDIvJyxcwpn25+sMFiw7YWfwKsxxpFwmPdsRoHagf8WbQJNx1oKFWqUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: kHkvfJDNC2YOKmfAA5dqdZ_pPH9F3pYR X-Proofpoint-ORIG-GUID: kHkvfJDNC2YOKmfAA5dqdZ_pPH9F3pYR Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Takashi Iwai commit 17bb60b74124e9491d593e2601e3afe14daa2f57 upstream. Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Signed-off-by: Takashi Iwai Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_stats.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c index 113883c4f202..f70f1255220b 100644 --- a/fs/xfs/xfs_stats.c +++ b/fs/xfs/xfs_stats.c @@ -57,13 +57,13 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) /* Loop over all stats groups */ for (i = j = 0; i < ARRAY_SIZE(xstats); i++) { - len += snprintf(buf + len, PATH_MAX - len, "%s", + len += scnprintf(buf + len, PATH_MAX - len, "%s", xstats[i].desc); /* inner loop does each group */ for (; j < xstats[i].endpoint; j++) - len += snprintf(buf + len, PATH_MAX - len, " %u", + len += scnprintf(buf + len, PATH_MAX - len, " %u", counter_val(stats, j)); - len += snprintf(buf + len, PATH_MAX - len, "\n"); + len += scnprintf(buf + len, PATH_MAX - len, "\n"); } /* extra precision counters */ for_each_possible_cpu(i) { @@ -72,9 +72,9 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) xs_read_bytes += per_cpu_ptr(stats, i)->s.xs_read_bytes; } - len += snprintf(buf + len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n", + len += scnprintf(buf + len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n", xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); - len += snprintf(buf + len, PATH_MAX-len, "debug %u\n", + len += scnprintf(buf + len, PATH_MAX-len, "debug %u\n", #if defined(DEBUG) 1); #else From patchwork Wed Oct 26 06:28:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020196 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 9C12FC38A2D for ; Wed, 26 Oct 2022 06:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233125AbiJZGaD (ORCPT ); Wed, 26 Oct 2022 02:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbiJZGaC (ORCPT ); Wed, 26 Oct 2022 02:30:02 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E791F9E8; Tue, 25 Oct 2022 23:30:00 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nEAZ023399; Wed, 26 Oct 2022 06:29: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=n6KQS4kuU1352yEvwe4iEu0M6Zlk8BcKBiK/xTkeCVo=; b=oA6pXROzSqthjra7fYHrE3OBm1lTWTyP1/5K4QN8gL5AJS5aCGPoWJ7g0wjzOjiCEN9R 4x97y1vZFV7y7vSOT1bGwxoUfomTl4WNtXMAnk4BMyRdbiwSukIpC39+ato6KN+cCtOq 7qNvAhZOURAiiIonrLJfIR7GKj/JpUZjSYRcyusoYVxSyLZmyVlIl+/mwJ4C28ttdvGi FBy3ZFNlhkI7uCS9NspfV2ibuVVhuDHCEV4hJEQNH9Qn53MdTsosHvGMsVnyRrX+yNWN NjRiFT8U5uzAP9iFtIfUBSchZRqIsyyO7FXKhXXOHmNfX8/J+LRQIfB9rJb/kbRVbAVD nQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc7a35npf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:55 +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 29Q2FAxs017123; Wed, 26 Oct 2022 06:29:54 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5mwwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:29:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i16zJ96yP7gWiAyE+k3TEfhps2gigdfrIkP1SXdwC5HTTbNVz3jhZ4nz6BZ63qavn2aPQh/Ktfq8XZnMqd0QHwrw6PxC7t3bsoq+Z8Uzx0QF5g8RLdzaHOMHGkJ2M5v0ATCQqW0YQJ8/xXDlpoSP/0vBY/SX+oKGEeBK2wsefv6s4zeBgpbLO3RXivnhBCvjQAejwJy32udYId73zSjZoy2BcjBAAYmZ7EocxLYtg1Ym2gAZtgjehMwESckHoZVSGdu+G+QEXtlU5ezuQrwAfaIrj4/4i1k0c1zDm3ssqLCh2vNMYs85syebl6TqW/EY2y0YHHXYAtFUvnTtVZsOnA== 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=n6KQS4kuU1352yEvwe4iEu0M6Zlk8BcKBiK/xTkeCVo=; b=PtxIaEbCpBN1bh9mJ5K378U/k9E9xJL8td3ma0sQX9wCvJ+xDDj9GDlfk71I/9GjlhSB6DWqfRcQCyrUpj1+k0Tbb8VPl8mK8xcGY/ZyepQIr1nXmRq+8aXA/okdCakel5lTlrGYGIRhuFpoEXqEABs3/bD4JUEIHv29zrd7Wo7Ht/o9zT9fWyjFCc70A2O4AnyL9gzQxLZwjZdsuB0Nrv1oyH00WJqmWqGEqisvr1AQR3XRJpeMPIJn04cidBcn2HJdDasldpcRsnVPtt5FbVSegtPGIT2srtM7xPDcAe12NoYLYo0ANt7b7jEfHlyf9aPbXtE41LdpljUW/xjH2A== 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=n6KQS4kuU1352yEvwe4iEu0M6Zlk8BcKBiK/xTkeCVo=; b=CTBSRS+nSz1lW0tXxWV32u0XUVbxACQibrfeUQECSwfHPO5iuJBXSWSk/99sb9kaPoAfqcwvm4TVcvXRX3K0uG6X0RPQ22Kc40lamCmJTOK+R19WB42hPK1YbeBoF+7HO0OKMPag/sXQsSz3QA5RJTdYKkwv8237TxuohZ1XfmQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:29:51 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:29:51 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 10/26] xfs: remove the xfs_disk_dquot_t and xfs_dquot_t Date: Wed, 26 Oct 2022 11:58:27 +0530 Message-Id: <20221026062843.927600-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0129.jpnprd01.prod.outlook.com (2603:1096:404:2d::21) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 4846c877-b233-4f96-f02b-08dab71b7ceb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rIQX9eQhxovPjYHYJC+dkihvEMMssTqQhP2InjJ7p8duxgzyULSJxJbLOdYDRbJJ4JcNDwMSC4pdPj3HNFNUABXJjSbgNo8drv7ZIyKX7EH5Z8+btoQudw6SVliimt59EAMDOJI23s6IDj5l1zUgZ8/iuU5uo/LqxpjiTqkdnEpZlddZGj/ZKqW6I28h02jasDJAOJb4gVyU9MVp5djyOoSYbPHp8wdG8TVVCfdvLkpkJ9k8uvLjcXFibr6n9ZvfFpREHhuaYUUAB45ZCIGxo23t0HzaLC3zO0wiGF202EtAtzHbtjURmrUUcX0IV6WYoFOugzv4G6muqNdgQZeigGKhOSLOw+DKVMXCHb6nV0NxszqXagnA1aU76SMc6s6X+aJFN0o935R8hGi0T+RacwH7cwF6hXDA6XtLz72PIxnKELAZUm4qmJYg4PFHyr5Z2dpUoK1cy0zXBkg7stFxeQnvI+AJv7gnowwMbJ/WqVZCBysliiclorW5VZWjQk1pCFICpfnNRS0vD0bQQ/wg3WzCduCrssdGOOJF7rOYS96MYfnSN0cb4LybFzkEWs2wk94leFbzaUkRzb/SDM6AX3zVZzs26qTiJHG0ad5uctdDp45e76Ih/j2P408WnGZV8pIAwCv37JfrUzKDpncuU7VdAhNGxcTjlAAuIn8ZzrlCkep0B82qKMfvi9vj9b3hxnMI8qicc4tLRfC+VrqcT1uv4XwH9zIFQ0fKMMpfdtVTsIsngyDrETnTo97Pnkwc 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(34290500002)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(30864003)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: opEybWLBvjBNcqwivaYuI2DvWyu/uWEVmQtweyQqXA0i8l96ldCk23Aux7FBqy2C+wHrMvFEzUSdJVgLCvavKp5ynfYo1QdajU7oMh1eMvnP8STWq0wngcEXilWEv62bit017x+1liUGLjCDDPz0/tGdnOEf1mAHGKyvGbcBKTJ/07F5CwdK09/yI8X/HMPfSU5OFu9s6BgPbfA9ENQNRRIpsM4JcjPIXIBT8Y4t8QIplnyaqaEP7Fd5k/FvDOHQLwRKB/NkEaZh2Vas3+2Gxp5nFhMjgmBSG/FulqH6s7GPMzVMw0sV+Bgxp3WCOw04yCWw3O9khXE7X3zYlsxQllTrbdqiIjJsPrNz7OtAD0GU/adJs7K7PjgPcw+ZPCEX00fYjD59upvONIXsNBLllIs5SNDkLnWBdGAJlx3ZDYKdS/HzG+2fN/5vJNqYq3o0sMWUA6FD2Isx4iGSKBexjDbwlRNu+Z7kyREGY1JdV6NIWKmoNUdMOGLoYX3utdLirhHwkGd7Rp3w/u5i8ZmLjV62UyKiEm6G+/GzuebuQSPSBvnTb7/efvR4bsi8ovjZJ0OGOciFsrEnepJlhw7iWRWCCWqUQlDZpffynNa5Qwtg0MZrYWn4Opc+dfBHAg0AAsf4qhFD3QD1qn+RoQsDjBEax635OnJ+2wHN/Jv4cygjF/jIs63A64OtsDcI0/eniBEixm5tiR4r1xnJ5kNB6QjYZNz1D+dGj32YNnxsCrRf8RN3LTA2Xn7SK6Tut+bqvJggb7SicTfe2VzplLmWTnDLuS4QiY5y5eicPiymaEKB1HE7aSKJWgD5gCkXJme++3BfxNr8L3fG031/LrZA49fF8W4w8/k+xfBfGLvCFt0Sm6akB8Lz9iLSpzXW/bVtLWGwYPx+s4H/txWApJq/7q2aum+Qvbm3nK+8NWN5T2qrVAhcacA86jzK8cF1G/zZfuXotK1ZJbYEF4Tj9RoRwBqIlE2BqAgBo7mRNR1OjPf1lqef4+rxJ4ha8E3Y53S0enLgx0t2KoeL0jN3rHMLSSq0vp4csk3VJkJy+jXdqORtbDOnkr0gPXdAjuLyCSyoWR6I974Vl7EwOwg1UQfSKttWkypRSbO8YqgOAPcUM7vkEYdC9MYqJVWO2MDKu/ZKt+QGbimvOrSDWqzOWpYUdMHa1BxwJnVKxNxrXtaWSxO4cwe8Cl9HlNAAoZx3fV7TjX7dBXZ7Ewr/OVA06+JHtfIrsggAEo+2oixU4LPaJlR/aL9C14t1hv6h8Z6KcQq7R+9DyP1vy6xDf0LhwiviyekPwVm4dslrXbsWHb74fZR0g2/mH+1bY+DJY5mO9agW7/avYr3XRTODcxqRXgxE11UCt9i839GiLa9AzOmqKKhYxxzXmXeAgrR2cDGFwfbHNUWFNChks0nCLEqd0Px3aU55YKM51lJK+0TQcVvNW4GxPMnXdFCiysXrsUztXCeuNlNvVJShfwq21JiMzQMsVM/QrFduQjtL1nCvbfuZ2lBLR5t896ymnKjP1805b8Y7u3ZTAzhIvaqwrPOExnsLdfK4+ER/zxA0e7iucgsjDm/E0aUBkHPqcYikcIhCgVVRaXkO232YQPp/lWuUQRraGg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4846c877-b233-4f96-f02b-08dab71b7ceb X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:29:51.7776 (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: oDLUiC180yonSIwTIt0NRE7J6iUiHsx9DhNTl+EXgO167Ko0gAuZmqx3MrdYR0NMY9Ca/Et8vLagU+qv+FO+Sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: EKmrCp11M7LYd6sBWLJSBJUygOa7dSXe X-Proofpoint-ORIG-GUID: EKmrCp11M7LYd6sBWLJSBJUygOa7dSXe Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Pavel Reichl commit aefe69a45d84901c702f87672ec1e93de1d03f73 upstream. Signed-off-by: Pavel Reichl Reviewed-by: Darrick J. Wong [darrick: fix some of the comments] Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_dquot_buf.c | 8 +-- fs/xfs/libxfs/xfs_format.h | 10 ++-- fs/xfs/libxfs/xfs_trans_resv.c | 2 +- fs/xfs/xfs_dquot.c | 18 +++---- fs/xfs/xfs_dquot.h | 98 +++++++++++++++++----------------- fs/xfs/xfs_log_recover.c | 5 +- fs/xfs/xfs_qm.c | 30 +++++------ fs/xfs/xfs_qm_bhv.c | 6 +-- fs/xfs/xfs_trans_dquot.c | 42 +++++++-------- 9 files changed, 111 insertions(+), 108 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c index e8bd688a4073..bedc1e752b60 100644 --- a/fs/xfs/libxfs/xfs_dquot_buf.c +++ b/fs/xfs/libxfs/xfs_dquot_buf.c @@ -35,10 +35,10 @@ xfs_calc_dquots_per_chunk( xfs_failaddr_t xfs_dquot_verify( - struct xfs_mount *mp, - xfs_disk_dquot_t *ddq, - xfs_dqid_t id, - uint type) /* used only during quotacheck */ + struct xfs_mount *mp, + struct xfs_disk_dquot *ddq, + xfs_dqid_t id, + uint type) /* used only during quotacheck */ { /* * We can encounter an uninitialized dquot buffer for 2 reasons: diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 28203b626f6a..1f24473121f0 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -1144,11 +1144,11 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) /* * This is the main portion of the on-disk representation of quota - * information for a user. This is the q_core of the xfs_dquot_t that + * information for a user. This is the q_core of the struct xfs_dquot that * is kept in kernel memory. We pad this with some more expansion room * to construct the on disk structure. */ -typedef struct xfs_disk_dquot { +struct xfs_disk_dquot { __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ __u8 d_version; /* dquot version */ __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ @@ -1171,15 +1171,15 @@ typedef struct xfs_disk_dquot { __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ __be16 d_pad; -} xfs_disk_dquot_t; +}; /* * This is what goes on disk. This is separated from the xfs_disk_dquot because * carrying the unnecessary padding would be a waste of memory. */ typedef struct xfs_dqblk { - xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ - char dd_fill[4]; /* filling for posterity */ + struct xfs_disk_dquot dd_diskdq; /* portion living incore as well */ + char dd_fill[4];/* filling for posterity */ /* * These two are only present on filesystems with the CRC bits set. diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index b3584cd2cc16..f7e87b90c7e5 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -776,7 +776,7 @@ xfs_calc_clear_agi_bucket_reservation( /* * Adjusting quota limits. - * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) + * the disk quota buffer: sizeof(struct xfs_disk_dquot) */ STATIC uint xfs_calc_qm_setqlim_reservation(void) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index aa5084180270..193a7d3353f4 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -48,7 +48,7 @@ static struct lock_class_key xfs_dquot_project_class; */ void xfs_qm_dqdestroy( - xfs_dquot_t *dqp) + struct xfs_dquot *dqp) { ASSERT(list_empty(&dqp->q_lru)); @@ -113,8 +113,8 @@ xfs_qm_adjust_dqlimits( */ void xfs_qm_adjust_dqtimers( - xfs_mount_t *mp, - xfs_disk_dquot_t *d) + struct xfs_mount *mp, + struct xfs_disk_dquot *d) { ASSERT(d->d_id); @@ -497,7 +497,7 @@ xfs_dquot_from_disk( struct xfs_disk_dquot *ddqp = bp->b_addr + dqp->q_bufoffset; /* copy everything from disk dquot to the incore dquot */ - memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); + memcpy(&dqp->q_core, ddqp, sizeof(struct xfs_disk_dquot)); /* * Reservation counters are defined as reservation plus current usage @@ -989,7 +989,7 @@ xfs_qm_dqput( */ void xfs_qm_dqrele( - xfs_dquot_t *dqp) + struct xfs_dquot *dqp) { if (!dqp) return; @@ -1019,7 +1019,7 @@ xfs_qm_dqflush_done( struct xfs_log_item *lip) { xfs_dq_logitem_t *qip = (struct xfs_dq_logitem *)lip; - xfs_dquot_t *dqp = qip->qli_dquot; + struct xfs_dquot *dqp = qip->qli_dquot; struct xfs_ail *ailp = lip->li_ailp; /* @@ -1129,7 +1129,7 @@ xfs_qm_dqflush( } /* This is the only portion of data that needs to persist */ - memcpy(ddqp, &dqp->q_core, sizeof(xfs_disk_dquot_t)); + memcpy(ddqp, &dqp->q_core, sizeof(struct xfs_disk_dquot)); /* * Clear the dirty field and remember the flush lsn for later use. @@ -1187,8 +1187,8 @@ xfs_qm_dqflush( */ void xfs_dqlock2( - xfs_dquot_t *d1, - xfs_dquot_t *d2) + struct xfs_dquot *d1, + struct xfs_dquot *d2) { if (d1 && d2) { ASSERT(d1 != d2); diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 4fe85709d55d..831e4270cf65 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -30,33 +30,36 @@ enum { /* * The incore dquot structure */ -typedef struct xfs_dquot { - uint dq_flags; /* various flags (XFS_DQ_*) */ - struct list_head q_lru; /* global free list of dquots */ - struct xfs_mount*q_mount; /* filesystem this relates to */ - uint q_nrefs; /* # active refs from inodes */ - xfs_daddr_t q_blkno; /* blkno of dquot buffer */ - int q_bufoffset; /* off of dq in buffer (# dquots) */ - xfs_fileoff_t q_fileoffset; /* offset in quotas file */ - - xfs_disk_dquot_t q_core; /* actual usage & quotas */ - xfs_dq_logitem_t q_logitem; /* dquot log item */ - xfs_qcnt_t q_res_bcount; /* total regular nblks used+reserved */ - xfs_qcnt_t q_res_icount; /* total inos allocd+reserved */ - xfs_qcnt_t q_res_rtbcount;/* total realtime blks used+reserved */ - xfs_qcnt_t q_prealloc_lo_wmark;/* prealloc throttle wmark */ - xfs_qcnt_t q_prealloc_hi_wmark;/* prealloc disabled wmark */ - int64_t q_low_space[XFS_QLOWSP_MAX]; - struct mutex q_qlock; /* quota lock */ - struct completion q_flush; /* flush completion queue */ - atomic_t q_pincount; /* dquot pin count */ - wait_queue_head_t q_pinwait; /* dquot pinning wait queue */ -} xfs_dquot_t; +struct xfs_dquot { + uint dq_flags; + struct list_head q_lru; + struct xfs_mount *q_mount; + uint q_nrefs; + xfs_daddr_t q_blkno; + int q_bufoffset; + xfs_fileoff_t q_fileoffset; + + struct xfs_disk_dquot q_core; + xfs_dq_logitem_t q_logitem; + /* total regular nblks used+reserved */ + xfs_qcnt_t q_res_bcount; + /* total inos allocd+reserved */ + xfs_qcnt_t q_res_icount; + /* total realtime blks used+reserved */ + xfs_qcnt_t q_res_rtbcount; + xfs_qcnt_t q_prealloc_lo_wmark; + xfs_qcnt_t q_prealloc_hi_wmark; + int64_t q_low_space[XFS_QLOWSP_MAX]; + struct mutex q_qlock; + struct completion q_flush; + atomic_t q_pincount; + struct wait_queue_head q_pinwait; +}; /* * Lock hierarchy for q_qlock: * XFS_QLOCK_NORMAL is the implicit default, - * XFS_QLOCK_NESTED is the dquot with the higher id in xfs_dqlock2 + * XFS_QLOCK_NESTED is the dquot with the higher id in xfs_dqlock2 */ enum { XFS_QLOCK_NORMAL = 0, @@ -64,21 +67,21 @@ enum { }; /* - * Manage the q_flush completion queue embedded in the dquot. This completion + * Manage the q_flush completion queue embedded in the dquot. This completion * queue synchronizes processes attempting to flush the in-core dquot back to * disk. */ -static inline void xfs_dqflock(xfs_dquot_t *dqp) +static inline void xfs_dqflock(struct xfs_dquot *dqp) { wait_for_completion(&dqp->q_flush); } -static inline bool xfs_dqflock_nowait(xfs_dquot_t *dqp) +static inline bool xfs_dqflock_nowait(struct xfs_dquot *dqp) { return try_wait_for_completion(&dqp->q_flush); } -static inline void xfs_dqfunlock(xfs_dquot_t *dqp) +static inline void xfs_dqfunlock(struct xfs_dquot *dqp) { complete(&dqp->q_flush); } @@ -112,7 +115,7 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type) } } -static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) +static inline struct xfs_dquot *xfs_inode_dquot(struct xfs_inode *ip, int type) { switch (type & XFS_DQ_ALLTYPES) { case XFS_DQ_USER: @@ -147,31 +150,30 @@ static inline bool xfs_dquot_lowsp(struct xfs_dquot *dqp) #define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ) #define XFS_QM_ISGDQ(dqp) ((dqp)->dq_flags & XFS_DQ_GROUP) -extern void xfs_qm_dqdestroy(xfs_dquot_t *); -extern int xfs_qm_dqflush(struct xfs_dquot *, struct xfs_buf **); -extern void xfs_qm_dqunpin_wait(xfs_dquot_t *); -extern void xfs_qm_adjust_dqtimers(xfs_mount_t *, - xfs_disk_dquot_t *); -extern void xfs_qm_adjust_dqlimits(struct xfs_mount *, - struct xfs_dquot *); -extern xfs_dqid_t xfs_qm_id_for_quotatype(struct xfs_inode *ip, - uint type); -extern int xfs_qm_dqget(struct xfs_mount *mp, xfs_dqid_t id, +void xfs_qm_dqdestroy(struct xfs_dquot *dqp); +int xfs_qm_dqflush(struct xfs_dquot *dqp, struct xfs_buf **bpp); +void xfs_qm_dqunpin_wait(struct xfs_dquot *dqp); +void xfs_qm_adjust_dqtimers(struct xfs_mount *mp, + struct xfs_disk_dquot *d); +void xfs_qm_adjust_dqlimits(struct xfs_mount *mp, + struct xfs_dquot *d); +xfs_dqid_t xfs_qm_id_for_quotatype(struct xfs_inode *ip, uint type); +int xfs_qm_dqget(struct xfs_mount *mp, xfs_dqid_t id, uint type, bool can_alloc, struct xfs_dquot **dqpp); -extern int xfs_qm_dqget_inode(struct xfs_inode *ip, uint type, - bool can_alloc, - struct xfs_dquot **dqpp); -extern int xfs_qm_dqget_next(struct xfs_mount *mp, xfs_dqid_t id, +int xfs_qm_dqget_inode(struct xfs_inode *ip, uint type, + bool can_alloc, + struct xfs_dquot **dqpp); +int xfs_qm_dqget_next(struct xfs_mount *mp, xfs_dqid_t id, uint type, struct xfs_dquot **dqpp); -extern int xfs_qm_dqget_uncached(struct xfs_mount *mp, - xfs_dqid_t id, uint type, - struct xfs_dquot **dqpp); -extern void xfs_qm_dqput(xfs_dquot_t *); +int xfs_qm_dqget_uncached(struct xfs_mount *mp, + xfs_dqid_t id, uint type, + struct xfs_dquot **dqpp); +void xfs_qm_dqput(struct xfs_dquot *dqp); -extern void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); +void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); -extern void xfs_dquot_set_prealloc_limits(struct xfs_dquot *); +void xfs_dquot_set_prealloc_limits(struct xfs_dquot *); static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp) { diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 248101876e1e..46b1e255f55f 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2577,6 +2577,7 @@ xlog_recover_do_reg_buffer( int bit; int nbits; xfs_failaddr_t fa; + const size_t size_disk_dquot = sizeof(struct xfs_disk_dquot); trace_xfs_log_recover_buf_reg_buf(mp->m_log, buf_f); @@ -2619,7 +2620,7 @@ xlog_recover_do_reg_buffer( "XFS: NULL dquot in %s.", __func__); goto next; } - if (item->ri_buf[i].i_len < sizeof(xfs_disk_dquot_t)) { + if (item->ri_buf[i].i_len < size_disk_dquot) { xfs_alert(mp, "XFS: dquot too small (%d) in %s.", item->ri_buf[i].i_len, __func__); @@ -3250,7 +3251,7 @@ xlog_recover_dquot_pass2( xfs_alert(log->l_mp, "NULL dquot in %s.", __func__); return -EFSCORRUPTED; } - if (item->ri_buf[1].i_len < sizeof(xfs_disk_dquot_t)) { + if (item->ri_buf[1].i_len < sizeof(struct xfs_disk_dquot)) { xfs_alert(log->l_mp, "dquot too small (%d) in %s.", item->ri_buf[1].i_len, __func__); return -EFSCORRUPTED; diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 66ea8e4fca86..035930a4f0dd 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -244,14 +244,14 @@ xfs_qm_unmount_quotas( STATIC int xfs_qm_dqattach_one( - xfs_inode_t *ip, - xfs_dqid_t id, - uint type, - bool doalloc, - xfs_dquot_t **IO_idqpp) + struct xfs_inode *ip, + xfs_dqid_t id, + uint type, + bool doalloc, + struct xfs_dquot **IO_idqpp) { - xfs_dquot_t *dqp; - int error; + struct xfs_dquot *dqp; + int error; ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); error = 0; @@ -544,8 +544,8 @@ xfs_qm_set_defquota( uint type, xfs_quotainfo_t *qinf) { - xfs_dquot_t *dqp; - struct xfs_def_quota *defq; + struct xfs_dquot *dqp; + struct xfs_def_quota *defq; struct xfs_disk_dquot *ddqp; int error; @@ -1746,14 +1746,14 @@ xfs_qm_vop_dqalloc( * Actually transfer ownership, and do dquot modifications. * These were already reserved. */ -xfs_dquot_t * +struct xfs_dquot * xfs_qm_vop_chown( - xfs_trans_t *tp, - xfs_inode_t *ip, - xfs_dquot_t **IO_olddq, - xfs_dquot_t *newdq) + struct xfs_trans *tp, + struct xfs_inode *ip, + struct xfs_dquot **IO_olddq, + struct xfs_dquot *newdq) { - xfs_dquot_t *prevdq; + struct xfs_dquot *prevdq; uint bfield = XFS_IS_REALTIME_INODE(ip) ? XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT; diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index 5d72e88598b4..b784a3751fe2 100644 --- a/fs/xfs/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c @@ -54,11 +54,11 @@ xfs_fill_statvfs_from_dquot( */ void xfs_qm_statvfs( - xfs_inode_t *ip, + struct xfs_inode *ip, struct kstatfs *statp) { - xfs_mount_t *mp = ip->i_mount; - xfs_dquot_t *dqp; + struct xfs_mount *mp = ip->i_mount; + struct xfs_dquot *dqp; if (!xfs_qm_dqget(mp, xfs_get_projid(ip), XFS_DQ_PROJ, false, &dqp)) { xfs_fill_statvfs_from_dquot(statp, dqp); diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 904780dd74aa..b6c8ee0dd39f 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -25,8 +25,8 @@ STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); */ void xfs_trans_dqjoin( - xfs_trans_t *tp, - xfs_dquot_t *dqp) + struct xfs_trans *tp, + struct xfs_dquot *dqp) { ASSERT(XFS_DQ_IS_LOCKED(dqp)); ASSERT(dqp->q_logitem.qli_dquot == dqp); @@ -49,8 +49,8 @@ xfs_trans_dqjoin( */ void xfs_trans_log_dquot( - xfs_trans_t *tp, - xfs_dquot_t *dqp) + struct xfs_trans *tp, + struct xfs_dquot *dqp) { ASSERT(XFS_DQ_IS_LOCKED(dqp)); @@ -486,12 +486,12 @@ xfs_trans_apply_dquot_deltas( */ void xfs_trans_unreserve_and_mod_dquots( - xfs_trans_t *tp) + struct xfs_trans *tp) { int i, j; - xfs_dquot_t *dqp; + struct xfs_dquot *dqp; struct xfs_dqtrx *qtrx, *qa; - bool locked; + bool locked; if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) return; @@ -571,21 +571,21 @@ xfs_quota_warn( */ STATIC int xfs_trans_dqresv( - xfs_trans_t *tp, - xfs_mount_t *mp, - xfs_dquot_t *dqp, - int64_t nblks, - long ninos, - uint flags) + struct xfs_trans *tp, + struct xfs_mount *mp, + struct xfs_dquot *dqp, + int64_t nblks, + long ninos, + uint flags) { - xfs_qcnt_t hardlimit; - xfs_qcnt_t softlimit; - time_t timer; - xfs_qwarncnt_t warns; - xfs_qwarncnt_t warnlimit; - xfs_qcnt_t total_count; - xfs_qcnt_t *resbcountp; - xfs_quotainfo_t *q = mp->m_quotainfo; + xfs_qcnt_t hardlimit; + xfs_qcnt_t softlimit; + time_t timer; + xfs_qwarncnt_t warns; + xfs_qwarncnt_t warnlimit; + xfs_qcnt_t total_count; + xfs_qcnt_t *resbcountp; + xfs_quotainfo_t *q = mp->m_quotainfo; struct xfs_def_quota *defq; From patchwork Wed Oct 26 06:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020197 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 78A17C38A2D for ; Wed, 26 Oct 2022 06:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233068AbiJZGaP (ORCPT ); Wed, 26 Oct 2022 02:30:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233130AbiJZGaL (ORCPT ); Wed, 26 Oct 2022 02:30:11 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E5224970; Tue, 25 Oct 2022 23:30:09 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nEj0013483; Wed, 26 Oct 2022 06:30:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=laglWZhUJgEY0DSDAP5AAl3xvn2qtfvmD+F0Fp6pQ3c=; b=SICxmu2IEWk9VKZOi5LrAVkOQHkpdLe9aEBUioFVhHTTMyw59dn0E9qwtLIGBdje6g8Q pB1+sMR12zRjLWteqpXDIW3wX9D+lx0K/EL8wL2pM9GSYaqCI9pRKbtE4kTOqMVOc6/c sgjGEMIyrunDp52XFsLrL7NFvtpnFyhz6Vvxn0yja/jNm6F5TzCmALf3gP99lO7yLTlx UqqMP+Ec2WoH5PGw1MPTtsNOUTTY1A1DX3K8puoX7C5cseA7egw2fOcbiVmEXuPka6cn IHPf19cFjkw/8hMC1T0hpommtQYKZtQO/B4AX3h4S2dcRqNKcb3vGPBEH5p4EOd1WgzW LA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc84t5hj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:04 +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 29Q31XV5011081; Wed, 26 Oct 2022 06:30:03 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d8g6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f91XEx3bZJNw31llfGIsx6LPxXqoepuLLlsCiFXjmgI/PqmA6UGq7ue+MYTPjwXojNIpBcUGqby269bVV9w5CIOa9IG/2k+h7p2g1ps5tpvmpTdGMcxxwWb+wcZuOyLikydWgmb8Pn2X4ie3dST+jcClLQ3qbPUQgpqhh6SDumi/kq6vpVb6Q3mpne3V5vYkxBWB2P8d3ilOAlZJXMcBQMObBXN0S3U98z7eQecTKsLApOG54T4luE0K7RwppZ+ui2OnKnU4ePZiZJsKBjfpXFbe7/+7WdlHLxSP+gH0kkgVRQkjShun+vvSraesgdMGdk8SOJuYi/miGTj376KVpA== 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=laglWZhUJgEY0DSDAP5AAl3xvn2qtfvmD+F0Fp6pQ3c=; b=N+Zyp2sL1P/kFxpGygwrPoprYH2+ClNaFag3tiWwKa5F2PGkxptyRKiARtEMCx45vqMkXdHHnD/a0uq4hCf4DhtgAf2J4vRLnzo6YaMngQYSilgJB9h7ywTZzOmaL0jhDw4ZV/9uaQ+cbIT7tLzM5YwVadFwm05wFfcKtXVdbBbuVRbjKhaOrLzNVhgQ5/EQshaE1za+txrrBYU/n4IxgSlMifmY1SHfgmdgXKq+Rtw46sORWtNfZ/+32IaXA8YVy/RULVsQMS+s8HRuc3RMrd6+XMEE4u/o+jlgPgl9Wkh+myAFr24ybtnRN4ozIQsyqpVAYMDoFnwoytN9d+I3yw== 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=laglWZhUJgEY0DSDAP5AAl3xvn2qtfvmD+F0Fp6pQ3c=; b=F7C/lrAnTDw1++d555BlhObKPPmRdbU5dqg7GTWx7JnAabUdXdbQEFOHqzcadsOIxtOrbVQlNB6OgKy/y4/kC1n7Jg4gOA3zHnPSYu/mjZZTLfXA5lw4V68ie1Uo1ZqL5VrfswZBLwjzWOXDTce+5nlf45AGbvmFnQv7dcD15uI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:01 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:01 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 11/26] xfs: remove the xfs_dq_logitem_t typedef Date: Wed, 26 Oct 2022 11:58:28 +0530 Message-Id: <20221026062843.927600-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR02CA0043.apcprd02.prod.outlook.com (2603:1096:404:a6::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f6b4f07-27b2-46c7-e82b-08dab71b82b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6qhGsUnyyFawsWDP+0IMFZ/zbBF1sbUi3rdRLqkX6HnrapGSsGrF170GrKNLlurwB4SfZL8BBgSb1pALGXe4XblP1jxhh1wB3tQTGHyc9K3HB6jtWps/eUlRJUM4L/JirrBOBmjW66tiUEuuuDSsh9xNB/LlR04loAlciI9Myb3PWR6IFyZt0yjznWGbJCos9rIySXlQhgImt38LTE/KhDTMFf09H4payJatbYe+GssIBtm2wsAJZujy4iuHnKTJ06EnZU0aT3FQ0WaQEwkcd/ccFT+4X9A+dzKinFPfzaMeYAEhm+mkYcNoLsiZzqw9Fu3JqLbJV+w7NKWr3NjIjnrCyrlI4JcbBANrGr23U5U7FPAYvzZRNSEBZ+LVoRy8RSaDdHMbyi5StZp+9B3ieH1Eu5COrSkOye8pO0H6bwzFD3QxL1FKu3sE2gOcUTaeOZKo3HgHq50fYATOdhI8Dre3/84EjOtTNfMmXQ5yMomjgR4ZHvbTxr99sN2WiPN2OZt/n/tQ42vS36IQ4BtcRkW6odbuVg4mBMKxCEQ3P/LoCPEsYgIpkOwTDR0Iwu2GWlIdXgl4l0Y1lWjcb84Vyd82YJqmqWIfpDMTM8sUpo5bEwXq/CV26LLf9emAd64wbK/0TiAjl15jdfqM7CRIApbXhupIWaRLeKj4aIqN9Q2k0N++2nc7ooqSq5YRTByXwT+CZdCXCp62Nz6eY363KLNxnqYGfCWqZ4YZAyVs3G+E0QWrLBrYZy3Jf2SsvAji 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4isE49MnvEPQQWVOIVjpcD8N7iYYDlnz6JpeKnXSXZiRN3ZUz8Gl6R9ON5lFDeHgH9oKJa9VyZv2uW9aszUq9PrJ27mIsEDOZcIzJv11L8kNNoUOmaog4hUqDW3oEIy2ieaT1vqd9meJ9ejt0nOlVI1Ykk5oY2D3a5eyhJUypw+yXW1bfGjUWBGJu2nsVNtgQvGDlOGhz/YhA4ewBnLcH2RiUoWV16Q/P/vlhCVebcF9/KXM1k57P0uXdfa6EqYzu7LeaGEwc5UojZp4CVcHSiXLRz4ZvD976nZd9QB5EKAtYE5zbrYKtPqxjSDdeD10C/SWMuRXfKBVQb/S1/r4Ldu5nHcqovzwbrJrLbZWJWaFQerla4DHDblfG5y85r5hwZf9W7ELfn/XLySDoJ3kdAP2mfXnWzfSdOP0EPRknwkALtvsMDTUex9XLO9bs+EUcBgtypysUYbkEwesZQmlkVAi7YicGHRx83dYrZgSYRtPl087IQC2+lhbq5ZbFzXHeLn3V4t7GQtXcml4XstN4KqAMCvykSEQe3tvywYKHh4NcTN9ytYbK6L1muj5TiilNnDPWWJh2qJ5tQfJX7q5AKQxIbyMbu+WC/SFH7JgN9MIr+guCa0IlpGcUtNwZHzupYUu5PunfG9XUWwctnFte5FACuj1b+oUnsIuDkfT9S5xxz0pmzv3/StGmThLmJMcUEdpT19tvQadhg5kBSzuQfJcfBF2BRkLXst5DEBaFYJugHH+VyzXfElGzCnPDy9SuTL/QgJWx07mvLWIbyHzoJ7E/47ZSUNz6tzuuhYWpp/7/CuaP4CnzZgqn2iqrG8Qr+96phzDKC/vnLUq4zYxbg2YAbgEdrs6D4IfEP3FYxCd7z7SX0qkJqmogDhmt/YyBC3n6nK4OrpLE4MCdeA6V3pRfoZdB8fgM2KYPjSM8tNeKo1/DZPecTYYruY9uUdCV7kOgx7on3L4jLfn0rVJhIqvYwGwQijT3hjEplv7/IxpypMpCxdZU1kQK+C52dtgv5kBl+jeL83DgcMAb89DchGXI9v6kq5H4ee7aXO/lrTo3sgc9T11r5U5tvPIgUrvYT0OnJfD2CAu0q00Fv2GC5IFf8DOv9dZhvVGmPsCHiRngIE39MVVgbVbBgzWcRYPFxJaRMp9crM2sTQ2ZpVUloV5kGG1j7kNOFrYRtJ/tl1DnV7HM81VUmv8OZgD7HccMNmFeQYtvzowY1jKP+Q7Woiv5QaxM8azgm2GB5oDtU4Rr9fdZIBqfS/dLsu5dgja5ds5w5HAi4I+Npi84dfmfTrs8FehhXDbQ9bIDr+1sWEEYEG3x/PIYDCXIdUqmZuAfcCbBFxigS/wQ19jRhwFp29JyEiYJHqnzr0Ya6LktsSb3WNH2PMl1uKJUuj53z7ORuTaWny7zRPkGYY5tEggfUd5Rt2lqimLSEOtscOFg5T5SsSksq7XMW+zM5Dxd4ktglHwqGGM+E+DSsI1OsPFTyP4dLCdnPFVRW0sFDesmnzgqPpusGvBASqMvhhK38bbxBiJYcvRK5SX4wZF1NG8Xdi8QOMU4GlB6xzn8ILhPEWD88g1bcqBjHSTNbzZ0F+zRjqVo4tEfUtnKGVSqMnb0g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f6b4f07-27b2-46c7-e82b-08dab71b82b6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:01.3558 (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: D0468STD1A6ZzRv2qYYWkz6pM6N/QRxacwjUW2BSMd7GutkcF9TknHZXwkk16A1TBFR7Q2vqzs16XFGpRsSPWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: ReYW1l7WQW_4OgyruxAwwLj7GWMfSTdz X-Proofpoint-GUID: ReYW1l7WQW_4OgyruxAwwLj7GWMfSTdz Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Pavel Reichl commit fd8b81dbbb23d4a3508cfac83256b4f5e770941c upstream. Signed-off-by: Pavel Reichl Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_dquot.h | 2 +- fs/xfs/xfs_dquot_item.h | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 193a7d3353f4..55c73f012762 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1018,7 +1018,7 @@ xfs_qm_dqflush_done( struct xfs_buf *bp, struct xfs_log_item *lip) { - xfs_dq_logitem_t *qip = (struct xfs_dq_logitem *)lip; + struct xfs_dq_logitem *qip = (struct xfs_dq_logitem *)lip; struct xfs_dquot *dqp = qip->qli_dquot; struct xfs_ail *ailp = lip->li_ailp; diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 831e4270cf65..fe3e46df604b 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h @@ -40,7 +40,7 @@ struct xfs_dquot { xfs_fileoff_t q_fileoffset; struct xfs_disk_dquot q_core; - xfs_dq_logitem_t q_logitem; + struct xfs_dq_logitem q_logitem; /* total regular nblks used+reserved */ xfs_qcnt_t q_res_bcount; /* total inos allocd+reserved */ diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h index 1aed34ccdabc..3a64a7fd3b8a 100644 --- a/fs/xfs/xfs_dquot_item.h +++ b/fs/xfs/xfs_dquot_item.h @@ -11,11 +11,11 @@ struct xfs_trans; struct xfs_mount; struct xfs_qoff_logitem; -typedef struct xfs_dq_logitem { - struct xfs_log_item qli_item; /* common portion */ - struct xfs_dquot *qli_dquot; /* dquot ptr */ - xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ -} xfs_dq_logitem_t; +struct xfs_dq_logitem { + struct xfs_log_item qli_item; /* common portion */ + struct xfs_dquot *qli_dquot; /* dquot ptr */ + xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ +}; typedef struct xfs_qoff_logitem { struct xfs_log_item qql_item; /* common portion */ From patchwork Wed Oct 26 06:28:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020198 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 148B5C433FE for ; Wed, 26 Oct 2022 06:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233130AbiJZGaT (ORCPT ); Wed, 26 Oct 2022 02:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233129AbiJZGaS (ORCPT ); Wed, 26 Oct 2022 02:30:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D7136DEB; Tue, 25 Oct 2022 23:30:18 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nVl9030448; Wed, 26 Oct 2022 06:30:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=V0p7N4PvwjuFGT5bQvHBa5EaeYmOzZ9KJhy4Carla8Q=; b=rsnGwTcqYmntF++zeHz9TLXjQpclsb7GT2w8Rr24a19j5B4FyxHof3eDVNX/R85luACn mRBTkh8H7PbT5D0pXxUfz5egNyuuMFFJLNXR/z0lEiZNsBXWtcBIPy2dxSdyxd0EQdF4 u1Ij5NpGdDrpFjuwA85TDfYLCW/v61kLJ7Dzm850FRcu5LTb1lCfvFeGjVM82nOlrSI+ imi71g54dR52qXvCWbjOPurd4H7Ed/604Se5qvMnPji6mgsK5yG3esE2QTQQGumhlzSd WuQNxzCRU8NGs3cTcSH15LH1k6w1W9lxSVQhe5dxAuGnH+xZD6BIl8Ti/h0Lmeizd7Hs iA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x23f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:11 +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 29Q2qJ8N021955; Wed, 26 Oct 2022 06:30:10 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybprbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O1Kg1auG+6+gawtr/Y5+4CM7pisz3z4VYkPVvAPlbvJf9YQkIPDiwFPS0raEWaoNHoVW8mZB7SBWrq5JMS1IUhL8iOJTdFcCAYZCsdoku3Ce+neO37wqwcJGZNaPwy6DlqGauhNeBTL13d9dfL+NNNx6W2oeU5ThUiYNnIVK6VAJJN0abArARpjypSVmqYCz3ExE887xJ9WCjFjyXZJJf/pYYJzjlb974lD5PeQjRlGmwUxtYpECg03ZKVxzbJc3eNteUdTS0yCykWSnwRbE/OUgX8R8CXCr3pW02u2MF1xL7cQJAmBN1HMturOHxYybeQQ4E+e1s4zB8Dudl6kIfg== 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=V0p7N4PvwjuFGT5bQvHBa5EaeYmOzZ9KJhy4Carla8Q=; b=giLC1WzM3Z2n+y7JCI7r0kjqdG5q130N2KbX4DvAfz3xX3fLY2qOjp6fN8fYRe0qdq2C0cxtMTbx1G9nUMT203ECUncfVvweCRv1SHT+jicmpYaH3qkKJOSZ/aPMzUi9kepwt5jSZ4K2llWALP762Kwd41/Bhq5EEfGsNJz6s2tWKugOSgMZLzIOeF30JhbjYm3E3sBMP0vRI63ET+qjF3sdwWissgIu2zJ2bxHDlLUwUmST68KlZYqsTrOayyfFNDaKaq/YD5PivOL5MZkZrEAwVt+NoYpPiP4WHlHQFg1leP8IKISuAz7OAJZgLIxrrnP3Pe6neHAYWkvuaHqPMg== 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=V0p7N4PvwjuFGT5bQvHBa5EaeYmOzZ9KJhy4Carla8Q=; b=tx5dBId+xRNIrVpiAsA6lEX14AbICq8VS64mWuiFDfJ2dLO9AqiVMxRhTJQvU/PSPF1XL0mbKd6Y9DueGtn8J/DvH4jd9O7kdOKQawHE0mnXRFUOUoysc/p29BPnGK2W/UJXJsB8mI0WXRCXC1CF/DzK98aWSDk0vqwBApSBGfU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:08 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:07 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 12/26] xfs: remove the xfs_qoff_logitem_t typedef Date: Wed, 26 Oct 2022 11:58:29 +0530 Message-Id: <20221026062843.927600-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0096.jpnprd01.prod.outlook.com (2603:1096:404:2c::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 5421a9bd-ca9d-4bad-751a-08dab71b869b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ZOumvdAeUiGVOH2wtPU2apaIPh8ju2c2CffSk/TfxaDSyr+91O7xBIc1G0Tdb5BxSRyF3jfFCueu1z2ky6TxXIfC3XbBncknpe/T3HpEidv/GMnqTtH30U7WbN/0PXOzzam7tOzjCdIV/sn1PxwJ2ogUB9aQNMuZISGu3zKws+p+/6KaIrtug1/bBnHhx0d7OBygtckx2Cp/6o+FLwiyhIwofAZCugfEqg/rP/RGZfSAL7FrfqrKeEgExmrmRzZ2oOz8slKSQkZ2Kp5pWITRAgI6Mm5JGlHYi9XfZjo3dZi9Fn+W52SOyU9y1xTzSm8MDa+BdBo9mnmQ6ARqs5wlCWQA5LEGLDf6ZH3FgfM3Vsu8LO9+HvJ+E6a+ctPj6WzindrhYep2mR+elwqwyQQ1n4xmb7KlCVONAbm6cWkU6nI13FiRuA6ahDtDtxTvPmZom3j8DPBER62cpQ/ynOOmXf19YFyaVbVZG4vxyKwFa8S69498rn+bVNsrCnMVGXW7D8+vcfjn2MFb7cSlfNtusKwQGWOJ9j+STkau+rNgtdP3wohi8MsQ2OTv6lSF4orXL6t05LNuYOiDg1NV8pF8ycyyCWP9JyQ2RkgcfZB0TlObrb7h+n4DLsc7Dx1FgvXbzo/uF8Dix59aGUSV68ltiUb6R6QLPAB087QZ2tHJ3ZFXmDkirq/jgKWWTjfoGU2J8TvyF8takK4jWVKE1MHWogoNilsAS7K8MFV+wIM4vTZ4Qgqf/H7ESPqUOnVqmTB 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8XEETqk/honShtYgMuHtE6EqPFhGARl4KwI8GBlrAz6U30tCS5MTR5C8Z2f3qOqnEMgMD910FLdHjs6NB0IxzKaaz7wLkgI2+lxm+0ihpB5l1u7wKf9WKpdOcqHZc9s7aJbdD3wM7ff0GGTx1t7tmi7j9e8bn2QoDbTk1I7tuFXu2Cuqs/tauYUqX/xqpa+F7PIoKmZU+c/FkffOLuZO3p1HPIac33xrQSvLKK/TEqtE+YE1f6flOGAJ6nNgL0F2f0YyKsvUuNXz0ZsTG17hPsG+6Wq02ZxVtQjByopJuYdGIlx60wTeyEEkcZygYiCjkplfuSiA3Lp569dAbU5wdiahxav5jJBLH6udH2pObUhE8e33/EnL8pCf+LlgfkKnKtoZn99kZWI0GXB76C0Y5RF0licSv351QW9VZZBdUVrUkKmxC/ZSd494rQI8Wl0/Dqc3XvCkQIOSfMumsCbx4WYmfwo186PNkUAQCAJYQK6W2ThSw/Cd5L6pP+TP7Cpgs7VNStViA7enWxEe6LfR8130JFEaVEsD4dlB7aEfVikZpV8JBIXstTLCfyEx7qKerhF5ZnVpwlAWNs1t2Tri+o/2dNKsclh9E/N9xKzjcRV4zTTUn8OMu9Q7h5PcGj8QUA7ZsFvtYRwu1B1nr/GZEIHqHw+Oiwms3WaKAtk2y20u3kpDvMRGNiww+nT2yAPlsxj6gD357XCAKcKeWbtz1umzpdSwHXRxfaWbUYG6tZIni96AoapamX9CQBUG1QJINoW83gAQkmWf75Iilat96dVqOIUU8X0CoZaQyL+BueDEFsuRnJV8qbTCyHPUqodB0BbQHHW99VIjHPENVfJEFkXttPbikRUwAUsQ37odoNpNVLaPu/Smnr1tLc2TXJgyuvSMWik0g/dvaVhicAqv4Pc6fbG+7NWxNSECVegSrquJApaNpT+sKbNiHjIR9tnGvLg2qjha1tWPb9tc1gHGtvgqrn4tUGGsVb+FFlFv5dnwRh1ZKaMfH2oxVRxIPaZowVrfTXMFD2Daa72d1+DSbCg29Qegzpdpsd8GLH69BPPuqdptEuXN6t84aGda/Vp6gJ3agTElL2JBS2Anv/s3iSO8gIOj/XYTFq2fVYOn9JSEBm6gWwZgOfIyABbmMP0t85Gh5zMt7VY5hFeIP3RdOZVbG62FJt3aNe1+knHETnilHobzdAwGLTI4kmsiwygz+D7UHoJlikRz6ICFZkVIlS1IdWyRj0Ln25Eq5n+mtLLCgP5uBqMR/DPukqifGNAjuqSC7/4d+pTyZ0njAOjvE66MLkxi5xc1+kgyqytkfUqfJ88YGNtM+5WswUumMlihkVH0zUjvRFHMowaPUG7Io8byT8B8ACSFWVPSEER/xCCaoACqE+yZ9CcBTtnXTQrfOBMoJG036MX6uvREWCVTSCGM3+MVt+BRXdUZw29vNSCXwTeawVXWxQMoaphUDMxWedJgIzkYnrK2nfiOdendiT+XPWFlzeqRBzi6D26zZXpfM+x126v7b0TgRHV+akpzrZCI/xN62yPsC783Xprl454uNj75Do9rfoAnqzwRX1NaQu0g4ZllVTtr+EL6whc6I3zEKSTede/ZgGvDJMNqyQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5421a9bd-ca9d-4bad-751a-08dab71b869b X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:07.8900 (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: gakNADoFsKEhnlE1KlR0icieqCeqVQzxN/W48psAGU4rjuF+D2cvpLPJ6pbvrm1pIYA9vtwmO3zFY5Ab91rkvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: Au565_3hnMcrAOtJSlivbmgP9teDPjak X-Proofpoint-ORIG-GUID: Au565_3hnMcrAOtJSlivbmgP9teDPjak Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Pavel Reichl commit d0bdfb106907e4a3ef4f25f6d27e392abf41f3a0 upstream. Signed-off-by: Pavel Reichl Reviewed-by: Darrick J. Wong [darrick: fix a comment] Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/libxfs/xfs_trans_resv.c | 4 ++-- fs/xfs/xfs_dquot_item.h | 28 +++++++++++++++------------- fs/xfs/xfs_qm_syscalls.c | 29 ++++++++++++++++------------- fs/xfs/xfs_trans_dquot.c | 12 ++++++------ 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index f7e87b90c7e5..824073a839ac 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c @@ -800,7 +800,7 @@ xfs_calc_qm_dqalloc_reservation( /* * Turning off quotas. - * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2 + * the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2 * the superblock for the quota flags: sector size */ STATIC uint @@ -813,7 +813,7 @@ xfs_calc_qm_quotaoff_reservation( /* * End of turning off quotas. - * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2 + * the quota off logitems: sizeof(struct xfs_qoff_logitem) * 2 */ STATIC uint xfs_calc_qm_quotaoff_end_reservation(void) diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h index 3a64a7fd3b8a..3bb19e556ade 100644 --- a/fs/xfs/xfs_dquot_item.h +++ b/fs/xfs/xfs_dquot_item.h @@ -12,24 +12,26 @@ struct xfs_mount; struct xfs_qoff_logitem; struct xfs_dq_logitem { - struct xfs_log_item qli_item; /* common portion */ + struct xfs_log_item qli_item; /* common portion */ struct xfs_dquot *qli_dquot; /* dquot ptr */ - xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ + xfs_lsn_t qli_flush_lsn; /* lsn at last flush */ }; -typedef struct xfs_qoff_logitem { - struct xfs_log_item qql_item; /* common portion */ - struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ +struct xfs_qoff_logitem { + struct xfs_log_item qql_item; /* common portion */ + struct xfs_qoff_logitem *qql_start_lip; /* qoff-start logitem, if any */ unsigned int qql_flags; -} xfs_qoff_logitem_t; +}; -extern void xfs_qm_dquot_logitem_init(struct xfs_dquot *); -extern xfs_qoff_logitem_t *xfs_qm_qoff_logitem_init(struct xfs_mount *, - struct xfs_qoff_logitem *, uint); -extern xfs_qoff_logitem_t *xfs_trans_get_qoff_item(struct xfs_trans *, - struct xfs_qoff_logitem *, uint); -extern void xfs_trans_log_quotaoff_item(struct xfs_trans *, - struct xfs_qoff_logitem *); +void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp); +struct xfs_qoff_logitem *xfs_qm_qoff_logitem_init(struct xfs_mount *mp, + struct xfs_qoff_logitem *start, + uint flags); +struct xfs_qoff_logitem *xfs_trans_get_qoff_item(struct xfs_trans *tp, + struct xfs_qoff_logitem *startqoff, + uint flags); +void xfs_trans_log_quotaoff_item(struct xfs_trans *tp, + struct xfs_qoff_logitem *qlp); #endif /* __XFS_DQUOT_ITEM_H__ */ diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index da7ad0383037..e685b9ae90b9 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -19,9 +19,12 @@ #include "xfs_qm.h" #include "xfs_icache.h" -STATIC int xfs_qm_log_quotaoff(xfs_mount_t *, xfs_qoff_logitem_t **, uint); -STATIC int xfs_qm_log_quotaoff_end(xfs_mount_t *, xfs_qoff_logitem_t *, - uint); +STATIC int xfs_qm_log_quotaoff(struct xfs_mount *mp, + struct xfs_qoff_logitem **qoffstartp, + uint flags); +STATIC int xfs_qm_log_quotaoff_end(struct xfs_mount *mp, + struct xfs_qoff_logitem *startqoff, + uint flags); /* * Turn off quota accounting and/or enforcement for all udquots and/or @@ -40,7 +43,7 @@ xfs_qm_scall_quotaoff( uint dqtype; int error; uint inactivate_flags; - xfs_qoff_logitem_t *qoffstart; + struct xfs_qoff_logitem *qoffstart; /* * No file system can have quotas enabled on disk but not in core. @@ -540,13 +543,13 @@ xfs_qm_scall_setqlim( STATIC int xfs_qm_log_quotaoff_end( - xfs_mount_t *mp, - xfs_qoff_logitem_t *startqoff, + struct xfs_mount *mp, + struct xfs_qoff_logitem *startqoff, uint flags) { - xfs_trans_t *tp; + struct xfs_trans *tp; int error; - xfs_qoff_logitem_t *qoffi; + struct xfs_qoff_logitem *qoffi; error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_equotaoff, 0, 0, 0, &tp); if (error) @@ -568,13 +571,13 @@ xfs_qm_log_quotaoff_end( STATIC int xfs_qm_log_quotaoff( - xfs_mount_t *mp, - xfs_qoff_logitem_t **qoffstartp, - uint flags) + struct xfs_mount *mp, + struct xfs_qoff_logitem **qoffstartp, + uint flags) { - xfs_trans_t *tp; + struct xfs_trans *tp; int error; - xfs_qoff_logitem_t *qoffi; + struct xfs_qoff_logitem *qoffi; *qoffstartp = NULL; diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index b6c8ee0dd39f..2a85c393cb71 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -824,13 +824,13 @@ xfs_trans_reserve_quota_nblks( /* * This routine is called to allocate a quotaoff log item. */ -xfs_qoff_logitem_t * +struct xfs_qoff_logitem * xfs_trans_get_qoff_item( - xfs_trans_t *tp, - xfs_qoff_logitem_t *startqoff, + struct xfs_trans *tp, + struct xfs_qoff_logitem *startqoff, uint flags) { - xfs_qoff_logitem_t *q; + struct xfs_qoff_logitem *q; ASSERT(tp != NULL); @@ -852,8 +852,8 @@ xfs_trans_get_qoff_item( */ void xfs_trans_log_quotaoff_item( - xfs_trans_t *tp, - xfs_qoff_logitem_t *qlp) + struct xfs_trans *tp, + struct xfs_qoff_logitem *qlp) { tp->t_flags |= XFS_TRANS_DIRTY; set_bit(XFS_LI_DIRTY, &qlp->qql_item.li_flags); From patchwork Wed Oct 26 06:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020199 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 6B3BAC433FE for ; Wed, 26 Oct 2022 06:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233129AbiJZGa0 (ORCPT ); Wed, 26 Oct 2022 02:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbiJZGaX (ORCPT ); Wed, 26 Oct 2022 02:30:23 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F71D43153; Tue, 25 Oct 2022 23:30:23 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1naL5024687; Wed, 26 Oct 2022 06:30:18 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=AZu0EhsXBGlWYaGEE1gA6PINQ8S6xWDUsLAUBqNMraY=; b=XRMxdL5qSsbLyHah17TllG0v8BKNwCL8LxXjL+eYMDfNrhXW8XOgxweD1QnJ/SLUTDwe +FlsAdRJEMfXRnn6dHOFpsn0u9k9JDHpOkLzTEEkmkKnGYS8CrsAodZCUioLA2FneSRF vSy8fFi7g8gDnv6eqJevwKeFJ7j/+rqOFr60efVEAtd5H1jWBhZ92UjykJ4eFZfD8f1h 4SswbFh5J3mHEnK+aYhiqbUzivxKfGM3blmJUWwYkUT/cF64gsNz/SMG1eZt8bivc/rr ui2ND/evZ+mygMWemKzLMTZM8w2Vvi4qrr5Lll2RljrrgjrX7o4f5TVaPYoFvwt7tMjx YQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc8dbnbj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:17 +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 29Q34WFe011106; Wed, 26 Oct 2022 06:30:17 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d8xk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cwv9LfOn5SYoVSs98XmCaLLflO1Xk5NMWOAGEYoNYY7Nc3UzdS1AfpUb3fJ9FR6j9Ob2lbnf0qyCbVpi+sT6KDFVMvMfG9erBk6P5dH3SkRZCkmLVlwZPO1s7zo6G9z7rdHfK8eu7vObcCBDoUbQwQjazuOWoO4iTl0eaygkJ4/tbcrx1fbPOj0orO1M8sCG4IfSdBqy+ft5alRCG7zRSfJKcU6T+vr8YbR8Nmh65HDVkGqfPZ3RGZzPtYJ/9kMcF75k8Cmpif5UXe5YUtDGcolEa3rrHNibre0uMdRzXOZTC/IK7WjrqU0IOsirgzFHY2Sg9pe+yAbGSoKmrPxsgg== 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=AZu0EhsXBGlWYaGEE1gA6PINQ8S6xWDUsLAUBqNMraY=; b=bffrt9DWjXvuiRU85QwU/OOV+Ug6C8kUDKyGB0jkjVCNE/HcX+v2ILVhoGsw8l9WkabjRVHjW54hFRq9NFRV4R/FFzKQfoCQyTbjTo/IuqNNaxYhWN17VDtdnO+fbufoS/li4u5vjlOSuX0YuByubCf20FTEWw23Jr59qRtitPy/31jz47yxXYoo1hMBMcC/gWhYZ33tx1BwS33a94XRd1C2R0ifvjWhXRzpMNXysvBscFUZ4lltzA0wP8PK5eJ5W5PM8LsSXgVYuAzhqQ6Iws0D0u7lZs6Y0+927DujC2HSFcIVCY7lUxuApEM1MQPq9EfsPBWalQKGRQPSKMHrLg== 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=AZu0EhsXBGlWYaGEE1gA6PINQ8S6xWDUsLAUBqNMraY=; b=ogEOrQ/gS4LU5/yQU1zjbeXg6W9nTdzhDkoNY6YwoAtvHONXB/yYtqzDcyKbROZWat7RS/Qk7gLoWSbNEoXg86VuZVTr15moYd87/W9bN2sQHriuj85U7DL3IgcOXwLwD87bRc+5Hsj5CypYm50q/JsdF73IEBZ9QbFqSzRgTv8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:14 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:14 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 13/26] xfs: Replace function declaration by actual definition Date: Wed, 26 Oct 2022 11:58:30 +0530 Message-Id: <20221026062843.927600-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0024.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:263::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d32e82e-c31d-4d8a-d129-08dab71b8ab2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +D1qfQCoDZjSQ8j78snBXp5O5UEQICOiodnRCujIE1XxCsBkhSRvprTE+uF5WS831QsYHO5vcvPhblDzsOItKPk2yTEfJGB4b708z8u+d8UuldqXrKbCB/DBw4UznMkG26SEnaTnsUDUe74T/9DaBeCJ4GkNP5TUvOcbFk2XDu0+3tP09t4EUYWIcdN0Uad+3IT5JyjuLpVQt3act/AhUgE+5HPUWuKDECK90gW9R+oPVgUBnqXzfRlln38dm3F+iG1MBQo9pOMNYYZzE38xuTttAKUDBa1/CwGrPuhEBVp+j5JEQ6hveSw/QGTIvELyfBvJjkBU+Es61ZVx/iSWLwDOxVQcvyat9wWdrxy9fDAdbkaefakK+KKJQ9k3GwxBZRYB5NJjAYLtBulECVJ+MAP2+aeF5TftDu+pXQ8zWrqozYELmWvzaJQTVDw2/0rVLJttklwJOx8DLExGyW41C2HZ2vgbrlpiEaqVN6l5eahuvIDaax/eu/a64G0rQR6Cyz7174AkIW3nN9UX3wn534wJ1/MPlIM6w2FRB0qgy85avq9xMkxLuXz0Scrn04NnB6GaOAl+wAzfz7nMB5yen3Vo5cFuDqTy40MhketULOIkERY1b2qX0E4VPS7QBnsBKB/N4Jc9977RhveLbftq1ZZrynQ/i7M1ODWoZg4shtp5luOoIoAO0CCQ6qhlX76b8Ph/Ma+cNRTcjw/rmGfOkUzCr6aaIuhlrqBIeDphsiDbbORTcabgleIeZv9VSxqj 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AYzhH+QOh2Z05Ty/JVd7slX6S6f+ZtZOPv2/5xTac13uo+e9X7nC7fTW45QsbrwbEQ7eNIlHk9FY3bF7nz0UEd4zsbNZRiO+n4ID2oQohTDfp0C2KhZQAcUX9ZJ1JP+4mXNOqh8srwb5Ytz7WwzB/M+I1u4MkwmPtBxEwbjs7fvRwfO+u0ew47axXS5CWqT9MSb+qB5VTX4ShI9m9GU/cxcnaE2Vc975wxn/KAuFiCNyWuoUY1Xnv02QsN1AictL9kwcNcp0dnjBcxWzv5XAXZ+6KAq2s9f9A8lz283uDq8AB/e26rot1HoGCJqqHvdVClfB2H+0WThXcvHtKSK1rKSl6FgwMDv+ZC2fOq6e80VQDTos2H5cEpwHUzvxzYiNaUjAscjyxtMm9ML/ITGOU/THtNhADHPGuma1IQLniCYdaPl0oKbpkqYwTKIDz/bbPCiJBKmOx5gbVU2KNDif5yb1LMDF+HGBd9SETYkllgIp2w4ztkS9nS3qeyM8pTDXgMS6OHJEo6qykFAFepPZV4V9EZa6AwKEw9eYXqjFUburfO7WNa8RD6E4pegFo8UC8f+hENnc5NEYC2JG6fu0V7PQpu5qArzG4gJGnOA9ZVg/zu1FOz+I7+La37vapcQf6lpGd3UGSKdFG1tRDNDIMuwKWcPQr+Eo0fdyzQSMsnte+efnxsoEmJqONdzI7kw4unuAre6rslhL145wGn2t7hyt5kkzribEjsZEviyaHVk3eunmsOjEG0YMBEKv1zBr7xbdpSdIUB1yTYwbhRMtZcbmwrAFjCUKzdGY0UtXjVwP6Vdg8ZXHJQfrJPGLjvxzZ2SEhzhoW/+hoKgVez5ecCfRGWqoC5i3h5Zx1UKILztx3PVkAjKx8r68O/JyJQezN0G7kwi5d9G7x8X3pLaSV1mTq79eBr0PqbRxL/FIbOrmQFrqy0e3+wuVPq72ciclFYxmNBkDLNoy5RuO4oHm3YmO6khOnc6KkPtYlUNomaKqoNCrWPi+L3seWufoT/fLcfjmCw38pm89tNMPiKYWatEgEfK9hiPFy/eBu73CM89ZQPHChRsZlSysDc01UN4IdwPxK7B8Ru1/28Kb3XRpP6kom4D6doifMSClzDsuH4Wq1sQAFA16M0C8CUljjfG0J77x0Qri3QhHtQZAYO384PmHXBuRXwsTuNuXjAQZmmrR5otTF0pjl7bS3VEMxrp8P/QAkJArhtxtrxjy7Nzk2hheJn/OZiTtsZnd6hwNcgr+nQIKHJb7LVbIHdcc0ny0LQeG65411ptxN5rnd1X9WgZ7GokJjvRRzsSVkbRU6MvXdDLZgkmf5DRKPOExE1r6Vx3hF2wEwGNp3sycQm4g3zmuEl8XMPxrKa+BmcUCEd3VMQ70QZCOebJPHrNP6IQGZkW7W+mzlFYc0otGbKNJnOvFmmI/fAyQ3EQKQA9OlQzGKmUxv3El8nJYa/CNZpm96hhlg05AN6b71WvaGhxggO2U3RapmTTuRl3pSW8bPtK3zUocqCUmf0oobbhOWLO33e85oomDRjjrNpazn7SwiGmt7a1hlVHtA2pQYQxI0FkXIIbdaZy4uCJUaujw49wZpaXeqh/Kx0JxrYWxCLAcxw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d32e82e-c31d-4d8a-d129-08dab71b8ab2 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:14.7508 (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: OVtVGUutU25YMiN52w+mcLepbLMC8O1VopFdvJp8119l2Yd3iAfz73SgT/AkNyUg/FQDi1p8XCTTR6Z7lsOLbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: NmM64YEV89IJqqm2s8doMUk6p7C6xUJw X-Proofpoint-GUID: NmM64YEV89IJqqm2s8doMUk6p7C6xUJw Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Pavel Reichl commit 1cc95e6f0d7cfd61c9d3c5cdd4e7345b173f764f upstream. Signed-off-by: Pavel Reichl Reviewed-by: Darrick J. Wong [darrick: fix typo in subject line] Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_qm_syscalls.c | 140 ++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 74 deletions(-) diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index e685b9ae90b9..1ea82764bf89 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -19,12 +19,72 @@ #include "xfs_qm.h" #include "xfs_icache.h" -STATIC int xfs_qm_log_quotaoff(struct xfs_mount *mp, - struct xfs_qoff_logitem **qoffstartp, - uint flags); -STATIC int xfs_qm_log_quotaoff_end(struct xfs_mount *mp, - struct xfs_qoff_logitem *startqoff, - uint flags); +STATIC int +xfs_qm_log_quotaoff( + struct xfs_mount *mp, + struct xfs_qoff_logitem **qoffstartp, + uint flags) +{ + struct xfs_trans *tp; + int error; + struct xfs_qoff_logitem *qoffi; + + *qoffstartp = NULL; + + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_quotaoff, 0, 0, 0, &tp); + if (error) + goto out; + + qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); + xfs_trans_log_quotaoff_item(tp, qoffi); + + spin_lock(&mp->m_sb_lock); + mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; + spin_unlock(&mp->m_sb_lock); + + xfs_log_sb(tp); + + /* + * We have to make sure that the transaction is secure on disk before we + * return and actually stop quota accounting. So, make it synchronous. + * We don't care about quotoff's performance. + */ + xfs_trans_set_sync(tp); + error = xfs_trans_commit(tp); + if (error) + goto out; + + *qoffstartp = qoffi; +out: + return error; +} + +STATIC int +xfs_qm_log_quotaoff_end( + struct xfs_mount *mp, + struct xfs_qoff_logitem *startqoff, + uint flags) +{ + struct xfs_trans *tp; + int error; + struct xfs_qoff_logitem *qoffi; + + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_equotaoff, 0, 0, 0, &tp); + if (error) + return error; + + qoffi = xfs_trans_get_qoff_item(tp, startqoff, + flags & XFS_ALL_QUOTA_ACCT); + xfs_trans_log_quotaoff_item(tp, qoffi); + + /* + * We have to make sure that the transaction is secure on disk before we + * return and actually stop quota accounting. So, make it synchronous. + * We don't care about quotoff's performance. + */ + xfs_trans_set_sync(tp); + return xfs_trans_commit(tp); +} /* * Turn off quota accounting and/or enforcement for all udquots and/or @@ -541,74 +601,6 @@ xfs_qm_scall_setqlim( return error; } -STATIC int -xfs_qm_log_quotaoff_end( - struct xfs_mount *mp, - struct xfs_qoff_logitem *startqoff, - uint flags) -{ - struct xfs_trans *tp; - int error; - struct xfs_qoff_logitem *qoffi; - - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_equotaoff, 0, 0, 0, &tp); - if (error) - return error; - - qoffi = xfs_trans_get_qoff_item(tp, startqoff, - flags & XFS_ALL_QUOTA_ACCT); - xfs_trans_log_quotaoff_item(tp, qoffi); - - /* - * We have to make sure that the transaction is secure on disk before we - * return and actually stop quota accounting. So, make it synchronous. - * We don't care about quotoff's performance. - */ - xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); -} - - -STATIC int -xfs_qm_log_quotaoff( - struct xfs_mount *mp, - struct xfs_qoff_logitem **qoffstartp, - uint flags) -{ - struct xfs_trans *tp; - int error; - struct xfs_qoff_logitem *qoffi; - - *qoffstartp = NULL; - - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_quotaoff, 0, 0, 0, &tp); - if (error) - goto out; - - qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); - xfs_trans_log_quotaoff_item(tp, qoffi); - - spin_lock(&mp->m_sb_lock); - mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; - spin_unlock(&mp->m_sb_lock); - - xfs_log_sb(tp); - - /* - * We have to make sure that the transaction is secure on disk before we - * return and actually stop quota accounting. So, make it synchronous. - * We don't care about quotoff's performance. - */ - xfs_trans_set_sync(tp); - error = xfs_trans_commit(tp); - if (error) - goto out; - - *qoffstartp = qoffi; -out: - return error; -} - /* Fill out the quota context. */ static void xfs_qm_scall_getquota_fill_qc( From patchwork Wed Oct 26 06:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020200 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 E9289FA373D for ; Wed, 26 Oct 2022 06:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233127AbiJZGab (ORCPT ); Wed, 26 Oct 2022 02:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbiJZGa3 (ORCPT ); Wed, 26 Oct 2022 02:30:29 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6749A4C01F; Tue, 25 Oct 2022 23:30:28 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nbxl017465; Wed, 26 Oct 2022 06:30: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=5W9v3eWpnM6xCr31lxTVWZBglzWEJwMnDhYqg27flUQ=; b=blfKi1uhvPz0MfnuU1g2492KUozMPUJGp2xPbp8ZSLj97mNkH3l+OCgqw2zr6KVONlts z0ZYcyP6pOUxU20Aldytt2RkPfUiXv5U5Yym5D8SXoJ6i8n2jYH52//NWicTBdlGaHse o3e8yusyIkFYRjWNcZWsYRxfHBaulNfy/rt/Wj65jZQvAXBG6B6W7yxJKrNvZ81QwOg3 5J69bUWeMaoq3UpvMnB2gEjLbcLhX6eEX9iG6srm4P/jYdSLgdg94rXSOyOzJ+J6EY9O optOa/rY0RUQFZEvOLa2LkPjaAXVE0CLSZWx+O43EReD9CXYhXBAUFzSfTGucasysL7Z hw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e620-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:23 +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 29Q2w6hZ031975; Wed, 26 Oct 2022 06:30:22 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2109.outbound.protection.outlook.com [104.47.70.109]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybe8et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bNvIns113QFpimc53F8JQqOHJjNGN9pUxWAj926X0OqYSzCt873bxaaTSJfqCN+tLyMk9FB3Y1H1x4ZrOmrbcQfp3DB/TXa9G9QJBG3gySNQ00+KPLBaRxKi2xmXIm2yGG+kar14fpeJc2YI01Uz+yKM51Ws+VIvYMUGElqT4vu8X76AS4a0/WIpZ65MjyY9vc/u94TD+VkcBWEyp6WPNGvUkklBfbHtzao5rbPwrcCsQnQJDqKG/xIcmg2sdv6hJzOnsIUnX2PwJQWbsxmkJm2TXXuKaxn8/g4cKxl36bcpTScNQxcBthcdlAe9JRKu24E8QZHGDZusxnK6bfSsrg== 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=5W9v3eWpnM6xCr31lxTVWZBglzWEJwMnDhYqg27flUQ=; b=UEJ+OBAwoaB32iJeaQIvAYrFYH2GaxwpiUzO0lFucTNs5/E+vIF3447v2v9YoTvBWveYel3Leon/Fy/0D8P5sOFzJExVHURnqkjVQnYS+r/lvomu+TvFiY/o/teHRJiyCtnDWiorOsGu0QTDfDg5QS6C9AGPKplfSm4ptWZAnLeqZPsFyZdHKpm70o/EU3jURjoTIZmdwydd+W4CmjMe7stRRWHIJnRBC49kuUEImfOW0QMkIqWy6n6nKpHj4xEfS+2DMCLN6o4frD6AOsAd64pIfOg4ZOWonAcM4D+H5odmGJQ7fPCFU/OzM9AkZDGZcFXtqofH67chvWmP7ye/+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=5W9v3eWpnM6xCr31lxTVWZBglzWEJwMnDhYqg27flUQ=; b=jjoHjHGlJ+HIqRRsVshP4KWJY+7F4Dv3Rz+09z1EBvxAjA53/u13T21xmD5Ic5Yh7pBJEpYYEUts5Y0H/Jn0DQ2C8iewz4UtD+IPlOGOwxCdUgUTU1bg+m/J9Y/47HunzikXf74LsSMTXDIf3EswN0fzFcEHH6e7Y/EqG/5H+Kw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:20 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:20 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 14/26] xfs: factor out quotaoff intent AIL removal and memory free Date: Wed, 26 Oct 2022 11:58:31 +0530 Message-Id: <20221026062843.927600-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0073.jpnprd01.prod.outlook.com (2603:1096:405:3::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_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: bb1db02e-48d8-4d0b-1498-08dab71b8de7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JS2hD3ROKV1q4+L8RuwcHWf4gz5Doa1mJ8ktpJF9LaerxHZgGRzkd3dU7OJhwoWicvMFYEpCHXq78fu+rbDN/LOAYA9ntbI/agTVL/SHdZDluI8B38RUNhRnMbiPXWgTeKAqmnyOGANIg5UhhuvCBImvqA459celc9YCRt4s26GVJTx0vMZ7urwFSjnU9CZdT4wVruIpTWLLxoC6VVPKrmlQHpfcS+Admul7C8jcTjojctHDx46hpIlOJpo4IhkuUmhnIzJJpKgZ6fCTSk+GozNroqT0SgZw53JFoIQ5TaoxIB3+PtVgiUgUc4CGmomWIvKVRJ31WRBYwqE4WeQifppvMvhlNCTa639XbuJwYjCT6wzJxk0uVxyp2N9K06bIjNh+C6cFaiQ2oa71auhgVJDBtJ+XNGNvCPWDRR/NFfy/UztVVFeX5PM0z3VjxAVgKPSTq71vNQSaE0xpmI+DpWCn0ArWtdxxJu9NJZTzHmC92Br9UprsbEzi6YjllrsVypyyEEaZtbsFPAXAZSYcms6FQYvNEhB2iYjILUSptJwl6D6s4kM+FkGwwRvKgXYCmXfVBSTmF+BCJq8Fn86Mtm4jcgs5aqs7ZTLlBlQ6ZhL0WQysQsctX6aL0NX6zzm9HYDBgK4evzn8NDyv6i7psrpk8O1BjHaQLiRj1ZV1NTSROvuF/7YuipYpBY8HO7qXYvCxmQQeYwaHKXsV7PQpokc7z3xA4kupJxAjZPabImNb59KtS0dmFLxOd9hLwlCM 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(15650500001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 25+tGvCNYCgIRQNWTFe7Yap/MCWCzYE6fohb910/Le9dL3fcsIz0+FOSsX37QU05h8hC95iInYSwYRDhVcw9dxlunJ5/vVRgKabWL3Jb3ORlPQCeJ3duRPI4M7KtOaQ5DuHyRb02gwG46wP4gPGP1scDbkEE35ITevJA2+Jwrj1A6h2ak+zcber4jQ8tcBPqE+udmRKrnt6KpcsgyBnROUcDrcIYFgTpxS3mdC0hKuRtXpiB8929CzqXHnY+2R7xx0VQioH9kSdOX86mYPIm2/RHnvGJOnpA7rDgO6si3NjHaUZqNm5ojHw4PTjyGPd5LPglCa688MGPwXDTbtz0540TnnNRFzATYHHs7ROF2BhqKhEzm+njGOfYi0yJT/NDOZ1VfuHCp+HQrEvD3KGe2VjdL1MI8sXa79wOTmNm+zlu+GXaBgK1YuO9NeE9YMI6AlLH+ha/dLHohaaQR4uH9pqj1uDg/bxJ5AWv0UylSilzhsYV2W365Mhxp+3xbAkGey9H8I9P6n3FKb05Smlk1eCviJ9DW/Higngr0/Yox8UdGe7okh1mDakaGsQNWhSBd8+h6AUy5x3d3IfCmwZDStXMAUdmj0yxIhsBq3hRIWUFUxtMLGgrs+IURCgRS1gnybcR5xq1YeEW6iqmRDJiUunrb9u25KxBRTTmGGrMkDzeDfm/pYrL69fzEc8omd6PWlpQcbuqG6eq7Sz3gn3w+hNl0wu99ljjwm0ir+EqXN2vE37Hroc4j6jUgTA1IsYGeQgtyWK25qzFW2QZl/l1NQNDfsOCApk3IQwUlkLaSqVEKUeFXc0tIs2Lvy4EwYnaItcY3+Wm8nlhhSKGoKfP6LpTO5iHX/J2wAQg91PeRID+kzw8bcsZSZpbbkDKgsH+Gu0UcwgW/kI3DOxbZzXxFYmZzIMEfD4QE5yr4UPabrMFONjkYqbe40/rZ6eWrFQhE8eE+AwP3uzSee+NLViEeURTd/z6kbU+zzqcJbhdFZLI+skmf7itvHAw0opmuavoMgZ0vj7KkGaPkfG78NmgR7Woz3uWDuOFTqcpgBr8n+UmQGkFTTCvOfUC/IQgxDZ8mDDb2f4PRKmDSnNe8e061NdRKdPlUD/keXc/TM+Si3tbNYhA7TLQ4nLHEwqcgnVzwk1QUu9f4+DVfXJFrDHzevg4S3EWQtkJ29PSnnC5TQqbC4ZKrTYL0iYUmiWfbB2QNt9ZZUODMzL1odnrQpI3HeXVIUsFSMc39rhC4BJsz4JWB1l02uG6kKj07FO4DP+Ja1CQUQTMi4zNlLUHCukfoPRpMilMjxcZnOPY7UwSLDHr0B6WAxrw6sYFstRMVJZARD4Otz2gik+KZOEgTRj/bwx8gOw2MTssVIDsZHTYeCE2VRHDXeTOANqEBpUs/CE5AaDIn2RXeGPSe1cWWQfJgkVCEp+4oCsmwy0REtHUNgTca0qByf7fUH4eNv0FZlvfcpt9wox7HFnFeNjT9lJ+ratcbbX6y9+PfACazNG1YJa1e8VolIU+NVK+Z+2nHcwbUSjCGrocomxjd8N9H77vfqECgzh1M2a2gRGLx8nomcIO1LUsPFLLz4aA8nDMd1yfUnK8K64rlrSV9M55imPn1Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb1db02e-48d8-4d0b-1498-08dab71b8de7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:20.1420 (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: YyF+3vosLe4ytzGngDYkuUGLjR12UIpoN8j54YJ0Lcp1WKyJDysZlV4sHdWovFZ3A0wMOvHhXCfMaHKNyxddtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: GsSET6VQB4vYkMpMjZxlfeU28guylw5c X-Proofpoint-ORIG-GUID: GsSET6VQB4vYkMpMjZxlfeU28guylw5c Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit 854f82b1f6039a418b7d1407513f8640e05fd73f upstream. AIL removal of the quotaoff start intent and free of both intents is hardcoded to the ->iop_committed() handler of the end intent. Factor out the start intent handling code so it can be used in a future patch to properly handle quotaoff errors. Use xfs_trans_ail_remove() instead of the _delete() variant to acquire the AIL lock and also handle cases where an intent might not reside in the AIL at the time of a failure. Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_dquot_item.c | 29 ++++++++++++++++++++--------- fs/xfs/xfs_dquot_item.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index d60647d7197b..2b816e9b4465 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c @@ -307,18 +307,10 @@ xfs_qm_qoffend_logitem_committed( { struct xfs_qoff_logitem *qfe = QOFF_ITEM(lip); struct xfs_qoff_logitem *qfs = qfe->qql_start_lip; - struct xfs_ail *ailp = qfs->qql_item.li_ailp; - /* - * Delete the qoff-start logitem from the AIL. - * xfs_trans_ail_delete() drops the AIL lock. - */ - spin_lock(&ailp->ail_lock); - xfs_trans_ail_delete(ailp, &qfs->qql_item, SHUTDOWN_LOG_IO_ERROR); + xfs_qm_qoff_logitem_relse(qfs); - kmem_free(qfs->qql_item.li_lv_shadow); kmem_free(lip->li_lv_shadow); - kmem_free(qfs); kmem_free(qfe); return (xfs_lsn_t)-1; } @@ -336,6 +328,25 @@ static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = { .iop_push = xfs_qm_qoff_logitem_push, }; +/* + * Delete the quotaoff intent from the AIL and free it. On success, + * this should only be called for the start item. It can be used for + * either on shutdown or abort. + */ +void +xfs_qm_qoff_logitem_relse( + struct xfs_qoff_logitem *qoff) +{ + struct xfs_log_item *lip = &qoff->qql_item; + + ASSERT(test_bit(XFS_LI_IN_AIL, &lip->li_flags) || + test_bit(XFS_LI_ABORTED, &lip->li_flags) || + XFS_FORCED_SHUTDOWN(lip->li_mountp)); + xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR); + kmem_free(lip->li_lv_shadow); + kmem_free(qoff); +} + /* * Allocate and initialize an quotaoff item of the correct quota type(s). */ diff --git a/fs/xfs/xfs_dquot_item.h b/fs/xfs/xfs_dquot_item.h index 3bb19e556ade..2b86a43d7ce2 100644 --- a/fs/xfs/xfs_dquot_item.h +++ b/fs/xfs/xfs_dquot_item.h @@ -28,6 +28,7 @@ void xfs_qm_dquot_logitem_init(struct xfs_dquot *dqp); struct xfs_qoff_logitem *xfs_qm_qoff_logitem_init(struct xfs_mount *mp, struct xfs_qoff_logitem *start, uint flags); +void xfs_qm_qoff_logitem_relse(struct xfs_qoff_logitem *); struct xfs_qoff_logitem *xfs_trans_get_qoff_item(struct xfs_trans *tp, struct xfs_qoff_logitem *startqoff, uint flags); From patchwork Wed Oct 26 06:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020201 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 2C8D5C38A2D for ; Wed, 26 Oct 2022 06:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233134AbiJZGaf (ORCPT ); Wed, 26 Oct 2022 02:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbiJZGae (ORCPT ); Wed, 26 Oct 2022 02:30:34 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7673E57E0E; Tue, 25 Oct 2022 23:30:33 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nXHg030454; Wed, 26 Oct 2022 06:30: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=7wwnJzQFEcsKNkkHPHnHyIljg6RSg1A5SCeFInZsnOM=; b=l+1w6MjUxB2MNhXMOVZCS/SdNsHpAzWk6yQ4n5t/WPk7aJNgrxOrxcGuzjY6WgzInEdI 7eEd2mHjAbRHX8DgGdqkejkioq2Ajf8qGof16CdgZYeZZ69tLuGnjTVDipK92S10EU2I vBOLDgsK+wp29ME6vviDVafQA6ZOaJ43sRsFsStAyX8K6Bc26eP3rniwAAEdxgaFuVYW fi3z+Jvo4XYoo+JfnZqx2zl3s64UL192777C4hCLILMtuUEEjL4vXxZtDzB2e5kfM1UU OP9bfpVE9nTHVH4WG8Dwnm1WivLpGlqtwqYUekUX1GMhKH/50Phacnahq00qm+flfZH/ FA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x249-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:28 +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 29Q38pKK021987; Wed, 26 Oct 2022 06:30:27 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybprsy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VbRmTWe4z6rTlqa97Ysc1ppHfXdVthsulyyU/HXjZvQrpxJDCLMQ3TR2NZtLypwlxd+MxJiVxf1cFWSwVj8lrmxHRnOSLvjDfXvNQ62eXm8XUiQZ0iqRDOH59ip4Eudw3zxsPpFycM58Eai08dyrFhSixBqIXd6JcTspCdOgrex9UtDnUMb19zeyNlwoWS55QaCo7Uu6Z/TR5+v+32BQQUyyZuSfCTNIwH8s2kHzq4E+3rkz1q/S9cYl8ZvNZR00cBLcINAyXfWVbrNCL3i0vulPwdZFIobiHVAj87bdu6Gwx0XFGJG02LA37B0vJIYc/mtCJukPCaYjewXA/e7mjA== 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=7wwnJzQFEcsKNkkHPHnHyIljg6RSg1A5SCeFInZsnOM=; b=PhLX6FqeWIEEwUqSJJOCZC9evSNt2ubSo94yepHbLDmrEJWqQV15ZowSrDmKvXtPPcMU5qtddAHwiquqQ1H43tgSDbZBTfBxlqSbqbJ6mB9CjTO42+c+QxCzvKbOErB7+LeAhpIvKLhNXhKW25ms8ScrjQ7B8hF7BXtD2BwXNQLljgU9yT4UscTN3BLW8knRaGCDOzDCJ4fGXAIU+O7yS6/XuxAHaNEqg8ou9+Cr/zJgb0buJUN4O7k7t/0seLQPQYq0dGYZR+5Xy0oh9Wcj+7ZDyazHM0Y5cavQfXoQCis+f5ayctCQwyYYUdhg3V9C3rnUoH3IMFv06Zjgw1spnw== 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=7wwnJzQFEcsKNkkHPHnHyIljg6RSg1A5SCeFInZsnOM=; b=LFTxBLP8l2hJPNUXTrVcSY+cOcTL7VIe01domwxseFWJgSDN2aL7Sr/Bll2GPHP+VR6eNemNG/5mkx09NLrwt6CJwkr9HgNXHXVomvGYOxKnDgaBJDxyATO+8Q2hZiO+TlQJ4Y0cZjbcaTuQfon0dvwietuXpV9jWh8ywuvW2rU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:25 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:25 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 15/26] xfs: fix unmount hang and memory leak on shutdown during quotaoff Date: Wed, 26 Oct 2022 11:58:32 +0530 Message-Id: <20221026062843.927600-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0086.jpnprd01.prod.outlook.com (2603:1096:405:3::26) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: 5de1b5e6-32d8-4735-d3d1-08dab71b914f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p96xdfxia8l2SfLWTBxoUMchmRIYnsTJA7xp1KKobEemqE1XTYXw/GmPFMORFYuCYA0bXDCL8hMW1FYtG+IBHsF+GiggqoiX0zG/u7RI0xQmTP0ZGaCw9cPTkOsEQ7NcNRQ9qofWXHqrAu4FZWFpWblMq3e3eVJjT3FaIEU2+nXtnZOP+ZDbA+6usY7TRJxENS/b5KB4M3GGud+SVbVDb75Cnq37Oy8e2HPwamZzNnc8/OErWbpDCR780L8k/ESSIrtHJDaNPKvmjRL8eDrIVOqJHOM8bCjUeYy1ARdlWuISMesX8DOYnU6YQ1XuQoEMZ4k2oC2WPhTYSu8LNRNNg2v3gZxGRxe3WlXqZq7kJzt5ftebDpPS+eNAs72Hby7Fqq6WbySzWMFcwHBQdAGyLp3EyKScrSPgB1EHUgRZxX/GE5R5GWYloSuNu+EIR6fBAv1BzvokFK+uoUGI6YOKoqRmAhUgTQDz5Ls+cuA1hpapNvyx4A3nrIyRJI+z0G4ZbA67EMHqak6MHmTOaZ2hHIZY8/kSAOUI94pI+3wl9WmAEUAWAriQ9+aOo0JSM8u9DaVZ37OpeFXyICuqbi4b3jp4IcD6LZkJIVHR/h/lIAs80WJwxpInpLnRpGWwKFWCUv2kMnG56AHmsKI4xN5TmOcPDbLa65v44udNquekDLFUq97ObqI42ncurLlTrDOw+lyL8Wy979lKTr29KgcAVXQTcANBaMIk841K8yJK3aeainNV3O0mijSXp7fOJQUM 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6666004)(6506007)(186003)(26005)(478600001)(15650500001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ECbN4pPhYmVGEwRc7PkjsSBPsCjemVLcLscbyoT0hDSNxnOymvfmIxZWzQjJ1O7shMbKLOtpY0zo+5f9c8ZGUL7Hdkf1DoiBI7+fWddH3s6oIyKS4j3PQCJtw4Hp7jBXeDd4uBuIZqn3fI+7m+Bw1kFwhLQxGoJjsJQzy3Ab97vZ+PQ5oq7pnnWxrMq5TQ1oSjsuYvRHNqSkT8VjfeK0hnSdLa8s8Nmj17ZBtzVp4N3uiXAy0ZlGcJYRjCYOXzpW+B4Muj6CgXVOZh4rAQFnjtXKHd2jMFWbNxVa6R4O9GWpL0r8j+oB0ZosJ7tKCLK4nH3c+OU6BBfurfftfa/5PdXvNkvCgOi9aGiRdpsVcsytGYzWll/vLNsqGCUdb+OvO7Jp5PeXDepGGjQtf9Sx2x5rz8GAr/hGpQ+DFVRfQHpzLUStgtad0bwQ3jVRlZ8O3tdeELrO2YA4RbvUs4xD8jJ+8ucNGm7dwItU1CMVzjhPUEQUxRQlQE3fG854Sk799F0+KPjupyt9oWrddDQWFmqGmoAE2dqVjKudNBvAQRJ6r7j2sU4iOelhlwmGoWaM0fGNqLFDwkDfC8OKy21hB0bW+riHkWaFGstrHSettKLiHfDUqAGMAi27UKnGwWUUWsbiV5Oh94fyxWT5aOyvpKlWv4OGyPC5TNEVy568hQ2TIzHxluIFjp09Q1RebTZk75Nq64Sqfs26T9BdxZdSjeKUjqbr48l9HP8KdP8e0Fa5KpnibcrxzvTwntkHnZmq4w6pKHApzJSktzP3yv7bLgXnm9gfsc9F1zxIpqZ/fbwVQohMQKylxp/2N3n+K24FqOvdbfTJ2KYvH0QQA7BkpngvT/r/EFt8TgVCw3P5hJsWI+abqKlJmXvAP50Gst0sxpBUQO7IXR2RJRr3XhEmG1eQ4ok6GsPsQCacDsN1LqdtiFUim6bt+OE+3TcgeZpN9u3yAX75E5uWNTjRzpwK624+zLKPYNI6Mnn3kDWqWqR9kxHPG2gDne+T/RXJftEzMP7faLeoFIYhiYwtAw+OUd1KYAR3dx7W/9azDoRXpoWR0xMk6xFNmLxh16T7ahrpJIUjq4RhGdSqCqTApGDE1BS+ufzGmjzEFuxVp3i2mm02Tgc15IPHzGrN2+ghb0cGYrD4btk4yd/kRXQQiBebiaKAqx8dwNoT6KRhnjUlABz3qwbiJe2RKnKNcsb25Uzy7sRvl5/ZgeHimQWCZI/53syagn8dFUT3zuXkD8/TiU4AF4luqepN45GtXNxC7vCkVIX7ebaFg0BA2+8yQY/3UyvRwmQBHSXvXk2PzyA2TmR6yuMY60m50ph5CPZiwlRiCOhUWjY/u1+0Wu5VT4ytg9ruuS9HNeo3WravJIHDdc+q3mA9Jnc4Pjv5rBoG/Cy6Iz9ts4pAVPwvqa78TNm7+RKUCoXyp0kyzc4BtcUZ5LKmERbe12usA2Wi6n8KnZ36DxNu7tveyU0kUdJ8ktHW/6n9H8LtAIp5ObzJTWmvpOhI70LU6G3N56EVyJGoHSy2Y9iJO1Hm9Qiiorp4x2BOwraslut2gsVEACKKamsEwUXmxwjDtfWMWoLc4odh1Qgc7nmeaLWXPHXIH++yZrYzVw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5de1b5e6-32d8-4735-d3d1-08dab71b914f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:25.7212 (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: qJzh/5JHCnpGxV3HcqYAxVBuOi6O12IW8UD+diKkRQQ2iURk5pRcFOyT9WhMWxxMpFxJMuVsSe1Bz90EavN+Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: XZK4H8RciGLAzO2yw2EIQn8RWsa40nTW X-Proofpoint-ORIG-GUID: XZK4H8RciGLAzO2yw2EIQn8RWsa40nTW Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit 8a62714313391b9b2297d67c341b35edbf46c279 upstream. AIL removal of the quotaoff start intent and free of both quotaoff intents is currently limited to the ->iop_committed() handler of the end intent. This executes when the end intent is committed to the on-disk log and marks the completion of the operation. The problem with this is it assumes the success of the operation. If a shutdown or other error occurs during the quotaoff, it's possible for the quotaoff task to exit without removing the start intent from the AIL. This results in an unmount hang as the AIL cannot be emptied. Further, no other codepath frees the intents and so this is also a memory leak vector. First, update the high level quotaoff error path to directly remove and free the quotaoff start intent if it still exists in the AIL at the time of the error. Next, update both of the start and end quotaoff intents with an ->iop_release() callback to properly handle transaction abort. This means that If the quotaoff start transaction aborts, it frees the start intent in the transaction commit path. If the filesystem shuts down before the end transaction allocates, the quotaoff sequence removes and frees the start intent. If the end transaction aborts, it removes the start intent and frees both. This ensures that a shutdown does not result in a hung unmount and that memory is not leaked regardless of when a quotaoff error occurs. Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_dquot_item.c | 15 +++++++++++++++ fs/xfs/xfs_qm_syscalls.c | 13 +++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index 2b816e9b4465..cf65e2e43c6e 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c @@ -315,17 +315,32 @@ xfs_qm_qoffend_logitem_committed( return (xfs_lsn_t)-1; } +STATIC void +xfs_qm_qoff_logitem_release( + struct xfs_log_item *lip) +{ + struct xfs_qoff_logitem *qoff = QOFF_ITEM(lip); + + if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) { + if (qoff->qql_start_lip) + xfs_qm_qoff_logitem_relse(qoff->qql_start_lip); + xfs_qm_qoff_logitem_relse(qoff); + } +} + static const struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { .iop_size = xfs_qm_qoff_logitem_size, .iop_format = xfs_qm_qoff_logitem_format, .iop_committed = xfs_qm_qoffend_logitem_committed, .iop_push = xfs_qm_qoff_logitem_push, + .iop_release = xfs_qm_qoff_logitem_release, }; static const struct xfs_item_ops xfs_qm_qoff_logitem_ops = { .iop_size = xfs_qm_qoff_logitem_size, .iop_format = xfs_qm_qoff_logitem_format, .iop_push = xfs_qm_qoff_logitem_push, + .iop_release = xfs_qm_qoff_logitem_release, }; /* diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 1ea82764bf89..5d5ac65aa1cc 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -29,8 +29,6 @@ xfs_qm_log_quotaoff( int error; struct xfs_qoff_logitem *qoffi; - *qoffstartp = NULL; - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_quotaoff, 0, 0, 0, &tp); if (error) goto out; @@ -62,7 +60,7 @@ xfs_qm_log_quotaoff( STATIC int xfs_qm_log_quotaoff_end( struct xfs_mount *mp, - struct xfs_qoff_logitem *startqoff, + struct xfs_qoff_logitem **startqoff, uint flags) { struct xfs_trans *tp; @@ -73,9 +71,10 @@ xfs_qm_log_quotaoff_end( if (error) return error; - qoffi = xfs_trans_get_qoff_item(tp, startqoff, + qoffi = xfs_trans_get_qoff_item(tp, *startqoff, flags & XFS_ALL_QUOTA_ACCT); xfs_trans_log_quotaoff_item(tp, qoffi); + *startqoff = NULL; /* * We have to make sure that the transaction is secure on disk before we @@ -103,7 +102,7 @@ xfs_qm_scall_quotaoff( uint dqtype; int error; uint inactivate_flags; - struct xfs_qoff_logitem *qoffstart; + struct xfs_qoff_logitem *qoffstart = NULL; /* * No file system can have quotas enabled on disk but not in core. @@ -228,7 +227,7 @@ xfs_qm_scall_quotaoff( * So, we have QUOTAOFF start and end logitems; the start * logitem won't get overwritten until the end logitem appears... */ - error = xfs_qm_log_quotaoff_end(mp, qoffstart, flags); + error = xfs_qm_log_quotaoff_end(mp, &qoffstart, flags); if (error) { /* We're screwed now. Shutdown is the only option. */ xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); @@ -261,6 +260,8 @@ xfs_qm_scall_quotaoff( } out_unlock: + if (error && qoffstart) + xfs_qm_qoff_logitem_relse(qoffstart); mutex_unlock(&q->qi_quotaofflock); return error; } From patchwork Wed Oct 26 06:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020202 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 E596AC38A2D for ; Wed, 26 Oct 2022 06:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbiJZGao (ORCPT ); Wed, 26 Oct 2022 02:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233141AbiJZGal (ORCPT ); Wed, 26 Oct 2022 02:30:41 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5815631FD; Tue, 25 Oct 2022 23:30:39 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nr6g018282; Wed, 26 Oct 2022 06:30: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=o//y0Cp6BgYyfFiLLdEPDlAj7cD89w+6qAS9zX8vDFA=; b=eK9A2fu5iutqYXI6k6pdzevbjzMqGmmfmVwc0eZ7q4tpFYZezu8L6eMjhbwln22nFSjz JgGtGE4Mz0SDt+i82HAZ97FYONCk6lnxjSpMpQ9OK6E1BSZz+2KVeCcNjnCXUMLrOc6j Ekh6cre7bf2NWB3y6PqitJQ65IEth8GeF9/umAUsHWR7141CDWDZxFDZjxkvBAgpu+oB MnQHV/zmhxLEjOb3yWPPE+RzwIvGO4FX5Di+9xs1HeQ+Vr17RiLgGrgirvjBBIyOf4WR iWb81GWQ9paE8XGJDFvZFKvvmR/UxmxQpzh+yeHt9klkveXMCcOGBjvKs2+Ra+uxcQCg 8g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc6xe4u2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:35 +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 29Q2s15N011197; Wed, 26 Oct 2022 06:30:34 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d99g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W5A7aLJlD8TBP4aRztXmLyRKwPTNS177Msoyij+q57SjlNM3lGIWGSpOnmHogoo4TXN3iZuIhGl1y56xusB0s5vgPpnQ3HvnE7vBv/QjjrjNUbvO01oyqSKb/lGCWd8mUnMAFp/pDFquW3hpbvnUidvnMu68QskEbByJ5/nvoA7IH2yh9v2GeQGnM42YQW52rhnj9Dz9Z97hOOo9snJMiU0nkHehydsjMw1bTZWcKeNdNYzLQW1+RWhsT0QtsaGbU4sedORzeR9dOfc/RT3LvVly45rCEoyOsWElqTNI8ibGof4oSa+P/LGiuygIRzv1tYOSiKy9l0w7yMyzfccedQ== 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=o//y0Cp6BgYyfFiLLdEPDlAj7cD89w+6qAS9zX8vDFA=; b=hZD6r2ZS7ADXLjLIYz1tKYGFjHA1f4elmW/KQqMlCFL/ES8zWE07e+znotGrr/Z2DSLTk7YsHF57xT2l/ZOpvD9s3tFAjC8tnL1YbRrwADjtHUOVDcSTsMFp1/MhvbjprVkJJt1qEC5kHoHOI1PUvINRcnMNraNVv3qfrRL1O8xzYxsMXtwFfUbVHF/VrdUMTE4kVLi0W5UR7eywp7QuVGpjAB98JlpZ4FW34f3AjrJOpPwp4m8onAvO4tDwiRtnVrZlTAZkUX/XgpYdA1n1OPMNp5JsiL5bZ2bZ/fNKy2TRf+TISOHWxsAog+0DgsRzjTJr0VrUigWmtBJCeCJ5cA== 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=o//y0Cp6BgYyfFiLLdEPDlAj7cD89w+6qAS9zX8vDFA=; b=ASu+6NbJ+rD678ZVzKtKpiQ74mTAgoDQmlVY2/3/oiVYQyXQh49/R7HbfvqbhIm5kdrKG5fy8+SEwztK08QPAvJOOaPge4ykfsh/uIQ0FzPMgGhJe+mC3oNi9Eu0WhZ5BZy7MP6w9JEqalmGCRdKDWoDYcv9Z9Ck4WsnLA8pJT8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by DS0PR10MB6151.namprd10.prod.outlook.com (2603:10b6:8:c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Wed, 26 Oct 2022 06:30:32 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:32 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 16/26] xfs: preserve default grace interval during quotacheck Date: Wed, 26 Oct 2022 11:58:33 +0530 Message-Id: <20221026062843.927600-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0156.jpnprd01.prod.outlook.com (2603:1096:400:2b1::16) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|DS0PR10MB6151:EE_ X-MS-Office365-Filtering-Correlation-Id: a0257626-f574-4a25-33d0-08dab71b951f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jlrAdg7VthQJNbxkb6fcGbAqDKOv0mKrkL2RlBAuX+2DT0x4H090vUiEsuYL8kjLGp5vEHFvDE0N8sLzS5DW8mio943ipjdhIpz/MKBaa9hJb0bNUIKDAC3GY2kjWnZNUv5b0Hh+JtzTIeo8OSZDU4WcxbKm0/dtkU2xjGadevyFi5OWWn0Gip9ymwuniykza0PJmJCIKb8jjRwMmS6YqauzhPsFdo3EZDZ0zW5u3fDViZp29326Y2Rt04LlfZ3IEAZSVItL+2kbXz11QCn/nOB6kY9EZwaQv8036c4J7dz8UA40HHj1ksY0hX0eVO0J+Mir2led5FGfyXMimRQwIl2wTxsSiPVwGSKqhj7b+BzG+zHIuXnn6B7nR1MYLJLr8wifwszdjrrCAQ4jyrbFCax29lfFX1XWFpwtpR12ZsFTLK3StiVHlLqO5b+k++W/LPdt4oc6Lc1WTh+U72l8V3yXgs4VmZiuKo/XZZZx2uytlgY7lgH9lsNd6U1cC5iByiztfr7xQyWBC6EwIwYxTRcnrg7ynbqh3mq2EEOsZwg62TSXuW/1Qi78HCApwvIettFwq2APIrf/w9yyL91MBxj5kNAWbWocTU/O1mWfMbgP5RTJ6G3ITu647qBKJ7CAjFKXCI26027+BT7V+FHU03KGiQc6xKZGkRyzDQ4Wt5BXtmM8nBlBa5BMERR48D7pcNnYOoHHKevock/oBCxe/IGcmB+F9wUO6TBUMBuyXNKGYE0TQJwz53/sY9yl6Xgd 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:(13230022)(136003)(346002)(39860400002)(366004)(396003)(376002)(451199015)(6486002)(6512007)(6506007)(186003)(26005)(478600001)(15650500001)(2906002)(6916009)(1076003)(83380400001)(2616005)(66946007)(41300700001)(66476007)(4326008)(66556008)(8676002)(86362001)(316002)(38100700002)(8936002)(5660300002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zihAupv2ANHHiXyJSE4LMiIw0h9SJ1oxJz5lzbbU66z0bpoDEp1FAQIKlktveCb38J/K11pL20beRfHMTF42WEu55P5y/8mTv5mGksuGzCIV14G05hk7xBkzVlirWRmKHFf8XYnMrtfbNyEPbrpOuPnKMwqhHKZ0YFdUL3/JCbBZnifuUsVLkDjGTxfDxAPwfIVcJZw8qJaSAZCNIvhBC2IGSaOAajmMUWdmA5fvMIBgp4sogUFkBsf+wQu9IhzVvOv+vwIh0N2cV1IudxcbizeFKNiAU7Hc+H3adTBIvybv21X/SAQejmqOp2qUR55QZGvytKzNsAqZKeeiFnKYR3Sq/i7LNS7bUOHXEeUwKy67L/7YxOm7kmxEpo+JXaXTXBsQZiLD8sljW1Xt/Bf9OFvhx2N623cweJ4DahOj0RrneSMALbTbkqtF5viW6uaW/YZTx/PCDwesKi1RTbwS8AejaItVWwe3jw+JYa103J/Rs6wqrho5g8eFHrzOCsUc3AWMWekj2PCwedEFs3ZQjHdm8FgCwuxAal7d3FHZ0aF+xlkUsGY6VjrIOQvU8aMJUC/BNtObGwu8FpQj+Xm2v2Od35rqMAvTQItiCuOIXrq06USZ4XKYOd5X3UwfBJaOjDIOdNBQ1azVhsAcXr5F/890GWpjcQEeRdHVXgbDwkIaThAe8nChcWkI+OWOwUK/Vp6rZz21APpOIocCAVmhk0Mf4DnxCYwvA6kCBmkin1KksIlN9ih87GsKe6hcboEMVFFOnFGGoGEySzEs766+EGgEu75YL4ODN8Knpb5pm1QB3P1AdCVupYIhHYyIpC/zWS2ONJ3KhgfOSwT1HBzAmcTIo2fNq65fqf9DCnn7oE8l32sKisYlm+d+jlmw7EGXgOOlqcsIxGSfWAiUdxFMgxI5iNY3BU+Hf5UqKwKTJ3J43XceW6RERCdzJwNek7dNtMSOSzJLf8hrlvCHTQmxV0P04F5wCZo15qc5COZ2Jq30zKio0RRVVw6U84Sa8nOkXHfRNHxwDFMuW9HK+T7/IP1R4pw1MN9Be/QGfBeD9sXc6eh0IuiUFz12TdsC8VqxvW5rPpR1ua6S2hIG8xM9i4Jji1aovWISUSUukFJ/72bTfykaaIh34Xj/deZII7QnYI9EfKTBC+ifmNtwLsSr1c8mPBd9SU07Rmpxc3lpxhnJGhapyg+uJxppJoRZU2FEJuDZew3Kf2lAuWdhVhYJN75GRn8iWdtuxuQc6p3/4GruDhppL3Hts7aQttsx3irzxm/SLxxTwvOejGCpz/uSEGtJwkn6tPl8sDAZl3bj/WdKel38FNgchTmXtrs3PDUCen3K2Ns63Lr/MmV7HYuKZV6rus7RcGD2iWabfDzfERB7BsIYQxBl++LyKiYr+XS9CVd6iLW9Oyds0dzIERih1u6sDcr3vRkHPZwS2bl08Db3YarpzhXgz7VMvLlpy/V4Xv+Zzf6cTjd7EpiVjVHNRArRuF9l4GZvqMByERCs692/grcQrZYWyQL35wUgfoWRlxdSUL7hZS9IdYa8Qp5Q4sThYREuEyzQeNZiIUNYK0frJKrBfsWTB7+08egKerbQX7NG7U05KzreOpW1Yp6H4Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0257626-f574-4a25-33d0-08dab71b951f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:32.2552 (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: japBxkkqu5smL1AmgzMY4xArJmhut7rZDdzH15Ahq+QSeM+yBEa6jpArWwIqGHo7SACBwUJeWzJd8W5xQmwjLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6151 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: rxJ5ty80ck4JTjSH23PWsUlkVtfS78W1 X-Proofpoint-ORIG-GUID: rxJ5ty80ck4JTjSH23PWsUlkVtfS78W1 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 5885539f0af371024d07afd14974bfdc3fff84c5 upstream. When quotacheck runs, it zeroes all the timer fields in every dquot. Unfortunately, it also does this to the root dquot, which erases any preconfigured grace intervals and warning limits that the administrator may have set. Worse yet, the incore copies of those variables remain set. This cache coherence problem manifests itself as the grace interval mysteriously being reset back to the defaults at the /next/ mount. Fix it by not resetting the root disk dquot's timer and warning fields. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Christoph Hellwig Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_qm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 035930a4f0dd..fe93e044d81b 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -875,12 +875,20 @@ xfs_qm_reset_dqcounts( ddq->d_bcount = 0; ddq->d_icount = 0; ddq->d_rtbcount = 0; - ddq->d_btimer = 0; - ddq->d_itimer = 0; - ddq->d_rtbtimer = 0; - ddq->d_bwarns = 0; - ddq->d_iwarns = 0; - ddq->d_rtbwarns = 0; + + /* + * dquot id 0 stores the default grace period and the maximum + * warning limit that were set by the administrator, so we + * should not reset them. + */ + if (ddq->d_id != 0) { + ddq->d_btimer = 0; + ddq->d_itimer = 0; + ddq->d_rtbtimer = 0; + ddq->d_bwarns = 0; + ddq->d_iwarns = 0; + ddq->d_rtbwarns = 0; + } if (xfs_sb_version_hascrc(&mp->m_sb)) { xfs_update_cksum((char *)&dqb[j], From patchwork Wed Oct 26 06:28:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020203 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 A70A5C38A2D for ; Wed, 26 Oct 2022 06:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbiJZGat (ORCPT ); Wed, 26 Oct 2022 02:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiJZGas (ORCPT ); Wed, 26 Oct 2022 02:30:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28AFF6EF0A; Tue, 25 Oct 2022 23:30:46 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nFTo013699; Wed, 26 Oct 2022 06:30:42 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=NjxfT+4hP3AkeMAgzD48cuao+Xuwe3WArOID6uTy21E=; b=PRh4uycdia/X5YjEhQFdufRczHDVXJhK7Mnz8GxOQaKl/QWFmmzZEmeiIpA8beURVFlu 5FPCHLjJRasEI1fu7OZgV6IsS+Dipq9V1x1YG2cKi2kejTf2jqNcffZHApNZVGfByD2i y8Aq2GLUTmczG9p0lCJilMskgzfq7MNNKQiFu0bKG3eQTjX08mZ5+OExpF5MKUD45/qJ qaAxxKrEAo1fG8SVh9Tiy4Rs/ECi6HJQH6nwXsgLZT2EgpUQKdCbmp6hsy01Bh2hiNLu DxrVNopFOqpu4+yoxgQiRYp/S478yTRN0ljToAsHklJmIleEu6KLlf2H5KavlBSe6lCm 7A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc84t5hkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:41 +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 29Q34gvI010994; Wed, 26 Oct 2022 06:30:40 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d9ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HE9dsZju4BtzTqhbvNZ8G0LKnPI9Nul2XMvuDpG57w3aGxvVAU4nUgu+rk8zDkiX6/fP6qHIPgPHLlyRyNK8k1CtL9F7I/EGyXjAJHgV6oqS8RJUKbPlRXVzohFgBCG5AjFttjutRTzXZOxeDeoOdqDYqvc9A2bgCtm4Sy06GvZKf2idXbUdkh5A+PGzEAw1HZ2uHR9OWOxWpNmOK+FrrssjCm1MID3/pTkJ4uWHJIXQGx4E6F8UWow8W81maN7Z6VIsHhwHPvrtPWr2hxy0QCaJrzRtlN72gCZWUkIp3lSc1uadV4Cm8RUmkpkgzgLDqEC2czVS12TADwHicyfqRg== 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=NjxfT+4hP3AkeMAgzD48cuao+Xuwe3WArOID6uTy21E=; b=OI1OIbaiFaXGY32aUd+n8AqbVo3UYfbQ4/Hy5IhBDy/jnn90RbHchtiwxG9Msc5sNhGMOXCaqeEbOj8lbqiG//ZfXEsinXv9yxGs09MNEWDCos0gRkVzP3xgNqnvkAp9qwYGXg7dEtb4ySRHXZ7b7n4CCGGaE9c5uMGiAlOg/AuFmlvBHc2At6sB20Q9VmsGbZ6QeXAJ0SkDHYVge4pOffodVRuNzK9SVe6jm8GbN0vngQY6WzO1LFznMfq01PoZYWu1mCuR34j5mlrWRsRkEEGst4ZiosQB3VsIcrTRzS0rfuYtMOeOLz7VRpCUjqEtuhOOF/UY3rLXvcUixnhL+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NjxfT+4hP3AkeMAgzD48cuao+Xuwe3WArOID6uTy21E=; b=qifRlXC4y1085zS/Q5v6uILLZUUa6XeS/rU6udZFPO0WpoeHXqCJqgRn5zL96TQWC67Mubxw5uGdmIDL9JPvokVbEEBLsTbrBRUJYApfxQs0+/3tFuXb08B6KbBqycHY8TJGsxUzH3TWroX4vo224glWHQKEn6TmaAQo4bmqkS8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:30:38 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:37 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 17/26] xfs: Lower CIL flush limit for large logs Date: Wed, 26 Oct 2022 11:58:34 +0530 Message-Id: <20221026062843.927600-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0079.jpnprd01.prod.outlook.com (2603:1096:404:2c::19) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d98f35c-30a2-409f-6fbd-08dab71b9869 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dGmWTg99axCuwPZBNH9c2r+pOqwBHmQvexPm4Mv/sN47l2s0pZCQpN0rPIlG6fnQGp1UYBQUNHpaXc3xWvYQ3223YsrGGKoOrMn8N1hvcM/QdbwLJbL19hg50EAnV3V0E9LE0tYPFXT5fc27pn13ZgwweCYMg8TQLMW0mV//ifcol5+p7Vehj9sfJa+XCWemWtPxjs6RBTdUh06CGjaeKSuokL2wmZZ5V0SJFOKN8pmy9GowoFuneYrMzWXVbm0zY7SskyOyC7RqyoQn9BRruZVATo3g3/3OUvdHoSaX4DFT8bJa9udEfrZKt1UL1trNPyx+mURjC+Vo4RjBJWNei8ie+7Egn3GlfS1KEngysdg8U2odzRRj0omWUfoinYZ2gBHZEvqyAtR3nvsSOz3tUQsJfFD7gr9zhb9a4+Xj/oqFtZA2fR6fPcIaDT0n9iamOSFkNYaV3+Q04Wjex7lcSHPTjgTcmCEogDxzUgoAue8IBo2GtHkqrx3NNyr6pyZ+nGbA67jnYNjiHdr8oABlq5f6uqkYPL5wB2JrgBpkGSOc0HBcRX68/9vtBykN+pzyjD4CGy18EREHNPSkKxwROj1HiqLot7ny/lGKP/Z2RhfxmTly8N6Px094LJxw1FRogPpP/DK840TLjAtk1vGwo4/joOWY4Z12bsZ8HZ6oIMzjNg82FKtiISIkcqu+romQf0++jC2ce/mC81OTyiy41A== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g3QgK+BEdmbwWhAg0x4KPpFvhNzuw7y5NHL/vBAjpZ4UJcmAC0v9VaKGCxMiiRsXQm7NrYaGqILk4KDqrEz7MuPNYYpD/iQn+z42Q2CaWYpknE1lYuevPzT51Bz6aG96OumvQ6wq/eraHhDXycAJf1y+cY1c2VBtwsSDyi41BkJS3JsjT86UJtp5yLVJmsi03uzODCwzEIX9FWsCvZVB7c5qvzhWliWU+s+V5u/Xvpp5Eykp7LIeuMIMahSOPDY/4NOP3qJS7HHEuYuv6z44En/nCkoDq862CSV6GZSWwWLKo2VliEnQRIaBlg2brcIV1UH+gzxNeAslQyJzKjknGVwwMhQqqwyaewzoHOya/ojHPJy1t5H9C6eQhgEjZNaKdxoebyX6dNFIQpgZ67ceNOAeZDU3yjqKwIG30u4HOe53z9lbsO2gd04Jcg8Iem1GQ+r8pIgsqoWjMazlQko86VNTB/RqdcFImC62kiy6QfZNfqwmXhZFCvwNNFum8hm/p38AcLqtDy42WbpeheaMC6yYp9VqUINVHkqTHSFP+9f3xfL1xCHjy7YSLChQdRu58ZqBe/CjiRkfB/4VJ2XLkka9lPY1/KCakwzF+6TWZ5/htuUaUUXuzJfnx7mgcNrucpsq+WnKaFNzUJH0lcCTh5CBrID4Bkaa9sm9JtU0WKMMIzMkJoYh+SzR9LBk0bASQ9QTkWDz6lqhXvmoU96m5XRV/cRKYdvbs3v5UoG5G6EFIEKD/1WbRd4yPZLhhUXkyxZYdXNbnu/n9oDqMv7ftAhsbnD62y+rMgcGKOA7XmbSv9svC93n8rdCZqimzGHF/GGr73H7OSknzCyCNjSrZSD3AoNWC545ouHy+Q+4QB94vnFa2kwVPOQlValGWv3S0E2KWRi4FcB65mgIGCjW7Zdl2m/iqSEirx4eaRT70dV50hu+D3/OPWiL4mcp161tFwlXrU1zb+VSNvH5p24bbw7O4yzc+LTr8J6mwnwdlxekymEwRrZdtU6djQEiT8GOiNspiiOI0Gmjgln2xznvs5D4cSW5VTax/odoFa3PypXxO4qiToomRLWWcpVkefPKXD8vbi6bEppqejlNf1O/EpKFhCAFKrZntU8ADRlo6kfBtyYENnbWdmkHTVjjG3gGD+sXzqUq0lW9gNHA1ld5IQpRtL1pxcgUnKb14lrXl7//NgKajBtek6LuPLoZjHW4u2VsjbWb3zHfH9jbxNvbRHBA5to4x5VcyXJaofwRAYHx02c4DQlBPfNSfYoTqVY4PMUqdOXGnZwUloX39un6SyHFZcNf2YR0K9Kosqor5L3/NBr9QO4nm2E3hkullqRwOohhvdqsodDyJ+UL0JKbWpwTdluOV6SiharFuzmPSt1ifHTikU/fVoy/zYhbGO6AE9GJEe8KTMBGGmujSJWj9NdifkA1kCjlSQV+NXvP12v4LpaSYFS7Hl0CKK5i5EzjyBZHUKd0PnVKB3RdtbDkhicUyzodRTTNSqVTaxj4vpScd70B5O7wJbCecIWIrOhLdjkmUIxKk2oFkRAP8+d7rVCDZ7CysB86/qZuRFEt9MuQm4DhxF7Q46/uwXfOWhGlJhzVDAbcqMSTn5PpV6EAuQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d98f35c-30a2-409f-6fbd-08dab71b9869 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:37.7736 (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: hFEZXkRpjMkLmgnZYM/BHdw2nkwaKL3lxWH/iLjniyv6E8H6cm6Rw4X4Jl/kZcqztaYbiKjPctlOH7XI5tDEbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=995 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: 5fdl-RRbgHI_0IhMTfjUVclafCDoVg-K X-Proofpoint-GUID: 5fdl-RRbgHI_0IhMTfjUVclafCDoVg-K Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit 108a42358a05312b2128533c6462a3fdeb410bdf upstream. The current CIL size aggregation limit is 1/8th the log size. This means for large logs we might be aggregating at least 250MB of dirty objects in memory before the CIL is flushed to the journal. With CIL shadow buffers sitting around, this means the CIL is often consuming >500MB of temporary memory that is all allocated under GFP_NOFS conditions. Flushing the CIL can take some time to do if there is other IO ongoing, and can introduce substantial log force latency by itself. It also pins the memory until the objects are in the AIL and can be written back and reclaimed by shrinkers. Hence this threshold also tends to determine the minimum amount of memory XFS can operate in under heavy modification without triggering the OOM killer. Modify the CIL space limit to prevent such huge amounts of pinned metadata from aggregating. We can have 2MB of log IO in flight at once, so limit aggregation to 16x this size. This threshold was chosen as it little impact on performance (on 16-way fsmark) or log traffic but pins a lot less memory on large logs especially under heavy memory pressure. An aggregation limit of 8x had 5-10% performance degradation and a 50% increase in log throughput for the same workload, so clearly that was too small for highly concurrent workloads on large logs. This was found via trace analysis of AIL behaviour. e.g. insertion from a single CIL flush: xfs_ail_insert: old lsn 0/0 new lsn 1/3033090 type XFS_LI_INODE flags IN_AIL $ grep xfs_ail_insert /mnt/scratch/s.t |grep "new lsn 1/3033090" |wc -l 1721823 $ So there were 1.7 million objects inserted into the AIL from this CIL checkpoint, the first at 2323.392108, the last at 2325.667566 which was the end of the trace (i.e. it hadn't finished). Clearly a major problem. Signed-off-by: Dave Chinner Reviewed-by: Brian Foster Reviewed-by: Allison Collins Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log_priv.h | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index b880c23cb6e4..a3cc8a9a16d9 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -323,13 +323,30 @@ struct xfs_cil { * tries to keep 25% of the log free, so we need to keep below that limit or we * risk running out of free log space to start any new transactions. * - * In order to keep background CIL push efficient, we will set a lower - * threshold at which background pushing is attempted without blocking current - * transaction commits. A separate, higher bound defines when CIL pushes are - * enforced to ensure we stay within our maximum checkpoint size bounds. - * threshold, yet give us plenty of space for aggregation on large logs. + * In order to keep background CIL push efficient, we only need to ensure the + * CIL is large enough to maintain sufficient in-memory relogging to avoid + * repeated physical writes of frequently modified metadata. If we allow the CIL + * to grow to a substantial fraction of the log, then we may be pinning hundreds + * of megabytes of metadata in memory until the CIL flushes. This can cause + * issues when we are running low on memory - pinned memory cannot be reclaimed, + * and the CIL consumes a lot of memory. Hence we need to set an upper physical + * size limit for the CIL that limits the maximum amount of memory pinned by the + * CIL but does not limit performance by reducing relogging efficiency + * significantly. + * + * As such, the CIL push threshold ends up being the smaller of two thresholds: + * - a threshold large enough that it allows CIL to be pushed and progress to be + * made without excessive blocking of incoming transaction commits. This is + * defined to be 12.5% of the log space - half the 25% push threshold of the + * AIL. + * - small enough that it doesn't pin excessive amounts of memory but maintains + * close to peak relogging efficiency. This is defined to be 16x the iclog + * buffer window (32MB) as measurements have shown this to be roughly the + * point of diminishing performance increases under highly concurrent + * modification workloads. */ -#define XLOG_CIL_SPACE_LIMIT(log) (log->l_logsize >> 3) +#define XLOG_CIL_SPACE_LIMIT(log) \ + min_t(int, (log)->l_logsize >> 3, BBTOB(XLOG_TOTAL_REC_SHIFT(log)) << 4) /* * ticket grant locks, queues and accounting have their own cachlines From patchwork Wed Oct 26 06:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020204 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 BBDA9FA373D for ; Wed, 26 Oct 2022 06:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233052AbiJZGaz (ORCPT ); Wed, 26 Oct 2022 02:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiJZGay (ORCPT ); Wed, 26 Oct 2022 02:30:54 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6317E7B1C0; Tue, 25 Oct 2022 23:30:53 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1ns9c018188; Wed, 26 Oct 2022 06:30:48 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=a88sNMO9jVtT2VZKHh12YeklY+tx4d17Rw198CGCP7w=; b=nTaJZhBtpa9p6HB32XYIAxHn+lWbWkos+ffsCws2o1m9KHUnjm62COU2DcYy0fMiOfzS F1DYXb8zIdyaHiKGnsYxehFi7We9nhCCk4f4EMyOxOgxvA9mTDg42PlXtwXBFJ4GalHG K60RpRcGscF7CfeDIA5gj6oq8n5no8Fee+cMAEbJJpmfEi6Q6VdNySiSgGncvtXtLw7l 2H1+4ah1vv82MTmTSuldc27kd9Y0Ab/7ryqOR9NP87lX6bB+5T83qjW5DXRvxdQN2rCF Id0rVVu7M/H9Z2eVo8VI4vliQjf7Owl3Xt+7fsf6w6MdMayv26/ZwSxvRN2sFxZrJthU Xg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e62m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:47 +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 29Q30Kq8013261; Wed, 26 Oct 2022 06:30:46 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6yb72x6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmWBhnS7c1xd+qKX7wi7XbpvFxTo8RHQ793jb19XuVB5L9546RoKw9YDdpf7jW/G00jTbQXG/Ojgw+dOCEjIkkJZcPWNsXLOa+HVLbRrXNJq1RXd9bSwGNQoAaYEJr7ZxPOH+wzWAdwaDIf9JOny7s7fdA9wplNVP1Mo899azwH/zvDoQ4KdONFHKYfg0Tg0+UnJBOL2kfcJJz56yRfOEqOz06nDeOa9r855xok4RBOH9DMjwOPYjtXb7XarO/xWONFTvc0c8z2KI09Eqj+bKTueW5BTiMiQFhJqT/GfJg0/yz9eqiqBwPYxh989HCNt2IQm/oE2NtcgYvAmUQ4JGA== 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=a88sNMO9jVtT2VZKHh12YeklY+tx4d17Rw198CGCP7w=; b=JodOOGEeKpIbaltigt4m33OepwxfC8WyXcUdXSXe5NKhWdsP8gTrDoq31UlseF3+bftZdKCtUerJ8G6ck9lDKmtLv2iMT6zyBBbKRmcp2410a8RFeuBCG+6o3GwG7hIdfcOcfx3/iLWGAcIechwE3acaMtMAjYq40VZTW/a3b/Lva+3pwm5BBUeGyAh8798ZVvsylW53IGKwzumtBXBsGVg5ZuQh6BmNdZylIBEPvuDkC7WuB+tEVgvoz/6hxsDYuMHUZLOIJ0Dd8oAX+Tr0bTLVAK8gJHXXrl/pawsoHrlICf5+zTP2/mBMHNV70gnoL/3F+m/OWaoPLhmf+36zxA== 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=a88sNMO9jVtT2VZKHh12YeklY+tx4d17Rw198CGCP7w=; b=KQLwkIvthl+ZVRpdPNP5jvuflFOjuGk+wbZWJ6l8Cu19nUt+zmeof7w/gSEK13RqMC4rAHhUOcPn1tV32SpxOdWrhRnzyuAKci2ppVVWKHbdQSvizidHrvD2so70Gwum3UEfJu/iFZAUZTrbr52o+ygHiGmYqD3d3//kANUHAv0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:30:44 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:44 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 18/26] xfs: Throttle commits on delayed background CIL push Date: Wed, 26 Oct 2022 11:58:35 +0530 Message-Id: <20221026062843.927600-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 70a932ca-b247-4212-113e-08dab71b9c36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OtRU63qvCHqw3nQkHoI01UyfjFA1zKcGvMghYqMouWYVw7W+FzdjkwpVMhrdK/atqwLN4TWuAzc5D8TUdc8bv47O0MqGPMBH+InjdBGytSS72fCCx75GFsZKmAedb32Okrz6My4BctQzSx3tGqGU9K8bwdeEStMQH55ZH3soHPji1WBrAp3DAxIU58KUr/wdEPJMKTF2xItiPVKRFwO4V0K4GRfkvncOP2VKqbp4dNU2rob6uQwP9BkZufAxWdbLNjIbt6RKc6IGY6/SoeYa/Hil8sSQJFd4cFg0LO/jQPL7KXm31g99+qYDu0oslqjn27dgi+rwsqRBUVn9UT4hBHyzlqFUACptRYfmCfTvfUoy7z36wHFiVMg/hVKY4zrZh8SNtz3G11FNkY2PH4Q0HK92W1HpbiLerGqmJMW6tzAjkeLbrE3efgFpZwIrlDVy3+D1sP8b8m3KCfJFEN7U5QQnL93JUraBSkQ2vsYQSuL7BqbDm8nL8JjO+MIQ8AyX1++8IegNQ8ZxiF65Qk4b7ljxC/UY08eCXGnWMX9LnwFVKp2C7SkGFNWBthktHbhlBlO4577ooCbCfT7lE4EU9Szz9lArzzKNLk9D9SQBrRzPM1+phk79OLvTYc36dZJ5YYDRzoCtm2M6WiOgvMcyh3NNeTk9pdkuvJkUCxgDcQ8Mdla7/p1qLDAnAy9ewHsj1i56/oraClwOSsRiQjQPnQ== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WDdOYdALoCrfmckf8bHKCZSH+k5Pu75PTBSYlbAbj/BeEonlvMrrh7WVaQ5qcNwoPc34oZw5d1kAYrbhrusaN8zoEMWTXXcZaqGhGNLOsWHunEtFu3RAUOfCTOwl9uJCwj51aV5MXPwzwo38Mc+/JG9d5s5dmAHcbnOaIU9+vIKDwwACWFjzwh6hkDzdx4bs+tlxJ2GiJUsK+utBzdf63Y0aSxjKblvPfghEvXRM/rH2n9rAzy26Z38iNaqUULHNSehyKYoLO6SLdIk0hwaNzmLr7qQCq875iFDY5akCKifuTsJgXDt1C5Eps7hGQ7czyaibxwhhOxxPw4LGUI6gtDh6J6Q3F0shWfihh0LThtF8ny2JsjfvzC8RvBCDHnoRdQiZt+vNmdb2BO5ssVxCqahvYxQuXUNLFw8X6DoOEFtQavBuGt+P3WaOk8OjNW0iSsjHE63l+Id/EVuIEy5iekQ3DvhUa2riOyRNhG3FIk8LUHKBucFbBzNSKNtJFjxQdIBwyvFLl/7XxKrdDaTe5hk2Hmz33SI87NfAy6tzAuu5IPt5Izdnz1Zw1Qw13oHgaXh9livQNFwq8YghsxEI0Us4QPeoCLbpIvxGOC0Y8BuCRrP/mnD/3ByiYaryoqOWVNv+1meat6KYCw8egWop81baTS9TAncNZNeKCkgTMkffZx/fdlgPWMEvzmay+5YxW6dff6t5OiT0FRzgIBUkfGL94tby4PRX/AXYlbsflhtSEkOXqRA9Pl64rGue1LCfSJGl4bb+H2uzuD5SbDJmIWc+zKMQbOdhu+mtBBLTjM9kCd1Beht2y+6Oxay5arGiXoucl5FqHl7M/QO7kOKX9R01TAT+5ypsokKVMlwsuDK1xQHjWe3X8JQz+DqHuli3HkDgBvStR+njFoctGdX9ze/dMh0V6QPsSg/gGqwf9GOQ7wl/4ZHqVrrs013kSQ/oSkHiB4K8Rt8C9HeSKvvu2FBxu+Nnd4SeZGSOIyJVM8aotVowFDcuOiJAH7/221QoiLKB4y+UrN4O55r4kdx+Fxjpyp2hQUWVjIDI6AgEL1nagsg4OQ7zlzM6V36Ms4t6BB+kHnRY0E/zYGzKVZvjYBxCpHkgx9IrH/xOhyytROUOyZLCWmbbHuSI/gBFfrx3mteG4Wz1Ag3xU/U9H/0jKxTHO6xgpm2s+7FcKMdqIDupAPbEwdgRng4pGuepqxHaf0aEC93g/51UqpbfFtPpGWC2cKcXBMPIJsuWuT7hY/2vOgSPnuLt5xOe2NPz4d1Kteg53iBe1hHqtGHso8QB9mIHvS4Kqirc3FPS/ZOqXlQkBJ5MiYgTiFs2MoDcMfSfDtixqmQj9Ppceuz8yjrNNsUjdggce9a4X2Teb7lSvHgzXmmpyLF6l0SZpqxSiZrsO59WJZ9R2k5LezihLo3AQOCs51KayAjfvQXOw94d6yc+o9C0ig5KBziigpZn4tiGu7VbH6qLUEajRAmwu0sQ0TjTDdCDwcfqv4XHgkyXqtLFUsonpCj1ApQgmZmh5Bvm3XrvVwOLvFLmU6tKAl1inHChu9lYnEbb9ITFAyubeZPy7hogyxs+MVmpf+p1xOGhuocYPpiM5SYiRlqmXGNLEQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70a932ca-b247-4212-113e-08dab71b9c36 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:44.1791 (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: 43YDxswYOTtrwzCiqFgGdcen1aoy+JXOSg6kuyQsVRM7ckEqQnCat+zRemiIQOiuQNsBIfsZuA96h4oO+wAv2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: 865nyakOY5DZ0omty1I4N-xdaFN29hU- X-Proofpoint-ORIG-GUID: 865nyakOY5DZ0omty1I4N-xdaFN29hU- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit 0e7ab7efe77451cba4cbecb6c9f5ef83cf32b36b upstream. In certain situations the background CIL push can be indefinitely delayed. While we have workarounds from the obvious cases now, it doesn't solve the underlying issue. This issue is that there is no upper limit on the CIL where we will either force or wait for a background push to start, hence allowing the CIL to grow without bound until it consumes all log space. To fix this, add a new wait queue to the CIL which allows background pushes to wait for the CIL context to be switched out. This happens when the push starts, so it will allow us to block incoming transaction commit completion until the push has started. This will only affect processes that are running modifications, and only when the CIL threshold has been significantly overrun. This has no apparent impact on performance, and doesn't even trigger until over 45 million inodes had been created in a 16-way fsmark test on a 2GB log. That was limiting at 64MB of log space used, so the active CIL size is only about 3% of the total log in that case. The concurrent removal of those files did not trigger the background sleep at all. Signed-off-by: Dave Chinner Reviewed-by: Allison Collins Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log_cil.c | 37 +++++++++++++++++++++++++++++++++---- fs/xfs/xfs_log_priv.h | 24 ++++++++++++++++++++++++ fs/xfs/xfs_trace.h | 1 + 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index ef652abd112c..4a09d50e1368 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -670,6 +670,11 @@ xlog_cil_push( push_seq = cil->xc_push_seq; ASSERT(push_seq <= ctx->sequence); + /* + * Wake up any background push waiters now this context is being pushed. + */ + wake_up_all(&ctx->push_wait); + /* * Check if we've anything to push. If there is nothing, then we don't * move on to a new sequence number and so we have to be able to push @@ -746,6 +751,7 @@ xlog_cil_push( */ INIT_LIST_HEAD(&new_ctx->committing); INIT_LIST_HEAD(&new_ctx->busy_extents); + init_waitqueue_head(&new_ctx->push_wait); new_ctx->sequence = ctx->sequence + 1; new_ctx->cil = cil; cil->xc_ctx = new_ctx; @@ -900,7 +906,7 @@ xlog_cil_push_work( */ static void xlog_cil_push_background( - struct xlog *log) + struct xlog *log) __releases(cil->xc_ctx_lock) { struct xfs_cil *cil = log->l_cilp; @@ -914,14 +920,36 @@ xlog_cil_push_background( * don't do a background push if we haven't used up all the * space available yet. */ - if (cil->xc_ctx->space_used < XLOG_CIL_SPACE_LIMIT(log)) + if (cil->xc_ctx->space_used < XLOG_CIL_SPACE_LIMIT(log)) { + up_read(&cil->xc_ctx_lock); return; + } spin_lock(&cil->xc_push_lock); if (cil->xc_push_seq < cil->xc_current_sequence) { cil->xc_push_seq = cil->xc_current_sequence; queue_work(log->l_mp->m_cil_workqueue, &cil->xc_push_work); } + + /* + * Drop the context lock now, we can't hold that if we need to sleep + * because we are over the blocking threshold. The push_lock is still + * held, so blocking threshold sleep/wakeup is still correctly + * serialised here. + */ + up_read(&cil->xc_ctx_lock); + + /* + * If we are well over the space limit, throttle the work that is being + * done until the push work on this context has begun. + */ + if (cil->xc_ctx->space_used >= XLOG_CIL_BLOCKING_SPACE_LIMIT(log)) { + trace_xfs_log_cil_wait(log, cil->xc_ctx->ticket); + ASSERT(cil->xc_ctx->space_used < log->l_logsize); + xlog_wait(&cil->xc_ctx->push_wait, &cil->xc_push_lock); + return; + } + spin_unlock(&cil->xc_push_lock); } @@ -1038,9 +1066,9 @@ xfs_log_commit_cil( if (lip->li_ops->iop_committing) lip->li_ops->iop_committing(lip, xc_commit_lsn); } - xlog_cil_push_background(log); - up_read(&cil->xc_ctx_lock); + /* xlog_cil_push_background() releases cil->xc_ctx_lock */ + xlog_cil_push_background(log); } /* @@ -1199,6 +1227,7 @@ xlog_cil_init( INIT_LIST_HEAD(&ctx->committing); INIT_LIST_HEAD(&ctx->busy_extents); + init_waitqueue_head(&ctx->push_wait); ctx->sequence = 1; ctx->cil = cil; cil->xc_ctx = ctx; diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index a3cc8a9a16d9..f231b7dfaeab 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -247,6 +247,7 @@ struct xfs_cil_ctx { struct xfs_log_vec *lv_chain; /* logvecs being pushed */ struct list_head iclog_entry; struct list_head committing; /* ctx committing list */ + wait_queue_head_t push_wait; /* background push throttle */ struct work_struct discard_endio_work; }; @@ -344,10 +345,33 @@ struct xfs_cil { * buffer window (32MB) as measurements have shown this to be roughly the * point of diminishing performance increases under highly concurrent * modification workloads. + * + * To prevent the CIL from overflowing upper commit size bounds, we introduce a + * new threshold at which we block committing transactions until the background + * CIL commit commences and switches to a new context. While this is not a hard + * limit, it forces the process committing a transaction to the CIL to block and + * yeild the CPU, giving the CIL push work a chance to be scheduled and start + * work. This prevents a process running lots of transactions from overfilling + * the CIL because it is not yielding the CPU. We set the blocking limit at + * twice the background push space threshold so we keep in line with the AIL + * push thresholds. + * + * Note: this is not a -hard- limit as blocking is applied after the transaction + * is inserted into the CIL and the push has been triggered. It is largely a + * throttling mechanism that allows the CIL push to be scheduled and run. A hard + * limit will be difficult to implement without introducing global serialisation + * in the CIL commit fast path, and it's not at all clear that we actually need + * such hard limits given the ~7 years we've run without a hard limit before + * finding the first situation where a checkpoint size overflow actually + * occurred. Hence the simple throttle, and an ASSERT check to tell us that + * we've overrun the max size. */ #define XLOG_CIL_SPACE_LIMIT(log) \ min_t(int, (log)->l_logsize >> 3, BBTOB(XLOG_TOTAL_REC_SHIFT(log)) << 4) +#define XLOG_CIL_BLOCKING_SPACE_LIMIT(log) \ + (XLOG_CIL_SPACE_LIMIT(log) * 2) + /* * ticket grant locks, queues and accounting have their own cachlines * as these are quite hot and can be operated on concurrently. diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index ffb398c1de69..b5d4ca60145a 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1011,6 +1011,7 @@ DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub); DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_enter); DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_exit); DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_sub); +DEFINE_LOGGRANT_EVENT(xfs_log_cil_wait); DECLARE_EVENT_CLASS(xfs_log_item_class, TP_PROTO(struct xfs_log_item *lip), From patchwork Wed Oct 26 06:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020205 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 6127FC38A2D for ; Wed, 26 Oct 2022 06:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbiJZGbA (ORCPT ); Wed, 26 Oct 2022 02:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiJZGa7 (ORCPT ); Wed, 26 Oct 2022 02:30:59 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF32836EA; Tue, 25 Oct 2022 23:30:57 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nQql030372; Wed, 26 Oct 2022 06:30:54 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=tvQT97mwKXAG3qEpqkQf8PyOnwa6+1aICe+SmpYulYI=; b=sf3bHUbcr5EneI8uCgKhAU0XDI/qGWjFPLhWP13Fam00OOgsa3JzyD7EfIE7/azfJBtD n6t86GL5i6G081GZyizgUm6xnzF1IPnx8KFXI7Q3kqH2Z08fwSmHzJYGBQADokarSsvw ZKCH00z2h7z60KBM7gmDmBAk0wQ+mthcy3sW1uQ4nrHQDExf4jnDyX5Y0KVAuCH2aGF5 +wVJ0UBtiIBxlUz7wRmjGT+b6gfjFCxhD7NsIXyUQXZmTdp74cgCEJcGOAG/D6ktF6l+ BIWrDhJS7ROB6xyvfEG6B0X4QjFzVP5tf5b0P+Jy2/OJqsHmQw0ViZnzpXEueqkJVKhI 5w== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x24w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:53 +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 29Q2Sajj013253; Wed, 26 Oct 2022 06:30:52 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2047.outbound.protection.outlook.com [104.47.74.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6yb732w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R+uDDqbrR9u2AFdgu0AbQFroXhFPAr4r//SQamOZssyh+IBMYPZno8jmXxGEiQknTPmlyC84MAhVuyEnJFeGUplTPnZx1vUByeG3oave5uJllNFtuKi7vaFVKpH5i9yw1CP7syvSVjzOPkR0aP07YH88Nc1WvCRGmMdj/9+ncsmW7ZQNXjxpZYAYdS7iiMET94YwEI7NZ7blDbSdaCiWGGiAtQAPFP2lX0CZvOcZ6uPiKwUvhwzXuHyzEMIZxqzYBG3HPk3rKtTRtVltwXgNpCfs6EYvD0kDpuExN3y5whcqVmiy+z7vQu8XJJP1+XDOuaEbLnjT6FE1ixjQpVr2uw== 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=tvQT97mwKXAG3qEpqkQf8PyOnwa6+1aICe+SmpYulYI=; b=B7R20wzEdvrhtmhCwp+yAsG10Jl+UyFUqg+gqMBVyTT5g3M/S0oMFsbjffLeYExv6q7+eLrITV+V56qD2NDX1OxjWVTFmlUDi/V/EVf+DGp/K0Q+BFBgTrhJ6sKh2cHxQJq+n4gD+mlnSq6DG7HExjlmvETfePvTl3hGzNm2+ZIu64VF71vNo5MAWXUDCYXwH58/ztaLF26WNxFEQ75ZgmCf9WbAESKyZXjVaNCgamENKyl5mABn5riTxstwttSWUCaXd0SRRaJRfjXR0SUQfcKFwEFl60+nbwgCR5mIGWNCOZf7Qo8ZinkCs2w5sTZX86MoBj9iD4+KQkrGrsuSRA== 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=tvQT97mwKXAG3qEpqkQf8PyOnwa6+1aICe+SmpYulYI=; b=B8e8NIIv+5hNUI5M9pJLo0HvFiLiYRhnoSwKTPD9OKVcvskzeFNnH7fRwzyRSS56mB5NmE5RJGwGErCPoD4uEYi5ai6N1jLiK+BEDtnIi1ohCnzEjP3peFcik4VZnCEFhYy71HAE6rx6of2E0n6+Eav6yBHzumU/0p07YSG9Xjs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:30:51 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:50 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 19/26] xfs: factor common AIL item deletion code Date: Wed, 26 Oct 2022 11:58:36 +0530 Message-Id: <20221026062843.927600-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0038.apcprd02.prod.outlook.com (2603:1096:4:1f6::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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: f31a3192-5b98-4e02-72a7-08dab71ba029 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l9LyPvhwGVFuecnPD1lMRqm11SdyodduhCJ2jQiRy+0Hq5TWLZKy3mrUXNCMAhSY/eZdOwfIcZbHN1VznnqJ9KUG+7jL/m/yFsni0uqXQcEkT2CKKQvrfhx1HQM38SZO2cSfDqjTJMFomz6e4LQoWiYwhjfhp6PVaV7rDB2IQqvQ6fUur4HSw+4g++ZhFa6NxaZMjRaf2jfOnPUpr9A6q40JrNRSYglEzqCyAPzPygVxnhGCRPr4m21lARTCA7DWwOoflbWKYQ+qyLmebZp/IeQGknxoh0LUIBjrbenL8F4r8xs3OQCrmGqx14vrAZwfLDsv7fWLebA4aEAJNIqDxEoMITpcAvhaKNZtwnRguz2Kmr3oe13i+dbqypabyEVySnGZ+lW9/i2jJ9VgJMVomYQk1AnNoucw+f+VzfQRT/lYeZdCo9CLTe0+AEq7aZr5+0VXLW4ZHYJL+rLZdxTfzHKnInWTw/k8bBUcLq2//EMg7zEtdPET7JEHYAxJachBXUEFUX5za3qovLVbkwhvZMqtHNHBn0mY5aSdaPV+TG/CUnTwAHp0hG/yhdEwhBHrqoSVt1qI46LMTwNncEvIMOmJHYqr5DqCQ63sqVpQ5cKPL47ApTbmJx9yRD086UFg9m15n3A0IhVML6T5TrHZuBC9g/Paxxgs0hsXpWuwmd8i3D2dEJNEGiZaa+7oGpC29/VT9R4QIyGPGIFSef6VZQ== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DNi3QGeYtn597WG4XVAphofYcpPGkqGThSBTGMDihSLFvqrkFYt6ja/yHRNPAwr6PNf97ghXVwtFBjv/wXjJmMwU5asGer631EcPKifmIUHsXTwrH0je8zO+Bhr+5VB/+lOnMtsO2YxjI11irkUkTF1vcIDcQo41PGXgdzAbSGDlSdJMIMuICjEV+2xzZig6FnIWpVc2MqBy9FJhVjNs1ZpaJEOsTHmhhso8FO035HGmkE0u6skc59yWztiIQYsxbl/1SdzLJNe3CBRN6eChjqPVR0uOTBNNZYNNNE1VSKQirLsuJcaoF+D7IvH2oMUZiZqDqrjtEEtCuwm09zK0uIDw22SZZ+KHB6j5B/sayMr3On/0ZV1iB2Ujpm3u7lmLfusOqGZy+jJvoB8RG8DUe8+Jwjo8wU76Zk5ejdmPRPK3f7Iub+5l6uKrWVYb6wryw5ggg1a2SBkYf8V2cOr6088yehjA0pW8YsAgB0pXRB8Vjf+/RyvW5SqmhoN5hdsUpCLOE+Y9Xedo9mI1j7hCUoHpaVHtATHFO5ZXENy6k5zBC6gYRf2CgjIAF0ikJsoBTTHW/oA8J50zqGBKoOFGTmmIpSoBu5T3O6CsMW5ZGthJV42eRjUTV93C3gFZieRA0SH8YzQbh5l+yHq3U5xPsyctOAuUJ/Ru4nmip7MFGoSlfu3cwb6jrAyhemuII9etj9Dd4+4h0PpX6B+W1l36ieryCKrO1gJMNw3xfqllSmYFLgMdrvOamVKlosDIKA1GawQKym/C4ZqV+pENfWJ3qTZtTjm2EMd2bGwimWqs63Qly5nfrhabXveNpRK8/b4bkkvagoSnkxLVr4wnFUzsnMB3PEw2xfbyuF+oDcPU+5ZEYNCNkz+7B1Lm5ruMVY+mFImn7zPMKhqRCHbEBcdK5KMThbxS0Bg1olcLdSU6XL1WmAK/LtHcVSj6G/wnYEW2e1ROXXCyWwn+7gKDdKBzrsYQhbcxffQSBB8NMiaJNJ7+Iv69KSjUz5a196aYu5xvb9s9/JzVkLrhyQC8npf26JJqHSKdgLl9IUCEvEQeBu/1DvG+168wTQ06k/HSaVcXkClHGWjj8UBcN5iKVM4MpbTzb2meJsg6P2jAGu/L7neT1D6KlWQfJfIt/OBZDQfWgpBODgfEoexVpuNsjcnptU28Exy7lJrk4/K9OyfTcTjccAK38hcpJ/kb3n/3nJAbUJ9aAXN0oKKHs/Q+11sBdwSarTk23uwdY1/GBgGX1qPNulyZzo6OwuufJX34t21YOu6vSZpBAON2ewW7cWyd34Sraj4NKAjq8qN/zKjgOoUpObfn/c4mX8QytPPhpmC+zRf2lxIHDpi0hY9Pl6cBMB8zFK/sfT0iRYVStRA/AnW/WMS4hLUvuM8Jy56KKBGC1scLNCUQJySvCxtxNFs+AjdFAHktEczELLzFWvb7y8fz7uXozPEnv44KwzBbcZCk6krPZB8PFo+QGk7UMa4zDX3155C9BbF7LxXbeaz+18mrm5FdwaHM125CF4ow6UlbCh0sNWamF9UnAJZt827KKxz4Hd9kDKgsM36A8D+LwnIwLnLFonDq8hcvgM+doR4tK1TZjw3LA4VcN644KTbfpQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f31a3192-5b98-4e02-72a7-08dab71ba029 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:50.8229 (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: 5HP+nJSJOx70x5NHU9y1+/Jp7V+xuSKn45RlukULTh7b9h3xJ5MA/WiSkEs7hOMg7SAOz1InQV0HIf0rL/RaRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: MLRFa2E2QtlpZdmFzyIITH13gmcHjSm7 X-Proofpoint-ORIG-GUID: MLRFa2E2QtlpZdmFzyIITH13gmcHjSm7 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit 4165994ac9672d91134675caa6de3645a9ace6c8 upstream. Factor the common AIL deletion code that does all the wakeups into a helper so we only have one copy of this somewhat tricky code to interface with all the wakeups necessary when the LSN of the log tail changes. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Allison Collins Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_inode_item.c | 12 +---------- fs/xfs/xfs_trans_ail.c | 48 ++++++++++++++++++++++------------------- fs/xfs/xfs_trans_priv.h | 4 +++- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 726aa3bfd6e8..a3243a9fa77c 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -744,17 +744,7 @@ xfs_iflush_done( xfs_clear_li_failed(blip); } } - - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount)) - xlog_assign_tail_lsn_locked(ailp->ail_mount); - if (list_empty(&ailp->ail_head)) - wake_up_all(&ailp->ail_empty); - } - spin_unlock(&ailp->ail_lock); - - if (mlip_changed) - xfs_log_space_wake(ailp->ail_mount); + xfs_ail_update_finish(ailp, mlip_changed); } /* diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 812108f6cc89..effcd0d079b6 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c @@ -680,6 +680,27 @@ xfs_ail_push_all_sync( finish_wait(&ailp->ail_empty, &wait); } +void +xfs_ail_update_finish( + struct xfs_ail *ailp, + bool do_tail_update) __releases(ailp->ail_lock) +{ + struct xfs_mount *mp = ailp->ail_mount; + + if (!do_tail_update) { + spin_unlock(&ailp->ail_lock); + return; + } + + if (!XFS_FORCED_SHUTDOWN(mp)) + xlog_assign_tail_lsn_locked(mp); + + if (list_empty(&ailp->ail_head)) + wake_up_all(&ailp->ail_empty); + spin_unlock(&ailp->ail_lock); + xfs_log_space_wake(mp); +} + /* * xfs_trans_ail_update - bulk AIL insertion operation. * @@ -739,15 +760,7 @@ xfs_trans_ail_update_bulk( if (!list_empty(&tmp)) xfs_ail_splice(ailp, cur, &tmp, lsn); - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(ailp->ail_mount)) - xlog_assign_tail_lsn_locked(ailp->ail_mount); - spin_unlock(&ailp->ail_lock); - - xfs_log_space_wake(ailp->ail_mount); - } else { - spin_unlock(&ailp->ail_lock); - } + xfs_ail_update_finish(ailp, mlip_changed); } bool @@ -791,10 +804,10 @@ void xfs_trans_ail_delete( struct xfs_ail *ailp, struct xfs_log_item *lip, - int shutdown_type) __releases(ailp->ail_lock) + int shutdown_type) { struct xfs_mount *mp = ailp->ail_mount; - bool mlip_changed; + bool need_update; if (!test_bit(XFS_LI_IN_AIL, &lip->li_flags)) { spin_unlock(&ailp->ail_lock); @@ -807,17 +820,8 @@ xfs_trans_ail_delete( return; } - mlip_changed = xfs_ail_delete_one(ailp, lip); - if (mlip_changed) { - if (!XFS_FORCED_SHUTDOWN(mp)) - xlog_assign_tail_lsn_locked(mp); - if (list_empty(&ailp->ail_head)) - wake_up_all(&ailp->ail_empty); - } - - spin_unlock(&ailp->ail_lock); - if (mlip_changed) - xfs_log_space_wake(ailp->ail_mount); + need_update = xfs_ail_delete_one(ailp, lip); + xfs_ail_update_finish(ailp, need_update); } int diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index 2e073c1c4614..64ffa746730e 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h @@ -92,8 +92,10 @@ xfs_trans_ail_update( } bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip); +void xfs_ail_update_finish(struct xfs_ail *ailp, bool do_tail_update) + __releases(ailp->ail_lock); void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip, - int shutdown_type) __releases(ailp->ail_lock); + int shutdown_type); static inline void xfs_trans_ail_remove( From patchwork Wed Oct 26 06:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020206 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 BF231C433FE for ; Wed, 26 Oct 2022 06:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233146AbiJZGbI (ORCPT ); Wed, 26 Oct 2022 02:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbiJZGbH (ORCPT ); Wed, 26 Oct 2022 02:31:07 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495528A1CB; Tue, 25 Oct 2022 23:31:06 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nFTs013699; Wed, 26 Oct 2022 06:31: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=JrXKkUmxVHaPEkFFh48ZrH51Yr9psUizxhiXFkwjZ0A=; b=u8tmmLtADIass48SGHQi3xZmV22Ftdg4P1nUYna+PS/EkmLZqAq4dJ23FwYfweZX2oER vTYGJWJcJ1rcG/ueER7QsLNA57SOKgW1Z8nP4Dp3JJ5omDo7eSfRzyoOEKPug9EDGOai JzyW4HkoZG5J6ZH59UadEMXB3uM4vz8CNs5oWSQG65IagvldFsUgo1ATqrhp8DYfBsKX ESd4+LKefcrJu0EgIppVVcV0qm5LmwcEP0WDkkh30sialoSBYyia+nTka+sptEEkgPik QnuhuveuDs9VtuFSYT4c5soEOh6n+VgDo3znuAGJnlewv2+XzIH8xcQPO919QqCHnVNx Lw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc84t5hm2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31: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 29Q2wgBq017877; Wed, 26 Oct 2022 06:30:59 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5myaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:30:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nXIXBTy1WMzKwRB57l/X3vj67yv54OV3dopCnN0E10MOiMEk7A1TksHCfkCQh6nJS3wvAZRQ4kSGsne+a3uciTSk8LgzaUeQpeSO1dBXy5FzYBPaGHR1GYDIuoAJZMw8UHyY6XVJ0Jj3yiHq8oMcGk14y281VLIHGMPZ8nm3ajMewh76Ci/+XHAGpcZqjOXJFTPRCmvT6czrvReU/S+i8RGZTIn2x25TgC+AO4FWyh7cApovezKeSHEE+ClVGHicgRk0NvBFvNZXVFHvl6Sp12J0/7CIVoLqvo2ENyuPOfkV+0HjLKlBy/+Bwp3GjCvungdxfCAmbBLunYfzW7Zz3w== 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=JrXKkUmxVHaPEkFFh48ZrH51Yr9psUizxhiXFkwjZ0A=; b=ICuxqeev5WyVOkjl/dGcsCdrWJGNzUY7h/gJWW/tpTNtFmlta98+0GKirxxUh3jLj4hgH10wAh4Ldfytf6T60eSn6S2mY25E9jxKP155TL5uvbZ724ocuwOjlu6lmFHhT3CRCtEs/7ufJpFwsO8dc+EQs+c5CRTWff2G28Mc7IxkE6Kmn4Mizg0hzgeEO/O1svNf4O0TteMpYizcMuR1eLEx8/uA8cHcKVvc4LeL7in4yywSGPiyo6QsRIscCj3SU3cMCClBUzH/EBsiErWLHsGIv4J9+10hBgnXtTBShItJPBXXzqt6AvVVhDShnA8EeQwmsaO1jHmtuzgrVeEqgQ== 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=JrXKkUmxVHaPEkFFh48ZrH51Yr9psUizxhiXFkwjZ0A=; b=x6h1fst5SKP/wWbMX0GyoldgPJRaCqFaH5JE62Xn+/N36bxU49ITc6lURRk+CaWBdIo6jm0jV9nRttNZD9eTiVN4kOEMBNiUYDIttyuPnpEpzZSS8yRBjvetjsg8gXMWw/95Pc5uYOb2VE7i3CuV1UR27PsLDs12PclqCdZFgjw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:30:57 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:30:57 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 20/26] xfs: tail updates only need to occur when LSN changes Date: Wed, 26 Oct 2022 11:58:37 +0530 Message-Id: <20221026062843.927600-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0018.apcprd02.prod.outlook.com (2603:1096:4:1f4::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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d06e210-f565-4620-61d0-08dab71ba421 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Co1rZUfCHz3MfKxot42jiVGy1jryelm/v/+mcSHDzVM3iElRXmKx1gqOv98+anShHopnfuvn31fUt/pNQFfuLpliQHIFWg+0qid0cB0gK8Txp9IH/hQL3PD7Y2LLQ1PBNYAX6bJdkzu52enIyg2kW4XGgcTSewPhi0UswmA2pjouDNniImpMKIDbLMVVn+sllkslITDfjZwAYJ3IQk5byCd3sF5npr1oHLo9xNT3GUgegjJJO9Mr3mKFM3wnR59pQTqaPKLZIZLKJjeh8IUQrYR/ZWg2K95NUNWZfk/NeXgZJJMjV0Vq6FteYiVsPqf0U37m/VMJIS4CJQMpMKG6gyNgFNptIL0xqcyk2FQs4WupovjFhfa9TdegWm1PWWe5NVxwGgjqUfcWmZgN+zLJGR0wRRowqHwA7LnZE3fSHkWVC3/pFit0U3i/S9BgwM5AUvN8kKxaV9MepIlpnfkJRxYznsW+q70bPGcmTWgneY2MOkucQ6tGKk5X8Sbweh64HBqH7QengxQI1yhQftF75NOaqn43KnEuSzNlpNHnXI3EcgjdquVJzh6Cc8/L7GOnUlDIRucIDnJ1SiVMk0+bEzvOJOBv4KnIUYKDwNEOu4c40XggJLlmDaTP0eIPLzef9dgQFu7rD7TdUEF+5S9B6chtLz6zjOOMkDn49GyUHRK7Bh0ANNIev1pluX9IsUlN9mChFN3ir3Ao1j9UrYLuRw== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(15650500001)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IEfDgNacc2yT/O+xWyrB4DxWxi0nqJdK7nAl//GpQAIWiFBboil5u5Lfng9WRQd09GgctQgwUB9LGN7anWgHREqaWI2QTixxR7ggRLfq0o8uUPiSiH1XJH31P3s9ZGRPgqxJzn/8ODRDdmdihSf6HL6GigHmb82m1iyRoo6cKEnoMB/hNgskyKote+U4lun7nvtvcT5f6jmt1vg3NygOfkRD3Pmalpy1nJEBeWtWh/XfcxJlZudpNJqUHEYuX4fDwKN4oAGpBt4nR/f5o150RmR8BBqaLQgi5zlRRPbnnq4lSgSxxUM5hFTMxmjJg/8WgMtVSUVAGvcGvuaZNjh7AfcM/BzOHXKAgxHs1AWVUPMf32p4CVOwNQ0kAu/Yglp/zOx9CSGshafTaNMC4RnR+apjZi6mdENBYWOGZExrIn8vC1DSj6CSu3hMZZE502+4tu3RBTnSH+cdmV7AEswMOtmYf4g6PsJzYwwHd5u+oDZcJhfYAhkekGwmIhYd/Y/U/dRc/r4Tq/BXinZzLvuJqAAMMl1fsGuNUDNzmfsUop8FOdlN2kZ99sd2czjVh68+bt6sS6Brl7qcK5ktva0jchWgnjHTXPQpc1FyykDtFRoCyQpVAvb+9m9EycbUb7boCogGGcmZtCgdFtn7mXtTQoxwt/GP3IuuttRyClI+i9Dl7zWjVTPhn6r2mcGmZ7JwLf97Zec3VYQhhgW4cxd+n2Ihm3e3W6SVM9AQAm0lYGPp5dl8FkJwhXvc8l/55qs3IxjcG/6mbq1kwZ6kNCuPkE84h60mXTlydwaHRUj4agkiWPb8T16/TBQViqJqFUBDphD57ByyogOPqnyELSjnaVahZaZJK6zECgiWUfAWxOOMHRefpXmO2iPWMcfUTZXbtnN7PZJghzQHScepizApbdgl5gJjQiwUwUGjuCJiQlBdyEty38VcC8pLNl4oTgDObCONKjXmylAZIJe9xpwWpe86EUzX61PP5jSJtKQcBZmJc08ps1GEM3ERXnU2a6+5AlMBPHqjM5pXGgg71Orm8JHiy2eU67jYqSwjKCa0MKMhRcbbX0xprXMzj3CcTYirANKqWb2YyB0PanXzoVttd6TTgvX0gDtjoy5WUcd1S8lVeSr3YpdttDWXEI52gwWEhb/ldQvcSbXVLkdW2Qe1su+YykCn9Mz9I24jqJazY1VfxxaSsymcvjEA2D4w3PcAZ1J99ZTbQ9oOE0Ff8kPQRfGSH16CuKkjnsbAdcSLhNNKq+m0oJAMAi8lBXI5jJ74v7dhAthz/4/6oWURXVQi3nWgyhbBt8pRpRN0T/rEtN7/aPJvHipvVScIFnKDKmgpVgKcptwr2fEMeYbnw0JLes+h0CjCIVbSOlSOCx/Ta8ZaCe1pMHdRAMNkuF8L45TQWfu1rD33ipZ5UCUB+Pv97JU77WH3l8HRlrC8bjxkF9OITdB2PLQjLFbUT0w7AN82qzyRbgsJgDZkFCPRRfdw5k83N3Bu6fjakUiM8hy/BZoN+hk9PVXxxqEyB15wSa0XRJnzebIAjwe2nII1L6BXCE+yLtp22zY6ODShq/OuSeCmvO7Kl6TOpcil5DPpr0znWZ0iAMfnqI3bipRHL5DaHQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d06e210-f565-4620-61d0-08dab71ba421 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:30:57.4823 (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: rcUq/EZMjVXoaYiHWDbSXtmBmMzrpXKXQLG6nnLe4Xsl4wTXDL546xmS4GLvoVJw7YnMbdub3FbejnxWB4Er6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: Q2So1gD5YkYWmloVVObZGMRN6fw72PjO X-Proofpoint-GUID: Q2So1gD5YkYWmloVVObZGMRN6fw72PjO Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit 8eb807bd839938b45bf7a97f0568d2a845ba6929 upstream. We currently wake anything waiting on the log tail to move whenever the log item at the tail of the log is removed. Historically this was fine behaviour because there were very few items at any given LSN. But with delayed logging, there may be thousands of items at any given LSN, and we can't move the tail until they are all gone. Hence if we are removing them in near tail-first order, we might be waking up processes waiting on the tail LSN to change (e.g. log space waiters) repeatedly without them being able to make progress. This also occurs with the new sync push waiters, and can result in thousands of spurious wakeups every second when under heavy direct reclaim pressure. To fix this, check that the tail LSN has actually changed on the AIL before triggering wakeups. This will reduce the number of spurious wakeups when doing bulk AIL removal and make this code much more efficient. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Allison Collins Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_inode_item.c | 18 ++++++++++---- fs/xfs/xfs_trans_ail.c | 52 ++++++++++++++++++++++++++++------------- fs/xfs/xfs_trans_priv.h | 4 ++-- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index a3243a9fa77c..76a60526af94 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -732,19 +732,27 @@ xfs_iflush_done( * holding the lock before removing the inode from the AIL. */ if (need_ail) { - bool mlip_changed = false; + xfs_lsn_t tail_lsn = 0; /* this is an opencoded batch version of xfs_trans_ail_delete */ spin_lock(&ailp->ail_lock); list_for_each_entry(blip, &tmp, li_bio_list) { if (INODE_ITEM(blip)->ili_logged && - blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn) - mlip_changed |= xfs_ail_delete_one(ailp, blip); - else { + blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn) { + /* + * xfs_ail_update_finish() only cares about the + * lsn of the first tail item removed, any + * others will be at the same or higher lsn so + * we just ignore them. + */ + xfs_lsn_t lsn = xfs_ail_delete_one(ailp, blip); + if (!tail_lsn && lsn) + tail_lsn = lsn; + } else { xfs_clear_li_failed(blip); } } - xfs_ail_update_finish(ailp, mlip_changed); + xfs_ail_update_finish(ailp, tail_lsn); } /* diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index effcd0d079b6..af782a7de21a 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c @@ -108,17 +108,25 @@ xfs_ail_next( * We need the AIL lock in order to get a coherent read of the lsn of the last * item in the AIL. */ +static xfs_lsn_t +__xfs_ail_min_lsn( + struct xfs_ail *ailp) +{ + struct xfs_log_item *lip = xfs_ail_min(ailp); + + if (lip) + return lip->li_lsn; + return 0; +} + xfs_lsn_t xfs_ail_min_lsn( struct xfs_ail *ailp) { - xfs_lsn_t lsn = 0; - struct xfs_log_item *lip; + xfs_lsn_t lsn; spin_lock(&ailp->ail_lock); - lip = xfs_ail_min(ailp); - if (lip) - lsn = lip->li_lsn; + lsn = __xfs_ail_min_lsn(ailp); spin_unlock(&ailp->ail_lock); return lsn; @@ -683,11 +691,12 @@ xfs_ail_push_all_sync( void xfs_ail_update_finish( struct xfs_ail *ailp, - bool do_tail_update) __releases(ailp->ail_lock) + xfs_lsn_t old_lsn) __releases(ailp->ail_lock) { struct xfs_mount *mp = ailp->ail_mount; - if (!do_tail_update) { + /* if the tail lsn hasn't changed, don't do updates or wakeups. */ + if (!old_lsn || old_lsn == __xfs_ail_min_lsn(ailp)) { spin_unlock(&ailp->ail_lock); return; } @@ -732,7 +741,7 @@ xfs_trans_ail_update_bulk( xfs_lsn_t lsn) __releases(ailp->ail_lock) { struct xfs_log_item *mlip; - int mlip_changed = 0; + xfs_lsn_t tail_lsn = 0; int i; LIST_HEAD(tmp); @@ -747,9 +756,10 @@ xfs_trans_ail_update_bulk( continue; trace_xfs_ail_move(lip, lip->li_lsn, lsn); + if (mlip == lip && !tail_lsn) + tail_lsn = lip->li_lsn; + xfs_ail_delete(ailp, lip); - if (mlip == lip) - mlip_changed = 1; } else { trace_xfs_ail_insert(lip, 0, lsn); } @@ -760,15 +770,23 @@ xfs_trans_ail_update_bulk( if (!list_empty(&tmp)) xfs_ail_splice(ailp, cur, &tmp, lsn); - xfs_ail_update_finish(ailp, mlip_changed); + xfs_ail_update_finish(ailp, tail_lsn); } -bool +/* + * Delete one log item from the AIL. + * + * If this item was at the tail of the AIL, return the LSN of the log item so + * that we can use it to check if the LSN of the tail of the log has moved + * when finishing up the AIL delete process in xfs_ail_update_finish(). + */ +xfs_lsn_t xfs_ail_delete_one( struct xfs_ail *ailp, struct xfs_log_item *lip) { struct xfs_log_item *mlip = xfs_ail_min(ailp); + xfs_lsn_t lsn = lip->li_lsn; trace_xfs_ail_delete(lip, mlip->li_lsn, lip->li_lsn); xfs_ail_delete(ailp, lip); @@ -776,7 +794,9 @@ xfs_ail_delete_one( clear_bit(XFS_LI_IN_AIL, &lip->li_flags); lip->li_lsn = 0; - return mlip == lip; + if (mlip == lip) + return lsn; + return 0; } /** @@ -807,7 +827,7 @@ xfs_trans_ail_delete( int shutdown_type) { struct xfs_mount *mp = ailp->ail_mount; - bool need_update; + xfs_lsn_t tail_lsn; if (!test_bit(XFS_LI_IN_AIL, &lip->li_flags)) { spin_unlock(&ailp->ail_lock); @@ -820,8 +840,8 @@ xfs_trans_ail_delete( return; } - need_update = xfs_ail_delete_one(ailp, lip); - xfs_ail_update_finish(ailp, need_update); + tail_lsn = xfs_ail_delete_one(ailp, lip); + xfs_ail_update_finish(ailp, tail_lsn); } int diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h index 64ffa746730e..35655eac01a6 100644 --- a/fs/xfs/xfs_trans_priv.h +++ b/fs/xfs/xfs_trans_priv.h @@ -91,8 +91,8 @@ xfs_trans_ail_update( xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn); } -bool xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip); -void xfs_ail_update_finish(struct xfs_ail *ailp, bool do_tail_update) +xfs_lsn_t xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip); +void xfs_ail_update_finish(struct xfs_ail *ailp, xfs_lsn_t old_lsn) __releases(ailp->ail_lock); void xfs_trans_ail_delete(struct xfs_ail *ailp, struct xfs_log_item *lip, int shutdown_type); From patchwork Wed Oct 26 06:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020207 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 BCFDBC38A2D for ; Wed, 26 Oct 2022 06:31:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbiJZGbO (ORCPT ); Wed, 26 Oct 2022 02:31:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiJZGbN (ORCPT ); Wed, 26 Oct 2022 02:31:13 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 515158E9AE; Tue, 25 Oct 2022 23:31:12 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nMHn016341; Wed, 26 Oct 2022 06:31: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=RcI50StIy12ptR4TMHlLnsR5ebHI2rMtvAANXH5BVw4=; b=aqiHvR0SnBorCMyMPSJkbuRiKdj6lTc015a15cIU3J+PZOx4NrRgK11vUgIaSoqfWmW4 r5yClZG++53LZEd4stSY37UtBt1MZlcusLr6pYDi5zOZlW5r4HbCSVrTbLY3A2nQHjnj UcA00p54MXSK7sCN46ex2S00POLs2JtBFtgZ5qMtsOQzb4gWyvIdUeiUvvs0JLc2GiAl GdUemhSn7uP/4cNpoz/8Ca7tikclNUgLZz0qzMfEZ2IXiR0/2jqrF91vY3Y12Y/EnFbv 25NQ2OF3hI4ibOfstmnZl0YryFNP6xkUDlkSPDEMjW4vRb/2Xh3rpnhMi9VgAvNqMCdX 3w== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc6xe4u3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:06 +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 29Q35aT2011247; Wed, 26 Oct 2022 06:31:06 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d9su-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWAUuGVJdW9JIcOfmvCMOMNM+TgpJoNuKGyjaNv8/BnK9hMJLeiI7zg8bbLkLWu8H9xbQ1XsSl6chU+XYxmVL4uhEGvbjebL0ojaui7tJ9Qa4O+qRID9VEMBw+fxZeytgHRrd0JujNGLDxkxlRsj0vl8LbKTNk3j/AbLpbzB3IhKIYPMbs2pkjTFucMvENLtNbLuPAoK1qNS2CqBBb/ra1OUDKQZz87JXCVzS1108gYtmPfGsoIBmilmbu7qK3PR8cIN/v5BbBDtc2hs855BJJVXo7vbkSvGWWHsArR8g+kKpaEXYdZHZj6YaCsezkisB3fu6aML0fBeAhhQ003d4g== 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=RcI50StIy12ptR4TMHlLnsR5ebHI2rMtvAANXH5BVw4=; b=kTAtFvsut+iEMC1rrE1Up1kC7hEwzU7DNfY+BMvaF28cuYTYU3HUsAv7UzhpTRW3I8ror5JhixeXYoaEbipt6/2fQW/2nBKTLWkSwiHVDfOLfn3boemn8V0S62naNWeP8SASnzKkqeKQ0FdaQviQs6qT32l0xNlaXz5J+6jJ0JHhfyrcgRA20Lk85tRfXe4m1bMH8Ex341aapezwW82A8lei4U5D/IwyeG7aMksGDV9IHU3UAq1wcdFW3B3gzuVvLlOVAoZCDsG1bPIDk+JWpjMXyFmchEZlkfTdr5bvQIpwCdyV7dS7W/Hh/+8JVYCRVoL5OJuRKkfwazsgYOH9LQ== 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=RcI50StIy12ptR4TMHlLnsR5ebHI2rMtvAANXH5BVw4=; b=KZjVn91WKIyn0djRYQFyLxyWlHSht5HWoZePx1g2dl0AGodW5vnjPya3hj/zK5OF72OmBizfhIhgVL8VWQ9lKbFIh8WyYqQCo1+ALPThCTpwp6X1jeGhsel8D0U/Wi2HblsDYdcQeUsnm7u9T2aqZJJkJqXrOn9XTfffSe7rED0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:03 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:03 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 21/26] xfs: don't write a corrupt unmount record to force summary counter recalc Date: Wed, 26 Oct 2022 11:58:38 +0530 Message-Id: <20221026062843.927600-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0032.apcprd02.prod.outlook.com (2603:1096:4:1f6::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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ee9222c-30a9-47d6-b76b-08dab71ba7f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JQZo81oSkdgMAocxVy3plRz6FHJNyIi5xLC6Nr7djoz04mJw/7ZyacBzYvIq4edvnixcUOvmf4wpBn+Ks1C4tSsAnp0auAaia8O64in0QtSoc8NMs/3l/k2yC78s8Zx7LP+j8qQJCHCdAz3l1BvZ9T9t1yhX/UM71aQLc1E5q5K078O07eTHUlIQMCuaNerga4Nl17D1OnQ5jq28BveuSOwA9h+Fdt1PJ11J4iHwckLbP6zuIBwlaUI3I/PTe9ZBOWhQANN0m01fkl5urO0Wn+46xnuVZ54TrzoBAf+mEPSA8lHsVH5zQNRf1OCVmaXcMPnMSbtlG8pc6cTOPZ8k/3yMBtZdsLxVIJ+CoPp5noDYXN6rIoZQ0j+9rPdC2xxA9rlGJl7L3Ng/FbP9NRyrvIQlH28coIyw89eX2F+J2ictBLS6yL/2QaBwwRdHHHBjArLqOqb5TrFjbJhBDvXvfz0htFPzjvKcvwBSxyxTSQCLR5yZRSQdB6w6lI+GgiioTd+vA64kWlKvgOdzRRR6Fd8guz5laeyOU9zjouGu/kJz+Tg2uO4PODb2I2gbtwpYYC6huQVApFvCkH3G6Mt+fKMRo+QXxUGT+YHJ1Bj3pPG9rU0szdiZccdAmRIocgHHRbeN+nHUAWT7zXL9LNmEzsG8GTosCRn7RS3rPXjJqUrGK7KojfobGNE3PYqLYWZdaJxXO22wC88oRYmNnTgfbg== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3yFS0ykXgT6Q/sy7VNzTDLKn//+hkk/zeFI68FgF6Ttma3H7yP+MNMmZfRoULFMNn2H1ke2mRRvAT1k3BD35RJ6Gexa+56xy6cJdvDlflDf1FkCFtr72lAqZlClWkJdIl2c0ZR08Cn8KVzbyWAZQ0klK1AoxzrCFCkJ0wTQpRPJK/vmr7VfbQq5AHnr2sRoRK0XGz0hLIRze0xXE0dd5Xn9eIK5YR5lVFm/TWVsVKJUclPqL4oCGhnsW4ifR98GpJT+URZfk2I1hJQY3xQUsX6oemeBHMazrJf1+/RgExQB0vAwRdt8AKBckgpdUla/m18Nm4gO6nCxJ1+wIz2d1Ssbb4xgG6ov053dNFlifaK49tdO7StU5OLbpTyhjcjgZyQVIhNE7rzisXWq9i6iZ0PROVpmy987+RDCkLsjYBpvONOsPVACe1grBc68Z0z2gImBiywqy0uPl54XSICiHbSrcFTOF9+mfK6AtMCD928PcM8hcF5lD5nNy0bKbMox9XaeMokMDzmifV9Ys0kSZJNtXspd1hIVw1dz5zGISAC3Fk9pNXTRI265mSi/I9VCQUBCRSPTLx9mQHGdG/+gBnnlUXFRWd5W5xa3mb3EvmOQlaJfGzi9m7tDzEK3Bb+eQOpHgbwNfASc/P01QEj0nvDV4MZuzuv0XJZ0DaWHXEgOvc9D/QCCiYZwrLeYx5HNa2xSl8SX61aPY7E9ZVT2cjgjjGXqS1o/F54CVOFLIN8Bq/0SEt5RHmL3UXLXd4ho+iyMeVZrhOaEATGyGnn/mJKbhWzqrOhqC/84Sdgo4/6DinCUOtTvY8PC4frdwnbRsi7CJwvKo42Y4wTkPcMJnp/J/xBLx28r7xVArB7SklsiTa6DHZYa8ElLZvIn7d4NPKEubFSK+djHpvD75fqRTQ+nza00P6VYAlPB/vyRXJ1Wg+TnyysKgJ3b1n7YsLTTI+MNj5YtP3vbehN8av/3ithRybmtqE2ns4qGGBQJzw4VzVAav6bkTCdFUIxTpM5/d8SsG9YS/9HII1Gv2tiFpZwFzOzlitb0vn/9jQoAghmF2xJR0abiqVFa41UsakVeyJuAkQGH3U1cR/eySjE2b1Mc1q3fS6OtmRHUhTeCe3CuVwrMQpMrGV/ooTBV+FoEIAUWcQVMnJxKKV+MH1POVjwjFTOvXXk49WhLEQhz1+keov+tSaPIep0qTq+RURcbV6J3cSTiTCe946QYmqZdSTXyxxmtYqNVpPBE57EM/8827r//sFYbgHvzHm+75w3hIOzOK9sGh2dPojp8XOHTjKZi3QiJetgBhnD5voSGKUcwkYozEaxMY/E3WzosSEmLlx5gkvHecTQhxegWzgfRIkLlDSBMlMFWFv8VqlPGJ5ySDDOtsI5YvFkl31pk5N63Rlb3R+Tp64Wi5smTOSXbM6HV1M2rEXbYHCFIdcXI7kNB4mq+AdtZqDAmCRpVWkvJKrDVEDHcOe4/P4UAA9i8DoDUP/IEs4bb9rHIl1VFoKRM0TECEq5IsLc40NqbRxCe9+7uZPDW5RXDy492p7I3lunySBk9aL5+vQIkIhwvh6gaW+Db7w1k8Vx/0Pk67w1bDO21/PhwG0QNsUL+9Hx6g2w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee9222c-30a9-47d6-b76b-08dab71ba7f7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:03.7312 (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: Gi+GRCEnO9t68LX7yYJydeEv1MrewaVpfM9IJJTLELDHGbq7dbjRSuTPIYOuWxmnS+xnGJRd3a8yK56nPvbWKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: B7DBvdqfmxRruNVxTQ6rMPGCrLUEfCac X-Proofpoint-ORIG-GUID: B7DBvdqfmxRruNVxTQ6rMPGCrLUEfCac Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit 5cc3c006eb45524860c4d1dd4dd7ad4a506bf3f5 upstream. [ Modify fs/xfs/xfs_log.c to include the changes at locations suitable for 5.4-lts kernel ] In commit f467cad95f5e3, I added the ability to force a recalculation of the filesystem summary counters if they seemed incorrect. This was done (not entirely correctly) by tweaking the log code to write an unmount record without the UMOUNT_TRANS flag set. At next mount, the log recovery code will fail to find the unmount record and go into recovery, which triggers the recalculation. What actually gets written to the log is what ought to be an unmount record, but without any flags set to indicate what kind of record it actually is. This worked to trigger the recalculation, but we shouldn't write bogus log records when we could simply write nothing. Fixes: f467cad95f5e3 ("xfs: force summary counter recalc at next mount") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 7b0d9ad8cb1a..63c0f1e9d101 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -837,19 +837,6 @@ xfs_log_write_unmount_record( if (error) goto out_err; - /* - * If we think the summary counters are bad, clear the unmount header - * flag in the unmount record so that the summary counters will be - * recalculated during log recovery at next mount. Refer to - * xlog_check_unmount_rec for more details. - */ - if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp, - XFS_ERRTAG_FORCE_SUMMARY_RECALC)) { - xfs_alert(mp, "%s: will fix summary counters at next mount", - __func__); - flags &= ~XLOG_UNMOUNT_TRANS; - } - /* remove inited flag, and account for space used */ tic->t_flags = 0; tic->t_curr_res -= sizeof(magic); @@ -932,6 +919,19 @@ xfs_log_unmount_write(xfs_mount_t *mp) } while (iclog != first_iclog); #endif if (! (XLOG_FORCED_SHUTDOWN(log))) { + /* + * If we think the summary counters are bad, avoid writing the + * unmount record to force log recovery at next mount, after + * which the summary counters will be recalculated. Refer to + * xlog_check_unmount_rec for more details. + */ + if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), + mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) { + xfs_alert(mp, + "%s: will fix summary counters at next mount", + __func__); + return 0; + } xfs_log_write_unmount_record(mp); } else { /* From patchwork Wed Oct 26 06:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020208 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 3F09AFA373D for ; Wed, 26 Oct 2022 06:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232944AbiJZGbU (ORCPT ); Wed, 26 Oct 2022 02:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiJZGbT (ORCPT ); Wed, 26 Oct 2022 02:31:19 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 436D295E4A; Tue, 25 Oct 2022 23:31:18 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nQqp030372; Wed, 26 Oct 2022 06:31:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=X73lIuVv1dKUGPvc38YuZn9piOhOQaHrY5lm2WaNfrg=; b=aTCLpTnr0R/RVMMd8vhTV5m0RlUnF3j7cu6kTps8REqQJeNViwT6lXbIBDfoqNrPwelC UD5UA9odFVW0AgOnTwRJz/jZsRaLGmMr5hb/RHsCC+pyMmYoAAZuVSNHCo167cOqlL78 tf+OhDfFfFxRa6wn8GqZqlseXP4/QPzNEsE+0msteHvkcUn9my5d2lKEoTv0Z0JYAb4L xpTQVbFHZmf/zIsKXmkd5P5867CUC5YdHa/a78X5dKuk9f9Q7jdesrx7+si8cJYAo48q ISCyFDDTIxM4yTGlfz4x6E6vlpsvBrAyEESJ9pIx1mR6G+eqfYPPz5wCiCpS6gR2r6Me qA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc741x25u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:13 +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 29Q357Z4010910; Wed, 26 Oct 2022 06:31:13 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5d9x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JhdDuLB5AxASQNaRaJUHFyOmiviSXzqToVdFZkdliGglnTwueViWBOJusYwwCAEZc/UlMCyhquF1+6KxjTwd2rbPKPzRzptEjfTthQflU4ZjVdqzMfsYWk/4VRCVxkphSQ+Hx7i89AS0reirdT0/IqPZEnkVdacQg007ghPrQp3DgUgGRAltxsS7xeH7YZTllANEqr3NXlApT+kPd7e+TsOVa4FrvbmigWgDSUYr71w7Z+F3IH9o/caElswz3EdNh2gPNh8Dh07Hebd7UOFd5vBuhPuPiFGwU4+83gI63JJrmho5F+n21jjlL+Znow7FCQ+n39vdYBSWZKeZfbivmg== 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=X73lIuVv1dKUGPvc38YuZn9piOhOQaHrY5lm2WaNfrg=; b=T+K6ChtR9KE2bvkAApYpOTF829M5gaI/ZnwaSX05427LOCv/SZ5hVuAwQow6NzttXOJq3wKjE6h0PJQ/sgW+R7KKvcwqxoO3JvoCZzUx2SYZ0/1y8g0fOgdFiTP0HUCf+BiDdEsGhEyDiAsZFrZR0guJzEOFkPrHh0K0+M71GiHNkuWN62b+0DUi+QAC67afFXzJ8Nb7Fbgg7XWZtwmoiHRngWXP8v6SpG+aUme4KdoNmNubhPSOWM6wWqngtjzJdxTJINFbyjRwXCRMR9X1xFYyAa7F/g/8UUf2yEAwf7rRxNzDNXGM4C7K3TYfMZ9XbJwiY/zCX+CUqq6iMvH8zQ== 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=X73lIuVv1dKUGPvc38YuZn9piOhOQaHrY5lm2WaNfrg=; b=pEyRe0r4X6Qsno3/f4LqJIeV1ovEaj5Gw56lczMjEq6Xu8kIvEirgDzLPqkRALN/g1eJ/gXSNCwflbH+5ajZ5lVMzjfEF4BmGN59KeYLZZ1bljnx+RyZK09s0jwDarYZSwWgAEkEplOPRlmJUYPzdwLvWwfAfucbXiuDDm47ofg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:11 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:10 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 22/26] xfs: trylock underlying buffer on dquot flush Date: Wed, 26 Oct 2022 11:58:39 +0530 Message-Id: <20221026062843.927600-23-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0010.apcprd02.prod.outlook.com (2603:1096:4:194::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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: b690774b-e79d-46f8-bb53-08dab71bac1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ojbSgCbcBDoFvm6GkjFexfCQd6mIqVSVs9Av3LZ+uDzeCXhc17M/pDBJm5JuQaDG8E0SEmsYFb9hM784uvUERlgtBBQ2lL/Q+EAaOJ49lzs37YwJn00MP3mG4PL/aq/k2zzDQ/1Mf0HiYbsSZqRg9Qbyn/tbRg56m9dSx+fSyS1zquaTDH63hb/TLWG8DwHCUeMqpoVctHusgg7q6TrrpxRxY2ctCPx8Nmfe45HQudoCWze0QzNN3R1YjdfGstU2MfhGDRZ4UmuK3QegYvwj0ZVNiPCEiubBaFyI+f35GILmCXXrW3WBjxwG57zofk4j6y77TaxRG6yMsouqIDEqnyNMFtvvqiJyOJ3iYYPD2b0kVyW1vCra/FOV1PVkokKNSdq0P0HEhmcwPBar2GwrpJtdeTF8MHutl6+qf4j62x/RwUuSKJ+uqgGd0OY88mpHWEAJ9b2x50MhmrDjLIqChwADZkuAsagthZVu9B1UlgrQ/Lv8DgOnUHekAagluDhHl+S5F6/0vuFGaJP7GITnI9LZHCBTh/+0leTp3hp95IhWIYy89OREc/rvyKPYzkFDEKw0gUm/rZZ0FKhbAAAFCkD36Xv4Z/MWQSv07I/eDM+SQs1DpO/jJaiIsIWF6Nlip5M8Ygs2wwGJ6TP+cOHBS0uX48a+MEWFuN4qMQmJ0n2rL6zQWWWVHJX58VIyI8q/dxKxT5Rit73mURF3t1OX+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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mZpjrmWAuYycYOENS2FmyxDouaE7yPCu7FKCPT3TN/jC3lDFerJ5rX/GMa4DRzqlTbrAXW54EHaCnVkmn35P/VIjZwdJ159HlqaQyD32+5opyt2s8OF7GGTA/CB/1jvYkc+eZycQBjuHh3U4MbUrgQl1jgg080KZHBMODQ1R/C54pLtGDE6goELwgrAaSlzf/Gic5vY1be0eV3HKKCPYGyPmtyVPDDAa9XpTtGyqsWov7A/o9ePb5Sfstydu5O+f8G1S08PKoavu7Y22xCx3mAkOCZC0RY5cB1cmBGdYR2urwB3iHFgUjoDQDy6uzKCticogoD6J5hbRSO2MSQFzjGUAj0A83Is9MyDsytHDnssORI68uc38Rg229pC11JAsm70TpFRMvfygXEa2nDbhNryZT2tbXB1TrwhSI+amMq2yU4jXWxjYI1nuTXjQ+R3JSNgfOdvIk4FMIGNN4x64EgMPxCjGZmA/CRp7cJMw2id+nmDhm95PxJ8N9AjPFzvAZMWSQvOeJ1GqPPNaPNnIbWOZW7CqY9rmLc0cHAwvER9l5RurnKjeAa9gfrpCoLf3mk+Ti7B4lHqJs+Fm5khP6CtBKGXwZs+rORGlhvnxLxNuOq78reGz6eH1OgNUdrIs0Xef9G3r7KGWFEjmCWJ5SAHMKNG+jNv/31EwPcRG5QkxpWGy9Z56ij9H4zuievUHzLxOX0F+wYaSc2sGclj0LasFctrYIHdUCWXrG1tZU/Ju472L6WmfK5qrfT8xft7VVyAJDvSwkQAERughGuqvHtW+R/e3wIskhNcBeT3n34s/p/T0g+0QDU9JoLqkpc54ICQebtEaIl+8GWKlZjLlhQubQphQaOdUWsbYit5CtOkq92LVFUuV7/wV9dVbZ/AItXJbEBb4f3eoj7Qi0qEx2Vm/Q3rFqQkUKd/TLl3RdRxHBHSUjTX1BDo3Sasf7E7zVrwN/wOEc+qJVteh0eCOkZzNOZIH0gY2T6QBquMoBhIs+2+dFCnJe6I1GnD/ErCKro51XddDpmBGPgx+SqWy5/abTPe2qBZ9hDiLg3/XwMNuVt0P7ejalmAugVZ5Os4nh3Ft+PKeRq1n8Vmay7trzQMizlKtKab9VJ6Y7wvQ3n0P4A8OQA2pLz57bnLRTSpW5uURPn6Cn+H72nvCMpb3gCJOXjXlDYMheljZQpg/NCVp2ClzgEzCkilqowbl5iy2U6/veC+Aghuadca5XaAqdrd98ko5Oi/TQ4F3VvQQzAJUq8zyg6JbVKo0jG5kolZHMY6mIT0yZTAxT9+XGKQIvMp9ZLNqgXtQcQu7kSuGjtAi2F3oBI1yWInV8PkhQbfNM0DTa7b9+YjLpMAVRBKodCi5ricFC7dT/RMseJTSc5M+qytHAAnSMZml1KsZZfm/0otKCOGIEekUpvwb9rVrY8Pdg+6EbPmESuRJ8DzKFZAl9oxyuB8HxixX7cSxgC08/QoMggk/xLgNujkvczCmZP2eYTVzHe2S1dZm4A0rn59ZMRiBnQjW1ibQbClpCkVpqizhS44tgVmWD4wcMj9TiTpNGIjbNJeueaXTFY7/6t6EjhwU6KDwmvFXbFTyTjNu3lUZBCTP2fN3H/vwHoC53g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b690774b-e79d-46f8-bb53-08dab71bac1d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:10.8788 (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: iHMKJVo7vV+/VLEIqF9ntGWD7NWPtSQxH9UPgR84nF0MPUJsQ2jVlQpOVDHZ8UQ+xxl0WUhn5AYH8MYhaoGVmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: TYgYcCcpnYyxv98iREtM1Svo7cCNdFmp X-Proofpoint-ORIG-GUID: TYgYcCcpnYyxv98iREtM1Svo7cCNdFmp Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Brian Foster commit 8d3d7e2b35ea7d91d6e085c93b5efecfb0fba307 upstream. A dquot flush currently blocks on the buffer lock for the underlying dquot buffer. In turn, this causes xfsaild to block rather than continue processing other items in the meantime. Update xfs_qm_dqflush() to trylock the buffer, similar to how inode buffers are handled, and return -EAGAIN if the lock fails. Fix up any callers that don't currently handle the error properly. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_dquot.c | 6 +++--- fs/xfs/xfs_dquot_item.c | 3 ++- fs/xfs/xfs_qm.c | 14 +++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 55c73f012762..9596b86e7de9 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1105,8 +1105,8 @@ xfs_qm_dqflush( * Get the buffer containing the on-disk dquot */ error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, - mp->m_quotainfo->qi_dqchunklen, 0, &bp, - &xfs_dquot_buf_ops); + mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK, + &bp, &xfs_dquot_buf_ops); if (error) goto out_unlock; @@ -1176,7 +1176,7 @@ xfs_qm_dqflush( out_unlock: xfs_dqfunlock(dqp); - return -EIO; + return error; } /* diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index cf65e2e43c6e..baad1748d0d1 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c @@ -189,7 +189,8 @@ xfs_qm_dquot_logitem_push( if (!xfs_buf_delwri_queue(bp, buffer_list)) rval = XFS_ITEM_FLUSHING; xfs_buf_relse(bp); - } + } else if (error == -EAGAIN) + rval = XFS_ITEM_LOCKED; spin_lock(&lip->li_ailp->ail_lock); out_unlock: diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index fe93e044d81b..ef2faee96909 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -121,12 +121,11 @@ xfs_qm_dqpurge( { struct xfs_mount *mp = dqp->q_mount; struct xfs_quotainfo *qi = mp->m_quotainfo; + int error = -EAGAIN; xfs_dqlock(dqp); - if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { - xfs_dqunlock(dqp); - return -EAGAIN; - } + if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) + goto out_unlock; dqp->dq_flags |= XFS_DQ_FREEING; @@ -139,7 +138,6 @@ xfs_qm_dqpurge( */ if (XFS_DQ_IS_DIRTY(dqp)) { struct xfs_buf *bp = NULL; - int error; /* * We don't care about getting disk errors here. We need @@ -149,6 +147,8 @@ xfs_qm_dqpurge( if (!error) { error = xfs_bwrite(bp); xfs_buf_relse(bp); + } else if (error == -EAGAIN) { + goto out_unlock; } xfs_dqflock(dqp); } @@ -174,6 +174,10 @@ xfs_qm_dqpurge( xfs_qm_dqdestroy(dqp); return 0; + +out_unlock: + xfs_dqunlock(dqp); + return error; } /* From patchwork Wed Oct 26 06:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020209 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 089F1FA373D for ; Wed, 26 Oct 2022 06:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233141AbiJZGb1 (ORCPT ); Wed, 26 Oct 2022 02:31:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbiJZGbZ (ORCPT ); Wed, 26 Oct 2022 02:31:25 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C52F39C20F; Tue, 25 Oct 2022 23:31:24 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nZF5017455; Wed, 26 Oct 2022 06:31: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=1aU8+QCH+AjYn43tBfVw3u2X4TYKpWaFlXG4TIxIgic=; b=bTz+N9fy8E0ZvRWa05osxoI5rj0j1V/U/edBa2loFHisvCPe5J0RE3kINxktvmwbFmYk daXYgI8REyhBKAu8eyvLPC6K3wx8lxYQ2926lT4D1NDNXSFh5eECfHn6KORuu1IvggDl yER30zoRthsHSjfljvdO5I3YxGGcgD1TEWBFZpswMa6XJz5O7K+MRfydxTHV5/Ob3IkZ Gxgtx50Y/bkojIvYHs3Hl7HmcIpJudG5583aKVFDOug7IfnxSk0LrZVDK+z3EJqZfymm fuZ+Y3z/p9j09ze12tnxEA1Ots6+8ogtka2UWIEkqog7oEUdZuwNNgM9qGyCogh3UOVn YA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e640-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:20 +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 29Q2eg5G021972; Wed, 26 Oct 2022 06:31:19 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2043.outbound.protection.outlook.com [104.47.74.43]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybpsm4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEF9gV9uVN/aNCedDxt+RO898icg5+HYm9P/emMGBVP//y3iOwZK70Kl5UGP53Z6eH/CJ6RbJuLeuw6Bmb9G9jiphI5XOF/7PBf4HPNawBVooKmLWtb6SoC9hXTj5PrPAlGkMGNlFVg9M4oDGwbiy4FtxSzrUfkkXNyAVuiJsWKODllVIFKIGJ97ZijeDcFqAuzO7U6smyzGvFbjbLTRusK28rLr/1Mv1+TqGkD69N4Z9WkKv1kkje/YgRw4IMTn97DqE4LIxy/f2aSJHMdI1qXAra04m3RKI5tXV3ygXPMEIqlSVkuI5FSxjln+lKtyQkXb4HWhOu3dy1rnQvhv4w== 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=1aU8+QCH+AjYn43tBfVw3u2X4TYKpWaFlXG4TIxIgic=; b=Am9bxNPNl5NKrckYRrxM/NFOXK7CjLfNIwTDCvirApCDcwPDM6thT5MGXwGh4rwXgSVUcF6PYDtSHVCuvebaT3l3lVCvplIIzEJHrUj1ZwXBbly3HrMqMm9cp5Itiz+LCJSlGKeOopBKr9BdZkn9vDJ+TktvUYgElgMA4/W7D4yXhsbP65CqTdpv3PxbKk2fRzdskyp3vX4LGB/Yqnx7IZ8lg0Flz511gASDCu+KWpprckaD9ovAP1Jf9f+eGjP7MjaxFWjF8Swb1UUe99pntnyZY9M6xMG+NQWp8p1wwEurL1YBJGAU2b96uU4qE+SzIG7SyYCxlCBgh7WK2DdMuQ== 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=1aU8+QCH+AjYn43tBfVw3u2X4TYKpWaFlXG4TIxIgic=; b=qQm9Sp9iv2rOBaYGHtpH/63X1mOwN8DFN46p6MKkbc4erTDBmCsBfbzLXt54zMq2S+RitIbD+CulzvgimA19B8dz37rp2pnDb0z+K4tg5qHx7YSI4RJ284f9AfP0JIB8d+q+V6/QFScOiRLzOY2OoN2dAX9Gxm37cUmCFXXF8YA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:17 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:17 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 23/26] xfs: factor out a new xfs_log_force_inode helper Date: Wed, 26 Oct 2022 11:58:40 +0530 Message-Id: <20221026062843.927600-24-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0051.apcprd01.prod.exchangelabs.com (2603:1096:4:193::6) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: e34b4dcd-1ac7-42a5-e8dc-08dab71bb023 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5h29XHu0WSBZRQM28yy6oxvdXAfF45fDv00zt/r13dbKgEEFpTTBl1n3ywTE0DvFrFH7lcT/pDeQappRI+rqoK3BooEYCMK7TDQym6TGBFi1aYZ3BrkFbN7JzxXaf5nzXbduu/kV+HIyuXWYTHDiCQrzoI1cQHLyaOjkSyytMd4eC5tgH7i+fztT+tHJNJQ3u5+UsCIH4ltWArbSTPoCicSdfrYQx39O6anmDwegahDu9aLg/i7u7NWOCeOhNKPVwf+6FrOPLt5d3em4HcUJGKsPvB2yVu3o1VE3JFspqb3Lepv1GHNNPWojf2Yu4vXdrcORn2AOJLtTejYeeqUIVgIW9iLsoXLAmTAb04yGRKUza0W/1z9oVMKHsQPFewxNSYmFWx19FlQmCrS1tVWnS3D9ThD6SIIYJxdbt+EkJ8yDkMuQrF0hAyS1JoUAk5DnKv2pwOL3x7zVeSWvFVZPHy8NcRMUyGGSIMIrADiRIA85kISNyvfJasXnCs8tQvmg3wPwig0vH86diZ+QOMDoR0wkau8F+kyQSNbSm5yoxOWDp2VW+btSiKFiNHTjBdVeBM9s9n1Fy655RYt+iJaELQf2za3rC5KUhrAVcljgZMMC6Ouln7W6RTIAAmyJE3T7AHSpvUPb1/nvqH3s+PYlr7OZO69HNNsScfCi5GHfpGHwnARiY/nCLJwSbw5kP0YXHf7wLz9GldotpkLy8xRZNA== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cp8K+/3oMnIqHEdH6Eotr8o0OlMJEnHHKv0pxH7iR66jLYUD9/7b9uWGLz3eUK3tzbiU1bBSvVJ56vWz1qD3AkzN3PG2Y0oFxX62ChhmGI810zwUL73OEOcw8WthE8FSfBR/CDbr+SfOMWyMZUDadRHK+tkpIWbm5pMmPuQfbCk/L7H354odWp9myNxiZNT/u+ffyEZNaK+wXOnHB58mkUTutesf3NeM4eQBTlPUyOn40XyBeyIaih2N7R8PgYMXR75dQtrhf/nv7L54cIAB8QFHV6OcP+tPLNnbIZ2Yww05dkDLd7xl2hrgbWs4ET4f/E3wDJVtf5N5Z6v3BKvq0kTp4OwFl5XEb+F4tCCFNLLm6QNB8RtQZduaCIO4VrHgCuI8rFtwHQu6LefKnRCXcG3AzJ4RrmxLBnRZhLy8QR/9d8BoawCg78bzUl+hZ9WzyxgLNmqDrFB90gUS7DQqDD9mttI0B1e3Qn52Dhrhl8AszMJfoDcEcaLKKWV8GFJur1xBS1ja9M8GEzQw5QvVkbcyLABujoJHVgf6Y4+mtqRoauUGaPg9BVwzdYiMqabKe5Duk1JVZTMyNToGc2oPYMJ0NoNVJp9S2RdxNt27urqHM36jDnamC7crGLQvmAe26dSHXNtV2jA+zp2eA4dl/WpDmECli2BYNPLVG6djEuzOFzJIx4STb/p9buf+XAJI+BmaJTTAGipC79irlw2HjiR/mncUWN4GyMNXmSlwWykGfCM5JyTZ2h+iiXEprEH54eT8Bg1flYlTm5wx36hC3/BFGXrZJNYyBG9EvxONYJ882iPPrEo8oo0gLBF3YJrviWYItOua7HUgGt8sS2X6Ab0anFqkW72/TY8a1wjEWTEwS6JtHAlk7x8yuzbslA/O3rEA/PybF4Vd5IYidlcWhnxnONuo9KZI1GuclQIaV/9HB8/SDAA8IoIUU2DX5ScNRgEZdqv1GoHlXgDTO4PHHd53zq2PTuRK6Ri7DckKlknWwKwUWN+MFzPzSoJzVTnuAh3qOQNZi4O3DfPI40U7/dg6HkK70EkC+GCojc2a/CGDwkfXJ/Lc9lj3oddnEc2R6X6oNK5NTEL5bZ/YKxPeAQpNdUMuOYP8jT6DJRYS+Dlqk7iiLUaJLm4ZMvzsKHVxZbrjMG5hjTrFhFrPS8TOhSa9+sYD8NFtP150/26ThaLtFfTmvgbnF3BLbKwnKWCVw/KEEgadLR8C5mYUsgwf+gyLKDJtAVuPhFpK/FvDtAAXyxnhcbsn5wDMpQgPB9DEqbkgWjuacScz5vtMYtfhrSd1GcbD2VEwN77rPntszZN+qqTP1L/u8cv6xBHhzk6XKXH+X24njNLhRUmv2/CClByATHzKeO+/CswSk5wkk+Mh6yvEcg/xn4DYBFnZvxCzb/KRUByEXeV5vpQcZEFS88QoNQBumE54gDjo0wDfIYhN5t9pokUaELuobVnq6wf2qgIUZNEarqNwOhLptmS1Yk2/qOnSuRH+73xEW0zK2IwzxIHjLDe5ibRZzkm2+BQYwXfLGmesorOUR6CIPtNIpl8gr1zEp3roVpAhSwqXWo9F1i11B/c09PEUW3LUUu82XX9BMPs2A9cxqAhnf8epAA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e34b4dcd-1ac7-42a5-e8dc-08dab71bb023 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:17.6314 (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: HP5RYu9TvTd/arg41Wj9Vxu+WqocFmapGzyup9eJlyaKzwBtjGjPrKsZGvRsOU1VBgow57zdjBdjAO/cifDShA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: nbwcwfDLDrdXtu6mc2qiurSINwtRBTlI X-Proofpoint-ORIG-GUID: nbwcwfDLDrdXtu6mc2qiurSINwtRBTlI Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit 54fbdd1035e3a4e4f4082c335b095426cdefd092 upstream. Create a new helper to force the log up to the last LSN touching an inode. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_export.c | 14 +------------- fs/xfs/xfs_file.c | 12 +----------- fs/xfs/xfs_inode.c | 19 +++++++++++++++++++ fs/xfs/xfs_inode.h | 1 + 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index f1372f9046e3..5a4b0119143a 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -15,7 +15,6 @@ #include "xfs_trans.h" #include "xfs_inode_item.h" #include "xfs_icache.h" -#include "xfs_log.h" #include "xfs_pnfs.h" /* @@ -221,18 +220,7 @@ STATIC int xfs_fs_nfs_commit_metadata( struct inode *inode) { - struct xfs_inode *ip = XFS_I(inode); - struct xfs_mount *mp = ip->i_mount; - xfs_lsn_t lsn = 0; - - xfs_ilock(ip, XFS_ILOCK_SHARED); - if (xfs_ipincount(ip)) - lsn = ip->i_itemp->ili_last_lsn; - xfs_iunlock(ip, XFS_ILOCK_SHARED); - - if (!lsn) - return 0; - return xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); + return xfs_log_force_inode(XFS_I(inode)); } const struct export_operations xfs_export_operations = { diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e41c13ffa5a4..ec955b18ea50 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -80,19 +80,9 @@ xfs_dir_fsync( int datasync) { struct xfs_inode *ip = XFS_I(file->f_mapping->host); - struct xfs_mount *mp = ip->i_mount; - xfs_lsn_t lsn = 0; trace_xfs_dir_fsync(ip); - - xfs_ilock(ip, XFS_ILOCK_SHARED); - if (xfs_ipincount(ip)) - lsn = ip->i_itemp->ili_last_lsn; - xfs_iunlock(ip, XFS_ILOCK_SHARED); - - if (!lsn) - return 0; - return xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); + return xfs_log_force_inode(ip); } STATIC int diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5f18c5c8c5b8..f8b5a37134f8 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -3973,3 +3973,22 @@ xfs_irele( trace_xfs_irele(ip, _RET_IP_); iput(VFS_I(ip)); } + +/* + * Ensure all commited transactions touching the inode are written to the log. + */ +int +xfs_log_force_inode( + struct xfs_inode *ip) +{ + xfs_lsn_t lsn = 0; + + xfs_ilock(ip, XFS_ILOCK_SHARED); + if (xfs_ipincount(ip)) + lsn = ip->i_itemp->ili_last_lsn; + xfs_iunlock(ip, XFS_ILOCK_SHARED); + + if (!lsn) + return 0; + return xfs_log_force_lsn(ip->i_mount, lsn, XFS_LOG_SYNC, NULL); +} diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 558173f95a03..e493d491b7cc 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -441,6 +441,7 @@ int xfs_itruncate_extents_flags(struct xfs_trans **, struct xfs_inode *, int, xfs_fsize_t, int); void xfs_iext_realloc(xfs_inode_t *, int, int); +int xfs_log_force_inode(struct xfs_inode *ip); void xfs_iunpin_wait(xfs_inode_t *); #define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) From patchwork Wed Oct 26 06:28:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020210 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 21A5AFA373D for ; Wed, 26 Oct 2022 06:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232540AbiJZGbd (ORCPT ); Wed, 26 Oct 2022 02:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiJZGbb (ORCPT ); Wed, 26 Oct 2022 02:31:31 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 668DC9E6AA; Tue, 25 Oct 2022 23:31:30 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nJv9013900; Wed, 26 Oct 2022 06:31: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=sOdiRY/MX0q8piX0oTDPicwy5Iibe43049eHzFygcoA=; b=kkbSVK7Sw7oSEsScbx3EvuJb4fqZ8kYZj18D23+daRES1Pq8BTVUsnGS3t9rVCTG+hn4 Dp3yYqfY159LGQK3Go9d6HbCX9yvX3Z2rLWqHa9sKeA3aFkoUq0R4dDu+T19C2ek1oOT 8hfanTNfVj6Lt9GozA7uwEOuYnxOac47AIGBcXfWKDNhAjsXJcn81dVLiBnYUxHcjPNu 3rDCtOeaF9ml8pggRNxtq1RKluMdE3j62K6crDIJJpK909n7inm5E4ve+AUklj1zqsam Zpzz785lsrlrx2sz+gu5uyPXmbt4zCV399670S1DC1RPxEdxrx5IqaTCgJSby16Mms3p mg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc84t5hmg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:25 +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 29Q2urYl017724; Wed, 26 Oct 2022 06:31:25 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6y5myta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oelv65ao+W6yqSzKys7/qNElCBorIkSBvJY6Zw3+ba0+zJ/erky5FMbSMlqa8r42g/OoM5srW4tT5CfoBjTJG8Y41mcN6Uit4KHaNKpSt0cErXRqGqjkkoxLubFVh0Us9Z0B9YAxhuAsHiv0hOvNrlh2VI32Qv2ndHEw5eYx84IU44R4OzYYkdR8uS2pd1bgCNVC4LIcIJcOhVIIX9mKViF4hyy4wfj7vywpQq3sBzfsIue72eIEd1TDIyNGsknsbciZ3Q0RJny8mA+pFY/eqeLWm+MoVOq2LvrbWy7zPih4gK41fH/32qQtnRYCsa2tPbrGiSktNQCTXoxleGYrYg== 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=sOdiRY/MX0q8piX0oTDPicwy5Iibe43049eHzFygcoA=; b=ezgaYTTUIktNkoHKv4+IWyrMen7UVzX7daJHbS//Kz0W+9ifza8OBYCa43B06ljlvQKEM7pfwBtjD4/XQ5krlcwz321cxkgZf+/kTjGZ1DcnPwWL9jQdntf9H+exVEVQ8PCj6dGKs6RcV9LaX+CXgaE2MjbFoevu3EKTFeUv3CnCrbeWdLeVZ9pd/lE3h+Q+UrP8zHlGyWQvz1AZuXYjvtVV1l1rpqI+XAXQebn6uP7/zvGPENafmx26VaODLIMrE5yYWbFfBHRd3rlL5E0Z+iq5GFyfYDff7dUkmfUPVygnhszSrtXsMrN09am9ihevIpYocKa0WsmAq/vYOo6p1A== 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=sOdiRY/MX0q8piX0oTDPicwy5Iibe43049eHzFygcoA=; b=zK76PRnXNtB4NaOha8/pjEOqUKMxTYAcRFd3GP4VTbMaxDdeOCtQvwtGpxB4lD8LmQHgsAEd5XbQDFyXnX+k4uacp6fIhIRZDLeogkTpvymims+egbGIVyN6n/G3QiRdgII48gvXsADfD2D+dn8PEdjSypr6lVIoPBEczqIv6Pk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:23 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:23 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 24/26] xfs: reflink should force the log out if mounted with wsync Date: Wed, 26 Oct 2022 11:58:41 +0530 Message-Id: <20221026062843.927600-25-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0002.jpnprd01.prod.outlook.com (2603:1096:400:a9::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_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 54e809e0-0836-490e-35d2-08dab71bb370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tqt4t9c9irNuVhXCAvmQ2SD1/hXC3zVsc/hDWIAlrKntWEFec8VFfWL4yeLUqX9sR8OAwv9keRLYE7eORSYFHM0L3UJsGsNehY9/+P7An5gTEB99rIUqlMbputKESJol6/B0nhyJ/+DM6YUcQRQD6c+2pg5M7d09SiU371DgpT9j5TIyPAKOxzAQgymIFsG+l9zZjQPhZhtsIFpzCrx5Td8qsUbYbXyzAXxLPjdxSEO6WoFGowZqAry8il2OCWFqC6VLQ+aVr322QkecDkpIicXT/i3qtwJpcEzXBpgeoasYXXeTSlpsyGy0b/kkuXLAbWrNEFzTZCDsRVNtVAY+jt+hjLE2AZ+7YlErKGkImoy3QW9YJvskFYCDgc4lHPwYTBYDlQsCEiOSa8hKAz2o0aG3rJ1xXjeDRrF82wgGm8HMGHesJB2lzVBbHOeQLEHY1RnBJiKd9KJmti5icae1/R31C05inc+lc3sS/ey1f1ek3AQ38iUl4vhpstMG0X3hlnbt+oD25shQlz4v7s5C8cMZfYHvWLhpTwUTpL+PhySS+oB9j2CTWOzk+eUIFGYDR83JZGk0Z8OFI8+W9iBzSo3IvqKMPWWLtZv8IA/XPJdK9QlJBsem+Dkxwuou+l7aMGgl7tDXOGuXE2rDWE7CAiXyzvqq6ZSpCf+N6XwdaQMEHZ8BkeMk+st5ky8mBWi5u+g44ItIv4l9vj2jI6rnAQ== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bQ5TXcVAnZbtZc7pSm4dvJa4QGHWTmWsKVuSu4u+KsR3KLpYVP+taeTE3p7QPn5hiV7d5UE71ws8aYWgR6HAXr7ZK/p5hzqehFHzuiHtP1L06SBjXR5B6nEHu5817Cx6UBL6lFm39L1CCzBNWrXd/6cc+sRt/0kIffV5jxBE5/6bWClL8zu+UMVGWUAH58SEfk9xyFMwdh+ss76NRbHe0UKvMPhnRxpJqzJG90CA8JtJziLvqPGIJkSZKMUE0JrIn5bGMYB9rXPOxFJC1k5qHblCK3PjiTcu2h3rPqRiNomPs1VWPh0yf62aH35kKeXMpgJpzbQseWDFRk6htzGpWYPQWLt5Kuy85sfvOHwCpd601EfCX3Ru5SI+XE5VPgZxMxpwPvc/OL5fwvciZUoNYI0sE/6s/rHDOC10Xjw1A0JaS8yMLwM6t0hx9rMpQqJcN1jBUh1AuShhL3+5Hd/2+y5fwQ8C/8GZq9z2T8EFFHQ0W1qnCOHDULbAPb+ctQGP8rvojgxoa+XW8osSkiwSB8toF4VuW7fOamReNcxsMsMfvLF++eueR4obLTOcz0zKj+6Jy4jp/+D4i68T45qaNhJdKtKNX2SdXetPosN/WA0xR5kJbsPwEt0Jkj/ADDheKwv+HuqKOg2LPJ1wzzFqdemFzzkWsohCU+XD4ddpA3qGUsZT1jPC5q3hsca+EPIdH/UtSStaM0aAQg1kP2zRKZQSTkI6dxbbHZrsAGgUbWtlFS7k/UymqKk4dCMy+WP/pFRYYBj6kN5j8j88ysQ1f7WL/FfxZrsCKxOkutH7gW6TjIIo8FTbTIBODnSPY6XwDVLfwhAEdGTWiDShw+q+bpZw0Xatbx/zWddrkf5UCUg1t7XJTsotuRJYjXhYqjvNS16Y0zB4K51+rf6uuPbOCoYhLIclY5FB50gl+uEptPOfCI+xykCColaTRe73qRI3MiPk9dqDLIxQiXaX1qLvzJj86g9vdmaFcE2c8eLPJPbB3G+Rv5IgYXqEMW0rf+9i3NjIum6EFtplAQjBL3VMqejNiakt+XimdasXRTynsHiu1FJXaxH9arUPBKVdikLbiiDogE8v4Q+OsA+tTEi2zb13bvPG5MgDZpnR4fxamOonFIfi6u0sJjaq7IorZqIjb1nj+SHDfNkKbqXaP8Tfh1D3nrb6xNcS98ovnbD+k6DmxUT7HUJLHcwNdTCQvHNY+sNoNrDCH7okBchqhos3j7lVX888pWXvIG51g0ABwZe7PCebxjO4IwPGhxVXKcXECxWALXUeyHHg1mbT9Xw4RGCJEJ4mcZD7xyzNQWkv8tb7TZmEDm89BZZagMki7sKnXjuv7Saeo1k9UB8w+oMuQlm8lp4KYesBKcZAhKK217MPs17h22CU5i4u+IuZl2cQVq2fVizgpw8R8U57NiyvG63dSyDECm9bw7iCsyFsa31OIIaEa33x06kgz/j1nLnsvd24/KVzyC89VeViOe7ieuXFNbATuDkoTM2Ka/F0o2IBF3z+cQYETDpWosuhtIXFWInWE3Fo8WJRv/73duIfbkjBJc0juWz9OQdmPO5Fy2qjTUV2kx5PA+iWoBlEGg00ebiAmLCXT34ucNcvvEmNxA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54e809e0-0836-490e-35d2-08dab71bb370 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:23.0852 (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: VOkEqZYg/vU2x3tPz5JvStCpmPH80Et3xGgUjluHo8xdi1ERBvUNt8DvWzosQa9fXA+R0D9ecEQlrN785Oj6VQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: 6ORNt4UX_DhMla8oFdeUMxp5n7u_ae0B X-Proofpoint-GUID: 6ORNt4UX_DhMla8oFdeUMxp5n7u_ae0B Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Christoph Hellwig commit 5833112df7e9a306af9af09c60127b92ed723962 upstream. Reflink should force the log out to disk if the filesystem was mounted with wsync, the same as most other operations in xfs. [Note: XFS_MOUNT_WSYNC is set when the admin mounts the filesystem with either the 'wsync' or 'sync' mount options, which effectively means that we're classifying reflink/dedupe as IO operations and making them synchronous when required.] Fixes: 3fc9f5e409319 ("xfs: remove xfs_reflink_remap_range") Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster [darrick: add more to the changelog] Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index ec955b18ea50..cbca91b4b5b8 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1044,7 +1044,11 @@ xfs_file_remap_range( ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize, remap_flags); + if (ret) + goto out_unlock; + if (mp->m_flags & XFS_MOUNT_WSYNC) + xfs_log_force_inode(dest); out_unlock: xfs_reflink_remap_unlock(file_in, file_out); if (ret) From patchwork Wed Oct 26 06:28:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020211 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 674BAFA373D for ; Wed, 26 Oct 2022 06:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231696AbiJZGbj (ORCPT ); Wed, 26 Oct 2022 02:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbiJZGbi (ORCPT ); Wed, 26 Oct 2022 02:31:38 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FEDA3AB3; Tue, 25 Oct 2022 23:31:37 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q5jTUa002596; Wed, 26 Oct 2022 06:31:34 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=CGQnHw7geJ+a6cpWNSBDrSXBGi0uFrDXB3XivYRrllk=; b=1QltGGBp5PUpjGQlxyVxzAN5VoH4A1zhvrpIDHxRzSrjOGBPbPfVGWYCG47ceUqSemn6 c/En+CxIWFlgnY00mFBSC+nE1z7yPlDn4Mf16vI8M3jhoRWPVU0jAcRuz2V/WohaVyUI Q1rzzaoSRoEKLSqH58BXChUo1hKng3YDwYgVGAsC21R4jJq7d3j5cOSkc4HvqamCt0rx VO85UK2IMGTErb0QE/iZegBPeZOYyrXqcfWI6H4L+T10KPRIU7lFkq+sbMG0F89svg/e 5d1Vbz/Hnob+9N79Mib8NkTy4a0in/OuZcbgmEFf+HoJxrXiZzNQFQe5NFayRKsVYnGo bw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc8dbnbmt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:33 +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 29Q30D95031852; Wed, 26 Oct 2022 06:31:32 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2103.outbound.protection.outlook.com [104.47.70.103]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6ybe9tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZfLIzlbTspgxg+LTo6/v9BJWSsXAnZNWlzN43UXbV5eeOcqRc67BbG1IHj9Knw3qtUB9JHKoGshPh0iVSaYxSF6tF/AGv7pETnyBBLNVqjx+raPLHMC1eZIu6SNtKzJD0lFzIOv2yOcamUmj2+ixaH4+uvcehkGyK3Ug16AKzkVNCYaVmb+3GuUTVafK3XABjXf5W+5yWX6KZMXsNEDzB7OAoFyAIODjzcZghHC9uB4r2ct0zdk8sltHhO4EBNM9jjdvKI998MyHKrycOu++Es7TpYqK+k0oRK7hRY/v+KIQ3aHuC0E18Nca2L+hBRehkbblA1sS0R83AqMzaBGLA== 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=CGQnHw7geJ+a6cpWNSBDrSXBGi0uFrDXB3XivYRrllk=; b=kEy/RT5EYaGCqN/ET9gyFIxKVvHL5kSyfUAZ1GwMXnov19yguiR/Hunw49qrjD47TWoNvYcTHaghDQsuL/sW/4LR5nbjATxaYdh4UuXHTFi5Oad8MNpyIL1kbcFnrWjgnZzd6sBMX/XcNBYE8XBm9qLsQhFVo0qOfUyu/6GOjmwtTz+lB6FdFxbqYuuD0BApMhP8Ca4TYKQb4NjZxM2Ps9eUdPyXmFEEeh4EJ1bzCqs3tJH4pDQ0RUSBL/nq605evL6GKeYHUK3OKMFKaQw99H4ombwZ6bQ9tmCViHPGd1WCCO3RlgZmBSwG3900U8bgWxmgDRDmIoBzcMHGTQfhpQ== 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=CGQnHw7geJ+a6cpWNSBDrSXBGi0uFrDXB3XivYRrllk=; b=h53cr55vzZcFhgIz52IQGCWqbq2o/9uyVH9ka1alB+ukpz3vjY33lmws2eBkVHjhSc0+n6JAam5wiS9esZvYBMyt+ZsJsENf1rkoEBV0gN+y/A4a2m1n7jQ5Xx+9louno2qLhxQaUKzt1hYgPegXRxtK2yXx+NCdto9Ngdkrqi4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:30 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:29 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 25/26] xfs: move inode flush to the sync workqueue Date: Wed, 26 Oct 2022 11:58:42 +0530 Message-Id: <20221026062843.927600-26-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR06CA0039.apcprd06.prod.outlook.com (2603:1096:404:2e::27) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e3cf583-9ff6-4a36-be06-08dab71bb778 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FqX4G0LpHuxTF8iXXqj2xVvLjuz+Lvk3oaa5sMt2SyRUcvfedeEOczNTpKVybhOFsjxQfVYLDLQbstw+ZYffDcDM1rTEzYdPTOj/mL/CL8bgpMCVv+eJAl+AcZpNnWC6bOhapT+VR8UMa2Dk0FtNYw0+QA5ML9cnYeAz/QC61pK6irJHT/J7RlHeK7mcLZdU+A2Z68ogD6dlgX2NOSy/oxsfY64a9GZhZHTLHSMHDyr1ee90Z/WAUS/nqENw9l0RpG9H10UfDr/tY565lf8XM8N++3qsG4CFpt8lgQfM7mQWFrZfOX2OR5xxuJwZjzCzKDwmyMjZkzhjz6U5L7lCXVrWcnh/Tw0Mj01au45a4YP62UGU8QB8H1w7QUEf0bNIzJ/vq19BfuioZ+KoABgeRPPzGMElL2QEGrE2KLsTC4YbJj34Nkde0E7nlvcVWY9v5KBMCCPjzfyztSkWegeej22svK2gHBaSmCflDB1keqw6HZtb/wQFi15KNXIOx86oaY7YWPUmtsvvPJfAwMtJUOfq5K7YrfH0j42PFSs2gvY+H5eQ9JK/Ks2yPCKLLPudNEZKGOOxCoUZ9QtEnJK1mRNosEEaywNydaeoYzBgSnuESY6YBi+nJt0a9pu9RhWGYC2d/Nc4bajhOdFbfIBwiFJQ9O61tbrmmMYGgcOW25/E+XmTyiAFNLdg/KlnF0Yd2i5Nb6t6Bd2pySYP3HmYBg== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Gpq1pMQMAx2pnYsR1WZf1ga9XsYxyXIEPVly5GjaR7L9FaJiVNExxVhWR/WJ2gpSjRuQU252drIPvgPHpvrUIjN5V506G3sa4C4TAAL/KjGZPw8/YwmTfEg+JQqXcRKjDxSPY0Nw0O9bYzSe3McVBkwZ2LsW8+KpcxpfzPeWBkVSfBBx/2Iz8gE7EBL2u9TOqN3O0PlkBNxbxfrtIxK9iQLKVAia0zLffcfrSsZx0CxlCdXA2VT7eEsYPKzp+T1cYyGo6GKMow1TdkU3pozONcaXvcLObD+ojH0obWD7ci0olT7mpNoGmO1qLvZBJ5i4vXqOzIyTYQeY/0Mi4HGWjNmyXrLIhCfHzKne89eGM7g4QG6xHiVYEBNpZkyDpjIM+TBVHg/1z7qVRvdnjMBipoByI6u2fK09pCwx6RbUBOymrQtgw7Z9BgK4Hnh9UWncfZVaNM0ZOCrY4wa6QmXok/wJQKiSDj6RUzZnLu/LluWIgFVjevNXIBlmgNkpAt6mPAblJ5YRSysnTt9hK3UFYhWUEy6uvPkzrzHA9CeNOdVQLAJcTgU6YpHY4E2nOJydJqQh41vaQCrTaheUX5cqVaECTCgFF7T8RIuL/g1OrB8Il7BJdqmhMAKgcU8yhEj62odztHbULq8PU9l1ZxF2bSUohkhzmlOsvQKm31qChrm8QOJEQtcbRqwAy31AwD+lScLV6MdnnHxpmA6jye9XfCaI5PU44/C7Jr45W1K/fG9a23e8ULvQu7Dn9nTnCKhc4lKoU4086iqrusPPVagJvJ94gbBxlvwjZ+k82eIh99BeoIgetYV099FDHfY2kew0yOPNUbI6UxZ0VlK3R3A3nbUoJgTJwAy2O2vRhgxw/yuwBiWHy44Pe7dYEK4OyvFCLS2CFWOArwDtVw7wr17KzdFwbrtg9erK4hUkIS+daTaaxsGuuZ+2+JN0UTkxrui5rMKKMfCMwquKMQtyhVQV0DbIQ489lg9oyWe6AbhmaJ17F8pPG5en101gDCGi8WWmmefVzi8V5KbmJk4D2nN2qaGDYCzBYmJHypPgYuIKYFiDhwftPbjtw+Ey7SLNaB2Vqh20UFf+KdPBx7v/W2Px7Eyvlfut9QT5F9Sej5arqTHltmJI3yzmO8dRSvjcxlDrIibeg6723PyG1WSaQp6+ljbUeI5N96iwmW8CjiceBvJFSMMSfYGWSmS5AdT8VbsR991gAMS1AeTofPSLIjiZoW/WSdnQro3mbveju8b2SLDSbjPeCOeRKn9OkIzwucigWt2rrJAnZhyFq0uXXLjwpDYgQk2xPdr8ufG59gxlQQkCmVeK0HE5m1DIX63QNLXHRpdeMbpiKomSFScEGZwB90NVotKyGaWGhCm7sG6u2LJklUS3Lbc6UCP5cV8rCeXav8iPv4RYr03AfYzCdd6Fe+9OhZySbDj7S0G1JcQEIKY+XF78l9KvPp8UIhpyF8s5Ge4wKYGlVs+KeVYtNUMMEyPS2o61XN92Ofx75e8E5qyvnVSdtjUg0uhXo2UVDAhllEzEh2A/aaL7F5Zx2NsOhuYh09YoHzwCMnRiwduYgMqTpDexKT6v8HR3tQ+8YuTepzDFTpGULSiDsx1c5QYIAg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e3cf583-9ff6-4a36-be06-08dab71bb778 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:29.8520 (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: gmMF/ulbaengavdoHLdXZDCIfNfOW70voK3qwM/uNzU0iAAvDexa4yNJACy13bUPRJJP1m8ZWhrtucLrI0Hgzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-ORIG-GUID: o7BcYcc5zCvN8CL3UmGRFuJn51CDCvvq X-Proofpoint-GUID: o7BcYcc5zCvN8CL3UmGRFuJn51CDCvvq Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: "Darrick J. Wong" commit f0f7a674d4df1510d8ca050a669e1420cf7d7fab upstream. [ Modify fs/xfs/xfs_super.c to include the changes at locations suitable for 5.4-lts kernel ] Move the inode dirty data flushing to a workqueue so that multiple threads can take advantage of a single thread's flushing work. The ratelimiting technique used in bdd4ee4 was not successful, because threads that skipped the inode flush scan due to ratelimiting would ENOSPC early, which caused occasional (but noticeable) changes in behavior and sporadic fstest regressions. Therefore, make all the writer threads wait on a single inode flush, which eliminates both the stampeding hordes of flushers and the small window in which a write could fail with ENOSPC because it lost the ratelimit race after even another thread freed space. Fixes: c6425702f21e ("xfs: ratelimit inode flush on buffered write ENOSPC") Signed-off-by: Darrick J. Wong Reviewed-by: Brian Foster Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_mount.h | 5 +++++ fs/xfs/xfs_super.c | 28 +++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index fdb60e09a9c5..ca7e0c656cee 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -179,6 +179,11 @@ typedef struct xfs_mount { struct xfs_error_cfg m_error_cfg[XFS_ERR_CLASS_MAX][XFS_ERR_ERRNO_MAX]; struct xstats m_stats; /* per-fs stats */ + /* + * Workqueue item so that we can coalesce multiple inode flush attempts + * into a single flush. + */ + struct work_struct m_flush_inodes_work; struct workqueue_struct *m_buf_workqueue; struct workqueue_struct *m_unwritten_workqueue; struct workqueue_struct *m_cil_workqueue; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index a3a54a0fbffe..2429acbfb132 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -840,6 +840,20 @@ xfs_destroy_mount_workqueues( destroy_workqueue(mp->m_buf_workqueue); } +static void +xfs_flush_inodes_worker( + struct work_struct *work) +{ + struct xfs_mount *mp = container_of(work, struct xfs_mount, + m_flush_inodes_work); + struct super_block *sb = mp->m_super; + + if (down_read_trylock(&sb->s_umount)) { + sync_inodes_sb(sb); + up_read(&sb->s_umount); + } +} + /* * Flush all dirty data to disk. Must not be called while holding an XFS_ILOCK * or a page lock. We use sync_inodes_sb() here to ensure we block while waiting @@ -850,12 +864,15 @@ void xfs_flush_inodes( struct xfs_mount *mp) { - struct super_block *sb = mp->m_super; + /* + * If flush_work() returns true then that means we waited for a flush + * which was already in progress. Don't bother running another scan. + */ + if (flush_work(&mp->m_flush_inodes_work)) + return; - if (down_read_trylock(&sb->s_umount)) { - sync_inodes_sb(sb); - up_read(&sb->s_umount); - } + queue_work(mp->m_sync_workqueue, &mp->m_flush_inodes_work); + flush_work(&mp->m_flush_inodes_work); } /* Catch misguided souls that try to use this interface on XFS */ @@ -1532,6 +1549,7 @@ xfs_mount_alloc( spin_lock_init(&mp->m_perag_lock); mutex_init(&mp->m_growlock); atomic_set(&mp->m_active_trans, 0); + INIT_WORK(&mp->m_flush_inodes_work, xfs_flush_inodes_worker); INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker); INIT_DELAYED_WORK(&mp->m_eofblocks_work, xfs_eofblocks_worker); INIT_DELAYED_WORK(&mp->m_cowblocks_work, xfs_cowblocks_worker); From patchwork Wed Oct 26 06:28:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13020228 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 6A8EEC433FE for ; Wed, 26 Oct 2022 06:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbiJZGbp (ORCPT ); Wed, 26 Oct 2022 02:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbiJZGbo (ORCPT ); Wed, 26 Oct 2022 02:31:44 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C016A7AA2; Tue, 25 Oct 2022 23:31:43 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29Q1nZF9017455; Wed, 26 Oct 2022 06:31:39 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=7WryNB1My5bJSxZ9gSU6/Lsoh6Sk6nBknjKAZ7z7xsc=; b=W4Ay8tT4yhYtFYj4C9Jc0l3kPrMZurP8gpl0jwfTXXb8+clxXdJ7esCePlJAKLoadoO3 AZatnwojaLnvxCpPkFtNjS/757fzo7wCFeyXZe5BVRi2L28+U8udOdmPRbh++xSdts2q EnRSQtOwAOcAgxMkZr91BSfgB3LuPG7kTbSFZLFSfJuCT0TghP0X0yTpHkG3de+aqWyN FZMP39lynozcgw/wAQ/y+/MXJpN2yQk5yH4bClDIInwpNIcan11a40Vjj9FQMc06hmwR 69hhgiJ+momyYNXbHTlL2C1/x2LMUPazPv/gXV8XI8mCwnEfM6aeMiKuubMSM88kPIHR +Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kc939e64k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:38 +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 29Q37GIH013251; Wed, 26 Oct 2022 06:31:37 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kc6yb73uc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Oct 2022 06:31:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5ozGoNCVsSVwqFEmFqMsMU6G/IC4cqxdFCx8HQwZZqwFg9D5L06o7BR/JIBPHWTN4Tr8Sk84B7lb9jUHRUFxNe6+7mzYwH0zWz2VpYJbqtpRTVXzO0FeqniuIpltpp2C51dSWNFtHMIONLTeADf2BxPQReYFAL0S+DguZemqBCBlVccukbUJehCOb0ZiZ/rALyM91FJX/IsOfKrE4l4v+nfD/vkl3rf/6JN2rJ6GbCN/vhrnMB0dOJ4EYAgs/v5FVk1trQQoUE/Gqysp9LLjgLl5Lif9IMxz51JTvGQcuI8An9avzgDoccoK8P3blj2Sl8j5LgaAWHAIjA7mgmsEg== 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=7WryNB1My5bJSxZ9gSU6/Lsoh6Sk6nBknjKAZ7z7xsc=; b=Mcd27OsuhaploE6WoyqKEANT53lkBRjM02W+BFtCeS8wkyyV6gudnZFOOzPuy+S0b4G+/Imh0p6cyXDtfJQf0+1oR5SHt8RkYh7QCwpBtPkTQbUgcGvIV/6muVMI1yl8homJM9LqDnNg9yc4UHzqkz0aFlmTt2sOXupt2R8uAVvozwq72TkodBiwTJyEsv/fdcUMBjySNIVIl8YmErvta1QS9SHdwrxINIDZiLxnGym+K4f5y1TcH3ZxF4MgqioXZS6qMIb4c2K/0VTTjD3Zc9mHcuUzq/t70AlW5iTbqEaSIQgkNb7qkcsT5ChKD6FppI78ebSe9QXLPUntFxQitw== 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=7WryNB1My5bJSxZ9gSU6/Lsoh6Sk6nBknjKAZ7z7xsc=; b=mBQAWntuyuxIas7hFGpa15nr/Cbr7gaFBBj43gnPEuTrTQIfWt96ZEnnjnk64y347oQDSzwIhHpffXaRSKucTqXGOpI3Cvky5qdCYcRxOciQLZzC0nc/zg3AinptPAE1XPJje3eE0bCBZAvhfV2u/srk7iqL88Mn27V1S3J3+HM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by PH0PR10MB4646.namprd10.prod.outlook.com (2603:10b6:510:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Wed, 26 Oct 2022 06:31:35 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::81a2:47b1:9cbf:e9c%6]) with mapi id 15.20.5723.033; Wed, 26 Oct 2022 06:31:35 +0000 From: Chandan Babu R To: gregkh@linuxfoundation.org Cc: sashal@kernel.org, mcgrof@kernel.org, linux-xfs@vger.kernel.org, stable@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, amir73il@gmail.com, leah.rumancik@gmail.com Subject: [PATCH 5.4 26/26] xfs: fix use-after-free on CIL context on shutdown Date: Wed, 26 Oct 2022 11:58:43 +0530 Message-Id: <20221026062843.927600-27-chandan.babu@oracle.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221026062843.927600-1-chandan.babu@oracle.com> References: <20221026062843.927600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0083.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b3::11) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4646:EE_ X-MS-Office365-Filtering-Correlation-Id: a75ef3f9-f00e-4628-83ff-08dab71bbaaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hn4CBfAJUwbKtb626G0N2GDEKPFrIDGXbB5uGEzYhI0y52gyhO49w/cqEDfm5cY8C0cRo3V/hAcaMRdK+hidtATlvoTFXJJ54aEIC0rTw95G9M683huvg2r5QNW8z/X7+89ulZWbpYjMMiOXgKDAKXFue8rfCFZnKl7kyNbShMb63nRut/g9CR8L1ACrobclVc2b50S1/ZzP21gmK3OFBNBAdC3Zdy9vlTauhcs5B7oygQWxvBLEFsmchK9X/q+TaCnW7fgXs/ZEGWsGQAi2dArp6vZThHNri7Ou8VpBpDHN7+nSGRok821cNeNT8B+A4cDLegQio2aKa2d/u71cZdrs4OyBwVemFoppNX4rUNjiUf4wo8FYCEWpgKDCR5MjFMxWH8za9CyqwYus3tPZ6g90GrSz06XUvRHZsOLvrCzX3lr8HcMGI2qCkuH64PKPbznspdrWAddIeMqKSRbd2lAHfqG1i+DueL+A+pj08Sug6Z/9QBebHCHj4fS3x1YChnI9Ak9dmNZuLLHfATu2eHfSAeAaatYFMMI7LB1ITyzgkuvYwnZgIvuOaS+J7KYT0ujsM+JxzcgyRznYK/Q3+HGJ7l157vYveVjmvG8/qIFeFN4xFA73dG8OMxUkVPOgLyCswsz1sg/4WgcVjsWmV3759Yf4c+PMcB9wH6HuNk3L0yNOPoOPWsP4G5+GTEG84No6nMEvFUsocJpP/Y9V+Q== 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:(13230022)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199015)(478600001)(38100700002)(83380400001)(6486002)(66556008)(6916009)(1076003)(6666004)(8676002)(36756003)(4326008)(66476007)(186003)(6506007)(8936002)(26005)(66946007)(41300700001)(316002)(2906002)(86362001)(6512007)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MKzMO3TcikTVajbGxyH9hA4s6QjbW8dkhmzYZHXOPjlhGKMqaKCDSwTdy7AzgzuzOyvDL0qnfZD+p3b6LP6+bxM7Okm9gkuPcV6zA/qtlDEnHftPk1zVt/4qEAX88kO+w8Rb8SB6E1qQ9Z/HTKDz9CnSsMqUTMch0w95aHIBdOwhX4ihs2ROVY83u36GGHKxmFRdpzohTa7JtBj13EJCjGNH7X+u5svx2xc0zCm2qwKot/3fyNUfOLBRYF5kk+mjZyjqUXGrhGODczldqYI0smn8wz/XyVRBAl+mijGRJlIwMZ/9RP8V1GkI+kwvDYmB3EQ1oePHdNv7wxOqweRj53eCUd9SFTdkXj+RaguEVo31JfjBob9ytgkpVLdkiETWaqaRC8pzpd/djGXdpg9htwbiNVv52N6/Mpl5gFfZ2hNMkD1+U37BibnPgLw6fh1DB3xsMvErQ5v+ydsLJNCVtEaJCgOf2DwYU7vvO5zfpkXJClzvbwLZPneiY5DQSQUZU3ScmKQLWszxATfoZDkfXnH+10DkXTVo36VZIXWFIfQiNnHuSWtiH1P7/mdB6l56aIfQ7CctAuFpFN/zCQdg1f4p0GEEgGbvi6slq6DEgN/le6H+n2FEDLDH1+/UBH11YdPUGs7YGNMMnr0CFZiGH3gD8kGewSkg/HbARFmqMzp08nl3RMZOV9jjRLjl4wQT8cVCc/CftNV0O2rGoTtQBpFdqtZTJL9ydmLsXQfvJZBMjbNrO6+mcCatcbAwr4T3CAritS/i3+EE2tBHo/RwQpy08ILfvUQgAeajHZ0d7+MOzmTX1o25utAabC1+TnA4O/0x8BA0GMh8FAXkm9ldfG5yqxOtL4B8F6qic9uXG5hnmJsA839X8/XqCxbu3w5sl57578iPcEuj0DOozFU+Z9AqreTuVnTh7nV70VIvDrsD2fuKnhSg3S7P506sMEdAS2igCCjMNBKZnTgVV89Livb1Hww+t3OiqMaoMTxj0VQ3Mm8nLDG2M91ZH/DqmASa8eumZzIZMaRO5RFaeGbIKZ9agjdANUau7YSH70CInnHCmJ3gq2kKUKuHtKCtOHrn6V0KKWmWweRRlmAWNe1+pWa4i3IegkjgzLIMrB35mMiN6tv1Xu26csqr5P6QkUO3L6quFJzMTMQN+5/75BwsfJeZ3pJvCcko7xjt2VzdJHCsErOo3/xhNRH/YSMwHnARgXP1fr5a2xh6eIv4uahBbre/JyDvWnI+ajvePwhmkMPvbD9MXOG5OuX4Ze2sCwR2WTT9gMXqcHERpDCLp8jQxK8LeqS3RYioJCMves++tTa7x+Fr5OWpw1HdjJhTP6eNoVTIKEiTmxgcaJQx460aOxlq5TAlGHgT2xj6Wxbz4XjF6SXgzqlgdUBdNwAj1ORyXOqTVuzvGLwWzfKLa2YODyy+2FkTXAAvl/qk7L6sZIpav4Za/GXK+ltwFEk670QhwgaFRVkVK/454hrTW8tfF/+VKuXOZ5hapDCLpH++wpJObRXmY5nUKJWpGu6nGHWi2RbSND9yH5uC7zdccbVphK0v1Z+koHt2a6hKtio9lNZuk2CDF8prwwtKjHLrbrpTLUW89Wcd4GovXkMCMBKVCQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a75ef3f9-f00e-4628-83ff-08dab71bbaaf X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2022 06:31:35.1505 (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: YH5S83rttEBHUF7wist7yPscGs8uaxwYxx6L/q2xBJWD4Yp2qKjBJd298fwuDhwimm+F14b1ojHpgMIP3hrCZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4646 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-26_02,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210260036 X-Proofpoint-GUID: jAoTQSD_73LZFTBY5Swpwi3j2roViF4R X-Proofpoint-ORIG-GUID: jAoTQSD_73LZFTBY5Swpwi3j2roViF4R Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner commit c7f87f3984cfa1e6d32806a715f35c5947ad9c09 upstream. xlog_wait() on the CIL context can reference a freed context if the waiter doesn't get scheduled before the CIL context is freed. This can happen when a task is on the hard throttle and the CIL push aborts due to a shutdown. This was detected by generic/019: thread 1 thread 2 __xfs_trans_commit xfs_log_commit_cil xlog_wait schedule xlog_cil_push_work wake_up_all xlog_cil_committed kmem_free remove_wait_queue spin_lock_irqsave --> UAF Fix it by moving the wait queue to the CIL rather than keeping it in in the CIL context that gets freed on push completion. Because the wait queue is now independent of the CIL context and we might have multiple contexts in flight at once, only wake the waiters on the push throttle when the context we are pushing is over the hard throttle size threshold. Fixes: 0e7ab7efe7745 ("xfs: Throttle commits on delayed background CIL push") Reported-by: Yu Kuai Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Acked-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- fs/xfs/xfs_log_cil.c | 10 +++++----- fs/xfs/xfs_log_priv.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 4a09d50e1368..550fd5de2404 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -673,7 +673,8 @@ xlog_cil_push( /* * Wake up any background push waiters now this context is being pushed. */ - wake_up_all(&ctx->push_wait); + if (ctx->space_used >= XLOG_CIL_BLOCKING_SPACE_LIMIT(log)) + wake_up_all(&cil->xc_push_wait); /* * Check if we've anything to push. If there is nothing, then we don't @@ -745,13 +746,12 @@ xlog_cil_push( /* * initialise the new context and attach it to the CIL. Then attach - * the current context to the CIL committing lsit so it can be found + * the current context to the CIL committing list so it can be found * during log forces to extract the commit lsn of the sequence that * needs to be forced. */ INIT_LIST_HEAD(&new_ctx->committing); INIT_LIST_HEAD(&new_ctx->busy_extents); - init_waitqueue_head(&new_ctx->push_wait); new_ctx->sequence = ctx->sequence + 1; new_ctx->cil = cil; cil->xc_ctx = new_ctx; @@ -946,7 +946,7 @@ xlog_cil_push_background( if (cil->xc_ctx->space_used >= XLOG_CIL_BLOCKING_SPACE_LIMIT(log)) { trace_xfs_log_cil_wait(log, cil->xc_ctx->ticket); ASSERT(cil->xc_ctx->space_used < log->l_logsize); - xlog_wait(&cil->xc_ctx->push_wait, &cil->xc_push_lock); + xlog_wait(&cil->xc_push_wait, &cil->xc_push_lock); return; } @@ -1222,12 +1222,12 @@ xlog_cil_init( INIT_LIST_HEAD(&cil->xc_committing); spin_lock_init(&cil->xc_cil_lock); spin_lock_init(&cil->xc_push_lock); + init_waitqueue_head(&cil->xc_push_wait); init_rwsem(&cil->xc_ctx_lock); init_waitqueue_head(&cil->xc_commit_wait); INIT_LIST_HEAD(&ctx->committing); INIT_LIST_HEAD(&ctx->busy_extents); - init_waitqueue_head(&ctx->push_wait); ctx->sequence = 1; ctx->cil = cil; cil->xc_ctx = ctx; diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index f231b7dfaeab..3a5d7fb09c43 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -247,7 +247,6 @@ struct xfs_cil_ctx { struct xfs_log_vec *lv_chain; /* logvecs being pushed */ struct list_head iclog_entry; struct list_head committing; /* ctx committing list */ - wait_queue_head_t push_wait; /* background push throttle */ struct work_struct discard_endio_work; }; @@ -281,6 +280,7 @@ struct xfs_cil { wait_queue_head_t xc_commit_wait; xfs_lsn_t xc_current_sequence; struct work_struct xc_push_work; + wait_queue_head_t xc_push_wait; /* background push throttle */ } ____cacheline_aligned_in_smp; /*