From patchwork Fri Jun 4 23:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300905 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.8 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 C812DC4743C for ; Fri, 4 Jun 2021 23:42:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3D10613FF for ; Fri, 4 Jun 2021 23:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbhFDXo3 (ORCPT ); Fri, 4 Jun 2021 19:44:29 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:48636 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhFDXo3 (ORCPT ); Fri, 4 Jun 2021 19:44: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 154Nee1f055627 for ; Fri, 4 Jun 2021 23:42:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=gOndIPq3yL0StYVAqC9PVAU9zgGvTO1HUubFLKPYzqA=; b=WBmtMiaePDOKL/Zfxn5KIUXNR6u5KZ2+QLQ26V+Px0WDu3ICZUq3e+l+KOXkiliJ8uaL Mh+wdsqI3CJotErLvWNk/EQzMRx8LeSR7otbKkVjVbEZ9NCTNUJkANCc8u6HpN7d4DrN 9ByyFNVNgPB2UzMjyog5gRhbyCPN/a5q7txAE8yj8B9QfT+GvDnySG8na/omnv8/Q7Dn bNPEzU/oFmlji9pq9XlYZwnR2W/jifwFARs3sFCCpS9zTISOWRW7GMQdAar480tFHkZD vGPSemD6muRmkH6zpVHuHGkZlOcLwjOOlKmBYZbjwI6VZEpHlLzCn01BH+sBcj5bPDwL dw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 38ub4cy2nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:42 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nedi5056299 for ; Fri, 4 Jun 2021 23:42:41 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3030.oracle.com with ESMTP id 38yuymb0mg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2U5Y66Gs5LyUgSP1d5v8qZ0d9Mjf54vncxUCtXz664x08QqCn8v36IG//EBYVoEzC/z2j3+P+IgcKdCQg77NoTUHPv/IFjudV4HZNIF1UzYH3M6NjfCS1dkpMRCkzVpns2KrigIRYsILdiFX4BPHUdtr7dF1m6wYZfMsKlnSe+DYjbso7GZb7BMl2VnAh2S5fZo/7GyGgi09M0CawXyOd13N/QoImOhz1ZlYd+ghPli3E4uc5e7VDheIQzA9lTG9zqJcUGpRq5XKhuGhqqJJFe9qJihiEzCdh/XD1nFIEFGpKTlxnTkXtqmvM39JBqqqldu0zYroM5BcbMUKgruNw== 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=gOndIPq3yL0StYVAqC9PVAU9zgGvTO1HUubFLKPYzqA=; b=gx2sMQHbKliv6QBG9k2gEexmOPhm/xnosnHEC15wKmwzeULYaBG9vH/lL97JSwksNbarNbpIoa8fG+TDSqSc78QQjPDdeMSovGjgqvRO267LyKWFYMnyuXNmxODNNmA81s43SW/4RE2TRFbUKbsTXA3S5kCGqMuMmhgV8LNw2h9F3XlCb0OGUeDGgHL/peIZ3Qjpn3SFjAW22nDquk02S5KIVRUmpYdAADzlEwgv2xMR8bMf8otiFcuyaMx5oXQ+pMrQ8kJdGbTjPwCrecvEs2U0fuf+6Dl6gJ5z7nMK3Bab5P6z5OzPfZUXIs9hkAM4li+DHfnMXYnQCg4ziA8N7Q== 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=gOndIPq3yL0StYVAqC9PVAU9zgGvTO1HUubFLKPYzqA=; b=o4Ym4TmFEhX5IIWg+r7dUzO6xqFX0R0KN4v+fR/bawJFGva8JD1f4qAJvZKwMgtUcCPdINHVWnnckTRj6aayJR3eXMWvVZP2Q2kHe3ZF/7HSXySiSaJNqI5WVKMNrWZeUp6UqwkwF5QXmC16HA1+7h6UQuMreP4sugopZkJcro0= 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 BYAPR10MB2485.namprd10.prod.outlook.com (2603:10b6:a02:b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Fri, 4 Jun 2021 23:42:39 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:39 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 01/14] xfs: Reverse apply 72b97ea40d Date: Fri, 4 Jun 2021 16:41:53 -0700 Message-Id: <20210604234206.31683-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb3a1af6-088a-4cf0-bb25-08d927b27026 X-MS-TrafficTypeDiagnostic: BYAPR10MB2485: 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: bxJvZe9nJTk30nsZKYDmUsRvffN2e/NOdqj6NQcuKCrTnowVT052SwPbPM8oBOhX6cYJMuqoAPovAxKpU2n34c7gQXAc2s8KFVwI8vQpIY6f0hvf3eMhLHxcDR4pe8sCGi1oJiu3sNF81xEAGxcy79t7aVdGvLrNmgtSoH5ye+P7QsGTa4a5gccx5q5Zbu/C+Orvsa3HjV9PFjDjm8g2U6A9jKJIIfxoVMTEksb6I7gItVurBPH/gT0+PdEYsMTpTY497pnVLrPI1vsVJwClQ/Y1TKWiLDCDpBirRVmUfatWE9Od65/3ndK7dYIRU32cxGkWlpQFfaQgQlb9MRcCA6UTmqaauxcDYuE6HEQ5kRMFA77+3j5971nJmN+/i650X94JlP3O+OWmpt7K/DHpyee4NVo/sSjWYE1b70pgGh5ofqiVoyBFu/Qp2ZdsbZZx5Rjz88Tp4bVIHXw7jFobgk05AWECX5wJd13A9mD59tOhw1dA/HYW6jywW+5KQM2xLIlpJOUoZj3xe35LjUAHhJbL44NItleIcdrNowl/0RJ2+MlmbrTmzHEGaBW/7ZTZcWH6heTiDVEXLFM8tWvQC4kAJ+5yZirMOb1tBUTapJIoOwA3bGpkZj6QSf32UEeWez79WxoBlxBu4OT6KqtlRI7yo5D0Oit+spfeSiMGPRPVamfwpZ9DIFWkTp4/dxYP 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)(376002)(396003)(346002)(39850400004)(316002)(956004)(38350700002)(2616005)(83380400001)(38100700002)(16526019)(44832011)(6666004)(2906002)(1076003)(186003)(6916009)(8676002)(6506007)(6486002)(36756003)(8936002)(66556008)(66946007)(86362001)(478600001)(66476007)(52116002)(26005)(6512007)(5660300002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 8UxJGwVuhyI1Q3uUH5AjW9TIiQekJS2IFY3uk0l7OhC0X3e42720cD0o9lftppp/X77MRaxdTBXTEufH8+rc8oebgpv/x/e98upFihl7UYP+2HqNSsiZN7BEj+KesjwVia5mYCFejtr82uTL7d5tHjjYgq8kNfdQilAYB9Y+8+F33DBggGntWBBDN+Mo+OUoDunI3qdXFEvGVfcJUUsRjc9d066fdRw7t/ZMPasupNU6y2zlINzoX7CRUt/bvtqEma2N+Ke/j8Ou2uLxI/l6/vJ1MYVLxwxco7F8mXChxfbiJeYhV/sRdGUNfyNMDu2C31CmReM5Q1EvLMYyqiCbBk2chRs/4Slh7YlVJnrRORBVFem9ojiUXlGKleEjC9s0WkCmxfZBn6/Af8096DOkZkqH7dEytN/g3vrepFtBm6+icMPRCd9DGjDA0gKDuM3CZ3njRhuolN1Yn99WTp+yoSrfmlx5WBPxqRk5c2LiP3P/Qv2Q+s/z1UJ0midGHJcr8fnNsBseyb0v6suTyJPizIadcTNPxJLJn3pq9VaNHfgOFaneKkJ+OHlvqKwhJdRYQVdcJDW0go3GlBFH7MhKKqVp+pntSogm9W8IB5X1DeNpv5IyxEO4t/BC77YdDBMMTnxNM1Q7eTtvf51sX557zEMG6bGP2mBc6q5lZ57GG54DiThm6TVTx1vXBVJDsa0+5n9S2ges+vEgN+ndWvzEg9wTXidWVd8THWrNAoGyqagUJ14mS4XnPXULIxZGVJDK0XeOP+3uI7KoyThJ94vT6QzdprMXYyORk/DFD94aFL9Uc/ugLafxmwrqNQ3/WQY2yHklwYcf8IdzAX4b4OulyPhJNnB8AcbY6e/ylh1G4SgCACR0KuooqYYZCssh5eruKvTVsA+yfENQ3PfIWSy3fGlBgLk28GQkagxwEnzJ3QRpMSztoyh4KWj8pxCxe/hCfS8yfZR8Sa8+WhqUV+OUz5e5dECln7gw7BqP0rhZ0PVNHwjzgjMO33TpqpxDYgJn9QLM0pJOPZxzxzLHSfR8s8SovJli0vbf6F1YlVE/QoWpRLcB7P8k8TlVrQ3MwQOpoSV3WLe1/OALVOFTr8H+tcuJ+ABqs3J4cV63MrPNnhiiVLR5/K6seDu57yGeWmlRFoWZnr60ifyfLgV+1nNe5UQf68FK+TbXQqpcYdb1IOUqiUaJfetEzyTnel8PgVNCJLzEYzaRI0FDyloY6CQCQfXd2v4m252myPNNIDF0xq/sSyOuuESEDBiVYujRnI4KmmIOTjk2syvHJq8nxmZbjwZrneo3f0EpppzURavmr+bXqkaBFyaZypf5Vk9MeU6T X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb3a1af6-088a-4cf0-bb25-08d927b27026 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:39.5166 (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: 6BlR3QQ7R4qS+nodFHFxNqEqCe2cJtqqCTF1J0YcyUseYxxb2To73ilY6ICuweYk6lWqJvBbDDQLZVuWvpolus7wXbMEmde28OECHvOWJ+g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: HB--ZtPHfTKIMYHpxi4eQOyNdhjgQwyW X-Proofpoint-ORIG-GUID: HB--ZtPHfTKIMYHpxi4eQOyNdhjgQwyW X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Originally we added this patch to help modularize the attr code in preparation for delayed attributes and the state machine it requires. However, later reviews found that this slightly alters the transaction handling as the helper function is ambiguous as to whether the transaction is diry or clean. This may cause a dirty transaction to be included in the next roll, where previously it had not. To preserve the existing code flow, we reverse apply this commit. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 96146f4..190b46d 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1214,24 +1214,6 @@ int xfs_attr_node_removename_setup( return 0; } -STATIC int -xfs_attr_node_remove_rmt( - struct xfs_da_args *args, - struct xfs_da_state *state) -{ - int error = 0; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - - /* - * Refill the state structure with buffers, the prior calls released our - * buffers. - */ - return xfs_attr_refillstate(state); -} - /* * Remove a name from a B-tree attribute list. * @@ -1260,7 +1242,15 @@ xfs_attr_node_removename( * overflow the maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno > 0) { - error = xfs_attr_node_remove_rmt(args, state); + error = xfs_attr_rmtval_remove(args); + if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior calls + * released our buffers. + */ + error = xfs_attr_refillstate(state); if (error) goto out; } From patchwork Fri Jun 4 23:41:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300907 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.8 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 B5475C4743F for ; Fri, 4 Jun 2021 23:42:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D3FC613BF for ; Fri, 4 Jun 2021 23:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbhFDXoa (ORCPT ); Fri, 4 Jun 2021 19:44:30 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58744 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbhFDXo3 (ORCPT ); Fri, 4 Jun 2021 19:44:29 -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 154NggwT041765 for ; Fri, 4 Jun 2021 23:42:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=IkA7W9KOxc/ye7hGsDKFTAXjCjcmRFlWYXXURRz9uwQsmxictWvLnGRyZzD2sEBO2Avx aaWsygcpVmtYg2BnrPa3h19bFrRL6VAEyOw9Xf27xdOj+0mNDRjxtQVESilbC0cpnJ4t dpTVxAkY0+wYAB/emBj/0Fs/GCpdc9Bj4lAqhPPQbj6hpg5ds2CLTd9XXRD2jP3L1+GM KHwIunTzqbFFuoYa+qXR9/l/S45hMTx37gB7r9GyUnRBFPyJH3UUmFTKYDA6A2lCrS+u vC4qxOKjWjqhsgZYItuKG3g2Svtnfz/HsN+rap5DcYL2Tn5ekoSyo0VcAgR2r4L5nFU/ DA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 38udjmy0vy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:42 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nedi6056299 for ; Fri, 4 Jun 2021 23:42:42 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3030.oracle.com with ESMTP id 38yuymb0mg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Caw1V/PpVJTVVdf2iSjemGAt7jER98/6BneSsou47XhWAg0hzZljvB/brfj056Pp0i5etBxLMrGn50ZoqeVhjetOh3wTxa69A4neiCFAvYGfJRMM+48OFLgISTHYPrTpiCd8xsSNHaE298LSenYw3rlr4NHIzkdwLgSHOGs2bZgBjKzzjwPRNpzJd1ov+WRnRN6ZO21nMmuK1c9975f9WDonsq9aOOQ2pL2BxhnglWaTYRg0k6s8zJdmOb2DcEAqwnhmkACTDbF8oe2bvEhIOH70wB4o98TGrcBhSzCJWVv6kdM1bPJ7EoMPElFTMCP1tMRACJoLV0W49+27UzztZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=OZL+CgsNS1B419I+0WIWqiOfnyhIgQ8VNO5TTr7uNCPQUoSFUDFnSxtQhIOjNaSex0y4KUIFHF1j82WsOV/RwPPsKkBVdFAPSMr8U34JNuiT0DuujtJhGLTOXZ/1Eft4frbZLVWc6MyBSUcMIA9L1l0UjthDd5zMinR1AAfCFNbp7Vf287bHbJaM8LVx60UU1ajACqHu2xaPLjp5vM5D6p8UulXY53bYtBFJZ46V4RGoIqjKzU52DCYosPwGBRnXIM5E2kuQYQ6dm8RadsprwnosCw1OV6qkLkFMkL30X9zeUfy8sa+NhgwUOje4GiNu/hIsFszzrgELZ9X2MmsekA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lsy5ghd5NCGtPxPjv0dZ32L1JJiBdQdTUN4+qBdRad0=; b=rBSanHSWzjaRm8v1pHx5j9rXp6wtmvX/P+/s1MPng1xCv+fbkcH5O+UHdjlUIkm/7xHvtpu+RqqH2+vD7Hp6a4aPSYjAkGlgZ2w8qJowLx+++Ur1+/GuawHpkRa59TZSPXQWxaK7fVzxb/z/VbbMRyhbwme08sDjJs2SpYBivFo= 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 BYAPR10MB2485.namprd10.prod.outlook.com (2603:10b6:a02:b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Fri, 4 Jun 2021 23:42:40 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:40 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 02/14] xfs: Add xfs_attr_node_remove_name Date: Fri, 4 Jun 2021 16:41:54 -0700 Message-Id: <20210604234206.31683-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c256c427-b1d7-46e8-b06c-08d927b270b5 X-MS-TrafficTypeDiagnostic: BYAPR10MB2485: 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: 3P0LB9cX549o8q47gPHqKyNU68MbZTfTXqbL7vBMyrNibEJppmXL9G08ynxxpM3MXc1E7mmxWUKzUkcGpFrSv2Q/uzlZjYerG8B2PWvj6QNWR1LZcAA4UvkT0AHft1ej92QTOFg5d7/hhfMJ+TXS8WVSkyOYEP4Hdes9fvWG1jQzeoFjA0Gg0xOh58SCNVS6y/ksBtYQiA8gCwF2klBracrdPaWDbqTwOlmK+OsMOFXwEa7PbD3AwZQCHCIY6LW/gFZ8VaI9tTvWmPcwmcTfmciAs0aKllUpvwBUUVl5z1bfL60vLJcAAAwTjVvrPiCwOvM4MP2QA9DGupRqsMG15tK96rTdyPuEKjlalENVuY8mqnQ0l56GeqSdFym2iln5YY4X0zKomFLga3sATD18D+9LcyRTACqKETs2DSgSBa0HPcBo0ADaIBoSI3YbKFYs4v0oJQPhc5rK9JJdcl924rGgU9gz5QTjajiwBPvF54sRLT9fg7C8LDcHEBzMTC4T7I453jUsIpNMAOHOlhiYXaNvpwSK/0rnDHaos03pzKcTRuIMPZaB1lan156WI6M+tS7puYe4Np/Gt6xA4WzzIcZEkhmywBDipZpvidAkbm8oOZLaSLp8c/QIKmbWRlSu6123vpMpKU406EPwbSGZgd+NbI6pdPlWrTbwb5lJUlsqwglZVR7Hp7kJelRNWh+G 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)(376002)(396003)(346002)(39850400004)(316002)(956004)(38350700002)(2616005)(83380400001)(38100700002)(16526019)(44832011)(6666004)(2906002)(1076003)(186003)(6916009)(8676002)(6506007)(6486002)(36756003)(8936002)(66556008)(66946007)(86362001)(478600001)(66476007)(52116002)(26005)(6512007)(5660300002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: n9zd/jO6S6oZfMEO4xZsUZiEWr4LdHv0fwhVdqmG/c7pue8W3k01Xhh0wg9MU5+ACFr9yZ8O546SHebo93CmkNVvVT+vSb0vCtoYAS6fXGqtc4/1rTI5CDaXTDfqlOY8aCi/pUhCy/CDjVGU9UfCmpdNOMhXvQXpe5/Us0BOwYj3FmxywFuKEYhYiAShdrTbt9dB8mkfh6tDyrrHXUHeiIsqZzXy9JFxAYjsA0+TDYwgSX93e9dJ6goYUK6DjLSEkfeqs+yb67VzvFdlhenoHrj816de+Xzxr1jtoobMfMVcYKQypCh5CgmHfDYE2Sdl4IYctzgNM4GYW9q7+d9h/vVE3nc0lcqHdV11bqLWva6f2700+M/rg0pp/EDb7/YTug08lORPvYz1nZomIm4rByskSbMvcfWYxP0kqxfehOWP7Rc1CX1FBlRCkUn6kzlpjcXWOJ2EgyLfbQx9EhZiMwPKAYitTJM3NoI4Ob5IPkkCJxN0JcVs4aOjx/rsM2I4oKxMOpNVVrjcChr9NVxeLhvyCyYe/HyWE4GXYmCqV2yVTOJjmm7FTZX/zJbGOZS3Cow6OwYGsy1ySzcr9OxtWy8vPcMY1OGApoi+vsLHzcX6Em7BEkhPUgclWYFdFLhLDPYdDM29oaHyBMjAFM333XUEFT6p+m6tEmTjOHpq/ojtsxBlns4eZlCfWJT/uOpRHhCJoOHHoDxvTf7cb9bOhjO5fg/gfKT+CbZgaFePg6XssdkTArnVa8bokD7NIgbejYif5CKVs+Tm/JZIuzOIulmcwUUgfqJMs6Azynn8JivZrt1WxzTzeK+yYgCMilGwTiVUJ5NLVM8EjWfWS/AoDTucRN4KvmX0k4fJnuizwxSLU6lE5giULae1jTcisY1GbhZjZ//UqpZpto3LHcKXYDStKBGn5ncbOQgaKFbe2Slzu/vZTel9OYCd6UrMNbHY4wzJBBmFomvcbgiF2qV15MYIlTx7jgCifI21XiBxtZLqFzod90wTs9kw1IeuFGbxcXGxR97F3A/DL8rizMTZ5DPTXqoFtXSk6EV4ZM44pYufc9qdjsMCi6UU+qgc/m0FTW9Zjl6ScTYw41BaRhLG8ZSBFDzu+hpeK43JnOoJby7HZS0xJmilWSrOdOwoRGAelZcmJ8BcVsBv78QHCBp9QhdrSsLj73tJSVCRgfqi2EcxIV0kfCb+qCG8hddvUs37DtbdflGu+4Z41sVVubd/cRKdJUP8/oUN+0HEk4MMcfp6irbb6eBAEglzwC23IpEI3pLQtScUkujUneuaDlZO4O3unRI92uFIP1jlcnVPUAUe9CF0fKh/ml4X/2+P4QCO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c256c427-b1d7-46e8-b06c-08d927b270b5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:39.9716 (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: w2Z0UT5KmtH3ZI4Yx8XbQrih4aohpNP7RFmCt/WY7E+fh+87Tc+LBppmMnR/jYY8/izX/E5HpWaOjqCWf7qR2GAF06LQl9v7XUYB4eYy8hs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: 6lc5HtvJtKEJYH42s-5fdg2_8rcgY8SF X-Proofpoint-ORIG-GUID: 6lc5HtvJtKEJYH42s-5fdg2_8rcgY8SF X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch pulls a new helper function xfs_attr_node_remove_name out of xfs_attr_node_remove_step. This helps to modularize xfs_attr_node_remove_step which will help make the delayed attribute code easier to follow Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 190b46d..8a08d5b 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1214,6 +1214,25 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_remove_name( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + int retval; + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + return retval; +} + /* * Remove a name from a B-tree attribute list. * @@ -1226,7 +1245,6 @@ xfs_attr_node_removename( struct xfs_da_args *args) { struct xfs_da_state *state; - struct xfs_da_state_blk *blk; int retval, error; struct xfs_inode *dp = args->dp; @@ -1254,14 +1272,7 @@ xfs_attr_node_removename( if (error) goto out; } - - /* - * Remove the name and update the hashvals in the tree. - */ - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_remove(blk->bp, args); - xfs_da3_fixhashpath(state, &state->path); + retval = xfs_attr_node_remove_name(args, state); /* * Check to see if the tree needs to be collapsed. From patchwork Fri Jun 4 23:41:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300911 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.8 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 DA5D1C4743D for ; Fri, 4 Jun 2021 23:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8178613FE for ; Fri, 4 Jun 2021 23:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbhFDXob (ORCPT ); Fri, 4 Jun 2021 19:44:31 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33290 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhFDXob (ORCPT ); Fri, 4 Jun 2021 19:44: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 154Ne3pZ062232 for ; Fri, 4 Jun 2021 23:42:43 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=gVd0enhwIWaYRhCmoYWj67z08taQidFZsLD19HHO84Q=; b=c9zA/uxh4lJC1OLpBTE4BOUksMpBzzAtuT3WILAz6dwQizvThgQqGBn206x2IdYBotH6 OF7dXD+s+FCnJF+C21948OP++6zTRGqTCD+9USCILmNpt273zN+z8lx3DRyjvVbNqYyP dkwEK6EemUKMgk4u5w5hb+KcYExei+FDnn1IHAZMJbR1F/Eis5d0kyJGU1un0kvHqjLd uHTZL3OjiLv0YAk0XoYrdy1gERGkEubgkfcgjneuVAJqpdmyI3p5ngsqOEkhEhDTXwNH JnrWDrCA92UdbJ0njD9LDifUro0dGNLUkbuNLS4yjyEM7s+nIO/BnN0rDQ1IOgi0bd84 SA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 38ue8pq0gr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:43 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nedi7056299 for ; Fri, 4 Jun 2021 23:42:42 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by aserp3030.oracle.com with ESMTP id 38yuymb0mg-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JgHt24/gPOYrCgqkpawWMbe7V4k/iuJXrDLDRwEg6MuNOJz6shU3OS5fCD0j0UeRdIvcuQRN3UhdwtZAKvjHVJb7G8sBR85J9dyOtmHpf85KUj7rAhvyXgktgWs1Nu3xfRzzmvHhqvwagU59wjW5+Au4EClLU+7g3vUpzdLt8c3652u2VNgSnYu8AIxt8m0TsVBRxJDgsMeDM2oUVle3GktZQ3ku4jDojccPvt6uhpoTJ9g0c7PsTANKescK3E2Fk9gOBrHtPF3wTA/JOo/RsumehrMLGjHnZu1hKfxbKrdc2omwhACBMq2KImoJRJziwCEoVJqgQtvvy5XXjWtsyA== 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=gVd0enhwIWaYRhCmoYWj67z08taQidFZsLD19HHO84Q=; b=ltbmTaNFmdKxMqasn7UA/rHWGTtr/6uX/eWmhQEPC+PVNunv2t3/reJzszt51SuiWXdeYdK6YRT9nuPwEFferMC54a03pfPFAZZz/2A+tEOClhpLCuqmqdJtbMRgl1nUiZaY9sU0L5Jw4PSMZtgc5LtkQBn0iBHhbnl+mz+VsyvJAtHPF8VIUB0qj8SaUkQaKOpFuUtbz1lqbPAfhVx5Rur3RooCLFCjsiTF/aoRg0/16ucTT2/+DQg7pzUvjBbEUhsCOljzBkLr5JVfAtSLYNlFjYpsTUgJXKvDDLal2paL82s8/8sdvD8WFIv2tHdP5TkDHm9lyq0X3FQRAVPQCw== 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=gVd0enhwIWaYRhCmoYWj67z08taQidFZsLD19HHO84Q=; b=V2c0YKHK7CDffHmMmktECxovUvsKStDse/coS42Cy2IW7iFXFKLhuGSI7/kRxkaAdjPwbpqu+OQWXwZa4MpbJ3oEv6+C4V7Qx4LE+Tn0FHTqt7TSMcoZYJSHhJ3wFfrJgjs/xy43UUZ1eQOmMkwBtGdTA/+y3U3MeXBWjpIEmlM= 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 BYAPR10MB2485.namprd10.prod.outlook.com (2603:10b6:a02:b2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Fri, 4 Jun 2021 23:42:41 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:41 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 03/14] xfs: Refactor xfs_attr_set_shortform Date: Fri, 4 Jun 2021 16:41:55 -0700 Message-Id: <20210604234206.31683-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 862c1551-c6ef-4332-835f-08d927b27112 X-MS-TrafficTypeDiagnostic: BYAPR10MB2485: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ydWW8+Ks7qPuJA5ZPuf3szulPfDfDH+1Er8P6oaiqZ9QNB4Vv7S22wQG122NMQ8LLdDb8mt5Xe2cJjjazX2LDMvh5h3boJrp2q6aZ2TA+s8UHUsZrOTox3QLyA4xmr32YCgEDZWwgx7nUkVe1/mEN22cTIvTrWFKzaDZhZdIqwWf8zcZRO7vCL+GgJclGT3zeNPB0/050xySw0QGvFBdfnMYPU30jK4+VT1LBA8fDQYHD7HbIv40wQmL5GKAjX+7Ubj1D1Q4YZg9N6maalCHzZDmqsTZFOGdwVLV2RNdKz5b66goXiIT7eF1liBiT8bGDpDA9TK/sOBdAkpcowSDpFs42GeX0hTlf5XeUkz0lopN6XpJ/YNpGAuuSaH84lpqL4RLnZuU0AWpj+9psne6OFop2+DZOP9R24DMlIrBQ28UErg1i0Dyk1uWlmtdEPpoYpFPMQAhqL7HXFzRVPKKNC+toBYmL5mu40FVwiW9eaIUSqBMl4rrX4KoBg+ceeIfAsqiMluC2lh1PWe2R5wvq456TgwkDNpkKNnSPFngn7zWSoaGLD432KyW+GXA6DaPLCOmAI4C3zFXgC+YTfoURCWIJ1oi+c686xPN+Gy59Xj3pwt111OpPDAsjJ+3AqHZT1WiWjul+mW70qt9QA8eXE3F8tFmUxKuanEzBai4GwjiCGoBr/K4zP8gCCjjV+yD 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)(376002)(396003)(346002)(39850400004)(316002)(956004)(38350700002)(2616005)(83380400001)(38100700002)(16526019)(44832011)(6666004)(2906002)(1076003)(186003)(6916009)(8676002)(6506007)(6486002)(36756003)(8936002)(66556008)(66946007)(86362001)(478600001)(66476007)(52116002)(26005)(6512007)(5660300002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2TI17QRFrV1cRTzofGmtZhWyrPZfNQ9er2nzrP1zG+tPp1snSS4Q0Vk4A0JRovxUsO1WcTQQApNmYr3572RC9crP36XtukBLigyrYQy3yvHic8zdaScqy7vBpOM5/zl4LvFIZ17uaPr5ue9O0GLlLP2x9CHs+eJWtwxrt3gW3H93URIeDj0dnGgpDsZdjpVettpHLxxTY1pgbu+jNp7ozWoavIb3BxWwhYDfWvQva+QA+js+iH5A3MesVyEC6wmENFvNdylTUAsqHSOK8+WwnRRekqqLq/D2ymwq5MqftfKlX0+eUC5R/zF9irRGETflI1uaYttKAJxN+QxVv6FslXWVYjuzahwFljxtMN3gHrYsvhpQ2PFxJwC8HvJeMqbAtnUd+2StcoGSmQVTJDHny1hiiTqpRKUcysrn+aewLgghY6/qfVDs9YAIg1LIYbKTxDi3YOPA3K40Pj3dZd17Q8hmuD26uFVpaaCGSBKpZfspR40RJgQHdLwF9Sl8Wm3geUMuxZOf3uhlCMq6hQRE4hfUxOvmmkoSCJcIZAHb6xKjch8xHzv+oEArqyE6lKUQsC6MxPKT80WtmlTg+/jjkNRKGiNox7O04AQZZDIV9UJfj5aMPilC4oBmaZ4WZGAn66MreS8iaX98V+h6wZqo0DwmBdajA9qCZ+21Oijtjm9IIG9CaNyXBFGl9Q22FxRDSh4jDcyyKJ4MsTbUThlTvByU2mnHRFJibbvE/h8FnM70gZunZSVF2RFzKj7BDuweN9i807QPwGVRqOUbRXCK/bWUNwRc8aJIbeRNfKDmkv0KSnJ4ml8Bch99NUZbftRS63/Ln+5CekM41iokT4tbcdXR5GoE6lxz0n21kdbjr+Fg6DEZKtByVuyG7DOPdNvIHlVn2Y1mOjgukHHjfttVukMHQZEv6fdC5xJp3WKlrM2IZOQWFKlvgLdWrSRGWZCUmb3ZhcGvYxgt5CF5RklvJMB2prk/FctZ30dCcBNuYH7vvp/XzRcBs2DX+H4xo43GlGxxc+nMPo9uiVjvkZxjacoFDvqaUus66YG0Hna60OGjrPGM4Nr+JGqEtq2D57CKAbNa9L2cTw3Ft/dBnqaqrxpPv/Ck5t1/AL9Mdq1GkRk2mIyD3LmSrMcEf25MfkE4iRKQRieToO6bN91SLy1Q3Q+RdKBpKj6hX4OBwuPjViRKaajqIsrxPjp4HE0KkePQ2c9mmffjzpAFEdcOr9LHVAcX+SgonAVLZkw+zTLPMz03cIkZLnj/o2Z3B8O7rcYA4q+Xp4VuD1REAxAJUm8l5vH62QuqmjO11zAnZGPUlX8XiRppp1+nmggdYpCl/LmS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 862c1551-c6ef-4332-835f-08d927b27112 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:41.2948 (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: /IN8WnrJmqjUDEkOgaoCuGHy+M0Yc8rxC4GsvOls0QUJhbOifjs+nwW2UExukniFTFIRgOVeftmG7HB1wTHkDP6AberYAMoFtAzOu9KCKW8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: 4FXeVuVfg0I-_dtIF-2LuPRElBhbUdT1 X-Proofpoint-ORIG-GUID: 4FXeVuVfg0I-_dtIF-2LuPRElBhbUdT1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 malwarescore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch is actually the combination of patches from the previous version (v18). Initially patch 3 hoisted xfs_attr_set_shortform, and the next added the helper xfs_attr_set_fmt. xfs_attr_set_fmt is similar the old xfs_attr_set_shortform. It 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: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 8a08d5b..0ec1547 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -236,16 +236,11 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } -/* - * 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) +xfs_attr_set_fmt( + struct xfs_da_args *args) { + struct xfs_buf *leaf_bp = NULL; struct xfs_inode *dp = args->dp; int error, error2 = 0; @@ -258,29 +253,29 @@ xfs_attr_set_shortform( 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); + 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. + * with the write verifier. */ - xfs_trans_bhold(args->trans, *leaf_bp); + xfs_trans_bhold(args->trans, leaf_bp); error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); + xfs_trans_bhold_release(args->trans, leaf_bp); if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); + xfs_trans_brelse(args->trans, leaf_bp); return error; } - return 0; + return -EAGAIN; } /* @@ -291,8 +286,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error = 0; + int error; /* * If the attribute list is already in leaf format, jump straight to @@ -301,15 +295,8 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { - - /* - * 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. - */ - error = xfs_attr_set_shortform(args, &leaf_bp); - if (error || !args->trans) + error = xfs_attr_set_fmt(args); + if (error != -EAGAIN) return error; } @@ -344,8 +331,7 @@ xfs_attr_set_args( return error; } - error = xfs_attr_node_addname(args); - return error; + return xfs_attr_node_addname(args); } /* From patchwork Fri Jun 4 23:41:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300909 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.8 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 6FD61C48BC2 for ; Fri, 4 Jun 2021 23:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FF4A613FE for ; Fri, 4 Jun 2021 23:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbhFDXob (ORCPT ); Fri, 4 Jun 2021 19:44:31 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:48654 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhFDXoa (ORCPT ); Fri, 4 Jun 2021 19:44:30 -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 154Nghlt067466 for ; Fri, 4 Jun 2021 23:42:43 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=QAS76PG8gCV+t1DEcGzPORiIJl8CPTcLNTqF2xo+fyQ=; b=kgaUnrTnn+o80Hdy4tUd3cy+SPMyTsc7IWqaXHxr2TyAtzZCYJDYc2DqIndNDEzsw/nO j5V+Cy/HsDjXRY14H/MXgSRGo5IufK0IW/I7X20x3v6T7IdfYGtsdSKVqOrcPoQtScug zGEjclrsnsqJ+Pq57Y08hU/mcaBDRKDsRHbabvkHfbkwprHd96wZy7do5we0eFDRguRJ MmOYvrllfvvQPnjzirECg+xReNvVFWTxSZ2nE7KYO13BdloQIARe2OTUvqDyfJwV/5XL sUg7JJvLpA4Kpys26wA7Kn6ezbJ5kcM6lt1KUq2mbsB2SScNx0G662l0qhu2t6Gex1R7 sg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 38ub4cy2np-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:43 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nde0U039038 for ; Fri, 4 Jun 2021 23:42:43 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by aserp3020.oracle.com with ESMTP id 38xyn50rp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XID3j0whDQXO40UTviQkEcV0qfHquo0RNf4DnaQnAeMJiRcr1Yu+UiO0n5CPZ/ZcIUSQAjI/737HVpg0Qkndy2iEgP06fvNECzKPAIW6IAe8N0ZDBiZMeRlNzZykyS1TW/ywlcCgyZpIthOTu4D1YDOAiAiMHzIJ9ovb3I//Hcdw6UXPO3zpNfSaW0xVEzCznjkeBW+diFzbETBCZ5pGwvj/sVsZtiA947fnQ0PD07oogJlp97tpl68NMI02/WVMTtP4wxZN6KctHuJD+yZ12UxqEHPmjdZtaJ5+toGHBph3B/7Kb4U7TVjmw/FY0G9RjLnLZP8PkzNQbDjnXvUWAQ== 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=QAS76PG8gCV+t1DEcGzPORiIJl8CPTcLNTqF2xo+fyQ=; b=ZPWMz2qc6mCb9ifK4LokJ39tR+QKiJs/I4H9DmYi6jdet+P8d53k3eKkEE8CUHf2E+/N33QVBGGoUhTWsEy4AE4OOM7WM9WiGRJyPJU8wl0Rbd/YidxyIr2tlNKh+wLCF+Rn2X/NsngcgMh2RRN44tMpuUqARj/RE5eyf2cnUxf8Cv82f+jWJ/AoBpQo2Nq6R3k4OMJQrsm3PWTJNPIQ+fz6RiMqaavMlTerIdioPKCHSqp1CB2ujoIc0eZyEyKQ3ij7d6yOiwulkq0IBK4xrcqVmrcFrx6aHNCU7RmbLIqjPqSBUZmAr4R7UFUsLJVJEPC3zoQu2uORF2nlI7bShA== 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=QAS76PG8gCV+t1DEcGzPORiIJl8CPTcLNTqF2xo+fyQ=; b=iQtGS0GEppTnZnNwfH1cAbofmh1e4TybfbYun8eDvXpKYgDLG68EwZADKGWZcRWfVRqL93MudU0fiUbZJ4815zTUifjM81ViVy04YI6vC7Lv1zuVhW96QHkCF/mUuURQl0JuW6BI8bDbwpaze5aOdbSGCG4E0WHifJrlVW+gYAE= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:41 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:41 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 04/14] xfs: Separate xfs_attr_node_addname and xfs_attr_node_addname_clear_incomplete Date: Fri, 4 Jun 2021 16:41:56 -0700 Message-Id: <20210604234206.31683-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e14a38b1-fbe5-4051-b49e-08d927b271cb X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: 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: 8EDjyfc62RCHruvN7x7iSgLvq2o4ueJ/ddBX+eaDbpqnIv+s0xpegH0VeR3lmUIDfZEdRtaAwtZcuilSs75asgXEJ82ag/RpPSb/UxDH6PRHgGRly5tLFUTiaGHtSV6rUeuIxAWmWx7TKtY9moJ0bqAVTVaiyGmjuhWupL8IZYQnEoZvXe1J1ZjRdjuLVQEMZiXAf+CC2loPsJclTO3c06fPfgwT1BaSzXud/GHGunD9SixpFCxIYGQ6blwuT87xeEmpnftAmOwjqtoV6ay853Uon0RLKSrpu7ZlM6PE9fOUl4JEgMtuyDSHvlPkBlwU6IyoFfZYpK674GhpWRacoS/Dq64o6PtlQulJt0zgLj0Q01Glethtjouzb5RzJsjiVolFhyL1tMGel10mv+G7kcktCBJQy3GjbYbADDSwD9C3phkmr0nL/W6jdGlPXtoEsA8xnvFJheyw8zmtgxGbBfuqglQvkVR5HeAvnByEYJ/OpiX/OuNo0PHkYpjI0hT981Yyrw5iJhBAIknm1n+3ZI4/4o07pdmk6OX9sqVTXnh9qWBciUuoChtif6fQWi6zS7Z4tJ2dK/vGF2cEjVTnmq2/h1ddX2I5Mf+Cvav+RUJ6ligrBsrC1Ix273ty5PpWfKRYkmhIQL9cmY5DqTGSONLrgj+X0GmoEgMjmt1Tpqr4zuuF3Kvn9WErzABZLX4m 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(6506007)(52116002)(6486002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tnB2IFziULDgw1KVcp+8mF3J6BEND4TiBXH03F+/3SxiwR97t/EWZPQNo+Inw3XfZkX7/7pOfr8ltIbfPJvTbHT9A5wDMYHae9E7msCGnOwAxPmf8ENHUcjXYqw/ivSuenrOgJkA1JMDnDQgRUBWmGpt9RzgawzgvmmuPc9izDuUEuT/1DxnohcSSAywMiRHav+q+Euq3GIL8EYh2exMCMOF1+6FQD7LgrJgyTBptR8XiFA55kDyZzPorLPhEmq/uVbzFNxRM3scGQZJx3nGxwV8xUSjtgG7QxP9Q+1SeTMhKD3pDrzgoygIdYSJx/v3Zo6pvbmiZqg6aHIKgIi2nIq+etx58Bs3SC7Udh2YxCgqkc6YtggfwIDcJ78ZP6P4ViHgFKJqZ3Q8eMfE/TdLez5JG9PiRECxy+oWWMEOdQ75X+ppl/bZqqgeyYY89YK0vc6YhRAqPhtVl2H9AOvBFV8Mrrg/kwRwlTVH9n9QSWy1MHd5E+HTyS5wsqIIHhTyhTsRI6bz5Y7ONYoytB9AFeal8/bRdgSIi7qvYrus0NlHhNWNozutPj+dSgJJx8trZs9rJO0XbS/uVfWIJaPuasYQShSXFVIdKqwaJzmyC8u7NFl7UlncFAVah8P6tPUh/Pf7LqhnQuds/m1UAN58lpqQPLP2nWT538X7agg8ES6Wp5/fTV9UEy/l+ZimFSa3ItMYCE7ggKnqInSqasynaC67W8hlxa630ojWBO6zJn9s9/bxKMZEeAkBAELCiWtHCwLUyKv/Myjz724wqFuGxBqejCG1TmBf8e095Xf8l9lJPf6LAWAruVOIpcyXyLGyUGRJq/wRwODOyyra4Tik8SQPqU96jzu8LCGJ2dXo1drPPk39ZoltIKK17TfmEFVkSv5ZhVyLKSpQZ4NOLbCQ0NROeGMhxkLS/A3QMl5QMemdTX4BsvqZy/YAedJjdnFbmnquX25fwRdwB8RCpo83UGtgl4NpIIHS8UwPCZL80nWaDd2k86VBLK+6hUPZDLW55C3sAhsOu1Y13SjlTeVrIKRwSBhozFkXzoWI3XRL1oHUAesVYbsaDsY5hfTJhhCDza/EZp5KFzDTtwf4+UCjL5qSJgstnezj2zGh/4K73fmoGwcZOSlILerrsJ42Sw9fkti0kovwU5xDqQXKZ56uKi9ZGhc1tNZWeY2PQi6Xa+RGrnke9oW6XUNzo4cn4E8F6ljHj0ous3hErNvVR3jNZuzogckjOtRg82ym5+Z5ePZDu5monIc9aEclis7XS0e1hKeAQECT986KTgVB1lX9VYutrmwsi2zPWc4WkL+QladBaV1JvHRS8PtUkL4AS1PN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e14a38b1-fbe5-4051-b49e-08d927b271cb X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:41.8145 (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: 4giefzCcV9qxIzFnPdqLC01+uel+XDW3TavrC5DaMxXHMZLFIoi/o+H31IYBnHI5xIURIH6Y13dRRmKbSekmSgIgOeDxiDH2MrYoWRdulPo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: R6J-UCcYHC4__7Q1yUIRQGTjk-ELFepk X-Proofpoint-ORIG-GUID: R6J-UCcYHC4__7Q1yUIRQGTjk-ELFepk X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch separate xfs_attr_node_addname into two functions. This will help to make it easier to hoist parts of xfs_attr_node_addname that need state management Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 0ec1547..ad44d77 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -54,6 +54,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC int xfs_attr_node_addname(xfs_da_args_t *args); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); @@ -1073,6 +1074,28 @@ xfs_attr_node_addname( return error; } + error = xfs_attr_node_addname_clear_incomplete(args); + if (error) + goto out; + retval = 0; +out: + if (state) + xfs_da_state_free(state); + if (error) + return error; + return retval; +} + + +STATIC int +xfs_attr_node_addname_clear_incomplete( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + int retval = 0; + int error = 0; + /* * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. From patchwork Fri Jun 4 23:41:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300913 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.8 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 05173C4743C for ; Fri, 4 Jun 2021 23:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2984613FE for ; Fri, 4 Jun 2021 23:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbhFDXod (ORCPT ); Fri, 4 Jun 2021 19:44:33 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51952 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhFDXoc (ORCPT ); Fri, 4 Jun 2021 19:44:32 -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 154Ne12H078362 for ; Fri, 4 Jun 2021 23:42:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=szvJfbvwmwL0QODj5H3eGmNFZ2raelHNU9VAKOWXOIU=; b=IRAvSvsdTqeSEmqtSafUAHry7MB3QslOUTHIvPUwUyQCBYsBF2CALbSboHN3KvPZ3R7T QBsmY+bSgTfrbLCL5lBHguTxkuVyTPhpSPc/UYa2kUS/BRYXzIJDnc/vZe8jZiViatEK 7GNH4UX77htgNTGHtr/Z7u9a9Qg4WNCH/5KdnkTqeH4VmXcBdX4VxQsTVsnX6tTro2BQ c74Qa3mW2FsY4cWuf+63oNOU0q9rjWicq89wJg+tD5EJ7Li07l/TIs6NPW1dQlYjo36/ 396D+i0V90x/21pONPEHxk2CiVuZFoA1JbcXNDDj0kaQpBhpz1FK0BXrBQcUBOp0hWlp PA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38ud1sq0cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:44 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nde0V039038 for ; Fri, 4 Jun 2021 23:42:43 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by aserp3020.oracle.com with ESMTP id 38xyn50rp7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l71qiBc1V3XN0z0HrCvmiNSOWtS2guo7QW2I5kHz7F6vjLuxrCQ3jqdCRvPm3wX+TWL4Koev4CS/VuCRvQT9XRuGaRKASmmyOONhAatRnP98d9MrBNKizB4/5cGkns2L83zzGwLoidHdSSceHshE1GlAsn9Log5B+BQs9V3eK6u3P6w1F6j4hA1GuxcPfUP7shqfWRJH+TlQTXim5EPo4R8gWhkI6pJcWtvsxDro5668e6E0V0H90aMRM8h+OMFAO0tvoVuJsWMfoHyFKgrQ+/GPF7GmUoL6Q8WdksNuamwZH7yuDGGBTlaKHz2HSjgD5X4vZaF+Ab1lzmoTTH+2YA== 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=szvJfbvwmwL0QODj5H3eGmNFZ2raelHNU9VAKOWXOIU=; b=lmufP/RkPLmFVsDOeNkGQPJWJPMcMlj/rw4ofsXbyEaJcMJDCGh9rX6o3sSWECBZLD7ITG5/bLDCh/RBbtuMfTEh0URPfnpOsGuz5GcbD6eMM8zAa6prEQRrUuy4c8qBOJ/VeckNQVnoejFmTJZ5yY7vVQdfG/8BFkvUIDf5u/xSkPs1s6MKbBe42cUqS8ue7emeyfDIpNjEsXg6irDKRXrUJmI5URrs/OV+YSopypvsey5CgIoH2dHT6gbx6MGb+ux8IDVjs2Ukl9jq3i/06jKSrAEuYa9X2iaw893297McSRGWMgdsp1sPpjsgWTV5yZBcFG39MGo+sI/8UCFtuQ== 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=szvJfbvwmwL0QODj5H3eGmNFZ2raelHNU9VAKOWXOIU=; b=XYxQpAdrwx7pKp1ISHDCkhd9iy9m2TUP+Xlo8itTwXG1xlhgF0OQO4C3oaaFTwfY3uA13X4fzUhPChq9PkfXA8UEaekdp098zZn/0WipLw2SAVY4UfhhxppTJpaNMpUGZM2AGFYVqPROLNAq3gtOAd8OjpBRIBU83Zk+YipZlJY= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:42 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:42 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 05/14] xfs: Add helper xfs_attr_node_addname_find_attr Date: Fri, 4 Jun 2021 16:41:57 -0700 Message-Id: <20210604234206.31683-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c3b95c53-d2fb-475a-291a-08d927b2721b X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: 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: TxKScocziUz8oF003aaKqrTX01nXm8eGgvTCZeZb8AwRzau7iL25nnR7zsohfkirj4j7/U6nl6tk9po+Ih89CixKU+eMhjUNywrvR8vVlZNLO8tCh4xQLY9+uj5PXpSlgvuVdmVjVtD78X5wjg7dFtODTzkQ7mnKGhlIF5DkY4WTOMZf6lw1xMezk+w50x3vsD8iodZHk4PEuu6P1VTjg3VTJmecuVPJKB50wTzi8rC3AtAGvFv8EDQN9rPYeoP6F1B+/804qMJPM9ZdgBEUjof4jXJyskGvW9Dmlm8wiZt/I8x7czqBiKt+y2K+5LF+FK3N888pdgS7Y2BcETI7tKHxUT8ibk2RxtKqofDKHTN6J5ZD5g/eQ5azSHw33xcgiJPNCR9pPOvgRSMIzHG76hzmoWvp3874eb9yrIFBl9Rcqeox6bkKoUoJIxfm1YKGbdt25gNYhWzLWIxnM26+WzFDblQhrVB3r/o20ChGEHYmTQzOJMkakcUIMQitsFrkLRhZ1IO7UiFs3Bq/NQRi35NL6zPtWauiZ3gKVrZ5F8SENGvory1FWQQhDi76iEolymsRLoUWZd2Kqc1XNUantXKl6aqWTKPATU6f01gHDswyxvmSAwA7SiDNVSmrDiN+tBUnD6QYcz5heGxEe2AZYiIvMyXTs77AIOS5JuiZw5SflyOZ5iiEUU7GmmtuEnDf 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(83380400001)(6506007)(52116002)(6486002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QB4P/+bExif/mB1DvBB+5mmXXqIcGdJMyscxUwibrg/fkaMIonwGrytESKGop2NVXBe03I8Na5Wz+0GhCWT1WuuamPD3AwmMUCmMLchXe3qxaRpO/S8owW0/eUWBxtHu9kUmRkhwAqZKsI6EabmyDFLliPDqgNcSyZu6TbFrFXdKt0qyW4XrbWaijkoIvKzDmJj4S3i9ta+aV7wkPGtOnAE5+S3o7ElOQvaQd8frxd+Eu54PYWi7hODx1JQZ8iaDyAoiVxImDmQ1YROYGdBc8IgyWnevBR+Jm2+LpYQcqqhW+cnIcqsvi0k4hKBPWsQho5nnBmB/2dpt6uNoagXhrTzfB0HnPRF16mwsqt1m41gYIhBqhN1DGCV3GTpUBcvwQpu5zj8P/dGxgaG12pCv5EIUXSYBH0CvT6E8w2fbToPHfImMrpQbZy20JBvLtLyRQSXcm4cviSD+naDRarj+vLBl9N8hGMvkXaRp9jfT9rE4cSKSVeajpCMyEhZj7ZxibLDW/Nt/vZ/UeDC595QcBIkR+lKnQuZ4iXTV6iuoS8/mgWnzgAOKmuex9/4IenuCZzOMgTzhhpAUGT3Qms69UqX/E5uJ7xtmmTtWhcEy20VUgQGpGEp+h+U21zGfN69hjaTFyTJXrDPnqpLLXgbajWdUmLpF33oQVFqdVmgdoxBfCpGGDlC+7rmmVj1NyG8dkrh7d6eiP3/bDrGKCJ2pE53vtPYhHA5wCHKrP+yNqxas/M8e4jICqbgMYx+7Kslxa4qFC5jqkA8RjbzLJwZuYHAI4Zf+8hJwhf9lbJOobMDqbIyP8gPQ0liuxeaC6LxV3RckEAUKNVkL9bCY8Tz+6kejnEmEnzIPIWtGUmmwv5vKm9HI945NCWZXKo4mYnGvKgz+iu9YFBCxt1+ccBkc5bmL0ryv6YkB0waqC9J/K88LeyYG6Ii4I8NG6IPaNfXE7N6EACWaF547XNJfLaMuJhmJjUC1LIfSA9KKT9CeKlYDncemUnHby7ql0xBLFqghUmCdYQryr3PF91MRItd36jx7SwiXfnD90RWBSeKdn4BugTLd7m/DUChVeoNd2VDVth5ZNVguCvMvRyMQ+D5N5Tt7sIq1logckA/QAm7KxjLvJ2P6KSLptjeEJx/K1+bh1DUC9tpn8dzZ0pN4FSR63myC+Ka8uc2U2LlmBB/4R1QvW3wlGXMoodTcvF6WkecR76P528xdPyW+p9m3LGNKJy3d8A9ZqStkxzRJe8QSgvw0EjTgu/Du6P5YcmgwP42vGWhb5EA7Ohaf5lEOhVVZBmVqzJKkZlIvqYSDp12T24CZ5gTTQrgYMiBarnxOOZ7s X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3b95c53-d2fb-475a-291a-08d927b2721b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:42.3323 (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: MRP+A/bmrBErmDd8+MBSWv1qlMAq7Vqhiyw2JWFVhPg1zfOLBqUPvLWzeECgdJRCf+mw13QPM5LOLzu51fV+MtY5DHjLvX34kJcTC+UeNrc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=986 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-ORIG-GUID: GO6vTeNN02GJ2lSK1gnxwsMxPYLiqtJw X-Proofpoint-GUID: GO6vTeNN02GJ2lSK1gnxwsMxPYLiqtJw X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 spamscore=0 impostorscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 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 ad44d77..5f56b05 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,7 +52,10 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); -STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname(struct xfs_da_args *args, + struct xfs_da_state *state); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, + struct xfs_da_state **state); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, @@ -287,6 +290,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_da_state *state; int error; /* @@ -332,7 +336,14 @@ xfs_attr_set_args( return error; } - return xfs_attr_node_addname(args); + do { + error = xfs_attr_node_addname_find_attr(args, &state); + if (error) + return error; + error = xfs_attr_node_addname(args, state); + } while (error == -EAGAIN); + + return error; } /* @@ -896,48 +907,26 @@ xfs_attr_node_hasname( * External routines when attribute list size > geo->blksize *========================================================================*/ -/* - * Add a name to a Btree-format attribute list. - * - * This will involve walking down the Btree, and may involve splitting - * leaf nodes and even splitting intermediate nodes up to and including - * the root node (a special case of an intermediate node). - * - * "Remote" attribute values confuse the issue and atomic rename operations - * add a whole extra layer of confusion on top of that. - */ STATIC int -xfs_attr_node_addname( - struct xfs_da_args *args) +xfs_attr_node_addname_find_attr( + struct xfs_da_args *args, + struct xfs_da_state **state) { - struct xfs_da_state *state; - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int retval, error; - - trace_xfs_attr_node_addname(args); + int retval; /* - * Fill in bucket of arguments/results/context to carry around. - */ - dp = args->dp; -restart: - /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - error = 0; - retval = xfs_attr_node_hasname(args, &state); + retval = xfs_attr_node_hasname(args, state); if (retval != -ENOATTR && retval != -EEXIST) - goto out; + goto error; - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) - goto out; + goto error; if (retval == -EEXIST) { if (args->attr_flags & XATTR_CREATE) - goto out; + goto error; trace_xfs_attr_node_replace(args); @@ -955,6 +944,38 @@ xfs_attr_node_addname( args->rmtvaluelen = 0; } + return 0; +error: + if (*state) + xfs_da_state_free(*state); + return retval; +} + +/* + * Add a name to a Btree-format attribute list. + * + * This will involve walking down the Btree, and may involve splitting + * leaf nodes and even splitting intermediate nodes up to and including + * the root node (a special case of an intermediate node). + * + * "Remote" attribute values confuse the issue and atomic rename operations + * add a whole extra layer of confusion on top of that. + */ +STATIC int +xfs_attr_node_addname( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + int retval, error; + + trace_xfs_attr_node_addname(args); + + dp = args->dp; + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_add(blk->bp, state->args); if (retval == -ENOSPC) { if (state->path.active == 1) { @@ -980,7 +1001,7 @@ xfs_attr_node_addname( if (error) goto out; - goto restart; + return -EAGAIN; } /* From patchwork Fri Jun 4 23:41:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300915 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.8 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 5174EC4743D for ; Fri, 4 Jun 2021 23:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B34B613BF for ; Fri, 4 Jun 2021 23:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbhFDXoe (ORCPT ); Fri, 4 Jun 2021 19:44:34 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33310 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhFDXod (ORCPT ); Fri, 4 Jun 2021 19:44:33 -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 154Ne6sf062244 for ; Fri, 4 Jun 2021 23:42:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=/0kr+2CVZ0D/nnuFADMy7+oShmgC1zOjuTk0MG5Scb4=; b=BVK72dZcwfuJjI5agsJzvklwVj+mwxciZDvBu9VaGHmpOcBUVyzGmZNT7y9o3/LZzDg9 7tgeHAhLNVLaYd4frSX4pN8IGfu+9/S2opL9Z1otEeRKgn77GwNRnxGB6CJsmbbLpDcR tVWYPUGr/+921JqD9uHUYC98Lm1+1vMWSwF6hzMzGFXUgh8yGQWsntbfygt1n0HTnBmW nw4+xjOdLQa6cqJMe0qVz/G8TOGhl2rYZNvkzs7FKBqfSHFyDBvXtwf4KXMp4AiK/YCy S6qwzxWDz5k395CFg+kpx69yHNeQcqTEHHy2FHOH96idOhkHBIfyXUtCt7m8jNlSQreC CQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 38ue8pq0gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:46 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154Nde6X038999 for ; Fri, 4 Jun 2021 23:42:45 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by aserp3020.oracle.com with ESMTP id 38xyn50rqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YLDobFoFG+OwkG1Y1XlBBN1MCu5wIweWVAtZxJF+b9E8K3RFelWm+lERAITo3bqDNLDr4CV+l82WM4sM1Pnxl24cVLQXiF8bZ8B4kX9ApyfB++u8CBmdSQg0yNvzZ+/+ZCKSo2WTI8seM9SFxIhcXXK5vA9zLvZ/8KNjf/z1Fas2f5twrse9TFu1l45kRwPXtUpUYyxZOD/4weFIBCS0343HkonSEOOL9ledyKjbovIWKb9gMpyJXTJF2MKNsPU4rj2gjliKQXg8l5H7DOm5q3dctCIKut+sQjscsHkpMB7iBpVpvriBgJGXhGzmFOqF5q62OffIywUxb+Kh+Y8p3g== 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=/0kr+2CVZ0D/nnuFADMy7+oShmgC1zOjuTk0MG5Scb4=; b=VVO5a4aLoLS/S4Qpph1qi2OCRbGghnG2Ux6hFf0A9I+QeuuONXGwu5v112S61wfdolClKrBCyMQYOAvaL43tmmoIvIVP4kiipoPOhLSO1A8qIREgogZA4kE73xv4J7NQQHFa8h189ydku33g1bgSrrFm1JA122aRNYQoeHISplIGLZllbFnffC0wOS9zL77TwxV3vDzhey3fREjILkaXTuqdyzzd/teNoMCeiLgT9LfDVlYLYHElMoJdB5YaxLR6OGcdTDPSGH8Qbr6iICa1RdtwOz0o4GOXhi+XDTcaXL7CI7fW88B+BRdLheWjykEb7L8bKHfajwUOT6KtUO+VZw== 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=/0kr+2CVZ0D/nnuFADMy7+oShmgC1zOjuTk0MG5Scb4=; b=ICyvLeHinigy03vCPsmxGfTZnoNXnqzEXXO/97H33CfW6+tYj/i5C3u5gBPGm0dFz8MbMBjMI+MMMJYzHBno6uCEikxpUVZE1Dw6onUF0KSx8sE2Dq3oQFR9B0dGF5VCDnzPFUYMY3Gk3/U1hfVme4q3ZetS4m2s01rlx3IpLZM= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:44 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:44 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 06/14] xfs: Hoist xfs_attr_node_addname Date: Fri, 4 Jun 2021 16:41:58 -0700 Message-Id: <20210604234206.31683-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d543f933-67ae-49fe-1503-08d927b272b3 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: 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: 6pVO448RBAy/ekEAQ+7zyCZdrBGbLcpephuSOVZYxvTMmMmTZjxRxzUsVy+x4+g91yNnVDgETg0A1QYP4xw7Vs3ZkTOmwOyi4lSspzO/urd9ebrH5ImT/7cxsHxfcAo6+Yb6D+8f6ExFW3fAzSigbcYk0Vgpas6hUL7a+wjsC2X9BceDpwMDVxWowQ+zz7hNC8DmGamfC51G82CHQ4Qr1npGEdZG+YKsUtPM2DYK/1ExcQZ7LcvaTdOR4SfJFFu4r+MFtBbfqp7MHVdHtmEY3U+uDDO4NLEpyEKZKOCW7UO7InYyyR+llbcfuXE2ieEIqq0wix49Ao7ivylfIsgW7tjmS+/zHCicpR+hrVP6UdbVRevR7KCVMQir0RZFBb5kHD4yFtB8c/wR7FyFjj80NIZ/78PmDqyCMeOsjHlvWmA7J5uK1ZtqLNscWdvrs5ael6W8p4rWv96OrSROF+m5lr3DB/IipWPqQhdyOtF/g208Whtq7FEO+m9+VCn0P8Sp7BNZ974h9hsuvL4PQLwCa2GG8UjGuRnvyJoB4KYYsgdyt041rgL8DTEQMUkat6tKbnNc5u8mhiVFTbN9npYEHVZVHXgLDlSh7Rr2XemBbP+DiHn8zS5qSH11rit/b6xPZn13M+HeVzMSWzvVJhDI7WD4jQHBr9dF1MY2d41etijzXEN2kI1BsMyCVuj1trEh 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(83380400001)(6506007)(52116002)(6486002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7ENUthyLp3MDaHxoCSHANtDLLpHTAHjvZR5YAsF/JQbAu2xn+mbFi3gJmI1S0UzJdbLCqFCZ1eBW9Kg873T6wFCGhjTvPGXABtBdS8tb+WIBbhA7VV6tpqmj6ythc5qobMs3ozTdx+H4CsDj3PCmafMImFROfKZTRb/p6BDw1KflJDLu4nSsKHl1wLzxfGX830oWXoD0LGREgF4763TkFYbmxmMMXRnXO8QZECQi7ZHGuPp5eH+PtlxjifJj8+uCyjXPJJXxkyoM7ZqzNTJu/AxD0Pgjuj3e50oh4Ox7AQSkzQN6OItUOThson5/acdzfYc4LDrLjtJ8RRvfGjvR22Rqq/Pf5U3j52JqmS5MtxQxFpWCKVIWk4vav/pZU7NskB1j6gjhTjdRreiD4v7D+ADDnGdsC9berd2Z5/jbp3KYKojQmvCUl48hQXIgqwuCIYf9R/yEouoGdpuZZQVooC9m3Pq2c1LTwgv01QMWn2itJiRdN9BO+mnERdUiNLSF6HPkm0JwMv8K6pD5tM22GAnngzuK3h7AXiHM+f91c8nlCrjVrTs5gOMC0nXFsE3L8N9FHCRhpibZ7jDjycircXY9KNEBUD3824fHf2i0fahwQADcOR7bSM54KoPoCaNkGs1uOZRc2koWjOkpFDOcc2O17fywUkyWYzvGoXZnZqXR5HN2TJQubEXaql8pf1tIynvYt1nIeRZF6SQdKZtR7tcnJ5niZPDaMA1agJhobbV+3Ts2Vc1nin8Z0i9aQ+XKI4ZF4l81ZFirFPkQXSXw/ed5ap+MEJrjXaMTdmC2yqXaBzG2A5IyP4KBs/Bxw1iJzDJ6qobEgZRmn71gqD58jnK5TeECQIJCt8OSqU+0cnS4+EfiMQhPniNhBQqZzQbsO8lVDlzk9Hj6Yad3OyBvGv0W6kNa4rMLiucJe9NVQDdtEzPAJljSztW6BCW1A/WgxXiKRMLJ1C5VREnrIsgVQr53gbhboDhw/doyeZMTshbHhJpNSaHVDyEuHdX6Bv0bDWkevZ5ZfcnrEM8TUVy17C/lCOciedB1i2h1CIDzc3oJJvAU0UJd+VdbkJdvuAgdA3tB0NqsarOD6CYAHAoa8EnK7dE3uUkfd/HqKLMRhmCUmRaJPBNsP/MJj85p+J+/W3MaWDw+LbhwBA6ukQskIPp3Hxf54sEtH+qcMX7tvrSkDucYafRcsp1afgJJynL1yjq8Ji9hBVEzZ6gpJzo9N2kZDevpDa8FRnj2/VAsP1FZPYjCJY+JUn30+7+0hXNxPs8rMWPkuCkww8x4TgX+/gzkdpOkkXmf/Tdh2FhbJrKjxTuRW+JFW1aBvo1XbtxX X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d543f933-67ae-49fe-1503-08d927b272b3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:44.1254 (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: 48/t1rpfPt7mOGYFFnMrZY4LuNpxcr3ts1TtkrbhNpwz8I6qQuaGzLtU6XQZB+2S1bVZ+52cmS7urKJGRoqnHO7m6d1U6gepGU2p8PnMy6M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: NrbRMNPn_jCOdNf-yclTcKbUeBXOfKxO X-Proofpoint-ORIG-GUID: NrbRMNPn_jCOdNf-yclTcKbUeBXOfKxO X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 malwarescore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch hoists the later half of xfs_attr_node_addname into the calling function. We do this because it is this area that will need the most state management, and we want to keep such code in the same scope as much as possible Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 159 ++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 84 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5f56b05..b35c742 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,6 +52,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); +STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, @@ -290,8 +291,8 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_da_state *state; - int error; + struct xfs_da_state *state = NULL; + int error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -342,7 +343,75 @@ xfs_attr_set_args( return error; error = xfs_attr_node_addname(args, state); } while (error == -EAGAIN); + if (error) + return error; + /* + * Commit the leaf addition or btree split and start the next + * trans in the chain. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + goto out; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } + + /* + * If this is an atomic rename operation, we must "flip" the incomplete + * flags on the "new" and "old" attribute/value pairs so that one + * disappears and one appears atomically. Then we must remove the "old" + * attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the "old" attr + * and clear the incomplete flag on the "new" attr. + */ + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in series + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; + + /* + * Dismantle the "old" attribute/value pair by removing a "remote" value + * (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + error = xfs_attr_node_addname_clear_incomplete(args); +out: return error; } @@ -968,7 +1037,7 @@ xfs_attr_node_addname( { struct xfs_da_state_blk *blk; struct xfs_inode *dp; - int retval, error; + int error; trace_xfs_attr_node_addname(args); @@ -976,8 +1045,8 @@ xfs_attr_node_addname( blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_add(blk->bp, state->args); - if (retval == -ENOSPC) { + error = xfs_attr3_leaf_add(blk->bp, state->args); + if (error == -ENOSPC) { if (state->path.active == 1) { /* * Its really a single leaf node, but it had @@ -1023,88 +1092,10 @@ xfs_attr_node_addname( xfs_da3_fixhashpath(state, &state->path); } - /* - * Kill the state structure, we're done with it and need to - * allow the buffers to come back later. - */ - xfs_da_state_free(state); - state = NULL; - - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - retval = error; - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - error = xfs_attr_node_addname_clear_incomplete(args); - if (error) - goto out; - retval = 0; out: if (state) xfs_da_state_free(state); - if (error) - return error; - return retval; + return error; } From patchwork Fri Jun 4 23:41:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300917 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.8 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 429FEC4743D for ; Fri, 4 Jun 2021 23:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C360613BF for ; Fri, 4 Jun 2021 23:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230127AbhFDXoh (ORCPT ); Fri, 4 Jun 2021 19:44:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58792 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhFDXog (ORCPT ); Fri, 4 Jun 2021 19:44:36 -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 154NeF0f029724 for ; Fri, 4 Jun 2021 23:42:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=QftG14Ie9+hiiNeRtV7kTMEXLO4BuF0eUx9rNA/vsjY=; b=xU5aY3xgGKZzreJBP/ySNp5j8Ug0O6DmAhQ/2gfi4dRX4zCzUZi733DN6AWbesfbY5GE LAJcpHG0xS6nlcUfpjaNFOHwsNAFVV3bJiuZp16N5/5aOJONINsVAzw3Q4Uq605+z8fR xUvgFpIHOMzMFRK8LxrEI6OAn1Tff1A7KrsxHu31drk5mxskfjONBa7dJM8RL9P+bK4t ElM5dCl+myYWHsNpkCAjS6a/MEwdlKLIA/0n8eNvmdU6HYO/UjRyS8+Fw1Dmmk9yXTHG DTUouJub0T8x5n+tHMGNqja1EmKnc0LZ7FzfkC6rytIbr6njkIEfkevGP03rEKYK+eN7 6A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 38udjmy0w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:48 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154NdeCI039021 for ; Fri, 4 Jun 2021 23:42:48 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3020.oracle.com with ESMTP id 38xyn50rsa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kufIrysafj5WJ8IE/vP2TctveWk1U7bvOnE4j5vYSf2rHKMeeiqEZwb0gYO8qu3W3eT/2pzoDlV92z8yRP56WiDX5T8qXfiLML1tho+Nylpda4KZGemBSGFIiuPnj8ylPA1bS6+an/2O51rqMiHW189OWV0c7kJzndP6tJtgcsB8MinZZwznzEdqNtNPAFZchU3TI0550bnQ2jC4UZ/V3rmbitKWC05GeA5DJpJkVhL5AgGiNaFqFH+oKNsyG4z87IZnL6kuMOSyvb/NR9xQmCnak7U+gcJ6jgJK2Lk3ZtWKHnV5lnpolNzepC27AjtNMXMicPOPQ7nHiBuOSapvBw== 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=QftG14Ie9+hiiNeRtV7kTMEXLO4BuF0eUx9rNA/vsjY=; b=VDVyG5w7z6D41Uun83/cuKoDJeD8L/wW9pM5yDleU/nvfFZ9AUERTemAJbMOmVYhoA1kP1qFqtJvEQEWvqSuxtI2Ni5K9naf4tlUyU18lIdbDNxiNk528Hu50vc74DLDrgLVEaFD7u1IQ8eh5Ak2ntRZf7LqyQW/O+48ifNriUHcoapyfECwaiPjZWpMe6WiRqvb8fQ9yMSZuhikolNuaYRH7vrwyM4iFlVwd+G2yq+10omtmDBlD5cpARKC8mJ5de6/IlZ7jAjXX672E5SrQvw8aqVf7MnW/7d9cLlBX9CiIob5jrfQcs3AxsWfd083afk9jxU/0Ii3SVByktwpkQ== 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=QftG14Ie9+hiiNeRtV7kTMEXLO4BuF0eUx9rNA/vsjY=; b=adKlpu3prz7ZeErDbP6lYbbujCD3JVojidkBz8+4eK3cuv0B1TJFYzaIlDruEhhehrjp+w3k4cTgyayic5xnFkuG+ERrb1qUThV5GDIKkq6L1gXWw/cUonx6BUc7ZMrD75QnGKwDXO4EGN814wY2sdZW5bPSCEaB9o8qkrXOVk4= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:46 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:46 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 07/14] xfs: Hoist xfs_attr_leaf_addname Date: Fri, 4 Jun 2021 16:41:59 -0700 Message-Id: <20210604234206.31683-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9eafb0d3-a7be-4216-2d0c-08d927b27380 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: 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: 5NSgDlmx/JbGXo2pmeA2c1kDqjlvb+uMOqlBaMRvbupA6m9CVPh+QGQDrahBKge0nZ9K5BjoHXXi+kYM9eBobTnjdXFUd7xdCwhEY5+UhUPanH7JcBb1WnefbAwgtgm6iTThg1hUHR6W1E7kvLCBsnVVspp64Z5MyRgWAMR1AFK2XbXmZAw314iOudkJ27iNHWUdaxmzkhuOnNYM0i7Mft82nz0tzV+4Y8jzhrHy3iWnwYuJElUl9Sv24AigYSVFmyDyvc4tZ+O85XggT3k89FEwPBos/g4RTDir2kL3z7KKeQK3t9UqGRvjzJnTZgXvH/ZCOQhTSaHHQfyLNaZfTsEy2OK+3KNQk/xlZf9n336zGR4OCYwG6coWWW5xCZEsqwvzubunfV3zrDBBg/50W78axP7SVkuKIbx0sTqvRtCNIhIBc36CrdJGBHeqmYtPfU6o9g39ek8CFhVN2EoibW23px9x3rO/GHvsE5RzyLSp0oJkPBzlNw9qobuN3YwXB3afdly5TLR7vFyBJQz0S+yZW5TYOUp5trqaOTB+BfH6W5XtMNiTYdne8kDqLoZW9wAZYPGeAxwBC6h6DEGhVIp5OGxL8fjALHv/qSwc5MlOQfGKlxapn4bQsp/l5Dna33tNjviIBXSvnlpfiis3c0I1oG3DQGAbEYfl3QgIMu6KIZd7K6Q6dPMFyU+o0ZUt 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(83380400001)(6506007)(52116002)(6486002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tAUeH50V1ywfASAZ9eA0fGE/YV9hOMhFhE8QiXGL5QL43VpbJYPXb4yMXzZ6DXHGYq+zTgM1mJdIACjDPRpZgN5YLgu5KFAhjbZzcl03cNzQb2ggv4ggX85hnhxxXBXSVK+cnyIBL0nLihCCzZmbooxAtApZSvoCfRIgTJHpqkQvhQW/0zm97eYgRtpLHDbE2rbVX3Q6w5Dal+xKR5vhtjDH7G3sjrxN+ldfLedHy2ZEGw1WHNCfVG7BVJWs16/EVI6gGMr3+mWL8g858qNl+aACIFmYTIsPqVb9PGIm+B0xDWdKupo7sLtKSfUT3/nzOBt0yN+2k/Y6CZkezvcBIOMcDP32WKfECT1pkuklJAV/maDWfvXqrEVX/gMrnGf6xjMRYHfwmcn8OqeoMOAN4OP+c2/i5AabO2i5AfVvI2EpWGZtqJVMB0ACt9G1L4HQKk8g4mhrmKluEfbfNpctURdxSmOVLchZNdbf7iUMn9FTDPNd9QbAb4Tu9dLvLY6/arsSfS0tWp8HlAIP38alzD9WdXGEyN5VqbYkUEK6AjF44P7/Z4rf2WUVd6BQPb83t8WYc1yiit3LHCtyKrqCRlJAR8psHKvrzESc1autRqsopyZ/66zyZHLjJS+9AbKY2v5zJimGD/s5BKD8m6Y5y7EARG4vP0bEXkNwoi2Ya1Q8aSl7aEnJR1kmeIJdP0bFnZ4vsp469T1zcl0j5xVOWP25EVANOVKvOGhR5/Dvz6Yc5mGmAbUgfVgpsbpaSM/txU+wgwueAj0+NRkn5dWwrg7gmmZhAJAp4HMeXeWYbcHTqzdQ0WUlKawUChMiol5I0pkSloWL69a9zIGf3VpsbeITwpquW9k9BftmTAgmUBQuE7odEYWsJeIPEYiEO/fhBridso3WeYcM28Efv7pcBsHisucVVunxB9vVVUxxnlCf5K1NREJzPUdcqMNrFo4peLoX+9YEAMvCXKlKEpyKtuZXf+8ndWzz7pOMWQlxV2XeMs3wKvhr0Lws07n2KcHrVZgU1a0E3B8BLXzItn1uUYsp129YPYQMiTUTGU5jCWpjacER7jWa/AbLTaZ0LLk3HndeQ8smUaJ8Juwiv3szYP7dyRwPqsBE6uDPj4EDiocWkfR8c69jbJ+olXbyi4a4mNDC6CYb+ehhGpuUm2/Hk09cXqvIs8g3UOwlr0VHRicelA/xA+D2qxFdtTPzzmNlBNW536LxsMNYtcDULpx74vFKdpxTSgOhQzMyThXKeJNS05CsMEaA2bodd57nutxcEpTPNYVXD/VpQ8bQqrqumv1RdgG7ACi3F0IHjpfgTG0r2NbwFlQwsedgEEfrmcHs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eafb0d3-a7be-4216-2d0c-08d927b27380 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:46.4472 (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: YuqqUOv7J7ZjHXPj2b00casbW6CDJOBNy/o3OX1KllyzJal9ZsI9kdykdF6xC6nQ+4zdbVL95/lkgHWzyYBMCqi5OvH513pS4e+Jxd0ACiA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: e6yfqVRPj67DoSJiqlTg41syCS-ry9sM X-Proofpoint-ORIG-GUID: e6yfqVRPj67DoSJiqlTg41syCS-ry9sM X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 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 b35c742..4bbf34c 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -44,9 +44,9 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); * Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); /* * Internal routines when attribute list is more than one block. @@ -291,8 +291,9 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; struct xfs_da_state *state = NULL; - int error = 0; + int forkoff, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -307,10 +308,101 @@ xfs_attr_set_args( } if (xfs_attr_is_leaf(dp)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) + error = xfs_attr_leaf_try_add(args, bp); + if (error == -ENOSPC) + goto node; + else if (error) + return error; + + /* + * Commit the transaction that added the attr name so that + * later routines can manage their own transactions. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + *flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + return error; + + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + /* + * Read in the block containing the "old" attr, then remove the + * "old" attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + &bp); + if (error) return error; + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + + return error; +node: /* * Promote the attribute list to the Btree format. */ @@ -737,115 +829,6 @@ xfs_attr_leaf_try_add( return retval; } - -/* - * Add a name to the leaf attribute list structure - * - * This leaf block cannot have a "remote" value, we only call this routine - * if bmap_one_block() says there is only one block (ie: no remote blks). - */ -STATIC int -xfs_attr_leaf_addname( - struct xfs_da_args *args) -{ - int error, forkoff; - struct xfs_buf *bp = NULL; - struct xfs_inode *dp = args->dp; - - trace_xfs_attr_leaf_addname(args); - - error = xfs_attr_leaf_try_add(args, bp); - if (error) - return error; - - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - - return error; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - - error = xfs_attr3_leaf_flipflags(args); - if (error) - return error; - /* - * Commit the flag value change and start the next trans in series. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - /* - * Read in the block containing the "old" attr, then remove the "old" - * attr from that block (neat, huh!) - */ - error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, - &bp); - if (error) - return error; - - xfs_attr3_leaf_remove(bp, args); - - /* - * If the result is small enough, shrink it all into the inode. - */ - forkoff = xfs_attr_shortform_allfit(bp, dp); - if (forkoff) - error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); - /* bp is gone due to xfs_da_shrink_inode */ - - return error; -} - /* * Return EEXIST if attr is found, or ENOATTR if not */ diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 808ae33..3c1c830 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1914,7 +1914,6 @@ DEFINE_ATTR_EVENT(xfs_attr_leaf_add); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_old); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_new); DEFINE_ATTR_EVENT(xfs_attr_leaf_add_work); -DEFINE_ATTR_EVENT(xfs_attr_leaf_addname); DEFINE_ATTR_EVENT(xfs_attr_leaf_create); DEFINE_ATTR_EVENT(xfs_attr_leaf_compact); DEFINE_ATTR_EVENT(xfs_attr_leaf_get); From patchwork Fri Jun 4 23:42:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300919 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.8 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 39A60C4743E for ; Fri, 4 Jun 2021 23:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AEC3613F4 for ; Fri, 4 Jun 2021 23:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbhFDXoh (ORCPT ); Fri, 4 Jun 2021 19:44:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58800 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhFDXog (ORCPT ); Fri, 4 Jun 2021 19:44:36 -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 154NgnXg041770 for ; Fri, 4 Jun 2021 23:42:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Rl5hjkbSu6ah9woombt7OArvqyhdXA1UKTGp09QgR08=; b=dNFs1OfT6j9iBPwxlCmR4g4fAJ5znCcnuctY+MMBXHFNt972+PWIJRnf0wN+wO6mKKHp dM9BaI6q0ya8iPD9M7tzWQDKPQCIlrBeJfuOT9TUgVrbrqmlYWCjhQunHUu4NiIEWLRJ nF/1RXa7X1CBt0D06Jw/D4gmAIOI9hP8lNtDhjYCsOSuiCWPSGCClgh3Xa0VurGFVqux J0svCWBH4V3nZ0nupeYK7wHmuuiYmoigjXK+VHMwzD9QEDglHWORpCcRVLkCxTwwc1Si 5sqZwT/FM2wUmtSLzqII2jq+D9NTCW1E+Iq9spPZOdaRfoSiFl3KGWEoBNkWrr19qayj BA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 38udjmy0w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:49 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 154NdeCJ039021 for ; Fri, 4 Jun 2021 23:42:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3020.oracle.com with ESMTP id 38xyn50rsa-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJSt0VRcwbLiFZWElCqJ0MYyOZkd57wsDOuI/ybpMMouE1TDSZG0I4uWJxG0FD2UEgeUy52/9TPaj0cfMIjzf+JrR0mZSUXi0mzEhf3YxyQCf1wOJ04Ax4lF250daafxLA6IqjCwZoQPBDtjRdD+obECuZu99ipYZrd1xBv2jWrl58Or432dVP6hFNQ2SgcA3jPbiIQGZILj6H5nMM3Cnzqz1L8/HaEBYwx3kRyBxWRbrcErTcwxtvSR/yS6XxKGUKcFA7W19yZuhki9oGn3dOQsgdmfPUXwyJ++tgljTmD60RMdqrZgU5LFSIrpw92Q+kqAiKxr6tnvcRgObwHKIw== 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=Rl5hjkbSu6ah9woombt7OArvqyhdXA1UKTGp09QgR08=; b=VOtQVHbudOIiBk4Lnfq4+I5bbtQk9/9rrDSnoYewRcHOXqFMNa0+QM2WzolKmbbCkCbev82uPp6xlVgkd0UhPDYroik2WwdK36xzWtgAgvEI4Oa4s6VtLAVMLzC1dI1Kf4Dth2X9a8wZ6tt/hivYJyEUT9vcrYuGFuowIJxEsbCnGnrfl3uXpBRXimKdhVeAfbOVLUypPs5XlNWd3QRweZOACnRw2/OEYar1PsSIOl6WwH/jJmhESo7I8UyCCWHiKtwcPAOJ+bNQeF83pxEz+OoUaNOWlD5tblb/x9BnaWBJXCkoeVwNd9E6at3iE+k7hhDU/JsGwJjWEr2T1GK2bg== 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=Rl5hjkbSu6ah9woombt7OArvqyhdXA1UKTGp09QgR08=; b=IgKXklMauU0Yc4hBr7vxm9akGIC5VBSO3F/uOLzvZXpBm1oCkXCjFz7QxcZXLrGkbMOxjBp6iAzpNtHiR7hzLf+b849mLeDsCzAJEQcQkfmnADmrdpjEX8ppCQ2CFLsCV40zqP/fraNIBemCP4fXM6SEq+10eYUA4cLr2yPxaNI= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:47 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:47 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 08/14] xfs: Hoist node transaction handling Date: Fri, 4 Jun 2021 16:42:00 -0700 Message-Id: <20210604234206.31683-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc994ac5-f842-429c-26bb-08d927b274d6 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: id6kcN3QvRSYadPUGHavqXsesthV1sIRzhLSbENqAa4r/nUkJlRO86xkrDqXi1rVDdWbbsoT7VyI2xMshQXZ6dLemdoxwHH7KbmBnTEKc95+PwtBVTiOFvI3nu6hyn32yUgIj4i/vnsLGGtcw0QYIGscuSBJUpzOvfO2slBELxUv1POr/TvJt6TQDYCFFm02bD7YJHr8aLLiCMY8Wbx0sT9sySUyew+IOkh/s0RGrCsuk2ErRa5EUskpaCrNanbkUUF5MIKIVXw01XEGpfgTJNDZRwRfYyNsC6NvchxnFSGEVlmhq5+pWVpnaqXmQ74JbsAqJ958TgaTpZLWDEveKU3hsZKRCKx3EI0d7dcJ3qrm/L/tmn+/OjBK5WKWyeMaxmmoA8qXsBfMJJ+s+lbaBp4siZgbn6mDoqILYtsc4qbrd8908QNE7Oa8sFVrEE+uAB0gmZBhEmKWVRR5GsldNI3qTpVynbkjkZhwqEMdmDaLPIcsk0EMqn/9fdE9Yd0mbYaoILPJRo4iDChqdmHkEV4O312sfMzhUcs3pnvb1HTekl0oTY4wlTIXU8rdRiRK3m1iJpju7dYO25rz8aQOwyOWkTPrVPu0xk0gPrXP3L/HOe1I2pl08AXT5qSjh8vvQrJCJa/MKSkKXyHY0cS4hwxyRgKI5xQ3/RidmbrnswCRIIqsfOSuBJNT9bFo9ZNs 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(83380400001)(6506007)(52116002)(6486002)(69590400013);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aBpGMcUDaZh6QDvL+p13PKkM256BZv6bgEJRbS6ov2Oa82Noyl2XcFPbVO5xg3Ri2FWL6Yd/+c3NQbUbcGy38o1NW7zfJYe/CSnUwaZfBJla7wrbi1CCisyHgQZaiEGAtcV4Tw21sYNOsBeoI5PWEfwskxz9eXg2ZzoMDHi4j3EGC88d+dRMYnKV1NAFWE4YSms48q7e8+3rxDWHaQdFSw+TOzPfYjouTeUceBL7RkMcf+tCPEIxnZjJ3rhZDHq5K6dGiXO/R2oqT2mWDCjp53x1ASQb1RjQilnbQfLX9/Zt/VJQxigzZa/XYMoOn0yy0tUwomhZbCVddOV9pOMFMTB0b44w54B0fPCeLGm0UHDC91o/aDLVryCBQ7PHWj0YzFp5VxjcTS1iXA+zHGY/BiWBc/Z0enHCvVML6Gxw6coOElZwEP+Voq0w/hSYne3m1R6qoc/cMFHoPb3x/Ep887dWHBIfrB0aX2zcUfdEb1i7Vc2QoMxN6PxdXnHRudyW6hvEaLwcQnVmMLsAgnwRedB96Wyq7/TNhrxQK2rAphbEtM0Y+ZWyiY4HIUwdp2mnXR+WUPNVYSwmvzDMubV0A++NuXaZcAx8pNm46aHiZ9rcM0geW7j5kJ+5wEPEoKdlm4UZ9DHE+PJ2TBFNKslQusl5OLzDFoIVFYSmYVVXgN0RX9I9gSlfGFQ4+oydKYE80erl8tiVouhGW3AfSfr1PvQ9R6Qo9oY7s99znT+nEAvQ2/FnzrbgptRMNIE3awUgzjSe5JOrFcQdm+Q8Ih/FNF0L1HAJr08fuAM5kJZ6aF8ypp70NCiJ1sxFXik8ScB22/hybim/CuKEl9dL48D9z5sj9PPfWVcS1vOg6unQua0F6RtV3cb7xXdQ1f/UcbjCrVSyyFFlA4qvfqbJWZdzRZ2TLIjK9N4W/xO+x61IqKY6LJi4nYadI6l8ANKx7smOLCMLiOILjbwzz75diFvH53iPm994QueL21zkXgddC5xcxNFwVwNndO6fjZNxMA7dJ6tiM9+vI/nkV3hVe19JOe3uwvuIIB308Zdt2pnQPtdP0mHDr4M+URyHixkk4pc04UKvApwLOBSXi3dX3n78SOWUrVO8bG2jMQFKchyYhxtxgdV6geLeor1B6aDDUU1iF0G/NzKxi72OpdkJ5jGJlUYSvphyExtn6XM2uyDpJKQvDFYFJrKnrIziG4gxof2x2HfpJZ/hQGAHeSFiYV3f3Rqwviur5/XZhAW7Zvij6xL0Jmr4q58s3sfp+zIDDMKnTe+H5IiaeCl5bRogrYYG9qL+Z4D3KElQBzrPEsmECVby6gYmlmxtVWVaW9OzMoJo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc994ac5-f842-429c-26bb-08d927b274d6 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:47.2348 (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: zFr1fVTx6ifikY8mdDP6ReDgb69UfnMnABFXRVw5kQ2mhMBz0fKktweYmrcsZrwQFY0os54q1nfkHUuMsz91gBBBMg4bgzisCvPlgU7f/+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: cP67WdnOdAjsLwY3PswMrpDRS2DtMRiK X-Proofpoint-ORIG-GUID: cP67WdnOdAjsLwY3PswMrpDRS2DtMRiK X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 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 4bbf34c..812dd1a 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -309,10 +309,36 @@ xfs_attr_set_args( if (xfs_attr_is_leaf(dp)) { error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the transaction once + * more. The goal here is to call node_addname with the inode + * and transaction in the same state (inode locked and joined, + * transaction clean) no matter how we got to this step. + */ + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + /* + * Commit the current trans (including the inode) and + * start a new one. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + goto node; - else if (error) + } else if (error) { return error; + } /* * Commit the transaction that added the attr name so that @@ -402,32 +428,9 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; + } node: - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); - if (error) - return error; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - } do { error = xfs_attr_node_addname_find_attr(args, &state); From patchwork Fri Jun 4 23:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12300921 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.8 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 0D022C4743D for ; Fri, 4 Jun 2021 23:42:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECD5E613FE for ; Fri, 4 Jun 2021 23:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbhFDXom (ORCPT ); Fri, 4 Jun 2021 19:44:42 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:48724 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhFDXol (ORCPT ); Fri, 4 Jun 2021 19:44:41 -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 154Nf96M066980 for ; Fri, 4 Jun 2021 23:42:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=sEi55v+VCIHWVZabXt5UUR5atBqsFFJtlItJV+JBiaw=; b=XJ7MVHgq4aKEMkffEjk6iaIz8cKuMrJFcIbX0JA4EeTpW0vJxpO9BfdWt3XYLsskqety WZeh5NEeE/7INjPD0TbiAoIj4QMqf6SqZUXIHpUbliFYWEUsoiloBtKX/Wn3ewXaeW0G Jgwei0+FxienEnHxvVtJyNE8kxYG5WVc/pjP1rKvbY+c8CLTibMbYDnbVuNizAkXZfPW EmwjoVCqbULbvagt+NHytfcr+fuIY0jF6gmiH3X5OiuAj3qArAd4eCNVFxdCWW4UoTW9 +YFRZeTTBEBxnDayueyvdiriq3jmp9APJyNbiyan04Z8MAkOSwAxh9v91sXJho7tEzpR zA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 38ub4cy2ns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:54 +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 154NfGks186287 for ; Fri, 4 Jun 2021 23:42:53 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3020.oracle.com with ESMTP id 38x1bfd89q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 04 Jun 2021 23:42:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmmYGq4bfo4aQNgoepUURGle0Ot3qb5NrM8fgxExfNhwgPKmZiHEqiJLMEeW0GywxO3knzsZf/LOiQ/0xudzFwc7ukZw9ggo6sSdvbyM/jZmEWWwq79gc/HvmUDf+6QiELcdCSBWvE5y+mAtAF5omM/HTtia0pbWarqWeEM+9UPw6nl2ay6Vy/Eu2J+mwghfFXH/lSRI15/Xbf2UdGz8EuNRnRULLPpgxh3N2ATvIhbwnH+aKYsDTjo+hGdSmb5QMWOubNLVTAkwZXBaIxgNOZ6BCM8C5O6OXq3tUsPgv6k5u1K7xKs6Pz5oZ95O+YqAnDN5cOdzdC0uVVa1xjTUUg== 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=sEi55v+VCIHWVZabXt5UUR5atBqsFFJtlItJV+JBiaw=; b=hbOFlmYjPO/bMis+RsrLqW24D/0lKkAYW6GgWz0Y3P8nECAprYjmpSpAQWCnAN/BpNRwwV7KweqndO29J26SIvdbba00gIAjhdjyOYF/utZkWYVlwjcMir/f6GNRTojjsfceDuYrJQHO+PNDmtjfWR3y3gaCp1vN+yEF3Dcclask9p94eYc9VRZgmOdO0AktRRO9/+Tcu/9tLVtsffxb/+TiHIz4UUXr19+XrxDJDKoOcehSAtMa2jvnaj5v2jybZ09X2Oa/rh8c3b6z9b7I2yOZJPABX57+IEGC5kLKbKx9yCOBBEdw20x5YaytfhAmgzlzFpD0Kg+lakHAdbqktw== 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=sEi55v+VCIHWVZabXt5UUR5atBqsFFJtlItJV+JBiaw=; b=EpEXRAQPbcIEALs+O0OOmsgImENpSBI/f0T2c/DeFiFiSYllLbP2BCQ/Wd8gQI/97w5YEE3j1h2Rmzx38k8wvjlyz0MmrIdz4SI6b2CQ+r70P5Kbu1+hrlGOU6q6ijCguJ1A4JTB1n26n28sHfaC7ClJ0Js/TGk5ed+2/otogXU= 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 SJ0PR10MB5485.namprd10.prod.outlook.com (2603:10b6:a03:3ab::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.23; Fri, 4 Jun 2021 23:42:51 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::a9c4:d124:3473:1728%5]) with mapi id 15.20.4195.025; Fri, 4 Jun 2021 23:42:51 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v20 09/14] xfs: Add delay ready attr remove routines Date: Fri, 4 Jun 2021 16:42:01 -0700 Message-Id: <20210604234206.31683-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210604234206.31683-1-allison.henderson@oracle.com> References: <20210604234206.31683-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.210.54] X-ClientProxiedBy: BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.210.54) by BYAPR07CA0095.namprd07.prod.outlook.com (2603:10b6:a03:12b::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.21 via Frontend Transport; Fri, 4 Jun 2021 23:42:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec17295c-9934-4759-04b0-08d927b275a9 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5485: 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: 4sOOl4HchMZ8GyFuhsikEu26an0oZGuuGzcT6/AhRSaTnN/h3++Vg2TpiMA778jDVaQYBI4LFu9KMzCQiYB1YWE2vp4j7LRB27sdEtVwGTp9bFq92cvI+CGpZVCKlyQr4JUgosEL1LnM+pd/y+2QFwnOlxLN4nAXF5Z+j57x9v/eQ2hTakS7iuTfT6zcSXtd1Q3RarInEstcRore7wnHTHFr6uWcxiAVSbCA5PPjAGSRGgN6nxR9BmAqiph4tjkL0uEq9/REYRn8bmAKFwv5TLzqHjceJ0wqluGWBk+bfFp749kJrGr3t4JQQyljRf6iJM9LIdMkLRbq50EaxLMpucQsR5CAQe05ZpQLrlQSu7xkLxYhkwomii1v48Jgky7xQBg3zR9D47NvN0Q32sBnPhERkqc9gOivBkdbwzrvj+etKMl8w7wRV9eTs6xNOJzSEfzgn6HpjuxTAqmHiWBg+dAJhyioq7KVLbG392M2cqKHKFC5VCu9VzdZdBLymkO1D1nOyL1KwA/jZIGlIPnN4dghyd+mCZe+OuCytuOGveuG2JdysuK6iaM5RrHktTLOspft25/kFd8Crg3/LyfjVo4VQkETtqr9JuYyFd9+JDrO+1wGDVNqZ3OJx+I5kZBO2Bh2T6030pIlN/ww1kN8UQ== 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)(376002)(396003)(136003)(346002)(39850400004)(2616005)(66476007)(66556008)(2906002)(66946007)(5660300002)(8676002)(956004)(316002)(186003)(16526019)(6916009)(30864003)(86362001)(38100700002)(478600001)(38350700002)(8936002)(6666004)(36756003)(26005)(6512007)(1076003)(44832011)(83380400001)(6506007)(52116002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dE4kxHRHq7ro+LiTHBmRtespWAirDXoHPJMWnuAO+VidGcDTGfBRJKvLYPONcraRe3rPQIjmdcn5E1wyueUy/LzAd6XCRGpp/SQNi5Ob2MHbk894h/KLtg621xhBf2YG9XgZP6e1eE/Jy/fKLAn/s2Jfr8JVzoMltynZZQ9hN0thChJBBdiLqfDC2QCvPk/JP+10R9/dftvQ/MajzK+J+v/BxSgMX+1KnjfrLfEKyUzQyNLlj5YFDQQ8uziknvHaBGr0mwEDP0eYscIbgPofJ17gWDwgwKk1IrIuk6F4i9Wn9rY8AGUMNc47DDZFb8vV6qWXOXOk0NF7tMM1VFW8K7N1N2fZyWhlcmXJFjKCwpAGhC7s1rmHpihkcEXVNhZ40UbHwNd1sHqGzY/80OPUlE0obRZKjm9E5geTHfDvjLZZsxUGkq96GEEXGkmi5sjhyEq/gP0YHsvV+DZWpfx3ewiBazdNo5EcIvQMe19v+7ShKwrDyGP4bJuDP0u+FBoxM5BYv6JYOVwNF7Iw7kLPfgJ5GrwJ7lYUmOikDiLaqGoa6uJfu8CBY/N3gRXrlbAadjUZXdUXdfO21k2CfsORqq78QOm6CDZ1zU1xJQcKAcxkM6QuBg9CGoMenk2zXma1PFLMjHANSXJt2Kwruj0OdKuxGN+yjyO2UQiDeVQaazbLHPDefbsfWXqmVYZANXd+6Asn0Za31ygifcRMqNfEa23I+IYtNpPiQUONiIPwOu6X6Tlrl3gkmx8FvsmVNW/11L6uiaNI8FMO0FM4AsNy7mVLmjYPlT7OIqs8t1vYnxKzA079MRhua0JXBJKmr2COvjSS75KypYBkExtOgS7ZVdt/El+TCgzKTII5ZQJ322gHzFIX6ugZ4p4ZBADCfpeXRMJ0npRGIIsvDY/fngd1DWPP+uJQfY3UcNr+06Stu/UehtwNEYmv1DMmzEMzuwx/dqFNe/O3yQXIVYgxo8eM9ED1XjN9TwAe07RbpdGv0YUhH40jVu+hphgbLp6g1EkuTQHH6LhhGvA6M3wPcU39JKt5Jlh5d7vYgmB7hKpuxwHhHP+286j8ScuSNBVhAXMjyAyyL8AwFRAC+kdWE1ae3gV+j1mJ7L2cP2mZ4XhB4NkuKG34+mVfQeLjcAywQoNxWfJ/GwZ6I79VZgb9NI7GQR/yFkupI1pKVsZ54XodUaLuwwgRSday8k3AYgzXEACeYBXXlmaASsB/L1Aob04qQ3pRNWWXfnpnSLNLhrR6L6UNbmN5hE5s4Wm4TXF8obHEGzj+TJrOEU7FNp+vhixhMslvChfH/EfoXFQ3ytIVXPkOh5ecrEulf1lil2HhpIIC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec17295c-9934-4759-04b0-08d927b275a9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2021 23:42:51.0062 (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: 3609oon11JPYETprEF7XMtuS4fTh7toFxtrcEBXs+8WM1eRLzOoZTwA9tuX5PXRxs+cldDTvGMfspctEttMgM2Cjn9pVowhYPv3C+1etKN4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5485 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 X-Proofpoint-GUID: N6OWrl9GD3SwKhadtjaBnBjCJbVg5Zhi X-Proofpoint-ORIG-GUID: N6OWrl9GD3SwKhadtjaBnBjCJbVg5Zhi X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10005 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106040162 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 calls. See xfs_attr.h for a more detailed diagram of the states. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 223 +++++++++++++++++++++++++++++----------- fs/xfs/libxfs/xfs_attr.h | 131 +++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 53 ++++++---- fs/xfs/libxfs/xfs_attr_remote.h | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- 6 files changed, 327 insertions(+), 86 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 812dd1a..513d9ca 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -57,7 +57,6 @@ STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, struct xfs_da_state **state); -STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); @@ -241,6 +240,31 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +/* + * Checks to see if a delayed attribute transaction should be rolled. If so, + * transaction is finished or rolled as needed. + */ +int +xfs_attr_trans_roll( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + int error; + + if (dac->flags & XFS_DAC_DEFER_FINISH) { + /* + * The caller wants us to finish all the deferred ops so that we + * avoid pinning the log tail with a large number of deferred + * ops. + */ + dac->flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + } else + error = xfs_trans_roll_inode(&args->trans, args->dp); + + return error; +} + STATIC int xfs_attr_set_fmt( struct xfs_da_args *args) @@ -544,16 +568,25 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - if (!xfs_inode_hasattr(args->dp)) - return -ENOATTR; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; - if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) - return xfs_attr_shortform_remove(args); - if (xfs_attr_is_leaf(args->dp)) - return xfs_attr_leaf_removename(args); - return xfs_attr_node_removename(args); + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + } while (true); + + return error; } /* @@ -1197,14 +1230,16 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state **state = &dac->da_state; + int error; error = xfs_attr_node_hasname(args, state); if (error != -EEXIST) return error; + error = 0; ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL); ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == @@ -1213,12 +1248,15 @@ int xfs_attr_node_removename_setup( if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) - return error; + goto out; - return xfs_attr_rmtval_invalidate(args); + error = xfs_attr_rmtval_invalidate(args); } +out: + if (error) + xfs_da_state_free(*state); - return 0; + return error; } STATIC int @@ -1241,70 +1279,133 @@ xfs_attr_node_remove_name( } /* - * Remove a name from a B-tree attribute list. + * Remove the attribute specified in @args. * * This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). + * + * This routine is meant to function as either an in-line or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and call the function until a + * successful error code is returned. */ -STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +int +xfs_attr_remove_iter( + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - int retval, error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + int retval, error; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (!xfs_inode_hasattr(dp)) + return -ENOATTR; - /* - * If there is an out-of-line value, de-allocate the blocks. - * This is done before we remove the attribute so that we don't - * overflow the maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; + /* + * Shortform or leaf formats don't require transaction rolls and + * thus state transitions. Call the right helper and return. + */ + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) + return xfs_attr_shortform_remove(args); + + if (xfs_attr_is_leaf(dp)) + return xfs_attr_leaf_removename(args); /* - * Refill the state structure with buffers, the prior calls - * released our buffers. + * Node format may require transaction rolls. Set up the + * state context and fall into the state machine. */ - error = xfs_attr_refillstate(state); - if (error) - goto out; - } - retval = xfs_attr_node_remove_name(args, state); + if (!dac->da_state) { + error = xfs_attr_node_removename_setup(dac); + if (error) + return error; + state = dac->da_state; + } + + /* fallthrough */ + case XFS_DAS_RMTBLK: + dac->dela_state = XFS_DAS_RMTBLK; - /* - * Check to see if the tree needs to be collapsed. - */ - if (retval && (state->path.active > 1)) { - error = xfs_da3_join(state); - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the Btree join operation and start a new trans. + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a + * deadlock. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } + if (args->rmtblkno > 0) { + /* + * May return -EAGAIN. Roll and repeat until all remote + * blocks are removed. + */ + error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + return error; + else if (error) + goto out; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_attr_is_leaf(dp)) - error = xfs_attr_node_shrink(args, state); + /* + * Refill the state structure with buffers (the prior + * calls released our buffers) and close out this + * transaction before proceeding. + */ + ASSERT(args->rmtblkno == 0); + error = xfs_attr_refillstate(state); + if (error) + goto out; + dac->dela_state = XFS_DAS_RM_NAME; + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_NAME: + /* + * If we came here fresh from a transaction roll, reattach all + * the buffers to the current transaction. + */ + if (dac->dela_state == XFS_DAS_RM_NAME) { + error = xfs_attr_refillstate(state); + if (error) + goto out; + } + retval = xfs_attr_node_remove_name(args, state); + + /* + * Check to see if the tree needs to be collapsed. If so, roll + * the transacton and fall into the shrink state. + */ + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; + + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_SHRINK: + /* + * If the result is small enough, push it all into the inode. + * This is our final state so it's safe to return a dirty + * transaction. + */ + if (xfs_attr_is_leaf(dp)) + error = xfs_attr_node_shrink(args, state); + ASSERT(error != -EAGAIN); + break; + default: + ASSERT(0); + error = -EINVAL; + goto out; + } out: if (state) xfs_da_state_free(state); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 2b1f619..1267ea8 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 called 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 remote blks? ──n─┐ + * │ │ v + * │ │ find and invalidate + * │ y the remote blocks. + * │ │ mark attr incomplete + * │ ├────────────────┘ + * └──────────┤ + * │ + * v + * Have remote blks to remove? ───y─────┐ + * │ ^ remove the blks + * │ │ │ + * │ │ v + * │ XFS_DAS_RMTBLK <─n── done? + * │ re-enter with │ + * │ one less blk to y + * │ remove │ + * │ V + * │ refill the state + * n │ + * │ v + * │ XFS_DAS_RM_NAME + * │ │ + * ├─────────────────────────┘ + * │ + * v + * remove leaf and + * update hash with + * xfs_attr_node_remove_cleanup + * │ + * v + * need to + * shrink tree? ─n─┐ + * │ │ + * y │ + * │ │ + * v │ + * join leaf │ + * │ │ + * v │ + * XFS_DAS_RM_SHRINK │ + * │ │ + * v │ + * do the shrink │ + * │ │ + * v │ + * free state <──┘ + * │ + * v + * done + * + */ + +/* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then call the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_UNINIT = 0, /* No state has been set yet */ + XFS_DAS_RMTBLK, /* Removing remote blks */ + XFS_DAS_RM_NAME, /* Remove attr name */ + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + + /* Used in xfs_attr_node_removename to roll through removing blocks */ + struct xfs_da_state *da_state; + + /* Used to keep track of current state of delayed operation */ + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -92,6 +219,10 @@ int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); +void xfs_delattr_context_init(struct xfs_delattr_context *dac, + struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 556184b..d97de20 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -19,8 +19,8 @@ #include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" -#include "xfs_attr_remote.h" #include "xfs_attr.h" +#include "xfs_attr_remote.h" #include "xfs_attr_leaf.h" #include "xfs_error.h" #include "xfs_trace.h" diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 48d8e9c..c26193b 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,30 @@ xfs_attr_rmtval_remove( * Keep de-allocating extents until the remote-value region is gone. */ do { - retval = __xfs_attr_rmtval_remove(args); - if (retval && retval != -EAGAIN) - return retval; + error = __xfs_attr_rmtval_remove(&dac); + if (error && error != -EAGAIN) + break; - /* - * Close out trans and start the next one in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); + error = xfs_attr_trans_roll(&dac); if (error) return error; - } while (retval == -EAGAIN); + } while (true); - return 0; + return error; } /* * Remove the value associated with an attribute by deleting the out-of-line - * buffer that it is stored on. Returns EAGAIN for the caller to refresh the - * transaction and re-call the function + * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the + * transaction and re-call the function. Callers should keep calling this + * routine until it returns something other than -EAGAIN. */ 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 +720,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. 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; + args->rmtblkno = 0; + args->rmtblkcnt = 0; + return 0; } 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"