From patchwork Fri Apr 16 09:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207227 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 DE20BC433B4 for ; Fri, 16 Apr 2021 09:21:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEC946117A for ; Fri, 16 Apr 2021 09:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241668AbhDPJV1 (ORCPT ); Fri, 16 Apr 2021 05:21:27 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50072 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235280AbhDPJVZ (ORCPT ); Fri, 16 Apr 2021 05:21:25 -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 13G99wr7166540 for ; Fri, 16 Apr 2021 09:21:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=s3y+uXvy6DQ4w6fKL88k7KNxZ7/2mi2Uo096tJlS4oQ=; b=e3BwPirMxm6EgLdQoE+cPU9tVputC5Q/1AIdZ7VirAi1l15Tl57/BEwCuL+rG5tltLuL 6qPAFpj4IpmMI8sZHkWgLmPjrSwuGDSpUUxfm3Pw66eDp3kjMgf8HaZItbIzsqRjODFP CVkt7lhS8WMaRmjveslryLGKpaQxziNxITgvhob/GkqDC+0emyfTblqxD7Rqz9qcfrMo S1Qyz+/Mo2gJkuPG0E5y/baeipGKvkgf6mz38/Mts66Tyu8qEFfpCvCjeQacHVIPj+hV f1tV+FdHXEdvaR3VuyZE/pu3ukrLyYGPqvVfW7O+eSMESYc3D5IGGKUnntLIvta/3K6z Rg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 37u3errkmp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:00 +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 13G9AXSw077147 for ; Fri, 16 Apr 2021 09:21:00 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q/oKVIzmCcHlOCcC+mt0kGsog+LvkAJEkNRFRqs9LWESfQhs2nnsxLyyrcgMtQ6I4oYsO0oZY4a/tUl/IwBFaX7xmInIxlQRx7EX2i+wZn++RA4Dalk728g+qOryBtgDelKSLA8p7y6FuOdfYP5qXVhnTs4rclu1lfr0fAz1Bu8GyucBUw8wd49EQUlAFM4Yp/0Tau+yLmnbDhjqK8NSTy0tA6rS/3fbE13n7Kj9fSj2w7gU04FXmKQrz6hcmRI9RKz0oMf78AIvdhNP6AW5qSZhdqG9tJwXKwyeh887/8vhEAiXU+okTqxKWyYnOEJ0mkq6AB3wZ+BD8nipU5Bc1g== 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=s3y+uXvy6DQ4w6fKL88k7KNxZ7/2mi2Uo096tJlS4oQ=; b=UASPWSyuEr/qQPD0jLve+86kPGIa2cXG/IJZ20wdRF0NFkQWjQw7+3Eq8cI3bqPwAM/RN7A/kICgHIynbAnQOQzhRWVRgaKMR/S3/4siu/9t6FQIktIHh0d8+/eBiIMI9Uhxojlqfp3sbCWp51T4B064D6u3wRIrzlb/RtLVhK1Sz/dRZeKXmJ3NtGVZRxd9j0jEu+NAXxemtfyUiTyh4FDXBh9auMJWMfS5dF/zv9NO4I++BZoiPrg3jrcZKMZk4uO23dXgXhNUbH1ebiNALV+ZAviQ+NlyRLQbjqE0bB3BLbHLiiGg1JgYKHG14sFQYKmVTojDxwPzS12LGhNmcw== 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=s3y+uXvy6DQ4w6fKL88k7KNxZ7/2mi2Uo096tJlS4oQ=; b=gCX3yQoxlZZloEZHMmgRrDfR31ZPgGsoZ2lJMAiZ7ZQp/AjR5yrFDOT0nbatj0zJKWWaF1OvHAzQwe84FiDW22eipmkcSWhOgEiMefIra5Cmz87BZuFixEDvKDJLO9zBzb2WTzwJest4uwIjy+6C7rUAEUdFLfLcYWgdOpanvsc= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:20:58 +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.4042.019; Fri, 16 Apr 2021 09:20:57 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 01/11] xfs: Reverse apply 72b97ea40d Date: Fri, 16 Apr 2021 02:20:35 -0700 Message-Id: <20210416092045.2215-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21741c71-4a23-4b27-3b0e-08d900b8f19d X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: +GoZlT600G31yXyWN9KIrr9ahJ4bDsbOeMPjrbybOxCcOxC+xtOzelI21c0PIEa/rf5R3hI5kH/4g1utSJa07reqOC5fkCImRJeCs60lTfrxgpYaLmDSIgf0FXVedT/z17alIVWLAmDJFvNejeK5EqFLrdRoG7rqQoNn+PnKP4jL+uS7q8Vy0G8UJt58sYxVwDhsZLnbterqE5FKj7jhKAIdtRUh4vVESjX9HQ3NI0w0sp02RbwrGSNNEUTli3qprAbYiuutkJyg/qex+ulpQwwzUsfjALzhW8JKSDGe51np0MFREqdM3mZgv6FBGNIPyJpdctGGDOiH3E39bvbcUjacWSVLCGr6Ov59AVL4vql/X3m4G3tNSm6Mf4v+fd0QBaJrziZaQOmQvfBz2w2SozeUe7gWA1BKWuaCuVnCNOzc2w1VPRolKXcuF9M9gMXexmjIW47R1lCS0b6izoUilF6f0CwGOKRBz3Zt0LOhVZWCcM0QPtBrIWsBeE5zN9v7PhfatS7N4baRMz4yD4jNz6+CSU4bk1vyny+h7otHki+svqMCyopZLRsAaUyv9FRkYcUJVcPtCvYVocljjZ3yNjvSraGgl1r8uy56c1IQiP9sT+4A+gad5bXyhJI6rpljlTmOaR1o9EPkeIfpjvX3JAqb3ATYpo0OiKYq4q0X7cU+0MKwCXdWVzI3tPKWfTFj 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Q3nV9ZU5iHdCodlp5BIboqGnDE2fOdMWNFg0NmF+Gcsa3P1jagVBlhTcpFp6Cv5Z284iAMbTd5dDlPsrBEbWVcQike1K+cteND7Eyh/g/l7s1HNAJalOsyJqV8NGfGxawN/YRo2xTQiBLbsoCBnZapXxSVmw6h9CM1z5ylYt89fN1vC3M3gfAkwCAx4symnZQzlkVIpCWtAf78wfhLmk62SwyJgnSEpI3g3lpxJiVoiLKVvijUUHJxmxOjZs1sfc1pD7t1l8qH5bVvQZ/Y+KvzeeKlwtxIooZIb7WPd3J2PeLEqjY5CBEQiolY/nfNVM8myYWqPTHxg8+VMya0LOEVKsJunfXGQUR0bm7ypgDHO6Z9To12vR5uwvrB7QoEshwnYa5vOM+hNAMmDiP9XwV2zwhooXlMFJ1Vui5tCkCZ23fIwMXjhdsd+7VGId4mMhOova5wfnA8Y7dPIZpxcWWNhjloQwwym1MY43ykkRAcgsXa0omVulBQXVMKvNz9eb/pP4MeDcyZN7cYSdjKj0GiCvlHI98ayR6+U4pk41eDATlD5knyzii+xrT3R4bgqfcMO+e66CVbpmGrXFVm9BCxuYmGgHS7wBe36gE32q/oZJq4VjOqt/1nx4WUxCWfcWLxkoYmHCFk7XpqFkrgnV4UdIiCKebi/joLYVmMQBKDDgV7U/cy+BPiS7QXtuFnnP6dCpv02oudi9+cOD57QY4uRQdq1WaeB1U0K00V4wXkOqQc2kZvI2fT9J+90vvuGGqeBcHDvqRt0ZCMrmtJ9U+hQuAqWqUP864dXE8Wyb/0ypkIZI/cms6VMwQWfZWVDWZOBwSgiPhgDEM5IqnR/Cz9Y8wki/TzwoNJhK/vNNpSK+cAhxt+3/rC71Gj5xCs0GGlbnY+qMnt75g5AQwDOXsTAlUGM6SFLoJ9UAmt4fxZx9owvRCL6gc54kzIalY5pNTYMgPCfgTQ3U9q4X/bTP4fqWqRLwItSdgEVt/9ZeelIxehy3QKdRa0TnqcmIXKlxd6PafZaysM5a2YpWv/6zY5dGHjIMMBVhJbw4dsh6OPfOJqCzE2EcAxsr+GFr68rsj9m+VwD0ASjw5t3YF1L7cy3HYNf9AgWU7Ya8qsmOH5EM/qVDLY27H2oEnV3GfCBwrS560lqcc9xD2c6XI64HS9s4VvfMVgYhFctvRM37rLmqk4k7ocHRRujcELGM1l2kJqb/y6RcezjHVAISDGLcRJUeTqb4J81fBJQn230x5Oy4rxaOKuWWf6+EinSpUON1CVb8RBVCZHnoCDHepQE6sAcO694fnNB/XPb8rLc+617CQkknD+OYsE8ws0wM6ItT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21741c71-4a23-4b27-3b0e-08d900b8f19d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:57.8705 (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: rObYzlKgr8rFacMmSqbcdkjsY6LhPzo4J7pvySIrB9kfCdOKJZ1ZIKyYbGc50Fq0xjBfbczmyWB7zVHGozUc++P6nkH69ecNBATlVp3Jww0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: juBH3mMyQZBNI6FONO5eB0NCj5l9BGY8 X-Proofpoint-GUID: juBH3mMyQZBNI6FONO5eB0NCj5l9BGY8 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 --- 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 902e5f7..94729aa 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1203,24 +1203,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. * @@ -1249,7 +1231,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 Fri Apr 16 09:20:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207229 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 1774DC43460 for ; Fri, 16 Apr 2021 09:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E93916117A for ; Fri, 16 Apr 2021 09:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239551AbhDPJV2 (ORCPT ); Fri, 16 Apr 2021 05:21:28 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36514 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241632AbhDPJV0 (ORCPT ); Fri, 16 Apr 2021 05:21:26 -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 13G99OJu026197 for ; Fri, 16 Apr 2021 09:21:01 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=0iE6QbqYZW2QHqj+u5esWOrkpy630dIALmY1ovxzaWs=; b=wrgp67dwcXXubApMVLXgXbqnyGlxW9DOEyMtDwXS//ZI9lFvxzYV1hEkgIOI+LEKpLiH HKEGFM/1gdLYtbAzwJ/zK3cpaV/lJ+gBaTlg+GTFPuiUInNTTxccG+180YsLVyXppaaV VX3ZW8UVWBgUwkulmBlCTQS66kbpwKClAGiY00kPpKEVxdpoWGnvR9E7oNWFFbuiFHpg gTH1U6FtqS6b4IzyGAnxvEGCgHK6f2cWFUfzVWPgIWCPm3CBdgsaPLIIiglshc6szvii uS47JUCw8/83AjN4tp7A5gvn//PmKAoqCVnjIvOl5ni0fS+az0BW+cR9jafKnPeK30yu Ag== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnrhej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:01 +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 13G9AXSx077147 for ; Fri, 16 Apr 2021 09:21:01 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=afBveZRqDx7WMA2lWXpFjlzvc0b2ouINubi0X7IOItTv8k+fCXqcNJ+zUiEmXnqtlDfk021W3KwEJvqoAHO/K6vQXGf/UBvbWbfFtbFX/r8sZI27tOCihg+5yG0EREFbDiZhjJNjbl+ifMYJL8VzDeNKn7H5IcsqED1Gf2+qr65WfxQyI7onqQhVLz7H0VlyGie1RgW76dHVEOXR2QrfC6tan3o1A9NYakh8qStioYVOtjDtHAhssGZq1sDpXA2jGb3IB/XYNBRUJGBs+2o1Phn18WRAzil5DjFUrsk0qaSyoKcu9d2ntLvIFHsEEIk72s3GnfN3CsNxJFxw+62JFA== 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=0iE6QbqYZW2QHqj+u5esWOrkpy630dIALmY1ovxzaWs=; b=nWphVCdf5NbWdBx+/L/IcMQJMDFe/xxLJ3y2eqLiSU2c4UqJQ+gR8tAb4QgBuHfdwqgbshikX83LFGulICpE2XIVsPBM67RnCgJ+qUHXOitWzbWSBf3RKtenqpUnwBnjzJ4jxJ3nRWM/gavaJndvGnPPn7OVvsN+Qg3tdEVugJ1WSCm/xLM74Q732zavKzTsupBohfr0vitfpW5TUixLwlBP7hWVS/XdCAHQon9QF6j+4pr3of4C2F5JPsOGCM/bEhv+IIupY7W1K9mg7Yr7K07nLHjhi0Lnb9hLgrZ7y4iNKsc3lD714d3h5NckQ6Or+I/orhcEyuDnnzzIj62W/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0iE6QbqYZW2QHqj+u5esWOrkpy630dIALmY1ovxzaWs=; b=ZcIOt032io2WTtsmg3ykzIiGWZqUYIQPI0qfJkO2JfQNHDes00Cma9t3M0kyw6nNSRGH5TRAb6WRSTwqEp8QGaqyWbEbrRUj1QLej9K+x52DEpAnA8/GcrHPQO0Z4pk7LOYlqY0lPxX1yb4vf1NpJIZ0fe2o2pWsHtz7wt7pObM= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:20:58 +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.4042.019; Fri, 16 Apr 2021 09:20:58 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 02/11] xfs: Add xfs_attr_node_remove_cleanup Date: Fri, 16 Apr 2021 02:20:36 -0700 Message-Id: <20210416092045.2215-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20febd88-6343-414f-4115-08d900b8f1d2 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: l/TMo+yD/PfgllsyMsq/q54pQpKHf+X1X+SLxqFcJf2TQnGeZZmNDo4FAgbth0w0mINi2QYphSATQhyWiTuDzH7Yt6v+rWdxLD9knyFJFoFy549tbHNyGD6tzwJY/b0JBU4spWnkKd+rRADvR9DVt5F7sM8m/vOf21HqL4xu1VpGg8r6MFniYaYUuFT3z1bHP6VMrob3ry+4N0FaRXsWwzM5qb6jedUI86kh8NuuSP0DEFyhW6H71250aeZxZqsph/VdNY0IX+gVYPyb8hubXP7Tadw0Mrz0OflWi7sLpLgrVpCRYcWBdrdBvdVVKa4GCxgqDzl7fLuiz5nBUXKT+Xno2GaQQb93XMLvEQli8G0MBcX51NXQGU5jQrdxZWDhIksgB/DjiZM3k16MEzoIsmIJOe5iW/e/Y56NZwmYMJHC6gkHNKpuAzPM6ZKC5OUT9SlW/7SJsIKN9DzjeCSl2sVx1DY1yp+UdNhJEfW0FPmnJU/olwLPLXrxSMpYZUScjw7LrjbrUG9xoTjjJbdzBhzDTac0jhXYpD1kGm2FKvyKMEgL5mp7eRMdn8tQvpqJxY+GS1Vwa0P1PIR0bR9msycZS5JMwNl9GhwzAOfK/TJAKY2HvLP8tIiN6CSTs257kd9n9s2YAb3FKrUfZjpkPg1gI+MpNlz1QJLxyvDAuJGIWPH1CrdC89XZeOa7z8Bp 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 13T7pM+yk9AmXQdVOMcAUKmn2hjfA3wQXaOlRcKqBEqf4LSrpsO+FqCK+X+AUGwuliUzfByjhb83QVHOYmabW2ewLIZwp6zVhx7ErMazFESJhAI6BCfS388UsAxNPe+Z1mKYJGslQNdzyLgoDsbrzVgnhq+iAxONnFxu2RP7pQ2cRgNZdD195PXPyQHwsz/R5zgEP6RKVm6zTIBo0FNu4aasX+yvL3/psv8fJeXyQmPhirNEsZdBAhVgdDsmJ6KbW9afXn1Unxj9/BVdHhujYcu1U5fwyBNzEuDseWrjfy3v7Lw5gmadCryRhagPRFJ7CoTB4P19j5gfsix3k6TV1AHsbOvF9nX4l5XNe7B7Uas+q8x/khD/kw2ZFOgZgX3FIjgRnSKD//9YBYRy3vxmWqJvRSK5sqXY+hcDed2uWf9rnGEqEQg7UWNrJldwC0MaPKC5NbfxN1WZyrXmBFD2I7+3g5MdBJcAhBtmcHV6QTHDRj2m/CUy2lma/WxFeSZHSEmPvBpW4z9+nYi3Ih5syvV0OzJRMnrAYeIcnHdMCpizbSWhcfqSkMFziaey+1hjaEi+uHp7vaNcWb1FKuaUkeJeXjlSHOJSmsL4Lyos6A1u0mFaqmqUTRzctByS3eemXw9DstXqU5bynyXsRf0Hr3uorQXYlNCCL8h5yr7XJDexmlMMc1Nc7zazc2Kz4PKvGlrD4Uw079UWZi24OKlWZqx1ATjJZ88qXbW4adXKTCSrSg3r/ScbkK1/vM41CSANW2KjGz/UKhC1u1SJU3/Q2oU4O+3OfWWvD+0IetFSMq6K8+AdAdYddlynaT67qMhV6sCppJ2KudyfTpkZL57uGOezemq/yquMIyGUr0toPyXJU00tsTcTsotbGJw0ruFBVCoGPwx9Ds0kBfurqP2A17ARKv3p/ZN+B+BlRta/4R5q6PSeXnkyJDmzleaNgA5o4LQ6uZJnmXVjhpN5XIK/PSykW1+0ZRoUv2VOo86BHxxLCODZGanYZ3gFqEg/3WsbGCS+fCLQOBsBsa92/oGQFW1AydBZzE6iMrZMh7L1VshZESNX6MJIsk9smR4zY1Hi5fwAe349T+z+xv3H+il1RVaN18F4uC+yafg82khhwN66XyK7Cu/opdgZ0GLctnzErW8mTwfREX9WLE0ifah6L0t9k44nOQfZMyb2d9zB5x1odIw7yZjcyen3d62MI5gHaNM1+CAV5hUMwJS+W/nneeoXBOhvq9YaO86WnW7zBIHFejD1eZGiVSs2f1tfccsPm2olYtlrrYQwx/9aVMiF+/kby2uFFXhdV1r+Z89MWGxVqK8+y2IJZKqJ9VNYKgjS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20febd88-6343-414f-4115-08d900b8f1d2 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:58.2150 (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: Zc7p/PMughVhmwVBnCU/ZheqATdp0BZgdTF8DWsA4Yj+76Bf9pK8LNvM1bmzu91qQYeFOkFE9SHqu/QuXq3PvLL85VRIX3I0PFRU7FoC8ig= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: Q9FKI1YMl-mgBN1nGDFMe4fLE0eYGaTF X-Proofpoint-GUID: Q9FKI1YMl-mgBN1nGDFMe4fLE0eYGaTF X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch pulls a new helper function xfs_attr_node_remove_cleanup 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 94729aa..1832bbf 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1203,6 +1203,25 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_remove_cleanup( + 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. * @@ -1215,7 +1234,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; @@ -1243,14 +1261,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_cleanup(args, state); /* * Check to see if the tree needs to be collapsed. From patchwork Fri Apr 16 09:20:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207233 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 6F6C0C433B4 for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51E4D61184 for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241678AbhDPJVa (ORCPT ); Fri, 16 Apr 2021 05:21:30 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:46566 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhDPJV1 (ORCPT ); Fri, 16 Apr 2021 05:21:27 -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 13G98aCJ036454 for ; Fri, 16 Apr 2021 09:21:02 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=WZ3nWaVIGdeD7O/E53SOGUNw4rHx3zLUXh2w/JoNiTg=; b=m9TwE7pR4EyX5DOO9CHd24KC5BUlMPDOA6HN5+SFKc/1WFV3BOtm11yByB6dcm68fyHh NiK9pRiSNAIIRsoGJwjnw6/1ZJCLt8/nQ8ETafOf848C9aPYyRz6O6I9CKNvF4Jxf+E1 8F+sjtUtF6Y2pl5UFgqmCiEtS4eD/tE5wXKaruIW8Qq2Rodu9xVWonuLUnu+CkMuCD6S N6YPscIsUKNeymivIshGMs2BoPPEbZpyCjQ6XQXp4VXRFUfiLDQmwZufmN80Y95AlkQF mIWTC+hBhHHObtqq/DtJw3DKi/tHJ+PFraF2TdvsT9mXPXo7qpa0/wqn2CA2CHUjmR8S Vw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 37u3ymrjae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:02 +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 13G9AXT0077147 for ; Fri, 16 Apr 2021 09:21:01 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jD3NzwR2LXOLc+mGZeFZiFbD0Rp4/pmHTdIYC8nhb0uX7fBQW2/EeJ6RFVMpXl3MK4zyXidX4uUFVi2BhfCFHFxryun/dJwhDb8nSFTE3WvOcC/MZKOIqKrivxjGetkS/Vu5+f5vv/W9dUb67WN87LNpKv3la1xx8T21PXRCJMVwZXUgtc6HwvXSls83jVSBSjieRKwm6tHnWwvfppq8SlDkAbsN49cZhRFr8GzLKPYtuNyx9kszqYV8+jPZ/xUPVZVe6slp9gdCXqzxhlPcXjytEbeWOcfZRlCQzM3Ezdz/Lmv+73nxIM3N8wG/N0bHxr5qMkI17JRy30pmwcZQKQ== 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=WZ3nWaVIGdeD7O/E53SOGUNw4rHx3zLUXh2w/JoNiTg=; b=B2+U99+ANPke5QLQBeWgvvqZMlsjGOjAmcjwYYpfL2eVJARnGdJxpeBAZV0ITiYxRth0NWWUQTiqMcLE6M+CwyRlebjjqtrzOxv4Lg+nQEza+mwVPfIY0YMerw/U+2XPOGDzaJQxivN7S1ENMaveGqjQhACBlJbdEtHZd1ptVNrBPouF3IgjH8jkEZkLyW7sh/rjSXr2+cLwIRi3aCPRVF4FaU1srxsGieNJw1sRRpce0WuoZJm5TTPZUtUPvrSnVWkc9mP/6RsBwua4GKmPvfNkBe1FPw/JMHHs7y2yVmzijTrjZdRntEt2y3bqVKA1+IUIR4hxKCuNjtJGqrfFSA== 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=WZ3nWaVIGdeD7O/E53SOGUNw4rHx3zLUXh2w/JoNiTg=; b=rp0SJl3DLXQBMeXEFydQQxu0/F/+25raRvW7OP96DA2gx8EfzbuvXZWneUg+OOQJsUyeIBn+yaKs5WNnuwrwUaKqfGMjimtHLNSYMJpYhqzoMIuw1mcaXRNceI5tKlemAu19EphZU1jJpZ/cIYsD9FuJJkMnoafBnvU+kwvbFHQ= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:20:58 +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.4042.019; Fri, 16 Apr 2021 09:20:58 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 03/11] xfs: Hoist xfs_attr_set_shortform Date: Fri, 16 Apr 2021 02:20:37 -0700 Message-Id: <20210416092045.2215-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c70cb21c-e293-4a16-16f2-08d900b8f210 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: 5ulgi3rFGRMItLsfmrIZsmc1g4N6ORZglKMbrwvucV+U4KMKdgHYYdXRRa6lgkOYD/yOr9VhrSib+wKm94KQsMwMWQZW/m/0/oYMSvlRiT59IggoABQBMle6Wa/7GjZ/e8c+197kkLYopor6TadGG0ho/tJEETn5qHWoJKinDSr3IDbmiyXmQL/Ssm4h3gDVFdpgePEud8vZ7qaro95sM0ud2m3AgExa+wgReZaEn69bHZcDYVajgjLBc2SUNxvOxRIeQPq+tjEDKb2+JqpIXCswl5J5vA5eWl6smXdYQx4Z18NMFOCAv+B1jsiFOC7FQYMd0XHRe5OaA2OLZpOdCM5/5anVIovKv7EssNm1Aud6KogxYbSVVWt9TikCzhOPz7aDJIHaFbUrQUqnCuz64aV+rT8WHwX1FvOuJKTbxERS1BZdJQccceNjkmauYIG660cZ7g3EvktWYZK5fj0OzQme3iUbiY2LxvmqfX2Lj2JSxN+m+/Ru9D8zki9VpvV1sRkQYSni021RaTffr3a5SOSrvtf8zvdZkMlNQK8OCyIT0+LqE+IqhdLJ/d0CO0mNHeQ2iGHLuqrIaZFOCDI/A+8jKUA2c+wCa3r0Xa4mT1+l1/bSboaxfr7BjpykPlENBLK92szLjelNFoqHEQTtCj2uMar/2Fvaqz7BpWZFAEpdkfApwkpURA70y32VIgCG 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: r+vz4qUsWLcOvAehjFZ3jViHm1Ie6LpbhLoPvyNfvnhH5+HPZraI5oGbZWWDI5VijrhlaldrTDxlHkQGnCFjPCkwOOh8jpoRINuBl5C0QjZ8Ul0VCl2EfuzsIjWN4zVkmyz+Wzh8ir8apiJB5VnuNW6PMLe1XOVn1OeuuH6Crmyzry8p9feqG45wJNLCJxYSWtc85BCR72eInTUIS3voJgnt0AoWAsOqZaN0zNbzrAUhOaLLWc5KMZ1qoH1QUtnYGuGaObwUjYIF08jcLi1P85MZEeXVtgXpq52FDgkLSQrCg0CqN2vZHq3Fi/R8DT/5k6zr8pTVUl3D+ugQ28N48H1CSQUzB431PruUUh4yhuAjXyK2vJ2xJtqA4Ys6PxqZYbP5NothWCfojwDIhjzmt61KKejRweSDOPpxYjUkifB0oM9eVBFkT5i82InZjaZP1hdNv09wycQCZVGZj8tK/9ChYruCTci9V5/b6o3AxnvCG0jgXcAKYAiq4D3jUf7yyPHHppFnJpMgNPxNCqfiU3NkNjqtmvPc1/2GTr3GnlxakMwDIHGdRhZiGIAo8wgG+Ef5nXEzCoZ2Tj5TLL9FJJ2z64O1R59vJsThqs+lYOTemqvw4aHzEDybw0guEwSf2u/71j+ZgIhUA8kBRjnaUHkuC13KEk6HeyBuWqU+NaDqufvfYiiFuiN4tSIUXbrQbDHFUlYfx4aArFY1zbO5dRNg9/tumi//QxKcOMqyn6StWcbFMXSY5fzCKBqHsvptOQ3l+hjIPEjFtR35VNPAf3285sGSTy1eaF9+fv6skhuOSKmrZ7UFYMMB4kyu5bZDxm5XxCP/Ur4ecYEqqerFeFsD7+q8mI8ZXWLN4/3xxVo68s0sZNYvgpISW4B9+NFghwdO2QuV1/ZXJ9ApRvvtMi5rM2AKk6fALDwOrXGPJgC3l1y3cuKQ3NMfoCE2dyNsasRkWypCN7gy9s5GNdOcqRAKE6JoWtgU2v09wlCdyl8mU1DYkdyrQoob4y6NasDuSqkYwHgC9HbdFXKof3PWZhWqbrrKcubnAjVY21RxDOULGWkWlG8Sy1yEv9T6Aq3jyxfOk98l9GizRu92rxar7TfKPVSZiTAWiYdI1W5VLAeGlEHS/KvOQE0QZhvDhpTXYjWM5ZE/RyW/8i6coRgkHQ+Zrqi/Z6OQrqqK9cg54cqWdGiY6xO3gIkxVQhj0seOI1mCeQcsL6egPOUCwOws5nWzy/HvMKIg/mHA7up78Sr8qRPt7AarcnkEkT3zjyMgG2ZXGSfEm4wmk6K5EJ58s/kJY9psdeWc6Dbhdjxl6Cy2M2ozyUxsDMWuwV8boQF3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c70cb21c-e293-4a16-16f2-08d900b8f210 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:58.6282 (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: 4cX1/lZ5DNEqAY0LCjpH0c152IGd1nZHnNPSERDlxEezFDyk5HCexqfVm+BDU2UgSZIyzkO+TRve/RlN455++q+NNtRW11RzVY590j1NiIg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: Bmt9hpHfXHePpfCS18_NDE_NfkZ5l_Xc X-Proofpoint-ORIG-GUID: Bmt9hpHfXHePpfCS18_NDE_NfkZ5l_Xc X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 1832bbf..6987ee5 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -217,53 +217,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 @@ -272,7 +225,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 @@ -281,16 +234,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_bmap_one_block(dp, XFS_ATTR_FORK)) { From patchwork Fri Apr 16 09:20:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207231 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 26758C433ED for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0831361166 for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241632AbhDPJV3 (ORCPT ); Fri, 16 Apr 2021 05:21:29 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36520 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241666AbhDPJV1 (ORCPT ); Fri, 16 Apr 2021 05:21:27 -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 13G99J3d026165 for ; Fri, 16 Apr 2021 09:21:02 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=rbRZmaNFpljFnLnx50Yl/6U5y5cIb1rcn5Th9pKxh5k=; b=mUyG6p5BPneTF4lYBP/6Zs/z/3xYugHtZEmj2+GgKwCdZu1kdiRRbJ4L3U+XrCzpkpbD +TImDofSTsI3iNU13Rt39cfzdmeCLq0W7wW/VF7OkDSquH+/1X/T3EnkmtzYG265sp+Y 13BMAfOKVgbwE/uc66gndfOXfn2tQcw0x2HNBgYDzYX2T/XTv6SwIA2ddza8EdR3K7mb nNZodKs+pp8M5aN82g+p1W7RTcTZgSpv2HqRzBF3hDq6iquymYsGPDYzecR0L7NxwR4O nL5wmnPqV/FkaOOHRy/1vOg5kMm2zf9ljUNFfxKIfNruib3lTGU7dlBXMb6vJeegLqDa vw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnrhem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:02 +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 13G9AXT2077147 for ; Fri, 16 Apr 2021 09:21:02 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvUis7xgjgNP5ZUZDMz21Bwj0+2QWfZoMuRGvY/32KxOcAnTP20zpKsGMcUKW1vgGqwmXIHkfuhMZw5RpXf6EypH6dxBbZnt+nq/p4aVAIJy7mHAUTAZoCAq2ies/cRyqXKa3fQqspZIzGKGg8hmPL7w9F4lBkZc+obxisNf+I323qTXV8g30XiWPlGBt4fpbLUn/SItt+K6NJg6iyxIX8b+/TBh5o9zKtnmXj//0vXizNddcAzXM2W6D04gsXQcTF8CUzKoAq3YSPxajZwPklbY0jRa290sGF/uITGFKrSIC4aVUjwIMpjqbde3NWW+7/AsxaiEQHlDCcQKABlFZQ== 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=rbRZmaNFpljFnLnx50Yl/6U5y5cIb1rcn5Th9pKxh5k=; b=MY3foYkO39QrN+oEarWL7TAgxCEimHp08gU8rJPwJ0fPGKB3W6YvVRmT5xv6inrNLiWx1Ny27WgVwUPZtOXpNHuQq8wDct8NvGpowk8ZYe53//flCIdaD9TdkD+VqWpfxJJGWU2XPsWl7uWH8ulbJ84Sl5q5Ez//XD4MBvAwrWaDtwE9CXuXAM+1nQNK5VHtzlll1ZqrrT3UbPGPSoziF7bbw+Kqa5M26kyCu7PVVcJAEpns0hlG9a8qpb/SDJamm5+yIRqDW1VJh71PIsMaqgy377v4TjY+wnZYvJGU724Hl6SOa3m47W6pZAuhH5pypUugqJEVuB1YXa9en4xurg== 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=rbRZmaNFpljFnLnx50Yl/6U5y5cIb1rcn5Th9pKxh5k=; b=oWM1zuuBUwTozGiQ7dXhf+S+58oT7xGreS+3Y7gtCMPzyscWAC78JhLY2m/baPIDH3uoociVW3ezlKfiZOc3TcYFMw3r5z44t+RmMxzH2QKSFJ0oNZPWHM4G37f4TeDpTb22Y/r5U9Q0452sjANegyHU2B3kdYJn1g1qs3GYk8o= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:20:59 +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.4042.019; Fri, 16 Apr 2021 09:20:59 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 04/11] xfs: Add helper xfs_attr_set_fmt Date: Fri, 16 Apr 2021 02:20:38 -0700 Message-Id: <20210416092045.2215-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fe0b32c-dca3-45ed-97fb-08d900b8f243 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: +LeJWd29GvazpAZPNVDjoICQ/l54BuK78Qml+MbX5MxH7ayrzjstfmz5o0zY3858QIhCc3Eh3P42ORmDp9Z0o42/A77GWD+jPS7Nzuqj94sSsXTViaJJt6qTp0uBvIGNktSCc8LLmzbfrkytRev/l30OfLaOR1NWgM+solgtuRU3tuCOUXLY2225/H23Kz6soDI7B2BzU22NW9989tdIZmH5veuS5ibrRrZqGa5YffBxsHp4nW8avtbH3CncZMoBH17nauLyB5t8mCr+NxYPF1D8YdLQbbzKr4qg4ybet+1WkHI0oa0PRhHzdlycUZfA9P6+clMFMRkKL5ACfxqmha9MarL5neGS+OoUX7FMhEeZ97SbuhaFa3HLCQjZsaoRkt06KICRmwrHcK2GKAPk5bHdP5r/ThdRcd+Hu+UK+o7Ozndcq/jAWgatRQyXGpCK5u3fsyHLUOrm6Kg/jJ8EkEH2HFqpEYK4I34SmPZsyqljzUG7FanR0GKDQQ3QtZjIhmjOnuVr29v1bwtW4PgcV4vN5tXhZVwo3TzcOJHNS33WsXGhuilKAnaoMbQHsm51fmL7aKd8XFn8lU7OIoDJ6Ce28OggwQuTGkWDXZx9buXLlSdMioJu46zZaEFDOnDn1zM+Pw4Vr0p+XrHzKXoQ/AYTLRGVmLPxpIhhwAWZcK6t43kdFmzJJ9Aamfld1bQu 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UfrD9xENsnpusMPqRDce2vsVS+rlXgcGcs9IYN+pJ1g9opmmkEw/+kLVbZhmujt37HIiPhq/PpdqgErf+IhyTzGDFj2tGxITjL0JgrDIFMvy+GhZhx1EpikyjVPPszo+yEFX0dv/LmcuAaBYqRSjAISAanyTfX5qERjsTZfoci7dlVTxQfkKrlu0Pk0a6GZQ0N8ok9gkYu8WIGeqH8Omoo9arpzp64T4UPsRZ69GSYLz8yBBT/AWcRgQiaAdFQOTlBe3uUIGBayEZ1ACdeYdvpohbHX+IDuvwfie1ZaoXyaOtHBvh8pwP3ZMp0JGijTbEmLX6MTIfJieuxWnCfo1WvJO0A9creCUWnrySZzqt41qrCqpzAN8FyU+V2cYEmGLZ277p2cjyvu5q99+tZq5bX/OXIUCa9ZVRWEX1tVv9ZVXhh58SB4jE55vInSo5kqEAFhjJokHvYjhRagpRcIJgLoIwfkgxqCZ+h9gzaI5WnYxyqykcaA7cRclBCHgaFJ1z6CwGpLwOByuxxMdgGptsajeZxiC+O1ZBrILV1aL0s26EVh94JoGRo62+Lg7gulOMOIeo+GxqZHvoeL68NlW4Lu2I0IPrjd0Jw6nt5Jsb/0S9ma51ataDAY24ovGB5ktRwd3n0gvOjyfgT3NCYz9Do3kAcfcByFXLqwgsmb9rtey+Qt1Ye725AkwapgglVvVuGcCgBUBHJRanrYPAGCKXFJOB1GlBFssCus1PGBeqrDkwAHtIl/FfTuJ+6uCz6f7iu4VipnLwV5IxXZF4pSz5VCgjQLwAQC/4SL3LP3iV10u5utXhOcHRgd8E0W7yKdvYg1Xy7xXpJ3shL2ngZqK6wdzUpAr6IcO+Nc361/ZYL7e/xPU9PltIA8eYOfFAYP37tsrJdGJA2jAske0jjYTlxMSG6/x7gVi0q/+5ch4OI4iQFcB09KeGHFhyxRCpL2lGtmtXPdTmoupUpC1/Y68h30Fygq80ljMWExEsyP3/922rd+jjCGF6rEITH0DNM/yYCo9pEullJ3VzR35DP56ApTzecnrpXl0u4WtTif6jmRDD30UeoqEn1HjpEMfx/A13vsV8tTzWFu/2zKldXcMu4cQR7zdDt5eSeYmkr4NY1JwHbOZrdFuwA/08Ehy+G0Q+3YnuQGsvozm1dWxzFU9RHuB+TYgXcIpipQbUdtc10wIfxhK/AaadRcKuhM4YAHE9wZ9y8de4CNpgvamStcsaAW1lojEZgYYi4f3rFlKX5ORGOcYN0dXVP0+7IfK46uCOUYfmCc/4timZdsuHYr0M9wgt184LntjqBFoMSmPtDHZAaCG53vd6d+Bf5ERjrCX X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fe0b32c-dca3-45ed-97fb-08d900b8f243 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:58.9747 (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: zVm+/diCabm3vmOyKqIqfJCISbcbo0TGtDwOgerWEE/IeK3ktKjGUPjPEc8tKgL8dyuD8FKgWDJuVsl50Z2rVdj5LLBm5pUQBvl15Di/hrU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: TysKMRIrPgbV_3nHinqQLdRF6bGPy1Q5 X-Proofpoint-GUID: TysKMRIrPgbV_3nHinqQLdRF6bGPy1Q5 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 --- 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 6987ee5..fff1c6f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -216,6 +216,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. */ @@ -224,8 +266,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 @@ -234,36 +275,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_bmap_one_block(dp, XFS_ATTR_FORK)) { @@ -297,8 +311,7 @@ xfs_attr_set_args( return error; } - error = xfs_attr_node_addname(args); - return error; + return xfs_attr_node_addname(args); } /* From patchwork Fri Apr 16 09:20:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207237 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 7FB3DC43460 for ; Fri, 16 Apr 2021 09:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DC6B61006 for ; Fri, 16 Apr 2021 09:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235280AbhDPJVb (ORCPT ); Fri, 16 Apr 2021 05:21:31 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36534 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239536AbhDPJV3 (ORCPT ); Fri, 16 Apr 2021 05:21:29 -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 13G99K0m026179 for ; Fri, 16 Apr 2021 09:21:04 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=ExKY231KY5SLqcqO0g71KGUdpRJMz43PiQUN3zbAM5U=; b=hFyttz2hpGW7RcB0Do9Anx81170DypsrWC3RZejtjx78tfMYavu/k0GaBVK0xKL+BTqN QZz9U/88Nr4u4c7mUCSu6wqr6g1ge3Skl5knjnBWwi+f0d5R4fpLk2OErWj37+mwsDKU loAxRtNM1YF+Ec38wsLIVlusJtixT3C07VUJ8z/DfDFaUsOya/B+V/Wy5MdZVmLnB6F9 uwuXfCswE7cWGwY+auKvDjY9OsVZAblgybQOt1b5bCfHIRz7G21/x9JKT4VyZv5nRGXl 3ruiv9QxBmLIBjVyL5qMDZFI2VvISUMFX+8chfuQbGLSYgP5QyJgUEklcIG2tzQiS3er bQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnrheq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G99eLS182118 for ; Fri, 16 Apr 2021 09:21:04 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by userp3020.oracle.com with ESMTP id 37unswy7h9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bOMcAyYdkC0VK2v9qTJdYVLGS1YdR7UIOHQxhYMm2haxdFF0Az2Cqy3BPMmIXS++WkLrIFjOLbwAiA+zVphhLZHS0Jjrh/90cw0nSjM6QHpROCQud1ZufjbdfuSwmsbJULI81l7uAp4FYSRpOvLq/4JyoP330j8Mh6oofjOceRCY6e+jbarGjTXWeB1zNJViZW3aln93d16HS96e6PnGR31nM70g4Zdjty0SN7/be5QJtoIaKfUdLlb95PeHzEdANVh1SiVJyRbWf1c1lLemiiplVcr5c14aFpg0knsqB68wwdfDk13P93W5xB6jNFuKpsrm4tLHNxw4LNqFBE4Dmg== 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=ExKY231KY5SLqcqO0g71KGUdpRJMz43PiQUN3zbAM5U=; b=Koek1ta3XuNb+o7emE7vHMqynYD+tLKR0TRYzKZyVtrRRJ3//Oi274UrbPW5xa9IvXoGkFoiEeUu45QHx9KYr17BXSd32AW4b5z0o1W7Cs1xmrYn67pmlul13sJacBOAx9yhpKm2It8o6ItCgaxnD/HYxU8NQH3sYJz4WkjXhUegY4BQ9EJSd4O74TXhyzIjvx+yo90B48f/78uTv0Bd/P5fhdx/iCf6H4AnfYreUDAc6c/78QWNAzXkT/3RpY74yg7OoZklqMZIQ/73iDCQAXYHst93EhqzY2Rx1/K1J8u98GXRK0qTd8Vz/VH4wbnWeujlxjVfJiqJtZ9XUVEivA== 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=ExKY231KY5SLqcqO0g71KGUdpRJMz43PiQUN3zbAM5U=; b=LWgClZCNJeLw2+LJwCeJTNpi+SAkdyk8M9nkqEG5p/bbs8CcqtUbQaKkhkHNu3SiHgJLR2RfhWhDTuSxou1B52ScoYmqlleY9NhdmxuL1j5U+L3Ca5XOiyETdNhG26WKMP2u4t5v+7o1e4GcdUIOayX8WbQfhpMFvrTiNJH3p4k= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:20:59 +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.4042.019; Fri, 16 Apr 2021 09:20:59 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 05/11] xfs: Separate xfs_attr_node_addname and xfs_attr_node_addname_clear_incomplete Date: Fri, 16 Apr 2021 02:20:39 -0700 Message-Id: <20210416092045.2215-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f3e3ae0-d295-4ba7-db83-08d900b8f277 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: AOYbvNYkKt3Jb0kTQhJZvlpx6EBuSs7ng8LMtaQWFd7lJZp8j0CB3QiFHD9HM7O73l5dqWPBp3kUcBLIWXXJ1r5GOQZKMT3dySw7TsouMC07aRavAnY2vwpXoxbcGxLY3Cy9EItBno1biWelSHyerHyc5YyqFPPnG6TUTigje2H+Go0UpMslJ39XnZMFtlZ+bBwBXcBedbvWpNGKJJG/4ZxkwR1Rl1GSpc9NTgMiJzSiDtDQ4IGlHfKWtWo3g4PBtLhugTFoKgiE25i3avysGjDI/czc1FlJ4dvLYLgsz3dJ1ZivYVqwQCagMr0JK3rJx9x3l1S8nsZc4nsPxzB6XwuNy73DuEXR+U8d22Bi24TLULAjMEFFkBAi+0hno8dAXuBDmoFT7/FrsGhmB/TzxVbuFp2pal3Wghvd36qauceptXHjgGeR2ZSIV6tzPsIcscac05gBQG5ZfoIZF6UT+VpBuXKsd56+wH/urjeOk2MjfrkrQjsl3XP968avdGdreXVYMbhkUjIv/f/uS+mIRogylY+8SljOy4wENYtW5PSRxgVA6ijh/JBxm+67Vb00RnbR6ap8wy6fAubXnktOLPgrnDy145xz5yOvvmMZf4WHH89UibF9YfxFI+dSzmCntoufjp/hyz/SE4+MkWNiFojkKGBcRY6QXs4UGMtVLm5WzrTNZWnqgeEIDA4UchdU 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EuXZzPG1w5QDccNv/KvRVCO1lUJgI/7lg1lSvPDSDlNMgJ6Smj9Hvp7e0SsSpw2s3yNWWVOEF1qADCsXyrM0LugLKH+2ml3Om0mXKg0d7F6xjofyBrxD0RWNbVFMSU4zgYMNd6EDL21cZQcvvfQdJF10BbzvG0neDTcyTXz+YETbrtVSA9Rbit1EE8+4cjHupflbzueZfXF714mtWR6IS2oJNNqvAmNgAnlEdunlMsw9IGiW0k745shj3a/Bb+lQTl/6lTltDrsybyLQoheY2ky189kc/fVzpul+FOb0GGQFgY6laNdSOns4C1ojx0dKQ7sxpJvseXjHOpMgqVhq2U5ZYwc+Jp4z/p/IkYrNajTuixCYUBO0+A6N3gmvd25TgBFjJszUUxkGhOMBYz6BqYecVe0h9D3BJMD/CC/t7l8A5fxpJtryomY3aIyT0DAp4bCdvUTaOQYEzh9fDeBApERpwV4wEqqeBUg6RVclrKkv71zHFAs9OTCPcyASC8cKL1zwTu/5SnsvwN+pvNVhQxzbm4goEMo1bmrt4RxrXyVPM1Eh9oWSIMdOgP8tD6qZ9DUzZ6Vy5kl1oA6CHdbnSngpDPj4sgMrep7NMSh2jFXf0+mBNDc244/8+Vg5si3tuvppQwpCXUw7UvXDCTyHvpOoWHw0ymBgp7eGrOdm7iqgm4mitpKognQLx93sK8TwpjHrtUGPH8sj1/nbmOvK6c2Gt1pe1B15D0igt6dJ+1+rozFT9BMz44rNdwrpo9H8vda2k81+HsB6vhtjJUoDY3T7sewIk5Q4Pt6Lmi1lvw0bdHWK+K+UY2XvZuV2rD6zdtT5xEU876BwJ9hiO0m20+2UTlkOipAGQCkhLQMMHL7coWbeSURfbckihMvQ0V2BuST0OhuEpCv6w6tirRS9WCibIbPQRgznZbwVT979dOAbGOgJJSd2/BPUCzeizwJjNNEMo0zFqjdytKvCsuPwjumnSKuwv4u9r4LYqoP/uwr5P1/qO7rC4PbSlJZuA6EgxKt6h+3kPK6tFq8rvRLEk9fjJTHRNJAmFybYs1yad9O/89RiwJ0ssEf0RPpQduGxcHxet8/z0XE99rxSO9ERBcw7PO70F1jzcgai7jV0H1eh/uI/tJH7Mcs3ix02xpkQPZjbKCrilZuVqYd7aWDGAIJ++hIJ0aZti8bft13l8ht/lxV2n7IpPpM1/zMI2YFPcmFVzCLU+IFjBOUBcPFjzZFOFJ2yMih9Gop2Z9UM+2/RZGPTIdPTnw0ywmRDJ8pj5mm5HnC1WVmubw3KGSlWjSLfudDKHuKve/WS1WSw94QxCGxyrXBdos6mBt0RD0gq X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f3e3ae0-d295-4ba7-db83-08d900b8f277 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:59.3152 (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: VujleWWnZyJvSeykEwW+//xtxwBKdN1sJYntmnIIncibVH6TBnfz8c2Ua2kyITB3prk5Fsn3PRFAjf1Jn0axtHVFo6KrYscj82++AEPxQ8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: adGhARD6iqRWI_jDlQiIB6OPnhNPwAfA X-Proofpoint-GUID: adGhARD6iqRWI_jDlQiIB6OPnhNPwAfA X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 --- fs/xfs/libxfs/xfs_attr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index fff1c6f..d9dfc8d2 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); @@ -1062,6 +1063,25 @@ xfs_attr_node_addname( return error; } + error = xfs_attr_node_addname_clear_incomplete(args); +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 Fri Apr 16 09:20:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207235 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 C29BCC43461 for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A566C61006 for ; Fri, 16 Apr 2021 09:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241684AbhDPJVb (ORCPT ); Fri, 16 Apr 2021 05:21:31 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:49770 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235280AbhDPJV2 (ORCPT ); Fri, 16 Apr 2021 05:21:28 -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 13G9AZ20043198 for ; Fri, 16 Apr 2021 09:21:04 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=dqi2bBnFzGGb1FkLhGADDXrjUZrQJbciyykmlsmnP+k=; b=J+Hi68BN4CYWbE3T9mOwA9WqmLF8a5403I2k5ICAWD+//U1mVbaIRmS3dk3ku+/Xh5cW hMyz9JQmbzkErHEoCPBiEMZLwcv8IbXcD36RGEP8azQpZNnle6QT/m2bsx8Br8ne9m5A XuUjjkmV8GxcnCvX7PfpnJYjKIcA29v6eZfVMUYGT2nnj+kaIHYGbV3Sr+ASyntOF9YG kqPPMnkZbFkZNbrkvowxKMAHmwTE+sE3Z8i7i0/84BU2e+e/y9ptisOhxDoIRss20X5D 3SVI4m27Mgeh45AOiiqZFgpCPm6l8HlZnd5DfSFnSwpNA6S2y1dgDsMY7oBu30SLQYHq BQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 37u1hbrpfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:03 +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 13G9AXT3077147 for ; Fri, 16 Apr 2021 09:21:03 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnz5ghYoBFXiEDSv4ij7D1O773ZAwz6IF2gTpQGMn3r0M4yCuqPPQzBCVehTnZc/uiDk+ojxcxzzjHqs94o3BR9wFv95vpFPvfgHRttLs1smvcSjqDpCdfqI6/XzBG0MxER+tQ9ZdgwHjlMnmQZeSChKT5bf3RM8cclgnfjShQ54iSRjG7I+c4CcaAUANPNspHRNrWTJKQWU2OPsPQ4odBpllctaBPRj77+xo0e4Ghnb05xOHBPM0QamKWTpCvakoLOM+F4wasDTL5L5EspMkikRNjMeXvAaJqf/k2wM811OFsRYWYC3oJ2IIyy0FhrdBNKk0lTgzcTdYLexA9hETw== 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=dqi2bBnFzGGb1FkLhGADDXrjUZrQJbciyykmlsmnP+k=; b=RKYFlQN3HuAie50ExXu+XWC2bGMc5fVBb6LkUQR2RGDaypBcUi/U/G1HWCF1gUTBSD8utTjelL+Qva8VZYyK5Y+uj/6lze4B+7escMZ8HetPLwCqQNU/InghQ/P/im9v8fgffEWipRReVbRjG305AqO8ansXG9OfJ52H1LmV7H9+LIP9/LQPU1vyD8KO/I4hSi0IJZTPYlj2tJW581kbI/XvJWhJCHsMykhs7WZBM+Zi7Miz2mZ+93P/16oMrG2RrzVIgbU7x12qOH5pEBvDYxk/1Aam3L0CFTQ5y1usXBXQrGH8Jgo74W9q7y5mvrRALRYQseyN42ISu0aNYQ1nEg== 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=dqi2bBnFzGGb1FkLhGADDXrjUZrQJbciyykmlsmnP+k=; b=lQpig2lYb8SdlfFmD4LCtbC/im6vQioy48P8GG2n7R85RN4XUc6kipaAZESNzw+pYzKVOFHDNlt4fbG2LZH/NJ+ZaqfLQehijqX8xw1g96Swy+ftIVJyaNx5NzZjB2Vz9KSs1BNofYhdV8C6OJZiriVmYnZy2tLykXcNhD7ckCM= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:00 +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.4042.019; Fri, 16 Apr 2021 09:20:59 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 06/11] xfs: Add helper xfs_attr_node_addname_find_attr Date: Fri, 16 Apr 2021 02:20:40 -0700 Message-Id: <20210416092045.2215-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eddcdee9-19d6-4ece-0205-08d900b8f2af X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: mzp40lpr+1U53UGaEJISM7hOUP42OfBmFojn2nsosx4A0FC0A4UF9B3Hp3qoyJOGRix4SK1v9GtsP0kGVImKN7Gsm8Ql2tl8U2WKtrRWd0kxO/RhGfVpOgz1sFJb2yL7jE1+LUx3yyAe8uNAyH9s1Uq5sDoRYygtaaJP5wC7OJ7Qzrc/LrZgVp/dqPHyHVieF+UEMrcbMQ4BZlU3+aKYEKwWhqVj9FEfKhsMzCLUdviCqRwirDe0CDTHPU13WG+tOeEv6PfbxPmy9/aATdcj+pKJlEdphs7guzcSgDmpKmX2iAUFGp95olIpjSYad36wdWqJbGXw7dPCtDT6Yb/13Ts235CJxXhNKTB9NqeCKKefxV/iI4w/uWeKrj6zJjA2GuNLC+RS/VmwLLp6852AVHoRoH+vqUUQ1jIQdT2TENfqOrc2Akc/DQQf1+HRveOqQJaVfO00kHCZIwW3iE9qWN5mt2+PomBtpLViAek5mlfYqD/VxPvxw69glqLLY5M6FC7A/t3gGgkonOVjLZRZWtF4E7Ji41xwhwQia2WreLA12NxG1tHnXwYK+Q92DevjCLDYcffrb7mXnd6Rit0eacoDrDgb2/pQNJu/E8EapgauUcfAcN93d/dbim9aQiGfd5VMq/epoLB9fGPqcCSbkVD21/kmRvgL9Kejfadu2Tf/0hxQNhzvZBzZsmO4XUFC 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kiX5fkOnvMnnKw5n917S6th34sZymT5ZVxi3+T/XNMS7BZAEMkJFRqOSFGHSRD9+MQNg7HkEQDDVYvdTz2XjgVOb5r4Yw+G/RqJr1gK1XHoTvVOtb3t5ekKRkoiJvp/prjhiJiQAsbhqW/D/5lP0DWkFWR4dMG2omPd8bxaDhMqeraEjJQGexW6kH1ngxDelVW6nZxIqmSwdQ7mUSlhAwTCT4e79d9MGzKHu5B/LQgUS7nccimugtM0jzSaCCDz5+6a0WWZLQgnTBdVickXUD5wW9cSQAGoOMWfddeP+KbKsbs3Ai5EkVBDRUfHfwHg9YJD3B+bBmfzRKEZ6Q+lpuRUPykPjFo6ldVHj99Wwd9pAhwCHhss+zTszQ5j5KfzW8cvYoHEgphMzYcwd5Fg/D8hFlFlWK9PkbC6fQuEv/rYo3H947MSaYXFh/wgYje1HyTH7hXC4dGUMvrnmiSnYM+L9nKVix064dRW2bsKrao+LJ8JrZlM/xjHCkdvbsdLYdDlpJ42GrG3BQq2OZP2hdBPGV2lIzHlHWvnKo7H0r+mRxqc9UfCHEqk5wQlJjgGaiQ5bzR1PqPOHH1KfC8az+bo8FZip+6Qjbd4tiQxBFbg0nwVw4la/wCX9xt7my+V6V+9YwHDPlu7nfS4GBW7VGryqp8n9DwJ0QYmyERFbt9THQYrxsnjEW50b/tVpwwlv5qAcb+f6vPR64JQfhowdwuWkPUeXL/dvQlChlM4CKSkEt/B8O6yMnn97ksCq95D4sAaEetbk4twbLMxgHoqPF8WF2Id09Nlv/5u3jnKAggY2te4V2soz66q21enCQmHqerUEyASMUb8IsEeZxG9VrYoVXspCaxzwW5kG7L8Ai7dFXWM3tv0hwQ21/Efbk0EtHp0zySQVanG+vgjKspJ4JmB1H0lBoiX/xSiGhfvyxxT0lPtaim/qi28vhQvUWIy6qJWN3a96qIXcp3lW8LrvHcKUtUhiI8ZIk6XF7gXTmaAzzwO6zDJrmenJbzmXOARnMgR4S8iLGapy1ouToFan2B/TZVMIWON5ftlgK4/LPv35+DqC78N6I0UKRJUIo+31IqCVLUP1N0QpFD0eHlk6R88UkIXfbinWb12QQChuuL0bVbCuFcVIIqRGdrGrLASUyvLLiXBlFUeggx4vQcF/kh2AjaKiU7/GCsWANskh2+47qgvOzEn6gKPT3OGBj8Q9XEO79q8QMh/FpnuZVqssctswswT9ZMSOTkVi8xuPW+/vJKSl3c8dS+itlDdrE2/wYEpKdLm1u/WuaTD7NMgXcVQHYDSRjCXnlWvecoBa9YbzL9eNxSjNk2KTaQc7Ryqk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eddcdee9-19d6-4ece-0205-08d900b8f2af X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:20:59.7145 (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: Xt0Sc5wBWF3mezalGuYVBeTOhnAcqXg5w29rVLitlTp4q8x7JF9qAsAJ6sPlhzKuXcwSb3IBikgqc9/eFcBujQOr/Li96aiNivgpd7xHojY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: YZC2kiAtjyuLF5uEUGc-z3CSK79HbEK8 X-Proofpoint-ORIG-GUID: YZC2kiAtjyuLF5uEUGc-z3CSK79HbEK8 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 d9dfc8d2..16159f6 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, @@ -267,6 +270,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_da_state *state; int error; /* @@ -312,7 +316,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; } /* @@ -885,48 +896,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); @@ -944,6 +933,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) { @@ -969,7 +990,7 @@ xfs_attr_node_addname( if (error) goto out; - goto restart; + return -EAGAIN; } /* From patchwork Fri Apr 16 09:20:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207241 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 CA584C43462 for ; Fri, 16 Apr 2021 09:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE1E3611AB for ; Fri, 16 Apr 2021 09:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241681AbhDPJVc (ORCPT ); Fri, 16 Apr 2021 05:21:32 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:49778 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241670AbhDPJV3 (ORCPT ); Fri, 16 Apr 2021 05:21:29 -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 13G99mks042539 for ; Fri, 16 Apr 2021 09:21:04 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=Y47eQKRhCOhDODdrjaSeS4zBFErfK9OK/HDU2O0mncg=; b=jpaS7SkzejuWB2eEKVIKDru4/bqFrul1GhjCU6DKwt5p47udkNQSF12i7zS1fU8+QwWJ ZdQuCBUuuXUjsuqiiNCi8UUPzUmYyivRvaGQHoxLAxudipA62TeZPoeQBH45y/8oCdzR 70brrJWbGvQF4Nx8gudruWnimWH1NZw5+GJWYy0MedTpXlNihaTCxXsBGnB9lnJipJrp QAoH36W4qrGsEmF+hbHQH3krDfnxRswA2DKLasV6isFjmLy64Gf9l17aUJNGy83itFYd PQ8e6h6188znRfSBorR57i0Tev045zKTegQx9Qy+cmt46XelNfp1u6YnXzDEa6ZW/jF7 1w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 37u1hbrpfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +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 13G9AXT5077147 for ; Fri, 16 Apr 2021 09:21:03 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HmtX1hARRHobCCLeM7a2mPKfFHXIrnsKC5wJHi5AvT18uHgxB+NctraokcB8y+j+MEgM+KtZ/agMXlP8j9CiN8NjDZYOCShJkbKgBb7IClhWXq89fUt+W1Aw1jVh4ilO9i/mz/WUezgpUlffQhtXm+X/19aCJZpvVEVhxgd709wxzEk9B+ubLbD6e7lNyqtgoF6Sp+/VBQZefsKevgqNej0Um82qm8qXcFPESv310bppXyjdRcfHaJo1ihXIt9JZAgqgdhiYNt5q2xRNkjFtjw8RDZ2gAY6bz8L5BnNqGYIHesPSJPXwST2o6mhDk/kkarvE70h9+ckrZRJfN7ZoIg== 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=Y47eQKRhCOhDODdrjaSeS4zBFErfK9OK/HDU2O0mncg=; b=S8k3C3aOSUcU3NNhcCDrS/JSIj3DBXPc6WiilD38xdGGUgQIclcMeroRKgLQY6KR0pLL4zSAM2JYPcJQEH/ARAA1Mxf2IbzPb1XalZZWbgZuN03DJgUjcDCu+kSai7ROT/1bzU3JJIbb1C4LXu30LMu0xUxFYIvVf7/CvklNfeiRqd2wdsw4tdfczkz10vaPKuOKqq4cyrsqwYELME9Vf/Y8E35Kbg5DcN6EokECDpdIH5Y2EX8p7HhoUkw8C6GwvIVc5d4mz+5LKwZ9BLyVlaFWRK0LHhgITTWDt2McBdmfSsaKz9/H3rPW4+Pt+X1TdA2D1irMmbSp5+yRlUUd7A== 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=Y47eQKRhCOhDODdrjaSeS4zBFErfK9OK/HDU2O0mncg=; b=gb0TNhbusCIUdznNR5DtUOpZaWjDy7K2ybdKhwo8ULKw7NOM3iM5ccssV600n8slSLOMzDcQtolV3Wtvk3Zg8psLWE4PYZwrnMwb1YLXjvPL5Hv1M7u23tKxCtUEQzOXNGEuiO+060JelKOS57kL6BwbFxuThBN3/5BMzQDh40U= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:00 +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.4042.019; Fri, 16 Apr 2021 09:21:00 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 07/11] xfs: Hoist xfs_attr_node_addname Date: Fri, 16 Apr 2021 02:20:41 -0700 Message-Id: <20210416092045.2215-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:20:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4160763b-bfac-4d1a-aa96-08d900b8f2ee X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: tnHF8QdfW51ALA91grrpQxfHx+JP9cHXtv08r/dQeblDFMSPAhVZVABBWD1cJ+EIgV0D3GOt9qQKcQN5NbFIuvotZoZPQDd03A4Nb3GbTP/1UuhZdsQfuT4brVF3k9k9ARSPLBznewPBh5JHH65Ne76do1ihxWJJpia0iPFO793NaI2A2NEGu40krhhqJkfM2wZFrQdCaURB3S4z9ARN2i75pFbf1tOhOCK58hhHItPVDFRWmbHPWX5M5aNsEMDMuMSksf+y9IU9QaRV4Ds51PjXSW+eG0WTiieApdeUSO+hJ9IglUe2QnfD8q0XYSodj2LjsGlzn99EBR+CVKKqz9eNkfHjj2qgEwfTaStBijWM8F4VuT9LrWvOHBcc08msXOQJyTq7Wu/OXx96JDzijN7RqyZMzY9RqoFxk9kAdzB6/P52PjEHs3vQO8gnsTEz517k0qh7bOgxH/Urqtya8VkXJB2Gh9DDI0U5Pk4VjBMJe5LfH9ZKE8vatnE8d+KtJ1zlJZDhKbQK2wt/el5OOnNT2GAqq/h1IFeXsQBxzLNdf639+BERR/kG8DuDqt/H8fr85aciQS5GxH4MTvO1d6RPJ5iIAgF9kEz8a84JuKI3p0DVkCzrsL9eWBhGB2ehFItGWzDoy7rVyjGb0a8VFQV5hxUQzvdq1YwStLkS0PYcUYYT6nDqtnvuseOagrPy 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QkqJjVHP/GnWSI+HOhz5oRyyifxXF62XJFx6g7jEws7wJ03ktem657zP/nuufY5kxwiV16IZpoCdPOB0yw4YkDiz8l0a0WEVvn9K8ty0BOuWe1fDRDe1zVs7MI6g/dCqSbjP2U0KmZhB5TlTrgb900UZtjmtp1eF+wl2DBe5oETWlLpCpGYEOVM1MCNWqJSsoW+WBrJGdMAX9hwsmo74mXfcazCluYxs/c7V8/IlDjhAcCh7eGwqAZ3ODgAf7OWFpwsbC1rHULQ0jfthRGifJr736+jvCSBek9wyPXschFwvBcuc5SIGieD5HTwwND1CKCPpT+M0l3VpERMWFclnhCwgLZWGFeNGgOtlSiTg4G5BG/6QKPVY76sOjcJ8xViAgJS1a0nVbr+eaOzfuXYhZIOFt3IeW+473lYu7+r/zXQyLQtzssFXBBrRlBIjXp3ohdkPCAy+idVg7CcHWbNdAUMXRP2o4F4w4/K0RV2mOQ7b8LBl1GWpVcvKz5B/xV+Xi3Gws6ur0rQjZFSycH2/Odwj9Gil61VgjZHuoOd7w+/9NbDFxiEebUUom+lenRy4ODp7cVy/xqhuciAOW4L4/t2TdOIonBUONof7SQMrQXLns2k3/On+yARx7G/9+OpTsAl+ymQx4Mi9fnh+azCNOYJFCJ4/ZIp8vrJU3vXXJU4Tf2n60D9EGkZB0PRzHakyHZ9hqFV627sGX/vjPYb3vqQTbCOOLootToZCV5ZRRKGcMsWCUaQw3oSp3ZiOvgMCyBT9iQbDJl2Cy87nHPvACMiRXMz6i5wksVARp8PIHzlvD5bQ5xQ0b7B1zgqvs8pOUMSlSAFFx6jMJ9l9oc4Cjjjlhp3Twn4FBpr+RLz9iQDgpOccuzVmwBBoFvFpJXyWe0YS10jC5GDPcvfVPeat9pil2G/pzi2Va+zGGnX/pcA3aBzAH1GXS6bxGkek4iMgBxLujTDBN/S046pI5PXtZ00OUKDiT0qkk5xU9Uex6gs7pB3xjiEACTTyrDrtAksof+gzEbEpK9a6h+VgDE+qwLgivEG9bAEQjyAVRc47wEnbTUCT5sK9Yr0Eb77V3aB3o2JFKd5o5eqW4HpQ+OkexCO1SLiC6r5ifX1yOwrUMQU8YHK86FkT0rS6EPui4thf+cF7N1ydlNYTVijbn21Zw/kfRyiS3dxhPWcm3hZsfszZqaq+JwzCrmDXs+atNAzeB5DC5M8DXnUndG+FtSVq1M2N9P7sDtoELKtiTj3Fs6FYyDq3MjaS+vMARhtBoTq1NRSa75P+vkA5ztZ3a2FoUBrjDa9uIJrufQUw0aqBbNhfERCGGLlXAaERtmOI7Q4H X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4160763b-bfac-4d1a-aa96-08d900b8f2ee X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:21:00.0709 (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: dxRX1kZNjqZ1RE1LCZL5IabSBy75kAiEpC835IQllJ2NCphj7xdikDOWT/cfNoIMMYv/dV7c0U+RfhAr6G9XTY/iCfX2EpFN1RohXpaFchk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: qL70anPgNxdTBmQ7v6xc3k8b5GlqfjFi X-Proofpoint-ORIG-GUID: qL70anPgNxdTBmQ7v6xc3k8b5GlqfjFi X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 | 157 +++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 16159f6..80212d2 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, @@ -270,8 +271,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 @@ -322,8 +323,77 @@ 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; + } /* @@ -957,7 +1027,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); @@ -965,8 +1035,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 @@ -1012,85 +1082,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); out: if (state) xfs_da_state_free(state); - if (error) - return error; - return retval; + return error; } From patchwork Fri Apr 16 09:20:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207243 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 20B66C43600 for ; Fri, 16 Apr 2021 09:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03E48611AB for ; Fri, 16 Apr 2021 09:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239536AbhDPJVc (ORCPT ); Fri, 16 Apr 2021 05:21:32 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36538 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241673AbhDPJV3 (ORCPT ); Fri, 16 Apr 2021 05:21:29 -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 13G99Iwq026159 for ; Fri, 16 Apr 2021 09:21:04 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=GI0JxQYNq8XrA1vs6XZ7ui++AkkVB61egpSCR8z98qg=; b=V1P8d+jd0o11xxlsvos4kJF/YDjYeym4SvdjQJkkmp4+gnzjOc8+aPiyutRPOZ3zeqmo v4o1CgfY0TYyOzs1+dCD7076iz6WuAcbQGaXDcPFODX13tobzR21+o9sMsAZ6HgK0xT/ bp+TNr1g8VIXXQNl9IFPcixVkwUmB4IlmelQCgumuL5J5iTdYavNqKx960eT3r+I/3Uc eb/wZnkf32tF6/ONPBxGL606gQwT+i3HE8Lfz53x5Fv2SYozhMjnn/UQ4gsar62KJx3T 5CupV97WglrCdNkuMOIEQ1RyyFY1eN4V/KV2JIQIRB00umzMAmMtgDXXzdKydgZm9msh TQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnrher-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +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 13G9AXT6077147 for ; Fri, 16 Apr 2021 09:21:04 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8HCWbOXXR6hm48ehFalf6OeD3c7W/QV/BC31yr62u/3gfACCWgplq729ZM6O506qqEzGr+0thdICDvtacwlkInp/VQy0DtVta/i2kiuIzc7Aw8hNhRznMEKQ5Enl0ahuFI6SghkiaLbciqOR/ukViyxXtkPQ29wotn0s5iuPHLHR2COqe+6mDSt/tGaly++0S1xwl4F8y+IZsouIahj4Onzr8sm6geJWKGkPdm9H290W5c/Ywm0IwWxlIiBbwucvBZXr4ZMNgn+vc9z6b0zLVhQNpLBUU4eOZ+qp+q5ssfF4RmlNSJkxc4oQcOWo49xRlPRVHpJAo6IaCPjhkQt8w== 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=GI0JxQYNq8XrA1vs6XZ7ui++AkkVB61egpSCR8z98qg=; b=MrgpsGXS6ulsSyxw3JmILB7iSiGf3nLuvzXDUTlTQ21mVQeOmNV9jc/kOSShvH2eGGXNy61dQP5K4lZBI0yPKyZhiF65gUGjqnCWe2h74ltdpy9lW6G7LJiTP+cpmnS01k6SlUeqaJ/zLeFOxTDthK/50c0CxXaAdgHWybgzJ73uPCz15KABK76ya+3uqbl2iY/azsmzfpbGM6tkK+NFn3YIxx00ZDYmXikVnmJ2tmgjD3XAWIMkt+f0oT4+SKrS51ETM844gPdcikTCzgRiRR0W04x2SiZrlpGy72oqtT51yYXWoSiSz2qB2+IkSHzFr7M8ee20bwNEgGWqUax9uQ== 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=GI0JxQYNq8XrA1vs6XZ7ui++AkkVB61egpSCR8z98qg=; b=QNW+ckRL8QMJl69xWBpPU93DnT2YYwGz8SnEJ+X6RSnl5Uy8bGtV5FF5Aeo74ASOvrv/6e1cWMLwDz96Ke5m058Bk2sJ4uRWGYCLO4t44GbzT8MU/GMUNh/khIXIYvJ2XOqYxUCKjwfOud+f3eWF4260E+r4P21E3fM/Dg62qFk= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:00 +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.4042.019; Fri, 16 Apr 2021 09:21:00 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 08/11] xfs: Hoist xfs_attr_leaf_addname Date: Fri, 16 Apr 2021 02:20:42 -0700 Message-Id: <20210416092045.2215-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:21:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb59cc05-aaaf-4672-bd51-08d900b8f31f X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: EexGKhzaF8koJ0hqcUB/QSqkalXyGRZC3QWgBgPLR6epjapwMaam32pfzvBHB0LrT/v4y5LhilwnU1xjHxh0Of6EJG/iIrQ+QJ/2+bavfDsWkCIr9rrZsOVaG5FnacbylQh+ww1JdYKHVWu3J/NkPwHbrQZ3//EA/jsiJQ1ETHnFhb0wZgK+HjNGyDk2PK6fWhody78Iq6gshHApozCAMQOYPjG2G0qFApw+3YRWp6oLemo6ehNfQGBszQufFQwnoHdRLiCtjakv+Y/rKW7Yrr1+V02GnnqGC6PIPdDk4iIxI0UUHNRNLCIHIWENNiI9paVTd+PbP11QTeJfz5MwmJffJGnqd55YwcDLGJu30t5BZaMdgAk83SzpbGSZ72JSwqCjf8iTloU/QyV+WF9NGYFL2w82mk9Sm0Hz7oJ9O6VsgHKrKXYa4WH/O0E3QrocimNQgrtbRESum6SSZcfFbShq26We7koyNVqG4k6cMu4xil1HlEMS1MrfBWPvP7AYTChSIaBLFaXVm7qghetTY9cA1KC7DANZD52TNJx2Euskbtr1HuMnbyPmVkPmDlKXYHYcG773f4Cvbrrq8WTaZTzJgx/6hfZ6uj+EH2es30nQV1lovUB8B771SAiWD5tftxhDap4khSOjMzk1lpq7WAIkIBmlIcTFMHT2ojwQHXE= 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: d14suktAhpLJJrFnD+F2IBFQBfROxomJUVM/wNerf1QNnpZmLf8XWZNUwsz2+dBUDJN+N1vnOgCwWSrU45gX5qLXTgYTUsNtOr0yOS72EOuCTwYtCBUO8VRONqKCeLv7TtJdbiMnXv3pod6lfZVYKOgCDAtY/DzRjVTK4pagD/l0AOfzNuYrNxsoQdbJAaeEeUuvw7sFt2ZPcPYvI5vfKl/++Tr81IfmRWl6F1z9hzOhhOnMOeSL+1d1zLoYCN5BRLUyZj8OJAXPDiBCNMn3B4/kxA5kyiYNPQdI2MZMd7CuHZNqyIbBWjTMTrqSR7HwzpCFxkvVKDo5ibEheVdk1SPcfW/zKcE2dbvcRWHpk6iaFZLYDA1zBqmjHeT5w/BK11WVLqBi1Qv47pm/u1/g/viuKsFLcWKrKJpNAmXOS/+d9bOGsT6wlWHFyxwCIGBI/NAUERCWkuwGCqFg1AMRRmca6Z/MT5O1ugtKb0ZSgkDL4G7GuwvVJ1nB9SsRWFxobil9Rv5Bu7/IrYsjxMPDdau4hAfXo6ucoC1dHVLpKSno0i0sXwCqXu0DZmtbX35ggbd5ii1yaRdcf8GlXEjiQi7vVql1ifHkoJ2aVsFASxe8NHw6b7Fdm1ncquL38PTRnOtxshDuez73e0nyKaubHo72xlChK8QMig60uQ+UvSMKrwkZiv7aoUWUuTGaUsEWC86MmtpWYR153vjZYgei4+ahStvo6WM/efw0Eckkq4L4qU851LJrQ27J61zWaQzdbNamgW3gYhQ+VAMrKUckEUmtSXjI1hzB3mlDVhiXEJQK/jUcaE5qlVqJkr0rYxrE0JSlFONgkErUSW7RAugzHhfnoTvCtsUPSfHZCLv6v0q7fibZ9TeM/yYQOsNiMG0y4ED0RDSqSAMrN1cH/8jm3Rg7zOem6IDe8FUCYPo680SfoNjt6pkqtYvGd63zFbU7oqTOHqUVTPQqLU7MwvEpERMpiItNl6moAiQVvvhZ6NsvxK69JS0zqf6vpoyzKZCTq0N3TbYnF38+KtMC/xMfTfonRlFd2ksmJlV0v3G9ObYnX8tYzf+aGS499V2p5G7VQW67Gpm6wiA7kh1t7U7kdru02RMEybyXBsMvkcF/FxfnKTxXxlhoPKhGevu1WVvD0YeIAyvLgLbdoLWKXDo9hGLkl4A88DPUeNU70vm7i7MoU8ZPhi6NEtofu00QwnxkAS3T5KAz73f2pQVijMPyryo58PYWaQVxlZRqbyPdyDwLjECrlOtWv8DYmS2OPxY5Q6OSXZ7gLmS6dAutyDxKhFZb0fTtCyP57kH+jeo1FufTeI96z3YoeZlz5ExQo5fC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb59cc05-aaaf-4672-bd51-08d900b8f31f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:21:00.4204 (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: RihLwD6fzOCB90KoOKsYZwtCcIj6oVttpX7Xbhnzl/4kyAb0VK5ElzQpUnvOgcrPJ5tqvu/iapqcGUOoEbwBDwKpoLcT/4ka4rIFRPmADtU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: xXLuTV2QdiwiGr-SYekSU0VAq7NV-y1b X-Proofpoint-GUID: xXLuTV2QdiwiGr-SYekSU0VAq7NV-y1b X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 80212d2..5740127 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. @@ -271,8 +271,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 @@ -287,10 +288,101 @@ xfs_attr_set_args( } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - 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. */ @@ -727,115 +819,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 Fri Apr 16 09:20:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207239 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 7A10BC43470 for ; Fri, 16 Apr 2021 09:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DCB061184 for ; Fri, 16 Apr 2021 09:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241670AbhDPJVd (ORCPT ); Fri, 16 Apr 2021 05:21:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36548 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241677AbhDPJVa (ORCPT ); Fri, 16 Apr 2021 05:21:30 -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 13G99Ifu026156 for ; Fri, 16 Apr 2021 09:21:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=OuE0LzcuFI5GB5AmuMHSJcqpK6JWUVPAl/AE3Nd1Vu0=; b=i649wPlWOrioZBrHoItPoGg+f3UYAViiTCnEgKtnlehkhZWHkslsfO8bwukvrt7A5VGd mBsWx0HZAp7gozwCo56GzrytieBrZdM1uCkSMhx0WxCxVwhQOek4R0/IfhQxFRgCfOIj jZomoXvAUvuOFP8KS7OOXPUUWeRAlN0cAkt/BwHrtjdlrzzu0k/6RW8W/wSKlj+hXBwx kU6WTXnh7bZwhILek30/9P3/9Mak/NRdzFqZmUU4mIvKeVNMfWmQNDkd+/9cSCACje+0 DHaNAMrj55VXQMxK5gvEgAOh0+oZAmMLwV3Ik92pXxz3mIY3nihwr6PUYCFItLi3iwbQ XA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnrhet-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G99eLU182118 for ; Fri, 16 Apr 2021 09:21:05 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by userp3020.oracle.com with ESMTP id 37unswy7h9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MCW7pd/I1WtkE2KlMYEIizGMd9J+4y+sPFQb1T7q3eOFyYZdZbOco0B1KLaPNk5q6YXXkax1/vaoDA1IVheBCJvuVSDKFRWPTAt10HVQZuTNZOb2WA5moQqC5YmDcHrdvi+RvSM/mj8OcxdwNvTWnfztBgkWN3Ngrn8Fhyl28+6q0PnI4neD6BhCVeNw5R/c6jrPbSM0gBVsxdV4cHbrrp0xUMHoOc5Gyz2fnmFdDIrOwOqB5urAhDMWtZEbGr4S3xG/M1pXg9Id6J4NIiusHvcqoDUNZ5hAzApp+LZjqAeLJWZgCF6oxeaiGbO75D7PbA9LHsusxi5r2C748MmhnA== 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=OuE0LzcuFI5GB5AmuMHSJcqpK6JWUVPAl/AE3Nd1Vu0=; b=R5WTZtsF7DK+GVZE07oUX2TB+h8C7OZmSdUk9N/c0HPS5jWRW4Y3rQQgHb8itUqJOoqMTOa89aVYZIikKMNK+MgdS/srW5rZK/Omo9za0vWL9xx4avsTqLPWpf4SSrZ/SDjMWtgfv5CtA8IvqkAgxj40JCbYqdyFy0OEtRtbCsLufZBiHvj+U+Bd/X0BTb2iNt3VdwOfNleplwWJBXlcB+dGLePe1bDye6VWIpGWDMnTRPhK6m/lXkcZ5RuNbjNVPZzaPMYjTIfnE3PBnfUVhPkgECI+xQRV3FQnn2E1mmoO77EATVeKhsogw5uuE4xqg7gRtqRS3pb5LgSbW/Befw== 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=OuE0LzcuFI5GB5AmuMHSJcqpK6JWUVPAl/AE3Nd1Vu0=; b=r8CCRH3XjoMGXRX7EtE6XD3lBn5T0hcmgbTbmS/7Kd02CNN8Gtdn9NgAr+CrILTfhAZ0JaRAf26w+ihBviJ5i6Cpef3z1VXhoc+3j8EAT3mKCsEYbRcXfvDyVaeEDSs2HUYdMf+1BDGWJ2zdpvYwXlF3+blwHKHQsQxBHwK656E= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:01 +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.4042.019; Fri, 16 Apr 2021 09:21:01 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 09/11] xfs: Hoist node transaction handling Date: Fri, 16 Apr 2021 02:20:43 -0700 Message-Id: <20210416092045.2215-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:21:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1ab0fd5-79ea-4d4d-5eec-08d900b8f355 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SsBgK/ZNBxXvBpx0Gjfik0l0/Wkyyey6Tl0yhRgPBnTCL8FDPfjh6BICfbgKKzC6Utb9f6PAD8TEdD8j60M7m2KpUfkcik0Y72xkvKYEqYeAVSQHs3N0a8muNh8I9ZzZ4O45pbbdxcqVRhM/Ww9TYYmoVdpJnV3REAPgylFIRjH1deY09/m+IFqK3z7j5CrAiuCdAX/XpKeOIXkDY++pKee7aWFnrkElW3hRw9ddm1ZMTHMnnuK8kXh0/C+zKWAAfvTMe/hTwSuPyKIClmaFxfpb81jrXlJldnCaN7PQjMf72HOaZxnq+pqqfoJmsvFr6RGF9fEIXvaLY3iqHa5CABGvzIJzZ82COifU4vr/UI8qJZ0Gr389wC2+Xkk/jEwgEbiWbKDWKK4L5hin+WABRcac7l6NJiD+Rr8tB+O8asCvY0ZZ7LBr35jfBSnuW2mVB7iRMlBISmnP0GPOzeaHuUtY0w/aQL5ShRa3I/NXhNppiL1SbmdGVAPvZZ/g6Yoh4uLX22tE8EhQ7dH3eN/5B3xHUi8Rx04iuh+7d/h+XSiwTVxJvr1+rVYiJjVVUdyZroaB30cPKtKCic58Hv/2ReR5ovwo/brhP78ocplHYTYMNjvgD1i+eHPanLSlBXy2VQCZ0wglmINV8dbas+ulVc+iu85koV89NsvjQ0RjjGKQIClyezhvtRL427mlf5f1 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(69590400012)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 71Xgbtrrac9GfS56uecHrRmUvEzfsw8i0SkRYLd7TLDB2tICcAkS9eM9tzwpMYBtqVzdb245qn8GN9M0tCvuOYgBsYv5EuIZSHbr4kMQm1qgDSAkFvRSLjjaDpqfwzQ83mfnJA+kBXlfVnH/809x9FyPM5tqeDYv1Aeb2yt+C9cMrz0yiUH5hzBEiRwT/uY8oDkBlRZCB6B0EvMakLk7l+oHXhrf+22gZW1QS11D6aKfc3hbXOpckEB4fPD7nsAt760TxnE+BDbpl+oAq4ANQXjkNn0O1H0DL31uEFjnOoGM7CJ1kxzvU1+69xqcxCApFFsvwEhYyy4VJUwz796CPHz/v/hnmRL9aqsi4C2EAbbFydQIQLpVj0oR7YKhPzcSeyLpJ9ABYn+7qdULRlkh/nHPD6SqUmhIcAfBKH+OUducstY89UfvMgAC1r+4CILDEeKdLuUQTDj0G7UjzWeWqd1PxNdfa4f3O5x/uiiO66XU2j8bz53y0YzPGi+G+0MgvMLU3fkK+foXZMGF/HGr6sgLyUt9rYpnNJ+Nq75gmncLgFQJbE7GVw/zoZle687AQcsnDF6hEWwAYv4mBXNmRillhhDwm32jfIponOpNCrjDY8fwfraQXalmVI5sLNrKduhHpAUNfofVETn7RKe5zVRQr7MRGjvnereg0TH0pLSp5Ncmiy7XFLt3O9k8tCCVlKPAAE/ciMiRfwnwB9dleeeEdFRMzDorGn88MfRlTD29dfIFnOt7DVVULrgfhyGsKp3evfK5voRA0lpOtGcpu51LDulbhEaAvGNMgBUwZM1+jdA/Kc6CRwK2Be/K91U0YKL2GEHXiU4YCRrI0nED8r9VKF/n6x70GJxYRsWdIh0UTladTS9Qo2KMf7GFaRlv0bhuriW/LI33SkrYfKSKNtjMiC81+hTin+yFx6cXpW50hlGl2e63Q9k0OtXSfp9jmaXR0kB3hQ1HAWvOG1PL/25Nf1tE3GClarSS9r6TOiE1FQW1Qbil5u1m3OE2plMX6fTTXrh4Ufl56WPKLIZZ4TLaZM5oOE68rmgNcM7fVa4x8VcYG77sRU3l7IxLeIknhwM4FFswFdtG3HjQkCjdMWm91NFCy0rEVfUZ2V+ehX7KlKTK+GM14jy6ilgXaxAT4GmTFuR5UvwqN3JD7Pkiha6FQhaYo08yRZW/iud4Gsj51OGyg7PGU6SCigHNJGCVIeQ0Oj+2L/c8pZ1N1YfgqBRZ8X2/2XJwm8Alae2feG/OKILg67ydxEFFNLbmmRjuO8yZzchXffQldKBE4PhecAsq+7SpiUKSWMc+V+4lg0vSah0182RO6hadRWvRU0cU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1ab0fd5-79ea-4d4d-5eec-08d900b8f355 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:21:00.7470 (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: IMmgHJiz9sZACLcdLVJroSPnTNAIdzgZ79t8AK7HG6crFFMgB8yjYRxZpTkdh/WyTlAcjT9zqxujy6GdWeY5wvReCLLnIWsLMUiz8hPIf3c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: XwV6CIxBsgEizGR9v3WaE7RveB6uQCe5 X-Proofpoint-GUID: XwV6CIxBsgEizGR9v3WaE7RveB6uQCe5 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 5740127..ed06b60 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -289,10 +289,36 @@ xfs_attr_set_args( if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { 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 @@ -382,32 +408,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 Fri Apr 16 09:20:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207245 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 D1A90C43603 for ; Fri, 16 Apr 2021 09:21:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44E06117A for ; Fri, 16 Apr 2021 09:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241673AbhDPJVd (ORCPT ); Fri, 16 Apr 2021 05:21:33 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50102 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241666AbhDPJVa (ORCPT ); Fri, 16 Apr 2021 05:21:30 -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 13G9ACN8166770 for ; Fri, 16 Apr 2021 09:21:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=15gncFFWXs1dJz1YJS3RuBiC7K5P0RtLfgKt3XrjKrI=; b=uptqMChVL+gBtPQt6aterH8koWjUFIjQFeIyc+7Yzz4qcRE8CNtOXnITB3D5FuQBviIj OSy74F9XE3UB5bGL58LWIOLGUtfjF25uLtsScy+vkuZm1vW3vNYm7GEaegJUFOmqDJsL i5St8oiDgno7J5aKMk7JD2m/06ZRsxVMGoFXOubn6njOllYCfNpGKyTsVEvtZ7SxpPzb MsNrlxW5qSQLPy5K5yfHIu8JuGrIHqATPOGxgdU+zm9Sn4nHyfjSxgKO2II1KrrFKlLg X5hBcwENFFGpLeOU27otmaZhb0u+VFoei3p7FMRj9ZmmbbMYPiCxNI4Ye2ExI3p4G3fi WA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 37u3errkmt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:05 +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 13G9AXT7077147 for ; Fri, 16 Apr 2021 09:21:05 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3030.oracle.com with ESMTP id 37uny2cegt-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSMuzZ+2DVlEeEXBOqm6yVtH9dZZ8qfprl4UErJAff2xfHDcnKEkDe7euh8OPsp6pmP3PsmC5nBRUMau/2ddNZ7upKalspZKOuYz4XD/unqRMtpDSafXVQMS+9b2+rMl0FAntJtWSAwQ5Kh1GRfbbYC0JZ0NajfCEslqSEhVed2YIU2JKh/d4vJ1BVgg954CwAeiS9CO8tgoBRkykcpGVx2FYmscUhzU5zBgtCztFx7GipYsleQWxdV86Xkq8Apej+zn0rhQ3K/kCsG2Q8DDpOJhbL2F5/TARVMxhKirGhEyIAMdLJl0Rc/qUnQBH9oj0oAu2CJuMN3r2qt4FeUVQQ== 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=15gncFFWXs1dJz1YJS3RuBiC7K5P0RtLfgKt3XrjKrI=; b=oFaiptmNsp25qr09zv9MP6hgKy254Falo4zlUL1mV7wkYamrASmaT6w6FtTOxASVgyjCfr9uqikoTv8/GPOGW2vH7qICkk6/Dpv6V24N1RV9e2Z3PpTMKu9virGHMVR7nIVA/qXfM8lbNizT992L0JK6A/9yncEI7J99faxIRZrgu+rzVVffvwFGoOiPltKX6SJs6mlmFtIN4wN2KOnlpLavHPxVPsJHB0dAkJYZxrb0K//qKV3xdJiHHoNOR1XUSFQR9yNYDc2pjfxKg+3tFPxwI9cTm5APLrzs6IkivKaH6Etn7DKfwNmhjghSxGaRYnUzjED/j21zxSTU3wl5RQ== 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=15gncFFWXs1dJz1YJS3RuBiC7K5P0RtLfgKt3XrjKrI=; b=q0iQ15ROjUStfp55aG/o80JeMnLwQZQnzmUxOvuaAM/W7YA6vaJcQUXYZIOXgLy+X98j2BEAc6/YvLnZif6SMvdy7mJbkYz2MsZ/DsTGWNH+0hPKaNjjahUlqghiifS1R3sEinbxQg1Y4foI2gSWBAzoAw9lIiejRvPLeat91WE= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:01 +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.4042.019; Fri, 16 Apr 2021 09:21:01 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 10/11] xfs: Add delay ready attr remove routines Date: Fri, 16 Apr 2021 02:20:44 -0700 Message-Id: <20210416092045.2215-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:21:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9e7e4fd-b755-4eeb-71a9-08d900b8f386 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: j730QWn7Kphf7LqurTTkqIka8173nd5+Y6TG8vSIBWf6j51AwsG5C6ldeObySFluewVr5HNUxwMnToidtu7Zd9aPHtWkdZJ812nxxbsG+4VzU6hfD5kC2S4fQ+oXoXYpp1Giy/pnQcUOgEARowvvUFOPmbEAc37EZpd8BHNjJ7Eh+wrhsU5PJhoZjU9oOEGPhM3UXF1+wY0oRarWtEqA/8jJcQ0Eb96lPghj2IzifIK3YBV4yxr+c2CTy/a8kAcd2Wdqo8Lca+DZl8wYhmYX+gMGljCSRrqcFyegTVl/fYPtVYJxxikPLOkkkC/u2aILG/2mHXt/VS3InJR+0+bpAmWTvsNOGiPRFdVjnvD6iWFK8xhRKfagmphywZ49N1ecF/knfA3ZIJeBTiweCDMDK484KX5hGQ4aMnzhSKhh3GbWUJuBPK67qZiKdiH84TPgS0fHRKU9uXxm6olGfRW7/LakrOvXB7OYDoiHA+KnQM5NmTRcX12lWKOhw4ZyWg2mxNKId9qSkIB8QFwZcKkblVpGOxFVZ7JJ9D48BlcxVfhx1Bai5rGNj2ft2j6E2upBwgUttxA1BIn6XIjZdk/Ym5Jwte0dFfmQVzDmxuS1NPiwQiR2PlUkrVy4ncWfhoUP93iJVVYxdY/aWN9niVyriw== 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(30864003)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 98511q8WwEpu/7WDiCToh28oW+gQhrXu1xc+UIsL+FI6X26dGSJgc5SppPrvp9YXbUTcwYWbPjGFH98Yc20AMaenUEQ4lzasljmmH5rBkNa0BOSWt3OcY6efG6ETcc8FpWjT6OUG5iFFTc4DjSESRkKQjlLXcLMtqobPRZ4Ismk0V4K9++gEX4uFyOHcnbPGObumQRlj0zIqbOb1CRf5dI3b9d567zho4AZkbxjDr8Z8f4a8UDtNM34G7lHy7M+T31KmMH/X1tUYJ0w2YtesuwnIpmhS6WZ/IIJrOuTVwoaSWnLnfcdoZbya2lcQnp48Vu5r/oXTzRQI+XXmFhHPL9SxcKV2CTImoziOBd7E7Vj5ykk4W+WwOO56cT1BOfdUJSeM7v3Yk7VzZF7PI9rtUjtKB/zBeuS9n4cXx74vDR+v5M4IFCaAhrh1eiRdzE9HY43wfw8RBHT32Cqj3BXN6Qy0yc01UIG5ZErLzm5qvXhXM28JjvyuWMKYozl11dbRZUq9w9X04uKRObo/0RWyGVhqrjg2w14/hpw71H3o2/LwFVv5ZowMRp1Ox1Ir6oioVUGAGug9sMjxliqGCyrJ4Lx1lgvXC0b+cZar31sOP8avV/WH3N/9nXFVxz3IbSTdzdm9yRjRYSsgHp8ISRujxM0IHps7OA0Ds1jeioQJ2mBSq09eozN8/trwN+56+em0a0dC7EDB4/TmnML4qkS2ChUejonvCJ4/du8bbI50HioU7kFV7KsBweUHf2JAcrRYMmg6Cot6rqGV7uEj7YYvDwm+PhPgfh9N/8EOD5BPfrX1Fu3nXRNu6TEKfP7Ysec8cvz3pZLtesK+kX9oVG9fg1xZyyHDDqHgjn5lDLs3ljeItNmJrOxvfSIF9zhsF3bxsecCCGNa/3aTeDcOuj+rF21jUhTP9vD/aYe1jFa9KsyD6F5zPQmEgXl8cR9aeXmheioj8hbAa9gWqz8d6MqWvrS7hwWRliWy+IO9meET9VPjPWdCJPDC/qmxJ1FeuZhLnBr62lUuLx+a+rWhT+afOB1MSZnPXO07a/IwLC1lyFeGXXrXfaCIUSfVVnaLGwL8WjSpx41uIxcl7+VU4Qm+OFEcbLm+lBg3GZzgTxMt0J/WAdeE+1tecd+zPZma6vzaBSz3Z/9/6WLowyqGR9UKPAAgnMsOmq4raeVHShlSsxOcgych/i/RqEPxMdsY36eyM9cE2+WCRd2ykRQ/udVSlKDp7MNS3DXVt5Cl4eupSnZI4lydHvkmP3YaqzeOM3wFfnzMMR/PhnN3k8qaH2wVqCWzs/yDe847/LDqyfYmOKDr4xrcoBswoG0IV3CGAozH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9e7e4fd-b755-4eeb-71a9-08d900b8f386 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:21:01.1194 (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: Udp5r4cQOvFMJEAcaLxT916S3ZIe2FPxYP4l5hChuMWpcBiqohWETe2A+t5KCGbJi4i4SYRqpNH6T/ZOfCkMnuOQyKnd3Z+pozCHBQSPWhU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: 8y0fm-OLasvSJrPe9--8y2gakz6BZXrH X-Proofpoint-GUID: 8y0fm-OLasvSJrPe9--8y2gakz6BZXrH X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 --- fs/xfs/libxfs/xfs_attr.c | 208 +++++++++++++++++++++++++++------------- 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, 305 insertions(+), 88 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index ed06b60..0bea8dd 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); @@ -221,6 +220,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) @@ -527,21 +551,23 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - struct xfs_inode *dp = args->dp; - int error; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; - if (!xfs_inode_hasattr(dp)) { - error = -ENOATTR; - } else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { - ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); - error = xfs_attr_shortform_remove(args); - } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_removename(args); - } else { - error = 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; } @@ -1187,14 +1213,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 == @@ -1203,10 +1231,13 @@ 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; } @@ -1231,70 +1262,117 @@ xfs_attr_node_remove_cleanup( } /* - * 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; + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + return xfs_attr_shortform_remove(args); + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + return xfs_attr_leaf_removename(args); + + 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; /* - * Refill the state structure with buffers, the prior calls - * released our buffers. + * 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_attr_refillstate(state); - if (error) - goto out; - } - retval = xfs_attr_node_remove_cleanup(args, state); + if (args->rmtblkno > 0) { + /* + * May return -EAGAIN. Remove blocks until 0 is returned + */ + error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + return error; + else if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior + * calls released our buffers. + */ + ASSERT(args->rmtblkno == 0); + error = xfs_attr_refillstate(state); + if (error) + goto out; + + dac->dela_state = XFS_DAS_CLNUP; + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + + case XFS_DAS_CLNUP: + retval = xfs_attr_node_remove_cleanup(args, state); - /* - * 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. + * Check to see if the tree needs to be collapsed. Set the flag + * to indicate that the calling function needs to move the + * shrink operation */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) - error = xfs_attr_node_shrink(args, state); + 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. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); + + break; + default: + ASSERT(0); + error = -EINVAL; + goto out; + } + if (error == -EAGAIN) + return error; 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 3e97a93..28fe719 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_CLNUP + * │ │ + * ├─────────────────────────┘ + * │ + * 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_CLNUP, /* Clean up phase */ + 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. *========================================================================*/ @@ -91,6 +218,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 23e2bf3..ea019e0 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..908521e7 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 != -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 Fri Apr 16 09:20:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207247 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 58922C433ED for ; Fri, 16 Apr 2021 09:21:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CE0E6117A for ; Fri, 16 Apr 2021 09:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241666AbhDPJVd (ORCPT ); Fri, 16 Apr 2021 05:21:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36564 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhDPJVb (ORCPT ); Fri, 16 Apr 2021 05:21:31 -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 13G99JcU026162 for ; Fri, 16 Apr 2021 09:21:06 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=a1flEBdq/mOGYIwhzA2ajbkdvOvCvF2o935u7UsJcxE=; b=Felxol5EjF+ExhR78id/5kOYi5Xmipi08XWrrB4y0O7lOEp5uK/aeRVIv8KeZD/wxhj4 CRqeAV60iTeKy9eOnXg/18NsUj5NM0JDLJZim1ghW0AA7fj4ojAkmcTLpGcjOs91So3r LlsAXwE/a5Ha4nLHJu7twaXvPNGJayV/ByZPoRewMr0hsZP5yBW1qZSmCDXmW+y4zAje XXeh2s1NaX62aX6soRWNXOOE87QAVLTO/3CDtvoVACil8G/cUA6/hbQsHpIvPwyKP/ES pTmueCiFe+dCOu98qH8d/mwcdGrokchQ1nVXAcrxqYK5ywiViOgBjhKHGVkAqLMC8teY FA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnrheu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:06 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G99eLX182118 for ; Fri, 16 Apr 2021 09:21:06 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by userp3020.oracle.com with ESMTP id 37unswy7h9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:21:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MX0JmWiTCeaeWn8MtrpaQGCY+paTalvCVbHuP9deaB5480L72lEA8FHeGeXoZCoeVtH6DngDlOCP0cJr9r45NVksrruFkrOyLP+lNNlbdlchR5UCUJGxiliA+QQeo7H8pY0eU/Y6fsVOkEZe2aN3FuL8+7zEwNHtmL5K8YhSUNAz4haGQqZCiqwN25VB+8a1BwDV79ngYRGYf/5LuQxbTR3UujmBmBT5W5w3S4WXEhN/NcQ2XDWDK6ZgiGpynTS3oSRIJO/ODMBhM97bEr9n5t6TYATPIzq59S0QAw6ZCGpwMvH5Cg+Wg6ymMvGrFObfeIy4bjwfC2HHhYz7oXy3Lg== 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=a1flEBdq/mOGYIwhzA2ajbkdvOvCvF2o935u7UsJcxE=; b=aQHWTiyn0Q3fMfnwjBW+ce99zu7FK4bUb/X7p8HHJSn7INOSBwRPcOd4yvkCo5WGawdUjYFGlHyw48G7YzG6diapfFwlVbwCI7l38c+tOphb7Ul7eJ7M0KL+U4N9iuPpTQTiBuXA0rXytZzKbUt37GqFPEA3mzGHiB1u6G8C9X4Z+Wau7IOgqOJOowt15J/xFdExaBr+OOTT3bJQszrerEitB6r2S6chxWl0IHXIvZTFQFZc/B0J5ZPOOzXdy0dKAA6hzYY+LXYAp2u0TQlBY+Ejd9eHVptGkLK5xFB1DoqJfm17Du7vIsXJX2cgeVJmmj/unRvd7ttLCQv4jL5HNw== 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=a1flEBdq/mOGYIwhzA2ajbkdvOvCvF2o935u7UsJcxE=; b=O87dbbVhu/ebDJqucBv+4xfOt/eaIFWoAlg3hsF3t693+TLaOBuMj3Na2LpCrjeg4Z291yDdpwSSJG/u/W7853WvrJy2u9TdnxLFzBIz1XsIuiTfSbzIBNy7pNPsTV0yWYJGl1Q4dMTxWlnGByLW93/S78C0RLhZfuQsSP5Ae3U= 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 BYAPR10MB2567.namprd10.prod.outlook.com (2603:10b6:a02:ab::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Fri, 16 Apr 2021 09:21:01 +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.4042.019; Fri, 16 Apr 2021 09:21:01 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 11/11] xfs: Add delay ready attr set routines Date: Fri, 16 Apr 2021 02:20:45 -0700 Message-Id: <20210416092045.2215-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416092045.2215-1-allison.henderson@oracle.com> References: <20210416092045.2215-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) 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.222.141) by BY5PR17CA0029.namprd17.prod.outlook.com (2603:10b6:a03:1b8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:21:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0b250bbc-e8f8-4621-d65c-08d900b8f3c8 X-MS-TrafficTypeDiagnostic: BYAPR10MB2567: 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: 03FiDQvI/fUHDbZ4zcmxXfACE4aszEVGGRyHUc+BKGLfYkgF6kbW1xDp2zOLsrFe4piU9lA7uOutrvSWhzSnqBhYJIdTQOmwS5CZ09mS5lKFwHEgbmLjvpCzowMVBBFakelDy3HbJ8hhk+1bGtsX5MgkQ/AFJj2UaH0nlDi4wTH04apSES445dKBaXYW+v+ANed2UU0dPynW6VuYe54Domj6fKmBoXSgUvcc65R2e0pHdOiPXzHQEX+sOow5zFFhcVvQRnEn47jtWiThMPW+1i4e7NMVuKPLDklORsvamMzi9w+tPZEHuJ4TvkXSza85tV3lS9Hb9PjwbAKKPy/+IQp+7sxJWG8KPiDPFoWNX2oF6TLE/Kma7ieEaH2lXoPK2331icRy7ghlur2EKhlmG3h13U8rX8Gp72p1XlmipCUI4l6JMw1o3EbXV+iQoprX9lUgoVljZKq9RaFxMkxTpkjo+5Jj6riRc69wBfwCUdMv+IGdGWKRn5M+wA5kLUIJPKSrPgPs7UPjjcoL2ekul4ZIE9r2MHFMv3zUvnH/V7CvqW0VSwsE6YdbtT43iqbjZ7emaoNPH+VQO1uDZCHpChB5yOmbgv7CxQ8mnN0nl7XGcWR2I7zw3ReBKJfskZ2KC09COXmvhib138Zba+MGUQ== 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:(366004)(136003)(39860400002)(346002)(396003)(376002)(16526019)(8676002)(36756003)(44832011)(8936002)(38350700002)(52116002)(6666004)(83380400001)(2616005)(86362001)(66556008)(26005)(6512007)(6486002)(316002)(186003)(2906002)(1076003)(38100700002)(6506007)(66476007)(6916009)(30864003)(5660300002)(956004)(508600001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: r8zoWI8IChF+TOg37vunspeu+gfDDWS6amyYwry0ncbvyuLYKQBu4JVAMR4yfBo5/rLH8xxBJqly1LX4CTM48UaVNyij1PXVUr6TbGv01TdYyYIuZeRnJa4SfQiIqFuPifnRrSUljc7U+r1CtTG3s7qXWUt5vcojKeUIDHAY1u8JwWd3IMkVhfnm+I434v8f4Uggwz9ppQaD34Ndtpmg0B0lgVRxaG8SqPfdozuHDcBu/5bZTQSTApuoOvN5uuCs+/prFDG8msMtXxkY4pwIx8lUhAcUlHpUcKdmo9ol8kO08saiOp6bH460i1FaGBwV5Bqq8eEA9LfZP0ujyJ3PluctAKtUbAMYU0yx1FoFYyqbw0UIXgHTF2VPaHYUyh8b5QsNBi/WtwW1tmH4StZwIKzR8ChtIa6wbsLsh2vMDd05/SuHQBtufJGDFcDW5DGeOMq5wr1zJgY/S94oy4v+oXJ1txsdDT0B5WDpsbGf82Kur+W/oDlUOuNJkMTs+Wv0AVNB3aHlDPooRyspOLmHCunyPobxOhjRyB9fwOibQJ9UeB2YDbGb74FlevkYmzeqgFMaJopyKVWgbVViIjO3z2iHfmCObmPRJcyZXpNlVROxLkwA3T70Ax5E8zyVVGs2FskQdE1vZKpLFwrObe2vthIBAuSJOYiRTSjySRT3popdyxaxiSKFzGlHJ+ljC8IOPxjQtLRoV+YiOouUr9Rptuq3TYYNfugR0Hr7g1O6ONQtSoWmBLA+sQ/JRfSrWO6nwADsF6HyrS3rY94CcCe+lTdKsJz8MibNb7ymlSRbBaG/xJQznLCoi94uLXv87Odkq7LRSJBYgD0J/nCE5L7DorHuuuZ5m6BehScy+24NX9a5RBTxMB0s0p6tAft0VV2hlzKr9zXIpDq7uRklqGQyAxN42uEBR1DBlxTG9ux/5KN40XMUqaeE/M4ZhsfexPFdcdcdbE6diXO+744Iywvrp8rwUBOxSBnxVJEAS7gkyjpx3dW/Q97/CnizJYGNzatBVeRnYLLXvcpnePC3R8J4n162CNvVmTBKJJM/0+9IkKvlGHheFC96GNboyo5HEIgKUQ3z95NEWyZSxOXH32N+IjdHnjM92sZUiwcjZF9IjbQGAI6BRDH3fBN0pO83pT4j6ZPBWM3s3qzhnZDU0I8YgjMDtO8z+9Ax/IdtjX9Q3871c9APJ7Gw1F9Q4QjR2aNo+HNmPE/S1z1Hzzl4JevB++GXjuGU+22I5KxDS6lMr0ht2lx+f/Ac0tlec4ODQLn9A7X4NBIiMZo6TIY9hWTDoDmnk1I+yv5l/tlFDb8LnIFWUTKIyvjHWJioQzQAe81T X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b250bbc-e8f8-4621-d65c-08d900b8f3c8 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:21:01.5734 (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: pRbm5hjIx1vnmuUDwfR+Clbyox/1jTfEsyX1bkpKdMQHtCpputylI/tWnuLJqqjNnsDdimf0ayVgcT7qYnRZvxhkTYCCcGc5He4J7dkxkLw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2567 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: enHyKDriSTV2_5Yw7FjHolH6nwyiPiNc X-Proofpoint-GUID: enHyKDriSTV2_5Yw7FjHolH6nwyiPiNc X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 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 | 445 ++++++++++++++++++++++++---------------- 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, 613 insertions(+), 210 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 0bea8dd..302e44e 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( @@ -224,7 +225,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) { @@ -245,29 +246,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; @@ -276,94 +306,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 (xfs_attr_is_shortform(dp)) + return xfs_attr_set_fmt(dac, leaf_bp); - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - 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) + /* + * After a shortform to leaf conversion, we need to hold the + * leaf and cycle out the transaction. When we get back, + * we need to release the leaf to release the hold on the leaf + * buffer. + */ + if (*leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, *leaf_bp); + *leaf_bp = NULL; + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + 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. + * + * 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; + return -EAGAIN; + + } 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; + return -EAGAIN; } - - /* - * 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; - + 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; + } + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + 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 (!(args->op_flags & XFS_DA_OP_RENAME)) { /* * Added a "remote" value, just clear the incomplete @@ -392,26 +458,35 @@ 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; + + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_LBLK; + + /* fallthrough */ + case 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!) @@ -432,89 +507,113 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; - } -node: + case XFS_DAS_FOUND_NBLK: + /* + * 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) { + /* + * Open coded xfs_attr_rmtval_set without trans + * handling + */ + 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; + /* + * Roll through the "value", allocating blocks on disk + * as required. Set the state in case of -EAGAIN return + * code + */ + dac->dela_state = XFS_DAS_ALLOC_NODE; + } - /* - * 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; + /* fallthrough */ + case XFS_DAS_ALLOC_NODE: + if (args->rmtblkno > 0) { + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); + 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; - } + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(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 (!(args->op_flags & XFS_DA_OP_RENAME)) { /* - * Added a "remote" value, just clear the incomplete flag. + * 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. */ - 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; + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in + * series + */ + 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; - } + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_NBLK; + + /* fallthrough */ + case XFS_DAS_RM_NBLK: + if (args->rmtblkno) { + error = __xfs_attr_rmtval_remove(dac); + if (error) + return error; - error = xfs_attr_node_addname_clear_incomplete(args); + dac->dela_state = XFS_DAS_CLR_FLAG; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_CLR_FLAG: + error = xfs_attr_node_addname_clear_incomplete(dac); + default: + ASSERT(dac->dela_state != XFS_DAS_RM_SHRINK); + break; + } out: return error; - } + /* * Return EEXIST if attr is found, or ENOATTR if not */ @@ -980,18 +1079,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; @@ -1017,8 +1116,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; } @@ -1031,19 +1130,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); @@ -1060,18 +1163,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; } @@ -1084,9 +1184,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. @@ -1103,8 +1201,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 28fe719..c0b94b5 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_CLNUP, /* Clean up phase */ 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; @@ -219,7 +490,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 908521e7..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 != -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, \