From patchwork Fri Apr 16 09:18: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: 12207207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0C7BC433ED for ; Fri, 16 Apr 2021 09:18:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC6756117A for ; Fri, 16 Apr 2021 09:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241719AbhDPJTJ (ORCPT ); Fri, 16 Apr 2021 05:19:09 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35044 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234914AbhDPJTB (ORCPT ); Fri, 16 Apr 2021 05:19:01 -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 13G9A3f7026508 for ; Fri, 16 Apr 2021 09:18:36 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=EV9q4k8AZpweLkPAyxKesluVzWS5H21v1FeXMBiMNN0=; b=W/9v3JDo74cQnDYNuAOnw1guMcyQnJ5NXlFwMesAyFV+Om3CBd60GzwM81EeyUro6wKw z3BamfIfpuqLJEZb+hoXnpmxfyMDCydkjUz2tsRsgy6HdFYKW8E2KsoZhR/qSAjmaaOx D/FmSnzEyNPtw9UYrn8G8jYF5pubVhBXzs6poo/6vV/JET05ug/Oo32MRtmfEkAyEZuC lIsi6+1GQoMG/xma6dm0kq3RUQYWmjAdaV39xk+OaSoHYozOuFe/5bXN5lVfLmUjtVQv XhfD5LJ02f0aumELuMwzf2wqUXO1eA3xat73aEy1qxHgv4NMNjWWplaLDVGG+1cbWG4x 0Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnrh8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +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 13G99dBO182009 for ; Fri, 16 Apr 2021 09:18:36 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 37unswy4uk-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/MIpCNLLNN7BPYvG4T3gLOXmNQpMkpHpP5JNSfmR42hL8GP0Kj7ObHd8CEWjZMTGwDBmQwu6EgbwmWk2TvmqiXwfkRV9/UtdGMSYcaCcp8/M1v02YJ4BV9grNLEOl5Mqg48FMy0uIlEn97r7qohc4iyE0A3CkI9UvKUfi4Obd2OGgMAYyiU+GflR5oBlGC+o7iQaahQM2EqhP6SZ/7u0FHvmzaeEBA8HSWfbZoq4jInQz+D3ipoDH/r4D5mjo6+VDQSn4sUWQhI5AsSlM+Krvoq75H8ZvWzgQ3RSExgyGgm66nTch6NkG7oYOARf9xtnmU/hRpf2gOG2o0FjMxMjA== 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=EV9q4k8AZpweLkPAyxKesluVzWS5H21v1FeXMBiMNN0=; b=SrE7JXvoVjlwR+UHLTEaMqlk/rJlgOWfCqkZWjGNrRBtnZvl+z4SB3hwHMsyDq9POTmvi234nJpuKyUejBMof9cYeyQFm512YyIVF7vFNlNC46Xp6QatIwcfON6Pu0M48ab3k0o+Aw8iRf7VcNRiFHJ2SvLaLHjNtU6pY9KkeQOUPC2Y99kpX/ewOzJKifv9rLBdjzDT43v0rwmU2Aw99u5yXQWeqGNsKwKIGmmPM9rpXYiKZfTzfCPWc6CSMTdEw2WDgtlk0sTkmXMu7t/5PjZaVFm6oD4/hBhJwq+fmtrwkZewOeRLvejcCDcLO9wOJJC0YbooR9FQQ3Z+VslwLw== 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=EV9q4k8AZpweLkPAyxKesluVzWS5H21v1FeXMBiMNN0=; b=fskzLEuR3sJR8aW5pIwVVHgbavCowySPTYuXvlLXdkDcx/k3F8EBi6awyzqiESzD7EP7l3ISl5Soajoj3OswZx/AKC/XGyb2XTQYHfR0ef4p2ywib7XKkX5uGg3F8n7a6ZNbRNzA6Nq2qpEkeOzdP3WNdrucmceohuZNHSyQnXc= 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 SJ0PR10MB4800.namprd10.prod.outlook.com (2603:10b6:a03:2da::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Fri, 16 Apr 2021 09:18:31 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:31 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 01/12] xfs: add error injection for per-AG resv failure Date: Fri, 16 Apr 2021 02:18:03 -0700 Message-Id: <20210416091814.2041-2-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38cde69d-abdd-49a5-b219-08d900b89a64 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4800: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:250; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x1Fkb0YA+wlYvD8xGc2CQHdVuH6VKl2X48uyFhdONn2oaWwXCi9QGzJjH0mlvhLRYWl6bMQdQQaq7jS9cVEBkx2Nr33SfesRPoQeHtdQydVRChIfn8NMxhVj46er/5gb4MVqBRWDoU81XXLnN/g4/WzaFX5OGQ3zh+blxPtavRYNHNkOArftGe3uJComKerwD+R6UhuTAhuphSYPrUD5/rBwBs3Ersp/0NleELR5nI5jLha6U2uws3Kxg0m2U4ZchmzgsIaO3FLDsJxuKrbfPRtFEIC47fgsGXIGCgb0xdW3ACaXaAN7KalK7X/ogooyla0GDyxwZz3E4mNuEWqB6ctTvzOXl/B/fuD589pITjP4FmhfttlOsQ1kOXtEr90Vh0C2EaiNUDjX/S09xAvHTEbCtuxIRhwpBtlJ/unLMD2LbA54DgPq6h4VqyqL4AtL6UcLenyMzaYF6oEhwsTJ1PbyOBeHMR5RoELcQqFsEHdOmisFRHBuqkJdXehkMaIIruj5j46wnvXeq4sUvzFj75aXLntSzPeCHVWSPPa3Tiqk9xQD6mMPsC6o+c8qQkaioFfy4YCzCNmuogARiGPo+nTwaKAlVDfLDic6Q433cmWfJ5IqyxyXEpCRE1cXu25CPT6nFCwiDiMRZKK7lRJo0FxgGIDzgXzhRYQppW+GJaKZe5nuZw0IwbgDHBa/6vQk 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)(346002)(376002)(366004)(136003)(39860400002)(1076003)(83380400001)(6506007)(5660300002)(16526019)(186003)(508600001)(316002)(8676002)(6512007)(36756003)(8936002)(26005)(66556008)(66476007)(69590400012)(44832011)(66946007)(38100700002)(38350700002)(6486002)(956004)(2616005)(6666004)(2906002)(86362001)(52116002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ymulaCMhcS7E0mjj/o92CLPvvjy+dUY//SZFn9ifiSXsVG+Gr8GDa11tS6kev3gOC0EKYD8pRQFqR6quAc5Q3tgAPrtbzqCrrjYtlxXcxSVMZCoGwThQ0c4hKsQkTqtcrcKZBtWmGVsgbM8xhEIqMJe8OxaXV/+6lKgwJeuQskS4W/xUFT3WC3DHLM6iY8bcpFY/rSCljHltrqOpkU5stfmpof3a3bdyA0M3On0btyxnyTdNr0Sk6nS+Az7QbgHXn0HxRZHCfpCL/wdFvHYJQp6POQ0t1sywFAA5HQH75zlcIsuICSjnGTGF2dfGnMk3swIwFilVxmy0twe0+PvgWZr4tJ/O8IzG5jE0ScpSSIAcfM+q1hOttQBbVwm+m7FtLS8hNTxu2a0m7J9ZALEznazZ2jd/aB3E7odQ1Nk1CUpxkzMMdwydLWqxTAIv/4CUbII2sZKl/K9GmZcstMyoj9SlJrO5u3Y1lYb+xIHVjLYHxn6Uf6EhiUnIHl7Iq8AyKmNpNxGZ4VeIocOeIpB75kgeFVEfkrNjBOIs62ZHgw0RpWrFYerl86Bi+HWrWmmS2RJMI2NPfVrUqu5PEZhzYo5aZs6cwfK9hXogtIvxREQyTYRuEumDqB53GqZtK3TAAO64EJTd8EM0WoM+dxCpxId6YssLPL8sw2BkSW56qWG73WZMb0YkMrLi6SYqG+MS1NDnF4BB/WVsYD29jvCoBk+0e54I3xmG91JJWIYaQT0lLZClWjXeDK2C9wvDGITITxQtbgExwmOdRevLmexN0yA41U9xLUgMfU8sjj2OHw+PoWg3CoBrevLcKoPvF+rQpfyxupPb+k+3D2Rr1Yrnc2kRaBsk52TuuBZyKaPtVeT2OzqYUEvHX20/wAummMkvC7+1I2RLeug5uOPYc9/zFQPWH4mtHN8/eXlFVN6n6sBzn/xDxTytkTOVPFN/aUjKFpF6DirQSX2JgrpXEmuhZUcaQdUcmsdc8FTq39TVA1jZIEQIgzMkl4+Si/G56nJdwPHxMTFLIvek3R6PFNmYkjnIJJd+ZLZf7jHzXBNYGleNI4YmuRCyiUhWgtdukMEVgKgHCBtDlzEnlZlxeytoCvOc5szY3CXdJoECzhxQ5RxNaRFaVaN3sIr9ssWAgiLjQWETaD/LWuvchNM/HUZDPYUf6jPtjVeC9KFP94xXsXC8jsoa32WxXm5vuMudQOyubDGfwmwbIhTfALtLbMwXNcgYzVWisnSQ9drbbG6OY4Cp8InnP6qFy7iUyOBKCAzT3eBEp4At2cnoK6LIH5aMUzgb7SsGoC9eNSdb+HMIfgCSWpcCjyCPNF7rrtOoO7Aa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38cde69d-abdd-49a5-b219-08d900b89a64 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:31.5730 (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: kTkumYW4x8ss1JM7r3lZU9IvYqVnNVtv4XP6Nd6v9/gwhPdY6ftuzKr9tvUKiopqu29SUrJ9WioHd2Vsn9MaWY+jrezeR0Nhq5JR1Rtc0Lc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4800 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: DbT2_TqMt8_lO1hDOu-7TaIzWla5697p X-Proofpoint-GUID: DbT2_TqMt8_lO1hDOu-7TaIzWla5697p X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Gao Xiang Source kernel commit: 2b92faed551173f065ee2a8cf087dc76cf40303b per-AG resv failure after fixing up freespace is hard to test in an effective way, so directly add an error injection path to observe such error handling path works as expected. Signed-off-by: Gao Xiang Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Allison Henderson --- io/inject.c | 1 + libxfs/xfs_ag_resv.c | 6 +++++- libxfs/xfs_errortag.h | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/io/inject.c b/io/inject.c index 9a401a1..0be1fd6 100644 --- a/io/inject.c +++ b/io/inject.c @@ -57,6 +57,7 @@ error_tag(char *name) { XFS_ERRTAG_BUF_IOERROR, "buf_ioerror" }, { XFS_ERRTAG_REDUCE_MAX_IEXTENTS, "reduce_max_iextents" }, { XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT, "bmap_alloc_minlen_extent" }, + { XFS_ERRTAG_AG_RESV_FAIL, "ag_resv_fail"}, { XFS_ERRTAG_MAX, NULL } }; int count; diff --git a/libxfs/xfs_ag_resv.c b/libxfs/xfs_ag_resv.c index 530455a..9dc5bf2 100644 --- a/libxfs/xfs_ag_resv.c +++ b/libxfs/xfs_ag_resv.c @@ -210,7 +210,11 @@ __xfs_ag_resv_init( ASSERT(0); return -EINVAL; } - error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); + + if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL)) + error = -ENOSPC; + else + error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true); if (error) { trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, error, _RET_IP_); diff --git a/libxfs/xfs_errortag.h b/libxfs/xfs_errortag.h index 6ca9084..a23a52e 100644 --- a/libxfs/xfs_errortag.h +++ b/libxfs/xfs_errortag.h @@ -58,7 +58,8 @@ #define XFS_ERRTAG_BUF_IOERROR 35 #define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37 -#define XFS_ERRTAG_MAX 38 +#define XFS_ERRTAG_AG_RESV_FAIL 38 +#define XFS_ERRTAG_MAX 39 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -101,5 +102,6 @@ #define XFS_RANDOM_BUF_IOERROR XFS_RANDOM_DEFAULT #define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1 #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1 +#define XFS_RANDOM_AG_RESV_FAIL 1 #endif /* __XFS_ERRORTAG_H_ */ From patchwork Fri Apr 16 09:18: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: 12207205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 070BDC433B4 for ; Fri, 16 Apr 2021 09:18:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD92C61166 for ; Fri, 16 Apr 2021 09:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241319AbhDPJTC (ORCPT ); Fri, 16 Apr 2021 05:19:02 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35038 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239944AbhDPJTA (ORCPT ); Fri, 16 Apr 2021 05:19:00 -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 13G99g7x026244 for ; Fri, 16 Apr 2021 09:18:36 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=Qmv/kUJZBgyPYv/BSQbHpRIxDuNKwrXgo9t8HQbjkmg=; b=fZ2Q3/lAklFWw+gx1fZVDltuQ7KFsMJsso0LYPfmdWClVVa1Ach7rCeeikZnDiKRHIWS 9WjZSvVIUrq5BRbr+9mtUewi5zNccv00kyy/IcLZdGxKlv04BJMckgSv15uYSqDv+Wie OxhphcvSMLrKczzFECRsX1BvEJ4gCW7KC/FZSNBBeI7WBmgN/EIgo6JBU7YVWjSH8Ko6 exk7FSj5iC6+dLhUDa7iYw0d7PXxUW3ExjtRGO9IrwijWL48XTsyU8sbqxIZurZg3DTF 4PhuvFeSL6psUU6HzpeMOEuBOViCqYP3p8JEbO3hlc8cB1PWC6chdTyoNPwS+nxrWDpN 3g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 37u4nnrh8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +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 13G99dBN182009 for ; Fri, 16 Apr 2021 09:18:35 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 37unswy4uk-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RoS+REZgvwZA8hLG0ISS/X1N2/RDpblEDTVQX+pFdYsTxukvSeTaLi6dGAXRdJUT61rfAPKfe0/ZHm7e6Wk3jrM1yqOKSMh3tPYZBCipD7jSKUC/hCFwlwSz/Y8Jn57a1HJqucCl26kR46eNY3vCmJseX++huTTJlblgqO9mljN8ppONptxf3D1r454ucSsXrnWj0b/uKvY/TODlXgw1Pe2oN2pjcCl7Gtdqa5TbbMpIubPgq2iDENSBSTgJuCQOAenkchyYaGxBVMQApHTL8XDb2G7aRhxBTFbHUeKbkDNLnENaWYJJnT4GnFxFT6ajPM8OmM54ZIxwDec8UPbZiQ== 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=Qmv/kUJZBgyPYv/BSQbHpRIxDuNKwrXgo9t8HQbjkmg=; b=a9eXh3/BLHmqqfbgJtcBsDjKQyH04zevuK6w+hAVjT2+Q9G5EKmOw6LNZHaz7jXR9pYJ6tnh3TBjN3iRHbXkOFVQPxasXSGd5/+mngGt6SF4ZuGy+dYCHOkzKl0ONO8FuzvUXZf9HU2MN4AeabGm939hXHarSdvEmErCCtMSUy1QEHxaW3BBekiQhzyFHsQeHK8gsTsDlnEz5Ju50w7XpqwsFnR9QXzSEDSoRvxEpAnrL6sYFlzkKAVSOwDZjBLbTiRScP++CWwdUmYpjE06++iA2seuLLcjS7Y7rZEcYCPocO9CAW+x6DKe13Lr0Tz1wRGPu6vIPOBlTonNEXLARQ== 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=Qmv/kUJZBgyPYv/BSQbHpRIxDuNKwrXgo9t8HQbjkmg=; b=M1PKtY0cnFYLguCC4ouF93pCBoq7sjd2oZ2qsrUzipip4r6+ivdR75apJ2DpT6N1VrgmJaZ4tUYaRmSUGPAnw79O3qY2tx+6N2aC8AgXyovL1WeHIFyNvDiKAzmKlUY4SIhB+UZmmWW+gKkPhdYklX0nJiBYJk6CdlV7ZKsaly0= 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 SJ0PR10MB4800.namprd10.prod.outlook.com (2603:10b6:a03:2da::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Fri, 16 Apr 2021 09:18:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:32 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 02/12] xfsprogs: Reverse apply 72b97ea40d Date: Fri, 16 Apr 2021 02:18:04 -0700 Message-Id: <20210416091814.2041-3-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b720bba9-f0be-40a8-4fb4-08d900b89aa1 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4800: 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: kIFuHj0Ia1PdykKCzmVNeT7SFpLfeZBdG2l6QyB0FMUNKHzOyqeYgJCT8e+f7j9+KKjmSsRSVD9sWM08HTtXhIMAEdXnOd+ZPANDbSoYHAnaohRst08vuXJlgScim4kd+U8ap5v8PtPBkfdI294L1QwZwF6AQ/Y2TVRRn34Yv3u0H3O9R3K0RKbA97gkJjwTTVWp5jsrUckSx6+TSe+gLQy68lPjHC/D4IJ/f673jzaOnMPGa9RAnp5PPliKyX0KiOMT9vmKI+yATEYs1oBKKQm0XJKALzDfUOmMKNnmB0AmFxl1dHZULSg3/3sMWUCOW4gmkYlDvsFSbbQwIeyjQYkxItKtEoUF1hxyI2ZwSiEcTZlIiO+k9jkrpJeZktp+efTdJUcHloP0rll4NW/2dnPew0Y3tJR1Fcke+t/tUzwI8IwfmzeeCzNf6c7oM1mvLVagPI2H8I39Px0izTHK8BXOwAJmZ3sOiFis/dBDqFqxyBkmZoNrtFpyjbeguxuzJf6DPRDe6ZZU5Lnjc2VFUijPO6c+QxMOi44jmZrcJX45SdKxqbEEg6XlAdR1S0C3C4CDpDjnwd/wzhE7DvZ+w1r7zpjj0wi+iAmNj3j7Jj8znZC6locBHx63oVXdqbkCxVuHr7aLjz8vWP9dRAaADujioesp3F6UNp1e6veIObx437qpT8VbcpnL/IAIWLdp 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)(346002)(376002)(366004)(136003)(39860400002)(1076003)(83380400001)(6506007)(5660300002)(16526019)(186003)(508600001)(316002)(8676002)(6512007)(36756003)(8936002)(26005)(66556008)(66476007)(69590400012)(44832011)(66946007)(38100700002)(38350700002)(6486002)(956004)(2616005)(6666004)(2906002)(86362001)(52116002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: OMJs2Yi5J2O84g7/F1D4dnROL3jMyUF7rnKpU58YQSd6BXDonr5GupphIXZs3ophD5O6FW6jJ/YEX0sYmg6K/GIELessyCs+7OvbjD4VDDURJeGym1Qa/s7V/NAIZgugu8qq12gH2MiXhXjzQ2QvIVGrsODCPsYc/FDMkDqm+WopmJ6Dn2KnKRjrNqfFngRFeNflWkd+mokrA1V9z2cVFpZxxozr9WNT3ns6P1FptTYn0LKBRyq1RsnmCNiEjzFhFyvt3VYN54oUt+DVSB/Ga2wcRX1XBcO2C1xYYiNbTMQTSENj5G3xPW8Bkz87b88f10cMcI6mOZ7b9zjcOEXJuQqm/JRJy1XEqUK0dlMCnBSnAx7lYmmJ+kG8Q1AUt3iJKisdzuwVVn+xKOY1Fhv7ZVkmiug4AwSOzZJMPbvH+G8yAEwRp5L+ssvt/J/mohGS44OOGOYcw4TOmyY/kxYlMW8G7PbjoQhxm7t2C+4M10Ey8zMrjtWszLY+phc4lqm5pihHJHv/h4i1bDUWVdCsCoMKkQBOTZjWFDAcihNavG7mGOPmA3HE2KQitti5LmAUO+OPjbh7nm4oFp3ySZkwIdKDPKWL7p2rjyWsDsjwyRAwlbhk20R2wWxb2i2xHeA1NBTNfzJWwzUEDg8O203FQB3b/onTn536BqgixYTeJb9DP0qPK1CppDUgE9Hh3ERae0xh2R+OYXhB62S5juRVbAVlV1ywHZuuJgbCUOGFAj5TrNu9Jw886YA3rL+M1cPVqXPegfJFUsyJwFZX2I2Yc2AUhk5qYWgIS7d/yryyO1OFS5YfPe/MT78w3mpXHNiWpmauYsLo67jtmPqpTZUtNefrZVdohAwJsEk/IuKVLNkG9ZKdqKGXtSt0XpIkhmsBvFzLMTSRfYW1X3BztwoVCOgF/NzlsgElokI2SpDHYSCNbOeohG8djPFSfCYtW770E+/xxVVdTGAt6mHQRZL+euu2+wNYjvQzmGKJwdEx07+kYbZITDu1sE6jqyq3zM5StbvZA5WPS5VfKseIeVGYrDgdUyr3omTVvVs1Q7ZBzxkqpg2ssN12ZN7TMf3qz1XWCf55Xo8vTAHgB1e1XQIramOTc+6MBhnbYKpv+KjzUVUO6BX/gNnO3br3uo+sboa1DaVUP+TWodQZfmIfu7vGft3wm3NAJnsyKp9pjwTkBxAQziteEVSF7PRe6ky1nL6fy3tVFOESpK+VJUppUQ08CMhLLDc98SkDEuDzZCU1Ij4NAuWhTlXtyO0hzgV/+PLdj/K+8Mb13KICXK43SNUKGK3FGzxp1w4wwWy6JIAg0pcBM8vTw1ZFEh6buzcwA8BR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b720bba9-f0be-40a8-4fb4-08d900b89aa1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:31.9733 (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: ZCn2tanUhjVLE7jyYHmsHfLugWxnkcpjp0/Okq8sftmLDUt1g44C2H1RuR2k7apydNkregr9xqSyCrNgkXNS1v0ysN6fQO4Bsyf5edQoso8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4800 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: i7S6D5mXgiRK94-8oewd-8fXsitzLNMm X-Proofpoint-GUID: i7S6D5mXgiRK94-8oewd-8fXsitzLNMm X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Originally we added this patch to help modularize the attr code in preparation for delayed attributes and the state machine it requires. However, later reviews found that this slightly alters the transaction handling as the helper function is ambiguous as to whether the transaction is diry or clean. This may cause a dirty transaction to be included in the next roll, where previously it had not. To preserve the existing code flow, we reverse apply this commit. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- libxfs/xfs_attr.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index f7ed4e2..c356238 100644 --- a/libxfs/xfs_attr.c +++ b/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 Apr 16 09:18: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: 12207201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6DB3C433B4 for ; Fri, 16 Apr 2021 09:18:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A99A661184 for ; Fri, 16 Apr 2021 09:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240870AbhDPJTB (ORCPT ); Fri, 16 Apr 2021 05:19:01 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48310 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235231AbhDPJTA (ORCPT ); Fri, 16 Apr 2021 05:19:00 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G99wVh166527 for ; Fri, 16 Apr 2021 09:18:35 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=gn0pEXl/tbbSf92GO+UUyaYMesazZksUIGR8pdNb13M=; b=Qxi5gzuPu4d2nhpxtp12+W/7Eee95kDNxpBGnLh4mFk48II+R32fmxGlHmApAUqFFdRX e9FJZvKEf/vZLLzFkA5t6uWx3DaLrusSnZyLXvL94T38CdeSyCExft6fK0pn8T0LyAHW Xd+Cyi5pwwliCgR9LH4XjnGAZf8vCGIa/bLXaFKoQFHrDwThlNch50ZUWxixH4P1ZRrO JCHGLc6wVtieVaEtdMntsSo4SArhD4rm/Q3PBD/7IEn/sn+KxPQ2krKGIWB97kroiWQo QNzbOj2X5AnsRcNRAwafPmKKP1aSQbceLdpyCWMOxOgK25iUiepEWyaL0vtBG0Fb0VfS Wg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37u3errkfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +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 13G99dBM182009 for ; Fri, 16 Apr 2021 09:18:35 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 37unswy4uk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f/bDLtnQ989mqk0d63oTnP4mGO8LwhbIrYDOw76vvWOQmyQHpTgKztQslalPC2aiPmSTswcKPSJmnK5+sM0YV7HDot9XmAY/z4oHngFymGSFM9xB3tUB4JYgefICJh/uUwRvFBSB1qfjyOk+20YQZESkvZb49Iby4wF1IIx72BqlefryTbMB2JkhcAVETWjowbMkuvnDRJubKziDRuBhhbzU90mfrOe4soZpvVNRHvrVsFZaW6R2opa83LbUKNpke8+KCyJLig7pobMKHOkLhwBOwM5eEE8sWljr9DsBn9Y7nDLKZiuoEaATsjCp6v5qNufbg0DbHobq7bhvS+Ww4g== 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=gn0pEXl/tbbSf92GO+UUyaYMesazZksUIGR8pdNb13M=; b=dTUztMFe+1GoLyqbfWSyweyWNLOhED1zNADZjOf0ZaOSqRi97QMIppxzZHcrPGR9OsGI7ece9yful3TELj2CcyrI32ez2WsbKCYDMCOc5CXdrbikqBZ3/nzvXRLdN4M29QmUN7JN6YroPNkSqEdpuL0QK5F+y2zQHAFQPH3x2GTSJDbVCi2rlZsRdoz0Zjo2feKoTa43dHpa02IO6bXZl5zr4pHs8YehCvW+7ceP8T/MOUVt+AqWoDtX6iL1tJCqMTOJ4p6QW3CyZNZ3ac47S43YddKr647367u8lTuCG0WvnlJcX7kAAjVJ3cS84l66P+ZO9/lICHimpehQxoIZGw== 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=gn0pEXl/tbbSf92GO+UUyaYMesazZksUIGR8pdNb13M=; b=zKKiWn2VbvnOnPxsJ2tDSD///EGDoOAvV568hLY2AuKEnQTqcsYmoLk3hua/7TEAU/DOMTmrxa97cRx/HL0ac/siJK1sW2Ynt4/WVEVsdljd2e5mgg6APFz+5C7nLrLspuFtEzigcXZbEuWElQ4RTJJxY2QIgHc4ghNSHzoVD48= 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 SJ0PR10MB4800.namprd10.prod.outlook.com (2603:10b6:a03:2da::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Fri, 16 Apr 2021 09:18:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:32 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 03/12] xfsprogs: Add xfs_attr_node_remove_cleanup Date: Fri, 16 Apr 2021 02:18:05 -0700 Message-Id: <20210416091814.2041-4-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 930e3ef2-e322-4c4f-1133-08d900b89ae5 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4800: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:854; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0yU6fo+HqRiwZAJY3PLnUG8lvrNA4ULdpHKno4lETx4m69TgaZAptK+QXZ1LPudYapqhF3OC5uHe1WHCLtBQ1QgNtCqtNlFivabJibVrCgeqlqFhPnLQSoZI9nIde+IMgHagy/M6TR5jlLQoXUfFkkSPD/VwbY7OmArDC8B7fN0zQUpV8I44EM8bjr7PkrKUD8jefecEqVidAbC6lqmUXWBPSVVuKOXRIOPPnqaYRzyZtdbg3ens9KAklrHUe9m2qSRdh/ikRMW3TqlZZJS+7OqUqok6zY9o+dAfZ0brjQ99XSj3tsbbx0L9Y6hd9lCCfE7SPE+sgbCrBT7RAWSwOaCsRSvK1IhkFagroiBXVPMtccMQA4KK9zsFcp3h4BI9iXCd7476BSSb08C44V6ihPBPrPM2rYQChIvTaCanB+2eB7e4wCKT1XNdVchrZEZl09HM2lBHG7NsNGjT1JIm2c4aP5/FI7BKnwY6+E9WEin7EUwbNvQInIb+oAOur85oT34kQdKtzhsvfL7aP5ZA0DCtcnYI3OLDPRC9J61KZBdTUaJQ9WsB25PQhgpV/L6uEuzQ4kTWuwIx/20s16IEcbcujoI5DgC7vmbcn7Nq3FEWSOWpamJ/tzD8r2qS+J2dxAuUcREF1TlvfeRa51s20Gn8ORj9BcL0GJPO8S8iEMw+HoazIwYf9hGFEZVK9EJ2 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)(346002)(376002)(366004)(136003)(39860400002)(1076003)(83380400001)(6506007)(5660300002)(16526019)(186003)(508600001)(316002)(8676002)(6512007)(36756003)(8936002)(26005)(66556008)(66476007)(69590400012)(44832011)(66946007)(38100700002)(38350700002)(6486002)(956004)(2616005)(6666004)(2906002)(86362001)(52116002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EsxT7DriFWmz80xy5FTpVXk/6WI4M6E0lW5LbACvUivqGTMRwv89oWYD5hmVqP4qW6XNK9NSQWfNpQyLMyKg61SNlrGAc4PmBa8uwxzyh9otkfFZxiUzW5zJmnBg+7J9gaCIZrHIGV3SEJ4J1lBpm970ti1GsIaUQdUthIt43NtNhUmzU5hMYHefpPM/Vgt90sW8lPI4707j1cO2+QvoFItiB/StI9RiNFb2QSkSujmca4bRPfllZz6cq+dWyN3SF6sc2Lnh+0H2A4zu8wMpgowjTUe0KfIbrDXfDGQyo+5BjDyA6CEdtI/o0hCanp/oYa0/sNZ+bhbVE3vOH0DtkwYEpT3xvwfZ9YhWUP8ivSGNGZYva3I+MwPO6sVm+zjkcvVDrR/lllbY2UAIPTC89K0+Oo5UArgodti2S83BSe1MxEhjCV+akOur1CDicJuRea9bpZG9LSntH86uEoMWyb3mV1fL9Ye+wYL0K1LmGJwIcsuq31mItu3V9zv20jH4i7bDFxv8rFdyslBqGCsyigpVtwdcU6FgAlc5Ey1tI5JGvtWUHopAvnUnTNwXW9RSpvO2kS+MzOa7ZX/j71oaYa89zA0y4cdjWijLtwm2KvYjNUzhPH9IbNhi/r4hV03hMLzXxr2xOHe569HJdfzllPKSW8XFvYTages3UpAneyOhQhKxkqKDeVDOaihDWXqfNRCWkQKxlcWi1gP1TXPN5CPZqVEhzGFxRvE1uUUg9BoBUSydyk3QHm/XBBf6Iwg0kGZf9p58J+uHBxHVlz+ZcQCu5jzd92P4vTcUzAusFQu1u/Ejha9YVjzSiWreVXgV7ATnbuJT2in6vXQZLUMv8/fj3H3uMCKrQS1LyPxSOVIFce07zc5uJelgkrVxGTlWXRpTx+pB7V4owZjx6TyC9B4h6njwbFSN2LZNvkCK3kM5ilsS4HCReYYrVyc8kVx/qHBXRTYnKlK4bJ3iFLFL+qu14KIoi/cfB3xc6lU5yzjoQWQ7PnfyyMCMLDrJnMYspIr1+NtNlkj4JVKmZP9Gm1mGVIhEO2VwuRqQON0CHbROzy6fcqwbieBEVJjfWoq32NASrG9dErK2S4AyW+TPoL2owC067BgJgRK4z00zTaXizJPfuBOdup518jEfTbfOM09peyWIu1pYV4k9NLLAJwUNit004IT6ApX9N9S+O5migiqx0q1XrlnRdo8C+UDhfBR/VKlamUIAbS85ZSHHQ96Ss4a7K47L3ahytF0nXgQdOO/ypkc1KC1isCwW0YK6DZgZJYCgL8PywaxKAnOXc1okj7qHLXNEFBIxLIXBE+bpbBEjnuKcP4P/ISqMkjI0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 930e3ef2-e322-4c4f-1133-08d900b89ae5 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:32.4034 (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: ydCAJ2f33p4IHbuRfPiSjM5pMVzL0X/cvS6IbMSQ1t/PP3jeLM0yrJ/7cLgYPUWtztGXsIuA+fiS1g1Wqn4yzzqYmYDza9s7/BUnJqZ1lQo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4800 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: C7tJZsIZz_Tipj5hnNqbqezZcYDoByF- X-Proofpoint-GUID: C7tJZsIZz_Tipj5hnNqbqezZcYDoByF- X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 4078af18570ef0f89fce18e9ed9c1fa0c827f37b 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 --- libxfs/xfs_attr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index c356238..956a832 100644 --- a/libxfs/xfs_attr.c +++ b/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 Apr 16 09:18: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: 12207211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B708C433ED for ; Fri, 16 Apr 2021 09:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F32C361006 for ; Fri, 16 Apr 2021 09:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239914AbhDPJTK (ORCPT ); Fri, 16 Apr 2021 05:19:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48322 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240975AbhDPJTC (ORCPT ); Fri, 16 Apr 2021 05:19:02 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AnBB166977 for ; Fri, 16 Apr 2021 09:18:37 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=wQExIpxlrPbOXVkePj9CC9uGZt+ZgNQxY7HaEDpUTyc=; b=F7wOcL1VXv+ppDUhoNrMg4JlcoWJRNs/I1eXSeYuMCw+p47tjqf6/9rxVR5TODtbn9xj gLSDmEedf0JFCdWwXSOzoz5Sp6S+q5phEiHqkoJKKoXqg/8ypkjEqT0W0KBSo4nt+JWn qJithwNtdrfetEOYAWUkjc4oqm1dk+3O6Y1j9VU3W/+UE3wYJD85InChhwHo5Gv1atdc PRdwcbgFiitW7AoaPFugsrbxGUH4dYfWX7o5AqdDCbBYr5E9ZF3AdmXhy8GHPLLbdrnG JjQecbmnWF972JUZ94jqJLXO8n5t5ol0lYYxFWHtiY6eYYHKXJkWnF7CMEf1jT0/xzAN 1A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37u3errkfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:37 +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 13G99dBP182009 for ; Fri, 16 Apr 2021 09:18:36 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 37unswy4uk-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=micc5vxriHwFfqkKGvQyAoBW67bStefTBtEVgmvhKn2aPSNWAMl8ShWmOuFPBS4elfKx+ndq6NrA1yo6yLASwa681jLkQ4OXHPPprlBWKNkCg9ZhV1Ck/uIijkCEjpZxCI8nJUB5GqdPB6LJOgspv2zkMJVtcVUFc5qS5WsoAEaflgWQ3gAYYUJs/vvGupn8TJ8Paj/pxWKccT04pjl7i9JS8kUBiNz8ESka5OgB16Z8oMJ7AdDmi/cjuAzYD4rWI/Kt0MLM3obbgM7bZh6i6u81SSb1bgZuw0wdOhblzmIEAZFf2614Ca5udd3v2HIMAhUpiKLEsW5sHyTYwc37jw== 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=wQExIpxlrPbOXVkePj9CC9uGZt+ZgNQxY7HaEDpUTyc=; b=E+vrQB2i4UdanJ5PhN/8nAJaZrWzpO9tcIDbJT63bzHychXAktC56wwVvtOrOj9WhMMhSINKrQKURNLrn0lltjM5qkU16oysh/HwbkCZoGR9RcEPbgfab0+LQ4QMpLKnqZ+YEjUwb9HhxK5dV794IzX++ncku1Kq/cGlYdEb5fplB4QFd7ajtguzhTfKwrYoF2rZGV65MCAA2BYSu/JhDmH7erStyVZpIAUW12fQfrpjwyoy230o3jyzPtZYG9mQ3PH6mJNNTsyLnr4E8VdSNkx7j99NEPlosDiwefR/3K69803Z7/XN8hytXg5oduI+fIaNHjZfLqIT/0rtgHI4JQ== 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=wQExIpxlrPbOXVkePj9CC9uGZt+ZgNQxY7HaEDpUTyc=; b=S2rZjBjAP47uNB6zVLSod6TJ5maxTFllVQEepBQy2X5yLWogaJksnnvpTAI/3gBUu1sGCSKCHiNQo4LJ80RncsCnu8m+IgHgXULNfGiz5T7UglpNDbWIj4gPra8cJAp+423fqJzcGozYkF5xcwfPEx3EUIJnYkT5JdBqIYF8O0M= 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 SJ0PR10MB4800.namprd10.prod.outlook.com (2603:10b6:a03:2da::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.18; Fri, 16 Apr 2021 09:18:32 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:32 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 04/12] xfsprogs: Hoist xfs_attr_set_shortform Date: Fri, 16 Apr 2021 02:18:06 -0700 Message-Id: <20210416091814.2041-5-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3182b36-6e1c-4dbd-ff95-08d900b89b1a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4800: 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: xNgX0VzOK8S+ChVsT5B6kFnoCpnhZcYHwrJLayqbDhGo3LQaum+wzFQD0YP500rpZLrLRw0EsSzbpRtP8QYwQtxrvGp/no48wSHlFY3ahb1nYAE0zTFyyabK40iiUSw6Kvy6RGzrttGOLnIrCkAp0Z/aSeOtWFmu0xcDF20urecJ/kgaS3gnALvopVdx4qEbk0p1h7NtZjXmDxJTzLKwiP3YDGmo/qB4YipyZrXngq3/eNEke1A+Z6jfwxIa1UufZyohDyUllEyVQWwU68J8pGyMNLyAnCfxwpC7hFQa9pyGumrogq0ZE9+S743KeaQtwc6mS9YKFSl9KNTBYbifpdujZdGE6tamf+O1qRFpAEy5SCiIpSFTJ8nU9DFx3D9GrL896M+MH0AMPyy9vYS3oAeOCZwgJ2aVmiB309LGQs+8edO0iJ38gMskdyWTqbjrfmyJ+e/9JMGcFfDqd/ZAmTkm58NNUqRSOtKK0lodErSygxo1Rey6TFvsN95nehsp8jXx7b4y4+NwZfXMJ9JHC4RMAcnCIVL5ad34cIS+04K3ddxETK24s836PtpG1JZ1sJg/2mWIrsBM1DhUD3mBCJc4qhQp+VX6prHdeEo8s9OSdUYk72ZcEDavarLUV2Y7wQoXHvlxQ7QaMqxJ8gpxAweUpBa+97+OzrF21Gsmu6vWx6TEc5zNBdgoYZxA8Oj/ 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)(346002)(376002)(366004)(136003)(39860400002)(1076003)(83380400001)(6506007)(5660300002)(16526019)(186003)(508600001)(316002)(8676002)(6512007)(36756003)(8936002)(26005)(66556008)(66476007)(69590400012)(44832011)(66946007)(38100700002)(38350700002)(6486002)(956004)(2616005)(6666004)(2906002)(86362001)(52116002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DkmOpixnTE7QyZ+wt3UdwvUNcI4gq6x3v6Vhab5dQLhVO7LdPqk3vZEXUbPLKyDpYtsboASkhZoQzhj1s6RhWZrELzdRFmLZBNKeePm7dV/rU3i4NDC6EUNe0blBhhNTlh2G3SCvzFNxQEIwJCzTAFHnlotWUaaq1y2Wt4naOeEZAIOYXe2RSeEe1BDUhcv6f1AMgyIhWToXUUjAp68ivMssFChOk+a49NmuGpqwWO6rTY92vSwjDl1Aw6jIjip6wGUx4Qa/TUqcQK4HsA5Hy61C9K/7t+hg/cRM0sQU4kPCMoclYDwbJYyND4O7n74ZnP4QkT10rThnvo7LL95cxajXDk9cWMfsZY40UXEylwQfDWZ7blgoceVB8Ej6yb5EkJbLDs7pxRYW7HrtaZ9AFhp7+l3WFZFB+7scidfjRwbQzQIgKCNYB/1YWWYfC/GxfNHBXSWACpjrnLabLIZa2FL7MfiwmL7OxN4mxBIVFL6DUIBX62EIOf+rNy6mxgmvNFbFapJzS5alfanMw8McFgHUH3kGDTNCUXypVPiu2sEC3cMy++zWjE7MA3rMwRfpse88VDGFaefRd4oVnO2StBeHMMDvmn+6fv+WgalA2LYObIlsTxGFGmYO7X/lbG+ssutIXKCBc7sKret5HI5/X+8khsPibMXljbSJCUWZU115WqK8+l9f932aJlD7vPes3tlcVQfBhy7yN0LTSv+Gn020kaY4dSBAQXz7ggiElMRA1eK1z+FQeih5UWd39ys5KBUv2Bc4wcNmP0nxdCE6Ahhn3SDeCGgO10geLqN7NILqbvUb7p+XoTBCByDVXFKCcfuAhBzVo1jxoDQkPxB2YjUyeMT8LH535SJN3D53vvSWy3iL67nirPc45vZrraC0APRcLOkWYw2+MW5ptCWfDM08AEg1oQhshh+Yjw+8Lvk6jEok6uMn4cOzBoIYb4JX6eZr9x9wrWPuII3zwB6gctPTYCqV73rftn3YIhH8tD7yg65AWFHZ9Q9qRB7qipD2sA2xBpoLHLnF09McJpHkNrpAEvH/R0JkdhQWJbeTopP4l5M5qPNzH1KXUEUUaZaJoBxCU6LicoCJJXfEZDi7R/Almet1b3KNtYAHwz7DRZaIL1kDr0QjO/Gxs7F3JS+J8bmEFsPdsN3WS9fgP1qriq8S04vzucH7+f7stjiQoyWW8ClIos6SaLCll8IYwekNLc5M5tYzxWlL+tsZDRsj4yWdjO0C7qyl5ab8PlkAJ8SkFsL3fN7twvr5dKCdLyCyMMo3hS44jl6fL0a96uNQPHHwU0PX4WCc0YzTHATnRXsZntYrYG+aLB+iXcsZR8k9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3182b36-6e1c-4dbd-ff95-08d900b89b1a X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:32.7230 (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: IQGhsTUdQWRYSSABBgexBHtfMoa0r8upwjVf2t+nlu/0er3coEj/8sIxG9GQVosPUnNjuBDiGJHrBsiVA67nQ802DnOm4f8fIvv1CgmwKmM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4800 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: rhfrX-XAM8AdBjGxNXa-v9rOYRNnhYiB X-Proofpoint-GUID: rhfrX-XAM8AdBjGxNXa-v9rOYRNnhYiB X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch 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 --- libxfs/xfs_attr.c | 81 +++++++++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 54 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 956a832..30d29eb 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -217,53 +217,6 @@ xfs_attr_is_shortform( } /* - * Attempts to set an attr in shortform, or converts short form to leaf form if - * there is not enough room. If the attr is set, the transaction is committed - * and set to NULL. - */ -STATIC int -xfs_attr_set_shortform( - struct xfs_da_args *args, - struct xfs_buf **leaf_bp) -{ - struct xfs_inode *dp = args->dp; - int error, error2 = 0; - - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - /* - * It won't fit in the shortform, transform to a leaf block. GROT: - * another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a concurrent AIL - * push cannot grab the half-baked leaf buffer and run into problems - * with the write verifier. Once we're done rolling the transaction we - * can release the hold and add the attr to the leaf. - */ - xfs_trans_bhold(args->trans, *leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, *leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, *leaf_bp); - return error; - } - - return 0; -} - -/* * Set the attribute specified in @args. */ int @@ -272,7 +225,7 @@ xfs_attr_set_args( { struct xfs_inode *dp = args->dp; struct xfs_buf *leaf_bp = NULL; - int error = 0; + int error2, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -281,16 +234,36 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; /* - * If the attr was successfully set in shortform, the - * transaction is committed and set to NULL. Otherwise, is it - * converted from shortform to leaf, and the transaction is - * retained. + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. */ - error = xfs_attr_set_shortform(args, &leaf_bp); - if (error || !args->trans) + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); return error; + } } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { From patchwork Fri Apr 16 09:18:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D332C43461 for ; Fri, 16 Apr 2021 09:18:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3D63611AB for ; Fri, 16 Apr 2021 09:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240890AbhDPJTB (ORCPT ); Fri, 16 Apr 2021 05:19:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35032 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239914AbhDPJTA (ORCPT ); Fri, 16 Apr 2021 05:19:00 -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 13G99K0g026179 for ; Fri, 16 Apr 2021 09:18:36 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=la5nbg9NmKhmFiVUAgJe8heJCrfXb2X7CSyI+9IYPa4=; b=Es3xPMI6wzh/IlxRR4vi0YWjGKok9wYNKPBxAWgK3Y/pf5N4g9Kqm/u3jRHyC44rbmE2 Bfff6tXe87n6VpXbsNT4vWm8AYRGT5AyePPf49nigF3V8swCWvMGMuOWRh+KULxqnM6Y 5q2WlHYUjFrD0gEiKypk9OrMpcIECE6KTHcuQvi6xOUyK8uNHy7EpIfUL9kKwW7F42C5 jdcBLT8jQTW7AQ5mgEDjyZhDAzDoSvgU+oihBGNMEhI0ONqsZZZAwhv8dmCwzHIYxAGf a1qV9VKqGMDDyvZcvL5jQuAGxDdYU0JzW9vbyV9fsmUn3vOdF1wtZkI5fqFsuoS5uzOu 6w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnrh8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpU077087 for ; Fri, 16 Apr 2021 09:18:35 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qn00NTTiD2jmRyp4zClAbYPh6RQDGyRW0z+ilm+n7UFUb7xddA+H+0OdoJnqp3NdRqBAqMyolc4cowq98zA5TckoKz4Pto/L7lZaQOyUtmJZmH/PcAlKWpysCGvgAviuyAhFmB4uaAcbAAjyoMh6SYeuvGtc1ujmZ5V9j7CIPMmmCpsSbsCy+4rTGUcBsQw9P+WdvRiz1uzf1tCTyr98bq/rsrfZdvYjMTYLfC8/ie0q+oC45WSNH5L1+AlpfH5lUjDLuwrqgg4+ZR6CBirWysUzXebWwc3+rEoFBa9ibQ2x4R81mbduFajUYjZYoguBYnXD60Qf/EOH4WKeNvIV9g== 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=la5nbg9NmKhmFiVUAgJe8heJCrfXb2X7CSyI+9IYPa4=; b=V/ze6FQcGk/mLt7f0fb2MT8ZK/0gvbtNspKrK9Ix8eBCcVC/DT6i1/BsJo7s84GZvtoZWf8EnRKF5ruL13VHDcukYAEfxTHYoMWqzMQ3713Sqye0CgCEy0oJnnf6OaPYOWic/AbNHlNxBRzkFXJ1n7HPN2mOqF/yaM6H+1dSpKGhtUImkpAWh5dkVDkxJB0sSwLNn8wEb6fGmsgXyX8QDllikU5MK/64GRvOA49FqzYE+M7SxGxfv9/dE0uhUGls0lh+rwxNd64uG6JABOaWNtBY5U6azfzUTCvlGfbqIFURg/ZOJae5BIcyjk17YmyukFyvNfeLTQkkesRjm70awA== 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=la5nbg9NmKhmFiVUAgJe8heJCrfXb2X7CSyI+9IYPa4=; b=PGOihGDhlafDuqk2NzQxLAtGp6s3RjVssob2UygxIgm1sqCtJS7+WkqeZhgRrmrop+bMiE8LLOJpNJ9PcFnFTGu8F46OyU6E9pxnDuUqvo1iFjX5O1TX7J1C5w4r80hTQpmAWereffewWVzkRyD0wDJYUrkPaysVwmFNOfo/xpo= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:33 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:33 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 05/12] xfsprogs: Add helper xfs_attr_set_fmt Date: Fri, 16 Apr 2021 02:18:07 -0700 Message-Id: <20210416091814.2041-6-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6ab935b-bbc9-4f14-6c77-08d900b89b54 X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: 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: rW6KiYjGcHC3YEVXBQbcx1Hf40c69t4v69GNWY1OC/0e7KQYOsfyPF+wqXOOW2CMkI8TjYsjwTQ89rk/C4NNG6vgbDARvGp5XgbDmy+BZ/vxL3Ri0e0gRVqpEIHstCPIc+5tgwhsSjfXHVrx3t8LyhbXirjpMgq4d7lHtSMLdndMj86WPwka/ATE7NFMJ2/YlcBw6EZP1hxfjUEavGpD/te/xfWIPmdA107hBbbmvgNidB2phBCLIPGLEtnYRfLQIU1pw7CgA2FOZcPFK3MqbWukkut9EfdccBsFohRSJkcLibwUHYQUuci667WJCZwPZzXjjUb2IFkEqs3oxN6qW8FUu7ucajRJ09VdTeRfCXBIvOM828MBRB5E3V0FjF9aV3ADeIgevTDnSWLomDIgDsk4RcE/WvAPbAjXlPqdUduR1IvT03iSk24JXEMNY5oJfmRxcoWMTqzIwdNX+klR4U1dh+Hhi+68Bi6QUjYr+tG6WUpiuDbqWQeZ2+EvaG5j6Zq0JF3vnxSweoHha6t+m121M3XLW5Fhe/Z+Yh6CkMaUfjWFtFIu0d4dnoLfq+NgxriehIf6SXlIYywneG6vjK9PyJRgH8cLf+BXC5jdj9WHK7XRExeiT6z21388H0kjck4tpKgxK7ibd05NitHG6l2JOi2sS12B1YxaMKyOkd1QUCLCgaJ6Hf398rAujKat 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vfV1BqHJVxmOuT4qLwnZMbqicUpjt/HOVGihd3vWERvzhH4WJ8aWjQpEKF1spQ9aWRspcQAqrujg7XGXSrLQdmvK1MiG6pW9xLMsdLxy9uZfUY5ofoNVys09FgpYnJnnhFEem0xGkuQ9PB3ljScunAdVnM0xzJJsmfSSynLRdrBYUZxAddSIhxQEr6KfxeqpsULW6wbrX/hlUxpUx5PgQXehbgXRU4Gk///5Iv/MAbSj+beLcJmRlpT2h3X7D9P8pslMbCBfHvNUpq3258apMdznt8i9OAqd/3Y9M3zpja0PNniH2/oYMEFkkds5Nce8J6fSfy1K0Tbj9kQSGhMMs4wXPNQZpoHaELUc3Lh6fnQwk6+mg7+10l6DQo7By1RODAxTW2U7lStkkomSf5X737bdzMNvXLjbM+WeWrdyru+Z4hWd+QXJ7qlo+cL6dNYjSrSQAN7XYCHzyUcPjs85u2RcywnwtEb7D1n+oLfnorAUNJykebzF/Wev/4zgdpuOX365RojBJAsaZHeIovN6mZAPMjulTRiLNKB28Bq1Zt6GNWOqacIbUB/e3v3d3MQLVGlpkBj+ztZJoynM2Sg738r029EuUi5NlEExV+mypz4hw3ON8nxe8YStooQZT78OGXCad+nWPMp8nL4KG94FBTo9cZH32xvklm0e1abI8/Jvll69AQ2IQNkCw3hTwZNm3zb1gnEGKTX+/ra7+irp9dd26O0Mr6wzJcG1+bII46/6/uoosuuB+EkbPWiQlk6jH3IlbCwVXX6t764x9mc6XODyP2evK3++0A/lWBWpxFruT95E8MH348dNtm6gxYyUCLlrR6VIGilbrlQDMXQzVL4PiRF2KCEwXjhlVu4ex/+A9oPo6BPGteOBFZDhu6BzhVqu7RJStbKBTuuQLQgleLW+scyZiXpdoekO0bDecpCQf48mtQAChUBrbAG7iEEBvxBIF2qnN5OK7adYAsKvtFG8jHPWIpVM+yphHS7gUJBFPb+8n16ah89MH/6VOKL7HBAFRPkqQpYDxif+jQxz6GfKxCojlUbVzgwflzSljRyqUoHzzHA4GAVUP6dTe3ddqYzxmNEf20EDrrsUuaHZa7rMVOWl8GuW5DkCy43HcmRZufAtQg8VcYAKozKfAwiJk41FdOA6Rs5r3vodU0CglxJ4YWVVPmwEPyxa7Oldl0cl+jPgfyLDhn0tXwGa1mS2G/KZMdiOvplWl0tDO0jI323imUBKomwAeeEG4mofpnJvRNxp4DWBPxMVzw53yoCdQlpsOmPOEIKJza/cgC1K6pd/ojYl7AmqTFgleS/RTgx0aVcMvaUp+CLREUNz5WMj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6ab935b-bbc9-4f14-6c77-08d900b89b54 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:33.1172 (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: i9TsvMF8pV4GR0MlkFFHgnzD8ulUsFdAjLZDGPxh/tX/z56VLFbsGTwPG0tuhK/ikVK1SHgiiHa6HD/s1hX+8V1+fLeeB198dSquUfney3c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: SiZzlb3UPFPht1PFcpWQKzd28fL8D2DB X-Proofpoint-GUID: SiZzlb3UPFPht1PFcpWQKzd28fL8D2DB X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 45b71a4f3fd8bc8d47adcbdfd859ed736a54e66b This patch adds a helper function xfs_attr_set_fmt. This will help isolate the code that will require state management from the portions that do not. xfs_attr_set_fmt returns 0 when the attr has been set and no further action is needed. It returns -EAGAIN when shortform has been transformed to leaf, and the calling function should proceed the set the attr in leaf form. Signed-off-by: Allison Henderson Reviewed-by: Chandan Babu R Reviewed-by: Brian Foster --- libxfs/xfs_attr.c | 79 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 30d29eb..40d1e6e 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -216,6 +216,48 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +STATIC int +xfs_attr_set_fmt( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + struct xfs_inode *dp = args->dp; + int error2, error = 0; + + /* + * Try to add the attr to the attribute list in the inode. + */ + error = xfs_attr_try_sf_addname(dp, args); + if (error != -ENOSPC) { + error2 = xfs_trans_commit(args->trans); + args->trans = NULL; + return error ? error : error2; + } + + /* + * It won't fit in the shortform, transform to a leaf block. + * GROT: another possible req'mt for a double-split btree op. + */ + error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + if (error) + return error; + + /* + * Prevent the leaf buffer from being unlocked so that a + * concurrent AIL push cannot grab the half-baked leaf buffer + * and run into problems with the write verifier. + */ + xfs_trans_bhold(args->trans, leaf_bp); + error = xfs_defer_finish(&args->trans); + xfs_trans_bhold_release(args->trans, leaf_bp); + if (error) { + xfs_trans_brelse(args->trans, leaf_bp); + return error; + } + + return -EAGAIN; +} + /* * Set the attribute specified in @args. */ @@ -224,8 +266,7 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_buf *leaf_bp = NULL; - int error2, error = 0; + int error; /* * If the attribute list is already in leaf format, jump straight to @@ -234,36 +275,9 @@ xfs_attr_set_args( * again. */ if (xfs_attr_is_shortform(dp)) { - /* - * Try to add the attr to the attribute list in the inode. - */ - error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } - - /* - * It won't fit in the shortform, transform to a leaf block. - * GROT: another possible req'mt for a double-split btree op. - */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); - if (error) - return error; - - /* - * Prevent the leaf buffer from being unlocked so that a - * concurrent AIL push cannot grab the half-baked leaf buffer - * and run into problems with the write verifier. - */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); + error = xfs_attr_set_fmt(args); + if (error != -EAGAIN) return error; - } } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { @@ -297,8 +311,7 @@ xfs_attr_set_args( return error; } - error = xfs_attr_node_addname(args); - return error; + return xfs_attr_node_addname(args); } /* From patchwork Fri Apr 16 09:18:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 105E1C433B4 for ; Fri, 16 Apr 2021 09:18:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E259E6117A for ; Fri, 16 Apr 2021 09:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240975AbhDPJTL (ORCPT ); Fri, 16 Apr 2021 05:19:11 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:48386 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235231AbhDPJTB (ORCPT ); Fri, 16 Apr 2021 05:19:01 -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 13G9A2FZ042760 for ; Fri, 16 Apr 2021 09:18:37 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=Lu/xJXQqK4Y4s2QPouqK+GV/fyLGcZACOwf4ZRKDonI=; b=qrEMrKXF7jAQGySmwWGnb7kPV2RQ9MmxPab/MgGueXd9fRfReu01P8batfSj+FolXxe1 1HciNBmEw33dHtzVVqmKHcqIbtkzr1Ezh1FSh0V5j4lJW/rlI54q8BCyPZdFWCT2vV59 8BUVDVKH6YygmMZRSI91FKkaGu+er79lH9UCgW8sWiJbzJhGPw7cfEVWjxi/5U31gwz2 CRNwE7uXFe5s0y9CbVPqkVnzBTNd1ykvMJ/UxJADmSAZlwtH2okJnmoA9Xw0wtABh+BI kMbIOwQgCoioFS54eiPFGnilAVDx3EdU0J7Y7UsZkVJCFYXF0Ao0xdGAnT3zWAxlb3wa 7g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 37u1hbrpar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpV077087 for ; Fri, 16 Apr 2021 09:18:36 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HPcC+w8ZumrV+QbLGN6G5KbjDPUAaEJfD6BRc8ANd67alcdAZMFYNN9jUqJKCnVbQ/bGIoV0CytLUBjoMCzryJoF/nihpOj98UF2ODgWw0keRLRSfzlOxDUkZ+Tmo+1GncAjCCK/GjRwR5ylEt8rxjVFhYg2TcDi/fFzabgi9vSUa/4SEUdc3YqOeISTPkZAClbve5RG7fjVk3fosuLiRD9TBdKeD4sjCBzFqG7VbWMvHXZuMQo96DL0fqKxP1B3JsslZc3FrTnLbCjZgGuHCOzo7asm+yEhdKWHU1akVAo+FQKSDuQq6tMctevMQu7zjq5rpnol8plORSfH0c167w== 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=Lu/xJXQqK4Y4s2QPouqK+GV/fyLGcZACOwf4ZRKDonI=; b=gBzlayw8TegunIGUoOE0gPASXY8Fj5Ay1yEBEvWLy9q9uvI9OuFA1dTH4XmeTz6kivmOUuONo+qSzaYvUdzCE47UQRH7++4XCEgoFoxOY8cnSrGFy2rmYXyTIAOSlR+bvFlgx/7LfsY3niwB3/D/2R2GJXzmoYg0jDKkVLq7yra4SQU6G2AIe9he+oXKrK4UtfXpsq0A1PTaUEsL46dF2tfwFOToR6va55ZapBO3UFpQITp/GCmJjHA2XsPYuIF87CUT2QfKQkD9DUKbL/uq3SAwuCqlKewU/YNedUA6Tr+VszM/IQSyhwcfJu8Lf/PCrnqfS4qHGVVqdZ6oKXMAEg== 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=Lu/xJXQqK4Y4s2QPouqK+GV/fyLGcZACOwf4ZRKDonI=; b=ESMzFw3NIENBcE2ePu2n/VkRrv02sMWbi9hnVZ8VOPdX3WJqi2qTFrhOEAjrsPxVAQHm2yKeP8frAWmCYuytd0t4WHOKd17yfQrshTI+xIXNikAgzXM1JhVbQICc3qt9nxfO6xxmlS+GDuvTJsNn1dot0t8ci+z8fY4tn1n/I/s= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:33 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:33 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 06/12] xfsprogs: Separate xfs_attr_node_addname and xfs_attr_node_addname_clear_incomplete Date: Fri, 16 Apr 2021 02:18:08 -0700 Message-Id: <20210416091814.2041-7-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18ca5dbb-03c1-4930-6b10-08d900b89b8b X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:330; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E8+Fx9wVB52O3A9jyUCV41skC05vQdo48m+14+G6yH0kCrkq2adp28HvlwgTQhHvCyTbiqLbo3m+xTpD9klk3hBq612eCbtufSEamQBoCGFnyA6t1ue8ayeuO+A0qhjevR7UGVvfNjOWaCKXsphWqGC+TVhGPrWIyPZpTg3mRwAaQ8JRuWUh+978mOMrsMzCFYgXxlmkhrLGE+MLevvzvyM0LCml0vvpBQyi8S1MDK2/p4EoC62Y+gYpP/O9+/LoCkMzjJoV0dJ8xkHvEzglzjeGnfX5qRDk4vfMT+VDL04gGG8WUZU3vZUGp01PDFj/wKX6lLhQI0mar41xieUShbIc4i6/FZ1jYjiCKgTk4regp5Xx0qQVUl3JU2geLmKYoOHvZAd6yOd/XhroK9S/UYw2oHWgI+ONbImODkrSH8Ln5lNAKUCu86ukRm+ExkdSAY8fI6gnIvPP64Y3wcwt2f4EHNkCTy/q+5ra6lmxU2F0ByaudpVVYmzWsyyKeRaT086s1q9nmugGWc12gMW6H/YHnCgepD57yuE3TmAezvDKIl1L1zYgv7z5GBUYef4NQMfi1zX5CKheWLQSoHzalj/RNdY7oFxDLjqE6FI5kyoI9lpSNwHl0ja5YILkljrYvT5qEp+glD4nE9xX2nfgnKVfEs6Xa+Dz80PwR3Ga7Xjt+4Eu2vPjSHjbGw0xYkg2 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2251lmaGQuZziN9lswg3YUwPnw8EjgJ7tBpRB6yH3COulonKzzEtT9y3ISnZ/mENwNUx6WyG/PsOzGe49vwrULORIgUnNAxa5eIIVAkvJ4T5rZb+q0l8NWPf+mHI0vUT+7haDxoGEQ5N12Hdxo9Hx/H3RZ8BLVdyyz64d/cO9Z7s+hcXrnqb+5NfiAGXxCejAnIbM2tEE5tGyHRFZZ1+WRfQFywzkZ88agGq172X5OnjbzhkXnE8OG9oFIK2GaZxvTthHj/guCE4/ulYmZ09dC8XN6GUsdnjTK0q5oK99fI3PG+70N/TqqO9LCaFwNxyjLL5bAHaT4284C8jydtmZAdxwM00oP96ejhZr7KpShWSY4K8pGHdXlq6NmQAXNKcdmZIN/bIhWzRGka9PC5sc8ewZjFXLV+2iU/IXINQ5bG8DSPR7oJVpN6OJvYgbiPH6naGwBZImRZkfe1eL+kJLRV3zIRrC/V8wb1ELnNMMGSaPhkEoP1HYbIW2KSwLJWig5WeyiaBl3AH069KOkCrrKd3aaHEdkKkyfH8gbZEb9fZmtJvuox8weCZcBgmGjYrocDcE3QccNIer6zQwnLAOgL5EIeZGHmcIh3blcS+1X829w6zjaRPP5yvY+PoKKpKQVdMIEcFd/jxHZ+lzPSHaAcFSoyQqc5piNugrkUx09PQGP/mrhL6rHRBREkClz4aRaD5jBE1aSRTR9/qUMD5GYjzGXpJiveI+ZGVYrmL7T2d7s79uIGRwGapM3juLn5XByikneHgB0KQcW7zRFcWNPz2A6Fmfis1/0pNtwgJnr+vrsvYvSnu9OiqniCFIGCYeH9BdGV6ZyTTsHFQUp0y+oxsstLH4xixg2pfG1bXTshJVTLyrKwBt3u9GkFHJkHOCBNvlZayJ0hDo/OUsTKnUTSNhqWBXvT3mxtqjHzvGmJs3kOx8/Y5jPjcBJMnvqccdFbNeXupFE4tGe9MNY+steVMoxiWTbczEktizBOEVyIsG1/csCziFb1Tfb+6bc7cwwWdNsoOscuZJus5bZ1nP0PA/UvC6HOT4rUMABzkY06e7+ssKrBnAJHWusKaEk1aV2IiaOKuQklO550MONWhAdewwH3XKx+Zplf/6VMYxYuOYt1jc3+NmRaAk62XRjgOp63g2sUQv/BQIQX2ik8gPAW5WyYtMM642WxAxpVqThWD4eSvob7R2sz56rkkcVgKQCwOvDbWQ25+IapNqP5tV4Zm5KtWtPmHr8C/+mvRdtYV0sv+eDdyZzUpNXqe+ONaQdMZuuwWg8ZDgbcN30G9PZAWhPOGicpTBpaImaF4IUNvmz+7RHmgU+fJSgKSmtDt X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18ca5dbb-03c1-4930-6b10-08d900b89b8b X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:33.4438 (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: AsiQ/F+HHGvf9vnJx850pvgYQhmP8Eo4OIM4pXt016wOdyyXNIvDGeU6mEnwcZV3zxeR3RbZ+aAaKoPnpLPQ4GIlWjZ4Wmeui+guKQAj3Ak= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: oAsKXBLTy9qCsv7UtpiHaGu-_0sYBq5- X-Proofpoint-ORIG-GUID: oAsKXBLTy9qCsv7UtpiHaGu-_0sYBq5- X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 392a7ea8080e3753aa179d4daaa2ad413d0ff441 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 --- libxfs/xfs_attr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 40d1e6e..3666c6c 100644 --- a/libxfs/xfs_attr.c +++ b/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 @@ restart: return error; } + error = xfs_attr_node_addname_clear_incomplete(args); +out: + if (state) + xfs_da_state_free(state); + if (error) + return error; + return retval; +} + + +STATIC +int xfs_attr_node_addname_clear_incomplete( + struct xfs_da_args *args) +{ + struct xfs_da_state *state = NULL; + struct xfs_da_state_blk *blk; + int retval = 0; + int error = 0; + /* * Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. From patchwork Fri Apr 16 09:18:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7246DC43461 for ; Fri, 16 Apr 2021 09:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C6D161006 for ; Fri, 16 Apr 2021 09:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234914AbhDPJTJ (ORCPT ); Fri, 16 Apr 2021 05:19:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45234 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239914AbhDPJTC (ORCPT ); Fri, 16 Apr 2021 05:19:02 -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 13G99rMl037127 for ; Fri, 16 Apr 2021 09:18:37 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=ESFhEwEl+zY/uYIHjl4R9VBJBVImfapxGFD6GPtKby4=; b=mdm7/JeTZzCZWZixfZJYtzsdIoknlZJfZPpIgvWIejgwQg8blun3YDnZe6sEpqOzA6Gi I23p/GAknaQGRmNc5Sxvy4I/tBemIZRnYb3vyWKJWPmOUA5lnsjTXDnip74auLRvSTWc grSto9QsxqwwYy+9jcpjnP7z5SxK09+opM22CZSJIRavHmErsUsYOBE10GVqzaGAIZGN sXuq86a9kQkmdCSVsi/bvXcGr9NfIZAAZCbzhOvSt98Pj+ParB2OWtcDrvsdWBIf2j2d DLNFjlmOwTMxIwu1SigM27GGZ1hbGgJTm8XgATQbABprHx4RsVNWibTpD/tdDUdSrWxC FA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 37u3ymrj47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpW077087 for ; Fri, 16 Apr 2021 09:18:36 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ePEzL0HCCmiMV+MQ5Fr9yNzQa3XNAYwTJhSvNtSjIDR8OtzsufrwlovqhuT8UcR+pZj/n22DlprcWuo6mMhBnCbWcpHHMT/Vb7SsfY2Dohz7g8SlGSKJ/OR2QUznG2d1KbkT+ddtYl8gY4yYXeYAz/4SH0Yd683h4NnC+Qp09DnHbBd2HbYiO0LzLUrkTbaCP7PRavmBqLOpgx/L2uMRLAPoY2PVJgjBL4F9FjRvdwXVfaEiiDd5qnI8Yfh2P5FwvxYK63ui3iUBEa1AVWFDoxfhzDSTdooWF5zFS6/LkVJGdD9ZQ3F6WwrCan6viGxoUCaEJNjiu9LhPzTtjHaf4Q== 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=ESFhEwEl+zY/uYIHjl4R9VBJBVImfapxGFD6GPtKby4=; b=IpINnvw9NQivnBv6He0mcFL/ltTE+We3ciA7kRoTq8uYw/HZmYw7faeLbEkHX7HjqPA7ycqL2YtvztVcvlksp39DYFSmpeDhtKNvWfl9RWSzd1gsPsjznJRBeA9tfYgiwFIvxA7qUSSf7WbF5NtLwJ50/g96DwoBQ0WT22ucy7r/oPUhT0nLLRmca8pRPG4SKYmeUJI6M4MqloH0wPnMIar0muuRH+ThcTcSDmJcb+yw/2GG/BS59YmgNn0scd7fAskvbYdn1CBD74sjwHN0uQp/roohKSqPcYqwIOeLp+AzlI9e/afPZQg1FKEUtX8QKyTsMSflXh1S0CXLUJ9A9A== 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=ESFhEwEl+zY/uYIHjl4R9VBJBVImfapxGFD6GPtKby4=; b=TG4rDbXCbF6KeFd656mWtPPgoC9SgrMZbDAehS+40wJzAsYl99X3MDMf9OTTgJ9PaIH3slkoeHnxfMzmQB7wDQl8RrGDCP5oCtvY8eSZnL+NI7qytWaR5vAMigFsHvgCxMFOFXWO8/mJUfbd2ubklOAFbLe+KD+5ZaiePz/uSo4= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:33 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:33 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 07/12] xfsprogs: Add helper xfs_attr_node_addname_find_attr Date: Fri, 16 Apr 2021 02:18:09 -0700 Message-Id: <20210416091814.2041-8-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fbcd087e-b432-4468-c7b6-08d900b89bc3 X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GBkLdwFpA48+lJBLtKaAxdGG04qIgzHzwlGg+RbHR9FODe3VYRiAvAFp8rWpR43U4kYKBL5d5tG1RkYg98RxkF/g/ZD9ZvQqlGjpQg3PfPdng8SLp5U+pRcotN4q782q8Jb0u9AsRNrloagifK2TuIhfDQSbqm64shn1ih4NW/GqExVFXdqygllDbE/q1K66XXs8yJKI4qLcC66jHS8vrvIGUFd9NT1TpwrumlnL0gd9cWkwjhWHAZW9PRpxUlshtgdRkQzgH+gCwPrGd37xXAiXKDSjSFcp1J4y3vrgvmBzv7PILD6RciBV2P5rwAI77vsG2BXbdaGeRa3laKN2pF8A+5pFU6LD5PY2TRuI77vBxBe8pD+NwS1KbKBQNzl2DU233TuptoDPtO3fIoL28NuhF0xPflr2YsnOpqn3Tudg3hgbfo/ApO2fTfyMU0ryNYi0NUpToBL3w+wHLR5EM4rRcCwsGELIjNsnrYY4rFs0R+BVMOTIHBYftk5SgJfui78PHdN0cfS7rec1pb8Lm14NF/ip7Vs5oXQTQu1u2Ph8rh5TeDVl4QXjr5/haNf7VeZW9g/HfTocBErt9ftaFpOwu3wqaxpfs1YRKwu34qpJU7pL2WRo6nQkDnSAXnmnR4jOgJgBdgPtxiFgWEeVMTm1ODmgGKrWEb9H0LMuoup3wm+acgSyPoGyG9zTVi4H 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: aHVYSWCLRSJCmSAqsC8O6MDH7LBcR064y269YkUoVcC5NSpAfLEWZWy+c0fSMdGbO34ED1m6BviuOqf0BbRe/FrsGGEb3TVIqpQgv0fyAk9Nigv/v495eylQ6Ie03MuekynNmhJ18zE7RoxDjPHHziQiJEe+/AqgmbnPfPryt4TW5SVhy+0pxLd2nnUuLPPgAp2qZiZ49xmnXUMeCvDVVEpcPewGmz09rTE+hfw7wVVuC+jAKJ05hv5A//QTkK6TYRMJJWcvCArgCgnPG51KdaCSl5YLde9H23jkmuAxMAWpoquXNRAN6026/DnZuKtjO9N8p/gdSH+KJaAKrq4b3cTmoS4rWjyAsNP1MPynFXNHe7oG2+92IDxcaA0V7qz0qwkWBaBiGmT1lkDjVpt8ExscggUiTpNLciAk0YHqezygDo7DedKgz+cx5M9Ze14an4bKWBRYi+K0C4kMza3LiyO7Gqus3iGo5XescmPGSQQBLtxCLcIAbH1vgYK/nv45KZrJj54DcmqYxBTpxPaDpwHM0vOet5V3kXPkBRFCiJ6x3wBXDFB+hHIHO3H/ya1kC5BoLIFIWblXbI5NnbqpR+m9a9Ms6tywXJ4I3LRDsgc5Xg1pxN1EFvdhyOgmRsO9A9TlnkhJZhaLFiBmoGWLZ5LjcYASRoA+6mzDU4b7UYQmdaxX8PENTRxTte68XNS3sD5WEDOJVh0bDVSbMRiQafFhdL43eb+8LXmzjwF+J1C/sETAdGHvFofknEVKFg20EA7GHnA510T8YgEoo+tJUHX/iP8F5ABiWcg4RrcpVDAVhcbAt8w+mWd1gjTDQhh55LRoFplOOMUUTaecuR7TyynK8/l9dVK5+LlC2CiY8u/bbaV0OzrYw8d1fSAKn8uE22i5EpFPDNQ8ed0yQ+WL8lE5MgJj3ns5//R7MJfUbVWFPjlTWN16keMifMDI58Ems/Q5FnC3XoKtuMbxDeVjJ7zxSpszHPhW1zFFTw/eSJc169OZVjgCfxTPrOtuYLVbLXN6J4zbgIxYx/xvlp2nWmUY+5nbTGrb4xx/ypLnpGkrDsYttIsasS+HJNQRy1uSEsMz2WKAhwUaIey5RnreNZEMEIc/lLc6wj0JoPECI+ayLZIRw+PofoNiqucgt91aEazS0WQAYPpy8vbuSz6zpGba8xzO6GVz2Zal4PWkQphwWxw6xBPyrWswEwh1z4kxI0W78MZ7vkIp9HvU0Hk1eQAg+PeV/fiOm4/gYgwe/S1m+ZMeaEzks3lyJI758B/HeNO7fmCLEMAYrB4UstUjd8GFF4C9LxJRTfqEvKsDe/HlVXyVe/0k08Xmf1AHZCl9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbcd087e-b432-4468-c7b6-08d900b89bc3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:33.8151 (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: FNnIXrNnVsSxhjCAH3/jVuUiikwIT7E2UQ0jx/po1LpGtI3d49RGxOEpmix9ZLB/pvUNOzMb8+eer1ifeGeg+smJzs0wPMxBwaraxmt0oFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: Ydqyp3qfkGlsmZGRh92d5by88X-8MffI X-Proofpoint-ORIG-GUID: Ydqyp3qfkGlsmZGRh92d5by88X-8MffI X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 1aeec98c3f70bff14cc0e65ef898e91c2c554d41 This patch separates the first half of xfs_attr_node_addname into a helper function xfs_attr_node_addname_find_attr. It also replaces the restart goto with an EAGAIN return code driven by a loop in the calling function. This looks odd now, but will clean up nicly once we introduce the state machine. It will also enable hoisting the last state out of xfs_attr_node_addname with out having to plumb in a "done" parameter to know if we need to move to the next state or not. Signed-off-by: Allison Henderson Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- libxfs/xfs_attr.c | 86 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3666c6c..82b6c19 100644 --- a/libxfs/xfs_attr.c +++ b/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 @@ restart: 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 @@ restart: if (error) goto out; - goto restart; + return -EAGAIN; } /* From patchwork Fri Apr 16 09:18:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7E07C433ED for ; Fri, 16 Apr 2021 09:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FF3E6117A for ; Fri, 16 Apr 2021 09:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239944AbhDPJTN (ORCPT ); Fri, 16 Apr 2021 05:19:13 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45238 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241585AbhDPJTC (ORCPT ); Fri, 16 Apr 2021 05:19:02 -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 13G98c71036469 for ; Fri, 16 Apr 2021 09:18:38 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=ijzmIM75l1GEP/KQzuWXYnkvA/MOZkxZ10rbTiwsBv8=; b=DO3kalcAF7LrszL3siUd0NXT+gOjKMpKO7dTKM8YvZWGLScztVCxyC2PdmxZukJfQYD7 QHaGuLxexCpNlWkrSI0guWs4H9AN9N8rcOXyHKL4rxlV06CdoxIQutJ9ppbUu3JQ8rGa MnKHGNH1bxEsi/HDsyAGe+0Bzjn9Wya4ubNT8n/twBpR7eAWX1QCz7qTDqXm3mq9x97n hlU4yZ+UvoXQwRfnrp30MEN4iavzUDIKst3QIv0zdvHNWWqPpTdJ8yS5PQW7wL1sIF0f /rlg0LzB1s+NBMwiizT/GMZToZgz1ZxsPMgVqUN6zUZhfggqYK6CzPl4SlqL257fzDm0 HA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 37u3ymrj48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpX077087 for ; Fri, 16 Apr 2021 09:18:37 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNqEs7olqT8rrpUrC+aUDFyLtCsZnds5OpYSPPwEaEgcQuwq9NLQTWU2pm2zW6utmgEsCWZkuNxe2jwk3CTo+Z7oPzl7kS4pMhxr59VP8OTN8MJcz0ZR4eaJ3Gio1oUS10TVqnDxizTuG5Ii2T2I3zs8u22xmtRh5fkWchFhL68IHkEvm01OJaV8wrlJKlD06Y+UohWrVUELb9FcAzTP5u3i6mroAGGjU63enJHEfoZscg19gZkAQstF4Ea+TUxhohdxmyUoP1MNjgL6jdS7+bK5QmatB17pcIr9BZtjp01/bN6dFNIZz8un15xgZ8Iegg+8mhaEKgVkH+ng4Q4DDQ== 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=ijzmIM75l1GEP/KQzuWXYnkvA/MOZkxZ10rbTiwsBv8=; b=cM7aGOZY5+jD1JuEOqhBF2yp/NW1XQr86ZeKdLv2eKxl0RSgKMcvgTKJs9u10wWl3Jx1MXpZuvc5QlkS8MdjeJsl0d63injwW96gR/bv7ObtxIsgbeDzWSZ2aci45qxtJzxi+u+kMaE5sjm8iNFLQ53VPwVARI53Vpc1nOASd0Ct13RTkQzDrqYsKXwzG0TM9qir2MUQDMjaRk7iggmXidIhrLd972BNdYxjAUUoyZVtk+1pMgq8ROCT1pWRTDc8TJAL+yUaCDDcq6mKwjLKsFPnNJ2vOvZqhE/BhlhdSEyYCbMkZX766FdKjK9HZnD8B9o70VreuraTwgl1So00UQ== 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=ijzmIM75l1GEP/KQzuWXYnkvA/MOZkxZ10rbTiwsBv8=; b=prg86xEmEBn1oVQyHcEppuk7B2/Q51nzGK/smMpOW68wtl+Vnc/3osK6XxQSk4nrIQtXYQaBfREXwHXFVKG4KZKor3hoizLyJ7nXczLCUUbrp+QaiRgmOmHjdfDtRKiyXj08OEqvUyRFyUHfz6dfUcDUfCQlIvUK8Txo4xS74U0= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:34 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:34 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 08/12] xfsprogs: Hoist xfs_attr_node_addname Date: Fri, 16 Apr 2021 02:18:10 -0700 Message-Id: <20210416091814.2041-9-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be11860a-a95e-44d9-47d3-08d900b89bf7 X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UUu8gafrjAQh3R6vR51hHLkCRtBLlb2Bvi3l12Vx1c7ef8N8bVaN1Dx9BDl0VzlEpnE63ZhLpjJctyTcRoEMnJgHE+XnKY6Q36lbIqw5ETqm5OzaZnM03IXOIWxcKajJy9Q8oYfr9srReMyPr2ycbv9FA4nXGG+pYvTBJGPSaIH2RJac7863CjENirEP66+hLt/YtFVAwyWED0l2DQG3/ngtNDGcaNwi5kOk2HXIPN2+OKtkIm/zb6F325qDIZYO2UuidngCO4v7qCL0oJ+Q3BelUW5pzqFn3IaWzjER0YKXiqe6NAgoiC5Qwab8zMocGPxq+/0fGH/Hgb5XG9Rm7rHG7ThD6Tiz15bS8JtSiasCHfGO0U0W2Ia4KqPy3MKluW2ETZ0pqqcc/ZjztSWfIPe9FH6W0N9anEN1g6TjEbJpMDF2JBBuv6JYFZW//oXAczqj+CCp7dqgFDXwpSbhq5XbcXUgO1WBLWSv1dgQF96Lzfa9MNWinnaGwC2gW4AVxfCI56lB+fgOatDE5WEwPpQokTw/3/r63qbCIHXVxnTsejUfRfDcSIdZKqFwujNrdwO6A9LKxt761Bpp+Xc6UnPsEGxH0I/dw6oKtF396Bk322ZQf+rdkryafG4yGWCtEMiOW533c7A3LhNpOjBgA1J/F+guWv6SN80I29QZMeWFQjk1cNBxudZUrH/nZPjt 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ujsFffIMKSVUDmEq9erMfwVbiV67zYBVw5IAOoejP7mKanUexxm8nZ/WXO4/32w3x6WhMOEN20tWqT/RA0xdqhAznw/n8nRvJtuvJQR71CvvUKK01/ly0B/c0e2ACGWxk37EFpohxRmk2MhNN2NrLWuxjtW6qzv9KLefioSwo29gclujcSWH44J031xJduQlHyvrblM7sgq8hAmRIYe6y2A9+Rgv7SP1ckL5EFkY2jpOSJttkKzqNwdDh8HcvFCLHXBqS7H1UIpaaI/ULFJF+TISqhBNq4B98PN/t3vn4y6Bi80HiIUTuJJIW2bUsQIvBYLoQ75Nod9rR1hKp8VChtdZusXJ+lBK7lOfVQ/GD+rYmiiVy30Q72lOsV3+TwgrbcybzGBIKyLrf9ggx6/pQfavq2sUNJ60GpzJYrJkrPHOXLyS+pkSo2wt2RubmyI1YBAvqAq40X63/YM7oCMs3rZcGxmXkOoacJxBBKyrRQn5sO2zSmoKjFTELQxFY1RNCRS4OZU+gmU2rWtKxz1hpsDSsrNS6Ws7CN/SXfyRJW4ixYGTaMpXbe+4ahc3C9ePKpcKPDxhFIT26me//pdG7MZoueUne/cz7dkhLay5K8zOg8YGBbTeTujeZZHcaTIsRRaXt/JnRsHksN25ZiZsUtH8+wleTWX70e1BPB4VqusjPva7UvS7LSZgFw2F2v/aor3FelDfuCC7wiV70El4BYCOQe8TvPISsXjG1hIyel3ATscEzPKUBW9tcuKJLcXyKxKENAz3yU+Lb85o5gJWGBw6trsVk7hpL/yf4m6qrrSOKMBz5y/QuAjbqrqDM4BvAPSDslEjTO0APgbMfhxMpV/XujgYlLZQhQDbT/340WevSqMWeJLx5/5yicwB5PkydApA1T3UqEL7OogaZC7nDVRYtxjZr0swvtH76jaK4Ku9HMgb49uJrC9pDQeKmZarsW2BS3pDJcljZ7FbW1bucDIKCdA5udqIg483ARD40wvqkdWawj/RjH8ciNpTLcKKSWn2g/JSElTmNdYGcIAe/RLyIJDLA8YZK4q3iubXjC1nj0oHmNn46scPkiPTX+ABubbR18fYtXb9y5BtdmXUFglWfhl3JIIJ2GhyVsi/a8cIFG7bWq57ZC5MEkC4+8UjUPd+1cd2obgXIiE8RAsPwmmILAp3VevwNDSkCGJwxulpCcVHLgKalDO5Ttpc/EL4Is0lzYR1LrLhD8xjWc5fa3pTxZQHov1LiB30HpuTmKvGACm1FEOlFJSDDyoReBbUTEQia0OEzyzd/L0sevNvjgBSMu7wUgzcNZdOM1N6qB15846eAjGXp010fY+NHDt4 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be11860a-a95e-44d9-47d3-08d900b89bf7 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:34.3239 (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: eboh/Rt0vUg9Q84qixxT2qOItphgvhNPT1RPrb63eRzIXry+IcaxS1oagRNA5VSoE6vxZT5PzmMISjqBWdaV7NsBaseijpFOu0iFAOzEyD0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: HJLPcwsE9Muj6OcOSTHH61Q5pZYIanch X-Proofpoint-ORIG-GUID: HJLPcwsE9Muj6OcOSTHH61Q5pZYIanch X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 8e7db2a154cf8889319a4d6e5f987998ed21fa1b 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 --- libxfs/xfs_attr.c | 157 ++++++++++++++++++++++++++---------------------------- 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 82b6c19..95e4875 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -52,6 +52,7 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); * Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); +STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, @@ -270,8 +271,8 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; - struct xfs_da_state *state; - int error; + struct xfs_da_state *state = NULL; + int error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -322,8 +323,77 @@ xfs_attr_set_args( return error; error = xfs_attr_node_addname(args, state); } while (error == -EAGAIN); + if (error) + return error; + + /* + * Commit the leaf addition or btree split and start the next + * trans in the chain. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + goto out; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } + + /* + * If this is an atomic rename operation, we must "flip" the incomplete + * flags on the "new" and "old" attribute/value pairs so that one + * disappears and one appears atomically. Then we must remove the "old" + * attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the "old" attr + * and clear the incomplete flag on the "new" attr. + */ + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in series + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + goto out; + + /* + * Dismantle the "old" attribute/value pair by removing a "remote" value + * (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + error = xfs_attr_node_addname_clear_incomplete(args); +out: return error; + } /* @@ -957,7 +1027,7 @@ xfs_attr_node_addname( { struct xfs_da_state_blk *blk; struct xfs_inode *dp; - int retval, error; + int error; trace_xfs_attr_node_addname(args); @@ -965,8 +1035,8 @@ xfs_attr_node_addname( blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); - retval = xfs_attr3_leaf_add(blk->bp, state->args); - if (retval == -ENOSPC) { + error = xfs_attr3_leaf_add(blk->bp, state->args); + if (error == -ENOSPC) { if (state->path.active == 1) { /* * Its really a single leaf node, but it had @@ -1012,85 +1082,10 @@ xfs_attr_node_addname( xfs_da3_fixhashpath(state, &state->path); } - /* - * Kill the state structure, we're done with it and need to - * allow the buffers to come back later. - */ - xfs_da_state_free(state); - state = NULL; - - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } - - if (!(args->op_flags & XFS_DA_OP_RENAME)) { - /* - * Added a "remote" value, just clear the incomplete flag. - */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - retval = error; - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; - - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); - - if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); - if (error) - return error; - - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } - - error = xfs_attr_node_addname_clear_incomplete(args); out: if (state) xfs_da_state_free(state); - if (error) - return error; - return retval; + return error; } From patchwork Fri Apr 16 09:18:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 754EFC433B4 for ; Fri, 16 Apr 2021 09:18:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F31961166 for ; Fri, 16 Apr 2021 09:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235231AbhDPJTM (ORCPT ); Fri, 16 Apr 2021 05:19:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35070 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241595AbhDPJTD (ORCPT ); Fri, 16 Apr 2021 05:19:03 -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 13G9Aie2027436 for ; Fri, 16 Apr 2021 09:18:38 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=44TsAg3cxQSK8GRJbDXZp0fZiSAO/SKRZIfjf9SAVV4=; b=PAnWShABisQLwau0ZHTyhLAQJXJEDE2K05JAKUQtVj+gGp9X4vjye02+ZJmZle0jTZKE NUQvJrNLPCUS5dpYkAi68MvZGoLD7foGbsiZ5kAovMOlGltaWsjca+vY2W4IEh/Ua8D4 ApJjBaOTY+9LXOp+HOqiNEuaoKjzDPviEZehOfJFsZ35S4Yrohj4h4yz+ZCeoSmiK0wr C8FYEwEprsA/VSE5kDJ0TLjzB6gc6uw6CPJewdWIw5KLRhNVGKW/xqKWKJv4rU2zdMC/ JLvnoP1TSjTKWpgEm6hwbcusIe41UZ55NX/cCHsNZyI0/uBpjx0eEOtzm+uXY7qPyFaq ow== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 37u4nnrh8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpY077087 for ; Fri, 16 Apr 2021 09:18:37 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UZtHfxotLpgTI0rFIWANSN+de/FsXv/1wTNTwb/E+c6lSYC3EuQbPAALEdY4v2Ig7PT/Pchshd5WgH6u0tBGVLuu8jYMZgkzsQyK+lW6iSyh9vvTZerlbkXvB5ibeTpWDk/scKETltZ1oepuCuXYrppNgXwuwH1ts/GuLipVKgiTjy1Ae4FC6Ppl90JnyRRV92HKYN0PLkTTjkHt7uj15BCkYkSeiEXjoCv30b8lUEHX+qQqzocJxcDH+zYLnWDktYKYHysppfm52TNSX9bu3mQqCW3hVZOyoUw6wQ+BbQiHvtYWjCj0s9uEaD9+j5LKvNk5lTO+1bYS5PobUDa/Xw== 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=44TsAg3cxQSK8GRJbDXZp0fZiSAO/SKRZIfjf9SAVV4=; b=TryDxDrm8SxhyVUNgnIOHZb/C/k/Rjx2xdJG/pbHI1RxtefVbcQavWFBqzCxNDeeuhAZZA1tYjdQs/gBwaz7TpSgsiuzFWi5nIJZOXrCe7vz1Z2BqU9Drccz4buoj2kwM1yA6R36/0qYtKK9quuOPxQUt/nav3DM3Oj6+UmGVTcuPa2ix8WHBv4w7coGIGYvZvnYRDYnjCFclNYzDwHTTzhqg9bTmewdqyuqhRy0em0PcJFDlJNv9J9uITLV9vDhTqC22qNl17EONPZd/Bs4yVjlRBuF2atCds1xANyW6GVIwTz2VkXYoGQyPutc/1179A+9jMq+zAsbJHeKqxAP4g== 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=44TsAg3cxQSK8GRJbDXZp0fZiSAO/SKRZIfjf9SAVV4=; b=q8OXB6XpoNdED8M8bP6eUIpG+oK/16fCjvLJjA0f2Cs4lTMe104ikXun6Stfw683QcEbtTb5AliyAnoCVR4CkLF3+N7o2UbozHJrQS6JctG3QeQTWaBc5b5Hs33bFX1DmQZ1x1KLCh3DPIliuYgP8CzCnaSYPv7t17Nx+yZfL/M= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:34 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:34 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 09/12] xfsprogs: Hoist xfs_attr_leaf_addname Date: Fri, 16 Apr 2021 02:18:11 -0700 Message-Id: <20210416091814.2041-10-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9c73a78-56e1-499e-9199-08d900b89c41 X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cHdmoVV0XNNrJsr1SXMPZdZ44xpm+WpT3xNLn/hK9zFgPT2UkmYSWNC7L9B33Jw5+I4wtRFbZFe1aERKrq44MA8Wb+LvxZKfWhcDhHma1SuT1lqkmFAkqp5nT8+GTIeKkWXOJVjPHL1Nof5vkJIe/m82ll8z1SaxuC11NpG55RXSjXT1vq5VfUy5xgKb/zFu7LwqVhfVuMit35Ei7lFxPcUFlWU3+/4+tD5brnCD5RcnfEnwIDy4zS0h49lYK35i/oiteOt2HLSb/Cz06q45s8lGveb1n5Y2BiHOuFHSsbY0VZ4ljyTGHCSme8whRuCon2CnCd6u8ZCOLrFHmyKt8ILeIWhTDzzle5iHM089tZkH5PfdzfwR8HaNmcU8GFysAqYU0MMpLJyIaZyZtUJo7EmxMU8O9PhF8uIxa3A+vCFjuxbojx6xO51xcQIyKsMuJf2lDLy17KdqRg8AqIpXWVRXUhY6QJ6dHtHzDGX2ldPlZSD9tTeGiTEqkmuJZy/nHphdeQccKwwgNCt/PWsqiXXYbQD56jK4YfCF3fxo83Q+8j7DW+FmwvOhi8C0/YIlbN1cCwupThcceR5SMyrqfiN4ROuTTqKFK4I20HhacqlGoUK/frKBGRwLSzX26wbQg28gGdaJN8B4WJ+THaTe/eNjjF0otd0f/54m72SJ7YM= 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: govmplTPUp1NgSmDifca9VNYBFnNW7qoIMfJAIRs5jPIThLKM6VFnTk85h7L+9wXdc0DSeFUr+r4NztlI27bLDJESr0va0VQS0YBc3TBpuZ8rgOX0980rVXvPZOoUlI4JcP2tvrzNU3Z4LHc8oktsA7VOyfXp8g2FOcDFPTM6De/WAFE626W+8QBVh3tYGbXCjdUS/kbFkAuqnmzh06P7/kkQF6l2W0rTk/vnSjFdQ+VuHDhojJStIX5DoHHx9VLpf7J6yCxFaAQHZrjRiZzRZuPJIdQOT6cv9E/86Ru4aK3Zwqrrcki4Il2uki3200d86+nExWeXZKQZEb84lifAJ9h4OgGpwYK6Q0OrETuOf/0MxfjOxbR6POPE3dnUSn19txb35aBjIVYNPXK5ozJbCYBWieRqRihGc7KFuqmcw+X40RBBjCO/LbR/w8ZMaJpLw5HGCHcQi3kP4ClM7lhSyt1uQdrROLM41iW3IU8raZUz+N+dgqz5vLHPVhIaODmEd/uekCqKw9JjhoNJqRCW3abjS0jUmrSfQratvBYH976p4zv2zPvJHP0CussRJM6aPzkGZ3Hpn+moWiZCKicu2OLxRPA25StSh4ZdRF7+/OkKvAv40Z7bAx4zy4cjUMZHNT5WZlXr6nAz8KlcOowa0lD/srcoalO8fGKMb59RaalRraJa4WliZCNWsI5ziwuG0nydzAnnIphPcTyEdl8ui1+ikzYQKNhq5omleY6ZBoyXYeG42RcxAnVh9C+f7xNX3T1YzAXVLq6mdJYlAJeqnA+C+wZzLEpm6RYbPLTV2YDYfrB36nR1r8N4OC+eZ99JA/5freImC2ghyJ2+Oi/uJhNvNyoVRSVHHgC1VTulovn3WXRq6+nYpvwU/hW5rIucJbdYPm3XHxu1U8JZVLjmSuzEHKl1BkjonAuISqrSiHwonhGc/+Gl7u7BJCNOzPKSfYslsry/bRet/S+0RXK4VmsXuQOPIQgexT9mStt2/Ak74cfB7ULDvD+rcQeSNHbsjKQeCPFNcXYWbHyeni8gcKlwFLtso0ys5wu3tvFyaiBpnArKxy5Z0q1uQdH10V4R632jM1zHJzfyZgvli9m6VQhxuVeodyRxlC5x2lsMNuoXbX1FE1sIy2qMI34HGgg1bsMTUu7jX2r7Uy/4IPSRxFST8x5omB4BTHmGgWALFxOKLRGGXWQHVYGPkFjaYUjJeQvlS+96ujhIFjbC3eBUSQLjLSid/xfV+5Bn/z8e5f3kvaVNlmSf4hW4kHyN2fLodU/Oa3K9MTRNafqtRRJ9qAcnNdZ8kg0MtN8oe55eSqOi30g+83FEso+xoaIcHuK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9c73a78-56e1-499e-9199-08d900b89c41 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:34.7062 (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: IOeFKgLf1YvWZW2ZizpwR33EW6rIPnvQ8bpuqIro8N8HlKdYMSZkNgF4sPsOdnGYgL7eXcY424LyRSkWv8muxYAv2Zh2IcXjMuuxih7F+Sw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: IzXIbwp1XjqZ3But3cQ-F-evqGiAzeWt X-Proofpoint-GUID: IzXIbwp1XjqZ3But3cQ-F-evqGiAzeWt X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 45adc55591f5d91b9b6c7752fa4253bf3de33886 This patch hoists xfs_attr_leaf_addname into the calling function. The goal being to get all the code that will require state management into the same scope. This isn't particularly aesthetic right away, but it is a preliminary step to merging in the state machine code. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Chandan Babu R --- include/xfs_trace.h | 1 - libxfs/xfs_attr.c | 209 ++++++++++++++++++++++++---------------------------- 2 files changed, 96 insertions(+), 114 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index a100263..fa4d38d 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -148,7 +148,6 @@ #define trace_xfs_attr_leaf_flipflags(a) ((void) 0) #define trace_xfs_attr_sf_addname(a) ((void) 0) -#define trace_xfs_attr_leaf_addname(a) ((void) 0) #define trace_xfs_attr_leaf_replace(a) ((void) 0) #define trace_xfs_attr_leaf_removename(a) ((void) 0) #define trace_xfs_attr_leaf_get(a) ((void) 0) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 95e4875..18a465dd 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -44,9 +44,9 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args); * Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); /* * Internal routines when attribute list is more than one block. @@ -271,8 +271,9 @@ xfs_attr_set_args( struct xfs_da_args *args) { struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; struct xfs_da_state *state = NULL; - int error = 0; + int forkoff, error = 0; /* * If the attribute list is already in leaf format, jump straight to @@ -287,10 +288,101 @@ xfs_attr_set_args( } if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_addname(args); - if (error != -ENOSPC) + error = xfs_attr_leaf_try_add(args, bp); + if (error == -ENOSPC) + goto node; + else if (error) + return error; + + /* + * Commit the transaction that added the attr name so that + * later routines can manage their own transactions. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_set(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + *flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + + return error; + } + + /* + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. + */ + + error = xfs_attr3_leaf_flipflags(args); + if (error) + return error; + /* + * Commit the flag value change and start the next trans in + * series. + */ + error = xfs_trans_roll_inode(&args->trans, args->dp); + if (error) + return error; + + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); + + if (args->rmtblkno) { + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + error = xfs_attr_rmtval_remove(args); + if (error) + return error; + } + + /* + * Read in the block containing the "old" attr, then remove the + * "old" attr from that block (neat, huh!) + */ + error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, + &bp); + if (error) return error; + xfs_attr3_leaf_remove(bp, args); + + /* + * If the result is small enough, shrink it all into the inode. + */ + forkoff = xfs_attr_shortform_allfit(bp, dp); + if (forkoff) + error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); + /* bp is gone due to xfs_da_shrink_inode */ + + return error; +node: /* * Promote the attribute list to the Btree format. */ @@ -727,115 +819,6 @@ out_brelse: 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 Apr 16 09:18:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23FE6C43460 for ; Fri, 16 Apr 2021 09:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED4BE61006 for ; Fri, 16 Apr 2021 09:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241585AbhDPJTN (ORCPT ); Fri, 16 Apr 2021 05:19:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48332 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241635AbhDPJTD (ORCPT ); Fri, 16 Apr 2021 05:19:03 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9BBHK167726 for ; Fri, 16 Apr 2021 09:18:38 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=nwlU5NwW5MbQ23DKe3EcmqNB5Oim+SZh3b3Op41CnQ4=; b=PrxHo+TzCU/kd23UpXWtfM7iClOzSqenyeB8b7niGwx4TOyiPoqcGZdbUF3qyR8iyP9T Gl2fjeEblh4JKOlxMuv3/bEQEgwJjeyX38qV1Wkkzm7AgvhJnTo7byq6Z4B7mEdshBQo uMMfbAqsg7/TmFmdzNO6xi8ki87qdJdCXCiQhJJbiVw7zx9PnJmd8jYjXbB66kJlH068 +iVFZO6YC8DEX0ECIrac7f8sdJCKL683+bPHTxUeP36NbXrOSYm22rthuBliD9vlUbTp sQgyksnyNWaXsoL2wHcSIRYzWNK0WYcmBAWiTzpDZ4PVY5Q4F7Ci9bSb1pcccjKK70hY bA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 37u3errkg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpZ077087 for ; Fri, 16 Apr 2021 09:18:38 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hNuxB5eTGDetXx5PtwxWoiw0+hz80EoHmw+NABD7/BRIF1YquASpQr8ScTX8F4ps1hZ6GYo7kgt7089RIeqcNbZwGpAtyPj2H5/7GMUNrDj4FlV83j8loZdZsvKq6bUOLorj58lGI2q+a4LFxgFeWuHQB6At3wYs1by8r6MmHjYi9ZP4YhUqLGc8zmau2IT9vT+CDdaIvdaDIRMJcwziA6H7L1pHP8d2txR2RQVYopQiL00KKRbyMYLRxKskTGp+8/ZOBQ6vaVsrzuZ/ff7BqPwnFKE5tpvnmeNYkPvW4pjNVnt4Dki4uawSlOZZJKMI2n+kXBIsn9t76ypgI3RGJg== 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=nwlU5NwW5MbQ23DKe3EcmqNB5Oim+SZh3b3Op41CnQ4=; b=mANuhrr+kAzjbLGcoihn/mab7idaV8LXTrSRCpz22OixRax4kbew2ViRGTc65sJXD6BBcq9ZhxrJk8Edb5u+Olm/FiJmMG2MxXI9oS/N1vcAH3pSPKm2x6ZyC63NFEwqKoCGs0Le2FXYvFoqj/0HpgWQ/oNPwdBU4u5CBaamOYUeBHmgpaG6IyKbueWP3BHIFHMK+2s8xUzH2J5KpZ1KURsmCv0y0uNhe3uqKN4a1SVLVtG0L6OcZh3cRw/PXXXDQUHiHQ+607o0n1mu5bO1FEJ7Cz564WRrf7vg7CYIMO9Z3KYclZD0sQXpHiWql2pC0pr3Eygg9J5hkdGSXwXGeQ== 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=nwlU5NwW5MbQ23DKe3EcmqNB5Oim+SZh3b3Op41CnQ4=; b=PkVchgI+x3aohaF1KagMoiB+8+HV0jtfvWnDW6bhl63RSgn8xBMuHgUH9xpw6zfhPE0h9Xp2oaN/MHCW9nHH7e390tQ2PHNgW653AJ2HglNEPghP7w70jIRmOKOHTvOGFSMyQxcymi1DIyQtRsK9DYj5QgUrjCDeblFWEnKJ9oI= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:35 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:35 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 10/12] xfsprogs: Hoist node transaction handling Date: Fri, 16 Apr 2021 02:18:12 -0700 Message-Id: <20210416091814.2041-11-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1710690f-0d11-474a-0858-08d900b89c7e X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WGWwc8GgZ/cP585G5eywkwyPqNE1qn5KdJGikbD2t0KdqDom8Y4yoNkA1df4mMEH/gaqwduoS8G3jbbwna2uFZWQ4X0kuU8rCohUDSY/AFSJLV4BHc2/lCIAPOPcP8t3NZ4X+Y8qdDD4MmXj01BfCuyOl2G7XOwNCEy073i8x8oUudvz8bJue9XCYIaYtsaLM6RHzUFTTAXyiNPa9/eQeRD/eD4qxMoOXDnamyyk5Nvp35dTRoP49elDjZlIj7cmJNdCYu6G7gkD2En3cMukkh7AQAelD6eRWbpOYhXqkCgyzZAMqzhIaS8ISXZQ2xz4UAl1MPJNkaI+RBZJX73I0L6cO9x8Iq91zRFOUKfT1c55S0AMX1httOcv6VbzmbNITQ1riQv+KWRYjrEGQG8AoBfGMDnCc+6Wcf71iJ0cnZYpkLA1SUqWq4dHj9HGP+aSPqchrC/A8ZObLdalIDvOZzO+HyYroLAPQia7S5/dBwN9OGUDXYFbjUjU4Nie1j+Meog/69YJ3ukWfFMWhzm0Ud337oWMzwt/rB44CKKLPcpIHigpZ3ERSGplCZGEc12kJlVbGd8gYTMryq7N4Lolz1t3ZLr+5jdlMdmNicgI8k0v69c2/Gq5Ab7R4iK+LYDxv1dqc4EuPXaSbBMsCD8hYDrX21+AP4RtpUwAuJSRPt5878So7t4L51qR9jrn53nK 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(69590400012)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DWlMST8EAlPe4002TSthhnfMBpC/GosSRwI3BiC9abWyQLl7SEYkEjIbDX2w2hfxe++mRBcbZ5vtiBZ7K1nfMyMiPqyXi5Tb+2KM7pd5iPNAhoItZhJETuq6i/rGpshprtM8n5pl1kuUy9jzU0InZtaTYSDfnpxHu1/iuwgLVhXt44BbJ4D6ZYB0iMtjZTTMmpUiQZhiTR86R+CHBePUgjuZGeYT+4pQEP7xQVU6Dt09TWQR+g3YIob2xjUdQ3r1SUTNDMjmnAWACVPctdJ2mUlBykfO9j7IQeJXC4pwZvI4gfBfTxeHjpNsyIs94hWtdxeZjaPYZ7vqY9z+LYADNqVlV7eJrviu9HOG8lJsBRvhA8+/Ve4fAz2IfVlwCOeUcMvfKAS8oZdJ81fYhFdBRPllMu68LsUUy5jpO19fL1gb1h0sGdLfOtmDhgTfd+FvCPQ2HcrnCp+GKc+5Rar2qxFEZSqlRTf//EbehroO4JGykUxyAHg0S9qGsQo/BnDzvRG4VmK/jTmJ80WGssZ9YCaJEZaOGPHO5JPv/7zKU3/GHX6xCqH3QqfR/tQymZF0yx08OKd7v96r6he7WJ7sl5hnK/O/RoA6mhC3PiSTQvJxzsLeAqndDChJMmloP+f8NQXFzwTHkW7InSMfwwShWgnTbDwB8RvEuoWMFX2Owp1VdpazL4D6jS80eCxSKPYXtlLBbkjOjsbqixCoE7s2CXtDNHqhjzodfADOUYOpiJTQyrJ0e/Ix5v1YfxqDFz1qO5PIU1sMNZIn7bWzXRETwA4zjpH3KT53AfvRppchhb2UmfTgtTZDDko3p1kXHvGB0nSFHvZOln7VCsRO1a57ypORb+9gZP7O/PlyxxteJ/mYYtyUwyvnI6f4LTlXrCnoK7s+o9tMG7FK566zI+b0U+6jxTbifBvwN99Xult8KbeBiLD+rF6nV9c9mqPXY0Vb0MuNMPF5sXUVwnmAHTz5g/FJMJ9ssC3JSAmr1HOb6Cz08Hy6d3Bm2j8FTvirMTA7mkT9wnoFIObArN8R1maqTOZYPjO/f76xU0lYIzq7dIc0CVzFlQOJodEx41eK78gKYm1Zy+yCBtMAcPPhjOCktoHVa8KigCPStIThLNJZvLR4SGM0fgCGWgjGFaWU8lQ7dMODgshSxViYQ8ZTdQMy98ZsPHAX/FoRuGsPxJ7UqNY9eNq+KWlz8zZJrSFHbg7Mg6fGvRFfFMlPDm/hcJ20IAMGWUbDFJiE6fD301/m0BlOZb3dDxe+/Q4KdvdXLbt1dMJAu3S/S39Slq+6PcXEjb3HrAZcCM0/vw1jFXQDnMs90fIb0dWUojdpmCg94BM+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1710690f-0d11-474a-0858-08d900b89c7e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:35.1801 (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: DYB9HR4KLqySynW0axnEdbGSS5NmP8MWUCixipNDihnq6B1k7JDfuViFpxl13TzfcnkqBURHHE+Syubd4PhppfY8XD+NQfrGntyVWYpJyZA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: q00w28ObuFB8Tu6pi7KBdu2KabsVqywO X-Proofpoint-GUID: q00w28ObuFB8Tu6pi7KBdu2KabsVqywO X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: cb9e8e1fb89d84c77c8035b2391359f9cbf209e6 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 --- libxfs/xfs_attr.c | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 18a465dd..b3a8202 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -289,10 +289,36 @@ xfs_attr_set_args( if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the transaction once + * more. The goal here is to call node_addname with the inode + * and transaction in the same state (inode locked and joined, + * transaction clean) no matter how we got to this step. + */ + error = xfs_defer_finish(&args->trans); + if (error) + return error; + + /* + * Commit the current trans (including the inode) and + * start a new one. + */ + error = xfs_trans_roll_inode(&args->trans, dp); + if (error) + return error; + goto node; - else if (error) + } else if (error) { return error; + } /* * Commit the transaction that added the attr name so that @@ -382,32 +408,9 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; + } node: - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) - return error; - - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); - if (error) - return error; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - } do { error = xfs_attr_node_addname_find_attr(args, &state); From patchwork Fri Apr 16 09:18:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E231DC43462 for ; Fri, 16 Apr 2021 09:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4ADE611AB for ; Fri, 16 Apr 2021 09:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241607AbhDPJTO (ORCPT ); Fri, 16 Apr 2021 05:19:14 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48338 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241649AbhDPJTE (ORCPT ); Fri, 16 Apr 2021 05:19:04 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AmQE166960 for ; Fri, 16 Apr 2021 09:18:39 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=MriA/hzHP15QlveKx7NjuV7KReKD8VKmKEklmxYA744=; b=F5Usm/DutCgwyW4Jp+GE0IhBt/cBNlYPG0ZzPYpC0BSuJKnZM+PYg4nANPtPCpKg54z+ XP7DiPRyIzcROLcmSsiVwByHfzAe7s9up+trJi6VJPmzCR+qjjNEaQhAmcrD8b41wg7b qfSciqHzVqnqhJnwjObvE6cylXjnWOAuHNKmMSpGfsZlOyXFjMUJRxmts4Pk0MfZSLSp 9pd/qYKiVwHS/O7HX7M/BNHLtH+v/vmx2H7KV/BM2M2FIEleJVDppn4wq+iwUz/TXrIS y8UzUUlQxPPE8Z+fZjz5/PH8Lw3g7EELoxPTxaBI9/ugOPbuXOWOmfRObzRkSnEoSmxJ qw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37u3errkg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:39 +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 13G99e3A182080 for ; Fri, 16 Apr 2021 09:18:39 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2040.outbound.protection.outlook.com [104.47.56.40]) by userp3020.oracle.com with ESMTP id 37unswy4wy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lc1O3rTtSAzOG8F4tSEx0BIEBYlqBW24kVNhGrOrWcKw2zHvMq3nglV7/R27ktlenH8+d+qU0YpePDRXOnBcwSpm3lk7ub0By1dmA+t7KT9eNKFWrnwXHIozkxrGH3NlFSc+2HWryzyEyKQoI50OoZVesEDA2DFdUkofbAqeHlQ6xkeMVAHvg4yB9cQC+a5k9pso9XsBZu2/zEuVqTwyWh2w7efiC7KDWQzUuO34i6chJWK3KgfX6ll5pz0665OmHd9nnrVt+2+mp8HQwTqylPlkdAmdwOfB1JG3kCdf9OqvFh9UNtym8yQ7v9M0oyxVtCfhIrfskebKyjx4EL/4WQ== 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=MriA/hzHP15QlveKx7NjuV7KReKD8VKmKEklmxYA744=; b=THOwf+62qO9rW1E8c3O7a4swnpNvbJrOd6SdgXv8qzU/RK1mfJScvRLlfSgFCa4r5iqwe7l42+68Y3Cd7S1ZaSKwprXNQ+uKDPacja+QxCXnewryU7/r4rgb7NnMFssz0/NFicSHyRxts2Y4DUFlPiqDhuYOU9yFhku+I+4+6GyJ1hp2XU1MHd9W3+WLho0GyBUKDx7FSDpOCGay/Ck2CD0pXTOQequUp0F9zo4UZZB8zetaSkxCHvrBGiz3rwnt6fdSdM3qAtzbUqigmCiJg9Rpzj/8k+AYoFylKKSdPpx/cu2fBixGfS9umy21PPh0FUiP4dynW8OCikikSe6ChA== 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=MriA/hzHP15QlveKx7NjuV7KReKD8VKmKEklmxYA744=; b=RzxkaQo6JWpR3GMZBA9YCty1P4XvAyYPl7QxaqBuB9Tfd1FM+5i4vBB9H6gukIV2FNho+FEc6opKrSunCGT206JsSV4jZXF4JSzPHc7ApQBjA929Nl8ruW0RWWFZqM9MpgJQQ9SfCOVDDnOGx+q4hzstl2V+agJKNXubFNpT7YQ= 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 SJ0PR10MB4464.namprd10.prod.outlook.com (2603:10b6:a03:2d0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Fri, 16 Apr 2021 09:18:36 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:36 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 11/12] xfsprogs: Add delay ready attr remove routines Date: Fri, 16 Apr 2021 02:18:13 -0700 Message-Id: <20210416091814.2041-12-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a92549d-aa83-4921-364c-08d900b89cef X-MS-TrafficTypeDiagnostic: SJ0PR10MB4464: 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: 14j60IPgIfZNBudFWGwqbcRx8sSrvlJ3rpKbl2S5GpcsFSAuMg72N5ocxo0bq0jCqUgzB75ILRxjp8X0GTN9RtTIO0A7ESHfkYttyRxK8iTSSe2nmUNdTI53TwJUnsFh3qnZgE4xCz7Qt09tEiK+sk8+7K+9m1yOFd3oWfVJvF/5iCgm70XHUUeKlUMd5JXTPjnM7Gbp2ufIFgsTmNpqKlS6GHWygsqUJArU+Sd3jOldLzAbvDyKqbhvHmKkUfEz3XcNsNzqMDSRofK8SBb023PoQ1aTK1jRjbW6P4SCX+3bViecAocZSGusi4Q0od5Ms5HYUsbfeAe9QFTaJCIXDggIClwlrhkX99xxbVPjvZq1BxTrENmKp+eO9BFkkb1RPbKFwZD808J/vPZKcWkyXUxN/ZwfBklJtcOR9/Kq/RHTQfMDmCD5J6WBQ6m1C4rDLHMss6MT1GrttQvFrWcgREoI+VC+IgcG0lfE+soH1VzpfJqSNW4avEUGglDn5Lsdes+citBNhmCgMgU//0sJySHfNHl8ZIVGUQonWoTYzI2S+/KIgIDkBsWVL/dmTONsCKcvxH7/0W5S4JVy00oU5uqq7xWeKIJzdcZxeSHyIcSDA2l9ASZdznJ7pvMwgsy9cDkPP5rBFTgmjntnfiRwug== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4306.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(376002)(366004)(39860400002)(396003)(346002)(508600001)(5660300002)(6916009)(8676002)(66556008)(83380400001)(36756003)(8936002)(44832011)(38100700002)(86362001)(38350700002)(2906002)(316002)(1076003)(6512007)(66946007)(186003)(6666004)(26005)(16526019)(6506007)(52116002)(66476007)(956004)(30864003)(6486002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EJN24y9w7LelxgcmZihfqrPZr4aaeNh32CQKPbQctCzQYKGx27Xb9J9+jCDm2oEerteoJv1q1Cf5P1AG3jgMX+Qi10rErOoJAGVp963gUPZHefgaU/7sp+BPTHI/IQe/OYWWDtI7P7kyGWBXrK2/Kusicg8FUKsEboIZF3dK/GHkPbkCm/CHxeNxdb133IPOd16Li7K4RsJ0k2sD+POaBpk55nfdUhflpwSuuvBGhy/opt+LCeYPo0hVAeNju6FtVZovAUS4mPPAm4ySKXKa1zgedFXhDgrqq+7wTamYs3NxHk2vMJgX0tkkpGfQxhD4Ntq8KMukiU3iNKMJlh8zv4jmR4oMB9S0mwQz27fPVoWB2zbGrroNlD16wDFY2RkXwuH3VBjhVsU1wFbPuJmq2Avb8LvS7BGkT1vgLlM99h+Psu6LgN6uLjGJmhif57vc/hZOl7DUgrueLPD5Sy6JhQg5FnsFCkWzP3OsW4SP5TrOP6xcN8QFPA4W/hW8NmjF9e7Zo4H19fW/B0Zvusktwo+ab5f1lDJ+034htKi85ZxJRwCE9eN50x0u+9Rey5LbK7Y3TioD/kwYh61hulbf0wkfOqXQ7NsSQFPtMeMmJaiM/2XyAVVEdJovGFl58NS1llsHMftrLrb+H4ybxMjQitSWMzUSsmERNXzCPnxMUiDHkZyBGKQAPHpDFqT9Sz7/gTBQ4wIWk9jQrGzRkR7sIsEsWWRxZWCs/Ollb7blR9C3rhhXM7eCVgMtfpxlKLGshSYV4pVpacKvSdpVGnakJBpYQn5cNU4Trclr8fJBdKxd3EmzvGV0+YiAmwJAmIo8ZDyAcUqJ2H4jCswC/qAOGKZvpzmzFyknDnZSUjw1BGclefhPJVj2UPvoZ1NA65WNcuosTYiof6AiYoFGY2XamnsWcb2rmSNW4reHkblvbl3MxCM7k6YsZ7P1O+Hg0wJoWrFphXg51smAFu1IakLzUK+93o9uOfy5TWe166KXxeemeLPWzAswfAK94ZoRKHnauJuJC+gNuOjBWRFbDp9wO+Gq6bMp9FtvNVDN4BODr/eTX52rwVrvz2/B7w3paa1j+y0+DCjzoiavK4x7iBCv3iRWudFPeH7BDx/jphME8//DgqvBUyl0VCV+WCEy38ZZWVd8YYv0I27paDxyUkWf64+lllMIeM635JvsjyNUjtPq+bRrarMbxEsVvu07cc9L4oPptb5PneCFO7d4roRcA7HWRCCJnBoScQ0XLdXWifG8aEwNL/ssKIAEbzPZLfRjeHy/CrIIlocB6GpdbI8wOhHu7T3ToPlhnQsuzqRv5GRebPnDBMXQp1SEu9AmnlY6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a92549d-aa83-4921-364c-08d900b89cef X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:36.2753 (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: vxvtR3uXIO7e6c3SQhSd993JIi489NbgXoJ31//MCR2yDas+0kC22YACt8eWzJYDCJVGNGRhg4Yz7Us6rWjaEd6vkt6+k64n44QW+wS8JCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4464 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-ORIG-GUID: gFiZ0_C2MkxlVgzJOrJtEQl83-gXpd8n X-Proofpoint-GUID: gFiZ0_C2MkxlVgzJOrJtEQl83-gXpd8n X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args is merged with xfs_attr_node_removename become a new function, xfs_attr_remove_iter. This new version uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. A new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A new XFS_DAC_DEFER_FINISH flag is used to finish the transaction where ever the existing code used to. Calls to xfs_attr_rmtval_remove are replaced with the delay ready version __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done. xfs_attr_rmtval_remove itself is still in use by the set routines (used during a rename). For reasons of preserving existing function, we modify xfs_attr_rmtval_remove to call xfs_defer_finish when the flag is set. Similar to how xfs_attr_remove_args does here. Once we transition the set routines to be delay ready, xfs_attr_rmtval_remove is no longer used and will be removed. This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls. See xfs_attr.h for a more detailed diagram of the states. Signed-off-by: Allison Henderson --- include/libxfs.h | 1 + libxfs/xfs_attr.c | 208 ++++++++++++++++++++++++++++++++--------------- libxfs/xfs_attr.h | 131 +++++++++++++++++++++++++++++ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_attr_remote.c | 48 ++++++----- libxfs/xfs_attr_remote.h | 2 +- 6 files changed, 305 insertions(+), 87 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index bc07655..02d97c1 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -168,6 +168,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC }; #include "xfs_ialloc.h" #include "xfs_attr_leaf.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_trans_space.h" diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index b3a8202..3cdc6ea 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -57,7 +57,6 @@ STATIC int xfs_attr_node_addname(struct xfs_da_args *args, struct xfs_da_state *state); STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, struct xfs_da_state **state); -STATIC int xfs_attr_node_removename(xfs_da_args_t *args); STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); @@ -221,6 +220,31 @@ xfs_attr_is_shortform( ip->i_afp->if_nextents == 0); } +/* + * Checks to see if a delayed attribute transaction should be rolled. If so, + * transaction is finished or rolled as needed. + */ +int +xfs_attr_trans_roll( + struct xfs_delattr_context *dac) +{ + struct xfs_da_args *args = dac->da_args; + int error; + + if (dac->flags & XFS_DAC_DEFER_FINISH) { + /* + * The caller wants us to finish all the deferred ops so that we + * avoid pinning the log tail with a large number of deferred + * ops. + */ + dac->flags &= ~XFS_DAC_DEFER_FINISH; + error = xfs_defer_finish(&args->trans); + } else + error = xfs_trans_roll_inode(&args->trans, args->dp); + + return error; +} + STATIC int xfs_attr_set_fmt( struct xfs_da_args *args) @@ -527,21 +551,23 @@ xfs_has_attr( */ int xfs_attr_remove_args( - struct xfs_da_args *args) + struct xfs_da_args *args) { - struct xfs_inode *dp = args->dp; - int error; + int error; + struct xfs_delattr_context dac = { + .da_args = args, + }; - if (!xfs_inode_hasattr(dp)) { - error = -ENOATTR; - } else if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { - ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); - error = xfs_attr_shortform_remove(args); - } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_removename(args); - } else { - error = xfs_attr_node_removename(args); - } + do { + error = xfs_attr_remove_iter(&dac); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) + return error; + + } while (true); return error; } @@ -1187,14 +1213,16 @@ xfs_attr_leaf_mark_incomplete( */ STATIC int xfs_attr_node_removename_setup( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state **state = &dac->da_state; + int error; error = xfs_attr_node_hasname(args, state); if (error != -EEXIST) return error; + error = 0; ASSERT((*state)->path.blk[(*state)->path.active - 1].bp != NULL); ASSERT((*state)->path.blk[(*state)->path.active - 1].magic == @@ -1203,10 +1231,13 @@ int xfs_attr_node_removename_setup( if (args->rmtblkno > 0) { error = xfs_attr_leaf_mark_incomplete(args, *state); if (error) - return error; + goto out; - return xfs_attr_rmtval_invalidate(args); + error = xfs_attr_rmtval_invalidate(args); } +out: + if (error) + xfs_da_state_free(*state); return 0; } @@ -1231,70 +1262,117 @@ xfs_attr_node_remove_cleanup( } /* - * Remove a name from a B-tree attribute list. + * Remove the attribute specified in @args. * * This will involve walking down the Btree, and may involve joining * leaf nodes and even joining intermediate nodes up to and including * the root node (a special case of an intermediate node). + * + * This routine is meant to function as either an in-line or delayed operation, + * and may return -EAGAIN when the transaction needs to be rolled. Calling + * functions will need to handle this, and recall the function until a + * successful error code is returned. */ -STATIC int -xfs_attr_node_removename( - struct xfs_da_args *args) +int +xfs_attr_remove_iter( + struct xfs_delattr_context *dac) { - struct xfs_da_state *state; - int retval, error; - struct xfs_inode *dp = args->dp; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + int retval, error; + struct xfs_inode *dp = args->dp; trace_xfs_attr_node_removename(args); - error = xfs_attr_node_removename_setup(args, &state); - if (error) - goto out; + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (!xfs_inode_hasattr(dp)) + return -ENOATTR; - /* - * If there is an out-of-line value, de-allocate the blocks. - * This is done before we remove the attribute so that we don't - * overflow the maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_remove(args); - if (error) - goto out; + if (dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL) { + ASSERT(dp->i_afp->if_flags & XFS_IFINLINE); + return xfs_attr_shortform_remove(args); + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + return xfs_attr_leaf_removename(args); + + if (!dac->da_state) { + error = xfs_attr_node_removename_setup(dac); + if (error) + return error; + state = dac->da_state; + } + + /* fallthrough */ + case XFS_DAS_RMTBLK: + dac->dela_state = XFS_DAS_RMTBLK; /* - * Refill the state structure with buffers, the prior calls - * released our buffers. + * If there is an out-of-line value, de-allocate the blocks. + * This is done before we remove the attribute so that we don't + * overflow the maximum size of a transaction and/or hit a + * deadlock. */ - error = xfs_attr_refillstate(state); - if (error) - goto out; - } - retval = xfs_attr_node_remove_cleanup(args, state); + if (args->rmtblkno > 0) { + /* + * May return -EAGAIN. Remove blocks until 0 is returned + */ + error = __xfs_attr_rmtval_remove(dac); + if (error == -EAGAIN) + return error; + else if (error) + goto out; + + /* + * Refill the state structure with buffers, the prior + * calls released our buffers. + */ + ASSERT(args->rmtblkno == 0); + error = xfs_attr_refillstate(state); + if (error) + goto out; + + dac->dela_state = XFS_DAS_CLNUP; + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } + + case XFS_DAS_CLNUP: + retval = xfs_attr_node_remove_cleanup(args, state); - /* - * Check to see if the tree needs to be collapsed. - */ - if (retval && (state->path.active > 1)) { - error = xfs_da3_join(state); - if (error) - goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the Btree join operation and start a new trans. + * Check to see if the tree needs to be collapsed. Set the flag + * to indicate that the calling function needs to move the + * shrink operation */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - } + if (retval && (state->path.active > 1)) { + error = xfs_da3_join(state); + if (error) + goto out; - /* - * If the result is small enough, push it all into the inode. - */ - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) - error = xfs_attr_node_shrink(args, state); + dac->flags |= XFS_DAC_DEFER_FINISH; + dac->dela_state = XFS_DAS_RM_SHRINK; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_RM_SHRINK: + /* + * If the result is small enough, push it all into the inode. + */ + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) + error = xfs_attr_node_shrink(args, state); + + break; + default: + ASSERT(0); + error = -EINVAL; + goto out; + } + if (error == -EAGAIN) + return error; out: if (state) xfs_da_state_free(state); diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 3e97a93..28fe719 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -74,6 +74,133 @@ struct xfs_attr_list_context { }; +/* + * ======================================================================== + * Structure used to pass context around among the delayed routines. + * ======================================================================== + */ + +/* + * Below is a state machine diagram for attr remove operations. The XFS_DAS_* + * states indicate places where the function would return -EAGAIN, and then + * immediately resume from after being recalled by the calling function. States + * marked as a "subroutine state" indicate that they belong to a subroutine, and + * so the calling function needs to pass them back to that subroutine to allow + * it to finish where it left off. But they otherwise do not have a role in the + * calling function other than just passing through. + * + * xfs_attr_remove_iter() + * │ + * v + * have attr to remove? ──n──> done + * │ + * y + * │ + * v + * are we short form? ──y──> xfs_attr_shortform_remove ──> done + * │ + * n + * │ + * V + * are we leaf form? ──y──> xfs_attr_leaf_removename ──> done + * │ + * n + * │ + * V + * ┌── need to setup state? + * │ │ + * n y + * │ │ + * │ v + * │ find attr and get state + * │ attr has blks? ───n────┐ + * │ │ v + * │ │ find and invalidate + * │ y the blocks. mark + * │ │ attr incomplete + * │ ├────────────────┘ + * └──────────┤ + * │ + * v + * Have blks to remove? ───y─────────┐ + * │ ^ remove the blks + * │ │ │ + * │ │ v + * │ XFS_DAS_RMTBLK <─n── done? + * │ re-enter with │ + * │ one less blk to y + * │ remove │ + * │ V + * │ refill the state + * n │ + * │ v + * │ XFS_DAS_CLNUP + * │ │ + * ├─────────────────────────┘ + * │ + * v + * remove leaf and + * update hash with + * xfs_attr_node_remove_cleanup + * │ + * v + * need to + * shrink tree? ─n─┐ + * │ │ + * y │ + * │ │ + * v │ + * join leaf │ + * │ │ + * v │ + * XFS_DAS_RM_SHRINK │ + * │ │ + * v │ + * do the shrink │ + * │ │ + * v │ + * free state <──┘ + * │ + * v + * done + * + */ + +/* + * Enum values for xfs_delattr_context.da_state + * + * These values are used by delayed attribute operations to keep track of where + * they were before they returned -EAGAIN. A return code of -EAGAIN signals the + * calling function to roll the transaction, and then recall the subroutine to + * finish the operation. The enum is then used by the subroutine to jump back + * to where it was and resume executing where it left off. + */ +enum xfs_delattr_state { + XFS_DAS_UNINIT = 0, /* No state has been set yet */ + XFS_DAS_RMTBLK, /* Removing remote blks */ + XFS_DAS_CLNUP, /* Clean up phase */ + XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ +}; + +/* + * Defines for xfs_delattr_context.flags + */ +#define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ + +/* + * Context used for keeping track of delayed attribute operations + */ +struct xfs_delattr_context { + struct xfs_da_args *da_args; + + /* Used in xfs_attr_node_removename to roll through removing blocks */ + struct xfs_da_state *da_state; + + /* Used to keep track of current state of delayed operation */ + unsigned int flags; + enum xfs_delattr_state dela_state; +}; + /*======================================================================== * Function prototypes for the kernel. *========================================================================*/ @@ -91,6 +218,10 @@ int xfs_attr_set(struct xfs_da_args *args); int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); +int xfs_attr_remove_iter(struct xfs_delattr_context *dac); +int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); +void xfs_delattr_context_init(struct xfs_delattr_context *dac, + struct xfs_da_args *args); #endif /* __XFS_ATTR_H__ */ diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c index a59660f..2c7aa6b 100644 --- a/libxfs/xfs_attr_leaf.c +++ b/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_trace.h" #include "xfs_dir2.h" diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 3807cd3..affff4b 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -673,10 +673,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); @@ -684,31 +686,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. @@ -718,12 +718,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/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 9eee615..002fd30 100644 --- a/libxfs/xfs_attr_remote.h +++ b/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__ */ From patchwork Fri Apr 16 09:18:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 12207223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AC68C43461 for ; Fri, 16 Apr 2021 09:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D430611AF for ; Fri, 16 Apr 2021 09:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241595AbhDPJTO (ORCPT ); Fri, 16 Apr 2021 05:19:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45250 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241652AbhDPJTE (ORCPT ); Fri, 16 Apr 2021 05:19:04 -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 13G98gCd036487 for ; Fri, 16 Apr 2021 09:18:40 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=/qhsm64NNcB9ZaU+njpDIUfliuXYEUbvJzXFqOx9+TM=; b=N6V5OXqtg9jNVjB/pR5d9qcbnYydA7XLSP38MuRABNZv0Var3+TdqJmvgTWXxfV1Zrse athculquMM+OPIX/VhmaFhkWfsiiPvLhUXMIjGjZHiriWFeNyRXVpLbV2jhRhTFDnbGm C+t5kPNUgdKoA18/CwLIXpBltssBZ8uQ3hCQBlHEDVQzV3VvnBf89RYg/eF5LEO26kPC Wsm812oQGYxA07K/hFQiJ/s3gfLBlyhmCScgLhtQKN66/+NrTSVkcgPhXTxcAOuYF8BB 7XZpTGAu/MJGHjjMuAInegYYYnkOrx6TdAaJ3ynkYHvbSvPUeYk+EVxNm8h/2s7RoOM7 sQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 37u3ymrj49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13G9AXpa077087 for ; Fri, 16 Apr 2021 09:18:39 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by userp3030.oracle.com with ESMTP id 37uny2cbx1-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 16 Apr 2021 09:18:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=njCFWtgoITN/VHOkGZLHeK5nfeW0SBHbieQlkXiVWt9rjGBOTVztF3uu/N+nSXZBeHaxvlM9EWzwi+SQV4Jpfq1Qt97gVIPpvXVxGtfd7bIe2WEFniKuPtDPpxb33optm7eRCnT23zHel2nZWV6dSOWsVdYk6SStHu3xUfbCCCjL7v8nWg6AB5lkqITD3vc+oIqK3HPkrWmsaCjRu0rIz3VNwnj39+Pchm2XYr9sEqMTAvnZRFvNVVU5p1ehnbO8924DCXBoq7dlBAe5PWS9e51egLIBzvG8BIAHgJY39euqjLPcMojmiTv2kR+/Rjl1zxXLLl39dSIXCBd2Dd43fQ== 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=/qhsm64NNcB9ZaU+njpDIUfliuXYEUbvJzXFqOx9+TM=; b=fPTr32Gs63CfNrRYAx+ICRFk/E1n+IUcwJYrMTKRXatAsLWmZyYRmtUr3eIW+oJYK7JYQSakINCMAxFMPvUUHNqoMMy6w4CC4uAI38mZeOy94M5XGp5bbCsWbHbMTLcW3Zhxi9x9nDB+uPJN/t54L4FvJonLHdDRw5KqcB5luGaHQqfyXyHTZpHpFba+CYGGz+xAu7b8zacsrZ/ZYNooQa/u6lTp9dm6aEVnRQHViiUtPn57RTxyqJoJyio2NYhbCG+bQejNx+kJNmsmn9iU7w/EmmWsAAn4/paIdkVa5uVKSMCsJdSlVT4U2GPVmcgNV6pOsad102/y8xEifnxDPQ== 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=/qhsm64NNcB9ZaU+njpDIUfliuXYEUbvJzXFqOx9+TM=; b=yrf8Q6mtn+p1U7kaL1/bnrN0uxJymWygJXj1jAACeaX0QpogbuZGkDChE/CpgauyimFCarGni3IJVzDtCRvrVtg6JZrSHUmkQQm+pzWHPVhUuv4+LQiFlPz9VzTcWGhucH1cKj/Pi2wtz87GwPtBmixLD54A8zSCvlgqHgHd/r8= 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 BYAPR10MB2486.namprd10.prod.outlook.com (2603:10b6:a02:b8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.19; Fri, 16 Apr 2021 09:18:36 +0000 Received: from BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88]) by BY5PR10MB4306.namprd10.prod.outlook.com ([fe80::55a0:c9fb:d00:cd88%3]) with mapi id 15.20.4042.019; Fri, 16 Apr 2021 09:18:36 +0000 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH v17 12/12] xfsprogs: Add delay ready attr set routines Date: Fri, 16 Apr 2021 02:18:14 -0700 Message-Id: <20210416091814.2041-13-allison.henderson@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416091814.2041-1-allison.henderson@oracle.com> References: <20210416091814.2041-1-allison.henderson@oracle.com> X-Originating-IP: [67.1.222.141] X-ClientProxiedBy: BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) To BY5PR10MB4306.namprd10.prod.outlook.com (2603:10b6:a03:211::7) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.1.222.141) by BYAPR07CA0070.namprd07.prod.outlook.com (2603:10b6:a03:60::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Fri, 16 Apr 2021 09:18:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c0bd80c-a005-4e05-7bb3-08d900b89d77 X-MS-TrafficTypeDiagnostic: BYAPR10MB2486: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mW8+gMD2ulh5vPTG2YsInxkBAAr5m/75M8xD7TTi9ptazWHxh3tz19m1AM7B419YeBTC8p1uNocOp8oqdOXeJZyzL5wa/CKe2mwt5gZZEEksu7mA9ioOirTDJUVjhypZtEAzapBteBToe8SgJE5a8TCJzaH4h4+iczwedGldK4O+fXdp4syeJRKNgL5rfQGIOwqz8Ngz+EuCTzdSVU+l+5r0IYTLHk5McLdSOMNDhrCa26A/8dbkLCGPUhumFrXzMTYCfNUzcyVINLswxCMe7qzyw/AIH6ajYIsYriPqRCDyhOj42OPjLLEtCdI/5UF9/9OY1dilL95CLlfyKTvt8mCpgCJIS39xaD4IWGHRB8NZHOppYbNrNrpy9cUllsIREeYaIIAMjJLHpMC5q6a7FBfYTKXcjYE3uRGAGsNk/q48dVSYAPP4/5xRKP6milPta05f+7AAXgHaUPF2WX5aCmYcdiwAC0m2IYJmfkLUJ832k0Hr7oUp4juRhmlzVx7pa0OYx/vZb24p17u2Myzc/IVCds4imvaXoWzA6qmeBYex2H+zgqqvu1IhhyCkrZTyCbGxIsfL2CHjgMdf+CwB7LDHjS/4NhLAofFUXz0A6f7gIRr6f1p0wzvBkJhOlImh9GdUIkOeisynHaCGaGBngg== 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:(376002)(396003)(366004)(136003)(39860400002)(346002)(8676002)(36756003)(8936002)(38100700002)(508600001)(38350700002)(6486002)(66556008)(66946007)(66476007)(956004)(52116002)(6506007)(6512007)(316002)(86362001)(44832011)(83380400001)(30864003)(1076003)(26005)(2906002)(6916009)(6666004)(16526019)(186003)(5660300002)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vhPs3W6uFG7QCg9LZyxyBpoH8+Zl2AmVxz/IaFkUrDRLoqvuztOZ8hsI9fDYZA3+JRvFEHwTEMt1ptFZfr0PvjeIMmi3W+B+qmDnt/WMtw6kxAelZB33AoFgbjpNdnUdVyB+xxH0GCqynd9emqyncMFO6LHY31OWIE4uB+D4DIYG02iQdhGgiS4ipNlI+6L29Ln/0dag+1ykS/HgXfJTIvCpQ6i0ADjkDC8BBKzD3eHN/cKt8wJf2btOG+dVhCGSm4J+AAFH8A3HOhqweTTXR6w4AdY4goCUS+hjhFSPYtMOxGQfpXJsFxTLml+KFvLr5R9v1SmcMJuYBbFTibynJJS8etInaLYueMZ2G6TMdH1vDmHSifTfQnQDClwyeeWqBPZiMeupXsmekH9+95ZasmCiGA40K9aIqg4rBuobkc7UY3cYPZLFdJ/kCEExzf62kesG31BnItZKPXaZr/WRWdh2EiIQ8ij2Kr4jIOkCXDEw5SQpFas/zLuWR6+cmqAuSNuqqeEEwYHxWgK3i0MhpJcqJVvXlXOmJGunlNSIsPkU6KYATxjxUR0Jty7rdN41Sb0Gd7QLorJg0FUVUuOhpEnsk6mv/vkizkQ8uj+GwGBcnZpeqrBGbJOn+ZkeRX7vRTnmqen5xtTqCsT0+mD48rsAjOFtlhRQP1zRsVWmvo8/5yvvFVqMT9SGzMfIl1pEQgtIrcQZWeHJ7eL7ZhpPzkfREADOnR088DVD6loZwdKbZ3TOn76WEn0V5fh/4gG+qtzYd6/5qeojV+EGYwcr3KAELQb30VZg7RNaU4wbVxqew1GOawtIzR86NDneoAeBxdtlNnIHuxufGS3ZgWLMOEHcOyzIKr0YlJY3QZOSnJDia2D3dLtNbSwMSASaPkrONxzVQc9r7Y/iuYESyCmPLjN9sCC9mkEvBQjLy3B9uVfR3dBg6258T2HYQ/hLioRpByE+2EGKIU+cbu0wP0elZ/mB2j4Xso7XWxX9+e7l5vQlRu/mdEHBbiO4YOL6yihJZ4mmp/kwt5yUQCLjz1+YW+bS/I+nVwgtJW4Q8UJPpYHzznYdEygBWnjt3qAlB08z8KBMZ9ghGFm9t7Lf5TCndyd3VuhcbkREKgcR7N29pJvbPzOKmGz6+dQrok2NS3xbqC+6WykFmYfaPk/z5adHOYHTdomtGr9Mr8SR/QNtWVnc/nIZPwdFYlxvTS6Z1cthsYqm0Eqg6082SO1QxMn5H3RbyL91uOnowpShiD2eTX/YC2A/S6ecscLjQkHJ7c5u3GLBqcLpo31JrCrPqqFttb5rqg3hdVH6ETTrpUBiiaZ6vdrAHCG4RtwLcHBhWQHd X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c0bd80c-a005-4e05-7bb3-08d900b89d77 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4306.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Apr 2021 09:18:36.7891 (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: epeaIFxbyw4yB+w6EwC/vW96pW4dMxc0Nqa+nSrV2ZBtL1Vr2OWZGTdC4VFbS35AwYG8b4V99m587g84mLp3vnpXqqTnfkWGWbu+lBzymPg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2486 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 X-Proofpoint-GUID: 7hTBt1Izqh_sVi5BHAanEKqGgchtyoZw X-Proofpoint-ORIG-GUID: 7hTBt1Izqh_sVi5BHAanEKqGgchtyoZw X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9955 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104160070 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Source kernel commit: 45e46c998cd75749f6975ffdeeb9a59768e4fcd3 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 --- include/xfs_trace.h | 1 - libxfs/xfs_attr.c | 445 +++++++++++++++++++++++++++++------------------ libxfs/xfs_attr.h | 272 ++++++++++++++++++++++++++++- libxfs/xfs_attr_remote.c | 100 +++++++---- libxfs/xfs_attr_remote.h | 5 +- 5 files changed, 613 insertions(+), 210 deletions(-) diff --git a/include/xfs_trace.h b/include/xfs_trace.h index fa4d38d..a847b50 100644 --- a/include/xfs_trace.h +++ b/include/xfs_trace.h @@ -159,7 +159,6 @@ #define trace_xfs_attr_node_get(a) ((void) 0) #define trace_xfs_attr_rmtval_get(a) ((void) 0) #define trace_xfs_attr_rmtval_set(a) ((void) 0) -#define trace_xfs_attr_rmtval_remove(a) ((void) 0) #define trace_xfs_bmap_pre_update(a,b,c,d) ((void) 0) #define trace_xfs_bmap_post_update(a,b,c,d) ((void) 0) diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index 3cdc6ea..a745f43 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -53,15 +53,16 @@ STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); STATIC void xfs_attr_restore_rmt_blk(struct xfs_da_args *args); -STATIC int xfs_attr_node_addname(struct xfs_da_args *args, - struct xfs_da_state *state); -STATIC int xfs_attr_node_addname_find_attr(struct xfs_da_args *args, - struct xfs_da_state **state); -STATIC int xfs_attr_node_addname_clear_incomplete(struct xfs_da_args *args); +STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_find_attr(struct xfs_delattr_context *dac); +STATIC int xfs_attr_node_addname_clear_incomplete( + struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp); int xfs_inode_hasattr( @@ -224,7 +225,7 @@ xfs_attr_is_shortform( * Checks to see if a delayed attribute transaction should be rolled. If so, * transaction is finished or rolled as needed. */ -int +STATIC int xfs_attr_trans_roll( struct xfs_delattr_context *dac) { @@ -245,29 +246,58 @@ xfs_attr_trans_roll( return error; } +/* + * Set the attribute specified in @args. + */ +int +xfs_attr_set_args( + struct xfs_da_args *args) +{ + struct xfs_buf *leaf_bp = NULL; + int error = 0; + struct xfs_delattr_context dac = { + .da_args = args, + }; + + do { + error = xfs_attr_set_iter(&dac, &leaf_bp); + if (error != -EAGAIN) + break; + + error = xfs_attr_trans_roll(&dac); + if (error) { + if (leaf_bp) + xfs_trans_brelse(args->trans, leaf_bp); + return error; + } + } while (true); + + return error; +} + STATIC int xfs_attr_set_fmt( - struct xfs_da_args *args) + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_buf *leaf_bp = NULL; - struct xfs_inode *dp = args->dp; - int error2, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + int error = 0; /* * Try to add the attr to the attribute list in the inode. */ error = xfs_attr_try_sf_addname(dp, args); - if (error != -ENOSPC) { - error2 = xfs_trans_commit(args->trans); - args->trans = NULL; - return error ? error : error2; - } + + /* Should only be 0, -EEXIST or -ENOSPC */ + if (error != -ENOSPC) + return error; /* * It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ - error = xfs_attr_shortform_to_leaf(args, &leaf_bp); + error = xfs_attr_shortform_to_leaf(args, leaf_bp); if (error) return error; @@ -276,94 +306,130 @@ xfs_attr_set_fmt( * concurrent AIL push cannot grab the half-baked leaf buffer * and run into problems with the write verifier. */ - xfs_trans_bhold(args->trans, leaf_bp); - error = xfs_defer_finish(&args->trans); - xfs_trans_bhold_release(args->trans, leaf_bp); - if (error) { - xfs_trans_brelse(args->trans, leaf_bp); - return error; - } + xfs_trans_bhold(args->trans, *leaf_bp); + /* + * We're still in XFS_DAS_UNINIT state here. We've converted + * the attr fork to leaf format and will restart with the leaf + * add. + */ + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } /* * Set the attribute specified in @args. + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + * returned. */ int -xfs_attr_set_args( - struct xfs_da_args *args) +xfs_attr_set_iter( + struct xfs_delattr_context *dac, + struct xfs_buf **leaf_bp) { - struct xfs_inode *dp = args->dp; - struct xfs_buf *bp = NULL; - struct xfs_da_state *state = NULL; - int forkoff, error = 0; + struct xfs_da_args *args = dac->da_args; + struct xfs_inode *dp = args->dp; + struct xfs_buf *bp = NULL; + int forkoff, error = 0; - /* - * If the attribute list is already in leaf format, jump straight to - * leaf handling. Otherwise, try to add the attribute to the shortform - * list; if there's no room then convert the list to leaf format and try - * again. - */ - if (xfs_attr_is_shortform(dp)) { - error = xfs_attr_set_fmt(args); - if (error != -EAGAIN) - return error; - } + /* State machine switch */ + switch (dac->dela_state) { + case XFS_DAS_UNINIT: + if (xfs_attr_is_shortform(dp)) + return xfs_attr_set_fmt(dac, leaf_bp); - if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { - error = xfs_attr_leaf_try_add(args, bp); - if (error == -ENOSPC) { - /* - * Promote the attribute list to the Btree format. - */ - error = xfs_attr3_leaf_to_node(args); - if (error) + /* + * After a shortform to leaf conversion, we need to hold the + * leaf and cycle out the transaction. When we get back, + * we need to release the leaf to release the hold on the leaf + * buffer. + */ + if (*leaf_bp != NULL) { + xfs_trans_bhold_release(args->trans, *leaf_bp); + *leaf_bp = NULL; + } + + if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { + error = xfs_attr_leaf_try_add(args, *leaf_bp); + if (error == -ENOSPC) { + /* + * Promote the attribute list to the Btree + * format. + */ + error = xfs_attr3_leaf_to_node(args); + if (error) + return error; + + /* + * Finish any deferred work items and roll the + * transaction once more. The goal here is to + * call node_addname with the inode and + * transaction in the same state (inode locked + * and joined, transaction clean) no matter how + * we got to this step. + * + * At this point, we are still in + * XFS_DAS_UNINIT, but when we come back, we'll + * be a node, so we'll fall down into the node + * handling code below + */ + dac->flags |= XFS_DAC_DEFER_FINISH; + return -EAGAIN; + } else if (error) { return error; + } - /* - * Finish any deferred work items and roll the transaction once - * more. The goal here is to call node_addname with the inode - * and transaction in the same state (inode locked and joined, - * transaction clean) no matter how we got to this step. - */ - error = xfs_defer_finish(&args->trans); + dac->dela_state = XFS_DAS_FOUND_LBLK; + return -EAGAIN; + + } else { + error = xfs_attr_node_addname_find_attr(dac); if (error) return error; - /* - * Commit the current trans (including the inode) and - * start a new one. - */ - error = xfs_trans_roll_inode(&args->trans, dp); + error = xfs_attr_node_addname(dac); if (error) return error; - goto node; - } else if (error) { - return error; + dac->dela_state = XFS_DAS_FOUND_NBLK; + return -EAGAIN; } - - /* - * Commit the transaction that added the attr name so that - * later routines can manage their own transactions. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - return error; - + case XFS_DAS_FOUND_LBLK: /* * If there was an out-of-line value, allocate the blocks we * identified for its storage and copy the value. This is done * after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); + + /* Open coded xfs_attr_rmtval_set without trans handling */ + if ((dac->flags & XFS_DAC_LEAF_ADDNAME_INIT) == 0) { + dac->flags |= XFS_DAC_LEAF_ADDNAME_INIT; + if (args->rmtblkno > 0) { + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; + } + } + + /* + * Roll through the "value", allocating blocks on disk as + * required. + */ + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); if (error) return error; + + return -EAGAIN; } + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* * Added a "remote" value, just clear the incomplete @@ -392,26 +458,35 @@ xfs_attr_set_args( * Commit the flag value change and start the next trans in * series. */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - return error; - + dac->dela_state = XFS_DAS_FLIP_LFLAG; + return -EAGAIN; + case XFS_DAS_FLIP_LFLAG: /* * Dismantle the "old" attribute/value pair by removing a * "remote" value (if it exists). */ xfs_attr_restore_rmt_blk(args); + error = xfs_attr_rmtval_invalidate(args); + if (error) + return error; + + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_LBLK; + + /* fallthrough */ + case XFS_DAS_RM_LBLK: if (args->rmtblkno) { - error = xfs_attr_rmtval_invalidate(args); + error = __xfs_attr_rmtval_remove(dac); if (error) return error; - error = xfs_attr_rmtval_remove(args); - if (error) - return error; + dac->dela_state = XFS_DAS_RD_LEAF; + return -EAGAIN; } + /* fallthrough */ + case XFS_DAS_RD_LEAF: /* * Read in the block containing the "old" attr, then remove the * "old" attr from that block (neat, huh!) @@ -432,89 +507,113 @@ xfs_attr_set_args( /* bp is gone due to xfs_da_shrink_inode */ return error; - } -node: + case XFS_DAS_FOUND_NBLK: + /* + * If there was an out-of-line value, allocate the blocks we + * identified for its storage and copy the value. This is done + * after we create the attribute so that we don't overflow the + * maximum size of a transaction and/or hit a deadlock. + */ + if (args->rmtblkno > 0) { + /* + * Open coded xfs_attr_rmtval_set without trans + * handling + */ + error = xfs_attr_rmtval_find_space(dac); + if (error) + return error; - do { - error = xfs_attr_node_addname_find_attr(args, &state); - if (error) - return error; - error = xfs_attr_node_addname(args, state); - } while (error == -EAGAIN); - if (error) - return error; + /* + * Roll through the "value", allocating blocks on disk + * as required. Set the state in case of -EAGAIN return + * code + */ + dac->dela_state = XFS_DAS_ALLOC_NODE; + } - /* - * Commit the leaf addition or btree split and start the next - * trans in the chain. - */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; + /* fallthrough */ + case XFS_DAS_ALLOC_NODE: + if (args->rmtblkno > 0) { + if (dac->blkcnt > 0) { + error = xfs_attr_rmtval_set_blk(dac); + if (error) + return error; - /* - * If there was an out-of-line value, allocate the blocks we - * identified for its storage and copy the value. This is done - * after we create the attribute so that we don't overflow the - * maximum size of a transaction and/or hit a deadlock. - */ - if (args->rmtblkno > 0) { - error = xfs_attr_rmtval_set(args); - if (error) - return error; - } + return -EAGAIN; + } + + error = xfs_attr_rmtval_set_value(args); + if (error) + return error; + } + + if (!(args->op_flags & XFS_DA_OP_RENAME)) { + /* + * Added a "remote" value, just clear the incomplete + * flag. + */ + if (args->rmtblkno > 0) + error = xfs_attr3_leaf_clearflag(args); + goto out; + } - if (!(args->op_flags & XFS_DA_OP_RENAME)) { /* - * Added a "remote" value, just clear the incomplete flag. + * If this is an atomic rename operation, we must "flip" the + * incomplete flags on the "new" and "old" attribute/value pairs + * so that one disappears and one appears atomically. Then we + * must remove the "old" attribute/value pair. + * + * In a separate transaction, set the incomplete flag on the + * "old" attr and clear the incomplete flag on the "new" attr. */ - if (args->rmtblkno > 0) - error = xfs_attr3_leaf_clearflag(args); - goto out; - } - - /* - * If this is an atomic rename operation, we must "flip" the incomplete - * flags on the "new" and "old" attribute/value pairs so that one - * disappears and one appears atomically. Then we must remove the "old" - * attribute/value pair. - * - * In a separate transaction, set the incomplete flag on the "old" attr - * and clear the incomplete flag on the "new" attr. - */ - error = xfs_attr3_leaf_flipflags(args); - if (error) - goto out; - /* - * Commit the flag value change and start the next trans in series - */ - error = xfs_trans_roll_inode(&args->trans, args->dp); - if (error) - goto out; + error = xfs_attr3_leaf_flipflags(args); + if (error) + goto out; + /* + * Commit the flag value change and start the next trans in + * series + */ + dac->dela_state = XFS_DAS_FLIP_NFLAG; + return -EAGAIN; - /* - * Dismantle the "old" attribute/value pair by removing a "remote" value - * (if it exists). - */ - xfs_attr_restore_rmt_blk(args); + case XFS_DAS_FLIP_NFLAG: + /* + * Dismantle the "old" attribute/value pair by removing a + * "remote" value (if it exists). + */ + xfs_attr_restore_rmt_blk(args); - if (args->rmtblkno) { error = xfs_attr_rmtval_invalidate(args); if (error) return error; - error = xfs_attr_rmtval_remove(args); - if (error) - return error; - } + /* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state = XFS_DAS_RM_NBLK; + + /* fallthrough */ + case XFS_DAS_RM_NBLK: + if (args->rmtblkno) { + error = __xfs_attr_rmtval_remove(dac); + if (error) + return error; - error = xfs_attr_node_addname_clear_incomplete(args); + dac->dela_state = XFS_DAS_CLR_FLAG; + return -EAGAIN; + } + + /* fallthrough */ + case XFS_DAS_CLR_FLAG: + error = xfs_attr_node_addname_clear_incomplete(dac); + default: + ASSERT(dac->dela_state != XFS_DAS_RM_SHRINK); + break; + } out: return error; - } + /* * Return EEXIST if attr is found, or ENOATTR if not */ @@ -980,18 +1079,18 @@ xfs_attr_node_hasname( STATIC int xfs_attr_node_addname_find_attr( - struct xfs_da_args *args, - struct xfs_da_state **state) + struct xfs_delattr_context *dac) { - int retval; + struct xfs_da_args *args = dac->da_args; + int retval; /* * Search to see if name already exists, and get back a pointer * to where it should go. */ - retval = xfs_attr_node_hasname(args, state); + retval = xfs_attr_node_hasname(args, &dac->da_state); if (retval != -ENOATTR && retval != -EEXIST) - goto error; + return retval; if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE)) goto error; @@ -1017,8 +1116,8 @@ xfs_attr_node_addname_find_attr( return 0; error: - if (*state) - xfs_da_state_free(*state); + if (dac->da_state) + xfs_da_state_free(dac->da_state); return retval; } @@ -1031,19 +1130,23 @@ error: * * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. + * + * This routine is meant to function as a delayed operation, and may return + * -EAGAIN when the transaction needs to be rolled. Calling functions will need + * to handle this, and recall the function until a successful error code is + *returned. */ STATIC int xfs_attr_node_addname( - struct xfs_da_args *args, - struct xfs_da_state *state) + struct xfs_delattr_context *dac) { - struct xfs_da_state_blk *blk; - struct xfs_inode *dp; - int error; + struct xfs_da_args *args = dac->da_args; + struct xfs_da_state *state = dac->da_state; + struct xfs_da_state_blk *blk; + int error; trace_xfs_attr_node_addname(args); - dp = args->dp; blk = &state->path.blk[state->path.active-1]; ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); @@ -1060,18 +1163,15 @@ xfs_attr_node_addname( error = xfs_attr3_leaf_to_node(args); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; /* - * Commit the node conversion and start the next - * trans in the chain. + * Now that we have converted the leaf to a node, we can + * roll the transaction, and try xfs_attr3_leaf_add + * again on re-entry. No need to set dela_state to do + * this. dela_state is still unset by this function at + * this point. */ - error = xfs_trans_roll_inode(&args->trans, dp); - if (error) - goto out; - + dac->flags |= XFS_DAC_DEFER_FINISH; return -EAGAIN; } @@ -1084,9 +1184,7 @@ xfs_attr_node_addname( error = xfs_da3_split(state); if (error) goto out; - error = xfs_defer_finish(&args->trans); - if (error) - goto out; + dac->flags |= XFS_DAC_DEFER_FINISH; } else { /* * Addition succeeded, update Btree hashvals. @@ -1103,8 +1201,9 @@ out: 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/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 28fe719..c0b94b5 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -164,6 +164,262 @@ struct xfs_attr_list_context { * v * done * + * + * Below is a state machine diagram for attr set operations. + * + * It seems the challenge with understanding this system comes from trying to + * absorb the state machine all at once, when really one should only be looking + * at it with in the context of a single function. Once a state sensitive + * function is called, the idea is that it "takes ownership" of the + * state machine. It isn't concerned with the states that may have belonged to + * it's calling parent. Only the states relevant to itself or any other + * subroutines there in. Once a calling function hands off the state machine to + * a subroutine, it needs to respect the simple rule that it doesn't "own" the + * state machine anymore, and it's the responsibility of that calling function + * to propagate the -EAGAIN back up the call stack. Upon reentry, it is + * committed to re-calling that subroutine until it returns something other than + * -EAGAIN. Once that subroutine signals completion (by returning anything other + * than -EAGAIN), the calling function can resume using the state machine. + * + * xfs_attr_set_iter() + * │ + * v + * ┌─y─ has an attr fork? + * │ | + * │ n + * │ | + * │ V + * │ add a fork + * │ │ + * └──────────┤ + * │ + * V + * ┌─y─ is shortform? + * │ │ + * │ V + * │ xfs_attr_set_fmt + * │ | + * │ V + * │ xfs_attr_try_sf_addname + * │ │ + * │ V + * │ had enough ──y──> done + * │ space? + * n │ + * │ n + * │ │ + * │ V + * │ transform to leaf + * │ │ + * │ V + * │ hold the leaf buffer + * │ │ + * │ V + * │ return -EAGAIN + * │ Re-enter in + * │ leaf form + * │ + * └─> release leaf buffer + * if needed + * │ + * V + * ┌───n── fork has + * │ only 1 blk? + * │ │ + * │ y + * │ │ + * │ v + * │ xfs_attr_leaf_try_add() + * │ │ + * │ v + * │ had enough ──────────────y─────────────┐ + * │ space? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ return -EAGAIN │ + * │ re-enter in │ + * │ node form │ + * │ │ │ + * └──────────┤ │ + * │ │ + * V │ + * xfs_attr_node_addname_find_attr │ + * determines if this │ + * is create or rename │ + * find space to store attr │ + * │ │ + * v │ + * xfs_attr_node_addname │ + * │ │ + * v │ + * fits in a node leaf? ────n─────┐ │ + * │ ^ v │ + * │ │ single leaf node? │ + * │ │ │ │ │ + * y │ y n │ + * │ │ │ │ │ + * v │ v v │ + * update │ grow the leaf split if │ + * hashvals └── return -EAGAIN needed │ + * │ retry leaf add │ │ + * │ on reentry │ │ + * ├────────────────────────────┘ │ + * │ │ + * v │ + * need to alloc │ + * ┌─y── or flip flag? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ done │ + * │ │ + * │ │ + * │ XFS_DAS_FOUND_LBLK <────────────────┘ + * │ │ + * │ V + * │ xfs_attr_leaf_addname() + * │ │ + * │ v + * │ ┌──first time through? + * │ │ │ + * │ │ y + * │ │ │ + * │ n v + * │ │ if we have rmt blks + * │ │ find space for them + * │ │ │ + * │ └──────────┤ + * │ │ + * │ v + * │ still have + * │ ┌─n─ blks to alloc? <──┐ + * │ │ │ │ + * │ │ y │ + * │ │ │ │ + * │ │ v │ + * │ │ alloc one blk │ + * │ │ return -EAGAIN ──┘ + * │ │ re-enter with one + * │ │ less blk to alloc + * │ │ + * │ │ + * │ └───> set the rmt + * │ value + * │ │ + * │ v + * │ was this + * │ a rename? ──n─┐ + * │ │ │ + * │ y │ + * │ │ │ + * │ v │ + * │ flip incomplete │ + * │ flag │ + * │ │ │ + * │ v │ + * │ XFS_DAS_FLIP_LFLAG │ + * │ │ │ + * │ v │ + * │ need to remove │ + * │ old bks? ──n──┤ + * │ │ │ + * │ y │ + * │ │ │ + * │ V │ + * │ remove │ + * │ ┌───> old blks │ + * │ │ │ │ + * │ XFS_DAS_RM_LBLK │ │ + * │ ^ │ │ + * │ │ v │ + * │ └──y── more to │ + * │ remove? │ + * │ │ │ + * │ n │ + * │ │ │ + * │ v │ + * │ XFS_DAS_RD_LEAF │ + * │ │ │ + * │ v │ + * │ remove leaf │ + * │ │ │ + * │ v │ + * │ shrink to sf │ + * │ if needed │ + * │ │ │ + * │ v │ + * │ done <──────┘ + * │ + * └──────> XFS_DAS_FOUND_NBLK + * │ + * v + * ┌─────n── need to + * │ alloc blks? + * │ │ + * │ y + * │ │ + * │ v + * │ find space + * │ │ + * │ v + * │ ┌─>XFS_DAS_ALLOC_NODE + * │ │ │ + * │ │ v + * │ │ alloc blk + * │ │ │ + * │ │ v + * │ └──y── need to alloc + * │ more blocks? + * │ │ + * │ n + * │ │ + * │ v + * │ set the rmt value + * │ │ + * │ v + * │ was this + * └────────> a rename? ──n─┐ + * │ │ + * y │ + * │ │ + * v │ + * flip incomplete │ + * flag │ + * │ │ + * v │ + * XFS_DAS_FLIP_NFLAG │ + * │ │ + * v │ + * need to │ + * remove blks? ─n──┤ + * │ │ + * y │ + * │ │ + * v │ + * remove │ + * ┌────────> old blks │ + * │ │ │ + * XFS_DAS_RM_NBLK │ │ + * ^ │ │ + * │ v │ + * └──────y── more to │ + * remove │ + * │ │ + * n │ + * │ │ + * v │ + * XFS_DAS_CLR_FLAG │ + * │ │ + * v │ + * clear flags │ + * │ │ + * ├──────────┘ + * │ + * v + * done */ /* @@ -180,12 +436,22 @@ enum xfs_delattr_state { XFS_DAS_RMTBLK, /* Removing remote blks */ XFS_DAS_CLNUP, /* Clean up phase */ XFS_DAS_RM_SHRINK, /* We are shrinking the tree */ + XFS_DAS_FOUND_LBLK, /* We found leaf blk for attr */ + XFS_DAS_FOUND_NBLK, /* We found node blk for attr */ + XFS_DAS_FLIP_LFLAG, /* Flipped leaf INCOMPLETE attr flag */ + XFS_DAS_RM_LBLK, /* A rename is removing leaf blocks */ + XFS_DAS_RD_LEAF, /* Read in the new leaf */ + XFS_DAS_ALLOC_NODE, /* We are allocating node blocks */ + XFS_DAS_FLIP_NFLAG, /* Flipped node INCOMPLETE attr flag */ + XFS_DAS_RM_NBLK, /* A rename is removing node blocks */ + XFS_DAS_CLR_FLAG, /* Clear incomplete flag */ }; /* * Defines for xfs_delattr_context.flags */ #define XFS_DAC_DEFER_FINISH 0x01 /* finish the transaction */ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x02 /* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations @@ -193,6 +459,11 @@ enum xfs_delattr_state { struct xfs_delattr_context { struct xfs_da_args *da_args; + /* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ + struct xfs_bmbt_irec map; + xfs_dablk_t lblkno; + int blkcnt; + /* Used in xfs_attr_node_removename to roll through removing blocks */ struct xfs_da_state *da_state; @@ -219,7 +490,6 @@ int xfs_attr_set_args(struct xfs_da_args *args); int xfs_has_attr(struct xfs_da_args *args); int xfs_attr_remove_args(struct xfs_da_args *args); int xfs_attr_remove_iter(struct xfs_delattr_context *dac); -int xfs_attr_trans_roll(struct xfs_delattr_context *dac); bool xfs_attr_namecheck(const void *name, size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac, struct xfs_da_args *args); diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index affff4b..fd43449 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -438,9 +438,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) { @@ -467,7 +467,7 @@ xfs_attr_rmt_find_hole( return 0; } -STATIC int +int xfs_attr_rmtval_set_value( struct xfs_da_args *args) { @@ -627,6 +627,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. */ @@ -668,37 +731,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/libxfs/xfs_attr_remote.h b/libxfs/xfs_attr_remote.h index 002fd30..8ad68d5 100644 --- a/libxfs/xfs_attr_remote.h +++ b/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__ */