From patchwork Wed May 12 16:13:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1D2DC433B4 for ; Wed, 12 May 2021 17:06:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BA07613C2 for ; Wed, 12 May 2021 17:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241161AbhELRGU (ORCPT ); Wed, 12 May 2021 13:06:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48558 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239711AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG8vlI052986 for ; Wed, 12 May 2021 16:14:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=9B3JttikW7NWuVWI8toWfIcSinNX3j9FKB4kzTkT9c0=; b=NjWQBCBH7TJr3/f3C0O90+DXnkS2H0Fs6gzOZTczGdW0cqk4spG4aOH4yxvaUVfT+rH9 Z/vu3I3NTmNSFIwZzSCGsz7NFtDapRm5yAPyOVLkHinQuruadbIxTcAU+AT2SquJO6CT tqI/plXliLk/kCZsrdAnUSpz7zJFOff9DvJf96V9PM9LLnQy4Bg+HRuMCpWwEz1TC53l NT3FYGLlYluU/fvjTZKXd/sLuYxnR9qf0rZ9yevevDA78NE4gCQYOuMDcOrkO6lpUCof rsetTUTSLA6cXK+iz2yBzn+3xUybSpaHy9wwcfueEhOidDx3AKbkQ/0ipRX8ucrpyv/U 0Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 38dk9njh8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9fYU021006 for ; Wed, 12 May 2021 16:14:27 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by userp3030.oracle.com with ESMTP id 38dfryyw0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZOYNfK05/vh88ikOVMERiELbruawTcbKqrMLtPa3jzSw96XWEZrO/HoooaaFK3sDPPebOqpFLYQFdvbW7yvAfkXVWPdClLrRNBFxwcCkWGpEtdXeodg6rAzSqYd0XV+J7sqsvJX1LfVBo5dGV2J9yYer0ORYNud6IZQsrv3x5E44KtUT9JVP6tiGp7dYxyDN1Yv4sIJm+gDHRG3V3ziWVXFs7we4zY21zYhn+xYeaWADZiXyHXkUBX+Z/AMR4xGCgDQn4gC/l0LcRztH4q1heP0LKcA7voXgrG5q83mdsPz4bgVxJw13sWbtHmReSDxKhXJnUkf1Gsh8VtfJ1Y/38Q== 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-SenderADCheck; bh=9B3JttikW7NWuVWI8toWfIcSinNX3j9FKB4kzTkT9c0=; b=NZUZN1vSU4eFq8HlyrHv0lyzLRPsg7XPD9feHkXAwjaTfj3EQ1dKglVk8P1dApbvObKlWUSdP+gqQ9fEJbh9uewIqFBHxs+gb6+1NHVQHZULEdyMOhivz6LigYMu0HGldzUcwvTI8SCMgqeocmar79gDnHzkDI9Cgtb1tkFoZuenZR2flb0jk2G1YsWO13MWNdXLPswJ77X9Tgyf24+GHZiwhQFMdsrZKvEuEN5gtKmG0arJ+1keqybtTEZid1iG3GhOYEzW/JYjQgml4OartDId2uwO3XtnTL0OLrhQxv/hOKnt0Do0jz9QO+pjSxWfO/BHYf45nxgPMQjfu5TXhg== 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=9B3JttikW7NWuVWI8toWfIcSinNX3j9FKB4kzTkT9c0=; b=AUqHVf6y+zZP7eaSIbluhcMKvxCbaMqZ8zIH2plHfGmnNOdx6WL3VupiK6ersdrokTHhabV3e1FYMOrBi7xhq7msad2CNAYI/GmT2soN2vnf1T1FwZi+9+epb3lwp7mZH1g88Fu2/8a3ZIoxY0V9b4/h361eHq5+mQsFRV+mNVA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:22 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 01/11] xfs: Reverse apply 72b97ea40d Date: Wed, 12 May 2021 09:13:58 -0700 Message-Id: <20210512161408.5516-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab17f7f1-f20d-402d-9f2f-08d9156100e6 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k45HDqNY+tIpq47ktrrSPhFRnSbR5MvbzlP8f/FL3KuU5saciHpUvRNOk6Uwtu/SOmIfeKGYjAI71PWYzyXa0rB2i6uFD9xm96K3A3hTiywJbbIlr9K+cQ0n8FLjmLpvL3tNdIKCYTas5/xrmbAdm63yeOrqA4GHTtlUvve76q7ulIoQfOaHjJF+xOrWQuyDV0yrd5J9Px6VMjeWiaf++ZOkCGPfh0SEn4lUvu6vldtd9y55EfamJ/tVjHwDOOaCw0RL/b5eHQ4ZEBVMaealINPbl0vH1nm2Yw8drPNO0UQ5hS/vJBD48Yi18Wh+48BHoF+CRc07scjIiVlUI45YDbUZRtcpY/hYbyXPYvWNGNsRx9PagdcVRm9cml/kMhMI/sFRY4ALD7p47b+Zb3c1pPn9eTsQK6/Y8ZZ9HDnQ2AQGtNM4MepNM6YR1k0+otfN0/Nfp5Lk/miYx0x2gLh83MlhzNx/mg5Vpy5WmDROc3RUf8SzAZz4Zwhc/Abi66+rumhR2KNBuKeC652iw7dx8tNoJRiSHdQB8IhbvQdYTYfr7eY321mFur325gYzua55BG+6IOzERy7bE4+ZuCk7Xjj4q59mi6WVJ/tzVw5JaNS4bzOnyzH7lLF3K+qPQp0tRCt4cquVjfp4pX+5UrnRgUqaenv1xNFePgi7S9JPt2NT9sdoJ+82nvlOx5pbxto/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iI5qPuXCAhOBOrwDbfjUe/uhZDbdKlvu2w3Nr+wEIGJT8igmeZu8b3jxG2WGSl9dPuhQFlWVOs8oXzuImpNpQh32eDjKHtMHoHqA/mQ0IRY0ZQbYN033E5jbikKE5KQodB9vzJxBTEiY70DXOzUlU0Y23yy69FIsxERygK2By33nKVhch+hNY247eJlLZLzJGCdSWWq7IIU1vT/Cd/immMlfSeinY4fRS8xcBdwf0hw+MXvYN+7/vAlsXlm2MdChf7JqVLovOEL+/oIcGP3iIyBpHHUkICApo2WJ0uqNl1J9z6EObBmvLyE1XHYexpjZ/dYCKKiSl6RMHCEF+WcWHZ0T1kuLxaI1tHd44x701YJuaHLoWHnjg2jN3bfK9qjDQ1sBj7oGxFlE+AHN1SonuRzoPq5bXi7ySxwtbcIU8iMRFODS1LV3Sx03Zn2SVEOD3nfPdE5hHAMgrqo1IMpxYGZIpT4+CL+2MYHiRHNRRaK/O/HauO9r6QqJcWGrNHfhJrHjyILgcl1obf8a6mMWzXsPV4c/v4Eh59RqxsWMBnHyaoWTa6lEUpxyuqT0Yqw2QsflznhWvsbra2AGXwhqE6/F261ABI0Yct8k0TXq1R3h6Hz2O7brVp0i0PhHJI6K5Vd54aXbqvsp8Xw2A+rKyrm8j08qrGeP7MiOkY+/X5e1PaQ5aPOEaT/aKNUq830eOldjThm2dww4U2NdEiAlkThW2NkW9BgqoxTMJ1qS0AfmQCB8vJLIRPCw4VvIdq3WGUf5AnDX+O2LC1WRJY1+3GowvIiWekhzUAeHCPpMD1uhbIHAcVDtoyjA8CP2XZoaCj/ylsR+1FDu3+VF0Pm6tIfm1R+9Ttl+fJ41tVhoCXzpS+j/X1PvhCbICCyQIZ4ldjn05GZq6eybCQz1lCfz/gRKLzQLX5zUVELB1g8Dtbk+M5CUz8tkq1lqj6bheFNNEaQOwliP9QzW2JlFVcIrmkboJYK1fV4sYo0Wd2lF5CFIVtO5roJ+v7ES/Lw9dIZS4YpoFJonR7mpgQtRwuNNAQLU8nC+b6XaUyGMD8pjE7tkPZpjfPuW3mroFZR+GqAdoWi9/jJtQaiza1otozNNlF1BU1L6D6K8GezFqO7CsNzK6K7fMStVLg3gWvH0a1U4mFe/gsCt5hqQ63rCQ9+joxUjbBTaXYd46sWt85wiR4OQbPhb7mpcVM3ouanJv8MFOUITfc/4F6ojyXqeSeTtOro3XLp/oBi98M9Jy0/Wm2Hyi0UaZgGgWWbe7e2eD2cTs3yzJ6qDYjC69iigD6YPCmqYN41g4+kkSRlmoE88OVRmXrHQ2blnSXoaPVPAJ0Jx X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab17f7f1-f20d-402d-9f2f-08d9156100e6 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:22.2503 (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: YJr6sP6g0AUWhVoXc1fY/XX4xKgSx0tHs0amaj3Dz2VmXpDROz/I1DSh/BRnfGMlDEbmpeseF3OGIxeLTv9/v10JesuoF3IrA1bFjNZ6Dvw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-ORIG-GUID: ar4WOAtzkPuxwsJB6NCEAlJrPDbwaCvi X-Proofpoint-GUID: ar4WOAtzkPuxwsJB6NCEAlJrPDbwaCvi X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Originally we added this patch to help modularize the attr code in preparation for delayed attributes and the state machine it requires. However, later reviews found that this slightly alters the transaction handling as the helper function is ambiguous as to whether the transaction is diry or clean. This may cause a dirty transaction to be included in the next roll, where previously it had not. To preserve the existing code flow, we reverse apply this commit. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 96146f4..190b46d 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1214,24 +1214,6 @@ int xfs_attr_node_removename_setup( return 0; } -STATIC int -xfs_attr_node_remove_rmt( - struct xfs_da_args *args, - struct xfs_da_state *state) -{ - int error = 0; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - - /* - * Refill the state structure with buffers, the prior calls released our - * buffers. - */ - return xfs_attr_refillstate(state); -} - /* * Remove a name from a B-tree attribute list. * @@ -1260,7 +1242,15 @@ xfs_attr_node_removename( * overflow the maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_node_remove_rmt(args, state); + error = xfs_attr_rmtval_remove(args); + if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior calls + * released our buffers. + */ + error = xfs_attr_refillstate(state); if (error) goto out; } From patchwork Wed May 12 16:13:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42785C433ED for ; Wed, 12 May 2021 17:06:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0092F613C2 for ; Wed, 12 May 2021 17:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239245AbhELRGP (ORCPT ); Wed, 12 May 2021 13:06:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55684 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239712AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGAB86028534 for ; Wed, 12 May 2021 16:14:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=PIq+0/TMBhYMaU948zTJqSJozdswrx7JQNw/b/6onPd6f8bCk4mfOlptVQ38g+FjnY/b mzbPazTV2Ttj1cuHJmUCAVEmV0b4RFLwIlh4BckWg8Cu96bp/R/GujL1tP+DEfpxN8R0 5w9p/50TtRVyGI+Jgl8LC3UzTHfqzmTQCvu3XGM+JDkUZ18wNE9kqqMUplFESnct+pv+ gCm/uSclSDSxCw/sktdTVINO71hh7sjfq3Q5lRR0m5ONicxYuaQscFsqR8wXFQZMMAbM HaqujDakt0J7sxw3oko7LrY/+2KUXHv/4qLNL0OHDlYIZ0qWqVB2jmwnNAlfMvPUrtUk IQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 38e285hua4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9fYW021006 for ; Wed, 12 May 2021 16:14:28 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by userp3030.oracle.com with ESMTP id 38dfryyw0g-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=II9v9os+Avw65DABfT5hyoHVblVJMbTKvnDS6TRrfqzwllPsnmAjfkRrD98Bki3lq5QXNDpm1CXxrYQ/ZGGrR1MkHIzshwOzNCUDlyXcp70FaIal7VUoQRf6GMifdbdJVwbmTez0rWMtTvPun8ReC4+SbHoCypk8OLriCGM5wCSJSpZhePbsHEdRGxOjofZjXV5dO1zHVLh1zHxTUqYF0twB7TVmK4J1pwZRwMqTcAeDDW85oZRuzVD7d9BVp7sckdeyHBcKP+ARiTqXDb+djd6hr2eLMeTkWSV171+4Zs514unRO/vrGuYiZfcz6Mga5A61HcbHGll7b903tSSvAQ== 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-SenderADCheck; bh=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=f3/hqDFAEnKwA2BhfrvM9AzWTqKu1bvGycrxFQWpDa8ddOzgFJIWTf1Yrjlp47GzB3kgscGJWXTPKgGsaasDhqQLiQ101wI4TCBoAvkgjfU/wBYam+9mgrBx83+cVps47vi72nsPo0o4tIVilOOSq2hUet4AzbkD/zUV6eqqH8ngySS6y8IIbGOPvkmlYIbqGY7PDAGc1vjjEfxg3ROGsnwZRVXi6hQgbI+fHzA+cpFKXEvsc4s6CwoNcfUzKljXki8D+4xhS5jPqzAEFMbGCEVjPWKc16SLPaordFDDDayOJN2ulVQD2FSSmkZGkjd55JcJ9TfXS+EGv2lVFzyKvA== 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=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=itCbZbLUPZqChu4g4e5EX3H8+gV68nSZvxwtxHqFPsT5Dz3hC4SylEbp4FGGkQuF2zH4U6qcSU72P3Q+JDsPzXttSA88h1bEdR8Hb491P1NlN6PKayIubK60VY7TCHut5NAR540+lIb3RpZvC9IuxE5RyDSZnZnsHmSoNL0AghA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:22 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 02/11] xfs: Add xfs_attr_node_remove_name Date: Wed, 12 May 2021 09:13:59 -0700 Message-Id: <20210512161408.5516-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d2d62ce-f14f-4bfa-0fc5-08d915610125 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mD7qRVOoLFmTAvIfMcpoIK4pawCQrPniXpSGu6MAlZZqwlSv3YzBMm8SE6v373t4Eq6j7+QdES71YBGjNvLLa8kUm6+nCTTFqVtUy2QXx7ACaCu2RTV5Dq/yplh1pFD9rJ797AVBVk5srm80fYAwXs89RQ2MMYbkLCGh15Ow4GMm8MIyhCg9c+ENz2A2ICMfa5GDrqSkcYrk6eUVL5lHPtIYLdT8bw0XOc4giVoNOeu2Lvh2qBw5gsnKALGGLsv3qYtJY6jw3/fFHktk9Upgu4JM6oitOP5ugOqFgAL2DMSRgAzSA9PftMJve27ZuyItgGqvYlfZIbS5I26AA7W6k6JUkbeHbzKCJktYG/LjT8MzJCE3kkW0Yti5e+gA+w4tytHj+uB3HBhtnxI1mb/K9b64l52eR8Endz8bQRGzFcMs23otEZWR+fJQydlymfm7z9hwskMpChNagrpJdBeThGyDqZb+oOiDsoYgoTRPDzLTx9po8HUnbY1w4bO4vEGt4SRCzBJv7+Ym7JTm7yYmV/SxotKs2vMU6B2yHsmVhJhAJeKqYblYKMziCUEzaSm6oYxgTZtAYH0hlR+sV+5GtMnQrOrHqfudBtI4PbGzCZihbG40t4AWeFIwDAzQORFsTgXq+0bNHm/fZS1gHC3cIAAVE9k2kBPtJfkEdM73JEZlacHCLbDqDQ1NOizTupzf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +mnuYFwAkHJmxCUzov8e20lwQpcn035NrddSiCz4uHYg2JtiH3j7b3kFS5HIXik9+MQbzWq+k1+XCbPObJc4zsKYL4OVwmEkVRTbBA2rip6gPcs3fW0t7umPYbfsZ2CmjQM3DWq+dRIV/9pgf1rF0OZHSpPiQesz21swLLFO7XDzNtEMPyqc5Xo5xB4l3EtzA0drm7UVPTVmLM/7A2AJEznx825fF8yA3pAd6vzFsOr4NpBrU30jAMVOssowni/2VBMNoVQM20B41aI7B22WlwPl/eo5/iro7scWfGg4Dycug2Ibxzqmv/limsHRR64Xh+Gprkxn+w32Hzeeta+2p3+d8Cx58E11gihz6I5SRPlE78s2Ww3T+QNl4je2yzsxi3v7yfnj57lQwMeagirUgBwfFBjbMUO/qNtvfxk2SEhDCXjDYgJ9NuEu+w8fzMLcqmQ4S5x0tR35nMFn5LHF+f9XNOn4SKv7tlawnxAKdiMNBHQs0bLbtg8WqS4uHQZ1wBY7UGA8w4VnM2KFQ/QhjMfHayTSPOKRwcNdlaXGhSswqc8zUvOIPd/Wlrkyi0TstHJ3vGOhQ1VlmG5zHD0ERUOMkGtTdOo40FDdCsHb9Uw7RNk6dvTaBHtwOb2dtSWLtXI/2lmc/+4HT/v85az5UTsIYvIosfYNEUYMBiHFxhzDqstxPy2/KksEQ5kpYifnJspu8lRXHsgzY6WLLbrfRSfRAlNBsh58W0uCNBJ1dQCONxVBjhpPIBU9e5V6UZalC8fU4yT72Oib1DJJIrL8u+Nx95ZAuDEG0nG39eoYBhZnKXrKK/R5nu5n573f7XzwsRGIuhyDBtCczDQErxBpFB9TcLN7N1L/i2ECm5uRP9udzg2YzUNGVml2kr41gijh/vaMo4hTek4kbfS1GPWdQkAcQYV4XzqRiRFAtWNtXTElXnucBxeYRh5NHtxHsjr+zuPP4nDfDdPQWpfsGFY2awcBjJUmABhtcqwMPKXf0tJpU43aMlm5rw0X0xHneBamoMShCV1f1MtDGI5BXSxd0r4t1+aIk3mkQ0lXH9/4jhoJVnVK2dcL2TMEJsxNbFXaPxlBq79iX7sOFlKVFNKS+24ObftOeAsmYuy5FsAQIamrbKsJjigQJG2VNsriskANBDebPtGezDKsJ0cY02UoagFJFPR8nrMCl8Ueg4BiNB/rXF2/7s9NJW4bBZBo+D4Y0KIw06/4vlZ5+qMiXeokDTdiqG4JhbQ3NiJI5z0Kpq6mEYPUWMOJB5QyY7N+Zekb5PMuKsEIkldzj3zU2lSnxm6B2zJUHxcPJ/T87tnY5/g89G4XFAJwZcTnvczom/Vs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d2d62ce-f14f-4bfa-0fc5-08d915610125 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:22.6505 (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: dIKWxcbcOzTbjlFEMc1jmPdBEdQpzOuh6gkoOPPYU+i8XGYaHU31hJhSNxab70DTDvxRiPry0Dg5g1JrEQNDM6g4P2tTVmouLCVFXZC08UM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: 4IYKrX5BwTsPMHWw3WgWu7iomNHcX1TE X-Proofpoint-ORIG-GUID: 4IYKrX5BwTsPMHWw3WgWu7iomNHcX1TE X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch pulls a new helper function xfs_attr_node_remove_name out of xfs_attr_node_remove_step. This helps to modularize xfs_attr_node_remove_step which will help make the delayed attribute code easier to follow Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 190b46d..8a08d5b 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1214,6 +1214,25 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_remove_name( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + int retval; + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + return retval; +} + /* * Remove a name from a B-tree attribute list. * @@ -1226,7 +1245,6 @@ xfs_attr_node_removename( struct xfs_da_args *args) { struct xfs_da_state *state; - struct xfs_da_state_blk *blk; int retval, error; struct xfs_inode *dp = args->dp; @@ -1254,14 +1272,7 @@ xfs_attr_node_removename( if (error) goto out; } - - /* - * Remove the name and update the hashvals in the tree. - */ - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_remove(blk->bp, args); - xfs_da3_fixhashpath(state, &state->path); + retval = xfs_attr_node_remove_name(args, state); /* * Check to see if the tree needs to be collapsed. From patchwork Wed May 12 16:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82B41C43461 for ; Wed, 12 May 2021 17:06:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B8CF613D3 for ; Wed, 12 May 2021 17:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241222AbhELRGY (ORCPT ); Wed, 12 May 2021 13:06:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:60182 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239713AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGAfv4012623 for ; Wed, 12 May 2021 16:14:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=c3GDTrPZMjkfclDu/3E4rkHg41Gf03hUsJQJhqMYAFE=; b=usA4LTB7TTPqjoIHpPdSJ2vYi6LwMYiTdWisR7WbxrL7xk4hvV6g0ptc+3AoH0T4DKZg DFEvTYIQARR13JRSdfSW8ETtI92OoeK2pJNUXuhi/LPySPc54Po1QrdS5eJEpsXTrShp bCSgM83uQF3lJF+4X1l5N7wRKfDoMlAW6u0xiFhP++ndockkfX3b7lJdCeYRzybo0fx5 mHDPhe3F8M2ZM/wEhUvudyPnfILZqTFMdmT0KRhYr4xkQXt2jU2Rh2hvB2izSTeS24EE 8W3/S+HtjLm35TLcpbYL5JkHRJZIyA8UDsyVG8RXeN4b6izqo4eVxLQWQI4fhrpTwgTu Wg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 38djkmjjn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9swn194902 for ; Wed, 12 May 2021 16:14:28 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2045.outbound.protection.outlook.com [104.47.57.45]) by aserp3030.oracle.com with ESMTP id 38e5q026eb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhBcqfChIaUHVF5W5utuTvAdxdJuH+w8+4EhKeoEheMaRQ670KuwJxQmrk3IKYABMHMt15ZUNitjOm9hWAeUbgeKNqHti/qMJzeJSyGG1T31o4xEej19uioQ6bmXnOl5dULNJ/vT7FCIlOXWHcrVJtOzhIAbhRiYL57MI4UpCAgyjvJPovt3ARRBo18ImkF3aPB41HYLlfOo2f5dEwoLfK7WK6gEgAZfS75yLcD5z/trlvD5QQ28W3PJUgj66PKhBgfg5YYObtgX9AzjBwAsmfUBwyMuq2CtiZWLFvdko2ca+iFfAV7i2K5weK5VvaSN3OF9iyrsY9IKdwkA1Ct47w== 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-SenderADCheck; bh=c3GDTrPZMjkfclDu/3E4rkHg41Gf03hUsJQJhqMYAFE=; b=Z4uPEU2/FMad3Q9Q67ePIshssDoSgW8J1jSLQsFo8p68Xo0UmcKB0a4FL9wehfNP5BPiSs90M7t2Tn+ZB48fbcF/w6YXCQPZa2GECQfhrpGdXOVuK7ICsFOzpYdeSM1QZNVE7g+tI3+pL1sCiRTpBDvYLdw6leKzBDYJnjcTdTw/eveY28x1S6oLzwsDxr6yhsNeJRDdPqWCRxG8s8mrpcduSfiL5WbnMl/6m6te60aI8coHOzoBIqKh7aeq+qrunXOY0FhdI8X5IzM9MfDNEIDEhR/GZEy5WSCXpkO13GSodBHeRviIHLzlUaN4W5d7Q/tbnWMiI9Cqgs/71MTVgQ== 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=c3GDTrPZMjkfclDu/3E4rkHg41Gf03hUsJQJhqMYAFE=; b=n3XXSnzhgWyppWsk9O9aNLQx+ok89sqT7113C0lccTJ+jVHQWJEqWrYUa2AKafWLGH31sBIHvwCZ8Rjfn4SBt2mji1axmX7gwGYpghcznGNJxsQCz6xd7MrHoBPpLFahypuUk+X3A0zMrDFqpUAZ49bKn0YkatYOaSm0fftyvwk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 03/11] xfs: Hoist xfs_attr_set_shortform Date: Wed, 12 May 2021 09:14:00 -0700 Message-Id: <20210512161408.5516-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9c20337-5743-44f5-fed2-08d915610166 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wBSBEFCDMjhWh8mRJAyF4BShOl0BuH/XQWbYqvKGH0oJSPsxtkI4R0VlnFGI9jgCsBF3/F+p2WcKiFvnzUDFGNG9sWCJgQ8E/HAbk49WqG3KHxEKnPZ4vu+dDQowgpf/ysBHxnnG/CxCGEsxTuLlGA5P+KQpc1qf+gC04qRzOLKJZc/opOngYxTPTYvfMaQPU5o4nJRCCXPwKYTSegItUKhzUzpG8Ns807RzbrEptI+SrLvYJHMn+q3aaGtkjX2BUn3cWiPs4US16TLJdmvyNNKH0Qwdvh5xYhGMhvXY+9XQCAjo5m2fUgNCB4YJ5mbi2rtzFm83VOE6eZENcVh0RXsUccBYy9ghxUT4n6C4JCNZuU7svCYJ5VIlZdwkLP14xREKG5V83WxDriLarYrRlo0+D5SO3//t4AddhAk7ncUokrw6o1Oy220Dfex0sg0VSyD+6ld3jyDXtbI7NFJKpDvMJcg1g+8JL3R0ZGEwSoYHGS9Q2U30u6S/rSqOWI81L5WAQDQtzCVj2tCpY0t1ahuCmrLpg1ksqX9ZIAYeSW57H6BjN2+Wf1UaU9eop0i4I1nzW73z5ZEW/BHNRs5e5CqQtsSpF4hvr1PQv7Bbod9KuID19rZQE3NrBuB9Gse9qYk728S6C2Ao8yInpbAsgefFD4uKV4pg6SWRAAJi1US8mXNlemmfj1xmqgKNtgjr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uTnXp54q/OGWyMefehDB9+Z9HBIcwGxD6vcCTwq7KhMiT33CCdc40IQ8t3e5lJMffkBiG8evbqKHEJf4K14Yt3RIqw6uNynTvAV/cwc9m1DPKzMioGNlZpIAwmOu8Utk5HILcrtdaJhfpZmZRJ4pIUcooaCD/H/MvZnxldfeJ2CzJEP0Cp15NY8Sxuu7WT3cztXGSvONohp6wSvHHakNy3/2tpCTAboguK+j4vYcU/grvuIsWhLMxqvgws3M+7VvaAXZWxwpnfgdXQC0auWDICS1ge2mKSoBOLd/GrQQ97Ju74M9G7eFCcoDOemCY86krdavRhrWkoV928NHmOggygwPpsa+cmnbbUG5AWZca/VVjJmYrPlUgsO4BkwwesV75hw2nXR+4PfokGPCMZqw2D/ASyt3MVjZRvyD4p+aufPZhJ5SrSgaQQaNWrw3Oc9+1tbP/0NC2UYgKrs5VraAlnkZmUrE4Kmfx14CQKheXGpCg6dASrRomBJG5HSoFIblOlRzT/hHiTKjVp1lJqDpuJI2HsL2ONHpMbvmQdYWo8Aa6XVzHAf5woA7iCZ1hye+uk3ZOqVZoDL33E+OX79avHCZR0KuatbkWgMHF0H1MdVEzddT34m4Vpxrx+b9PFH3S5yg9AUNepkiOgZlyzkSu1BLlrrC6tLKeAwh7BnbiwpeIn6ypp5fb2XM3D51TG+vtUW1sihpOXtVOEMoZ+YC2WnqF1LU3v/syNjn8GAvgCQggWZ/AUlZd1I/GfN5LAp2i1qjFangT57V8NZ5viVOZp3Lu3vGIv8hJJ6hW6d8pX75gbsZlAECNf7crDi1XCe11EqBC7gv0pkDCeJAyzV7RcesL/jm7fz2VFFa0dJTzYp5pASmTLjbKLtDKE/YylaU7O4VguxJDsdDCE7IyeTVIrEWJZ6/4E7eiMwbcjqogXO7omCrj4quQOR75urogrcnGmtpC+NvDnxDvApxrPhMH3iuimxD4cAV7tAxEjlVm3s4pnmSDY8Fk8jOXkw/go14YueWA9TYthYLdsIXAEKQh3gd5d0jS58KrsZy1uT3F5YmtnujZ+Gfn6oUD073AwEHs2bzNeQt1bR0V4fu3SEwfmBZ2qu/WLhfJpp1rblSgrCHzN8uRqw8Ks4jNzxk6DcZhF6pP8xCx4iYB+y1i52gf87C/gNHtHnCoV1o268jJ1njQCLAse016us/QPJZJEgsuRhH6qcNS12xyEaktI9bk9NnIjzdHE8N/iy8xdWax+slfa6iSLq9anArOlw37qwXbMcH/u992v51CTJEVPZciU44SWQSMV1cuCTMekkIbuLkaeNasD1Ug0XU4HoQEAIU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9c20337-5743-44f5-fed2-08d915610166 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:23.1215 (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: FJngVFNiXPzvdoHzjnTL20GTO/AsDsOu8ECgD5Xt2dUqeS1ff7hWgcn5QXWHX+V03MElgLE3aiA+GIevrJ9xjk1G7KD77gOb5QKMkukKiJU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: zBVZk6kDPlKEyGX9Dir-ms47nGx4NnSX X-Proofpoint-ORIG-GUID: zBVZk6kDPlKEyGX9Dir-ms47nGx4NnSX X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch hoists xfs_attr_set_shortform into the calling function. This will help keep all state management code in the same scope. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 81 ++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 54 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 8a08d5b..32133a0 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -237,53 +237,6 @@ xfs_attr_is_shortform( } /* - * Attempts to set an attr in shortform, or converts short form to leaf form if - * there is not enough room. If the attr is set, the transaction is committed - * and set to NULL. - */ -STATIC int -xfs_attr_set_shortform( - struct xfs_da_args *args, - struct xfs_buf **leaf_bp) -{ - struct xfs_inode *dp = args->dp; - int error, error2 = 0; - - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - /* - * It won't fit in the shortform, transform to a leaf block. GROT: - * another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a concurrent AIL - * push cannot grab the half-baked leaf buffer and run into problems - * with the write verifier. Once we're done rolling the transaction we - * can release the hold and add the attr to the leaf. - */ - xfs_trans_bhold(args->trans, *leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); - return error; - } - - return 0; -} - -/* * Set the attribute specified in @args. */ int @@ -292,7 +245,7 @@ xfs_attr_set_args( { struct xfs_inode *dp = args->dp; struct xfs_buf *leaf_bp = NULL; - int error = 0; + int error2, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -301,16 +254,36 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; /* - * If the attr was successfully set in shortform, the - * transaction is committed and set to NULL. Otherwise, is it - * converted from shortform to leaf, and the transaction is - * retained. + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. */ - error = xfs_attr_set_shortform(args, &leaf_bp); - if (error || !args->trans) + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); return error; + } } if (xfs_attr_is_leaf(dp)) { From patchwork Wed May 12 16:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54B77C43618 for ; Wed, 12 May 2021 17:06:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21D62613CF for ; Wed, 12 May 2021 17:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238981AbhELRGN (ORCPT ); Wed, 12 May 2021 13:06:13 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:52566 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239720AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGA0gq188859 for ; Wed, 12 May 2021 16:14:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=KKFXo4sujt3AaXUtS7xAiZK703t1SfcnASNuiJzD8ps=; b=R48/BCFyl3FFSEzj6yMMfFfurlPrr42ZlIexHCjtLgXBCkeF1ZOhoFed85HE5ZwEWvNE 3QRifq5pky89RDBSAmRUEDOI9GJZXx6Z022ijKfya28tInVTmgY1HdFZ8rWHjy0QpaSS fa+iG7353SoOIbSMO2BgkEhLJ12vk0aExs6qVPT2vfvG7Qnbg7KcuzF1R0Yh27qztN0j jY/GanMklD//JpcNxsprhtYLU4Q2iteweq2p7K471sNWXcsRc2+0/HwBL/RZ11XYYczM ml6p3VhZePeiz/coe7VJvK0Mwh1BANveMmANaOc7Skgs0225/wTMD/d4KqdUrPaeJs0G rw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 38dg5bjpnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9fYX021006 for ; Wed, 12 May 2021 16:14:29 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by userp3030.oracle.com with ESMTP id 38dfryyw0g-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxtyGBmvG6xmk+fGCdwfYO3eJoYSDma9vyCWGFOlVui6TikOsU/4lmojum18w5iS0M85+vZntEbLy31k/GnCPOFlcHdg4DMA5P0mvdDGIqe3DPGh8ZZA9MX27pZQ1CKE06Erb58zXIuSfOWQ1NG9SQqkoE+pBAsQfVVDEx/ioRxQzThIGZh6ugPmyDvRQRaXx1elqoJFSx+sny881JqEBCrvvCBHTmVfhnOd+TMjMP5Eb+w0GqhKvR4boliqLETMPsISfzTKbHbKUskfs2N2xVXnRxEm2IZQtwGgjXxUTCCwfn+dmcsOA47JKwuE/oWbtVSVcj4TcM7YReUHPZMTYA== 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-SenderADCheck; bh=KKFXo4sujt3AaXUtS7xAiZK703t1SfcnASNuiJzD8ps=; b=LKapVyS4KCHXnEbsesfGUzQ/DzCvX10teQhoc9L6WBfdv+g/g378gvvbnvl59TJs5k5o1rVN17PTPdScC932OqIcbK9AXN8NGbgAhKcViQN9/EH5iY3aEqTzxmBxoQeGxLQdhn6Mhesfw9pLNFbjmxY3ail9i+9aK5iNaJ5V1JNyaabG3Y2fqYnPNUydUlW7sqlNlzkIHrnpCqn74DE/14lAjbLunF4kcMb0Cw8hkTYC8W8rjliF7sFSUYnUsPik1iisb4nUMWE/3BgVLxy356FjfEYW3YJvkw2x4XXQT6CHwukDa8LoWhjJurMCW0UbTdbG3ssZjChDKmeicLb2tw== 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=KKFXo4sujt3AaXUtS7xAiZK703t1SfcnASNuiJzD8ps=; b=uR04kCOqI//Q9Ro018qjylipU+cw/xqZ8Yw1lVsyRZsb1o06jxDPMM23+ln5OKomSr+7n8IHjY4RMPaiNdkPwluHLE8UvBVm3CIDuFUV1GidGYUPmm+4tdlqXWnDVK31chtehbPCWsXAbhX4yRqk6HE5C9/gEr+Lgst/yHWrNQg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 04/11] xfs: Add helper xfs_attr_set_fmt Date: Wed, 12 May 2021 09:14:01 -0700 Message-Id: <20210512161408.5516-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2b66e3d-bcff-4e19-55ce-08d9156101ad X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kW+8ne1vlgY00fh95puFzXbfIHFbGAlEAckbDCDhiKK6GplZzsAYkEzyI4S+EnJKliDiRMe6kekcZLCKlj510RivZpUvXR6nNVDzKaU76Pq+9NBwgRlGIJzAkdvpV6wktStfhn7lVyjhRpjSSoOydzxI3Rv+DSJtHIKI7vvhVoS31h3d7BSW6oY91+zSmZrPcNt6dzKhCSFYqVzTzYBAnmuC5fSw8FXRy8klmvtBGlVw4M8NQWWM63BoAdDHSPmWUBOifGYjkfeckBTAmgbI0JZ3ZQxmtTxFOwmvqlRZQzFk1TOaAosqnD7PP7vQlClsXneQD+N2SYFWlYb21bXXYE/jGDKkknRoI8As0koHZuoEiMl7UEjbtCz0BWGi2U1AXO5IVGAsSsnzM7awrmYkznzwHBMLErko0Sp0l4pnocCnKW5G6ZpNCutOxpf1Uvi9lGz7dsqE8RzNkEyxyOtRk/ksIdYohZDeNJJtbNtgwoNLV1+v6iuXQ661J+5EmAqJ7TDrBmuymcxMDO1gft06BM0J5bCTIwX9ldYfLb/t3tJLWSsaMsanKG3MVhzX4XZd+uG8fovDWB0qS+uFZ9eUUkIQffc6r4Yw60sqB/1itaBhm1GbL+1UmcmzazbC8Y65n1qDaWLGZrWXts4DrcNoZxVIQaNoPVY5YrsWfLc0M6NUvMgp2K5LGkXDdc7NJeyy X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: gPgbgqlTpn69hiIA38IWZAIFfqakpkg/Mde8tLeUNHTJTeTMn1PlspAqgDMeQGWldMWEYFd5xQclFW+U1XoFYWlUoBRcfjoOL9zjNrxkVM+tc3InAHbuFalNOewT19dl4uO89KmPXXcW6WQvYfWbIdvJc0PpIQHa5vYrkB+yJ2ovtKWvlERmBQiPjF7XQclUYE7jXTVUwMNdxtyggjHo17eU6q4/1Qn1/8RtQzUn0jOmBsKUabHNYW8tZFTUycgDyvshNxBYysFOktIC+jdCE2gu6UQVVy6RbdpWCcgqEDcnC5QRXAaI3IBW4mElRGZ3zWeErHfLwOUGsk367ygLBE3yxX9ZISTmpbnXcyp4tF2t8w2JZLjYGbKnxHXCdDsMZjQzSQWmQMrtHr+51n9KIloKbJSIAqRXlgYv6GxtjZXZq+T4FsEOr3lQrL6QyXaaePlClyI1Iqby9gzp+1n4YzAa7xH0Ha2bIkAQvsMfvKXKTFVZ0xwmeOBQlQQIqZ79byU3voJXQskfnoKm7avGKfNkT7Q0gNoOraifpqrckep3fekmVCA0jNhZyJzTqydOCSuCcSCpthtCECMOPBI/mqxbt0OaMIF2elg4lMlxVFLvGz08h4Q5D5ioMizWv5JpdKOyZnCOouhUoGt+LYuw3fokntuYBbkPpy4pormLedc9q6R0GrK6Qxt94DQDUpuc+kKVg05nOw9UX8g6n/GE5k43KDH6x4pNV+QJP5L1A23MaBp/a1qP1vISYNTR0CICQIZiFmgEIwn4f46AN49N+wiQOASEggsv2Xql1oBXfw/Efc6Pnym0ZFNF6oOBuCjnpw8o3NFv0zn+oioygAXr0CtyKi36nZaW4Jjo2FTbEJXG63gaw7Gl9DRelrFPXBE40AY9W27bMacjnwkbPPawmStpra26pl8YbqFCtqTM+7Tmz2pkv0AT0h4Myk0A+8Rz5Jy5rlMquj55pBGPriuVPNp4hM0C8qraKzQqmRKmullO+sBD8c7JU60uhoKQ1eBVjiYdZCvsYBNyKpNiSLiVfZdo2d85/tvgbTcO7UUF6RtzsqByNlzb+v2hwHPe0pWqAsR8V6NwISq3UQyIbWt8zvvtk7PKQ89MrvMxPMoP0Njy1maeph4GXFCtGOHB5FWgkHvbTlmZ9BY55uSC0QXc7FWPckFDcbgpaoOIYtIMFPWkjThsNrXVyhPO15JE+gjR7h+IIczJRAGz0Z/jFUQo9udmDYaBAvm+EIZQKxlfQZgyJZdFxsXqXWhanHu9UlYML3JPquUGMFrMFBrQv0z177r26S+3RObHeNKkwd9CJLXl8wBUirHN2H8q9chkmYEZ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2b66e3d-bcff-4e19-55ce-08d9156101ad X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:23.6123 (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: FZ6rhBCijyxoxjIfLWT7ZraHjvh+/dcX1I7fRqHixc7w6Z+mQh8EOtIhmcv91oqqvczNd/CeZ+V7fanh9TB38OGqmx638g7cCCpTkaJ4Kmg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: _uQQMYaLqf5D7aTdcVoPeeS3rdlXji39 X-Proofpoint-ORIG-GUID: _uQQMYaLqf5D7aTdcVoPeeS3rdlXji39 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a helper function xfs_attr_set_fmt. This will help isolate the code that will require state management from the portions that do not. xfs_attr_set_fmt returns 0 when the attr has been set and no further action is needed. It returns -EAGAIN when shortform has been transformed to leaf, and the calling function should proceed the set the attr in leaf form. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 79 ++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 32133a0..1a618a2 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -236,6 +236,48 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +STATIC int +xfs_attr_set_fmt( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + struct xfs_inode *dp = args->dp; + int error2, error = 0; + + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; + + /* + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. + */ + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); + return error; + } + + return -EAGAIN; +} + /* * Set the attribute specified in @args. */ @@ -244,8 +286,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error2, error = 0; + int error; /* * If the attribute list is already in leaf format, jump straight to @@ -254,36 +295,9 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - - /* - * It won't fit in the shortform, transform to a leaf block. - * GROT: another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a - * concurrent AIL push cannot grab the half-baked leaf buffer - * and run into problems with the write verifier. - */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); + error = xfs_attr_set_fmt(args); + if (error != -EAGAIN) return error; - } } if (xfs_attr_is_leaf(dp)) { @@ -317,8 +331,7 @@ xfs_attr_set_args( return error; } - error = xfs_attr_node_addname(args); - return error; + return xfs_attr_node_addname(args); } /* From patchwork Wed May 12 16:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B881C43611 for ; Wed, 12 May 2021 17:06:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C57DC613CF for ; Wed, 12 May 2021 17:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238882AbhELRGN (ORCPT ); Wed, 12 May 2021 13:06:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:60188 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239717AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGARNA005181 for ; Wed, 12 May 2021 16:14:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=KCetmiGa5dHnWGsOUmK2gGVSX5hK6fcSyKsnfgmTFJU=; b=F2jTapP7cpk+FwDcz/zQoYR/BYfSGe8QCi8t2PII+ACTsJJTIE/m5PTvwpQvTZ7f8tvg ZIKx+Awv7pWgspU0NwMfYsTMHI1sry3LTiXn3KMEhfvhx/dhzaabCudBKW2jaQbdiu6o taiCZXdjLYSTruxYHihI+Cots0Av70XLVi3c5wO9AFb2ZiK2nbocsEzSt9sjAILkCMbH R7etchkfh0z5YZrco2bGNM9sDUwYr3hF/dAoB61qkrC/99qZO86xzUaNHRzQobxmns2X rzURJaNee4hh3C1vIM3fBuXgg07dQijL9d5kOzmfTow1bQEJ8TAH1rFF77YRSmPQdD3k 9w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 38djkmjjn2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9swo194902 for ; Wed, 12 May 2021 16:14:29 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2045.outbound.protection.outlook.com [104.47.57.45]) by aserp3030.oracle.com with ESMTP id 38e5q026eb-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B09UUsR41iXIPHM0UuQ/haky8uWwXBOwiEnXuERzJjaKwTx+P+cosVBw4fcd4y/lH0mreLmueOmMcLyuJ1CLgwcJ3C/LP6gSYv8pirgrghH5c81vgnaQ6FpGvj+3S/l9SmIYmnUJq0q4dmiIoOMvcNsqkaEa2RJW6Drg2UKM1OiCfXafG7LwZBRBHwe0aAUSazHK/2o0wYqG/npEkZEfXFTl/e3E8a7yM/KKsNQ4jBK8j8ccRIYf1HujPQ/h+hrOTHWAzW7KhbehnbMDI+TkGv9qBSOFF4VJbBRgn+B9f9+Z8pj1t8QBqX5/+U2M2AW516lFyWwNogTTREXJzSQq+Q== 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-SenderADCheck; bh=KCetmiGa5dHnWGsOUmK2gGVSX5hK6fcSyKsnfgmTFJU=; b=P4PN/M17WwzpDtyExJui5bg40zFNmpnvW9vgI1flLvyyMxKZmcl5Q+sLmv52uDjzUMfil0DrIBtBXtloDbDgYCzrRGdt5WKm8Go9tp7+XeuTeUrDAS1W/16mrnDUnmQcWULEmjH7KHUpWBxna2hPXbSVWIYLbnWGNo0+VzLAR425SY3KMXNYy7XMnfTrqWotWnPcTa3HtItfrTavQm988VJG7dH7XNTdaMJZbz4PoApdh4xh21H5j//9PqJ6fEzLBTauyALYaYsG0ebtqvs6VjF9BsGPVanZ7RCrHQHZvf9+sJweMigX6C3gqdpDCJv9Uym8TDtrz40ZP3srFLLoKg== 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=KCetmiGa5dHnWGsOUmK2gGVSX5hK6fcSyKsnfgmTFJU=; b=lh6eb01s87MJduWC97fnFxehaTi08ByLZKtWPXu0s/Nj3yAlMDn6DSMAWy8cGXrL9utb4ORKn7i+s5xyhXDK+bQnryyRUIoM/JmSNAhEJVKdd77/Xvfdc4EPoGmtB0+x6Q4C1DqfDhx4/caw17RxSY7ODub11TvHMFDQhicB5P4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:24 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 05/11] xfs: Separate xfs_attr_node_addname and xfs_attr_node_addname_clear_incomplete Date: Wed, 12 May 2021 09:14:02 -0700 Message-Id: <20210512161408.5516-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74261f36-a059-460e-b697-08d9156101f6 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8otDWe8qH3qZquq0BLcU3rIOkrgCyhQsycxk/U1uB4AMlwquFwb2QuoMBB0VSRFLPUWw9irrNN7zjhx3cN4zaUL/cUI/8IIILcZQoORUA5k5vu7o95FVWVE05BUptrP24YHBuBHK+PY5K14zDP2IL6x510UHjZZEfz2KuJgxdqEX4OBVAhfYOc+IzjtluGIHcJ1O+zswG7YiuQCpCPZ4LUIce7zLz5em+nUEld90rUZlPVg9/5uEUqmDphIRBY+81sIwy309DgdVCsdcM2neZLpq3EV2g6FuvRfNPJO6reV6smRQyS89obaiBhBiMO8ZDhinb42FQ4bb82RtEivUCbHqiCDat0J9EE3bEk0C9pqiEsYnL53SVcg1Vg6V6Zmlp00+XeYMqzBNQcN4FReexyKDjrDEYmxxY+pp+fdoEdZOKmPET8w1triePD61h6FdDJ/nqf2LG/JuYveZRajagY1qDz/24MmX+he3UVnGf0+n02X9WhstW6Y1Mgz6i+zSuh7Vrvmtci/oCo9RgzCzaXHQcpASCFTVdSIexW38WqUkBTbMc46ZHCB/VCR2eQaE+dViylBOrub2YLN3UIkNHLjQNtau+o26PnGbkaQ/WDttNJf2yzWfx4hH3qKpMD2DJw9UeHUu4GDGhnlr3G84QE2ilFcnz3/MRTsbHN+9ASBSYNhT/KIzus76xHzwB8yL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2oIBgylEH1znjpjcLlrVWaxufB+9bc3YsD4c1N+YGuDEqoeULVGnTeiwg3ylMDZj2OzYTKcsR8rMj2gGd9JBIDc9Z379mOOS9bbckmhcB+jXagezXUSvW6AbyCUXrgmvncg+BvufIAmc+aK0r/gegjOz8s+/vRNVrSleZdCa5zCRjxGC/iv5syiabPuLe6MUQl9EjGnjM51v60SW1pC6AOd4UDme6oKNcIWmFhO+AAn8NdxAHYEgw4Mg5r6OTdWoSSMttF8J3cpDIP8KP8yX/yXb6LE4aNpXm/C3l9h+737lv3qcCa1NKjMXK7VKOsh+KMAV74EFuVG1JaZFrlammxqEI+FZPaPn/OKayFSk2yx+GV1rGG0QXjdGCGTWb7qjt1+fURGhUO78o54AiKJUXH2prSvRFfY9ibe3MvGZ7YwJ5FLRULWSS6wArHG2LcM26pZp5cnRMdmW/Khtgvzu18a052ircXEczgsJuPAzzXRwkaYJ0uUZSvIcxMOZe+WXjxEKO9NCksiGh4o1MNCac4AsHnXjwusIZoxd6fsE5vKvCKeoZOm8xNDCNtOwQLMz9OvdVnjXw96th0CsSiZBylF62TnCw5nQgEd02xi54dzBP0H2au56tuajWE/tFjFHr6OaDe+SC2iKKquB1RLYkzUhzPCwD0ptNvE7K2KyxBnhRSBZK7Ek2fO0d0w9N3jWwO1PT6qbWiG2Nj6vDECWXjvRj3a+QAgYrvz0eKAaKsN7Dl93794DTj9/0kdHJ6HP80XEVumGYY5QiLXekgAOhZqyVHFiP9+Hz1CuzRJiaR00hilxARvth3n1cWEaXhLQp9Ov0sOrRUvHLYmwfN7Y6DQ6bs61AHKQkdXl/pt1qo+Qb/3ji7yTESEEZp6PymMSv0k6f1N3pi1bdLGGii+q/VLlEgUGKKiwEWzEVXKSQsNi6qMi05HiDYvV5nJtlfg44SRHOl/2FfFFxM5qZswNrRJ7krR0OrI4y0+z03Rw5gQ8OEjVyPqcqLk713gzlD6aIdmmOtCOw6GR7kiCSvGA9xZqQpBiq6gqbCkg70ODIc6Ta7AIaMxlCIzBQ06SXsAyf7fL822Itn00f2AQM/MuUWrtMTueL/lIY5XkbeewBzYnhY9ChHdNdwuCcr2e/bkUobyVZlcUw9KsOjdiFHEPe44E8MnRv8Mh0th3zsrIdsYIYc68IVHKMdBrvUXMD+E93kUk+FkXpotcY3vlJQEVNrwJzqgRlBLcMPf0WeromZgV/dHVOJ8lm9yikCk/jQoPKzFAtQiTIeyqh0CZ7MUOPO6e7RpgWq57eKORIeyG8PEAQWTh19HbbVQ7wfupNku0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74261f36-a059-460e-b697-08d9156101f6 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:24.1241 (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: z4MDc7cD/ZK8mlmmr0FfX4g8DnTCvLpqd/Feph4klUEwWfC0wp9uBtJe/fDTvY2JseXBojc7HkCynD78duGKdepTIJA+PMC/XHp0fuKAwgs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: zfGhKrD0OX8bBMBgMDieYJ7y1KuSvR2l X-Proofpoint-ORIG-GUID: zfGhKrD0OX8bBMBgMDieYJ7y1KuSvR2l X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch separate xfs_attr_node_addname into two functions. This will help to make it easier to hoist parts of xfs_attr_node_addname that need state management Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 1a618a2..5cf2e71 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -54,6 +54,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); @@ -1073,6 +1074,28 @@ xfs_attr_node_addname( return error; } + error = xfs_attr_node_addname_clear_incomplete(args); + if (error) + goto out; + retval = 0; +out: + if (state) + xfs_da_state_free(state); + if (error) + return error; + return retval; +} + + +STATIC +int xfs_attr_node_addname_clear_incomplete( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + int retval = 0; + int error = 0; + /* * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. From patchwork Wed May 12 16:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69450C4360C for ; Wed, 12 May 2021 17:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36C4C61363 for ; Wed, 12 May 2021 17:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232454AbhELRGH (ORCPT ); Wed, 12 May 2021 13:06:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55670 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239709AbhELQPi (ORCPT ); Wed, 12 May 2021 12:15:38 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGATeI028640 for ; Wed, 12 May 2021 16:14:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=axtKP2TLLLFxoRvmO7V+X/k/eb6Omt75vxkwITHZwjE=; b=D2DjjQqyOt+lv3Ufod85wndEUZBT/sORPrkUWECvP8FYt5DrolI7zNzAbBAuFMYTqYRR BXVFF6T1dpm+m22gB0A59kttFsgKmucTrWocKqaY1ROUEEFlZW5iQBouk66FAig3P4JV 3vT1rNJsriKQ+vHtoTLQ3kYCC/QKiE1uO7SwydpterIKPFVqolljZMb/2nYUIrYwfD38 9j7DzcKfXr3SAS880XxzQZGx6edvzrboCG+d0gC4Bu9xrKXTsQKYjGsiOX+sjyFLheQV p62AhxQZjMU0iSjmKWXyKo1AaceDofkngZjjidN0td2nLe7eS0DUqma4AkJFz3d6zHB3 kA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38e285hu9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:27 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGApnm142059 for ; Wed, 12 May 2021 16:14:26 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 38djfc4w78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGUPD+x4Rq7zks4JM0aGjD2+PN9dmaTCcVtHkEJsHWSvqVRNIaeZ8YFQTKEVJ2DuRdEjTOsXTNYxZhDrR1s7y5+/Qnwj0A+eQZaZyDJKRg3v2nuVOY+VXL5SKtZmBeS806LG5aYojrHMyWsqQHt5dR2b+8ZpqDEuaLJ6UdCuiJeW8QJTa9dhEPb8Ul4q/JKppSKY4Xkx3ZjOwxuf4xlznX6eS4qCNrIeNyi4lvodmkiDmOXunW/jDR/xCY3JkzRSBOKtaPdK4fjwEt/oey5RhOi+UYRVnqqfMI4FOb/2EjHuWzNZTz/vdsQFysedlCoJqileoE0E6YXx40GeHoH6Qw== 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-SenderADCheck; bh=axtKP2TLLLFxoRvmO7V+X/k/eb6Omt75vxkwITHZwjE=; b=TlQIyEg1EaaXyu9lqL2pFG7CzW2MgGEfXoi8QvBx3FhEyTKJcwj1KWcu7FyRnXFp0GNIEdTkiggh7gh4IspSSHxDOP7m9sGCe90+6/Tc0MaEwIO8VyHCIDlZLPb5zbxhvAJleGJTz8X6z/pX7V6IV0uFUWtP0NBoWlY74FOHNWmSsFyCtxHsIhUNHFoj6qNwq+bk8nhTEZiaMG9VqPpkIYPYPf+WoCiAEuPHFhsvn5f64c7FotgUeqnpdwo7QlEUEmKdTs4b6JFl2wXSMdpBai5HLW4qsmciM7vbO1avrfPbYhfh4bq+7/rGcTbEsszq1hfUELZ+uHzgap9Mj+ea5g== 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=axtKP2TLLLFxoRvmO7V+X/k/eb6Omt75vxkwITHZwjE=; b=PJj7YXumB/HBMGtpgi+zvYXuCyrtJpu3tRFjJnSafDm6ugMCWe2DvF6GGtQjSo7aoGjg6ZrruqrFO3I6u3OgIhIsc3BrRMDKfhBARCfiaZAalN4LIz/XsXfTOUiSohW+KmI+G8RgEvxBSj8bNepMoK2LTerpQusqcQsWSEwl7qc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3336.namprd10.prod.outlook.com (2603:10b6:a03:158::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.29; Wed, 12 May 2021 16:14:24 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:24 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 06/11] xfs: Add helper xfs_attr_node_addname_find_attr Date: Wed, 12 May 2021 09:14:03 -0700 Message-Id: <20210512161408.5516-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66f3928f-4624-43b8-41b2-08d915610245 X-MS-TrafficTypeDiagnostic: BYAPR10MB3336: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g9lKKwW7mODFodfl046hRQlwNomg2G9/FjwN3HWcLn79JT7TmcPzPQj85gxF5yuQdaJUVVfatDER/S+emRoiPvaC2ZtL0AvGzmz9M+nTbBzIfLCjcZ1ntZLfE41Ff8OlxK7F/IdKkPOR0wzhtBCk4D6oc+A2l42B23s+VB2ZWiwpYkC9m+glzYq0LymROYCovDppm8ENRx/sxxIBWz9jCbA6f6HUrCMcqI0GK2bP7OTbGK+A/UG/03TgZQYlH44kgHfMZaXNTZCfYHcvC2fIBZZ5Wt7Fp30QTbtlC1wa+MLZUH+uvs+dbbIQwVWBW85Lc/ECTH4ShjVcN7fcBQwiyWZQttiaE8Peq1Lre8jLe7Vms5KovrwNTcNOeL6wkDub5l4OWVTRsgU2H9ULWTANKKHa/vBeKDZH8fsA1r/Z0F3yMu3HcaZ1KFgpfe3JsSiFfiiuF3p4bU1TqwjZcNeRUaVekvc21I3/GCvMScY71Cswk5AzK/FsSwQqTYrjdKHfRqCe8csY4bYlSouqyi6dlzKe4x7iyw9y94udcwuE6394Q6eh3k0VH51Vxb+WSOgXYbrmBJ1bcYj2W3mEiBGEVHsBgS26XImORV1KB+SaOnjtGUbLsi+JUOV/nYvCEwnNXzUCVkTegrN84DlALmbmgN5zaAuB9IVrWuqFP+4OjEA+Y4YXTINYZK1CbhJQwDhu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(376002)(346002)(39860400002)(396003)(366004)(2616005)(66946007)(1076003)(66476007)(6916009)(16526019)(26005)(6512007)(956004)(36756003)(83380400001)(38350700002)(6486002)(478600001)(8676002)(38100700002)(2906002)(6666004)(316002)(186003)(8936002)(44832011)(6506007)(86362001)(5660300002)(66556008)(52116002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ItnX09LgnUFQj09B5GO0P6Icmdwg9eVMTwyasmNo1i5qmgbuojpRdWyJJUzk0dCK9TnuiagXDkUSokf9MFjmROMkYi9fVX+0zrzSRuhR5an6dHieBG/EQ+1xwKAISxiA21TsD+o/4lafmir7rhu8cVhgF9BSVvJJ/z5I9QwODO0Ji34uzKvFaYPLIpgQsQyFFmo8zIRDSdmXzK+I5rCYVUD1zRfoOXWJOL3CmodeUjYmkmh06nmijqUtL+Z9DZu/RgTGt4XgHiHCDz62zQ39PcL1vbGFHtA8HggfsrKO2+KBg8+mzvewyOC96bLIoQUMQUbylkqSLOFD4hL5XIzDxXDPSg/Ch+gu6BAspJom2fk1k0iM207xeKfVDT4PYUrLzqM0AAcpUG3MZMcGezxbvDoviY0L6uAcV2FiPH6QBN/6Fom2uQSCyG96z74AlKtI34vIz9+AJ6JqKqFWluXDuPyVPsfnWalByNHtQQN1/+cKFuHINd2m6YlqKfa1b3/7bjvFt9C777UZJt1bhl1DS9hkrdBmBseZLEHiELF8rbxv6QXv/I+e1lCRzl+j8sqXPresms2Px1nbxp7PzZ+rElr8xWQTGDVfPRVhOwzGiluOs8OZGjjtzw08FqexrcAIXJpsyxaJU9EJxFAkXjxZ0BJiQG0KPALt8Tbayd3SMx2dNN1HdBq2hOvLTf3FhrgzUQFLGuFnYoegadLgGP5mZfvIde5MbJNS86nj/389MRzXbUvRZxIaohHrWWOtn8gcSB4ko4O+Jo9a+57c6+GzAEMGeKZnIk//blCTFgZF9R15yT1s5Quk1bH50ysgrkfi72w1dUBc+ua0aaT/VaK5S4UBsH9CC6BaWDjT/D6He/Ce4a/vFM7XgJRAUZ69SqcZLj17dY9XjvV7NA3/Akd4kaUkifTh+Jb3s4ZI1L4B4i4vsshYkNrRjy9M/ETJqMJHNMYKswZZBKaEJUMYUfaUea2WMOSTPzbsR/TLOeT/NJx0zC6noY8Iiv9Q9FP0e00JDOJ4PYWLfzgKM7QtPjfZeUeywrqzftRra4QLyC6VewuWiJh+QtQq0JBaW+nwK28oMrupBOFvCDHhJZ2ski226cqqhwL8uWBlMvj/22y8jByP+2j6uEUnzmHgvOaC8v4M+IJh4Vsa/jX8p6XETa8z9erACg9rJux8jGcClBUCufdKMfoLuYJVfyUZukVY1U2ZQMuYti7rC5xVTFi7NYbYY5t2f33IAZtO3lNU0cB651LEQw5PxH6Y4c4YlLNwThAevzn54iSV3bBz1ls33JFgxAA2PBw2ZrPDbKLWrM93gsR0Qwdi1u/2heXvTAinsCzU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66f3928f-4624-43b8-41b2-08d915610245 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:24.5392 (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: eFloea9TzfDr55ZcyqbZbQkNba9Lqxp7f9SHeOvlAbkvxT3MQSLd6XJp/yERUUXljVj+5D5kISY0ot8BUH51BReEaf5xOlvrrV/J2OZjZQ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3336 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: _tJsFfxHE-hLenqGiZRqpvIyps9922wA X-Proofpoint-ORIG-GUID: _tJsFfxHE-hLenqGiZRqpvIyps9922wA X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch separates the first half of xfs_attr_node_addname into a helper function xfs_attr_node_addname_find_attr. It also replaces the restart goto with an EAGAIN return code driven by a loop in the calling function. This looks odd now, but will clean up nicly once we introduce the state machine. It will also enable hoisting the last state out of xfs_attr_node_addname with out having to plumb in a "done" parameter to know if we need to move to the next state or not. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 87 ++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5cf2e71..8a60534 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,7 +52,10 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); -STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname(struct xfs_da_args *args, + struct xfs_da_state *state); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, + struct xfs_da_state **state); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, @@ -287,6 +290,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_da_state *state; int error; /* @@ -332,7 +336,14 @@ xfs_attr_set_args( return error; } - return xfs_attr_node_addname(args); + do { + error = xfs_attr_node_addname_find_attr(args, &state); + if (error) + return error; + error = xfs_attr_node_addname(args, state); + } while (error == -EAGAIN); + + return error; } /* @@ -896,48 +907,26 @@ xfs_attr_node_hasname( * External routines when attribute list size > geo->blksize *========================================================================*/ -/* - * Add a name to a Btree-format attribute list. - * - * This will involve walking down the Btree, and may involve splitting - * leaf nodes and even splitting intermediate nodes up to and including - * the root node (a special case of an intermediate node). - * - * "Remote" attribute values confuse the issue and atomic rename operations - * add a whole extra layer of confusion on top of that. - */ STATIC int -xfs_attr_node_addname( - struct xfs_da_args *args) +xfs_attr_node_addname_find_attr( + struct xfs_da_args *args, + struct xfs_da_state **state) { - struct xfs_da_state *state; - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int retval, error; - - trace_xfs_attr_node_addname(args); + int retval; /* - * Fill in bucket of arguments/results/context to carry around. - */ - dp = args->dp; -restart: - /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - error = 0; - retval = xfs_attr_node_hasname(args, &state); + retval = xfs_attr_node_hasname(args, state); if (retval != -ENOATTR && retval != -EEXIST) - goto out; + goto error; - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) - goto out; + goto error; if (retval == -EEXIST) { if (args->attr_flags & XATTR_CREATE) - goto out; + goto error; trace_xfs_attr_node_replace(args); @@ -955,6 +944,38 @@ xfs_attr_node_addname( args->rmtvaluelen = 0; } + return 0; +error: + if (*state) + xfs_da_state_free(*state); + return retval; +} + +/* + * Add a name to a Btree-format attribute list. + * + * This will involve walking down the Btree, and may involve splitting + * leaf nodes and even splitting intermediate nodes up to and including + * the root node (a special case of an intermediate node). + * + * "Remote" attribute values confuse the issue and atomic rename operations + * add a whole extra layer of confusion on top of that. + */ +STATIC int +xfs_attr_node_addname( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + int retval, error; + + trace_xfs_attr_node_addname(args); + + dp = args->dp; + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_add(blk->bp, state->args); if (retval == -ENOSPC) { if (state->path.active == 1) { @@ -980,7 +1001,7 @@ xfs_attr_node_addname( if (error) goto out; - goto restart; + return -EAGAIN; } /* From patchwork Wed May 12 16:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24FA1C43462 for ; Wed, 12 May 2021 17:06:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8501613D3 for ; Wed, 12 May 2021 17:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239719AbhELRGS (ORCPT ); Wed, 12 May 2021 13:06:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48582 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239721AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG8wl7053056 for ; Wed, 12 May 2021 16:14:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=iH8DBhHTdRUsmaxPrKlOxJnFoOqyqiNHSPKWeZB5Nd4=; b=dAHM3QqFVyOJTCzDA2JfEgk2zFnMJozrj8+TKJ7gcFftG+AFX935IOkbwM0LloyzIIry PQTSVNRSq5knDDmTpn8fcItIMJIxDyJJjVd4mUoyDWL+HP5Ouaai4Box2yXqvnqlVo5Q 31eyEwc1RSnXyY+UmB1svRN9C6dAXHQXyTSedwLkQFJlzIByN9scGbIMb3P2QfXeMaak trR45bhN6qMyiFZwcFKQotBDSXBmzrN0vteoCN1uYL2KtUAOY3WTLdiKYkynXOyCS63x DccNn/TTPDFD/OHSGnZGVgTE16LTBZ0jRQIOJWb0oFWLKAzjvIQGqeqkxeC+vKcrc0ps 9A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 38dk9njh8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9fYY021006 for ; Wed, 12 May 2021 16:14:29 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2049.outbound.protection.outlook.com [104.47.57.49]) by userp3030.oracle.com with ESMTP id 38dfryyw0g-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G6UgCvR6me4yxwWFDnxeHGZGqHWmBknMOlXqIg7j6a3rLTvo7Y9+m/GMghLTQ5J+fg9qbdwgxdoD8wuhabTpWh3jugRhxz87SVaYseIz31kPOwqK1YTEf+P6/VI1BH325TSnF+6AzqvSvG/I7yN9V7MUGjs///nVctt4iqW/r7uocdB78OPoAuu7dwQvZFN90FyQALEiRccQVihZrnZeeGppTDJz9B2I2ODqWrKot74MIZIYNJ7PQa2xWrg8k5Pt0uC6EFT1kB+l03shx3ASWH+uLMGYASLEz1a0DOjzGnC/xExLarWiFMtVMArroy0NFTKaT/xCY8u1IrQsYT97Ow== 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-SenderADCheck; bh=iH8DBhHTdRUsmaxPrKlOxJnFoOqyqiNHSPKWeZB5Nd4=; b=M9IL9vnA1RSbMJcvw0y65TPqgsaD7j9JgmtNvF+LjWKEsfvtviLCLRC8EC0CQPEfmbz3V58uyrG7LI1qTSOnuilJ50ZxgAOn/Md5eh225D9TOGmkBY0+Hi7QdJIFFaNmvQgcuMnSibiEIteuVcI0LOuRB3DfphsunIlD14OlQkMHFoafEcgWTMQyTSpnrXLBR/ya/A6uYVaG6BzWVRtl5v/BNBMJi94VUBdQ8QHIfR7+MHUEU6pPaRVsEF5S0jJ/frQBQleDIP11KpQf6K8CD/YY7AoIu+gYb2eeP3XbQooQ1xANQJ5fsW3YWmJU6P3ol8p5F4c9a6Sl9xgwh4XQZg== 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=iH8DBhHTdRUsmaxPrKlOxJnFoOqyqiNHSPKWeZB5Nd4=; b=sZ8ZKJUmra1BZ4SSGHQnRAoD0i3khMG0GXSivRMs09GU+oxR2cyrFQupjPUQajicoirQWvHXKnvvi8xqEAImYKSNQk3aBGd1o3ydH/MO3XrzzoTgFQktF9cTSV3WgWROXodP5+aVNGIvP/4cm3uVK2iJ070UmegDFRky9XxYSE4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:25 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 07/11] xfs: Hoist xfs_attr_node_addname Date: Wed, 12 May 2021 09:14:04 -0700 Message-Id: <20210512161408.5516-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 750fa6a6-da2b-454a-3a9a-08d91561028a X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oShJJqdo8GDn1/REULdfF7pfSsmMLCBxy3S/myaWIuMabPdzv+sHRoK4QqIuYtQw6+cQ6UGaBnvHeixxrX6+N+hhwWkyp40gzGP709zh+DiId3u679PGXbNMGdA/2Ic2FXTcIlAQnZQr0b7r7a4cuDtGiz28UNMJQXOWexgxgX6fF38i/fSyIlBWHGMMlKjQkljunBMYKV9p5hwdlSXp2ZZI9OT51x4p2d+HqlEP2S4LTPhYsXX/OISP13nk3oynj/YMhL4GRRKTGoIgcAfg4u+Yp/KIMzInw/dQx1tamYqBpL1245VFYB1BKw7qoK4WWOOoNdoJI6M/GwwqiUS2SW24WhCDmiZ9+ZS2uPj1oPKKOreK0c9yy8HpRTfn2d9XM7JZZTG41NwnXFIN1Z+wUAZ6gRdMLqaOz2NhYkHz5ysbSiCktLVjchQ+2cx7cvkUcWc8N0tb8L/Lu7twtjVE8A9wfQAvMl93XSr2kWLHGzEaMH8Ys3PMIv/cvD0rO7igMl66uWvVnECm2n4wAIq/Ro9jgbqiLjV68yOBGAYjkRAvwFxRYScZRew3fRD63eKTOjfspljb+Qw2vrOpiOQFLtrPK7ZlkOaWdyq5qnhfE1RUPVZFltzJ/GuQygxHxUoneZsC6WpLsoQn4CajR7gHUYYsqgzZ5IpGsOhtyp+MtNDAPBRWERYrGL07zvGipZTk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7NubTiVBwufQdY07LMg6JgyttV5ZlnN2h6D4Ru1Ghs9InuflpWpKVprD+FtmTDDf9JX0dyaw2zD81JbGfisdyiCy+j2EM/NtCA523N878lBHXYwtIkE7oOscjfA6CpF7vp2BiTGVvDE3QVQQMwNyz7ZueBBwwNSD80tGaRe2t7zDXBiQpf0ieaIGOCTkXMxD3zThAycrx7yPRhjvqoNpqyeAn3CELPZzTqtMjkleqy0llaCCdgXmE+FGedLb1EGPJAk8WK1Gbs+DIsOcxSLrkY9EIiXKUj+you5KRTXzSl/U1xAF5BQ9lvMMyzGLnkNgR5cS26BpQgj9AOq8a4lavHam/C9b2ZVaLtEfITY98qhUe6RsGjeP86xDkmv78wEvClECG2g+VWiqGyRzSCnKKbYBP2qTpjiTXFaYiUj8Wa4OjUYFdbV4GU9HUIxOv8Si9HJxCdScO9X6cwp/Go9aNHV4WWNKUflaCuz6KeimeGmcQHUA/hCs0sAyUA+jezB6Kn418+3/o85bsvEtlsXMiWHdlnquH58gmU9jGxjQTAYNTgd7wNEvG/zMiD6Mine4hqjsPpmG0+qSRbu74fxqmFqfyaX6d4skHsUb0HXsypzjEz+L0BB0vPnuL2uToiIezkZuK+DUzuqTY17wydwT63vsYezWKQJeGJ2lZU7N81oTG4EaCuW1ukSbYdeeL/14ukfldxtwdyvoQD4uiVQzpw+WiYQc6oK0uIgea0mdBQWVupeWPUfUOQuJMMDWSjGv495xgl6QlVJEHoX0x6goHNUPCCzUB+bZSUV3eXffvnjKYu0iAK+mLIahfz+WKbVcw1gehypZyWUv/624yUNpidjtJ5OY4jKTSJvntjM5JoDvtMABAIzVdxEak6/x4y/t+vna3mYlFpy6ziWyx2m3jqt8dICsUjEb5ouYgTup/z8aJPpCXghwktdWr9xp6Jq1AdmFODzY0wuZELPkcHkNCDLYenEP8E10pFuXVCTf2a7AKTzU+oNA0StVKH1kPqEkBuMgRC69iquP3OzZzu+E5nOBBZyptqC7v2Ua1EG2s5AnrWG0C8f0mOiK6ITrh8xH7O+uJScgX83vYjsbBrPE4VL8cEn9/ua8+uzHo9+VkhzgWTShRGs6OkWLz43RvqsH3/RXOamkBSh73lQaVguHacm5/KcD//INcmkT9tVKaNtVDKs3zC6y9ib/htIXojxNJbIUoj9SVVatt1aUSNn1gTGWppcQsJsGxeovDleE4GV2jM+3sizyrdG3gCza1klAiPxWTwyYVJOJSZY0yMqBHLE0YffTR4fWprNB4WFsp0uiMfD7lPBEuyZwgvekFCPF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 750fa6a6-da2b-454a-3a9a-08d91561028a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:25.0112 (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: ybmjzsUOJ+kU5VlEGmapdDgD8izRBcTydfOPhsQa04Fn0i7pkz8JIdIOcywzzJA57sRUJrFH34KeNwsyyKH6hziUhH1b9tdtHKoP1OancqU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-ORIG-GUID: U_9Y3Dc7XnTi2DnT3P7pJyBcoNdRS2bO X-Proofpoint-GUID: U_9Y3Dc7XnTi2DnT3P7pJyBcoNdRS2bO X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch hoists the later half of xfs_attr_node_addname into the calling function. We do this because it is this area that will need the most state management, and we want to keep such code in the same scope as much as possible Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 159 ++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 84 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 8a60534..3cc09e2 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,6 +52,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); +STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, @@ -290,8 +291,8 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_da_state *state; - int error; + struct xfs_da_state *state = NULL; + int error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -342,7 +343,75 @@ xfs_attr_set_args( return error; error = xfs_attr_node_addname(args, state); } while (error == -EAGAIN); + if (error) + return error; + /* + * Commit the leaf addition or btree split and start the next + * trans in the chain. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + goto out; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } + + /* + * If this is an atomic rename operation, we must "flip" the incomplete + * flags on the "new" and "old" attribute/value pairs so that one + * disappears and one appears atomically. Then we must remove the "old" + * attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the "old" attr + * and clear the incomplete flag on the "new" attr. + */ + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in series + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; + + /* + * Dismantle the "old" attribute/value pair by removing a "remote" value + * (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + error = xfs_attr_node_addname_clear_incomplete(args); +out: return error; } @@ -968,7 +1037,7 @@ xfs_attr_node_addname( { struct xfs_da_state_blk *blk; struct xfs_inode *dp; - int retval, error; + int error; trace_xfs_attr_node_addname(args); @@ -976,8 +1045,8 @@ xfs_attr_node_addname( blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_add(blk->bp, state->args); - if (retval == -ENOSPC) { + error = xfs_attr3_leaf_add(blk->bp, state->args); + if (error == -ENOSPC) { if (state->path.active == 1) { /* * Its really a single leaf node, but it had @@ -1023,88 +1092,10 @@ xfs_attr_node_addname( xfs_da3_fixhashpath(state, &state->path); } - /* - * Kill the state structure, we're done with it and need to - * allow the buffers to come back later. - */ - xfs_da_state_free(state); - state = NULL; - - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - retval = error; - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - error = xfs_attr_node_addname_clear_incomplete(args); - if (error) - goto out; - retval = 0; out: if (state) xfs_da_state_free(state); - if (error) - return error; - return retval; + return error; } From patchwork Wed May 12 16:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 541D1C43470 for ; Wed, 12 May 2021 17:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13D3B613DA for ; Wed, 12 May 2021 17:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238143AbhELRGK (ORCPT ); Wed, 12 May 2021 13:06:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55674 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239710AbhELQPi (ORCPT ); Wed, 12 May 2021 12:15:38 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGA6SJ028481 for ; Wed, 12 May 2021 16:14:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=NYCBjTkB0ufDS/cT1In+t4bRFyWQh1tJLthLRHR8kK8=; b=slyZRldL9tqVeHz1VJVGv/B5tGJWkwASgl2jyhLAd7CwbyJLrO86EEt7dPYrULgpXwcD eTc2P9mIJMWC3OsDDFMsCOr3OhCcfEHFC1wXr3FyKaZzRQPHlHTWoXFqk7oEuEpIAG30 Yh+sFnV+ws3uE2M1J22D1oVTaJGBECg7i/OWSxWthqTW6s5ZUts9Zhw01EG/GwB719wk PatblIcOLeNDDboQHqGMVzProGh7OkaqK3whUl6pQRm5jltm0xvk4h4bF7mAxiFJlxrx dLEwKRjhhLyTYG8iwSGksJ+dRkLYYfsfE4UqcwEYioPB1aprt9umH89W4t5QSONsoj1f rw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38e285hua1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGApnn142059 for ; Wed, 12 May 2021 16:14:27 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 38djfc4w78-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SE31Qs+nta1tSnb+orZcBdFRtijo2tF3ppyeW8gbKXSfmTX4PDE970Z4pPz8X8mQhcK5HVFfoYODXql21xOPTJV6NQCDrEtEyvoNVXSAw64NLn7i3m0v0/6AsoW5nZEl2Wo7FOwNz0mkQqI2ujTbHI+sc/Bz4KX9uD2a46fHkbWjwcYvrDPjYLLVN5WMn8IEZUKuG+Ih1iVOXsbT+g3n4/gaQa+gyoz2l4V/etTo2IqOPkTV59Am20NC7wVci1PqUfEchdLPYd82AiWLC0szDGuB+z8DlEO4Mp470Rk+QKEUVoJAXh8hM52lViQpM9sKcf1aPrtKnZPpTwiJDWICWw== 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-SenderADCheck; bh=NYCBjTkB0ufDS/cT1In+t4bRFyWQh1tJLthLRHR8kK8=; b=Tpd2uUup/DjnrLGaXvRYtWye0TBx+u0qksdujPnqwHkSiqAlmkh6W124z0gsAMx0NfSQJO47qk5KLa3xAU1gCYHThBRIs0wgB7RsqNL6umEitmg5NYr4dG+by+TFPy2M37Sgu7HZiXdIZuGwUqryGbeVuox+AAXpVEw8Om0UyKuu9XUmmum+GLqtvmSpU7SEuBftWpp9aJiphCyljhckdK4AAIZYP3qzd+R4bFt03vivEi7rHF/+pX2Hpy1kP0L/fw4dKeX8l/5b7eLkjlcrd7shsZLokbKOuGYgDWk31Ilt2ZXSRlqOlq73sqAIJkvyClcv09h4iSjwCJjigFryTw== 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=NYCBjTkB0ufDS/cT1In+t4bRFyWQh1tJLthLRHR8kK8=; b=cTbB5BxKyiLmRtgAgilOzUl3FF5qwd8eo8ikO66zl7HjVj18YYCaJusWHMN013NA6cpBp4BhcKYGD5LHiTIkG+TsP++UeSZGFphSlxCYsh8OxpY4xz/GDW/5u48UR5rYML6j1Drlu8+l8Qezluwuh4f7nktrvgSD4FaKJ2vjxho= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3336.namprd10.prod.outlook.com (2603:10b6:a03:158::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.29; Wed, 12 May 2021 16:14:25 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:25 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 08/11] xfs: Hoist xfs_attr_leaf_addname Date: Wed, 12 May 2021 09:14:05 -0700 Message-Id: <20210512161408.5516-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5940d3b-55ef-402f-a4cc-08d9156102ca X-MS-TrafficTypeDiagnostic: BYAPR10MB3336: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kx3T0AgymsH5jOopGHgggqQ8nSB5S8zJ6SSzFSbbA8PYcr41OUk2vuB74f5VuYMTWlfWM5dJ3PtIFUtjEjrnbto65NmwF1YDlIHGiTPrLJw/u9hE5BEbAZR5n/EjhJZd1837oVPgZ4I/Wdz852aFYubL2T43m4ANPKEDMVlo1QmFXd7ohKntt4W7a/ewXhme4DiZknDMCZId6RUGIyJ+gFiz+9T+T/ZEAH6XqkCve+bQ88IwPJO808JSIzisNer89lq5D4wo71W9v8ChCTNC2Qgf8II2v12LQisGH19fWNDBtzs9KFu6rJq2U0XMGntR3+5KxLV6HK/i1WJ8p7CQYKYaFtont9Af7y/qabkV/lYga/ofk5vaojRYN0EvZM7XtFxZPv7HRfqns9tu0s6C0AIBTs+oYT0rygsYlaA370ET9cGtslClG/XS50T5orsw2c8liI4J6Y6NcMrWX7U15U+W/g7M5lQmHSY0KTgnYRVKr6wBtGKQ/3cDc9j2AtJsG0Azki4aMIlsheo1FmBa1FL9MZsqyn1Ps0/uZWR+gixLune0PJlL3MPNipdOC/buZw4q0aqYF5wqOU3K9iC76d3qHjIFjrmUXhx1hYOE+3MkemoUUH7EA84UQ5xXjc8wSb8afivrBhOi3AJ8ND4JxCwUNxmdqUiw4OdN4ZKN/OY14Rf+BrK0U5YHICaXhxEM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(376002)(346002)(39860400002)(396003)(366004)(2616005)(66946007)(1076003)(66476007)(6916009)(16526019)(26005)(6512007)(956004)(36756003)(83380400001)(38350700002)(6486002)(478600001)(8676002)(38100700002)(2906002)(6666004)(316002)(186003)(8936002)(44832011)(6506007)(86362001)(5660300002)(66556008)(52116002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3qTbsV+bvTgqzCQxBXLLm0wOdbmGKmWMsmfOn+S4RvvuYD0eu4thBIygfypx98HMrOy7WOlx3T/sD0iWZOsHH6H3nOQN2ku4B+xIpX7ds7xLJmNShl/zRwtvSuB5xoAXKexH63K50+z/FELCYIg7UpRmd+89NKKwaihkkdSjXhAMa/nti7YdQjzy6icVC8Q5dodTqF/IeSi+TryL1DAMUmL1eevMrwyFUVzVaziE5cipBArGj9lErW7wjxOe9gV08k28D/GkjDtuvtcUID41lP7PL/HsN5XX22wM4stYlyzm/Pv5uAlsX8NdmN0oGPJMxv3G4UAefYyefnQoe4s0HXDMLRVRkOlxHfKT3fwjbEI9GMJETuspHDqV6r6MTppHQBdug94O72gKFPR9TlDnxIBo1D3mrChFVunVycCSrdWrwfo8lpARf8Vvjw0jNPUmFp+zB0bkz0ij4RGXuU3wl8fN7ta477Jdbe6FWzSJYzU0Pgmvhn01TUOi1EZA61lOM5NieB8cYQjNAsqWTWxhXK4y6gaybdR/qYKHNlrLx4zlTWVzKKK4ZVq0Hhlc6v9PWHZm5/PxqgWRUtL8jPmhbi6iNzPm8zhW5fOKwl3zCFLNCjMxNxvaZJXY4O63DWKjvcBD0VlJsr//fHnxKpeaSp7L0T3aQkhnLCRYyC6ph/IHnbFqVTZBVW/ZhCwoFNXmWR3vek/PQvFwKTnzepw4iy6rncTwzFdF6/R6Btv1r+IVwndJdCD8oAbZxXqZcX5ykWQw4wr69t3MEi7cumdjTux70njvvEMmxoppNzhdh6ua21DpiNh7U98tuMv1EFUqQ7QGivFa+Pr9bT69RhnEL3mnUG5mEaNYw/6wUD28P8ahboiVbxNGlvtrSI64A66EzvwUrU+Dnzq8k9HyoC6j2TEnSoVf7/HgekP3tfKJDBI/cnSK8AuaAaG0oGHhByPL/JjlBGqJS8mfbo4/aDeE+xaKdCZpU3gSEQWTvdl+lJfRaTeCNHVAsMXHJJX0v7k+xKaQwPcx1JTEf/u736OTsRGlbtbxbrYei9LStX3RTtp5Un+JQSoRIoeoczNaL3JqsctGHysdyecsHiBaOyHQyNFaZJZXONPM8UqVgPWhMyCdz99kvkGraaNyeV7BUJprHxvhR2tZjIHbOYPAXixuA4mdREp8VzbdPLiUf85hs2a2+elKILQZC797P1AoLG03vuS49Cdc6rB3inR8RHtZYzwbRq1/vCr+pL04KDfQixOSE/YY1K18MiL14roMIYAX/qMHD6gFCLdsLBqwNQLeQfyDQffdSyzUEUKxov54ukUMJzK9KWZ/J94dOF5K2Y/p X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5940d3b-55ef-402f-a4cc-08d9156102ca X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:25.4184 (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: qWniiCvgWVkrxfelW0O5QuijdDB2G+Oc5C60fC3r1YQ1NZQF0KbnFWQWcauPM/DiKV4qgcNXbmX37za9DKHrw8TJNUzJVsnHrhXTlg6/13c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3336 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: vQTF0fd0kCLDpSWzmZVeL5g8FjYNMPHZ X-Proofpoint-ORIG-GUID: vQTF0fd0kCLDpSWzmZVeL5g8FjYNMPHZ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch hoists xfs_attr_leaf_addname into the calling function. The goal being to get all the code that will require state management into the same scope. This isn't particularly aesthetic right away, but it is a preliminary step to merging in the state machine code. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 209 ++++++++++++++++++++++------------------------- fs/xfs/xfs_trace.h | 1 - 2 files changed, 96 insertions(+), 114 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 3cc09e2..6edc3db 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -44,9 +44,9 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); * Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); /* * Internal routines when attribute list is more than one block. @@ -291,8 +291,9 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; struct xfs_da_state *state = NULL; - int error = 0; + int forkoff, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -307,10 +308,101 @@ xfs_attr_set_args( } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) + error = xfs_attr_leaf_try_add(args, bp); + if (error == -ENOSPC) + goto node; + else if (error) + return error; + + /* + * Commit the transaction that added the attr name so that + * later routines can manage their own transactions. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + *flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + return error; + + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + /* + * Read in the block containing the "old" attr, then remove the + * "old" attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + &bp); + if (error) return error; + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + + return error; +node: /* * Promote the attribute list to the Btree format. */ @@ -737,115 +829,6 @@ xfs_attr_leaf_try_add( return retval; } - -/* - * Add a name to the leaf attribute list structure - * - * This leaf block cannot have a "remote" value, we only call this routine - * if bmap_one_block() says there is only one block (ie: no remote blks). - */ -STATIC int -xfs_attr_leaf_addname( - struct xfs_da_args *args) -{ - int error, forkoff; - struct xfs_buf *bp = NULL; - struct xfs_inode *dp = args->dp; - - trace_xfs_attr_leaf_addname(args); - - error = xfs_attr_leaf_try_add(args, bp); - if (error) - return error; - - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - - return error; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - - error = xfs_attr3_leaf_flipflags(args); - if (error) - return error; - /* - * Commit the flag value change and start the next trans in series. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - /* - * Read in the block containing the "old" attr, then remove the "old" - * attr from that block (neat, huh!) - */ - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, - &bp); - if (error) - return error; - - xfs_attr3_leaf_remove(bp, args); - - /* - * If the result is small enough, shrink it all into the inode. - */ - forkoff = xfs_attr_shortform_allfit(bp, dp); - if (forkoff) - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - - return error; -} - /* * Return EEXIST if attr is found, or ENOATTR if not */ diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 808ae33..3c1c830 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1914,7 +1914,6 @@ DEFINE_ATTR_EVENT(xfs_attr_leaf_add); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_work); -DEFINE_ATTR_EVENT(xfs_attr_leaf_addname); DEFINE_ATTR_EVENT(xfs_attr_leaf_create); DEFINE_ATTR_EVENT(xfs_attr_leaf_compact); DEFINE_ATTR_EVENT(xfs_attr_leaf_get); From patchwork Wed May 12 16:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C48C43616 for ; Wed, 12 May 2021 17:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 494CF61363 for ; Wed, 12 May 2021 17:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238619AbhELRGL (ORCPT ); Wed, 12 May 2021 13:06:11 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:60190 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239719AbhELQPj (ORCPT ); Wed, 12 May 2021 12:15:39 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGAREe005168 for ; Wed, 12 May 2021 16:14:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=lWTj+lTZidiJiPK4WClnpscjlQicWH8NOxdMwtp5Tcs=; b=KyIifu2QUkNS22rKbPoLXXFLsN+v7HvdM/wqUIYMPxDrCktl8I/hD2nc+X9Si9rSxZfc x6BDfv51JUARffwFA8BwN1Ig0QNg5h9ZfsTaMRQ4w1jcOQMGrRErhGfGHuFZ6GZLiYYn Nb3KRunpopN6dEXBeYBikfCj4Ukpzi4CxdMBp9eNqjpe8zNRYPa+f9Bjb5es6dGQj+re SZ0J6Jx5qaL/Hr275PMDBQ0xw/a52b+SzbD9779kO6ntNgG+kyFz5kzbGl9aSZzzlO9a zjlPwYxfE5Zi1bOfrYFXq43xjxF/b7AJ03iy5P+ZI02dpcfJ3jNR10xzMOm8QeH2nPcx 1g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 38djkmjjn3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9swp194902 for ; Wed, 12 May 2021 16:14:29 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2045.outbound.protection.outlook.com [104.47.57.45]) by aserp3030.oracle.com with ESMTP id 38e5q026eb-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k/wtdFRVto/wasV6vk1HXdex3VSRDpKXRy3GAxVEyIj4U5FLxTjtQU3W9QOC0g8QOqbdthv+efMme6R3fKYE68hWHGr68qGNVQ5YLu6AbGu9Z5aCd9qoU/onv7M5wp7EnUHfh2PR7OHdWRjv/54liXXphdtDnkWebZEceBSqx9sPcqjENrnHTZb7HaBRuemtMoC4nIOrp2XtA9Kcdmrn3XD67IfuIfOqHdo71uogUmAqF4BJ0g9dc10w0zOV5tt8l1q3AMHKVy5xdeYCN0Qj4fVJi47gk4goDl0B0hsVW9VGLyJPZHYqpWIqfSa/CbQTNoNwOgZYqNDhPM8ImC7+IA== 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-SenderADCheck; bh=lWTj+lTZidiJiPK4WClnpscjlQicWH8NOxdMwtp5Tcs=; b=U/vkB15OPz0oQPd30/8+LamN+X8lmgmgvksDjPtQALYiPJXe+pRXzQZXhc9G2+BrOvWEm+RRRn93FhUZm+UwpB9yNo2DuXSUJVY8R/YvSHpsVCNHnnTBMRAXlzHONcukf4j1s+vOXIqSjm8TNu/HNRvefmDUbSm0xB8V3xkb8nn1PNI50Fn6clUGoR1F//sQMLMB10B/B4aRYvL+TRpndPNjmkoQCJz5BBPhYpfkrYB7KTRTCMJHOYeAQDKEWSCoHYxxoW0b8Mr521NBtzymsKv9sfRV0VPZg+uPpcQZivQ6UKY2lMyhv0olcbO043FOhut2+vEj492ceACvSdOwOw== 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=lWTj+lTZidiJiPK4WClnpscjlQicWH8NOxdMwtp5Tcs=; b=tKnbJMnVCaQ3BI0AB3d4nzo9dnEwosD8hB8pdsdGZhu/EQ4CWMvh8yZwl8i9OAoaZPhhcYH5b940YTFret5+rf2KvOV4niV+pVdRX059ZU6bX2w4x4V9ax0Ez/jOGw+L2FGvF0D5+DVTBOatnjLttNGWuGqFaCvGUmvXGFMUCb4= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:25 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 09/11] xfs: Hoist node transaction handling Date: Wed, 12 May 2021 09:14:06 -0700 Message-Id: <20210512161408.5516-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c84ddf6-1c01-4584-3c46-08d915610309 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hp3g8VaBC0Kf54d1QbH8Vv+tanJ0v2tvGRyepRAl7k/IZGJt4GijGAqbC8YKAHtRyAFBc5HXpO+gnv4x9ph70Sd9zMTD+pxMvFXHZrYjOS0iGW83YSy2P9+o5jSvpTZb8RQ98fee5sIDJVK6XtpNgl7IfO7fkelhT2W+9BJXd2NSKfkY+3VWUEHN4nYrRzlsalkEw9DnhHXGc1Ri7fh7Za6mNA3r9JlzMbCiU+gDUQas+CL76FKFjSnH330aUFEcyPi7LokhStJHKQ8cKrQpzEj5o6LMfHD8KPhheyncVWziJEh+1OSBqF+1WDLHZ8mfqbOeKtoh+zSHwBja2Iw5xPWJ09rge6QPBl9YtgHAIqo24pyuGd8XC34Lb2AoHHpx7flvLRgAK4JnhbhKGbs1uyuDReWM2W02G8Ro0JR6bTUXtDFHX67EfNdMA7oMxWwVW3ZFqH+x0+6ohqkSKjCrPVcfq/Ljo5H+MGQv9cFr2vaeRCUjnyhJxcUIWbySl4zYzpi8IQAGzKovNyh3m9vBS9uLSTJKg0Wgkee+m93zVPGz0VSeLCn1YmgUciISppJJgHDf5DpE3WFfGnchDJOqwPdMU9+BHDe9qL3aGQh7Y5sZBm/ZOrxXncElkW/1605W6U0IMJ5qo+axDcuycOH5YpIiXg+wx9UEAChC5kEw2ycHADhrMzH5Qh60eGwRWem3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7zvjEgW3TR23o5lfKKgqJ/Qeq6N5J48drAxWlkBIso1jmGSgyxqJQzJxF99U4KEKQ4ffJiUUd0cRF0lFkif9RlMtkNeGcoYBsjDeUlI3egAD6KvTKwxUU0NXJ4+a2uePX7iO2M9efzhHDw8xHXBJgxPPRVIIf1LwYLsDvB/86j9VVm7kRk1jJ5dTdWB+ThRsjgDprdaRqi3HTteSrIrhxllcMZfeBgCg9X7DmEtGESdruN2w959jbLebxI2Lz9jTHX1c/3cqVEuvL9fwDfFKibiWtJH+X7ljns7jyWjJO+GShipAwTf9lC9+OAEUym7alglbGm6tbc1yysr4NpPUg/bO2Wsr23X/sf4FoRWFZCvgLCaLlrX9nSUlv+bgCrynJmSaTkkwbV2nPEi5JbPJfKpsr6jyXtTiIHz72wb/hqmrDb8IY3ZkkuTfKpETnrMXE1uQUxxPsc1wU3816oPqKP3kb49Tl74v+m4cAyOKrvJs2e31ubb1AZkisuoL5Vs7xFeIYBxNB4Tku4hjSVnrwF6WP4A6AWUCg3DMmTCRO1eLmX2LbMM55l8uPLKmrULBfN3F6gXU/97G91BHVzAMD1BF+yoMIIplMR8hD1ayVKVNi0fukWWyDTudd/ROmrhRM8fV+7POAgrRaLc7WzdDcnQ3m7bS40fmskRF/tbQudr97KX6WTQMBJYr0v9TSQyq8nvapu7+QPGkjoopFsvw6aBlDehSLO48MdpDiXN62zRTJGCUdkq97FZoumDN5XqG4rrCfW/2F18gCwm0D+dlG/nOOQp6Lr/WS/Q4hF8lk2cyaVt4hquepjkodMT5/mdLEXmlBqQOuS3/GdM4hCtARU54uxKDy/C/oCmdC6MVM2ltp0chwxIWQPlTmNJ5nT2Q3xGuIvYZmFxWgeF3flSdd1X+xuaOhnq+Vg8SutWGVm2kgF0qYAxEiIdhUfqzpMFKptMUjNTBxllW8SWOlcHTZpXK4vFLfsHMWo61ZEZyzQJSW4Wduag0Aqz2R9+FT0B0uZO0bL1Lc0jwSrQrTPkJ2cmQzdrH7NcxK5r8ivO90Wc3pyolb6HGA8bR+oSvh78gPEycfC8v0lRe4mWHE73O1cj5jmAeV2Rmd8nxz/YRMIIXQ+CBbYQBop/gN4qSgNoZyaYbAjI02qba1FpGgB+TLk54b2eRuRVACqFK32GFO2FM7sC9Hlog9m4zlvrLGAk07NGJc82di7PmI1J5mZ3l9PwmiLEiCgTvOqaQiXbN1I0/Ay3/FtWWNJBm6iee96WYoD1kzA8GQSLOv1wpAY3tFErjIJdidFG9GfpP1hESaV2Eii0zwbdBOaXBfqUhofh2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c84ddf6-1c01-4584-3c46-08d915610309 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:25.8584 (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: hO/1e02mloBssV039SiK19KnWR2j54D/eRUe03zSZ4INmIkwq6qhK3W3tg0XVm+ZAqnSooYs5oukvlNeIsd7MzQbZutHuAtN8TgkNqNBwkA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: te1dj7qnbVaAL849rNEjwv_TyTFlt_oB X-Proofpoint-ORIG-GUID: te1dj7qnbVaAL849rNEjwv_TyTFlt_oB X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch basically hoists the node transaction handling around the leaf code we just hoisted. This will helps setup this area for the state machine since the goto is easily replaced with a state since it ends with a transaction roll. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 55 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 6edc3db..21f862e 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -309,10 +309,36 @@ xfs_attr_set_args( if (xfs_attr_is_leaf(dp)) { error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the transaction once + * more. The goal here is to call node_addname with the inode + * and transaction in the same state (inode locked and joined, + * transaction clean) no matter how we got to this step. + */ + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + /* + * Commit the current trans (including the inode) and + * start a new one. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + goto node; - else if (error) + } else if (error) { return error; + } /* * Commit the transaction that added the attr name so that @@ -402,32 +428,9 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; + } node: - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); - if (error) - return error; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - } do { error = xfs_attr_node_addname_find_attr(args, &state); From patchwork Wed May 12 16:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41E6CC43603 for ; Wed, 12 May 2021 17:06:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09266613C9 for ; Wed, 12 May 2021 17:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245073AbhELRGa (ORCPT ); Wed, 12 May 2021 13:06:30 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48586 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239726AbhELQPk (ORCPT ); Wed, 12 May 2021 12:15:40 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG8v0x053014 for ; Wed, 12 May 2021 16:14:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=me3C4nEfwQK4R2UManbiZwUmw4sD5S3WVGJVlFN1cwY=; b=zT/aslhU7N2Jc0UdxWlH9jY4b1JD2jYsK4BMd6MqZ1kSu0bLEb0BVej+xeRP8O7gDu8Z Gj2r6/Wx774ZzwlbjnecZltps5Im9BUTgMtg2/jZBmp3ypYuAi0kIUQoKkYNxHPh7aIG oYvegSdlRgtAJ0wPq7+ago36kXlkCgur5ez1a9QUApz5eCDd6MSvaE21NZtnHcgKKG+S LrfN7UfVFACBnMMmt4msQaTHd6L4A9Hg7ZTrLhExF5ZJqHo9uHOhjRX71VS30iqenV9Y QWbyXng4RO4H/9LaTM2FEMYO7jAyvG33od9I3RWihyzfxfoGGWtVGMxNq+bP+DyRmlLM qQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 38dk9njh8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9swq194902 for ; Wed, 12 May 2021 16:14:30 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2045.outbound.protection.outlook.com [104.47.57.45]) by aserp3030.oracle.com with ESMTP id 38e5q026eb-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T7gczt4KAmePNou4YP4hT8uZrmvcCMBhOdK/jSHqwz/8V+Dvpv3yhdcFUH45zAIxIgJWNYzIfBoF5mt2sOglS6lT2k4GRtTu0s0cpky1uNUf5GlDvC35Z29gIFMUruLDQFt2Jzvj2j/Gs1lnosooTVrbGjFb/pnT1kKTA13sWjyLB0oNqPBpsufdTMkWY/9yUB4mBMfjJp555hUvebwRrq+vQ6uNZG4apzX/3TLpB1mYTYDGwYvSb32pn2tH9wtRG4d07QmqDffRYRkVJRw9wqwi80wBk+O9gVmzfrN6bAFgRgsrqNitC55Z5og6I3B2Ec1nMOjbT9Q0wd0Bcw6s8Q== 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-SenderADCheck; bh=me3C4nEfwQK4R2UManbiZwUmw4sD5S3WVGJVlFN1cwY=; b=goxBgl8PE+SbaocF0RpNV327vx8k/7C3TR9ZvekC1jQAZVlg8J3DdAtxHbHrPV4jCoHIEAjd5KnF+m0E1p2PFsC4gSoad9GYto5x1tDxyCD3il9Vw2hWNh5PTOdjvikvVxb+SohUbLlZlXESpDyEL78R2vqQ3VDmpIaCjUlRKLeyGgISnRzXleuGqAfkvzDK2xUmaNYdo3jTiDZNhm3YC9XpxfMMyZp2nevXANZCE1bWUH9gSNRHnKUufp/uZJiY7TGFA2sglcqnu7pgVI01mdACkBQO8HJBgOgmz1oZRcF9s9LwaFthab81aULoFDGkl9Ns7Hge78vtzyECu/8BZA== 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=me3C4nEfwQK4R2UManbiZwUmw4sD5S3WVGJVlFN1cwY=; b=Si5t5CKNpRIO9TSgEFxWBzlu/mqiibCHQ/P5Ie+cuRDLvpLAM5szAtVKSrR0DPtPbrVqEgSMw9+caihsQqhpZ5vuA2kmBc7EQuGi9hfqSGjqp87N/QMLPQ1ChuRjLKmH3R0tuKrrAxlvZROAIqTV7qWqIiSorPUcvDbR9JMCpzs= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3112.namprd10.prod.outlook.com (2603:10b6:a03:157::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Wed, 12 May 2021 16:14:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:26 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 10/11] xfs: Add delay ready attr remove routines Date: Wed, 12 May 2021 09:14:07 -0700 Message-Id: <20210512161408.5516-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50b297bc-90d7-452f-a66a-08d915610349 X-MS-TrafficTypeDiagnostic: BYAPR10MB3112: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ckpgHuq6nuvhR9IwzTqdOsYVsY1dmwJkaUhbfz7mhGiqOiicoSBICFIiea+4N5PQqaSi/6Nh3P81LeV7bv3htXAxwzhA4313MAmggNGe1aoA5fdal1HqM/9ek78tyD+6OYa5UYrXExG+HBpCIP7/mxcVBVsy4fnApV+lbIxFJadYfvQhiUUZr6KoDIUVxlCWsuFue3MpXmqmFSmqaSE262oUGrexNrMgyuhTa6IG0bjpng3l2Bh+GyiZ+pkUShMNaGHh1pWAIxqQmDHN9SQKDOlGs8JSHlU9rps9DdZxMbgtDLOyYgKToNXNyN2ImAsbXwKOptmbCyuIdcALqPmHzg1mdg4+EEoUINCntU5fQ8TYYYeCP9KvrbRj3loAXMBM4pC2FYfLHVytHzdBPwpQ8gkYMqwNT55ApmxGuTRuFhg45A6ICLXMardE7uH7VnMJcuuvCICc8XkTTH0zVCbBQCdjCL/LIUqlx3fm9Wef3LqbW/rZhd5CY5RbKb9y3brBvcxyNqpDc1pyb9UqeESW8FQX8R7/edRL+TSfDv+1nB8aCUXD4/4FJ/+OfDJVAGWUYZojZF9sTRUGvzggsoKFymjl3Ms927qQP5Vax3bkZwo/GIx+4BZRwY3iF/+JM9ZVjsCzTBSuTfYRzap8kh+qNw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(136003)(346002)(376002)(39860400002)(366004)(478600001)(316002)(66946007)(38350700002)(1076003)(52116002)(2616005)(5660300002)(30864003)(36756003)(8676002)(8936002)(66556008)(6486002)(6506007)(83380400001)(44832011)(2906002)(6916009)(186003)(26005)(38100700002)(16526019)(66476007)(6512007)(6666004)(956004)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?C2qQ8fxkclOTrBH57Q9ekCnrItFNDs?= =?utf-8?q?+gVZCrA72A988pFRgVXSKvvPGMgXGzDaPMSVrMCzhrSO+pYH0lB05ZVU+/RurqKb5?= =?utf-8?q?iuFvA1HVe6Dk6Sd2Dy+gOn8y/FX9Fd9zvbdN/Y1p1fT+EA6AyUq4wclkT2IOALo9f?= =?utf-8?q?kyYoLnrMk6e3Tjxj0Oh192KUrBBp1sZi+rVFLtQ8q9OHPuRbrFws1oMWaIHVWYn9Q?= =?utf-8?q?u2LizNGWzSUHrEn9PMcNGxTI8CwhIBk/mZZJ8XxGxs2GSG84s3U36MbjIY6YR99lu?= =?utf-8?q?YSVyfaxJI5PPh8kxIMXf8RNocAHNgHnSdAZmKGZN/OPrQb3cgREsm4rqpFCwh4Z6f?= =?utf-8?q?QFxgSQ3ziBVvnxRtb9Q0hZArMp4PxdyGGHCSj9YGCwfyfL/3ooGuZObreE2DlokHd?= =?utf-8?q?GWS//QbXTPFEOqPBC5Hs7+pc82X0ANvt5RXa93ehvpH5ynzBrGC3RW6g46T07Q12B?= =?utf-8?q?z4wQOKb6TAtyrsvwIhUy47Hpuo8egDZi2yg9BW4nJhl/Fw5viNKKrCKOAVycoJhTO?= =?utf-8?q?zTR7qLQ8yDNkI3tvBGUUCqQ9L1C59kimsBePtbX8OQ8G+upqNq0ORJnXuvhYszH5P?= =?utf-8?q?QaxvPAQuBSI3qrpHC+PGlUdfgWFWmOBf09gziS8KZBtjdj6fjw5aBseOPKNZ4JXnm?= =?utf-8?q?BLe72qcqJn+0beR33BDpebcWSJdFA3wAMGbSzqQBrwE8AVGAJEcCDUowZ0FI2pg0z?= =?utf-8?q?Pp4h1pvEBMWCs/ks2KA9Rugl0O+/OCW/HBHorSdIr58vg3uMqHPWQaJMEbPoa7T1O?= =?utf-8?q?4kKP58sal0WJ1PyckVMJkUR08xd/2Rwmr3/NqpchJHO5OYehOPIq4B6UE2rRmmuRL?= =?utf-8?q?/+5cU+NP805kPHmpqktaePCTpY6aQBf4lQajflMIDPNqoB7N7ZU+/qLDJ0Pr+sIzH?= =?utf-8?q?xL3UXznJU8FxjznKMBTfzshQXzMAnh8ibdGhoDX8ceDGh2khuNCYeXWFaxGIqEi9g?= =?utf-8?q?h02HJfA3Tx68z5Ko9rrL9xkmiwkqReFZRxr9+XRVrDa14pVVi9yvRIKoR81j67obd?= =?utf-8?q?iYRG7Or15vg0A9m4/Yq6nhF4KAx9M/PILR91H7IOIeWW3VUkoUuY9aIW9G7+2lFrj?= =?utf-8?q?wCLUdpCf95jbd/1h7QJLe+0rUItHWYs1Xx5cjdizB5Im6bDJ4MEgksvQ2H7Vj2ai4?= =?utf-8?q?/U0w8o1NqrMMQgtQ+nLoYC3bSJ7BsESXrpyYuO4NEG9DM8bnxjXdtYwbvwipcMCfm?= =?utf-8?q?INYwoBRKqxu6d51+UnhoyKT7nZbk9f6yK8tq/ODfAsyuDqrhTgSbZT3xa3v+G4ow+?= =?utf-8?q?W35ugq/Bvd8dFX?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50b297bc-90d7-452f-a66a-08d915610349 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:26.3085 (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: h57jdevwhDZzuhdc/ndXrLZFe7EHzL7f8L8MyvHMGvLbTQ+U5MeVstU9WnZFkmLymiWlOxO2tMwoi3OJfrvETMe8R3xBGDlElRa7DKko93M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3112 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-ORIG-GUID: CP_JOSi1KVQbx3Z12IGHW_HS5OCd99xr X-Proofpoint-GUID: CP_JOSi1KVQbx3Z12IGHW_HS5OCd99xr X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args is merged with xfs_attr_node_removename become a new function, xfs_attr_remove_iter. This new version uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. A new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A new XFS_DAC_DEFER_FINISH flag is used to finish the transaction where ever the existing code used to. Calls to xfs_attr_rmtval_remove are replaced with the delay ready version __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done. xfs_attr_rmtval_remove itself is still in use by the set routines (used during a rename). For reasons of preserving existing function, we modify xfs_attr_rmtval_remove to call xfs_defer_finish when the flag is set. Similar to how xfs_attr_remove_args does here. Once we transition the set routines to be delay ready, xfs_attr_rmtval_remove is no longer used and will be removed. This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls. See xfs_attr.h for a more detailed diagram of the states. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 213 ++++++++++++++++++++++++++++------------ fs/xfs/libxfs/xfs_attr.h | 131 ++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 48 +++++---- fs/xfs/libxfs/xfs_attr_remote.h | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- 6 files changed, 314 insertions(+), 84 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 21f862e..a91fff6 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -57,7 +57,6 @@ STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, struct xfs_da_state **state); -STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); @@ -241,6 +240,31 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +/* + * Checks to see if a delayed attribute transaction should be rolled. If so, + * transaction is finished or rolled as needed. + */ +int +xfs_attr_trans_roll( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + int error; + + if (dac->flags & XFS_DAC_DEFER_FINISH) { + /* + * The caller wants us to finish all the deferred ops so that we + * avoid pinning the log tail with a large number of deferred + * ops. + */ + dac->flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + } else + error = xfs_trans_roll_inode(&args->trans, args->dp); + + return error; +} + STATIC int xfs_attr_set_fmt( struct xfs_da_args *args) @@ -544,16 +568,25 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - if (!xfs_inode_hasattr(args->dp)) - return -ENOATTR; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; - if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) - return xfs_attr_shortform_remove(args); - if (xfs_attr_is_leaf(args->dp)) - return xfs_attr_leaf_removename(args); - return xfs_attr_node_removename(args); + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + } while (true); + + return error; } /* @@ -1197,14 +1230,16 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state **state = &dac->da_state; + int error; error = xfs_attr_node_hasname(args, state); if (error != -EEXIST) return error; + error = 0; ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL); ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == @@ -1213,12 +1248,15 @@ int xfs_attr_node_removename_setup( if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) - return error; + goto out; - return xfs_attr_rmtval_invalidate(args); + error = xfs_attr_rmtval_invalidate(args); } +out: + if (error) + xfs_da_state_free(*state); - return 0; + return error; } STATIC int @@ -1241,70 +1279,123 @@ xfs_attr_node_remove_name( } /* - * Remove a name from a B-tree attribute list. + * Remove the attribute specified in @args. * * This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). + * + * This routine is meant to function as either an in-line or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and recall the function until a + * successful error code is returned. */ -STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +int +xfs_attr_remove_iter( + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - int retval, error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + int retval, error; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (!xfs_inode_hasattr(dp)) + return -ENOATTR; - /* - * If there is an out-of-line value, de-allocate the blocks. - * This is done before we remove the attribute so that we don't - * overflow the maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; + /* + * Shortform or leaf formats don't require transaction rolls and + * thus state transitions. Call the right helper and return. + */ + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) + return xfs_attr_shortform_remove(args); + + if (xfs_attr_is_leaf(dp)) + return xfs_attr_leaf_removename(args); /* - * Refill the state structure with buffers, the prior calls - * released our buffers. + * Node format may require transaction rolls. Set up the + * state context and fall into the state machine. */ - error = xfs_attr_refillstate(state); - if (error) - goto out; - } - retval = xfs_attr_node_remove_name(args, state); + if (!dac->da_state) { + error = xfs_attr_node_removename_setup(dac); + if (error) + return error; + state = dac->da_state; + } + + /* fallthrough */ + case XFS_DAS_RMTBLK: + dac->dela_state = XFS_DAS_RMTBLK; - /* - * Check to see if the tree needs to be collapsed. - */ - if (retval && (state->path.active > 1)) { - error = xfs_da3_join(state); - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the Btree join operation and start a new trans. + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a + * deadlock. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } + if (args->rmtblkno > 0) { + /* + * May return -EAGAIN. Roll and repeat until all remote + * blocks are removed. + */ + error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + return error; + else if (error) + goto out; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_attr_is_leaf(dp)) - error = xfs_attr_node_shrink(args, state); + /* + * Refill the state structure with buffers (the prior + * calls released our buffers) and close out this + * transaction before proceeding. + */ + ASSERT(args->rmtblkno == 0); + error = xfs_attr_refillstate(state); + if (error) + goto out; + dac->dela_state = XFS_DAS_RM_NAME; + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_NAME: + retval = xfs_attr_node_remove_name(args, state); + /* + * Check to see if the tree needs to be collapsed. If so, roll + * the transacton and fall into the shrink state. + */ + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; + + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_SHRINK: + /* + * If the result is small enough, push it all into the inode. + * This is our final state so it's safe to return a dirty + * transaction. + */ + if (xfs_attr_is_leaf(dp)) + error = xfs_attr_node_shrink(args, state); + ASSERT(error != -EAGAIN); + break; + default: + ASSERT(0); + error = -EINVAL; + goto out; + } out: if (state) xfs_da_state_free(state); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 2b1f619..32736d9 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -74,6 +74,133 @@ struct xfs_attr_list_context { }; +/* + * ======================================================================== + * Structure used to pass context around among the delayed routines. + * ======================================================================== + */ + +/* + * Below is a state machine diagram for attr remove operations. The XFS_DAS_* + * states indicate places where the function would return -EAGAIN, and then + * immediately resume from after being recalled by the calling function. States + * marked as a "subroutine state" indicate that they belong to a subroutine, and + * so the calling function needs to pass them back to that subroutine to allow + * it to finish where it left off. But they otherwise do not have a role in the + * calling function other than just passing through. + * + * xfs_attr_remove_iter() + * │ + * v + * have attr to remove? ──n──> done + * │ + * y + * │ + * v + * are we short form? ──y──> xfs_attr_shortform_remove ──> done + * │ + * n + * │ + * V + * are we leaf form? ──y──> xfs_attr_leaf_removename ──> done + * │ + * n + * │ + * V + * ┌── need to setup state? + * │ │ + * n y + * │ │ + * │ v + * │ find attr and get state + * │ attr has blks? ───n────┐ + * │ │ v + * │ │ find and invalidate + * │ y the blocks. mark + * │ │ attr incomplete + * │ ├────────────────┘ + * └──────────┤ + * │ + * v + * Have blks to remove? ───y─────────┐ + * │ ^ remove the blks + * │ │ │ + * │ │ v + * │ XFS_DAS_RMTBLK <─n── done? + * │ re-enter with │ + * │ one less blk to y + * │ remove │ + * │ V + * │ refill the state + * n │ + * │ v + * │ XFS_DAS_RM_NAME + * │ │ + * ├─────────────────────────┘ + * │ + * v + * remove leaf and + * update hash with + * xfs_attr_node_remove_cleanup + * │ + * v + * need to + * shrink tree? ─n─┐ + * │ │ + * y │ + * │ │ + * v │ + * join leaf │ + * │ │ + * v │ + * XFS_DAS_RM_SHRINK │ + * │ │ + * v │ + * do the shrink │ + * │ │ + * v │ + * free state <──┘ + * │ + * v + * done + * + */ + +/* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then recall the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_UNINIT = 0, /* No state has been set yet */ + XFS_DAS_RMTBLK, /* Removing remote blks */ + XFS_DAS_RM_NAME, /* Remove attr name */ + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + + /* Used in xfs_attr_node_removename to roll through removing blocks */ + struct xfs_da_state *da_state; + + /* Used to keep track of current state of delayed operation */ + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -92,6 +219,10 @@ int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); +void xfs_delattr_context_init(struct xfs_delattr_context *dac, + struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 556184b..d97de20 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -19,8 +19,8 @@ #include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" -#include "xfs_attr_remote.h" #include "xfs_attr.h" +#include "xfs_attr_remote.h" #include "xfs_attr_leaf.h" #include "xfs_error.h" #include "xfs_trace.h" diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 48d8e9c..2f3c4cc 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -674,10 +674,12 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_da_args *args) { - int error; - int retval; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; trace_xfs_attr_rmtval_remove(args); @@ -685,31 +687,29 @@ xfs_attr_rmtval_remove( * Keep de-allocating extents until the remote-value region is gone. */ do { - retval = __xfs_attr_rmtval_remove(args); - if (retval && retval != -EAGAIN) - return retval; + error = __xfs_attr_rmtval_remove(&dac); + if (error && error != -EAGAIN) + break; - /* - * Close out trans and start the next one in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); + error = xfs_attr_trans_roll(&dac); if (error) return error; - } while (retval == -EAGAIN); + } while (true); - return 0; + return error; } /* * Remove the value associated with an attribute by deleting the out-of-line - * buffer that it is stored on. Returns EAGAIN for the caller to refresh the + * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the * transaction and re-call the function */ int __xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - int error, done; + struct xfs_da_args *args = dac->da_args; + int error, done; /* * Unmap value blocks for this attr. @@ -719,12 +719,20 @@ __xfs_attr_rmtval_remove( if (error) return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - - if (!done) + /* + * We don't need an explicit state here to pick up where we left off. We + * can figure it out using the !done return code. Calling function only + * needs to keep recalling this routine until we indicate to stop by + * returning anything other than -EAGAIN. The actual value of + * attr->xattri_dela_state may be some value reminiscent of the calling + * function, but it's value is irrelevant with in the context of this + * function. Once we are done here, the next state is set as needed + * by the parent + */ + if (!done) { + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; + } return error; } diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index 9eee615..002fd30 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -14,5 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int __xfs_attr_rmtval_remove(struct xfs_da_args *args); +int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index bfad669..aaa7e66 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -15,10 +15,10 @@ #include "xfs_da_format.h" #include "xfs_da_btree.h" #include "xfs_inode.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_trans.h" #include "xfs_bmap.h" -#include "xfs_attr.h" #include "xfs_attr_leaf.h" #include "xfs_quota.h" #include "xfs_dir2.h" From patchwork Wed May 12 16:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12254331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D16C1C43462 for ; Wed, 12 May 2021 17:06:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9503C61419 for ; Wed, 12 May 2021 17:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241296AbhELRG2 (ORCPT ); Wed, 12 May 2021 13:06:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55688 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239722AbhELQPk (ORCPT ); Wed, 12 May 2021 12:15:40 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CGA6Gw028454 for ; Wed, 12 May 2021 16:14:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=apBVEMCECGqSZXvhn4W4+W6k+OReoYJds97WK7QSpdA=; b=Z7bjofih6nFhd5A9UkPbLhp+BDywQE8cyMBpS26qcX9b7qeJ0E7xeW/7NobKXYVXmCqZ +0TAToVWgzqwm9zA9zmKatak0MCKU4OoPaY+XdC7foMM5Kgll8NoEuVIVvAT8MmTPquc dRS+pZfBgaO2HGxTOR08Z9v50Jn/XH8gzdAqEoGdmOOrfApX0EuSeKJ2MyCRFdn6PMFU ZqJ2CWGsyAHd4X6IfkcEnpew+TpxcVA49XAjmaF+XcfOfJ4SrR/DpEn7QHj3y7bvPcl4 Y+oiuFf88vau5lzPftFXLFdHHiFu0IHkIE2QBhTjq4jo4znZTY+Enc5cJ/xsgX8LCYEp LQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 38e285hua5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:30 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14CG9fj7020986 for ; Wed, 12 May 2021 16:14:30 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by userp3030.oracle.com with ESMTP id 38dfryyw16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 May 2021 16:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cOrOmgDYMf6MusMGyB3a9A5SiNC3TfhknU5tp0q6tXjs/NIkD/o7nfXlFT1y7cne+SQSgPN2Q5EvB3rRUq4psHPpWik5oV4ICO98oekirhsDQOEn/QtJoXEEFKz5Gx97T/PwUfja6NwHpYk5Otcm9THx/qmP3+H0FfzV+SCGp0R87qMgre4nFXuuDDQxnwclmeU2TRlBJSFxAcgAEvQoTFmQbzFTWGG/Gt02gWpkMv6DCVlforzEtvhaGGeWfNchxKQeaL1Y327xMZvZ4vLLsVbpvuOMvJm4YgoBijS1tkFcrKrNdnyfEaaZQ0zS5dOprgxiqsQ9vHFyat7t8gXOag== 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-SenderADCheck; bh=apBVEMCECGqSZXvhn4W4+W6k+OReoYJds97WK7QSpdA=; b=cwVIuAjit4B17hdjSFJ9i2zGKVCV+FZ+MS9Z8AoCLjBgk8OQDbHJooBf77UgazQd4OzM9xFdpHqcMuowZp6w8yFn8PCTv16Xm0dp5LNbFxEYkn/Y2F87KmfHY0gPLG4rgsi9VqBruhofjpaiM8sPmdD3fbA44r5lVEsD/hmZkEmI7hyDYN635HWUaaws/4fbDIngj03rQ0EMnrZOlYMfFpzLogg5aQ3WUcl8k2PQKMJ0OB5FF/lndlMAC7ViAvYMFndz0fX1G7KZs/sgyQnyzoCrkUeKifl28TOGr60EAPl9tuQ47gcA5I0jugisci1Tdjtgv1Hvjaz914FqUijxRQ== 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=apBVEMCECGqSZXvhn4W4+W6k+OReoYJds97WK7QSpdA=; b=qCaZK2FqcYeXnT9lRHcKQ2ICJ83lMl9NKSF+cBkManc/XK/v8mAKLAZUgf4DW+6yg2KMANI010MU6Qy6rhnKzXfBch9BeUHUgi/aa2z9o2Akx2pwvngrilC0pTCmqFvtBeHznmhjzW294I+GABaUhJZNZ3Wo1DnnGDJJpHjRKD8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com; Received: from BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) by BYAPR10MB3336.namprd10.prod.outlook.com (2603:10b6:a03:158::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.29; Wed, 12 May 2021 16:14:26 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4129.027; Wed, 12 May 2021 16:14:26 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH RESEND v18 11/11] xfs: Add delay ready attr set routines Date: Wed, 12 May 2021 09:14:08 -0700 Message-Id: <20210512161408.5516-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512161408.5516-1-allison.henderson@oracle.com> References: <20210512161408.5516-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by SJ0PR05CA0200.namprd05.prod.outlook.com (2603:10b6:a03:330::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.11 via Frontend Transport; Wed, 12 May 2021 16:14:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05a6f8a4-ff1b-4208-47b8-08d91561038b X-MS-TrafficTypeDiagnostic: BYAPR10MB3336: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bS0Xc+RWRxgCD6h+OLENuuirTimJbi+SqhS7DrbI+RhncXQSISPLSWTyYULitVzs9jPslhKhUz/JKwQ1otgA4px0Z6joSCGjXpN2t7jZPsRd/wdxr/N/fze7ctTU2QVR5hzm1y3kMW/qBDlZkCt8YGirdazaT1r75hOgM8DqID23hwwC8b5Ema3oDGOB/QB0604RAAR3I/Ku/ZiYC6Dye1AFlT12jJPghdKEVE/ORfoCsEKNn6hbnC/p6GN2noVcH1FKO3x8XVdxcRzxH5zBVREbceZvgIYhhUBSuIAl1wzP7pDlgFIiIMUk2GkT0bPG4gUb12rlzPcDF8r+lcmGdk5I2kB0KdYOjDyCAjBWv0dejkYSORceuPQ9mBKAFBnI++2HyOQXL8dPlEDjJCUg51QMwkXWpFZNghR2FqD6x1uiFW1D0ndeQBYV4PRIL85Idl7AOmMJz77xtm1hCCgjloGdrgt5IdwJZoMvt0KAKqyzunf5NFunylp/1Labf5O4w7QdJ+uWtrtBabt5UFqeF7MTvK5xtpozNWiysjx3GQEi5gJvHmCguvSlwiHnrisOlri1Rs8aLaxVqGnolhwWynkMcxAPCx/qbhBBFxE6ycGy4JMlFeVQ8rfo80yhyTl1LcJrScUWlTNmycbyXMEfOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(376002)(346002)(39860400002)(396003)(366004)(2616005)(66946007)(1076003)(66476007)(6916009)(16526019)(26005)(6512007)(956004)(36756003)(83380400001)(38350700002)(30864003)(6486002)(478600001)(8676002)(38100700002)(2906002)(6666004)(316002)(186003)(8936002)(44832011)(6506007)(86362001)(5660300002)(66556008)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?mit8kthi0HWf65cUqd4VaxjkABQyH3?= =?utf-8?q?meSii4kQqWIu7IKgRm2qiaxXopSLWCntTkc8CLYH5l6H0r7Sew4a9mS/HgSLuqeTs?= =?utf-8?q?pg5An0rNODnFOq2Bmk3h7L8qcMl3by55Kz6YvYCxMT+h8WnOvSLSY9rwb0PWTDVH7?= =?utf-8?q?ysPuPxa5YrA4VBGWdIUODEj61CXe1all381UWNdCdoVwr7U4ScW+vtP06JnSBf7AG?= =?utf-8?q?BfYyt9LB5qujgDsimfT8bIGd8Le7gZbsYv23Im6wm6C+cPbUvXvFWlk3okQzFHJ3O?= =?utf-8?q?JSlMSrQLtkfmZmSl6HgF/FxY6h+ji8VWka2CfXtg5JVMe/A01v2Dq3qkC5e6vsbN7?= =?utf-8?q?b4cxNpge1U2aev4DDJ1QVtv1EAFttmU1rC2rQylJmKRfKCRXptthQsrMf+oHWvrKn?= =?utf-8?q?T0Nvqd6NxZv/gH0+dbuF/5jVNnxQwo55k7Yh8MyMR5BU95TaLR7IhWzdkAovqneaB?= =?utf-8?q?BuSvyb6aso3aW8yewvGKLz0f3f90fmwr4v3qgw+wjFXzeGdIjyrvcqMeHUsBUjk3F?= =?utf-8?q?aBKjyxoK5qf3QLZNqhbWlK8Xvza52uVUr4682z/tMX40HsUHInD9RzBNDfGDcpPWS?= =?utf-8?q?zyvZVzh+x3+JVRO/1yaXC2qWItj4A4vwmN8J4le139k4H6FjZvnQsuzB8pIw0K6X0?= =?utf-8?q?94tt9bJemazwdJnWlKIdG7KlUPcuWXJNJUPmL8Vsy9+OHWVHaC3/5d+vJMBhEuEU2?= =?utf-8?q?OiPwATB/GMqPHHk8l5c/3l5vXFgKxmzTxCC3ZRBI9kCvsMDpTjRD+yfgr6HAiEvgB?= =?utf-8?q?cu0WHHuG0GShjkaEHAB7laBJaJBjCRMKeyPZW1eBdHyQlPYcGjTZSSLC+s+pqHHlC?= =?utf-8?q?Shl0g9bmQBcSnrHk92Pc1e/CQy6L/xdqfbY5/C+eRVA7pt0xJcjLom96sEV17OPa4?= =?utf-8?q?I77PZLGpb+Adh5dWEzGfmHKGqIK7uaHvMU47JIOuH83A2QlsBsQUm4kPBi7B74tOt?= =?utf-8?q?E1XgWp4kze5b0b0+zPFNjRX4tSCZZGrQg9ZHa23hD9JmZgjDu+bceQJzfLQnsqdiR?= =?utf-8?q?gXqtrfRl+/Kv4Uzs2QmerGu7YO281tVEpIRGC34NErIRbGOpGopDYZLuIf+M2kwzd?= =?utf-8?q?w75hS4z5L6JlDZxEhy0IUTsIcp/Bo8JIeGQmImM06TLoLqPUtz0fmh0BkWGFxuOlA?= =?utf-8?q?UQBWfkFZ80HFlfe40Pc9KRSnhFO/KyBq+S2gTGQakYZHLfWBulx8ZkNBg1GemqOAL?= =?utf-8?q?fYhXUDG3zwC4vKZOLm2vrE+RkSp/NQreQXlN3NR68on3b3zYxCBcQdoEFJSs7ZSc2?= =?utf-8?q?hJ3O2E0dIObg4n?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05a6f8a4-ff1b-4208-47b8-08d91561038b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 16:14:26.7685 (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: geOcgb3xGPIlCevT7LuG19qeYqjBDtUFL5pzcPlEW0B9HlUvwKztlAAZ2hWe8H38JcE8iNDs1LkaTYrQrqK53azPZn1jLFNeFuQevBHhJB8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3336 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 X-Proofpoint-GUID: 784ClvcF5qbMKNHfphSF7cTG8J6J2Wdm X-Proofpoint-ORIG-GUID: 784ClvcF5qbMKNHfphSF7cTG8J6J2Wdm X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9982 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105120102 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr set routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_set_args has become xfs_attr_set_iter, which uses a state machine like switch to keep track of where it was when EAGAIN was returned. See xfs_attr.h for a more detailed diagram of the states. Two new helper functions have been added: xfs_attr_rmtval_find_space and xfs_attr_rmtval_set_blk. They provide a subset of logic similar to xfs_attr_rmtval_set, but they store the current block in the delay attr context to allow the caller to roll the transaction between allocations. This helps to simplify and consolidate code used by xfs_attr_leaf_addname and xfs_attr_node_addname. xfs_attr_set_args has now become a simple loop to refresh the transaction until the operation is completed. Lastly, xfs_attr_rmtval_remove is no longer used, and is removed. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 450 ++++++++++++++++++++++++---------------- fs/xfs/libxfs/xfs_attr.h | 272 +++++++++++++++++++++++- fs/xfs/libxfs/xfs_attr_remote.c | 100 ++++++--- fs/xfs/libxfs/xfs_attr_remote.h | 5 +- fs/xfs/xfs_trace.h | 1 - 5 files changed, 608 insertions(+), 220 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index a91fff6..4096418 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -53,15 +53,16 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); -STATIC int xfs_attr_node_addname(struct xfs_da_args *args, - struct xfs_da_state *state); -STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, - struct xfs_da_state **state); -STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); +STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_clear_incomplete( + struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_inode_hasattr( @@ -244,7 +245,7 @@ xfs_attr_is_shortform( * Checks to see if a delayed attribute transaction should be rolled. If so, * transaction is finished or rolled as needed. */ -int +STATIC int xfs_attr_trans_roll( struct xfs_delattr_context *dac) { @@ -265,29 +266,58 @@ xfs_attr_trans_roll( return error; } +/* + * Set the attribute specified in @args. + */ +int +xfs_attr_set_args( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; + + do { + error = xfs_attr_set_iter(&dac, &leaf_bp); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) { + if (leaf_bp) + xfs_trans_brelse(args->trans, leaf_bp); + return error; + } + } while (true); + + return error; +} + STATIC int xfs_attr_set_fmt( - struct xfs_da_args *args) + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_buf *leaf_bp = NULL; - struct xfs_inode *dp = args->dp; - int error2, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + int error = 0; /* * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } + + /* Should only be 0, -EEXIST or -ENOSPC */ + if (error != -ENOSPC) + return error; /* * It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + error = xfs_attr_shortform_to_leaf(args, leaf_bp); if (error) return error; @@ -296,102 +326,130 @@ xfs_attr_set_fmt( * concurrent AIL push cannot grab the half-baked leaf buffer * and run into problems with the write verifier. */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); - return error; - } + xfs_trans_bhold(args->trans, *leaf_bp); + /* + * We're still in XFS_DAS_UNINIT state here. We've converted + * the attr fork to leaf format and will restart with the leaf + * add. + */ + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } /* * Set the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + * returned. */ int -xfs_attr_set_args( - struct xfs_da_args *args) +xfs_attr_set_iter( + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_inode *dp = args->dp; - struct xfs_buf *bp = NULL; - struct xfs_da_state *state = NULL; - int forkoff, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; + int forkoff, error = 0; - /* - * If the attribute list is already in leaf format, jump straight to - * leaf handling. Otherwise, try to add the attribute to the shortform - * list; if there's no room then convert the list to leaf format and try - * again. - */ - if (xfs_attr_is_shortform(dp)) { - error = xfs_attr_set_fmt(args); - if (error != -EAGAIN) - return error; - } + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + /* + * If the fork is shortform, attempt to add the attr. If there + * is no space, this converts to leaf format and returns + * -EAGAIN with the leaf buffer held across the roll. The caller + * will deal with a transaction roll error, but otherwise + * release the hold once we return with a clean transaction. + */ + if (xfs_attr_is_shortform(dp)) + return xfs_attr_set_fmt(dac, leaf_bp); + if (*leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, *leaf_bp); + *leaf_bp = NULL; + } - if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) { - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) + if (xfs_attr_is_leaf(dp)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + if (error == -ENOSPC) { + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to + * call node_addname with the inode and + * transaction in the same state (inode locked + * and joined, transaction clean) no matter how + * we got to this step. + * + * At this point, we are still in + * XFS_DAS_UNINIT, but when we come back, we'll + * be a node, so we'll fall down into the node + * handling code below + */ + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } else if (error) { return error; + } - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); + dac->dela_state = XFS_DAS_FOUND_LBLK; + } else { + error = xfs_attr_node_addname_find_attr(dac); if (error) return error; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); + error = xfs_attr_node_addname(dac); if (error) return error; - goto node; - } else if (error) { - return error; + dac->dela_state = XFS_DAS_FOUND_NBLK; } - - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - + return -EAGAIN; + case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we * identified for its storage and copy the value. This is done * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + + /* Open coded xfs_attr_rmtval_set without trans handling */ + if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + } + } + + /* + * Repeat allocating remote blocks for the attr value until + * blkcnt drops to zero. + */ + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + return -EAGAIN; } + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + + /* + * If this is not a rename, clear the incomplete flag and we're + * done. + */ if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete - *flag. - */ if (args->rmtblkno > 0) error = xfs_attr3_leaf_clearflag(args); - return error; } @@ -404,7 +462,6 @@ xfs_attr_set_args( * In a separate transaction, set the incomplete flag on the * "old" attr and clear the incomplete flag on the "new" attr. */ - error = xfs_attr3_leaf_flipflags(args); if (error) return error; @@ -412,29 +469,37 @@ xfs_attr_set_args( * Commit the flag value change and start the next trans in * series. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - + dac->dela_state = XFS_DAS_FLIP_LFLAG; + return -EAGAIN; + case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a * "remote" value (if it exists). */ xfs_attr_restore_rmt_blk(args); + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + /* fallthrough */ + case XFS_DAS_RM_LBLK: + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_LBLK; if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); + error = __xfs_attr_rmtval_remove(dac); if (error) return error; - error = xfs_attr_rmtval_remove(args); - if (error) - return error; + dac->dela_state = XFS_DAS_RD_LEAF; + return -EAGAIN; } + /* fallthrough */ + case XFS_DAS_RD_LEAF: /* - * Read in the block containing the "old" attr, then remove the - * "old" attr from that block (neat, huh!) + * This is the last step for leaf format. Read the block with + * the old attr, remove the old attr, check for shortform + * conversion and return. */ error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, &bp); @@ -443,97 +508,116 @@ xfs_attr_set_args( xfs_attr3_leaf_remove(bp, args); - /* - * If the result is small enough, shrink it all into the inode. - */ forkoff = xfs_attr_shortform_allfit(bp, dp); if (forkoff) error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ return error; - } -node: + case XFS_DAS_FOUND_NBLK: + /* + * Find space for remote blocks and fall into the allocation + * state. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + } - do { - error = xfs_attr_node_addname_find_attr(args, &state); - if (error) - return error; - error = xfs_attr_node_addname(args, state); - } while (error == -EAGAIN); - if (error) - return error; + /* fallthrough */ + case XFS_DAS_ALLOC_NODE: + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + dac->dela_state = XFS_DAS_ALLOC_NODE; + if (args->rmtblkno > 0) { + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); + if (error) + return error; + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + /* + * If this was not a rename, clear the incomplete flag and we're + * done. + */ + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + error = xfs_attr3_leaf_flipflags(args); if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { + goto out; /* - * Added a "remote" value, just clear the incomplete flag. + * Commit the flag value change and start the next trans in + * series */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; + dac->dela_state = XFS_DAS_FLIP_NFLAG; + return -EAGAIN; - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); + case XFS_DAS_FLIP_NFLAG: + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); - if (args->rmtblkno) { error = xfs_attr_rmtval_invalidate(args); if (error) return error; - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } + /* fallthrough */ + case XFS_DAS_RM_NBLK: + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_NBLK; + if (args->rmtblkno) { + error = __xfs_attr_rmtval_remove(dac); + if (error) + return error; + + dac->dela_state = XFS_DAS_CLR_FLAG; + return -EAGAIN; + } - error = xfs_attr_node_addname_clear_incomplete(args); + /* fallthrough */ + case XFS_DAS_CLR_FLAG: + /* + * The last state for node format. Look up the old attr and + * remove it. + */ + error = xfs_attr_node_addname_clear_incomplete(dac); + break; + default: + ASSERT(dac->dela_state != XFS_DAS_RM_SHRINK); + break; + } out: return error; } + /* * Return EEXIST if attr is found, or ENOATTR if not */ @@ -997,18 +1081,18 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int retval; + struct xfs_da_args *args = dac->da_args; + int retval; /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - retval = xfs_attr_node_hasname(args, state); + retval = xfs_attr_node_hasname(args, &dac->da_state); if (retval != -ENOATTR && retval != -EEXIST) - goto error; + return retval; if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto error; @@ -1034,8 +1118,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (*state) - xfs_da_state_free(*state); + if (dac->da_state) + xfs_da_state_free(dac->da_state); return retval; } @@ -1048,19 +1132,23 @@ xfs_attr_node_addname_find_attr( * * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. + * + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + *returned. */ STATIC int xfs_attr_node_addname( - struct xfs_da_args *args, - struct xfs_da_state *state) + struct xfs_delattr_context *dac) { - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + struct xfs_da_state_blk *blk; + int error; trace_xfs_attr_node_addname(args); - dp = args->dp; blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); @@ -1077,18 +1165,15 @@ xfs_attr_node_addname( error = xfs_attr3_leaf_to_node(args); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the node conversion and start the next - * trans in the chain. + * Now that we have converted the leaf to a node, we can + * roll the transaction, and try xfs_attr3_leaf_add + * again on re-entry. No need to set dela_state to do + * this. dela_state is still unset by this function at + * this point. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -1101,9 +1186,7 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1120,8 +1203,9 @@ xfs_attr_node_addname( STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { + struct xfs_da_args *args = dac->da_args; struct xfs_da_state *state = NULL; struct xfs_da_state_blk *blk; int retval = 0; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 32736d9..41ad5e8 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -164,6 +164,262 @@ struct xfs_attr_list_context { * v * done * + * + * Below is a state machine diagram for attr set operations. + * + * It seems the challenge with understanding this system comes from trying to + * absorb the state machine all at once, when really one should only be looking + * at it with in the context of a single function. Once a state sensitive + * function is called, the idea is that it "takes ownership" of the + * state machine. It isn't concerned with the states that may have belonged to + * it's calling parent. Only the states relevant to itself or any other + * subroutines there in. Once a calling function hands off the state machine to + * a subroutine, it needs to respect the simple rule that it doesn't "own" the + * state machine anymore, and it's the responsibility of that calling function + * to propagate the -EAGAIN back up the call stack. Upon reentry, it is + * committed to re-calling that subroutine until it returns something other than + * -EAGAIN. Once that subroutine signals completion (by returning anything other + * than -EAGAIN), the calling function can resume using the state machine. + * + * xfs_attr_set_iter() + * │ + * v + * ┌─y─ has an attr fork? + * │ | + * │ n + * │ | + * │ V + * │ add a fork + * │ │ + * └──────────┤ + * │ + * V + * ┌─y─ is shortform? + * │ │ + * │ V + * │ xfs_attr_set_fmt + * │ | + * │ V + * │ xfs_attr_try_sf_addname + * │ │ + * │ V + * │ had enough ──y──> done + * │ space? + * n │ + * │ n + * │ │ + * │ V + * │ transform to leaf + * │ │ + * │ V + * │ hold the leaf buffer + * │ │ + * │ V + * │ return -EAGAIN + * │ Re-enter in + * │ leaf form + * │ + * └─> release leaf buffer + * if needed + * │ + * V + * ┌───n── fork has + * │ only 1 blk? + * │ │ + * │ y + * │ │ + * │ v + * │ xfs_attr_leaf_try_add() + * │ │ + * │ v + * │ had enough ──────────────y─────────────┐ + * │ space? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ return -EAGAIN │ + * │ re-enter in │ + * │ node form │ + * │ │ │ + * └──────────┤ │ + * │ │ + * V │ + * xfs_attr_node_addname_find_attr │ + * determines if this │ + * is create or rename │ + * find space to store attr │ + * │ │ + * v │ + * xfs_attr_node_addname │ + * │ │ + * v │ + * fits in a node leaf? ────n─────┐ │ + * │ ^ v │ + * │ │ single leaf node? │ + * │ │ │ │ │ + * y │ y n │ + * │ │ │ │ │ + * v │ v v │ + * update │ grow the leaf split if │ + * hashvals └── return -EAGAIN needed │ + * │ retry leaf add │ │ + * │ on reentry │ │ + * ├────────────────────────────┘ │ + * │ │ + * v │ + * need to alloc │ + * ┌─y── or flip flag? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ done │ + * │ │ + * │ │ + * │ XFS_DAS_FOUND_LBLK <────────────────┘ + * │ │ + * │ V + * │ xfs_attr_leaf_addname() + * │ │ + * │ v + * │ ┌──first time through? + * │ │ │ + * │ │ y + * │ │ │ + * │ n v + * │ │ if we have rmt blks + * │ │ find space for them + * │ │ │ + * │ └──────────┤ + * │ │ + * │ v + * │ still have + * │ ┌─n─ blks to alloc? <──┐ + * │ │ │ │ + * │ │ y │ + * │ │ │ │ + * │ │ v │ + * │ │ alloc one blk │ + * │ │ return -EAGAIN ──┘ + * │ │ re-enter with one + * │ │ less blk to alloc + * │ │ + * │ │ + * │ └───> set the rmt + * │ value + * │ │ + * │ v + * │ was this + * │ a rename? ──n─┐ + * │ │ │ + * │ y │ + * │ │ │ + * │ v │ + * │ flip incomplete │ + * │ flag │ + * │ │ │ + * │ v │ + * │ XFS_DAS_FLIP_LFLAG │ + * │ │ │ + * │ v │ + * │ need to remove │ + * │ old bks? ──n──┤ + * │ │ │ + * │ y │ + * │ │ │ + * │ V │ + * │ remove │ + * │ ┌───> old blks │ + * │ │ │ │ + * │ XFS_DAS_RM_LBLK │ │ + * │ ^ │ │ + * │ │ v │ + * │ └──y── more to │ + * │ remove? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ XFS_DAS_RD_LEAF │ + * │ │ │ + * │ v │ + * │ remove leaf │ + * │ │ │ + * │ v │ + * │ shrink to sf │ + * │ if needed │ + * │ │ │ + * │ v │ + * │ done <──────┘ + * │ + * └──────> XFS_DAS_FOUND_NBLK + * │ + * v + * ┌─────n── need to + * │ alloc blks? + * │ │ + * │ y + * │ │ + * │ v + * │ find space + * │ │ + * │ v + * │ ┌─>XFS_DAS_ALLOC_NODE + * │ │ │ + * │ │ v + * │ │ alloc blk + * │ │ │ + * │ │ v + * │ └──y── need to alloc + * │ more blocks? + * │ │ + * │ n + * │ │ + * │ v + * │ set the rmt value + * │ │ + * │ v + * │ was this + * └────────> a rename? ──n─┐ + * │ │ + * y │ + * │ │ + * v │ + * flip incomplete │ + * flag │ + * │ │ + * v │ + * XFS_DAS_FLIP_NFLAG │ + * │ │ + * v │ + * need to │ + * remove blks? ─n──┤ + * │ │ + * y │ + * │ │ + * v │ + * remove │ + * ┌────────> old blks │ + * │ │ │ + * XFS_DAS_RM_NBLK │ │ + * ^ │ │ + * │ v │ + * └──────y── more to │ + * remove │ + * │ │ + * n │ + * │ │ + * v │ + * XFS_DAS_CLR_FLAG │ + * │ │ + * v │ + * clear flags │ + * │ │ + * ├──────────┘ + * │ + * v + * done */ /* @@ -180,12 +436,22 @@ enum xfs_delattr_state { XFS_DAS_RMTBLK, /* Removing remote blks */ XFS_DAS_RM_NAME, /* Remove attr name */ XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ + XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ + XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ + XFS_DAS_FLIP_LFLAG, /* Flipped leaf INCOMPLETE attr flag */ + XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */ + XFS_DAS_RD_LEAF, /* Read in the new leaf */ + XFS_DAS_ALLOC_NODE, /* We are allocating node blocks */ + XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */ + XFS_DAS_RM_NBLK, /* A rename is removing node blocks */ + XFS_DAS_CLR_FLAG, /* Clear incomplete flag */ }; /* * Defines for xfs_delattr_context.flags */ #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -193,6 +459,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + int blkcnt; + /* Used in xfs_attr_node_removename to roll through removing blocks */ struct xfs_da_state *da_state; @@ -220,7 +491,6 @@ int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); -int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 2f3c4cc..fc71f10 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -439,9 +439,9 @@ xfs_attr_rmtval_get( /* * Find a "hole" in the attribute address space large enough for us to drop the - * new attribute's value into + * new attributes value into */ -STATIC int +int xfs_attr_rmt_find_hole( struct xfs_da_args *args) { @@ -468,7 +468,7 @@ xfs_attr_rmt_find_hole( return 0; } -STATIC int +int xfs_attr_rmtval_set_value( struct xfs_da_args *args) { @@ -628,6 +628,69 @@ xfs_attr_rmtval_set( } /* + * Find a hole for the attr and store it in the delayed attr context. This + * initializes the context to roll through allocating an attr extent for a + * delayed attr operation + */ +int +xfs_attr_rmtval_find_space( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_bmbt_irec *map = &dac->map; + int error; + + dac->lblkno = 0; + dac->blkcnt = 0; + args->rmtblkcnt = 0; + args->rmtblkno = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + dac->blkcnt = args->rmtblkcnt; + dac->lblkno = args->rmtblkno; + + return 0; +} + +/* + * Write one block of the value associated with an attribute into the + * out-of-line buffer that we have defined for it. This is similar to a subset + * of xfs_attr_rmtval_set, but records the current block to the delayed attr + * context, and leaves transaction handling to the caller. + */ +int +xfs_attr_rmtval_set_blk( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec *map = &dac->map; + int nmap; + int error; + + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, + dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, + map, &nmap); + if (error) + return error; + + ASSERT(nmap == 1); + ASSERT((map->br_startblock != DELAYSTARTBLOCK) && + (map->br_startblock != HOLESTARTBLOCK)); + + /* roll attribute extent map forwards */ + dac->lblkno += map->br_blockcount; + dac->blkcnt -= map->br_blockcount; + + return 0; +} + +/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */ @@ -669,37 +732,6 @@ xfs_attr_rmtval_invalidate( } /* - * Remove the value associated with an attribute by deleting the - * out-of-line buffer that it is stored on. - */ -int -xfs_attr_rmtval_remove( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - trace_xfs_attr_rmtval_remove(args); - - /* - * Keep de-allocating extents until the remote-value region is gone. - */ - do { - error = __xfs_attr_rmtval_remove(&dac); - if (error && error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - } while (true); - - return error; -} - -/* * Remove the value associated with an attribute by deleting the out-of-line * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the * transaction and re-call the function diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index 002fd30..8ad68d5 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -10,9 +10,12 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen); int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_set(struct xfs_da_args *args); -int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmt_find_hole(struct xfs_da_args *args); +int xfs_attr_rmtval_set_value(struct xfs_da_args *args); +int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 3c1c830..96f93a7 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1943,7 +1943,6 @@ DEFINE_ATTR_EVENT(xfs_attr_refillstate); DEFINE_ATTR_EVENT(xfs_attr_rmtval_get); DEFINE_ATTR_EVENT(xfs_attr_rmtval_set); -DEFINE_ATTR_EVENT(xfs_attr_rmtval_remove); #define DEFINE_DA_EVENT(name) \ DEFINE_EVENT(xfs_da_class, name, \