From patchwork Fri Mar 26 00:32: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: 12165371 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 52B42C433E1 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D65A461A0D for ; Fri, 26 Mar 2021 00:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbhCZAde (ORCPT ); Thu, 25 Mar 2021 20:33:34 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39306 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbhCZAdX (ORCPT ); Thu, 25 Mar 2021 20:33:23 -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 12Q0Ol6b066392 for ; Fri, 26 Mar 2021 00:33:23 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=wZHHIINaGVjD+KW9VQdtpsunANMAZFXluaGiua2U3P8=; b=mCSFSslpwUPINjK0LUk1rk6U8Nk9qASiC1tvduQlyxBV5rgynLY+ntJkp7MSnF6wOtJ5 LS0s91MFbvpMVIbU3YnV3xuyqtZE+3MhryV99N4VfG2mpoHWf3z9IIHYPhdnV4oysCEc zUDzS6qzuAkGzBoiu0p1AOLqQBa5u+N4wXX5Yj+0o7lm18kCyv5qm/UdnUul6QRzfHzg zeSFGgNH/XwvPhqcTa8//Z3SQVOfFJIiUerqJrJcx5sX8Sk+0l8b+nHvk2AfyufgQnEG KHwUBUjX422CC9f4gOZ2Tuyd4hx12QxL4O/x1N4iqTUsBQ/iuo0dOmpSdPwtnFLw4XhA MA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 37h13hrh79-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +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 12Q0QXn9076081 for ; Fri, 26 Mar 2021 00:33:22 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2106.outbound.protection.outlook.com [104.47.55.106]) by userp3020.oracle.com with ESMTP id 37h14gg490-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKuGB8qm5wP4myEEIjTqlnHLLshVibIJDSzKNQqlJuPFXyDCzSkwvbj55GzskQyzrNQDtzUFLCfcviRolYqvlHKQICEYGS7T+h6xsJWZEe2Z7JtouKNmweuDuHEz/sGhgyX5lYhLONhEjVqzVEMwx6kkwT7ekKE1bKGobdCmZnCVtcO1UTzjXMj6hv/CWQJ1t0hS7wuPJQgtse2SKFGAyaQHiFjYQgkDPprT/7nxOUSTT/JCdCtP/chOmR36jdrt4h2qzUZRv9PMAlky/agx9+ecdSZaEaZwzDc0jqkHOCjKxj2kxtKbeSC0Rh7oWFw8lAsSx3DkWWc9zfjlZYNxdA== 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=wZHHIINaGVjD+KW9VQdtpsunANMAZFXluaGiua2U3P8=; b=CElf1+IY5XwBlJHL8GGZ182xYjartRpi6NdHOXgkquk8cVdbgz9MUtaL4rT24lnGwm4srQiysboTzcNcCbJ95HV0lwBXrOuz5dPB8Jq7zxTr2Wn4BOG8fePhifQFXwCRznpt8/rrLsdh8ItMJ0btm4qmeeVVDMVFrtAeih0BYqygiAfQe8SNOuXMRMWzuMtUkSJTjgcdQmhGmqhTqKma0KbX50IEZLv/qcmYqjxqVdc8N/HilHSRhN0kXBgxlVbCjjtnFLX4/nCerQKEZPU/QKBdDDNDKuXO83zwkmnYe6K78GqR/d/7ygwJacp7KQIaP2bLaDr4ME3rgK5y9X3n6w== 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=wZHHIINaGVjD+KW9VQdtpsunANMAZFXluaGiua2U3P8=; b=CLwJhsmxlT4Kj5hx9/YM6p4LTQiZBofd0G2179nwtPOwiiiy8tdBx2BT778iHvqTEzJx70iN0kBk4LV77epXhWM53Bv/rxO22qU2BkJ391nKpuLm/Fgz9clj86ZlDlGztIoht7DtSM9TK81JI4oNBIWsBUCk8T+Svf+e3/mdIaQ= 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 BYAPR10MB2709.namprd10.prod.outlook.com (2603:10b6:a02:b7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Fri, 26 Mar 2021 00:33:19 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:19 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 01/11] xfs: Reverse apply 72b97ea40d Date: Thu, 25 Mar 2021 17:32:58 -0700 Message-Id: <20210326003308.32753-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd42de58-d818-4761-46a1-08d8efeec138 X-MS-TrafficTypeDiagnostic: BYAPR10MB2709: 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: jr4jLyUpdMyySHJmp0a5Mnmiujg5RTCIvv0u9IP99oWDhwgAgGpinRVz+y2D8WQKrMnHVPUYslfbddjbzZ0EzzAggQMTk3jQQPLyioNsvscJ+78EyUlPL+ZXMzDWjjT0wP5zlw//3sO+P74GqntgnneMf1ozuSxKxeYIm0L8nx+a1T6cna/QTj5BltSFbdfZ/ZiMJjzOkE3IGtrLN+v4qPf1Kli4SNEdZvut13XWTTAVmSXPB1fMkQxHoVG5yovZsDdHks0Hz0zmwRy1SB2H4Ga8nOGzz6dApemtUVwNxDAcfaZocI7KsP/bmoIn7wtGQDOk0W+Up+lB9JOJM3Gjj9atTGvF6CuWxvdHJiuohvhDQGDt/OXSgV5CJtOXZ63xUv8k/1y92SV51gtdx7nDpSoxQoBpZtVWm2UT9ChSMagLZV8EFHwWGywuidupPIxYybwbEFA5vXnBsLskvuTf9J89mg+Sr6sek9ayJrx0Yu5qC6vP575mUx6wzbg1I2IjQfXaYg6inwpClUnsYbJ0/Hf7vopM23LsjWQTLq8z3kJnxzfdQWd9knVLlUT0eJB/8yJsCOG9s4Pq1I0tmXYaKa8DF1ZMZnun2e+5mODtpeIfe6WOVfTxvy5o8N/gwWHPfrddqSoweICctkRPaIoRmeezE0nNF0hMoyExDanjAE+xnOM13T47gL9++d9Glkp4 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:(39860400002)(136003)(376002)(396003)(346002)(366004)(1076003)(8936002)(6506007)(2906002)(6512007)(6486002)(52116002)(6916009)(5660300002)(8676002)(83380400001)(36756003)(66476007)(66556008)(69590400012)(86362001)(38100700001)(66946007)(956004)(6666004)(316002)(2616005)(478600001)(44832011)(16526019)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MYebtkAYf4Rnbue1qPr3uNthdR0E1zmSNxWrxMI76MNqgSpTN5rJkIcXuBk5XX7RSCXP8VFYPsVZY5KRCbiPJXzGxsgwXozmQLozFdVz/lZDJVprdbn6o7ThwOi31vxbuhzsyV7UDjiqWUu+aXnO2/s3y+t6ofMa5HVwSBYeb8NPhOVAr0xr/zxXMDZ5jZNGsRASGetLR3Oz8Wn5smf+eu/NGYDamVs3RXjuIMBQE/Nzm7IQff0AebDdctTdB0z1jM66Kphw6X1ykT9hl3CBwYv66Tvn2cGZx7VvzIk92cG2qhoFm1547e286RRled0JZD9XhedMyW8NA4/o0kKqJ3EPNtyfGxj4Z6dIeHbZPUQW5CRX+59n4eyZ5nFMj7E5Vgfu96LYABGwq+9pZb6CGv/DaCJvm0ntXJrtuM41Tu9HfTPq60Dl22KiQqWjYAgqUettyqBrwYJIfCxmowcImYlmGo4yCkhBA+Y43N4fHVDed4cdE2sr5iETjbxkZBxBC36R5QHzPxWT+IEwcIlYA6BTTPzTeCvKinYJTclbqYZZ4evrhO7RPhdAZ0Emc3ImPN8uvr/NkNNKSaYmon4pET21ePTia7sb4V1RnGE/ZMjC+Avsb6EQ7R905pzV7ExqQroCUvNhr4Li9ADgK4nMMrpP7lQmx2fDkxvbkBESQJKCIgwoyVjN5oQMIDx/S21gD+9ZVX7pzKGvTXRL/aWKfo2mDK3VRHDaYwI1UtVvF7sqr2z68hZsalG1J/zV/VeKq/WamO8hp3hjiEvO0ZO/QsD94urDP1tiTRLFxiAu+9JhN/yjzKQIyzKnciIvCuuENFOcfGol7TRcT+uW/I2dyVNjgOqs5w79OnxqW1gQoZpVS3B/19v6Rop3PT7E7Q0eTY6V6AegikzNwGk9igi20NI6n0BRiXlgQcMcGzwBvSG464culJQE5s6P3xffNjbSP39yRz/g3OjzEPMaJeZNsa8Hy6efJ2N5uWtlfAsLxHuaDbRj7l28UAjtVfq3XVksVVnEbdfnQ0d7/AY+KHC1YfB1MbnAv6DwHIfaPGuLpp8cnGDxoRyw7SDwZVPltEB7BhYdBrK5ZoMeefqYaGlnHkAZWqW4hZyW9DzQxQiZII2n+Jcw02nL9QL2nzKS9nbUNHF+uYMizt6xASL459RxRb3GwEbfVy33J7v5lbSZIw1RFis8cK17XirEPh+fccCm/RbLP3m94Xr8nRg9nXqUMv98FPf9ZNhYRvyl9HkwvqhVdYPQ4iZKzsO+B/JtqCRBN8xxA4Aa+etm7/p5rTdlwl23N0DeshgID2sBsgpcjwTVFso6B3apianoCGNvbds8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd42de58-d818-4761-46a1-08d8efeec138 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:19.7085 (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: jMpsManU0Ye2pTghEGY9Zg2671aUqXXUWZx0aDbznmpoR0WVGU8Lbo3Dpd3mNdm449NIqzSPK/boLu3xVEeqlq8W4Yg0R6J7Ex9hhYyRa5s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2709 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: 8HwZzYmC4vWPhm2NzU5SrjQaC-eeW5VJ X-Proofpoint-ORIG-GUID: 8HwZzYmC4vWPhm2NzU5SrjQaC-eeW5VJ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 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: Chandan Babu R Reviewed-by: Brian Foster --- 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 472b303..b42144e 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1202,24 +1202,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. * @@ -1248,7 +1230,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 Mar 26 00:32: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: 12165381 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 7CB07C433E8 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F62361A1E for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229836AbhCZAdg (ORCPT ); Thu, 25 Mar 2021 20:33:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57568 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhCZAdX (ORCPT ); Thu, 25 Mar 2021 20:33:23 -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 12Q0OksD057470 for ; Fri, 26 Mar 2021 00:33:23 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=g2cw3EdKTsurvbuhjudKonZ7HCpp/xTCHqrQTxoxU3E=; b=Zf5MS7wxkEfjCZoxSCYzWaz7xMT1mIprHCwURp4PM8bZgX+x5W7VY0up9zoNWN3YM3ql qlpbKXJP2wXb1c8OOsBdUjgj17nxE/uBacu2vLWoU6aPWPbvMAU55VUGUspdoBnDRN3l an04hZYIS9YM33ot8p7fwnFEFAM5MWVmr8MimvrBImHH93DLsfY639RopkKTwK2wXHr9 m76QdvSE8V0nIK8XbhPanwiH6rkxr9rE6dGAEho2rUOCyjY7BFQwsyYa+Z3co+AQeUK/ 9bW3rG2GbIKm7dptfE8aHdwpbU/zW84kOQ410mduo2KyU1ySBFUIIb1ASl0IoRT5GglQ 0g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37h13e8h62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +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 12Q0QXnA076081 for ; Fri, 26 Mar 2021 00:33:22 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2106.outbound.protection.outlook.com [104.47.55.106]) by userp3020.oracle.com with ESMTP id 37h14gg490-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lqt+qDOMII5ej5Yfqrryy+aibJ/ZsXqhe2cSW5uxI7nErDQ3pZeoZYm77vKUAdBDODajKTj7WHaYX3duZUfKbs3eIIEt/+vkJKYiFiRvI4EtxDikoXv6okQCo8Q+W2pR/9F191DzK6c8JKV7A1ul+h7d4l2WOaasQ7cQ5xkPRYMfNBtUVer2n/C/Mr0ZgXY3K1RH/vozCmjsAi2wYlkWXbMmTEEocjfBGyKsTc4ngsBccbNs2Q6F9tW4+H7FWNrRLXwYbcA5LRK6UhFWEWD+aIkAosroL5htGT7Lw0rPD0Mfwp2lDkSkc9mKcZYsQQUIrcxBr74td249k2G+4Ht/Rg== 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=g2cw3EdKTsurvbuhjudKonZ7HCpp/xTCHqrQTxoxU3E=; b=S2kIiVgl3f450Y8S2omPN4cMrnQLxD26kvhFVqB8pGDbbgWnqjCHCNgVSlfJG1XdFve2a3gHGMRGhBUbORfJCyKmLwJrHR2cZV3lcN5F5UDBgiT8AlKV0vyj1mXhop/dqpu6yNgtzCJPpvLTGj2omf3bjql7aLyZm9qGBSaxPTmobmyHV27mK4/lV8Bmtxu0YN4NjNSqXPjX9HLKjtnboolAKFld4tehVfAWicMQBIXgNRB8SaV+LNbellPEGQuHeT29xEponAitArVpO4zX8TZ/x69DQlBm47peHvAlct9NlgcOKaOAkK8a9P1IA3YhSjwX6KdUE9ZPG9vr587lAg== 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=g2cw3EdKTsurvbuhjudKonZ7HCpp/xTCHqrQTxoxU3E=; b=Eh4M4hKaVzjZEiWuyrZEYe6ds1w7/RmoGtJv6IUptTD0mG3/5wztmayiU8Rp/eexDuYNnSbyNDT+0NBOgCGEFzieAecvmLCeTK2WfeqMwE5HpKDnNbkLdggNUc3FgehYWlIuoYwpsZ35P3izeqvp9dHYRCRBET6L5yNuZQAipcg= 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 BYAPR10MB2709.namprd10.prod.outlook.com (2603:10b6:a02:b7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Fri, 26 Mar 2021 00:33:20 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:20 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 02/11] xfs: Add xfs_attr_node_remove_cleanup Date: Thu, 25 Mar 2021 17:32:59 -0700 Message-Id: <20210326003308.32753-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc729ad7-fd17-42ad-524f-08d8efeec16b X-MS-TrafficTypeDiagnostic: BYAPR10MB2709: 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: yDPBvM3xu1ry8/TjBYnRdN3bKBxZyK5qhLWUWuU8GmIs3MIgmZ4I5wA74zKiWcgp6+fOHUXFp7njrofABU/wjToyRwK9D4YYcQ/2efy3rXhTrS0+NCavswLyklx71TZuNB0cLh5v/msLraf5NjKA9vmv16iRMtHng9/Mn/r/gat+B6AYxIUTlB4Y95CWSDW4AmKIwcu+2dU/eYa9TNi0DWMiDkdlhbC1n/syzJ9klFAJLB1h0AQE/d6s05hMpDDgy7JsyElFJlTmt/nZFr5rrQLiiAyFdD3NQ6n28dZExjaQCvq9Tn0YKnUFR4bfw51Y6Ps9+6vKszhZYPUb17VM7cTBp2oVM/WKMpTpDFryytmAhFo/AriaiFfFTNd/P8VaBmZoflIxHntK1EpVpnRJ0sb5nw3urOlRF9WhXzEQ2rXedVcvOiKcqYDp+bPkiKYbZhjmATcruP0NS82DIA8RaFWizxCa9kBUp5FoIhEf/xWH5zhk0b2Nh/Lnpqb4fA43W27O2OXh9FQTtnBR6WI13SQnuCXwqcjWDgXaJcjw2skCM3POEi1JWrlWol86Bo0TA4iC4b5K7BANGaihI3n8q5FH6n5mytD52gVfumgYm7/iraisqt12jMPYhfkmpqLweowMeAeE79VJbd084zKEOGRsw5BGaQUwmEN/UXki5qZNpkHnCWTkpdPIb5dPk7fT 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:(39860400002)(136003)(376002)(396003)(346002)(366004)(1076003)(8936002)(6506007)(2906002)(6512007)(6486002)(52116002)(6916009)(5660300002)(8676002)(83380400001)(36756003)(66476007)(66556008)(69590400012)(86362001)(38100700001)(66946007)(956004)(6666004)(316002)(2616005)(478600001)(44832011)(16526019)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +S/e3EAwjc53bKM5BWXddvTDomu50F0kn2FrUCPI7Fu81EV2iRiqwTM6NDVgp7NxhNIERcT8JtoDowRzYNNfoln2G/49P+LClDgQLE63nsbDrPZQI0wWIoud/G+egDdsKOPEMdirFt/NKRcnMaVUK/TxqqwTxk9iErf3yNW3vMEYxY5xxymK5saphhoCEqZBghxTnmacUEsfCkqn7ku5LUlejMqTFj+x59K4Yivk45G1K1wMjflaI4rnpGhdasgZ18CUJzRpWB9lNERwCxqncITPUhe4o3ptlhKOS7q2smHTweihcU4+mnO4r8cXx6RhHBEJHX29zFoDkJuY1uZOBbfOB3EGaiZ+Gmcf4NhqFMRcIuJvmsYMbRdFS4gia/2mqktie8LGfQzGG4ndi8spiZbo6naPua0+f2SAPjzI/bCOkfbJbip7bTVgjm8II17UvjTQlogdcryiJzYEwGpjOkeV6PRlJAB2dSNVQzYWuVJakvPpVyqKzyAARQ2xBhbnM1c2ag9XZonjbtt3dLUewSlmfyAkOqFD7DN/VpUeY2z/3BauCMpnlKFd7BBkOdsb953i0HbVjKV6uEIGtueXZnpa5oukNIlKlXSBuHO269quv7XsYmAMswYhi0UExpTXsRZ1XrM15VrnJGR+KAD6qB4jGzMSJoonr2phZ4rmcoVqAu2aJQzl8d46qkTRmMAxPthskI5r3r7gWo1ZaVALhjlhZ4mDoJwvpp5nIPwpCV+HcQBASkcKwJY7+b4q1V6jANTXszmll8mt8r6PJAC/X+8WKftJe8pyIpjdTniUdWB3JLfGJpC+QFMOOHB7DR7oMgE3JkDQlLLePzx+uhP/fLZAzFAd8d0fQqWP7eQfeK5ChH1b1hxRHtksfCBSJ1sI9Btj5yvlZXuCRb4CbQsv+M2raDyLpQDghlwjoonOCRpwBdXb3pOD9q+/oZU3sxCNwekzA9Nb+GlelxOp4+YW45tz2Sexs+ZWNUge2FlaqlL2nEAN5WdejCGGH05pI/8CWT/m8dS6Ou+7hNqbz7xV6KQt1jS0a2edQeBQ8VaIgevQN1gIJwFgjE2FtCSOnokhiuBv1uktnZYq5yYGSOZhfIIUv9/fu8E0uC3HuoUHaBLPSQS3n23ctxlXikr2isP9EHP0/6F7yVpzvymovSBAe2pANlFBn5r15CWqWZCSaq4TJRC0OwaKNMq6sTI/RNG2BqgTtoKF+U3PYs5zZsUIuI/zPfFZcGt/LTfPO/vwdEc10N97VQ6j74RrEN20M756Gat9Oc2wlMgAFPdBcK3W2YpSQ2z+TueHnLn00XIVLaMd5DPpFSCJo2Eg7zxPfwfL X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc729ad7-fd17-42ad-524f-08d8efeec16b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:20.0331 (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: f09zwXKgu179HlNNr7bAR4iVzOqolk2SJtMiwqrSgqFBsQnktlqm8S8ZCjnIYQ93Y8CmhNksNO2WdSao1n/7AOS4nELWSDBs9dgaPSyFghs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2709 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-ORIG-GUID: _oJ7c46WO12n1-nG5vZEU8QBKiwFCWBJ X-Proofpoint-GUID: _oJ7c46WO12n1-nG5vZEU8QBKiwFCWBJ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch pulls a new helper function xfs_attr_node_remove_cleanup out of xfs_attr_node_remove_step. This helps to modularize xfs_attr_node_remove_step which will help make the delayed attribute code easier to follow Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index b42144e..32c7447 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -1202,6 +1202,25 @@ int xfs_attr_node_removename_setup( return 0; } +STATIC int +xfs_attr_node_remove_cleanup( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + int retval; + + /* + * Remove the name and update the hashvals in the tree. + */ + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_remove(blk->bp, args); + xfs_da3_fixhashpath(state, &state->path); + + return retval; +} + /* * Remove a name from a B-tree attribute list. * @@ -1214,7 +1233,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; @@ -1242,14 +1260,7 @@ xfs_attr_node_removename( if (error) goto out; } - - /* - * Remove the name and update the hashvals in the tree. - */ - blk = &state->path.blk[ state->path.active-1 ]; - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_remove(blk->bp, args); - xfs_da3_fixhashpath(state, &state->path); + retval = xfs_attr_node_remove_cleanup(args, state); /* * Check to see if the tree needs to be collapsed. From patchwork Fri Mar 26 00:33: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: 12165373 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 5E541C433E3 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07F8361A42 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbhCZAdf (ORCPT ); Thu, 25 Mar 2021 20:33:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57572 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbhCZAdY (ORCPT ); Thu, 25 Mar 2021 20:33:24 -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 12Q0OopG057478 for ; Fri, 26 Mar 2021 00:33:23 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=B9sWea3/YaG96nhmVZAVqAHTn7obC4YkltX7E1wKzB8=; b=BQKjJhxEXbOsy2k8Bw52nAwsWrE9spl5f/IVDNrO2KDj6lI6aFhIaN8JDM/r8Qthg4CF dk8acD2cjDrM7TRIJ0/WavCbY6nW3AsUmI82A24xLw8Rtmt7VSRnLkqLFgAdAj3mRi6P XZOmUYiZlCXB19U4C0Jjt+V+uNq79ecZQ03Ebcrz+0LuRXVe3auSnIMvspmxDYvO42vr kQ4i1U/kqomyBw11Peb33Ci6WWcKSnrzO1pflr+qWjADdjA4FokdfK+Ut1qJlRvfv6Fu Uuhe9MOKPbWh2P5nw/QBiMjoNDzFxvJzu4T9iAl6VrHVNgBXw+NuYaNqC1fJIw0Nw9qw 5g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37h13e8h63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +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 12Q0QXnB076081 for ; Fri, 26 Mar 2021 00:33:23 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2106.outbound.protection.outlook.com [104.47.55.106]) by userp3020.oracle.com with ESMTP id 37h14gg490-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fMWtlg+pefF9w+uVCztEI0GoH7iDh9fj7m4fF0E4+tzOKkvYpWl5AO2bRuEw/UoV7uxG/xmzkt4uioR31muPN9LQzEOjAkZ+HEIfUM4sxwV7974BpI/R57FOvQG7OhRK2Q5gQxRfS6fARvO5rsUbi2tdPEKOQMp9optn5bpekVj12u8h71poxCD/OtmA5Mm/Ug/uf+MbD0DSAiPHcyROtL/GSalp7uVDpGU+Nx8Dn3+s97qftT0iLXstNu13h15RouUNHaGZ00rx2X/5xTkue1Vc1YqgAcUKsI2san5ZbZfLpkakJipTd8yHvIb2Ec+nctYTpqI2nIVCENN6K+YnfA== 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=B9sWea3/YaG96nhmVZAVqAHTn7obC4YkltX7E1wKzB8=; b=id6CJ+MQNWUo3IrMUTP4B5aZclBzrWOr4WulAn9LZgZqNLcncH7V3Rmm+6s9BdmS49+SD/fMMuHgPL5dz+jM0x48uEp59HuLwGObeysg6MkEHcH2mr2xJlmj559CvR1DQ16Nc2PUUfra8soo4r2jESZJFEAS9y+EcVaD8/Kn+h2GdlVtKOUiJpg3MwBOkyekE23aXVferfv3nWapj3Qcje3220N9fBbcnayvrQ9pE72+vk1K5r0Bi4EZUIk+spRZkxE592mC69lppoZAP8Tv6dg5yrN0QzEtu75bGIOcCM69F1qSC7FT03hkTN2xh+gZwLRx5jgK0QyD67KRIts5/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B9sWea3/YaG96nhmVZAVqAHTn7obC4YkltX7E1wKzB8=; b=kCLMfLyG1DcBfo9ZLiDrQlXaT9dEX2HfdfthbMLbaB0ucOHrDnbqQHdsStRs6+UUUrqDyedwIUKV1j2nzABUEBikiMi8p9O4lb//H5BDC82BVtRi0ZKuT6sbYL7b8+DiAVVyjQrTaoGHqhnZpzP8My1jXKKW7bbekhPf0VnAg7s= 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 BYAPR10MB2709.namprd10.prod.outlook.com (2603:10b6:a02:b7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Fri, 26 Mar 2021 00:33:20 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:20 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 03/11] xfs: Hoist xfs_attr_set_shortform Date: Thu, 25 Mar 2021 17:33:00 -0700 Message-Id: <20210326003308.32753-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0c747ba-002c-40cd-efb8-08d8efeec19b X-MS-TrafficTypeDiagnostic: BYAPR10MB2709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yAoONLhLzPAU/Z34ZQsuGwUPaDu+AVZ9vkJDrD6zHKhC9/LCS1/ZVYEyXeK6kw3wVVX7gh16dPh4ZLdwPmTd6pceD1FuwwsEY4KgdW6JdiKEWRouszamC2TQTcNRpI36SSl2h5CS6m644OxT+8zXuDR0BHnFxLsGt/1p0ot8qNONT6KKh/yJijDTY9PnNggtua5F8jhBKGmPd/7nsCL+2ikYYLd9jvbhTopWl3xwjYtObNGNy15LQ0bOIXsCkXpJD4CIaHDdEqPh4uZPV32cYml+O4MwetIzpnsAhI3TvK+JNWTcvwZlLVxDLZpT4XnMvdk8x0zSi5ldCos1mT/cCGIfdJLbvNXJxAbxoYUL8oPcRY94ii7vXjOlFWvqGuWhfuPJOTY7avVpYcOtS+hxHSmuVf2HDGBsaYcM4U4KH1Q36nZJICc8aQDc9+FT9AKthp41jUKz5Rzdj3xaZEHEzu2XtPSzzgnHE3VBHBr/vAMaTzPXqn6mlNqiIZJzK1KOl21zMmmkYabXTm0mghRCWBZFRiaQTU9XkryLKmCnJJ4KIOsxUbZ3DzRaLd1nknEabnw0Rfkq+rKcGAR1GWd/4hqI2ary6g2zX2aYG7rXxuYFywuPcDBguX/cKfFiKlrz9qH9tQzstsk/ngsxTrVNg9auxhgW73gz5KBBMDgRK6IG+1QKWa3ptN8GWt+FdcPv 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:(39860400002)(136003)(376002)(396003)(346002)(366004)(1076003)(8936002)(6506007)(2906002)(6512007)(6486002)(52116002)(6916009)(5660300002)(8676002)(83380400001)(36756003)(66476007)(66556008)(69590400012)(86362001)(38100700001)(66946007)(956004)(6666004)(316002)(2616005)(478600001)(44832011)(16526019)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aR4cxoq+elZipEMLxSP6dvhL6Kf3jQdNq28Ropsg+kqFeD5yLmK+mLw3awyZxZgDr6hUGVZo4DVf0oAHeAn+mO8CTJBAhyKttsIIWPYgDITglpLpFiZZfxiSt8+1LPum8uHenA/f3/bCfBwUOitQyclj7HgXo9PeAT7Gqa7wElvVyn+Vok7vk5a6Qm2biO5cImITLodp8hAo2OgTIYxtPMJKwqPBY66EPbZrhhiIDHIOEMYIjv5E6NNzZzC3qj17lSW8r2Bm1AUN+htvUSiDlqGmUprFCvGpUdlK9+9vC4ozKC7ePS7sVQDECKiRtJlqlQoiarMuIYRzPYpN3vfqkZ6MhooesR0iayDpTqSeWv5JYI+oPu6yAjT3PDPkrXuV+6evzLT2KTpKQXd07fYPYDf54r/7VxEoEps+Ipkst3Bbayb22mi3DdXAZ4P6qJxgL8/UOejkquYH0Kggenn74+evBxqb1shjjFLPNXiHlsnkXwGPnwOxB46JBXExRk1TotErtdSixcapIt2333FMB8/217m2a3+Vaz8s53dOvQsbKt9HhQOsSY5SV6TyRXwODkCJqmZO2+tVk5tAyEupGqyb74dEc1FjsQBIw/liSzP6Zh6trkl48cDrc6PgsfBWk0+r/36YEVTgD/RmSgZ8dIeN3RTUL+/ofuWh4tn4CWwVjx1RF3hjHj0MaFC7auWRcj9utiyee84duYz86lLE/R2WW+ASSoQT39NBuVU0+0Kc14dOTzByLcqlQ1xP/i9KVg20SRQZ+XzGdxlqNF2Q7cb5yBwGsJv9UDGmhqNfyv9dGbi1CdS6XzoOcrnWxg0yJcsy846JifI89+pniAaP3T8X1A7ItVI/wtwUYvloPBmHQpHyuZM0XoomHeKAp1PSbaeLaGLpj7LqgslTAIgifTZwvnBiIQvcMsXiRRx3CYjYaq/lgM0L9qWjV7DHKESd6RfxlSRzFXI8AcLGqHun65yk21Dv5T6nsLkgme3dcraTaf3ZmI7/VHtk2inED7F+XI+LgHvDV/vldYYO8xECTYN62pwrIgVPsVuCDaw6bH2X0rmRh8N4MlPoLFAMmlUWGhGJTA8LR7CvmcPGWNkzoL46aRGfi5cI8SburJB1aRNJewibZQUoBeybkE6H4e5kmhm+qCpD6XwyPxg7AlDNQ7clMlpFJ1w7Pmeu5fSWcKG0L6dNKhoyJ8IGy2/u34q9xbfmfW3WFbgL5CLhD/ZGt3wbk7XlAgWPaSe583eEmsQl9fM8UZd1uHMr9dCSA2GfQPhO84FS6xge8bIxx6Q10KH/ATKcNqPGPWIjmqpUWsc95+/joerMSYbnI0Xx3zaz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0c747ba-002c-40cd-efb8-08d8efeec19b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:20.3616 (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: OsRXRUZJIF8V6hzkNjywRWIdVmmQ6XknwUdLjRYqN+9S+Qff7NpNR2D0AG0w9NL3mH64Ye5z276Ck1YEAjs7YL5kjqzkEMe7OrD2g9bvWg8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2709 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-ORIG-GUID: AsWY5QdhaOhtDEc4wnD-UsRbnXeV9Tnr X-Proofpoint-GUID: AsWY5QdhaOhtDEc4wnD-UsRbnXeV9Tnr X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch hoists xfs_attr_set_shortform into the calling function. This will help keep all state management code in the same scope. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 81 ++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 54 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 32c7447..5216f67 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -217,53 +217,6 @@ xfs_attr_is_shortform( } /* - * Attempts to set an attr in shortform, or converts short form to leaf form if - * there is not enough room. If the attr is set, the transaction is committed - * and set to NULL. - */ -STATIC int -xfs_attr_set_shortform( - struct xfs_da_args *args, - struct xfs_buf **leaf_bp) -{ - struct xfs_inode *dp = args->dp; - int error, error2 = 0; - - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - /* - * It won't fit in the shortform, transform to a leaf block. GROT: - * another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a concurrent AIL - * push cannot grab the half-baked leaf buffer and run into problems - * with the write verifier. Once we're done rolling the transaction we - * can release the hold and add the attr to the leaf. - */ - xfs_trans_bhold(args->trans, *leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); - return error; - } - - return 0; -} - -/* * Set the attribute specified in @args. */ int @@ -272,7 +225,7 @@ xfs_attr_set_args( { struct xfs_inode *dp = args->dp; struct xfs_buf *leaf_bp = NULL; - int error = 0; + int error2, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -281,16 +234,36 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; /* - * If the attr was successfully set in shortform, the - * transaction is committed and set to NULL. Otherwise, is it - * converted from shortform to leaf, and the transaction is - * retained. + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. */ - error = xfs_attr_set_shortform(args, &leaf_bp); - if (error || !args->trans) + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); return error; + } } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { From patchwork Fri Mar 26 00:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165369 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 56018C433E0 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C021B61A0F for ; Fri, 26 Mar 2021 00:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbhCZAdf (ORCPT ); Thu, 25 Mar 2021 20:33:35 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39304 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbhCZAdX (ORCPT ); Thu, 25 Mar 2021 20:33:23 -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 12Q0OtrH066416 for ; Fri, 26 Mar 2021 00:33:22 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=niRsdzHL9xK5RHpOId50sCexYB3pdtB6cKJ9osUtZls=; b=QpSaNoZDdq4RTDkr7ID4kSjhDTHPDc1VmQb4x/DOZcZG2pzMUAlfMVNbjQA/ixz9nK7I bxqJqOC3Awue4KNkk41f+mrFlpucvm2CL1jtnaHnvAGnzIqFY23WHv3JeumdpRzTllY8 6Sv1LP/w4zb4UFkOmzFO0CbiWOvSsQq/hBYHENGz69RTZWSMpGPtucuWvAMIn+FQ/zu1 gto96jzv0nW4qolGQj0gVoImwCBuJLpaWKWkVd7AGvJiWIhIlFyYIVFprAJVr1bcCqXm 4rSLVkSx3lXASa4m2mxl2YWZStO+hVysJfYim4PmPkt8eq9dA1hNI2zcBJStMawXAU1D tQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37h13hrh7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +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 12Q0OlNK009463 for ; Fri, 26 Mar 2021 00:33:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by aserp3020.oracle.com with ESMTP id 37h14mfud0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MT465HgQNcWSo/XmONRy8Uc+vX25e6XswmMwzaz081qntXnlfgzJxNQ1Ef/nHpLQa/ccokM+MdfHx3GmUjiMbQ3ZrDprk40vLZ3pBRy4fMQXY0D1W6LxldShgHfaTfQ028jQXxwivZOe+1WApSUVzcv/9Z7eBsjkAavI6ypsi5z7aF+e6Do1hVYnDbi6n/e9WSFkjiPECwf21TRvKjfXkA1olRyUEVQ/NuYGWt0epODb9kZ5oZo0JtPH1ubzhSdo37YYXRrjv2mE6WNfDXqTSdvgpTWCL6OroaMDdSaiw9qrlrwOm1osuIlk7GoUixYlmE0LMBDam43RNV3weRniWQ== 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=niRsdzHL9xK5RHpOId50sCexYB3pdtB6cKJ9osUtZls=; b=MewLYwxkk6SdhczXAe/kU4oIinKnfIgz/5khFgwtATE8PdS3TERYVUU9TEPxCkpfoLrKHEKMAxabIH/k6/9W7r20b/8lXLI6lxEAW8Y8MBA9o30HAaJU3QFOwaq6hs2v62Y/T4gCsRoCS9PXN8777BTpIEXf9MX92whuW2YrRfE8SUNEVwFJ0su1xkTCEDMvTdrtQcDIOJOnnhCpe3t5LeMwlpTtlHQ/B+x/ryz508/P86VxYs7YBEo17OVkxn9oVSRCKlLNfxLcdb5mngUTPw3pP5j71V8Ogt4WRq278aOn8sBqSl8+BlOwReZ6Prd6eGesR1G0zRwfTBE2LxJNkg== 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=niRsdzHL9xK5RHpOId50sCexYB3pdtB6cKJ9osUtZls=; b=jp3N6Qpme61DvhokTmtlP1S8a5Q7HZBuU7H4r2h8CeQ8e7Cdi3A+L/Vwca+oOlv5/GNoeGdZ8DOGjKLqFA+dxMnSKDEcByqUzkJnWRYD/YO+SSpgoW7KvvjPIJKgxj4Zq4gYff5dyKYuE8XLPEop4IyJNvVOn3KEwFpJ94Ijryk= 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 BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Fri, 26 Mar 2021 00:33:20 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:20 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 04/11] xfs: Add helper xfs_attr_set_fmt Date: Thu, 25 Mar 2021 17:33:01 -0700 Message-Id: <20210326003308.32753-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0b69f7ed-21e1-4782-596c-08d8efeec1d0 X-MS-TrafficTypeDiagnostic: BY5PR10MB4162: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:586; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bpMaAIAVQhUXb14g0fwGiB0V52OAYkmU2bRD4gYjULzRa6DR48GhuuNaCnB4Hq3LBNYCsETTNSGUehCJPI3IsOFZ78LeHeVNhOJzfXMA31M3gjD1ehL3OCtZd6ZWIGJBTlM96n2uCQUJZeMmWLCoH5d8jfYOH8MCTBs/k6oEYtwgNXoY63OEjlrrUCFX0p83p1EEhKAy6idMuKjXOZewrGPcc95kkvRcrLvNMm1jQb3vQ9418IwlFVIkvsL+4KIRfkAWMMaHNw0J2bv6wEjDZtIWiw5fuZrWQZ2j5MjFiaC7APpt8izSLW25lzJHCSRCk8/60HyX/OmJ+ftRvrSHsFTvG4NhheBD4T/RH4hcHKrp2j84XasM4ArhvoGM9Zl+s+gkKZJGWwt++9Ao2r/l8pFjC71LIhzQ89g4b6WWW058fvr2uMeySrHbgjO6EzIsBIuh44zKXcF7ElHNzPaKDKUJXOLHBJrC1fr/SxJUojkdhSQw2uZqNfHA5KhVhTGkdg4ZN/BipXy4nC9MycZ0J7G3vOeFr3LScS2cpijsg9u0D+juffjnWTBKxJ9Kwm7UBbE/rGjqeDRsMJMFU+DaXlrPweDb0vvJH1pa/lzeAj2YPHho9pFvDNbTnYbhbdzOQ4twxs9nRv8g/2f02deUHhUNBj58IklPWnJmPNBxlQ6ZcuSTzRieXysRaV2werec X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39860400002)(136003)(376002)(346002)(16526019)(186003)(44832011)(478600001)(83380400001)(6512007)(316002)(86362001)(6916009)(26005)(956004)(2616005)(36756003)(66476007)(6506007)(52116002)(5660300002)(8936002)(69590400012)(6486002)(2906002)(8676002)(66556008)(6666004)(1076003)(38100700001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Q/GrzzQs/q4V/clJqN3gOrSMDH/EA6YBjgrWuQKqnsHaBmwecOiHGQAAzTj2RcCO1bzwrG9UxWT5uzAHtYCv0nTwfSMS5+elmDuKA9w6ADWrkOPGBt9k6E5iLiQEaE4lv1b8tj+INjoD0k1+NgTHhkhyx42z7wv4bApVFUNlImWKReSXYWbUKSZiqx9u+ERM1EEG6vwMhCLQU5/9IbqUDGo1xq+jU7D8Ru6G8pW7JLOQs8bn0ei0+4Gz0SGV6hmrDX3R5oGqvh6Ztsia5pEBBFlV6m/0E0O1QP8mN+Y+gy1xNF2BGWMzus5X/C5Wni7Pl8TZzGnYf8v35M79HlJeqy0rjJSCnCtiP16PeGe0wDHIRzDXtw7aIzedrQOA4phlnnia3mdGS+P13AR0XRqImbG5YFKzoU6cG4RYMzBELfA7GLZiP7sA8Z37YLhDzm/pS4pWKNC26yHiKvSfKUgZHuXhjDayivpwYh8+NxoEOdZJIjOPE1RwiWVoMDnOpJyPgNs8yPzSrGQruwxnUKfDGsfnAW86tFIzdAi6kDXr13MbNBgmUKHanDSJashpRVS9SizcFt0XYfrvSDmhk33ldrJZx8rC5FVGJCU3Xb5Da51clRjDziHZUbeu4da8b3anzQZanUwSkUDcLGJ/Spj4nfRpVIV2GlEp7NZGxRVRageBJCM+NC8KUJFI7YBTeVHVWNrvVyT7X4PTL4Bkdy0E4NwDrr1Kt3IX+maXU3UwfucUmvgcT7UvsadExavaHohMj/6It+StFjlTX6fNKYxCFYZdzrWN0DQGnI4oU4Q5106WQlZvuJmk4KJpRdvC3NYHE69SEkTmaF9mpSA1Q7T0rgw3cn8n105Ipw02nkUyP4yKLbaqVn19gvvRp2oXk1J6bNTcOhqzDLDuyjhBJ62Zsmm1DAA4/73TOgnPXEcEMk0jXAUAwSsZMth6xvei52hBWH4+3JSWNjxaDf2EC+RiIgKI/a9vS6xMmvfBnxXGBF7cHbTrOQhNKrO1KHW5xqyL7kC8IvKmFvP4XfM1D+kPHWTmkV0OT3LFDLKjEGKPbYdZv8rf0PeYoETWELWC8zyDVXCH7smWjAYO9i5qo4PLRiwYOvCqi/F4hYtv6I6dmKXuJt1QG2crxQmcAH/ROH8Is8EGehlfaxfbXqReYufoahNxYWDwNCUqQ6JIhqvA/WgevU70Hfz18gurNJi24LJT5xkRPyDtYPQbVJ0a1Qp0GvBDfgbAAKwL63GQc0HOFYyIq+Ety/Kde4nkWcnGIEpirZU/ZYfyFa1z9fDgJZE7Fl14bDyCa+m36T4W6PDypsliFe2cciIJkSHg1Kf+wO6n X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b69f7ed-21e1-4782-596c-08d8efeec1d0 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:20.7061 (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: TXvaLjIRI6W2yUJdnFHKWLXl/WKk0tbMSku9lKm1X6Qvgc+NfZUjA9acyaQo5SOBGFY7lqNC0SUEAStRpKgW6qg7TCZWKysyFskam9lhLf4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: 4JK4b6-nVXH9bXw8e7gfr--WD-wNAxV4 X-Proofpoint-ORIG-GUID: 4JK4b6-nVXH9bXw8e7gfr--WD-wNAxV4 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch adds a helper function xfs_attr_set_fmt. This will help isolate the code that will require state management from the portions that do not. xfs_attr_set_fmt returns 0 when the attr has been set and no further action is needed. It returns -EAGAIN when shortform has been transformed to leaf, and the calling function should proceed the set the attr in leaf form. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/libxfs/xfs_attr.c | 79 ++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5216f67..d46324a 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -216,6 +216,48 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +STATIC int +xfs_attr_set_fmt( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + struct xfs_inode *dp = args->dp; + int error2, error = 0; + + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; + + /* + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. + */ + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); + return error; + } + + return -EAGAIN; +} + /* * Set the attribute specified in @args. */ @@ -224,8 +266,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error2, error = 0; + int error; /* * If the attribute list is already in leaf format, jump straight to @@ -234,36 +275,9 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - - /* - * It won't fit in the shortform, transform to a leaf block. - * GROT: another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a - * concurrent AIL push cannot grab the half-baked leaf buffer - * and run into problems with the write verifier. - */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); + error = xfs_attr_set_fmt(args); + if (error != -EAGAIN) return error; - } } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { @@ -297,8 +311,7 @@ xfs_attr_set_args( return error; } - error = xfs_attr_node_addname(args); - return error; + return xfs_attr_node_addname(args); } /* From patchwork Fri Mar 26 00:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA6CC433E4 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E89061A38 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbhCZAdg (ORCPT ); Thu, 25 Mar 2021 20:33:36 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39310 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbhCZAdX (ORCPT ); Thu, 25 Mar 2021 20:33:23 -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 12Q0P7Wc066486 for ; Fri, 26 Mar 2021 00:33:23 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=RqfGCr4FVABa59oylu389p+knF70YwRUQcBgnKN1qng=; b=g/CPLtmpaUd6kEL/M1TuhPEFBYgCzmbV9SGRR91rmGaXGrSV+rxTEJe4yfkVtE1e+/9l TbW8d9WylDbxo6+PwU8STYMr/cDrYbH55rXykHehSJLqL16HuODwmo1ceqkYvQEx012G U2Ecp9GIO8Zad32bgl8jedCLu8BoNK9HAZWDaEX5yeP3eGUKgctmdVF7kpRUFmfR+N/1 1dkr99QCaEP+gDk871K+xnXAorySsmTGmuHSuuTFkz+RUEy4nfybnwyUXNAWYr3PK230 BroLDFiMRx7WzwQDF6HtXeroFyfZCq3URAkeSPb5/6UQdOTQy3gTKkV+Dy7rrYGM15Bn vg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 37h13hrh7b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +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 12Q0OlNL009463 for ; Fri, 26 Mar 2021 00:33:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by aserp3020.oracle.com with ESMTP id 37h14mfud0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gx7fb7nmjtUj7ZpoL9LH89GeWcTs1xGU6UT8eyn8dnoDsLpufA9nBqIOL1PLQ0ckC0vgrSqhTGnHVPrupObhveHtvh4nmsBouCKrQ/axiftnzQ/pjpLH+SLnTO4GNr/OOwguXniYbCERPCiGMkatpuKM5SsErUk/b/48Gefz9zZ/JvRZeQ0TcX9E0RpBhJcYUGGilphds0A4BF1AGXDoeucqcMmoeWpdB1VWJByxMfc3h+XgBf/wF4AK9aCexwLsj6c3jBP4tLY/xJe+g2evBakCx6/6of3lcYc67SW1g2GKcphV2jruWEvOYQNIoKNB+pZLsB9+/kqScZ4uSVSavQ== 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=RqfGCr4FVABa59oylu389p+knF70YwRUQcBgnKN1qng=; b=XQQdk5v/QTCFsgdEzMk8F1lln9ZmU6QTkEon8IaC4GvWW7MTMFhq6HntelzX072Gub14d4XMNFKEWUG+JKr6tnNHZqfBp2FOv3Rs8IgFRh0nhmneyQUnISvrqp7wWe02cGR8PX0lkr9HzrV24vdebFFCDcTPvGKabbgqaJHfdZaZbYrrwXPDPqlT5afsQ+sKcqFdPYQi5+EUowBsuIguUa8PorHQIejFPqHw5Q6wPUhx0Wlkhpkt3oRydaTPVJHs4qdoNB9hENb+DZ9d7Ci3yztQr8KfE6GbP5w3ckXzr7zb5J4/Pw/qJYGOM+ffiFTDV76vqDO9Ex2WWkFomYgYWQ== 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=RqfGCr4FVABa59oylu389p+knF70YwRUQcBgnKN1qng=; b=GwmNRmQi22o1QDvrqxZ03LJNUy+dCOtfoKOSnVmL1w5liNco6IW7cMLTv/EcC2IleaNJLqIJriLkmSnDbgYYE1BE3d7DHpnftnM47SCUhSY61K19PZ8QX54YhNTWENgh2b+GYEIOSFhbwamuMlDfb+pdWvFl2xXJCBdVcaOmO0M= 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 BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Fri, 26 Mar 2021 00:33:21 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:21 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 05/11] xfs: Separate xfs_attr_node_addname and xfs_attr_node_addname_clear_incomplete Date: Thu, 25 Mar 2021 17:33:02 -0700 Message-Id: <20210326003308.32753-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f77c4964-c474-4cde-10e6-08d8efeec205 X-MS-TrafficTypeDiagnostic: BY5PR10MB4162: 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: PAWODnroDNqDvzIvdxYReBwnMKPxFbfnBHjc5XsWVH63d0imDzl/8r0ekhXjacxhi00XPC98rerV18508mMiVnWhoUyz3mNwwsIPNZrkN0QlDYfp9IS7QpkxGK4Fq42O8rST/Xy+ea0EpxMAPjxXWYEb8ZzR1fUG2YFmX0oT8W4KX4R9LO9u61slFKlAYKk4eCKXwSO47vutvD+YP37Lzh2KChcsKdLdHbyOOT0WhcgXIvpuHvB8JmPHSNPyZDekMJ2hEo6XJS+pvO+Pdq/NCLQMlOPHGFy3wVNqT3F/5wqB8bDoXn5v0qpQKqQ8TamV/QH2Jeao7SIU2c/AdmypHtgqP65MC7v15UwsrvDak6GBcMxiYkucnLs28JiLXqvZyPNfXNkWv7WTRsCIxEQApeCcCGMoxsF7cj1WeOtr2vkYoA1VgW6S5pGIevd67OSS3A3rgZBRG08kNKpR6iLcGnf5Ts4PUW8Zhn+uDt3LDvW1rJ6LSai6t+ygr2r+oC3Ka7qayv8RO90kYQkhjuAWgCmaamhoHp+kZxZ1fQ89KLNPMcFOxP9yK4sPB6BtwX7f7/vgUDyFd09MVqinbyLUfI7zotArIiIsymRY/VHHj6CGic1maRCHyasaGtR4IM1ehNRVMhRNZNcJAvIwpiwMwTm4/C9Va5YTmAwUSG0/PfQNuseUphe+t8UOy2zLSRH+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39860400002)(136003)(376002)(346002)(16526019)(186003)(44832011)(478600001)(6512007)(316002)(86362001)(6916009)(26005)(956004)(2616005)(36756003)(66476007)(6506007)(52116002)(5660300002)(8936002)(69590400012)(6486002)(2906002)(8676002)(66556008)(6666004)(1076003)(38100700001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0RLgekKX3rg48wHu6S8u/maEynQnIn3Upda00wvv7wi6apTpBm/XEejsLIkFN66VJXXevnVCiUF1xc9AODADwb9g3NIeh0Y81PCORMuW+kmzYyiNB2yX2vi/kf0inxX0i4VuJqexJbiCAW9IUlCi1LK0zG069OGmW+6mYEND7PC2NwNwgGafu4k1GiqYxD2CFGst7IOmZm4qLz1nEn8ANbgYeryrz4ayuU71ktZo6YR3D9fephnRv7eJakWIbeVC6oRGoIoXdMtTzq6Voucnw+stpxryhjkwmygNYsQxyQvlmhYOimKWZPFRBo8Rh18X/Fvp8Fw+Iketx0rSHenXuE6lVXW2KR/aFY61+Oh0TGA+DHj7cc5qzFeEydzIyGACizBlRK5OErblAxF89XLErpB4EFiouR6XQw4BikgtNC3vht9WnUDZUoBSsYbNJ/PUUQTBO1AHwWoClouHbdXN5rRoFrw5xIE7EobW91l/7THV0zzPl1GOVX7viP9rsabEFDEV+jTQCDGMxnjT8mjv1qkQM3m0d6b0aG+zrstxAfMu0rLq5Lj9QVfKhq5HNE8zBo6NlSqAScP06KWr+A0ijkxL2JnCEmIwX1kt8nwllymz4Zq3FBEtoGzSw+giBJtM0BfYDR01PFZHvezXbG8HsZF2gnoYAPWvbQ5A0L1Vsoqg3JZsmm4j6Jw28BDMYA5BY0G13EBDfxktLgaW7g6yHwZyZ+S0dVYG2MkXvDEplbiHBj8pRDi06QMVQee6MlrddT/QkPoy7Lw3cHeX8DVQmPNE41ihfYZ43DhrT7l64VlZpTvc+9ci96WmCtrOxGkJMH5VItz2lsTnwyljZc+RJGFcqsueV5rmJz3Uhr5vV+XNaAnH2fFrPlnELdTPGBllkxx6opwrAIbcpEgZFsc9Qcg+u4HUnkuxsEP4uWZVo4RkHw5KjtuRrEG2IGVm13X2h0CWCrc7x++5DV1HtsuSsRsvqkQXXgXu6ox3Sj6qQd8uUCLPITPwpCdPvcn+m1VZtaSmSRGZls3COW0OBpoPQwGPjQJ7eUSgfjfUY6Qhbo+MgXNtYHwrGZv76tW0r2KtFgkvY/Ed3SuqsnNKnMO8vR4CHVy36z7QGzesDS6zVcVWZ9y+svlUMFPtEQncdf0H7qucLgi+3Uvb0tMjGlAk3vQAiVRjOUY1KVFuXpDkEnGBPVQp85G9yuMSjexR+diKidvTVCy3xjOMnSA2u+9EjlisEJFeeXyxm3wuDLJ9vZk5eSsI15Q5GVR/pswhNiI9tHfsTsCo0okA2jKPkpzPGcD0jjEqLgjQ32yL/DACLNWRxeSlOZ7yjcvVkIyy/+HB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f77c4964-c474-4cde-10e6-08d8efeec205 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:21.0695 (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: Tf/TwS1L4K+V/GsIuhGzysbzzs5iYuyGQy9rYD6lUfszfKKTmoxT/RJSexYTrJmAR78192/T64UX9pJxIR/zXtmQJPY92rIOo8cHroVdDdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: rNeuUWh-GhQ1ooFtKTYGTAPS_oogzvY- X-Proofpoint-ORIG-GUID: rNeuUWh-GhQ1ooFtKTYGTAPS_oogzvY- X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch separate xfs_attr_node_addname into two functions. This will help to make it easier to hoist parts of xfs_attr_node_addname that need state management Signed-off-by: Allison Henderson Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_attr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index d46324a..531ff56 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); @@ -1061,6 +1062,25 @@ xfs_attr_node_addname( return error; } + error = xfs_attr_node_addname_clear_incomplete(args); +out: + if (state) + xfs_da_state_free(state); + if (error) + return error; + return retval; +} + + +STATIC +int xfs_attr_node_addname_clear_incomplete( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + int retval = 0; + int error = 0; + /* * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. From patchwork Fri Mar 26 00:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165379 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 52B0DC433C1 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9AC661A02 for ; Fri, 26 Mar 2021 00:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbhCZAdg (ORCPT ); Thu, 25 Mar 2021 20:33:36 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58834 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbhCZAdY (ORCPT ); Thu, 25 Mar 2021 20:33:24 -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 12Q0Qp20112886 for ; Fri, 26 Mar 2021 00:33:23 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=DEmSWLxmYNQZ3iM+FsGnGMwvNhGLdFqIIubfOpQpbbM=; b=r34hOeIlZpSD1xVSA6p8YGD+F5/70p6iFjkjNZ1UYkCiX0BbOI2RicYdqpA0YIJEu6AJ nfqyovtk54OIQPu6T8VRWF49KuBX25rRyq++ojOXjjb9DMhHP8qRltCMyLRjpNRD5mkE hnUqvgRXxX57q3CA29Grtg/glkOWvmWhHgP4QJEPU++wkb8FA6sUmu26HjEGgSmLYVXc 4fq1+BTR627GttqMER/23OrDYMH5LMbpZLw36gtxTbx92PvL3TJwrWVr7bLbq1IibKza 2pMotIwY2NwKlgEazqLKnivE3aNdVLBRbxUU9alqs18anUtCf0tyBkE0fNDGbHW6Mt5d 0Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37h1420h8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +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 12Q0OlNM009463 for ; Fri, 26 Mar 2021 00:33:23 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by aserp3020.oracle.com with ESMTP id 37h14mfud0-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHhXa7TXml24lmntvuhq6m7b7n8y3uS1Riw54LfWkZZhfu5yl3P4WYxY/V9yDtx60qlxYAWybpmkjrqpT2MaPgvvYkDaAFmUaoILrDtDW1xtnM820N/bmejiXt1aGORfC3DH6w6FDlq6iZskhGBoxkmFXZxhyUYrdlGgNvxX25ajLnnbTeJml+k9+kisK0jy4fChMWEdvzrqOv8pudeg7VNuJ245XHAtOPmeRdI4VPw4gkN7nmWowSGUahaT7FsdTQyXbkesVZ63D6IRGJH4RDIPVdxMlRktn72XrIDlIo2dfhStGBvMCu71b12oyR+piK7Gvk7TaVo8OAr6BwcO3g== 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=DEmSWLxmYNQZ3iM+FsGnGMwvNhGLdFqIIubfOpQpbbM=; b=Xvlqt3a5EntwIIBzHvZaG3lXkgSItlm0ykqHLwmDH5ADaByldQ1uT5T4INF1BWynYcKWxFsoANw34ZCzFJH62oUGPjbt473Ey/Jm1Y4Noc0/PXik9xvpywy3xS3h15HOKGyz/RFAtXyIQq+PMAZ2Q74bjPlRS7qqxGPxK+/r8rXN4OW4PfEeywnS9pYyVAEPO3ytQOoRl2K2Nrj6jdwNJguN+RPbsrK+mQMH+vizbhyauCGvzsLv1SLV5IIOwl1BgKUqoFKxUUA0QjZhAb4thV8pWRM7RUprLvWg2nTYJ7/5Pl+Je1uKlgQYHOE+1TaOrhVbMpLw+028PfEubPDtwQ== 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=DEmSWLxmYNQZ3iM+FsGnGMwvNhGLdFqIIubfOpQpbbM=; b=U+b7qiPiNp9CKk9zS3xsyKwEn+S/dns4oC3gWfeDdoLKFlLZ7SPt0UEa0/EV018W5utyfvl3lFZ7aU8CNrxSAr8jVN6cLWXqasSJfiJqI94gH/lWR94alik6YY73yVNSoTgbmWns5qDU9+e/8QBmdabpX3ShrQqG2p58Us9NkRk= 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 BY5PR10MB4162.namprd10.prod.outlook.com (2603:10b6:a03:20c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Fri, 26 Mar 2021 00:33:21 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:21 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 06/11] xfs: Add helper xfs_attr_node_addname_find_attr Date: Thu, 25 Mar 2021 17:33:03 -0700 Message-Id: <20210326003308.32753-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc5dbd5b-497f-469c-46e8-08d8efeec23d X-MS-TrafficTypeDiagnostic: BY5PR10MB4162: 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: a0SGRXkpbIS1Zf0tUO09VpVTgHrk70qU55CzAb5h4BosrZbHbTA6ugsLPoO5xlddXBIRHvIokjDFJw2xkfrrPySgM3Zn8OHjMi7r77ZvJrDV6Vt8Tfk39YOpkpBo52mnxQTHN/fQAOZ6sBcVb1lSRzavCB8rHnQ73S815bucXsk31nzJcixQqmOH1R8KK1yV8ifoTzzTTybcmoytQGO/oGfO2O3LWwI6hZnoCJevhPQN/DNiCckxy8hv1B8iYuPhTXa1DKYRYj5xPYTrtzse+sW+zidc/cniqhooDc+73HeBUBUbkfJBTBDwFOd/HaiPZ7VAuQWukfdSE9OEiv0zPViKiCnMzKJ6C+0uZD/veLtRyA83YSvewWSWd65AMpxEmL4dwd75UZYoD74QemRpQC2JqE7D233QF2eUMEuMQyvC9v5d5pyoOqIomsYUtdD3jwk5pA7bYcq+l2Jo3/VzOhtK5QlU+qBWEFhqSfk7uZufUU7piM7Feu2KMijjJnJc+fyINVuzJu0p1dtiaC/2lmcFKkNH8YM/rAlyTRZ0T817OqtEJCR5EImORAoVnfg8JGR78VViAI/45/rVfTgjyILGTnlkQP4xQHgWm02/lixP/skRGAeR/Gu/z9CndBqtPApgwxnJCCWuBKawPJ6ewMvWGz3XcM6Ta5VLS/JJ7nYpKTXpqxpvDBNvtTDNGj3r X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39860400002)(136003)(376002)(346002)(16526019)(186003)(44832011)(478600001)(83380400001)(6512007)(316002)(86362001)(6916009)(26005)(956004)(2616005)(36756003)(66476007)(6506007)(52116002)(5660300002)(8936002)(69590400012)(6486002)(2906002)(8676002)(66556008)(6666004)(1076003)(38100700001)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YcIx7mmtTuyoj9v0edGg+OPocrDO/2pSZ0CQGNvLXUa8xJmhoPh6LP7a0F+Hi92uG97EK7L5nRSet+GfCD2KOHsZsAOt7CFYXxtzgaVRYiD7iJ+k+F9JMqFlgqFzRv0ccZctawSQea5oFhVLGJSmVudrta1ocHoBRnAeZbvx66H1ZUOUfnBShsRXd25e27yPVr68yWvGFh2b7/vg75sOpsPxPDZi3Q0r4AzdnAnvJ1nj1DjeWvo9AiLOX2WqmKR2sDNxBKpJUopIRt1pKmcpJ9rFTkB1NggTp2sWty1x6WcT+OI8breBLCVx2q4UidzGYPFqhg0++TjS/54jtD4HCtT7I76LUYBdV9UdgZV/mnJMwfOH/dGSBPKvffEJVQjVcjUpAM0Uz7NzOidOhWc2NSKvxGpVUMGL7yYWtdkHdIkxgVYEb39OsiJSA0RB6nYMXLSgeNJGtZA46paishhRxnVVg6NkglzFrOGNyFrDBDK8u2fa0kEoDvqk/oWnWgqZ6SpXN8qmDE3QNHysMbMc8zM/IehE6bo3kM6NzWKI3xKDK2W3rVYYH5or4B99jR9QCsl6SHeOGtx4ZfNkPwIJM5lnKiTG2NnIANrvL+Wtj0f0SzPhrFsW7mxAkt0NSOW5vaJufkSR+S3ExL6ecS9O9rYCez6g8dudeN2cZp8qH4v1bOlVf94XEw1kFWpLFXzRvJErQPUAdMf7wi+n6nLr8oB2hchgaI78NIoNvy+6zM/xmsFwFD4xOYYaCtn+o2ki+udjeLdwD6/iTzN7+erf5orBTd3JveLIiZXb77AWiRa+DaoTxs3ir+1wqVv0U0k06343jdfQDMdRKVXoqe9dQj0Eg4G8fWpjzgY6OXnfqrF4o+0K64PacLhZ2HiCGjUJwDNqbBqhbBvLDnH5E5ULH2aWoyJQRYlf3y1ZMqcGHPyqawioXtR8WfzaRyW/BhRKVwCajX80gkteh8gTtcxyATNPOH+X4uA7KB5Kn7nFIIOpcO9e2aBMhppP4YC91JpBLDkvx//ucm7luyv6V+wNrlk59nbeu5rYQ4hBHG0TjQiz2isDZiX75MJEz9rrx1W5cdKEnZIt8RLuT6xFdA2qPa8mCuVugjC/+kgH62hKEHHn1TYmlLaQ24JKTqZpV3KhswTJsiwivBhOsIW1M1yhdd48huHBoDVkX6xVLUguysNKO+0oVrY4RlajJmnc9ozrRQr4HVQT9PENfb2c+G9JcOsUUQ82jCncnfjv8ZEEuxHTB7ZbVXlHoNQYB/I4y6VRNOgE9fewh858HaSHH47ICxXYSVkBgq2RReo/TndHyTrogLAPfvovXvbd7c7SnYsV X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc5dbd5b-497f-469c-46e8-08d8efeec23d X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:21.4230 (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: JR/+jAg7DbyTBDAcnf1mtrRO9Dfvpyb2aSg1XGXIO9BBgz+kXGR8rUziQf1kKxWFuSPuIiokV45fXX25AZHMRkAkab4jC463bpcMgkhzc84= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4162 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: dlbILE5X--4yNY2CkgccXMT3dF-La5Cp X-Proofpoint-ORIG-GUID: dlbILE5X--4yNY2CkgccXMT3dF-La5Cp X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 clxscore=1015 impostorscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 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 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 | 86 ++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 531ff56..16159f6 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,7 +52,10 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); -STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname(struct xfs_da_args *args, + struct xfs_da_state *state); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, + struct xfs_da_state **state); STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, @@ -267,6 +270,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_da_state *state; int error; /* @@ -312,7 +316,14 @@ xfs_attr_set_args( return error; } - return xfs_attr_node_addname(args); + do { + error = xfs_attr_node_addname_find_attr(args, &state); + if (error) + return error; + error = xfs_attr_node_addname(args, state); + } while (error == -EAGAIN); + + return error; } /* @@ -885,47 +896,26 @@ xfs_attr_node_hasname( * External routines when attribute list size > geo->blksize *========================================================================*/ -/* - * Add a name to a Btree-format attribute list. - * - * This will involve walking down the Btree, and may involve splitting - * leaf nodes and even splitting intermediate nodes up to and including - * the root node (a special case of an intermediate node). - * - * "Remote" attribute values confuse the issue and atomic rename operations - * add a whole extra layer of confusion on top of that. - */ STATIC int -xfs_attr_node_addname( - struct xfs_da_args *args) +xfs_attr_node_addname_find_attr( + struct xfs_da_args *args, + struct xfs_da_state **state) { - struct xfs_da_state *state; - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int retval, error; - - trace_xfs_attr_node_addname(args); + int retval; /* - * Fill in bucket of arguments/results/context to carry around. - */ - dp = args->dp; -restart: - /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - 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); @@ -943,6 +933,38 @@ xfs_attr_node_addname( args->rmtvaluelen = 0; } + return 0; +error: + if (*state) + xfs_da_state_free(*state); + return retval; +} + +/* + * Add a name to a Btree-format attribute list. + * + * This will involve walking down the Btree, and may involve splitting + * leaf nodes and even splitting intermediate nodes up to and including + * the root node (a special case of an intermediate node). + * + * "Remote" attribute values confuse the issue and atomic rename operations + * add a whole extra layer of confusion on top of that. + */ +STATIC int +xfs_attr_node_addname( + struct xfs_da_args *args, + struct xfs_da_state *state) +{ + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + int retval, error; + + trace_xfs_attr_node_addname(args); + + dp = args->dp; + blk = &state->path.blk[state->path.active-1]; + ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); + retval = xfs_attr3_leaf_add(blk->bp, state->args); if (retval == -ENOSPC) { if (state->path.active == 1) { @@ -968,7 +990,7 @@ xfs_attr_node_addname( if (error) goto out; - goto restart; + return -EAGAIN; } /* From patchwork Fri Mar 26 00:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165383 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 85230C433E9 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6921461A0F for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbhCZAdh (ORCPT ); Thu, 25 Mar 2021 20:33:37 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57580 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbhCZAdZ (ORCPT ); Thu, 25 Mar 2021 20:33:25 -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 12Q0OJ9J057396 for ; Fri, 26 Mar 2021 00:33:24 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=9JWfLLMHh9FuUy7F/QPdDZSUMvXZ8qkkmQeUODCuZ0Y=; b=eJKpS597dLqVWdAib0rdorj6k6J6kOoaEI44V5PCGSnaNOnsYhucrho85FGjk4fCUfT9 LiLLpZBTuYoqcQdNV/jXUBcPGQkhfgAwIox/hS2vv7vepXJw+pSiia7J8xNOGYVqjPNn SvbolxnhY7WHCiNFWFrnjVUXEF42BWdlwdenqwC9unIF+jli+PLpzIbtb7EfwqocxSsw WFPs/mrYqWZ8anxDVtSDAcz1oTxPxjxFEUxp/yaM+3zLe9AKCxf1kUSO7joDaxJkYaGA Bxt2iS4ofcwajlJF8BIHzFy6Hd8zUXnHqycaFsYPBZLgbdwHwFDOSNzSTiyL8baO3wMw NA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 37h13e8h64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:24 +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 12Q0PYwL096811 for ; Fri, 26 Mar 2021 00:33:23 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3030.oracle.com with ESMTP id 37h140qtxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RbORL7tP4T0phuv02m3N9uzejTzyvWVSa7IRzqD+CVeLYdANgu/tu6ReCW9Ba/EG9QR6hIXnWxB0xuyMVuDEkzg6Vj7d9BQouPANYiGe5uamnfTeWjFT91ONWTLLzElN93ouyElZDn+7wGDbpe5tZEapyWB4OOYlxd5c7mLqxseKo5fZCJcajfCoXEZHW02SIOg3F7mbZW9fEajlzUX4zHPgVhU0AXCqWRzZG/HyBOqClqfg7eC+5kMTPtK2ynfbOpjrmvFFPI5gJUZLjPfXzK3Ct8F/COOIimvuHhpHKpzrzeU1NRBQdFckjuhl1bUhkSYYV2lRxxRX/JJVuJ7/YA== 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=9JWfLLMHh9FuUy7F/QPdDZSUMvXZ8qkkmQeUODCuZ0Y=; b=iuEU4aJDz9h/4N1h6p/S/ICcvx5vwBL5qY7ldvfbL/mnipFskcuALXWoIg8YEjWp9iry4Oh7aMshKDVPHbzRHvofX+IlU3DckKXNQ8Yn+3kdcPvn6B6ssv6GLBnS2Es8iQpw9wEtix6h+wEktKAjRoFC4i6uMcoD/IKRfmyqTZ7Lv/64W9OeamAI4FDpm50mMj5BrRdEkoH8/FvgXLLw6vvvklZEpcn2YEM9WDg+7+2SRb7QcZZSsgO4vnz24h8zRZcw1Skt/wpHOxtLbc0FEDFh7qZTcRLjyKLbHh+CK+u+8uHb3s8J999YpKJrcZGHzQymuwaYs8EFaHcTn2yFWw== 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=9JWfLLMHh9FuUy7F/QPdDZSUMvXZ8qkkmQeUODCuZ0Y=; b=HcSY2Ll/8HbxoXmy3x81rvBpuGBZtmleGQgxFj+IjTTKxQdsZArqBXNdJv2Bf5yayBVg7McmDnleff9OgFG57zXwYCpwYPgeTYpXQEI4LYLUEgYgv2/+n1WHc74NFg7HV3LxAur9bCqPDd3hx9U9oBOqn3GiYgAkthvZbjTAbNk= 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 BYAPR10MB2645.namprd10.prod.outlook.com (2603:10b6:a02:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:33:21 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:21 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 07/11] xfs: Hoist xfs_attr_node_addname Date: Thu, 25 Mar 2021 17:33:04 -0700 Message-Id: <20210326003308.32753-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25109b17-a098-4f03-796e-08d8efeec270 X-MS-TrafficTypeDiagnostic: BYAPR10MB2645: 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: dr+0XcgvTDtqu9p4QE7xGUE8Gw5s31CMsxqEsM1gD9TinqU40VN7Px8MRFvNlpBzTQAYiMyf47BueVrs+CZqVVV5uRIKQu4A+cKcc6rxEHQXMwObgqVsPX1O+i2jT7T/94Qc6ht4/thFg6C89aguJmnszH1MMZEQ4Qq/EOHhSxjSF9s/WVLzrsuI946tymhV7DslZJY8CHj0f0/mShz0301DZYGPFZ6NrApp69Qvfo7i5CMd5kEWo9vU2yD2RZp53QHkCRLxYpkxlWcAt4IMlvYriFoMZ2keWdxjhepgvf9KETYFfBIBYTJxSdcRMSaxsByQTcNYEDicufpXGl7e/MCzN4P1kM3PJMf+iqVggRyjrJQmAxnI5mjpimRp0JWhQe03SJ6HdKFXTNTlS7mbHPHeDVZBn/gcnU+TS3BnGc+oQZtd/vERF9G3qZeU5lh8mglcpAL7SAdtxU90tAiDwNbvb1Frr/+PO2gabAieHw6t3HZtsnqGoH0wADGpOudXrQcePmexH3CGzMUJHXEMb/nsSypD8mrZGNFEHmyYBCknA3L9pbOmC6jbxvDn2TynIShQUxnVH6MZ/LS7Yma5OhHkrC6C5xVy9AdoHK+6uTz2NB+yn7NSWA3acSmd7t58I/uZcr/PnvwgJQ9GmlA+ZjUtQ1LfuZg97EI/SgDxWbsD7SOi9U3aAzp++nfvbATi 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:(346002)(376002)(366004)(396003)(136003)(39860400002)(66476007)(478600001)(6666004)(8936002)(66946007)(86362001)(8676002)(1076003)(6916009)(66556008)(52116002)(5660300002)(2906002)(956004)(6486002)(83380400001)(26005)(6506007)(186003)(2616005)(16526019)(38100700001)(316002)(6512007)(36756003)(44832011)(69590400012);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EY2VApNb+CTN4XKeJpGWn75AE1Dg9q4uqhZ21YDDrVw6wkLeOkJoaMh/wzKmtlkkwF0KA2n4YkCYLN0L0NVLQuA4fld7IL6cOxt4iHx1rQ1HlJBd1qZ+/UgIO0yiIuUFDWa6KZuIpBKv21JdxL8M+SIasF4qu/2PJU9cGwXp6aXk8ZRelfnbFEcoAka24YQ1XOlfD1vUMGmZOCrYoDuSpJ970Sbg8F4Z+dbDqQTm/GeSz6SOCS2aRhqrqco6d+P4ZpygbpZVKZvXrK55EsLtTlecfcQ33nnXNwAfwxHB7Ah4Ic1c+xERAyIrduPeBLpdW+4SPeo14HEk5UEq2PVfuHkwpdhWuddF+bhQlVZXY+u/0T/Gg9kwCXOPpCxd8L9DiijOvS+9RbMultZwT8W4+rhZxb91iKW2z0RQ46sFRaClTc+8vHfoILUFlp5eoQZE5h1BbIQnEpKUnTC0ctbks7cNMOeBGvVietqiY6SWJHIDqGuiG338gtKH3Ve55k1kJbJo21ABQrp4fVocpW1yLyvkLmHRvFTFg/syaSx5QLeC3BqE/6qiKXfQMWUoA45mpRnY3Z1MffcjtW+j9Zp2zUBU1MuA2fRiAIY96vhKZk4ixxJa9d42ij9e381qv4fv2fC1KLcsFlmrZ36f1s1KGWbzPtI+9Rv8viJom67cCdt/f5NWW0u2XsqcRyudf8xl4fYY1kIgb8f+r1qWMnRay8LzeZpiO4e02ikiQQ6q29ucLWTlhDqWcVzbmSE6crUkERpTJlrRGaWarPeNmR8dcLxggYlmVNsVB8RBFeundlLTnchSkgGIeP57x3ZTHWVI0+SrIc2YcsRyL8c10Zb7x++0miEd1ZUC9Q9gqo9HGiO9txz2l0HfJLlsV6Jf3G1Gjla1rPdaxyIcER/M+CjHqiAYMtijKCKXEQvlTv7dFG5KbVlXWb2ezaMVOnsbIP3ppThC6pF0ZDpEAk91VwWWbCxCI8sydYQ/pAtIgPtlccWusJGqw5LgnqwM0gisGXJJ7/KujJl92uHTgKy81GFvBDACcEvaXxbHW54hqZ9YTa2EkJQor/88zlVhP2JY6U37Ks0bRjMYN3i0Ra3+knhQoK8bbqKi1ncSwt+qU5Ib/tW+csHyrxk02DRC/ukfOEmF5DX/ohEC1Pij0+4RKvdzyvzFbZCaAHmfXA5t5r7fIA4RejQzV7x9uDkU+VeRPWtu0LjlsaBWkFABDe9oo36LZX5t++Fws5BLPBzdNEDwZk4R+mG62uWLuDwvh6/jQ2f70KHpLYWgPgaDGFT8hJseuK8+NSA2kKniusyT07PGxf4inE5aE4ORNggybNLBoFiD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25109b17-a098-4f03-796e-08d8efeec270 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:21.7734 (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: hv9crwFlsZGB+wHpvscoBzD+krHglYRaEXWEVcEvwxDNYSU4PCh4nkZyJU0DFf707DIS8F1l4UF9mA8LBA26Ave/KISRqY45f6y4qX6nz0k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2645 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-ORIG-GUID: SuWO7oeZE6zVMrDJoFCWs-ECUJv_8Lc2 X-Proofpoint-GUID: SuWO7oeZE6zVMrDJoFCWs-ECUJv_8Lc2 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 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 --- fs/xfs/libxfs/xfs_attr.c | 161 +++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 83 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 16159f6..5b5410f 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -52,6 +52,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); +STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, @@ -270,8 +271,8 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_da_state *state; - int error; + struct xfs_da_state *state = NULL; + int error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -322,8 +323,79 @@ 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: + if (state) + xfs_da_state_free(state); return error; + } /* @@ -957,7 +1029,7 @@ xfs_attr_node_addname( { struct xfs_da_state_blk *blk; struct xfs_inode *dp; - int retval, error; + int error; trace_xfs_attr_node_addname(args); @@ -965,8 +1037,8 @@ xfs_attr_node_addname( blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_add(blk->bp, state->args); - if (retval == -ENOSPC) { + error = xfs_attr3_leaf_add(blk->bp, state->args); + if (error == -ENOSPC) { if (state->path.active == 1) { /* * Its really a single leaf node, but it had @@ -1012,85 +1084,8 @@ xfs_attr_node_addname( xfs_da3_fixhashpath(state, &state->path); } - /* - * Kill the state structure, we're done with it and need to - * allow the buffers to come back later. - */ - xfs_da_state_free(state); - state = NULL; - - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - retval = error; - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - error = xfs_attr_node_addname_clear_incomplete(args); out: - if (state) - xfs_da_state_free(state); - if (error) - return error; - return retval; + return error; } From patchwork Fri Mar 26 00:33:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165377 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 60C76C433E2 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DC3761A44 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbhCZAdh (ORCPT ); Thu, 25 Mar 2021 20:33:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58844 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbhCZAdZ (ORCPT ); Thu, 25 Mar 2021 20:33:25 -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 12Q0NrUY110904 for ; Fri, 26 Mar 2021 00:33:24 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=WLqVEIn+affmeKWJT39nHlvfz2asjXUnkmIDJn22heE=; b=UjojKSIvsW/FLZsyh57W+3rjl/50w5AIVWlzU9JgKU3cHBhy/FZhUMWHzpKRXQmuksLC b4tI/H4eBTrJwqFqldo+4o9FR4GJHXYPog+H1FuzmdyX8djAlsvpgVLeHYRSa9P1JR69 Iwf9/u7oWKcxX7H8NcYHBV4X4rUPqWNobLhI2wuEQZ0brTHZRCYCVgeIQAXUjlS505WN ZRkvGkkYJwomboP6Rr4IOPrrTa2SttlY1GBSXxcIpNrNcCqowov4gwW+ZOWRIMaXlGSB OCukSwAocFYJiFpmmT/Tjc2pbrDq0JBEvt4e9BgvJjJHG5xtHab29JrMtrc5bk4Kq8ln lw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 37h1420h8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:24 +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 12Q0PYwM096811 for ; Fri, 26 Mar 2021 00:33:24 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3030.oracle.com with ESMTP id 37h140qtxx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gVlaSE7VdR3RAgreZE/J9DVAYvXh99HHy38mRQ0rZdhh+7BhFUSpsCCt8sC7MIHS1hiGe3Bv+bCnmJKkg+kItC4sD8TBXiSEuZB6T/LFxzwORCpSoi3+Ic594KjMcqhQPYMVZNcaEKmMMYQNYVrnu+kFrqo0Fn02MZEQlWvJKHvSd80WyawoOMasSimX7heUw9pQGWfP7mEWaDau3NBwLMxsb/9u2PV7ZfM3CaYlahRO1h4P9GueIwNZC9cCs55ojSUrKXztBZX+oPmoxQQ3wiza4FFYJ2PenXC/tzijxmTDYg5dcjTJGGUJDK6kMYi4pzR1ACKHi4lZ8WmFM9ezCg== 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=WLqVEIn+affmeKWJT39nHlvfz2asjXUnkmIDJn22heE=; b=ema5X4AmW+3CYX8swn0HAUAtKCyfWThELTIF/egnn64ifSr6DAXIg0zl5W+u3FF2Xsas9RqHVjTY45yuYyj4BqgDAsGh3abZ5SygbcJOFCyfyO1/eXyLUvz6Wj+Kkb9Tf1UwNiXe7lyewBebRy0/fG3ljmwYuL75L4PTQ1mIMTMoAjd/mZtcEfHutzv1N03TFUQ/GTwNGdqGRL8iU8aEHrwhGFJ1hXcNOMjLvDNqrECkDwrz0d3yWgXlsgX/mU0iE/ZEv13+p0ZFEuTSlbiD9zBpCH9MTtiDuN0aOxWvsM7sywkIMxCaD7UYq/ZfsLDFPamw7rdqaKJTBuvik2a4cA== 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=WLqVEIn+affmeKWJT39nHlvfz2asjXUnkmIDJn22heE=; b=S0SYjPj80QlA8jTo9THViQIX5vCnmXtqK7CzDJ7CbkBmXNXUg7pe1h+yCLl5FPVwcXhVMxnu5G6bz391IFkljI58IxEHuH4oTyA50bFz24aSFasJYSdT3zSUXAblYSD15/TKD3wF/NxeWauUZDMJdUfkYfMHozqVk6w0K6f4W54= 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 BYAPR10MB2645.namprd10.prod.outlook.com (2603:10b6:a02:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:33:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:22 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 08/11] xfs: Hoist xfs_attr_leaf_addname Date: Thu, 25 Mar 2021 17:33:05 -0700 Message-Id: <20210326003308.32753-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63301d5c-0044-4319-d2e8-08d8efeec2a3 X-MS-TrafficTypeDiagnostic: BYAPR10MB2645: 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: HpPBqS/mEaxicaXdYrP7qx/GNxw4f/OaFDcmsAgyDHhCMEYvKxgNMJoz3a+LrXMOsB3M28sVivoGGd0eJJBDFYg4IAqjV2jsPxz3K6/LnE7C36XZTd+Kfgdt5kjiqp+MV9zJzc2hrmCFCsAm+0HK6x8C776MG53NqWd7VjR189tmts6i8OUMZ8Rzd17zt+zaMtsIgqZ372kfJn7IP48w5SmMPZb2SpjzU9Wp/3CPuU7KtNRVJPPTPE/skc9TM6h9FGXC8fd41pySISACnvgJVXNFKlU38caSo71darz6iq0K8mwtMOsNoryy+Hp+Wzkr9yJ6haqWONYGrgdw/0bA2owLyn+kagvu37GE1hfAmF6xLa+JrNINZ4nfhqZ3hAfExtXPfU6nnh2psrrI+k4MelEzLRnAz93D71pbvxexHSLumf/JUcGdK2G/CE/7u5CFFZStO8U6+pb07FhxUbKhB3MCvX+8kNzlqQZ0okCEuKDodyIDQe4LcxBm760G7kYuXgsoQKEVG+ttIPl/f+Vs0BtB3H7poAWQH901RBlPaITidBBxV17gLirfCtIjXKylJ3NsBTffpJKT/5ysCTRepqoedXqCbAsPe9cfBftBr52L83PLi5dUtkOX05AI17LWeaKBJfnszBnQ25DJ7XLIky6H3O6MiJoEFwfaKWgp9cE= 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:(346002)(376002)(366004)(396003)(136003)(39860400002)(66476007)(478600001)(6666004)(8936002)(66946007)(86362001)(8676002)(1076003)(6916009)(66556008)(52116002)(5660300002)(2906002)(956004)(6486002)(83380400001)(26005)(6506007)(186003)(2616005)(16526019)(38100700001)(316002)(6512007)(36756003)(44832011)(69590400012);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 5u30lKXZeHRDH0mHItuwdJJWSTIUYllsCwq2REfzhQYewbuBL3LOKEBF9pbOngIqOuLDaNWgbeKHfGdHhf4goValRJ8Avw6e1ZqFuqkwEsHzVo66OuIieIi7IYHyRSANxzb2vGxDrOddAVUoPS3O6GLQH+ijX7xm0RzDH7iN36uQ2f3ubBnOPHGgpIvixGe4Iw9t6hh9FIV/J20icd+tkF7GONRhuTOof0KNdNdbWxEDbWI/xn4tKzRArXLX3IiUrBju2+eZvyNy9aO6TH3JWGfTXaDC2HE6r1QL/24y444Ha8/wPRI4Jf1AgMWZbKW7FvQmcnCkOs7ExUHVw4VKD6w95AJ/wjpU/IfjgxWhQjTQXQjCOM+H3CG4790sphGqf3PIGvO18xolErTFPJrSA30Zx181Dd1Mvvtvj8pRpPT4nt92mSPui2lP3EBmzY5qtaz/01EjSGzj5OQg0VJm0SiyruEeHD1xsIF9qPs4oSGXiWlzQcOaliTXEUHuzqeHK29ihwR6jDFAZMFGf1JvmQbk9RXfrstBaGf1XPb/q0jwijkuQmGXOCw4w7wPnagjIZJpWIsT9e68JsGtQf8CWRAkWqlXcH3mVALPivcFjd4lxVOYCE2+z+FezhWi2voVDfWxk+qjGKSdRD70a4CLvFyda5PnP71vCnumL00O+bEJiPCr6yztCkpAxkJ41SqaV0v14IV7+OzYfD5N1EgtBbBat4B7GD8gF43WTA2Z77wJIUPTd0HrZ1oCLJ07hJgBoDDMmL2HmErZCG9tWT+1O2TM+AB+Mqx42GIVdP2acm3T6Ppm0alzOnURmeVDNEjO8tO8hkblZrKTM+uFDDhcffkx7tJJIWjNTXWpXSZJ83AfaeKFgsqlxjb2tkL9DUlDbzzadF6mbwG5biBiO9qENtM2FjuDlAh01XxnbZuJ1hOtth0gLAK+m8kTaKl7JB5McVPqU6wRWLx/Xa5PqWQLxAL42xozygJpdGToRjdpT6qOPuyDEhO3pZr5OSFX9P0ujm2LJGBPz6CRJ2CZFB79b/EVQLV6Bmb+GuI0fQGvQxQt/QKzRi2KNt6nqqYIMklmNE0ODZiqpvJwq9Ue08h0v2F79uQxTpKNOIrdOph99KlNmmENGArxAZ6hSyL0oEwAcKXZ4vDzxbCwXYd7Thryt1ordCbar0+pYbMwlVgbI9A3h4MWqMhktti5KYkEUdErHqv+QWIxC3Nm8TQowaoiaNHXlTnhwwss4S+5X2qJy7kfRB3NT4pLmpmCM0B/ZIrnr6Na+AcdeTM9MdWXknxv2bHPW6mn3kwJdQjrjjT3FmXZQmfQaW7O4aZha/lGrfSH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63301d5c-0044-4319-d2e8-08d8efeec2a3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:22.0851 (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: xh0D9iLcSaC99KVI8yOSGcdFRQsVjYmOTtdLOlYE6mjByY60QPToVPUlzwdL0ZgFmtT58qmlwpcSulXHDKoYWNIi9xk8JIaZGR4IHZZg3x0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2645 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: -hjTITV9awgTw39nOPLcWnPWcHbS2Ccs X-Proofpoint-ORIG-GUID: -hjTITV9awgTw39nOPLcWnPWcHbS2Ccs X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 clxscore=1015 impostorscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 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 particuarly 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 --- fs/xfs/libxfs/xfs_attr.c | 209 ++++++++++++++++++++++------------------------- 1 file changed, 96 insertions(+), 113 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 5b5410f..16f10ac 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -44,9 +44,9 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); * Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); /* * Internal routines when attribute list is more than one block. @@ -271,8 +271,9 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; struct xfs_da_state *state = NULL; - int error = 0; + int forkoff, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -287,10 +288,101 @@ xfs_attr_set_args( } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) + error = xfs_attr_leaf_try_add(args, bp); + if (error == -ENOSPC) + goto node; + else if (error) + return error; + + /* + * Commit the transaction that added the attr name so that + * later routines can manage their own transactions. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + *flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + return error; + + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + /* + * Read in the block containing the "old" attr, then remove the + * "old" attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + &bp); + if (error) return error; + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + + return error; +node: /* * Promote the attribute list to the Btree format. */ @@ -729,115 +821,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 */ From patchwork Fri Mar 26 00:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165385 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 7CAC4C433E5 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5627A61A4D for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbhCZAdi (ORCPT ); Thu, 25 Mar 2021 20:33:38 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39322 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbhCZAdZ (ORCPT ); Thu, 25 Mar 2021 20:33:25 -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 12Q0WvAp085232 for ; Fri, 26 Mar 2021 00:33:25 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=/HitteRPM3O4J4gvlLmuX7017jzcJOxv/oWnXRw1yqU=; b=T0Gv8S440eOEHsCMzlfV75hq1XKv6LGx02LMhOz/DIgUeJ7/MrBhnE0sIFPuRe/Mw1UU WQzeQbT0NiHlRn6vsx/3/06KJRNTOAaZuQhS1loqic4HgTb22TIAPgZa0YZSXUWPXBGq sSs+xIGVeLLVwBjojbdWRBhNzMFA3w8CV/7ewR2DRI6XcpVq3LSXPVLIsvZsSXlx/7Ze GrRVOqgEuLIVCyNJlW8aVwdbErC6b4A4KYoviAGMgCHIAJiDJUmj+ylBZUuJ+4t6LYsQ qZBSnH80LE1lalkJCsulNtL8p/LqC4PDt8dNPG8ucRDGL+KKyeRjwQNblGBZ4MKB7EGK XQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 37h13hrh7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:25 +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 12Q0PYwN096811 for ; Fri, 26 Mar 2021 00:33:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3030.oracle.com with ESMTP id 37h140qtxx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dekrjA0W2I/HMF9hOGIOSIUyf42CimeEjea8I2tqRg1yjouvTyjl195J3cgfytk16WHWIzR7AT8l+6ZsX+dEUqdCI/3OMseJAGYn4Pjt6lPbrTrHjYu0TaQuVqlvjkfFfi/ShsfTGxPk9Duxolnjd7zj4jpBfALTfKaURgMgTsn0+mykudW8ztwWcQB1aLXkh79QijCTBTzAc/hLhpVpj/h4QReT22YuS/aeOwdASDQnzouJtEVXgsmYwgQgacNZwyKAKsEPRnsOSJYEOSEAAtBe4jwcKgNPmOYM2OggNhbWD0zo5cR3d1OaGrPIfo/PieyywfqIzW1ZQajF+DjpvQ== 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=/HitteRPM3O4J4gvlLmuX7017jzcJOxv/oWnXRw1yqU=; b=PeV0tzpA+6w5bD1igeUBOlXLcdcPv7r1ceQc3SvA84/Da1DdZBqy58VLkqyQqd0vfk11hI2foz06Y6l5UpTR2DtW50Bs6XVzYEAIgmNgjTuY3tgQluN0BrtBeB0ANfFmpQFjQotkX3kbK94g3ouT97D06xlkjGAmLNJgpeQXnEisVN5Dm0gNwZx6BMvR+PKLYAHzwfWTQpGwGS2VosgteWsvDAy2kRwKCl9FDVGLO5Qchz1+3tn4LDkTgAcpKOjNpOyoAGbq1jJ/LdLW4t4Iv4inH07F8C1FJpPjadQqbmyFuhAHa910a7IL+VUPE+RTPd90wZXgV87rVm5cKu+EfA== 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=/HitteRPM3O4J4gvlLmuX7017jzcJOxv/oWnXRw1yqU=; b=IrqOmbERrUNjHyKaiU4g03bir5miq9GCyXfnsokapozFcWwvS4a5FeYwlHouaraYckymAbXcE2iK/qpE161z9K4bZQ/ve0EEJOk4ZvImIm3W+nUCbivCmL3n8uRK23uYNugQ9bSY18OXY/PgY4SMQ1xEU8qNWNTf/v1iju7M9m4= 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 BYAPR10MB2645.namprd10.prod.outlook.com (2603:10b6:a02:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:33:22 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:22 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 09/11] xfs: Hoist node transaction handling Date: Thu, 25 Mar 2021 17:33:06 -0700 Message-Id: <20210326003308.32753-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7332fa18-1085-48d7-c17d-08d8efeec2d9 X-MS-TrafficTypeDiagnostic: BYAPR10MB2645: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9AlV2+vezzadu3feBl33xRaWSdFK5QK/GQ+u7IP+6Q8Gmb0SUvSZPa0Ffxzc6j6sF7xTaicO8RS1XiISx7Io9vF2okeabDSqlhqrl7+mJVa+Of1qkrkpeqCOagIOmvP/YZAD4VmScYrHgJxl7qGQSN4FmiKN4oqFaFJwpMOx038BeMNJASMAUAp4BDFxpxrYEpHIgL0GWjA6DgO6/Y/2PkOweI5sLL+ogCq8fI45hAGJuZehWZDOgck54Wisj9L8V00WgyE8W5G/VUKkQZ5qRsvN60wF3YfFGmWy+zCf9n17N2+EB6AkQv/nClpqNTdieNCR1b5i+YQLLYPusI9TodZfpl2ooau371QgcutBoQMsAlwbiDSFJAMdUTgPAj+LJA1/uOcP9v6AkOXr6l2uR/dQvGguwzQxyh+FlmFPHlPnasylb9ShBXMxRTqAE9BYVuSF18o7Kmf5ow42Noq4yY9Y2TN8LHqyCcFuZTNqsSEbt9SVLsjVGFyOz8IO68bhyqVLMaOa9Jn+rOZNBgKWF9rBFSdGlgC5lyswwFAGothctvCtDKkgex59p534jyI/+0Qhy61VN7CabeLEVaaC4RQ0Iist2jt25LKbar1o4BJgjKru6R33EI3+0KsuVntupAzKyrRFD355d0AYw9cRc6hHqoAPFr2DzOPnlASj9bIJG8H8sCwZ9qK3/PMRwehM 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:(346002)(376002)(366004)(396003)(136003)(39860400002)(66476007)(478600001)(6666004)(8936002)(66946007)(86362001)(8676002)(1076003)(6916009)(66556008)(52116002)(5660300002)(2906002)(956004)(6486002)(83380400001)(26005)(6506007)(186003)(2616005)(16526019)(38100700001)(316002)(6512007)(36756003)(44832011)(69590400012);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qm6sci4CR+wMuaT6gqFv5wG9fLl8YoQ05HM/KSw82DaUbks0vCMVv3mHDTqFkU3d9lkSkep3GjR+NlTNC3sRZxqKtzPZoVOeOR1WTGGhAiU0W3jqN5PhX7MSNtaYlec6iP83BclAtwnHUrnlZQbLDG09tuSXHsXm4C7j266MZCwWXnZiIlojWUeu+jjnbaZGpEJxBXnRBpijWu4CXlzWPBjhGcY/uT/113fYfyQfEOGXMjneTH4lc/Z89WlyeJsWqbzBHhjWV/EB3tL2KynK8BRgYpP7VP9wMYO+ZfKeZ+lUuoMPKRDKt94tAOZC+ABCh/UqcI/sSsIkez/ZVgsXIqP6MVGgrMznU4JCWldyUksCpHx/7dYg6U1x1/GTLyiq8PApoIr9CpUhm1MtU683Ek8bBgXfOgUwXkmJeqBHsUImaO0IlsBtR+5jHJbd3gCYuRl+XPb+pBpZCv03zJR+RTxoxm4grWxNn2HmjvyGoz864kwTU+3ai0uOp9e5vhddOcZ9EFg7+pTqs8KleHdGlnRGJSnQlHNnQAbeXzVTvowkv1OnEWqNMFGyW4mmVdYoPMErjq5C5LwKCoX+rJtYcAwEfsevUbdXmzMF3S++j++j9+xUUvobNak4LMlbD71LLJhgcNB0ZJsOnmPkU/AoRePbl8/PCUPZXXU5+7lkqBpFXNAZ0FbImFPfrjp7O+bK7u/K/R2EpC2xBI9A8OiIi0edfXJiFespT4Q7kzc8OSpcnlIb93wyegEVpXS/ZQVuL2Wg2eudhEZthubk/h1eF3KGv7NzKB6gmkQYmLDLS2AcFVcoppNO+ZeDFx5++EUcr9L5dX13mg9oio0k4ZZtr/LIc0QbfSmTHjuWZwYIy0vEkV0D929YyQXXcqz2EKmh+Slz/AH9P8jiwwS48x/hrW4Smcuf+pLklsBZXBPoWkZkkelRJeyHHPZq9oZSxbmlFAGKK9PosGf5lmrEp8mK/X93Z505JNnp4rRgYqnwRH8adQ8q8PjzoVx1zxGtryxDjdPaHiyxW2xnwbV+CQMDIuBjywR75PE/V3Vr0qQkfG7Fb6MBBg6VTaZ56/xijm03ZeHWFMjmQG3kVYp/mFIOc6OcIyapWapIBBIA5ImWArX4ovBuAb7z21cAbLtXkEcBFtBD4snCKaHfgNTNmKIh8xPjHnj4a0/5IUbxTRzwNTaXqgRx4NGLCm/3IKzcpzPqd2tm6kNsHyjk7YCGIQ56sWQSrsWM63zn6W13fJIlEuJqjFndRe9pT8p2GGb11F3WntyUBJ5MZTyyGeRHFK6ktdA/8C+3hzKLTRGuxOGs5+0UyI0B1RyTSRSnzXYTIttz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7332fa18-1085-48d7-c17d-08d8efeec2d9 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:22.4604 (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: CY7oY5AaU80kO6MHcLEhpnaMySbhDC68HaX3jYWKjjFtdt5Mjnn13MWN1XBb+46cjwx6T34Zc98ijc4UeSC++crUzDL92pcx/y8/Z+sBtoM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2645 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: aGM_l_w5QSkHS33HJaNX3CcE6at4z4Zg X-Proofpoint-ORIG-GUID: aGM_l_w5QSkHS33HJaNX3CcE6at4z4Zg X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 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 | 56 ++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 16f10ac..41accd5 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -289,10 +289,37 @@ xfs_attr_set_args( if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the transaction once + * more. The goal here is to call node_addname with the inode + * and transaction in the same state (inode locked and joined, + * transaction clean) no matter how we got to this step. + */ + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + /* + * Commit the current trans (including the inode) and + * start a new one. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + goto node; - else if (error) + } + else if (error) { return error; + } /* * Commit the transaction that added the attr name so that @@ -382,32 +409,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 Mar 26 00:33:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165389 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 A863AC433EA for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F09561A02 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbhCZAdi (ORCPT ); Thu, 25 Mar 2021 20:33:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57594 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhCZAd1 (ORCPT ); Thu, 25 Mar 2021 20:33:27 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12Q0OKGE057415 for ; Fri, 26 Mar 2021 00:33:26 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=uczZZz8BvF444cNr9e2bmQ6SMxE6GYfpsbKl5VNKZo4=; b=rZxV6aaen6ckRPUBHNtGkCNHPj/IM5B9nsVkZCa/+joEf5uyH8mNoJ6ME4XZoUlFLuW4 KgnhJL/pyO6Hh9Q3o0AONb0RRr6na80RRbP0ejcnPg1Pao9p1bvslOWylYZYw6ZaJezI stKGfepwrJQUPB3o1l0LKA4Woxk7J9YbzGCcbg3S3bTlhF5e2Qng5YcYkOTiyQGOL8VB ZE/3n2XoxcqPcgdqk4cqITv418nL1uwdnmfAO/gE39T9FY9j+cKJCpLRi/DU/Cyphp1x QT4SZ4m1hfP3n/TqE862nzai3rgw8kHFKcqFPcgFVqZqSoZCxJFiwcZS4BVsbxi1CqR6 AQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 37h13e8h67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:26 +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 12Q0PYwO096811 for ; Fri, 26 Mar 2021 00:33:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3030.oracle.com with ESMTP id 37h140qtxx-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XbPFTnfmUVGScYzaXwNHMSP0admFsCN05eDBrsjgNWAOsZ1Ik5nqDI3Zo4Ifrg2nvDFzReT5wDHuQuNByzQvqwe8UV7jD1dAWeMteqoq0y/eSDC11lphSeZ8BZH5DGLy+QIfpZtZlU+t/uv8oIDAsKcfuYipTlyDGU0kuK4LMQZeBaYIrwgGYSHqUPL4DrQ9P3aDbTeGgCaQi6aj6HP0try/bCBW749EhJzyfnWMIlvPZOeHoclqi0qARzDsML/BYN7QqQLLxT0nOBsWQ+ogFfmRc4vwStc83KCNjUrQJCkYmxO1zRg1loUiX4Z8seA1YHkYtsCBfZYq4f9K9GsBwA== 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=uczZZz8BvF444cNr9e2bmQ6SMxE6GYfpsbKl5VNKZo4=; b=cnuwd5t085MTV0cLQthwzI/EvPTRX57vFmLYTbDyAWGkcHdyirx7CUyfCGwPXrswASu1uVLy7QtIFkhuKCbjnjXZ9wdKxFI/xydbZJsDLaF+jW3cCFNqVYvo6Eh9VLvcIb9VpqydqRdzJOInDD+/v9sTBg3NptdQ/y/eurT9k+taLnS+lvVF/r6CX6KtevBN2EwQsMvrv1L9ZYticUuoYO6ShmdDMr5tSFG0xFn8sjwKDRhbdA5/mZnHKcrJ+Xb587lVNcuw+G/l5n/iKP0DGiuO3eGnoJaQoPTXCTyqoGs7UllKZAYptd42RWIpzqST0T4L92u7TMx/1o5q5Zz6jA== 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=uczZZz8BvF444cNr9e2bmQ6SMxE6GYfpsbKl5VNKZo4=; b=dyte6ewDXaZ3i1FQeT+s5OHqqAGqeTPtBL/FXb0c0WxCwHKq2KIxnMHurLi1U+pu2jYHoWVOEyyGOyyxuZZNqrs5KAvYj7Hr4rccLbO/O3tW6cshkjlwA9YCV0HrNI0YZ6PzCy10mI8CDRT/2MOO6RmaUoa3tOxQStvZtE/ofeA= 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 BYAPR10MB2645.namprd10.prod.outlook.com (2603:10b6:a02:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:33:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 10/11] xfs: Add delay ready attr remove routines Date: Thu, 25 Mar 2021 17:33:07 -0700 Message-Id: <20210326003308.32753-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec444a6d-7ce2-43bc-82d7-08d8efeec311 X-MS-TrafficTypeDiagnostic: BYAPR10MB2645: 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: GsvRbP7nnoDBTEyiQ5ZewPgjJOcAXlQvzVXs6a/rk0MQE6j2NfaBBGfKvCkUl2bCKJg92nSwYv7oJ8/0oeiIRs0cPgLmr3uvtG/vCXUNJtjZNZ9JYwdls+eFH37SRIQ7rmseBjM5rr6k4d54GT0N7Xi7IX6AXAATgrTzkMTutp8DE+S5HQXzHEO5e8L1x+3MTSTvKtB1faZ0BVCa23ALSZW251nDUH6Ym0TIbfv+PFcKCpXeDo+5aKhZ8dt165rW8EQ+/WeSLXmy2OXxx166Gz7eFOljVLc32XWU+CFuAdNCAG+E7NWbGW4pUv4bE7NCv7Q3UYCSeWiAt2H/VL9+uTdJsLoAFyxiqEio5foArM42KGU0zFY35KS9j0JZj56Vuz51yDFG2yh2EUcGcMAaTtRMH3m8nP2fiIfytJLMH5UM4yANBVWABBTbMoFpYRDwvMLC+XmSgs9DtD2y1efKNK37peO2418ez/AXsv8NnWS4t/+RpqLf1VIQYbbM8Ut54/r8ab/kOQWf1VkO3mhHuS6LX94m2WYsQTpV/O0GWeVjvZNSiNyZtnCSKI4MuChKRe9Dmq6r2LUAhDaABXoCO2ADGkm/x2VxLbtl4XBJaN93CL9abYxB8tYEvJeeo8QRMu+oIWhB/i6MvVXQjEQ0kQ== 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:(346002)(376002)(366004)(396003)(136003)(39860400002)(66476007)(478600001)(6666004)(8936002)(66946007)(86362001)(8676002)(1076003)(6916009)(66556008)(52116002)(5660300002)(2906002)(956004)(6486002)(83380400001)(26005)(6506007)(30864003)(186003)(2616005)(16526019)(38100700001)(316002)(6512007)(36756003)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YtmaxOtsQnmM2Mnln6U9qnocOXbWZ/v9wyAQB4jCZ3h/VOrV6K3sR4SSmG3iPjK8cwlJ03yDSAAaeicNNKJPaDuj+FYVv91bzNrphIXoiQH5SkS+4clZEwdwB86MzFZX3xTljlWiP3P5bR+pQkP02I/VAR/p45RNxEMsH5i8K+NMthja9ZZv6EhClKCGVuX1KvL2YQ5zOdOg+keGjohrGc3K4RJ8RIeib3T1TjXBO/BhguIP/0Vp1PJenzaVwaEFz53rUVqyVkKVTCWLZEXFF3jPso3hrDrU3a80ldrrS0rzZaGp0PBja26GUC013zIH51H1SDjzYs2/a1M9ian/Z4uDEkZU7Iy8gGbP7SR4LkvIBmToxt+Y1FSKgBq/LYKjnQbgtVENdMKZpBt4/ZyBxUGqXavBAFKSPQHYmySvuf5LJmZcGH/Y+LXIPzGRnse4+wlPW8gl3IcuCKA/fym82oxc+Eskwrlm+uwV1L3ZkmnTtkbkbMeLyKt5MtEyyEoYywm6p/4jtePwmEXJcBSVHNVkobuV69yyfNGHGajP9AiUfh86e39ZRxnxECm4rZ/RitHZj7mMHMP1cgeUz5FselJkMAEGOWy9V+G0y4g9GBgci73Yd/5QVsLZda7q/WLUsT8ri16OknSxnRyDFSSv/RBZxmWb+v9QdxJSoZ2/9il08zGumuxLJ9uKPhSIpUSXYrzzsS1XLgUv/hpw4lXycjMtUz59n5Wnzba0+F8jvx3xSkPyucukBwnKdp4xFO5TgVpPEaXBOhcCSLGE+FNG93jaIGstauTRC0rY+R4eedDfyXt1kyWlYrkhbrZbx3o/PKzG2tcmqebDmr2vLDsnzKaZpcEyMsw2DsgPjRVWQJpPRyTZqtWHqGggM/FwuqoSZPigg2AovJftxNzfdXKcuOTgL9AH19BrpIIVauQGPANta8D+zwIZF0UQ+qzpNDyqezXNObTDp1sYv/W9q8SPtQB8yF1fh2Srgc+OHN/M6TZsFPkMdRvX/GDKJEt6b6XoWMNE0nbdvTPUKuBME5Pkm0UCWSCCpM0HQL1iCIpr7T5zxG+R7IWK02S3sRaAjrSsLMVLk8EPklNBljq7zWzwyWtwmWh0oH18o2Wedw9g8gGLRVR537NfLNtomp9wzNuu0ioPqFZzxpTQ3UMJyMXHEcNnZj+l2fRbDR/h/c5SOL8G/IfOM9+mnDNJnbyBmwnB9aQ4y/lOZ0WYkfLNBnZsJ9QdcAMN5y9V7BZPkgZ+VQJXczwLcdHdwrCq4/5JoSA4ZiVAfTGgfHJ8g7KyZc16qHF3v6Wn+0Bnr12TwWYGtlxA1cXoj0Sgfx8Sf5lzJEr4 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec444a6d-7ce2-43bc-82d7-08d8efeec311 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:22.8975 (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: GI5ZyWMF9Weh7VsBxApnqrsYF89P2nDhU25BtIEHPkWuQqMv8x0M/p2n0oIn0DDqaxPCuzwL6B4O45KAlQ9/3ykWnW77wbxpIda38kMInSo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2645 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-ORIG-GUID: tfv9er-V_qs0obUNxo2c_Dcw0IRzU3FY X-Proofpoint-GUID: tfv9er-V_qs0obUNxo2c_Dcw0IRzU3FY X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args is merged with xfs_attr_node_removename become a new function, xfs_attr_remove_iter. This new version uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. A new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A new XFS_DAC_DEFER_FINISH flag is used to finish the transaction where ever the existing code used to. Calls to xfs_attr_rmtval_remove are replaced with the delay ready version __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done. xfs_attr_rmtval_remove itself is still in use by the set routines (used during a rename). For reasons of preserving existing function, we modify xfs_attr_rmtval_remove to call xfs_defer_finish when the flag is set. Similar to how xfs_attr_remove_args does here. Once we transition the set routines to be delay ready, xfs_attr_rmtval_remove is no longer used and will be removed. This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls. See xfs_attr.h for a more detailed diagram of the states. Signed-off-by: Allison Henderson --- fs/xfs/libxfs/xfs_attr.c | 206 +++++++++++++++++++++++++++------------- fs/xfs/libxfs/xfs_attr.h | 125 ++++++++++++++++++++++++ fs/xfs/libxfs/xfs_attr_leaf.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 48 ++++++---- fs/xfs/libxfs/xfs_attr_remote.h | 2 +- fs/xfs/xfs_attr_inactive.c | 2 +- 6 files changed, 297 insertions(+), 88 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 41accd5..4a73691 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -57,7 +57,6 @@ STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, struct xfs_da_state **state); -STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); @@ -221,6 +220,32 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +/* + * Checks to see if a delayed attribute transaction should be rolled. If so, + * also checks for a defer finish. Transaction is finished and rolled as + * needed, and returns true of false if the delayed operation should continue. + */ +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) @@ -530,21 +555,23 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - struct xfs_inode *dp = args->dp; - int error; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; - if (!xfs_inode_hasattr(dp)) { - error = -ENOATTR; - } else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { - ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); - error = xfs_attr_shortform_remove(args); - } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_removename(args); - } else { - error = xfs_attr_node_removename(args); - } + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + } while (true); return error; } @@ -1188,14 +1215,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 == @@ -1204,10 +1233,13 @@ int xfs_attr_node_removename_setup( if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) - return error; + goto out; - return xfs_attr_rmtval_invalidate(args); + error = xfs_attr_rmtval_invalidate(args); } +out: + if (error) + xfs_da_state_free(*state); return 0; } @@ -1232,70 +1264,114 @@ xfs_attr_node_remove_cleanup( } /* - * Remove a name from a B-tree attribute list. + * Remove the attribute specified in @args. * * This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). + * + * This routine is meant to function as either an in-line or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and recall the function until a + * successful error code is returned. */ -STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +int +xfs_attr_remove_iter( + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - int retval, error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + int retval, error; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (!xfs_inode_hasattr(dp)) + return -ENOATTR; - /* - * If there is an out-of-line value, de-allocate the blocks. - * This is done before we remove the attribute so that we don't - * overflow the maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + return xfs_attr_shortform_remove(args); + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + return xfs_attr_leaf_removename(args); + + /* fallthrough */ + case XFS_DAS_RMTBLK: + dac->dela_state = XFS_DAS_RMTBLK; + + if (!dac->da_state) { + error = xfs_attr_node_removename_setup(dac); + if (error) + goto out; + } + state = dac->da_state; /* - * Refill the state structure with buffers, the prior calls - * released our buffers. + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a + * deadlock. */ - error = xfs_attr_refillstate(state); - if (error) - goto out; - } - retval = xfs_attr_node_remove_cleanup(args, state); + if (args->rmtblkno > 0) { + /* + * May return -EAGAIN. Remove blocks until + * args->rmtblkno == 0 + */ + error = __xfs_attr_rmtval_remove(dac); + if (error) + break; + + /* + * Refill the state structure with buffers, the prior + * calls released our buffers. + */ + ASSERT(args->rmtblkno == 0); + error = xfs_attr_refillstate(state); + if (error) + goto out; + + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + + retval = xfs_attr_node_remove_cleanup(args, state); - /* - * Check to see if the tree needs to be collapsed. - */ - if (retval && (state->path.active > 1)) { - error = xfs_da3_join(state); - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the Btree join operation and start a new trans. + * Check to see if the tree needs to be collapsed. Set the flag + * to indicate that the calling function needs to move the + * shrink operation */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) - error = xfs_attr_node_shrink(args, state); + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_SHRINK: + /* + * If the result is small enough, push it all into the inode. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); + + break; + default: + ASSERT(0); + error = -EINVAL; + goto out; + } + if (error == -EAGAIN) + return error; out: if (state) xfs_da_state_free(state); diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 3e97a93..92a6a50 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -74,6 +74,127 @@ struct xfs_attr_list_context { }; +/* + * ======================================================================== + * Structure used to pass context around among the delayed routines. + * ======================================================================== + */ + +/* + * Below is a state machine diagram for attr remove operations. The XFS_DAS_* + * states indicate places where the function would return -EAGAIN, and then + * immediately resume from after being recalled by the calling function. States + * marked as a "subroutine state" indicate that they belong to a subroutine, and + * so the calling function needs to pass them back to that subroutine to allow + * it to finish where it left off. But they otherwise do not have a role in the + * calling function other than just passing through. + * + * xfs_attr_remove_iter() + * │ + * v + * have attr to remove? ──n──> done + * │ + * y + * │ + * v + * are we short form? ──y──> xfs_attr_shortform_remove ──> done + * │ + * n + * │ + * V + * are we leaf form? ──y──> xfs_attr_leaf_removename ──> done + * │ + * n + * │ + * V + * ┌── need to setup state? + * │ │ + * n y + * │ │ + * │ v + * │ find attr and get state + * │ attr has blks? ───n────┐ + * │ │ v + * │ │ find and invalidate + * │ y the blocks. mark + * │ │ attr incomplete + * │ ├────────────────┘ + * └──────────┤ + * │ + * v + * Have blks to remove? ─────y────┐ + * │ ^ remove the blks + * │ │ │ + * │ │ v + * │ │ refill the state + * n │ │ + * │ │ v + * │ │ XFS_DAS_RMTBLK + * │ └───── re-enter with one + * │ less blk to remove + * │ + * v + * remove leaf and + * update hash with + * xfs_attr_node_remove_cleanup + * │ + * v + * need to + * shrink tree? ─n─┐ + * │ │ + * y │ + * │ │ + * v │ + * join leaf │ + * │ │ + * v │ + * XFS_DAS_RM_SHRINK │ + * │ │ + * v │ + * do the shrink │ + * │ │ + * v │ + * free state <──┘ + * │ + * v + * done + * + */ + +/* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then recall the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_UNINIT = 0, /* No state has been set yet */ + XFS_DAS_RMTBLK, /* Removing remote blks */ + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + + /* Used in xfs_attr_node_removename to roll through removing blocks */ + struct xfs_da_state *da_state; + + /* Used to keep track of current state of delayed operation */ + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -91,6 +212,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 d6ef69a..3780141 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -19,8 +19,8 @@ #include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" -#include "xfs_attr_remote.h" #include "xfs_attr.h" +#include "xfs_attr_remote.h" #include "xfs_attr_leaf.h" #include "xfs_error.h" #include "xfs_trace.h" diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 48d8e9c..908521e7 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -674,10 +674,12 @@ xfs_attr_rmtval_invalidate( */ int xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_da_args *args) { - int error; - int retval; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; trace_xfs_attr_rmtval_remove(args); @@ -685,31 +687,29 @@ xfs_attr_rmtval_remove( * Keep de-allocating extents until the remote-value region is gone. */ do { - retval = __xfs_attr_rmtval_remove(args); - if (retval && retval != -EAGAIN) - return retval; + error = __xfs_attr_rmtval_remove(&dac); + if (error != -EAGAIN) + break; - /* - * Close out trans and start the next one in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); + error = xfs_attr_trans_roll(&dac); if (error) return error; - } while (retval == -EAGAIN); + } while (true); - return 0; + return error; } /* * Remove the value associated with an attribute by deleting the out-of-line - * buffer that it is stored on. Returns EAGAIN for the caller to refresh the + * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the * transaction and re-call the function */ int __xfs_attr_rmtval_remove( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { - int error, done; + struct xfs_da_args *args = dac->da_args; + int error, done; /* * Unmap value blocks for this attr. @@ -719,12 +719,20 @@ __xfs_attr_rmtval_remove( if (error) return error; - error = xfs_defer_finish(&args->trans); - if (error) - return error; - - if (!done) + /* + * We don't need an explicit state here to pick up where we left off. We + * can figure it out using the !done return code. Calling function only + * needs to keep recalling this routine until we indicate to stop by + * returning anything other than -EAGAIN. The actual value of + * attr->xattri_dela_state may be some value reminiscent of the calling + * function, but it's value is irrelevant with in the context of this + * function. Once we are done here, the next state is set as needed + * by the parent + */ + if (!done) { + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; + } return error; } diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index 9eee615..002fd30 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -14,5 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); -int __xfs_attr_rmtval_remove(struct xfs_da_args *args); +int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index bfad669..aaa7e66 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -15,10 +15,10 @@ #include "xfs_da_format.h" #include "xfs_da_btree.h" #include "xfs_inode.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_trans.h" #include "xfs_bmap.h" -#include "xfs_attr.h" #include "xfs_attr_leaf.h" #include "xfs_quota.h" #include "xfs_dir2.h" From patchwork Fri Mar 26 00:33:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12165387 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 9AFBCC433E6 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7995661A42 for ; Fri, 26 Mar 2021 00:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbhCZAdj (ORCPT ); Thu, 25 Mar 2021 20:33:39 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39332 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhCZAd1 (ORCPT ); Thu, 25 Mar 2021 20:33:27 -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 12Q0P7Wd066486 for ; Fri, 26 Mar 2021 00:33:26 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=lNvCHmRLty2+4UpFpUvvttiblncDNGbUReUtP1hSy1M=; b=Ou1UGGVZ6XH/4GtHGmANtjf+2AApcxofR0csqpGxl0UkXF4kwQCS28NDlnhw0SDwSgcR IG25lJEgXNFq1GKoalwKLgMJ0+1vqVQVjBJsEhtdypfBRsoj/e6y7nTzltyeKTCevEZi gTfmueI/OI1mDKwY7wCupRiMRY+hTVIK61sKkrcu6fj5joJMdx0kbfAc0SO+GOXWi+gu cMFDJQPccPfiHt6bCxBHhHwl0lC3jQ3u1YnR1EYre0JkMLoiU8OdGBImAKnqOdyzZknQ KI/ChgvI55RcF/8zjRyVucPZzU45Vf7DRP6VbgfYZWJh69H1k51T03ck/uO4mXpVhhoW Hw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 37h13hrh7d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:26 +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 12Q0PYwP096811 for ; Fri, 26 Mar 2021 00:33:26 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3030.oracle.com with ESMTP id 37h140qtxx-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 00:33:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WgoUPBL51ivutr3F0IFwxpFOjwpKCNGv4iIEIXVR0+siSz+Nn5/xUDNP/QhVeRPrDlUJpYQGDQzx93cPkymcbfO3rj0Pyd67cZFkIJNIhnad1aA7gZ3kZS3nnDrSXcoPRYRQ1CtRdSZX/LNRg+1hqvzeQy0GbHEKHPWrdcFfvlEXGopY9utFTEjdPfgTFqIwrBwwuJqxcp/LbVyV32ks523g80aBNgWnKkJlKruEOMh7fvr1TDHfk+NOjU5SjcZoOTmtKv79cLsDFSTo103B98Cf34pGyf5vAMvdfXC5VtmpM6ignBXm/oypLJpzZYlCe+Rq84DIc0XtbvLgPZHIYw== 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=lNvCHmRLty2+4UpFpUvvttiblncDNGbUReUtP1hSy1M=; b=H1tBrcqJ6jpgoWrzfXXhoBV2DFMxc0E6G2W6cxj8cqXSYU7xY18p9o/N9eBzRB1PCwElDsYONGhOB/kb6cKDcNh+gDRoX8XaHsRMI7Hl5P0n+GLYW2UeBddQNvVxZj3wz3py2mqU/1oqZyvR3ShjElOg3axkuEWhBw2k6GJWAMmdw1i8wy/vX/d02qjyqYYR10gVzWrd+gAyTkR7Msxw79ypLqkotV5ojpbjPlMfhOtSU/nhYFmRmZOpJKNY6f1ZcpcK2Z0EWxQCB46heDAKman+E3J8JyZK+DegMdOunGwTNwOw/s/7AFrZzYe1oBuF0vGz+Xpj9YIT1xgltp5Qjw== 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=lNvCHmRLty2+4UpFpUvvttiblncDNGbUReUtP1hSy1M=; b=u4IY1uPvjhSayKRuECiZoZlNz2U3d+ZWU9+nTVpPSpwTukbhBlpSwD4PWs4PiXkJwbmOOwxqlDeCGiRz9LI1z80ZhDvVAxE38pSdpbh0LSpScx2BAku99iElbIXwlFsNyB2CKBQsT20uslLhKjUwpDwxXF+yMWRYzmTIGI02+sQ= 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 BYAPR10MB2645.namprd10.prod.outlook.com (2603:10b6:a02:b0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:33:23 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::f4a1:6643:4c93:2a9f%3]) with mapi id 15.20.3977.024; Fri, 26 Mar 2021 00:33:23 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v16 11/11] xfs: Add delay ready attr set routines Date: Thu, 25 Mar 2021 17:33:08 -0700 Message-Id: <20210326003308.32753-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210326003308.32753-1-allison.henderson@oracle.com> References: <20210326003308.32753-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.223.248] X-ClientProxiedBy: SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) 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.223.248) by SJ0PR03CA0003.namprd03.prod.outlook.com (2603:10b6:a03:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:33:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8cefd84a-1438-492d-bc3e-08d8efeec34e X-MS-TrafficTypeDiagnostic: BYAPR10MB2645: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: paoJDautxCYKvAQRDSIuhHFMDy40q5rlekmyb+MePrSE4zYTjisBNy/YG2M9BCs1/WuEtUFs+c2Pa0dK3fnZnzYT953jj/h+LFK61taUkxFWdZg9O6Z4IUpAbcR3sddVWX5FI2e5Yeer/VLyF0Be8PCkAx79K1gIHOgJXZzY6zvJ8MlTPIpKDAStgDWi0xubt6sActhKwTHB0eDfivXCX/y5e0kZGKZNykP8/iWY6I7GNfQJJ3C5s62x7U7kV8TBoFjJtx6nSeSJaF3dLMrSkqj0NVgBgAuHawLej5hJkKIVp3K3P8Dit9xKrIurjSzRU4ErS69rf1u92EnOQXMENNX7fSDs26pWi5a46R2GW6ELMz2uCAz7g9J8pjschQkNEamGz81eaunNJaF3p9vJlgZIHUWa0wtyDQZ41fBuVYL+elJbHy7FhMxj6gNTq3c73wRYNPykAd6uVBiY9G2foT8t5kfFTfayUjFtRvsGPEQKUm45acMsWvbusvpg0JlibF0RlI6HEHiioprH+j3/3lAyn2x8QpwJWol84PztIzzQy6IsSrlCXhLUFoI60OwKKUIelPMx9/GXx1McqpMVW/L3JJglRmLZE6HBXGOdALe1UF8PsvKe0s2XfjkoSNECqZv1QBpmKEMZwyHdIzNWIw== 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:(346002)(376002)(366004)(396003)(136003)(39860400002)(66476007)(478600001)(6666004)(8936002)(66946007)(86362001)(8676002)(1076003)(6916009)(66556008)(52116002)(5660300002)(2906002)(956004)(6486002)(83380400001)(26005)(6506007)(30864003)(186003)(2616005)(16526019)(38100700001)(316002)(6512007)(36756003)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wJFlztiPDqncO5Nxfj8t90bEGM4wrI3XEnerDv2RYbFMTOTV7gOgCswUCAKAj/GMsAkdxk6RPTZB1dbd6R8RZXk/GUdDlIqXtOnxJ3LIGA4IfaQJEY36KSHqhBweGlhKwkxnI8YEuC09fR8lPU0Xi1waQ0lCsmHPSlR78s1b1/2p/x6pOPBusCfCy44yPsS0AptD32aSTwOrJwlyhFOLqbnpeLDJaBrECBBBHAnKqqJKVSLTDZeWYFB7mqTaE/Oct1r9odjdZcbCHmpY/7XncOkF8w22QRihOsLuz0nJL8bVEaYE8mOzhYM1oNDs8/jldbJ8q2g31Z9yd7UL1GMBq3ljBdVa1PXyupr1YG/6SUvDgJ37gXvV+hef237vfOVK1m0z+62Sl1a5CD7ysn4AldmjPqZjfntYBi+RJ1sRSzYVn4PJHGu3optLxaPU8vjhp6NYGalooe7ClKM7ok87NLJL7Ii/RY0MRRAYb4PSx0PPgLU5csFEz7s+CeQdym7jrpDKSIum26tGxKK4pwdVS0l7QQKv9N8ZYMCpKj1OCEMie1OBKPv/fewBxOdqLJBkag0jekpwwETVIx4sQGHBe2EB2a9qWEFnBJy2Dc2rwdWTmNWsZqZ3l4CDNarJsD1qckLmKRG6+kDC5K4+QtNyXBneh791Ybq6S4J9vQMKJTqvPiY879ouR7c8FcxzrziPS3Ue56rcVF3X2A3TziUw5lWhXcOAJJ1IjrQSwH9AEdwV35q88BtYM4p+PnpbTpFIPAE3k10mnpENAlafb/qWfXOEaDcefnl9JN7PFfDSzObumC4beA/dr9rGvlA9UU/oYi3S8wFQNigJ8b0BNN6aRnMDRl9D0REt7nwxl4Yer6fuxJkvDU9vH8eYbN96NzuxafJXVRKUH19NgLra4p98fGohdDQJoLeR9FHSzISQhmSV106tDaWA8kRNcfPOOzzbLuFlUzBWo+HrgTUlqIkUQLTkLZ691cAJQY095mDdZk4d5WKoquDabgkT2IWYY7eC1jhzgg7E6L8K792D33blC1I8H7ZIuAfn877A1d2cC8I8588mI6fNevBkWJNZPt8l5hJpDS65pFUwC4b0AZSYp6/tUrN9T7tYlYsE3fJbUygJbR4xC6SHTDcBGABhUC9MDQvqw+751sTDmXtD5b+1CndPasBs/2S7Nci1IpusU+bRCWclzQSUc6uan0TQt+U37DDXPAsuwfzm0JKKi37ZTgPI1XtZNos9libM1c1l1lZbJEQFLxU1MgO3QRd0cHxck+67amTnOohxGneIbX+lO1DU6pCzQjMmfcSaJk8bbjYjv0O4sZHZ2pNfHsDmkFbu X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cefd84a-1438-492d-bc3e-08d8efeec34e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:33:23.8513 (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: zMSg2FHLNO+GozLrp30JLVasbeTds8QqnECdPGydxbl1sNzxAs5WBwKlRo299UvyiW5TDMRd2T6AwQl3bAiRX4Ww822jGDl2GwZbttjydhE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2645 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 X-Proofpoint-GUID: IEUoLgNlOe2vh0RhxlR7-rCodytql-sz X-Proofpoint-ORIG-GUID: IEUoLgNlOe2vh0RhxlR7-rCodytql-sz X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9934 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 spamscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260000 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr set routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_set_args has become xfs_attr_set_iter, which uses a state machine like switch to keep track of where it was when EAGAIN was returned. See xfs_attr.h for a more detailed diagram of the states. Two new helper functions have been added: xfs_attr_rmtval_find_space and xfs_attr_rmtval_set_blk. They provide a subset of logic similar to xfs_attr_rmtval_set, but they store the current block in the delay attr context to allow the caller to roll the transaction between allocations. This helps to simplify and consolidate code used by xfs_attr_leaf_addname and xfs_attr_node_addname. xfs_attr_set_args has now become a simple loop to refresh the transaction until the operation is completed. Lastly, xfs_attr_rmtval_remove is no longer used, and is removed. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 446 ++++++++++++++++++++++++---------------- fs/xfs/libxfs/xfs_attr.h | 241 +++++++++++++++++++++- fs/xfs/libxfs/xfs_attr_remote.c | 100 ++++++--- fs/xfs/libxfs/xfs_attr_remote.h | 5 +- fs/xfs/xfs_trace.h | 1 - 5 files changed, 582 insertions(+), 211 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 4a73691..6a86b62 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -53,15 +53,16 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); -STATIC int xfs_attr_node_addname(struct xfs_da_args *args, - struct xfs_da_state *state); -STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, - struct xfs_da_state **state); -STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); +STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_clear_incomplete( + struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_inode_hasattr( @@ -225,7 +226,7 @@ xfs_attr_is_shortform( * also checks for a defer finish. Transaction is finished and rolled as * needed, and returns true of false if the delayed operation should continue. */ -int +STATIC int xfs_attr_trans_roll( struct xfs_delattr_context *dac) { @@ -246,29 +247,55 @@ xfs_attr_trans_roll( return error; } +/* + * Set the attribute specified in @args. + */ +int +xfs_attr_set_args( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; + + do { + error = xfs_attr_set_iter(&dac, &leaf_bp); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + } while (true); + + return error; +} + STATIC int xfs_attr_set_fmt( - struct xfs_da_args *args) + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_buf *leaf_bp = NULL; - struct xfs_inode *dp = args->dp; - int error2, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + int error = 0; /* * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } + + /* Should only be 0, -EEXIST or -ENOSPC */ + if (error != -ENOSPC) + return error; /* * It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + error = xfs_attr_shortform_to_leaf(args, leaf_bp); if (error) return error; @@ -277,95 +304,139 @@ xfs_attr_set_fmt( * concurrent AIL push cannot grab the half-baked leaf buffer * and run into problems with the write verifier. */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); - return error; - } + xfs_trans_bhold(args->trans, *leaf_bp); + /* + * We're still in XFS_DAS_UNINIT state here. We've converted + * the attr fork to leaf format and will restart with the leaf + * add. + */ + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } /* * Set the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + * returned. */ int -xfs_attr_set_args( - struct xfs_da_args *args) +xfs_attr_set_iter( + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_inode *dp = args->dp; - struct xfs_buf *bp = NULL; - struct xfs_da_state *state = NULL; - int forkoff, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; + struct xfs_da_state *state = NULL; + int forkoff, error = 0; - /* - * If the attribute list is already in leaf format, jump straight to - * leaf handling. Otherwise, try to add the attribute to the shortform - * list; if there's no room then convert the list to leaf format and try - * again. - */ - if (xfs_attr_is_shortform(dp)) { - error = xfs_attr_set_fmt(args); - if (error != -EAGAIN) - return error; - } + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (xfs_attr_is_shortform(dp)) + return xfs_attr_set_fmt(dac, leaf_bp); - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) { - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); + /* + * After a shortform to leaf conversion, we need to hold the + * leaf and cycle out the transaction. When we get back, + * we need to release the leaf to release the hold on the leaf + * buffer. + */ + if (*leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, *leaf_bp); + *leaf_bp = NULL; + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree + * format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to + * call node_addname with the inode and + * transaction in the same state (inode locked + * and joined, transaction clean) no matter how + * we got to this step. + * + * At this point, we are still in + * XFS_DAS_UNINIT, but when we come back, we'll + * be a node, so we'll fall down into the node + * handling code below + */ + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + else if (error) + return error; + } + else { + error = xfs_attr_node_addname_find_attr(dac); 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); + error = xfs_attr_node_addname(dac); if (error) return error; /* - * Commit the current trans (including the inode) and - * start a new one. + * If addname was successful, and we dont need to alloc + * anymore blks, we're done. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) + if (!args->rmtblkno && !args->rmtblkno2) return error; - goto node; - } - else if (error) { - return error; + dac->dela_state = XFS_DAS_FOUND_NBLK; + return -EAGAIN; } - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; + dac->dela_state = XFS_DAS_FOUND_LBLK; + return -EAGAIN; + case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we * identified for its storage and copy the value. This is done * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + + /* Open coded xfs_attr_rmtval_set without trans handling */ + if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + } + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + + return -EAGAIN; } + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* * Added a "remote" value, just clear the incomplete @@ -394,22 +465,26 @@ xfs_attr_set_args( * Commit the flag value change and start the next trans in * series. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - + dac->dela_state = XFS_DAS_FLIP_LFLAG; + return -EAGAIN; + case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a * "remote" value (if it exists). */ xfs_attr_restore_rmt_blk(args); - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_LBLK; - error = xfs_attr_rmtval_remove(args); + /* fallthrough */ + case XFS_DAS_RM_LBLK: + if (args->rmtblkno) { + error = __xfs_attr_rmtval_remove(dac); if (error) return error; } @@ -434,91 +509,114 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; - } -node: + case XFS_DAS_FOUND_NBLK: + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + /* + * Open coded xfs_attr_rmtval_set without trans + * handling + */ + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; - do { - error = xfs_attr_node_addname_find_attr(args, &state); - if (error) - return error; - error = xfs_attr_node_addname(args, state); - } while (error == -EAGAIN); - if (error) - return error; + /* + * Roll through the "value", allocating blocks on disk + * as required. Set the state in case of -EAGAIN return + * code + */ + dac->dela_state = XFS_DAS_ALLOC_NODE; + } - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + /* fallthrough */ + case XFS_DAS_ALLOC_NODE: + if (args->rmtblkno > 0) { + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); + if (error) + return error; - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + * flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } - if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* - * Added a "remote" value, just clear the incomplete flag. + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in + * series + */ + dac->dela_state = XFS_DAS_FLIP_NFLAG; + return -EAGAIN; - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); + case XFS_DAS_FLIP_NFLAG: + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); - if (args->rmtblkno) { error = xfs_attr_rmtval_invalidate(args); if (error) return error; - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_NBLK; + + /* fallthrough */ + case XFS_DAS_RM_NBLK: + if (args->rmtblkno) { + error = __xfs_attr_rmtval_remove(dac); + if (error) + return error; + } + + error = xfs_attr_node_addname_clear_incomplete(dac); - error = xfs_attr_node_addname_clear_incomplete(args); out: - if (state) - xfs_da_state_free(state); - return error; + if (state) + xfs_da_state_free(state); + return error; + + default: + ASSERT(dac->dela_state != XFS_DAS_RM_SHRINK); + break; + } + return error; } + /* * Return EEXIST if attr is found, or ENOATTR if not */ @@ -984,18 +1082,18 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int retval; + struct xfs_da_args *args = dac->da_args; + int retval; /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - retval = xfs_attr_node_hasname(args, state); + retval = xfs_attr_node_hasname(args, &dac->da_state); if (retval != -ENOATTR && retval != -EEXIST) - goto error; + return retval; if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto error; @@ -1021,8 +1119,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (*state) - xfs_da_state_free(*state); + if (dac->da_state) + xfs_da_state_free(dac->da_state); return retval; } @@ -1035,20 +1133,24 @@ xfs_attr_node_addname_find_attr( * * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. + * + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + *returned. */ STATIC int xfs_attr_node_addname( - struct xfs_da_args *args, - struct xfs_da_state *state) + struct xfs_delattr_context *dac) { - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + struct xfs_da_state_blk *blk; + int error; trace_xfs_attr_node_addname(args); - dp = args->dp; - blk = &state->path.blk[state->path.active-1]; + blk = &state->path.blk[ state->path.active-1 ]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); error = xfs_attr3_leaf_add(blk->bp, state->args); @@ -1064,18 +1166,15 @@ xfs_attr_node_addname( error = xfs_attr3_leaf_to_node(args); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the node conversion and start the next - * trans in the chain. + * Now that we have converted the leaf to a node, we can + * roll the transaction, and try xfs_attr3_leaf_add + * again on re-entry. No need to set dela_state to do + * this. dela_state is still unset by this function at + * this point. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -1088,9 +1187,7 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1105,8 +1202,9 @@ xfs_attr_node_addname( STATIC int xfs_attr_node_addname_clear_incomplete( - struct xfs_da_args *args) + struct xfs_delattr_context *dac) { + struct xfs_da_args *args = dac->da_args; struct xfs_da_state *state = NULL; struct xfs_da_state_blk *blk; int retval = 0; diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h index 92a6a50..4e4233d 100644 --- a/fs/xfs/libxfs/xfs_attr.h +++ b/fs/xfs/libxfs/xfs_attr.h @@ -159,6 +159,233 @@ struct xfs_attr_list_context { * v * done * + * + * Below is a state machine diagram for attr set operations. + * + * It seems the challenge with understanding this system comes from trying to + * absorb the state machine all at once, when really one should only be looking + * at it with in the context of a single function. Once a state sensitive + * function is called, the idea is that it "takes ownership" of the + * state machine. It isn't concerned with the states that may have belonged to + * it's calling parent. Only the states relevant to itself or any other + * subroutines there in. Once a calling function hands off the state machine to + * a subroutine, it needs to respect the simple rule that it doesn't "own" the + * state machine anymore, and it's the responsibility of that calling function + * to propagate the -EAGAIN back up the call stack. Upon reentry, it is + * committed to re-calling that subroutine until it returns something other than + * -EAGAIN. Once that subroutine signals completion (by returning anything other + * than -EAGAIN), the calling function can resume using the state machine. + * + * xfs_attr_set_iter() + * │ + * v + * ┌─y─ has an attr fork? + * │ | + * │ n + * │ | + * │ V + * │ add a fork + * │ │ + * └──────────┤ + * │ + * V + * ┌─y─ is shortform? + * │ │ + * │ V + * │ xfs_attr_set_fmt + * │ | + * │ V + * │ xfs_attr_try_sf_addname + * │ │ + * │ V + * │ had enough ──y──> done + * │ space? + * n │ + * │ n + * │ │ + * │ V + * │ transform to leaf + * │ │ + * │ V + * │ hold the leaf buffer + * │ │ + * │ V + * │ return -EAGAIN + * │ Re-enter in + * │ leaf form + * │ + * └─> release leaf buffer + * if needed + * │ + * V + * ┌───n── fork has + * │ only 1 blk? + * │ │ + * │ y + * │ │ + * │ v + * │ xfs_attr_leaf_try_add() + * │ │ + * │ v + * │ had enough ──────────────y───────────────┐ + * │ space? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ return -EAGAIN │ + * │ re-enter in │ + * │ node form │ + * │ │ │ + * └──────────┤ │ + * │ │ + * V │ + * xfs_attr_node_addname_find_attr │ + * determines if this │ + * is create or rename │ + * find space to store attr │ + * │ │ + * v │ + * xfs_attr_node_addname │ + * │ │ + * v │ + * fits in a node leaf? ────n─────┐ │ + * │ ^ v │ + * │ │ single leaf node? │ + * │ │ │ │ │ + * y │ y n │ + * │ │ │ │ │ + * v │ v v │ + * update │ grow the leaf split if │ + * hashvals └─── return -EAGAIN needed │ + * │ retry leaf add │ │ + * │ on reentry │ │ + * ├─────────────────────────────┘ │ + * │ │ + * v │ + * need to alloc │ + * ┌─y── or flip flag? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ done │ + * │ │ + * │ │ + * │ XFS_DAS_FOUND_LBLK <──────────────────┘ + * │ │ + * │ V + * │ xfs_attr_leaf_addname() + * │ │ + * │ v + * │ ┌──first time through? + * │ │ │ + * │ │ y + * │ │ │ + * │ n v + * │ │ if we have rmt blks + * │ │ find space for them + * │ │ │ + * │ └──────────┤ + * │ │ + * │ v + * │ still have + * │ ┌─n─ blks to alloc? <──┐ + * │ │ │ │ + * │ │ y │ + * │ │ │ │ + * │ │ v │ + * │ │ alloc one blk │ + * │ │ return -EAGAIN ──┘ + * │ │ re-enter with one + * │ │ less blk to alloc + * │ │ + * │ │ + * │ └───> set the rmt + * │ value + * │ │ + * │ v + * │ was this + * │ a rename? ──n─┐ + * │ │ │ + * │ y │ + * │ │ │ + * │ v │ + * │ flip incomplete │ + * │ flag │ + * │ │ │ + * │ v │ + * │ XFS_DAS_FLIP_LFLAG │ + * │ │ │ + * │ v │ + * │ remove │ + * │ ┌───> old name │ + * │ │ │ │ + * │ XFS_DAS_RM_LBLK │ │ + * │ ^ │ │ + * │ │ v │ + * │ └──y── more to │ + * │ remove │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ done <──────┘ + * │ + * └──────> XFS_DAS_FOUND_NBLK + * │ + * v + * ┌─────n── need to + * │ alloc blks? + * │ │ + * │ y + * │ │ + * │ v + * │ find space + * │ │ + * │ v + * │ ┌─>XFS_DAS_ALLOC_NODE + * │ │ │ + * │ │ v + * │ │ alloc blk + * │ │ │ + * │ │ v + * │ └──y── need to alloc + * │ more blocks? + * │ │ + * │ n + * │ │ + * │ v + * │ set the rmt value + * │ │ + * │ v + * │ was this + * └────────> a rename? ──n─┐ + * │ │ + * y │ + * │ │ + * v │ + * flip incomplete │ + * flag │ + * │ │ + * v │ + * XFS_DAS_FLIP_NFLAG │ + * │ │ + * v │ + * remove │ + * ┌────────> old name │ + * │ │ │ + * XFS_DAS_RM_NBLK │ │ + * ^ │ │ + * │ v │ + * └──────y── more to │ + * remove │ + * │ │ + * n │ + * │ │ + * v │ + * done <──────┘ + * */ /* @@ -174,12 +401,20 @@ enum xfs_delattr_state { XFS_DAS_UNINIT = 0, /* No state has been set yet */ XFS_DAS_RMTBLK, /* Removing remote blks */ XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ + XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ + XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ + XFS_DAS_FLIP_LFLAG, /* Flipped leaf INCOMPLETE attr flag */ + XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */ + XFS_DAS_ALLOC_NODE, /* We are allocating node blocks */ + XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */ + XFS_DAS_RM_NBLK, /* A rename is removing node blocks */ }; /* * Defines for xfs_delattr_context.flags */ #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -187,6 +422,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + int blkcnt; + /* Used in xfs_attr_node_removename to roll through removing blocks */ struct xfs_da_state *da_state; @@ -213,7 +453,6 @@ int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); -int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 908521e7..fc71f10 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -439,9 +439,9 @@ xfs_attr_rmtval_get( /* * Find a "hole" in the attribute address space large enough for us to drop the - * new attribute's value into + * new attributes value into */ -STATIC int +int xfs_attr_rmt_find_hole( struct xfs_da_args *args) { @@ -468,7 +468,7 @@ xfs_attr_rmt_find_hole( return 0; } -STATIC int +int xfs_attr_rmtval_set_value( struct xfs_da_args *args) { @@ -628,6 +628,69 @@ xfs_attr_rmtval_set( } /* + * Find a hole for the attr and store it in the delayed attr context. This + * initializes the context to roll through allocating an attr extent for a + * delayed attr operation + */ +int +xfs_attr_rmtval_find_space( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_bmbt_irec *map = &dac->map; + int error; + + dac->lblkno = 0; + dac->blkcnt = 0; + args->rmtblkcnt = 0; + args->rmtblkno = 0; + memset(map, 0, sizeof(struct xfs_bmbt_irec)); + + error = xfs_attr_rmt_find_hole(args); + if (error) + return error; + + dac->blkcnt = args->rmtblkcnt; + dac->lblkno = args->rmtblkno; + + return 0; +} + +/* + * Write one block of the value associated with an attribute into the + * out-of-line buffer that we have defined for it. This is similar to a subset + * of xfs_attr_rmtval_set, but records the current block to the delayed attr + * context, and leaves transaction handling to the caller. + */ +int +xfs_attr_rmtval_set_blk( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_bmbt_irec *map = &dac->map; + int nmap; + int error; + + nmap = 1; + error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)dac->lblkno, + dac->blkcnt, XFS_BMAPI_ATTRFORK, args->total, + map, &nmap); + if (error) + return error; + + ASSERT(nmap == 1); + ASSERT((map->br_startblock != DELAYSTARTBLOCK) && + (map->br_startblock != HOLESTARTBLOCK)); + + /* roll attribute extent map forwards */ + dac->lblkno += map->br_blockcount; + dac->blkcnt -= map->br_blockcount; + + return 0; +} + +/* * Remove the value associated with an attribute by deleting the * out-of-line buffer that it is stored on. */ @@ -669,37 +732,6 @@ xfs_attr_rmtval_invalidate( } /* - * Remove the value associated with an attribute by deleting the - * out-of-line buffer that it is stored on. - */ -int -xfs_attr_rmtval_remove( - struct xfs_da_args *args) -{ - int error; - struct xfs_delattr_context dac = { - .da_args = args, - }; - - trace_xfs_attr_rmtval_remove(args); - - /* - * Keep de-allocating extents until the remote-value region is gone. - */ - do { - error = __xfs_attr_rmtval_remove(&dac); - if (error != -EAGAIN) - break; - - error = xfs_attr_trans_roll(&dac); - if (error) - return error; - } while (true); - - return error; -} - -/* * Remove the value associated with an attribute by deleting the out-of-line * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the * transaction and re-call the function diff --git a/fs/xfs/libxfs/xfs_attr_remote.h b/fs/xfs/libxfs/xfs_attr_remote.h index 002fd30..8ad68d5 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.h +++ b/fs/xfs/libxfs/xfs_attr_remote.h @@ -10,9 +10,12 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen); int xfs_attr_rmtval_get(struct xfs_da_args *args); int xfs_attr_rmtval_set(struct xfs_da_args *args); -int xfs_attr_rmtval_remove(struct xfs_da_args *args); int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map, xfs_buf_flags_t incore_flags); int xfs_attr_rmtval_invalidate(struct xfs_da_args *args); int __xfs_attr_rmtval_remove(struct xfs_delattr_context *dac); +int xfs_attr_rmt_find_hole(struct xfs_da_args *args); +int xfs_attr_rmtval_set_value(struct xfs_da_args *args); +int xfs_attr_rmtval_set_blk(struct xfs_delattr_context *dac); +int xfs_attr_rmtval_find_space(struct xfs_delattr_context *dac); #endif /* __XFS_ATTR_REMOTE_H__ */ diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index e74bbb6..0c16d46 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1944,7 +1944,6 @@ DEFINE_ATTR_EVENT(xfs_attr_refillstate); DEFINE_ATTR_EVENT(xfs_attr_rmtval_get); DEFINE_ATTR_EVENT(xfs_attr_rmtval_set); -DEFINE_ATTR_EVENT(xfs_attr_rmtval_remove); #define DEFINE_DA_EVENT(name) \ DEFINE_EVENT(xfs_da_class, name, \